From 98501be8df20fe273cc4eec3ffa1607584a6ace6 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:32:22 +0100 Subject: [PATCH 01/73] Obj_Usiyane (#902) * Obj_Usiyane * PR * RP * PR --- spec | 3 +- .../actors/ovl_Obj_Usiyane/z_obj_usiyane.c | 243 ++++++++++++++++-- .../actors/ovl_Obj_Usiyane/z_obj_usiyane.h | 26 +- undefined_syms.txt | 6 - 4 files changed, 248 insertions(+), 30 deletions(-) diff --git a/spec b/spec index e17d3af91..9a0f31668 100644 --- a/spec +++ b/spec @@ -4850,8 +4850,7 @@ beginseg name "ovl_Obj_Usiyane" compress include "build/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.data.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Usiyane/ovl_Obj_Usiyane_reloc.o" endseg beginseg 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 e895eeba9..33ebf1e50 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -5,6 +5,7 @@ */ #include "z_obj_usiyane.h" +#include "objects/object_obj_usiyane/object_obj_usiyane.h" #define FLAGS (ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjUsiyane_Destroy(Actor* thisx, PlayState* play); void ObjUsiyane_Update(Actor* thisx, PlayState* play); void ObjUsiyane_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Usiyane_InitVars = { ACTOR_OBJ_USIYANE, ACTORCAT_PROP, @@ -28,40 +28,245 @@ const ActorInit Obj_Usiyane_InitVars = { (ActorFunc)ObjUsiyane_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C086B0[] = { +PosRot D_80C08660[] = { + { { 800.0f, -940.0f, 2000.0f }, { 0, 0, 0x2AF8 } }, + { { 560.0f, -790.0f, -2000.0f }, { 0, 0, 0x2EE0 } }, + { { -480.0f, -780.0f, -1990.0f }, { 0, 0, -0x2710 } }, + { { -470.0f, -850.0f, 2000.0f }, { 0, 0, -0x2710 } }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -#endif +s32 func_80C07C80(s32 arg0) { + s32 var_v1; -extern InitChainEntry D_80C086B0[]; + if (!(arg0 & 1)) { + var_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; + } else { + var_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + } + return var_v1 + CLOCK_TIME(2, 30); +} -extern UNK_TYPE D_06000838; -extern UNK_TYPE D_060022AC; +s32 func_80C07CD0(void) { + if (CURRENT_DAY <= 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07C80.s") + if (CURRENT_DAY == 1) { + s32 time = gSaveContext.save.time; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07CD0.s") + if ((time < CLOCK_TIME(2, 30)) || (time >= CLOCK_TIME(6, 0))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DC4.s") + if (time < CLOCK_TIME(5, 15)) { + s32 var_s1 = CLOCK_TIME(5, 15); + s32 temp_v0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DFC.s") + for (i = 0; i < 8; i++) { + temp_v0_2 = func_80C07C80(i); + var_s1 = CLAMP_MAX(var_s1, temp_v0_2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07F30.s") + if (time < (var_s1 + 0xE11)) { + return false; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C081C8.s") + if (gSaveContext.save.weekEventReg[22] & 1) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082CC.s") +void func_80C07DC4(ObjUsiyane* this, PlayState* play) { + if (func_80C07CD0()) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082E0.s") +void func_80C07DFC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5, Vec3f* arg6, Vec3s* arg7) { + f32 temp_fv0 = (f32)arg4 / arg5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Init.s") + // VEC3F_LERPIMPDST + arg6->x = ((arg2->x - arg0->x) * temp_fv0) + arg0->x; + arg6->y = ((arg2->y - arg0->y) * temp_fv0) + arg0->y; + arg6->z = ((arg2->z - arg0->z) * temp_fv0) + arg0->z; + arg7->x = (((f32)arg3->x - (f32)arg1->x) * temp_fv0) + arg1->x; + arg7->y = (((f32)arg3->y - (f32)arg1->y) * temp_fv0) + arg1->y; + arg7->z = (((f32)arg3->z - (f32)arg1->z) * temp_fv0) + arg1->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Destroy.s") +void func_80C07F30(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + Vec3f sp94; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Update.s") + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + if (i != ARRAY_COUNT(this->unk_168[0]) - 1) { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[i + 1], &D_80C08660[i + 1].rot, j, + 10, &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } else { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[0], &D_80C08660[0].rot, j, 10, + &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } + func_800B12F0(play, &this->unk_168[j][i].unk_00, &gZeroVec3f, &gZeroVec3f, 100, 30, 7); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Draw.s") + this->unk_168[j][i].unk_18.y = (s32)Rand_Next() >> 0x10; + + sp94.x = this->unk_168[j][i].unk_00.x - this->unk_708; + sp94.y = 0.0f; + sp94.z = this->unk_168[j][i].unk_00.z - this->unk_70C; + Math3D_Normalize(&sp94); + + sp94.x *= 5.0f; + sp94.y = 19.0f; + sp94.z *= 5.0f; + + this->unk_168[j][i].unk_0C = sp94; + + this->unk_168[j][i].unk_1E.x = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.y = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.z = Rand_Centered() * 4000.0f; + } + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_HOUSE_BROKEN); + this->unk_740 = 0; + this->unk_744 |= 4; +} + +void func_80C081C8(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + + this->unk_744 |= 1; + + if (this->unk_740 <= 70) { + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + this->unk_168[j][i].unk_0C.y += -0.8f; + + this->unk_168[j][i].unk_00.x += this->unk_168[j][i].unk_0C.x; + this->unk_168[j][i].unk_00.y += this->unk_168[j][i].unk_0C.y; + this->unk_168[j][i].unk_00.z += this->unk_168[j][i].unk_0C.z; + + this->unk_168[j][i].unk_18.x += this->unk_168[j][i].unk_1E.x; + this->unk_168[j][i].unk_18.y += this->unk_168[j][i].unk_1E.y; + this->unk_168[j][i].unk_18.z += this->unk_168[j][i].unk_1E.z; + } + } + + } else if (this->unk_740 >= 70) { + Actor_MarkForDeath(&this->dyna.actor); + } + this->unk_740++; +} + +void func_80C082CC(ObjUsiyane* this, PlayState* play) { + this->unk_164 = -1; +} + +void func_80C082E0(ObjUsiyane* this, PlayState* play) { + CsCmdActorAction* csAction; + + if (Cutscene_CheckActorAction(play, 0x228)) { + this->unk_160 = Cutscene_GetActorActionIndex(play, 0x228); + csAction = play->csCtx.actorActions[this->unk_160]; + if (this->unk_164 != csAction->action) { + this->unk_164 = csAction->action; + if (this->unk_164 == 2) { + func_80C07F30(this, play); + this->actionFunc = func_80C081C8; + } + } + } +} + +void ObjUsiyane_Init(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->unk_744 = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_obj_usiyane_Colheader_0022AC); + + switch (OBJUSIYANE_GET_F(&this->dyna.actor)) { + case OBJUSIYANE_F_0: + this->actionFunc = func_80C07DC4; + break; + + case OBJUSIYANE_F_1: + func_80C082CC(this, play); + this->actionFunc = func_80C082E0; + break; + + default: + Actor_MarkForDeath(&this->dyna.actor); + break; + } +} + +void ObjUsiyane_Destroy(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void ObjUsiyane_Update(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + this->actionFunc(this, play); +} + +void ObjUsiyane_Draw(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + MtxF mf; + + if (!(this->unk_744 & 1)) { + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000838); + } + + if (!(this->unk_744 & 2)) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80C08660); i++) { + Vec3f sp74; + + Matrix_MultVec3f(&D_80C08660[i].pos, &this->unk_710[i]); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + this->unk_708 = sp74.x; + this->unk_70C = sp74.z; + } + this->unk_744 |= 2; + } + + if ((this->unk_744 & 4) && !(this->unk_744 & 8)) { + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + Matrix_Push(); + SkinMatrix_SetScaleRotateRPYTranslate(&mf, 0.1f, 0.1f, 0.1f, this->unk_168[j][i].unk_18.x, + this->unk_168[j][i].unk_18.y, this->unk_168[j][i].unk_18.z, + this->unk_168[j][i].unk_00.x, this->unk_168[j][i].unk_00.y, + this->unk_168[j][i].unk_00.z); + Matrix_Put(&mf); + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000098); + Matrix_Pop(); + } + } + } +} diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h index 7c4cdd8a5..c38a08ed9 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -7,11 +7,31 @@ struct ObjUsiyane; typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, PlayState*); +#define OBJUSIYANE_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 0 */ OBJUSIYANE_F_0, + /* 1 */ OBJUSIYANE_F_1, +}; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ Vec3s unk_1E; +} ObjUsiyaneStruct; // size = 0x24 + typedef struct ObjUsiyane { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjUsiyaneActionFunc actionFunc; - /* 0x160 */ char unk_160[0x5E8]; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ ObjUsiyaneStruct unk_168[10][4]; + /* 0x708 */ f32 unk_708; + /* 0x70C */ f32 unk_70C; + /* 0x710 */ Vec3f unk_710[4]; + /* 0x740 */ s32 unk_740; + /* 0x744 */ s32 unk_744; } ObjUsiyane; // size = 0x748 extern const ActorInit Obj_Usiyane_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index faf0aba38..20a4cf5e2 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1450,12 +1450,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Usiyane - -D_06000098 = 0x06000098; -D_06000838 = 0x06000838; -D_060022AC = 0x060022AC; - // ovl_player_actor D_06008860 = 0x06008860; From 90ade1be9fe9f21357365f75362888e5fea72ef4 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:37:21 -0300 Subject: [PATCH 02/73] ovl_En_Js Decompiled (#991) * progress * progress * func_80968E38 (thanks @engineer124) * progress * remove comments * general cleanup * warnings * all functions matching * macros * final details * format * ovl_En_Js Decompiled * PLAYER_AO enums * fix * pr review * re preview * pr review * pr review * pr review * resolving after merge * conflict resolution * pr review * pr review * pr review --- assets/xml/objects/object_ob.xml | 177 ++-- spec | 3 +- src/overlays/actors/ovl_En_Js/z_en_js.c | 1035 ++++++++++++++++++++++- src/overlays/actors/ovl_En_Js/z_en_js.h | 18 +- tools/disasm/functions.txt | 4 +- 5 files changed, 1106 insertions(+), 131 deletions(-) diff --git a/assets/xml/objects/object_ob.xml b/assets/xml/objects/object_ob.xml index 75217e04e..d2390fc39 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -1,84 +1,101 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 9a0f31668..22a85ed0f 100644 --- a/spec +++ b/spec @@ -1644,8 +1644,7 @@ beginseg name "ovl_En_Js" compress include "build/src/overlays/actors/ovl_En_Js/z_en_js.o" - include "build/data/ovl_En_Js/ovl_En_Js.data.o" - include "build/data/ovl_En_Js/ovl_En_Js.reloc.o" + include "build/src/overlays/actors/ovl_En_Js/ovl_En_Js_reloc.o" endseg beginseg 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 57763a190..4e35a5158 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -15,7 +15,18 @@ void EnJs_Destroy(Actor* thisx, PlayState* play); void EnJs_Update(Actor* thisx, PlayState* play); void EnJs_Draw(Actor* thisx, PlayState* play); -#if 0 +s32 func_80968B8C(EnJs* this, PlayState* play); +s32 func_809692A8(s32 arg0); +void func_80968A5C(EnJs* this); +void func_80969400(s32 arg0); +void func_8096971C(EnJs* this, PlayState* play); +void func_80969898(EnJs* this, PlayState* play); +void func_80969B5C(EnJs* this, PlayState* play); +void func_80969DA4(EnJs* this, PlayState* play); +void func_8096A104(EnJs* this, PlayState* play); +void func_8096A38C(EnJs* this, PlayState* play); +void func_8096A6F4(EnJs* this, PlayState* play); + const ActorInit En_Js_InitVars = { ACTOR_EN_JS, ACTORCAT_NPC, @@ -28,89 +39,1021 @@ const ActorInit En_Js_InitVars = { (ActorFunc)EnJs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8096ABA0 = { - { 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 Gfx* D_8096ABCC[] = { + gMoonChildMajorasMaskDL, gMoonChildOdalwasMaskDL, gMoonChildGohtsMaskDL, + gMoonChildGyorgsMaskDL, gMoonChildTwinmoldsMaskDL, +}; -extern ColliderCylinderInit D_8096ABA0; +f32 D_8096ABE0[] = { 1.0f, 0.5f, 0.5f, 0.48f, 0.45f }; -extern UNK_TYPE D_06010880; -extern UNK_TYPE D_06016F58; -extern UNK_TYPE D_06017E98; +f32 D_8096ABF4[] = { 60.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Init.s") +f32 D_8096AC08[] = { -450.0f, 1400.0f, 1470.0f, 1670.0f, 1470.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Destroy.s") +f32 D_8096AC1C[] = { 0.0f, 700.0f, 900.0f, 900.0f, 900.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968A5C.s") +Vec3f D_8096AC30 = { 500.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968B18.s") +void EnJs_Init(Actor* thisx, PlayState* play) { + s32 pad; + s16 cs; + s32 i; + EnJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968B8C.s") + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gMoonChildSkel, &gMoonChildStandingAnim, this->jointTable, + this->morphTable, MOONCHILD_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gMoonChildStandingAnim); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968CB8.s") + this->actionFunc = func_8096971C; + this->maskType = 0; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968DD0.s") + cs = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968E38.s") + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968F48.s") + this->cutsceneIndex = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809691B8.s") + switch (ENJS_GET_TYPE(&this->actor)) { + case 0: + this->maskType = 0; + this->actionFunc = func_8096A6F4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809692A8.s") + Animation_PlayLoop(&this->skelAnime, &gMoonChildSittingAnim); + func_8016566C(0x3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096933C.s") + if (gSaveContext.save.weekEventReg[84] & 0x20) { + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + } + break; + case 1: + case 2: + case 3: + case 4: + this->maskType = ENJS_GET_TYPE(&this->actor); + func_80968B8C(this, play); + this->actionFunc = func_80969B5C; + func_80968A5C(this); + if (func_809692A8(ENJS_GET_TYPE(&this->actor) + 4)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + case 5: + case 6: + case 7: + case 8: + this->maskType = ENJS_GET_TYPE(&this->actor) - 4; + this->actionFunc = func_8096A104; + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969400.s") +void EnJs_Destroy(Actor* thisx, PlayState* play) { + u32 paramsF; + EnJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969494.s") + Collider_DestroyCylinder(play, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809694E8.s") + paramsF = ENJS_GET_TYPE(&this->actor); + switch (paramsF) { + case 0: + func_80165690(); + break; + case 5: + case 6: + case 7: + case 8: + if (!func_809692A8(paramsF)) { + func_80969400(ENJS_GET_TYPE(&this->actor)); + } + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969530.s") +void func_80968A5C(EnJs* this) { + if (Rand_ZeroOne() < 0.5f) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildRunningAnim, -10.0f); + this->unk_2B4 = 5.0f; + } else { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildWalkingAnim, -10.0f); + this->unk_2B4 = 2.5f; + } + this->unk_2B8 &= ~4; + this->unk_2BC = Rand_ZeroFloat(40.0f) + 80.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809695FC.s") +void func_80968B18(EnJs* this) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, -10.0f); + this->unk_2B4 = 0.0f; + this->unk_2BC = Rand_ZeroFloat(20.0f) + 40.0f; + this->unk_2B8 |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969688.s") +s32 func_80968B8C(EnJs* this, PlayState* play) { + Path* path; + f32 temp_f0; + f32 temp_f2; + s32 pathIndex = ENJS_GET_PATH_INDEX(&this->actor); + s32 i; + f32 sp18 = 0.0f; + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809696EC.s") + if (pathIndex != 0x3F) { + this->path = &play->setupPathList[pathIndex]; + if (this->path != NULL) { + path = this->path; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096971C.s") + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969748.s") + for (i = 0; i < path->count; i++, points++) { + temp_f0 = points->x - this->actor.world.pos.x; + temp_f2 = points->z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f0) + SQ(temp_f2); + if (i == 0) { + sp18 = temp_f0; + this->unk_2B0 = 0; + } else if (temp_f0 < sp18) { + sp18 = temp_f0; + this->unk_2B0 = i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969898.s") + this->unk_2B0++; + if (this->unk_2B0 >= path->count) { + this->unk_2B0 = 0; + } + } + } else { + this->path = NULL; + this->unk_2B0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969AA0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969B5C.s") +s32 func_80968CB8(EnJs* this) { + Path* path; + s32 pad; + f32 temp_fa0; + f32 temp_fa1; + Vec3s* temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969C54.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969DA4.s") + path = this->path; + temp_v1 = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2B0]; + temp_fa0 = temp_v1->x - this->actor.world.pos.x; + temp_fa1 = temp_v1->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_fa0, temp_fa1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A080.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x7D0, 0xC8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A104.s") + if ((SQ(temp_fa0) + SQ(temp_fa1)) < SQ(10.0f)) { + this->unk_2B0++; + if (this->unk_2B0 >= path->count) { + this->unk_2B0 = 0; + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A184.s") + Math_StepToF(&this->actor.speedXZ, this->unk_2B4, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A1E8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A2C0.s") +s32 func_80968DD0(EnJs* this, PlayState* play) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A38C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A6F4.s") +s32 func_80968E38(s32 arg0) { + s32 i; + s32 count; + u8 mask; + u8* maskMaskBit = gSaveContext.maskMaskBit; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Update.s") + if (((arg0 < 0) || (arg0 >= 9))) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A9F4.s") + count = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Draw.s") + arg0 *= 3; + for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { + if (maskMaskBit[arg0] & mask) { + count++; + } + } + + arg0++; + for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { + if (maskMaskBit[arg0] & mask) { + count++; + } + } + + arg0++; + for (mask = 1, i = 0; i < 5; i++, mask <<= 1) { + if (maskMaskBit[arg0] & mask) { + count++; + } + } + + return count; +} + +s32 EnJs_GetRemainingMasks(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++; + } + + count -= func_80968E38(0); + return count; +} + +void EnJs_TakeMask(s32 actionParams, s32 childType) { + u8* maskMaskBit = gSaveContext.maskMaskBit; + s32 temp = 0; + + if ((childType >= 0) && (childType < 9)) { + actionParams -= PLAYER_AP_MASK_TRUTH; + childType *= 3; + if (actionParams < 8) { + maskMaskBit[childType] |= 1 << actionParams; + maskMaskBit[temp] |= 1 << actionParams; + return; + } + + actionParams -= 8; + childType++; + temp++; + if (actionParams < 8) { + maskMaskBit[childType] |= 1 << actionParams; + maskMaskBit[temp] |= 1 << actionParams; + return; + } + + actionParams -= 8; + childType++; + temp++; + if (actionParams < 6) { + maskMaskBit[childType] |= 1 << actionParams; + maskMaskBit[temp] |= 1 << actionParams; + } + } +} + +s32 func_809692A8(s32 arg0) { + switch (arg0) { + case 1: + case 2: + case 3: + case 4: + if (func_80968E38(arg0) < arg0) { + return false; + } + return true; + case 5: + case 6: + case 7: + case 8: + if (func_80968E38(arg0) < (arg0 - 4)) { + return false; + } + return true; + default: + return false; + } +} + +s32 func_8096933C(s32 arg0) { + s32 sp1C; + + switch (arg0) { + case 1: + case 2: + case 3: + case 4: + sp1C = EnJs_GetRemainingMasks(); + if ((func_80968E38(arg0) + sp1C) < arg0) { + return false; + } else { + return true; + } + case 5: + case 6: + case 7: + case 8: + sp1C = EnJs_GetRemainingMasks(); + if ((func_80968E38(arg0) + sp1C) < (arg0 - 4)) { + return false; + } else { + return true; + } + default: + return false; + } +} + +void func_80969400(s32 arg0) { + u8* maskMaskBit = gSaveContext.maskMaskBit; + u8* temp_v0 = &gSaveContext.maskMaskBit[arg0 * 3]; + + if ((arg0 >= 0) && (arg0 < 9)) { + maskMaskBit[0] &= ~temp_v0[0]; + maskMaskBit[1] &= ~temp_v0[1]; + + temp_v0[2] &= 0xF; + maskMaskBit[2] &= ~temp_v0[2]; + + temp_v0[0] = 0; + temp_v0[1] = 0; + temp_v0[2] = 0; + } +} + +void func_80969494(EnJs* this, PlayState* play) { + func_80968A5C(this); + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80969B5C; +} + +void func_809694E8(EnJs* this, PlayState* play) { + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_8096A104; +} + +void func_80969530(EnJs* this, PlayState* play) { + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_8096A6F4; + if ((this->actor.home.rot.y == this->actor.shape.rot.y) && (this->unk_2B8 & 0x10)) { + Animation_Change(&this->skelAnime, &gMoonChildGettingUpAnim, -1.0f, + Animation_GetLastFrame(&gMoonChildGettingUpAnim) - 1.0f, 0.0f, ANIMMODE_ONCE, -10.0f); + this->unk_2B8 &= ~0x10; + this->unk_2B8 |= 8; + } +} + +s32 func_809695FC(EnJs* this, PlayState* play) { + if (ENJS_GET_EXIT_INDEX(&this->actor) == 0x3F) { + return false; + } + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntrance = play->setupExitList[ENJS_GET_EXIT_INDEX(&this->actor)]; + this->actionFunc = func_8096971C; + play->msgCtx.msgLength = 0; + gSaveContext.respawnFlag = -2; + return true; +} + +void func_80969688(EnJs* this) { + if (this->cutsceneIndex != -1) { + if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { + ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + } + this->cutsceneIndex = -1; + } +} + +void func_809696EC(EnJs* this, s16 arg1) { + func_80969688(this); + this->cutsceneIndex = arg1; +} + +void func_8096971C(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} + +void func_80969748(EnJs* this, PlayState* play) { + s32 itemActionParam; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemActionParam = func_80123810(play); + if (itemActionParam != PLAYER_AP_NONE) { + this->actionFunc = func_80969898; + } + if (itemActionParam > PLAYER_AP_NONE) { + func_801477B4(play); + if ((itemActionParam >= PLAYER_AP_MASK_TRUTH) && (itemActionParam <= PLAYER_AP_MASK_GIANT)) { + EnJs_TakeMask(itemActionParam, ENJS_GET_TYPE(&this->actor)); + Inventory_UnequipItem(itemActionParam - 4); + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + player->actor.textId = 0x2212; + } else { + player->actor.textId = 0x2213; + } + } else if ((itemActionParam >= PLAYER_AP_MASK_FIERCE_DEITY) && (itemActionParam <= PLAYER_AP_MASK_DEKU)) { + player->actor.textId = 0x2211; + } else { + player->actor.textId = 0x2210; + } + } + if (itemActionParam <= PLAYER_AP_MINUS1) { + func_80151938(play, 0x2216); + } + } +} + +void func_80969898(EnJs* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x2215)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(play, 0x2217); + break; + case 1: + func_8019F230(); + func_80151938(play, 0x2216); + break; + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x220C: + this->unk_2B8 |= 1; + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + func_80151938(play, 0x220F); + break; + } + func_80151938(play, 0x220D); + break; + case 0x220D: + case 0x2213: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x220E: + func_80151938(play, 0xFF); + this->actionFunc = func_80969748; + break; + case 0x2210: + case 0x2211: + case 0x2212: + player->exchangeItemId = PLAYER_AP_NONE; + func_80151938(play, 0xFF); + this->actionFunc = func_80969748; + break; + case 0x2214: + case 0x2217: + if (!func_809695FC(this, play)) { + func_80969494(this, play); + break; + } + break; + default: + func_80969494(this, play); + break; + } + } + break; + } +} + +void func_80969AA0(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x220B; + } else { + textId = 0x2215; + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + if (this->unk_2B8 & 1) { + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + textId = 0x220F; + } else { + textId = 0x220E; + } + } else { + textId = 0x220C; + } + } else { + textId = 0x2215; + } + } + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, -10.0f); + Message_StartTextbox(play, textId, &this->actor); +} + +void func_80969B5C(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (this->unk_2BC > 0) { + this->unk_2BC--; + if (this->unk_2BC == 0) { + if (this->unk_2B8 & 4) { + func_80968A5C(this); + } else { + func_80968B18(this); + } + } + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80969898; + this->actor.speedXZ = 0.0f; + this->unk_2B4 = 0.0f; + func_80969AA0(this, play); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 120.0f); + } + func_80968CB8(this); +} + +void func_80969C54(EnJs* this, PlayState* play) { + s32 itemActionParam; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemActionParam = func_80123810(play); + if (itemActionParam != PLAYER_AP_NONE) { + this->actionFunc = func_80969DA4; + } + if (itemActionParam > PLAYER_AP_NONE) { + func_801477B4(play); + if ((itemActionParam >= PLAYER_AP_MASK_TRUTH) && (itemActionParam <= PLAYER_AP_MASK_GIANT)) { + EnJs_TakeMask(itemActionParam, ENJS_GET_TYPE(&this->actor)); + Inventory_UnequipItem(itemActionParam - 4); + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + player->actor.textId = 0x2221; + } else { + player->actor.textId = 0x2222; + } + } else if ((itemActionParam >= PLAYER_AP_MASK_FIERCE_DEITY) && (itemActionParam <= PLAYER_AP_MASK_DEKU)) { + player->actor.textId = 0x2220; + } else { + player->actor.textId = 0x221D; + } + } + if (itemActionParam <= PLAYER_AP_MINUS1) { + func_80151938(play, 0x221E); + } + } +} + +void func_80969DA4(EnJs* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && + ((play->msgCtx.currentTextId == 0x2219) || (play->msgCtx.currentTextId == 0x221E))) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + if (!func_809695FC(this, play)) { + func_809694E8(this, play); + break; + } + break; + case 1: + func_8019F230(); + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x221B: + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + func_80151938(play, 0x2219); + break; + } + func_80151938(play, 0x221C); + break; + case 0x2224: + case 0x2226: + case 0x2228: + case 0x222A: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x2225: + case 0x2227: + case 0x2229: + case 0x222B: + if (!func_809695FC(this, play)) { + func_809694E8(this, play); + break; + } + break; + case 0x2222: + player->exchangeItemId = PLAYER_AP_NONE; + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x2223: + switch (ENJS_GET_TYPE(&this->actor)) { + case 5: + func_80151938(play, 0x2224); + break; + case 6: + func_80151938(play, 0x2226); + break; + case 7: + func_80151938(play, 0x2228); + break; + case 8: + func_80151938(play, 0x222A); + break; + } + break; + case 0x221C: + func_80151938(play, 0xFF); + this->actionFunc = func_80969C54; + break; + case 0x221D: + case 0x2220: + case 0x2221: + player->exchangeItemId = PLAYER_AP_NONE; + func_80151938(play, 0xFF); + this->actionFunc = func_80969C54; + break; + default: + func_809694E8(this, play); + break; + } + } + break; + } +} + +void func_8096A080(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x2218; + } else { + textId = 0x221B; + if (this->unk_2B8 & 1) { + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + textId = 0x2219; + } else { + textId = 0x221C; + } + } else { + this->unk_2B8 |= 1; + } + } + Message_StartTextbox(play, textId, &this->actor); +} + +void func_8096A104(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80969DA4; + func_8096A080(this, play); + } else if (func_80968DD0(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void func_8096A184(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x220B; + } else if (func_80968E38(0) >= 20) { + textId = 0x2202; + } else { + textId = 0x21FC; + } + Message_StartTextbox(play, textId, &this->actor); +} + +void func_8096A1E8(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = func_8096A38C; + Message_StartTextbox(play, 0x2208, &this->actor); + gSaveContext.save.weekEventReg[84] |= 0x20; + func_809696EC(this, 0); + } else { + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); + } +} + +void func_8096A2C0(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + } + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_8096A1E8; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); + } else { + Actor_PickUp(&this->actor, play, GI_MASK_FIERCE_DEITY, 10000.0f, 1000.0f); + } +} + +void func_8096A38C(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + this->unk_2B8 |= 2; + } + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + break; + + case 1: + func_8019F230(); + break; + } + + switch (play->msgCtx.currentTextId) { + case 0x21FC: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x21FE); + Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); + this->unk_2B8 |= 0x10; + break; + case 1: + func_80151938(play, 0x21FD); + break; + } + break; + + case 0x21FE: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x2200); + func_809696EC(this, 0); + break; + case 1: + func_80151938(play, 0x21FF); + break; + } + break; + + case 0x2203: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x2205); + Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); + this->unk_2B8 |= 0x10; + break; + case 1: + func_80151938(play, 0x2204); + break; + } + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x2202: + case 0x2205: + case 0x2206: + case 0x2209: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x2200: + case 0x2208: + func_809696EC(this, 1); + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x2207: + if (INV_CONTENT(ITEM_MASK_FIERCE_DEITY) == ITEM_MASK_FIERCE_DEITY) { + func_80151938(play, 0x2208); + func_809696EC(this, 0); + } else { + func_801477B4(play); + this->actionFunc = func_8096A2C0; + func_8096A2C0(this, play); + } + break; + + case 0x2201: + + case 0x220A: + if (!func_809695FC(this, play)) { + func_80969530(this, play); + } + break; + + default: + func_80969530(this, play); + break; + } + } + break; + } +} + +void func_8096A6F4(EnJs* this, PlayState* play) { + s32 pad; + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + if ((this->actor.home.rot.y == this->actor.shape.rot.y) && (this->unk_2B8 & 0x10)) { + Animation_Change(&this->skelAnime, &gMoonChildGettingUpAnim, -1.0f, + Animation_GetLastFrame(&gMoonChildGettingUpAnim) - 1.0f, 0.0f, ANIMMODE_ONCE, -10.0f); + this->unk_2B8 &= ~0x10; + this->unk_2B8 |= 8; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildSittingAnim, -10.0f); + this->unk_2B8 &= ~8; + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_8096A38C; + this->unk_2B8 &= ~2; + func_8096A184(this, play); + return; + } + if (!(this->unk_2B8 & 8) && (this->actor.xzDistToPlayer < 100.0f) && + Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x1000)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnJs_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnJs* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); + + this->actionFunc(this, play); + + 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])) { + ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } + } +} + +void func_8096A9F4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnJs* this = THIS; + + if (limbIndex == MOONCHILD_LIMB_HEAD) { + Matrix_MultVec3f(&D_8096AC30, &thisx->focus.pos); + if ((this->maskType >= 0) && (this->maskType < 5)) { + OPEN_DISPS(play->state.gfxCtx); + + if (this->maskType != 0) { + Matrix_Scale(D_8096ABE0[this->maskType], D_8096ABE0[this->maskType], D_8096ABE0[this->maskType], + MTXMODE_APPLY); + Matrix_RotateZYX(0, -0x4000, -0x36B0, MTXMODE_APPLY); + } + Matrix_Translate(D_8096ABF4[this->maskType], D_8096AC08[this->maskType], D_8096AC1C[this->maskType], + MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_8096ABCC[this->maskType]); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + +void EnJs_Draw(Actor* thisx, PlayState* play) { + EnJs* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + func_8096A9F4, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.h b/src/overlays/actors/ovl_En_Js/z_en_js.h index 96c1bbf49..534557e66 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.h +++ b/src/overlays/actors/ovl_En_Js/z_en_js.h @@ -2,6 +2,11 @@ #define Z_EN_JS_H #include "global.h" +#include "objects/object_ob/object_ob.h" + +#define ENJS_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define ENJS_GET_PATH_INDEX(thisx) (((thisx)->params & 0xFC00) >> 10) +#define ENJS_GET_EXIT_INDEX(thisx) (((thisx)->params & 0x3F0) >> 4) struct EnJs; @@ -9,7 +14,18 @@ typedef void (*EnJsActionFunc)(struct EnJs*, PlayState*); typedef struct EnJs { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x180]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[MOONCHILD_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[MOONCHILD_LIMB_MAX]; + /* 0x2AC */ Path* path; + /* 0x2B0 */ s32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ u16 unk_2B8; + /* 0x2BA */ s16 maskType; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 cutscenes[2]; + /* 0x2C2 */ s16 cutsceneIndex; /* 0x2C4 */ EnJsActionFunc actionFunc; } EnJs; // size = 0x2C8 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bea647d45..cddc0dc43 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7955,8 +7955,8 @@ 0x80968CB8:("func_80968CB8",), 0x80968DD0:("func_80968DD0",), 0x80968E38:("func_80968E38",), - 0x80968F48:("func_80968F48",), - 0x809691B8:("func_809691B8",), + 0x80968F48:("EnJs_GetRemainingMasks",), + 0x809691B8:("EnJs_TakeMask",), 0x809692A8:("func_809692A8",), 0x8096933C:("func_8096933C",), 0x80969400:("func_80969400",), From 3d430a57336442c608a33009ee685bd4c0dd5d5b Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Wed, 14 Sep 2022 08:46:16 -0700 Subject: [PATCH 03/73] En_bubble OK (#995) * bubble OK * fixing elfbulb * flag fix * PR comments * PR comments * missed a fix * PR fixes * don't know how this got in there * u to s * small fix --- assets/xml/objects/object_bubble.xml | 4 +- spec | 3 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- .../actors/ovl_En_Bubble/z_en_bubble.c | 402 ++++++++++++++++-- .../actors/ovl_En_Bubble/z_en_bubble.h | 21 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 2 +- tools/disasm/functions.txt | 22 +- 7 files changed, 398 insertions(+), 58 deletions(-) diff --git a/assets/xml/objects/object_bubble.xml b/assets/xml/objects/object_bubble.xml index 4397a017f..da2f01d47 100644 --- a/assets/xml/objects/object_bubble.xml +++ b/assets/xml/objects/object_bubble.xml @@ -1,6 +1,6 @@  - - + + diff --git a/spec b/spec index 22a85ed0f..a1ca83eb2 100644 --- a/spec +++ b/spec @@ -883,8 +883,7 @@ beginseg name "ovl_En_Bubble" compress include "build/src/overlays/actors/ovl_En_Bubble/z_en_bubble.o" - include "build/data/ovl_En_Bubble/ovl_En_Bubble.data.o" - include "build/data/ovl_En_Bubble/ovl_En_Bubble.reloc.o" + include "build/src/overlays/actors/ovl_En_Bubble/ovl_En_Bubble_reloc.o" endseg beginseg 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 64c42a1ce..12da39288 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -649,7 +649,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, PlayState* play2) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { - gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); } else { gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } 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 3030041ca..06c5c33b1 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -15,11 +15,10 @@ void EnBubble_Destroy(Actor* thisx, PlayState* play); void EnBubble_Update(Actor* thisx, PlayState* play); void EnBubble_Draw(Actor* thisx, PlayState* play); -void func_808A029C(EnBubble* this, PlayState* play); -void func_808A0350(EnBubble* this, PlayState* play); -void func_808A03E8(EnBubble* this, PlayState* play); +void EnBubble_Wait(EnBubble* this, PlayState* play); +void EnBubble_Pop(EnBubble* this, PlayState* play); +void EnBubble_Regrow(EnBubble* this, PlayState* play); -#if 0 const ActorInit En_Bubble_InitVars = { ACTOR_EN_BUBBLE, ACTORCAT_ENEMY, @@ -32,73 +31,396 @@ const ActorInit En_Bubble_InitVars = { (ActorFunc)EnBubble_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808A0700[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x04 }, { 0xF7CFD757, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x04 }, + { 0xF7CFD757, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 16 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 16 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808A0748 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_808A0700, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808A0758 = { 1, 2, 25, 25, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 2, 25, 25, MASS_IMMOVABLE }; -#endif +void EnBubble_SetDimensions(EnBubble* this, f32 dim) { + f32 x; + f32 y; + f32 z; + f32 norm; -extern ColliderJntSphElementInit D_808A0700[2]; -extern ColliderJntSphInit D_808A0748; -extern CollisionCheckInfoInit2 D_808A0758; + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 1.0f); + this->actor.shape.yOffset = 16.0f; + this->modelRotSpeed = 16.0f; + this->modelEllipticity = 0.08f; + this->modelWidth = dim; + this->modelHeight = dim; + x = Rand_ZeroOne(); + y = Rand_ZeroOne(); + z = Rand_ZeroOne(); + this->unk_210 = 1.0f; + this->unk_214 = 1.0f; + norm = SQ(x) + SQ(y) + SQ(z); + this->unk1F8.x = x / norm; + this->unk1F8.y = y / norm; + this->unk1F8.z = z / norm; +} -extern UNK_TYPE D_06001000; +s32 func_8089F59C(EnBubble* this) { + ColliderInfo* info = &this->colliderSphere.elements[0].info; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F4E0.s") + info->toucher.dmgFlags = DMG_EXPLOSIVES; + info->toucher.effect = 0; + info->toucher.damage = 4; + info->toucherFlags = TOUCH_ON; + this->actor.velocity.y = 0.0f; + return 6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F59C.s") +s32 func_8089F5D0(EnBubble* this) { + EnBubble_SetDimensions(this, -1.0f); + return 12; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F5D0.s") +void EnBubble_DamagePlayer(EnBubble* this, PlayState* play) { + play->damagePlayer(play, -this->colliderSphere.elements[0].info.toucher.damage); + func_800B8E1C(play, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F5F4.s") +s32 EnBubble_Explosion(EnBubble* this, PlayState* play) { + static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEffectEnvColor = { 150, 150, 150, 0 }; + s32 i; + Vec3f effectAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f effectVel; + Vec3f effectPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F660.s") + Math_SmoothStepToF(&this->modelWidth, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelHeight, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelRotSpeed, 54.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelEllipticity, 0.2f, 0.1f, 1000.0f, 0.0f); + this->actor.shape.yOffset = (this->modelHeight + 1.0f) * 16.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F8BC.s") + if (DECR(this->explosionCountdown) != 0) { + return -1; + } + effectPos.x = this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y + this->actor.shape.yOffset; + effectPos.z = this->actor.world.pos.z; + for (i = 0; i < 20; i++) { + effectVel.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + effectVel.y = Rand_ZeroOne() * 7.0f; + effectVel.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(play, &effectPos, &effectVel, &effectAccel, &sEffectPrimColor, + &sEffectEnvColor, Rand_S16Offset(100, 50), 25, 0); + } + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x50); + this->actor.flags &= ~ACTOR_FLAG_1; + return Rand_S16Offset(90, 60); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F908.s") +s32 func_8089F8BC(EnBubble* this) { + if (DECR(this->explosionCountdown) != 0) { + return -1; + } else { + return func_8089F5D0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F95C.s") +s32 func_8089F908(EnBubble* this) { + this->modelWidth += 1.0f / 12.0f; + this->modelHeight += 1.0f / 12.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F9E4.s") + if (DECR(this->explosionCountdown) != 0) { + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FA54.s") +void EnBubble_Vec3fNormalizedReflect(Vec3f* vec1, Vec3f* vec2, Vec3f* dest) { + f32 norm; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FF30.s") + func_80179F64(vec1, vec2, dest); + norm = sqrtf(SQ(dest->x) + SQ(dest->y) + SQ(dest->z)); + if (norm != 0.0f) { + dest->x /= norm; + dest->y /= norm; + dest->z /= norm; + } else { + dest->x = dest->y = dest->z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FFCC.s") +void EnBubble_Vec3fNormalize(Vec3f* vec) { + f32 norm = sqrtf(SQ(vec->x) + SQ(vec->y) + SQ(vec->z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A005C.s") + if (norm != 0.0f) { + vec->x /= norm; + vec->y /= norm; + vec->z /= norm; + } else { + vec->x = vec->y = vec->z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Init.s") +void EnBubble_Fly(EnBubble* this, PlayState* play) { + CollisionPoly* poly; + Actor* bumpActor; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f normal; + Vec3f bounceDirection; + f32 bounceSpeed; + s32 bgId; + u8 bounceCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Destroy.s") + if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + bumpActor = this->colliderSphere.base.ac; + this->normalizedBumpVelocity = bumpActor->velocity; + EnBubble_Vec3fNormalize(&this->normalizedBumpVelocity); + this->velocityFromBump.x += this->normalizedBumpVelocity.x * 3.0f; + this->velocityFromBump.y += this->normalizedBumpVelocity.y * 3.0f; + this->velocityFromBump.z += this->normalizedBumpVelocity.z * 3.0f; + } + this->yVelocity -= 0.1f; + if (this->yVelocity < this->actor.terminalVelocity) { + this->yVelocity = this->actor.terminalVelocity; + } + bounceDirection.x = this->velocityFromBounce.x + this->velocityFromBump.x; + bounceDirection.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->yVelocity; + bounceDirection.z = this->velocityFromBounce.z + this->velocityFromBump.z; + EnBubble_Vec3fNormalize(&bounceDirection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A029C.s") + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + this->actor.shape.yOffset; + sp78.z = this->actor.world.pos.z; + sp6C = sp78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A0350.s") + sp6C.x += (bounceDirection.x * 24.0f); + sp6C.y += (bounceDirection.y * 24.0f); + sp6C.z += (bounceDirection.z * 24.0f); + if (BgCheck_EntityLineTest1(&play->colCtx, &sp78, &sp6C, &sp84, &poly, true, true, true, false, &bgId)) { + normal.x = COLPOLY_GET_NORMAL(poly->normal.x); + normal.y = COLPOLY_GET_NORMAL(poly->normal.y); + normal.z = COLPOLY_GET_NORMAL(poly->normal.z); + EnBubble_Vec3fNormalizedReflect(&bounceDirection, &normal, &bounceDirection); + this->bounceDirection = bounceDirection; + bounceCount = this->bounceCount; + this->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + this->bounceCount = 0; + } + bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; + this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; + this->velocityFromBounce.x = this->bounceDirection.x * bounceSpeed; + this->velocityFromBounce.y = this->bounceDirection.y * bounceSpeed; + this->velocityFromBounce.z = this->bounceDirection.z * bounceSpeed; + this->yVelocity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + } else if ((this->actor.bgCheckFlags & 0x20) && (bounceDirection.y < 0.0f)) { + normal.x = normal.z = 0.0f; + normal.y = 1.0f; + EnBubble_Vec3fNormalizedReflect(&bounceDirection, &normal, &bounceDirection); + this->bounceDirection = bounceDirection; + bounceCount = this->bounceCount; + this->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + this->bounceCount = 0; + } + bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; + this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; + this->velocityFromBounce.x = (this->bounceDirection.x * bounceSpeed); + this->velocityFromBounce.y = (this->bounceDirection.y * bounceSpeed); + this->velocityFromBounce.z = (this->bounceDirection.z * bounceSpeed); + this->yVelocity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + } + this->actor.velocity.x = this->velocityFromBounce.x + this->velocityFromBump.x; + this->actor.velocity.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->yVelocity; + this->actor.velocity.z = this->velocityFromBounce.z + this->velocityFromBump.z; + Math_ApproachF(&this->velocityFromBump.x, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&this->velocityFromBump.y, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&this->velocityFromBump.z, 0.0f, 0.3f, 0.1f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A03A0.s") +s32 func_8089FF30(EnBubble* this) { + if (((this->colliderSphere.base.acFlags & AC_HIT) != 0) == false) { + return false; + } + this->colliderSphere.base.acFlags &= ~AC_HIT; + if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + this->unk1F4.x = this->colliderSphere.base.ac->velocity.x / 10.0f; + this->unk1F4.y = this->colliderSphere.base.ac->velocity.y / 10.0f; + this->unk1F4.z = this->colliderSphere.base.ac->velocity.z / 10.0f; + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + return false; + } + this->timer = 8; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A03E8.s") +s32 EnBubble_IsPopped(EnBubble* this, PlayState* play) { + if ((DECR(this->timer) != 0) || (this->actionFunc == EnBubble_Pop)) { + return false; + } + if (this->colliderSphere.base.ocFlags2 & OC2_HIT_PLAYER) { + this->colliderSphere.base.ocFlags2 &= ~OC2_HIT_PLAYER; + EnBubble_DamagePlayer(this, play); + this->timer = 8; + return true; + } + return func_8089FF30(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Update.s") +void func_808A005C(EnBubble* this) { + ColliderJntSphElementDim* dim = &this->colliderSphere.elements[0].dim; + Vec3f src; + Vec3f dest; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Draw.s") + src.x = dim->modelSphere.center.x; + src.y = dim->modelSphere.center.y; + src.z = dim->modelSphere.center.z; + + Matrix_MultVec3f(&src, &dest); + dim->worldSphere.center.x = dest.x; + dim->worldSphere.center.y = dest.y; + dim->worldSphere.center.z = dest.z; + dim->worldSphere.radius = dim->modelSphere.radius * (1.0f + this->modelWidth); + this->colliderSphere.elements[1].dim = *dim; +} + +void EnBubble_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnBubble* this = THIS; + + ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); + Collider_InitJntSph(play, &this->colliderSphere); + Collider_SetJntSph(play, &this->colliderSphere, &this->actor, &sJntSphInit, this->colliderElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(9), &sColChkInfoInit); + this->actor.hintId = 0x16; + this->bounceDirection.x = Rand_ZeroOne(); + this->bounceDirection.y = Rand_ZeroOne(); + this->bounceDirection.z = Rand_ZeroOne(); + EnBubble_Vec3fNormalize(&this->bounceDirection); + this->velocityFromBounce.x = this->bounceDirection.x * 3.0f; + this->velocityFromBounce.y = this->bounceDirection.y * 3.0f; + this->velocityFromBounce.z = this->bounceDirection.z * 3.0f; + EnBubble_SetDimensions(this, 0); + this->actionFunc = EnBubble_Wait; +} + +void EnBubble_Destroy(Actor* thisx, PlayState* play) { + EnBubble* this = (EnBubble*)thisx; + + Collider_DestroyJntSph(play, &this->colliderSphere); +} + +void EnBubble_Wait(EnBubble* this, PlayState* play) { + if (EnBubble_IsPopped(this, play)) { + this->explosionCountdown = func_8089F59C(this); + this->actionFunc = EnBubble_Pop; + } else { + EnBubble_Fly(this, play); + this->actor.shape.yOffset = (this->modelHeight + 1.0f) * 16.0f; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); + } +} + +void EnBubble_Pop(EnBubble* this, PlayState* play) { + if (EnBubble_Explosion(this, play) > -1) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + Actor_MarkForDeath(&this->actor); + } +} + +void EnBubble_Disappear(EnBubble* this, PlayState* play) { + s32 temp_v0 = func_8089F8BC(this); + + if (temp_v0 >= 0) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->explosionCountdown = temp_v0; + this->actionFunc = EnBubble_Regrow; + } +} + +void EnBubble_Regrow(EnBubble* this, PlayState* play) { + if (func_8089F908(this)) { + this->actionFunc = EnBubble_Wait; + } + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); +} + +void EnBubble_Update(Actor* thisx, PlayState* play) { + EnBubble* this = (EnBubble*)thisx; + + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 16.0f, 16.0f, 0.0f, 7); + this->actionFunc(this, play); + Actor_SetFocus(&this->actor, this->actor.shape.yOffset); +} + +void EnBubble_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnBubble* this = (EnBubble*)thisx; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->actionFunc != EnBubble_Disappear) { + func_8012C2DC(play->state.gfxCtx); + Math_SmoothStepToF(&this->modelRotSpeed, 16.0f, 0.2f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelEllipticity, 0.08f, 0.2f, 1000.0f, 0.0f); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(this->modelWidth + 1.0f, this->modelHeight + 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF((f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + Matrix_Scale(this->modelEllipticity + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(-(f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); + } + + CLOSE_DISPS(play->state.gfxCtx); + + if (this->actionFunc != EnBubble_Disappear) { + this->actor.shape.shadowScale = (this->modelWidth + 1.0f) * 0.2f; + func_808A005C(this); + } +} diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h index 2217b86b1..7affed807 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h @@ -2,6 +2,7 @@ #define Z_EN_BUBBLE_H #include "global.h" +#include "objects/object_bubble/object_bubble.h" struct EnBubble; @@ -10,7 +11,25 @@ typedef void (*EnBubbleActionFunc)(struct EnBubble*, PlayState*); typedef struct EnBubble { /* 0x000 */ Actor actor; /* 0x144 */ EnBubbleActionFunc actionFunc; - /* 0x148 */ char unk_148[0x110]; + /* 0x148 */ ColliderJntSph colliderSphere; + /* 0x168 */ ColliderJntSphElement colliderElements[2]; + /* 0x1F4 */ Vec3f unk1F4; // set but never used + /* 0x1F4 */ Vec3f unk1F8; // randomly generated, set but never used + /* 0x200 */ s16 timer; // set to 8 when about to pop + /* 0x202 */ s16 explosionCountdown; + /* 0x204 */ UNK_TYPE1 pad204[4]; // unused + /* 0x208 */ f32 modelRotSpeed; + /* 0x20C */ f32 modelEllipticity; + /* 0x210 */ f32 unk_210; // set to 1.0f, never used + /* 0x214 */ f32 unk_214; // set to 1.0f, never used + /* 0x218 */ f32 modelWidth; + /* 0x21C */ f32 modelHeight; + /* 0x220 */ u8 bounceCount; + /* 0x224 */ Vec3f bounceDirection; + /* 0x230 */ Vec3f velocityFromBounce; + /* 0x23C */ Vec3f normalizedBumpVelocity; + /* 0x248 */ Vec3f velocityFromBump; + /* 0x254 */ f32 yVelocity; } EnBubble; // size = 0x258 extern const ActorInit En_Bubble_InitVars; 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 d0bc05b8b..287ca85e1 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -161,7 +161,7 @@ void EnElfbub_Draw(Actor* thisx, PlayState* play2) { Matrix_RotateZS(this->zRot * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index cddc0dc43..20fb6c0c2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5621,25 +5621,25 @@ 0x8089F2C4:("func_8089F2C4",), 0x8089F380:("EnViewer_Update",), 0x8089F3C8:("EnViewer_Draw",), - 0x8089F4E0:("func_8089F4E0",), + 0x8089F4E0:("EnBubble_SetDimensions",), 0x8089F59C:("func_8089F59C",), 0x8089F5D0:("func_8089F5D0",), - 0x8089F5F4:("func_8089F5F4",), - 0x8089F660:("func_8089F660",), + 0x8089F5F4:("EnBubble_DamagePlayer",), + 0x8089F660:("EnBubble_Explosion",), 0x8089F8BC:("func_8089F8BC",), 0x8089F908:("func_8089F908",), - 0x8089F95C:("func_8089F95C",), - 0x8089F9E4:("func_8089F9E4",), - 0x8089FA54:("func_8089FA54",), + 0x8089F95C:("EnBubble_Vec3fNormalizedReflect",), + 0x8089F9E4:("EnBubble_Vec3fNormalize",), + 0x8089FA54:("EnBubble_Fly",), 0x8089FF30:("func_8089FF30",), - 0x8089FFCC:("func_8089FFCC",), + 0x8089FFCC:("EnBubble_IsPopped",), 0x808A005C:("func_808A005C",), 0x808A0170:("EnBubble_Init",), 0x808A0270:("EnBubble_Destroy",), - 0x808A029C:("func_808A029C",), - 0x808A0350:("func_808A0350",), - 0x808A03A0:("func_808A03A0",), - 0x808A03E8:("func_808A03E8",), + 0x808A029C:("EnBubble_Wait",), + 0x808A0350:("EnBubble_Pop",), + 0x808A03A0:("EnBubble_Disappear",), + 0x808A03E8:("EnBubble_Regrow",), 0x808A0458:("EnBubble_Update",), 0x808A04D4:("EnBubble_Draw",), 0x808A08F0:("DoorShutter_SetupAction",), From bf2606586732d1dc39e48fe1b09b98fd668760be Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Wed, 14 Sep 2022 10:51:10 -0500 Subject: [PATCH 04/73] EnAz and EnTwig (Beaver bros and the minigame rings) (#999) * leave it to beavers * match * merge * catchup part 2 * fix warnings * I accidentally the xml * hopefully that's all of them * lol merge * linked object * now with more enums * Update src/overlays/actors/ovl_En_Az/z_en_az.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * more fixes * limbs and maths * stuff * more macro management * last enum? * more fixes * fixed * entrances Co-authored-by: petrie911 Co-authored-by: petrie911 Co-authored-by: petrie911 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/z64actor.h | 2 +- include/z64math.h | 3 + spec | 8 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 1814 ++++++++++++++++++- src/overlays/actors/ovl_En_Az/z_en_az.h | 40 +- src/overlays/actors/ovl_En_Twig/z_en_twig.c | 214 ++- src/overlays/actors/ovl_En_Twig/z_en_twig.h | 17 +- 7 files changed, 2014 insertions(+), 84 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 175d9ef22..bbf0a5534 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -83,7 +83,7 @@ typedef struct { typedef struct { /* 0x0 */ s16 unk_0; // frame? - /* 0x2 */ Vec3s unk_2; // pos? + /* 0x2 */ Vec3s unk_2; // scale } struct_80124618; // size = 0x8 typedef struct { diff --git a/include/z64math.h b/include/z64math.h index 16ab72e8a..323042b15 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -101,6 +101,9 @@ typedef struct { #define BINANG_LERPIMP(v0, v1, t) ((v0) + (s16)(BINANG_SUB((v1), (v0)) * (t))) #define BINANG_LERPIMPINV(v0, v1, t) ((v0) + BINANG_SUB((v1), (v0)) / (t)) +#define LERPWEIGHT(val, prev, next) (((val) - (prev)) / ((next) - (prev))) +#define F32_LERPWEIGHT(val, prev, next) (((f32)(val) - (f32)(prev)) / ((f32)(next) - (f32)(prev))) + #define VEC3F_LERPIMPDST(dst, v0, v1, t){ \ (dst)->x = (v0)->x + (((v1)->x - (v0)->x) * t); \ (dst)->y = (v0)->y + (((v1)->y - (v0)->y) * t); \ diff --git a/spec b/spec index a1ca83eb2..cb56bb471 100644 --- a/spec +++ b/spec @@ -3038,9 +3038,7 @@ beginseg name "ovl_En_Az" compress include "build/src/overlays/actors/ovl_En_Az/z_en_az.o" - include "build/data/ovl_En_Az/ovl_En_Az.data.o" - include "build/data/ovl_En_Az/ovl_En_Az.bss.o" - include "build/data/ovl_En_Az/ovl_En_Az.reloc.o" + include "build/src/overlays/actors/ovl_En_Az/ovl_En_Az_reloc.o" endseg beginseg @@ -3206,9 +3204,7 @@ beginseg name "ovl_En_Twig" compress include "build/src/overlays/actors/ovl_En_Twig/z_en_twig.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.data.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.bss.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.reloc.o" + include "build/src/overlays/actors/ovl_En_Twig/ovl_En_Twig_reloc.o" endseg beginseg 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 c025a6f77..a3594bec4 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -5,28 +5,69 @@ */ #include "z_en_az.h" +#include "objects/object_az/object_az.h" +#include "overlays/actors/ovl_En_Twig/z_en_twig.h" +#include "overlays/actors/ovl_En_Fish/z_en_fish.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnAz*)thisx) +typedef struct { + /* 0x0 */ s16 unk_0; + /* 0x4 */ f32 unk_4; +} struct_80A98F94; // size = 0x8 + void EnAz_Init(Actor* thisx, PlayState* play); void EnAz_Destroy(Actor* thisx, PlayState* play); void EnAz_Update(Actor* thisx, PlayState* play); void EnAz_Draw(Actor* thisx, PlayState* play); +void func_80A982E0(PlayState* play, ActorPathing* actorPathing); +void func_80A98414(EnAz* this, PlayState* play); +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4); +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp); + +void func_80A95C5C(EnAz* this, PlayState* play); void func_80A95CEC(EnAz* this, PlayState* play); + +void func_80A95DA0(EnAz* this, PlayState* play); void func_80A95E88(EnAz* this, PlayState* play); + +void func_80A95F94(EnAz* this, PlayState* play); void func_80A95FE8(EnAz* this, PlayState* play); + +void func_80A979DC(EnAz* this, PlayState* play); void func_80A979F4(EnAz* this, PlayState* play); + +void func_80A97A28(EnAz* this, PlayState* play); void func_80A97A40(EnAz* this, PlayState* play); + +void func_80A97A9C(EnAz* this, PlayState* play); void func_80A97AB4(EnAz* this, PlayState* play); + +void func_80A97C0C(EnAz* this, PlayState* play); void func_80A97C24(EnAz* this, PlayState* play); void func_80A97C4C(EnAz* this, PlayState* play); + +void func_80A97D5C(EnAz* this, PlayState* play); void func_80A97E48(EnAz* this, PlayState* play); + +void func_80A97EAC(EnAz* this, PlayState* play); void func_80A97F9C(EnAz* this, PlayState* play); -#if 0 +static AnimationSpeedInfo sAnimationInfo[14] = { + { &object_az_Anim_00BCFC, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_az_Anim_00C94C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_008960, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_008BB4, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_00925C, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_009B4C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_0086AC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_007D3C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_008EAC, 2.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00A25C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_00AAEC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00B94C, 1.0f, ANIMMODE_ONCE, -5.0f }, + { &object_az_Anim_00C0A0, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00C47C, 1.0f, ANIMMODE_LOOP, -5.0f }, +}; + const ActorInit En_Az_InitVars = { ACTOR_EN_AZ, ACTORCAT_NPC, @@ -39,108 +80,1771 @@ const ActorInit En_Az_InitVars = { (ActorFunc)EnAz_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A99110 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, 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 | AC_TYPE_ENEMY, + 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, 46, 0, { 0, 0, 0 } }, }; -#endif +static EnAz* D_80A9913C = NULL; -extern ColliderCylinderInit D_80A99110; +Vec3f D_80A99E80; // path point? +f32 D_80A99E8C; // player distance to path point? +f32 D_80A99E90[2]; // unused? -extern UNK_TYPE D_0600C94C; -extern UNK_TYPE D_0601ABF0; +void func_80A94A30(EnAz* 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_Az/func_80A94A30.s") +void func_80A94A64(EnAz* this) { + func_80A94A30(this); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A64.s") +s32 func_80A94A90(PlayState* play, ActorPathing* actorPathing) { + func_80A94A64((EnAz*)actorPathing->actor); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A90.s") +void func_80A94AB8(EnAz* this, PlayState* play, s32 spawnIndex) { + play->nextEntrance = Entrance_CreateFromSpawn(spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94AB8.s") +void func_80A94B20(PlayState* play) { + Actor* ring = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B20.s") + do { + ring = SubS_FindActor(play, ring, ACTORCAT_MISC, ACTOR_EN_TWIG); + if (ring != NULL) { + if (RACERING_GET_PARAM_F(ring) == 1) { + Actor_MarkForDeath(ring); + } + ring = ring->next; + } + } while (ring != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B98.s") +s32 func_80A94B98(EnAz* this, PlayState* play) { + EnTwig* ring; + s32 ret = false; + Actor* misc = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Init.s") + do { + if (1) {} + ring = (EnTwig*)SubS_FindActor(play, misc, ACTORCAT_MISC, ACTOR_EN_TWIG); + if ((ring != NULL) && (RACERING_GET_PARAM_F(&ring->dyna.actor) == 1) && !(ring->unk_16C & 1)) { + ret = true; + break; + } + misc = ring->dyna.actor.next; + } while (misc != NULL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Destroy.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A954AC.s") +static InitChainEntry sInitChain[3] = { + ICHAIN_F32(uncullZoneScale, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95534.s") +void EnAz_Init(Actor* thisx, PlayState* play2) { + static s16 D_80A9914C[7] = { 1, 0, 3, 2, 5, 4, -1 }; + static s16 D_80A9915C[7] = { 0, 1, 0, 1, 0, 1, 1 }; + EnAz* this = THIS; + PlayState* play = play2; + s16 sp4E; + s32 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9565C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_374 = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + switch (BEAVER_GET_PARAM_F00(thisx)) { + case 0: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + (gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + case 2: + phi_v1 = (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || + !(gSaveContext.save.weekEventReg[24] & 4); + break; + case 4: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 1: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + (gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + case 3: + phi_v1 = (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || + (gSaveContext.save.weekEventReg[24] & 4); + break; + case 5: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 6: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + !(gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + default: + phi_v1 = true; + break; + } + if (phi_v1) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95730.s") + this->unk_2F8 = D_80A9915C[BEAVER_GET_PARAM_F00(thisx)]; + if (BEAVER_GET_PARAM_F00(thisx) >= 0) { + sp4E = D_80A9914C[BEAVER_GET_PARAM_F00(thisx)]; + } else { + sp4E = -1; + } + if (this->unk_2F8 == 0) { + this->unk_374 |= 2; + } + SubS_FillCutscenesList(&this->actor, this->unk_3D0, ARRAY_COUNT(this->unk_3D0)); + if (D_80A9913C == NULL) { + D_80A9913C = THIS; + this->unk_374 |= 1; + } + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + if (this->unk_374 & 2) { + SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_007438, &object_az_Anim_00C94C, this->jointTable, + this->morphTable, OBJECT_AZ_1_LIMB_MAX); + Actor_SetScale(&this->actor, 0.012f); + } else { + SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_017990, &object_az_Anim_00C94C, this->jointTable, + this->morphTable, OBJECT_AZ_2_LIMB_MAX); + } + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if (this->unk_374 & 2) { + this->collider.dim.radius *= 1.2f; + this->collider.dim.height *= 1.2f; + this->collider.dim.yShift *= 1.2f; + } + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 5); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + this->unk_374 |= 0x100; + this->unk_376 |= 0x100; + } + Animation_Change(&this->skelAnime, sAnimationInfo[0].animation, 1.0f, + Animation_GetLastFrame(sAnimationInfo[0].animation) * Rand_ZeroOne(), + Animation_GetLastFrame(sAnimationInfo[0].animation), sAnimationInfo[0].mode, + sAnimationInfo[0].morphFrames); + this->unk_37E = 0; + this->unk_380 = 0; + this->unk_384 = 0; + this->actor.gravity = -1.0f; + this->unk_376 = this->unk_374; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A958B0.s") + switch (gSaveContext.save.entrance) { + case ENTRANCE(WATERFALL_RAPIDS, 0): + if (gSaveContext.save.weekEventReg[93] & 1) { + this->unk_2FA = 5; + if (this->unk_374 & 2) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + } else { + this->unk_2FA = 0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + func_80A94B20(play); + if (this->unk_2FA == 5) { + func_80A97C0C(this, play); + } else { + func_80A95DA0(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 3): + this->unk_2FA = 0; + if (!(this->unk_374 & 2)) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } + if (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 3)) { + this->unk_2FA = 0xA; + } + func_80A97C0C(this, play); + break; + case ENTRANCE(WATERFALL_RAPIDS, 1): + if (gSaveContext.save.weekEventReg[93] & 1) { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 8; + } else { + this->unk_2FA = 6; + } + } else { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 3; + } else { + this->unk_2FA = 1; + } + } + if (this->unk_374 & 1) { + SubS_CopyPointFromPathList(play->setupPathList, BEAVER_GET_PARAM_FF(thisx), + play->setupPathList[BEAVER_GET_PARAM_FF(thisx)].count - 1, &D_80A99E80); + } + if (gSaveContext.save.weekEventReg[24] & 4) { + if (this->unk_374 & 2) { + func_80A97D5C(this, play); + } else { + func_80A979DC(this, play); + } + } else if (this->unk_374 & 2) { + func_80A979DC(this, play); + } else { + func_80A97D5C(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 2): + if (gSaveContext.save.weekEventReg[93] & 1) { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 9; + } else { + this->unk_2FA = 7; + } + } else { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 4; + } else { + this->unk_2FA = 2; + } + } + if (this->unk_2FA == 2) { + if (!(this->unk_374 & 2)) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->actionFunc = func_80A97C24; + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + func_80A95C5C(this, play); + } + } else { + if (this->unk_374 & 2) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + this->actionFunc = func_80A97C24; + } + break; + } + if (sp4E >= 0) { + this->brother = NULL; + do { + this->brother = (EnAz*)SubS_FindActor(play, &this->brother->actor, ACTORCAT_NPC, ACTOR_EN_AZ); + if (this->brother != NULL) { + if (sp4E == BEAVER_GET_PARAM_F00(&this->brother->actor)) { + break; + } + this->brother = (EnAz*)this->brother->actor.next; + } + } while (this->brother != NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95B34.s") +void EnAz_Destroy(Actor* thisx, PlayState* play2) { + EnAz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95C5C.s") + if (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) { + gSaveContext.unk_3DD0[4] = 5; + } + Collider_DestroyCylinder(play2, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95CEC.s") +f32 func_80A954AC(EnAz* this) { + ActorPathing* pathing = &this->unk_300; + Vec3f sp28; + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95DA0.s") + sp28.x = pathing->curPoint.x - this->actor.world.pos.x; + sp28.y = pathing->curPoint.y - this->actor.world.pos.y; + sp28.z = pathing->curPoint.z - this->actor.world.pos.z; + sp1C.x = pathing->curPoint.x - pathing->prevPoint.x; + sp1C.y = pathing->curPoint.y - pathing->prevPoint.y; + sp1C.z = pathing->curPoint.z - pathing->prevPoint.z; + return Math3D_Parallel(&sp28, &sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95E88.s") +s32 func_80A95534(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95F94.s") + this->actor.world.rot.x = 0; + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, 0xE38, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x71C, 0); + this->actor.gravity = -1.0f; + this->unk_36C = 1.5f; + if (actorPathing->curPointIndex == actorPathing->endPointIndex) { + if (actorPathing->distSqToCurPointXZ < this->unk_36C) { + this->unk_36C = actorPathing->distSqToCurPointXZ; + } + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + actorPathing->moveFunc = SubS_ActorPathing_MoveWithGravity; + if (actorPathing->distSqToCurPointXZ <= this->actor.speedXZ) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95FE8.s") +s32 func_80A9565C(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9617C.s") + this->actor.gravity = -1.0f; + actorPathing->moveFunc = func_80A94A90; + this->unk_374 |= 0x2000; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + this->unk_39E = this->actor.world.rot.x = + Math_Atan2S(-this->actor.velocity.y, Math_CosS(-this->actor.world.rot.x) * this->actor.speedXZ); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97114.s") +s32 func_80A95730(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; + f32 sp40; + s32 sp3C; + s32 sp38; + s32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97274.s") + this->actor.gravity = 0.0f; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + sp40 = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp34 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A973B4.s") + sp3C = (s32)(sp34 * sp40) + 0xAAA; + sp34 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97410.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp3C, 0); + sp38 = (s32)(sp34 * sp40) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp38, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979DC.s") + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp3C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp38, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979F4.s") +s32 func_80A958B0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp; + f32 phi_f0; + f32 temp1; + f32 temp2; + f32 sp3C; + s32 sp2C; + s32 sp28; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A28.s") + this->actor.gravity = 0.0f; + temp2 = D_80A99E8C; + temp = D_80A99E90[this->unk_2F8]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A40.s") + if (temp <= temp2) { + phi_f0 = (this->unk_374 & 2) ? 480.0f : 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A9C.s") + if (this->actor.xzDistToPlayer < phi_f0) { + Math_SmoothStepToF(&this->unk_36C, 12.0f, 0.8f, 0.5f, 0.01f); + } else { + Math_SmoothStepToF(&this->unk_36C, 6.0f, 0.8f, 0.5f, 0.01f); + } + } else { + Math_SmoothStepToF(&this->unk_36C, 26.0f, 0.5f, 1.0f, 0.01f); + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + temp1 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp1 <= 0.0f)) { + ret = true; + } else { + sp3C = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp30 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); + sp2C = (s32)(sp30 * sp3C) + 0xAAA; + sp30 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97AB4.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp2C, 0); + sp28 = (s32)(sp30 * sp3C) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp28, 0); + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp2C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp28, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C0C.s") +s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C24.s") + if (this->unk_374 & 0x100) { + if (!(this->unk_374 & 8)) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 8, &this->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + } + this->unk_374 |= 8; + } + if (this->unk_2FA == 0) { + ret = func_80A95730(play, actorPathing); + } else { + ret = func_80A958B0(play, actorPathing); + } + } else if (this->actor.bgCheckFlags & 1) { + if (this->unk_374 & 8) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 1, &this->animIndex); + this->unk_374 &= ~8; + } + ret = func_80A95534(play, actorPathing); + } else { + ret = func_80A9565C(play, actorPathing); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C4C.s") +void func_80A95C5C(EnAz* this, PlayState* play) { + this->actor.draw = NULL; + this->actor.world.pos.y = this->actor.home.pos.y + 120.0f; + this->actor.gravity = -1.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_3C0 = 0; + this->actionFunc = func_80A95CEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97D5C.s") +void func_80A95CEC(EnAz* this, PlayState* play) { + if (this->unk_374 & 0x8000) { + if (!(this->actor.bgCheckFlags & 1)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.draw = EnAz_Draw; + Actor_MoveWithGravity(&this->actor); + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } else { + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } + if (SubS_StartActorCutscene(&this->actor, 0x7C, this->unk_3D0[0], SUBS_CUTSCENE_NORMAL)) { + func_80A97C0C(this, play); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97E48.s") +void func_80A95DA0(EnAz* this, PlayState* play) { + ActorPathing* sp40 = &this->unk_300; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97EAC.s") + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, sp40, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 1); + this->unk_36C = 4.0f; + this->actor.speedXZ = 4.0f; + this->actor.gravity = 0.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + Math_Vec3f_Copy(&this->actor.world.pos, &sp40->curPoint); + this->actionFunc = func_80A95E88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97F9C.s") +void func_80A95E88(EnAz* this, PlayState* play) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + if (!(this->unk_374 & 0x2000)) { + SkelAnime_Update(&this->skelAnime); + } + this->unk_374 &= ~0x2000; + if (this->actor.isTargeted) { + func_80A95F94(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A982E0.s") +void func_80A95F94(EnAz* this, PlayState* play) { + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + this->unk_39E = 0; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A95FE8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98414.s") +void func_80A95FE8(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (ActorCutscene_GetCanPlayNext(this->unk_3D0[0])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_3D0[0], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_3D0[0]); + } + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 20.0f) { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 3, 0xE38, 0x38E); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0xE38, 0x38E); + this->actor.shape.rot.z = 0; + Actor_MoveWithoutGravityReverse(&this->actor); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 &= ~0x1000; + this->actor.gravity = -1.0f; + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 3, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1038, 0x100); + if (this->actor.bgCheckFlags & 1) { + this->actor.shape.rot.x = 0; + this->actor.gravity = 0.0f; + func_80A97C0C(this, play); + ActorCutscene_Stop(this->unk_3D0[0]); + } + Actor_MoveWithGravity(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Update.s") +s32 func_80A9617C(EnAz* this, PlayState* play) { + s32 pad[2]; + s32 ret = 2; + EnAz* brother = this->brother; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Draw.s") + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if ((play->msgCtx.currentTextId == 0x10DD) && (this->unk_374 & 0x8000)) { + if (SubS_StartActorCutscene(&brother->actor, brother->unk_3D0[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { + brother->unk_374 |= 0x8000; + play->msgCtx.msgMode = 0x44; + ret = 0; + } + } else if (Message_ShouldAdvance(play)) { + ret = 3; + switch (play->msgCtx.currentTextId) { + case 0x70: + case 0xCD: + gSaveContext.save.weekEventReg[24] &= (u8)~1; + this->actor.textId = 0x10F2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + break; + case 0x10CE: + this->actor.textId = 0x10CF; + gSaveContext.save.weekEventReg[16] |= 0x40; + break; + case 0x10CF: + this->actor.textId = 0x10D0; + break; + case 0x10D0: + this->actor.textId = 0x10D1; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + break; + case 0x10D1: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D2: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10D6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10D3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + } + break; + case 0x10D3: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10D4: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D6: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + func_80A979DC(this, play); + this->unk_2FA = 1; + ret = 0; + break; + case 0x10D7: + this->actor.textId = 0x10D8; + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + switch (this->unk_2FA) { + case 2: + this->unk_2FA = 1; + break; + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + this->unk_2FA = 8; + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10D9; + } + break; + case 0x10D9: + if ((this->unk_2FA == 3) || (this->unk_2FA == 8)) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10DA: + this->actor.textId = 0x10DB; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10DB: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + this->unk_2FA = 1; + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10DC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + } + break; + case 0x10DC: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10DD: + func_80A98EFC(this, play, 0x10DE, 13, 9); + this->unk_374 |= 0x8000; + ret = 2; + break; + case 0x10DE: + func_80A98EFC(this, play, 0x10DF, 12, 10); + ret = 0; + break; + case 0x10DF: + func_80A98EFC(this, play, 0x10E0, 13, 9); + ret = 0; + break; + case 0x10E0: + func_80A98EFC(this, play, 0x10E1, 12, 10); + ret = 0; + break; + case 0x10E1: + func_80A98EFC(this, play, 0x10E2, 13, 9); + ret = 0; + break; + case 0x10E2: + this->actor.textId = 0x10E3; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10E3: + func_80A98EFC(this, play, 0x10E4, 0, 4); + ret = 0; + break; + case 0x10E4: + func_80A98EFC(this, play, 0x10E5, 0, 4); + ret = 0; + break; + case 0x10E5: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10E8; + } else { + func_8019F230(); + this->actor.textId = 0x10E6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10E6: + this->actor.textId = 0x10E7; + func_80A98EFC(this, play, 0x10E7, 0, 10); + ret = 0; + break; + case 0x10E7: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + func_80A94AB8(this, play, 0); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10E8: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 3; + ret = 0; + break; + case 0x10E9: + func_80A98EFC(this, play, 0x10EA, 12, 4); + ret = 0; + break; + case 0x10EA: + func_80A98EFC(this, play, 0x10EB, 0, 4); + ret = 0; + break; + case 0x10EB: + if (play->msgCtx.choiceIndex == 0) { + play->msgCtx.msgMode = 0x44; + func_8019F208(); + switch (this->unk_2FA) { + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + default: + this->unk_2FA = 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98DA4.s") + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10EC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 7, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10EC: + func_80A98EFC(this, play, 0x10ED, -1, 6); + ret = 0; + break; + case 0x10ED: + if ((this->unk_2FA == 4) || (this->unk_2FA == 9)) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10EE: + func_80A98EFC(this, play, 0x10EF, 12, 10); + ret = 0; + break; + case 0x10EF: + func_80A98EFC(this, play, 0x10F0, 13, 9); + ret = 0; + break; + case 0x10F0: + func_80A98EFC(this, play, 0x10F1, 12, 10); + ret = 0; + break; + case 0x10F1: + gSaveContext.save.weekEventReg[93] |= 1; + if (gSaveContext.save.weekEventReg[23] & 0x80) { + this->getItemId = GI_RUPEE_RED; + } else { + this->getItemId = GI_BOTTLE; + gSaveContext.save.weekEventReg[23] |= 0x80; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + ret = 7; + break; + case 0x10F2: + case 0x1109: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10F3: + func_80A98EFC(this, play, 0x10F4, 12, 10); + ret = 0; + break; + case 0x10F4: + func_80A98EFC(this, play, 0x10F5, 13, 9); + ret = 0; + break; + case 0x10F5: + func_80A98EFC(this, play, 0x10F6, 12, 10); + ret = 0; + break; + case 0x10F6: + func_80A98EFC(this, play, 0x10F7, 13, 5); + ret = 0; + break; + case 0x10F7: + this->actor.textId = 0x10F8; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10F8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.save.weekEventReg[25] & 1) { + this->actor.textId = 0x1107; + } else { + this->actor.textId = 0x10FA; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10F9; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, + &brother->animIndex); + } + break; + case 0x10F9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10FA: + case 0x1107: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 6; + ret = 0; + break; + case 0x10FB: + func_80A98EFC(this, play, 0x10FC, 12, 10); + ret = 0; + break; + case 0x10FC: + func_80A98EFC(this, play, 0x10FD, 13, 4); + ret = 0; + break; + case 0x10FD: + this->actor.textId = 0x10FE; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + break; + case 0x10FE: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.save.weekEventReg[25] & 1) { + this->actor.textId = 0x1108; + } else { + this->actor.textId = 0x1101; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10FF; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10FF: + func_80A98EFC(this, play, 0x1100, 12, 10); + ret = 0; + break; + case 0x1100: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x1101: + case 0x1108: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 8; + ret = 0; + break; + case 0x1102: + func_80A98EFC(this, play, 0x1103, 12, 10); + ret = 0; + break; + case 0x1103: + func_80A98EFC(this, play, 0x1104, 13, 9); + ret = 0; + break; + case 0x1104: + func_80A98EFC(this, play, 0x1105, 12, 10); + ret = 0; + break; + case 0x1105: + if (gSaveContext.save.weekEventReg[25] & 1) { + this->getItemId = GI_RUPEE_PURPLE; + } else { + this->getItemId = GI_HEART_PIECE; + gSaveContext.save.weekEventReg[25] |= 1; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + ret = 7; + break; + case 0x1106: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10D5: + default: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + } + } + break; + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98E48.s") +void func_80A97114(EnAz* this, PlayState* play) { + EnAz* brother = this->brother; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98EFC.s") + this->actor.flags &= ~ACTOR_FLAG_10000; + switch (this->actor.textId) { + case 0x10DA: + case 0x10DD: + case 0x10E9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10EE: + case 0x10F3: + case 0x10FB: + case 0x1102: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + sp20 = true; + break; + case 0x10F2: + case 0x1106: + case 0x1109: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + if (brother != NULL) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + } + break; + } + if ((brother != NULL) && sp20) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, &brother->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 12, &brother->animIndex); + } + } + this->unk_374 &= ~0x20; + this->unk_378 = 2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98F94.s") +s32 func_80A97274(EnAz* this, PlayState* play) { + s32 textId; + + if (this->unk_374 & 0x4000) { + return 0x10D7; + } + switch (this->unk_2FA) { + case 0: + default: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + if (!(gSaveContext.save.weekEventReg[16] & 0x40)) { + textId = 0x10CE; + } else { + textId = 0x10D4; + } + break; + case 2: + if (gSaveContext.save.weekEventReg[24] & 1) { + gSaveContext.save.weekEventReg[24] |= 4; + this->unk_3C0 = 0; + textId = 0x10DD; + } else { + textId = 0x10DA; + } + break; + case 4: + if (gSaveContext.save.weekEventReg[24] & 1) { + textId = 0x10EE; + } else { + textId = 0x10E9; + } + break; + case 5: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + textId = 0x10F3; + break; + case 7: + if (gSaveContext.save.weekEventReg[24] & 1) { + gSaveContext.save.weekEventReg[24] |= 4; + textId = 0x10FB; + } else { + textId = 0x10E9; + } + break; + case 9: + if (gSaveContext.save.weekEventReg[24] & 1) { + textId = 0x1102; + } else { + textId = 0x10E9; + } + break; + } + return textId; +} + +s32 func_80A973B4(EnAz* this, PlayState* play) { + s32 ret = 0; + + if (this->getItemId != GI_RUPEE_RED) { + if ((this->getItemId != GI_RUPEE_PURPLE) && (this->getItemId != GI_HEART_PIECE)) { + if (this->getItemId == GI_BOTTLE) { + ret = 0x10F2; + } + } else { + ret = 0x1106; + } + } else { + ret = 0x1109; + } + this->unk_374 |= 0x20; + + return ret; +} + +void func_80A97410(EnAz* this, PlayState* play) { + s16 sp56; + s16 sp54; + s32 temp_a0; + + if (this->unk_378 != 0) { + Vec3f* thisPos = &this->actor.world.pos; + + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0xA); + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0xA); + } + if (this->brother != NULL) { + Vec3f* broPos = &this->brother->actor.world.pos; + + if (this->unk_374 & 0x40) { + this->actor.focus.pos.x = (thisPos->x * 0.5f) + (broPos->x * 0.5f); + this->actor.focus.pos.y = (thisPos->y * 0.5f) + (broPos->y * 0.5f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.5f) + (broPos->z * 0.5f); + } else { + this->actor.focus.pos.x = (thisPos->x * 0.7f) + (broPos->x * 0.3f); + this->actor.focus.pos.y = (thisPos->y * 0.7f) + (broPos->y * 0.3f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.7f) + (broPos->z * 0.3f); + } + } else { + this->actor.focus.pos.x = thisPos->x; + this->actor.focus.pos.y = thisPos->y; + this->actor.focus.pos.z = thisPos->z; + } + 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; + } + if (this->unk_378 == 2) { + this->unk_378 = func_80A9617C(this, play); + if (this->unk_378 == 0) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + } + if (this->unk_378 == 3) { + func_80151938(play, this->actor.textId); + this->unk_378 = 2; + } else if (this->unk_378 == 5) { + Message_StartTextbox(play, this->actor.textId, &this->actor); + this->unk_378 = 2; + } else { + if ((this->unk_378 == 6) || (this->unk_378 == 7)) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + if (this->unk_378 == 7) { + this->unk_378 = 1; + this->unk_374 |= 0x20; + } else { + this->unk_378 = 0; + } + } else { + Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); + } + } + if (this->unk_378 == 9) { + temp_a0 = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38, 0x222); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (temp_a0 == 0) { + switch (this->unk_3D2) { + case 0x10CE: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D4: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + break; + } + Message_StartTextbox(play, this->unk_3D2, &this->actor); + this->actor.textId = this->unk_3D2; + this->unk_378 = 2; + } + } else if (((this->unk_378 == 0) || (this->unk_378 == 1)) && (this->unk_374 & 0x20)) { + if (this->unk_378 == 1) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + } else if (func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + PLAYER_AP_MINUS1)) { + this->actor.textId = func_80A973B4(this, play); + } + } else { + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + s16 temp_a1_2 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + s16 temp_v0_7; + + if (ABS(temp_a1_2) < 0x1800) { + Math_SmoothStepToS(&this->unk_3D4, temp_a1_2, 2, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0); + } + Math_Vec3f_Copy(&sp38, &player->actor.world.pos); + sp38.y = player->bodyPartsPos[7].y + 3.0f; + temp_v0_7 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp38); + if (ABS(temp_v0_7) < 0x800) { + Math_SmoothStepToS(&this->unk_3D6, temp_v0_7, 3, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0); + } + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->unk_378 = 9; + } + } else { + Actor_GetScreenPos(play, &this->actor, &sp56, &sp54); + if ((sp56 >= 0) && (sp56 <= SCREEN_WIDTH) && (sp54 >= 0) && (sp54 <= SCREEN_HEIGHT) && + func_800B8500(&this->actor, play, 120.0f, 120.0f, 0)) { + this->unk_3D2 = func_80A97274(this, play); + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->actor.textId = 0; + } else { + this->actor.textId = this->unk_3D2; + } + } + } + } + } + } +} + +void func_80A979DC(EnAz* this, PlayState* play) { + this->actionFunc = func_80A979F4; +} + +void func_80A979F4(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Actor_MoveWithGravity(&this->actor); +} + +void func_80A97A28(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97A40; +} + +void func_80A97A40(EnAz* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->actor, 0, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80A97A9C(this, play); + } +} + +void func_80A97A9C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97AB4; +} + +void func_80A97AB4(EnAz* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + Message_StartTextbox(play, 0x10D7, NULL); + break; + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x10D7: + func_80151938(play, 0x10D8); + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + func_800FD750(NA_BGM_MINI_GAME_2); + func_80A94AB8(this, play, 1); + func_80A979DC(this, play); + } else { + func_8019F230(); + if (gSaveContext.save.weekEventReg[24] & 4) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80151938(play, 0x10D9); + } + break; + case 0x10D9: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + break; + } + } + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + break; + } +} + +void func_80A97C0C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97C4C; +} + +void func_80A97C24(EnAz* this, PlayState* play) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A97C4C; +} + +void func_80A97C4C(EnAz* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == 0xB)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + } + func_80A97410(this, play); + if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { + gSaveContext.save.weekEventReg[24] &= (u8)~1; + func_800FD750(NA_BGM_MINI_GAME_2); + play->nextEntrance = Entrance_CreateFromSpawn(1); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + func_80A979DC(this, play); + } else { + Actor_MoveWithGravity(&this->actor); + } +} + +void func_80A97D5C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + func_80112AFC(play); + gSaveContext.minigameScore = (this->unk_374 & 2) ? 25 : 20; + play->interfaceCtx.unk_280 = 1; + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + func_8010E9F0(4, 120); + } else if (gSaveContext.save.weekEventReg[25] & 1) { + func_8010E9F0(4, 100); + } else { + func_8010E9F0(4, 110); + } + this->actionFunc = func_80A97E48; +} + +void func_80A97E48(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (play->interfaceCtx.unk_280 >= 8) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80A97EAC(this, play); + } + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); +} + +void func_80A97EAC(EnAz* this, PlayState* play) { + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, &this->unk_300, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 0); + this->unk_36C = 8.0f; + this->actor.speedXZ = 8.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 6.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + this->unk_3C2 = 0; + this->unk_3C4 = 0; + this->actionFunc = func_80A97F9C; +} + +void func_80A97F9C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + D_80A99E8C = + Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z); + if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z) >= + SQ(1000.0f)) { + this->unk_374 |= 0x1000; + } + if (!(this->unk_300.flags & ACTOR_PATHING_REACHED_END_PERMANENT)) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + } + if (!(this->unk_374 & 0x10) && + SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + this->unk_374 |= 0x10; + } + if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (func_80A94B98(this, play)) { + gSaveContext.save.weekEventReg[24] &= (u8)~1; + } else { + gSaveContext.save.weekEventReg[24] |= 1; + } + gSaveContext.unk_3DD0[4] = 5; + this->unk_374 &= ~0x10; + play->nextEntrance = Entrance_CreateFromSpawn(2); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + this->actor.speedXZ = 0.0f; + func_80A979DC(this, play); + } else { + if (gSaveContext.unk_3DE0[4] == 0) { + gSaveContext.unk_3DD0[4] = 5; + this->unk_374 |= 0x4000; + func_80A97A28(this, play); + } + if (this->unk_374 & 0x100) { + if (this->actor.flags & ACTOR_FLAG_40) { + func_80A98414(this, play); + } + if ((DECR(this->unk_37A) == 0) && (this->actor.flags & ACTOR_FLAG_40)) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 20.0f, 20.0f, 0.35f); + this->unk_37A = (Rand_ZeroOne() * 70.0f) + 10.0f; + } + } + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80A982E0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + Vec3f sp28; + + actorPathing->curPoint.x = actorPathing->points[actorPathing->curPointIndex].x; + if (this->actor.bgCheckFlags & 1) { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y; + } else { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y - this->unk_3A4; + } + actorPathing->curPoint.z = actorPathing->points[actorPathing->curPointIndex].z; + sp28.x = actorPathing->curPoint.x - actorPathing->worldPos->x; + sp28.y = actorPathing->curPoint.y - actorPathing->worldPos->y; + sp28.z = actorPathing->curPoint.z - actorPathing->worldPos->z; + actorPathing->distSqToCurPointXZ = Math3D_XZLengthSquared(sp28.x, sp28.z); + actorPathing->distSqToCurPoint = Math3D_LengthSquared(&sp28); + actorPathing->rotToCurPoint.y = Math_FAtan2F(sp28.z, sp28.x); + actorPathing->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPathing->distSqToCurPointXZ), -sp28.y); + actorPathing->rotToCurPoint.z = 0; +} + +void func_80A98414(EnAz* this, PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_EN_FISH) { + EnFish* fish = (EnFish*)itemAction; + + if ((fish->actor.params < 0) && (fish->actor.room == this->actor.room) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &fish->actor.world.pos) < SQ(200.0f))) { + fish->unk_276 = 0x14; + fish->unk_274 = Actor_YawBetweenActors(&fish->actor, &this->actor); + } + } + itemAction = itemAction->next; + } +} + +void EnAz_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + this->unk_374 &= ~0x100; + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + if (!(this->unk_376 & 0x100)) { + this->unk_374 |= 0x200; + } + this->unk_374 |= 0x100; + } else if (this->unk_376 & 0x100) { + this->unk_374 |= 0x400; + } + this->actionFunc(this, play); + Actor_SetFocus(&this->actor, 40.0f); + if (this->unk_374 & 0x200) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER); + } + if (this->unk_374 & 0x400) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + } + this->unk_37E++; + if (this->unk_37E >= 4) { + this->unk_37E = 0; + } + this->unk_380++; + if (this->unk_380 >= 3) { + this->unk_380 = 0; + } + this->unk_384--; + if (this->unk_384 < 0) { + this->unk_384 = 2; + } + this->unk_39C++; + if (this->unk_39C >= 16) { + this->unk_39C = 0; + } + if (!(this->unk_374 & 0x1000)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + } else { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x400); + this->unk_374 &= ~0x1000; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + this->unk_376 = this->unk_374; + this->unk_374 &= ~0x600; + + if (GET_ACTIVE_CAM(play)->stateFlags & CAM_STATE_UNDERWATER) { + this->unk_374 |= 0x800; + } else { + this->unk_374 &= ~0x800; + } +} + +static Gfx* D_80A9916C[5] = { + object_az_DL_01A600, object_az_DL_01A730, object_az_DL_01A860, object_az_DL_01A990, object_az_DL_01AAC0, +}; +static AnimatedMaterial* D_80A99180[5] = { + object_az_Matanimheader_01A6E8, object_az_Matanimheader_01A818, object_az_Matanimheader_01A948, + object_az_Matanimheader_01AA78, object_az_Matanimheader_01ABA8, +}; +static u8 D_80A99194[5] = { + 95, 135, 175, 215, 255, +}; +static u8 D_80A9919C[5] = { + 31, 45, 58, 73, 85, +}; +static struct_80124618 D_80A991A4[5][9] = { + { + { 0, { 200, 160, 160 } }, + { 2, { 250, 210, 210 } }, + { 4, { 200, 160, 160 } }, + { 6, { 250, 210, 210 } }, + { 8, { 200, 160, 160 } }, + { 10, { 250, 210, 210 } }, + { 12, { 200, 160, 160 } }, + { 14, { 250, 210, 210 } }, + { 16, { 200, 160, 160 } }, + }, + { + { 0, { 330, 200, 200 } }, + { 2, { 280, 150, 150 } }, + { 4, { 330, 200, 200 } }, + { 6, { 280, 150, 150 } }, + { 8, { 330, 200, 200 } }, + { 10, { 280, 150, 150 } }, + { 12, { 330, 200, 200 } }, + { 14, { 280, 150, 150 } }, + { 16, { 330, 200, 200 } }, + }, + { + { 0, { 350, 170, 120 } }, + { 2, { 400, 220, 170 } }, + { 4, { 350, 170, 120 } }, + { 6, { 400, 220, 170 } }, + { 8, { 350, 170, 120 } }, + { 10, { 400, 220, 170 } }, + { 12, { 350, 170, 120 } }, + { 14, { 400, 220, 170 } }, + { 16, { 350, 170, 120 } }, + }, + { + { 0, { 480, 216, 156 } }, + { 2, { 540, 216, 156 } }, + { 4, { 450, 300, 216 } }, + { 6, { 540, 216, 156 } }, + { 8, { 450, 300, 216 } }, + { 10, { 540, 216, 156 } }, + { 12, { 450, 300, 216 } }, + { 14, { 540, 300, 156 } }, + { 16, { 450, 250, 216 } }, + }, + { + { 0, { 600, 375, 160 } }, + { 2, { 640, 510, 200 } }, + { 4, { 600, 375, 160 } }, + { 6, { 640, 510, 200 } }, + { 8, { 600, 375, 160 } }, + { 10, { 640, 510, 200 } }, + { 12, { 600, 375, 160 } }, + { 14, { 640, 510, 200 } }, + { 16, { 600, 375, 160 } }, + }, +}; +static struct_80A98F94 D_80A9930C[5][4] = { + { { 0, 2100.0f }, { 7, 1500.0f }, { 16, 2100.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 7, 2200.0f }, { 10, 1600.0f }, { 16, 1900.0f } }, + { { 0, 1700.0f }, { 7, 2200.0f }, { 16, 1700.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 4, 1600.0f }, { 10, 2200.0f }, { 16, 1900.0f } }, + { { 0, 1900.0f }, { 7, 1400.0f }, { 16, 1900.0f }, { 0, 0.0f } }, +}; +static Vec3f D_80A993AC[3] = { + { 1.0f, 1.0f, 0.0f }, + { 0.9f, 0.9f, 120.0f }, + { 0.95f, 0.95f, 240.0f }, +}; +static Vec3f D_80A993D0[3] = { + { 1.5f, 1.5f, 0.0f }, + { 1.2f, 1.2f, 120.0f }, + { 1.35f, 1.35f, 240.0f }, +}; +static TexturePtr D_80A993F4[4] = { + object_az_Tex_00F918, + object_az_Tex_010118, + object_az_Tex_010918, + object_az_Tex_011118, +}; +static TexturePtr D_80A99404[3] = { + object_az_Tex_016018, + object_az_Tex_016818, + object_az_Tex_017018, +}; + +void EnAz_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + CLOSE_DISPS(play->state.gfxCtx); + + if (this->unk_374 & 2) { + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + } else { + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A993F4[this->unk_37E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A99404[this->unk_380])); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + CLOSE_DISPS(play->state.gfxCtx); + } + OPEN_DISPS(play->state.gfxCtx); + if ((this->actor.depthInWater >= 28.0f) && (this->actor.speedXZ > 0.5f)) { + Matrix_Translate(this->unk_3B4.x, this->unk_3B4.y, this->unk_3B4.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_RotateXS(this->unk_39E, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + if (this->unk_374 & 2) { + s32 i; + Vec3f sp98; + f32 sp94; + + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(D_80A99180); i++) { + Matrix_Push(); + func_80A98F94(D_80A9930C[i], this->unk_39C, &sp94); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(D_80A99180[i])); + Matrix_Translate(0.0f, sp94 * 100.0f, i * -930.0f, MTXMODE_APPLY); + Matrix_Scale(1.1f, 0.95f, 1.0f, MTXMODE_APPLY); + func_80124618(D_80A991A4[i], this->unk_39C, &sp98); + Matrix_Scale(sp98.x, sp98.y, sp98.z, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A99194[i])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A9919C[i])); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80A9916C[i]); + Matrix_Pop(); + } + } else { + Matrix_Push(); + Matrix_Translate(0.0f, 2000.0f, -2000.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993AC[this->unk_384].x, D_80A993AC[this->unk_384].y, 0.0f, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 255)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 85)); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01ABF0); + Matrix_Pop(); + Matrix_Translate(0.0f, 2000.0f, -2100.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993D0[this->unk_384].x, D_80A993D0[this->unk_384].y, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01AD00); + } + } + CLOSE_DISPS(play->state.gfxCtx); +} + +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAz* this = THIS; + + if ((limbIndex == OBJECT_AZ_1_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { + *dList = NULL; + } + if (limbIndex == OBJECT_AZ_1_LIMB_NONE) { + rot->x = rot->x; + rot->y = rot->y; + rot->z = rot->z; + } + if (limbIndex == OBJECT_AZ_1_LIMB_03) { + rot->y -= this->unk_39E; + } else { + // this space intentionally left blank + } + if (limbIndex == OBJECT_AZ_1_LIMB_05) { + rot->x += this->unk_3D4; + rot->y -= this->unk_3D6; + } + return false; +} + +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80A99410 = { 700.0f, 0.0f, 0.0f }; + static Vec3f D_80A9941C = { -500.0f, 0.0f, 0.0f }; + static Vec3f D_80A99428 = { -1200.0f, 0.0f, 1000.0f }; + EnAz* this = THIS; + + if (limbIndex == OBJECT_AZ_1_LIMB_03) { + Matrix_MultVec3f(&D_80A99410, &this->unk_3A8); + Math_SmoothStepToF(&this->unk_3A4, this->unk_3A8.y - this->actor.world.pos.y, 0.8f, 10.0f, 0.01f); + if (this->unk_374 & 2) { + Matrix_MultVec3f(&D_80A9941C, &this->unk_3B4); + } else { + Matrix_MultVec3f(&D_80A99428, &this->unk_3B4); + } + } +} + +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4) { + EnAz* brother = this->brother; + + Actor_ChangeFocus(&this->actor, play, &brother->actor); + if (arg3 >= 0) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, arg3, &this->animIndex); + } + this->actor.textId = 0; + brother->actor.textId = textId; + brother->unk_378 = 5; + if ((arg4 >= 0) && (arg4 != brother->animIndex)) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, arg4, &brother->animIndex); + } + this->unk_378 = 0; +} + +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp) { + f32 nextFrame; + f32 prevFrame; + f32 weight; + + do { + yData++; + nextFrame = yData[0].unk_0; + } while (nextFrame < frame); + prevFrame = yData[-1].unk_0; + weight = LERPWEIGHT(frame, prevFrame, nextFrame); + *yInterp = LERPIMP(yData[-1].unk_4, yData[0].unk_4, weight) * 0.01f; +} diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.h b/src/overlays/actors/ovl_En_Az/z_en_az.h index 5c302c6f3..ffe094a93 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -7,10 +7,48 @@ struct EnAz; typedef void (*EnAzActionFunc)(struct EnAz*, PlayState*); +#define BEAVER_GET_PARAM_F00(thisx) (((thisx)->params >> 8) & 0xF) +#define BEAVER_GET_PARAM_FF(thisx) ((thisx)->params & 0xFF) + typedef struct EnAz { /* 0x000 */ Actor actor; /* 0x144 */ EnAzActionFunc actionFunc; - /* 0x148 */ char unk_148[0x290]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[24]; + /* 0x268 */ Vec3s morphTable[24]; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; // cutscene state? + /* 0x2FC */ s32 animIndex; + /* 0x300 */ ActorPathing unk_300; + /* 0x36C */ f32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk370[4]; + /* 0x374 */ u16 unk_374; // flags of some sort + /* 0x376 */ u16 unk_376; // flags of some sort + /* 0x378 */ u8 unk_378; // cutscene state? + /* 0x37A */ s16 unk_37A; + /* 0x37C */ s16 unk_37C; + /* 0x37E */ s16 unk_37E; + /* 0x380 */ s16 unk_380; + /* 0x382 */ s16 unk_382; + /* 0x384 */ s16 unk_384; + /* 0x388 */ struct EnAz* brother; + /* 0x38C */ UNK_TYPE1 unk38C[0x10]; + /* 0x39C */ s16 unk_39C; + /* 0x39E */ s16 unk_39E; // some sort of rotation + /* 0x3A0 */ UNK_TYPE1 unk3A0[4]; + /* 0x3A4 */ f32 unk_3A4; + /* 0x3A8 */ Vec3f unk_3A8; + /* 0x3B4 */ Vec3f unk_3B4; // translation + /* 0x3C0 */ s16 unk_3C0; // seems to do nothing + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ UNK_TYPE1 unk3C6[6]; + /* 0x3CC */ s32 getItemId; + /* 0x3D0 */ s16 unk_3D0[1]; + /* 0x3D2 */ u16 unk_3D2; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D6 */ s16 unk_3D6; } EnAz; // size = 0x3D8 extern const ActorInit En_Az_InitVars; 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 182db5659..5df9cee3c 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -5,6 +5,7 @@ */ #include "z_en_twig.h" +#include "objects/object_twig/object_twig.h" #define FLAGS (ACTOR_FLAG_10) @@ -12,10 +13,18 @@ void EnTwig_Init(Actor* thisx, PlayState* play); void EnTwig_Destroy(Actor* thisx, PlayState* play); -void EnTwig_Update(Actor* thisx, PlayState* play); -void EnTwig_Draw(Actor* thisx, PlayState* play); +void EnTwig_Update(Actor* this, PlayState* play); +void EnTwig_Draw(EnTwig* this, PlayState* play); + +void func_80AC0A54(EnTwig* this, PlayState* play); +void func_80AC0A6C(EnTwig* this, PlayState* play); + +void func_80AC0A7C(EnTwig* this, PlayState* play); +void func_80AC0AC8(EnTwig* this, PlayState* play); + +void func_80AC0CC4(EnTwig* this, PlayState* play); +void func_80AC0D2C(EnTwig* this, PlayState* play); -#if 0 const ActorInit En_Twig_InitVars = { ACTOR_EN_TWIG, ACTORCAT_MISC, @@ -28,36 +37,205 @@ const ActorInit En_Twig_InitVars = { (ActorFunc)EnTwig_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC10C0[] = { +static s32 sCurrentRing; +static s16 sRingCount; +static s16 sRingNotCollected[25]; + +static CollisionHeader* sColHeaders[] = { + NULL, + &object_twig_Colheader_0020A0, + &object_twig_Colheader_0016C0, +}; + +static s16 sRingsHaveSpawned = false; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +void EnTwig_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + s32 i; -extern InitChainEntry D_80AC10C0[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = RACERING_GET_PARAM_F(&this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 1); + if (sColHeaders[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); + } + this->dyna.actor.bgCheckFlags |= 0x400; + switch (this->unk_160) { + case 0: + Actor_MarkForDeath(&this->dyna.actor); + break; + case 1: + if (!sRingsHaveSpawned) { + sRingCount = (gSaveContext.save.weekEventReg[24] & 4) ? 25 : 20; + for (i = 0; i < sRingCount; i++) { + sRingNotCollected[i] = false; + } + sRingsHaveSpawned = true; + } + if (RACERING_GET_PARAM_1F0(&this->dyna.actor) != 0) { + if (!(gSaveContext.save.weekEventReg[24] & 4)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } else if (gSaveContext.save.weekEventReg[24] & 4) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + Actor_SetScale(&this->dyna.actor, 4.2f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 60.0f; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + func_80AC0A7C(this, play); + break; + case 2: + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 880.0f; + func_80AC0A54(this, play); + break; + } +} -extern UNK_TYPE D_06001C38; +void EnTwig_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Destroy.s") +void func_80AC0A54(EnTwig* this, PlayState* play) { + this->actionFunc = func_80AC0A6C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A54.s") +void func_80AC0A6C(EnTwig* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A6C.s") +void func_80AC0A7C(EnTwig* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A7C.s") + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); + this->unk_178 = 0; + this->unk_17A = 0; + this->actionFunc = func_80AC0AC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0AC8.s") +void func_80AC0AC8(EnTwig* this, PlayState* play) { + static Vec3f D_80AC10D0 = { 0.0f, 0.0f, 1.0f }; + Player* player = GET_PLAYER(play); + Plane sp4C; + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0CC4.s") + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + if (this->unk_17A == 3) { + this->unk_17A = 0; + this->dyna.actor.shape.rot.z += 0x2000; + } else { + this->unk_17A++; + } + } + SubS_ConstructPlane(&this->dyna.actor.world.pos, &D_80AC10D0, &this->dyna.actor.shape.rot, &sp4C); + if ((sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) && + Math3D_LineSegVsPlane(sp4C.normal.x, sp4C.normal.y, sp4C.normal.z, sp4C.originDist, &this->unk_180, + &player->bodyPartsPos[0], &sp40, 0)) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &sp40) <= SQ(this->dyna.actor.scale.x * 0.345f * 40.0f)) { + func_80AC0CC4(this, play); + return; + } + } else { + if (this->dyna.actor.xyzDistToPlayerSq <= SQ((this->dyna.actor.scale.x * 40.0f) + 40)) { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } + if (this->dyna.actor.xyzDistToPlayerSq >= (this->dyna.actor.scale.x * 10.0f * 40.0f * 40.0f)) { + this->dyna.actor.shape.rot.y = this->dyna.actor.yawTowardsPlayer; + this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; + } + } + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0D2C.s") +void func_80AC0CC4(EnTwig* this, PlayState* play) { + this->unk_170 = 3458.0f; + this->unk_174 = 0.2f; + this->unk_16C |= 1; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AC0D2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Update.s") +void func_80AC0D2C(EnTwig* this, PlayState* play) { + static Vec3f sKiraVel = { 0.0f, -0.05f, 0.0f }; + static Vec3f sKiraAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 sColorWhite = { 255, 255, 255, 130 }; + static Color_RGBA8 sColorYellow = { 255, 255, 0, 0 }; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Draw.s") + Math_SmoothStepToF(&this->dyna.actor.world.pos.x, player->bodyPartsPos[0].x, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, player->bodyPartsPos[0].y, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.z, player->bodyPartsPos[0].z, 0.5f, 100.0f, 0.01f); + this->dyna.actor.shape.rot.z += (s16)this->unk_170; + this->dyna.actor.scale.x -= this->unk_174; + if (this->dyna.actor.scale.x < 0.0f) { + Actor_SetScale(&this->dyna.actor, 0.0f); + } else { + Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); + } + if (this->dyna.actor.scale.x <= 0.0f) { + s32 j; + Vec3f sp6C; + + for (j = 0; j < 7; j++) { + sp6C.x = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.x; + sp6C.y = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.y; + sp6C.z = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.z; + EffectSsKirakira_SpawnDispersed(play, &sp6C, &sKiraVel, &sKiraAccel, &sColorWhite, &sColorYellow, 1000, + (s32)(Rand_ZeroOne() * 10.0f) + 20); + } + play_sound(NA_SE_SY_GET_ITEM); + play->interfaceCtx.unk_25C--; + sRingNotCollected[RACERING_GET_PARAM_FE0(&this->dyna.actor)] = true; + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + s32 i; + + for (i = 0; i < sRingCount; i++) { + if (!sRingNotCollected[i]) { + sCurrentRing = i; + break; + } + } + if (i == sRingCount) { + sCurrentRing = -1; + } + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_170 += 180.0f / 0x10000; + this->unk_174 += 0.15f; +} + +void EnTwig_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + + this->actionFunc(this, play); +} + +void EnTwig_Draw(EnTwig* thisx, PlayState* play) { + EnTwig* this = THIS; + + switch (this->unk_160) { + case 1: + Gfx_DrawDListOpa(play, object_twig_DL_001C38); + break; + case 2: + Gfx_DrawDListOpa(play, object_twig_DL_0014C8); + break; + } +} diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.h b/src/overlays/actors/ovl_En_Twig/z_en_twig.h index 2caebeb82..3de7f8f4b 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.h +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.h @@ -7,11 +7,22 @@ struct EnTwig; typedef void (*EnTwigActionFunc)(struct EnTwig*, PlayState*); +#define RACERING_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define RACERING_GET_PARAM_1F0(thisx) (((thisx)->params >> 4) & 0x1F) +#define RACERING_GET_PARAM_FE0(thisx) (((thisx)->params >> 9) & 0x7F) + typedef struct EnTwig { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ EnTwigActionFunc actionFunc; - /* 0x160 */ char unk_160[0x2C]; + /* 0x160 */ s32 unk_160; + /* 0x160 */ UNK_TYPE1 unk164[8]; + /* 0x16C */ s32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ f32 unk_174; + /* 0x178 */ s16 unk_178; + /* 0x17A */ u16 unk_17A; + /* 0x17C */ UNK_TYPE1 unk17C[4]; + /* 0x180 */ Vec3f unk_180; } EnTwig; // size = 0x18C extern const ActorInit En_Twig_InitVars; From e47dc7da25ee45b4e2805d78766e27ac8c0f6970 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:57:47 -0300 Subject: [PATCH 05/73] ovl_Oceff_Wipe3 OK (#1001) * all functions matching * ovl_Oceff_Wipe3 decompiled * bss * pr review * pr review * renamings * pr review --- assets/xml/overlays/ovl_Oceff_Wipe3.xml | 10 +++ spec | 4 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 81 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h | 2 +- 4 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe3.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe3.xml b/assets/xml/overlays/ovl_Oceff_Wipe3.xml new file mode 100644 index 000000000..d8be72985 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe3.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spec b/spec index cb56bb471..5f0500cf3 100644 --- a/spec +++ b/spec @@ -1988,9 +1988,7 @@ beginseg name "ovl_Oceff_Wipe3" compress include "build/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.data.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.bss.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3_reloc.o" endseg beginseg 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 fb1f2a45d..1b1347e8f 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -16,7 +16,6 @@ void OceffWipe3_Destroy(Actor* thisx, PlayState* play); void OceffWipe3_Update(Actor* thisx, PlayState* play); void OceffWipe3_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe3_InitVars = { ACTOR_OCEFF_WIPE3, ACTORCAT_ITEMACTION, @@ -29,12 +28,82 @@ const ActorInit Oceff_Wipe3_InitVars = { (ActorFunc)OceffWipe3_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Init.s") +s32 D_80989130; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Destroy.s") +void OceffWipe3_Init(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Draw.s") +void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; + + func_80115D5C(&play->state); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe3_Update(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe3_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffWipe3* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + vtxPtr = sSariaSongFrustumVtx; + + if (this->counter < 32) { + z = Math_SinS(this->counter * 512) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[17].v.cn[3] = vtxPtr[19].v.cn[3] = + vtxPtr[21].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 128); + gSPDisplayList(POLY_XLU_DISP++, &sSariaSongFrustrumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 12, scroll * -12, 64, 64, 1, + scroll * 8, scroll * -8, 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, &sSariaSongFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h index b9f41bb09..f29ca9278 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h @@ -7,7 +7,7 @@ struct OceffWipe3; typedef struct OceffWipe3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe3; // size = 0x148 extern const ActorInit Oceff_Wipe3_InitVars; From 33f7ede84f01eaae9d9e7560416e2f925a70e8a4 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:07:46 -0300 Subject: [PATCH 06/73] ovl_Oceff_Spot OK (#1004) * ovl_Oceff_Spot decompiled * format * renamings and pr review * pr review * pr review --- assets/xml/overlays/ovl_Oceff_Spot.xml | 7 + spec | 3 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 146 ++++++++++++++++-- .../actors/ovl_Oceff_Spot/z_oceff_spot.h | 7 +- tools/disasm/functions.txt | 6 +- 5 files changed, 146 insertions(+), 23 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Spot.xml diff --git a/assets/xml/overlays/ovl_Oceff_Spot.xml b/assets/xml/overlays/ovl_Oceff_Spot.xml new file mode 100644 index 000000000..f4e9beea7 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Spot.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spec b/spec index 5f0500cf3..1135ac921 100644 --- a/spec +++ b/spec @@ -1694,8 +1694,7 @@ beginseg name "ovl_Oceff_Spot" compress include "build/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.o" - include "build/data/ovl_Oceff_Spot/ovl_Oceff_Spot.data.o" - include "build/data/ovl_Oceff_Spot/ovl_Oceff_Spot.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Spot/ovl_Oceff_Spot_reloc.o" endseg beginseg 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 91a5d3e66..504a2815a 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -10,17 +10,17 @@ #define THIS ((OceffSpot*)thisx) -void OceffSpot_Init(Actor* thisx, PlayState* play); -void OceffSpot_Destroy(Actor* thisx, PlayState* play); +void OceffSpot_Init(Actor* thisx, PlayState* play2); +void OceffSpot_Destroy(Actor* thisx, PlayState* play2); void OceffSpot_Update(Actor* thisx, PlayState* play); void OceffSpot_Draw(Actor* thisx, PlayState* play); -void func_809728F8(OceffSpot* this, PlayState* play); -void func_80972934(OceffSpot* this, PlayState* play); +void OceffSpot_Wait(OceffSpot* this, PlayState* play); +void OceffSpot_GrowCylinder(OceffSpot* this, PlayState* play); +void OceffSpot_End(OceffSpot* this, PlayState* play); void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc); -#if 0 const ActorInit Oceff_Spot_InitVars = { ACTOR_OCEFF_SPOT, ACTORCAT_ITEMACTION, @@ -33,28 +33,140 @@ const ActorInit Oceff_Spot_InitVars = { (ActorFunc)OceffSpot_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80973478[] = { +#include "assets/overlays/ovl_Oceff_Spot/ovl_Oceff_Spot.c" + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_STOP), }; -#endif +void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80973478[]; +void OceffSpot_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + OceffSpot* this = THIS; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_SetupAction.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + OceffSpot_SetupAction(this, OceffSpot_GrowCylinder); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Init.s") + Lights_PointNoGlowSetInfo(&this->lightInfo1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->lightNode1 = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Destroy.s") + Lights_PointNoGlowSetInfo(&this->lightInfo2, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->lightNode2 = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo2); + this->actor.scale.y = 0.3f; + this->unk16C = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_80972844.s") +void OceffSpot_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + OceffSpot* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_809728F8.s") + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode1); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2); + func_80115D5C(&play->state); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_80972934.s") +void OceffSpot_End(OceffSpot* this, PlayState* play) { + if (this->unk16C > 0.0f) { + this->unk16C -= 0.05f; + } else { + Actor_MarkForDeath(&this->actor); + if ((REG(15) != 0x190) && (play->msgCtx.unk12046 == 0)) { + if ((play->msgCtx.ocarinaAction != 0x39) || (play->msgCtx.ocarinaMode != 0xA)) { + gSaveContext.sunsSongState = SUNSSONG_START; + } + } else { + play->msgCtx.ocarinaMode = 4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Update.s") +void OceffSpot_Wait(OceffSpot* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else { + OceffSpot_SetupAction(this, OceffSpot_End); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Draw.s") +void OceffSpot_GrowCylinder(OceffSpot* this, PlayState* play) { + if (this->unk16C < 1.0f) { + this->unk16C += 0.05f; + } else { + OceffSpot_SetupAction(this, OceffSpot_Wait); + this->timer = 60; + } +} + +void OceffSpot_Update(Actor* thisx, PlayState* play) { + f32 scale; + s32 pad; + Player* player = GET_PLAYER(play); + f32 temp; + OceffSpot* this = THIS; + + temp = (1.0f - cosf(this->unk16C * M_PI)) * 0.5f; + this->actionFunc(this, play); + + switch (gSaveContext.save.playerForm) { + default: + scale = 1.0f; + break; + + case PLAYER_FORM_DEKU: + scale = 1.3f; + break; + + case PLAYER_FORM_ZORA: + scale = 1.2f; + break; + + case PLAYER_FORM_GORON: + scale = 2.0f; + break; + } + + this->actor.scale.z = (scale * 0.42f) * temp; + this->actor.scale.x = (scale * 0.42f) * temp; + + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y = this->actor.world.pos.y + 5.0f; + + temp = (2.0f - this->unk16C) * this->unk16C; + + func_800FD2B4(play, temp * 0.5f, 880.0f, 0.2f, 0.9f); + + Lights_PointNoGlowSetInfo(&this->lightInfo1, this->actor.world.pos.x, this->actor.world.pos.y + 55.0f, + this->actor.world.pos.z, (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), + 100.0f * temp); + Lights_PointNoGlowSetInfo( + &this->lightInfo2, this->actor.world.pos.x + (Math_SinS(player->actor.shape.rot.y) * 20.0f), + this->actor.world.pos.y + 20.0f, this->actor.world.pos.z + (Math_CosS(player->actor.shape.rot.y) * 20.0f), + (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), 100.0f * temp); +} + +void OceffSpot_Draw(Actor* thisx, PlayState* play) { + OceffSpot* this = THIS; + u32 scroll = play->state.frames & 0xFFFF; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &sSunSongEffectCylinderMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 2, scroll * -2, 0x20, 0x20, 1, 0, + scroll * -8, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, &sSunSongEffectCylinderModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h index 922b1f89b..0a770ee9d 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h @@ -9,7 +9,12 @@ typedef void (*OceffSpotActionFunc)(struct OceffSpot*, PlayState*); typedef struct OceffSpot { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x30]; + /* 0x144 */ LightNode* lightNode1; + /* 0x148 */ LightInfo lightInfo1; + /* 0x158 */ LightNode* lightNode2; + /* 0x15C */ LightInfo lightInfo2; + /* 0x16C */ f32 unk16C; + /* 0x170 */ u16 timer; /* 0x174 */ OceffSpotActionFunc actionFunc; } OceffSpot; // size = 0x178 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 20fb6c0c2..dc205b344 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8057,9 +8057,9 @@ 0x80972680:("OceffSpot_SetupAction",), 0x8097268C:("OceffSpot_Init",), 0x809727EC:("OceffSpot_Destroy",), - 0x80972844:("func_80972844",), - 0x809728F8:("func_809728F8",), - 0x80972934:("func_80972934",), + 0x80972844:("OceffSpot_End",), + 0x809728F8:("OceffSpot_Wait",), + 0x80972934:("OceffSpot_GrowCylinder",), 0x80972998:("OceffSpot_Update",), 0x80972C54:("OceffSpot_Draw",), 0x80973550:("EnTorch_Init",), From 420403a09ae34516a63987685537700cde3cefe4 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:12:31 -0300 Subject: [PATCH 07/73] ovl_En_Encount1 OK (#1005) * 1 Non matching * all functions matching * new reloc problems * Documenting * ovl_En_Encount1 decompiled * Co-authored-by: Synray synray@users.noreply.github.com * Co-authored-by: petrie911 petrie911@users.noreply.github.com * Co-authored-by: Fig02 fig02srl@gmail.com * Co-authored-by: Maide eeeedddccc@hotmail.co.uk * Co-authored-by: EllipticEllipsis EllipticEllipsis@users.noreply.github.com * uncomment old reloc * pr review --- spec | 3 +- .../actors/ovl_En_Encount1/z_en_encount1.c | 128 +++++++++++++++++- .../actors/ovl_En_Encount1/z_en_encount1.h | 23 +++- 3 files changed, 144 insertions(+), 10 deletions(-) diff --git a/spec b/spec index 1135ac921..95d8074c9 100644 --- a/spec +++ b/spec @@ -1162,8 +1162,7 @@ beginseg name "ovl_En_Encount1" compress include "build/src/overlays/actors/ovl_En_Encount1/z_en_encount1.o" - include "build/data/ovl_En_Encount1/ovl_En_Encount1.data.o" - include "build/data/ovl_En_Encount1/ovl_En_Encount1.reloc.o" + include "build/src/overlays/actors/ovl_En_Encount1/ovl_En_Encount1_reloc.o" endseg beginseg 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 8e68f9205..0305af8ef 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -15,7 +15,6 @@ void EnEncount1_Update(Actor* thisx, PlayState* play); void func_808E0954(EnEncount1* this, PlayState* play); -#if 0 const ActorInit En_Encount1_InitVars = { ACTOR_EN_ENCOUNT1, ACTORCAT_PROP, @@ -28,10 +27,129 @@ const ActorInit En_Encount1_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sActorList[] = { + ACTOR_EN_GRASSHOPPER, + ACTOR_EN_WALLMAS, + ACTOR_EN_PR2, + ACTOR_EN_PR2, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Init.s") +static s16 sActorParams[] = { 1, 0, 1, 3 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/func_808E0954.s") +void EnEncount1_Init(Actor* thisx, PlayState* play) { + EnEncount1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Update.s") + if (this->actor.params <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actorType = ENENCOUNT1_GET_TYPE(&this->actor); + this->unk_14C = ENENCOUNT1_GET_7C0(&this->actor); + this->unk_154 = ENENCOUNT1_GET_PATH(&this->actor); + this->unk_158 = this->actor.world.rot.x; + this->unk_15C = this->actor.world.rot.y; + this->unk_160 = (this->actor.world.rot.z * 40.0f) + 120.0f; + + if (this->unk_154 >= 0x3F) { + this->unk_154 = -1; + } + if (this->actor.world.rot.z < 0) { + this->unk_160 = -1.0f; + } + if (this->actorType == EN_ENCOUNT1_SKULLFISH_2) { + this->unk_15A = ENENCOUNT1_GET_PATH(&this->actor); + this->path = SubS_GetPathByIndex(play, this->unk_15A, 0x3F); + this->unk_154 = -1; + this->unk_160 = -1.0f; + } + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_808E0954; +} + +void func_808E0954(EnEncount1* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f spawnPos; + f32 sp64; + f32 temp_fv0_2; + s16 sp5E; + s16 actorList; + s32 actorParams; + CollisionPoly* sp54; + s32 sp50; + + if (((this->unk_14E >= this->unk_14C) || ((this->unk_160 > 0.0f) && (this->unk_160 < this->actor.xzDistToPlayer)) || + ((this->unk_154 > 0) && (this->unk_154 <= this->unk_152)))) { + return; + } else if (this->unk_156 != 0) { + this->unk_156++; + if (this->unk_156 < this->unk_158) { + return; + } + } + + this->unk_156 = 0; + switch (this->actorType) { + case EN_ENCOUNT1_GRASSHOPPER: + sp64 = randPlusMinusPoint5Scaled(40.0f) + 200.0f; + sp5E = player->actor.shape.rot.y; + if (this->unk_14E & 1) { + sp5E = -sp5E; + sp64 = randPlusMinusPoint5Scaled(20.0f) + 100.0f; + } + spawnPos.x = player->actor.world.pos.x + (Math_SinS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + spawnPos.y = player->actor.floorHeight + 120.0f; + spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); + if ((temp_fv0_2 <= BGCHECK_Y_MIN) || + ((player->actor.depthInWater != BGCHECK_Y_MIN) && + (temp_fv0_2 < (player->actor.world.pos.y - player->actor.depthInWater)))) { + return; + } + spawnPos.y = temp_fv0_2; + break; + + case EN_ENCOUNT1_WALLMASTER: + Math_Vec3f_Copy(&spawnPos, &player->actor.world.pos); + break; + + case EN_ENCOUNT1_SKULLFISH: + sp64 = randPlusMinusPoint5Scaled(250.0f) + 500.0f; + sp5E = player->actor.shape.rot.y; + spawnPos.x = player->actor.world.pos.x + Math_SinS(sp5E) * sp64 + randPlusMinusPoint5Scaled(40.0f); + spawnPos.y = player->actor.world.pos.y - Rand_ZeroFloat(20.0f); + spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); + if ((!(player->stateFlags1 & 0x8000000) || (temp_fv0_2 <= (BGCHECK_Y_MIN)) || + (player->actor.depthInWater < temp_fv0_2))) { + return; + } + break; + + case EN_ENCOUNT1_SKULLFISH_2: + if ((this->path != NULL) && (!SubS_CopyPointFromPath(this->path, 0, &spawnPos))) { + Actor_MarkForDeath(&this->actor); + } + break; + } + + actorList = sActorList[this->actorType]; + actorParams = sActorParams[this->actorType]; + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorList, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, + actorParams) != NULL) { + this->unk_14E++; + if (this->unk_154 > 0) { + this->unk_152++; + } + + if ((this->unk_14E >= this->unk_14C) && (this->unk_158 != 0)) { + this->unk_156 = 1; + } + } +} + +void EnEncount1_Update(Actor* thisx, PlayState* play) { + EnEncount1* this = THIS; + + this->actionFunc(this, play); +} 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 d625f2151..8906d523e 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -3,6 +3,17 @@ #include "global.h" +#define ENENCOUNT1_GET_TYPE(thisx) (((thisx)->params >> 11) & 0x1F) +#define ENENCOUNT1_GET_7C0(thisx) (((thisx)->params >> 6) & 0x1F) +#define ENENCOUNT1_GET_PATH(thisx) ((thisx)->params & 0x3F) + +typedef enum EnEncount1Enemy { + /* 0x0 */ EN_ENCOUNT1_GRASSHOPPER, + /* 0x1 */ EN_ENCOUNT1_WALLMASTER, + /* 0x2 */ EN_ENCOUNT1_SKULLFISH, + /* 0x3 */ EN_ENCOUNT1_SKULLFISH_2, +} EnEncount1Enemy; + struct EnEncount1; typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*); @@ -10,11 +21,17 @@ typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*); typedef struct EnEncount1 { /* 0x000 */ Actor actor; /* 0x144 */ EnEncount1ActionFunc actionFunc; - /* 0x148 */ char unk_148[0x6]; + /* 0x148 */ Path* path; + /* 0x14C */ s16 unk_14C; /* 0x14E */ s16 unk_14E; - /* 0x150 */ char unk_150[0xA]; + /* 0x150 */ s16 actorType; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ s16 unk_158; /* 0x15A */ s16 unk_15A; - /* 0x15C */ char unk_15C[0x8]; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ f32 unk_160; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; From aa6841a33b0ec0fe185c4cea0a4f2463868b89ca Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:21:02 -0300 Subject: [PATCH 08/73] ovl_Oceff_Wipe2 OK (#1006) * ovl_Oceff_Wipe2 Decompiled * pr review * renamings * renamings --- assets/xml/overlays/ovl_Oceff_Wipe2.xml | 11 +++ spec | 4 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 82 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h | 2 +- 4 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe2.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe2.xml b/assets/xml/overlays/ovl_Oceff_Wipe2.xml new file mode 100644 index 000000000..c43ced3c0 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/spec b/spec index 95d8074c9..cc7babd85 100644 --- a/spec +++ b/spec @@ -1977,9 +1977,7 @@ beginseg name "ovl_Oceff_Wipe2" compress include "build/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.data.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.bss.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2_reloc.o" endseg beginseg 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 ca7ff8de2..a26636e15 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -15,7 +15,6 @@ void OceffWipe2_Destroy(Actor* thisx, PlayState* play); void OceffWipe2_Update(Actor* thisx, PlayState* play); void OceffWipe2_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe2_InitVars = { ACTOR_OCEFF_WIPE2, ACTORCAT_ITEMACTION, @@ -28,12 +27,83 @@ const ActorInit Oceff_Wipe2_InitVars = { (ActorFunc)OceffWipe2_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Init.s") +s32 D_809879D0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Destroy.s") +void OceffWipe2_Init(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->timer = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Draw.s") +void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; + + func_80115D5C(&play->state); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe2_Update(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->timer < 100) { + this->timer++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe2_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFF; + OceffWipe2* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + vtxPtr = sEponaSongFrustumVtx; + + if (this->timer < 32) { + z = Math_SinS(this->timer << 9) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->timer >= 80) { + alpha = 12 * (100 - this->timer); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[18].v.cn[3] = + vtxPtr[20].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); + gSPDisplayList(POLY_XLU_DISP++, sEponaSongFrustumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 6, scroll * -6, 64, + 64, 1, scroll * -6, 0, 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, sEponaSongFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h index 79d366525..c213dfe38 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h @@ -7,7 +7,7 @@ struct OceffWipe2; typedef struct OceffWipe2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 timer; } OceffWipe2; // size = 0x148 extern const ActorInit Oceff_Wipe2_InitVars; From 85e141128b6d2150d0729613779a394ed198509f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs?= <49660929+SailorSnoW@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:39:55 +0200 Subject: [PATCH 09/73] set LANG variable to C (#888) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïs --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index e4729002c..75ad3a54c 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,9 @@ N_THREADS ?= $(shell nproc) #### Setup #### +# Ensure the map file being created using English localization +export LANG := C + ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING CPPFLAGS := -DNON_MATCHING From 6451bcf15855ff3c0cb6cd1c0d4a9e2d03f41fae Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:49:17 -0400 Subject: [PATCH 10/73] `z_parameter`: Magic (#934) * Document magic * Cleanup * Few fixes * PR Suggestions, More Lens Docs * Few comments * missed a spot * Better macros/names * Deactivate Lens * more PR suggestions * fix names --- assets/xml/interface/parameter_static.xml | 6 +- include/functions.h | 12 +- include/macros.h | 3 + include/regs.h | 107 ++-- include/variables.h | 12 +- include/z64.h | 2 +- include/z64actor.h | 9 +- include/z64save.h | 52 +- src/code/title_setup.c | 2 +- src/code/z_actor.c | 43 +- src/code/z_elf_message.c | 2 +- src/code/z_en_item00.c | 2 +- src/code/z_kaleido_setup.c | 3 +- src/code/z_parameter.c | 494 +++++++++++++++++- src/code/z_sram_NES.c | 16 +- .../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 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 10 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 2 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 3 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 7 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 7 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 4 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 4 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 3 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 3 +- src/overlays/actors/ovl_En_Test2/z_en_test2.c | 2 +- .../ovl_Item_Etcetera/z_item_etcetera.c | 2 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 2 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 2 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 2 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 2 +- .../actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c | 2 +- tools/disasm/functions.txt | 20 +- tools/disasm/variables.txt | 12 +- tools/namefixer.py | 16 +- tools/sizes/code_functions.csv | 20 +- 41 files changed, 699 insertions(+), 203 deletions(-) diff --git a/assets/xml/interface/parameter_static.xml b/assets/xml/interface/parameter_static.xml index 33ab40de4..7532a95b8 100644 --- a/assets/xml/interface/parameter_static.xml +++ b/assets/xml/interface/parameter_static.xml @@ -75,9 +75,9 @@ - - - + + + diff --git a/include/functions.h b/include/functions.h index 65d1b8b18..fa90ff688 100644 --- a/include/functions.h +++ b/include/functions.h @@ -718,7 +718,7 @@ void func_800B9038(Actor* actor, s32 timer); void func_800B9084(Actor* actor); void func_800B9098(Actor* actor); s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); -void func_800B90F4(PlayState* play); +void Actor_DeactivateLens(PlayState* play); void func_800B9120(ActorContext* actorCtx); void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry); void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx); @@ -1855,13 +1855,9 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange); void Health_GiveHearts(s16 hearts); void Rupees_ChangeBy(s16 rupeeChange); void Inventory_ChangeAmmo(s16 item, s16 ammoChange); -void Parameter_AddMagic(PlayState* play, s16 arg1); -void func_80115D5C(GameState* gamestate); -// void func_80115DB4(void); -// void func_80116088(void); -// void func_80116114(void); -// void func_80116348(void); -// void func_80116918(void); +void Magic_Add(PlayState* play, s16 magicToAdd); +void Magic_Reset(PlayState* play); +s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type); // void func_80116FD8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_801170B8(void); // void func_80117100(void); diff --git a/include/macros.h b/include/macros.h index f713bf736..996be52ca 100644 --- a/include/macros.h +++ b/include/macros.h @@ -45,6 +45,9 @@ #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) +// To be used with `Magic_Add`, but ensures enough magic is added to fill the magic bar to capacity +#define MAGIC_FILL_TO_CAPACITY (((void)0, gSaveContext.magicFillTarget) + (gSaveContext.save.playerData.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER) + #define CONTROLLER1(gameState) (&(gameState)->input[0]) #define CONTROLLER2(gameState) (&(gameState)->input[1]) #define CONTROLLER3(gameState) (&(gameState)->input[2]) diff --git a/include/regs.h b/include/regs.h index f8ce4ca86..aa3ba523b 100644 --- a/include/regs.h +++ b/include/regs.h @@ -43,61 +43,58 @@ #define bREG(r) BASE_REG(28, r) /* TODO: Actually confirm these, in case of miss-match it's at least a simple list to `sed` */ -#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT -#define R_RUN_SPEED_LIMIT REG(45) -#define R_UPDATE_RATE SREG(30) -#define R_PAUSE_MENU_MODE SREG(94) -#define R_C_UP_ICON_X YREG(88) -#define R_C_UP_ICON_Y YREG(89) -#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) -#define R_C_BTN_COLOR(i) ZREG(39 + i) -#define R_B_BTN_COLOR(i) ZREG(43 + i) -#define R_START_LABEL_DD(i) ZREG(48 + i) -#define R_START_LABEL_Y(i) ZREG(51 + i) -#define R_START_LABEL_X(i) ZREG(54 + i) -#define R_C_UP_BTN_X ZREG(62) -#define R_C_UP_BTN_Y ZREG(63) -#define R_START_BTN_X ZREG(68) -#define R_START_BTN_Y ZREG(69) -#define R_ITEM_BTN_X(i) ZREG(70 + i) -#define R_ITEM_BTN_Y(i) ZREG(74 + i) -#define R_ITEM_BTN_DD(i) ZREG(78 + i) -#define R_ITEM_ICON_X(i) ZREG(82 + i) -#define R_ITEM_ICON_Y(i) ZREG(86 + i) -#define R_ITEM_ICON_DD(i) ZREG(90 + i) -#define R_A_BTN_Y XREG(16) -#define R_A_BTN_X XREG(17) -#define R_A_ICON_Y XREG(19) -#define R_A_ICON_X XREG(20) -#define R_A_BTN_COLOR(i) XREG(22 + i) -#define R_MAGIC_BAR_SMALL_Y XREG(48) -#define R_MAGIC_BAR_X XREG(49) -#define R_MAGIC_BAR_LARGE_Y XREG(50) -#define R_MAGIC_FILL_X XREG(51) -#define R_MINIMAP_DISABLED XREG(95) -#define R_B_LABEL_DD WREG(0) -#define R_OW_MINIMAP_X WREG(29) -#define R_OW_MINIMAP_Y WREG(30) -#define R_B_LABEL_X(i) WREG(40 + i) -#define R_B_LABEL_Y(i) WREG(43 + i) -#define R_DGN_MINIMAP_X WREG(68) -#define R_DGN_MINIMAP_Y WREG(69) -#define R_MAP_INDEX VREG(11) -#define R_MAP_TEX_INDEX_BASE VREG(12) -#define R_MAP_TEX_INDEX VREG(13) -#define R_COMPASS_SCALE_X VREG(14) -#define R_COMPASS_SCALE_Y VREG(15) -#define R_COMPASS_OFFSET_X VREG(16) -#define R_COMPASS_OFFSET_Y VREG(17) -#define R_MINIMAP_COLOR(i) VREG(18 + i) -#define R_ITEM_AMMO_X(i) VREG(64 + i) -#define R_ITEM_AMMO_Y(i) VREG(68 + i) -#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) -#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) +#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT +#define R_RUN_SPEED_LIMIT REG(45) +#define R_UPDATE_RATE SREG(30) +#define R_PAUSE_MENU_MODE SREG(94) +#define R_C_UP_ICON_X YREG(88) +#define R_C_UP_ICON_Y YREG(89) +#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) +#define R_C_BTN_COLOR(i) ZREG(39 + i) +#define R_B_BTN_COLOR(i) ZREG(43 + i) +#define R_START_LABEL_DD(i) ZREG(48 + i) +#define R_START_LABEL_Y(i) ZREG(51 + i) +#define R_START_LABEL_X(i) ZREG(54 + i) +#define R_C_UP_BTN_X ZREG(62) +#define R_C_UP_BTN_Y ZREG(63) +#define R_START_BTN_X ZREG(68) +#define R_START_BTN_Y ZREG(69) +#define R_ITEM_BTN_X(i) ZREG(70 + i) +#define R_ITEM_BTN_Y(i) ZREG(74 + i) +#define R_ITEM_BTN_DD(i) ZREG(78 + i) +#define R_ITEM_ICON_X(i) ZREG(82 + i) +#define R_ITEM_ICON_Y(i) ZREG(86 + i) +#define R_ITEM_ICON_DD(i) ZREG(90 + i) +#define R_A_BTN_Y XREG(16) +#define R_A_BTN_X XREG(17) +#define R_A_ICON_Y XREG(19) +#define R_A_ICON_X XREG(20) +#define R_A_BTN_COLOR(i) XREG(22 + i) +#define R_MAGIC_CONSUME_TIMER_GIANTS_MASK XREG(41) +#define R_MINIMAP_DISABLED XREG(95) +#define R_B_LABEL_DD WREG(0) +#define R_OW_MINIMAP_X WREG(29) +#define R_OW_MINIMAP_Y WREG(30) +#define R_B_LABEL_X(i) WREG(40 + i) +#define R_B_LABEL_Y(i) WREG(43 + i) +#define R_DGN_MINIMAP_X WREG(68) +#define R_DGN_MINIMAP_Y WREG(69) +#define R_MAP_INDEX VREG(11) +#define R_MAP_TEX_INDEX_BASE VREG(12) +#define R_MAP_TEX_INDEX VREG(13) +#define R_COMPASS_SCALE_X VREG(14) +#define R_COMPASS_SCALE_Y VREG(15) +#define R_COMPASS_OFFSET_X VREG(16) +#define R_COMPASS_OFFSET_Y VREG(17) +#define R_MINIMAP_COLOR(i) VREG(18 + i) +#define R_ITEM_AMMO_X(i) VREG(64 + i) +#define R_ITEM_AMMO_Y(i) VREG(68 + i) +#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) +#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) -#define R_FB_FILTER_TYPE SREG(80) -#define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) -#define R_FB_FILTER_A SREG(84) -#define R_FB_FILTER_ENV_COLOR(c) SREG(85 + c) +#define R_FB_FILTER_TYPE SREG(80) +#define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) +#define R_FB_FILTER_A SREG(84) +#define R_FB_FILTER_ENV_COLOR(c) SREG(85 + c) #endif diff --git a/include/variables.h b/include/variables.h index e39b4adfb..36ad5440a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1028,11 +1028,11 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE2 D_801BF890; // extern UNK_TYPE2 D_801BF898; // extern UNK_TYPE2 D_801BF89C; -// extern UNK_TYPE2 D_801BF8A0; -// extern UNK_TYPE2 D_801BF8A4; -// extern UNK_TYPE2 D_801BF8A8; -// extern UNK_TYPE2 D_801BF8AC; -// extern UNK_TYPE2 D_801BF8B0; +// extern UNK_TYPE2 sMagicMeterOutlinePrimRed; +// extern UNK_TYPE2 sMagicMeterOutlinePrimGreen; +// extern UNK_TYPE2 sMagicMeterOutlinePrimBlue; +// extern UNK_TYPE2 sMagicBorderRatio; +// extern UNK_TYPE2 sMagicBorderStep; // extern UNK_TYPE2 D_801BF8DC; // extern UNK_TYPE2 D_801BF8E0; // extern UNK_TYPE2 D_801BF8E4; @@ -2719,7 +2719,7 @@ extern f32 D_801DE860; extern f32 D_801DE864; extern f32 D_801DE868; extern f32 D_801DE884; -extern TexturePtr D_801DE890[]; +extern TexturePtr gCircleTex; extern f32 D_801DF090; extern f32 D_801DF094; extern f32 D_801DF0A0; diff --git a/include/z64.h b/include/z64.h index ec51a3a8c..cf4643d53 100644 --- a/include/z64.h +++ b/include/z64.h @@ -523,7 +523,7 @@ typedef struct { /* 0x252 */ s16 lifeSizeChange; /* 0x254 */ s16 lifeSizeChangeDirection; // 1 means shrinking, 0 growing /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; + /* 0x258 */ s16 magicConsumptionTimer; // For certain magic states, 1 unit of magic is consumed every time the timer reaches 0 /* 0x25A */ u8 numHorseBoosts; /* 0x25C */ u16 unk_25C; /* 0x25E */ u16 unk_25E; diff --git a/include/z64actor.h b/include/z64actor.h index bbf0a5534..4c3539901 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -365,15 +365,18 @@ typedef struct ActorListEntry { /* 0x8 */ s32 unk_08; } ActorListEntry; // size = 0xC +// Target size when activated +#define LENS_MASK_ACTIVE_SIZE 100 + typedef struct ActorContext { /* 0x000 */ u8 freezeFlashTimer; /* 0x001 */ UNK_TYPE1 pad1; /* 0x002 */ u8 unk2; - /* 0x003 */ u8 unk3; - /* 0x004 */ s8 unk4; + /* 0x003 */ u8 lensActive; + /* 0x004 */ s8 lensMaskSize; // The size of the circle when drawn the lens mask. Larger value leads to a smaller circle /* 0x005 */ u8 unk5; /* 0x006 */ UNK_TYPE1 pad6[0x5]; - /* 0x00B */ s8 unkB; + /* 0x00B */ s8 lensActorsDrawn; /* 0x00C */ s16 unkC; /* 0x00E */ u8 totalLoadedActors; /* 0x00F */ u8 undrawnActorCount; diff --git a/include/z64save.h b/include/z64save.h index 6b77e2968..1ff39ec92 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -24,6 +24,36 @@ typedef enum RespawnMode { #define SAVE_BUFFER_SIZE 0x4000 +typedef enum { + /* 0 */ MAGIC_STATE_IDLE, // Regular gameplay + /* 1 */ MAGIC_STATE_CONSUME_SETUP, // Sets the speed at which the magic border flashes + /* 2 */ MAGIC_STATE_CONSUME, // Consume magic until target is reached or no more magic is available + /* 3 */ MAGIC_STATE_METER_FLASH_1, // Flashes border + /* 4 */ MAGIC_STATE_METER_FLASH_2, // Flashes border and draws yellow magic to preview target consumption + /* 5 */ MAGIC_STATE_RESET, // Reset colors and return to idle + /* 6 */ MAGIC_STATE_METER_FLASH_3, // Flashes border with no additional behaviour + /* 7 */ MAGIC_STATE_CONSUME_LENS, // Magic slowly consumed by Lens of Truth + /* 8 */ MAGIC_STATE_STEP_CAPACITY, // Step `magicCapacity` to full capacity + /* 9 */ MAGIC_STATE_FILL, // Add magic until magicFillTarget is reached + /* 10 */ MAGIC_STATE_CONSUME_GORON_ZORA_SETUP, + /* 11 */ MAGIC_STATE_CONSUME_GORON_ZORA, // Magic slowly consumed by Goron spiked rolling or Zora electric barrier. + /* 12 */ MAGIC_STATE_CONSUME_GIANTS_MASK // Magic slowly consumed by Giant's Mask +} MagicState; + +typedef enum { + /* 0 */ MAGIC_CONSUME_NOW, // Consume magic immediately without preview + /* 1 */ MAGIC_CONSUME_WAIT_NO_PREVIEW, // Sets consume target but waits to consume. No yellow magic preview to target consumption. Unused + /* 2 */ MAGIC_CONSUME_NOW_ALT, // Identical behaviour to MAGIC_CONSUME_NOW. Unused + /* 3 */ MAGIC_CONSUME_LENS, // Lens of Truth consumption + /* 4 */ MAGIC_CONSUME_WAIT_PREVIEW, // Sets consume target but waits to consume. Show magic to be consumed in yellow. + /* 5 */ MAGIC_CONSUME_GORON_ZORA, // Goron spiked rolling or Zora electric barrier slow consumption + /* 6 */ MAGIC_CONSUME_GIANTS_MASK, // Giant's Mask slow consumption + /* 7 */ MAGIC_CONSUME_DEITY_BEAM // Fierce Deity Beam consumption, consumed magic now and not via request +} MagicChangeType; + +#define MAGIC_NORMAL_METER 0x30 +#define MAGIC_DOUBLE_METER (2 * MAGIC_NORMAL_METER) + typedef struct SramContext { /* 0x00 */ u8* readBuff; /* 0x04 */ u8 *saveBuf; @@ -105,13 +135,13 @@ typedef struct SavePlayerData { /* 0x08 */ char playerName[8]; // "player_name" /* 0x10 */ s16 healthCapacity; // "max_life" /* 0x12 */ s16 health; // "now_life" - /* 0x14 */ s8 magicLevel; // "magic_max" - /* 0x15 */ s8 magic; // "magic_now" + /* 0x14 */ s8 magicLevel; // 0 for no magic/new load, 1 for magic, 2 for double magic "magic_max" + /* 0x15 */ s8 magic; // current magic available for use "magic_now" /* 0x16 */ s16 rupees; // "lupy_count" /* 0x18 */ u16 swordHealth; // "long_sword_hp" /* 0x1A */ u16 tatlTimer; // "navi_timer" - /* 0x1C */ u8 magicAcquired; // "magic_mode" - /* 0x1D */ u8 doubleMagic; // "magic_ability" + /* 0x1C */ u8 isMagicAcquired; // "magic_mode" + /* 0x1D */ u8 isDoubleMagicAcquired; // "magic_ability" /* 0x1E */ u8 doubleDefense; // "life_ability" /* 0x1F */ u8 unk_1F; // "ocarina_round" /* 0x20 */ u8 unk_20; // "first_memory" @@ -226,13 +256,13 @@ typedef struct SaveContext { /* 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" + /* 0x3F28 */ s16 magicState; // determines magic meter behavior on each frame "magic_flag" + /* 0x3F2A */ s16 isMagicRequested; // a request to add magic has been given "recovery_magic_flag" + /* 0x3F2C */ s16 magicFlag; // Set to 0 in func_80812D94(), otherwise unused "keep_magic_flag" + /* 0x3F2E */ s16 magicCapacity; // maximum magic available "magic_now_max" + /* 0x3F30 */ s16 magicFillTarget; // target used to fill magic "magic_now_now" + /* 0x3F32 */ s16 magicToConsume; // accumulated magic that is requested to be consumed "magic_used" + /* 0x3F34 */ s16 magicToAdd; // accumulated magic that is requested to be added "magic_recovery" /* 0x3F36 */ u16 mapIndex; // "scene_ID" /* 0x3F38 */ u16 minigameState; // "yabusame_mode" /* 0x3F3A */ u16 minigameScore; // "yabusame_total" diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 69790b60c..4be91d2e8 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -8,7 +8,7 @@ void TitleSetup_GameStateResetContext(void) { XREG(12) = 0xE; XREG(13) = 0; XREG(31) = 0; - XREG(41) = 0x50; + R_MAGIC_CONSUME_TIMER_GIANTS_MASK = 80; XREG(43) = 0xFC54; XREG(44) = 0xD7; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index da2b70292..1b2d02b66 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2212,10 +2212,10 @@ s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 bgI return false; } -void func_800B90F4(PlayState* play) { - if (play->actorCtx.unk3 != 0) { - play->actorCtx.unk3 = 0; - func_80115D5C(&play->state); +void Actor_DeactivateLens(PlayState* play) { + if (play->actorCtx.lensActive) { + play->actorCtx.lensActive = false; + Magic_Reset(play); } } @@ -2594,7 +2594,7 @@ void func_800B9D1C(Actor* actor) { void Actor_DrawAllSetup(PlayState* play) { play->actorCtx.undrawnActorCount = 0; - play->actorCtx.unkB = 0; + play->actorCtx.lensActorsDrawn = false; } s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) { @@ -2607,13 +2607,12 @@ s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) { return true; } -void func_800B9E84(Gfx** arg0, s32 arg1) { - func_80164C14(arg0, D_801DE890, 4, 0, 6, 6, ((100 - arg1) * 0.003f) + 1.0f); +void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) { + func_80164C14(gfxP, &gCircleTex, 4, 0, 6, 6, ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); } #ifdef NON_EQUIVALENT -// Related to draw actors with lens -void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) { +void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors) { s32 spB4; Gfx* spAC; void* spA8; // pad @@ -2684,7 +2683,7 @@ void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) { } // spAC = phi_s1; - func_800B9E84(&spAC, play->actorCtx.unk4); + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); phi_s1_2 = func_801660B8(play, spAC); for (spB4 = 0; spB4 < numActors; spB4++, actors++) { @@ -2744,7 +2743,7 @@ void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) { spAC = phi_s1_2; // spAC = temp_s1_11; - func_800B9E84(&spAC, (s32)play->actorCtx.unk4); + Actor_DrawLensOverlay(&spAC, (s32)play->actorCtx.lensMaskSize); // temp_s1_11->words.w0 = 0xE7000000; // temp_s1_11->words.w1 = 0; // temp_s1_12 = temp_s1_11 + 8; @@ -2796,15 +2795,15 @@ void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) { // spAC = temp_s1_18 + 8; gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); - func_800B9E84(&spAC, (s32)play->actorCtx.unk4); + Actor_DrawLensOverlay(&spAC, (s32)play->actorCtx.lensMaskSize); OVERLAY_DISP = spAC; CLOSE_DISPS(play->state.gfxCtx); } #else -void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s") +void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawLensActors.s") #endif s32 func_800BA2D8(PlayState* play, Actor* actor) { @@ -2883,7 +2882,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { actor->isDrawn = false; if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { if ((actor->flags & ACTOR_FLAG_80) && - ((play->roomCtx.currRoom.unk5 == 0) || (play->actorCtx.unk4 == 0x64) || + ((play->roomCtx.currRoom.unk5 == 0) || (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || (actor->room != play->roomCtx.currRoom.num))) { if (Actor_RecordUndrawnActor(play, actor)) {} } else { @@ -2903,17 +2902,17 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { gSPDisplayList(sp58, &ref2[1]); POLY_XLU_DISP = &ref2[1]; - if (play->actorCtx.unk3 != 0) { - Math_StepToC(&play->actorCtx.unk4, 100, 20); + if (play->actorCtx.lensActive) { + Math_StepToC(&play->actorCtx.lensMaskSize, LENS_MASK_ACTIVE_SIZE, 20); if (GET_PLAYER(play)->stateFlags2 & 0x8000000) { - func_800B90F4(play); + Actor_DeactivateLens(play); } } else { - Math_StepToC(&play->actorCtx.unk4, 0, 10); + Math_StepToC(&play->actorCtx.lensMaskSize, 0, 10); } - if (play->actorCtx.unk4 != 0) { - play->actorCtx.unkB = 1; - func_800B9EF4(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors); + if (play->actorCtx.lensMaskSize != 0) { + play->actorCtx.lensActorsDrawn = true; + Actor_DrawLensActors(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors); } tmp2 = POLY_XLU_DISP; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 57e84e86b..25d6f8ca8 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -25,7 +25,7 @@ u16 ElfMessage_GetFirstCycleHint(PlayState* play) { } return 0x21D; } - if (gSaveContext.save.playerData.magicAcquired != true) { + if (gSaveContext.save.playerData.isMagicAcquired != true) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 0637f6392..953648f49 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -500,7 +500,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { } } - if (play->gameOverCtx.state != 0) { + if (play->gameOverCtx.state != GAMEOVER_INACTIVE) { return; } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 625adf20f..fa490dbca 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -75,7 +75,8 @@ void KaleidoSetup_Update(PlayState* play) { if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { - if ((play->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && + (gSaveContext.magicState != MAGIC_STATE_FILL)) { if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { if (!(play->actorCtx.unk5 & 2) && !(play->actorCtx.unk5 & 4)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index b63af9038..403a69c51 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -139,11 +139,11 @@ u16 sMinigameScoreDigits[] = { 0, 0, 0, 0 }; u16 sCUpInvisible = 0; u16 sCUpTimer = 0; -s16 sMagicBarOutlinePrimRed = 255; -s16 sMagicBarOutlinePrimGreen = 255; -s16 sMagicBarOutlinePrimBlue = 255; -s16 D_801BF8AC = 2; // sMagicBorderRatio -s16 D_801BF8B0 = 1; +s16 sMagicMeterOutlinePrimRed = 255; +s16 sMagicMeterOutlinePrimGreen = 255; +s16 sMagicMeterOutlinePrimBlue = 255; +s16 sMagicBorderRatio = 2; +s16 sMagicBorderStep = 1; s16 sExtraItemBases[] = { ITEM_STICK, // ITEM_STICKS_5 @@ -225,10 +225,14 @@ s16 sFinalHoursClockColorTargetIndex = 0; #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CD98.s") +Gfx* func_8010CFBC(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, + s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, s16 a); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CFBC.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D2D4.s") +Gfx* func_8010D480(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, + s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, s16 a, s32 argE, s32 argF); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D480.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D7D0.s") @@ -600,7 +604,7 @@ u8 Item_Give(PlayState* play, u8 item) { return item; } else if (item == ITEM_MAGIC_SMALL) { - Parameter_AddMagic(play, 0x18); + Magic_Add(play, MAGIC_NORMAL_METER / 2); if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { gSaveContext.save.weekEventReg[12] |= 0x80; return ITEM_NONE; @@ -608,7 +612,7 @@ u8 Item_Give(PlayState* play, u8 item) { return item; } else if (item == ITEM_MAGIC_LARGE) { - Parameter_AddMagic(play, 0x30); + Magic_Add(play, MAGIC_NORMAL_METER); if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { gSaveContext.save.weekEventReg[12] |= 0x80; return ITEM_NONE; @@ -1145,26 +1149,482 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Parameter_AddMagic.s") +void Magic_Add(PlayState* play, s16 magicToAdd) { + if (((void)0, gSaveContext.save.playerData.magic) < ((void)0, gSaveContext.magicCapacity)) { + gSaveContext.magicToAdd += magicToAdd; + gSaveContext.isMagicRequested = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115D5C.s") +void Magic_Reset(PlayState* play) { + if ((gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + gSaveContext.magicState = MAGIC_STATE_IDLE; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115DB4.s") +/** + * Request to consume magic. + * + * @param magicToConsume the positive-valued amount to decrease magic by + * @param type how the magic is consumed. + * @return false if the request failed + */ +s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116088.s") + // Magic is not acquired yet + if (!gSaveContext.save.playerData.isMagicAcquired) { + return false; + } -s16 magicBorderColors[][3] = { + // Not enough magic available to consume + if ((gSaveContext.save.playerData.magic - magicToConsume) < 0) { + if (gSaveContext.magicCapacity != 0) { + play_sound(NA_SE_SY_ERROR); + } + return false; + } + + switch (type) { + case MAGIC_CONSUME_NOW: + case MAGIC_CONSUME_NOW_ALT: + // Drain magic immediately e.g. Deku Bubble + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (gSaveContext.save.weekEventReg[14] & 8) { + // Drank Chateau Romani + magicToConsume = 0; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_WAIT_NO_PREVIEW: + // Sets consume target but waits to consume. + // No yellow magic to preview target consumption. + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (gSaveContext.save.weekEventReg[14] & 8) { + // Drank Chateau Romani + magicToConsume = 0; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_3; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_LENS: + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = 80; + gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; + return true; + } else { + return false; + } + } else if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + return true; + } else { + return false; + } + + case MAGIC_CONSUME_WAIT_PREVIEW: + // Sets consume target but waits to consume. + // Preview consumption with a yellow bar. e.g. Spin Attack + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_2; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_GORON_ZORA: + // Goron spiked rolling or Zora electric barrier + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = 10; + gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA_SETUP; + return true; + } else { + return false; + } + + case MAGIC_CONSUME_GIANTS_MASK: + // Wearing Giant's Mask + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; + gSaveContext.magicState = MAGIC_STATE_CONSUME_GIANTS_MASK; + return true; + } else { + return false; + } + } + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_GIANTS_MASK) { + return true; + } else { + return false; + } + + case MAGIC_CONSUME_DEITY_BEAM: + // Consumes magic immediately + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (gSaveContext.save.weekEventReg[14] & 8) { + // Drank Chateau Romani + magicToConsume = 0; + } + gSaveContext.save.playerData.magic -= magicToConsume; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + } + + return false; +} + +void Magic_UpdateAddRequest(void) { + if (gSaveContext.isMagicRequested) { + gSaveContext.save.playerData.magic += 4; + play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); + + if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicCapacity)) { + gSaveContext.save.playerData.magic = gSaveContext.magicCapacity; + gSaveContext.magicToAdd = 0; + gSaveContext.isMagicRequested = false; + } else { + gSaveContext.magicToAdd -= 4; + if (gSaveContext.magicToAdd <= 0) { + gSaveContext.magicToAdd = 0; + gSaveContext.isMagicRequested = false; + } + } + } +} + +s16 sMagicBorderColors[][3] = { { 255, 255, 255 }, { 150, 150, 150 }, }; -s16 magicBorderIndices[] = { 0, 1, 1, 0 }; -s16 magicBorderColorTimerIndex[] = { 2, 1, 2, 1 }; +s16 sMagicBorderIndices[] = { 0, 1, 1, 0 }; +s16 sMagicBorderColorTimerIndex[] = { 2, 1, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116114.s") +void Magic_FlashMeterBorder(void) { + s16 borderChangeR; + s16 borderChangeG; + s16 borderChangeB; + s16 index = sMagicBorderIndices[sMagicBorderStep]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116348.s") + borderChangeR = ABS_ALT(sMagicMeterOutlinePrimRed - sMagicBorderColors[index][0]) / sMagicBorderRatio; + borderChangeG = ABS_ALT(sMagicMeterOutlinePrimGreen - sMagicBorderColors[index][1]) / sMagicBorderRatio; + borderChangeB = ABS_ALT(sMagicMeterOutlinePrimBlue - sMagicBorderColors[index][2]) / sMagicBorderRatio; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116918.s") + if (sMagicMeterOutlinePrimRed >= sMagicBorderColors[index][0]) { + sMagicMeterOutlinePrimRed -= borderChangeR; + } else { + sMagicMeterOutlinePrimRed += borderChangeR; + } + + if (sMagicMeterOutlinePrimGreen >= sMagicBorderColors[index][1]) { + sMagicMeterOutlinePrimGreen -= borderChangeG; + } else { + sMagicMeterOutlinePrimGreen += borderChangeG; + } + + if (sMagicMeterOutlinePrimBlue >= sMagicBorderColors[index][2]) { + sMagicMeterOutlinePrimBlue -= borderChangeB; + } else { + sMagicMeterOutlinePrimBlue += borderChangeB; + } + + sMagicBorderRatio--; + if (sMagicBorderRatio == 0) { + sMagicMeterOutlinePrimRed = sMagicBorderColors[index][0]; + sMagicMeterOutlinePrimGreen = sMagicBorderColors[index][1]; + sMagicMeterOutlinePrimBlue = sMagicBorderColors[index][2]; + + sMagicBorderRatio = sMagicBorderColorTimerIndex[sMagicBorderStep]; + + sMagicBorderStep++; + if (sMagicBorderStep >= 4) { + sMagicBorderStep = 0; + } + } +} + +void Magic_Update(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 magicCapacityTarget; + + if (gSaveContext.save.weekEventReg[14] & 8) { + // Drank Chateau Romani + Magic_FlashMeterBorder(); + } + + switch (gSaveContext.magicState) { + case MAGIC_STATE_STEP_CAPACITY: + // Step magicCapacity to the capacity determined by magicLevel + // This changes the width of the magic meter drawn + magicCapacityTarget = gSaveContext.save.playerData.magicLevel * MAGIC_NORMAL_METER; + if (gSaveContext.magicCapacity != magicCapacityTarget) { + if (gSaveContext.magicCapacity < magicCapacityTarget) { + gSaveContext.magicCapacity += 0x10; + if (gSaveContext.magicCapacity > magicCapacityTarget) { + gSaveContext.magicCapacity = magicCapacityTarget; + } + } else { + gSaveContext.magicCapacity -= 0x10; + if (gSaveContext.magicCapacity <= magicCapacityTarget) { + gSaveContext.magicCapacity = magicCapacityTarget; + } + } + } else { + // Once the capacity has reached its target, + // follow up by filling magic to magicFillTarget + gSaveContext.magicState = MAGIC_STATE_FILL; + } + break; + + case MAGIC_STATE_FILL: + // Add magic until magicFillTarget is reached + gSaveContext.save.playerData.magic += 0x10; + + if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneSetupIndex < 4)) { + play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); + } + + if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicFillTarget)) { + gSaveContext.save.playerData.magic = gSaveContext.magicFillTarget; + gSaveContext.magicState = MAGIC_STATE_IDLE; + } + break; + + case MAGIC_STATE_CONSUME_SETUP: + // Sets the speed at which magic border flashes + sMagicBorderRatio = 2; + gSaveContext.magicState = MAGIC_STATE_CONSUME; + break; + + case MAGIC_STATE_CONSUME: + // Consume magic until target is reached or no more magic is available + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + gSaveContext.save.playerData.magic = + ((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume); + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + } + // fallthrough (flash border while magic is being consumed) + case MAGIC_STATE_METER_FLASH_1: + case MAGIC_STATE_METER_FLASH_2: + case MAGIC_STATE_METER_FLASH_3: + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_RESET: + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + gSaveContext.magicState = MAGIC_STATE_IDLE; + break; + + case MAGIC_STATE_CONSUME_LENS: + // Slowly consume magic while Lens of Truth is active + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) { + + if ((gSaveContext.save.playerData.magic == 0) || + ((func_801242DC(play) >= 2) && (func_801242DC(play) <= 4)) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) != ITEM_LENS) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) != ITEM_LENS) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) != ITEM_LENS)) || + !play->actorCtx.lensActive) { + // Deactivate Lens of Truth and set magic state to idle + play->actorCtx.lensActive = false; + play_sound(NA_SE_SY_GLASSMODE_OFF); + gSaveContext.magicState = MAGIC_STATE_IDLE; + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + break; + } + + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + gSaveContext.save.playerData.magic--; + } + interfaceCtx->magicConsumptionTimer = 80; + } + } + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_CONSUME_GORON_ZORA_SETUP: + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + gSaveContext.save.playerData.magic -= 2; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA; + // fallthrough + case MAGIC_STATE_CONSUME_GORON_ZORA: + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == 0) && (msgCtx->msgMode == 0) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF)) { + if (!Play_InCsMode(play)) { + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + gSaveContext.save.playerData.magic--; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + interfaceCtx->magicConsumptionTimer = 10; + } + } + } + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_CONSUME_GIANTS_MASK: + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + if (!Play_InCsMode(play)) { + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + gSaveContext.save.playerData.magic--; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; + } + } + } + if (!(gSaveContext.save.weekEventReg[14] & 8)) { + Magic_FlashMeterBorder(); + } + break; + + default: + gSaveContext.magicState = MAGIC_STATE_IDLE; + break; + } +} + +void Magic_DrawMeter(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 magicBarY; + + OPEN_DISPS(play->state.gfxCtx); + + if (gSaveContext.save.playerData.magicLevel != 0) { + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + magicBarY = 42; // two rows of hearts + } else { + magicBarY = 34; // one row of hearts + } + + func_8012C654(play->state.gfxCtx); + + gDPSetEnvColor(OVERLAY_DISP++, 100, 50, 50, 255); + + OVERLAY_DISP = func_8010CFBC(OVERLAY_DISP, gMagicMeterEndTex, 8, 16, 18, magicBarY, 8, 16, 1 << 10, 1 << 10, + sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, sMagicMeterOutlinePrimBlue, + interfaceCtx->magicAlpha); + OVERLAY_DISP = + func_8010CFBC(OVERLAY_DISP, gMagicMeterMidTex, 24, 16, 26, magicBarY, ((void)0, gSaveContext.magicCapacity), + 16, 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, + sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha); + OVERLAY_DISP = + func_8010D480(OVERLAY_DISP, gMagicMeterEndTex, 8, 16, ((void)0, gSaveContext.magicCapacity) + 26, magicBarY, + 8, 16, 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, + sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha, 3, 0x100); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + + if (gSaveContext.magicState == MAGIC_STATE_METER_FLASH_2) { + // Yellow part of the meter indicating the amount of magic to be subtracted + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 250, 250, 0, interfaceCtx->magicAlpha); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 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); + gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + // Fill the rest of the meter with the normal magic color + gDPPipeSync(OVERLAY_DISP++); + if (gSaveContext.save.weekEventReg[14] & 8) { + // Blue magic (drank Chateau Romani) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); + } else { + // Green magic (default) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); + } + + gSPTextureRectangle( + OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + ((((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + 26) << 2, + (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } else { + // Fill the whole meter with the normal magic color + if (gSaveContext.save.weekEventReg[14] & 8) { + // Blue magic (drank Chateau Romani) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); + } else { + // Green magic (default) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); + } + + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 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); + gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116FD8.s") diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5f92d13e5..7b8b67443 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -597,12 +597,12 @@ SavePlayerData sSaveDefaultPlayerData = { 0x30, // healthCapacity 0x30, // health 0, // magicLevel - 0x30, // magic + MAGIC_NORMAL_METER, // magic 0, // rupees 0, // swordHealth 0, // tatlTimer - 0, // magicAcquired - 0, // doubleMagic + false, // isMagicAcquired + false, // isDoubleMagicAcquired 0, // doubleDefense 0, // unk_1F 0xFF, // unk_20 @@ -697,12 +697,12 @@ SavePlayerData sSaveDebugPlayerData = { 0x80, // healthCapacity 0x80, // health 0, // magicLevel - 0x30, // magic - 0x32, // rupees - 0x64, // swordHealth + MAGIC_NORMAL_METER, // magic + 50, // rupees + 100, // swordHealth 0, // tatlTimer - 1, // magicAcquired - 0, // doubleMagic + true, // isMagicAcquired + false, // isDoubleMagicAcquired 0, // doubleDefense 0, // unk_1F 0xFF, // unk_20 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 16e4832a8..9cf65349f 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -81,7 +81,7 @@ void ArrowFire_Init(Actor* thisx, PlayState* play) { void ArrowFire_Destroy(Actor* thisx, PlayState* play) { ArrowFire* this = THIS; - func_80115D5C(&play->state); + Magic_Reset(play); Collider_DestroyQuad(play, &this->collider1); Collider_DestroyQuad(play, &this->collider2); } 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 7c4f1f969..88eddb39e 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -57,7 +57,7 @@ void ArrowIce_Init(Actor* thisx, PlayState* play) { } void ArrowIce_Destroy(Actor* thisx, PlayState* play) { - func_80115D5C(&play->state); + Magic_Reset(play); (void)"消滅"; // Unreferenced in retail, means "Disappearance" } 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 1a7503e54..9f974472f 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -56,7 +56,7 @@ void ArrowLight_Init(Actor* thisx, PlayState* play) { } void ArrowLight_Destroy(Actor* thisx, PlayState* play) { - func_80115D5C(&play->state); + Magic_Reset(play); (void)"消滅"; // Unreferenced in retail, means "Disappearance" } 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 3ed675c5f..d1fb0a3bd 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -571,7 +571,7 @@ void Boss02_Init(Actor* thisx, PlayState* play) { } else { this->unk_1D20 = 1; } - XREG(41) = KREG(14) + 20; + R_MAGIC_CONSUME_TIMER_GIANTS_MASK = KREG(14) + 20; this->unk_01AC = 1.0f; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON5, 0.0f, 1000.0f, 0.0f, 0, 0, 0, 0); } else if (this->actor.params == TWINMOLD_TAIL) { 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 46d42a817..4ca78d239 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -139,7 +139,7 @@ void EnArrow_Destroy(Actor* thisx, PlayState* play) { } if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { - func_80115D5C(&play->state); + Magic_Reset(play); } } @@ -162,13 +162,13 @@ void func_8088A594(EnArrow* this, PlayState* play) { this->bubble.unk_148++; if (this->bubble.unk_148 > 20) { this->actionFunc = func_8088ACE0; - func_80115D5C(&play->state); + Magic_Reset(play); } } } else { if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { if (this->actor.params == ENARROW_7) { - func_80115D5C(&play->state); + Magic_Reset(play); } Actor_MarkForDeath(&this->actor); return; @@ -202,7 +202,7 @@ void func_8088A594(EnArrow* this, PlayState* play) { this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); func_8088A514(this); this->unk_260 = 99; - func_80115D5C(&play->state); + Magic_Reset(play); } 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); @@ -310,7 +310,7 @@ void func_8088AA98(EnArrow* this, PlayState* play) { return; } - func_80115D5C(&play->state); + Magic_Reset(play); } } } 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 4f8d5eaaa..31e326409 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -639,7 +639,7 @@ void func_80B3F78C(EnDai* this, PlayState* play) { }; s32 pad; - if (play->actorCtx.unkB != 0) { + if (play->actorCtx.lensActorsDrawn) { this->unk_1CE |= 0x40; } else { Actor_RecordUndrawnActor(play, &this->actor); 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 0d28281ef..3b4ab74ae 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -201,7 +201,7 @@ void func_80A5063C(EnDnb* this, PlayState* play) { void EnDnb_Draw(Actor* thisx, PlayState* play) { EnDnb* this = THIS; - if (play->actorCtx.unk4 != 0) { + if (play->actorCtx.lensMaskSize != 0) { func_80A50510(this, play); } else { func_80A5063C(this, play); 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 bc84c329b..798311c77 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -675,8 +675,7 @@ void func_8088DD34(EnElf* this, PlayState* play) { !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { Health_ChangeBy(play, 0x80); if (this->fairyFlags & 0x200) { - Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + - (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; 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 ba8cb4f01..61457bf50 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -99,7 +99,7 @@ void EnElfgrp_Init(Actor* thisx, PlayState* play) { break; case ENELFGRP_2: - if (gSaveContext.save.playerData.doubleMagic == true) { + if (gSaveContext.save.playerData.isDoubleMagicAcquired == true) { func_80A396B0(this, 1); } break; @@ -156,7 +156,7 @@ void EnElfgrp_Init(Actor* thisx, PlayState* play) { func_80A396B0(this, 3); this->unk_14A |= 2; } - } else if (gSaveContext.save.playerData.magicAcquired == true) { + } else if (gSaveContext.save.playerData.isMagicAcquired == true) { func_80A396B0(this, 1); } } else { @@ -477,8 +477,7 @@ void func_80A3A610(EnElfgrp* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->unk_144 == 60) { - Parameter_AddMagic(play, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); gSaveContext.healthAccumulator = 320; } 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 d8cbe91f5..e91d04c48 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -739,7 +739,7 @@ s32 EnFirefly_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 Gfx** gfx) { EnFirefly* this = THIS; - if (this->isInvisible && (play->actorCtx.unk4 != 0x64)) { + if (this->isInvisible && (play->actorCtx.lensMaskSize != LENS_MASK_ACTIVE_SIZE)) { *dList = NULL; } else if (limbIndex == 1) { pos->y += 2300.0f; 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 5e3b46fe6..4172773f0 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -651,9 +651,8 @@ void func_80962A10(EnFu* this, PlayState* play) { this->unk_546 = 1; } - if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { - Parameter_AddMagic(play, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.isMagicAcquired) { + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } func_80962F10(this); @@ -1139,7 +1138,7 @@ void func_80963DE4(EnFu* this, PlayState* play) { } void func_80963EAC(EnFu* this, PlayState* play) { - if (gSaveContext.save.playerData.magicAcquired) { + if (gSaveContext.save.playerData.isMagicAcquired) { if (this->unk_540 == 1) { Message_StartTextbox(play, 0x2847, &this->actor); this->unk_552 = 0x2847; 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 5c4606185..e2ebab0d5 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -231,7 +231,7 @@ void func_80B35450(EnGg* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { - func_800B90F4(play); + Actor_DeactivateLens(play); } this->unk_308 = 1; this->actionFunc = func_80B352A4; @@ -682,7 +682,7 @@ void EnGg_Destroy(Actor* thisx, PlayState* play) { void EnGg_Update(Actor* thisx, PlayState* play) { EnGg* this = THIS; - if (play->actorCtx.unk4 == 100) { + if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; } else { 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 9726a693a..ebbaaca7f 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -421,7 +421,7 @@ void EnGg2_Destroy(Actor* thisx, PlayState* play) { void EnGg2_Update(Actor* thisx, PlayState* play) { EnGg2* this = THIS; - if (play->actorCtx.unk4 == 100) { + if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { @@ -443,7 +443,7 @@ void EnGg2_Update(Actor* thisx, PlayState* play) { if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); - if ((play->actorCtx.unk4 == 100) && ((play->state.frames % 4) == 0)) { + if ((play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) && ((play->state.frames % 4) == 0)) { func_80B3B4B0(this, play); } } 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 235b4ba9f..7563d07fa 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -724,8 +724,7 @@ void func_80B51B40(EnGk* this, PlayState* play) { play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_03; gSaveContext.nextTransitionType = TRANS_TYPE_03; - Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + - (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } else { this->actionFunc = func_80B51760; } 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 b20edf2b4..eb6d4ab42 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 @@ -433,8 +433,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { gSaveContext.nextTransitionType = TRANS_TYPE_02; func_801477B4(play); func_800B7298(play, &this->actor, 7); - Parameter_AddMagic(play, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); gSaveContext.eventInf[1] &= (u8)~1; gSaveContext.eventInf[1] &= (u8)~2; 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 4a051fc23..54c3f0609 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -107,7 +107,7 @@ void EnTest2_Update(Actor* thisx, PlayState* play) { void EnTest2_UpdateForLens(Actor* thisx, PlayState* play) { EnTest2* this = THIS; - if (play->actorCtx.unk4 == 100) { + if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_80; } else { this->actor.flags &= ~ACTOR_FLAG_80; 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 d2fa8e3a0..0bd1fd30c 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -123,7 +123,7 @@ void ItemEtcetera_Update(Actor* thisx, PlayState* play) { void ItemEtcetera_DrawThroughLens(Actor* thisx, PlayState* play) { ItemEtcetera* this = THIS; - if (play->actorCtx.unk4 == 100) { + if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { func_800B8050(&this->actor, play, 0); func_800B8118(&this->actor, play, 0); GetItem_Draw(play, this->getItemDrawId); 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 504a2815a..7eaf78c20 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -72,7 +72,7 @@ void OceffSpot_Destroy(Actor* thisx, PlayState* play2) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode1); LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2); - func_80115D5C(&play->state); + Magic_Reset(play); } void OceffSpot_End(OceffSpot* this, PlayState* play) { 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 a26636e15..54672f173 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -42,7 +42,7 @@ void OceffWipe2_Init(Actor* thisx, PlayState* play) { void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { OceffWipe2* this = THIS; - func_80115D5C(&play->state); + Magic_Reset(play); play->msgCtx.unk120B0 = 0; } 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 1b1347e8f..4837f6949 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -43,7 +43,7 @@ void OceffWipe3_Init(Actor* thisx, PlayState* play) { void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { OceffWipe3* this = THIS; - func_80115D5C(&play->state); + Magic_Reset(play); play->msgCtx.unk120B0 = 0; } 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 3dd701dbf..97c688434 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -38,7 +38,7 @@ void OceffWipe6_Init(Actor* thisx, PlayState* play) { } void OceffWipe6_Destroy(Actor* thisx, PlayState* play) { - func_80115D5C(&play->state); + Magic_Reset(play); play->msgCtx.unk120B0 = 0; } 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 5a71ef0d1..abd01e1ff 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -42,7 +42,7 @@ void OceffWipe7_Init(Actor* thisx, PlayState* play) { void OceffWipe7_Destroy(Actor* thisx, PlayState* play) { OceffWipe7* this = THIS; - func_80115D5C(&play->state); + Magic_Reset(play); play->msgCtx.unk120B0 = 0; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index dc205b344..52e28708d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -811,7 +811,7 @@ 0x800B9084:("func_800B9084",), 0x800B9098:("func_800B9098",), 0x800B90AC:("func_800B90AC",), - 0x800B90F4:("func_800B90F4",), + 0x800B90F4:("Actor_DeactivateLens",), 0x800B9120:("func_800B9120",), 0x800B9170:("Actor_InitContext",), 0x800B9334:("Actor_SpawnSetupActors",), @@ -821,8 +821,8 @@ 0x800B9D1C:("func_800B9D1C",), 0x800B9E3C:("Actor_DrawAllSetup",), 0x800B9E4C:("Actor_RecordUndrawnActor",), - 0x800B9E84:("func_800B9E84",), - 0x800B9EF4:("func_800B9EF4",), + 0x800B9E84:("Actor_DrawLensOverlay",), + 0x800B9EF4:("Actor_DrawLensActors",), 0x800BA2D8:("func_800BA2D8",), 0x800BA2FC:("func_800BA2FC",), 0x800BA42C:("Actor_DrawAll",), @@ -2134,13 +2134,13 @@ 0x801159C0:("Health_GiveHearts",), 0x801159EC:("Rupees_ChangeBy",), 0x80115A14:("Inventory_ChangeAmmo",), - 0x80115D14:("Parameter_AddMagic",), - 0x80115D5C:("func_80115D5C",), - 0x80115DB4:("func_80115DB4",), - 0x80116088:("func_80116088",), - 0x80116114:("func_80116114",), - 0x80116348:("func_80116348",), - 0x80116918:("func_80116918",), + 0x80115D14:("Magic_Add",), + 0x80115D5C:("Magic_Reset",), + 0x80115DB4:("Magic_Consume",), + 0x80116088:("Magic_UpdateAddRequest",), + 0x80116114:("Magic_FlashMeterBorder",), + 0x80116348:("Magic_Update",), + 0x80116918:("Magic_DrawMeter",), 0x80116FD8:("func_80116FD8",), 0x801170B8:("func_801170B8",), 0x80117100:("func_80117100",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index eaca8ea4b..ab5318936 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1069,11 +1069,11 @@ 0x801BF890:("sMinigameScoreDigits","UNK_TYPE2","",0x2), 0x801BF898:("sCUpInvisible","UNK_TYPE2","",0x2), 0x801BF89C:("sCUpTimer","UNK_TYPE2","",0x2), - 0x801BF8A0:("sMagicBarOutlinePrimRed","UNK_TYPE2","",0x2), - 0x801BF8A4:("sMagicBarOutlinePrimGreen","UNK_TYPE2","",0x2), - 0x801BF8A8:("sMagicBarOutlinePrimBlue","UNK_TYPE2","",0x2), - 0x801BF8AC:("D_801BF8AC","UNK_TYPE2","",0x2), - 0x801BF8B0:("D_801BF8B0","UNK_TYPE2","",0x2), + 0x801BF8A0:("sMagicMeterOutlinePrimRed","UNK_TYPE2","",0x2), + 0x801BF8A4:("sMagicMeterOutlinePrimGreen","UNK_TYPE2","",0x2), + 0x801BF8A8:("sMagicMeterOutlinePrimBlue","UNK_TYPE2","",0x2), + 0x801BF8AC:("sMagicBorderRatio","UNK_TYPE2","",0x2), + 0x801BF8B0:("sMagicBorderStep","UNK_TYPE2","",0x2), 0x801BF8DC:("D_801BF8DC","UNK_TYPE2","",0x2), 0x801BF8E0:("D_801BF8E0","UNK_TYPE2","",0x2), 0x801BF8E4:("D_801BF8E4","UNK_TYPE2","",0x2), @@ -3434,7 +3434,7 @@ 0x801DE868:("D_801DE868","f32","",0x4), 0x801DE86C:("jtbl_801DE86C","UNK_PTR","",0x4), 0x801DE884:("D_801DE884","f32","",0x4), - 0x801DE890:("D_801DE890","UNK_TYPE1","",0x1), + 0x801DE890:("gCircleTex","UNK_TYPE1","",0x1), 0x801DF090:("D_801DF090","f32","",0x4), 0x801DF094:("D_801DF094","f32","",0x4), 0x801DF0A0:("D_801DF0A0","f32","",0x4), diff --git a/tools/namefixer.py b/tools/namefixer.py index e7b0a10e0..f8f714f8c 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -283,6 +283,7 @@ wordReplace = { "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", + "func_800B90F4": "Actor_DeactivateLens", "zelda_malloc": "ZeldaArena_Malloc", "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", @@ -498,6 +499,9 @@ wordReplace = { "func_801159c0": "Health_GiveHearts", "func_801159EC": "Rupees_ChangeBy", "func_80115A14": "Inventory_ChangeAmmo", + "Parameter_AddMagic": "Magic_Add", + "func_80115D5C": "Magic_Reset", + "func_80115DB4": "Magic_Consume", "func_8013EC44": "Rumble_Override", "func_8013ECE0": "Rumble_Request", "func_8017D2FC": "Math3D_LineSegVsPlane", @@ -648,8 +652,8 @@ wordReplace = { "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", - "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", - "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", "gSaveContext.inventory": "gSaveContext.save.inventory", @@ -671,6 +675,11 @@ wordReplace = { "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", "gSaveContext.unk_48C8": "gSaveContext.dungeonIndex", + "gSaveContext.save.playerData.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", + "gSaveContext.save.playerDatadoubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", + "gSaveContext.unk_3F28": "gSaveContext.magicState", + "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", + "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", "player->unk_A87": "player->exchangeItemId", @@ -704,6 +713,9 @@ wordReplace = { "play->msgCtx.unk12023": "play->msgCtx.stateTimer", "play->msgCtx.unk1202A": "play->msgCtx.ocarinaMode", "play->msgCtx.unk1202C": "play->msgCtx.ocarinaAction", + "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->actorCtx.unk3": "play->actorCtx.lensActive", + "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", "play->nextEntranceIndex": "play->nextEntrance", "play->sceneLoadFlag": "play->transitionTrigger", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 15c5a5f60..991b30fdf 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -325,7 +325,7 @@ asm/non_matchings/code/z_actor/func_800B9038.s,func_800B9038,0x800B9038,0x13 asm/non_matchings/code/z_actor/func_800B9084.s,func_800B9084,0x800B9084,0x5 asm/non_matchings/code/z_actor/func_800B9098.s,func_800B9098,0x800B9098,0x5 asm/non_matchings/code/z_actor/func_800B90AC.s,func_800B90AC,0x800B90AC,0x12 -asm/non_matchings/code/z_actor/func_800B90F4.s,func_800B90F4,0x800B90F4,0xB +asm/non_matchings/code/z_actor/Actor_DeactivateLens.s,Actor_DeactivateLens,0x800B90F4,0xB asm/non_matchings/code/z_actor/func_800B9120.s,func_800B9120,0x800B9120,0x14 asm/non_matchings/code/z_actor/Actor_InitContext.s,Actor_InitContext,0x800B9170,0x71 asm/non_matchings/code/z_actor/Actor_SpawnSetupActors.s,Actor_SpawnSetupActors,0x800B9334,0x56 @@ -335,8 +335,8 @@ asm/non_matchings/code/z_actor/Actor_Draw.s,Actor_Draw,0x800B9A04,0xC6 asm/non_matchings/code/z_actor/func_800B9D1C.s,func_800B9D1C,0x800B9D1C,0x48 asm/non_matchings/code/z_actor/Actor_DrawAllSetup.s,Actor_DrawAllSetup,0x800B9E3C,0x4 asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s,Actor_RecordUndrawnActor,0x800B9E4C,0xE -asm/non_matchings/code/z_actor/func_800B9E84.s,func_800B9E84,0x800B9E84,0x1C -asm/non_matchings/code/z_actor/func_800B9EF4.s,func_800B9EF4,0x800B9EF4,0xF9 +asm/non_matchings/code/z_actor/Actor_DrawLensOverlay.s,Actor_DrawLensOverlay,0x800B9E84,0x1C +asm/non_matchings/code/z_actor/Actor_DrawLensActors.s,Actor_DrawLensActors,0x800B9EF4,0xF9 asm/non_matchings/code/z_actor/func_800BA2D8.s,func_800BA2D8,0x800BA2D8,0x9 asm/non_matchings/code/z_actor/func_800BA2FC.s,func_800BA2FC,0x800BA2FC,0x4C asm/non_matchings/code/z_actor/Actor_DrawAll.s,Actor_DrawAll,0x800BA42C,0xB4 @@ -1648,13 +1648,13 @@ asm/non_matchings/code/z_parameter/Health_ChangeBy.s,Health_ChangeBy,0x80115908, asm/non_matchings/code/z_parameter/Health_GiveHearts.s,Health_GiveHearts,0x801159C0,0xB asm/non_matchings/code/z_parameter/Rupees_ChangeBy.s,Rupees_ChangeBy,0x801159EC,0xA asm/non_matchings/code/z_parameter/Inventory_ChangeAmmo.s,Inventory_ChangeAmmo,0x80115A14,0xC0 -asm/non_matchings/code/z_parameter/Parameter_AddMagic.s,Parameter_AddMagic,0x80115D14,0x12 -asm/non_matchings/code/z_parameter/func_80115D5C.s,func_80115D5C,0x80115D5C,0x16 -asm/non_matchings/code/z_parameter/func_80115DB4.s,func_80115DB4,0x80115DB4,0xB5 -asm/non_matchings/code/z_parameter/func_80116088.s,func_80116088,0x80116088,0x23 -asm/non_matchings/code/z_parameter/func_80116114.s,func_80116114,0x80116114,0x8D -asm/non_matchings/code/z_parameter/func_80116348.s,func_80116348,0x80116348,0x174 -asm/non_matchings/code/z_parameter/func_80116918.s,func_80116918,0x80116918,0x1B0 +asm/non_matchings/code/z_parameter/Magic_Add.s,Magic_Add,0x80115D14,0x12 +asm/non_matchings/code/z_parameter/Magic_Reset.s,Magic_Reset,0x80115D5C,0x16 +asm/non_matchings/code/z_parameter/Magic_Consume.s,Magic_Consume,0x80115DB4,0xB5 +asm/non_matchings/code/z_parameter/Magic_UpdateAddRequest.s,Magic_UpdateAddRequest,0x80116088,0x23 +asm/non_matchings/code/z_parameter/Magic_FlashMeterBorder.s,Magic_FlashMeterBorder,0x80116114,0x8D +asm/non_matchings/code/z_parameter/Magic_Update.s,Magic_Update,0x80116348,0x174 +asm/non_matchings/code/z_parameter/Magic_DrawMeter.s,Magic_DrawMeter,0x80116918,0x1B0 asm/non_matchings/code/z_parameter/func_80116FD8.s,func_80116FD8,0x80116FD8,0x38 asm/non_matchings/code/z_parameter/func_801170B8.s,func_801170B8,0x801170B8,0x12 asm/non_matchings/code/z_parameter/func_80117100.s,func_80117100,0x80117100,0x248 From 2c6816ba7791c6e6e8043d2a0e6598234588d4cf Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Wed, 14 Sep 2022 10:01:06 -0700 Subject: [PATCH 11/73] Add enum for tatl hint id (#993) * first round, need to investigate the others * naming the remainder * changed my mind on the name * foooooormat * fixing a number * ...another one... * names galore * PR feedback * fixing * fixes * 4mat * adding "POE_SISTER" * forgot a rename --- include/z64actor.h | 105 ++++++++++++++++++ src/code/z_actor.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 4 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 2 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.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_Bbfall/z_en_bbfall.c | 2 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 6 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 2 +- src/overlays/actors/ovl_En_Death/z_en_death.c | 2 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 2 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 2 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 2 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 2 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 2 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 10 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 2 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 2 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 6 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 2 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 4 +- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 2 +- src/overlays/actors/ovl_En_Okuta/z_en_okuta.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 4 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 2 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 4 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 2 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 2 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 2 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 8 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 10 +- src/overlays/actors/ovl_En_Rat/z_en_rat.c | 2 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 34 +++--- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 2 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 12 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 2 +- src/overlays/actors/ovl_En_St/z_en_st.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 4 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 2 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 2 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 10 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 2 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 2 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 2 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 2 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 4 +- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 4 +- 58 files changed, 211 insertions(+), 106 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 4c3539901..925a9975f 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -1188,4 +1188,109 @@ typedef enum { /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; +typedef enum { + /* 0x00 */ TATL_HINT_ID_DEFAULT, + /* 0x01 */ TATL_HINT_ID_SNAPPER, + /* 0x02 */ TATL_HINT_ID_MINI_BABA, + /* 0x03 */ TATL_HINT_ID_MAD_JELLY, + /* 0x04 */ TATL_HINT_ID_SKULLTULA, + /* 0x05 */ TATL_HINT_ID_RED_CHUCHU, + /* 0x06 */ TATL_HINT_ID_BLUE_CHUCHU, + /* 0x07 */ TATL_HINT_ID_DEKU_BABA, + /* 0x08 */ TATL_HINT_ID_BIO_DEKU_BABA, + /* 0x09 */ TATL_HINT_ID_WILTED_DEKU_BABA, + /* 0x0A */ TATL_HINT_ID_DEXIHAND, + /* 0x0B */ TATL_HINT_ID_NEJIRON, + /* 0x0C */ TATL_HINT_ID_GIANT_BEE, + /* 0x0D */ TATL_HINT_ID_DODONGO, + /* 0x0E */ TATL_HINT_ID_DEEP_PYTHON, + /* 0x0F */ TATL_HINT_ID_DEATH_ARMOS, + /* 0x10 */ TATL_HINT_ID_DINOLFOS, + /* 0x11 */ TATL_HINT_ID_FIRE_KEESE, + /* 0x12 */ TATL_HINT_ID_KEESE, + /* 0x13 */ TATL_HINT_ID_ARMOS, + /* 0x14 */ TATL_HINT_ID_EENO, + /* 0x15 */ TATL_HINT_ID_DRAGONFLY, + /* 0x16 */ TATL_HINT_ID_IGOS_DU_IKANA, + /* 0x17 */ TATL_HINT_ID_GARO, + /* 0x18 */ TATL_HINT_ID_GARO_MASTER, + /* 0x19 */ TATL_HINT_ID_WART, + /* 0x1A */ TATL_HINT_ID_GOMESS, + /* 0x1B */ TATL_HINT_ID_GOHT, + /* 0x1C */ TATL_HINT_ID_BLUE_BUBBLE, + /* 0x1D */ TATL_HINT_ID_KINGS_LACKEYS_DARK_ROOM, + /* 0x1E */ TATL_HINT_ID_KINGS_LACKEYS_LIGHT_ROOM, + /* 0x1F */ TATL_HINT_ID_SKULLWALLTULA, + /* 0x20 */ TATL_HINT_ID_GOLD_SKULLTULA, // Only in JP Ver. + /* 0x21 */ TATL_HINT_ID_CAPTAIN_KEETA, + /* 0x22 */ TATL_HINT_ID_YELLOW_CHUCHU, + /* 0x23 */ TATL_HINT_ID_TAKKURI, + /* 0x24 */ TATL_HINT_ID_RED_BUBBLE, + /* 0x25 */ TATL_HINT_ID_HIPLOOP, + /* 0x26 */ TATL_HINT_ID_MASKED_HIPLOOP, + /* 0x27 */ TATL_HINT_ID_SHELLBLADE, + /* 0x28 */ TATL_HINT_ID_GYORG, // "if you go near, you'll be eaten!" + /* 0x29 */ TATL_HINT_ID_GYORG_STUNNED, // "Jump in and attack it!" + /* 0x2A */ TATL_HINT_ID_REDEAD, + /* 0x2B */ TATL_HINT_ID_2B, + /* 0x2C */ TATL_HINT_ID_BLACK_BOE, + /* 0x2D */ TATL_HINT_ID_GIBDO, + /* 0x2E */ TATL_HINT_ID_TWINMOLD, + /* 0x2F */ TATL_HINT_ID_WEARING_GIANTS_MASK, // Twinmold, JP Ver. only + /* 0x30 */ TATL_HINT_ID_WALLMASTER, + /* 0x31 */ TATL_HINT_ID_FLOORMASTER, + /* 0x32 */ TATL_HINT_ID_MAJORAS_MASK, + /* 0x33 */ TATL_HINT_ID_MAJORAS_INCARNATION, + /* 0x34 */ TATL_HINT_ID_MAJORAS_WRATH, + /* 0x35 */ TATL_HINT_ID_IRON_KNUCKLE, + /* 0x36 */ TATL_HINT_ID_36, // Empty + /* 0x37 */ TATL_HINT_ID_LIKE_LIKE, + /* 0x38 */ TATL_HINT_ID_38, // Empty + /* 0x39 */ TATL_HINT_ID_BEAMOS, + /* 0x3A */ TATL_HINT_ID_3A, // Empty + /* 0x3B */ TATL_HINT_ID_FREEZARD, + /* 0x3C */ TATL_HINT_ID_WHITE_BOE, + /* 0x3D */ TATL_HINT_ID_3D, // Empty + /* 0x3E */ TATL_HINT_ID_3E, // Empty + /* 0x3F */ TATL_HINT_ID_3F, // Empty + /* 0x40 */ TATL_HINT_ID_40, // Empty + /* 0x41 */ TATL_HINT_ID_41, // Empty + /* 0x42 */ TATL_HINT_ID_OCTOROK, + /* 0x43 */ TATL_HINT_ID_43, // Empty + /* 0x44 */ TATL_HINT_ID_POE, + /* 0x45 */ TATL_HINT_ID_GEKKO_SNAPPER, + /* 0x46 */ TATL_HINT_ID_BLUE_TEKTITE, + /* 0x47 */ TATL_HINT_ID_LEEVER, + /* 0x48 */ TATL_HINT_ID_PEAHAT, + /* 0x49 */ TATL_HINT_ID_PEAHAT_LARVA, + /* 0x4A */ TATL_HINT_ID_EYEGORE, + /* 0x4B */ TATL_HINT_ID_WIZROBE, + /* 0x4C */ TATL_HINT_ID_WOLFOS, + /* 0x4D */ TATL_HINT_ID_MAD_SCRUB, + /* 0x4E */ TATL_HINT_ID_4E, // Empty + /* 0x4F */ TATL_HINT_ID_4F, // Empty + /* 0x50 */ TATL_HINT_ID_POE_SISTER_MEG, + /* 0x51 */ TATL_HINT_ID_POE_SISTER_JO, + /* 0x52 */ TATL_HINT_ID_POE_SISTER_BETH, + /* 0x53 */ TATL_HINT_ID_POE_SISTER_AMY, + /* 0x54 */ TATL_HINT_ID_PIRATE, + /* 0x55 */ TATL_HINT_ID_STALCHILD, + /* 0x56 */ TATL_HINT_ID_ICE_KEESE, + /* 0x57 */ TATL_HINT_ID_WHITE_WOLFOS, + /* 0x58 */ TATL_HINT_ID_GUAY, + /* 0x59 */ TATL_HINT_ID_BIG_OCTO, + /* 0x5A */ TATL_HINT_ID_BIG_POE, + /* 0x5B */ TATL_HINT_ID_SKULLFISH, + /* 0x5C */ TATL_HINT_ID_DESBREKO, + /* 0x5D */ TATL_HINT_ID_GREEN_CHUCHU, + /* 0x5E */ TATL_HINT_ID_ODOLWA_1, + /* 0x5F */ TATL_HINT_ID_GEKKO_GIANT_SLIME, + /* 0x60 */ TATL_HINT_ID_BAD_BAT, + /* 0x61 */ TATL_HINT_ID_REAL_BOMBCHU, + /* 0x62 */ TATL_HINT_ID_ODOLWA_2, + /* 0x63 */ TATL_HINT_ID_ODOLWA_3, + /* 0x64 */ TATL_HINT_ID_MUSHROOM, + /* 0xFF */ TATL_HINT_ID_NONE = 0xFF +} TatlHintId; + #endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 1b2d02b66..3669dd136 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1076,7 +1076,7 @@ void Actor_Init(Actor* actor, PlayState* play) { actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; - actor->hintId = 255; + actor->hintId = TATL_HINT_ID_NONE; CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; 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 d1fb0a3bd..9808e68a4 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -577,7 +577,7 @@ void Boss02_Init(Actor* thisx, PlayState* play) { } else if (this->actor.params == TWINMOLD_TAIL) { this->actor.update = Boss02_Tail_Update; this->actor.draw = NULL; - this->actor.hintId = 0x2E; + this->actor.hintId = TATL_HINT_ID_TWINMOLD; } else { if (this->actor.params != TWINMOLD_BLUE) { this->actor.params = TWINMOLD_RED; 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 75378de78..84987a9f5 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -1762,7 +1762,7 @@ void Boss03_SetupStunned(Boss03* this, PlayState* play) { } void Boss03_Stunned(Boss03* this, PlayState* play) { - this->actor.hintId = 0x29; + this->actor.hintId = TATL_HINT_ID_GYORG_STUNNED; if (this->unk_240 >= 16) { Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); @@ -1955,7 +1955,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { s16 j; f32 yRot; - this->actor.hintId = 0x28; + this->actor.hintId = TATL_HINT_ID_GYORG; if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { D_809E9842 = true; 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 3524efa53..e7d96d205 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -163,7 +163,7 @@ void Boss04_Init(Actor* thisx, PlayState* play2) { this->actor.params = 0x64; Actor_SetScale(&this->actor, 0.1f); this->actor.targetMode = 5; - this->actor.hintId = 0x19; + this->actor.hintId = TATL_HINT_ID_WART; this->actor.colChkInfo.health = 20; this->actor.colChkInfo.damageTable = &sDamageTable; this->unk_700 = 1.0f; 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 5b1b488cb..eda01c254 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -128,7 +128,7 @@ static CollisionCheckInfoInit sColChkInfoInit = { 1, 23, 98, MASS_HEAVY }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 19, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_ARMOS, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; 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 a0954943b..e2496e18e 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -126,7 +126,7 @@ void EnBaguo_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); SkelAnime_Init(play, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, NEJIRON_LIMB_MAX); - this->actor.hintId = 0xB; + this->actor.hintId = TATL_HINT_ID_NEJIRON; this->maxDistanceFromHome = 240.0f; this->maxDistanceFromHome += this->actor.world.rot.z * 40.0f; this->actor.world.rot.z = 0; 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 e81608721..fe1eb9fd8 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -107,7 +107,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 10 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 96, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BAD_BAT, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), 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 488ed0482..a66c28a89 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -114,7 +114,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BLUE_BUBBLE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; 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 2193203fe..b1e4db445 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -143,7 +143,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_RED_BUBBLE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; 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 bb3f28bee..047567b98 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -88,7 +88,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 89, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BIG_OCTO, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 33, ICHAIN_STOP), }; 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 8121db9e2..0be5ad0b4 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -154,7 +154,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 90, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BIG_POE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; @@ -671,7 +671,7 @@ void EnBigpo_SetupDeath(EnBigpo* this) { this->idleTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->collider.base.ocFlags1 &= ~OC1_ON; this->actionFunc = EnBigpo_BurnAwayDeath; } 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 12076537e..392f9a441 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -303,7 +303,7 @@ static AnimationHeader* sGekkoAttackAnimations[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 95, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GEKKO_GIANT_SLIME, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(targetArrowOffset, -13221, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), @@ -765,7 +765,7 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { this->actor.colChkInfo.mass = 50; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_400); this->actor.flags |= ACTOR_FLAG_200; - this->actor.hintId = 95; + this->actor.hintId = TATL_HINT_ID_GEKKO_GIANT_SLIME; this->gekkoRot.x = 0; this->gekkoRot.y = 0; this->actor.bgCheckFlags &= ~1; @@ -2308,7 +2308,7 @@ void EnBigslime_FormBigslime(EnBigslime* this, PlayState* play) { if (this->minislimeCounter == MINISLIME_NUM_SPAWN) { this->minislimeState = MINISLIME_INACTIVE_STATE; - this->actor.hintId = 3; + this->actor.hintId = TATL_HINT_ID_MAD_JELLY; EnBigslime_SetupMoveOnCeiling(this); } } 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 e6980ba4f..c04462c44 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -118,7 +118,7 @@ static s32 sDeadCount = 0; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GUAY, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; 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 edc240cd5..b0f03af7c 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -131,7 +131,7 @@ static CollisionCheckInfoInit2 D_808C9A30 = { 20, 28, 90, 20, 100 }; // static InitChainEntry sInitChain[] = { static InitChainEntry D_808C9A60[] = { ICHAIN_VEC3F(scale, 0, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 26, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GOMESS, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; 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 15ae675a1..0f37266e2 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -109,7 +109,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_MAD_SCRUB, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; 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 eb7719150..65c11e035 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -253,7 +253,7 @@ static s32 D_8089E350 = 0; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 16, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DINOLFOS, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_STOP), }; 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 45311b83f..65e5417f3 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -273,7 +273,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 100, 100, 80 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 13, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DODONGO, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1400, ICHAIN_STOP), }; 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 901efc0d2..5bc260ccc 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -242,7 +242,7 @@ void EnDragon_Init(Actor* thisx, PlayState* play) { 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->actor.hintId = TATL_HINT_ID_DEEP_PYTHON; this->scale = 0.5f; this->actor.flags &= ~ACTOR_FLAG_8000000; 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 287ca85e1..4b091efc3 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -62,7 +62,7 @@ void EnElfbub_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); - this->actor.hintId = 0x16; + this->actor.hintId = TATL_HINT_ID_IGOS_DU_IKANA; Actor_SetScale(&this->actor, 1.25f); this->actionFunc = EnElfbub_Idle; 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 cc447a1a1..b6b93aded 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -154,7 +154,7 @@ static AnimatedMaterial* sEmblemAnimatedMats[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 15, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DEATH_ARMOS, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; 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 e91d04c48..3ac02d9c9 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -149,19 +149,19 @@ void EnFirefly_Init(Actor* thisx, PlayState* play) { this->auraType = KEESE_AURA_FIRE; this->timer = Rand_S16Offset(20, 60); this->actor.shape.rot.x = 0x1554; - this->actor.hintId = 0x11; // Fire Keese + this->actor.hintId = TATL_HINT_ID_FIRE_KEESE; this->maxAltitude = this->actor.home.pos.y; this->actionFunc = EnFirefly_FlyIdle; } else if (this->actor.params == KEESE_ICE_FLY) { this->auraType = KEESE_AURA_ICE; this->collider.info.toucher.effect = 2; // Freeze - this->actor.hintId = 0x56; // Ice Keese + this->actor.hintId = TATL_HINT_ID_ICE_KEESE; this->maxAltitude = this->actor.home.pos.y + 100.0f; this->actionFunc = EnFirefly_FlyIdle; } else { this->auraType = KEESE_AURA_NONE; this->collider.info.toucher.effect = 0; // Nothing - this->actor.hintId = 0x12; // Keese + this->actor.hintId = TATL_HINT_ID_KEESE; this->maxAltitude = this->actor.home.pos.y + 100.0f; this->actionFunc = EnFirefly_Perch; } @@ -188,7 +188,7 @@ void EnFirefly_Extinguish(EnFirefly* this) { this->currentType = KEESE_NORMAL; this->collider.info.toucher.effect = 0; // Nothing this->auraType = KEESE_AURA_NONE; - this->actor.hintId = 0x12; // Keese + this->actor.hintId = TATL_HINT_ID_KEESE; } void EnFirefly_Ignite(EnFirefly* this) { @@ -196,7 +196,7 @@ void EnFirefly_Ignite(EnFirefly* this) { this->currentType = KEESE_FIRE; this->collider.info.toucher.effect = 1; // Fire this->auraType = KEESE_AURA_FIRE; - this->actor.hintId = 0x11; // Fire Keese + this->actor.hintId = TATL_HINT_ID_FIRE_KEESE; } } 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 c5e7b24f1..411d83712 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -129,7 +129,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 49, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_FLOORMASTER, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; 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 00c47b111..198166b00 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -156,7 +156,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 59, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_FREEZARD, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), 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 3664fcede..46a52a9fa 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 @@ -158,7 +158,7 @@ void EnHintSkb_Init(Actor* thisx, PlayState* play) { Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElement); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->unk_3E4 = 0; this->unk_3DE = 0; this->unk_3E0 = 0; @@ -587,7 +587,7 @@ void func_80C20D64(EnHintSkb* this, PlayState* play) { if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.hintId = 255; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); @@ -597,7 +597,7 @@ void func_80C20D64(EnHintSkb* this, PlayState* play) { } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.textId = 0; if (this->skelAnime.animation == &object_skb_Anim_00697C) { func_80C1FE0C(this); 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 a1c33264e..d71e4c193 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -388,7 +388,7 @@ void EnIk_Idle(EnIk* this, PlayState* play) { } else if (this->colliderCylinder.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); func_801A2E54(NA_BGM_MINI_BOSS); - this->actor.hintId = 0x35; + this->actor.hintId = TATL_HINT_ID_IRON_KNUCKLE; this->colliderCylinder.base.acFlags &= ~AC_HIT; this->invincibilityFrames = 12; EnIk_SetupWalk(this); 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 b6edc7778..c1ea3ae46 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -114,7 +114,7 @@ static TexturePtr D_80AD8E34[] = { object_tl_Tex_0055A0, object_tl_Tex_0057A0, o object_tl_Tex_0057A0 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_SNAPPER, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; 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 5412065f5..46a1adfd5 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -154,9 +154,9 @@ void EnKarebaba_Init(Actor* thisx, PlayState* play) { this->unk_22C = NULL; if (this->actor.params == ENKAREBABA_2) { - this->actor.hintId = 2; + this->actor.hintId = TATL_HINT_ID_MINI_BABA; } else { - this->actor.hintId = 9; + this->actor.hintId = TATL_HINT_ID_WILTED_DEKU_BABA; } if (this->actor.params == ENKAREBABA_0) { 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 bd56373e5..bf91c7516 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 @@ -134,7 +134,7 @@ void EnNeoReeba_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 2; - this->actor.hintId = 0x47; + this->actor.hintId = TATL_HINT_ID_LEEVER; this->actor.gravity = -0.5f; this->targetPos = gZeroVec3f; 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 a0de8cc48..938696e88 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -95,7 +95,7 @@ static DamageTable D_80870900 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80870920[] = { - ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_OCTOROK, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; 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 5feb50245..2ff9d814e 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -163,7 +163,7 @@ static ColliderJntSphInit sJntSphInit = { static CollisionCheckInfoInit sColChkInit = { 3, 30, 60, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 69, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GEKKO_SNAPPER, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(targetArrowOffset, -13221, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_CONTINUE), @@ -1191,7 +1191,7 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, PlayState* play) { // Zooms in on Gekko Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); this->timer = 0; - this->actor.hintId = 0x5F; + this->actor.hintId = TATL_HINT_ID_GEKKO_GIANT_SLIME; this->actionFunc = EnPametfrog_CallSnapper; } 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 d0598ce79..f7e943957 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -194,7 +194,7 @@ void EnPeehat_Init(Actor* thisx, PlayState* play) { this->actor.shape.yOffset = -1000.0f; } Actor_SetScale(&this->actor, 0.036f); - this->actor.hintId = 0x48; + this->actor.hintId = TATL_HINT_ID_PEAHAT; func_80897498(this); } else { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); @@ -205,7 +205,7 @@ void EnPeehat_Init(Actor* thisx, PlayState* play) { this->colliderCylinder.dim.radius = 20; this->colliderCylinder.dim.height = 15; this->colliderCylinder.dim.yShift = -5; - this->actor.hintId = 0x49; + this->actor.hintId = TATL_HINT_ID_PEAHAT_LARVA; this->colliderCylinder.base.ocFlags1 &= ~OC1_ON; func_80897A34(this); 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 b9afa5229..57e32a554 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 @@ -177,7 +177,7 @@ void EnPoSisters_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->type = ENPOSISTERS_GET_TYPE(thisx); - this->actor.hintId = this->type + 80; + this->actor.hintId = this->type + TATL_HINT_ID_POE_SISTER_MEG; this->megCloneId = ENPOSISTERS_GET_MEG_CLONE_ID(thisx); this->floatingBobbingTimer = 32; this->zTargetTimer = 20; 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 9d1dca75e..dde6236b5 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -143,7 +143,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 25, 50, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 68, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_POE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; @@ -388,7 +388,7 @@ void func_80B2D2C0(EnPoh* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B2D300; } 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 c7fae7c88..724b2c19f 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -118,7 +118,7 @@ void EnPr_Init(Actor* thisx, PlayState* play2) { this->actor.colChkInfo.health = 3; this->actor.colChkInfo.mass = 50; - this->actor.hintId = 0x5C; + this->actor.hintId = TATL_HINT_ID_DESBREKO; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); 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 2454639c5..4564c679f 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -109,7 +109,7 @@ void EnPr2_Init(Actor* thisx, PlayState* play) { EnPr2* this = THIS; this->actor.targetMode = 3; - this->actor.hintId = 0x5B; + this->actor.hintId = TATL_HINT_ID_SKULLFISH; this->unk_1EC = 255; this->actor.colChkInfo.health = 1; this->actor.colChkInfo.damageTable = &sDamageTable; 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 6fc5ea24a..e5c611578 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -110,7 +110,7 @@ void EnPrz_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 3; this->unk_1E8 = 255; - this->actor.hintId = 0x5B; + this->actor.hintId = TATL_HINT_ID_SKULLFISH; this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 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 095ee3fec..56201271b 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 @@ -282,7 +282,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.speedXZ = 1.6f; - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->unk_3F2 = 0; this->unk_2E4 = -1; this->unk_3FC = 0; @@ -825,7 +825,7 @@ void func_80B723F8(EnRailSkb* this) { 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.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; } @@ -926,7 +926,7 @@ void func_80B72880(EnRailSkb* this, PlayState* play) { 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.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; func_80B71650(this); } @@ -934,7 +934,7 @@ void func_80B72880(EnRailSkb* this, PlayState* play) { 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.hintId = TATL_HINT_ID_STALCHILD; 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 10bbf2f83..58ab51cf8 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -246,7 +246,7 @@ void EnRailgibud_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.targetMode = 0; - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; this->actor.textId = 0; if (ENRAILGIBUD_IS_CUTSCENE_TYPE(&this->actor)) { EnRailgibud_InitCutsceneGibdo(this, play); @@ -580,7 +580,7 @@ void EnRailgibud_Damage(EnRailgibud* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_RAILGIBUD_TYPE_REDEAD; @@ -933,7 +933,7 @@ void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, PlayState* play) { if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_WalkToHome)) { EnRailgibud_SetupWalkToHome(this); @@ -943,9 +943,9 @@ void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, PlayState* play) { 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; + this->actor.hintId = TATL_HINT_ID_REDEAD; } else { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } this->actor.textId = 0; } 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 1054876aa..cc98c05e1 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -118,7 +118,7 @@ static TexturePtr sSparkTextures[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 97, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_REAL_BOMBCHU, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 15, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5000, ICHAIN_STOP), }; 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 1f4c10281..0092189c5 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -223,7 +223,7 @@ void EnRd_Init(Actor* thisx, PlayState* play) { if (!EnRd_ShouldNotDance(play)) { EnRd_SetupSquattingDance(this); } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupSquattingDance; @@ -233,7 +233,7 @@ void EnRd_Init(Actor* thisx, PlayState* play) { if (!EnRd_ShouldNotDance(play)) { EnRd_SetupClappingDance(this); } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupClappingDance; @@ -243,7 +243,7 @@ void EnRd_Init(Actor* thisx, PlayState* play) { if (!EnRd_ShouldNotDance(play)) { EnRd_SetupPirouette(this); } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupPirouette; @@ -251,9 +251,9 @@ void EnRd_Init(Actor* thisx, PlayState* play) { default: if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } EnRd_SetupIdle(this); this->setupDanceFunc = EnRd_SetupIdle; @@ -436,9 +436,9 @@ void EnRd_SquattingDance(EnRd* this, PlayState* play) { this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; @@ -446,9 +446,9 @@ void EnRd_SquattingDance(EnRd* this, PlayState* play) { if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } EnRd_SetupIdle(this); } @@ -480,9 +480,9 @@ void EnRd_ClappingDance(EnRd* this, PlayState* play) { this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; @@ -490,9 +490,9 @@ void EnRd_ClappingDance(EnRd* this, PlayState* play) { if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } EnRd_SetupIdle(this); } @@ -541,18 +541,18 @@ void EnRd_Pirouette(EnRd* this, PlayState* play) { this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(play) && func_800B715C(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } this->actionFunc = EnRd_EndPirouetteWhenPlayerIsClose; } if (EnRd_ShouldNotDance(play)) { if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } EnRd_SetupIdle(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 8fc202ddd..4a61e62b9 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -118,7 +118,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 45, 60, 250 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 55, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_LIKE_LIKE, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), 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 acd645d63..adcb78115 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -92,7 +92,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 39, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_SHELLBLADE, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; 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 e3c5b1730..62cb638d9 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -249,7 +249,7 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { default: this->actor.flags &= ~ACTOR_FLAG_100000; - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; func_8099495C(this, play); break; } @@ -353,7 +353,7 @@ void func_80995068(EnSkb* this, PlayState* play) { } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; func_80995A30(this); } else if (!(this->collider.base.acFlags & AC_HIT)) { @@ -427,7 +427,7 @@ void func_8099533C(EnSkb* this, PlayState* play) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); } @@ -449,7 +449,7 @@ void func_8099544C(EnSkb* this, PlayState* play) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); } @@ -487,7 +487,7 @@ void func_8099556C(EnSkb* this, PlayState* play) { func_80994F7C(this, play); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.targetArrowOffset = 2000.0f; func_8099571C(this); @@ -571,7 +571,7 @@ void func_80995A8C(EnSkb* this, PlayState* play) { if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.colChkInfo.mass = MASS_HEAVY; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); func_8099504C(this); 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 b07a1667e..e2dd8b54b 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -178,7 +178,7 @@ static Gfx* sSnowballFragmentDLs[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_EENO, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; 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 b3c353f1f..7d0dcbf11 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -704,7 +704,7 @@ void func_808A6A78(EnSt* this, PlayState* play) { Actor_SetScale(&this->actor, 0.04f); this->actor.draw = func_808A7478; - this->actor.hintId = 4; + this->actor.hintId = TATL_HINT_ID_SKULLTULA; this->actor.gravity = 0.0f; func_808A63E8(this); this->unk_18C = 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 a69cbe213..fc3aff029 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -1144,11 +1144,11 @@ void EnSw_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); if (!ENSW_GET_3(&this->actor)) { - this->actor.hintId = 0x1F; + this->actor.hintId = TATL_HINT_ID_SKULLWALLTULA; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->collider.info.toucher.damage = 8; } else { - this->actor.hintId = 0x20; + this->actor.hintId = TATL_HINT_ID_GOLD_SKULLTULA; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit2); this->collider.info.toucher.damage = 16; } 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 a8d76a7a8..ef8973295 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 @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GUAY, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; 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 fcb1e8330..51a941b28 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 @@ -79,7 +79,7 @@ static AnimationInfo sAnimationInfo[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_MAD_SCRUB, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; 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 9077b38c4..f631439bd 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 @@ -72,7 +72,7 @@ static AnimationInfo sAnimationInfo[] = { #include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_OCTOROK, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; 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 d15859a74..647b21182 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 @@ -186,7 +186,7 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, this->morphTable, WOLFOS_NORMAL_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); - this->actor.hintId = 0x4C; + this->actor.hintId = TATL_HINT_ID_WOLFOS; func_80A201CC(this); } 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 f1268e1e0..393caa1d9 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 @@ -229,7 +229,7 @@ void EnTalkGibud_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.targetMode = 0; - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; this->actor.textId = 0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); @@ -566,7 +566,7 @@ void EnTalkGibud_Damage(EnTalkGibud* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, @@ -926,7 +926,7 @@ void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, PlayState* play) { if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; EnTalkGibud_SetupPassiveIdle(this); } @@ -934,9 +934,9 @@ void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, PlayState* play) { 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; + this->actor.hintId = TATL_HINT_ID_REDEAD; } else { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } this->actor.textId = 0; EnTalkGibud_SetupWalkToHome(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 03c7d0e1d..dd4890d53 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -136,7 +136,7 @@ static s16 D_80C13664[] = { ITEM00_ARROWS_10, ITEM00_BOMBS_B, ITEM00_RUPEE_GR static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 35, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_TAKKURI, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; 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 2b1385965..b912f6f38 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -125,7 +125,7 @@ static Color_RGBA8 D_80896B40 = { 180, 180, 180, 255 }; static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BLUE_TEKTITE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32(terminalVelocity, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), 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 4e7e85147..5ce0f0286 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -151,7 +151,7 @@ TexturePtr D_808CD58C[] = { static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 57, ICHAIN_STOP), + ICHAIN_S8(hintId, TATL_HINT_ID_BEAMOS, ICHAIN_STOP), }; s32 D_808CD5B8 = false; 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 16cfa6a4b..9dca3642f 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -123,7 +123,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_WALLMASTER, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; 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 8a5da16c5..811f828a8 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -319,7 +319,7 @@ void EnWf_Init(Actor* thisx, PlayState* play) { if (this->actor.params == 0) { SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, this->morphTable, WOLFOS_NORMAL_LIMB_MAX); - this->actor.hintId = 0x4C; + this->actor.hintId = TATL_HINT_ID_WOLFOS; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); this->collider1.elements[0].info.toucher.damage = 8; this->collider1.elements[1].info.toucher.damage = 8; @@ -327,7 +327,7 @@ void EnWf_Init(Actor* thisx, PlayState* play) { } else { SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, this->morphTable, WOLFOS_WHITE_LIMB_MAX); - this->actor.hintId = 0x57; + this->actor.hintId = TATL_HINT_ID_WHITE_WOLFOS; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } 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 deb315bc4..24597e4aa 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -41,11 +41,11 @@ void ObjKinoko_Update(Actor* thisx, PlayState* play) { if (player->currentMask != PLAYER_MASK_SCENTS) { thisx->draw = NULL; - thisx->hintId = 0xFF; + thisx->hintId = TATL_HINT_ID_NONE; thisx->flags &= ~ACTOR_FLAG_1; } else { thisx->draw = ObjKinoko_Draw; - thisx->hintId = 0x64; + thisx->hintId = TATL_HINT_ID_MUSHROOM; thisx->flags |= ACTOR_FLAG_1; if (Actor_HasParent(thisx, play)) { Flags_SetCollectible(play, OBJ_KINOKO_GET_FLAG(thisx)); From f31056ef8aade431da97ac0850ea2c7383ebc38b Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:04:03 -0700 Subject: [PATCH 12/73] Effect Dust OK (#1016) * OK * Some cleanup * Description * format * Better name * whoops * Array count * Name dust texture arrays * Fix * static * Update dust tex outnames --- assets/xml/objects/gameplay_keep.xml | 18 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 39 ++-- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 4 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 6 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 6 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 6 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 6 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 6 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 8 +- .../ovl_Effect_Ss_Dust/z_eff_ss_dust.c | 182 +++++++++++++++++- .../ovl_Effect_Ss_Dust/z_eff_ss_dust.h | 10 + tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 2 +- 15 files changed, 245 insertions(+), 61 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 4f1ad1841..e042feda0 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -905,7 +905,7 @@ - + @@ -1427,14 +1427,14 @@ - - - - - - - - + + + + + + + + diff --git a/spec b/spec index cc7babd85..493bc0181 100644 --- a/spec +++ b/spec @@ -1737,8 +1737,7 @@ beginseg name "ovl_Effect_Ss_Dust" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.o" - include "build/data/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust.data.o" - include "build/data/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust_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 5258c2ecf..9bdb0f9a4 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -91,63 +91,76 @@ void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* veloc void func_800B0DE0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_NORMAL); } void func_800B0E48(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_NORMAL); } void func_800B0EB0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } void func_800B0F18(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } void func_800B0F80(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(play, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } void func_800B0FE8(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_FIRE); } void func_800B1054(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_FIRE); } static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 }; static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 }; void func_800B10C0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, 100, 5, 10, DUST_UPDATE_NORMAL); } void func_800B1130(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, 100, 5, 10, DUST_UPDATE_NORMAL); } void func_800B11A0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, 10, DUST_UPDATE_NORMAL); } void func_800B1210(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, 10, DUST_UPDATE_NORMAL); } void func_800B1280(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, life, DUST_UPDATE_NORMAL); } void func_800B12F0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, life, DUST_UPDATE_NORMAL); } void func_800B1360(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, 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 84987a9f5..23aa023da 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -2428,7 +2428,7 @@ void Boss03_DrawEffects(PlayState* play) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); @@ -2462,7 +2462,7 @@ void Boss03_DrawEffects(PlayState* play) { if (!flag) { func_8012C448(gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); 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 3b4ab74ae..d663bcf74 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -252,8 +252,8 @@ s32 func_80A5086C(EnDnbUnkStruct* arg0) { } s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2) { - static TexturePtr D_80A50CBC[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, + static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; PlayState* play = play2; s32 isGfxSetup = false; @@ -286,7 +286,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = (arg0->unk_01 / (f32)arg0->unk_02) * 8.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A50CBC[idx])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, object_hanareyama_obj_DL_000020); Matrix_Pop(); 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 8ad22ff53..cacc2e728 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -444,8 +444,8 @@ void EnFg_UpdateDust(EnFgEffectDust* dustEffect) { } } -TexturePtr sDustTex[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; void EnFg_DrawDust(PlayState* play, EnFgEffectDust* dustEffect) { @@ -475,7 +475,7 @@ void EnFg_DrawDust(PlayState* play, EnFgEffectDust* dustEffect) { Matrix_Scale(dustEffect->xyScale, dustEffect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); index = 0.5f * dustEffect->timer; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTex[index])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); gSPDisplayList(POLY_XLU_DISP++, object_fr_DL_00B338); } } 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 491e1c95e..976489fd9 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -299,8 +299,8 @@ void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4 } void func_80A115B4(EnGoStruct* ptr, PlayState* play) { - static TexturePtr D_80A16644[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, + static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; static Color_RGBA8 D_80A16664[] = { { 255, 255, 255, 0 }, @@ -341,7 +341,7 @@ void func_80A115B4(EnGoStruct* ptr, PlayState* play) { Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[(s32)(temp * 7.0f)])); gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); 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 896947fa6..2d976bdd5 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -123,8 +123,8 @@ AnimationInfoS D_80BF5914[] = { { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -TexturePtr D_80BF5934[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; Color_RGBA8 D_80BF5954[] = { @@ -190,7 +190,7 @@ void func_80BF3920(EnRgStruct* ptr, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = temp_f20 * 7.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); 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 996a32bef..42cbdc22a 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -80,8 +80,8 @@ static Color_RGBA8 D_80A8B25C[] = { static f32 D_80A8B274[] = { 60.0f, 255.0f, 60.0f }; -static TexturePtr D_80A8B280[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; static ColliderSphereInit sSphereInit = { @@ -307,7 +307,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B280[idx])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); Matrix_Pop(); 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 499ca365f..92bec240e 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 @@ -285,7 +285,7 @@ void EnWaterEffect_Draw(Actor* thisx, PlayState* play2) { if (!phi_s4) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); phi_s4++; @@ -317,7 +317,7 @@ void EnWaterEffect_Draw(Actor* thisx, PlayState* play2) { if (!phi_s4) { func_8012C448(gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); phi_s4++; @@ -678,7 +678,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { if (!phi_s4) { func_8012C448(play->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); phi_s4++; 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 0247cd23a..4057ff817 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -554,7 +554,7 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) { gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust5Tex)); } Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); @@ -569,7 +569,7 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) { Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); } } @@ -629,14 +629,14 @@ void func_808DD970(Actor* thisx, PlayState* play2) { Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust5Tex)); gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c index c3a72bb7f..7a2274a5d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c @@ -1,30 +1,192 @@ /* * File: z_eff_ss_dust.c * Overlay: ovl_Effect_Ss_Dust - * Description: + * Description: Dust Particle Effect */ #include "z_eff_ss_dust.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 rTexIndex regs[8] // this reg is also used to set specific colors in the fire update function +#define rScale regs[9] +#define rScaleStep regs[10] +#define rDrawFlags regs[11] +#define rLifespan regs[12] #define PARAMS ((EffectSsDustInitParams*)initParamsx) -s32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); -void func_809776BC(PlayState* play, u32 index, EffectSs* this); -void func_809777B4(PlayState* play, u32 index, EffectSs* this); +u32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this); void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dust_InitVars = { EFFECT_SS_DUST, EffectSsDust_Init, }; -#endif +static EffectSsUpdateFunc sUpdateFuncs[] = { + EffectSsDust_Update, + EffectSsDust_UpdateFire, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/EffectSsDust_Init.s") +static TexturePtr sDustTextures[] = { + gEffDust1Tex, gEffDust2Tex, gEffDust3Tex, gEffDust4Tex, gEffDust5Tex, gEffDust6Tex, gEffDust7Tex, gEffDust8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/EffectSsDust_Draw.s") +u32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDustInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/func_809776BC.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffDustDL; + this->life = initParams->life; + this->update = sUpdateFuncs[initParams->updateMode]; + this->draw = EffectSsDust_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/func_809777B4.s") + if (initParams->drawFlags & DUST_DRAWFLAG_RAND_COLOR_OFFSET) { + s32 randColorOffset = Rand_ZeroOne() * 20.0f - 10.0f; + + this->rPrimColorR = initParams->primColor.r + randColorOffset; + this->rPrimColorG = initParams->primColor.g + randColorOffset; + this->rPrimColorB = initParams->primColor.b + randColorOffset; + this->rEnvColorR = initParams->envColor.r + randColorOffset; + this->rEnvColorG = initParams->envColor.g + randColorOffset; + this->rEnvColorB = initParams->envColor.b + randColorOffset; + } else { + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + } + + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorA = initParams->envColor.a; + this->rTexIndex = 0; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rLifespan = initParams->life; + this->rDrawFlags = initParams->drawFlags; + + return 1; +} + +void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &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); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[this->rTexIndex])); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gDPPipeSync(POLY_XLU_DISP++); + + if (this->rDrawFlags & DUST_DRAWFLAG1) { + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, + COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else if (this->rDrawFlags & DUST_DRAWFLAG2) { + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else { // DUST_DRAWFLAG0 + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + } + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + if ((this->life <= this->rLifespan) && (this->life >= (this->rLifespan - 7))) { + if (this->rLifespan >= 5) { + this->rTexIndex = this->rLifespan - this->life; + } else { + this->rTexIndex = ((this->rLifespan - this->life) * (ARRAY_COUNT(sDustTextures) / this->rLifespan)); + } + } else { + this->rTexIndex = ARRAY_COUNT(sDustTextures) - 1; + } + + this->rScale += this->rScaleStep; +} + +// this update mode is unused in the original game +void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + switch (this->rTexIndex) { + case 0: + this->rPrimColorR = 255; + this->rPrimColorG = 150; + this->rPrimColorB = 0; + this->rEnvColorR = 150; + this->rEnvColorG = 50; + this->rEnvColorB = 0; + break; + case 1: + this->rPrimColorR = 200; + this->rPrimColorG = 50; + this->rPrimColorB = 0; + this->rEnvColorR = 100; + this->rEnvColorG = 0; + this->rEnvColorB = 0; + break; + case 2: + this->rPrimColorR = 50; + this->rPrimColorG = 0; + this->rPrimColorB = 0; + this->rEnvColorR = 0; + this->rEnvColorG = 0; + this->rEnvColorB = 0; + break; + case 3: + this->rPrimColorR = 50; + this->rEnvColorR = this->rPrimColorG = this->rEnvColorG = this->rPrimColorB = this->rEnvColorB = 0; + break; + } + + if (this->rTexIndex < (ARRAY_COUNT(sDustTextures) - 1)) { + this->rTexIndex++; + } + + this->rScale += this->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h index 7e8bfbfb8..410a14352 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h @@ -3,6 +3,16 @@ #include "global.h" +#define DUST_DRAWFLAG0 (0) +#define DUST_DRAWFLAG1 (1 << 0) +#define DUST_DRAWFLAG2 (1 << 1) +#define DUST_DRAWFLAG_RAND_COLOR_OFFSET (1 << 2) + +typedef enum { + /* 0 */ DUST_UPDATE_NORMAL, + /* 1 */ DUST_UPDATE_FIRE +} DustUpdateMode; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 52e28708d..be488e0d9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8129,8 +8129,8 @@ 0x809765A0:("OceffWipe_Draw",), 0x80977210:("EffectSsDust_Init",), 0x80977394:("EffectSsDust_Draw",), - 0x809776BC:("func_809776BC",), - 0x809777B4:("func_809777B4",), + 0x809776BC:("EffectSsDust_Update",), + 0x809777B4:("EffectSsDust_UpdateFire",), 0x80977A00:("EffectSsKirakira_Init",), 0x80977B5C:("EffectSsKirakira_Draw",), 0x80977DB4:("func_80977DB4",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ab5318936..94a59d695 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12339,7 +12339,7 @@ 0x80A8B188:("D_80A8B188","UNK_TYPE1","",0x1), 0x80A8B250:("D_80A8B250","UNK_TYPE4","",0x4), 0x80A8B25C:("D_80A8B25C","Color_RGBA8","[6]",0x18), - 0x80A8B280:("D_80A8B280","UNK_TYPE1","",0x1), + 0x80A8B280:("sDustTextures","UNK_TYPE1","",0x1), 0x80A8B2A0:("D_80A8B2A0","UNK_TYPE1","",0x1), 0x80A8B2CC:("D_80A8B2CC","UNK_TYPE1","",0x1), 0x80A8B2D8:("sAnimationInfo","UNK_TYPE1","",0x1), From fb4ca3fb1706771c4426051cf3a6084ad7bc805f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:09:46 -0700 Subject: [PATCH 13/73] Effect DtBubble OK (#1017) * OK * Some cleanup * Format * Name enum --- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 3 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 2 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 4 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 6 +- src/overlays/actors/ovl_En_Part/z_en_part.c | 3 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 2 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 2 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 3 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- .../z_eff_ss_dt_bubble.c | 103 ++++++++++++++++-- .../z_eff_ss_dt_bubble.h | 7 ++ 14 files changed, 123 insertions(+), 23 deletions(-) diff --git a/spec b/spec index 493bc0181..bef6cdca6 100644 --- a/spec +++ b/spec @@ -1817,8 +1817,7 @@ beginseg name "ovl_Effect_Ss_Dt_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.o" - include "build/data/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble_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 9bdb0f9a4..35302a22e 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -505,7 +505,7 @@ void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velo Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - initParams.customColor = 0; + initParams.customColor = false; initParams.colorProfile = colorProfile; initParams.scale = scale; initParams.life = life; @@ -526,7 +526,7 @@ void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* veloc initParams.scale = scale; initParams.life = life; initParams.randXZ = randXZ; - initParams.customColor = 1; + initParams.customColor = true; EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } 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 047567b98..4f8f28f3c 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -443,7 +443,7 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, PlayState* play) { bubblePos.z = this->picto.actor.world.pos.z + (2.0f * bubbleVel.z); EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &bubbleVel, &D_80AC45A4, &D_80AC45B0, - &D_80AC45B8, Rand_S16Offset(150, 50), 25, 0); + &D_80AC45B8, Rand_S16Offset(150, 50), 25, false); } if (this->picto.actor.params != 0xFF) { 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 5bc260ccc..c8b1c9823 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -317,7 +317,8 @@ void EnDragon_SpawnBubbles(EnDragon* this, PlayState* play, Vec3f basePos) { sBubbleAccel.y = Rand_ZeroFloat(1.0f) * 20.0f * 3.0f; scale = Rand_S16Offset(380, 240); EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &sBubbleVelocity, &sBubbleAccel, - &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, + false); } } 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 4b091efc3..e50fc13cd 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -113,7 +113,7 @@ void EnElfbub_Pop(EnElfbub* this, PlayState* play) { velocity.y = Rand_ZeroOne() * 7.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; EffectSsDtBubble_SpawnCustomColor(play, &pos, &velocity, &sAccel, &sPrimColor, &sEnvColor, - Rand_S16Offset(100, 50), 25, 0); + Rand_S16Offset(100, 50), 25, false); } SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); 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 7563d07fa..4c74a779c 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -297,9 +297,9 @@ void func_80B509A8(EnGk* this, PlayState* play) { } EffectSsDtBubble_SpawnCustomColor(play, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, - Rand_S16Offset(15, 15), phi_s1, 0); + Rand_S16Offset(15, 15), phi_s1, false); EffectSsDtBubble_SpawnCustomColor(play, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, - Rand_S16Offset(15, 15), phi_s1, 0); + Rand_S16Offset(15, 15), phi_s1, false); } void func_80B50B38(EnGk* this, PlayState* play) { 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 50f0c1e1e..81cb9850c 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 @@ -176,7 +176,8 @@ void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { sp74.x += randPlusMinusPoint5Scaled(15.0f); sp74.z += randPlusMinusPoint5Scaled(15.0f); - EffectSsDtBubble_SpawnCustomColor(play, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, 1); + EffectSsDtBubble_SpawnCustomColor(play, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, + true); } this->unk_218 = 30; } @@ -218,7 +219,8 @@ void func_80BDB59C(EnHiddenNuts* this, PlayState* play) { sp78.x += randPlusMinusPoint5Scaled(15.0f); sp78.z += randPlusMinusPoint5Scaled(15.0f); - EffectSsDtBubble_SpawnCustomColor(play, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, 1); + EffectSsDtBubble_SpawnCustomColor(play, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, + true); } this->unk_218 = 30; } 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 a2f2c618f..ef348f4cc 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -5,6 +5,7 @@ */ #include "z_en_part.h" +#include "overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h" #define FLAGS (ACTOR_FLAG_10) @@ -96,7 +97,7 @@ void func_808654C4(EnPart* this, PlayState* play) { effectVelocity.y = Rand_ZeroOne() + 1.0f; effectScale = Rand_S16Offset(80, 100); EffectSsDtBubble_SpawnColorProfile(play, &effectPos, &effectVelocity, &gZeroVec3f, effectScale, 25, - 0, 1); + DTBUBBLE_COLOR_PROFILE_RED, true); } break; } 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 f631439bd..d9059577c 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 @@ -285,7 +285,7 @@ void func_80A365EC(EnSyatekiOkuta* this, PlayState* play) { sp84.y = Rand_ZeroOne() * 7.0f; sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, - &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + &D_80A37BA8, Rand_S16Offset(100, 50), 25, false); } func_80A362F8(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 4f19b73a8..542a564f5 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -371,7 +371,7 @@ void func_80BB71C8(EnTanron2* this, PlayState* play) { sp9C.z = spA8.z * -0.03f; EffectSsDtBubble_SpawnCustomColor(play, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, - Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, false); } } 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 64d8b2dd7..d683cde8c 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -142,7 +142,8 @@ void EnTanron3_SpawnBubbles(EnTanron3* this, PlayState* play) { acceleration.y = velocity.y * -0.05f; acceleration.z = velocity.z * -0.05f; EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &velocity, &acceleration, &sPrimColor, - &sEnvColor, Rand_ZeroFloat(30.0f) + 70.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + &sEnvColor, Rand_ZeroFloat(30.0f) + 70.0f, Rand_ZeroFloat(5.0f) + 15.0f, + false); } } 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 011d8a101..9dab9c61a 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 @@ -1,7 +1,7 @@ /* * File: z_eff_ss_bubble.c * Overlay: ovl_Effect_Ss_Bubble - * Description: + * Description: Water Bubbles */ #include "z_eff_ss_bubble.h" diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c index a4aed4732..4d009c00a 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c @@ -1,27 +1,116 @@ /* * File: z_eff_ss_dt_bubble.c * Overlay: ovl_Effect_Ss_Dt_Bubble - * Description: + * Description: Non-Water Bubbles (a random mix of translucent and opaque) */ #include "z_eff_ss_dt_bubble.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 rRandXZ regs[8] +#define rScale regs[9] +#define rLifespan regs[10] #define PARAMS ((EffectSsDtBubbleInitParams*)initParamsx) -s32 EffectSsDtBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsDtBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsDtBubble_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDtBubble_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 +static Color_RGBA8 sPrimColors[] = { + { 255, 255, 100, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, + { 255, 255, 255, 255 }, +}; + +static Color_RGBA8 sEnvColors[] = { + { 170, 0, 0, 255 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, + { 150, 150, 150, 0 }, +}; + const EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { EFFECT_SS_DT_BUBBLE, EffectSsDtBubble_Init, }; -#endif +u32 EffectSsDtBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDtBubbleInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Init.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Draw.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Update.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->life = initParams->life; + + if (!initParams->customColor) { + this->rPrimColorR = sPrimColors[initParams->colorProfile].r; + this->rPrimColorG = sPrimColors[initParams->colorProfile].g; + this->rPrimColorB = sPrimColors[initParams->colorProfile].b; + this->rPrimColorA = sPrimColors[initParams->colorProfile].a; + this->rEnvColorR = sEnvColors[initParams->colorProfile].r; + this->rEnvColorG = sEnvColors[initParams->colorProfile].g; + this->rEnvColorB = sEnvColors[initParams->colorProfile].b; + this->rEnvColorA = sEnvColors[initParams->colorProfile].a; + } else { + 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->rRandXZ = initParams->randXZ; + this->rScale = initParams->scale; + this->rLifespan = initParams->life; + this->draw = EffectSsDtBubble_Draw; + this->update = EffectSsDtBubble_Update; + + return 1; +} + +void EffectSsDtBubble_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.004f; + 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); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + (this->rPrimColorA * this->life) / this->rLifespan); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, + (this->rEnvColorA * this->life) / this->rLifespan); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDtBubble_Update(PlayState* play, u32 index, EffectSs* this) { + if (this->rRandXZ == true) { + this->pos.x += (Rand_ZeroOne() * 2.0f) - 1.0f; + this->pos.z += (Rand_ZeroOne() * 2.0f) - 1.0f; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h index 75847c0c4..e572f4a2c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h @@ -3,6 +3,13 @@ #include "global.h" +typedef enum { + /* 0 */ DTBUBBLE_COLOR_PROFILE_RED, + /* 1 */ DTBUBBLE_COLOR_PROFILE_GREEN, + /* 2 */ DTBUBBLE_COLOR_PROFILE_BLUE, + /* 3 */ DTBUBBLE_COLOR_PROFILE_CLEAR +} DtBubbleColorProfile; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; From 71e4046415cde8c96522101b044dd40c158b61f6 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:15:48 -0700 Subject: [PATCH 14/73] Effect Deadds OK (#1018) * OK * cleanup * Fix merge * Small cleanups --- assets/xml/objects/gameplay_keep.xml | 2 +- spec | 3 +- .../ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c | 3 +- .../ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c | 111 ++++++++++++++++-- 4 files changed, 107 insertions(+), 12 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index e042feda0..9f958e974 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1182,7 +1182,7 @@ - + diff --git a/spec b/spec index bef6cdca6..b0ad8b8b8 100644 --- a/spec +++ b/spec @@ -1938,8 +1938,7 @@ beginseg name "ovl_Effect_Ss_Dead_Ds" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.o" - include "build/data/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds.data.o" - include "build/data/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c index 6dfbce5a1..5e8a1e451 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c @@ -116,14 +116,13 @@ void EffectSsDeadDd_Draw(PlayState* play, u32 index, EffectSs* this) { gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054940); + gSPDisplayList(POLY_XLU_DISP++, gLensFlareCircleDL); } CLOSE_DISPS(gfxCtx); } void EffectSsDeadDd_Update(PlayState* play, u32 index, EffectSs* this) { - this->rScale += this->rScaleStep; if (this->rScale < 0) { diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c index e5079f55d..7bf60c2a1 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c @@ -1,27 +1,124 @@ /* * File: z_eff_ss_dead_ds.c * Overlay: ovl_Effect_Ss_Dead_Ds - * Description: + * Description: Burn mark on the floor */ #include "z_eff_ss_dead_ds.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTimer regs[1] +#define rRoll regs[2] +#define rPitch regs[3] +#define rYaw regs[4] +#define rAlpha regs[5] +#define rScaleStep regs[9] +#define rAlphaStep regs[10] +#define rHalfOfLife regs[11] #define PARAMS ((EffectSsDeadDsInitParams*)initParamsx) -s32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsDeadDs_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dead_Ds_InitVars = { EFFECT_SS_DEAD_DS, EffectSsDeadDs_Init, }; -#endif +u32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDsInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->rScaleStep = initParams->scaleStep; + this->rHalfOfLife = initParams->life / 2; + this->rAlphaStep = initParams->alpha / this->rHalfOfLife; + this->draw = EffectSsDeadDs_Draw; + this->update = EffectSsDeadDs_Update; + this->rScale = initParams->scale; + this->rAlpha = initParams->alpha; + this->rTimer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Update.s") +void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + s32 pad2[2]; + MtxF mf; + f32 yIntersect; + Vec3f pos; + CollisionPoly* floorPoly; + + OPEN_DISPS(play->state.gfxCtx); + + scale = this->rScale * 0.01f; + func_8012C974(play->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + pos = this->pos; + + if (this->rTimer == 0) { + Vec3s rot; + Vec3f prevPos; + + prevPos.x = pos.x - this->velocity.x; + prevPos.y = pos.y - this->velocity.y; + prevPos.z = pos.z - this->velocity.z; + + if (BgCheck_EntitySphVsWall1(&play->colCtx, &this->pos, &pos, &prevPos, 1.5f, &floorPoly, 1.0f)) { + func_800C0094(floorPoly, this->pos.x, this->pos.y, this->pos.z, &mf); + Matrix_Put(&mf); + } else { + pos.y++; + yIntersect = BgCheck_EntityRaycastFloor1(&play->colCtx, &floorPoly, &pos); + + if (floorPoly != NULL) { + func_800C0094(floorPoly, this->pos.x, yIntersect + 1.5f, this->pos.z, &mf); + Matrix_Put(&mf); + } else { + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Get(&mf); + } + } + + Matrix_MtxFToZYXRot(&mf, &rot, false); + this->rRoll = rot.x; + this->rPitch = rot.y; + this->rYaw = rot.z; + this->pos.y = mf.yw; + this->rTimer++; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateZYX(this->rRoll, this->rPitch, this->rYaw, MTXMODE_APPLY); + Matrix_RotateXFApply(1.57f); // (M_PI / 2) + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + gSPDisplayList(POLY_XLU_DISP++, gLensFlareCircleDL); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EffectSsDeadDs_Update(PlayState* play, u32 index, EffectSs* this) { + if (this->life < this->rHalfOfLife) { + + this->rScale += this->rScaleStep; + if (this->rScale < 0) { + this->rScale = 0; + } + + this->rAlpha -= this->rAlphaStep; + if (this->rAlpha < 0) { + this->rAlpha = 0; + } + } +} From b5a9189cef20a81439cb98475e7502bb89f8fa4a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:21:08 -0700 Subject: [PATCH 15/73] Effect Deaddb OK (#1037) * OK * Add description * format * Fix EffectSsDeadDbInitParams size comment --- assets/xml/objects/gameplay_keep.xml | 22 ++-- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 6 +- .../ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c | 116 ++++++++++++++++-- .../ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h | 4 +- undefined_syms.txt | 1 - 7 files changed, 128 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 9f958e974..372c6031e 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1075,17 +1075,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/spec b/spec index b0ad8b8b8..501335c57 100644 --- a/spec +++ b/spec @@ -1923,8 +1923,7 @@ beginseg name "ovl_Effect_Ss_Dead_Db" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.data.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db_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 35302a22e..09c3621ad 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -940,7 +940,7 @@ void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac // EffectSsDeadDb Spawn Functions void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, - Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) { + Color_RGBA8* env, s16 scale, s16 scaleStep, s32 life) { EffectSsDeadDbInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -955,7 +955,7 @@ void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* a initParams.envColor.r = env->r; initParams.envColor.g = env->g; initParams.envColor.b = env->b; - initParams.unk_30 = unk; + initParams.life = life; EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams); } 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 5ce0f0286..2dedc7c2a 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -144,8 +144,8 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; 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, + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, }; static InitChainEntry sInitChain[] = { @@ -532,7 +532,7 @@ void EnVm_Draw(Actor* thisx, PlayState* play) { gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); gSPSegment(&gfx[5], 0x08, D_808CD58C[play->gameplayFrames & 7]); - gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + gSPDisplayList(&gfx[6], gEffEnemyDeathFlameDL); POLY_XLU_DISP = &gfx[7]; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c index 616d30d03..54963eb3b 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c @@ -1,27 +1,129 @@ /* * File: z_eff_ss_dead_db.c * Overlay: ovl_Effect_Ss_Dead_Db - * Description: + * Description: Enemy Death Flames */ #include "z_eff_ss_dead_db.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTexIndex 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 rScaleStep regs[9] +#define rTotalLife regs[11] #define PARAMS ((EffectSsDeadDbInitParams*)initParamsx) -s32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dead_Db_InitVars = { EFFECT_SS_DEAD_DB, EffectSsDeadDb_Init, }; -#endif +static TexturePtr sTextures[] = { + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, + gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Init.s") +u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDbInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Draw.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffEnemyDeathFlameDL; + this->life = initParams->life; + this->flags = 4; + this->rScaleStep = initParams->scaleStep; + this->rTotalLife = initParams->life; + this->draw = EffectSsDeadDb_Draw; + this->update = EffectSsDeadDb_Update; + this->rScale = initParams->scale; + this->rTexIndex = 0; + 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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Update.s") + return 1; +} + +void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.01f; + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, scale); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this) { + this->rTexIndex = (f32)((this->rTotalLife - this->life) * 9) / this->rTotalLife; + this->rScale += this->rScaleStep; + + this->rPrimColorR -= 10; + if (this->rPrimColorR < 0) { + this->rPrimColorR = 0; + } + + this->rPrimColorG -= 10; + if (this->rPrimColorG < 0) { + this->rPrimColorG = 0; + } + + this->rPrimColorB -= 10; + if (this->rPrimColorB < 0) { + this->rPrimColorB = 0; + } + + this->rEnvColorR -= 10; + if (this->rEnvColorR < 0) { + this->rEnvColorR = 0; + } + + this->rEnvColorG -= 10; + if (this->rEnvColorG < 0) { + this->rEnvColorG = 0; + } + + this->rEnvColorB -= 10; + if (this->rEnvColorB < 0) { + this->rEnvColorB = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h index bbdf3c290..a1ac62167 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h @@ -11,8 +11,8 @@ typedef struct { /* 0x26 */ s16 scaleStep; /* 0x28 */ Color_RGBA8 primColor; /* 0x2C */ Color_RGBA8 envColor; - /* 0x30 */ s32 unk_30; -} EffectSsDeadDbInitParams; // size = 0x30 + /* 0x30 */ s32 life; +} EffectSsDeadDbInitParams; // size = 0x34 extern const EffectSsInit Effect_Ss_Dead_Db_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 20a4cf5e2..6623ed8ac 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -428,7 +428,6 @@ D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; D_0403F230 = 0x0403F230; -D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; D_04050550 = 0x04050550; D_04050D10 = 0x04050D10; From 1402db400813197ff3b2c461db2e3e37a66a5ee1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:26:08 -0700 Subject: [PATCH 16/73] Effect Dfire OK (#1038) * OK * rename function * MTXMODE enum * PR * Format * % -> & * note --- assets/xml/objects/object_dodongo.xml | 10 +- include/functions.h | 2 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- .../ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c | 102 ++++++++++++++++-- .../ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h | 4 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 8 -- 8 files changed, 108 insertions(+), 27 deletions(-) diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index df70802d0..8de3f4653 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -62,7 +62,13 @@ - - + + + + + + + + diff --git a/include/functions.h b/include/functions.h index fa90ff688..9a81e2ded 100644 --- a/include/functions.h +++ b/include/functions.h @@ -539,7 +539,7 @@ void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* arg1, Vec3f* arg2 void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel); // void EffectSsGSpk_SpawnRandColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsGSpk_SpawnSmall(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 EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 life, s32 arg9); +void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 alphaStep, s16 fadeDelay, s32 life); void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); diff --git a/spec b/spec index 501335c57..f93b54e6b 100644 --- a/spec +++ b/spec @@ -1774,8 +1774,7 @@ beginseg name "ovl_Effect_Ss_D_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.o" - include "build/data/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire.data.o" - include "build/data/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire_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 09c3621ad..6d1a9176e 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -404,7 +404,7 @@ void EffectSsGSpk_SpawnSmall(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* v // EffectSsDFire Spawn Functions void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 alpha, s16 fadeDelay, s16 arg8, s32 life) { + s16 alpha, s16 alphaStep, s16 fadeDelay, s32 life) { EffectSsDFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -413,8 +413,8 @@ void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac initParams.scale = scale; initParams.scaleStep = scaleStep; initParams.alpha = alpha; + initParams.alphaStep = alphaStep; initParams.fadeDelay = fadeDelay; - initParams.unk_2C = arg8; initParams.life = life; EffectSs_Spawn(play, EFFECT_SS_D_FIRE, 128, &initParams); diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c index ff8c54053..9d8eecfbc 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c @@ -1,31 +1,115 @@ /* * File: z_eff_ss_d_fire.c * Overlay: ovl_Effect_Ss_D_Fire - * Description: + * Description: Dodongo Fire */ #include "z_eff_ss_d_fire.h" +#include "objects/object_dodongo/object_dodongo.h" + +#define rScale regs[0] +#define rTexIndex regs[1] +#define rAlpha regs[5] +#define rAlphaStep regs[6] +#define rFadeDelay regs[7] +#define rScaleStep regs[8] +#define rObjectIndex regs[9] #define PARAMS ((EffectSsDFireInitParams*)initParamsx) -s32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_D_Fire_InitVars = { EFFECT_SS_D_FIRE, EffectSsDFire_Init, }; -#endif +static TexturePtr sFireTextures[] = { gDodongoFire0Tex, gDodongoFire1Tex, gDodongoFire2Tex, gDodongoFire3Tex }; -extern UNK_TYPE D_060098A0; +s32 EffectSsDFire_CheckForObject(EffectSs* this, PlayState* play) { + if (((this->rObjectIndex = Object_GetIndex(&play->objectCtx, OBJECT_DODONGO)) < 0) || + !Object_IsLoaded(&play->objectCtx, this->rObjectIndex)) { + this->life = -1; + this->draw = NULL; + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/func_809791B0.s") +u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Init.s") + if (EffectSsDFire_CheckForObject(this, play)) { + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gDodongoFireDL; + this->life = initParams->life; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->draw = EffectSsDFire_Draw; + this->update = EffectSsDFire_Update; + this->rTexIndex = (play->state.frames & 3) ^ 3; // The xor reverses order, i.e 3 -> 2 -> 1 -> 0 -> 3 + this->rAlpha = initParams->alpha; + this->rFadeDelay = this->life - initParams->fadeDelay; + this->rAlphaStep = initParams->alphaStep; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Draw.s") + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Update.s") + return 0; +} + +void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + void* object; + f32 scale; + + if (EffectSsDFire_CheckForObject(this, play)) { + object = play->objectCtx.status[this->rObjectIndex].segment; + + OPEN_DISPS(gfxCtx); + + gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSPSegment(POLY_XLU_DISP++, 0x06, object); + + scale = this->rScale / 100.0f; + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, this->rAlpha); + + { + TexturePtr* tex = sFireTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this) { + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; + if (this->life < this->rFadeDelay) { + this->rAlpha -= this->rAlphaStep; + if (this->rAlpha < 0) { + this->rAlpha = 0; + this->life = -1; + } + } + + EffectSsDFire_CheckForObject(this, play); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h index 09298249d..2d657bc43 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h @@ -10,8 +10,8 @@ typedef struct { /* 0x24 */ s16 scale; /* 0x26 */ s16 scaleStep; /* 0x28 */ s16 alpha; - /* 0x2A */ s16 fadeDelay; - /* 0x2C */ s16 unk_2C; + /* 0x2A */ s16 alphaStep; + /* 0x2C */ s16 fadeDelay; /* 0x30 */ s32 life; } EffectSsDFireInitParams; // size = 0x34 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index be488e0d9..c76ff1601 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8147,7 +8147,7 @@ 0x80978D70:("EffectSsGSpk_Draw",), 0x80978F40:("EffectSsGSpk_Update",), 0x80979068:("EffectSsGSpk_UpdateNoAccel",), - 0x809791B0:("func_809791B0",), + 0x809791B0:("EffectSsDFire_CheckForObject",), 0x80979228:("EffectSsDFire_Init",), 0x8097930C:("EffectSsDFire_Draw",), 0x809794D4:("EffectSsDFire_Update",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 6623ed8ac..4feb10cca 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -844,14 +844,6 @@ D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -// ovl_Effect_Ss_D_Fire - -D_060098A0 = 0x060098A0; - -// ovl_Effect_Ss_Extra - -D_06000DC0 = 0x06000DC0; - // ovl_Eff_Kamejima_Wave D_06000000 = 0x06000000; From 77be902c25e0427fed6f7854ff080f391909ed8f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:31:20 -0700 Subject: [PATCH 17/73] Effect Bomb2 Ok (#1039) * OK * PR --- assets/xml/objects/gameplay_keep.xml | 22 +-- spec | 3 +- .../ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c | 185 +++++++++++++++++- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 3 - 5 files changed, 189 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 372c6031e..b958f6cf2 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -845,17 +845,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/spec b/spec index f93b54e6b..0e9d0a781 100644 --- a/spec +++ b/spec @@ -1751,8 +1751,7 @@ beginseg name "ovl_Effect_Ss_Bomb2" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.o" - include "build/data/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2.data.o" - include "build/data/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c index 7903deffa..d15151d49 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c @@ -1,30 +1,195 @@ /* * File: z_eff_ss_bomb2.c * Overlay: ovl_Effect_Ss_Bomb2 - * Description: + * Description: Bomb Blast */ #include "z_eff_ss_bomb2.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTexIndex 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 rScaleStep regs[9] +#define rDepth regs[10] #define PARAMS ((EffectSsBomb2InitParams*)initParamsx) -s32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this); +void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this); void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this); -void func_80978138(PlayState* play, u32 index, EffectSs* this); -void func_80978304(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bomb2_InitVars = { EFFECT_SS_BOMB2, EffectSsBomb2_Init, }; -#endif +static EffectSsDrawFunc sDrawFuncs[] = { + EffectSsBomb2_DrawFade, + EffectSsBomb2_DrawLayered, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/EffectSsBomb2_Init.s") +static TexturePtr sTextures[] = { + gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, + gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/func_80978138.s") +static TexturePtr sLayeredTextures[] = { + gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, + gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/func_80978304.s") +u32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBomb2InitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/EffectSsBomb2_Update.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffBombExplosion1DL; + this->life = 24; + this->update = EffectSsBomb2_Update; + this->draw = sDrawFuncs[initParams->drawMode]; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 255; + this->rPrimColorA = 255; + this->rEnvColorR = 0; + this->rEnvColorG = 0; + this->rEnvColorB = 200; + + return 1; +} + +// unused in the original game. looks like EffectSsBomb but with color +void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + s32 pad; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + MtxF mtx2F; + Mtx* mtx2; + Mtx* mtx; + s32 pad[3]; + f32 scale; + f32 depth; + f32 layer2Scale = 0.925f; + s32 i; + + OPEN_DISPS(gfxCtx); + + depth = this->rDepth; + scale = this->rScale * 0.01f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx2 = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx2 != NULL) { + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLayeredTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion2DL); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); + + Matrix_MtxToMtxF(mtx2, &mtx2F); + Matrix_Put(&mtx2F); + + for (i = 1; i >= 0; i--) { + Matrix_Translate(0.0f, 0.0f, depth, MTXMODE_APPLY); + Matrix_RotateZF((this->life * 0.02f) + 180.0f, MTXMODE_APPLY); + Matrix_Scale(layer2Scale, layer2Scale, layer2Scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); + layer2Scale -= 0.15f; + } + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this) { + s32 divisor; + + this->rTexIndex = (23 - this->life) / 3; + this->rScale += this->rScaleStep; + + if (this->rScaleStep == 30) { + this->rDepth += 4; + } else { + this->rDepth += 2; + } + + if ((this->life < 23) && (this->life > 13)) { + divisor = this->life - 13; + this->rPrimColorR = func_800B096C(this->rPrimColorR, 255, divisor); + this->rPrimColorG = func_800B096C(this->rPrimColorG, 255, divisor); + this->rPrimColorB = func_800B096C(this->rPrimColorB, 150, divisor); + this->rPrimColorA = func_800B096C(this->rPrimColorA, 255, divisor); + this->rEnvColorR = func_800B096C(this->rEnvColorR, 150, divisor); + this->rEnvColorG = func_800B096C(this->rEnvColorG, 0, divisor); + this->rEnvColorB = func_800B096C(this->rEnvColorB, 0, divisor); + } else if ((this->life < 14) && (this->life > -1)) { + divisor = this->life + 1; + this->rPrimColorR = func_800B096C(this->rPrimColorR, 50, divisor); + this->rPrimColorG = func_800B096C(this->rPrimColorG, 50, divisor); + this->rPrimColorB = func_800B096C(this->rPrimColorB, 50, divisor); + this->rPrimColorA = func_800B096C(this->rPrimColorA, 150, divisor); + this->rEnvColorR = func_800B096C(this->rEnvColorR, 10, divisor); + this->rEnvColorG = func_800B096C(this->rEnvColorG, 10, divisor); + this->rEnvColorB = func_800B096C(this->rEnvColorB, 10, divisor); + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c76ff1601..eaeb2f69d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8137,8 +8137,8 @@ 0x80977E6C:("func_80977E6C",), 0x80977F28:("func_80977F28",), 0x80978070:("EffectSsBomb2_Init",), - 0x80978138:("func_80978138",), - 0x80978304:("func_80978304",), + 0x80978138:("EffectSsBomb2_DrawFade",), + 0x80978304:("EffectSsBomb2_DrawLayered",), 0x80978628:("EffectSsBomb2_Update",), 0x809788D0:("EffectSsBlast_Init",), 0x809789FC:("EffectSsBlast_Draw",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 4feb10cca..5cb5cdf0b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -385,9 +385,6 @@ D_04014560 = 0x04014560; D_04015DB0 = 0x04015DB0; D_04015FA0 = 0x04015FA0; D_04016360 = 0x04016360; -D_0401A4D0 = 0x0401A4D0; -D_0401A538 = 0x0401A538; -D_0401A590 = 0x0401A590; D_0401ACF0 = 0x0401ACF0; D_0401ED00 = 0x0401ED00; D_0401F0F0 = 0x0401F0F0; From 71a18d70cf85970dd73c3bdb0fa18c0ccad5131d Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:36:55 -0700 Subject: [PATCH 18/73] OK (#1040) --- include/functions.h | 2 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- .../ovl_Effect_Ss_Blast/z_eff_ss_blast.c | 77 +++++++++++++++++-- .../ovl_Effect_Ss_Blast/z_eff_ss_blast.h | 2 +- 5 files changed, 75 insertions(+), 13 deletions(-) diff --git a/include/functions.h b/include/functions.h index 9a81e2ded..416c7ca29 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2552,7 +2552,7 @@ void func_80168DAC(PlayState* play); void Play_Main(PlayState* play); s32 Play_InCsMode(PlayState* play); f32 func_80169100(PlayState* play, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); -// void func_801691F0(void); +void func_801691F0(PlayState* play, MtxF* mtx, Vec3f* arg2); void* Play_LoadScene(PlayState* play, RomFile* entry); void func_8016927C(PlayState* play, s16 sParm2); // void func_801692C4(PlayState* play, UNK_TYPE1 uParm2); diff --git a/spec b/spec index 0e9d0a781..334ff6bbb 100644 --- a/spec +++ b/spec @@ -1758,8 +1758,7 @@ beginseg name "ovl_Effect_Ss_Blast" compress include "build/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.o" - include "build/data/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast.data.o" - include "build/data/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast_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 6d1a9176e..5fc51b0c3 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -298,7 +298,7 @@ void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Ve // EffectSsBlast Spawn Functions void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life) { + Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { EffectSsBlastInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -308,7 +308,7 @@ void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac Color_RGBA8_Copy(&initParams.envColor, envColor); initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.sclaeStepDecay = sclaeStepDecay; + initParams.scaleStepDecay = scaleStepDecay; initParams.life = life; EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams); diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c index bb4cada88..93353f28c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c @@ -1,27 +1,90 @@ /* * File: z_eff_ss_blast.c * Overlay: ovl_Effect_Ss_Blast - * Description: + * Description: Shockwave Effect */ #include "z_eff_ss_blast.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 rAlphaStep regs[8] +#define rScale regs[9] +#define rScaleStep regs[10] +#define rScaleStepDecay regs[11] #define PARAMS ((EffectSsBlastInitParams*)initParamsx) -s32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Blast_InitVars = { EFFECT_SS_BLAST, EffectSsBlast_Init, }; -#endif +u32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBlastInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Init.s") + this->pos = initParams->pos; + this->pos.y += 5.0f; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->gfx = gEffShockwaveDL; + this->life = initParams->life; + this->draw = EffectSsBlast_Draw; + this->update = EffectSsBlast_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->rAlphaStep = initParams->primColor.a / initParams->life; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rScaleStepDecay = initParams->scaleStepDecay; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Update.s") +void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mf; + s32 pad; + f32 radius; + + OPEN_DISPS(gfxCtx); + + radius = this->rScale * 0.0025f; + + func_8012C2DC(play->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + func_801691F0(play, &mf, &this->pos); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + Matrix_Put(&mf); + Matrix_Scale(radius, radius, radius, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this) { + Math_StepToS(&this->rPrimColorA, 0, this->rAlphaStep); + this->rScale += this->rScaleStep; + + if (this->rScaleStep != 0) { + this->rScaleStep -= this->rScaleStepDecay; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h index 2a13227c3..72a264c03 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h @@ -11,7 +11,7 @@ typedef struct { /* 0x28 */ Color_RGBA8 envColor; /* 0x2C */ s16 scale; /* 0x2E */ s16 scaleStep; - /* 0x30 */ s16 sclaeStepDecay; + /* 0x30 */ s16 scaleStepDecay; /* 0x32 */ s16 life; } EffectSsBlastInitParams; // size = 0x34 From cdee1fc45b5b327a4169ecb3aa899174ddcfc851 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 24 Sep 2022 13:43:21 -0400 Subject: [PATCH 19/73] `z_kaleido_prompt.c` Ok and Documented (Pause Menu Save/Continue Prompt. Unused) (#1045) * kaleido prompt ok * fix pauseCtx --- include/z64.h | 4 +- spec | 1 + src/code/z_kaleido_setup.c | 2 +- .../ovl_kaleido_scope/z_kaleido_mask.c | 10 +--- .../ovl_kaleido_scope/z_kaleido_prompt.c | 49 +++++++++++++++++++ .../ovl_kaleido_scope/z_kaleido_scope.h | 3 ++ tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 6 +-- 8 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c diff --git a/include/z64.h b/include/z64.h index cf4643d53..4128a2b38 100644 --- a/include/z64.h +++ b/include/z64.h @@ -469,8 +469,8 @@ typedef struct { /* 0x290 */ f32 unk_290; /* 0x294 */ f32 unk_294; /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x29E */ s16 unk_29E; + /* 0x29C */ s16 promptChoice; // save/continue choice: 0 = yes; 4 = no + /* 0x29E */ s16 promptAlpha; /* 0x2A0 */ s16 unk_2A0; /* 0x2A2 */ u8 worldMapPoints[20]; /* 0x2B6 */ u8 unk_2B6; diff --git a/spec b/spec index 334ff6bbb..dcdf27862 100644 --- a/spec +++ b/spec @@ -703,6 +703,7 @@ beginseg include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.o" include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.o" include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.o" + include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.o" include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.o" include "build/data/ovl_kaleido_scope/ovl_kaleido_scope.bss.o" include "build/data/ovl_kaleido_scope/ovl_kaleido_scope.reloc.o" diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index fa490dbca..a2742c746 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -138,7 +138,7 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->unk_2A0 = -1; pauseCtx->unk_2BA = 320; pauseCtx->unk_2BC = 40; - pauseCtx->unk_29E = 100; + pauseCtx->promptAlpha = 100; View_Init(&pauseCtx->view, play->state.gfxCtx); } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index aa24bf2e2..f8f61c5dc 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -50,18 +50,10 @@ s16 D_8082B6DC[] = { 0x0000, }; -s32 D_8082B6E4[] = { 0, 0, 0 }; - -s16 D_8082B6F0[] = { 100, 255 }; - -s32 D_8082B6F4 = 0; - -s16 D_8082B6F8[] = { 10, 0, 0, 0 }; +s16 D_8082B6E4 = 0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FF80.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808204AC.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80820FA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821730.s") diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c new file mode 100644 index 000000000..53453e8e7 --- /dev/null +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c @@ -0,0 +1,49 @@ +/* + * File: z_kaleido_prompt.c + * Overlay: ovl_kaleido_scope + * Description: Pause Menu - Save and Continue Prompt + */ + +#include "z_kaleido_scope.h" + +s16 sPromptAlphaTargets[] = { 100, 255 }; + +// Unused remnant of OoT +void KaleidoScope_UpdatePrompt(PlayState* play) { + static s16 sPromptAlphaTargetIndex = 0; + static s16 sPromptAlphaTimer = 10; + PauseContext* pauseCtx = &play->pauseCtx; + Input* input = CONTROLLER1(&play->state); + s8 relStickX = input->rel.stick_x; + s16 alphaStep; + + if (((pauseCtx->state == 7) && (pauseCtx->unk_208 == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x11)) { + + // Move the prompt + if ((pauseCtx->promptChoice == PAUSE_PROMPT_YES) && (relStickX >= 30)) { + // Move right to the no prompt + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_NO; + } else if ((pauseCtx->promptChoice != PAUSE_PROMPT_YES) && (relStickX <= -30)) { + // Move left to the yes prompt + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + } + + // Update the alpha for the green glowing orb above the prompt + alphaStep = ABS_ALT(pauseCtx->promptAlpha - sPromptAlphaTargets[sPromptAlphaTargetIndex]) / sPromptAlphaTimer; + + if (pauseCtx->promptAlpha >= sPromptAlphaTargets[sPromptAlphaTargetIndex]) { + pauseCtx->promptAlpha -= alphaStep; + } else { + pauseCtx->promptAlpha += alphaStep; + } + + sPromptAlphaTimer--; + if (sPromptAlphaTimer == 0) { + pauseCtx->promptAlpha = sPromptAlphaTargets[sPromptAlphaTargetIndex]; + sPromptAlphaTimer = sPromptAlphaTargetIndex + 20; + sPromptAlphaTargetIndex ^= 1; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index f4c91e9e8..b4d2a192f 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -18,6 +18,9 @@ typedef enum { /* 3 */ DEBUG_EDITOR_EVENTS } DebugEditor; +#define PAUSE_PROMPT_YES 0 +#define PAUSE_PROMPT_NO 4 + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index eaeb2f69d..70850a769 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4217,7 +4217,7 @@ 0x8081FF80:("func_8081FF80",), 0x808204AC:("func_808204AC",), 0x80820FA4:("func_80820FA4",), - 0x80821730:("func_80821730",), + 0x80821730:("KaleidoScope_UpdatePrompt",), 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), 0x80821958:("func_80821958",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 94a59d695..32ae1dd5e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4734,9 +4734,9 @@ 0x8082B6D4:("D_8082B6D4","UNK_TYPE1","",0x1), 0x8082B6DC:("D_8082B6DC","UNK_TYPE1","",0x1), 0x8082B6E4:("D_8082B6E4","UNK_TYPE2","",0x2), - 0x8082B6F0:("D_8082B6F0","UNK_TYPE1","",0x1), - 0x8082B6F4:("D_8082B6F4","UNK_TYPE2","",0x2), - 0x8082B6F8:("D_8082B6F8","UNK_TYPE2","",0x2), + 0x8082B6F0:("sPromptAlphaTargets","UNK_TYPE1","",0x1), + 0x8082B6F4:("sPromptAlphaTargetIndex","UNK_TYPE2","",0x2), + 0x8082B6F8:("sPromptAlphaTimer","UNK_TYPE2","",0x2), 0x8082B700:("D_8082B700","UNK_TYPE1","",0x1), 0x8082B73C:("D_8082B73C","UNK_TYPE1","",0x1), 0x8082B778:("D_8082B778","UNK_TYPE1","",0x1), From b4adfb0a2224e5c87a5e3679b1804c75377b3b18 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Sat, 24 Sep 2022 10:49:07 -0700 Subject: [PATCH 20/73] Fbdemo_triforce OK with documentation (#1053) * close to done * OK and doc'd * PR feedback * 4mat * PR feedback round 2 * fixed engineers comment --- assets/xml/objects/object_fbdemo_triforce.xml | 8 ++ include/functions.h | 4 +- spec | 3 +- .../ovl_fbdemo_triforce/z_fbdemo_triforce.c | 136 +++++++++++++++--- .../ovl_fbdemo_triforce/z_fbdemo_triforce.h | 23 ++- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- 7 files changed, 153 insertions(+), 27 deletions(-) create mode 100644 assets/xml/objects/object_fbdemo_triforce.xml diff --git a/assets/xml/objects/object_fbdemo_triforce.xml b/assets/xml/objects/object_fbdemo_triforce.xml new file mode 100644 index 000000000..a00c9bf13 --- /dev/null +++ b/assets/xml/objects/object_fbdemo_triforce.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 416c7ca29..4b116af1f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -200,7 +200,7 @@ s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); // void osVoiceSetWord(void); -// void guScale(void); +void guScale(Mtx* mtx, f32 x, f32 y, f32 z); f32 sinf(f32 __x); s16 sins(u16 x); OSTask* _VirtualToPhysicalTask(OSTask* intp); @@ -383,7 +383,7 @@ u32 osAiGetLength(void); s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data); void osMapTLBRdb(void); void osYieldThread(void); -// void guTranslate(void); +void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z); u32 __osGetCause(void); s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); diff --git a/spec b/spec index dcdf27862..eaf97f178 100644 --- a/spec +++ b/spec @@ -3228,8 +3228,7 @@ beginseg name "ovl_fbdemo_triforce" compress include "build/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.o" - include "build/data/ovl_fbdemo_triforce/ovl_fbdemo_triforce.data.o" - include "build/data/ovl_fbdemo_triforce/ovl_fbdemo_triforce.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_triforce/ovl_fbdemo_triforce_reloc.o" endseg beginseg diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c index 268f8e1a6..4584cfab2 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -5,6 +5,7 @@ */ #include "z_fbdemo_triforce.h" +#include "assets/objects/object_fbdemo_triforce/ovl_fbdemo_triforce.c" void* TransitionTriforce_Init(void* thisx); void TransitionTriforce_Destroy(void* thisx); @@ -15,35 +16,132 @@ void TransitionTriforce_SetType(void* thisx, s32 type); void TransitionTriforce_SetColor(void* thisx, u32 color); s32 TransitionTriforce_IsDone(void* thisx); -#if 0 const TransitionInit TransitionTriforce_InitVars = { - TransitionTriforce_Init, - TransitionTriforce_Destroy, - TransitionTriforce_Update, - TransitionTriforce_Draw, - TransitionTriforce_Start, - TransitionTriforce_SetType, - TransitionTriforce_SetColor, - NULL, + TransitionTriforce_Init, TransitionTriforce_Destroy, TransitionTriforce_Update, TransitionTriforce_Draw, + TransitionTriforce_Start, TransitionTriforce_SetType, TransitionTriforce_SetColor, NULL, TransitionTriforce_IsDone, }; -#endif +void TransitionTriforce_Start(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Start.s") + switch (this->state) { + case STATE_SPIRAL_IN_SLOW: + case STATE_SPIRAL_IN_FAST: + this->transPos = 1.0f; + return; + } + this->transPos = 0.03f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Init.s") +void* TransitionTriforce_Init(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Destroy.s") + bzero(this, sizeof(TransitionTriforce)); + guOrtho(&this->projection, -SCREEN_WIDTH / 2, SCREEN_WIDTH / 2, -SCREEN_HEIGHT / 2, SCREEN_HEIGHT / 2, -1000.0f, + 1000.0f, 1.0f); + this->transPos = 1.0f; + this->state = STATE_SPIRAL_IN_FAST; + this->step = 0.015f; + this->fadeType = TYPE_TRANSPARENT_TRIFORCE; + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Update.s") +void TransitionTriforce_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_SetColor.s") +void TransitionTriforce_Update(void* thisx, s32 updateRate) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_SetType.s") + for (i = updateRate; i > 0; i--) { + if (this->state == STATE_SPIRAL_IN_SLOW) { + this->transPos = CLAMP_MIN(this->transPos * (1.0f - this->step), 0.03f); + } else if (this->state == STATE_SPIRAL_IN_FAST) { + this->transPos = CLAMP_MIN(this->transPos - this->step, 0.03f); + } else if (this->state == STATE_SPIRAL_OUT_SLOW) { + this->transPos = CLAMP_MAX(this->transPos / (1.0f - this->step), 1.0f); + } else if (this->state == STATE_SPIRAL_OUT_FAST) { + this->transPos = CLAMP_MAX(this->transPos + this->step, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/func_80AC5280.s") +void TransitionTriforce_SetColor(void* thisx, u32 color) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Draw.s") + this->color.rgba = color; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_IsDone.s") +void TransitionTriforce_SetType(void* thisx, s32 type) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + this->fadeType = type; +} + +void TransitionTriforce_SetState(void* thisx, s32 state) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + this->state = state; +} + +void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + Mtx* modelView; + s32 pad[2]; + TransitionTriforce* this = (TransitionTriforce*)thisx; + f32 rotation = this->transPos * 360.0f; + + modelView = this->modelView[this->frame]; + this->frame ^= 1; + guScale(&modelView[0], this->transPos * 0.625f, this->transPos * 0.625f, 1.0f); + guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f); + guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); + gDPPipeSync(gfx++); + gSPDisplayList(gfx++, sTriforceWipeDL); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); + gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPVertex(gfx++, &sTriforceWipeVtx, ARRAY_COUNT(sTriforceWipeVtx), 0); + if (!TransitionTriforce_IsDone(this)) { + switch (this->fadeType) { + case TYPE_TRANSPARENT_TRIFORCE: + gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0); + gSP1Triangle(gfx++, 5, 3, 2, 0); + break; + + case TYPE_FILLED_TRIFORCE: + gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0); + gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0); + gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0); + gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0); + break; + } + + } else { + switch (this->fadeType) { + case TYPE_TRANSPARENT_TRIFORCE: + break; + + case TYPE_FILLED_TRIFORCE: + gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0); + break; + } + } + gDPPipeSync(gfx++); + *gfxP = gfx; +} + +s32 TransitionTriforce_IsDone(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + if ((this->state == STATE_SPIRAL_IN_SLOW) || (this->state == STATE_SPIRAL_IN_FAST)) { + return this->transPos <= 0.03f; + } else if ((this->state == STATE_SPIRAL_OUT_SLOW) || (this->state == STATE_SPIRAL_OUT_FAST)) { + return (this->transPos >= 1.0f); + } + return false; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h index 7d7dcae56..2637b32cf 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h @@ -3,8 +3,29 @@ #include "global.h" +typedef enum { + /* 0 */ STATE_NONE, + /* 1 */ STATE_SPIRAL_IN_SLOW, + /* 2 */ STATE_SPIRAL_IN_FAST, + /* 3 */ STATE_SPIRAL_OUT_SLOW, + /* 4 */ STATE_SPIRAL_OUT_FAST +} FbTriforceState; + +typedef enum { + /* 0 */ TYPE_NONE, + /* 1 */ TYPE_TRANSPARENT_TRIFORCE, + /* 2 */ TYPE_FILLED_TRIFORCE +} TriforceFadeType; + typedef struct { - /* 0x0000 */ char unk_0[0x1E0]; + /* 0x000 */ Color_RGBA8_u32 color; + /* 0x004 */ f32 transPos; + /* 0x008 */ f32 step; + /* 0x00C */ s32 state; + /* 0x010 */ s32 fadeType; + /* 0x018 */ Mtx projection; + /* 0x058 */ s32 frame; + /* 0x060 */ Mtx modelView[2][3]; } TransitionTriforce; // size = 0x1E0 extern const TransitionInit TransitionTriforce_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 70850a769..718f05e49 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11956,7 +11956,7 @@ 0x80AC5154:("TransitionTriforce_Update",), 0x80AC5268:("TransitionTriforce_SetColor",), 0x80AC5274:("TransitionTriforce_SetType",), - 0x80AC5280:("func_80AC5280",), + 0x80AC5280:("TransitionTriforce_SetState",), 0x80AC528C:("TransitionTriforce_Draw",), 0x80AC559C:("TransitionTriforce_IsDone",), 0x80AC57B0:("TransitionWipe1_Start",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 32ae1dd5e..1f8a8a974 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12926,8 +12926,8 @@ 0x80AC4F60:("D_80AC4F60","f32","",0x4), 0x80AC4F64:("D_80AC4F64","f32","",0x4), 0x80AC5060:("D_80AC5060","UNK_TYPE1","",0x1), - 0x80AC5630:("D_80AC5630","UNK_TYPE1","",0x1), - 0x80AC5660:("D_80AC5660","UNK_TYPE1","",0x1), + 0x80AC5630:("sTriforceWipeDL","UNK_TYPE1","",0x1), + 0x80AC5660:("sTriforceWipeVtx","UNK_TYPE1","",0x1), 0x80AC5700:("TransitionTriforce_InitVars","UNK_PTR","",0x4), 0x80AC5730:("D_80AC5730","f32","",0x4), 0x80AC5734:("D_80AC5734","f32","",0x4), From 0aede274ae91375baa510a0a80366afc012add59 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 10:54:40 -0700 Subject: [PATCH 21/73] Document BgInibsMoveBg (Twinmold's Arena) and object_inibs_object (#1055) * Document BgInibsMoveBg (Twinmold's Arena) and object_inibs_object * Respond to hensldm's review --- assets/xml/objects/object_inibs_object.xml | 70 +++++++++++-------- .../ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c | 37 +++++----- .../ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h | 8 +-- tools/disasm/variables.txt | 6 +- 4 files changed, 64 insertions(+), 57 deletions(-) diff --git a/assets/xml/objects/object_inibs_object.xml b/assets/xml/objects/object_inibs_object.xml index e1d454ae7..db78735fb 100644 --- a/assets/xml/objects/object_inibs_object.xml +++ b/assets/xml/objects/object_inibs_object.xml @@ -1,35 +1,43 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 bd641bf4c..68c432c5f 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 @@ -27,9 +27,9 @@ const ActorInit Bg_Inibs_Movebg_InitVars = { (ActorFunc)BgInibsMovebg_Draw, }; -Gfx* D_80B96560[] = { object_inibs_object_DL_0062D8, object_inibs_object_DL_001DC0 }; -Gfx* D_80B96568[] = { object_inibs_object_DL_006140, object_inibs_object_DL_001C10 }; -AnimatedMaterial* D_80B96570[] = { object_inibs_object_Matanimheader_006858, object_inibs_object_Matanimheader_002598 }; +Gfx* sOpaDLists[] = { gTwinmoldArenaNormalModeSandDL, gTwinmoldArenaGiantModeSandDL }; +Gfx* sXluDLists[] = { gTwinmoldArenaNormalModeCenterPlatformDL, gTwinmoldArenaGiantModeCenterPlatformDL }; +AnimatedMaterial* sSandTexAnims[] = { gTwinmoldArenaNormalModeSandTexAnim, gTwinmoldArenaGiantModeSandTexAnim }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), @@ -41,9 +41,9 @@ void BgInibsMovebg_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - this->unk_15C = D_80B96560[BGINIBSMOVEBG_GET_F(thisx)]; - this->unk_160 = D_80B96568[BGINIBSMOVEBG_GET_F(thisx)]; - this->unk_164 = D_80B96570[BGINIBSMOVEBG_GET_F(thisx)]; + this->opaDList = sOpaDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; + this->xluDList = sXluDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; + this->sandTexAnim = sSandTexAnims[BG_INIBS_MOVEBG_GET_MODE(thisx)]; } void BgInibsMovebg_Destroy(Actor* thisx, PlayState* play) { @@ -54,23 +54,22 @@ void BgInibsMovebg_Destroy(Actor* thisx, PlayState* play) { void BgInibsMovebg_Draw(Actor* thisx, PlayState* play) { BgInibsMovebg* this = THIS; + AnimatedMaterial* sandTexAnim; + Gfx* opaDList; + Gfx* xluDList; - AnimatedMaterial* animMat; - Gfx* dl1; - Gfx* dl2; - - animMat = this->unk_164; - if (animMat != NULL) { - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->unk_164)); + sandTexAnim = this->sandTexAnim; + if (sandTexAnim != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->sandTexAnim)); } - dl1 = this->unk_15C; - if (dl1 != NULL) { - Gfx_DrawDListOpa(play, this->unk_15C); + opaDList = this->opaDList; + if (opaDList != NULL) { + Gfx_DrawDListOpa(play, this->opaDList); } - dl2 = this->unk_160; - if (dl2 != NULL) { - Gfx_DrawDListXlu(play, this->unk_160); + xluDList = this->xluDList; + if (xluDList != NULL) { + Gfx_DrawDListXlu(play, this->xluDList); } } diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h index 92494a35f..629a5cd03 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h @@ -5,13 +5,13 @@ struct BgInibsMovebg; -#define BGINIBSMOVEBG_GET_F(thisx) ((u16)((thisx)->params) & 0xF) +#define BG_INIBS_MOVEBG_GET_MODE(thisx) ((u16)((thisx)->params) & 0xF) typedef struct BgInibsMovebg { /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ Gfx* unk_15C; - /* 0x160 */ Gfx* unk_160; - /* 0x164 */ AnimatedMaterial* unk_164; + /* 0x15C */ Gfx* opaDList; + /* 0x160 */ Gfx* xluDList; + /* 0x164 */ AnimatedMaterial* sandTexAnim; } BgInibsMovebg; // size = 0x168 extern const ActorInit Bg_Inibs_Movebg_InitVars; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1f8a8a974..fa4654705 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15288,9 +15288,9 @@ 0x80B96178:("D_80B96178","UNK_TYPE1","",0x1), 0x80B963C0:("Obj_Jg_Gakki_InitVars","UNK_TYPE1","",0x1), 0x80B96540:("Bg_Inibs_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80B96560:("D_80B96560","UNK_TYPE1","",0x1), - 0x80B96568:("D_80B96568","UNK_TYPE1","",0x1), - 0x80B96570:("D_80B96570","UNK_TYPE1","",0x1), + 0x80B96560:("sOpaDLists","UNK_TYPE1","",0x1), + 0x80B96568:("sXluDLists","UNK_TYPE1","",0x1), + 0x80B96570:("sSandTexAnims","UNK_TYPE1","",0x1), 0x80B96578:("D_80B96578","UNK_TYPE1","",0x1), 0x80B998C0:("En_Zot_InitVars","UNK_TYPE1","",0x1), 0x80B998E0:("D_80B998E0","UNK_TYPE1","",0x1), From d968e58f9c678feeaf2c9c67b41bae75578dd786 Mon Sep 17 00:00:00 2001 From: StickyThwomp <89738536+StickyThwomp@users.noreply.github.com> Date: Sat, 24 Sep 2022 13:00:53 -0500 Subject: [PATCH 22/73] Obj_Kendo_Kanban OK and Documented (Decomp was mostly done already) (#1057) * stuff * Renaming in-process - Changed action names and setup names based on examples. - Undid some ill-advised changes that broke matching. - Misc variable naming. Need verification and not all complete. * wip renaming * A bit more progress on determining names for everything. * Done with naming. * Touchup before review * Updates from review: - Leave displacementY/unk_AC0 naming to z_actor work. - Remove unnecessary include of z64math.h, indirect inclusion preferred - Add trailing comma for better formatting of sDisplayLists - Rename of static vectors sNullVec3f->sZeroVec, sUnitVectorX->sUnitVecX - Restore pad instead of using local const. Change const to #define - Prefer index over idx - Remove 'b' prefix from bHasNewRootCornerPos - Const -> Enum and formatting in ObjKendoKanban_IsPlayerOnTop - Rename 'Aerial' to 'Tumble' * Missed items in review: - Missed an instance of displacementY->unk_AC0 renaming (Cause of build failure) - Whitespace formatting - UNK_TYPE2 undo * More adjustments from review: - Undo accidental formatting changes to z64player.h, restoring to master. - Naming and Formatting changes. - Removing some comments. * From review, qualify enum and #define with obj name, whitespace cleanup. --- spec | 4 - .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 423 +++++++++--------- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h | 32 +- tools/disasm/functions.txt | 18 +- 4 files changed, 242 insertions(+), 235 deletions(-) diff --git a/spec b/spec index eaf97f178..326380916 100644 --- a/spec +++ b/spec @@ -3910,11 +3910,7 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.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 bc1d353fd..cbe3cecfc 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 @@ -1,7 +1,7 @@ /* * File: z_obj_kendo_kanban.c * Overlay: ovl_Obj_Kendo_Kanban - * Description: Swordsman's School - Cuttable Board + * Description: Swordsman's School - Cuttable Board at back of school */ #include "z_obj_kendo_kanban.h" @@ -9,20 +9,40 @@ #define FLAGS 0x00000000 +// Board Fragment Flags: Identify which of the 4 quadrants of the board are present. +#define OBJKENDOKANBAN_PART_FULL 0 +#define OBJKENDOKANBAN_PART_TOP_RIGHT (1 << 0) +#define OBJKENDOKANBAN_PART_TOP_LEFT (1 << 1) +#define OBJKENDOKANBAN_PART_BOTTOM_RIGHT (1 << 2) +#define OBJKENDOKANBAN_PART_BOTTOM_LEFT (1 << 3) +#define OBJKENDOKANBAN_RIGHT_HALF (OBJKENDOKANBAN_PART_TOP_RIGHT | OBJKENDOKANBAN_PART_BOTTOM_RIGHT) +#define OBJKENDOKANBAN_LEFT_HALF (OBJKENDOKANBAN_PART_TOP_LEFT | OBJKENDOKANBAN_PART_BOTTOM_LEFT) +#define OBJKENDOKANBAN_TOP_HALF (OBJKENDOKANBAN_PART_TOP_RIGHT | OBJKENDOKANBAN_PART_TOP_LEFT) +#define OBJKENDOKANBAN_BOTTOM_HALF (OBJKENDOKANBAN_PART_BOTTOM_RIGHT | OBJKENDOKANBAN_PART_BOTTOM_LEFT) + +// Number of bounces the board takes before settling. +#define MAX_BOUNCE_COUNT (7) + #define THIS ((ObjKendoKanban*)thisx) +typedef enum { + /* -1 */ OBJKENDOKANBAN_DIR_DOWN = -1, + /* 0 */ OBJKENDOKANBAN_DIR_UNDETERMINED, + /* 1 */ OBJKENDOKANBAN_DIR_UP, +} ObjKendoKanbanDirection; + void ObjKendoKanban_Init(Actor* thisx, PlayState* play); void ObjKendoKanban_Destroy(Actor* thisx, PlayState* play); void ObjKendoKanban_Update(Actor* thisx, PlayState* play); void ObjKendoKanban_Draw(Actor* thisx, PlayState* play); -void func_80B65880(ObjKendoKanban* this); -void func_80B65894(ObjKendoKanban* this, PlayState* play); -void func_80B658A4(ObjKendoKanban* this, PlayState* play); -void func_80B65CE0(ObjKendoKanban* this, PlayState* play); -void func_80B65D68(ObjKendoKanban* this, PlayState* play); -void func_80B65DA8(ObjKendoKanban* this, PlayState* play); -s32 func_80B6618C(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_SetupDoNothing(ObjKendoKanban* this); +void ObjKendoKanban_DoNothing(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_SetupTumble(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_Tumble(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_Settled(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play); +s32 ObjKendoKanban_IsPlayerOnTop(ObjKendoKanban* this, PlayState* play); const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, @@ -36,29 +56,36 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -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 }; +// Directly applied to the velocity of the actor upon object creation. +static Vec3f sVelocityLeftHalf = { -1.5f, 10.0f, 0.5f }; // Push Left/Up/Forward (Left side Breakaway) +static Vec3f sVelocityRightHalf = { 1.5f, 10.0f, 0.5f }; // Push Right/Up/Forward (Right side Breakaway) +static Vec3f sVelocityBottomHalf = { 0.0f, 4.0f, -1.0f }; // Push _/Up/Back (Bottom Breakaway) +static Vec3f sVelocityTopHalf = { 1.0f, 7.0f, 4.0f }; // Push Right/Up/Forward (Top Breakaway) -Gfx* D_80B666C0 = gKendoKanbanTopRightDL; -Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; -Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; -Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; +// Centerpoint of the piece +static Vec3f sCenterPointLeftHalf = { -150.0f, 425.0f, 40.0f }; +static Vec3f sCenterPointRightHalf = { 150.0f, 425.0f, 40.0f }; +static Vec3f sCenterPointBottomHalf = { 0.0f, 140.0f, 40.0f }; +static Vec3f sCenterPointTopHalf = { 0.0f, 565.0f, 40.0f }; -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 }; +// Displaylists for the 4 pieces. +static Gfx* sDisplayLists[] = { + gKendoKanbanTopRightDL, + gKendoKanbanTopLeftDL, + gKendoKanbanBottomRightDL, + gKendoKanbanBottomLeftDL, +}; + +// Coordinates on the object face upon which the board can break +static Vec3f sPointTL = { -300.0f, 850.0f, 40.0f }; +static Vec3f sPointTC = { 10.0f, 850.0f, 40.0f }; +static Vec3f sPointTR = { 300.0f, 850.0f, 40.0f }; +static Vec3f sPointCL = { -300.0f, 310.0f, 40.0f }; +static Vec3f sPointCC = { 0.0f, 280.0f, 40.0f }; // Unused +static Vec3f sPointCR = { 300.0f, 250.0f, 40.0f }; +static Vec3f sPointBL = { -300.0f, 10.0f, 40.0f }; +static Vec3f sPointBC = { 0.0f, 10.0f, 40.0f }; +static Vec3f sPointBR = { 300.0f, 10.0f, 40.0f }; static ColliderTrisElementInit sTrisElementsInit[] = { { @@ -155,13 +182,13 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; -Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; +static Vec3f sUnitVecX = { 1.0f, 0.0f, 0.0f }; void ObjKendoKanban_Init(Actor* thisx, PlayState* play) { s32 pad[2]; ObjKendoKanban* this = THIS; - Vec3f sp70[3]; + Vec3f vertices[3]; s32 i; s32 j; @@ -178,35 +205,35 @@ void ObjKendoKanban_Init(Actor* thisx, PlayState* play) { 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_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + for (j = 0; j < ARRAY_COUNT(vertices); j++) { + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &vertices[j]); } - Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + Collider_SetTrisVertices(&this->colliderTris, i, &vertices[0], &vertices[1], &vertices[2]); } Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); + this->boardFragments = OBJKENDOKANBAN_GET_BOARD_FRAGMENTS(&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; + this->centerPoint = sZeroVec; + this->centerPos = sZeroVec; + this->rootCornerPos = sZeroVec; + this->rotAxis = sUnitVecX; + this->rotAngle = 0; + this->rotVelocity = 0; + this->indexLastRootCornerPos = -1; + this->hasNewRootCornerPos = false; + this->numBounces = 0; - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + this->cornerPos[i] = this->cornerPoints[i] = sZeroVec; } this->unk_30A = 0; - if (this->unk_30C == OBJKENDOKANBAN_F_0) { - func_80B65880(this); + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { + ObjKendoKanban_SetupDoNothing(this); } else { - func_80B658A4(this, play); + ObjKendoKanban_SetupTumble(this, play); } } @@ -217,135 +244,138 @@ void ObjKendoKanban_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyTris(play, &this->colliderTris); } -void func_80B65880(ObjKendoKanban* this) { - this->actionFunc = func_80B65894; +void ObjKendoKanban_SetupDoNothing(ObjKendoKanban* this) { + this->actionFunc = ObjKendoKanban_DoNothing; } -void func_80B65894(ObjKendoKanban* this, PlayState* play) { +void ObjKendoKanban_DoNothing(ObjKendoKanban* this, PlayState* play) { } -void func_80B658A4(ObjKendoKanban* this, PlayState* play) { +void ObjKendoKanban_SetupTumble(ObjKendoKanban* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { if ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_2H) || (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { - this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); - this->unk_304 = 0x71C; - this->actor.velocity = D_80B6666C; - this->unk_2CC = D_80B6669C; + + // Vertical cuts initialize the right half, spawn the left half. + this->boardFragments = OBJKENDOKANBAN_RIGHT_HALF; + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityRightHalf; + this->centerPoint = sCenterPointRightHalf; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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); + OBJKENDOKANBAN_LEFT_HALF); - this->unk_29C[0] = D_80B666DC; - this->unk_29C[1] = D_80B666E8; - this->unk_29C[2] = D_80B66730; - this->unk_29C[3] = D_80B66724; + this->cornerPoints[0] = sPointTC; + this->cornerPoints[1] = sPointTR; + this->cornerPoints[2] = sPointBR; + this->cornerPoints[3] = sPointBC; } else { - this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); - this->unk_304 = -0x71C; - this->actor.velocity = D_80B66678; - this->unk_2CC = D_80B666A8; + // Horizontal cuts initialize the bottom half, spawn the top half. + this->boardFragments = OBJKENDOKANBAN_BOTTOM_HALF; + this->rotVelocity = -0x71C; // -10 degrees + this->actor.velocity = sVelocityBottomHalf; + this->centerPoint = sCenterPointBottomHalf; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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->actor.home.pos.y + 5.0f, this->actor.home.pos.z, 0, 0, 0, OBJKENDOKANBAN_TOP_HALF); - this->unk_29C[0] = D_80B666F4; - this->unk_29C[1] = D_80B6670C; - this->unk_29C[2] = D_80B66730; - this->unk_29C[3] = D_80B66718; + this->cornerPoints[0] = sPointCL; + this->cornerPoints[1] = sPointCR; + this->cornerPoints[2] = sPointBR; + this->cornerPoints[3] = sPointBL; } - } 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; + } else if (this->boardFragments == OBJKENDOKANBAN_LEFT_HALF) { + // Initialize the newly spawned left half + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityLeftHalf; + this->centerPoint = sCenterPointLeftHalf; - 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->cornerPoints[0] = sPointTL; + this->cornerPoints[1] = sPointTC; + this->cornerPoints[2] = sPointBC; + this->cornerPoints[3] = sPointBL; + } else if (this->boardFragments == OBJKENDOKANBAN_TOP_HALF) { + // Initialize the newly spawned top half + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityTopHalf; + this->centerPoint = sCenterPointTopHalf; - 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->cornerPoints[0] = sPointTL; + this->cornerPoints[1] = sPointTR; + this->cornerPoints[2] = sPointCR; + this->cornerPoints[3] = sPointCL; } this->unk_30A = 0; - this->actionFunc = func_80B65CE0; + this->actionFunc = ObjKendoKanban_Tumble; } -void func_80B65CE0(ObjKendoKanban* this, PlayState* play) { +void ObjKendoKanban_Tumble(ObjKendoKanban* this, PlayState* play) { this->actor.velocity.y += this->actor.gravity; Actor_UpdatePos(&this->actor); - this->unk_302 += this->unk_304; - func_80B65DA8(this, play); + this->rotAngle += this->rotVelocity; + ObjKendoKanban_HandlePhysics(this, play); 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 ObjKendoKanban_SetupSettled(ObjKendoKanban* this) { + this->actionFunc = ObjKendoKanban_Settled; } -void func_80B65D68(ObjKendoKanban* this, PlayState* play) { +void ObjKendoKanban_Settled(ObjKendoKanban* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (func_80B6618C(this, play) == 1) { + if (ObjKendoKanban_IsPlayerOnTop(this, play) == true) { player->unk_AC0 = 700.0f; } } -void func_80B65DA8(ObjKendoKanban* this, PlayState* play) { - Vec3f sp5C; +void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play) { + Vec3f rootCornerPos = this->cornerPos[0]; s32 pad[2]; - Vec3f sp48; + Vec3f vecCenterOut = this->actor.world.pos; s32 pad2; - s32 index = 0; + s32 indexRootCornerPos = 0; s32 i; - f32 sp38; + f32 verticalScalar; - 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; + // Calculate an affect on the rotation from gravity. + vecCenterOut.x -= this->centerPos.x; + vecCenterOut.y -= this->centerPos.y; + vecCenterOut.z -= this->centerPos.z; + verticalScalar = (this->rotAxis.x * vecCenterOut.z) + (this->rotAxis.z * -vecCenterOut.x); + if (verticalScalar < 0.0f) { + this->rotVelocity += 0x64; } else { - this->unk_304 -= 0x64; + this->rotVelocity -= 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; + // Find the lowest point + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + if (this->cornerPos[i].y < rootCornerPos.y) { + rootCornerPos = this->cornerPos[i]; + indexRootCornerPos = i; } } - if (index != this->unk_2FC) { - this->unk_300 = 1; - this->unk_2FC = index; - this->unk_2E4 = this->unk_29C[index]; + // When the lowest point changes, re-initialize the actor position to that point + if (indexRootCornerPos != this->indexLastRootCornerPos) { + this->hasNewRootCornerPos = true; + this->indexLastRootCornerPos = indexRootCornerPos; + this->rootCornerPos = this->cornerPoints[indexRootCornerPos]; 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_MultVec3f(&this->unk_2E4, &this->actor.world.pos); - this->actor.world.pos = sp5C; + Matrix_MultVec3f(&this->rootCornerPos, &this->actor.world.pos); + this->actor.world.pos = rootCornerPos; this->actor.prevPos = this->actor.world.pos; Matrix_Pop(); } @@ -353,102 +383,105 @@ void func_80B65DA8(ObjKendoKanban* this, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->actor.bgCheckFlags & 1) { + // When on the ground, apply some friction. 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 (this->hasNewRootCornerPos == true) { + if (this->numBounces >= MAX_BOUNCE_COUNT) { + s16 deltaRotAngle = this->rotAngle & 0x3FFF; - if (temp_v0_3 >= 0x2000) { - temp_v0_3 -= 0x4000; + if (deltaRotAngle >= 0x2000) { // 45 degrees + deltaRotAngle -= 0x4000; // 90 degrees } - this->unk_302 -= temp_v0_3; - this->unk_304 = 0; - func_80B65D54(this); + this->rotAngle -= deltaRotAngle; + this->rotVelocity = 0; + ObjKendoKanban_SetupSettled(this); return; } if (this->actor.bgCheckFlags & 2) { + // Upon touching the ground... Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); - this->unk_300 = 0; + this->hasNewRootCornerPos = false; this->actor.velocity.y *= 0.5f; } else if (this->actor.bgCheckFlags & 1) { - this->unk_308++; - this->unk_300 = 0; + // When on the ground... + this->numBounces++; + this->hasNewRootCornerPos = false; 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; + // Adjust and (potentially) reverse rotation depending on the current + // facing of the board and the direction in which it is rotating. + if (verticalScalar > 0.0f) { + if (this->rotVelocity > 0) { + this->rotVelocity *= 1.2f; } else { - this->unk_304 *= -0.6f; + this->rotVelocity *= -0.6f; } - } else if (this->unk_304 < 0) { - this->unk_304 *= 1.2f; } else { - this->unk_304 *= -0.6f; + if (this->rotVelocity < 0) { + this->rotVelocity *= 1.2f; + } else { + this->rotVelocity *= -0.6f; + } } } } } -s32 func_80B6618C(ObjKendoKanban* this, PlayState* play) { +s32 ObjKendoKanban_IsPlayerOnTop(ObjKendoKanban* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 phi_v0; - s32 phi_v1 = 0; s32 i; - f32 x; - f32 z; - f32 x2; - f32 z2; + s32 j; + Vec2f playerToCornerA; + Vec2f playerToCornerB; + s32 priorDir = OBJKENDOKANBAN_DIR_UNDETERMINED; - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - if (i != 3) { - phi_v0 = i + 1; - } else { - phi_v0 = 0; - } + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + j = (i != 3) ? (i + 1) : 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) { + // For each pair of points (moving clockwise around the shape), verify that the normal + // vector's magnitute is in the same direction. This condition being true means + // the player is within the bounds of the four cornerPoints. + playerToCornerA.z = this->cornerPos[i].z - player->actor.world.pos.z; + playerToCornerA.x = this->cornerPos[i].x - player->actor.world.pos.x; + playerToCornerB.z = this->cornerPos[j].z - player->actor.world.pos.z; + playerToCornerB.x = this->cornerPos[j].x - player->actor.world.pos.x; + if ((playerToCornerA.x * playerToCornerB.z) < (playerToCornerA.z * playerToCornerB.x)) { + if (priorDir == OBJKENDOKANBAN_DIR_UNDETERMINED) { + priorDir = OBJKENDOKANBAN_DIR_UP; + } else if (priorDir != OBJKENDOKANBAN_DIR_UP) { + return false; + } + } else { + if (priorDir == OBJKENDOKANBAN_DIR_UNDETERMINED) { + priorDir = OBJKENDOKANBAN_DIR_DOWN; + } else if (priorDir != OBJKENDOKANBAN_DIR_DOWN) { return false; } - } else if (phi_v1 == 0) { - phi_v1 = -1; - } else if (phi_v1 != -1) { - return false; } } return true; } -void func_80B66304(ObjKendoKanban* this, PlayState* play) { - if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { +void ObjKendoKanban_UpdateCollision(ObjKendoKanban* this, PlayState* play) { + if ((this->actionFunc != ObjKendoKanban_Tumble) && (this->actionFunc != ObjKendoKanban_Settled)) { if (this->colliderTris.base.acFlags & AC_HIT) { this->colliderTris.base.acFlags &= ~AC_HIT; - func_80B658A4(this, play); + ObjKendoKanban_SetupTumble(this, play); } 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) { + if (this->actionFunc == ObjKendoKanban_DoNothing) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); } - CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); } } @@ -457,54 +490,38 @@ void ObjKendoKanban_Update(Actor* thisx, PlayState* play) { ObjKendoKanban* this = THIS; this->actionFunc(this, play); - - func_80B66304(this, play); + ObjKendoKanban_UpdateCollision(this, play); } -#ifdef NON_MATCHING void ObjKendoKanban_Draw(Actor* thisx, PlayState* play) { ObjKendoKanban* this = THIS; s32 i; - Gfx* poly; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { - 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); - + Matrix_RotateAxisS(this->rotAngle, &this->rotAxis, MTXMODE_APPLY); + Matrix_Translate(-this->rootCornerPos.x, -this->rootCornerPos.y, -this->rootCornerPos.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + // Display only the fragments of the board which are present + for (i = 0; i < ARRAY_COUNT(sDisplayLists); i++) { + if ((1 << i) & this->boardFragments) { + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); + } } } CLOSE_DISPS(play->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); + // Update the alternate position trackers (Corners and Center of the board) + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + Matrix_MultVec3f(&this->cornerPoints[i], &this->cornerPos[i]); } - - Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); + Matrix_MultVec3f(&this->centerPoint, &this->centerPos); } -#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 8526f4976..9d01b63fc 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,13 +7,7 @@ struct ObjKendoKanban; typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, PlayState*); -#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) +#define OBJKENDOKANBAN_GET_BOARD_FRAGMENTS(thisx) ((thisx)->params & 0xF) typedef struct ObjKendoKanban { /* 0x000 */ Actor actor; @@ -21,20 +15,20 @@ typedef struct ObjKendoKanban { /* 0x190 */ ColliderTris colliderTris; /* 0x1B0 */ ColliderTrisElement colliderTrisElements[2]; /* 0x268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x26C */ Vec3f unk_26C[4]; - /* 0x29C */ Vec3f unk_29C[4]; - /* 0x2CC */ Vec3f unk_2CC; - /* 0x2D8 */ Vec3f unk_2D8; - /* 0x2E4 */ Vec3f unk_2E4; - /* 0x2F0 */ Vec3f unk_2F0; - /* 0x2FC */ s32 unk_2FC; - /* 0x300 */ s16 unk_300; - /* 0x302 */ s16 unk_302; - /* 0x304 */ s16 unk_304; + /* 0x26C */ Vec3f cornerPos[4]; + /* 0x29C */ Vec3f cornerPoints[4]; + /* 0x2CC */ Vec3f centerPoint; + /* 0x2D8 */ Vec3f centerPos; + /* 0x2E4 */ Vec3f rootCornerPos; + /* 0x2F0 */ Vec3f rotAxis; + /* 0x2FC */ s32 indexLastRootCornerPos; + /* 0x300 */ s16 hasNewRootCornerPos; + /* 0x302 */ s16 rotAngle; + /* 0x304 */ s16 rotVelocity; /* 0x306 */ UNK_TYPE1 pad306[2]; - /* 0x308 */ s16 unk_308; + /* 0x308 */ s16 numBounces; /* 0x30A */ s16 unk_30A; - /* 0x30C */ u8 unk_30C; + /* 0x30C */ u8 boardFragments; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 718f05e49..7698b0d2c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14230,15 +14230,15 @@ 0x80B64DFC:("func_80B64DFC",), 0x80B654C0:("ObjKendoKanban_Init",), 0x80B65840:("ObjKendoKanban_Destroy",), - 0x80B65880:("func_80B65880",), - 0x80B65894:("func_80B65894",), - 0x80B658A4:("func_80B658A4",), - 0x80B65CE0:("func_80B65CE0",), - 0x80B65D54:("func_80B65D54",), - 0x80B65D68:("func_80B65D68",), - 0x80B65DA8:("func_80B65DA8",), - 0x80B6618C:("func_80B6618C",), - 0x80B66304:("func_80B66304",), + 0x80B65880:("ObjKendoKanban_SetupDoNothing",), + 0x80B65894:("ObjKendoKanban_DoNothing",), + 0x80B658A4:("ObjKendoKanban_SetupTumble",), + 0x80B65CE0:("ObjKendoKanban_Tumble",), + 0x80B65D54:("ObjKendoKanban_SetupSettled",), + 0x80B65D68:("ObjKendoKanban_Settled",), + 0x80B65DA8:("ObjKendoKanban_HandlePhysics",), + 0x80B6618C:("ObjKendoKanban_IsPlayerOnTop",), + 0x80B66304:("ObjKendoKanban_UpdateCollision",), 0x80B66418:("ObjKendoKanban_Update",), 0x80B66454:("ObjKendoKanban_Draw",), 0x80B66A20:("ObjHariko_Init",), From c23112c855cb02847e9ec8e0b5d65b56b1d1b35f Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Sat, 24 Sep 2022 15:07:11 -0300 Subject: [PATCH 23/73] ovl_En_Bee OK (#1086) * all functions matching * initial cleanup * tatl hint * clean up + SFX * SFX * more SFX * func_800B3030 * SFX FIX * castings * clean up * array of Vec3f * for loop fix (Thanks @Maide) * ACTORCAT_ITEMACTION * a few nits * ACTORCAT_ENEMY * actor struct size restored * ACTORCAT_ENEMY * Update src/overlays/actors/ovl_En_Bee/z_en_bee.c Co-authored-by: Derek Hensley * parenthesis * parenthesis * merge fail Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley --- spec | 3 +- src/overlays/actors/ovl_En_Bee/z_en_bee.c | 227 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Bee/z_en_bee.h | 16 +- 3 files changed, 222 insertions(+), 24 deletions(-) diff --git a/spec b/spec index 326380916..d1cf750bd 100644 --- a/spec +++ b/spec @@ -3874,8 +3874,7 @@ beginseg name "ovl_En_Bee" compress include "build/src/overlays/actors/ovl_En_Bee/z_en_bee.o" - include "build/data/ovl_En_Bee/ovl_En_Bee.data.o" - include "build/data/ovl_En_Bee/ovl_En_Bee.reloc.o" + include "build/src/overlays/actors/ovl_En_Bee/ovl_En_Bee_reloc.o" endseg beginseg 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 f53b58bf6..0a0c6dd3f 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -17,8 +17,11 @@ void EnBee_Draw(Actor* thisx, PlayState* play); void func_80B5A9E8(EnBee* this, PlayState* play); void func_80B5AC3C(EnBee* this, PlayState* play); +void func_80B5A854(EnBee* this); +void func_80B5ABC4(EnBee* this); + +s32 D_80B5B1F0 = 0; -#if 0 const ActorInit En_Bee_InitVars = { ACTOR_EN_BEE, ACTORCAT_ENEMY, @@ -31,8 +34,7 @@ const ActorInit En_Bee_InitVars = { (ActorFunc)EnBee_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B5B214 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -67,34 +69,219 @@ static DamageTable D_80B5B214 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B5B234 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x02 }, { 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_HARD | AC_TYPE_PLAYER, + OC1_ON, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 13, -4, { 0, 0, 0 } }, }; -#endif +void EnBee_Init(Actor* thisx, PlayState* play) { + EnBee* this = THIS; -extern DamageTable D_80B5B214; -extern ColliderCylinderInit D_80B5B234; + this->actor.colChkInfo.mass = 10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_Init(play, &this->skelAnime, &object_bee_Skel_001398, &object_bee_Anim_00005C, this->morphTable, + this->jointTable, OBJECT_BEE_LIMB_MAX); + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->unk_218 = D_80B5B1F0; + D_80B5B1F0++; + this->actor.shape.shadowScale = 12.0f; -extern UNK_TYPE D_0600005C; + if (ActorCutscene_GetCurrentIndex() != -1) { + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ITEMACTION); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Init.s") + this->actor.hintId = TATL_HINT_ID_GIANT_BEE; + func_80B5A854(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Destroy.s") +void EnBee_Destroy(Actor* thisx, PlayState* play) { + EnBee* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5A854.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5A9E8.s") +void func_80B5A854(EnBee* this) { + s32 pad; + Vec3f sp48; + s16 sp46; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5ABC4.s") + Animation_Change(&this->skelAnime, &object_bee_Anim_00005C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_bee_Anim_00005C), 0, -10.0f); + Math_Vec3f_Copy(&sp48, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5AC3C.s") + sp46 = (this->unk_218 * 0x700) + 0x2000; + sp48.x += Math_SinS(sp46) * 50.0f; + sp48.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + sp48.z += Math_CosS(sp46) * 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5AF80.s") + Math_Vec3f_Copy(&this->unk_21C[0], &sp48); + Math_Vec3f_Copy(&sp48, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Update.s") + sp48.x += Math_SinS(sp46 - 0x4000) * 50.0f; + sp48.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + sp48.z += Math_CosS(sp46 - 0x4000) * 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Draw.s") + Math_Vec3f_Copy(&this->unk_21C[1], &sp48); + + this->unk_204 = Rand_S16Offset(0x14, 0x1E); + this->unk_208 = 0; + this->actionFunc = func_80B5A9E8; +} + +void func_80B5A9E8(EnBee* this, PlayState* play) { + Vec3f sp3C; + s32 pad[2]; + + if ((this->actor.category != ACTORCAT_ENEMY) && (ActorCutscene_GetCurrentIndex() == -1)) { + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); + } + + Math_Vec3f_Copy(&sp3C, &this->unk_21C[this->unk_214]); + sp3C.x += Math_SinS(this->unk_20C) * 30.0f; + sp3C.z += Math_CosS(this->unk_20C) * 30.0f; + + if (!(this->unk_218 & 1)) { + this->unk_20C += (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + } else { + this->unk_20C -= (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + } + + this->unk_210 += 1000; + this->actor.velocity.y = Math_SinS(this->unk_210); + + if (this->unk_20C > 0x10000) { + this->unk_20C = 0; + this->unk_214++; + this->unk_214 &= 1; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C), 1, 0x7D0, 0); + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 1.0f); + + if ((this->unk_204 == 0) && (this->actor.params != 0)) { + func_80B5ABC4(this); + } +} + +void func_80B5ABC4(EnBee* this) { + Animation_Change(&this->skelAnime, &object_bee_Anim_00005C, 1.0f, 0.0f, + Animation_GetLastFrame(&object_bee_Anim_00005C), 0, -10.0f); + this->unk_208 = 1; + this->actionFunc = func_80B5AC3C; +} + +void func_80B5AC3C(EnBee* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp88; + f32 rnd; + f32 phi_fs1; + s32 i; + + Math_Vec3f_Copy(&sp88, &player->actor.world.pos); + phi_fs1 = (this->unk_218 * 0x700) + 0x2000; + + for (i = 0; i < 2; i++) { + rnd = randPlusMinusPoint5Scaled(20.0f); + sp88.x += Math_SinS((this->actor.yawTowardsPlayer + ((f32)this->unk_20C)) + phi_fs1) * (rnd + 30.0f); + sp88.y = (Math_SinS(this->unk_210) * 10.0f) + (player->actor.floorHeight + 40.0f); + rnd = randPlusMinusPoint5Scaled(20.0f); + sp88.z += Math_CosS((f32)this->actor.yawTowardsPlayer + this->unk_20C + phi_fs1) * (rnd + 30.0f); + Math_Vec3f_Copy(&this->unk_21C[i], &sp88); + phi_fs1 -= 16384.0f; + } + + Math_Vec3f_Copy(&sp88, &this->unk_21C[this->unk_214]); + + if (!(this->unk_218 & 1)) { + this->unk_20C += (this->unk_218 * 0x700) + (s32)randPlusMinusPoint5Scaled((this->unk_218 * 0x700) * 0.5f); + } else { + this->unk_20C -= (this->unk_218 * 0x700) + (s32)randPlusMinusPoint5Scaled((this->unk_218 * 0x700) * 0.5f); + } + + this->unk_210 += (s32)randPlusMinusPoint5Scaled(500.0f) + 1000; + + if (this->unk_20C > 0x10000) { + this->unk_20C = 0; + this->unk_214++; + this->unk_214 &= 1; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp88), 1, 0x1388, 0); + Math_ApproachF(&this->actor.world.pos.y, sp88.y, 0.3f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); +} + +void func_80B5AF80(EnBee* this, PlayState* play) { + if ((this->unk_206 == 0) && (this->collider.base.atFlags & AC_HIT)) { + AudioSfx_StopByPosAndId(&this->actor.projectedPos, NA_SE_EN_BEE_FLY - SFX_FLAG); + this->unk_206 = 5; + } + + if (this->collider.base.acFlags & AC_HIT) { + Enemy_StartFinishingBlow(play, &this->actor); + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_CUTBODY); + this->actor.colChkInfo.health = 0; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + Actor_MarkForDeath(&this->actor); + } +} + +void EnBee_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBee* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + if (this->actor.category == ACTORCAT_ENEMY) { + if (this->unk_204 != 0) { + this->unk_204--; + } + if (this->unk_206 != 0) { + this->unk_206--; + } + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BEE_FLY - SFX_FLAG); + func_80B5AF80(this, play); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + Actor_SetFocus(&this->actor, 0.0f); + Actor_SetScale(&this->actor, 0.01f); + + this->actionFunc(this, play); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); +} + +void EnBee_Draw(Actor* thisx, PlayState* play) { + EnBee* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.h b/src/overlays/actors/ovl_En_Bee/z_en_bee.h index 1676a5507..1638407ee 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.h +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.h @@ -2,6 +2,7 @@ #define Z_EN_BEE_H #include "global.h" +#include "assets/objects/object_bee/object_bee.h" struct EnBee; @@ -9,9 +10,20 @@ typedef void (*EnBeeActionFunc)(struct EnBee*, PlayState*); typedef struct EnBee { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xBC]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s morphTable[OBJECT_BEE_LIMB_MAX]; + /* 0x1C4 */ Vec3s jointTable[OBJECT_BEE_LIMB_MAX]; /* 0x200 */ EnBeeActionFunc actionFunc; - /* 0x204 */ char unk_204[0x84]; + /* 0x204 */ s16 unk_204; + /* 0x206 */ s16 unk_206; + /* 0x208 */ s16 unk_208; + /* 0x20C */ s32 unk_20C; + /* 0x210 */ s32 unk_210; + /* 0x214 */ s32 unk_214; + /* 0x218 */ s32 unk_218; + /* 0x21C */ Vec3f unk_21C[2]; + /* 0x234 */ UNK_TYPE1 pad234[8]; + /* 0x23C */ ColliderCylinder collider; } EnBee; // size = 0x288 extern const ActorInit En_Bee_InitVars; From fd5ff73a356e4aa9669c16922df86b7efd0dabe7 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:14:59 -0700 Subject: [PATCH 24/73] Extract assets from link_animetion (#1056) * Extract assets from link_animetion * Add empty last line --- assets/xml/misc/link_animetion.xml | 699 +++++++++++++++++++++++++++ assets/xml/objects/gameplay_keep.xml | 1 + spec | 3 +- 3 files changed, 702 insertions(+), 1 deletion(-) create mode 100644 assets/xml/misc/link_animetion.xml diff --git a/assets/xml/misc/link_animetion.xml b/assets/xml/misc/link_animetion.xml new file mode 100644 index 000000000..788e0a49d --- /dev/null +++ b/assets/xml/misc/link_animetion.xml @@ -0,0 +1,699 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index b958f6cf2..6f658a42c 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1,4 +1,5 @@  + diff --git a/spec b/spec index d1cf750bd..147e5a77b 100644 --- a/spec +++ b/spec @@ -273,7 +273,8 @@ endseg beginseg name "link_animetion" romalign 0x1000 - include "build/baserom/link_animetion.o" + include "build/assets/misc/link_animetion/link_animetion.o" + number 7 endseg beginseg From 62502ac22f063557fd025aaf94b93d5126f2a3a9 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:21:01 -0700 Subject: [PATCH 25/73] Document object_mtoride (Woodfall scene objects) (#1062) * Name everything in object_mtoride * Get ready for PR * Update some of the names --- assets/xml/objects/object_mtoride.xml | 112 +++++++++++------- assets/xml/overlays/ovl_Dm_Char01.xml | 3 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 70 +++++------ 3 files changed, 106 insertions(+), 79 deletions(-) diff --git a/assets/xml/objects/object_mtoride.xml b/assets/xml/objects/object_mtoride.xml index a79547730..145fcd33f 100644 --- a/assets/xml/objects/object_mtoride.xml +++ b/assets/xml/objects/object_mtoride.xml @@ -1,49 +1,71 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Dm_Char01.xml b/assets/xml/overlays/ovl_Dm_Char01.xml index 3f855c376..2aa05fcb6 100644 --- a/assets/xml/overlays/ovl_Dm_Char01.xml +++ b/assets/xml/overlays/ovl_Dm_Char01.xml @@ -1,6 +1,7 @@ + - + 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 8c1aebc96..900530f4d 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -80,11 +80,11 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { this->unk_348 = 255.0f; 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; + this->unk_1AC[i] = gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] * 409.6f; } DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_009E4C); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryPoisonWaterDamageCol); this->unk_34D = true; if (gSaveContext.sceneSetupIndex == 1) { @@ -114,7 +114,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.y += 0x8000; this->dyna.actor.shape.rot.y += 0x8000; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_010C3C); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryTempleCol); this->unk_34D = true; this->unk_348 = 200.0f; this->actionFunc = func_80AA8F2C; @@ -131,7 +131,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_00FE5C); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryTempleRampAndPlatformCol); this->unk_34D = true; if (!(gSaveContext.save.weekEventReg[20] & 2)) { @@ -252,8 +252,9 @@ void func_80AA892C(DmChar01* this, PlayState* play) { 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])); + for (i = 0; i < ARRAY_COUNT(gWoodfallSceneryDynamicPoisonWaterVtx); i++) { + s32 temp_s2 = sqrtf(SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[2]) + + SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[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; @@ -265,7 +266,7 @@ void func_80AA892C(DmChar01* this, PlayState* play) { temp_f20 += temp_f18; this->unk_1AC[i] += 1600; - ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] = temp_f20; } } @@ -297,8 +298,9 @@ void func_80AA8C28(DmChar01* this, PlayState* play) { 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])); + for (i = 0; i < ARRAY_COUNT(gWoodfallSceneryDynamicPoisonWaterVtx); i++) { + s32 temp_s2 = sqrtf(SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[2]) + + SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[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; @@ -310,7 +312,7 @@ void func_80AA8C28(DmChar01* this, PlayState* play) { temp_f20 += temp_f18; this->unk_1AC[i] += 1600; - ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] = temp_f20; } Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.6f, 0.4f); @@ -404,18 +406,18 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { case DMCHAR01_0: switch (this->unk_34C) { case 0: - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00AA50)); - Gfx_DrawDListOpa(play, object_mtoride_DL_00A8F8); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPoisonWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPoisonWaterDL); break; case 1: if (gSaveContext.sceneSetupIndex == 1) { - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); - Gfx_DrawDListOpa(play, object_mtoride_DL_010FD8); - Gfx_DrawDListXlu(play, object_mtoride_DL_010EF0); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPurifiedWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); + Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); } - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryDynamicPoisonWaterTexAnim)); OPEN_DISPS(play->state.gfxCtx); @@ -426,10 +428,11 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { 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)); + gSPSegment(POLY_OPA_DISP++, 0x0B, + Lib_SegmentedToVirtual(gWoodfallSceneryDynamicPoisonWaterVtx)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_mtoride_DL_009928); + gSPDisplayList(POLY_OPA_DISP++, gWoodfallSceneryDynamicPoisonWaterDL); } else { func_8012C2DC(play->state.gfxCtx); @@ -437,19 +440,20 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { 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)); + gSPSegment(POLY_XLU_DISP++, 0x0B, + Lib_SegmentedToVirtual(gWoodfallSceneryDynamicPoisonWaterVtx)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_009928); + gSPDisplayList(POLY_XLU_DISP++, gWoodfallSceneryDynamicPoisonWaterDL); } CLOSE_DISPS(play->state.gfxCtx); break; case 2: - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); - Gfx_DrawDListOpa(play, object_mtoride_DL_010FD8); - Gfx_DrawDListXlu(play, object_mtoride_DL_010EF0); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPurifiedWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); + Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); break; } break; @@ -457,23 +461,23 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { case DMCHAR01_1: switch (this->unk_34C) { case 0: - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00A5C0)); - Gfx_DrawDListOpa(play, object_mtoride_DL_00A398); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPoisonWallsTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPoisonWallsDL); break; case 1: - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); - Gfx_DrawDListOpa(play, object_mtoride_DL_00AF98); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPurifiedWallsTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPurifiedWallsDL); break; } break; case DMCHAR01_2: - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00FE90)); - Gfx_DrawDListOpa(play, object_mtoride_DL_00DF18); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryTempleTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryTempleDL); if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryWaterFlowingOverTempleTexAnim)); OPEN_DISPS(play->state.gfxCtx); @@ -484,7 +488,7 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (u8)this->unk_348); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_00F3C0); + gSPDisplayList(POLY_XLU_DISP++, gWoodfallSceneryWaterFlowingOverTempleDL); CLOSE_DISPS(play->state.gfxCtx); } @@ -536,12 +540,12 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { } } - Gfx_DrawDListXlu(play, object_mtoride_DL_00DE50); + Gfx_DrawDListXlu(play, gWoodfallSceneryTempleEntrancesDL); break; case DMCHAR01_3: if (thisx->world.pos.y > -120.0f) { - Gfx_DrawDListOpa(play, object_mtoride_DL_00FAE8); + Gfx_DrawDListOpa(play, gWoodfallSceneryTempleRampAndPlatformDL); } break; } From 4088aea3f7db074908d35e24b8382fb1244ae00a Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:28:49 -0700 Subject: [PATCH 26/73] Document object_lotus (lily pad) (#1067) --- assets/xml/objects/object_lotus.xml | 9 +++++---- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/xml/objects/object_lotus.xml b/assets/xml/objects/object_lotus.xml index a9835b81b..b9f40033c 100644 --- a/assets/xml/objects/object_lotus.xml +++ b/assets/xml/objects/object_lotus.xml @@ -1,8 +1,9 @@  + - - - - + + + + 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 6ac4ac866..72a38b21b 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -43,7 +43,7 @@ void BgLotus_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_lotus_Colheader_000A20); + DynaPolyActor_LoadMesh(play, &this->dyna, &gLilyPadCol); this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; @@ -171,5 +171,5 @@ void BgLotus_Update(Actor* thisx, PlayState* play) { } void BgLotus_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_lotus_DL_000040); + Gfx_DrawDListOpa(play, gLilyPadDL); } From be121f7dd7fac9f5c9cec7d6be86ec6eff1528ba Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:34:59 -0700 Subject: [PATCH 27/73] Document Song of Time Clock assets in gameplay_keep (#1068) --- assets/xml/objects/gameplay_keep.xml | 11 +++++++---- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 6f658a42c..1923fe8df 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1348,10 +1348,13 @@ - - - - + + + + + + + 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 82af65e3c..3211d3167 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -1126,7 +1126,7 @@ void func_80A93298(EnTest6* this, PlayState* play) { 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); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); temp_s4 += 0x1000; cos = Math_CosS(temp_s4) * this->unk_150; @@ -1140,7 +1140,7 @@ void func_80A93298(EnTest6* this, PlayState* play) { 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); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); phi_f24 -= this->unk_14C; phi_s2 += this->unk_27E; @@ -1213,7 +1213,7 @@ void func_80A9369C(Actor* thisx, PlayState* play2) { 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); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); phi_s2 += 0x505; } @@ -1257,7 +1257,7 @@ void func_80A939E8(EnTest6* this, PlayState* play2) { 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); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); POLY_XLU_DISP = this->unk_148; } From 8fa3a58b350c40e36ac71a5ee97bf7ba4a87e0da Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:40:36 -0700 Subject: [PATCH 28/73] Document object_market_obj (West Clock Town Market) (#1074) * Document object_market_obj (West Clock Town Market) * Update the names of ground textures * Respond to Elliptic's review --- assets/xml/objects/object_market_obj.xml | 126 +++++++++--------- .../ovl_Bg_Market_Step/z_bg_market_step.c | 20 ++- .../ovl_Bg_Market_Step/z_bg_market_step.h | 2 + tools/disasm/variables.txt | 4 +- 4 files changed, 83 insertions(+), 69 deletions(-) diff --git a/assets/xml/objects/object_market_obj.xml b/assets/xml/objects/object_market_obj.xml index 81ab838f1..8ad9436cc 100644 --- a/assets/xml/objects/object_market_obj.xml +++ b/assets/xml/objects/object_market_obj.xml @@ -1,65 +1,69 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 8ac6c61c3..f2f5ef870 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 @@ -27,17 +27,25 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -Gfx* D_80AF0120[] = { object_market_obj_DL_01F050, object_market_obj_DL_018DA0 }; -Gfx* D_80AF0128[] = { object_market_obj_DL_01EF10, object_market_obj_DL_018C60 }; +Gfx* sMarketDLs[] = { + gWestClockTownMarketDayDL, + gWestClockTownMarketNightDL, +}; + +Gfx* sBankAdvertisementsAndDoorDLs[] = { + gWestClockTownMarketBankAdvertisementsAndDoorDayDL, + gWestClockTownMarketBankAdvertisementsAndDoorNightDL, +}; void BgMarketStep_Init(Actor* thisx, PlayState* play) { BgMarketStep* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); } -void BgMarketStep_Draw(Actor* thisx, PlayState* play) { - s32 index = thisx->params & 1; - Gfx_DrawDListOpa(play, D_80AF0120[index]); - Gfx_DrawDListOpa(play, D_80AF0128[index]); +void BgMarketStep_Draw(Actor* thisx, PlayState* play) { + s32 timeOfDay = BG_MARKET_STEP_GET_TIME_OF_DAY(thisx); + + Gfx_DrawDListOpa(play, sMarketDLs[timeOfDay]); + Gfx_DrawDListOpa(play, sBankAdvertisementsAndDoorDLs[timeOfDay]); } diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h index aa98c0aa1..c779b227a 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h @@ -3,6 +3,8 @@ #include "global.h" +#define BG_MARKET_STEP_GET_TIME_OF_DAY(thisx) ((thisx)->params & 1) + struct BgMarketStep; typedef struct BgMarketStep { diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index fa4654705..538030f58 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -13328,8 +13328,8 @@ 0x80AF0050:("D_80AF0050","UNK_TYPE1","",0x1), 0x80AF00F0:("Bg_Market_Step_InitVars","UNK_TYPE1","",0x1), 0x80AF0110:("D_80AF0110","UNK_TYPE1","",0x1), - 0x80AF0120:("D_80AF0120","UNK_TYPE1","",0x1), - 0x80AF0128:("D_80AF0128","UNK_TYPE1","",0x1), + 0x80AF0120:("sMarketDLs","UNK_TYPE1","",0x1), + 0x80AF0128:("sBankAdvertisementsAndFakeDoorDLs","UNK_TYPE1","",0x1), 0x80AF0720:("Obj_Lupygamelift_InitVars","UNK_TYPE1","",0x1), 0x80AF0740:("D_80AF0740","UNK_TYPE1","",0x1), 0x80AF0750:("D_80AF0750","f32","",0x4), From a390da9b56aef8f244ebf3592511613fc13880bb Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:45:46 -0700 Subject: [PATCH 29/73] Document object_warp1 (blue warp, warp crystal, boss warp) (#1075) * Document object_warp1 (blue warp, warp crystal, boss warp) * Fix description for actor --- assets/xml/objects/object_warp1.xml | 130 ++++++++++-------- .../actors/ovl_Door_Warp1/z_door_warp1.c | 31 ++--- 2 files changed, 90 insertions(+), 71 deletions(-) diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 6ac25e827..0f6fe168b 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -1,59 +1,79 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 9399bf5ca..ca3e1a9fd 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1,7 +1,7 @@ /* * File: z_door_warp1.c * Overlay: ovl_Door_Warp1 - * Description: Blue Warp + * Description: Blue warp portal and crystal, and the Majora's Mask-shaped boss warp platform */ #include "z_door_warp1.h" @@ -152,7 +152,7 @@ void DoorWarp1_Init(Actor* thisx, PlayState* play) { case ENDOORWARP1_FF_5: this->unk_1D3 = 1; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_warp1_Colheader_008BD4); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWarpBossWarpPlatformCol); func_808B8C48(this, play); break; @@ -210,8 +210,8 @@ void func_808B8924(DoorWarp1* this, PlayState* play) { } void func_808B8A7C(DoorWarp1* this, PlayState* play) { - SkelAnime_Init(play, &this->skelAnime, &object_warp1_Skel_002CA8, &object_warp1_Anim_001374, NULL, NULL, 0); - Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); + SkelAnime_Init(play, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); this->unk_1C4 = 0; this->unk_1C6 = -140; this->unk_1C8 = -80; @@ -622,9 +622,8 @@ void func_808B9FD0(DoorWarp1* this, PlayState* play) { ActorCutscene_Start(play->playerActorCsIds[9], NULL); AudioSfx_PlaySfx(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, - Animation_GetLastFrame(&object_warp1_Anim_001374.common), - Animation_GetLastFrame(&object_warp1_Anim_001374.common), 2, 40.0f, 1); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), 2, 40.0f, 1); this->unk_1CA = 50; D_808BC004 = player2->actor.world.pos.y; DoorWarp1_SetupAction(this, func_808BA550); @@ -992,7 +991,7 @@ void func_808BAE9C(DoorWarp1* this, PlayState* play) { MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->state.gfxCtx)); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); Matrix_Pop(); @@ -1010,14 +1009,14 @@ void func_808BAE9C(DoorWarp1* this, PlayState* play) { MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->state.gfxCtx)); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); } CLOSE_DISPS(play->state.gfxCtx); } void func_808BB4C4(DoorWarp1* this, PlayState* play) { - Gfx_DrawDListOpa(play, object_warp1_DL_0076C0); + Gfx_DrawDListOpa(play, gWarpBossWarpPlatformDL); } void func_808BB4F4(DoorWarp1* this, PlayState* play2) { @@ -1035,8 +1034,8 @@ void func_808BB4F4(DoorWarp1* this, PlayState* play2) { 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(play, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0044D8)); - Gfx_DrawDListXlu(play, object_warp1_DL_003230); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWarpBossWarpActivationBeamTexAnim)); + Gfx_DrawDListXlu(play, gWarpBossWarpActivationBeamDL); return; } @@ -1054,7 +1053,7 @@ void func_808BB4F4(DoorWarp1* this, PlayState* play2) { 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(play, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0057D8)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWarpBossWarpLightShaftsTexAnim)); OPEN_DISPS(play->state.gfxCtx); @@ -1063,13 +1062,13 @@ void func_808BB4F4(DoorWarp1* this, PlayState* play2) { gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); + gSPDisplayList(POLY_XLU_DISP++, gWarpBossWarpLightShaftsDL); CLOSE_DISPS(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWarpBossWarpGlowTexAnim)); 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); @@ -1080,7 +1079,7 @@ void func_808BB4F4(DoorWarp1* this, PlayState* play2) { gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->unk_203); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0058C8); + gSPDisplayList(POLY_XLU_DISP++, gWarpBossWarpGlowDL); CLOSE_DISPS(play->state.gfxCtx); } From 76dc0dd867cd57bddcff191fcad3589b3f89422c Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:51:10 -0700 Subject: [PATCH 30/73] Document object_dblue_object (Great Bay Temple objects) (#1077) * Document everything except the unknown blob and the weird collision * Add the last unused texture, thanks Tharo! * Finish up documentation * Respond to Elliptic's review --- assets/xml/objects/object_dblue_object.xml | 218 ++++++++++++------ .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 60 ++--- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 74 +++--- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h | 6 +- .../z_bg_dblue_waterfall.c | 14 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- tools/disasm/variables.txt | 10 +- 7 files changed, 227 insertions(+), 157 deletions(-) diff --git a/assets/xml/objects/object_dblue_object.xml b/assets/xml/objects/object_dblue_object.xml index d49b368e1..8611c539b 100644 --- a/assets/xml/objects/object_dblue_object.xml +++ b/assets/xml/objects/object_dblue_object.xml @@ -1,78 +1,148 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 d849ab5ed..d7e1bef1f 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 @@ -1,7 +1,7 @@ /* * File: z_bg_dblue_balance.c * Overlay: ovl_Bg_Dblue_Balance - * Description: Great Bay Temple - See-Saw + * Description: Great Bay Temple - Seesaw and Waterwheel w/ Platforms */ #include "prevent_bss_reordering.h" @@ -43,19 +43,19 @@ const ActorInit Bg_Dblue_Balance_InitVars = { }; typedef struct { - /* 0x00 */ Gfx* unk_00; - /* 0x04 */ CollisionHeader* unk_04; + /* 0x00 */ Gfx* opaDList; + /* 0x04 */ CollisionHeader* colHeader; /* 0x08 */ u32 unk_08; /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; - /* 0x14 */ ActorFunc unk_14; - /* 0x18 */ ActorFunc unk_18; -} BgDblueBalanceStruct2; + /* 0x14 */ ActorFunc update; + /* 0x18 */ ActorFunc draw; +} BgDblueBalanceTypeInfo; // size = 0x1C -BgDblueBalanceStruct2 D_80B83A20[] = { +BgDblueBalanceTypeInfo sTypeInfo[] = { { - object_dblue_object_DL_00B8F8, - &object_dblue_object_Colheader_00BC08, + gGreatBayTempleObjectSeesawShaftDL, + &gGreatBayTempleObjectSeesawShaftCol, 0x10, 360.0f, 300.0f, @@ -63,8 +63,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_00BF48, - &object_dblue_object_Colheader_00C180, + gGreatBayTempleObjectLargeSeesawPlatformDL, + &gGreatBayTempleObjectLargeSeesawPlatformCol, 0x10, 210.0f, 190.0f, @@ -72,8 +72,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_00C4B8, - &object_dblue_object_Colheader_00C700, + gGreatBayTempleObjectSmallSeesawPlatformDL, + &gGreatBayTempleObjectSmallSeesawPlatformCol, 0x10, 180.0f, 180.0f, @@ -81,8 +81,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_001E68, - &object_dblue_object_Colheader_002E78, + gGreatBayTempleObjectWaterwheelWithPlatformsDL, + &gGreatBayTempleObjectWaterwheelWithPlatformsCol, 0x30, 1500.0f, 1500.0f, @@ -311,19 +311,19 @@ void BgDblueBalance_Init(Actor* thisx, PlayState* play) { 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; + this->dyna.actor.flags = sTypeInfo[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = sTypeInfo[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = sTypeInfo[sp2C].unk_10; + this->dyna.actor.update = sTypeInfo[sp2C].update; + this->dyna.actor.draw = sTypeInfo[sp2C].draw; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, D_80B83A20[sp2C].unk_04); + DynaPolyActor_LoadMesh(play, &this->dyna, sTypeInfo[sp2C].colHeader); if (sp2C == 3) { - D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + D_80B83C70 = Lib_SegmentedToVirtual(gGreatBayTempleObjectWaterwheelSplashTexAnim); } else if (sp2C == 0) { - D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + D_80B83C74 = Lib_SegmentedToVirtual(gGreatBayTempleObjectSeesawSplashTexAnim); } if (sp2C == 0) { @@ -645,11 +645,11 @@ void func_80B83518(Actor* thisx, PlayState* play) { void BgDblueBalance_Draw(Actor* thisx, PlayState* play) { s32 pad; BgDblueBalance* this = THIS; - BgDblueBalanceStruct2* ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + BgDblueBalanceTypeInfo* ptr2 = &sTypeInfo[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; BgDblueBalance* sp38; Gfx* gfx; - Gfx_DrawDListOpa(play, ptr2->unk_00); + Gfx_DrawDListOpa(play, ptr2->opaDList); if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { AnimatedMat_Draw(play, D_80B83C74); @@ -666,7 +666,7 @@ void BgDblueBalance_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(gfx++, &sSetupDL[6 * 25]); gSPMatrix(gfx++, Matrix_NewMtx(play->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); + gSPDisplayList(gfx++, gGreatBayTempleObjectSeesawSplashDL); POLY_XLU_DISP = gfx; @@ -681,7 +681,7 @@ void func_80B83758(Actor* thisx, PlayState* play) { Gfx* gfx; s32 i; BgDblueBalanceStruct* ptr; - BgDblueBalanceStruct2* ptr2; + BgDblueBalanceTypeInfo* ptr2; s32 temp; if (this->unk_178 != 0) { @@ -695,8 +695,8 @@ void func_80B83758(Actor* thisx, PlayState* play) { } if (this->dyna.actor.flags & ACTOR_FLAG_40) { - ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; - Gfx_DrawDListOpa(play, ptr2->unk_00); + ptr2 = &sTypeInfo[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(play, ptr2->opaDList); if (this->unk_183 != 0) { AnimatedMat_Draw(play, D_80B83C70); @@ -717,7 +717,7 @@ void func_80B83758(Actor* thisx, PlayState* play) { temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; gDPSetEnvColor(gfx++, 0, 0, 0, temp); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + gSPDisplayList(gfx++, gGreatBayTempleObjectWaterwheelSplashDL); } } 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 c42d96c0f..53a3300d4 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 @@ -1,7 +1,7 @@ /* * File: z_bg_dblue_movebg.c * Overlay: ovl_Bg_Dblue_Movebg - * Description: Great Bay Temple - Waterwheels and push switches + * Description: Great Bay Temple - Waterwheels, push switches, gear shafts, and whirlpools */ #include "prevent_bss_reordering.h" @@ -57,42 +57,42 @@ const ActorInit Bg_Dblue_Movebg_InitVars = { (ActorFunc)BgDblueMovebg_Draw, }; -Gfx* D_80A2B8AC[] = { +static Gfx* sOpaDLists[] = { NULL, - object_dblue_object_DL_0069D8, + gGreatBayTempleObjectTwoWaySwitchDL, NULL, NULL, NULL, NULL, - object_dblue_object_DL_004848, - object_dblue_object_DL_0061B8, + gGreatBayTempleObjectGearShaftWithPlatformsDL, + gGreatBayTempleObjectOneWaySwitchDL, NULL, NULL, NULL, NULL, }; -Gfx* D_80A2B8DC[] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_DL_00CAA0, NULL, +static Gfx* sXluDLists[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, gGreatBayTempleObjectWhirlpoolDL, NULL, }; -CollisionHeader* D_80A2B90C[] = { +static CollisionHeader* sColHeaders[] = { NULL, - &object_dblue_object_Colheader_006EA8, + &gGreatBayTempleObjectTwoWaySwitchCol, 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, + &gGreatBayTempleObjectUnusedCol, + &gGreatBayTempleObjectGearShaftWithPlatformsCol, + &gGreatBayTempleObjectOneWaySwitchCol, + &gGreatBayTempleObjectWaterwheelCol, + &gGreatBayTempleObjectWaterwheelCol, NULL, NULL, }; -AnimatedMaterial* D_80A2B93C[] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_Matanimheader_00CC18, NULL, +static AnimatedMaterial* sTexAnims[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, gGreatBayTempleObjectWhirlpoolTexAnim, NULL, }; s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; @@ -189,13 +189,13 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { D_80A2BBF4.unk_01 = 1; } - if (D_80A2B90C[this->unk_160] != NULL) { - DynaPolyActor_LoadMesh(play, &this->dyna, D_80A2B90C[this->unk_160]); + if (sColHeaders[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); } - this->unk_164 = D_80A2B8AC[this->unk_160]; - this->unk_168 = D_80A2B8DC[this->unk_160]; - this->unk_16C = D_80A2B93C[this->unk_160]; + this->opaDList = sOpaDLists[this->unk_160]; + this->xluDList = sXluDLists[this->unk_160]; + this->texAnim = sTexAnims[this->unk_160]; SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); @@ -341,9 +341,9 @@ void func_80A2A1E0(BgDblueMovebg* this, PlayState* play) { this->dyna.actor.shape.rot.y += this->unk_1CC; if (play->roomCtx.currRoom.num == 0) { - this->unk_164 = object_dblue_object_DL_004848; + this->opaDList = gGreatBayTempleObjectGearShaftWithPlatformsDL; } else if (play->roomCtx.currRoom.num == 8) { - this->unk_164 = NULL; + this->opaDList = NULL; } if (play->roomCtx.currRoom.num != this->unk_170) { @@ -678,9 +678,9 @@ void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { } if (play->roomCtx.currRoom.num == 0) { - this->unk_164 = object_dblue_object_DL_008778; + this->opaDList = gGreatBayTempleObjectWaterwheelDL; } else if (play->roomCtx.currRoom.num == 8) { - this->unk_164 = object_dblue_object_DL_00A528; + this->opaDList = gGreatBayTempleObjectWaterwheelWithFakeGearDL; } if (this == D_80A2BBF0) { @@ -756,7 +756,7 @@ void func_80A2B308(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, this->unk_164); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); CLOSE_DISPS(play->state.gfxCtx); } @@ -774,34 +774,34 @@ void BgDblueMovebg_Draw(Actor* thisx, PlayState* play2) { OPEN_DISPS(play->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(play, Lib_SegmentedToVirtual(this->unk_16C)); + if (this->texAnim != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->texAnim)); } - if ((this->unk_164 != 0) || (this->unk_160 == 6)) { + if ((this->opaDList != NULL) || (this->unk_160 == 6)) { gfx2 = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); gSPMatrix(&gfx2[0], Matrix_NewMtx(play->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); + gSPDisplayList(&gfx2[1], gGreatBayTempleObjectGearShaftDL); + if (this->opaDList != NULL) { + gSPDisplayList(&gfx2[2], this->opaDList); POLY_OPA_DISP = &gfx2[3]; } else { POLY_OPA_DISP = &gfx2[2]; } } else { - gSPDisplayList(&gfx2[1], this->unk_164); + gSPDisplayList(&gfx2[1], this->opaDList); POLY_OPA_DISP = &gfx2[2]; } } - if (this->unk_168 != NULL) { + if (this->xluDList != NULL) { gfx = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&gfx[1], this->unk_168); + gSPDisplayList(&gfx[1], this->xluDList); POLY_XLU_DISP = &gfx[2]; } @@ -812,7 +812,7 @@ void BgDblueMovebg_Draw(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); if ((this->unk_160 == 8) && (this->unk_172 & 0x20)) { - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gGreatBayTempleObjectWaterwheelSplashTexAnim)); OPEN_DISPS(play->state.gfxCtx); @@ -844,7 +844,7 @@ void BgDblueMovebg_Draw(Actor* thisx, PlayState* play2) { gSPMatrix(gfx++, Matrix_NewMtx(play->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); + gSPDisplayList(gfx++, gGreatBayTempleObjectWaterwheelSplashDL); Matrix_Pop(); } 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 83fb1df62..6b5351c2c 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 @@ -17,9 +17,9 @@ typedef struct BgDblueMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgDblueMovebgActionFunc actionFunc; /* 0x160 */ s32 unk_160; - /* 0x164 */ Gfx* unk_164; - /* 0x168 */ Gfx* unk_168; - /* 0x16C */ TexturePtr unk_16C; + /* 0x164 */ Gfx* opaDList; + /* 0x168 */ Gfx* xluDList; + /* 0x16C */ AnimatedMaterial* texAnim; /* 0x170 */ s8 unk_170; /* 0x171 */ s8 unk_171; /* 0x172 */ u16 unk_172; 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 6f914a475..a2fa18103 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 @@ -1,7 +1,7 @@ /* * File: z_bg_dblue_waterfall.c * Overlay: ovl_Bg_Dblue_Waterfall - * Description: Great Bay Temple - Freezable Geyser + * Description: Great Bay Temple - Freezable Waterfall */ #include "z_bg_dblue_waterfall.h" @@ -344,7 +344,7 @@ void BgDblueWaterfall_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider); - this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); + this->unk_190 = Lib_SegmentedToVirtual(gGreatBayTempleObjectWaterfallTexAnim); Actor_SetFocus(&this->actor, -100.0f); func_80B84568(this, play); @@ -600,30 +600,30 @@ void BgDblueWaterfall_Draw(Actor* thisx, PlayState* play) { AnimatedMat_Draw(play, this->unk_190); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); - gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectWaterfallDL); } 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); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectIceStalactiteDL); } else { func_8012C28C(play->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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + gSPDisplayList(POLY_OPA_DISP++, gGreatBayTempleObjectIceStalactiteDL); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); - gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectIceStalactiteRimDL); } 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); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectFrozenWaterfallDL); } CLOSE_DISPS(play->state.gfxCtx); 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 0c99056b4..691f00e60 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -78,7 +78,7 @@ ShutterInfo D_808A21B0[] = { { 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 }, + { gGreatBayTempleObjectDoorDL, 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 }, diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 538030f58..b4585b987 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -11090,10 +11090,10 @@ 0x80A297D0:("D_80A297D0","f32","",0x4), 0x80A2B870:("D_80A2B870","UNK_TYPE1","",0x1), 0x80A2B88C:("Bg_Dblue_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80A2B8AC:("D_80A2B8AC","UNK_TYPE1","",0x1), - 0x80A2B8DC:("D_80A2B8DC","UNK_TYPE1","",0x1), - 0x80A2B90C:("D_80A2B90C","UNK_TYPE1","",0x1), - 0x80A2B93C:("D_80A2B93C","UNK_TYPE1","",0x1), + 0x80A2B8AC:("sOpaDLists","UNK_TYPE1","",0x1), + 0x80A2B8DC:("sXluDLists","UNK_TYPE1","",0x1), + 0x80A2B90C:("sColHeaders","UNK_TYPE1","",0x1), + 0x80A2B93C:("sTexAnims","UNK_TYPE1","",0x1), 0x80A2B96C:("D_80A2B96C","UNK_TYPE1","",0x1), 0x80A2B974:("D_80A2B974","UNK_TYPE2","",0x2), 0x80A2B978:("D_80A2B978","UNK_TYPE1","",0x1), @@ -15082,7 +15082,7 @@ 0x80B82228:("D_80B82228","f32","",0x4), 0x80B8222C:("D_80B8222C","f32","",0x4), 0x80B83A00:("Bg_Dblue_Balance_InitVars","UNK_TYPE1","",0x1), - 0x80B83A20:("D_80B83A20","UNK_TYPE4","",0x4), + 0x80B83A20:("sTypeInfo","UNK_TYPE4","",0x4), 0x80B83A74:("D_80B83A74","UNK_TYPE1","",0x1), 0x80B83A90:("D_80B83A90","UNK_TYPE1","",0x1), 0x80B83A92:("D_80B83A92","UNK_TYPE1","",0x1), From 6bd4b58eb592f5498bd7d7ee7480765cf8b3a04a Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 11:58:48 -0700 Subject: [PATCH 31/73] Document object_gs (Gossip Stone) (#1078) * Document object_gs (Gossip Stone) * Fix one of the names --- assets/xml/objects/object_gs.xml | 9 +++++---- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/assets/xml/objects/object_gs.xml b/assets/xml/objects/object_gs.xml index 1e9b159df..eebe60035 100644 --- a/assets/xml/objects/object_gs.xml +++ b/assets/xml/objects/object_gs.xml @@ -1,8 +1,9 @@  + - - - - + + + + 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 e831328f6..3927305ad 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -1082,10 +1082,10 @@ void EnGs_Draw(Actor* thisx, PlayState* play) { } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000950); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneMaterialDL); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1FA.r, this->unk_1FA.g, this->unk_1FA.b, 255); - gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_0009D0); - gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000A60); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneDL); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneBottomModelDL); Matrix_Pop(); From c222747977d036e0afb5a0514277dcae9ea9367a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 12:03:34 -0700 Subject: [PATCH 32/73] Object_trt documented + other shopkeeper cleanup (#1081) * trt skel * Some cleanup * Textures * Better Tex names * Small renames * Animations * Animation enum * trt2 * format * Update assets/xml/objects/object_trt.xml Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update assets/xml/objects/object_trt.xml Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Whitespace * HairPiece -> Braid Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/object_cne.xml | 12 +- assets/xml/objects/object_trt.xml | 192 ++++++++------- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 84 ++++--- src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 4 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 172 +++++++------- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 14 ++ src/overlays/actors/ovl_En_Trt/z_en_trt.c | 223 ++++++++++-------- src/overlays/actors/ovl_En_Trt/z_en_trt.h | 4 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 82 ++++--- tools/disasm/functions.txt | 8 +- 11 files changed, 442 insertions(+), 355 deletions(-) diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index a4c8b28e2..135aae7a2 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -38,12 +38,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index c7fb81321..826aa1ef0 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -1,94 +1,106 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 fe7a91667..0c00c6040 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -261,26 +261,26 @@ u8 EnFsn_SetCursorIndexFromNeutral(EnFsn* this) { } void EnFsn_CursorLeftRight(EnFsn* this) { - u8 cursorScan = this->cursorIdx; + u8 cursorScan = this->cursorIndex; if (this->stickAccumX > 0) { if (cursorScan != this->totalSellingItems - 1) { while (cursorScan != this->totalSellingItems - 1) { cursorScan++; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; break; } } } else if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; } } else if (this->stickAccumX < 0) { if (cursorScan != 0) { while (cursorScan != 0) { cursorScan--; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; break; } else if (cursorScan == 0) { play_sound(NA_SE_SY_CURSOR); @@ -294,7 +294,7 @@ void EnFsn_CursorLeftRight(EnFsn* this) { this->drawCursor = 0; this->actionFunc = EnFsn_LookToShopkeeperFromShelf; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; } } } @@ -417,7 +417,7 @@ s32 EnFsn_TestEndInteraction(EnFsn* this, PlayState* play, Input* input) { s32 EnFsn_TestCancelOption(EnFsn* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -429,7 +429,7 @@ void EnFsn_UpdateCursorPos(EnFsn* this, PlayState* play) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -466,9 +466,9 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, PlayState* play, Input* input) { return true; } if (EnFsn_TestItemSelected(play)) { - if (!this->items[this->cursorIdx]->isOutOfStock) { + if (!this->items[this->cursorIndex]->isOutOfStock) { this->prevActionFunc = this->actionFunc; - func_80151938(play, this->items[this->cursorIdx]->choiceTextId); + func_80151938(play, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -522,7 +522,7 @@ void EnFsn_UpdateJoystickInputState(EnFsn* this, PlayState* play) { void EnFsn_PositionSelectedItem(EnFsn* this) { Vec3f selectedItemPosition = { 13.0f, 38.0f, -71.0f }; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item = this->items[i]; Vec3f worldPos; @@ -572,7 +572,7 @@ void EnFsn_UpdateItemSelectedProperty(EnFsn* this) { this->drawCursor == 0) { (*items)->isSelected = false; } else { - (*items)->isSelected = (i == this->cursorIdx) ? true : false; + (*items)->isSelected = (i == this->cursorIndex) ? true : false; } } } @@ -712,7 +712,7 @@ void EnFsn_InitShop(EnFsn* this, PlayState* play) { } this->blinkTimer = 20; this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; - this->eyeTextureIdx = 0; + this->eyeTexIndex = 0; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnFsn_Idle; } @@ -995,7 +995,7 @@ void EnFsn_MakeOffer(EnFsn* this, PlayState* play) { void EnFsn_GiveItem(EnFsn* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { - if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { + if ((this->isSelling == true) && (this->items[this->cursorIndex]->getItemId == GI_MASK_ALL_NIGHT)) { func_80151BB4(play, 45); func_80151BB4(play, 3); } @@ -1005,7 +1005,7 @@ void EnFsn_GiveItem(EnFsn* this, PlayState* play) { } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, play, this->getItemId, 300.0f, 300.0f); } @@ -1086,7 +1086,7 @@ void EnFsn_LookToShelf(EnFsn* this, PlayState* play) { this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, play); this->actionFunc = EnFsn_BrowseShelf; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -1096,7 +1096,7 @@ void EnFsn_LookToShelf(EnFsn* this, PlayState* play) { void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { u8 talkstate = Message_GetState(&play->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; + u8 prevCursorIdx = this->cursorIndex; if (!EnFsn_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -1110,9 +1110,9 @@ void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { func_8011552C(play, 6); if (!EnFsn_HasPlayerSelectedItem(this, play, CONTROLLER1(&play->state))) { EnFsn_CursorLeftRight(this); - if (this->cursorIdx != prevCursorIdx) { + if (this->cursorIndex != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } } @@ -1144,7 +1144,7 @@ void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, PlayState* play) { } void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_2: @@ -1156,23 +1156,23 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->buyFanfareFunc(play, item); - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->boughtFunc(play, item); - if (this->stolenItem1 == this->cursorIdx) { + if (this->stolenItem1 == this->cursorIndex) { SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); - } else if (this->stolenItem2 == this->cursorIdx) { + } else if (this->stolenItem2 == this->cursorIndex) { SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; - this->itemIds[this->cursorIdx] = -1; + this->itemIds[this->cursorIndex] = -1; this->actionFunc = EnFsn_GiveItem; break; case CANBUY_RESULT_NEED_RUPEES: @@ -1218,7 +1218,7 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } } @@ -1227,7 +1227,7 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { void EnFsn_PlayerCannotBuy(EnFsn* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1326,16 +1326,16 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play) { void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - u8 cursorIdx; + u8 cursorIndex; if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnFsn_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && (!Message_ShouldAdvance(play) || !EnFsn_FacingShopkeeperDialogResult(this, play)) && this->stickAccumX > 0) { - cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnFsn_SetCursorIndexFromNeutral(this); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; this->actionFunc = EnFsn_LookToShelf; func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; @@ -1394,13 +1394,13 @@ void EnFsn_Blink(EnFsn* this) { s16 decr = this->blinkTimer - 1; if (decr >= 3) { - this->eyeTextureIdx = 0; + this->eyeTexIndex = 0; this->blinkTimer = decr; } else if (decr == 0) { - this->eyeTextureIdx = 2; + this->eyeTexIndex = 2; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; } else { - this->eyeTextureIdx = 1; + this->eyeTexIndex = 1; this->blinkTimer = decr; } } @@ -1427,7 +1427,7 @@ void EnFsn_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->blinkTimer = 20; - this->eyeTextureIdx = 0; + this->eyeTexIndex = 0; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->animIndex = FSN_ANIM_IDLE; @@ -1472,6 +1472,7 @@ void EnFsn_DrawCursor(EnFsn* this, PlayState* play, f32 x, f32 y, f32 z, u8 draw s32 pad; OPEN_DISPS(play->state.gfxCtx); + if (drawCursor != 0) { func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, @@ -1486,6 +1487,7 @@ void EnFsn_DrawCursor(EnFsn* this, PlayState* play, f32 x, f32 y, f32 z, u8 draw dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1501,6 +1503,7 @@ void EnFsn_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y s32 dtdy; OPEN_DISPS(play->state.gfxCtx); + gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1517,6 +1520,7 @@ void EnFsn_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1525,6 +1529,7 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, PlayState* play) { s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; OPEN_DISPS(play->state.gfxCtx); + if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -1559,6 +1564,7 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, PlayState* play) { this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1604,8 +1610,10 @@ void EnFsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, this->actor.focus.pos.z = this->actor.world.pos.z; OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1617,9 +1625,10 @@ void EnFsn_Draw(Actor* thisx, PlayState* play) { s16 i; OPEN_DISPS(play->state.gfxCtx); + func_8012C5B0(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFsn_OverrideLimbDraw, EnFsn_PostLimbDraw, &this->actor); @@ -1631,5 +1640,6 @@ void EnFsn_Draw(Actor* thisx, PlayState* play) { EnFsn_DrawCursor(this, play, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnFsn_DrawStickDirectionPrompts(this, play); + CLOSE_DISPS(play->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 9479e982e..6bf337be7 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -30,7 +30,7 @@ typedef struct EnFsn { /* 0x27A */ Vec3s unk27A; // Set but never used /* 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; + /* 0x364 */ s16 eyeTexIndex; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; /* 0x36A */ s16 cutscene; @@ -41,7 +41,7 @@ typedef struct EnFsn { /* 0x374 */ s16 price; /* 0x376 */ u16 textId; /* 0x378 */ u8 isSelling; - /* 0x379 */ u8 cursorIdx; + /* 0x379 */ u8 cursorIndex; /* 0x37C */ s32 getItemId; /* 0x380 */ s16 stolenItem1; /* 0x382 */ s16 stolenItem2; 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 fc5a2a724..ef46c5e81 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -291,7 +291,7 @@ void EnOssan_UpdateCursorPos(PlayState* play, EnOssan* this) { s16 x; s16 y; - Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x; this->cursorPos.y = y; } @@ -332,7 +332,7 @@ s32 EnOssan_TestEndInteraction(EnOssan* this, PlayState* play, Input* input) { s32 EnOssan_TestCancelOption(EnOssan* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -500,7 +500,7 @@ u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { u8 i; // if cursor is on the top shelf - if (this->cursorIdx & 1) { + if (this->cursorIndex & 1) { // scan top shelf for (i = shelfOffset + 1; i < shelfOffset + 4; i += 2) { if (this->items[i] != NULL) { @@ -530,26 +530,26 @@ u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { return CURSOR_INVALID; } -u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIdx, u8 shelfSlotMin) { +u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIndex, u8 shelfSlotMin) { u8 end = shelfSlotMin + 4; - while (cursorIdx >= shelfSlotMin && cursorIdx < end) { - cursorIdx -= 2; - if (cursorIdx >= shelfSlotMin && cursorIdx < end) { - if (this->items[cursorIdx] != NULL) { - return cursorIdx; + while (cursorIndex >= shelfSlotMin && cursorIndex < end) { + cursorIndex -= 2; + if (cursorIndex >= shelfSlotMin && cursorIndex < end) { + if (this->items[cursorIndex] != NULL) { + return cursorIndex; } } } return CURSOR_INVALID; } -u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { - while (cursorIdx < shelfSlotMax) { - cursorIdx += 2; - if (cursorIdx < shelfSlotMax) { - if (this->items[cursorIdx] != NULL) { - return cursorIdx; +u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIndex, u8 shelfSlotMax) { + while (cursorIndex < shelfSlotMax) { + cursorIndex += 2; + if (cursorIndex < shelfSlotMax) { + if (this->items[cursorIndex] != NULL) { + return cursorIndex; } } } @@ -619,7 +619,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s32 pad; Player* player = GET_PLAYER(play); - u8 cursorIdx; + u8 cursorIndex; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -634,18 +634,18 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && (!Message_ShouldAdvance(play) || !EnOssan_FacingShopkeeperDialogResult(this, play))) { if (this->stickAccumX < 0) { - cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_SetCursorIndexFromNeutral(this, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnOssan_SetupAction(this, EnOssan_LookToLeftShelf); func_8011552C(play, 6); this->stickLeftPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } } else if (this->stickAccumX > 0) { - cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 0); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_SetCursorIndexFromNeutral(this, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnOssan_SetupAction(this, EnOssan_LookToRightShelf); func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; @@ -693,7 +693,7 @@ void EnOssan_LookToLeftShelf(EnOssan* this, PlayState* play) { this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseLeftShelf); - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -721,7 +721,7 @@ void EnOssan_LookToRightShelf(EnOssan* this, PlayState* play) { this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseRightShelf); - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -731,16 +731,16 @@ void EnOssan_LookToRightShelf(EnOssan* this, PlayState* play) { } void EnOssan_CursorUpDown(EnOssan* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; u8 curScanTemp; if (this->stickAccumY < 0) { curTemp &= (u8)~1; if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; return; } - // cursorIdx on right shelf + // cursorIndex on right shelf if (curTemp < 4) { curScanTemp = curTemp + 2; if (curScanTemp >= 4) { @@ -748,7 +748,7 @@ void EnOssan_CursorUpDown(EnOssan* this) { } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -757,14 +757,14 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } } else { - // cursorIdx on left shelf + // cursorIndex on left shelf curScanTemp = curTemp + 2; if (curScanTemp >= 8) { curScanTemp = 4; } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -776,10 +776,10 @@ void EnOssan_CursorUpDown(EnOssan* this) { } else if (this->stickAccumY > 0) { curTemp |= 1; if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; return; } - // cursorIdx on right shelf + // cursorIndex on right shelf if (curTemp < 4) { curScanTemp = curTemp + 2; if (curScanTemp >= 4) { @@ -787,7 +787,7 @@ void EnOssan_CursorUpDown(EnOssan* this) { } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -796,14 +796,14 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } } else { - // cursorIdx on left shelf + // cursorIndex on left shelf curScanTemp = curTemp + 2; if (curScanTemp >= 8) { curScanTemp = 5; } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -816,7 +816,7 @@ void EnOssan_CursorUpDown(EnOssan* this) { } s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; if (EnOssan_TestEndInteraction(this, play, input)) { return true; @@ -824,7 +824,7 @@ s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) if (EnOssan_TestItemSelected(play)) { if (!item->isOutOfStock) { this->prevActionFunc = this->actionFunc; - func_80151938(play, this->items[this->cursorIdx]->choiceTextId); + func_80151938(play, this->items[this->cursorIndex]->choiceTextId); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_DECIDE); @@ -841,8 +841,8 @@ s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - u8 prevCursorIndex = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -857,38 +857,38 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal) { if (this->stickAccumX > 0) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 8); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 8); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } else { if (this->stickAccumX > 0 && this->stickAccumX > 500) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0 && this->stickAccumX < -500) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 8); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 8); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } EnOssan_CursorUpDown(this); - if (this->cursorIdx != prevCursorIndex) { - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + if (this->cursorIndex != prevCursorIndex) { + func_80151938(play, this->items[this->cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -899,8 +899,8 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - u8 prevCursorIndex = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -915,38 +915,38 @@ void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal != 0) { if (this->stickAccumX < 0) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } else { if (this->stickAccumX < 0 && this->stickAccumX < -500) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0 && this->stickAccumX > 500) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } EnOssan_CursorUpDown(this); - if (this->cursorIdx != prevCursorIndex) { - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + if (this->cursorIndex != prevCursorIndex) { + func_80151938(play, this->items[this->cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -981,7 +981,7 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, PlayState* play) { void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; @@ -1001,7 +1001,7 @@ void EnOssan_SetupBuy(PlayState* play, EnOssan* this, u16 textId) { } void EnOssan_HandleCanBuyItem(PlayState* play, EnOssan* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: @@ -1061,7 +1061,7 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1071,7 +1071,7 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { void EnOssan_CannotBuy(EnOssan* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1081,10 +1081,10 @@ void EnOssan_CanBuy(EnOssan* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1093,7 +1093,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, PlayState* play) { this->actor.parent = NULL; EnOssan_SetupAction(this, EnOssan_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1122,7 +1122,7 @@ void EnOssan_ContinueShopping(EnOssan* this, PlayState* play) { func_8011552C(play, 6); if (Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { switch (play->msgCtx.choiceIndex) { @@ -1144,7 +1144,7 @@ void EnOssan_ContinueShopping(EnOssan* this, PlayState* play) { } } else if (talkState == TEXT_STATE_5 && Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; @@ -1184,7 +1184,7 @@ void EnOssan_PositionSelectedItem(EnOssan* this) { { -35.0f, 68.0f, -130.0f }, }; EnGirlA* item; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; u8 i2; ShopItem* shopItem = &sShops[this->actor.params][i]; Vec3f worldPos; @@ -1245,7 +1245,7 @@ void EnOssan_UpdateItemSelectedProperty(EnOssan* this) { this->drawCursor == 0) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1479,7 +1479,7 @@ void EnOssan_InitShop(EnOssan* this, PlayState* play) { this->actor.colChkInfo.cylRadius = 50; this->stickAccumX = this->stickAccumY = 0; - this->cursorIdx = 0; + this->cursorIndex = 0; this->cursorPos.z = 1.5f; this->cursorColor.r = 0; this->cursorColor.g = 80; @@ -1573,6 +1573,7 @@ void EnOssan_DrawCursor(PlayState* play, EnOssan* this, f32 x, f32 y, f32 z, u8 (void)"../z_en_oB1.c"; OPEN_DISPS(play->state.gfxCtx); + if (drawCursor != 0) { func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, @@ -1587,6 +1588,7 @@ void EnOssan_DrawCursor(PlayState* play, EnOssan* this, f32 x, f32 y, f32 z, u8 dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1605,6 +1607,7 @@ void EnOssan_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 (void)"../z_en_oB1.c"; OPEN_DISPS(play->state.gfxCtx); + gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1621,6 +1624,7 @@ void EnOssan_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1631,6 +1635,7 @@ void EnOssan_DrawStickDirectionPrompts(PlayState* play, EnOssan* this) { (void)"../z_en_oB1.c"; OPEN_DISPS(play->state.gfxCtx); + if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -1665,6 +1670,7 @@ void EnOssan_DrawStickDirectionPrompts(PlayState* play, EnOssan* this) { this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1713,6 +1719,7 @@ void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play) { EnOssan* this = THIS; OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, @@ -1720,6 +1727,7 @@ void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play) { &this->actor); EnOssan_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(play, this); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1729,11 +1737,13 @@ void EnOssan_PartTimer_Draw(Actor* thisx, PlayState* play) { EnOssan* this = THIS; OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnOssan_PartTimer_OverrideLimbDraw, EnOssan_PartTimer_PostLimbDraw, &this->actor); EnOssan_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(play, this); + CLOSE_DISPS(play->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 539906ea8..20d669ea4 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -35,7 +35,7 @@ typedef struct EnOssan { /* 0x230 */ f32 cursorAnimTween; /* 0x234 */ u8 cursorAnimState; /* 0x235 */ u8 drawCursor; - /* 0x236 */ u8 cursorIdx; + /* 0x236 */ u8 cursorIndex; /* 0x238 */ StickDirectionPrompt stickLeftPrompt; /* 0x270 */ StickDirectionPrompt stickRightPrompt; /* 0x2A8 */ f32 arrowAnimTween; 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 aa8f651ec..4f17b9880 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1479,6 +1479,7 @@ void EnSob1_DrawCursor(PlayState* play, EnSob1* this, f32 x, f32 y, f32 z, u8 dr s32 pad; OPEN_DISPS(play->state.gfxCtx); + if (drawCursor != 0) { func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, @@ -1493,6 +1494,7 @@ void EnSob1_DrawCursor(PlayState* play, EnSob1* this, f32 x, f32 y, f32 z, u8 dr dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1511,6 +1513,7 @@ void EnSob1_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 (void)"../z_en_soB1.c"; OPEN_DISPS(play->state.gfxCtx); + gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1527,6 +1530,7 @@ void EnSob1_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1537,6 +1541,7 @@ void EnSob1_DrawStickDirectionPrompt(PlayState* play, EnSob1* this) { (void)"../z_en_soB1.c"; OPEN_DISPS(play->state.gfxCtx); + if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -1571,6 +1576,7 @@ void EnSob1_DrawStickDirectionPrompt(PlayState* play, EnSob1* this) { this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1596,9 +1602,11 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** void EnSob1_BombShopkeeper_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { OPEN_DISPS(play->state.gfxCtx); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_LEFT_HAND) { gSPDisplayList(POLY_OPA_DISP++, gBombShopkeeperBombDL); } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1619,6 +1627,7 @@ void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, PlayState* play) { s32 i; OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(play->state.gfxCtx)); @@ -1632,6 +1641,7 @@ void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, PlayState* play) { } EnSob1_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnSob1_DrawStickDirectionPrompt(play, this); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1642,6 +1652,7 @@ void EnSob1_GoronShopkeeper_Draw(Actor* thisx, PlayState* play) { s32 i; OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sGoronShopkeeperEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, @@ -1653,6 +1664,7 @@ void EnSob1_GoronShopkeeper_Draw(Actor* thisx, PlayState* play) { } EnSob1_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnSob1_DrawStickDirectionPrompt(play, this); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1663,6 +1675,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, PlayState* play) { s32 i; OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, @@ -1683,5 +1696,6 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, -frames * 20, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + CLOSE_DISPS(play->state.gfxCtx); } 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 6402e5920..39a16dea9 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -23,7 +23,7 @@ void EnTrt_Draw(Actor* thisx, PlayState* play); void EnTrt_GetCutscenes(EnTrt* this, PlayState* play); void EnTrt_ResetItemPosition(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, PlayState* play); +void EnTrt_TrackPlayer(EnTrt* this, PlayState* play); s32 EnTrt_ReturnItemToShelf(EnTrt* this); s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, PlayState* play); s32 EnTrt_TakeItemOffShelf(EnTrt* this); @@ -64,17 +64,30 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); +typedef enum { + /* 0 */ TRT_ANIM_IDLE, + /* 1 */ TRT_ANIM_HALF_AWAKE, + /* 2 */ TRT_ANIM_SLEEPING, + /* 3 */ TRT_ANIM_WAKE_UP, + /* 4 */ TRT_ANIM_SURPRISED, + /* 5 */ TRT_ANIM_HANDS_ON_COUNTER, + /* 6 */ TRT_ANIM_HOVER, + /* 7 */ TRT_ANIM_FLY_LOOK_AROUND, + /* 8 */ TRT_ANIM_FLY_DOWN, + /* 9 */ TRT_ANIM_FLY +} TrtAnimation; + static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &gKotakeIdleAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHalfAwakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSleepingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeWakeUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHandsOnCounterAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt_InitVars = { @@ -149,7 +162,7 @@ void EnTrt_UpdateCursorPos(PlayState* play, EnTrt* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(play, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(play, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -178,18 +191,18 @@ void EnTrt_SetupGetMushroomCutscene(EnTrt* this) { } u16 EnTrt_GetItemTextId(EnTrt* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; - if (item->actor.params == SI_POTION_BLUE && !(this->flags & ENTRT_GIVEN_MUSHROOM)) { + if ((item->actor.params == SI_POTION_BLUE) && !(this->flags & ENTRT_GIVEN_MUSHROOM)) { return 0x880; } return item->actor.textId; } u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { + if ((item->actor.params == SI_POTION_BLUE) && !(gSaveContext.save.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -384,7 +397,7 @@ void EnTrt_Goodbye(EnTrt* this, PlayState* play) { } } -void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, PlayState* play) { +void EnTrt_StartRedPotionConversation(EnTrt* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x88F) { if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { @@ -501,7 +514,7 @@ s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, PlayState* play) { void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - u8 cursorIdx; + u8 cursorIndex; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -523,9 +536,9 @@ void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { if ((!Message_ShouldAdvance(play) || !EnTrt_FacingShopkeeperDialogResult(this, play)) && (this->stickAccumX > 0)) { - cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnTrt_SetCursorIndexFromNeutral(this, 2); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; this->actionFunc = EnTrt_LookToShelf; func_8011552C(play, 6); this->stickRightPrompt.isEnabled = false; @@ -562,7 +575,7 @@ void EnTrt_LookToShelf(EnTrt* this, PlayState* play) { } void EnTrt_CursorLeftRight(PlayState* play, EnTrt* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; if (this->stickAccumX < 0) { if (curTemp != 2) { @@ -571,20 +584,20 @@ void EnTrt_CursorLeftRight(PlayState* play, EnTrt* this) { EnTrt_SetupLookToShopkeeperFromShelf(play, 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 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; if (EnTrt_TestEndInteraction(this, play, input)) { return true; @@ -609,8 +622,8 @@ s32 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIdx = this->cursorIndex; + u8 cursorIndex; if (!EnTrt_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -624,7 +637,7 @@ void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { func_8011552C(play, 6); if (!EnTrt_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { EnTrt_CursorLeftRight(play, this); - if (this->cursorIdx != prevCursorIdx) { + if (this->cursorIndex != prevCursorIdx) { func_80151938(play, EnTrt_GetItemTextId(this)); play_sound(NA_SE_SY_CURSOR); } @@ -636,7 +649,7 @@ void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; @@ -656,7 +669,7 @@ void EnTrt_SetupCanBuy(PlayState* play, EnTrt* this, u16 textId) { } void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; EnGirlA* item2; switch (item->canBuyFunc(play, item)) { @@ -666,13 +679,14 @@ void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* this) { this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; + item2 = this->items[this->cursorIndex]; item2->buyFanfareFunc(play, item2); EnTrt_SetupBuyItemWithFanfare(play, this); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(play, item); break; + case CANBUY_RESULT_SUCCESS_2: func_8019F208(); item->buyFunc(play, item); @@ -681,27 +695,34 @@ void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* this) { this->shopItemSelectedTween = 0.0f; item->boughtFunc(play, item); break; + case CANBUY_RESULT_NO_ROOM: play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(play, this, 0x641); break; + case CANBUY_RESULT_NEED_EMPTY_BOTTLE: play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(play, this, 0x846); break; + case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(play, this, 0x847); break; + case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(play, this, 0x643); break; + + default: + break; } } void EnTrt_SelectItem(EnTrt* this, PlayState* play) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; u8 talkState = Message_GetState(&play->msgCtx); if (EnTrt_TakeItemOffShelf(this)) { @@ -757,8 +778,8 @@ void EnTrt_IdleSleeping(EnTrt* this, PlayState* play) { } this->prevTextId = this->textId; - if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA || - player->transformation == PLAYER_FORM_DEKU) { + if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_ZORA) || + (player->transformation == PLAYER_FORM_DEKU)) { this->textId = 0x850; } if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { @@ -779,14 +800,14 @@ void EnTrt_IdleSleeping(EnTrt* this, PlayState* play) { player->stateFlags2 |= 0x20000000; this->timer = 45; this->actionFunc = EnTrt_BeginInteraction; - } else if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= -25.0f) && - (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { + } else if (((player->actor.world.pos.x >= -50.0f) && (player->actor.world.pos.x <= -25.0f)) && + ((player->actor.world.pos.z >= -19.0f) && (player->actor.world.pos.z <= 30.0f))) { func_800B8614(&this->actor, play, 200.0f); } if (DECR(this->timer) == 0) { this->timer = 40; - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 1); - this->animIndex = 1; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_HALF_AWAKE); + this->animIndex = TRT_ANIM_HALF_AWAKE; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -799,7 +820,7 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { Player* player = GET_PLAYER(play); this->flags &= ~ENTRT_FULLY_AWAKE; - if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_FIERCE_DEITY) { + if ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } else { @@ -821,7 +842,7 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 2); + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_SLEEPING); this->blinkFunc = EnTrt_EyesClosed; this->timer = 45; this->actionFunc = EnTrt_BeginInteraction; @@ -831,8 +852,8 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { } if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 2); - this->animIndex = 2; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_SLEEPING); + this->animIndex = TRT_ANIM_SLEEPING; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -842,7 +863,7 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; - s16 animLastFrame = Animation_GetLastFrame(&object_trt_Anim_0030EC) / (s16)this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&gKotakeWakeUpAnim) / (s16)this->skelAnime.playSpeed; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -852,10 +873,10 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animIndex != 5) { + if (this->animIndex != TRT_ANIM_HANDS_ON_COUNTER) { if (curFrame == animLastFrame) { - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 3); - this->animIndex = 3; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_WAKE_UP); + this->animIndex = TRT_ANIM_WAKE_UP; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -868,9 +889,9 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { } } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 5); + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_HANDS_ON_COUNTER); Message_StartTextbox(play, this->textId, &this->actor); - this->animIndex = 5; + this->animIndex = TRT_ANIM_HANDS_ON_COUNTER; switch (this->textId) { case 0x834: if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && @@ -880,7 +901,7 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_Hello; } else { - this->actionFunc = EnTrt_SetupTryToGiveRedPotion; + this->actionFunc = EnTrt_StartRedPotionConversation; } break; case 0x83E: @@ -894,7 +915,7 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { this->actionFunc = EnTrt_SetupEndInteraction; break; case 0x88F: - this->actionFunc = EnTrt_SetupTryToGiveRedPotion; + this->actionFunc = EnTrt_StartRedPotionConversation; break; } } @@ -910,8 +931,8 @@ void EnTrt_Surprised(EnTrt* this, PlayState* play) { } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 4); - this->animIndex = 4; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_SURPRISED); + this->animIndex = TRT_ANIM_SURPRISED; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -919,9 +940,9 @@ void EnTrt_Surprised(EnTrt* this, PlayState* play) { } } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); - EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, 5); + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_HANDS_ON_COUNTER); Message_StartTextbox(play, this->textId, &this->actor); - this->animIndex = 5; + this->animIndex = TRT_ANIM_HANDS_ON_COUNTER; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } @@ -1057,7 +1078,7 @@ void EnTrt_CanBuy(EnTrt* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); this->actionFunc = this->prevActionFunc; func_80151938(play, EnTrt_GetItemTextId(this)); @@ -1069,7 +1090,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, PlayState* play) { this->actor.parent = NULL; this->actionFunc = EnTrt_SetupItemGiven; } else { - Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1096,7 +1117,7 @@ void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { func_8011552C(play, 6); if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { switch (play->msgCtx.choiceIndex) { @@ -1119,7 +1140,7 @@ void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { } else if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(play, item); EnTrt_EndInteraction(play, this); } @@ -1128,7 +1149,7 @@ void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { void EnTrt_PositionSelectedItem(EnTrt* this) { static Vec3f sSelectedItemPosition = { 6.0f, 35.0f, -12.0f }; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item; ShopItem* shopItem = &sShop[i]; Vec3f worldPos; @@ -1189,7 +1210,7 @@ void EnTrt_UpdateItemSelectedProperty(EnTrt* this) { (this->drawCursor == 0)) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1278,53 +1299,53 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { } void EnTrt_OpenEyes(EnTrt* this) { - if (this->eyeTextureIdx <= 0) { - this->eyeTextureIdx = 0; + if (this->eyeTexIndex <= 0) { + this->eyeTexIndex = 0; } else { - this->eyeTextureIdx--; + this->eyeTexIndex--; } } void EnTrt_CloseEyes(EnTrt* this) { - if (this->eyeTextureIdx >= 2) { - this->eyeTextureIdx = 2; + if (this->eyeTexIndex >= 2) { + this->eyeTexIndex = 2; } else { - this->eyeTextureIdx++; + this->eyeTexIndex++; } } void EnTrt_Blink(EnTrt* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTexIndex; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTextureIdx + 1; - if (eyeTextureIdxTemp > 2) { - this->eyeTextureIdx = 0; + eyeTexIndex = this->eyeTexIndex + 1; + if (eyeTexIndex > 2) { + this->eyeTexIndex = 0; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; } else { - this->eyeTextureIdx = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTexIndex; this->blinkTimer = 1; } } void EnTrt_NodOff(EnTrt* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTexIndex; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTextureIdx + 1; - if (eyeTextureIdxTemp > 2) { - this->eyeTextureIdx = 1; + eyeTexIndex = this->eyeTexIndex + 1; + if (eyeTexIndex > 2) { + this->eyeTexIndex = 1; this->blinkTimer = 20; } else { - this->eyeTextureIdx = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTexIndex; this->blinkTimer = 3; } } @@ -1333,14 +1354,14 @@ void EnTrt_OpenThenCloseEyes(EnTrt* this) { if (this->skelAnime.curFrame >= 40.0f) { EnTrt_CloseEyes(this); } else if (this->skelAnime.curFrame >= 35.0f) { - this->eyeTextureIdx = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame >= 10.0f) { EnTrt_OpenEyes(this); } } void EnTrt_EyesClosed(EnTrt* this) { - this->eyeTextureIdx = 2; + this->eyeTexIndex = 2; } void EnTrt_OpenEyes2(EnTrt* this) { @@ -1350,7 +1371,7 @@ void EnTrt_OpenEyes2(EnTrt* this) { void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { if (this->skelAnime.curFrame >= 7.0f) { EnTrt_OpenEyes(this); - if (this->eyeTextureIdx == 0) { + if (this->eyeTexIndex == 0) { this->blinkFunc = EnTrt_Blink; } } @@ -1363,7 +1384,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { - if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { + if ((this->talkOptionTextId == 0x845) || (this->talkOptionTextId == 0x882)) { func_80151938(play, 0xFF); } else { EnTrt_StartShopping(play, this); @@ -1441,9 +1462,9 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, PlayState* play) { } void EnTrt_InitShopkeeper(EnTrt* this, PlayState* play) { - SkelAnime_InitFlex(play, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gKotakeSkel, &gKotakeSleepingAnim, NULL, NULL, 0); if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && - gSaveContext.save.day >= 2) { + (gSaveContext.save.day >= 2)) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; @@ -1472,7 +1493,7 @@ void EnTrt_InitShop(EnTrt* this, PlayState* play) { 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; @@ -1522,7 +1543,7 @@ void EnTrt_InitShop(EnTrt* this, PlayState* play) { Actor_SetScale(&this->actor, sActorScale); EnTrt_SpawnShopItems(this, play, sShop); this->blinkTimer = 20; - this->eyeTextureIdx = 0; + this->eyeTexIndex = 0; this->blinkFunc = EnTrt_EyesClosed; if (gSaveContext.save.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; @@ -1548,6 +1569,7 @@ void EnTrt_DrawCursor(PlayState* play, EnTrt* this, f32 x, f32 y, f32 z, u8 draw s32 pad; OPEN_DISPS(play->state.gfxCtx); + if (drawCursor != 0) { func_8012C654(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, @@ -1562,6 +1584,7 @@ void EnTrt_DrawCursor(PlayState* play, EnTrt* this, f32 x, f32 y, f32 z, u8 draw dsdx = (1.0f / z) * 1024.0f; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, 0, 0, dsdx, dsdx); } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1579,6 +1602,7 @@ void EnTrt_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y (void)"../z_en_trt.c"; OPEN_DISPS(play->state.gfxCtx); + gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, r, g, b, a); @@ -1595,6 +1619,7 @@ void EnTrt_DrawTextRec(PlayState* play, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y dtdy = dy * unk; gSPTextureRectangle(OVERLAY_DISP++, ulx, uly, lrx, lry, G_TX_RENDERTILE, s, t, dsdx, dtdy); + CLOSE_DISPS(play->state.gfxCtx); } @@ -1605,6 +1630,7 @@ void EnTrt_DrawStickDirectionPrompt(PlayState* play, EnTrt* this) { (void)"../z_en_trt.c"; OPEN_DISPS(play->state.gfxCtx); + if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -1639,6 +1665,7 @@ void EnTrt_DrawStickDirectionPrompt(PlayState* play, EnTrt* this) { this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } } + CLOSE_DISPS(play->state.gfxCtx); } @@ -1668,14 +1695,14 @@ void EnTrt_Update(Actor* thisx, PlayState* play) { EnTrt_UpdateItemSelectedProperty(this); EnTrt_UpdateStickDirectionPromptAnim(this); EnTrt_UpdateCursorAnim(this); - EnTrt_UpdateHeadYawAndPitch(this, play); + EnTrt_TrackPlayer(this, play); this->actionFunc(this, play); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); EnTrt_UpdateCollider(this, play); } -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, PlayState* play) { +void EnTrt_TrackPlayer(EnTrt* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f playerPos; Vec3f pos; @@ -1690,7 +1717,7 @@ void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, PlayState* play) { this->headPitch = CLAMP(this->headPitch, -0x1C70, 0x1C70); } -void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 isFullyAwake) { +void EnTrt_UpdateLimb(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 overrideRot) { Vec3f newPos; Vec3f zeroVec = gZeroVec3f; Vec3s newRot; @@ -1700,7 +1727,7 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Matrix_Get(¤tState); Matrix_MtxFToYXZRot(¤tState, &newRot, false); *pos = newPos; - if (isFullyAwake) { + if (overrideRot) { newRot.x += pitch; newRot.y += yaw; Math_SmoothStepToS(&rot->x, newRot.x, 4, 0x1FFE, 1); @@ -1723,7 +1750,7 @@ s32 EnTrt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p this->items[i]->actor.scale.z = 0.2f; } - if (limbIndex == 14) { + if (limbIndex == KOTAKE_LIMB_BROOM) { *dList = NULL; } return false; @@ -1731,14 +1758,14 @@ s32 EnTrt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnTrt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTrt* this = THIS; - s32 isFullyAwake; + s32 overrideRot; - isFullyAwake = false; + overrideRot = false; if (this->flags & ENTRT_FULLY_AWAKE) { - isFullyAwake = true; + overrideRot = true; } - if (limbIndex == 21) { - EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); + if (limbIndex == KOTAKE_LIMB_HEAD) { + EnTrt_UpdateLimb(this->headPitch, this->headYaw, &this->headPos, &this->headRot, overrideRot); 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_RotateYS(this->headRot.y, MTXMODE_APPLY); @@ -1750,7 +1777,7 @@ void EnTrt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void EnTrt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTrt* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { 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_RotateYS(this->headRot.y, MTXMODE_APPLY); @@ -1760,15 +1787,15 @@ void EnTrt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } void EnTrt_Draw(Actor* thisx, PlayState* play) { - static TexturePtr sEyeTextures[] = { object_trt_Tex_00B0B8, object_trt_Tex_00B8B8, object_trt_Tex_00C0B8 }; + static TexturePtr sEyeTextures[] = { gKotakeEyeOpenTex, gKotakeEyeHalfTex, gKotakeEyeClosedTex }; EnTrt* this = THIS; s32 pad; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt_OverrideLimbDraw, EnTrt_PostLimbDraw, EnTrt_TransformLimbDraw, &this->actor); 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 46f070797..9cbf5d51c 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -22,7 +22,7 @@ typedef struct EnTrt { /* 0x338 */ s32 stickAccumX; /* 0x33C */ s32 stickAccumY; /* 0x340 */ EnGirlA* items[3]; - /* 0x34C */ u8 cursorIdx; + /* 0x34C */ u8 cursorIndex; /* 0x350 */ StickDirectionPrompt stickLeftPrompt; /* 0x388 */ StickDirectionPrompt stickRightPrompt; /* 0x3C0 */ f32 shopItemSelectedTween; @@ -33,7 +33,7 @@ typedef struct EnTrt { /* 0x3D4 */ u8 arrowAnimState; /* 0x3D5 */ u8 stickAnimState; /* 0x3D6 */ s16 blinkTimer; - /* 0x3D8 */ s16 eyeTextureIdx; + /* 0x3D8 */ s16 eyeTexIndex; /* 0x3DC */ EnTrtBlinkFunc blinkFunc; /* 0x3E0 */ s16 cutscene; /* 0x3E2 */ s16 tmpGetMushroomCutscene; 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 9e791dbea..1f521d250 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -26,17 +26,30 @@ void func_80AD4FE4(EnTrt2* this, PlayState* play); void func_80AD5234(EnTrt2* this, PlayState* play); void func_80AD56E8(Actor* thisx, PlayState* play); +typedef enum { + /* 0 */ TRT2_ANIM_IDLE, + /* 1 */ TRT2_ANIM_HALF_AWAKE, + /* 2 */ TRT2_ANIM_SLEEPING, + /* 3 */ TRT2_ANIM_WAKE_UP, + /* 4 */ TRT2_ANIM_SURPRISED, + /* 5 */ TRT2_ANIM_HANDS_ON_COUNTER, + /* 6 */ TRT2_ANIM_HOVER, + /* 7 */ TRT2_ANIM_FLY_LOOK_AROUND, + /* 8 */ TRT2_ANIM_FLY_DOWN, + /* 9 */ TRT2_ANIM_FLY +} Trt2Animation; + static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &gKotakeIdleAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHalfAwakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSleepingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeWakeUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHandsOnCounterAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt2_InitVars = { @@ -108,18 +121,18 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { - f32 phi_f0; +void EnTrt2_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { + f32 endFrame; - animation += arg2; + animationInfo += animIndex; - if (animation->frameCount < 0) { - phi_f0 = Animation_GetLastFrame(animation->animation); + if (animationInfo->frameCount < 0) { + endFrame = Animation_GetLastFrame(animationInfo->animation); } else { - phi_f0 = animation->frameCount; + endFrame = animationInfo->frameCount; } - Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f0, - animation->mode, animation->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); } void func_80AD341C(EnTrt2* this, PlayState* play) { @@ -170,7 +183,7 @@ void func_80AD3530(EnTrt2* this, PlayState* play) { if (DECR(this->unk_3AE) == 0) { this->unk_3AE = Rand_S16Offset(20, 20); - func_80AD3380(&this->skelAnime, sAnimationInfo, 7); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); this->unk_3B2 = 5; } } @@ -277,7 +290,7 @@ void func_80AD3A24(EnTrt2* this, PlayState* play) { Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); } else if (DECR(this->unk_3AE) == 0) { this->unk_3AE = Rand_S16Offset(100, 50); - func_80AD3380(&this->skelAnime, sAnimationInfo, 6); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); this->unk_3B2 = 4; } Actor_MoveWithGravity(&this->actor); @@ -288,7 +301,7 @@ void func_80AD3AE4(EnTrt2* this, PlayState* play) { Math_ApproachF(&this->actor.velocity.y, 0.5f, 0.2f, 0.1f); } else { this->actor.velocity.y = 0.0f; - func_80AD3380(&this->skelAnime, sAnimationInfo, 6); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); this->unk_3B2 = 4; } Actor_MoveWithGravity(&this->actor); @@ -298,7 +311,7 @@ void func_80AD3B6C(EnTrt2* this, PlayState* play) { if (DECR(this->unk_3B0) == 0) { this->unk_3B0 = 10; this->actor.velocity.y = -1.0f; - func_80AD3380(&this->skelAnime, sAnimationInfo, 8); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_DOWN); this->unk_3B2 = 8; } } @@ -311,7 +324,7 @@ void func_80AD3BE4(EnTrt2* this, PlayState* play) { this->actor.world.rot.y += this->unk_3C0; this->actor.shape.rot.y = this->actor.world.rot.y; if (this->actor.world.pos.y < 5.0f) { - func_80AD3380(&this->skelAnime, sAnimationInfo, 9); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY); this->unk_3B2 = 9; } } @@ -335,7 +348,7 @@ void func_80AD3CEC(EnTrt2* this, PlayState* play) { } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - func_80AD3380(&this->skelAnime, sAnimationInfo, 6); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); this->unk_3B2 = 4; } } @@ -436,7 +449,7 @@ void func_80AD417C(EnTrt2* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; if (this->unk_3A8 == 0x84C) { - func_80AD3380(&this->skelAnime, sAnimationInfo, 6); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); this->path = SubS_GetPathByIndex(play, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { @@ -510,7 +523,7 @@ void func_80AD4550(EnTrt2* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if ((player->transformation != PLAYER_FORM_HUMAN) && (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { - func_80AD3380(&this->skelAnime, sAnimationInfo, 7); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); this->unk_3B2 = 17; } @@ -539,7 +552,7 @@ void func_80AD4608(EnTrt2* this) { } void func_80AD469C(EnTrt2* this, PlayState* play) { - SkelAnime_InitFlex(play, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_000A44, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gKotakeSkel, &gKotakeHoverAnim, NULL, NULL, 0); this->actor.draw = func_80AD56E8; } @@ -665,7 +678,7 @@ s32 func_80AD4B4C(EnTrt2* this, PlayState* play) { } else { this->unk_3A8 = 0x84F; this->unk_3D8 = true; - func_80AD3380(&this->skelAnime, sAnimationInfo, 7); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); this->unk_3B2 = 7; } } @@ -876,7 +889,8 @@ void func_80AD5394(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { s32 EnTrt2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTrt2* this = THIS; - if ((limbIndex == 8) || (limbIndex == 13) || (limbIndex == 19)) { + if ((limbIndex == KOTAKE_LIMB_TORSO_LIMB) || (limbIndex == KOTAKE_LIMB_LEFT_HAND) || + (limbIndex == KOTAKE_LIMB_RIGHT_HAND)) { rot->y += (s16)Math_SinS(this->unk_33C[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->unk_372[limbIndex]) * 200; } @@ -892,7 +906,7 @@ void EnTrt2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot phi_v0 = true; } - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { func_80AD5394(this->unk_3D4, this->unk_3D6, &this->unk_3C8, &this->unk_3C2, phi_v0); 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); @@ -906,7 +920,7 @@ void EnTrt2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot void EnTrt2_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTrt2* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { 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_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); @@ -917,9 +931,9 @@ void EnTrt2_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void func_80AD56E8(Actor* thisx, PlayState* play) { static TexturePtr D_80AD5978[] = { - object_trt_Tex_00B0B8, - object_trt_Tex_00B8B8, - object_trt_Tex_00C0B8, + gKotakeEyeOpenTex, + gKotakeEyeHalfTex, + gKotakeEyeClosedTex, }; s32 pad; EnTrt2* this = THIS; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7698b0d2c..3699d0100 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11270,7 +11270,7 @@ 0x80A8BFE0:("EnTrt_GetMushroom",), 0x80A8C168:("EnTrt_PayForMushroom",), 0x80A8C1E8:("EnTrt_Goodbye",), - 0x80A8C288:("EnTrt_SetupTryToGiveRedPotion",), + 0x80A8C288:("EnTrt_StartRedPotionConversation",), 0x80A8C488:("EnTrt_GiveRedPotionForKoume",), 0x80A8C564:("EnTrt_GivenRedPotionForKoume",), 0x80A8C64C:("EnTrt_EndConversation",), @@ -11327,8 +11327,8 @@ 0x80A8F7AC:("EnTrt_Init",), 0x80A8F7E8:("EnTrt_Destroy",), 0x80A8F828:("EnTrt_Update",), - 0x80A8F8C4:("EnTrt_UpdateHeadYawAndPitch",), - 0x80A8FA00:("EnTrt_UpdateHeadPosAndRot",), + 0x80A8F8C4:("EnTrt_TrackPlayer",), + 0x80A8FA00:("EnTrt_UpdateLimb",), 0x80A8FB34:("EnTrt_OverrideLimbDraw",), 0x80A8FBB4:("EnTrt_PostLimbDraw",), 0x80A8FC64:("EnTrt_TransformLimbDraw",), @@ -12163,7 +12163,7 @@ 0x80AD3054:("BgCtowerGear_UpdateOrgan",), 0x80AD3124:("BgCtowerGear_Draw",), 0x80AD3164:("BgCtowerGear_DrawOrgan",), - 0x80AD3380:("func_80AD3380",), + 0x80AD3380:("EnTrt2_ChangeAnim",), 0x80AD341C:("func_80AD341C",), 0x80AD349C:("func_80AD349C",), 0x80AD3530:("func_80AD3530",), From fc94be22aca82deee28566ab72f2542ab4430f0d Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 12:09:58 -0700 Subject: [PATCH 33/73] Document object_az (Beaver Bros.) (#1083) * Document object_az (Beaver Bros.) * Respond to Elliptic's review --- assets/xml/objects/object_az.xml | 306 ++++++++++---------- src/overlays/actors/ovl_En_Az/z_en_az.c | 358 ++++++++++++++---------- tools/disasm/variables.txt | 4 +- 3 files changed, 384 insertions(+), 284 deletions(-) diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index 81207b06b..ea6fd5e7d 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -1,145 +1,169 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 a3594bec4..dcc6312bc 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -58,14 +58,38 @@ void func_80A97E48(EnAz* this, PlayState* play); void func_80A97EAC(EnAz* this, PlayState* play); void func_80A97F9C(EnAz* this, PlayState* play); -static AnimationSpeedInfo sAnimationInfo[14] = { - { &object_az_Anim_00BCFC, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_az_Anim_00C94C, 1.0f, ANIMMODE_LOOP, -5.0f }, - { &object_az_Anim_008960, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_008BB4, 1.0f, ANIMMODE_LOOP, -5.0f }, - { &object_az_Anim_00925C, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_009B4C, 1.0f, ANIMMODE_LOOP, -5.0f }, - { &object_az_Anim_0086AC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_007D3C, 1.0f, ANIMMODE_LOOP, -5.0f }, - { &object_az_Anim_008EAC, 2.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00A25C, 1.0f, ANIMMODE_LOOP, -5.0f }, - { &object_az_Anim_00AAEC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00B94C, 1.0f, ANIMMODE_ONCE, -5.0f }, - { &object_az_Anim_00C0A0, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00C47C, 1.0f, ANIMMODE_LOOP, -5.0f }, +typedef enum { + /* 0 */ BEAVER_ANIM_IDLE, + /* 1 */ BEAVER_ANIM_WALK, + /* 2 */ BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + /* 3 */ BEAVER_ANIM_SWIM_WITH_RAISED_TAIL, // Unused + /* 4 */ BEAVER_ANIM_TALK, + /* 5 */ BEAVER_ANIM_TALK_WAVE_ARMS, + /* 6 */ BEAVER_ANIM_LAUGH_RIGHT, + /* 7 */ BEAVER_ANIM_LAUGH_LEFT, + /* 8 */ BEAVER_ANIM_SWIM, + /* 9 */ BEAVER_ANIM_TALK_TO_LEFT, + /* 10 */ BEAVER_ANIM_TALK_TO_RIGHT, + /* 11 */ BEAVER_ANIM_BOW, + /* 12 */ BEAVER_ANIM_IDLE_FACE_LEFT, + /* 13 */ BEAVER_ANIM_IDLE_FACE_RIGHT, +} BeaverAnimation; + +static AnimationSpeedInfo sAnimationInfo[] = { + { &gBeaverIdleAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gBeaverWalkAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimWithSpinningTail, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimWithRaisedTail, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkWaveArmsAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverLaughRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverLaughLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimAnim, 2.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkToLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkToRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverBowAnim, 1.0f, ANIMMODE_ONCE, -5.0f }, + { &gBeaverIdleFaceLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverIdleFaceRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, }; const ActorInit En_Az_InitVars = { @@ -170,8 +194,8 @@ static InitChainEntry sInitChain[3] = { }; void EnAz_Init(Actor* thisx, PlayState* play2) { - static s16 D_80A9914C[7] = { 1, 0, 3, 2, 5, 4, -1 }; - static s16 D_80A9915C[7] = { 0, 1, 0, 1, 0, 1, 1 }; + static s16 D_80A9914C[] = { 1, 0, 3, 2, 5, 4, -1 }; + static s16 D_80A9915C[] = { 0, 1, 0, 1, 0, 1, 1 }; EnAz* this = THIS; PlayState* play = play2; s16 sp4E; @@ -236,12 +260,12 @@ void EnAz_Init(Actor* thisx, PlayState* play2) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); if (this->unk_374 & 2) { - SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_007438, &object_az_Anim_00C94C, this->jointTable, - this->morphTable, OBJECT_AZ_1_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gBeaverOlderBrotherSkel, &gBeaverWalkAnim, this->jointTable, + this->morphTable, BEAVER_OLDER_BROTHER_LIMB_MAX); Actor_SetScale(&this->actor, 0.012f); } else { - SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_017990, &object_az_Anim_00C94C, this->jointTable, - this->morphTable, OBJECT_AZ_2_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gBeaverYoungerBrotherSkel, &gBeaverWalkAnim, this->jointTable, + this->morphTable, BEAVER_YOUNGER_BROTHER_LIMB_MAX); } Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); if (this->unk_374 & 2) { @@ -254,16 +278,16 @@ void EnAz_Init(Actor* thisx, PlayState* play2) { this->unk_374 |= 0x100; this->unk_376 |= 0x100; } - Animation_Change(&this->skelAnime, sAnimationInfo[0].animation, 1.0f, - Animation_GetLastFrame(sAnimationInfo[0].animation) * Rand_ZeroOne(), - Animation_GetLastFrame(sAnimationInfo[0].animation), sAnimationInfo[0].mode, - sAnimationInfo[0].morphFrames); + Animation_Change(&this->skelAnime, sAnimationInfo[BEAVER_ANIM_IDLE].animation, 1.0f, + Animation_GetLastFrame(sAnimationInfo[BEAVER_ANIM_IDLE].animation) * Rand_ZeroOne(), + Animation_GetLastFrame(sAnimationInfo[BEAVER_ANIM_IDLE].animation), + sAnimationInfo[BEAVER_ANIM_IDLE].mode, sAnimationInfo[BEAVER_ANIM_IDLE].morphFrames); this->unk_37E = 0; this->unk_380 = 0; this->unk_384 = 0; this->actor.gravity = -1.0f; this->unk_376 = this->unk_374; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; switch (gSaveContext.save.entrance) { @@ -524,9 +548,10 @@ s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { if (this->unk_374 & 0x100) { if (!(this->unk_374 & 8)) { if (this->unk_374 & 2) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 8, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM, &this->animIndex); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); } this->unk_374 |= 8; } @@ -537,7 +562,7 @@ s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { } } else if (this->actor.bgCheckFlags & 1) { if (this->unk_374 & 8) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 1, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_WALK, &this->animIndex); this->unk_374 &= ~8; } ret = func_80A95534(play, actorPathing); @@ -551,7 +576,7 @@ void func_80A95C5C(EnAz* this, PlayState* play) { this->actor.draw = NULL; this->actor.world.pos.y = this->actor.home.pos.y + 120.0f; this->actor.gravity = -1.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.bgCheckFlags &= ~0x21; this->unk_3C0 = 0; @@ -585,7 +610,8 @@ void func_80A95DA0(EnAz* this, PlayState* play) { this->unk_36C = 4.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = 0.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.bgCheckFlags &= ~0x21; this->unk_374 |= 0x1000; @@ -636,7 +662,7 @@ void func_80A95FE8(EnAz* this, PlayState* play) { this->actor.shape.rot.z = 0; Actor_MoveWithoutGravityReverse(&this->actor); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); this->unk_374 &= ~0x1000; this->actor.gravity = -1.0f; this->actor.speedXZ = 0.0f; @@ -674,8 +700,10 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { case 0xCD: gSaveContext.save.weekEventReg[24] &= (u8)~1; this->actor.textId = 0x10F2; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &brother->animIndex); break; case 0x10CE: this->actor.textId = 0x10CF; @@ -687,34 +715,41 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { case 0x10D0: this->actor.textId = 0x10D1; ret = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_WAVE_ARMS, + &this->animIndex); break; case 0x10D1: this->actor.textId = 0x10D2; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10D2: if (play->msgCtx.choiceIndex == 0) { func_8019F208(); this->actor.textId = 0x10D6; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, + BEAVER_ANIM_TALK_WAVE_ARMS, &this->animIndex); } else { func_8019F230(); this->actor.textId = 0x10D3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); } break; case 0x10D3: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); this->unk_374 |= 0x20; ret = 0; break; case 0x10D4: this->actor.textId = 0x10D2; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10D6: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); func_80A979DC(this, play); this->unk_2FA = 1; ret = 0; @@ -755,7 +790,8 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { break; case 0x10DA: this->actor.textId = 0x10DB; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10DB: if (play->msgCtx.choiceIndex == 0) { @@ -766,7 +802,8 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { } else { func_8019F230(); this->actor.textId = 0x10DC; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); } break; case 0x10DC: @@ -776,37 +813,38 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { ret = 0; break; case 0x10DD: - func_80A98EFC(this, play, 0x10DE, 13, 9); + func_80A98EFC(this, play, 0x10DE, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); this->unk_374 |= 0x8000; ret = 2; break; case 0x10DE: - func_80A98EFC(this, play, 0x10DF, 12, 10); + func_80A98EFC(this, play, 0x10DF, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10DF: - func_80A98EFC(this, play, 0x10E0, 13, 9); + func_80A98EFC(this, play, 0x10E0, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); ret = 0; break; case 0x10E0: - func_80A98EFC(this, play, 0x10E1, 12, 10); + func_80A98EFC(this, play, 0x10E1, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10E1: - func_80A98EFC(this, play, 0x10E2, 13, 9); + func_80A98EFC(this, play, 0x10E2, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); ret = 0; break; case 0x10E2: this->actor.textId = 0x10E3; ret = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10E3: - func_80A98EFC(this, play, 0x10E4, 0, 4); + func_80A98EFC(this, play, 0x10E4, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); ret = 0; break; case 0x10E4: - func_80A98EFC(this, play, 0x10E5, 0, 4); + func_80A98EFC(this, play, 0x10E5, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); ret = 0; break; case 0x10E5: @@ -816,36 +854,41 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { } else { func_8019F230(); this->actor.textId = 0x10E6; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, - &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); } break; case 0x10E6: this->actor.textId = 0x10E7; - func_80A98EFC(this, play, 0x10E7, 0, 10); + func_80A98EFC(this, play, 0x10E7, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10E7: gSaveContext.save.weekEventReg[24] &= (u8)~4; func_80A94AB8(this, play, 0); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); func_80A979DC(this, play); ret = 0; break; case 0x10E8: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); this->unk_2FA = 3; ret = 0; break; case 0x10E9: - func_80A98EFC(this, play, 0x10EA, 12, 4); + func_80A98EFC(this, play, 0x10EA, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK); ret = 0; break; case 0x10EA: - func_80A98EFC(this, play, 0x10EB, 0, 4); + func_80A98EFC(this, play, 0x10EB, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); ret = 0; break; case 0x10EB: @@ -869,13 +912,14 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { } else { func_8019F230(); this->actor.textId = 0x10EC; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 7, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, - &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_LAUGH_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); } break; case 0x10EC: - func_80A98EFC(this, play, 0x10ED, -1, 6); + func_80A98EFC(this, play, 0x10ED, -1, BEAVER_ANIM_LAUGH_RIGHT); ret = 0; break; case 0x10ED: @@ -887,15 +931,15 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { ret = 0; break; case 0x10EE: - func_80A98EFC(this, play, 0x10EF, 12, 10); + func_80A98EFC(this, play, 0x10EF, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10EF: - func_80A98EFC(this, play, 0x10F0, 13, 9); + func_80A98EFC(this, play, 0x10F0, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); ret = 0; break; case 0x10F0: - func_80A98EFC(this, play, 0x10F1, 12, 10); + func_80A98EFC(this, play, 0x10F1, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10F1: @@ -906,39 +950,44 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { this->getItemId = GI_BOTTLE; gSaveContext.save.weekEventReg[23] |= 0x80; } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); ret = 7; break; case 0x10F2: case 0x1109: gSaveContext.save.weekEventReg[24] &= (u8)~4; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); func_80A94AB8(this, play, 0); func_80A979DC(this, play); ret = 0; break; case 0x10F3: - func_80A98EFC(this, play, 0x10F4, 12, 10); + func_80A98EFC(this, play, 0x10F4, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10F4: - func_80A98EFC(this, play, 0x10F5, 13, 9); + func_80A98EFC(this, play, 0x10F5, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); ret = 0; break; case 0x10F5: - func_80A98EFC(this, play, 0x10F6, 12, 10); + func_80A98EFC(this, play, 0x10F6, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10F6: - func_80A98EFC(this, play, 0x10F7, 13, 5); + func_80A98EFC(this, play, 0x10F7, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_WAVE_ARMS); ret = 0; break; case 0x10F7: this->actor.textId = 0x10F8; ret = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10F8: if (play->msgCtx.choiceIndex == 0) { @@ -948,41 +997,49 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { } else { this->actor.textId = 0x10FA; } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, + BEAVER_ANIM_TALK_WAVE_ARMS, &this->animIndex); } else { func_8019F230(); this->actor.textId = 0x10F9; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, &brother->animIndex); } break; case 0x10F9: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); this->unk_374 |= 0x20; ret = 0; break; case 0x10FA: case 0x1107: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); this->unk_2FA = 6; ret = 0; break; case 0x10FB: - func_80A98EFC(this, play, 0x10FC, 12, 10); + func_80A98EFC(this, play, 0x10FC, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x10FC: - func_80A98EFC(this, play, 0x10FD, 13, 4); + func_80A98EFC(this, play, 0x10FD, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK); ret = 0; break; case 0x10FD: this->actor.textId = 0x10FE; ret = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); break; case 0x10FE: if (play->msgCtx.choiceIndex == 0) { @@ -992,44 +1049,50 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { } else { this->actor.textId = 0x1101; } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); } else { func_8019F230(); this->actor.textId = 0x10FF; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, - &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); } break; case 0x10FF: - func_80A98EFC(this, play, 0x1100, 12, 10); + func_80A98EFC(this, play, 0x1100, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x1100: gSaveContext.save.weekEventReg[24] &= (u8)~4; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); func_80A94AB8(this, play, 0); func_80A979DC(this, play); ret = 0; break; case 0x1101: case 0x1108: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); this->unk_2FA = 8; ret = 0; break; case 0x1102: - func_80A98EFC(this, play, 0x1103, 12, 10); + func_80A98EFC(this, play, 0x1103, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x1103: - func_80A98EFC(this, play, 0x1104, 13, 9); + func_80A98EFC(this, play, 0x1104, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); ret = 0; break; case 0x1104: - func_80A98EFC(this, play, 0x1105, 12, 10); + func_80A98EFC(this, play, 0x1105, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); ret = 0; break; case 0x1105: @@ -1039,21 +1102,26 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { this->getItemId = GI_HEART_PIECE; gSaveContext.save.weekEventReg[25] |= 1; } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); ret = 7; break; case 0x1106: gSaveContext.save.weekEventReg[24] &= (u8)~4; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); func_80A94AB8(this, play, 0); func_80A979DC(this, play); ret = 0; break; case 0x10D5: default: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); this->unk_374 |= 0x20; ret = 0; break; @@ -1078,29 +1146,33 @@ void func_80A97114(EnAz* this, PlayState* play) { case 0x10DA: case 0x10DD: case 0x10E9: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, &this->animIndex); break; case 0x10EE: case 0x10F3: case 0x10FB: case 0x1102: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); sp20 = true; break; case 0x10F2: case 0x1106: case 0x1109: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, &this->animIndex); if (brother != NULL) { - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &brother->animIndex); } break; } if ((brother != NULL) && sp20) { if (this->unk_374 & 2) { - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE_FACE_RIGHT, + &brother->animIndex); } else { - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 12, &brother->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE_FACE_LEFT, + &brother->animIndex); } } this->unk_374 &= ~0x20; @@ -1247,10 +1319,12 @@ void func_80A97410(EnAz* this, PlayState* play) { if (temp_a0 == 0) { switch (this->unk_3D2) { case 0x10CE: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); break; case 0x10D4: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_WAVE_ARMS, + &this->animIndex); break; } Message_StartTextbox(play, this->unk_3D2, &this->actor); @@ -1386,8 +1460,8 @@ void func_80A97C24(EnAz* this, PlayState* play) { } void func_80A97C4C(EnAz* this, PlayState* play) { - if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == 0xB)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == BEAVER_ANIM_BOW)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); } func_80A97410(this, play); if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { @@ -1439,7 +1513,8 @@ void func_80A97EAC(EnAz* this, PlayState* play) { this->actor.speedXZ = 8.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 6.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.bgCheckFlags &= ~0x21; @@ -1603,17 +1678,18 @@ void EnAz_Update(Actor* thisx, PlayState* play2) { } } -static Gfx* D_80A9916C[5] = { - object_az_DL_01A600, object_az_DL_01A730, object_az_DL_01A860, object_az_DL_01A990, object_az_DL_01AAC0, +static Gfx* D_80A9916C[] = { + gBeaverOlderBrotherTailVortex1DL, gBeaverOlderBrotherTailVortex2DL, gBeaverOlderBrotherTailVortex3DL, + gBeaverOlderBrotherTailVortex4DL, gBeaverOlderBrotherTailVortex5DL, }; -static AnimatedMaterial* D_80A99180[5] = { - object_az_Matanimheader_01A6E8, object_az_Matanimheader_01A818, object_az_Matanimheader_01A948, - object_az_Matanimheader_01AA78, object_az_Matanimheader_01ABA8, +static AnimatedMaterial* D_80A99180[] = { + gBeaverOlderBrotherTailVortex1TexAnim, gBeaverOlderBrotherTailVortex2TexAnim, gBeaverOlderBrotherTailVortex3TexAnim, + gBeaverOlderBrotherTailVortex4TexAnim, gBeaverOlderBrotherTailVortex5TexAnim, }; -static u8 D_80A99194[5] = { +static u8 D_80A99194[] = { 95, 135, 175, 215, 255, }; -static u8 D_80A9919C[5] = { +static u8 D_80A9919C[] = { 31, 45, 58, 73, 85, }; static struct_80124618 D_80A991A4[5][9] = { @@ -1680,26 +1756,26 @@ static struct_80A98F94 D_80A9930C[5][4] = { { { 0, 1900.0f }, { 4, 1600.0f }, { 10, 2200.0f }, { 16, 1900.0f } }, { { 0, 1900.0f }, { 7, 1400.0f }, { 16, 1900.0f }, { 0, 0.0f } }, }; -static Vec3f D_80A993AC[3] = { +static Vec3f D_80A993AC[] = { { 1.0f, 1.0f, 0.0f }, { 0.9f, 0.9f, 120.0f }, { 0.95f, 0.95f, 240.0f }, }; -static Vec3f D_80A993D0[3] = { +static Vec3f D_80A993D0[] = { { 1.5f, 1.5f, 0.0f }, { 1.2f, 1.2f, 120.0f }, { 1.35f, 1.35f, 240.0f }, }; -static TexturePtr D_80A993F4[4] = { - object_az_Tex_00F918, - object_az_Tex_010118, - object_az_Tex_010918, - object_az_Tex_011118, +static TexturePtr sYoungerBrotherEyeTextures[] = { + gBeaverYoungerBrotherEye1Tex, + gBeaverYoungerBrotherEye2Tex, + gBeaverYoungerBrotherEye3Tex, + gBeaverYoungerBrotherEye4Tex, }; -static TexturePtr D_80A99404[3] = { - object_az_Tex_016018, - object_az_Tex_016818, - object_az_Tex_017018, +static TexturePtr sYoungerBrotherBeltTextures[] = { + gBeaverYoungerBrotherBeltRedTex, + gBeaverYoungerBrotherBeltGreenTex, + gBeaverYoungerBrotherBeltBlueTex, }; void EnAz_Draw(Actor* thisx, PlayState* play2) { @@ -1715,8 +1791,8 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { func_80A98DA4, func_80A98E48, &this->actor); } else { OPEN_DISPS(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A993F4[this->unk_37E])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A99404[this->unk_380])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sYoungerBrotherEyeTextures[this->unk_37E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sYoungerBrotherBeltTextures[this->unk_380])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80A98DA4, func_80A98E48, &this->actor); CLOSE_DISPS(play->state.gfxCtx); @@ -1767,13 +1843,13 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 85)); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01ABF0); + gSPDisplayList(POLY_XLU_DISP++, gBeaverYoungerBrotherTailVortexDL); Matrix_Pop(); Matrix_Translate(0.0f, 2000.0f, -2100.0f, MTXMODE_APPLY); Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); Matrix_Scale(D_80A993D0[this->unk_384].x, D_80A993D0[this->unk_384].y, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01AD00); + gSPDisplayList(POLY_XLU_DISP++, gBeaverYoungerBrotherTailSplashDL); } } CLOSE_DISPS(play->state.gfxCtx); @@ -1782,20 +1858,20 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAz* this = THIS; - if ((limbIndex == OBJECT_AZ_1_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { + if ((limbIndex == BEAVER_OLDER_BROTHER_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { *dList = NULL; } - if (limbIndex == OBJECT_AZ_1_LIMB_NONE) { + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_NONE) { rot->x = rot->x; rot->y = rot->y; rot->z = rot->z; } - if (limbIndex == OBJECT_AZ_1_LIMB_03) { + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_PELVIS) { rot->y -= this->unk_39E; } else { // this space intentionally left blank } - if (limbIndex == OBJECT_AZ_1_LIMB_05) { + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_HEAD_ROOT) { rot->x += this->unk_3D4; rot->y -= this->unk_3D6; } @@ -1808,7 +1884,7 @@ void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Acto static Vec3f D_80A99428 = { -1200.0f, 0.0f, 1000.0f }; EnAz* this = THIS; - if (limbIndex == OBJECT_AZ_1_LIMB_03) { + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_PELVIS) { Matrix_MultVec3f(&D_80A99410, &this->unk_3A8); Math_SmoothStepToF(&this->unk_3A4, this->unk_3A8.y - this->actor.world.pos.y, 0.8f, 10.0f, 0.01f); if (this->unk_374 & 2) { @@ -1819,18 +1895,18 @@ void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Acto } } -void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4) { +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 animIndex, s32 brotherAnimIndex) { EnAz* brother = this->brother; Actor_ChangeFocus(&this->actor, play, &brother->actor); - if (arg3 >= 0) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, arg3, &this->animIndex); + if (animIndex >= 0) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, animIndex, &this->animIndex); } this->actor.textId = 0; brother->actor.textId = textId; brother->unk_378 = 5; - if ((arg4 >= 0) && (arg4 != brother->animIndex)) { - SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, arg4, &brother->animIndex); + if ((brotherAnimIndex >= 0) && (brotherAnimIndex != brother->animIndex)) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, brotherAnimIndex, &brother->animIndex); } this->unk_378 = 0; } diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b4585b987..dffd1bd19 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12442,8 +12442,8 @@ 0x80A9930C:("D_80A9930C","UNK_TYPE1","",0x1), 0x80A993AC:("D_80A993AC","UNK_TYPE1","",0x1), 0x80A993D0:("D_80A993D0","UNK_TYPE1","",0x1), - 0x80A993F4:("D_80A993F4","UNK_TYPE1","",0x1), - 0x80A99404:("D_80A99404","UNK_TYPE1","",0x1), + 0x80A993F4:("sYoungerBrotherEyeTextures","UNK_TYPE1","",0x1), + 0x80A99404:("sYoungerBrotherBeltTextures","UNK_TYPE1","",0x1), 0x80A99410:("D_80A99410","UNK_TYPE1","",0x1), 0x80A9941C:("D_80A9941C","UNK_TYPE1","",0x1), 0x80A99428:("D_80A99428","UNK_TYPE1","",0x1), From 3d24a8be68c4f0c518153746bbf5466d021c5ee2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 12:15:18 -0700 Subject: [PATCH 34/73] Document object_bdoor (Boss Doors) (#1087) --- assets/xml/objects/gameplay_dangeon_keep.xml | 10 ++--- assets/xml/objects/object_bdoor.xml | 41 ++++++++++++------- src/code/z_actor.c | 6 +-- .../actors/ovl_Door_Shutter/z_door_shutter.c | 5 +-- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 7e4d2d201..e9acb308b 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -1,10 +1,10 @@  - - - - - + + + + + diff --git a/assets/xml/objects/object_bdoor.xml b/assets/xml/objects/object_bdoor.xml index a57339f3b..2e64110f5 100644 --- a/assets/xml/objects/object_bdoor.xml +++ b/assets/xml/objects/object_bdoor.xml @@ -1,18 +1,31 @@  + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 3669dd136..c367e75e9 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3814,9 +3814,9 @@ typedef struct { } DoorLockInfo; // size = 0x1C DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = { - /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL }, - /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_000530, object_bdoor_DL_000400 }, - /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL }, + /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainDL, gDoorLockDL }, + /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, gBossDoorChainDL, gBossDoorLockDL }, + /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainDL, gDoorLockDL }, }; /** 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 691f00e60..b5f75efaa 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -74,7 +74,7 @@ typedef struct { } ShutterInfo; // size = 0xC ShutterInfo D_808A21B0[] = { - { object_bdoor_DL_0000C0, NULL, 130, 12, 50, 15 }, + { gBossDoorDL, 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 }, @@ -129,8 +129,7 @@ Vec3f D_808A22C4 = { 120.0f, 0.0f, 0.0f }; Vec3f D_808A22D0 = { -90.0f, 0.0f, 0.0f }; TexturePtr D_808A22DC[] = { - object_bdoor_Tex_006BA0, object_bdoor_Tex_005BA0, object_bdoor_Tex_0005C0, - object_bdoor_Tex_004BA0, object_bdoor_Tex_003BA0, + gBossDoorDefaultTex, gBossDoorWoodfallTex, gBossDoorSnowheadTex, gBossDoorGreatBayTex, gBossDoorStoneTowerTex, }; void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { From 96986bc3f1d55744dd39528a36740b5d9916cf86 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 12:20:12 -0700 Subject: [PATCH 35/73] Cleanup some "raw" actor flags (#1044) * Cleanup some "raw" actor flags * Respond to Anghelo's review --- src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c | 12 ++++++------ src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 5 +++-- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 2 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 4 ++-- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 6 +++--- src/overlays/actors/ovl_En_Fishing/z_en_fishing.c | 4 ++-- src/overlays/actors/ovl_En_Peehat/z_en_peehat.c | 2 +- src/overlays/actors/ovl_En_Pp/z_en_pp.c | 2 +- src/overlays/actors/ovl_En_Rat/z_en_rat.c | 2 +- src/overlays/actors/ovl_En_Wood02/z_en_wood02.c | 2 +- 11 files changed, 22 insertions(+), 21 deletions(-) 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 5f32870a7..3be9ff149 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -69,7 +69,7 @@ void ArmsHook_Destroy(Actor* thisx, PlayState* play) { ArmsHook* this = THIS; if (this->grabbed != NULL) { - this->grabbed->flags &= ~0x2000; + this->grabbed->flags &= ~ACTOR_FLAG_2000; } Collider_DestroyQuad(play, &this->collider); } @@ -100,7 +100,7 @@ s32 ArmsHook_AttachToPlayer(ArmsHook* this, Player* player) { void ArmsHook_DetachHookFromActor(ArmsHook* this) { if (this->grabbed != NULL) { - this->grabbed->flags &= ~0x2000; + this->grabbed->flags &= ~ACTOR_FLAG_2000; this->grabbed = NULL; } } @@ -120,7 +120,7 @@ s32 ArmsHook_CheckForCancel(ArmsHook* this) { } void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { - actor->flags |= 0x2000; + actor->flags |= ACTOR_FLAG_2000; this->grabbed = actor; Math_Vec3f_Diff(&actor->world.pos, &this->actor.world.pos, &this->unk1FC); } @@ -140,10 +140,10 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { if (this->timer != 0 && (this->collider.base.atFlags & AT_HIT) && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { Actor* touchedActor = this->collider.base.at; - if ((touchedActor->update != NULL) && (touchedActor->flags & 0x600)) { + if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_200 | ACTOR_FLAG_400))) { if (this->collider.info.atHitInfo->bumperFlags & BUMP_HOOKABLE) { ArmsHook_AttachHookToActor(this, touchedActor); - if ((touchedActor->flags & 0x400) == 0x400) { + if ((touchedActor->flags & ACTOR_FLAG_400) == ACTOR_FLAG_400) { func_808C1154(this); } } @@ -164,7 +164,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { grabbed = this->grabbed; if (grabbed != NULL) { - if ((grabbed->update == NULL) || (grabbed->flags & 0x2000) != 0x2000) { + if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_2000)) { grabbed = NULL; this->grabbed = NULL; } else { 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 4ca78d239..8fd78fb51 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -389,11 +389,12 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { 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)) { + if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && + (sp7C->flags & ACTOR_FLAG_4000)) { this->unk_264 = sp7C; func_8088A894(this, play); Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); - sp7C->flags |= 0x8000; + sp7C->flags |= ACTOR_FLAG_8000; this->collider.base.atFlags &= ~AT_HIT; this->actor.speedXZ *= 0.5f; this->actor.velocity.y *= 0.5f; 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 0be5ad0b4..20a868bc6 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -219,7 +219,7 @@ void EnBigpo_Init(Actor* thisx, PlayState* play2) { } if (thisx->params == ENBIGPO_REGULAR) { // the well poe, starts immediately - thisx->flags &= ~0x10; // always update OFF + thisx->flags &= ~ACTOR_FLAG_10; // always update OFF this->unkBool204 = true; EnBigpo_InitWellBigpo(this); } else if (thisx->params == ENBIGPO_SUMMONED) { // dampe type 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 6b79d6021..97b80fe9e 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -541,7 +541,7 @@ void EnBom_Update(Actor* thisx, PlayState* play) { Camera_AddQuake(&play->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; - thisx->flags |= (0x100000 | 0x20); + thisx->flags |= (ACTOR_FLAG_20 | ACTOR_FLAG_100000); this->actionFunc = func_808715B8; if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; 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 df4adfc20..2c68e20f8 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -219,7 +219,7 @@ void func_808A2918(EnBoom* this, PlayState* play) { (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; + this->collider.base.at->flags |= ACTOR_FLAG_2000; } } @@ -264,7 +264,7 @@ void func_808A2918(EnBoom* this, PlayState* play) { sp7C->gravity = -0.9f; sp7C->bgCheckFlags &= ~3; } else { - sp7C->flags &= -0x2001; + sp7C->flags &= ~ACTOR_FLAG_2000; } } Actor_MarkForDeath(&this->actor); 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 798311c77..c7ea4f5b0 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1463,7 +1463,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { } if (player->tatlTextId < 0) { - thisx->flags |= 0x10000; + thisx->flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(thisx, &play->state)) { @@ -1480,7 +1480,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { thisx->update = func_8088FE64; func_8088C51C(this, 3); if (this->elfMsg != NULL) { - this->elfMsg->flags |= 0x100; + this->elfMsg->flags |= ACTOR_FLAG_100; thisx->cutscene = this->elfMsg->cutscene; if (thisx->cutscene != -1) { func_8088FD04(this); @@ -1492,7 +1492,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { } else { thisx->cutscene = -1; } - thisx->flags &= ~0x10000; + thisx->flags &= ~ACTOR_FLAG_10000; } else if (this->unk_264 & 4) { thisx->focus.pos = thisx->world.pos; this->fairyFlags |= 0x10; 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 59e3abdb4..2aabec27f 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -830,7 +830,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { thisx->focus.pos = thisx->world.pos; thisx->focus.pos.y += 75.0f; - thisx->flags |= 9; + thisx->flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT @@ -960,7 +960,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { this->unk_150 = 100; func_800BC154(play, &play->actorCtx, thisx, ACTORCAT_PROP); thisx->targetMode = 0; - thisx->flags |= 9; + thisx->flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } else { this->unk_150 = 10; 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 f7e943957..02e660f14 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -788,7 +788,7 @@ void EnPeehat_Update(Actor* thisx, PlayState* play2) { } if (this->colliderTris.base.atFlags & AT_ON) { - thisx->flags |= 0x1000000; + thisx->flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderTris.base); if (thisx->params == 0) { Vec3f sp74; 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 7766fa8fa..7587e38ca 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -1110,7 +1110,7 @@ void EnPp_Mask_SetupDetach(EnPp* this, PlayState* play) { * Moves the mask through the air and eventually makes it burst into flames. */ void EnPp_Mask_Detach(EnPp* this, PlayState* play) { - if (((this->actor.flags & ACTOR_FLAG_2000) != ACTOR_FLAG_2000) || (this->action == EN_PP_ACTION_MASK_DEAD)) { + if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000) || (this->action == EN_PP_ACTION_MASK_DEAD)) { switch (this->actionVar.maskDetachState) { case EN_PP_MASK_DETACH_STATE_START: this->action = EN_PP_ACTION_MASK_DEAD; 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 cc98c05e1..9057fdb4c 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -822,7 +822,7 @@ void EnRat_Update(Actor* thisx, PlayState* play) { if (this->damageReaction.hookedState == EN_RAT_HOOK_STARTED) { // The player just hit the Real Bombchu with the Hookshot. this->damageReaction.hookedState = EN_RAT_HOOKED; - } else if ((this->actor.flags & ACTOR_FLAG_2000) != ACTOR_FLAG_2000) { + } else if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { // The player has hooked the Real Bombchu for more than one frame, but // the actor flag indicating that the Hookshot is attached is *not* set. EnRat_Explode(this, play); 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 3098b9a6a..67faa1f3c 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -364,7 +364,7 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) { // 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)) { + if (!(thisx->flags & ACTOR_FLAG_40) && (this->unk_151 != 2)) { s32 index = this->unk_14A[0]; s32 phi_v0 = 0; From 6fab0f962c4a67c251387078c5373144b4a91c33 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 24 Sep 2022 12:24:39 -0700 Subject: [PATCH 36/73] Fix up some actor descriptions (#1059) * Fix up some actor descriptions * Respond to Elliptic's review * Add ObjDowsing description * Respond to hensldm's review * Fix bad find-replace issue --- .../z_bg_ikana_rotaryroom.c | 4 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 8 ++-- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 2 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 2 +- src/overlays/actors/ovl_En_Hs2/z_en_hs2.c | 2 +- .../actors/ovl_En_Tag_Obj/z_en_tag_obj.c | 2 +- .../actors/ovl_En_Tanron6/z_en_tanron6.c | 2 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 41 ++++++++++++------- .../ovl_En_Water_Effect/z_en_water_effect.h | 15 +++---- .../actors/ovl_Item_Inbox/z_item_inbox.c | 2 +- .../actors/ovl_Obj_Dowsing/z_obj_dowsing.c | 2 +- 11 files changed, 49 insertions(+), 33 deletions(-) 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 94eec2c1d..77bf92531 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 @@ -7,6 +7,7 @@ #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 "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" #include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -679,7 +680,8 @@ void func_80B81570(BgIkanaRotaryroom* this, PlayState* play) { sp70.y += this->dyna.actor.world.pos.y; sp70.z += this->dyna.actor.world.pos.z; - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, + ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER); } Matrix_Pop(); 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 23aa023da..380ef6f0b 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -724,7 +724,7 @@ void Boss03_ChasePlayer(Boss03* this, PlayState* play) { if (sp43 != 0) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, this->waterHeight, - player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); + player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_TYPE_GYORG_RIPPLES); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); } @@ -1055,7 +1055,7 @@ void Boss03_Charge(Boss03* this, PlayState* play) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); func_800BC848(&this->actor, play, 20, 15); Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, 0x96, - ENWATEREFFECT_30C); + ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE); // Player is above water && Player is standing on ground if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { @@ -1528,7 +1528,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { 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(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, - this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_TYPE_GYORG_RIPPLES); if (this->actionFunc == Boss03_DeathCutscene) { if ((D_809E9840 % 2) != 0) { @@ -2012,7 +2012,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { } Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, - this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_TYPE_GYORG_RIPPLES); this->unk_280 = 27; this->unk_284 = this->actor.world.pos.x; 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 64b6a7a98..4cd28f454 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -160,7 +160,7 @@ Actor* func_80C1C8E8(PlayState* play) { } tempActor = foundActor->next; - if (tempActor == NULL || NULL) { + if (tempActor == NULL || false) { foundActor = NULL; break; } 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 2b9c62e19..b51f4df8d 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -1,7 +1,7 @@ /* * File: z_dm_gm.c * Overlay: ovl_Dm_Gm - * Description: Anju (cutscene) (duplicate of Dm_An?) + * Description: Complete duplicate of Dm_An */ #include "z_dm_gm.h" 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 3e6ab858f..a251dd113 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -1,7 +1,7 @@ /* * File: z_en_hs2.c * Overlay: ovl_En_Hs2 - * Description: Blue Target Spot (?) + * Description: Near-empty actor. Does nothing, but can be targeted. */ #include "z_en_hs2.h" diff --git a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c index db6a9d172..0d39a0db2 100644 --- a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c +++ b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c @@ -1,7 +1,7 @@ /* * File: z_en_tag_obj.c * Overlay: ovl_En_Tag_Obj - * Description: + * Description: Unused Seahorse Spawner */ #include "z_en_tag_obj.h" 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 45459e8b3..ceac1e116 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -1,7 +1,7 @@ /* * File: z_en_tanron6.c * Overlay: ovl_En_Tanron6 - * Description: Swarm of Giant Bees + * Description: Unused invisible enemy. Only draws a circle shadow. */ #include "z_en_tanron6.h" 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 92bec240e..fc1ad7279 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 @@ -1,7 +1,15 @@ /* * File: z_en_water_effect.c * Overlay: ovl_En_Water_Effect - * Description: Water splashing effect (used for Gyorg) + * Description: Water/rock drop spawner and Gyorg water splashing effect + * + * This actor serves two purposes: + * - It can act as a "spawner" for either water drops or flaming rocks. This + * spawner can be placed in the ceiling to drop these repeatedly. + * - It is also used to control various water splashing effects for the Gyorg + * fight. Specifically, it handles the splashing that is caused when it + * enters or exits the water, and it handles the shockwave that is created + * when it rams the center platform. */ #include "z_en_water_effect.h" @@ -85,27 +93,30 @@ void EnWaterEffect_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_DC4 = Rand_ZeroFloat(100.0f); - if (this->actor.params == ENWATEREFFECT_1) { + if (this->actor.params == ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER) { this->actor.update = func_80A59C04; this->actor.draw = func_80A5A184; this->unk_DC6 = Rand_ZeroFloat(100.0f) + 60.0f; - } else if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A) || - (this->actor.params == ENWATEREFFECT_30B) || (this->actor.params == ENWATEREFFECT_30C)) { + } else if ((this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE)) { this->actor.update = func_80A5A534; this->actor.draw = func_80A5A6B8; this->actor.shape.rot.y = Rand_ZeroFloat(0x10000); Actor_SetScale(&this->actor, this->actor.shape.rot.z * 0.0002f); - if (this->actor.params == ENWATEREFFECT_309) { + if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30A); + this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY); Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30B); - } else if (this->actor.params == ENWATEREFFECT_30A) { + this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, + ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY); + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY) { this->unk_DC4 = -3; - } else if (this->actor.params == ENWATEREFFECT_30B) { + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY) { this->unk_DC4 = -6; - } else if (this->actor.params == ENWATEREFFECT_30C) { + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE) { this->unk_DC4 = 23; } @@ -620,7 +631,8 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Push(); Matrix_Push(); - if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A)) { + if ((this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY)) { if (this->unk_E2C > 1.0f) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000DE0)); @@ -648,7 +660,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Pop(); } - if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_30C)) { + if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE)) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E40)); Matrix_Scale(this->unk_DC8[3].y, this->unk_DC8[3].z, this->unk_DC8[3].y, MTXMODE_APPLY); @@ -660,7 +672,8 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Pop(); - if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30C)) { + if ((this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE)) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000E58)); Matrix_Scale(this->unk_DC8[4].y, this->unk_DC8[4].z, this->unk_DC8[4].y, MTXMODE_APPLY); @@ -670,7 +683,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000CD8); } - if (this->actor.params == ENWATEREFFECT_309) { + if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) { func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h index 35aebd83e..e4fb752dc 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h @@ -18,13 +18,14 @@ typedef struct { /* 0x3C */ s16 unk_3C; } EnWaterEffectStruct; // size = 0x40 -enum { - /* 0x001 */ ENWATEREFFECT_1 = 1, - /* 0x309 */ ENWATEREFFECT_309 = 0x309, - /* 0x30A */ ENWATEREFFECT_30A, - /* 0x30B */ ENWATEREFFECT_30B, - /* 0x30C */ ENWATEREFFECT_30C, -}; +typedef enum { + /* 0x001 */ ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER = 1, // Spawner for falling flaming rocks, + /* 0x0FF */ ENWATEREFFECT_TYPE_FALLING_WATER_SPAWNER = 0xFF, // Spawner for water dripping from the ceiling + /* 0x309 */ ENWATEREFFECT_TYPE_GYORG_RIPPLES = 0x309, // Ripples on the surface when Gyrog enters/leaves the water + /* 0x30A */ ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY, // Large "funnel" of water that forms when Gyorg enters/leaves the water + /* 0x30B */ ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY, // Secondary "funnel" in the middle of the larger "funnel" + /* 0x30C */ ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE, // Shockwave on the surface when Gyorg rams into the central platform +} EnWaterEffectType; typedef struct EnWaterEffect { /* 0x000 */ Actor actor; 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 cdf0447e6..1f3fae3ac 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -1,7 +1,7 @@ /* * File: z_item_inbox.c * Overlay: ovl_Item_Inbox - * Description: + * Description: Unused, can draw GetItem models. Perhaps intended to draw items inside chests. */ #include "z_item_inbox.h" 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 cbbdf82ed..0c0177d2f 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -1,7 +1,7 @@ /* * File: z_obj_dowsing.c * Overlay: ovl_Obj_Dowsing - * Description: + * Description: Rumbles controller if switch or collectible/chest flag is unset */ #include "z_obj_dowsing.h" From 37a9b8e3c487f2798d0eb4aafbacfbe235b5fdc2 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 24 Sep 2022 15:29:21 -0400 Subject: [PATCH 37/73] ActorContext Flags (#1060) * actor context flags * bracket cleanup * comment out recursive name-fixer * Empty-Commit --- include/z64actor.h | 18 ++++++-- src/code/z_actor.c | 46 +++++++++---------- src/code/z_kaleido_setup.c | 3 +- src/code/z_play.c | 22 ++++----- src/code/z_sram_NES.c | 10 ++-- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 11 +++-- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 4 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 3 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- .../actors/ovl_En_Scopecoin/z_en_scopecoin.c | 2 +- .../actors/ovl_En_Scopecrow/z_en_scopecrow.c | 2 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 2 +- src/overlays/actors/ovl_En_Sth2/z_en_sth2.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 28 +++++------ src/overlays/actors/ovl_En_Toto/z_en_toto.c | 4 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 9 ++-- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 2 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 2 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 24 +++++----- .../actors/ovl_Obj_Switch/z_obj_switch.c | 2 +- src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c | 2 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 8 ++-- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 2 +- tools/namefixer.py | 2 + 30 files changed, 121 insertions(+), 103 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 925a9975f..b11078316 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -307,6 +307,16 @@ typedef enum { /* 0x0C */ ACTORCAT_MAX } ActorType; +#define ACTORCTX_FLAG_0 (1 << 0) +#define ACTORCTX_FLAG_1 (1 << 1) +#define ACTORCTX_FLAG_2 (1 << 2) +#define ACTORCTX_FLAG_3 (1 << 3) +#define ACTORCTX_FLAG_4 (1 << 4) +#define ACTORCTX_FLAG_5 (1 << 5) +#define ACTORCTX_FLAG_6 (1 << 6) +#define ACTORCTX_FLAG_7 (1 << 7) + + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; @@ -351,13 +361,13 @@ typedef struct ActorContext_unk_20C { /* 0x4 */ void* ptr; } ActorContext_unk_20C; // size = 0x8 -typedef struct ActorContextFlags { +typedef struct ActorContextSceneFlags { /* 0x00 */ u32 switches[4]; // First 0x40 are permanent, second 0x40 are temporary /* 0x10 */ u32 chest; /* 0x14 */ u32 clearedRoom; /* 0x18 */ u32 clearedRoomTemp; /* 0x1C */ u32 collectible[4]; // bitfield of 128 bits -} ActorContextFlags; // size = 0x2C +} ActorContextSceneFlags; // size = 0x2C typedef struct ActorListEntry { /* 0x0 */ s32 length; // number of actors loaded of this type @@ -374,7 +384,7 @@ typedef struct ActorContext { /* 0x002 */ u8 unk2; /* 0x003 */ u8 lensActive; /* 0x004 */ s8 lensMaskSize; // The size of the circle when drawn the lens mask. Larger value leads to a smaller circle - /* 0x005 */ u8 unk5; + /* 0x005 */ u8 flags; /* 0x006 */ UNK_TYPE1 pad6[0x5]; /* 0x00B */ s8 lensActorsDrawn; /* 0x00C */ s16 unkC; @@ -383,7 +393,7 @@ typedef struct ActorContext { /* 0x010 */ ActorListEntry actorLists[ACTORCAT_MAX]; /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame /* 0x120 */ TargetContext targetContext; - /* 0x1B8 */ ActorContextFlags flags; + /* 0x1B8 */ ActorContextSceneFlags sceneFlags; /* 0x1E4 */ TitleCardContext titleCtxt; /* 0x1F4 */ u8 unk1F4; /* 0x1F5 */ u8 unk1F5; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index c367e75e9..61e4dc807 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -692,7 +692,7 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS */ s32 Flags_GetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - return play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + return play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -702,7 +702,7 @@ s32 Flags_GetSwitch(PlayState* play, s32 flag) { */ void Flags_SetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); } } @@ -711,7 +711,7 @@ void Flags_SetSwitch(PlayState* play, s32 flag) { */ void Flags_UnsetSwitch(PlayState* play, s32 flag) { if (flag >= 0 && flag < 0x80) { - play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); + play->actorCtx.sceneFlags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); } } @@ -719,70 +719,70 @@ void Flags_UnsetSwitch(PlayState* play, s32 flag) { * Tests if current scene chest flag is set. */ s32 Flags_GetTreasure(PlayState* play, s32 flag) { - return play->actorCtx.flags.chest & (1 << flag); + return play->actorCtx.sceneFlags.chest & (1 << flag); } /** * Sets current scene chest flag. */ void Flags_SetTreasure(PlayState* play, s32 flag) { - play->actorCtx.flags.chest |= (1 << flag); + play->actorCtx.sceneFlags.chest |= (1 << flag); } /** * Overrides the all the chest flags. */ void Flags_SetAllTreasure(PlayState* play, s32 flag) { - play->actorCtx.flags.chest = flag; + play->actorCtx.sceneFlags.chest = flag; } /** * Returns all the chest flags. */ s32 Flags_GetAllTreasure(PlayState* play) { - return play->actorCtx.flags.chest; + return play->actorCtx.sceneFlags.chest; } /** * Tests if current scene clear flag is set. */ s32 Flags_GetClear(PlayState* play, s32 roomNumber) { - return play->actorCtx.flags.clearedRoom & (1 << roomNumber); + return play->actorCtx.sceneFlags.clearedRoom & (1 << roomNumber); } /** * Sets current scene clear flag. */ void Flags_SetClear(PlayState* play, s32 roomNumber) { - play->actorCtx.flags.clearedRoom |= (1 << roomNumber); + play->actorCtx.sceneFlags.clearedRoom |= (1 << roomNumber); } /** * Unsets current scene clear flag. */ void Flags_UnsetClear(PlayState* play, s32 roomNumber) { - play->actorCtx.flags.clearedRoom &= ~(1 << roomNumber); + play->actorCtx.sceneFlags.clearedRoom &= ~(1 << roomNumber); } /** * Tests if current scene temp clear flag is set. */ s32 Flags_GetClearTemp(PlayState* play, s32 roomNumber) { - return play->actorCtx.flags.clearedRoomTemp & (1 << roomNumber); + return play->actorCtx.sceneFlags.clearedRoomTemp & (1 << roomNumber); } /** * Sets current scene temp clear flag. */ void Flags_SetClearTemp(PlayState* play, s32 roomNumber) { - play->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber); + play->actorCtx.sceneFlags.clearedRoomTemp |= (1 << roomNumber); } /** * Unsets current scene temp clear flag. */ void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber) { - play->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber); + play->actorCtx.sceneFlags.clearedRoomTemp &= ~(1 << roomNumber); } /** @@ -790,7 +790,7 @@ void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber) { */ s32 Flags_GetCollectible(PlayState* play, s32 flag) { if (flag > 0 && flag < 0x80) { - return play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + return play->actorCtx.sceneFlags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -800,7 +800,7 @@ s32 Flags_GetCollectible(PlayState* play, s32 flag) { */ void Flags_SetCollectible(PlayState* play, s32 flag) { if (flag > 0 && flag < 0x80) { - play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + play->actorCtx.sceneFlags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); } } @@ -2249,14 +2249,14 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto overlayEntry++; } - actorCtx->flags.chest = cycleFlags->chest; - actorCtx->flags.switches[0] = cycleFlags->switch0; - actorCtx->flags.switches[1] = cycleFlags->switch1; + actorCtx->sceneFlags.chest = cycleFlags->chest; + actorCtx->sceneFlags.switches[0] = cycleFlags->switch0; + actorCtx->sceneFlags.switches[1] = cycleFlags->switch1; if (play->sceneNum == SCENE_INISIE_R) { cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneNum]; } - actorCtx->flags.collectible[0] = cycleFlags->collectible; - actorCtx->flags.clearedRoom = cycleFlags->clearedRoom; + actorCtx->sceneFlags.collectible[0] = cycleFlags->collectible; + actorCtx->sceneFlags.clearedRoom = cycleFlags->clearedRoom; TitleCard_ContextInit(&play->state, &actorCtx->titleCtxt); func_800B6468(play); @@ -2976,9 +2976,9 @@ void func_800BA798(PlayState* play, ActorContext* actorCtx) { } CollisionCheck_ClearContext(play, &play->colChkCtx); - actorCtx->flags.clearedRoomTemp = 0; - actorCtx->flags.switches[3] = 0; - actorCtx->flags.collectible[3] = 0; + actorCtx->sceneFlags.clearedRoomTemp = 0; + actorCtx->sceneFlags.switches[3] = 0; + actorCtx->sceneFlags.collectible[3] = 0; play->msgCtx.unk_12030 = 0; } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index a2742c746..b054dac74 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -78,7 +78,8 @@ void KaleidoSetup_Update(PlayState* play) { if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { - if (!(play->actorCtx.unk5 & 2) && !(play->actorCtx.unk5 & 4)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + !(play->actorCtx.flags & ACTORCTX_FLAG_2)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { gSaveContext.unk_3F26 = gSaveContext.unk_3F22; pauseCtx->unk_2B9 = 0; diff --git a/src/code/z_play.c b/src/code/z_play.c index c24a45b51..346f34692 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -345,16 +345,16 @@ void Play_SaveCycleSceneFlags(GameState* thisx) { CycleSceneFlags* cycleSceneFlags; cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(this->sceneNum)]; - cycleSceneFlags->chest = this->actorCtx.flags.chest; - cycleSceneFlags->switch0 = this->actorCtx.flags.switches[0]; - cycleSceneFlags->switch1 = this->actorCtx.flags.switches[1]; + cycleSceneFlags->chest = this->actorCtx.sceneFlags.chest; + cycleSceneFlags->switch0 = this->actorCtx.sceneFlags.switches[0]; + cycleSceneFlags->switch1 = this->actorCtx.sceneFlags.switches[1]; if (this->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneNum]; } - cycleSceneFlags->collectible = this->actorCtx.flags.collectible[0]; - cycleSceneFlags->clearedRoom = this->actorCtx.flags.clearedRoom; + cycleSceneFlags->collectible = this->actorCtx.sceneFlags.collectible[0]; + cycleSceneFlags->clearedRoom = this->actorCtx.sceneFlags.clearedRoom; } void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 roomIndex, s32 playerParams, Vec3f* pos, @@ -366,9 +366,9 @@ void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 ro gSaveContext.respawn[respawnMode].pos = *pos; gSaveContext.respawn[respawnMode].yaw = yaw; gSaveContext.respawn[respawnMode].playerParams = playerParams; - gSaveContext.respawn[respawnMode].tempSwitchFlags = this->actorCtx.flags.switches[2]; - gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.flags.collectible[1]; - gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.flags.collectible[2]; + gSaveContext.respawn[respawnMode].tempSwitchFlags = this->actorCtx.sceneFlags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.sceneFlags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.sceneFlags.collectible[2]; } void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) { @@ -395,9 +395,9 @@ void func_80169ECC(PlayState* this) { void func_80169EFC(GameState* thisx) { PlayState* this = (PlayState*)thisx; - gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2]; - gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1]; - gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwitchFlags = this->actorCtx.sceneFlags.switches[2]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.sceneFlags.collectible[1]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.sceneFlags.collectible[2]; this->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance; gSaveContext.respawnFlag = 1; func_80169ECC(this); diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 7b8b67443..781b623b2 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -267,11 +267,11 @@ void Sram_SaveEndOfCycle(PlayState* play) { sceneNum = Play_GetOriginalSceneNumber(play->sceneNum); Play_SaveCycleSceneFlags(&play->state); - play->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; - play->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; - play->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; - play->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; - play->actorCtx.flags.clearedRoom = 0; + play->actorCtx.sceneFlags.chest &= D_801C5FC0[sceneNum][2]; + play->actorCtx.sceneFlags.switches[0] &= D_801C5FC0[sceneNum][0]; + play->actorCtx.sceneFlags.switches[1] &= D_801C5FC0[sceneNum][1]; + play->actorCtx.sceneFlags.collectible[0] &= D_801C5FC0[sceneNum][3]; + play->actorCtx.sceneFlags.clearedRoom = 0; for (i = 0; i < SCENE_MAX; i++) { gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0]; 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 7fb51ff8d..9091948ae 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -216,7 +216,7 @@ void func_80953F9C(BgIngate* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() != -1) { Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); player->stateFlags1 |= 0x20; - play->actorCtx.unk5 &= ~0x4; + play->actorCtx.flags &= ~ACTORCTX_FLAG_2; } else { Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); player->stateFlags1 &= ~0x20; 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 1417d8094..120c9ea49 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1089,7 +1089,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); } else if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { - if (!(play->actorCtx.unk5 & 2)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } @@ -1632,7 +1632,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { this->alpha = 0; this->fadeOutState = SK_FADE_OUT_STATE_NONE; gSaveContext.save.weekEventReg[12] |= 4; - if (!(play->actorCtx.unk5 & 2)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } else { this->shouldDraw = false; @@ -1813,9 +1813,10 @@ void DmStk_Update(Actor* thisx, PlayState* play) { // 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 ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && - !FrameAdvance_IsEnabled(&play->state) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != 0) && + (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && + (play->csCtx.state == 0)) { 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_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 97b80fe9e..5d5b01ee8 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -139,7 +139,7 @@ void EnBom_Init(Actor* thisx, PlayState* play) { this->flashSpeedScale = 7; this->isPowderKeg = ENBOM_GETX_1(&this->actor); if (this->isPowderKeg) { - play->actorCtx.unk5 |= 1; + play->actorCtx.flags |= ACTORCTX_FLAG_0; this->timer = gSaveContext.powderKegTimer; } else { this->timer = 70; @@ -188,7 +188,7 @@ void EnBom_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider2); Collider_DestroyCylinder(play, &this->collider1); if (this->isPowderKeg) { - play->actorCtx.unk5 &= ~1; + play->actorCtx.flags &= ~ACTORCTX_FLAG_0; } } 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 bfc242060..10c28b6eb 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -604,7 +604,7 @@ void EnBox_Update(Actor* thisx, PlayState* play) { EnBox_ClipToGround(this, play); } if ((this->getItemId == GI_STRAY_FAIRY) && !Flags_GetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; } this->actionFunc(this, play); if (this->movementFlags & ENBOX_MOVE_0x80) { 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 04ad98f8f..fa465afbe 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -263,7 +263,7 @@ void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { } void func_80ACCBB8(EnElforg* this, PlayState* play) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; } void EnElforg_TrappedByBubble(EnElforg* this, PlayState* play) { 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 7e3a93fa8..fc1bdce22 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -279,7 +279,7 @@ void EnFall_Setup(EnFall* this, PlayState* play) { this->actor.draw = NULL; this->actionFunc = EnFall_MoonsTear_Fall; Actor_SetScale(&this->actor, 0.02f); - if (!(play->actorCtx.unk5 & 2)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } moon = EnFall_MoonsTear_GetTerminaFieldMoon(play); 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 3ad077fec..3faf24a1c 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -963,7 +963,8 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { this->unk_18C(this, play); } - if ((this->unk_3E8 == 6) && !(play->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { + if ((this->unk_3E8 == 6) && !(play->actorCtx.flags & ACTORCTX_FLAG_5) && + Animation_OnFrame(&this->skelAnime, 20.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } 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 976489fd9..e5775d129 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -987,7 +987,7 @@ Actor* func_80A13400(EnGo* this, PlayState* play) { } void func_80A134B0(EnGo* this, PlayState* play, s32 arg2) { - if ((gSaveContext.save.weekEventReg[18] & 0x80) || (play->actorCtx.unk5 & 1) || arg2) { + if ((gSaveContext.save.weekEventReg[18] & 0x80) || (play->actorCtx.flags & ACTORCTX_FLAG_0) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; 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 b78b65a19..6d7cc29ea 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -346,7 +346,7 @@ void EnKakasi_IdleStanding(EnKakasi* this, PlayState* play) { EnKakasi_SetupDialogue(this); return; } - if (play->actorCtx.unk5 & 0x4) { + if (play->actorCtx.flags & ACTORCTX_FLAG_2) { Actor_GetScreenPos(play, &this->picto.actor, &x, &y); if (this->picto.actor.projectedPos.z > -20.0f && x > 0 && x < SCREEN_WIDTH && y > 0 && y < SCREEN_HEIGHT && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { 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 2265fd22e..9a854ccf2 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -52,7 +52,7 @@ void EnScopecoin_Init(Actor* thisx, PlayState* play) { this->unk148 = 0; } - if (play->actorCtx.unk5 & 2) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { if (this->unk148 == 2 || this->unk148 == 6) { if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); 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 fce03f2b8..a4fcb6cb3 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -300,7 +300,7 @@ void EnScopecrow_Init(Actor* thisx, PlayState* play) { return; } - if (play->actorCtx.unk5 & 2) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { SkelAnime_InitFlex(play, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.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 2553962f9..fd0ced593 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -707,7 +707,7 @@ void EnScopenuts_Init(Actor* thisx, PlayState* play) { if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); - } else if (play->actorCtx.unk5 & 2) { + } else if (play->actorCtx.flags & ACTORCTX_FLAG_1) { this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; 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 77c40d173..4354e7f58 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -103,7 +103,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { switch (ENSTH_GET_F(&this->actor)) { case ENSTH_F_1: - if (play->actorCtx.unk5 & 2) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80B67958; } else { 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 3ce5ba447..1bf91af6b 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -40,7 +40,7 @@ void EnSth2_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); this->unused = 0; - if (play->actorCtx.unk5 & 2) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); } else { Actor_MarkForDeath(&this->actor); 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 73309f615..6129a699a 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -48,8 +48,8 @@ static s16 sCurrentCs; void func_80A41D70(EnTest4* this, PlayState* play) { if (this->unk_144 != 0) { func_80151A68(play, sNightMessages1[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0)) { - if (play->actorCtx.unk5 & 2) { + } else if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); func_80151A68(play, sDayMessages1[CURRENT_DAY - 1]); @@ -66,7 +66,7 @@ void func_80A41D70(EnTest4* this, PlayState* play) { } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.unk5 & 2)) { + if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; @@ -91,7 +91,7 @@ void func_80A41D70(EnTest4* this, PlayState* play) { void func_80A41FA4(EnTest4* this, PlayState* play) { if (this->unk_144 != 0) { func_80151A68(play, sNightMessages2[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0)) { + } else if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); func_8010EE74(play, CURRENT_DAY); @@ -103,7 +103,7 @@ void func_80A41FA4(EnTest4* this, PlayState* play) { } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && ((play->actorCtx.unk5 & 2) == 0)) { + if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; @@ -277,7 +277,7 @@ void func_80A425E4(EnTest4* this, PlayState* play) { this->nextBellTime = CLOCK_TIME(17, 30); } - if ((sCutscenes[this->unk_144] < 0) || ((play->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || + if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1) || (CURRENT_DAY == 3) || (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { gSaveContext.screenScale = 1000.0f; } @@ -335,7 +335,8 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { this->unk_144 = 0; func_80A41D70(this, play); - if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.unk5 & 2)) { + if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && + !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { player->stateFlags1 |= 0x200; } } else { @@ -356,7 +357,7 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { } this->lastBellTime = gSaveContext.save.time; - if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.unk5 & 2)) { + if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { gSaveContext.screenScaleFlag = 0; gSaveContext.screenScale = 1000.0f; } @@ -383,8 +384,8 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { if ((temp_a3 * temp_a2) <= 0) { gSaveContext.unk_3CA7 = 1; - if (play->actorCtx.unk5 & 0x4) { - play->actorCtx.unk5 &= ~0x4; + if (play->actorCtx.flags & ACTORCTX_FLAG_2) { + play->actorCtx.flags &= ~ACTORCTX_FLAG_2; } if (temp_a0 != CLOCK_TIME(6, 0)) { @@ -394,7 +395,8 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { func_8011C808(play); Actor_MarkForDeath(&this->actor); gSaveContext.eventInf[1] |= 0x80; - } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { + } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && + (CURRENT_DAY != 3)) { func_80A41FA4(this, play); } else { gSaveContext.screenScale = 0.0f; @@ -419,7 +421,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } } - if ((sCutscenes[this->unk_144] >= 0) && ((play->actorCtx.unk5 & 2) == 0)) { + if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { player->stateFlags1 |= 0x200; this->unk_146 = gSaveContext.save.time; } else { @@ -442,7 +444,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { s32 playerParams; u32 entrance = gSaveContext.save.entrance; - if ((play->actorCtx.unk5 & 2)) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_1)) { playerParams = 0xCFF; } else { playerParams = 0xBFF; 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 473ff1edd..6dda48fc7 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -315,7 +315,7 @@ void func_80BA3D38(EnToto* this, PlayState* play) { this->cutscene = this->actor.cutscene; this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; func_80BA4C0C(this, play); - play->actorCtx.unk5 |= 0x20; + play->actorCtx.flags |= ACTORCTX_FLAG_5; this->unk260[0] = 0; } @@ -344,7 +344,7 @@ void func_80BA3DBC(EnToto* this, PlayState* play) { func_80BA36C0(this, play, 0); ActorCutscene_Stop(this->cutscene); - play->actorCtx.unk5 &= ~0x20; + play->actorCtx.flags &= ~ACTORCTX_FLAG_5; } s32 func_80BA3EC0(EnToto* this, PlayState* play) { 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 752447a5d..092c693f2 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 @@ -352,7 +352,7 @@ void func_80966FEC(EnWeatherTag* this, PlayState* play) { } // unique pirates fortress behavior? - if ((play->sceneNum == SCENE_KAIZOKU) && (play->actorCtx.unk5 & 2)) { + if ((play->sceneNum == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) { EnWeatherTag_SetupAction(this, func_80967060); } } @@ -482,9 +482,10 @@ void EnWeatherTag_Update(Actor* thisx, PlayState* play) { EnWeatherTag* this = THIS; this->actionFunc(this, play); - if ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && - (!FrameAdvance_IsEnabled(&play->state)) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != 0) && + (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && + (play->csCtx.state == 0)) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { 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 2ce8f6ef3..ef1feb1a9 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -545,7 +545,7 @@ void ObjComb_Update(Actor* thisx, PlayState* play) { } if (this->unk_1B7 != 0) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; this->actor.flags |= ACTOR_FLAG_10; } } 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 fcbdfbad4..d32e7a2cd 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -228,7 +228,7 @@ void ObjKibako2_Update(Actor* thisx, PlayState* play) { ObjKibako2* this = THIS; if (this->unk_1AC != 0) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; } if (this->skulltulaNoiseTimer >= 0) { 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 681faf3c1..4c56bb794 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -164,14 +164,14 @@ void func_80BA2790(ObjNozoki* this) { } void func_80BA27C4(ObjNozoki* this, PlayState* play) { - if (!(play->actorCtx.unk5 & 0x20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { if (OBJNOZOKI_GET_200(&this->dyna.actor)) { if (!func_80BA2708(this, play)) { return; } } else { if (D_80BA36B0 != 0) { - play->actorCtx.unk5 |= 0x80; + play->actorCtx.flags |= ACTORCTX_FLAG_7; } if (!Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { @@ -189,7 +189,7 @@ void func_80BA27C4(ObjNozoki* this, PlayState* play) { if (this->unk_15E < 0) { this->unk_15E = 50; } - play->actorCtx.unk5 |= 0x10; + play->actorCtx.flags |= ACTORCTX_FLAG_4; } } GET_PLAYER(play)->linearVelocity = 0.0f; @@ -204,7 +204,7 @@ void func_80BA28DC(ObjNozoki* this, PlayState* play) { return; } - if (!(play->actorCtx.unk5 & 0x20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { 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); @@ -250,7 +250,7 @@ void func_80BA2AB4(ObjNozoki* this, PlayState* play) { D_80BA36B0 = 1; } - if (!(play->actorCtx.unk5 & 0x20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { func_80BA2790(this); @@ -316,7 +316,7 @@ void func_80BA2C94(ObjNozoki* this, PlayState* play) { Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); - if ((play->actorCtx.unk5 & 0x40) || (play->actorCtx.unk5 & 0x20)) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_6) || (play->actorCtx.flags & ACTORCTX_FLAG_5)) { temp_f0 = 0.5f; } else { temp_f0 = this->dyna.actor.speedXZ; @@ -326,20 +326,20 @@ void func_80BA2C94(ObjNozoki* this, PlayState* play) { D_80BA36B8 += this->dyna.actor.speedXZ; - if (play->actorCtx.unk5 & 0x40) { + if (play->actorCtx.flags & ACTORCTX_FLAG_6) { if (sp34 <= 5.0f) { Actor_MarkForDeath(&this->dyna.actor); } - } else if (!(play->actorCtx.unk5 & 0x20) && (GET_PLAYER(play)->actor.id == ACTOR_PLAYER) && + } else if (!(play->actorCtx.flags & ACTORCTX_FLAG_5) && (GET_PLAYER(play)->actor.id == ACTOR_PLAYER) && Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { static Vec3f D_80BA34F0 = { 0.0f, 0.0f, 50.0f }; - play->actorCtx.unk5 |= 0x40; + play->actorCtx.flags |= ACTORCTX_FLAG_6; 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) { - play->actorCtx.unk5 |= 0x20; + play->actorCtx.flags |= ACTORCTX_FLAG_5; if (sp34 < 20.0f) { this->dyna.actor.velocity.y -= 0.4f; @@ -369,11 +369,11 @@ void func_80BA3044(ObjNozoki* this, PlayState* play) { Vec3f* sp1C = &this->dyna.actor.focus.pos; if (this->unk_15D == 0) { - if (play->actorCtx.unk5 & 0x40) { + if (play->actorCtx.flags & ACTORCTX_FLAG_6) { this->unk_15D = 1; this->unk_15E = 20; Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); - } else if (!(play->actorCtx.unk5 & 0x20) && + } else if (!(play->actorCtx.flags & ACTORCTX_FLAG_5) && Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { sp1C = &this->dyna.actor.home.pos; } 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 801cfc3ce..02743db29 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -296,7 +296,7 @@ void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, PlayState* pla s16 yaw; f32 cos; - if (play->actorCtx.unk5 & 0x80) { + if (play->actorCtx.flags & ACTORCTX_FLAG_7) { player = GET_PLAYER(play); // compute yawTowardsPlayer relative to model space yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c index 9aadc668c..c7aa4549d 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c @@ -310,7 +310,7 @@ void ObjTaru_Update(Actor* thisx, PlayState* play) { if (!OBJ_TARU_GET_80(thisx)) { if (this->unk_1AC != 0) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; } if (this->unk_1AD >= 0) { switch (this->unk_1AD) { 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 79b2e577e..74c121656 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -701,7 +701,7 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, PlayState* play) { this->clockTime += 3; this->actor.draw = ObjTokeidai_Clock_Draw; } else { - if (!(play->actorCtx.unk5 & 2) && + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; @@ -734,9 +734,9 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, PlayState* play) { this->clockTime += 3; this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { - if ((play->actorCtx.unk5 & 2) == 0 && - OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD && - ActorCutscene_GetCurrentIndex() == -1) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD) && + (ActorCutscene_GetCurrentIndex() == -1)) { this->actor.draw = NULL; } this->clockTime = gSaveContext.save.time; 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 c2cc74a82..acba9ec31 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -665,7 +665,7 @@ void ObjTsubo_Update(Actor* thisx, PlayState* play) { } if (!this->unk_197) { if (this->unk_198) { - play->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; this->actor.flags |= ACTOR_FLAG_10; } if (this->unk_19A >= 0) { diff --git a/tools/namefixer.py b/tools/namefixer.py index f8f714f8c..af17edc3c 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -707,6 +707,8 @@ wordReplace = { "globalCtx->envCtx.unk_DC": "play->envCtx.lightBlend", "globalCtx->interfaceCtx.unk_21E": "play->interfaceCtx.bButtonDoAction", + # "play->actorCtx.flags": "play->actorCtx.sceneFlags", + # "play->actorCtx.unk5": "play->actorCtx.flags", "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", "play->msgCtx.unk11F10": "play->msgCtx.msgLength", "play->msgCtx.unk11F22": "play->msgCtx.msgMode", From 0e1b244354f776a7ecb800c60fc314c904718bb5 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 24 Sep 2022 15:35:37 -0400 Subject: [PATCH 38/73] Audio: Various Cleanup and Docs (#1034) * cleanup and docs * pr suggestions * audio errors * fix bss * Empty-Commit --- include/functions.h | 8 +- include/variables.h | 4 +- include/z64audio.h | 141 +++--- src/code/audio/audio_effects.c | 14 +- src/code/audio/audio_heap.c | 229 ++++----- src/code/audio/audio_init_params.c | 4 +- src/code/audio/audio_load.c | 449 +++++++++++------- src/code/audio/audio_playback.c | 292 ++++++------ src/code/audio/audio_seqplayer.c | 97 ++-- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 1 + .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 1 - tools/disasm/functions.txt | 22 +- tools/disasm/variables.txt | 2 +- tools/sizes/code_functions.csv | 18 +- 14 files changed, 709 insertions(+), 573 deletions(-) diff --git a/include/functions.h b/include/functions.h index 4b116af1f..bfcb5f562 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3037,8 +3037,8 @@ void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); -void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size); -void AudioHeap_PopCache(s32 tableType); +void AudioHeap_InitPool(AudioAllocPool* pool, void* addr, size_t size); +void AudioHeap_PopPersistentCache(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); @@ -3123,10 +3123,10 @@ s32 osAiSetNextBuffer(void* buf, u32 size); void AudioPlayback_NoteDisable(Note* note); void AudioPlayback_ProcessNotes(void); -SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone); +TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone); Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId); Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId); -SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId); +SoundEffect* AudioPlayback_GetSoundEffect(s32 fontId, s32 sfxId); s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); void AudioPlayback_SeqLayerNoteDecay(SequenceLayer* layer); void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer); diff --git a/include/variables.h b/include/variables.h index 36ad5440a..54248860f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -2968,7 +2968,7 @@ extern f64 D_801E0EB0; // extern UNK_TYPE4 D_801E1068; extern UNK_PTR D_801E10B0; extern const s16 gAudioTatumInit[]; -extern const AudioContextInitSizes gAudioContextInitSizes; +extern const AudioHeapInitSizes gAudioHeapInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; extern u8 gSoundFontTable[]; @@ -3489,7 +3489,7 @@ extern ActiveSfx gActiveSfx[7][3]; extern AudioContext gAudioContext; // at 0x80200C70 extern void (*D_80208E68)(void); extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); -extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); +extern s32 (*D_80208E70)(Sample*, s32, s8, s32); extern Acmd* (*D_80208E74)(Acmd*, s32, s32); // post-code buffers diff --git a/include/z64audio.h b/include/z64audio.h index 4095251ca..fc9bf9f4c 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -10,6 +10,12 @@ #define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) #define SEQ_NUM_CHANNELS 16 +typedef enum { + /* 0 */ SEQPLAYER_STATE_0, + /* 1 */ SEQPLAYER_STATE_1, // Fading in + /* 2 */ SEQPLAYER_STATE_2 // Fading out +} SeqPlayerState; + #define MAX_CHANNELS_PER_BANK 3 #define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing @@ -27,6 +33,21 @@ #define AIBUF_LEN 0x580 +// Must be the same amount of samples as copied by aDuplicate() (audio microcode) +#define WAVE_SAMPLE_COUNT 64 + +#define AUDIO_RELOCATED_ADDRESS_START K0BASE + +typedef enum { + /* 0x1 */ AUDIO_ERROR_NO_INST = 1, + /* 0x3 */ AUDIO_ERROR_INVALID_INST_ID = 3, + /* 0x4 */ AUDIO_ERROR_INVALID_DRUM_SFX_ID, + /* 0x5 */ AUDIO_ERROR_NO_DRUM_SFX, + /* 0x10 */ AUDIO_ERROR_FONT_NOT_LOADED = 0x10 +} AudioError; + +#define AUDIO_ERROR(fontId, id, err) (((fontId << 8) + id) + (err << 24)) + typedef enum { /* 0 */ SOUNDMODE_STEREO, /* 1 */ SOUNDMODE_HEADSET, @@ -157,20 +178,20 @@ typedef struct { typedef struct { /* 0x00 */ u32 unk_0 : 1; - /* 0x00 */ u32 codec : 3; - /* 0x00 */ u32 medium : 2; - /* 0x00 */ u32 unk_bit26 : 1; - /* 0x00 */ u32 unk_bit25 : 1; - /* 0x01 */ u32 size : 24; - /* 0x04 */ u8* sampleAddr; - /* 0x08 */ AdpcmLoop* loop; - /* 0x0C */ AdpcmBook* book; -} SoundFontSample; // size = 0x10 + /* 0x00 */ u32 codec : 3; // The state of compression or decompression + /* 0x00 */ u32 medium : 2; // Medium where sample is currently stored + /* 0x00 */ u32 unk_bit26 : 1; // Has the sample header been relocated (offsets to pointers) + /* 0x00 */ u32 isRelocated : 1; // Size of the sample + /* 0x01 */ u32 size : 24; // Size of the sample + /* 0x04 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either rom or ram + /* 0x08 */ AdpcmLoop* loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram + /* 0x0C */ AdpcmBook* book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram +} Sample; // size = 0x10 typedef struct { - /* 0x00 */ SoundFontSample* sample; + /* 0x00 */ Sample* sample; /* 0x04 */ f32 tuning; // frequency scale factor -} SoundFontSound; // size = 0x8 +} TunedSample; // size = 0x8 typedef struct { /* 0x00 */ s16 numSamplesAfterDownsampling; // never read @@ -222,29 +243,33 @@ typedef struct { /* 0x27C */ s16* unk_27C; /* 0x280 */ s16* filterLeftState; /* 0x284 */ s16* filterRightState; - /* 0x288 */ SoundFontSound sound; - /* 0x290 */ SoundFontSample sample; + /* 0x288 */ TunedSample tunedSample; + /* 0x290 */ Sample sample; /* 0x2A0 */ AdpcmLoop loop; } SynthesisReverb; // size = 0x2D0 typedef struct { - /* 0x00 */ u8 loaded; + /* 0x00 */ u8 isRelocated; // have the envelope and all samples been relocated (offsets to pointers) /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; /* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x04 */ EnvelopePoint* envelope; - /* 0x08 */ SoundFontSound lowNotesSound; - /* 0x10 */ SoundFontSound normalNotesSound; - /* 0x18 */ SoundFontSound highNotesSound; + /* 0x08 */ TunedSample lowPitchTunedSample; + /* 0x10 */ TunedSample normalPitchTunedSample; + /* 0x18 */ TunedSample highPitchTunedSample; } Instrument; // size = 0x20 typedef struct { /* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x01 */ u8 pan; - /* 0x02 */ u8 loaded; - /* 0x04 */ SoundFontSound sound; - /* 0x14 */ EnvelopePoint* envelope; -} Drum; // size = 0x18 + /* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers) + /* 0x04 */ TunedSample tunedSample; + /* 0x0C */ EnvelopePoint* envelope; +} Drum; // size = 0x10 + +typedef struct { + /* 0x00 */ TunedSample tunedSample; +} SoundEffect; // size = 0x08 typedef struct { /* 0x00 */ u8 numInstruments; @@ -254,7 +279,7 @@ typedef struct { /* 0x04 */ u16 numSfx; /* 0x08 */ Instrument** instruments; /* 0x0C */ Drum** drums; - /* 0x10 */ SoundFontSound* soundEffects; + /* 0x10 */ SoundEffect* soundEffects; } SoundFont; // size = 0x14 typedef struct { @@ -290,10 +315,7 @@ typedef struct { /* 0x012 */ u16 fadeTimer; /* 0x014 */ u16 fadeTimerUnkEu; /* 0x016 */ u16 unk_16; - union { - /* 0x018 */ u8* seqData; - /* 0x018 */ u16* seqData16; - }; + /* 0x018 */ u8* seqData; /* 0x01C */ f32 fadeVolume; /* 0x020 */ f32 fadeVelocity; /* 0x024 */ f32 volume; @@ -437,7 +459,7 @@ typedef struct SequenceChannel { /* 0xD0 */ u8* sfxState; // SfxChannelState /* 0xD4 */ s16* filter; /* 0xD8 */ Stereo stereo; - /* 0xDC */ s32 unk_DC; + /* 0xDC */ s32 startSamplePos; /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 @@ -501,7 +523,7 @@ typedef struct SequenceLayer { /* 0x50 */ f32 noteVelocity; /* 0x54 */ f32 noteFreqScale; /* 0x58 */ Instrument* instrument; - /* 0x5C */ SoundFontSound* sound; + /* 0x5C */ TunedSample* tunedSample; /* 0x60 */ SequenceChannel* channel; // Not SequenceChannel? /* 0x64 */ SeqScriptState scriptState; /* 0x80 */ AudioListItem listItem; @@ -557,12 +579,18 @@ typedef struct { /* 0x1A */ u16 delay; } VibratoState; // size = 0x1C +typedef enum { + /* 0 */ PLAYBACK_STATUS_0, + /* 1 */ PLAYBACK_STATUS_1, + /* 2 */ PLAYBACK_STATUS_2 +} NotePlaybackStatus; + typedef struct { /* 0x00 */ u8 priority; /* 0x01 */ u8 waveId; - /* 0x02 */ u8 sampleCountIndex; + /* 0x02 */ u8 harmonicIndex; // the harmonic index for the synthetic wave contained in gWaveSamples (also matches the base 2 logarithm of the harmonic order) /* 0x03 */ u8 fontId; - /* 0x04 */ u8 unk_04; + /* 0x04 */ u8 status; /* 0x05 */ u8 stereoHeadsetEffects; /* 0x06 */ s16 adsrVolScaleUnused; /* 0x08 */ f32 portamentoFreqScale; @@ -575,7 +603,7 @@ typedef struct { /* 0x54 */ Portamento portamento; /* 0x60 */ VibratoState vibratoState; /* 0x7C */ char unk_7C[0x8]; - /* 0x84 */ u32 unk_84; + /* 0x84 */ u32 startSamplePos; } NotePlaybackState; // size = 0x88 typedef struct { @@ -600,16 +628,16 @@ typedef struct { /* 0x03 */ u8 headsetPanRight; /* 0x04 */ u8 headsetPanLeft; /* 0x05 */ u8 reverbVol; - /* 0x06 */ u8 unk_06; + /* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex /* 0x07 */ u8 unk_07; /* 0x08 */ u16 targetVolLeft; /* 0x0A */ u16 targetVolRight; /* 0x0C */ u16 resamplingRateFixedPoint; /* 0x0E */ u16 unk_0E; - union { - /* 0x10 */ SoundFontSound* soundFontSound; - /* 0x10 */ s16* samples; // used for synthetic waves - } sound; + union { + /* 0x10 */ TunedSample* tunedSample; + /* 0x10 */ s16* waveSampleAddr; // used for synthetic waves + }; /* 0x14 */ s16* filter; /* 0x18 */ u8 unk_18; /* 0x19 */ u8 unk_19; @@ -640,7 +668,7 @@ typedef struct { } ReverbSettings; // size = 0x18 /** - * The high-level audio specifications requested when initializing or resetting the audio heap. + * The high-level audio specifications requested when initializing or resetting the audio pool. * Most often resets during scene transitions, but will highly depend on game play. */ typedef struct { @@ -648,7 +676,8 @@ typedef struct { /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; - /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero + /* 0x07 */ u8 unk_07; // unused, set to zero + /* 0x08 */ u8 unk_08; // unused, set to zero /* 0x09 */ u8 numReverbs; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; @@ -675,17 +704,17 @@ typedef struct { /* 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; - /* 0x0C */ s16 updatesPerFrame; + /* 0x08 */ s16 maxAiBufNumSamples; + /* 0x0A */ s16 minAiBufNumSamples; + /* 0x0C */ s16 updatesPerFrame; // for each frame of the audio thread (default 60 fps), number of updates to process audio /* 0x0E */ s16 samplesPerUpdate; /* 0x10 */ s16 samplesPerUpdateMax; /* 0x12 */ s16 samplesPerUpdateMin; /* 0x14 */ s16 numSequencePlayers; /* 0x18 */ f32 resampleRate; - /* 0x1C */ f32 updatesPerFrameInv; - /* 0x20 */ f32 unkUpdatesPerFrameScaled; - /* 0x24 */ f32 unk_24; + /* 0x1C */ f32 updatesPerFrameInv; // inverse (reciprocal) of updatesPerFrame + /* 0x20 */ f32 updatesPerFrameInvScaled; // updatesPerFrameInv scaled down by a factor of 256 + /* 0x24 */ f32 updatesPerFrameScaled; // updatesPerFrame scaled down by a factor of 4 } AudioBufferParameters; // size = 0x28 /** @@ -767,7 +796,7 @@ typedef struct { typedef struct { /* 0x00 */ u32 endAndMediumKey; - /* 0x04 */ SoundFontSample* sample; + /* 0x04 */ Sample* sample; /* 0x08 */ u8* ramAddr; /* 0x0C */ u32 encodedInfo; /* 0x10 */ s32 isFree; @@ -822,7 +851,7 @@ typedef struct { /* 0x14 */ s32 status; /* 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; + /* 0x20 */ Sample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; /* 0x4C */ OSIoMesg ioMesg; @@ -873,7 +902,7 @@ typedef struct { /* 0x0014 */ NoteSubEu* noteSubsEu; /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; /* 0x0B58 */ char unk_0B58[0x30]; - /* 0x0B88 */ SoundFontSample* usedSamples[128]; + /* 0x0B88 */ Sample* usedSamples[128]; /* 0x0D88 */ AudioPreloadReq preloadSampleStack[128]; /* 0x1788 */ s32 numUsedSamples; /* 0x178C */ s32 preloadSampleStackTop; @@ -889,7 +918,7 @@ typedef struct { /* 0x1E58 */ OSMesg externalLoadMesgBuf[0x10]; /* 0x1E98 */ OSMesgQueue preloadSampleQueue; /* 0x1EB0 */ OSMesg preloadSampleMesgBuf[0x10]; - /* 0x1EF0 */ OSMesgQueue currAudioFrameDmaQueue; + /* 0x1EF0 */ OSMesgQueue curAudioFrameDmaQueue; /* 0x1F08 */ OSMesg currAudioFrameDmaMesgBuf[0x40]; /* 0x2008 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40]; /* 0x2608 */ OSMesgQueue syncDmaQueue; @@ -911,7 +940,7 @@ typedef struct { /* 0x285C */ char unk_285C[0x4]; /* 0x2860 */ u8* sequenceFontTable; /* 0x2864 */ u16 numSequences; - /* 0x2868 */ SoundFont* soundFonts; + /* 0x2868 */ SoundFont* soundFontList; /* 0x286C */ AudioBufferParameters audioBufferParameters; /* 0x2994 */ f32 unk_2870; /* 0x2898 */ s32 sampleDmaBufSize1; @@ -925,7 +954,7 @@ typedef struct { /* 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 rspTaskIndex; - /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28CC */ s32 curAiBufferIndex; /* 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* curTask; @@ -933,16 +962,16 @@ typedef struct { /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; /* 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 + /* 0x2994 */ s16 aiBufNumSamples[3]; // Number of samples 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; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29C0 */ AudioAllocPool sessionPool; // 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 + /* 0x29E0 */ AudioAllocPool initPool; // 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; // The common pool for all cache entries @@ -978,7 +1007,7 @@ typedef struct { /* 0x7978 */ u8 cmdWritePos; /* 0x7979 */ u8 cmdReadPos; /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed + /* 0x797C */ u16 activeChannelsFlags[5]; // bit-packed for 16 channels. Only channels with bit turned on will be processed /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; /* 0x7990 */ OSMesgQueue* cmdProcQueueP; @@ -1008,9 +1037,9 @@ typedef struct { typedef struct { /* 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. + /* 0x4 */ size_t initPoolSize; // The entire audio heap is split into two pools. /* 0x8 */ size_t permanentPoolSize; -} AudioContextInitSizes; // size = 0xC +} AudioHeapInitSizes; // size = 0xC typedef struct { /* 0x00 */ f32 unk_00; diff --git a/src/code/audio/audio_effects.c b/src/code/audio/audio_effects.c index ab9228bbf..bc27a6e22 100644 --- a/src/code/audio/audio_effects.c +++ b/src/code/audio/audio_effects.c @@ -63,7 +63,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) { } seqPlayer->fadeTimer--; - if (seqPlayer->fadeTimer == 0 && seqPlayer->state == 2) { + if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_2)) { AudioSeq_SequencePlayerDisable(seqPlayer); return; } @@ -243,12 +243,10 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { break; } // fallthrough - case ADSR_STATE_START_LOOP: adsr->envIndex = 0; adsr->action.s.state = ADSR_STATE_LOOP; // fallthrough - retry: case ADSR_STATE_LOOP: adsr->delay = adsr->envelope[adsr->envIndex].delay; @@ -256,18 +254,21 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { case ADSR_DISABLE: adsr->action.s.state = ADSR_STATE_DISABLED; break; + case ADSR_HANG: adsr->action.s.state = ADSR_STATE_HANG; break; + case ADSR_GOTO: adsr->envIndex = adsr->envelope[adsr->envIndex].arg; goto retry; + case ADSR_RESTART: adsr->action.s.state = ADSR_STATE_INITIAL; break; default: - adsr->delay *= gAudioContext.audioBufferParameters.unk_24; + adsr->delay *= gAudioContext.audioBufferParameters.updatesPerFrameScaled; if (adsr->delay == 0) { adsr->delay = 1; } @@ -282,14 +283,13 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { break; } // fallthrough - case ADSR_STATE_FADE: adsr->current += adsr->velocity; - if (--adsr->delay <= 0) { + adsr->delay--; + if (adsr->delay <= 0) { adsr->action.s.state = ADSR_STATE_LOOP; } // fallthrough - case ADSR_STATE_HANG: break; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index 7d3ea8ba6..667cd1c40 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -4,7 +4,7 @@ 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); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample); SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); void AudioHeap_DiscardSampleCaches(void); void AudioHeap_DiscardSampleBank(s32 sampleBankId); @@ -14,29 +14,37 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); #define gTatumsPerBeat (gAudioTatumInit[1]) -f32 func_8018B0F0(f32 arg0) { - return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +/** + * Effectively scales `updatesPerFrameInv` by the reciprocal of `scaleInv` + * `updatesPerFrameInvScaled` is just `updatesPerFrameInv` scaled down by a factor of 256.0f + * i.e. (256.0f * `updatesPerFrameInvScaled`) is just `updatesPerFrameInv` + */ +f32 AudioHeap_CalculateAdsrDecay(f32 scaleInv) { + return 256.0f * gAudioContext.audioBufferParameters.updatesPerFrameInvScaled / scaleInv; } -void func_8018B10C(void) { +/** + * Initialize the decay rate table used for decaying notes as part of adsr + */ +void AudioHeap_InitAdsrDecayTable(void) { s32 i; - gAudioContext.adsrDecayTable[255] = func_8018B0F0(0.25f); - gAudioContext.adsrDecayTable[254] = func_8018B0F0(0.33f); - gAudioContext.adsrDecayTable[253] = func_8018B0F0(0.5f); - gAudioContext.adsrDecayTable[252] = func_8018B0F0(0.66f); - gAudioContext.adsrDecayTable[251] = func_8018B0F0(0.75f); + gAudioContext.adsrDecayTable[255] = AudioHeap_CalculateAdsrDecay(0.25f); + gAudioContext.adsrDecayTable[254] = AudioHeap_CalculateAdsrDecay(0.33f); + gAudioContext.adsrDecayTable[253] = AudioHeap_CalculateAdsrDecay(0.5f); + gAudioContext.adsrDecayTable[252] = AudioHeap_CalculateAdsrDecay(0.66f); + gAudioContext.adsrDecayTable[251] = AudioHeap_CalculateAdsrDecay(0.75f); for (i = 128; i < 251; i++) { - gAudioContext.adsrDecayTable[i] = func_8018B0F0(251 - i); + gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(251 - i); } for (i = 16; i < 128; i++) { - gAudioContext.adsrDecayTable[i] = func_8018B0F0(4 * (143 - i)); + gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(4 * (143 - i)); } for (i = 1; i < 16; i++) { - gAudioContext.adsrDecayTable[i] = func_8018B0F0(60 * (23 - i)); + gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(60 * (23 - i)); } gAudioContext.adsrDecayTable[0] = 0.0f; @@ -71,7 +79,7 @@ void AudioHeap_DiscardFont(s32 fontId) { Note* note = &gAudioContext.notes[i]; if (note->playbackState.fontId == fontId) { - if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + if ((note->playbackState.status == PLAYBACK_STATUS_0) && (note->playbackState.priority != 0)) { note->playbackState.parentLayer->enabled = false; note->playbackState.parentLayer->finished = true; } @@ -233,19 +241,19 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { * 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) { +void AudioHeap_InitPool(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; } -void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { +void AudioHeap_InitPersistentCache(AudioPersistentCache* persistent) { persistent->pool.count = 0; persistent->numEntries = 0; persistent->pool.curAddr = persistent->pool.startAddr; } -void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { +void AudioHeap_InitTemporaryCache(AudioTemporaryCache* temporary) { temporary->pool.count = 0; temporary->pool.curAddr = temporary->pool.startAddr; temporary->nextSide = 0; @@ -260,7 +268,7 @@ void AudioHeap_ResetPool(AudioAllocPool* pool) { pool->curAddr = pool->startAddr; } -void AudioHeap_PopCache(s32 tableType) { +void AudioHeap_PopPersistentCache(s32 tableType) { AudioCache* loadedCache; AudioAllocPool* persistentHeap; AudioPersistentCache* persistent; @@ -306,69 +314,65 @@ void AudioHeap_PopCache(s32 tableType) { 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); +void AudioHeap_InitMainPool(size_t initPoolSize) { + AudioHeap_InitPool(&gAudioContext.initPool, gAudioContext.audioHeap, initPoolSize); + AudioHeap_InitPool(&gAudioContext.sessionPool, gAudioContext.audioHeap + initPoolSize, + gAudioContext.audioHeapSize - initPoolSize); gAudioContext.externalPool.startAddr = NULL; } void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { - gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + gAudioContext.sessionPool.curAddr = gAudioContext.sessionPool.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); + AudioHeap_InitPool(&gAudioContext.miscPool, AudioHeap_Alloc(&gAudioContext.sessionPool, split->miscPoolSize), + split->miscPoolSize); + AudioHeap_InitPool(&gAudioContext.cachePool, AudioHeap_Alloc(&gAudioContext.sessionPool, 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); + AudioHeap_InitPool(&gAudioContext.persistentCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_InitPool(&gAudioContext.temporaryCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); } -void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { +void AudioHeap_InitPersistentPoolsAndCaches(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_InitPool(&gAudioContext.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), split->seqCacheSize); + AudioHeap_InitPool(&gAudioContext.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_InitPool(&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); + AudioHeap_InitPersistentCache(&gAudioContext.seqCache.persistent); + AudioHeap_InitPersistentCache(&gAudioContext.fontCache.persistent); + AudioHeap_InitPersistentCache(&gAudioContext.sampleBankCache.persistent); } -void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { +void AudioHeap_InitTemporaryPoolsAndCaches(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_InitPool(&gAudioContext.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), split->seqCacheSize); + AudioHeap_InitPool(&gAudioContext.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), split->fontCacheSize); + AudioHeap_InitPool(&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); + AudioHeap_InitTemporaryCache(&gAudioContext.seqCache.temporary); + AudioHeap_InitTemporaryCache(&gAudioContext.fontCache.temporary); + AudioHeap_InitTemporaryCache(&gAudioContext.sampleBankCache.temporary); } void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { @@ -764,7 +768,7 @@ void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { s32 cutOff; //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 - if (lowPassCutoff == 0 && highPassCutoff == 0) { + if ((lowPassCutoff == 0) && (highPassCutoff == 0)) { // Identity filter AudioHeap_LoadLowPassFilter(filter, 0); } else if (highPassCutoff == 0) { @@ -830,13 +834,13 @@ void AudioHeap_UpdateReverbs(void) { * Clear the Audio Interface Buffers */ void AudioHeap_ClearAiBuffers(void) { - s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 curAiBufferIndex = gAudioContext.curAiBufferIndex; s32 i; - gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.minAiBufNumSamples; for (i = 0; i < AIBUF_LEN; i++) { - gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + gAudioContext.aiBuffers[curAiBufferIndex][i] = 0; } } @@ -902,8 +906,8 @@ s32 AudioHeap_ResetStep(void) { case 1: AudioHeap_Init(); gAudioContext.resetStatus = 0; - for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { - gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufNumSamples); i++) { + gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.maxAiBufNumSamples; for (j = 0; j < AIBUF_LEN; j++) { gAudioContext.aiBuffers[i][j] = 0; } @@ -940,9 +944,9 @@ void AudioHeap_Init(void) { gAudioContext.audioBufferParameters.samplesPerFrameTarget = ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); - gAudioContext.audioBufferParameters.minAiBufferLength = + gAudioContext.audioBufferParameters.minAiBufNumSamples = gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; - gAudioContext.audioBufferParameters.maxAiBufferLength = + gAudioContext.audioBufferParameters.maxAiBufNumSamples = gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; gAudioContext.audioBufferParameters.updatesPerFrame = ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; @@ -952,9 +956,10 @@ void AudioHeap_Init(void) { 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 = + gAudioContext.audioBufferParameters.updatesPerFrameInvScaled = (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; - gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; + gAudioContext.audioBufferParameters.updatesPerFrameScaled = + gAudioContext.audioBufferParameters.updatesPerFrame / 4.0f; gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; // sample dma size @@ -980,12 +985,12 @@ void AudioHeap_Init(void) { 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.maxAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.minAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { - gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + gAudioContext.audioBufferParameters.maxAiBufNumSamples -= 0x10; } // Determine the maximum allowable number of audio command list entries for the rsp microcode @@ -998,7 +1003,7 @@ void AudioHeap_Init(void) { temporarySize = spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; cachePoolSize = persistentSize + temporarySize; - miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + miscPoolSize = gAudioContext.sessionPool.size - cachePoolSize - 0x100; if (gAudioContext.externalPool.startAddr != NULL) { gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; @@ -1018,13 +1023,13 @@ void AudioHeap_Init(void) { gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; - AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + AudioHeap_InitPersistentPoolsAndCaches(&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_InitTemporaryPoolsAndCaches(&gAudioContext.temporaryCommonPoolSplit); AudioHeap_ResetLoadStatus(); @@ -1039,12 +1044,12 @@ void AudioHeap_Init(void) { // 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)); + AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(Acmd)); } - // Initialize adsrDecayTable (fadeOutVelocities for ADSR) + // Initialize the decay rate table for ADSR gAudioContext.adsrDecayTable = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); - func_8018B10C(); + AudioHeap_InitAdsrDecayTable(); // Initialize reverbs for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { @@ -1139,14 +1144,14 @@ void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t tempora if (addr == NULL) { gAudioContext.persistentSampleCache.pool.size = 0; } else { - AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + AudioHeap_InitPool(&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); + AudioHeap_InitPool(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); } gAudioContext.persistentSampleCache.numEntries = 0; @@ -1257,35 +1262,35 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { Drum* drum; Instrument* inst; - SoundFontSound* sfx; + SoundEffect* soundEffect; s32 instId; s32 drumId; s32 sfxId; - for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + for (instId = 0; instId < gAudioContext.soundFontList[fontId].numInstruments; instId++) { inst = AudioPlayback_GetInstrumentInner(fontId, instId); if (inst != NULL) { if (inst->normalRangeLo != 0) { - AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->lowPitchTunedSample.sample); } if (inst->normalRangeHi != 0x7F) { - AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->highPitchTunedSample.sample); } - AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->normalPitchTunedSample.sample); } } - for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + for (drumId = 0; drumId < gAudioContext.soundFontList[fontId].numDrums; drumId++) { drum = AudioPlayback_GetDrum(fontId, drumId); if (drum != NULL) { - AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + AudioHeap_UnapplySampleCache(entry, drum->tunedSample.sample); } } - for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { - sfx = AudioPlayback_GetSfx(fontId, sfxId); - if (sfx != NULL) { - AudioHeap_UnapplySampleCache(entry, sfx->sample); + for (sfxId = 0; sfxId < gAudioContext.soundFontList[fontId].numSfx; sfxId++) { + soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId); + if (soundEffect != NULL) { + AudioHeap_UnapplySampleCache(entry, soundEffect->tunedSample.sample); } } } @@ -1298,8 +1303,8 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { numFonts = gAudioContext.soundFontTable->numEntries; for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2; if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || entry->sampleBankId == 0xFE) { @@ -1313,7 +1318,7 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { } } -void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample) { if (sample != NULL) { if (sample->sampleAddr == entry->allocatedAddr) { sample->sampleAddr = entry->sampleAddr; @@ -1362,8 +1367,8 @@ void AudioHeap_DiscardSampleCaches(void) { numFonts = gAudioContext.soundFontTable->numEntries; for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2; if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { continue; } @@ -1390,7 +1395,7 @@ typedef struct { u8 newMedium; } StorageChange; -void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { +void AudioHeap_ChangeStorage(StorageChange* change, Sample* sample) { if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { uintptr_t startAddr = change->oldAddr; @@ -1430,7 +1435,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { s32 fontId; Drum* drum; Instrument* inst; - SoundFontSound* sfx; + SoundEffect* soundEffect; uintptr_t* newAddr; s32 pad[4]; @@ -1457,8 +1462,8 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { } for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2; if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { if (!AudioLoad_IsFontLoadComplete(fontId) || AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { @@ -1471,30 +1476,30 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { continue; } - for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + for (instId = 0; instId < gAudioContext.soundFontList[fontId].numInstruments; instId++) { inst = AudioPlayback_GetInstrumentInner(fontId, instId); if (inst != NULL) { if (inst->normalRangeLo != 0) { - AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->lowPitchTunedSample.sample); } if (inst->normalRangeHi != 0x7F) { - AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->highPitchTunedSample.sample); } - AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->normalPitchTunedSample.sample); } } - for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + for (drumId = 0; drumId < gAudioContext.soundFontList[fontId].numDrums; drumId++) { drum = AudioPlayback_GetDrum(fontId, drumId); if (drum != NULL) { - AudioHeap_ChangeStorage(&change, drum->sound.sample); + AudioHeap_ChangeStorage(&change, drum->tunedSample.sample); } } - for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { - sfx = AudioPlayback_GetSfx(fontId, sfxId); - if (sfx != NULL) { - AudioHeap_ChangeStorage(&change, sfx->sample); + for (sfxId = 0; sfxId < gAudioContext.soundFontList[fontId].numSfx; sfxId++) { + soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId); + if (soundEffect != NULL) { + AudioHeap_ChangeStorage(&change, soundEffect->tunedSample.sample); } } } @@ -1671,9 +1676,9 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) reverb->framesToIgnore = 2; } - reverb->sound.sample = &reverb->sample; + reverb->tunedSample.sample = &reverb->sample; reverb->sample.loop = &reverb->loop; - reverb->sound.tuning = 1.0f; + reverb->tunedSample.tuning = 1.0f; reverb->sample.codec = CODEC_REVERB; reverb->sample.medium = MEDIUM_RAM; reverb->sample.size = reverb->windowSize * 2; diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index b407ef7c9..81c49b30c 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -5,8 +5,8 @@ const s16 gAudioTatumInit[] = { 0x30, // gTatumsPerBeat }; -const AudioContextInitSizes gAudioContextInitSizes = { +const AudioHeapInitSizes gAudioHeapInitSizes = { 0x137F00, // heapSize - 0x1C480, // mainPoolSplitSize + 0x1C480, // initPoolSize 0x1A000, // permanentPoolSize }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 9ebdd1d85..c8e5ac5d1 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -16,7 +16,7 @@ * SoundFont Notes: * */ -// opaque type for unpatched sound font data (should maybe get rid of this?) +// opaque type for soundfont data loaded into ram (should maybe get rid of this?) typedef void SoundFontData; typedef struct { @@ -26,7 +26,7 @@ typedef struct { /* 0x0C */ uintptr_t baseAddr2; /* 0x10 */ u32 medium1; /* 0x14 */ u32 medium2; -} AudioRelocInfo; // size = 0x18 +} SampleBankRelocInfo; // size = 0x18 void AudioLoad_DiscardFont(s32 fontId); s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2); @@ -42,7 +42,7 @@ void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 un 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); +Sample* 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); @@ -56,8 +56,9 @@ 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); +void AudioLoad_RelocateSample(TunedSample* tunedSample, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc, + s32 isAsync); s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); #define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ @@ -217,7 +218,7 @@ void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaI 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, + OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.curAudioFrameDmaQueue, medium, "SUPERDMA"); *dmaIndexRef = dmaIndex; return (devAddr - dmaDevAddr) + dma->ramAddr; @@ -423,10 +424,10 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3 } } -s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { +s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) { void* sampleAddr; - if (sample->unk_bit25 == true) { + if (sample->isRelocated == true) { if (sample->medium != MEDIUM_RAM) { sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, CACHE_PERSISTENT); @@ -454,11 +455,11 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { return -1; } if (instrument->normalRangeLo != 0) { - AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + AudioLoad_SyncLoadSample(instrument->lowPitchTunedSample.sample, fontId); } - AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + AudioLoad_SyncLoadSample(instrument->normalPitchTunedSample.sample, fontId); if (instrument->normalRangeHi != 0x7F) { - return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + return AudioLoad_SyncLoadSample(instrument->highPitchTunedSample.sample, fontId); } // TODO: is this missing return UB? } else if (instId == 0x7F) { @@ -467,7 +468,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { if (drum == NULL) { return -1; } - AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + AudioLoad_SyncLoadSample(drum->tunedSample.sample, fontId); return 0; } // TODO: is this missing return UB? @@ -680,28 +681,29 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { s32 sampleBankId1; s32 sampleBankId2; s32 didAllocate; - AudioRelocInfo relocInfo; + SampleBankRelocInfo sampleBankReloc; s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } - sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + sampleBankId1 = gAudioContext.soundFontList[realFontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFontList[realFontId].sampleBankId2; - relocInfo.sampleBankId1 = sampleBankId1; - relocInfo.sampleBankId2 = sampleBankId2; - if (relocInfo.sampleBankId1 != 0xFF) { - relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + sampleBankReloc.sampleBankId1 = sampleBankId1; + sampleBankReloc.sampleBankId2 = sampleBankId2; + if (sampleBankReloc.sampleBankId1 != 0xFF) { + sampleBankReloc.baseAddr1 = + AudioLoad_TrySyncLoadSampleBank(sampleBankReloc.sampleBankId1, &sampleBankReloc.medium1, false); } else { - relocInfo.baseAddr1 = 0; + sampleBankReloc.baseAddr1 = 0; } if (sampleBankId2 != 0xFF) { - relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + sampleBankReloc.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &sampleBankReloc.medium2, false); } else { - relocInfo.baseAddr2 = 0; + sampleBankReloc.baseAddr2 = 0; } fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); @@ -709,7 +711,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { return NULL; } if (didAllocate == true) { - AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &sampleBankReloc, false); } return fontData; @@ -778,7 +780,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { } if (tableType == FONT_TABLE) { - SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + SoundFont* soundFont = &gAudioContext.soundFontList[realId]; soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; @@ -861,89 +863,131 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) { } /** + * Read and extract information from soundFont binary loaded into ram. + * Also relocate offsets into pointers within this loaded soundFont * - * SoundFontData* mem -> the address of the soundFont as stored in memory + * @param fontId index of font being processed + * @param fontDataStartAddr ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples */ -void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { - uintptr_t reloc; - uintptr_t reloc2; +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, SampleBankRelocInfo* sampleBankReloc) { + uintptr_t soundOffset; + uintptr_t soundListOffset; Instrument* inst; Drum* drum; - SoundFontSound* sfx; + SoundEffect* soundEffect; s32 i; - s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; - s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; - s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; - void** ptrs = (void**)fontData; + s32 numDrums = gAudioContext.soundFontList[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFontList[fontId].numInstruments; + s32 numSfx = gAudioContext.soundFontList[fontId].numSfx; + u32* fontData = (u32*)fontDataStartAddr; -#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + // Relocate an offset (relative to the start of the font data) to a pointer (a ram address) +#define RELOC_TO_RAM(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontDataStartAddr)) - // relocate drums - reloc2 = ptrs[0]; + // Drums relocation + + // The first u32 in fontData is an offset to a list of offsets to the drums + soundListOffset = fontData[0]; if (1) {} - if ((reloc2 != 0) && (numDrums != 0)) { - ptrs[0] = BASE_OFFSET(reloc2); + + // If the soundFont has drums + if ((soundListOffset != 0) && (numDrums != 0)) { + + fontData[0] = RELOC_TO_RAM(soundListOffset); + + // Loop through the drum offsets 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; + // Get the i'th drum offset + soundOffset = ((Drum**)fontData[0])[i]; + + // Some drum data entries are empty, represented by an offset of 0 in the list of drum offsets + if (soundOffset != 0) { + soundOffset = RELOC_TO_RAM(soundOffset); + ((Drum**)fontData[0])[i] = drum = soundOffset; + + // The drum may be in the list multiple times and already relocated + if (!drum->isRelocated) { + AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); + + soundOffset = drum->envelope; + drum->envelope = RELOC_TO_RAM(soundOffset); + + drum->isRelocated = true; } } } } - // relocate sfxs - reloc2 = ptrs[1]; + // Sound effects relocation + + // The second u32 in fontData is an offset to the first sound effect entry + soundListOffset = fontData[1]; if (1) {} - if ((reloc2 != 0) && (numSfx != 0)) { - ptrs[1] = BASE_OFFSET(reloc2); + + // If the soundFont has sound effects + if ((soundListOffset != 0) && (numSfx != 0)) { + + fontData[1] = RELOC_TO_RAM(soundListOffset); + + // Loop through the sound effects 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); - } + // Get a pointer to the i'th sound effect + soundOffset = (TunedSample*)fontData[1] + i; + soundEffect = (SoundEffect*)soundOffset; + + // Check for NULL (note: the pointer is guaranteed to be in fontData and can never be NULL) + if ((soundEffect != NULL) && (soundEffect->tunedSample.sample != NULL)) { + AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); } } } - if (numInstruments > 0x7E) { - numInstruments = 0x7E; + // Instruments relocation + + // Instrument Id 126 and above is reserved. + // There can only be 126 instruments, indexed from 0 to 125 + if (numInstruments > 126) { + numInstruments = 126; } - // relocate instruments + // Starting from the 3rd u32 in fontData is the list of offsets to the instruments + // Loop through the 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) { + // Some instrument data entries are empty, represented by an offset of 0 in the list of instrument offsets + if (fontData[i] != 0) { + fontData[i] = RELOC_TO_RAM(fontData[i]); + inst = (Instrument*)fontData[i]; + + // The instrument may be in the list multiple times and already relocated + if (!inst->isRelocated) { + // Some instruments have a different sample for low pitches 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); + AudioLoad_RelocateSample(&inst->lowPitchTunedSample, fontDataStartAddr, sampleBankReloc); } - reloc = inst->envelope; - inst->envelope = BASE_OFFSET(reloc); - inst->loaded = true; + // Every instrument has a sample for the default range + AudioLoad_RelocateSample(&inst->normalPitchTunedSample, fontDataStartAddr, sampleBankReloc); + + // Some instruments have a different sample for high pitches + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highPitchTunedSample, fontDataStartAddr, sampleBankReloc); + } + + soundOffset = inst->envelope; + inst->envelope = (EnvelopePoint*)RELOC_TO_RAM(soundOffset); + + inst->isRelocated = true; } } } -#undef BASE_OFFSET +#undef RELOC_TO_RAM - gAudioContext.soundFonts[fontId].drums = ptrs[0]; - gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; - gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); + // Store the relocated pointers + gAudioContext.soundFontList[fontId].drums = (Drum**)fontData[0]; + gAudioContext.soundFontList[fontId].soundEffects = (SoundEffect*)fontData[1]; + gAudioContext.soundFontList[fontId].instruments = (Instrument**)(&fontData[2]); } void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { @@ -1102,7 +1146,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, } if (tableType == FONT_TABLE) { - soundFont = &gAudioContext.soundFonts[realId]; + soundFont = &gAudioContext.soundFontList[realId]; soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; @@ -1154,8 +1198,8 @@ void AudioLoad_SetUnusedHandler(void* callback) { sUnusedHandler = callback; } -void AudioLoad_InitSoundFontMeta(s32 fontId) { - SoundFont* font = &gAudioContext.soundFonts[fontId]; +void AudioLoad_InitSoundFont(s32 fontId) { + SoundFont* font = &gAudioContext.soundFontList[fontId]; AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; @@ -1210,20 +1254,20 @@ void AudioLoad_Init(void* heap, size_t heapSize) { AudioThread_InitMesgQueues(); - for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { - gAudioContext.aiBufLengths[i] = 0xA0; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufNumSamples); i++) { + gAudioContext.aiBufNumSamples[i] = 0xA0; } gAudioContext.totalTaskCount = 0; gAudioContext.rspTaskIndex = 0; - gAudioContext.curAiBuffferIndex = 0; + gAudioContext.curAiBufferIndex = 0; gAudioContext.soundMode = SOUNDMODE_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, + osCreateMesgQueue(&gAudioContext.curAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); @@ -1235,23 +1279,24 @@ void AudioLoad_Init(void* heap, size_t heapSize) { if (heap == NULL) { gAudioContext.audioHeap = gAudioHeap; - gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + gAudioContext.audioHeapSize = gAudioHeapInitSizes.heapSize; } else { void** hp = &heap; + gAudioContext.audioHeap = *hp; gAudioContext.audioHeapSize = heapSize; } - for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { + for (i = 0; i < ((s32)gAudioContext.audioHeapSize / (s32)sizeof(u64)); i++) { ((u64*)gAudioContext.audioHeap)[i] = 0; } // Main Pool Split (split entirety of audio heap into initPool and sessionPool) - AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + AudioHeap_InitMainPool(gAudioHeapInitSizes.initPoolSize); - // Initialize the audio interface buffer + // Initialize the audio interface buffers for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { - gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.initPool, AIBUF_LEN * sizeof(s16)); } // Connect audio tables to their tables in memory @@ -1272,18 +1317,18 @@ void AudioLoad_Init(void* heap, size_t heapSize) { AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); numFonts = gAudioContext.soundFontTable->numEntries; - gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + gAudioContext.soundFontList = AudioHeap_Alloc(&gAudioContext.initPool, numFonts * sizeof(SoundFont)); for (i = 0; i < numFonts; i++) { - AudioLoad_InitSoundFontMeta(i); + AudioLoad_InitSoundFont(i); } - if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { - // cast away const from D_8014A6C4 - *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + if (addr = AudioHeap_Alloc(&gAudioContext.initPool, gAudioHeapInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from gAudioHeapInitSizes + *((u32*)&gAudioHeapInitSizes.permanentPoolSize) = 0; } - AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); + AudioHeap_InitPool(&gAudioContext.permanentPool, addr, gAudioHeapInitSizes.permanentPoolSize); gAudioContextInitalized = true; osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); } @@ -1294,7 +1339,7 @@ void AudioLoad_InitSlowLoads(void) { } s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { - SoundFontSample* sample; + Sample* sample; AudioSlowLoad* slowLoad; sample = AudioLoad_GetFontSample(fontId, instId); @@ -1344,8 +1389,8 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { return 0; } -SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { - SoundFontSample* sample; +Sample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + Sample* sample; if (instId < 0x80) { Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); @@ -1353,21 +1398,21 @@ SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { if (instrument == NULL) { return NULL; } - sample = instrument->normalNotesSound.sample; + sample = instrument->normalPitchTunedSample.sample; } else if (instId < 0x100) { Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); if (drum == NULL) { return NULL; } - sample = drum->sound.sample; + sample = drum->tunedSample.sample; } else { - SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + SoundEffect* soundEffect = AudioPlayback_GetSoundEffect(fontId, instId - 0x100); - if (sound == NULL) { + if (soundEffect == NULL) { return NULL; } - sample = sound->sample; + sample = soundEffect->tunedSample.sample; } return sample; @@ -1377,7 +1422,7 @@ void AudioLoad_Unused2(void) { } void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { - SoundFontSample* sample; + Sample* sample; if (slowLoad->sample.sampleAddr == NULL) { return; @@ -1596,7 +1641,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { OSMesg doneMsg; u32 sampleBankId1; u32 sampleBankId2; - AudioRelocInfo relocInfo; + SampleBankRelocInfo sampleBankReloc; if (1) {} switch (ASYNC_TBLTYPE(retMsg)) { @@ -1608,16 +1653,16 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { 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; + sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2; + sampleBankReloc.sampleBankId1 = sampleBankId1; + sampleBankReloc.sampleBankId2 = sampleBankId2; + sampleBankReloc.baseAddr1 = + (sampleBankId1 != 0xFF) ? AudioLoad_GetSampleBank(sampleBankId1, &sampleBankReloc.medium1) : 0; + sampleBankReloc.baseAddr2 = + (sampleBankId2 != 0xFF) ? AudioLoad_GetSampleBank(sampleBankId2, &sampleBankReloc.medium2) : 0; AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); - AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &sampleBankReloc, true); break; } @@ -1700,28 +1745,48 @@ void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { 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; +/** + * Read and extract information from TunedSample and its Sample + * contained in the soundFont binary loaded into ram + * TunedSample contains metadata on a sample used by a particular instrument/drum/sfx + * Also relocate offsets into pointers within this loaded TunedSample + * + * @param fontId index of font being processed + * @param fontData ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples + */ +void AudioLoad_RelocateSample(TunedSample* tunedSample, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc) { + Sample* 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); + // Relocate an offset (relative to data loaded in ram at `base`) to a pointer (a ram address) +#define AUDIO_RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) - // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + if ((uintptr_t)tunedSample->sample <= AUDIO_RELOCATED_ADDRESS_START) { + + sample = tunedSample->sample = AUDIO_RELOC(tunedSample->sample, fontData); + + // If the sample exists and has not already been relocated + // Note: this is important, as the same sample can be used by different drums, sound effects, instruments + if ((sample->size != 0) && (sample->isRelocated != true)) { + sample->loop = AUDIO_RELOC(sample->loop, fontData); + sample->book = AUDIO_RELOC(sample->book, fontData); + + // Resolve the sample medium 2-bit bitfield into a real value based on sampleBankReloc. + // Then relocate the offset sample within the sampleBank (not the fontData) into absolute address. + // sampleAddr can be either rom or ram depending on sampleBank cache policy + // in practice, this is always in rom switch (sample->medium) { case 0: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); - sample->medium = relocInfo->medium1; + sample->sampleAddr = AUDIO_RELOC(sample->sampleAddr, sampleBankReloc->baseAddr1); + sample->medium = sampleBankReloc->medium1; break; + case 1: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); - sample->medium = relocInfo->medium2; + sample->sampleAddr = AUDIO_RELOC(sample->sampleAddr, sampleBankReloc->baseAddr2); + sample->medium = sampleBankReloc->medium2; break; + case 2: case 3: // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE @@ -1729,7 +1794,8 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRe break; } - sample->unk_bit25 = true; + sample->isRelocated = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; } @@ -1737,12 +1803,19 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRe } } -#undef RELOC +#undef AUDIO_RELOC -void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { +/** + * @param fontId index of font being processed + * @param fontData ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples + * @param isAsync bool for whether this is an asynchronous load or not + */ +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc, + s32 isAsync) { AudioPreloadReq* preload; AudioPreloadReq* topPreload; - SoundFontSample* sample; + Sample* sample; size_t size; s32 nChunks; u8* sampleRamAddr; @@ -1757,7 +1830,7 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud } gAudioContext.numUsedSamples = 0; - AudioLoad_RelocateFont(fontId, mem, relocInfo); + AudioLoad_RelocateFont(fontId, fontData, sampleBankReloc); size = 0; for (i = 0; i < gAudioContext.numUsedSamples; i++) { @@ -1772,13 +1845,13 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud sample = gAudioContext.usedSamples[i]; sampleRamAddr = NULL; - switch (async) { + switch (isAsync) { case false: - if (sample->medium == relocInfo->medium1) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + if (sample->medium == sampleBankReloc->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); - } else if (sample->medium == relocInfo->medium2) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + } else if (sample->medium == sampleBankReloc->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } else if (sample->medium == MEDIUM_DISK_DRIVE) { sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, @@ -1787,23 +1860,26 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud break; case true: - if (sample->medium == relocInfo->medium1) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + if (sample->medium == sampleBankReloc->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); - } else if (sample->medium == relocInfo->medium2) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + } else if (sample->medium == sampleBankReloc->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->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; + + default: + break; } if (sampleRamAddr == NULL) { continue; } - switch (async) { + switch (isAsync) { case false: if (sample->medium == MEDIUM_UNK) { AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, @@ -1827,6 +1903,9 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; gAudioContext.preloadSampleStackTop++; break; + + default: + break; } } gAudioContext.numUsedSamples = 0; @@ -1841,7 +1920,7 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud } s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { - SoundFontSample* sample; + Sample* sample; AudioPreloadReq* preload; u32 preloadIndex; u32 key; @@ -1902,7 +1981,7 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { return true; } -s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { +s32 AudioLoad_AddToSampleSet(Sample* sample, s32 numSamples, Sample** sampleSet) { s32 i; for (i = 0; i < numSamples; i++) { @@ -1919,18 +1998,18 @@ s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontS return numSamples; } -s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { +s32 AudioLoad_GetSamplesForFont(s32 fontId, Sample** sampleSet) { s32 i; s32 numSamples = 0; - s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; - s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numDrums = gAudioContext.soundFontList[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFontList[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); + numSamples = AudioLoad_AddToSampleSet(drum->tunedSample.sample, numSamples, sampleSet); } } @@ -1939,12 +2018,12 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { if (instrument != NULL) { if (instrument->normalRangeLo != 0) { - numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->lowPitchTunedSample.sample, numSamples, sampleSet); } if (instrument->normalRangeHi != 0x7F) { - numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->highPitchTunedSample.sample, numSamples, sampleSet); } - numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->normalPitchTunedSample.sample, numSamples, sampleSet); } } @@ -1952,27 +2031,27 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { return numSamples; } -void AudioLoad_AddUsedSample(SoundFontSound* sound) { - SoundFontSample* sample = sound->sample; +void AudioLoad_AddUsedSample(TunedSample* tunedSample) { + Sample* sample = tunedSample->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) { +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, SampleBankRelocInfo* sampleBankReloc) { s32 numDrums; s32 numInstruments; s32 numSfx; Drum* drum; Instrument* instrument; - SoundFontSound* sound; + SoundEffect* soundEffect; AudioPreloadReq* preload; AudioPreloadReq* topPreload; u8* addr; size_t size; s32 i; - SoundFontSample* sample; + Sample* sample; s32 preloadInProgress; s32 nChunks; @@ -1983,34 +2062,34 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relo gAudioContext.numUsedSamples = 0; - numDrums = gAudioContext.soundFonts[fontId].numDrums; - numInstruments = gAudioContext.soundFonts[fontId].numInstruments; - numSfx = gAudioContext.soundFonts[fontId].numSfx; + numDrums = gAudioContext.soundFontList[fontId].numDrums; + numInstruments = gAudioContext.soundFontList[fontId].numInstruments; + numSfx = gAudioContext.soundFontList[fontId].numSfx; for (i = 0; i < numInstruments; i++) { instrument = AudioPlayback_GetInstrumentInner(fontId, i); if (instrument != NULL) { if (instrument->normalRangeLo != 0) { - AudioLoad_AddUsedSample(&instrument->lowNotesSound); + AudioLoad_AddUsedSample(&instrument->lowPitchTunedSample); } if (instrument->normalRangeHi != 0x7F) { - AudioLoad_AddUsedSample(&instrument->highNotesSound); + AudioLoad_AddUsedSample(&instrument->highPitchTunedSample); } - AudioLoad_AddUsedSample(&instrument->normalNotesSound); + AudioLoad_AddUsedSample(&instrument->normalPitchTunedSample); } } for (i = 0; i < numDrums; i++) { drum = AudioPlayback_GetDrum(fontId, i); if (drum != NULL) { - AudioLoad_AddUsedSample(&drum->sound); + AudioLoad_AddUsedSample(&drum->tunedSample); } } for (i = 0; i < numSfx; i++) { - sound = AudioPlayback_GetSfx(fontId, i); - if (sound != NULL) { - AudioLoad_AddUsedSample(sound); + soundEffect = AudioPlayback_GetSoundEffect(fontId, i); + if (soundEffect != NULL) { + AudioLoad_AddUsedSample(&soundEffect->tunedSample); } } @@ -2036,21 +2115,21 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relo switch (async) { case false: - if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + if (sample->medium == sampleBankReloc->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); - } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + } else if (sample->medium == sampleBankReloc->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } break; case true: - if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + if (sample->medium == sampleBankReloc->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); - } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + } else if (sample->medium == sampleBankReloc->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } break; @@ -2104,23 +2183,25 @@ void AudioLoad_LoadPermanentSamples(void) { sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); for (i = 0; i < gAudioContext.permanentPool.count; i++) { - AudioRelocInfo relocInfo; + SampleBankRelocInfo sampleBankReloc; 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; + sampleBankReloc.sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1; + sampleBankReloc.sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2; - if (relocInfo.sampleBankId1 != 0xFF) { - relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); - relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + if (sampleBankReloc.sampleBankId1 != 0xFF) { + sampleBankReloc.sampleBankId1 = + AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankReloc.sampleBankId1); + sampleBankReloc.medium1 = sampleBankTable->entries[sampleBankReloc.sampleBankId1].medium; } - if (relocInfo.sampleBankId2 != 0xFF) { - relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); - relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + if (sampleBankReloc.sampleBankId2 != 0xFF) { + sampleBankReloc.sampleBankId2 = + AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankReloc.sampleBankId2); + sampleBankReloc.medium2 = sampleBankTable->entries[sampleBankReloc.sampleBankId2].medium; } - AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + AudioLoad_PreloadSamplesForFont(fontId, false, &sampleBankReloc); } } } diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index e7f5153ac..e1a42b1ed 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -4,9 +4,10 @@ void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRat void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item); void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer); -void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { - f32 volRight, volLeft; - s32 smallPanIndex; +void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttributes* subAttrs) { + f32 volLeft; + f32 volRight; + s32 halfPanIndex; u64 pad; u8 strongLeft; u8 strongRight; @@ -16,41 +17,41 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at StereoData stereoData; s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects; - vel = attrs->velocity; - pan = attrs->pan; - reverbVol = attrs->reverbVol; - stereoData = attrs->stereo.s; + vel = subAttrs->velocity; + pan = subAttrs->pan; + reverbVol = subAttrs->reverbVol; + stereoData = subAttrs->stereo.s; - sub->bitField0 = note->noteSubEu.bitField0; - sub->bitField1 = note->noteSubEu.bitField1; - sub->sound.samples = note->noteSubEu.sound.samples; - sub->unk_06 = note->noteSubEu.unk_06; + noteSubEu->bitField0 = note->noteSubEu.bitField0; + noteSubEu->bitField1 = note->noteSubEu.bitField1; + noteSubEu->waveSampleAddr = note->noteSubEu.waveSampleAddr; + noteSubEu->harmonicIndexCurAndPrev = note->noteSubEu.harmonicIndexCurAndPrev; - AudioPlayback_NoteSetResamplingRate(sub, attrs->frequency); + AudioPlayback_NoteSetResamplingRate(noteSubEu, subAttrs->frequency); pan &= 0x7F; - sub->bitField0.stereoStrongRight = false; - sub->bitField0.stereoStrongLeft = false; - sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; - sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; - if (stereoHeadsetEffects && gAudioContext.soundMode == SOUNDMODE_HEADSET) { - smallPanIndex = pan >> 1; - if (smallPanIndex > 0x3F) { - smallPanIndex = 0x3F; + noteSubEu->bitField0.stereoStrongRight = false; + noteSubEu->bitField0.stereoStrongLeft = false; + noteSubEu->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; + noteSubEu->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; + if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_HEADSET)) { + halfPanIndex = pan >> 1; + if (halfPanIndex > 0x3F) { + halfPanIndex = 0x3F; } - sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex]; - sub->headsetPanRight = gHeadsetPanQuantization[0x3F - smallPanIndex]; - sub->bitField1.usesHeadsetPanEffects2 = true; + noteSubEu->headsetPanLeft = gHeadsetPanQuantization[halfPanIndex]; + noteSubEu->headsetPanRight = gHeadsetPanQuantization[0x3F - halfPanIndex]; + noteSubEu->bitField1.usesHeadsetPanEffects2 = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; - } else if (stereoHeadsetEffects && gAudioContext.soundMode == SOUNDMODE_STEREO) { + } else if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_STEREO)) { strongLeft = strongRight = false; - sub->headsetPanRight = 0; - sub->headsetPanLeft = 0; - sub->bitField1.usesHeadsetPanEffects2 = false; + noteSubEu->headsetPanRight = 0; + noteSubEu->headsetPanLeft = 0; + noteSubEu->bitField1.usesHeadsetPanEffects2 = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[0x7F - pan]; @@ -60,34 +61,38 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at strongRight = true; } - sub->bitField0.stereoStrongRight = strongRight; - sub->bitField0.stereoStrongLeft = strongLeft; + // case 0: + noteSubEu->bitField0.stereoStrongRight = strongRight; + noteSubEu->bitField0.stereoStrongLeft = strongLeft; switch (stereoData.bit2) { case 0: break; + case 1: - sub->bitField0.stereoStrongRight = stereoData.strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; + noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; break; + case 2: - sub->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; + noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; + noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; break; + case 3: - sub->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; + noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; + noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; break; } } else if (gAudioContext.soundMode == SOUNDMODE_MONO) { - sub->bitField0.stereoHeadsetEffects = false; - sub->bitField0.usesHeadsetPanEffects = false; + noteSubEu->bitField0.stereoHeadsetEffects = false; + noteSubEu->bitField0.usesHeadsetPanEffects = false; volLeft = 0.707f; // approx 1/sqrt(2) volRight = 0.707f; } else { - sub->bitField0.stereoStrongRight = stereoData.strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; + noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; volLeft = gDefaultPanVolume[pan]; volRight = gDefaultPanVolume[0x7F - pan]; } @@ -95,15 +100,15 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at vel = 0.0f > vel ? 0.0f : vel; vel = 1.0f < vel ? 1.0f : vel; - sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); - sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); + noteSubEu->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); + noteSubEu->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - sub->gain = attrs->gain; - sub->filter = attrs->filter; - sub->unk_07 = attrs->unk_14; - sub->unk_0E = attrs->unk_16; - sub->reverbVol = reverbVol; - sub->unk_19 = attrs->unk_3; + noteSubEu->gain = subAttrs->gain; + noteSubEu->filter = subAttrs->filter; + noteSubEu->unk_07 = subAttrs->unk_14; + noteSubEu->unk_0E = subAttrs->unk_16; + noteSubEu->reverbVol = reverbVol; + noteSubEu->unk_19 = subAttrs->unk_3; } void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) { @@ -133,7 +138,7 @@ void AudioPlayback_NoteInit(Note* note) { ¬e->playbackState.adsrVolScaleUnused); } - note->playbackState.unk_04 = 0; + note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL; note->noteSubEu = gDefaultNoteSub; } @@ -144,7 +149,7 @@ void AudioPlayback_NoteDisable(Note* note) { } note->playbackState.priority = 0; note->noteSubEu.bitField0.enabled = false; - note->playbackState.unk_04 = 0; + note->playbackState.status = PLAYBACK_STATUS_0; note->noteSubEu.bitField0.finished = false; note->playbackState.parentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; @@ -154,7 +159,7 @@ void AudioPlayback_NoteDisable(Note* note) { void AudioPlayback_ProcessNotes(void) { s32 pad; - s32 unk_04; + s32 playbackStatus; NoteAttributes* attrs; NoteSubEu* noteSubEu2; NoteSubEu* noteSubEu; @@ -174,19 +179,19 @@ void AudioPlayback_ProcessNotes(void) { continue; } - if (note != playbackState->parentLayer->note && playbackState->unk_04 == 0) { + if ((note != playbackState->parentLayer->note) && (playbackState->status == PLAYBACK_STATUS_0)) { playbackState->adsr.action.s.release = true; playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; playbackState->priority = 1; - playbackState->unk_04 = 2; + playbackState->status = PLAYBACK_STATUS_2; goto out; - } else if (!playbackState->parentLayer->enabled && playbackState->unk_04 == 0 && - playbackState->priority >= 1) { + } else if (!playbackState->parentLayer->enabled && (playbackState->status == PLAYBACK_STATUS_0) && + (playbackState->priority >= 1)) { // do nothing } else if (playbackState->parentLayer->channel->seqPlayer == NULL) { AudioSeq_SequenceChannelDisable(playbackState->parentLayer->channel); playbackState->priority = 1; - playbackState->unk_04 = 1; + playbackState->status = PLAYBACK_STATUS_1; continue; } else if (playbackState->parentLayer->channel->seqPlayer->muted && (playbackState->parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_NOTES)) { @@ -199,8 +204,8 @@ void AudioPlayback_ProcessNotes(void) { AudioPlayback_AudioListRemove(¬e->listItem); AudioPlayback_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem); playbackState->priority = 1; - playbackState->unk_04 = 2; - } else if (playbackState->unk_04 == 0 && playbackState->priority >= 1) { + playbackState->status = PLAYBACK_STATUS_2; + } else if ((playbackState->status == PLAYBACK_STATUS_0) && (playbackState->priority >= 1)) { continue; } @@ -208,8 +213,8 @@ void AudioPlayback_ProcessNotes(void) { if (playbackState->priority != 0) { if (1) {} noteSubEu = ¬e->noteSubEu; - if (playbackState->unk_04 >= 1 || noteSubEu->bitField0.finished) { - if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || noteSubEu->bitField0.finished) { + if ((playbackState->status >= 1) || noteSubEu->bitField0.finished) { + if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || noteSubEu->bitField0.finished) { if (playbackState->wantedParentLayer != NO_LAYER) { AudioPlayback_NoteDisable(note); if (playbackState->wantedParentLayer->channel != NULL) { @@ -249,9 +254,9 @@ void AudioPlayback_ProcessNotes(void) { scale = AudioEffects_AdsrUpdate(&playbackState->adsr); AudioEffects_NoteVibratoUpdate(note); - unk_04 = playbackState->unk_04; + playbackStatus = playbackState->status; attrs = &playbackState->attributes; - if (unk_04 == 1 || unk_04 == 2) { + if ((playbackStatus == PLAYBACK_STATUS_1) || (playbackStatus == PLAYBACK_STATUS_2)) { subAttrs.frequency = attrs->freqScale; subAttrs.velocity = attrs->velocity; subAttrs.pan = attrs->pan; @@ -317,17 +322,18 @@ void AudioPlayback_ProcessNotes(void) { } } -SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone) { - SoundFontSound* sound; +TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone) { + TunedSample* tunedSample; if (semitone < instrument->normalRangeLo) { - sound = &instrument->lowNotesSound; + tunedSample = &instrument->lowPitchTunedSample; } else if (semitone <= instrument->normalRangeHi) { - sound = &instrument->normalNotesSound; + tunedSample = &instrument->normalPitchTunedSample; } else { - sound = &instrument->highNotesSound; + tunedSample = &instrument->highPitchTunedSample; } - return sound; + + return tunedSample; } Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId) { @@ -338,18 +344,18 @@ Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId) { } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioContext.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (instId >= gAudioContext.soundFonts[fontId].numInstruments) { - gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000; + if (instId >= gAudioContext.soundFontList[fontId].numInstruments) { + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, instId, AUDIO_ERROR_INVALID_INST_ID); return NULL; } - inst = gAudioContext.soundFonts[fontId].instruments[instId]; + inst = gAudioContext.soundFontList[fontId].instruments[instId]; if (inst == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000; + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, instId, AUDIO_ERROR_NO_INST); return inst; } @@ -364,58 +370,58 @@ Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId) { } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioContext.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (drumId >= gAudioContext.soundFonts[fontId].numDrums) { - gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000; + if (drumId >= gAudioContext.soundFontList[fontId].numDrums) { + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, drumId, AUDIO_ERROR_INVALID_DRUM_SFX_ID); return NULL; } - if ((u32)gAudioContext.soundFonts[fontId].drums < 0x80000000) { + if ((u32)gAudioContext.soundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) { return NULL; } - drum = gAudioContext.soundFonts[fontId].drums[drumId]; + drum = gAudioContext.soundFontList[fontId].drums[drumId]; if (drum == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x5000000; + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, drumId, AUDIO_ERROR_NO_DRUM_SFX); } return drum; } -SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId) { - SoundFontSound* sfx; +SoundEffect* AudioPlayback_GetSoundEffect(s32 fontId, s32 sfxId) { + SoundEffect* soundEffect; if (fontId == 0xFF) { return NULL; } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioContext.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) { - gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000; + if (sfxId >= gAudioContext.soundFontList[fontId].numSfx) { + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, sfxId, AUDIO_ERROR_INVALID_DRUM_SFX_ID); return NULL; } - if ((u32)gAudioContext.soundFonts[fontId].soundEffects < 0x80000000) { + if ((u32)gAudioContext.soundFontList[fontId].soundEffects < AUDIO_RELOCATED_ADDRESS_START) { return NULL; } - sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId]; + soundEffect = &gAudioContext.soundFontList[fontId].soundEffects[sfxId]; - if (sfx == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000; + if (soundEffect == NULL) { + gAudioContext.audioErrorFlags = AUDIO_ERROR(fontId, sfxId, AUDIO_ERROR_NO_DRUM_SFX); } - if (sfx->sample == NULL) { + if (soundEffect->tunedSample.sample == NULL) { return NULL; } - return sfx; + return soundEffect; } s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value) { @@ -429,24 +435,24 @@ s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, v switch (instrumentType) { case 0: - if (index >= gAudioContext.soundFonts[fontId].numDrums) { + if (index >= gAudioContext.soundFontList[fontId].numDrums) { return -3; } - gAudioContext.soundFonts[fontId].drums[index] = value; + gAudioContext.soundFontList[fontId].drums[index] = value; break; case 1: - if (index >= gAudioContext.soundFonts[fontId].numSfx) { + if (index >= gAudioContext.soundFontList[fontId].numSfx) { return -3; } - gAudioContext.soundFonts[fontId].soundEffects[index] = *(SoundFontSound*)value; + gAudioContext.soundFontList[fontId].soundEffects[index] = *(SoundEffect*)value; break; default: - if (index >= gAudioContext.soundFonts[fontId].numInstruments) { + if (index >= gAudioContext.soundFontList[fontId].numInstruments) { return -3; } - gAudioContext.soundFonts[fontId].instruments[index] = value; + gAudioContext.soundFontList[fontId].instruments[index] = value; break; } @@ -456,7 +462,7 @@ s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, v void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { Note* note; NoteAttributes* attrs; - SequenceChannel* chan; + SequenceChannel* channel; s32 i; if (layer == NO_LAYER) { @@ -491,27 +497,27 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->pan = layer->notePan; if (layer->channel != NULL) { - chan = layer->channel; + channel = layer->channel; if (layer->unk_0A.s.bit_2 == 1) { - attrs->reverb = chan->reverb; + attrs->reverb = channel->reverb; } else { attrs->reverb = layer->unk_09; } if (layer->unk_08 == 0x80) { - attrs->unk_3 = chan->unk_10; + attrs->unk_3 = channel->unk_10; } else { attrs->unk_3 = layer->unk_08; } if (layer->unk_0A.s.bit_9 == 1) { - attrs->gain = chan->gain; + attrs->gain = channel->gain; } else { attrs->gain = 0; } - attrs->filter = chan->filter; + attrs->filter = channel->filter; if (attrs->filter != NULL) { for (i = 0; i < 8; i++) { @@ -520,18 +526,18 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->filter = attrs->filterBuf; } - attrs->unk_6 = chan->unk_20; - attrs->unk_4 = chan->unk_0F; - if (chan->seqPlayer->muted && (chan->muteFlags & MUTE_FLAGS_3)) { + attrs->unk_6 = channel->unk_20; + attrs->unk_4 = channel->unk_0F; + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { note->noteSubEu.bitField0.finished = true; } if (layer->stereo.asByte == 0) { - attrs->stereo = chan->stereo; + attrs->stereo = channel->stereo; } else { attrs->stereo = layer->stereo; } - note->playbackState.priority = chan->someOtherPriority; + note->playbackState.priority = channel->someOtherPriority; } else { attrs->stereo = layer->stereo; note->playbackState.priority = 1; @@ -542,9 +548,9 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { if (target == ADSR_STATE_RELEASE) { note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; note->playbackState.adsr.action.s.release = true; - note->playbackState.unk_04 = 2; + note->playbackState.status = PLAYBACK_STATUS_2; } else { - note->playbackState.unk_04 = 1; + note->playbackState.status = PLAYBACK_STATUS_1; note->playbackState.adsr.action.s.decay = true; if (layer->adsr.decayIndex == 0) { note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->channel->adsr.decayIndex]; @@ -570,10 +576,18 @@ void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer) { AudioPlayback_SeqLayerDecayRelease(layer, ADSR_STATE_RELEASE); } +/** + * Extract the synthetic wave to use from gWaveSamples and update corresponding frequencies + * + * @param note + * @param layer + * @param waveId the index of the type of synthetic wave to use, offset by 128 + * @return harmonicIndex, the index of the harmonic for the synthetic wave contained in gWaveSamples + */ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveId) { f32 freqScale; - f32 ratio; - u8 sampleCountIndex; + f32 freqRatio; + u8 harmonicIndex; if (waveId < 128) { waveId = 128; @@ -583,42 +597,48 @@ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveI if (layer->portamento.mode != 0 && 0.0f < layer->portamento.extent) { freqScale *= (layer->portamento.extent + 1.0f); } + + // Map frequency to the harmonic to use from gWaveSamples if (freqScale < 0.99999f) { - sampleCountIndex = 0; - ratio = 1.0465f; + harmonicIndex = 0; + freqRatio = 1.0465f; } else if (freqScale < 1.99999f) { - sampleCountIndex = 1; - ratio = 0.52325f; + harmonicIndex = 1; + freqRatio = 1.0465f / 2; } else if (freqScale < 3.99999f) { - sampleCountIndex = 2; - ratio = 0.26263f; + harmonicIndex = 2; + freqRatio = 1.0465f / 4 + 1.005E-3; } else { - sampleCountIndex = 3; - ratio = 0.13081f; + harmonicIndex = 3; + freqRatio = 1.0465f / 8 - 2.5E-6; } - layer->freqScale *= ratio; + + // Update results + layer->freqScale *= freqRatio; note->playbackState.waveId = waveId; - note->playbackState.sampleCountIndex = sampleCountIndex; + note->playbackState.harmonicIndex = harmonicIndex; - note->noteSubEu.sound.samples = &gWaveSamples[waveId - 128][sampleCountIndex * 64]; + // Save the pointer to the synthethic wave + // waveId index starts at 128, there are WAVE_SAMPLE_COUNT samples to read from + note->noteSubEu.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; - return sampleCountIndex; + return harmonicIndex; } void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer) { - s32 sampleCountIndex; - s32 waveSampleCountIndex; + s32 prevHarmonicIndex; + s32 curHarmonicIndex; s32 waveId = layer->instOrWave; if (waveId == 0xFF) { waveId = layer->channel->instOrWave; } - sampleCountIndex = note->playbackState.sampleCountIndex; - waveSampleCountIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); + prevHarmonicIndex = note->playbackState.harmonicIndex; + curHarmonicIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); - if (waveSampleCountIndex != sampleCountIndex) { - note->noteSubEu.unk_06 = waveSampleCountIndex * 4 + sampleCountIndex; + if (curHarmonicIndex != prevHarmonicIndex) { + note->noteSubEu.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; } } @@ -805,7 +825,7 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { if (instId == 0xFF) { instId = channel->instOrWave; } - noteSubEu->sound.soundFontSound = layer->sound; + noteSubEu->tunedSample = layer->tunedSample; if (instId >= 0x80 && instId < 0xC0) { noteSubEu->bitField1.isSyntheticWave = true; @@ -815,12 +835,12 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { if (noteSubEu->bitField1.isSyntheticWave) { AudioPlayback_BuildSyntheticWave(note, layer, instId); - } else if (channel->unk_DC == 1) { - playbackState->unk_84 = noteSubEu->sound.soundFontSound->sample->loop->start; + } else if (channel->startSamplePos == 1) { + playbackState->startSamplePos = noteSubEu->tunedSample->sample->loop->start; } else { - playbackState->unk_84 = channel->unk_DC; - if (playbackState->unk_84 >= noteSubEu->sound.soundFontSound->sample->loop->end) { - playbackState->unk_84 = 0; + playbackState->startSamplePos = channel->startSamplePos; + if (playbackState->startSamplePos >= noteSubEu->tunedSample->sample->loop->end) { + playbackState->startSamplePos = 0; } } @@ -969,7 +989,7 @@ void AudioPlayback_NoteInitAll(void) { note = &gAudioContext.notes[i]; note->noteSubEu = gZeroNoteSub; note->playbackState.priority = 0; - note->playbackState.unk_04 = 0; + note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.parentLayer = NO_LAYER; note->playbackState.wantedParentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; @@ -981,7 +1001,7 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.cur = 0; note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; - note->playbackState.unk_84 = 0; + note->playbackState.startSamplePos = 0; 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 ebcc9a8d1..ea5c5ed5e 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -33,7 +33,7 @@ u8 AudioSeq_ScriptReadU8(SeqScriptState* state); s16 AudioSeq_ScriptReadS16(SeqScriptState* state); u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state); void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer); -s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound); +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample); s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer); s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd); s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd); @@ -320,7 +320,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->unused = false; AudioPlayback_InitNoteLists(&channel->notePool); - channel->unk_DC = 0; + channel->startSamplePos = 0; channel->unk_E0 = 0; channel->sfxState = NULL; } @@ -582,7 +582,7 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { } while ((cmd == -1) && (layer->delay == 0)); if (cmd != PROCESS_SCRIPT_END) { - // returns `sameSound` instead of a command + // returns `sameTunedSample` instead of a command cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd); } @@ -611,20 +611,20 @@ void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) { layer->notePropertiesNeedInit = true; } -s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound) { +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample) { Note* note; if ((layer->continuousNotes == true) && (layer->bit1 == true)) { return 0; } - if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameSound == true) && + if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameTunedSample == true) && (layer->note->playbackState.parentLayer == layer)) { - if (layer->sound == NULL) { + if (layer->tunedSample == NULL) { AudioPlayback_InitSyntheticWave(layer->note, layer); } } else { - if (!sameSound) { + if (!sameTunedSample) { AudioPlayback_SeqLayerNoteDecay(layer); } @@ -815,7 +815,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { } s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { - s32 sameSound = true; + s32 sameTunedSample = true; s32 instOrWave; s32 speed; f32 temp_f14; @@ -823,10 +823,10 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { Portamento* portamento; f32 freqScale; f32 freqScale2; - SoundFontSound* sound; + TunedSample* tunedSample; Instrument* instrument; Drum* drum; - s32 pad; + SoundEffect* soundEffect; SequenceChannel* channel; SequencePlayer* seqPlayer; u8 semitone = cmd; @@ -861,15 +861,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { return PROCESS_SCRIPT_END; } - sound = &drum->sound; + tunedSample = &drum->tunedSample; layer->adsr.envelope = drum->envelope; layer->adsr.decayIndex = drum->adsrDecayIndex; if (!layer->ignoreDrumPan) { layer->pan = drum->pan; } - layer->sound = sound; - layer->freqScale = sound->tuning; + layer->tunedSample = tunedSample; + layer->freqScale = tunedSample->tuning; break; case 1: @@ -877,15 +877,16 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { layer->semitone = semitone; sfxId = (layer->transposition << 6) + semitone; - sound = AudioPlayback_GetSfx(channel->fontId, sfxId); - if (sound == NULL) { + soundEffect = AudioPlayback_GetSoundEffect(channel->fontId, sfxId); + if (soundEffect == NULL) { layer->stopSomething = true; layer->delay2 = layer->delay + 1; return PROCESS_SCRIPT_END; } - layer->sound = sound; - layer->freqScale = sound->tuning; + tunedSample = &soundEffect->tunedSample; + layer->tunedSample = tunedSample; + layer->freqScale = tunedSample->tuning; break; default: @@ -909,15 +910,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { vel = (semitone > layer->portamentoTargetNote) ? semitone : layer->portamentoTargetNote; if (instrument != NULL) { - sound = AudioPlayback_InstrumentGetSound(instrument, vel); - sameSound = (layer->sound == sound); - layer->sound = sound; - tuning = sound->tuning; + tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, vel); + sameTunedSample = (layer->tunedSample == tunedSample); + layer->tunedSample = tunedSample; + tuning = tunedSample->tuning; } else { - layer->sound = NULL; + layer->tunedSample = NULL; tuning = 1.0f; if (instOrWave >= 0xC0) { - layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + layer->tunedSample = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].tunedSample; } } @@ -971,15 +972,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { } if (instrument != NULL) { - sound = AudioPlayback_InstrumentGetSound(instrument, semitone); - sameSound = (sound == layer->sound); - layer->sound = sound; - layer->freqScale = gPitchFrequencies[semitone2] * sound->tuning; + tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, semitone); + sameTunedSample = (tunedSample == layer->tunedSample); + layer->tunedSample = tunedSample; + layer->freqScale = gPitchFrequencies[semitone2] * tunedSample->tuning; } else { - layer->sound = NULL; + layer->tunedSample = NULL; layer->freqScale = gPitchFrequencies[semitone2]; if (instOrWave >= 0xC0) { - layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + layer->tunedSample = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].tunedSample; } } break; @@ -989,8 +990,8 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { layer->freqScale *= layer->bend; if (layer->delay == 0) { - if (layer->sound != NULL) { - time = layer->sound->sample->loop->end; + if (layer->tunedSample != NULL) { + time = layer->tunedSample->sample->loop->end; } else { time = 0.0f; } @@ -1020,7 +1021,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { } } } - return sameSound; + return sameTunedSample; } s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { @@ -1571,7 +1572,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->unk_0F = 0; channel->unk_20 = 0; channel->bookOffset = 0; - channel->unk_DC = 0; + channel->startSamplePos = 0; channel->unk_E0 = 0; channel->freqScale = 1.0f; break; @@ -1659,7 +1660,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xBD: // channel: - channel->unk_DC = cmdArgs[0]; + channel->startSamplePos = cmdArgs[0]; break; case 0xBE: // channel: @@ -1672,10 +1673,10 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { } break; - case 0xA0: // channel: - case 0xA1: // channel: - case 0xA2: // channel: - case 0xA3: // channel: + case 0xA0: // channel: read from SfxChannelState using arg + case 0xA1: // channel: read from SfxChannelState using unk_22 + case 0xA2: // channel: write to SfxChannelState using arg + case 0xA3: // channel: write to SfxChannelState using unk_22 if ((cmd == 0xA0) || (cmd == 0xA2)) { cmdArgU16 = (u16)cmdArgs[0]; } else { @@ -1958,15 +1959,15 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { cmd = AudioSeq_ScriptReadU8(seqScript); temp = AudioSeq_ScriptReadS16(seqScript); switch (cmd) { - case 0: - case 1: - if (seqPlayer->state != 2) { + case SEQPLAYER_STATE_0: + case SEQPLAYER_STATE_1: + if (seqPlayer->state != SEQPLAYER_STATE_2) { seqPlayer->fadeTimerUnkEu = temp; seqPlayer->state = cmd; } break; - case 2: + case SEQPLAYER_STATE_2: seqPlayer->fadeTimer = temp; seqPlayer->state = cmd; seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; @@ -1977,11 +1978,11 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { case 0xDB: // seqPlayer: set volume value = AudioSeq_ScriptReadU8(seqScript); switch (seqPlayer->state) { - case 1: - seqPlayer->state = 0; + case SEQPLAYER_STATE_1: + seqPlayer->state = SEQPLAYER_STATE_0; seqPlayer->fadeVolume = 0.0f; // fallthrough - case 0: + case SEQPLAYER_STATE_0: seqPlayer->fadeTimer = seqPlayer->fadeTimerUnkEu; if (seqPlayer->fadeTimerUnkEu != 0) { seqPlayer->fadeVelocity = @@ -1991,7 +1992,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { } break; - case 2: + case SEQPLAYER_STATE_2: break; } break; @@ -2102,7 +2103,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { cmd = AudioSeq_ScriptReadU8(seqScript); if (cmd == 0xFF) { cmd = seqPlayer->playerIndex; - if (seqPlayer->state == 2) { + if (seqPlayer->state == SEQPLAYER_STATE_2) { break; } } @@ -2224,7 +2225,7 @@ void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) { AudioSeq_SequencePlayerDisable(seqPlayer); seqPlayer->stopScript = false; seqPlayer->delay = 0; - seqPlayer->state = 1; + seqPlayer->state = SEQPLAYER_STATE_1; seqPlayer->fadeTimer = 0; seqPlayer->fadeTimerUnkEu = 0; seqPlayer->tempoAcc = 0; 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 380ef6f0b..1c14d63bb 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -53,6 +53,7 @@ * - Seaweed */ +#include "prevent_bss_reordering.h" #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" 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 73c5e32c6..b699cd9af 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,7 +4,6 @@ * Description: Breakable Pot With Grass */ -#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3699d0100..37515bb05 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3546,8 +3546,8 @@ 0x8018A808:("func_8018A808",), 0x8018ACC4:("func_8018ACC4",), 0x8018AE34:("func_8018AE34",), - 0x8018B0F0:("func_8018B0F0",), - 0x8018B10C:("func_8018B10C",), + 0x8018B0F0:("AudioHeap_CalculateAdsrDecay",), + 0x8018B10C:("AudioHeap_InitAdsrDecayTable",), 0x8018B250:("AudioHeap_ResetLoadStatus",), 0x8018B318:("AudioHeap_DiscardFont",), 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), @@ -3560,16 +3560,16 @@ 0x8018B640:("AudioHeap_AllocZeroed",), 0x8018B69C:("AudioHeap_TestAlloc",), 0x8018B6E8:("AudioHeap_Alloc",), - 0x8018B740:("AudioHeap_AllocPoolInit",), - 0x8018B768:("AudioHeap_ClearPersistentCache",), - 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B740:("AudioHeap_InitPool",), + 0x8018B768:("AudioHeap_InitPersistentCache",), + 0x8018B77C:("AudioHeap_InitTemporaryCache",), 0x8018B7AC:("AudioHeap_ResetPool",), - 0x8018B7BC:("AudioHeap_PopCache",), + 0x8018B7BC:("AudioHeap_PopPersistentCache",), 0x8018B8FC:("AudioHeap_InitMainPool",), 0x8018B95C:("AudioHeap_InitSessionPool",), 0x8018B9E0:("AudioHeap_InitCachePool",), - 0x8018BA64:("AudioHeap_InitPersistentCache",), - 0x8018BB28:("AudioHeap_InitTemporaryCache",), + 0x8018BA64:("AudioHeap_InitPersistentPoolsAndCaches",), + 0x8018BB28:("AudioHeap_InitTemporaryPoolsAndCaches",), 0x8018BBEC:("AudioHeap_AllocCached",), 0x8018C380:("AudioHeap_SearchCaches",), 0x8018C3D8:("AudioHeap_SearchRegularCaches",), @@ -3645,7 +3645,7 @@ 0x80190B08:("AudioLoad_ProcessLoads",), 0x80190B38:("AudioLoad_SetDmaHandler",), 0x80190B44:("AudioLoad_SetUnusedHandler",), - 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190B50:("AudioLoad_InitSoundFont",), 0x80190BB0:("AudioLoad_Init",), 0x80190F50:("AudioLoad_InitSlowLoads",), 0x80190F64:("AudioLoad_SlowLoadSample",), @@ -3731,10 +3731,10 @@ 0x80194E60:("AudioPlayback_NoteInit",), 0x80194F20:("AudioPlayback_NoteDisable",), 0x80194F84:("AudioPlayback_ProcessNotes",), - 0x801954CC:("AudioPlayback_InstrumentGetSound",), + 0x801954CC:("AudioPlayback_GetInstrumentTunedSample",), 0x80195508:("AudioPlayback_GetInstrumentInner",), 0x801955DC:("AudioPlayback_GetDrum",), - 0x801956C0:("AudioPlayback_GetSfx",), + 0x801956C0:("AudioPlayback_GetSoundEffect",), 0x801957B4:("AudioPlayback_SetFontInstrument",), 0x801958F8:("AudioPlayback_SeqLayerDecayRelease",), 0x80195C40:("AudioPlayback_SeqLayerNoteDecay",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index dffd1bd19..86ab55c72 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -3814,7 +3814,7 @@ 0x801E10B0:("jtbl_801E10B0","UNK_PTR","",0x4), 0x801E10C4:("jtbl_801E10C4","UNK_PTR","",0x4), 0x801E1100:("gAudioTatumInit","s16","[2]",0x4), - 0x801E1104:("gAudioContextInitSizes","AudioContextInitSizes","",0xC), + 0x801E1104:("gAudioHeapInitSizes","AudioHeapInitSizes","",0xC), 0x801E1110:("sGameOverTimer","UNK_TYPE2","",0x2), 0x801E1120:("jtbl_801E1120","UNK_PTR","",0x4), 0x801E1180:("gSoundFontTable","UNK_TYPE2","",0x2), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 991b30fdf..db8f76ef7 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3076,16 +3076,16 @@ asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_All asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 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/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_InitPool.s,AudioHeap_InitPool,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,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_PopPersistentCache.s,AudioHeap_PopPersistentCache,0x8018B7BC,0x50 asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 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_InitPersistentPoolsAndCaches.s,AudioHeap_InitPersistentPoolsAndCaches,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryPoolsAndCaches.s,AudioHeap_InitTemporaryPoolsAndCaches,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/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 @@ -3161,7 +3161,7 @@ asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoad 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_InitSoundFont.s,AudioLoad_InitSoundFont,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 @@ -3247,10 +3247,10 @@ asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,Audi asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30 asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19 asm/non_matchings/code/audio_playback/AudioPlayback_ProcessNotes.s,AudioPlayback_ProcessNotes,0x80194F84,0x152 -asm/non_matchings/code/audio_playback/AudioPlayback_InstrumentGetSound.s,AudioPlayback_InstrumentGetSound,0x801954CC,0xF +asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentTunedSample.s,AudioPlayback_GetInstrumentTunedSample,0x801954CC,0xF asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentInner.s,AudioPlayback_GetInstrumentInner,0x80195508,0x35 asm/non_matchings/code/audio_playback/AudioPlayback_GetDrum.s,AudioPlayback_GetDrum,0x801955DC,0x39 -asm/non_matchings/code/audio_playback/AudioPlayback_GetSfx.s,AudioPlayback_GetSfx,0x801956C0,0x3D +asm/non_matchings/code/audio_playback/AudioPlayback_GetSoundEffect.s,AudioPlayback_GetSoundEffect,0x801956C0,0x3D asm/non_matchings/code/audio_playback/AudioPlayback_SetFontInstrument.s,AudioPlayback_SetFontInstrument,0x801957B4,0x51 asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerDecayRelease.s,AudioPlayback_SeqLayerDecayRelease,0x801958F8,0xD2 asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerNoteDecay.s,AudioPlayback_SeqLayerNoteDecay,0x80195C40,0x8 From 6d6304d1a0602e2cdaa0a0d9e6f148791ee51794 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 12:40:40 -0700 Subject: [PATCH 39/73] Gamestates Cleanup (#1047) * Setup * ConsoleLogo * TitleSetup * MapSelect * FileSelect * Daytelop * Save file * PreNMI * Final cleanup and format * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * DayTelop * Split off setup * split of prenmi * readd SET * shorten some gamestate member names * Add comment about init * Update include/z64.h Co-authored-by: EllipticEllipsis * Small cleanup of comments * PR Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: EllipticEllipsis --- include/functions.h | 15 +- include/macros.h | 17 +- include/z64.h | 10 +- include/z64save.h | 14 +- include/z_prenmi.h | 15 ++ include/z_title_setup.h | 13 ++ src/code/game.c | 12 +- src/code/graph.c | 30 +-- src/code/title_setup.c | 26 ++- src/code/z_demo.c | 14 +- src/code/z_game_dlftbls.c | 11 +- src/code/z_prenmi.c | 49 ++--- src/code/z_sram_NES.c | 192 +++++++++--------- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 8 +- .../gamestates/ovl_daytelop/z_daytelop.c | 45 ++-- .../gamestates/ovl_daytelop/z_daytelop.h | 8 +- .../ovl_file_choose/z_file_choose.h | 8 +- .../ovl_file_choose/z_file_choose_NES.c | 16 +- .../gamestates/ovl_opening/z_opening.c | 44 ++-- .../gamestates/ovl_opening/z_opening.h | 8 +- src/overlays/gamestates/ovl_select/z_select.c | 19 +- src/overlays/gamestates/ovl_select/z_select.h | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 78 ++++--- src/overlays/gamestates/ovl_title/z_title.h | 8 +- tools/disasm/functions.txt | 62 +++--- tools/sizes/code_functions.csv | 12 +- 26 files changed, 369 insertions(+), 369 deletions(-) create mode 100644 include/z_prenmi.h create mode 100644 include/z_title_setup.h diff --git a/include/functions.h b/include/functions.h index bfcb5f562..f73f95a96 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1968,12 +1968,6 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); void func_80128B74(PlayState* play, Player* player, s32 limbIndex); void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); -void PreNMI_Stop(PreNMIContext* prenmiCtx); -void PreNMI_Update(PreNMIContext* prenmiCtx); -void PreNMI_Draw(PreNMIContext* prenmiCtx); -void PreNMI_Main(PreNMIContext* prenmiCtx); -void PreNMI_Destroy(PreNMIContext* prenmiCtx); -void PreNMI_Init(PreNMIContext* prenmiCtx); f32 Quake_Random(void); void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation); s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake); @@ -2664,10 +2658,7 @@ void AudioMgr_HandlePRENMI(AudioMgr* audioMgr); void AudioMgr_ThreadEntry(void* arg); void AudioMgr_Unlock(AudioMgr* audioMgr); void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr); -void TitleSetup_GameStateResetContext(void); -void TitleSetup_InitImpl(GameState* gameState); -void TitleSetup_Destroy(GameState* gameState); -void TitleSetup_Init(GameState* gameState); + void Game_UpdateFramerateVariables(s32 divisor); void Game_SetFramerateDivisor(GameState* gameState, s32 divisor); void GameState_SetFBFilter(Gfx** gfx, u32 arg1); @@ -2682,8 +2673,8 @@ void GameState_InitArena(GameState* gameState, size_t size); void GameState_Realloc(GameState* gameState, size_t size); void GameState_Init(GameState* gameState, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); void GameState_Destroy(GameState* gameState); -GameStateFunc GameState_GetNextStateInit(GameState* gameState); -size_t GameState_GetNextStateSize(GameState* gameState); +GameStateFunc GameState_GetInit(GameState* gameState); +size_t GameState_GetSize(GameState* gameState); u32 GameState_IsRunning(GameState* gameState); s32 GameState_GetArenaSize(GameState* gameState); s32 func_80173B48(GameState* gameState); diff --git a/include/macros.h b/include/macros.h index 996be52ca..ad963153f 100644 --- a/include/macros.h +++ b/include/macros.h @@ -24,9 +24,20 @@ #define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) -#define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ - (curState)->nextGameStateInit = (GameStateFunc)newInit; \ - (curState)->nextGameStateSize = sizeof(newStruct) +#define STOP_GAMESTATE(curState) \ + do { \ + GameState* state = curState; \ + \ + state->running = false; \ + } while(0) + +#define SET_NEXT_GAMESTATE(curState, nextInit, nextSize) \ + do { \ + GameState* state = curState; \ + \ + (state)->init = nextInit; \ + (state)->size = nextSize; \ + } while (0) #define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first) diff --git a/include/z64.h b/include/z64.h index 4128a2b38..197396216 100644 --- a/include/z64.h +++ b/include/z64.h @@ -867,8 +867,8 @@ typedef struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; /* 0x08 */ GameStateFunc destroy; - /* 0x0C */ GameStateFunc nextGameStateInit; - /* 0x10 */ size_t nextGameStateSize; + /* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load. + /* 0x10 */ size_t size; /* 0x14 */ Input input[4]; /* 0x74 */ TwoHeadArena heap; /* 0x84 */ GameAlloc alloc; @@ -880,12 +880,6 @@ typedef struct GameState { /* 0xA3 */ u8 unk_A3; } GameState; // size = 0xA4 -typedef struct PreNMIContext { - /* 0x00 */ GameState state; - /* 0xA4 */ u32 timer; - /* 0xA8 */ UNK_TYPE4 unkA8; -} PreNMIContext; // size = 0xAC - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; diff --git a/include/z64save.h b/include/z64save.h index 1ff39ec92..12b525f4d 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -7,7 +7,7 @@ struct GameState; struct PlayState; -struct FileChooseContext; +struct FileSelectState; // TODO: properly name DOWN, RETURN and TOP typedef enum RespawnMode { @@ -398,15 +398,15 @@ 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 Sram_OpenSave(struct FileSelectState* fileSelect, 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_801457CC(struct FileSelectState* fileSelect, SramContext* sramCtx); +void func_80146580(struct FileSelectState* fileSelect, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileSelectState* fileSelect, SramContext* sramCtx); +void Sram_InitSave(struct FileSelectState* fileSelect, 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_Alloc(struct GameState* gameState, SramContext* sramCtx); void Sram_SaveSpecialEnterClockTown(struct PlayState* play); void Sram_SaveSpecialNewDay(struct PlayState* play); void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); diff --git a/include/z_prenmi.h b/include/z_prenmi.h new file mode 100644 index 000000000..1aa1e6f99 --- /dev/null +++ b/include/z_prenmi.h @@ -0,0 +1,15 @@ +#ifndef Z64_PRENMI_H +#define Z64_PRENMI_H + +#include "global.h" + +void PreNMI_Destroy(GameState* thisx); +void PreNMI_Init(GameState* thisx); + +typedef struct { + /* 0x00 */ GameState state; + /* 0xA4 */ u32 timer; + /* 0xA8 */ UNK_TYPE4 unkA8; +} PreNMIState; // size = 0xAC + +#endif diff --git a/include/z_title_setup.h b/include/z_title_setup.h new file mode 100644 index 000000000..685b87c79 --- /dev/null +++ b/include/z_title_setup.h @@ -0,0 +1,13 @@ +#ifndef Z64_TITLE_SETUP_H +#define Z64_TITLE_SETUP_H + +#include "global.h" + +void Setup_Destroy(GameState* gameState); +void Setup_Init(GameState* gameState); + +typedef struct { + /* 0x00 */ GameState state; +} SetupState; // size = 0xA4 + +#endif diff --git a/src/code/game.c b/src/code/game.c index 84743b8c5..da21de17f 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -200,8 +200,8 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g gfxCtx->viConfigFeatures = gViConfigFeatures; gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; - gameState->nextGameStateInit = NULL; - gameState->nextGameStateSize = 0; + gameState->init = NULL; + gameState->size = 0; { s32 requiredScopeTemp; @@ -242,12 +242,12 @@ void GameState_Destroy(GameState* gameState) { GameAlloc_Cleanup(&gameState->alloc); } -GameStateFunc GameState_GetNextStateInit(GameState* gameState) { - return gameState->nextGameStateInit; +GameStateFunc GameState_GetInit(GameState* gameState) { + return gameState->init; } -size_t GameState_GetNextStateSize(GameState* gameState) { - return gameState->nextGameStateSize; +size_t GameState_GetSize(GameState* gameState) { + return gameState->size; } u32 GameState_IsRunning(GameState* gameState) { diff --git a/src/code/graph.c b/src/code/graph.c index 481aa1da0..654d2c5f7 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -6,6 +6,7 @@ #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_select/z_select.h" #include "overlays/gamestates/ovl_title/z_title.h" +#include "z_title_setup.h" FaultAddrConvClient sGraphFaultAddrConvClient; FaultClient sGraphFaultClient; @@ -63,44 +64,45 @@ void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { } GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { - GameStateFunc gameStateInit = GameState_GetNextStateInit(gameState); + GameStateFunc gameStateInit = GameState_GetInit(gameState); - if (gameStateInit == (GameStateFunc)TitleSetup_Init) { + if (gameStateInit == Setup_Init) { return &gGameStateOverlayTable[0]; } - if (gameStateInit == (GameStateFunc)MapSelect_Init) { + if (gameStateInit == MapSelect_Init) { return &gGameStateOverlayTable[1]; } - if (gameStateInit == (GameStateFunc)Title_Init) { + if (gameStateInit == ConsoleLogo_Init) { return &gGameStateOverlayTable[2]; } - if (gameStateInit == (GameStateFunc)Play_Init) { + if (gameStateInit == Play_Init) { return &gGameStateOverlayTable[3]; } - if (gameStateInit == (GameStateFunc)Opening_Init) { + if (gameStateInit == TitleSetup_Init) { return &gGameStateOverlayTable[4]; } - if (gameStateInit == (GameStateFunc)FileChoose_Init) { + if (gameStateInit == FileSelect_Init) { return &gGameStateOverlayTable[5]; } - if (gameStateInit == (GameStateFunc)Daytelop_Init) { + if (gameStateInit == DayTelop_Init) { return &gGameStateOverlayTable[6]; } + return NULL; } void* Graph_FaultAddrConvFunc(void* address, void* param) { uintptr_t addr = address; - GameStateOverlay* gamestateOvl = &gGameStateOverlayTable[0]; + GameStateOverlay* gameStateOvl = &gGameStateOverlayTable[0]; uintptr_t ramConv; void* ramStart; uintptr_t diff; s32 i; - for (i = 0; i < graphNumGameStates; i++, gamestateOvl++) { - diff = VRAM_PTR_SIZE(gamestateOvl); - ramStart = gamestateOvl->loadedRamAddr; - ramConv = (uintptr_t)gamestateOvl->vramStart - (uintptr_t)ramStart; + for (i = 0; i < graphNumGameStates; i++, gameStateOvl++) { + diff = VRAM_PTR_SIZE(gameStateOvl); + ramStart = gameStateOvl->loadedRamAddr; + ramConv = (uintptr_t)gameStateOvl->vramStart - (uintptr_t)ramStart; if (ramStart != NULL) { if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) { @@ -235,7 +237,7 @@ void Graph_UpdateGame(GameState* gameState) { } /** - * Run the gamestate logic, then finalize the gfx buffer + * Run the game state logic, then finalize the gfx buffer * and run the graphics task for this frame. */ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 4be91d2e8..dad3c6458 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -1,7 +1,7 @@ -#include "global.h" +#include "z_title_setup.h" #include "overlays/gamestates/ovl_title/z_title.h" -void TitleSetup_GameStateResetContext(void) { +void Setup_SetRegs(void) { XREG(2) = 0; XREG(10) = 0x1A; XREG(11) = 0x14; @@ -45,23 +45,21 @@ void TitleSetup_GameStateResetContext(void) { YREG(43) = 0xB1; } -void TitleSetup_InitImpl(GameState* gameState) { +void Setup_InitImpl(SetupState* this) { func_80185908(); SaveContext_Init(); - TitleSetup_GameStateResetContext(); + Setup_SetRegs(); - gameState->running = 0; - -setNextGamestate - :; // This label is probably a leftover of a debug ifdef, it's essential to not have gameState->running reordered! - SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState)); } -void TitleSetup_Destroy(GameState* gameState) { - ; +void Setup_Destroy(GameState* thisx) { } -void TitleSetup_Init(GameState* gameState) { - gameState->destroy = TitleSetup_Destroy; - TitleSetup_InitImpl(gameState); +void Setup_Init(GameState* thisx) { + SetupState* this = (SetupState*)thisx; + + this->state.destroy = Setup_Destroy; + Setup_InitImpl(this); } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 8923669a7..4b571cadd 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -126,12 +126,11 @@ void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { /* Start of command handling section */ // Command 0x96: Miscellaneous commands. -void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { static u16 D_801BB15C = 0xFFFF; - Player* player = GET_PLAYER(play2); - PlayState* play = play2; - u8 isStartFrame = false; + Player* player = GET_PLAYER(play); f32 progress; + u8 isStartFrame = false; SceneTableEntry* loadedScene; if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { @@ -346,11 +345,8 @@ void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* gSaveContext.save.day = 9; - { - GameState* gameState = &play->state; - gameState->running = false; - } - SET_NEXT_GAMESTATE(&play->state, Daytelop_Init, DaytelopContext); + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); Sram_SaveSpecialNewDay(play); break; diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c index a79c732d8..11d390a28 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -4,6 +4,7 @@ #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_select/z_select.h" #include "overlays/gamestates/ovl_title/z_title.h" +#include "z_title_setup.h" #define GAMESTATE_OVERLAY(name, init, destroy, size) \ { \ @@ -14,13 +15,13 @@ { NULL, 0, 0, NULL, NULL, 0, init, destroy, 0, 0, 0, size } GameStateOverlay gGameStateOverlayTable[] = { - GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), + GAMESTATE_OVERLAY_INTERNAL(Setup_Init, Setup_Destroy, sizeof(SetupState)), GAMESTATE_OVERLAY(select, MapSelect_Init, MapSelect_Destroy, sizeof(MapSelectState)), - GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), + GAMESTATE_OVERLAY(title, ConsoleLogo_Init, ConsoleLogo_Destroy, sizeof(ConsoleLogoState)), GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Destroy, sizeof(PlayState)), - GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)), - GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)), - GAMESTATE_OVERLAY(daytelop, Daytelop_Init, Daytelop_Destroy, sizeof(DaytelopContext)), + GAMESTATE_OVERLAY(opening, TitleSetup_Init, TitleSetup_Destroy, sizeof(TitleSetupState)), + GAMESTATE_OVERLAY(file_choose, FileSelect_Init, FileSelect_Destroy, sizeof(FileSelectState)), + GAMESTATE_OVERLAY(daytelop, DayTelop_Init, DayTelop_Destroy, sizeof(DayTelopState)), }; s32 graphNumGameStates = ARRAY_COUNT(gGameStateOverlayTable); diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index 0e9c435c6..e0381153a 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -1,23 +1,22 @@ -#include "global.h" +#include "z_prenmi.h" -void PreNMI_Stop(PreNMIContext* prenmiCtx) { - prenmiCtx->state.running = 0; - prenmiCtx->state.nextGameStateInit = NULL; - prenmiCtx->state.nextGameStateSize = 0; +void PreNMI_Stop(PreNMIState* this) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, NULL, 0); } -void PreNMI_Update(PreNMIContext* prenmiCtx) { - if (prenmiCtx->timer == 0) { +void PreNMI_Update(PreNMIState* this) { + if (this->timer == 0) { ViConfig_UpdateVi(1); - PreNMI_Stop(prenmiCtx); + PreNMI_Stop(this); return; } - prenmiCtx->timer--; + this->timer--; } -void PreNMI_Draw(PreNMIContext* prenmiCtx) { - GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx; +void PreNMI_Draw(PreNMIState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; func_8012CF0C(gfxCtx, true, true, 0, 0, 0); @@ -26,26 +25,30 @@ void PreNMI_Draw(PreNMIContext* prenmiCtx) { func_8012C470(gfxCtx); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); - gDPFillRectangle(POLY_OPA_DISP++, 0, prenmiCtx->timer + 100, SCREEN_WIDTH - 1, prenmiCtx->timer + 100); + gDPFillRectangle(POLY_OPA_DISP++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100); CLOSE_DISPS(gfxCtx); } -void PreNMI_Main(PreNMIContext* prenmiCtx) { - PreNMI_Update(prenmiCtx); - PreNMI_Draw(prenmiCtx); +void PreNMI_Main(GameState* thisx) { + PreNMIState* this = (PreNMIState*)thisx; - prenmiCtx->state.unk_A3 = 1; + PreNMI_Update(this); + PreNMI_Draw(this); + + this->state.unk_A3 = 1; } -void PreNMI_Destroy(PreNMIContext* prenmiCtx) { +void PreNMI_Destroy(GameState* thisx) { } -void PreNMI_Init(PreNMIContext* prenmiCtx) { - prenmiCtx->state.main = (GameStateFunc)PreNMI_Main; - prenmiCtx->state.destroy = (GameStateFunc)PreNMI_Destroy; - prenmiCtx->timer = 30; - prenmiCtx->unkA8 = 10; +void PreNMI_Init(GameState* thisx) { + PreNMIState* this = (PreNMIState*)thisx; - Game_SetFramerateDivisor(&prenmiCtx->state, 1); + this->state.main = PreNMI_Main; + this->state.destroy = PreNMI_Destroy; + this->timer = 30; + this->unkA8 = 10; + + Game_SetFramerateDivisor(&this->state, 1); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 781b623b2..ed7945ec3 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -918,7 +918,7 @@ u16 D_801C6A58[] = { ENTRANCE(IKANA_CANYON, 4), ENTRANCE(STONE_TOWER, 3), }; -void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { +void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { s32 i; s32 pad; s32 phi_t1; @@ -930,7 +930,7 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { if (gSaveContext.fileNum == 0xFF) { func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); - } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + } else if (fileSelect->unk_2446A[gSaveContext.fileNum] != 0) { phi_t1 = gSaveContext.fileNum + 2; phi_t1 *= 2; @@ -1079,8 +1079,8 @@ void func_80145698(SramContext* sramCtx) { // Verifies save and use backup if corrupted? #ifdef NON_EQUIVALENT -void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { + FileSelectState* fileSelect = fileSelect2; u16 sp7A; // u16 sp78; u16 sp76; @@ -1119,7 +1119,7 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } if (sp76 < 2) { - fileChooseCtx->unk_24468[sp76] = 0; + fileSelect->unk_24468[sp76] = 0; if (phi_s2) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); @@ -1157,34 +1157,33 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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]; + fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; } - if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { - fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + if (!CHECK_NEWF(fileSelect->newf[sp76])) { + fileSelect->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]; + fileSelect->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.defenseHearts; - 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); + fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[sp76] = gSaveContext.save.time; + fileSelect->unk_24460[sp76] = gSaveContext.save.day; + fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->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); + fileSelect->maskCount[sp76] = phi_a0; + fileSelect->heartPieceCount[sp76] = ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); } if (sp6E == 1) { @@ -1209,9 +1208,9 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } } else if (sp76 < 4) { - fileChooseCtx->unk_24468[sp76] = 0; + fileSelect->unk_24468[sp76] = 0; - if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (!CHECK_NEWF(fileSelect->newf2[(s32)sp76])) { // TODO: Needed? if (phi_s2) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, @@ -1251,34 +1250,34 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { 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]; + fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; } - if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { - fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + if (!CHECK_NEWF(fileSelect->newf[sp76])) { + fileSelect->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]; + fileSelect->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.defenseHearts; - 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); + fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[sp76] = gSaveContext.save.time; + fileSelect->unk_24460[sp76] = gSaveContext.save.day; + fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->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] = + fileSelect->maskCount[sp76] = phi_a0; + fileSelect->heartPieceCount[sp76] = ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); } @@ -1342,14 +1341,14 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") #endif -void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_80146580(FileSelectState* fileSelect2, SramContext* sramCtx, s32 fileNum) { + FileSelectState* fileSelect = fileSelect2; s32 pad; if (gSaveContext.unk_3F3F) { - if (fileChooseCtx->unk_2446A[fileNum]) { + if (fileSelect->unk_2446A[fileNum]) { func_80147314(sramCtx, fileNum); - fileChooseCtx->unk_2446A[fileNum] = 0; + fileSelect->unk_2446A[fileNum] = 0; } bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); @@ -1361,30 +1360,30 @@ void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 #ifdef NON_MATCHING // v0/v1 -void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_80146628(FileSelectState* fileSelect2, SramContext* sramCtx) { + FileSelectState* fileSelect = fileSelect2; 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; + if (fileSelect->unk_2446A[fileSelect->unk_2448E]) { + func_80147414(sramCtx, fileSelect->unk_2448E, fileSelect->fileNum); + fileSelect->unk_24410[fileSelect->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]; + fileSelect->unk_24424[fileSelect->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.defenseHearts; - 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; + fileSelect->unk_24438[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileSelect->unk_24440[fileSelect->fileNum] = gSaveContext.save.playerData.health; + fileSelect->unk_24456[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_2444C[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->unk_2445C[fileSelect->fileNum] = gSaveContext.save.time; + fileSelect->unk_24464[fileSelect->fileNum] = gSaveContext.save.day; + fileSelect->unk_2446A[fileSelect->fileNum] = gSaveContext.save.isOwlSave; + fileSelect->unk_24470[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); - fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + fileSelect->unk_24476[fileSelect->fileNum] = (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { @@ -1393,41 +1392,39 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; - fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = - (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + fileSelect->unk_2447A[fileSelect->fileNum] = maskCount; + fileSelect->unk_2447E[fileSelect->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]); + func_80185968(sramCtx->saveBuf, D_801C67C8[fileSelect->unk_2448E * 2], D_801C67F0[fileSelect->unk_2448E * 2]); if (1) {} - func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], - D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileSelect->unk_2448E * 2 + 1], + D_801C67F0[fileSelect->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; + fileSelect->unk_2440C[fileSelect->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]; + fileSelect->unk_24414[fileSelect->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.defenseHearts; - 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; + fileSelect->healthCapacity[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[fileSelect->fileNum] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[fileSelect->fileNum] = gSaveContext.save.time; + fileSelect->unk_24460[fileSelect->fileNum] = gSaveContext.save.day; + fileSelect->unk_24468[fileSelect->fileNum] = gSaveContext.save.isOwlSave; + fileSelect->rupees[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); - fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + fileSelect->unk_24474[fileSelect->fileNum] = (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { @@ -1436,8 +1433,8 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; - fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + fileSelect->maskCount[fileSelect->fileNum] = maskCount; + fileSelect->heartPieceCount[fileSelect->fileNum] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; } @@ -1448,21 +1445,20 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") #endif -void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { +void Sram_InitSave(FileSelectState* fileSelect2, SramContext* sramCtx) { s32 phi_v0; u16 i; - FileChooseContext* fileChooseCtx = fileChooseCtx2; + FileSelectState* fileSelect = fileSelect2; s16 maskCount; if (gSaveContext.unk_3F3F) { Sram_InitNewSave(); - if (fileChooseCtx->unk_24480 == 0) { + if (fileSelect->unk_24480 == 0) { gSaveContext.save.cutscene = 0xFFF0; } 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]; + gSaveContext.save.playerData.playerName[phi_v0] = fileSelect->unk_24414[fileSelect->unk_24480][phi_v0]; } gSaveContext.save.playerData.newf[0] = 'Z'; @@ -1478,24 +1474,24 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { - fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + fileSelect->newf[fileSelect->unk_24480][i] = gSaveContext.save.playerData.newf[i]; } - fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[fileSelect->unk_24480] = gSaveContext.save.playerData.deaths; for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + fileSelect->unk_24414[fileSelect->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; } - 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.defenseHearts; - 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); + fileSelect->healthCapacity[fileSelect->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[fileSelect->unk_24480] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[fileSelect->unk_24480] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->unk_24480] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[fileSelect->unk_24480] = gSaveContext.save.time; + fileSelect->unk_24460[fileSelect->unk_24480] = gSaveContext.save.day; + fileSelect->unk_24468[fileSelect->unk_24480] = gSaveContext.save.isOwlSave; + fileSelect->rupees[fileSelect->unk_24480] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24474[fileSelect->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); for (i = 0, maskCount = 0; i < 24; i++) { if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { @@ -1503,8 +1499,8 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; - fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + fileSelect->maskCount[fileSelect->unk_24480] = maskCount; + fileSelect->heartPieceCount[fileSelect->unk_24480] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; } @@ -1526,9 +1522,9 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { func_801A3D98(gSaveContext.options.audioSetting); } -void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { +void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { if (gSaveContext.unk_3F3F) { - sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->saveBuf = THA_AllocEndAlign16(&gameState->heap, SAVE_BUFFER_SIZE); sramCtx->status = 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 6129a699a..f0f94a494 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -315,12 +315,8 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; - { - GameState* state = &play->state; - state->running = false; - } - SET_NEXT_GAMESTATE(&play->state, Daytelop_Init, DaytelopContext); - if (this && this && this) {} + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); this->unk_144 = 1; gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index eac0b8f59..ad5230253 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -63,7 +63,7 @@ UNK_TYPE D_808158E0[] = { 0x00000001, 0x00000000, }; -void Daytelop_Update(DaytelopContext* this, GameState* gameState) { +void DayTelop_Update(DayTelopState* this, GameState* thisx) { static u8 D_80815FF0 = 0; s16 new_var; u8 temp_v0_2; @@ -77,12 +77,9 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { gSaveContext.save.day = 1; } - { - GameState* state = &this->state; - state->running = 0; - } + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); - SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { @@ -126,7 +123,7 @@ TexturePtr sHoursLeftTextures[] = { gDaytelop24HoursNESTex, }; -void Daytelop_Draw(DaytelopContext* this) { +void DayTelop_Draw(DayTelopState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -187,11 +184,11 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); } - CLOSE_DISPS(this->state.gfxCtx); + CLOSE_DISPS(gfxCtx); } -void Daytelop_Main(GameState* thisx) { - DaytelopContext* this = (DaytelopContext*)thisx; +void DayTelop_Main(GameState* thisx) { + DayTelopState* this = (DayTelopState*)thisx; func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); @@ -200,18 +197,18 @@ void Daytelop_Main(GameState* thisx) { gSPSegment(POLY_OPA_DISP++, 0x0C, this->gameoverStaticFile); CLOSE_DISPS(this->state.gfxCtx); - Daytelop_Draw(this); - Daytelop_Update(this, &this->state); + DayTelop_Draw(this); + DayTelop_Update(this, &this->state); } -void Daytelop_Destroy(GameState* thisx) { +void DayTelop_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); } -void Daytelop_nop80815770(DaytelopContext* this) { +void DayTelop_Noop(DayTelopState* this) { } -void Daytelop_LoadGraphics(DaytelopContext* this) { +void DayTelop_LoadGraphics(DayTelopState* this) { size_t segmentSize = SEGMENT_ROM_SIZE(daytelop_static); this->daytelopStaticFile = THA_AllocEndAlign16(&this->state.heap, segmentSize); @@ -222,15 +219,15 @@ void Daytelop_LoadGraphics(DaytelopContext* this) { DmaMgr_SendRequest0(this->gameoverStaticFile, SEGMENT_ROM_START(icon_item_gameover_static), segmentSize); } -void Daytelop_Init(GameState* thisx) { - DaytelopContext* this = (DaytelopContext*)thisx; +void DayTelop_Init(GameState* thisx) { + DayTelopState* this = (DayTelopState*)thisx; - Game_SetFramerateDivisor(thisx, 1); - Matrix_Init(thisx); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Destroy(); - View_Init(&this->view, thisx->gfxCtx); - thisx->main = Daytelop_Main; - thisx->destroy = Daytelop_Destroy; + View_Init(&this->view, this->state.gfxCtx); + this->state.main = DayTelop_Main; + this->state.destroy = DayTelop_Destroy; this->transitionCountdown = 140; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; @@ -241,7 +238,7 @@ void Daytelop_Init(GameState* thisx) { Sram_IncrementDay(); } - Daytelop_nop80815770(this); - Daytelop_LoadGraphics(this); + DayTelop_Noop(this); + DayTelop_LoadGraphics(this); play_sound(NA_SE_OC_TELOP_IMPACT); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h index d77a5f334..a7350e898 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h @@ -3,8 +3,8 @@ #include "global.h" -void Daytelop_Init(GameState* thisx); -void Daytelop_Destroy(GameState* thisx); +void DayTelop_Init(GameState* thisx); +void DayTelop_Destroy(GameState* thisx); typedef struct { /* 0x000 */ GameState state; @@ -16,12 +16,12 @@ typedef struct { /* 0x240 */ s16 transitionCountdown; /* 0x242 */ s16 fadeInState; /* 0x244 */ s16 alpha; -} DaytelopContext; // size = 0x248 +} DayTelopState; // size = 0x248 typedef enum { /* 0 */ DAYTELOP_HOURSTEXT_OFF, /* 1 */ DAYTELOP_HOURSTEXT_FADEIN, /* 2 */ DAYTELOP_HOURSTEXT_ON -} Daytelop_FadeState; +} DaytelopFadeState; #endif 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 4184ca576..f3231ec56 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -3,10 +3,10 @@ #include "global.h" -void FileChoose_Init(GameState* thisx); -void FileChoose_Destroy(GameState* thisx); +void FileSelect_Init(GameState* thisx); +void FileSelect_Destroy(GameState* thisx); -typedef struct FileChooseContext { +typedef struct FileSelectState { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -110,6 +110,6 @@ typedef struct FileChooseContext { /* 0x2454C */ s16 unk_2454C; /* 0x2454E */ s16 unk_2454E; /* 0x24550 */ s16 unk_24550; -} FileChooseContext; // size = 0x24558 +} FileSelectState; // size = 0x24558 #endif diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 62ea8ef7e..657a2530f 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -19,15 +19,15 @@ extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BC20.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_nop8080bc44.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_nop8080bc44.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_nop8080BC4C.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_nop8080BC4C.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BC58.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BDAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_RenderView.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_RenderView.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BE60.s") @@ -85,13 +85,13 @@ extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80812ED0.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_UpdateAndDrawSkybox.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_UpdateAndDrawSkybox.s") -void FileChoose_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Main.s") +void FileSelect_Main(GameState* thisx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Main.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80813908.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Destroy.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Destroy.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Init.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Init.s") diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index bc5e46940..b7e5ec378 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -6,55 +6,53 @@ #include "z_opening.h" -void Opening_SetupForTitleCutscene(OpeningContext* this) { - static s32 openingEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; - static s32 openingCutscenes[] = { 0xFFFA, 0xFFFA }; +void TitleSetup_SetupTitleScreen(TitleSetupState* this) { + static s32 sOpeningEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; + static s32 sOpeningCutscenes[] = { 0xFFFA, 0xFFFA }; gSaveContext.eventInf[1] &= (u8)~0x80; gSaveContext.gameMode = 1; Sram_InitNewSave(); - gSaveContext.save.entrance = openingEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.save.entrance = sOpeningEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = sOpeningCutscenes[D_801BB12C]; gSaveContext.sceneSetupIndex = 0; 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, PlayState); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } -void func_80803EA0(OpeningContext* this) { +void func_80803EA0(TitleSetupState* this) { SREG(33) |= 1; } -void Opening_Main(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; +void TitleSetup_Main(GameState* thisx) { + TitleSetupState* this = (TitleSetupState*)thisx; - func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); - Opening_SetupForTitleCutscene(this); + func_8012CF0C(this->state.gfxCtx, false, true, 0, 0, 0); + TitleSetup_SetupTitleScreen(this); func_80803EA0(this); } -void Opening_Destroy(GameState* thisx) { +void TitleSetup_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); } -void Opening_Init(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; +void TitleSetup_Init(GameState* thisx) { + TitleSetupState* this = (TitleSetupState*)thisx; - Game_SetFramerateDivisor(&this->gameState, 1); - Matrix_Init(&this->gameState); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Init(); - View_Init(&this->view, this->gameState.gfxCtx); - this->gameState.main = Opening_Main; - this->gameState.destroy = Opening_Destroy; + View_Init(&this->view, this->state.gfxCtx); + this->state.main = TitleSetup_Main; + this->state.destroy = TitleSetup_Destroy; gSaveContext.respawnFlag = 0; gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.h b/src/overlays/gamestates/ovl_opening/z_opening.h index 809767fe4..36a01ffe9 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.h +++ b/src/overlays/gamestates/ovl_opening/z_opening.h @@ -3,13 +3,13 @@ #include "global.h" -void Opening_Init(GameState* thisx); -void Opening_Destroy(GameState* thisx); +void TitleSetup_Init(GameState* thisx); +void TitleSetup_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState gameState; + /* 0x000 */ GameState state; /* 0x0A4 */ UNK_TYPE1 unk_A4[0x4]; /* 0x0A8 */ View view; -} OpeningContext; // size = 0x210 +} TitleSetupState; // size = 0x210 #endif diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 0147cca64..898b1f351 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -8,13 +8,9 @@ #include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" -void MapSelect_LoadTitle(MapSelectState* this) { - { - GameState* gameState = &this->state; - gameState->running = false; - } - - SET_NEXT_GAMESTATE(&this->state, Title_Init, TitleContext); +void MapSelect_LoadConsoleLogo(MapSelectState* this) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState)); } void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { @@ -55,11 +51,8 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { gSaveContext.respawn[RESPAWN_MODE_HUMAN].entrance = 0xFF; gWeatherMode = 0; - do { - GameState* gameState = &this->state; - gameState->running = false; - } while (0); - SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); } // "Translation" (Actual name) @@ -501,7 +494,7 @@ static SceneSelectEntry sScenes[] = { { "X 1:SPOT00", MapSelect_LoadGame, ENTRANCE(CUTSCENE, 0) }, // "Title" (Title Screen) - { "title", (void*)MapSelect_LoadTitle, 0 }, + { "title", (void*)MapSelect_LoadConsoleLogo, 0 }, }; void MapSelect_UpdateMenu(MapSelectState* this) { diff --git a/src/overlays/gamestates/ovl_select/z_select.h b/src/overlays/gamestates/ovl_select/z_select.h index efe5f9945..69312e986 100644 --- a/src/overlays/gamestates/ovl_select/z_select.h +++ b/src/overlays/gamestates/ovl_select/z_select.h @@ -5,11 +5,11 @@ struct MapSelectState; -typedef void (*Select_LoadFunc)(struct MapSelectState*, u32, s32); +typedef void (*SelectLoadFunc)(struct MapSelectState*, u32, s32); typedef struct { /* 0x00 */ char* name; - /* 0x04 */ Select_LoadFunc loadFunc; + /* 0x04 */ SelectLoadFunc loadFunc; /* 0x08 */ s32 entrance; } SceneSelectEntry; // size = 0xC diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 68488b336..352997f94 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -8,7 +8,7 @@ #include "overlays/gamestates/ovl_opening/z_opening.h" #include "misc/nintendo_rogo_static/nintendo_rogo_static.h" -void Title_UpdateCounters(TitleContext* this) { +void ConsoleLogo_UpdateCounters(ConsoleLogoState* this) { if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) { this->timer--; this->visibleDuration--; @@ -32,7 +32,7 @@ void Title_UpdateCounters(TitleContext* this) { this->ult++; } -void Title_RenderView(TitleContext* this, f32 x, f32 y, f32 z) { +void ConsoleLogo_RenderView(ConsoleLogoState* this, f32 x, f32 y, f32 z) { View* view = &this->view; Vec3f eye; Vec3f at; @@ -49,10 +49,10 @@ void Title_RenderView(TitleContext* this, f32 x, f32 y, f32 z) { View_RenderView(view, 0xF); } -void Title_Draw(GameState* thisx) { - static s16 titleRotation = 0; +void ConsoleLogo_Draw(GameState* thisx) { + static s16 sTitleRotation = 0; static Lights1 sTitleLights = gdSPDefLights1(100, 100, 100, 255, 255, 255, 69, 69, 69); - TitleContext* this = (TitleContext*)thisx; + ConsoleLogoState* this = (ConsoleLogoState*)thisx; u16 y; u16 idx; Vec3f lightDir; @@ -60,7 +60,7 @@ void Title_Draw(GameState* thisx) { Vec3f eye; s32 pad[2]; - OPEN_DISPS(this->gameState.gfxCtx); + OPEN_DISPS(this->state.gfxCtx); lightDir.x = 69.0f; lightDir.y = 69.0f; @@ -74,20 +74,20 @@ void Title_Draw(GameState* thisx) { eye.y = 4002.5417f; eye.z = 1119.0837f; - Hilite_DrawOpa(&object, &eye, &lightDir, this->gameState.gfxCtx); + Hilite_DrawOpa(&object, &eye, &lightDir, this->state.gfxCtx); gSPSetLights1(POLY_OPA_DISP++, sTitleLights); - Title_RenderView(this, 0.0f, 150.0f, 300.0f); - func_8012C28C(this->gameState.gfxCtx); + ConsoleLogo_RenderView(this, 0.0f, 150.0f, 300.0f); + func_8012C28C(this->state.gfxCtx); Matrix_Translate(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZYX(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, sTitleRotation, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); - func_8012C628(this->gameState.gfxCtx); + func_8012C628(this->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); @@ -109,62 +109,58 @@ void Title_Draw(GameState* thisx) { 1 << 10, 1 << 10); } - func_800FC444(this->gameState.gfxCtx, 0, 0, 0, this->coverAlpha, 2); + func_800FC444(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, 2); - titleRotation += 300; + sTitleRotation += 300; - CLOSE_DISPS(this->gameState.gfxCtx); + CLOSE_DISPS(this->state.gfxCtx); } -void Title_Main(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; +void ConsoleLogo_Main(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; - func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); - OPEN_DISPS(this->gameState.gfxCtx); + OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); - Title_UpdateCounters(this); - Title_Draw(&this->gameState); + ConsoleLogo_UpdateCounters(this); + ConsoleLogo_Draw(&this->state); if (this->exit) { gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.gameMode = 1; - { - GameState* gameState = &this->gameState; - gameState->running = false; - } - SET_NEXT_GAMESTATE(&this->gameState, Opening_Init, OpeningContext); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); } - CLOSE_DISPS(this->gameState.gfxCtx); + CLOSE_DISPS(this->state.gfxCtx); } -void Title_Destroy(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; +void ConsoleLogo_Destroy(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; - Sram_InitSram(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->state, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } -void Title_Init(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; - uintptr_t segmentSize = - (uintptr_t)_nintendo_rogo_staticSegmentRomEnd - (uintptr_t)_nintendo_rogo_staticSegmentRomStart; +void ConsoleLogo_Init(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; + uintptr_t segmentSize = SEGMENT_ROM_SIZE(nintendo_rogo_static); - this->staticSegment = THA_AllocEndAlign16(&this->gameState.heap, segmentSize); - DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); + this->staticSegment = THA_AllocEndAlign16(&this->state.heap, segmentSize); + DmaMgr_SendRequest0(this->staticSegment, SEGMENT_ROM_START(nintendo_rogo_static), segmentSize); - Game_SetFramerateDivisor(thisx, 1); - Matrix_Init(thisx); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Init(); - View_Init(&this->view, thisx->gfxCtx); + View_Init(&this->view, this->state.gfxCtx); - thisx->main = Title_Main; - thisx->destroy = Title_Destroy; + this->state.main = ConsoleLogo_Main; + this->state.destroy = ConsoleLogo_Destroy; this->exit = false; if (!(Padmgr_GetControllerBitmask() & 1)) { diff --git a/src/overlays/gamestates/ovl_title/z_title.h b/src/overlays/gamestates/ovl_title/z_title.h index 7f2f34425..0cb19da1a 100644 --- a/src/overlays/gamestates/ovl_title/z_title.h +++ b/src/overlays/gamestates/ovl_title/z_title.h @@ -3,11 +3,11 @@ #include "global.h" -void Title_Init(GameState* thisx); -void Title_Destroy(GameState* thisx); +void ConsoleLogo_Init(GameState* thisx); +void ConsoleLogo_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState gameState; + /* 0x000 */ GameState state; /* 0x0A4 */ u8* staticSegment; /* 0x0A8 */ View view; /* 0x210 */ SramContext sramCtx; @@ -18,6 +18,6 @@ typedef struct { /* 0x240 */ s16 ult; /* 0x242 */ s16 uls; /* 0x244 */ u8 exit; -} TitleContext; // size = 0x248 +} ConsoleLogoState; // size = 0x248 #endif diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 37515bb05..2afc5d553 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3116,10 +3116,10 @@ 0x80172ED0:("AudioMgr_ThreadEntry",), 0x80173048:("AudioMgr_Unlock",), 0x80173074:("AudioMgr_Init",), - 0x80173130:("TitleSetup_GameStateResetContext",), - 0x801732DC:("TitleSetup_InitImpl",), - 0x8017332C:("TitleSetup_Destroy",), - 0x80173338:("TitleSetup_Init",), + 0x80173130:("Setup_SetRegs",), + 0x801732DC:("Setup_InitImpl",), + 0x8017332C:("Setup_Destroy",), + 0x80173338:("Setup_Init",), 0x80173360:("Game_UpdateFramerateVariables",), 0x801733A8:("Game_SetFramerateDivisor",), 0x801733DC:("GameState_SetFBFilter",), @@ -3134,8 +3134,8 @@ 0x80173880:("GameState_Realloc",), 0x80173950:("GameState_Init",), 0x80173A50:("GameState_Destroy",), - 0x80173B00:("GameState_GetNextStateInit",), - 0x80173B0C:("GameState_GetNextStateSize",), + 0x80173B00:("GameState_GetInit",), + 0x80173B0C:("GameState_GetSize",), 0x80173B18:("GameState_IsRunning",), 0x80173B24:("GameState_GetArenaSize",), 0x80173B48:("func_80173B48",), @@ -4083,13 +4083,13 @@ 0x801AA624:("GameOver_FadeLights",), 0x801AA68C:("GameOver_Update",), 0x801AAAA0:("func_801AAAA0",), - 0x80800000:("Title_UpdateCounters",), - 0x8080009C:("Title_RenderView",), - 0x80800134:("Title_Draw",), - 0x8080066C:("Title_Main",), - 0x8080071C:("Title_Destroy",), - 0x8080074C:("Title_Init",), - 0x80800910:("MapSelect_LoadTitle",), + 0x80800000:("ConsoleLogo_UpdateCounters",), + 0x8080009C:("ConsoleLogo_RenderView",), + 0x80800134:("ConsoleLogo_Draw",), + 0x8080066C:("ConsoleLogo_Main",), + 0x8080071C:("ConsoleLogo_Destroy",), + 0x8080074C:("ConsoleLogo_Init",), + 0x80800910:("MapSelect_LoadConsoleLogo",), 0x80800930:("MapSelect_LoadGame",), 0x80800A44:("MapSelect_UpdateMenu",), 0x808013B8:("MapSelect_PrintMenu",), @@ -4102,11 +4102,11 @@ 0x80801AFC:("MapSelect_Main",), 0x80801B28:("MapSelect_Destroy",), 0x80801B4C:("MapSelect_Init",), - 0x80803DF0:("Opening_SetupForTitleCutscene",), + 0x80803DF0:("TitleSetup_SetupTitleScreen",), 0x80803EA0:("func_80803EA0",), - 0x80803EC0:("Opening_Main",), - 0x80803F0C:("Opening_Destroy",), - 0x80803F30:("Opening_Init",), + 0x80803EC0:("TitleSetup_Main",), + 0x80803F0C:("TitleSetup_Destroy",), + 0x80803F30:("TitleSetup_Init",), 0x80804010:("func_80804010",), 0x808041A0:("func_808041A0",), 0x80804654:("func_80804654",), @@ -4152,11 +4152,11 @@ 0x8080A708:("func_8080A708",), 0x8080BBFC:("func_8080BBFC",), 0x8080BC20:("func_8080BC20",), - 0x8080BC44:("FileChoose_nop8080bc44",), - 0x8080BC4C:("FileChoose_nop8080BC4C",), + 0x8080BC44:("FileSelect_nop8080bc44",), + 0x8080BC4C:("FileSelect_nop8080BC4C",), 0x8080BC58:("func_8080BC58",), 0x8080BDAC:("func_8080BDAC",), - 0x8080BDDC:("FileChoose_RenderView",), + 0x8080BDDC:("FileSelect_RenderView",), 0x8080BE60:("func_8080BE60",), 0x8080C040:("func_8080C040",), 0x8080C228:("func_8080C228",), @@ -4185,18 +4185,18 @@ 0x80812D94:("func_80812D94",), 0x80812E94:("func_80812E94",), 0x80812ED0:("func_80812ED0",), - 0x8081313C:("FileChoose_UpdateAndDrawSkybox",), - 0x80813268:("FileChoose_Main",), + 0x8081313C:("FileSelect_UpdateAndDrawSkybox",), + 0x80813268:("FileSelect_Main",), 0x80813908:("func_80813908",), - 0x80813C74:("FileChoose_Destroy",), - 0x80813C98:("FileChoose_Init",), - 0x80814EB0:("Daytelop_Update",), - 0x80814FE8:("Daytelop_Draw",), - 0x808156B4:("Daytelop_Main",), - 0x8081574C:("Daytelop_Destroy",), - 0x80815770:("Daytelop_nop80815770",), - 0x8081577C:("Daytelop_LoadGraphics",), - 0x80815820:("Daytelop_Init",), + 0x80813C74:("FileSelect_Destroy",), + 0x80813C98:("FileSelect_Init",), + 0x80814EB0:("DayTelop_Update",), + 0x80814FE8:("DayTelop_Draw",), + 0x808156B4:("DayTelop_Main",), + 0x8081574C:("DayTelop_Destroy",), + 0x80815770:("DayTelop_Noop",), + 0x8081577C:("DayTelop_LoadGraphics",), + 0x80815820:("DayTelop_Init",), 0x808160A0:("func_808160A0",), 0x80817B5C:("func_80817B5C",), 0x80818904:("func_80818904",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index db8f76ef7..50a3309c4 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2630,10 +2630,10 @@ asm/non_matchings/code/audioMgr/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x asm/non_matchings/code/audioMgr/AudioMgr_ThreadEntry.s,AudioMgr_ThreadEntry,0x80172ED0,0x5E asm/non_matchings/code/audioMgr/AudioMgr_Unlock.s,AudioMgr_Unlock,0x80173048,0xB asm/non_matchings/code/audioMgr/AudioMgr_Init.s,AudioMgr_Init,0x80173074,0x2F -asm/non_matchings/code/title_setup/TitleSetup_GameStateResetContext.s,TitleSetup_GameStateResetContext,0x80173130,0x6B -asm/non_matchings/code/title_setup/TitleSetup_InitImpl.s,TitleSetup_InitImpl,0x801732DC,0x14 -asm/non_matchings/code/title_setup/TitleSetup_Destroy.s,TitleSetup_Destroy,0x8017332C,0x3 -asm/non_matchings/code/title_setup/TitleSetup_Init.s,TitleSetup_Init,0x80173338,0xA +asm/non_matchings/code/title_setup/Setup_SetRegs.s,Setup_SetRegs,0x80173130,0x6B +asm/non_matchings/code/title_setup/Setup_InitImpl.s,Setup_InitImpl,0x801732DC,0x14 +asm/non_matchings/code/title_setup/Setup_Destroy.s,Setup_Destroy,0x8017332C,0x3 +asm/non_matchings/code/title_setup/Setup_Init.s,Setup_Init,0x80173338,0xA asm/non_matchings/code/game/Game_UpdateFramerateVariables.s,Game_UpdateFramerateVariables,0x80173360,0x12 asm/non_matchings/code/game/Game_SetFramerateDivisor.s,Game_SetFramerateDivisor,0x801733A8,0xD asm/non_matchings/code/game/GameState_SetFBFilter.s,GameState_SetFBFilter,0x801733DC,0x56 @@ -2648,8 +2648,8 @@ asm/non_matchings/code/game/Game_InitHeap.s,Game_InitHeap,0x80173810,0x1C asm/non_matchings/code/game/Game_ResizeHeap.s,Game_ResizeHeap,0x80173880,0x34 asm/non_matchings/code/game/GameState_Init.s,GameState_Init,0x80173950,0x40 asm/non_matchings/code/game/GameState_Destroy.s,GameState_Destroy,0x80173A50,0x2C -asm/non_matchings/code/game/GameState_GetNextStateInit.s,GameState_GetNextStateInit,0x80173B00,0x3 -asm/non_matchings/code/game/GameState_GetNextStateSize.s,GameState_GetNextStateSize,0x80173B0C,0x3 +asm/non_matchings/code/game/GameState_GetInit.s,GameState_GetInit,0x80173B00,0x3 +asm/non_matchings/code/game/GameState_GetSize.s,GameState_GetSize,0x80173B0C,0x3 asm/non_matchings/code/game/GameState_IsRunning.s,GameState_IsRunning,0x80173B18,0x3 asm/non_matchings/code/game/Game_GetHeapFreeSize.s,Game_GetHeapFreeSize,0x80173B24,0x9 asm/non_matchings/code/game/func_80173B48.s,func_80173B48,0x80173B48,0x2A From 00bf71460f56c5a8aba5e235b729c8a5e594bae8 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 24 Sep 2022 15:45:53 -0400 Subject: [PATCH 40/73] Item cleanup: Item drops, rupees, signs (#1048) * item cleanup * pr suggestions Co-authored-by: Anghelo Carvajal --- assets/xml/objects/gameplay_keep.xml | 79 ++++--- include/variables.h | 2 - src/code/z_en_item00.c | 204 +++++++++++------- .../actors/ovl_En_Col_Man/z_en_col_man.c | 10 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- .../actors/ovl_En_Gamelupy/z_en_gamelupy.c | 9 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 2 +- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c | 14 +- .../actors/ovl_En_Scopecoin/z_en_scopecoin.c | 54 +++-- .../actors/ovl_En_Scopecoin/z_en_scopecoin.h | 6 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 6 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 12 +- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 14 +- 15 files changed, 240 insertions(+), 180 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 1923fe8df..03ed9eef5 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1218,37 +1218,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1257,10 +1264,12 @@ - - - - + + + + + + diff --git a/include/variables.h b/include/variables.h index 54248860f..05602af8f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -362,8 +362,6 @@ extern ActorInit En_A_Obj_InitVars; extern ColliderCylinderInit enAObjCylinderInit; extern InitChainEntry enAObjInitVar; extern Gfx* enAObjDisplayLists[2]; -extern UNK_PTR D_801ADF30[5]; -extern UNK_PTR D_801ADF44[12]; extern u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER]; extern u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER]; extern s32 D_801AE194[32]; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 953648f49..437728f0e 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -18,6 +18,11 @@ void func_800A6650(EnItem00* this, PlayState* play); void func_800A6780(EnItem00* this, PlayState* play); void func_800A6A40(EnItem00* this, PlayState* play); +void EnItem00_DrawRupee(EnItem00* this, PlayState* play); +void EnItem00_DrawSprite(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); + const ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, ACTORCAT_MISC, @@ -102,12 +107,14 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->unk154 = 0.015f; shadowOffset = 750.0f; break; + case ITEM00_SMALL_KEY: this->unk150 = 0; Actor_SetScale(&this->actor, 0.03f); this->unk154 = 0.03f; shadowOffset = 350.0f; break; + case ITEM00_HEART_PIECE: case ITEM00_HEART_CONTAINER: this->unk150 = 0; @@ -118,12 +125,14 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { sp30 = -1; } break; + case ITEM00_RECOVERY_HEART: - this->actor.home.rot.z = randPlusMinusPoint5Scaled(65535.0f); + this->actor.home.rot.z = randPlusMinusPoint5Scaled(0xFFFF); shadowOffset = 430.0f; Actor_SetScale(&this->actor, 0.02f); this->unk154 = 0.02f; break; + case ITEM00_ARROWS_10: case ITEM00_ARROWS_30: case ITEM00_ARROWS_40: @@ -132,6 +141,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->unk154 = 0.035f; shadowOffset = 250.0f; break; + case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: case ITEM00_NUTS_1: @@ -143,39 +153,47 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->unk154 = 0.03f; shadowOffset = 320.0f; break; + case ITEM00_MAGIC_LARGE: - Actor_SetScale(&this->actor, 0.044999998f); - this->unk154 = 0.044999998f; + Actor_SetScale(&this->actor, 4.5f * 0.01f); + this->unk154 = 4.5f * 0.01f; shadowOffset = 320.0f; break; + case ITEM00_RUPEE_HUGE: - Actor_SetScale(&this->actor, 0.044999998f); - this->unk154 = 0.044999998f; + Actor_SetScale(&this->actor, 4.5f * 0.01f); + this->unk154 = 4.5f * 0.01f; shadowOffset = 750.0f; break; + case ITEM00_RUPEE_PURPLE: Actor_SetScale(&this->actor, 0.03f); this->unk154 = 0.03f; shadowOffset = 750.0f; break; + case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: shadowOffset = 500.0f; Actor_SetScale(&this->actor, 0.01f); this->unk154 = 0.01f; break; + case ITEM00_SHIELD_HERO: this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2); EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; + case ITEM00_MAP: this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_MAP); EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; + case ITEM00_COMPASS: this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_COMPASS); EnItem00_SetObject(this, play, &shadowOffset, &shadowScale); break; + default: break; } @@ -191,6 +209,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->unk152 = -1; return; } + if (sp30 == 0) { this->actionFunc = func_800A640C; this->unk152 = -1; @@ -208,61 +227,78 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { case ITEM00_RUPEE_GREEN: Item_Give(play, ITEM_RUPEE_GREEN); break; + case ITEM00_RUPEE_BLUE: Item_Give(play, ITEM_RUPEE_BLUE); break; + case ITEM00_RUPEE_RED: Item_Give(play, ITEM_RUPEE_RED); break; + case ITEM00_RUPEE_PURPLE: Item_Give(play, ITEM_RUPEE_PURPLE); break; + case ITEM00_RUPEE_HUGE: Item_Give(play, ITEM_RUPEE_HUGE); break; + case ITEM00_RECOVERY_HEART: Item_Give(play, ITEM_RECOVERY_HEART); break; + case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: Health_ChangeBy(play, 0x70); break; + case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: Item_Give(play, ITEM_BOMBS_5); break; + case ITEM00_ARROWS_10: Item_Give(play, ITEM_ARROWS_10); break; + case ITEM00_ARROWS_30: Item_Give(play, ITEM_ARROWS_30); break; + case ITEM00_ARROWS_40: Item_Give(play, ITEM_ARROWS_40); break; + case ITEM00_ARROWS_50: Item_Give(play, ITEM_ARROWS_50); break; + case ITEM00_MAGIC_LARGE: Item_Give(play, ITEM_MAGIC_LARGE); break; + case ITEM00_MAGIC_SMALL: Item_Give(play, ITEM_MAGIC_SMALL); break; + case ITEM00_SMALL_KEY: Item_Give(play, ITEM_KEY_SMALL); break; + case ITEM00_NUTS_1: getItemId = GI_NUTS_1; break; + case ITEM00_NUTS_10: getItemId = GI_NUTS_10; break; + default: break; } - if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, play) == 0)) { + if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); } @@ -277,11 +313,10 @@ void EnItem00_Destroy(Actor* thisx, PlayState* play) { } void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) { - s32 sp1C; + s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS); - sp1C = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS); - if (Object_IsLoaded(&play->objectCtx, sp1C)) { - this->actor.objBankIndex = sp1C; + if (Object_IsLoaded(&play->objectCtx, objBankIndex)) { + this->actor.objBankIndex = objBankIndex; this->actionFunc = func_800A640C; } } @@ -327,15 +362,15 @@ void func_800A640C(EnItem00* this, PlayState* play) { } } - if ((this->actor.gravity != 0.0f) && ((this->actor.bgCheckFlags & 1) == 0)) { + if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 1)) { this->actionFunc = func_800A6650; } } -static Color_RGBA8 D_801ADF10 = { 255, 255, 127, 0 }; -static Color_RGBA8 D_801ADF14 = { 255, 255, 255, 0 }; -static Vec3f D_801ADF18 = { 0.0f, 0.1f, 0.0f }; -static Vec3f D_801ADF24 = { 0.0f, 0.01f, 0.0f }; +static Color_RGBA8 sEffectPrimColor = { 255, 255, 127, 0 }; +static Color_RGBA8 sEffectEnvColor = { 255, 255, 255, 0 }; +static Vec3f sEffectVelocity = { 0.0f, 0.1f, 0.0f }; +static Vec3f sEffectAccel = { 0.0f, 0.01f, 0.0f }; void func_800A6650(EnItem00* this, PlayState* play) { u32 pad; @@ -344,20 +379,21 @@ void func_800A6650(EnItem00* this, PlayState* play) { if (this->actor.params <= ITEM00_RUPEE_RED) { this->actor.shape.rot.y = this->actor.shape.rot.y + 960; } + if ((play->gameplayFrames & 1) != 0) { 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(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if ((this->actor.bgCheckFlags & 3) != 0) { + + if (this->actor.bgCheckFlags & 3) { if (this->actor.velocity.y > -2.0f) { this->actionFunc = func_800A640C; - return; + } else { + this->actor.velocity.y = this->actor.velocity.y * -0.8f; + this->actor.bgCheckFlags &= ~1; } - - this->actor.velocity.y = this->actor.velocity.y * -0.8f; - this->actor.bgCheckFlags = this->actor.bgCheckFlags & 0xFFFE; } } @@ -384,18 +420,18 @@ void func_800A6780(EnItem00* this, PlayState* play) { } if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y += 960; + this->actor.shape.rot.y += 0x3C0; } else if ((this->actor.params >= ITEM00_SHIELD_HERO) && (this->actor.params != ITEM00_NUTS_10) && (this->actor.params != ITEM00_BOMBS_0)) { - this->actor.world.rot.x -= 700; - this->actor.shape.rot.y += 400; + this->actor.world.rot.x -= 0x2BC; + this->actor.shape.rot.y += 0x190; this->actor.shape.rot.x = this->actor.world.rot.x - 0x4000; } if (this->actor.velocity.y <= 2.0f) { - var1 = (u16)this->actor.shape.rot.z + 10000; - if (var1 < 65535) { - this->actor.shape.rot.z += 10000; + var1 = (u16)this->actor.shape.rot.z + 0x2710; + if (var1 < 0xFFFF) { + this->actor.shape.rot.z += 0x2710; } else { this->actor.shape.rot.z = -1; } @@ -405,10 +441,10 @@ void func_800A6780(EnItem00* this, PlayState* play) { 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(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 0x0003) { + if (this->actor.bgCheckFlags & 3) { this->actionFunc = func_800A640C; this->actor.shape.rot.z = 0; this->actor.speedXZ = 0.0f; @@ -419,7 +455,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->getItemId != GI_NONE) { - if (Actor_HasParent(&this->actor, play) == 0) { + if (!Actor_HasParent(&this->actor, play)) { Actor_PickUp(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk152++; } else { @@ -435,7 +471,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { this->actor.world.pos = player->actor.world.pos; if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y = this->actor.shape.rot.y + 960; + this->actor.shape.rot.y += 0x3C0; } else if (this->actor.params == ITEM00_RECOVERY_HEART) { this->actor.shape.rot.y = 0; } @@ -443,7 +479,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { this->actor.world.pos.y += (40.0f + (Math_SinS(this->unk152 * 15000) * (this->unk152 * 0.3f))); if (LINK_IS_ADULT) { - this->actor.world.pos.y = this->actor.world.pos.y + 20.0f; + this->actor.world.pos.y += 20.0f; } } @@ -509,78 +545,101 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { this->unk1A4 = 1; Item_Give(play, ITEM_RUPEE_GREEN); break; + case ITEM00_RUPEE_BLUE: this->unk1A4 = 1; Item_Give(play, ITEM_RUPEE_BLUE); break; + case ITEM00_RUPEE_RED: this->unk1A4 = 1; Item_Give(play, ITEM_RUPEE_RED); break; + case ITEM00_RUPEE_PURPLE: this->unk1A4 = 1; Item_Give(play, ITEM_RUPEE_PURPLE); break; + case ITEM00_RUPEE_HUGE: this->unk1A4 = 1; Item_Give(play, ITEM_RUPEE_HUGE); break; + case ITEM00_STICK: getItemId = GI_STICKS_1; break; + case ITEM00_NUTS_1: getItemId = GI_NUTS_1; break; + case ITEM00_NUTS_10: getItemId = GI_NUTS_10; break; + case ITEM00_RECOVERY_HEART: Item_Give(play, ITEM_RECOVERY_HEART); break; + case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: Health_ChangeBy(play, 0x70); break; + case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: Item_Give(play, ITEM_BOMBS_5); break; + case ITEM00_ARROWS_10: Item_Give(play, ITEM_ARROWS_10); break; + case ITEM00_ARROWS_30: Item_Give(play, ITEM_ARROWS_30); break; + case ITEM00_ARROWS_40: Item_Give(play, ITEM_ARROWS_40); break; + case ITEM00_ARROWS_50: Item_Give(play, ITEM_ARROWS_50); break; + case ITEM00_SMALL_KEY: getItemId = GI_KEY_SMALL; break; + case ITEM00_HEART_PIECE: getItemId = GI_HEART_PIECE; break; + case ITEM00_HEART_CONTAINER: getItemId = GI_HEART_CONTAINER; break; + case ITEM00_MAGIC_LARGE: Item_Give(play, ITEM_MAGIC_LARGE); break; + case ITEM00_MAGIC_SMALL: Item_Give(play, ITEM_MAGIC_SMALL); break; + case ITEM00_SHIELD_HERO: getItemId = GI_SHIELD_HERO; break; + case ITEM00_MAP: getItemId = GI_MAP; break; + case ITEM00_COMPASS: getItemId = GI_COMPASS; break; + default: break; } @@ -603,6 +662,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { Actor_MarkForDeath(&this->actor); } return; + default: break; } @@ -634,11 +694,6 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { this->actionFunc = func_800A6A40; } -void EnItem00_DrawRupee(EnItem00* this, PlayState* play); -void EnItem00_DrawSprite(EnItem00* this, PlayState* play); -void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); -void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); - void EnItem00_Draw(Actor* thisx, PlayState* play) { s32 pad; EnItem00* this = THIS; @@ -652,16 +707,20 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { case ITEM00_RUPEE_PURPLE: EnItem00_DrawRupee(this, play); break; + case ITEM00_HEART_PIECE: EnItem00_DrawHeartPiece(this, play); break; + case ITEM00_HEART_CONTAINER: EnItem00_DrawHeartContainer(this, play); break; + case ITEM00_RECOVERY_HEART: if (this->unk152 < 0) { if (this->unk152 == -1) { s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); + if (Object_IsLoaded(&play->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; Actor_SetObjectDependency(play, &this->actor); @@ -673,6 +732,7 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { } break; } + // fallthrough case ITEM00_BOMBS_A: case ITEM00_ARROWS_10: case ITEM00_ARROWS_30: @@ -688,14 +748,19 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { case ITEM00_BOMBS_0: EnItem00_DrawSprite(this, play); break; + case ITEM00_SHIELD_HERO: GetItem_Draw(play, GID_SHIELD_HERO); break; + case ITEM00_MAP: GetItem_Draw(play, GID_DUNGEON_MAP); break; + case ITEM00_COMPASS: GetItem_Draw(play, GID_COMPASS); + break; + case ITEM00_MASK: case ITEM00_FLEXIBLE: case ITEM00_3_HEARTS: @@ -706,17 +771,13 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) { } } -TexturePtr D_801ADF30[] = { - gameplay_keep_Tex_061FC0, // Green rupee - gameplay_keep_Tex_061FE0, // Blue rupee - gameplay_keep_Tex_062000, // Red rupee - gameplay_keep_Tex_062040, // Orange rupee - gameplay_keep_Tex_062020 // Purple rupee +static TexturePtr sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, }; void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { s32 pad; - s32 iconNb; + s32 texIndex; OPEN_DISPS(play->state.gfxCtx); @@ -724,67 +785,66 @@ void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { func_800B8050(&this->actor, play, 0); if (this->actor.params <= ITEM00_RUPEE_RED) { - iconNb = this->actor.params; + texIndex = this->actor.params; } else { - iconNb = this->actor.params - 0x10; + texIndex = this->actor.params - 0x10; } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF30[iconNb])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTextures[texIndex])); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); // TODO symbol + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(play->state.gfxCtx); } -TexturePtr D_801ADF44[12] = { - gameplay_keep_Tex_05E6F0, // Heart (Not used) - gameplay_keep_Tex_05CEF0, // Bombs (A), Bombs (0) - gameplay_keep_Tex_05BEF0, // Arrows (10) - gameplay_keep_Tex_05B6F0, // Arrows (30) - gameplay_keep_Tex_05C6F0, // Arrows (40), Arrows (50) - gameplay_keep_Tex_05CEF0, // Bombs (B) - gameplay_keep_Tex_0607C0, // Nuts (1), Nuts (10) - gameplay_keep_Tex_060FC0, // Sticks (1) - gameplay_keep_Tex_0617C0, // Magic (Large) - gameplay_keep_Tex_05FFC0, // Magic (Small) +TexturePtr sItemDropTextures[] = { + gDropRecoveryHeartTex, // Heart (Not used) + gDropBombTex, // Bombs (A), Bombs (0) + gDropArrows1Tex, // Arrows (10) + gDropArrows2Tex, // Arrows (30) + gDropArrows3Tex, // Arrows (40), Arrows (50) + gDropBombTex, // Bombs (B) + gDropDekuNutTex, // Nuts (1), Nuts (10) + gDropDekuStickTex, // Sticks (1) + gDropMagicLargeTex, // Magic (Large) + gDropMagicSmallTex, // Magic (Small) NULL, - gameplay_keep_Tex_05F7C0 // Small Key + gDropKeySmallTex // Small Key }; void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { - s32 iconNb = this->actor.params - 3; + s32 texIndex = this->actor.params - 3; OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); if (this->actor.params == ITEM00_NUTS_10) { - iconNb = 6; + texIndex = 6; } else if (this->actor.params == ITEM00_BOMBS_0) { - iconNb = 1; + texIndex = 1; } else if (this->actor.params >= ITEM00_ARROWS_30) { - iconNb -= 3; + texIndex -= 3; if (this->actor.params < ITEM00_ARROWS_50) { - iconNb++; + texIndex++; } } POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF44[iconNb])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sItemDropTextures[texIndex])); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); CLOSE_DISPS(play->state.gfxCtx); } void EnItem00_DrawHeartContainer(EnItem00* actor, PlayState* play) { - s32 pad; - s32 pad2; + s32 pad[2]; if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) { OPEN_DISPS(play->state.gfxCtx); @@ -811,7 +871,7 @@ void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); + gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); CLOSE_DISPS(play->state.gfxCtx); } @@ -893,7 +953,7 @@ Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) { } spawnedActor->speedXZ = 2.0f; spawnedActor->gravity = -0.9f; - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); Actor_SetScale(spawnedActor, 0.0f); ((EnItem00*)spawnedActor)->actionFunc = func_800A6780; ((EnItem00*)spawnedActor)->unk152 = 0xDC; @@ -948,7 +1008,7 @@ Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) { } else { spawnedActor->gravity = -0.9f; } - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); spawnedActor->flags |= 0x10; } } 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 54a78442c..0b909d61f 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 @@ -234,7 +234,7 @@ void func_80AFE414(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); func_800B8118(&this->actor, play, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); + gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); CLOSE_DISPS(play->state.gfxCtx); } @@ -246,9 +246,9 @@ void func_80AFE4AC(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); CLOSE_DISPS(play->state.gfxCtx); } @@ -268,8 +268,8 @@ void func_80AFE650(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05CEF0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropBombTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); CLOSE_DISPS(play->state.gfxCtx); } 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 4172773f0..6b0a7e3b9 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -1460,7 +1460,7 @@ void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len) { Matrix_ReplaceRotation(&play->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)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0E0); } 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 c2c42fa59..e01193378 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -55,9 +55,8 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -static TexturePtr sRupeeTex[] = { - gameplay_keep_Tex_061FC0, gameplay_keep_Tex_061FE0, gameplay_keep_Tex_062000, - gameplay_keep_Tex_062040, gameplay_keep_Tex_062020, +static TexturePtr sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, }; static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; @@ -185,8 +184,8 @@ void EnGamelupy_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); func_800B8050(&this->actor, play, 0); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTex[this->rupeeIndex])); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTextures[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(play->state.gfxCtx); } 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 4499ed44a..5113c1291 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -963,7 +963,7 @@ void EnKanban_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->partFlags == 0xFFFF) { - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05AED0); + gSPDisplayList(POLY_OPA_DISP++, gSignRectangularDL); } else { for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { if (sPartFlags[i] & this->partFlags) { 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 6ea2c6153..bf93b729f 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -1152,7 +1152,7 @@ void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2) { Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), 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)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000078); } 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 5aa54307a..3eb978314 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 @@ -36,12 +36,12 @@ const ActorInit En_Sc_Ruppe_InitVars = { }; 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) + { gRupeeGreenTex, 1 }, // Green rupee + { gRupeeBlueTex, 5 }, // Blue rupee + { gRupeeRedTex, 20 }, // Red rupee + { gRupeeOrangeTex, 200 }, // Orange rupee + { gRupeePurpleTex, 50 }, // Purple rupee + { gRupeeSilverTex, 10 }, // (unused) }; static ColliderCylinderInit sCylinderInit = { @@ -185,7 +185,7 @@ void EnScRuppe_Draw(Actor* thisx, PlayState* play) { func_800B8050(&this->actor, play, 0); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(play->state.gfxCtx); } 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 9a854ccf2..4bccdb846 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -16,9 +16,6 @@ void EnScopecoin_Destroy(Actor* thisx, PlayState* play); void EnScopecoin_Update(Actor* thisx, PlayState* play); void EnScopecoin_Draw(Actor* thisx, PlayState* play); -void func_80BFCFA0(EnScopecoin* this, PlayState* play); -void func_80BFCFB8(EnScopecoin* this, PlayState* play); - const ActorInit En_Scopecoin_InitVars = { ACTOR_EN_SCOPECOIN, ACTORCAT_NPC, @@ -31,12 +28,12 @@ const ActorInit En_Scopecoin_InitVars = { (ActorFunc)EnScopecoin_Draw, }; -void func_80BFCFA0(EnScopecoin* this, PlayState* play) { - this->actor.shape.rot.y += 500; +void EnScopecoin_Spin(EnScopecoin* this, PlayState* play) { + this->actor.shape.rot.y += 0x1F4; } -void func_80BFCFB8(EnScopecoin* this, PlayState* play) { - if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { +void EnScopecoin_CheckCollectible(EnScopecoin* this, PlayState* play) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); Actor_MarkForDeath(&this->actor); } @@ -47,31 +44,32 @@ void EnScopecoin_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 10.0f); - this->unk148 = (this->actor.params & 0xF); - if (this->unk148 < 0 || this->unk148 >= 8) { - this->unk148 = 0; + + this->rupeeIndex = OBJMUPICT_GET_RUPEE_INDEX(&this->actor); + if ((this->rupeeIndex < 0) || (this->rupeeIndex > 7)) { + this->rupeeIndex = 0; } if (play->actorCtx.flags & ACTORCTX_FLAG_1) { - if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { + if ((this->rupeeIndex == 2) || (this->rupeeIndex == 6)) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } } this->actor.shape.yOffset = 700.0f; - this->actionFunc = func_80BFCFA0; - return; - } - if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(play, (this->actor.params & 0x7F0) >> 4)) { - Actor_MarkForDeath(&this->actor); - } else { - this->actor.draw = NULL; - this->actionFunc = func_80BFCFB8; - } + this->actionFunc = EnScopecoin_Spin; } else { - Actor_MarkForDeath(&this->actor); + if ((this->rupeeIndex == 2) || (this->rupeeIndex == 6)) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.draw = NULL; + this->actionFunc = EnScopecoin_CheckCollectible; + } else { + Actor_MarkForDeath(&this->actor); + } } } @@ -84,9 +82,8 @@ void EnScopecoin_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); } -static TexturePtr D_80BFD280[] = { - gameplay_keep_Tex_061FC0, gameplay_keep_Tex_061FE0, gameplay_keep_Tex_062000, gameplay_keep_Tex_062040, - gameplay_keep_Tex_062020, gameplay_keep_Tex_062060, gameplay_keep_Tex_062000, +static TexturePtr sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, gRupeeSilverTex, gRupeeRedTex, }; void EnScopecoin_Draw(Actor* thisx, PlayState* play) { @@ -95,11 +92,12 @@ void EnScopecoin_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); func_800B8050(&this->actor, play, 0); + OPEN_DISPS(gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BFD280[this->unk148])); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTextures[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h index 37a6bbf8e..8fd9b142c 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h @@ -5,13 +5,15 @@ struct EnScopecoin; +#define OBJMUPICT_GET_RUPEE_INDEX(thisx) ((thisx)->params & 0xF) +#define OBJMUPICT_GET_RUPEE_FLAG(thisx) (((thisx)->params & 0x7F0) >> 4) + typedef void (*EnScopecoinActionFunc)(struct EnScopecoin*, PlayState*); typedef struct EnScopecoin { /* 0x000 */ Actor actor; /* 0x144 */ EnScopecoinActionFunc actionFunc; - /* 0x148 */ s16 unk148; - /* 0x14A */ s16 unk14A; + /* 0x148 */ s16 rupeeIndex; } EnScopecoin; // size = 0x14C extern const ActorInit En_Scopecoin_InitVars; 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 dc74fa461..45f88ffb7 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -508,9 +508,9 @@ void func_80BE5C10(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); if (this->unk_1A0 == 0) { - texture = gameplay_keep_Tex_05BEF0; + texture = gDropArrows1Tex; } else { - texture = gameplay_keep_Tex_0617C0; + texture = gDropMagicLargeTex; } POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); @@ -521,7 +521,7 @@ void func_80BE5C10(Actor* thisx, PlayState* play) { Matrix_RotateZS(this->unk_198, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); CLOSE_DISPS(play->state.gfxCtx); } 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 3211d3167..ba375f583 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -80,13 +80,7 @@ u8 D_80A93E80[] = { }; 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, + NULL, gDropArrows2Tex, gDropBombTex, gDropDekuNutTex, gDropDekuStickTex, gRupeeGreenTex, gRupeeBlueTex, }; Color_RGB8 D_80A94048 = { 230, 230, 220 }; @@ -221,7 +215,7 @@ void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); } Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); @@ -273,7 +267,7 @@ void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->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); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); } Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2afc5d553..f2af2a653 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16430,8 +16430,8 @@ 0x80BFC9E4:("EnRz_Update",), 0x80BFCAD0:("func_80BFCAD0",), 0x80BFCB3C:("EnRz_Draw",), - 0x80BFCFA0:("func_80BFCFA0",), - 0x80BFCFB8:("func_80BFCFB8",), + 0x80BFCFA0:("EnScopecoin_Spin",), + 0x80BFCFB8:("EnScopecoin_CheckCollectible",), 0x80BFD010:("EnScopecoin_Init",), 0x80BFD148:("EnScopecoin_Destroy",), 0x80BFD158:("EnScopecoin_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 86ab55c72..f21fc7d98 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -377,12 +377,12 @@ 0x801ADEC0:("En_Item00_InitVars","ActorInit","",0x20), 0x801ADEE0:("enItem00CylinderInit","ColliderCylinderInit","",0x2c), 0x801ADF0C:("enItem00InitVars","ActorInitVar","[1]",0x4), - 0x801ADF10:("D_801ADF10","ColorRGBA8","",0x4), - 0x801ADF14:("D_801ADF14","ColorRGBA8","",0x4), - 0x801ADF18:("D_801ADF18","Vec3f","",0xc), - 0x801ADF24:("D_801ADF24","Vec3f","",0xc), - 0x801ADF30:("D_801ADF30","UNK_PTR","[5]",0x14), - 0x801ADF44:("D_801ADF44","UNK_PTR","[12]",0x30), + 0x801ADF10:("sEffectPrimColor","ColorRGBA8","",0x4), + 0x801ADF14:("sEffectEnvColor","ColorRGBA8","",0x4), + 0x801ADF18:("sEffectVelocity","Vec3f","",0xc), + 0x801ADF24:("sEffectAccel","Vec3f","",0xc), + 0x801ADF30:("sRupeeTextures","UNK_PTR","[5]",0x14), + 0x801ADF44:("sItemDropTextures","UNK_PTR","[12]",0x30), 0x801ADF74:("sDropTable","u8","[272]",0x110), 0x801AE084:("sDropTableAmounts","u8","[272]",0x110), 0x801AE194:("D_801AE194","s32","[32]",0x80), @@ -16250,7 +16250,7 @@ 0x80BFCD78:("D_80BFCD78","f32","",0x4), 0x80BFCD7C:("D_80BFCD7C","f32","",0x4), 0x80BFD260:("En_Scopecoin_InitVars","UNK_TYPE1","",0x1), - 0x80BFD280:("D_80BFD280","UNK_TYPE1","",0x1), + 0x80BFD280:("sRupeeTextures","UNK_TYPE1","",0x1), 0x80BFDEA0:("D_80BFDEA0","UNK_TYPE1","",0x1), 0x80BFDEB4:("D_80BFDEB4","UNK_TYPE1","",0x1), 0x80BFDF28:("En_Bjt_InitVars","UNK_TYPE1","",0x1), From 72d24b999553517adcefee85ef25927c897718b3 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Mon, 26 Sep 2022 16:59:31 -0700 Subject: [PATCH 41/73] Give Deku Princess/King/Butler's objects the "correct" name (#1084) * Give Deku Princess/King/Butler's objects the "correct" name * Document the actor/object discrepancy in the actors * format --- assets/xml/objects/object_dnj.xml | 86 +++++++++++ assets/xml/objects/object_dno.xml | 172 +++++++++++----------- assets/xml/objects/object_dnp.xml | 88 ----------- assets/xml/objects/object_dnq.xml | 172 +++++++++++----------- include/segment_symbols.h | 6 +- include/z64object.h | 6 +- spec | 12 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 30 ++-- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 69 ++++----- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 49 +++--- tools/ZAPDConfigs/MM/ObjectList_MM.txt | 6 +- tools/disasm/dma_filenames.txt | 6 +- tools/extract_baserom.py | 6 +- tools/filelists/mm.us.rev1/all.csv | 6 +- tools/filelists/mm.us.rev1/objects.csv | 6 +- 15 files changed, 365 insertions(+), 355 deletions(-) create mode 100644 assets/xml/objects/object_dnj.xml delete mode 100644 assets/xml/objects/object_dnp.xml diff --git a/assets/xml/objects/object_dnj.xml b/assets/xml/objects/object_dnj.xml new file mode 100644 index 000000000..95b563913 --- /dev/null +++ b/assets/xml/objects/object_dnj.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index 664663628..e1528989c 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -1,86 +1,94 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml deleted file mode 100644 index d9494909c..000000000 --- a/assets/xml/objects/object_dnp.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index 92d818a4b..63f27a6f8 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -1,94 +1,88 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/segment_symbols.h b/include/segment_symbols.h index e133437cc..1339c879c 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -922,7 +922,7 @@ DECLARE_ROM_SEGMENT(object_driftice) DECLARE_ROM_SEGMENT(object_fall) DECLARE_ROM_SEGMENT(object_hanareyama_obj) DECLARE_ROM_SEGMENT(object_crace_object) -DECLARE_ROM_SEGMENT(object_dnq) +DECLARE_ROM_SEGMENT(object_dno) DECLARE_ROM_SEGMENT(object_obj_tokeidai) DECLARE_ROM_SEGMENT(object_eg) DECLARE_ROM_SEGMENT(object_tru) @@ -993,7 +993,7 @@ DECLARE_ROM_SEGMENT(object_gg) DECLARE_ROM_SEGMENT(object_maruta) DECLARE_ROM_SEGMENT(object_ghaka) DECLARE_ROM_SEGMENT(object_oyu) -DECLARE_ROM_SEGMENT(object_dnp) +DECLARE_ROM_SEGMENT(object_dnq) DECLARE_ROM_SEGMENT(object_dai) DECLARE_ROM_SEGMENT(object_kgy) DECLARE_ROM_SEGMENT(object_fb) @@ -1014,7 +1014,7 @@ DECLARE_ROM_SEGMENT(object_gi_loach) DECLARE_ROM_SEGMENT(object_gi_seahorse) DECLARE_ROM_SEGMENT(object_bigpo) DECLARE_ROM_SEGMENT(object_hariko) -DECLARE_ROM_SEGMENT(object_dno) +DECLARE_ROM_SEGMENT(object_dnj) DECLARE_ROM_SEGMENT(object_sinkai_kabe) DECLARE_ROM_SEGMENT(object_kin2_obj) DECLARE_ROM_SEGMENT(object_ishi) diff --git a/include/z64object.h b/include/z64object.h index 3b221088a..306f84ebd 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -404,7 +404,7 @@ typedef enum { /* 0x188 */ OBJECT_FALL, /* 0x189 */ OBJECT_HANAREYAMA_OBJ, /* 0x18A */ OBJECT_CRACE_OBJECT, - /* 0x18B */ OBJECT_DNQ, + /* 0x18B */ OBJECT_DNO, /* 0x18C */ OBJECT_OBJ_TOKEIDAI, /* 0x18D */ OBJECT_EG, /* 0x18E */ OBJECT_TRU, @@ -477,7 +477,7 @@ typedef enum { /* 0x1D1 */ OBJECT_MARUTA, /* 0x1D2 */ OBJECT_GHAKA, /* 0x1D3 */ OBJECT_OYU, - /* 0x1D4 */ OBJECT_DNP, + /* 0x1D4 */ OBJECT_DNQ, /* 0x1D5 */ OBJECT_DAI, /* 0x1D6 */ OBJECT_KGY, /* 0x1D7 */ OBJECT_FB, @@ -508,7 +508,7 @@ typedef enum { /* 0x1F0 */ OBJECT_GI_SEAHORSE, /* 0x1F1 */ OBJECT_BIGPO, /* 0x1F2 */ OBJECT_HARIKO, - /* 0x1F3 */ OBJECT_DNO, + /* 0x1F3 */ OBJECT_DNJ, /* 0x1F4 */ OBJECT_SINKAI_KABE, /* 0x1F5 */ OBJECT_KIN2_OBJ, /* 0x1F6 */ OBJECT_ISHI, diff --git a/spec b/spec index 147e5a77b..284cbc561 100644 --- a/spec +++ b/spec @@ -7013,11 +7013,11 @@ beginseg endseg beginseg - name "object_dnq" + name "object_dno" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dnq/object_dnq.o" + include "build/assets/objects/object_dno/object_dno.o" endseg beginseg @@ -7581,11 +7581,11 @@ beginseg endseg beginseg - name "object_dnp" + name "object_dnq" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dnp/object_dnp.o" + include "build/assets/objects/object_dnq/object_dnq.o" endseg beginseg @@ -7749,11 +7749,11 @@ beginseg endseg beginseg - name "object_dno" + name "object_dnj" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dno/object_dno.o" + include "build/assets/objects/object_dnj/object_dnj.o" endseg beginseg 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 d935a1dae..cb33ce422 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -2,12 +2,16 @@ * File: z_en_dno.c * Overlay: ovl_En_Dno * Description: Deku Butler + * + * This actor's name is probably short for "Dekunuts Ou (king)". This is likely a misnamed actor, + * since it uses assets from object_dnj (probably short for "Dekunuts Jii (grandfather, elderly + * person"). Note that the Deku Princess and King both call the Butler "Jii" in the Japanese text. */ #include "z_en_dno.h" #include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_dno/object_dno.h" +#include "objects/object_dnj/object_dnj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -41,23 +45,23 @@ s32 EnDno_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); 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 }, + { &object_dnj_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dnj_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dnj_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dnj_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dnj_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { ACTOR_EN_DNO, ACTORCAT_NPC, FLAGS, - OBJECT_DNO, + OBJECT_DNJ, sizeof(EnDno), (ActorFunc)EnDno_Init, (ActorFunc)EnDno_Destroy, @@ -194,7 +198,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dno_Skel_00E1F8, &object_dno_Anim_007CA4, + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnj_Skel_00E1F8, &object_dnj_Anim_007CA4, this->jointTable, this->morphTable, 28); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); 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 604453640..667a20b9b 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -2,10 +2,13 @@ * File: z_en_dnp.c * Overlay: ovl_En_Dnp * Description: Deku Princess + * + * This actor's name is probably short for "Dekunuts Princess". It uses assets from object_dnq, + * which is probably short for "Dekunuts Queen". */ #include "z_en_dnp.h" -#include "objects/object_dnp/object_dnp.h" +#include "objects/object_dnq/object_dnq.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -26,7 +29,7 @@ const ActorInit En_Dnp_InitVars = { ACTOR_EN_DNP, ACTORCAT_NPC, FLAGS, - OBJECT_DNP, + OBJECT_DNQ, sizeof(EnDnp), (ActorFunc)EnDnp_Init, (ActorFunc)EnDnp_Destroy, @@ -57,32 +60,32 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &object_dnq_Anim_0007D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0026B8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_004D08, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0071F4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_007960, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_008588, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_00A900, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00AEB8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00B754, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_00674C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00BAD8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_006B74, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_012428, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_00923C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_009AA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00125C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0017F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_001C1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0057AC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_00625C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; static s32 D_80B3DE58[] = { @@ -347,7 +350,7 @@ void EnDnp_Init(Actor* thisx, PlayState* play) { EnDnp* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 16.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dnp_Skel_010D60, NULL, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnq_Skel_010D60, NULL, this->jointTable, this->morphTable, 26); this->unk_340 = -1; func_80B3CC38(this, 15); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -479,10 +482,10 @@ void EnDnp_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnDnp_Draw(Actor* thisx, PlayState* play) { static TexturePtr D_80B3DEAC[] = { - object_dnp_Tex_0103D0, - object_dnp_Tex_0105D0, - object_dnp_Tex_0107D0, - object_dnp_Tex_0109D0, + object_dnq_Tex_0103D0, + object_dnq_Tex_0105D0, + object_dnq_Tex_0107D0, + object_dnq_Tex_0109D0, }; EnDnp* this = THIS; 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 6b21d3fc1..3e252c034 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -2,10 +2,13 @@ * File: z_en_dnq.c * Overlay: ovl_En_Dnq * Description: Deku King + * + * This actor's name is probably short for "Dekunuts Queen". This is likely a misnamed actor, + * since it uses assets from object_dno (probably short for "Dekunuts Ou (king)"). */ #include "z_en_dnq.h" -#include "objects/object_dnq/object_dnq.h" +#include "objects/object_dno/object_dno.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -27,7 +30,7 @@ const ActorInit En_Dnq_InitVars = { ACTOR_EN_DNQ, ACTORCAT_NPC, FLAGS, - OBJECT_DNQ, + OBJECT_DNO, sizeof(EnDnq), (ActorFunc)EnDnq_Init, (ActorFunc)EnDnq_Destroy, @@ -58,26 +61,26 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &object_dno_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dno_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_007528, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_0006F0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dno_Anim_000BF8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_002690, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dno_Anim_002690, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_003408, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_006984, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_005E18, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_005A14, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_005284, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_001AEC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dno_Anim_001100, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dno_Anim_004EA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_00F504, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_0047B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dno_Anim_005A14, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dno_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; s32 EnDnq_ValidatePictograph(PlayState* play, Actor* thisx) { @@ -417,7 +420,7 @@ void EnDnq_Init(Actor* thisx, PlayState* play) { EnDnq* this = THIS; ActorShape_Init(&this->picto.actor.shape, 0.0f, NULL, 14.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dnq_Skel_00EB48, NULL, this->jointTable, this->morphTable, 33); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dno_Skel_00EB48, NULL, this->jointTable, this->morphTable, 33); this->unk_398 = -1; func_80A5257C(this, 0); Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &sCylinderInit); diff --git a/tools/ZAPDConfigs/MM/ObjectList_MM.txt b/tools/ZAPDConfigs/MM/ObjectList_MM.txt index c3848574c..93c17e298 100644 --- a/tools/ZAPDConfigs/MM/ObjectList_MM.txt +++ b/tools/ZAPDConfigs/MM/ObjectList_MM.txt @@ -393,7 +393,7 @@ OBJECT_DRIFTICE OBJECT_FALL OBJECT_HANAREYAMA_OBJ OBJECT_CRACE_OBJECT -OBJECT_DNQ +OBJECT_DNO OBJECT_OBJ_TOKEIDAI OBJECT_EG OBJECT_TRU @@ -466,7 +466,7 @@ OBJECT_GG OBJECT_MARUTA OBJECT_GHAKA OBJECT_OYU -OBJECT_DNP +OBJECT_DNQ OBJECT_DAI OBJECT_KGY OBJECT_FB @@ -497,7 +497,7 @@ OBJECT_GI_LOACH OBJECT_GI_SEAHORSE OBJECT_BIGPO OBJECT_HARIKO -OBJECT_DNO +OBJECT_DNJ OBJECT_SINKAI_KABE OBJECT_KIN2_OBJ OBJECT_ISHI diff --git a/tools/disasm/dma_filenames.txt b/tools/disasm/dma_filenames.txt index e9a743615..aaa17ab6d 100644 --- a/tools/disasm/dma_filenames.txt +++ b/tools/disasm/dma_filenames.txt @@ -885,7 +885,7 @@ 'object_fall', 'object_hanareyama_obj', 'object_crace_object', - 'object_dnq', + 'object_dno', 'object_obj_tokeidai', 'object_eg', 'object_tru', @@ -956,7 +956,7 @@ 'object_maruta', 'object_ghaka', 'object_oyu', - 'object_dnp', + 'object_dnq', 'object_dai', 'object_kgy', 'object_fb', @@ -977,7 +977,7 @@ 'object_gi_seahorse', 'object_bigpo', 'object_hariko', - 'object_dno', + 'object_dnj', 'object_sinkai_kabe', 'object_kin2_obj', 'object_ishi', diff --git a/tools/extract_baserom.py b/tools/extract_baserom.py index bf9829bcb..03d230e80 100755 --- a/tools/extract_baserom.py +++ b/tools/extract_baserom.py @@ -892,7 +892,7 @@ FILE_NAMES = [ 'object_fall', 'object_hanareyama_obj', 'object_crace_object', - 'object_dnq', + 'object_dno', 'object_obj_tokeidai', 'object_eg', 'object_tru', @@ -963,7 +963,7 @@ FILE_NAMES = [ 'object_maruta', 'object_ghaka', 'object_oyu', - 'object_dnp', + 'object_dnq', 'object_dai', 'object_kgy', 'object_fb', @@ -984,7 +984,7 @@ FILE_NAMES = [ 'object_gi_seahorse', 'object_bigpo', 'object_hariko', - 'object_dno', + 'object_dnj', 'object_sinkai_kabe', 'object_kin2_obj', 'object_ishi', diff --git a/tools/filelists/mm.us.rev1/all.csv b/tools/filelists/mm.us.rev1/all.csv index b76d241e1..c23622330 100644 --- a/tools/filelists/mm.us.rev1/all.csv +++ b/tools/filelists/mm.us.rev1/all.csv @@ -883,7 +883,7 @@ 882,object_fall 883,object_hanareyama_obj 884,object_crace_object -885,object_dnq +885,object_dno 886,object_obj_tokeidai 887,object_eg 888,object_tru @@ -954,7 +954,7 @@ 953,object_maruta 954,object_ghaka 955,object_oyu -956,object_dnp +956,object_dnq 957,object_dai 958,object_kgy 959,object_fb @@ -975,7 +975,7 @@ 974,object_gi_seahorse 975,object_bigpo 976,object_hariko -977,object_dno +977,object_dnj 978,object_sinkai_kabe 979,object_kin2_obj 980,object_ishi diff --git a/tools/filelists/mm.us.rev1/objects.csv b/tools/filelists/mm.us.rev1/objects.csv index 187ec1c11..2e572503e 100644 --- a/tools/filelists/mm.us.rev1/objects.csv +++ b/tools/filelists/mm.us.rev1/objects.csv @@ -233,7 +233,7 @@ 882,object_fall 883,object_hanareyama_obj 884,object_crace_object -885,object_dnq +885,object_dno 886,object_obj_tokeidai 887,object_eg 888,object_tru @@ -304,7 +304,7 @@ 953,object_maruta 954,object_ghaka 955,object_oyu -956,object_dnp +956,object_dnq 957,object_dai 958,object_kgy 959,object_fb @@ -325,7 +325,7 @@ 974,object_gi_seahorse 975,object_bigpo 976,object_hariko -977,object_dno +977,object_dnj 978,object_sinkai_kabe 979,object_kin2_obj 980,object_ishi From 363a7cda46c19502f6b064bb1fa47b0f7c18f592 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 26 Sep 2022 23:35:50 -0300 Subject: [PATCH 42/73] ovl_Oceff_Wipe4 OK (#1007) * ovl_Oceff_Wipe4 decompiled * pr review * renamings * renamings * Material -> Model * pr review * Magic_Reset --- assets/xml/overlays/ovl_Oceff_Wipe4.xml | 12 +++ spec | 4 +- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 86 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h | 7 +- 4 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe4.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe4.xml b/assets/xml/overlays/ovl_Oceff_Wipe4.xml new file mode 100644 index 000000000..995ad18b1 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe4.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spec b/spec index 284cbc561..7f44f277e 100644 --- a/spec +++ b/spec @@ -2080,9 +2080,7 @@ beginseg name "ovl_Oceff_Wipe4" compress include "build/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.data.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.bss.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4_reloc.o" endseg beginseg 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 56942962d..18fecfe71 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -15,7 +15,6 @@ void OceffWipe4_Destroy(Actor* thisx, PlayState* play); void OceffWipe4_Update(Actor* thisx, PlayState* play); void OceffWipe4_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe4_InitVars = { ACTOR_OCEFF_WIPE4, ACTORCAT_ITEMACTION, @@ -28,12 +27,87 @@ const ActorInit Oceff_Wipe4_InitVars = { (ActorFunc)OceffWipe4_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Init.s") +s32 D_8099E780; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Destroy.s") +void OceffWipe4_Init(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Draw.s") +void OceffWipe4_Destroy(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; + + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe4_Update(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 50) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe4_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffWipe4* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + if (this->counter < 16) { + z = Math_SinS(this->counter * 0x400) * 1220.0f; + } else { + z = 1220.0f; + } + + vtxPtr = sScarecrowSongFrustumVtx; + if (this->counter >= 30) { + alpha = 12 * (50 - this->counter); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[17].v.cn[3] = vtxPtr[19].v.cn[3] = + vtxPtr[21].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->actor.params == OCEFF_WIPE4_UNUSED) { + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongUnusedMaterialDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongMaterialDL); + } + + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongModelDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 2, scroll * -2, 32, + 64, 1, scroll * -1, scroll, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, &sScarecrowSongModelDL[11]); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h index 76debbeed..59b592318 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h @@ -3,11 +3,16 @@ #include "global.h" +typedef enum { + /* 0 */ OCEFF_WIPE4_SCARECROWS, + /* 1 */ OCEFF_WIPE4_UNUSED +} OceffWipe4Type; + struct OceffWipe4; typedef struct OceffWipe4 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe4; // size = 0x148 extern const ActorInit Oceff_Wipe4_InitVars; From ee82e65c1a8273615095fd153fc677065b14ff45 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 26 Sep 2022 23:37:00 -0400 Subject: [PATCH 43/73] z_kaleido_item.c Ok and Documented (Pause Menu Item Page) (#1027) * import wip from kaleido * small cleanup * add for-loop comments * pr review 1 * spacing * Update src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c Co-authored-by: EllipticEllipsis Co-authored-by: EllipticEllipsis --- docs/tutorial/object_decomp_example.md | 2 +- include/functions.h | 8 +- include/z64.h | 22 +- include/z64item.h | 4 +- src/code/z_kaleido_setup.c | 28 +- src/code/z_message.c | 2 +- src/code/z_message_nes.c | 2 +- src/code/z_player_lib.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 6 +- .../ovl_kaleido_scope/z_kaleido_debug.c | 8 +- .../ovl_kaleido_scope/z_kaleido_item.c | 1017 ++++++++++++++++- .../ovl_kaleido_scope/z_kaleido_scope.h | 32 +- .../ovl_kaleido_scope/z_kaleido_scope_NES.c | 4 +- tools/disasm/functions.txt | 14 +- tools/disasm/variables.txt | 20 +- 15 files changed, 1054 insertions(+), 117 deletions(-) diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md index d1cc4738a..f4030be5b 100644 --- a/docs/tutorial/object_decomp_example.md +++ b/docs/tutorial/object_decomp_example.md @@ -149,7 +149,7 @@ Gfx object_dns_DL_001A50[] = { }; ``` -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: +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 RGBA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: ```xml diff --git a/include/functions.h b/include/functions.h index f73f95a96..05db21f4f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1807,13 +1807,13 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b); void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); // void func_8010CB80(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void func_8010CD98(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); +Gfx* func_8010CD98(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); // void func_8010CFBC(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); // void func_8010D2D4(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11); // void func_8010D480(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16); // void func_8010D7D0(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); // void func_8010D9F4(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); -// void func_8010DC58(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +Gfx* func_8010DC58(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, u16 i); // void func_8010DE38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // void func_8010E028(void); // void func_8010E968(void); @@ -1903,7 +1903,7 @@ void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 al void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1); void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1); u8 Player_MaskIdToItemId(s32 maskIdMinusOne); -u8 Player_GetCurMaskItemId(PlayState* play); +s32 Player_GetCurMaskItemId(PlayState* play); void func_80122F28(Player* player); s32 func_80122F9C(PlayState* play); s32 func_80122FCC(PlayState* play); @@ -2402,7 +2402,7 @@ void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_ // void func_8014D7B4(void); void func_80150A84(PlayState* play); void func_80150D08(PlayState* play, u32 uParm2); -// void func_801514B0(void); +void func_801514B0(PlayState* play, u16 arg1, u8 arg2); void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor); void func_80151938(PlayState* play, u16 textId); void func_80151A68(PlayState* play, u16 textId); diff --git a/include/z64.h b/include/z64.h index 197396216..e161b723f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -444,15 +444,15 @@ typedef struct { /* 0x22C */ s32 unk_22C; /* 0x230 */ s32 stickRelX; /* 0x234 */ s32 stickRelY; - /* 0x238 */ s16 unk_238[5]; - /* 0x242 */ s16 unk_242[5]; - /* 0x24C */ s16 unk_24C[5]; + /* 0x238 */ s16 cursorPoint[5]; + /* 0x242 */ s16 cursorX[5]; + /* 0x24C */ s16 cursorY[5]; /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; + /* 0x258 */ s16 cursorSpecialPos; + /* 0x25A */ s16 pageSwitchTimer; /* 0x25C */ u16 unk_25C; /* 0x25E */ u16 cursorItem[5]; - /* 0x268 */ u16 unk_268[5]; + /* 0x268 */ u16 cursorSlot[5]; /* 0x272 */ u16 equipTargetItem; /* 0x274 */ u16 equipTargetSlot; /* 0x276 */ u16 equipTargetCBtn; @@ -461,8 +461,8 @@ typedef struct { /* 0x27C */ s16 equipAnimAlpha; /* 0x27E */ s16 unk_27E; /* 0x280 */ u16 unk_280; - /* 0x282 */ u16 unk_282; - /* 0x284 */ s16 unk_284; + /* 0x282 */ u16 nameColorSet; + /* 0x284 */ s16 cursorColorSet; /* 0x286 */ s16 unk_286; /* 0x288 */ f32 unk_288; /* 0x28C */ f32 unk_28C; @@ -476,9 +476,9 @@ typedef struct { /* 0x2B6 */ u8 unk_2B6; /* 0x2B7 */ u8 unk_2B7; /* 0x2B8 */ u8 unk_2B8; - /* 0x2B9 */ u8 unk_2B9; - /* 0x2BA */ s16 unk_2BA; - /* 0x2BC */ s16 unk_2BC; + /* 0x2B9 */ u8 itemDescriptionOn; // helpful description of item given through a message box + /* 0x2BA */ s16 equipAnimScale; // scale of item icon while moving being equipped to c-button + /* 0x2BC */ s16 equipAnimShrinkRate; // rate the scale is shrinking for the item icon while moving being equipped to c-button /* 0x2BE */ s16 unk_2BE[5]; /* 0x2C8 */ u16 unk_2C8; /* 0x2CA */ s16 unk_2CA; diff --git a/include/z64item.h b/include/z64item.h index f68355858..d8a2185cc 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -285,7 +285,7 @@ typedef enum { /* 0xF2 */ ITEM_F2, /* 0xFD */ ITEM_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF -} ItemID; +} ItemId; #define BOTTLE_FIRST 0 #define BOTTLE_MAX 6 @@ -428,7 +428,7 @@ typedef enum { /* 0xB8 */ GI_TINGLE_MAP_GREAT_BAY, /* 0xB9 */ GI_TINGLE_MAP_STONE_TOWER, /* 0xBA */ GI_MAX -} GetItemID; +} GetItemId; typedef enum { /* 0x00 */ GID_BOTTLE, diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index b054dac74..50022849e 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -33,12 +33,12 @@ void func_800F4A10(PlayState* play) { for (i = 9; i >= 0; i--) { if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { pauseCtx->worldMapPoints[i] = 1; - pauseCtx->unk_238[4] = i; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = i; } } if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { - pauseCtx->unk_238[4] = 4; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 4; } } @@ -82,7 +82,7 @@ void KaleidoSetup_Update(PlayState* play) { !(play->actorCtx.flags & ACTORCTX_FLAG_2)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { gSaveContext.unk_3F26 = gSaveContext.unk_3F22; - pauseCtx->unk_2B9 = 0; + pauseCtx->itemDescriptionOn = false; pauseCtx->state = 1; func_800F4A10(play); pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; @@ -122,23 +122,23 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->unk_20C = 936.0f; pauseCtx->unk_220 = -314.0f; - pauseCtx->unk_238[PAUSE_MAP] = XREG(94) + 3; + pauseCtx->cursorPoint[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->unk_258 = 11; - pauseCtx->unk_25A = 0; + pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; + pauseCtx->pageSwitchTimer = 0; - pauseCtx->cursorItem[PAUSE_ITEM] = 999; + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; pauseCtx->cursorItem[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->cursorItem[PAUSE_QUEST] = 999; - pauseCtx->cursorItem[PAUSE_MASK] = 999; + pauseCtx->cursorItem[PAUSE_QUEST] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; - pauseCtx->unk_268[PAUSE_ITEM] = 0; - pauseCtx->unk_268[PAUSE_MAP] = XREG(94) + 3; + pauseCtx->cursorSlot[PAUSE_ITEM] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->unk_284 = 2; + pauseCtx->cursorColorSet = 2; pauseCtx->unk_2A0 = -1; - pauseCtx->unk_2BA = 320; - pauseCtx->unk_2BC = 40; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; pauseCtx->promptAlpha = 100; View_Init(&pauseCtx->view, play->state.gfxCtx); diff --git a/src/code/z_message.c b/src/code/z_message.c index 16e1203d7..f98d3cf3a 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -270,7 +270,7 @@ void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) { phi_v0 = 0xA; } else { - phi_v0 = pauseCtx->unk_238[PAUSE_WORLD_MAP]; + phi_v0 = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; } temp_s6 = D_801D0250[phi_v0]; diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 9231ca9b9..1ac301f20 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -257,7 +257,7 @@ void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decod if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) { currentArea = 10; } else { - currentArea = play->pauseCtx.unk_238[PAUSE_WORLD_MAP]; + currentArea = play->pauseCtx.cursorPoint[PAUSE_WORLD_MAP]; } stringLimit = D_801D07C4[currentArea]; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 1566077f1..8ced31cb7 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -274,7 +274,7 @@ u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { return sMaskItemIds[maskIdMinusOne]; } -u8 Player_GetCurMaskItemId(PlayState* play) { +s32 Player_GetCurMaskItemId(PlayState* play) { Player* player = GET_PLAYER(play); if (player->currentMask != PLAYER_MASK_NONE) { 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 0c00c6040..07de01c12 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -922,11 +922,7 @@ void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { - if (player->heldItemButton == 0) { - buttonItem = CUR_FORM_EQUIP(player->heldItemButton); - } else { - buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; - } + buttonItem = GET_CUR_FORM_BTN_ITEM(player->heldItemButton); this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { player->actor.textId = 0x29EF; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 2854b02c6..9f6a58a86 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -34,10 +34,10 @@ s16 sCurRow = 0; // Geometry of the highlights for the selected section typedef struct { - /* 0 */ s16 screenX; - /* 1 */ s16 screenY; - /* 2 */ s16 width; -} SectionPosition; + /* 0x0 */ s16 screenX; + /* 0x2 */ s16 screenY; + /* 0x4 */ s16 width; +} SectionPosition; // size = 0x6; // clang-format off SectionPosition sSectionPositions[] = { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index ae2140f2c..888f715c0 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -1,85 +1,1004 @@ /* * File: z_kaleido_item.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Item Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +typedef enum { + /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, + /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, + /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, + /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN +} EquipState; -s32 D_8082B3C0 = 0; +s16 sEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -s32 D_8082B3C4 = 0; +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sEquipMagicArrowSlotHoldTimer = 0; -s16 D_8082B3C8 = 10; +// Number of frames to move icon from slot to target position when equipping. +s16 sEquipAnimTimer = 10; -u8 D_8082B3CC[5][24] = { +u8 gPlayerFormSlotRestrictions[PLAYER_FORM_MAX][24] = { + // Fierce Deity { - false, false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, true, true, true, + false, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + false, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + false, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + false, // SLOT_PICTO_BOX + false, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + false, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Goron { - true, false, false, false, false, true, false, false, false, false, false, true, - true, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + true, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Zora { - true, false, false, false, false, true, false, false, false, false, false, true, - false, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Deku { - true, false, false, false, false, true, false, false, false, true, false, true, - false, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + true, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Human { - true, true, true, true, true, true, true, true, true, true, true, true, - false, true, true, true, true, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + true, // SLOT_BOW + true, // SLOT_ARROW_FIRE + true, // SLOT_ARROW_ICE + true, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + true, // SLOT_BOMB + true, // SLOT_BOMBCHU + true, // SLOT_STICK + true, // SLOT_NUT + true, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + true, // SLOT_HOOKSHOT + true, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, }; -s16 D_8082B444[] = { - 0x005F, 0x003E, 0x005F, 0x0080, 0x00A1, 0x00C2, 0x003E, 0x005F, +s16 sAmmoRectLeft[] = { + 95, // SLOT_BOW + 62, // SLOT_BOMB + 95, // SLOT_BOMBCHU + 128, // SLOT_STICK + 161, // SLOT_NUT + 194, // SLOT_MAGIC_BEANS + 62, // SLOT_POWDER_KEG + 95, // SLOT_PICTO_BOX }; -s16 D_8082B454[] = { - 0x0055, 0x0075, 0x0075, 0x0075, 0x0075, 0x0075, 0x0096, 0x0096, 0x00FF, 0x0064, - 0x00FF, 0x0000, 0x0000, 0x0064, 0x00FF, 0x0000, 0x0000, 0x00FF, 0x0064, 0x0000, +s16 sAmmoRectHeight[] = { + 85, // SLOT_BOW + 117, // SLOT_BOMB + 117, // SLOT_BOMBCHU + 117, // SLOT_STICK + 117, // SLOT_NUT + 117, // SLOT_MAGIC_BEANS + 150, // SLOT_POWDER_KEG + 150, // SLOT_PICTO_BOX }; -u8 D_8082B47C[] = { - 0x35, 0x33, 0x34, 0x32, 0xFF, +void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, u16 ammoIndex) { + s16 ammoUpperDigit; + s16 ammo; + + OPEN_DISPS(gfxCtx); + + if (item == ITEM_PICTO_BOX) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + ammo = 0; + } else { + ammo = 1; + } + } else { + ammo = AMMO(item); + } + + gDPPipeSync(POLY_OPA_DISP++); + + if (!gPlayerFormSlotRestrictions[((void)0, gSaveContext.save.playerForm)][SLOT(item)]) { + // Ammo item is restricted + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); + } else { + // Default ammo + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + if (ammo == 0) { + // Out of ammo + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 130, 130, 130, pauseCtx->alpha); + } else if (((item == ITEM_BOMB) && (AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((item == ITEM_BOW) && (AMMO(item) == CUR_CAPACITY(UPG_QUIVER))) || + ((item == ITEM_STICK) && (AMMO(item) == CUR_CAPACITY(UPG_STICKS))) || + ((item == ITEM_NUT) && (AMMO(item) == CUR_CAPACITY(UPG_NUTS))) || + ((item == ITEM_BOMBCHU) && (AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((item == ITEM_POWDER_KEG) && (ammo == 1)) || ((item == ITEM_PICTO_BOX) && (ammo == 1)) || + ((item == ITEM_MAGIC_BEANS) && (ammo == 20))) { + // Ammo at capacity + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 255, 0, pauseCtx->alpha); + } + } + + // Separate ammo into upper and lower digits + for (ammoUpperDigit = 0; ammo >= 10; ammoUpperDigit++) { + ammo -= 10; + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw upper digit + if (ammoUpperDigit != 0) { + POLY_OPA_DISP = func_8010CD98(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammoUpperDigit)), 8, 8, + sAmmoRectLeft[ammoIndex], sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + } + + // Draw lower digit + POLY_OPA_DISP = func_8010CD98(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammo)), 8, 8, + sAmmoRectLeft[ammoIndex] + 6, sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + + CLOSE_DISPS(gfxCtx); +} + +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx) { + pauseCtx->cursorVtx[0].v.ob[0] = vtx[index].v.ob[0]; + pauseCtx->cursorVtx[0].v.ob[1] = vtx[index].v.ob[1]; +} + +s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; + +void KaleidoScope_DrawItemSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = 24 * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) < 24) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j], 4, 0); + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < 24; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + if ((pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0) && + gPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], pauseCtx->alpha); + + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + + } else if (i == pauseCtx->cursorSlot[PAUSE_ITEM]) { + // Increase the size of the selected item + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32(play->state.gfxCtx, + gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); + } + } + + // Draw the ammo digits + if (pauseCtx->pageIndex == PAUSE_ITEM) { + if ((pauseCtx->state == 6) && ((pauseCtx->unk_200 == 0) || (pauseCtx->unk_200 == 3)) && + (pauseCtx->state != 7) && ((pauseCtx->state < 8) || (pauseCtx->state >= 0x13))) { + func_8012C628(play->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + // Loop over slots (i) and ammoIndex (j) + for (j = 0, i = 0; i < 24; i++) { + if (gAmmoItems[i] != ITEM_NONE) { + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, + ((void)0, gSaveContext.save.inventory.items[i]), j); + } + j++; + } + } + func_8012C8AC(play->state.gfxCtx); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, }; -s16 D_8082B484[] = { - 0x0294, - 0x0384, - 0x0474, - 0x0000, -}; +void KaleidoScope_UpdateItemCursor(PlayState* play) { + s32 pad1; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + u8 magicArrowIndex; + s16 cursorPoint; + s16 cursorX; + s16 cursorY; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; -s16 D_8082B48C[] = { - 0x044C, - 0x0398, - 0x044C, - 0x0000, -}; + pauseCtx->cursorColorSet = 0; + pauseCtx->nameColorSet = 0; -s32 D_8082B494[] = { 0, 0, 0 }; + if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && + !pauseCtx->itemDescriptionOn) { + moveCursorResult = 0; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B240.s") + cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6BC.s") + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = 2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6EC.s") + if (ABS_ALT(pauseCtx->stickRelX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorX = pauseCtx->cursorX[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081BCA8.s") + // Search for slot to move to + while (moveCursorResult == 0) { + if (pauseCtx->stickRelX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { + pauseCtx->cursorX[PAUSE_ITEM]--; + pauseCtx->cursorPoint[PAUSE_ITEM]--; + moveCursorResult = 1; + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM]++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081C684.s") + if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { + pauseCtx->cursorY[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = 2; + } + } + } else if (pauseCtx->stickRelX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorX[PAUSE_ITEM] <= 4) { + pauseCtx->cursorX[PAUSE_ITEM]++; + pauseCtx->cursorPoint[PAUSE_ITEM]++; + moveCursorResult = 1; + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM]++; + + if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { + pauseCtx->cursorY[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = 2; + } + } + } + } + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + func_80821A04(play); + cursorY = 0; + cursorX = 0; + cursorPoint = 0; // top row, left column (SLOT_OCARINA) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + // move 1 row down and retry + cursorY++; + cursorPoint += 6; + if (cursorY < 4) { + continue; + } + + // move 1 column right and retry + cursorY = 0; + cursorPoint = cursorX + 1; + cursorX = cursorPoint; + if (cursorX < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + if (pauseCtx->stickRelX < -30) { + func_80821A04(play); + cursorX = 5; + cursorPoint = 5; // top row, right columne (SLOT_TRADE_DEED) + cursorY = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + // move 1 row down and retry + cursorY++; + cursorPoint += 6; + if (cursorY < 4) { + continue; + } + + // move 1 column left and retry + cursorY = 0; + cursorPoint = cursorX - 1; + cursorX = cursorPoint; + if (cursorX >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickRelY) > 30) { + moveCursorResult = 0; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + + while (moveCursorResult == 0) { + if (pauseCtx->stickRelY > 30) { + // move cursor up + moveCursorResult = 2; + if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { + pauseCtx->cursorY[PAUSE_ITEM]--; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; + moveCursorResult = 1; + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } else if (pauseCtx->stickRelY < -30) { + // move cursor down + moveCursorResult = 2; + if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { + pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] += 6; + moveCursorResult = 1; + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; + pauseCtx->cursorColorSet = 2; + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } else if (moveCursorResult != 2) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = 0; + } + + if ((cursorItem != (u32)PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.unk_3F22 = 0; + Interface_ChangeAlpha(50); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.unk_3F22 = 0; + Interface_ChangeAlpha(50); + } + + pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; + pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a transformation mask can not be unequipped while being used + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (1) {} + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + } + + // Ensure that a non-transformation mask can not be unequipped while being used + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot; + pauseCtx->unk_200 = 3; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->itemVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->itemVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sEquipMagicArrowSlotHoldTimer = 0; + sEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sEquipAnimTimer = 10; + + if ((pauseCtx->equipTargetItem == ITEM_ARROW_FIRE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT)) { + magicArrowIndex = 0; + if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) { + magicArrowIndex = 1; + } + if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) { + magicArrowIndex = 2; + } + play_sound(NA_SE_SY_SET_FIRE_ARROW + magicArrowIndex); + pauseCtx->equipTargetItem = 0xB5 + magicArrowIndex; + pauseCtx->equipAnimAlpha = sEquipState = 0; // EQUIP_STATE_MAGIC_ARROW_GROW_ORB + sEquipAnimTimer = 6; + } else { + play_sound(NA_SE_SY_DECIDE); + } + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == 6) && + (pauseCtx->unk_200 == 0) && CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && + (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorY[PAUSE_ITEM] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_ITEM]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->unk_200 == 3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + pauseCtx->cursorColorSet = 2; + } +} + +s16 sCButtonPosX[] = { 660, 900, 1140 }; +s16 sCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateItemEquip(PlayState* play) { + static s16 sEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sEquipMagicArrowBowSlotHoldTimer--; + + if (sEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[4]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sCButtonPosX[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sCButtonPosY[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[4].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[4].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + if (pauseCtx->equipAnimX >= sCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sEquipAnimTimer--; + if (sEquipAnimTimer == 0) { + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sEquipState++; + sEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip item onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if item is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if item is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if item is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } + + // Equip item on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->unk_200 = 0; + sEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sEquipMagicArrowSlotHoldTimer--; + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index b4d2a192f..19e3c8719 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -3,14 +3,25 @@ #include "global.h" +#define PAUSE_ITEM_NONE 999 + +#define PAUSE_CURSOR_PAGE_LEFT 10 +#define PAUSE_CURSOR_PAGE_RIGHT 11 + typedef enum { - /* 0x00 */ PAUSE_ITEM, - /* 0x01 */ PAUSE_MAP, - /* 0x02 */ PAUSE_QUEST, - /* 0x03 */ PAUSE_MASK, - /* 0x04 */ PAUSE_WORLD_MAP + /* 0 */ PAUSE_ITEM, + /* 1 */ PAUSE_MAP, + /* 2 */ PAUSE_QUEST, + /* 3 */ PAUSE_MASK, + /* 4 */ PAUSE_WORLD_MAP } PauseMenuPage; +typedef enum { + /* 0 */ PAUSE_EQUIP_C_LEFT, + /* 1 */ PAUSE_EQUIP_C_DOWN, + /* 2 */ PAUSE_EQUIP_C_RIGHT +} PauseEquipCButton; + typedef enum { /* 0 */ DEBUG_EDITOR_NONE, /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, @@ -21,6 +32,17 @@ typedef enum { #define PAUSE_PROMPT_YES 0 #define PAUSE_PROMPT_NO 4 +// NES +void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos); +void KaleidoScope_DrawQuadTextureRGBA32(GraphicsContext* gfxCtx, void* texture, u16 width, u16 height, u16 point); +void func_80821A04(PlayState* play); + +// Item +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); +void KaleidoScope_DrawItemSelect(PlayState* play); +void KaleidoScope_UpdateItemCursor(PlayState* play); +void KaleidoScope_UpdateItemEquip(PlayState* play); + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 44575f156..c02ebcad2 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -318,11 +318,11 @@ s32 D_8082BEB8[] = { 0, 0 }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821958.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821984.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_MoveCursorToSpecialPos.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821AD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuadTextureRGBA32.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f2af2a653..edd85dc51 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4204,11 +4204,11 @@ 0x808190C4:("KaleidoScope_DrawDigit",), 0x80819238:("KaleidoScope_DrawInventoryEditor",), 0x80819F04:("KaleidoScope_UpdateInventoryEditor",), - 0x8081B240:("func_8081B240",), - 0x8081B6BC:("func_8081B6BC",), - 0x8081B6EC:("func_8081B6EC",), - 0x8081BCA8:("func_8081BCA8",), - 0x8081C684:("func_8081C684",), + 0x8081B240:("KaleidoScope_DrawAmmoCount",), + 0x8081B6BC:("KaleidoScope_SetCursorVtx",), + 0x8081B6EC:("KaleidoScope_DrawItemSelect",), + 0x8081BCA8:("KaleidoScope_UpdateItemCursor",), + 0x8081C684:("KaleidoScope_UpdateItemEquip",), 0x8081D240:("func_8081D240",), 0x8081D6DC:("func_8081D6DC",), 0x8081E118:("func_8081E118",), @@ -4221,9 +4221,9 @@ 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), 0x80821958:("func_80821958",), - 0x80821984:("func_80821984",), + 0x80821984:("KaleidoScope_MoveCursorToSpecialPos",), 0x80821A04:("func_80821A04",), - 0x80821AD4:("func_80821AD4",), + 0x80821AD4:("KaleidoScope_DrawQuadTextureRGBA32",), 0x80821CC4:("func_80821CC4",), 0x80821D84:("func_80821D84",), 0x80821F30:("func_80821F30",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f21fc7d98..82acecd8d 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4693,16 +4693,16 @@ 0x8082B388:("sRowFirstSections","UNK_TYPE2","",0x2), 0x8082B3AC:("sPrevDBtnInput","UNK_TYPE4","",0x4), 0x8082B3B0:("sHeldDBtnTimer","UNK_TYPE4","",0x4), - 0x8082B3C0:("D_8082B3C0","UNK_TYPE2","",0x2), - 0x8082B3C4:("D_8082B3C4","UNK_TYPE2","",0x2), - 0x8082B3C8:("D_8082B3C8","UNK_TYPE2","",0x2), - 0x8082B3CC:("D_8082B3CC","UNK_TYPE1","",0x1), - 0x8082B444:("D_8082B444","UNK_TYPE1","",0x1), - 0x8082B454:("D_8082B454","UNK_TYPE1","",0x1), - 0x8082B47C:("D_8082B47C","UNK_TYPE1","",0x1), - 0x8082B484:("D_8082B484","UNK_TYPE1","",0x1), - 0x8082B48C:("D_8082B48C","UNK_TYPE1","",0x1), - 0x8082B494:("D_8082B494","UNK_TYPE2","",0x2), + 0x8082B3C0:("sEquipState","UNK_TYPE2","",0x2), + 0x8082B3C4:("sEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B3C8:("sEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B3CC:("gPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B444:("sAmmoRectLeft","UNK_TYPE1","",0x1), + 0x8082B454:("sAmmoRectHeight","UNK_TYPE1","",0x1), + 0x8082B47C:("sPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B484:("sCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B48C:("sCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B494:("sEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), 0x8082B4A0:("D_8082B4A0","UNK_TYPE4","",0x4), 0x8082B4AC:("D_8082B4AC","UNK_TYPE1","",0x1), 0x8082B4BC:("D_8082B4BC","UNK_TYPE1","",0x1), From 77d8e386a3e354bf59f87f5fa1f399b8021cc758 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 27 Sep 2022 05:42:15 -0700 Subject: [PATCH 44/73] Add comments to everything in the scene enum (#1052) * Add comments to everything in the scene enum * Respond to isghj5's review * Respond to Elliptic's review --- include/z64scene.h | 204 ++++++++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/include/z64scene.h b/include/z64scene.h index 6a0808b55..649a4e011 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -534,119 +534,119 @@ typedef union { } SceneCmd; // size = 0x8 typedef enum { - /* 0x00 */ SCENE_20SICHITAI2, + /* 0x00 */ SCENE_20SICHITAI2, // Southern Swamp (Clear) /* 0x01 */ SCENE_UNSET_1, /* 0x02 */ SCENE_UNSET_2, /* 0x03 */ SCENE_UNSET_3, /* 0x04 */ SCENE_UNSET_4, /* 0x05 */ SCENE_UNSET_5, /* 0x06 */ SCENE_UNSET_6, - /* 0x07 */ SCENE_KAKUSIANA, - /* 0x08 */ SCENE_SPOT00, + /* 0x07 */ SCENE_KAKUSIANA, // Lone Peak Shrine & Grottos + /* 0x08 */ SCENE_SPOT00, // Cutscene Scene /* 0x09 */ SCENE_UNSET_9, - /* 0x0A */ SCENE_WITCH_SHOP, - /* 0x0B */ SCENE_LAST_BS, - /* 0x0C */ SCENE_HAKASHITA, - /* 0x0D */ SCENE_AYASHIISHOP, + /* 0x0A */ SCENE_WITCH_SHOP, // Magic Hags' Potion Shop + /* 0x0B */ SCENE_LAST_BS, // Majora's Lair + /* 0x0C */ SCENE_HAKASHITA, // Beneath the Graveyard + /* 0x0D */ SCENE_AYASHIISHOP, // Curiosity Shop /* 0x0E */ SCENE_UNSET_E, /* 0x0F */ SCENE_UNSET_F, - /* 0x10 */ SCENE_OMOYA, - /* 0x11 */ SCENE_BOWLING, - /* 0x12 */ SCENE_SONCHONOIE, - /* 0x13 */ SCENE_IKANA, - /* 0x14 */ SCENE_KAIZOKU, - /* 0x15 */ SCENE_MILK_BAR, - /* 0x16 */ SCENE_INISIE_N, - /* 0x17 */ SCENE_TAKARAYA, - /* 0x18 */ SCENE_INISIE_R, - /* 0x19 */ SCENE_OKUJOU, - /* 0x1A */ SCENE_OPENINGDAN, - /* 0x1B */ SCENE_MITURIN, - /* 0x1C */ SCENE_13HUBUKINOMITI, - /* 0x1D */ SCENE_CASTLE, - /* 0x1E */ SCENE_DEKUTES, - /* 0x1F */ SCENE_MITURIN_BS, - /* 0x20 */ SCENE_SYATEKI_MIZU, - /* 0x21 */ SCENE_HAKUGIN, - /* 0x22 */ SCENE_ROMANYMAE, - /* 0x23 */ SCENE_PIRATE, - /* 0x24 */ SCENE_SYATEKI_MORI, - /* 0x25 */ SCENE_SINKAI, - /* 0x26 */ SCENE_YOUSEI_IZUMI, - /* 0x27 */ SCENE_KINSTA1, - /* 0x28 */ SCENE_KINDAN2, - /* 0x29 */ SCENE_TENMON_DAI, - /* 0x2A */ SCENE_LAST_DEKU, - /* 0x2B */ SCENE_22DEKUCITY, - /* 0x2C */ SCENE_KAJIYA, - /* 0x2D */ SCENE_00KEIKOKU, - /* 0x2E */ SCENE_POSTHOUSE, - /* 0x2F */ SCENE_LABO, - /* 0x30 */ SCENE_DANPEI2TEST, + /* 0x10 */ SCENE_OMOYA, // Mama's House (Ranch House in PAL) & Barn + /* 0x11 */ SCENE_BOWLING, // Honey & Darling's Shop + /* 0x12 */ SCENE_SONCHONOIE, // The Mayor's Residence + /* 0x13 */ SCENE_IKANA, // Ikana Canyon + /* 0x14 */ SCENE_KAIZOKU, // Pirates' Fortress + /* 0x15 */ SCENE_MILK_BAR, // Milk Bar + /* 0x16 */ SCENE_INISIE_N, // Stone Tower Temple + /* 0x17 */ SCENE_TAKARAYA, // Treasure Chest Shop + /* 0x18 */ SCENE_INISIE_R, // Inverted Stone Tower Temple + /* 0x19 */ SCENE_OKUJOU, // Clock Tower Rooftop + /* 0x1A */ SCENE_OPENINGDAN, // Before Clock Town + /* 0x1B */ SCENE_MITURIN, // Woodfall Temple + /* 0x1C */ SCENE_13HUBUKINOMITI, // Path to Mountain Village + /* 0x1D */ SCENE_CASTLE, // Ancient Castle of Ikana + /* 0x1E */ SCENE_DEKUTES, // Deku Scrub Playground + /* 0x1F */ SCENE_MITURIN_BS, // Odolwa's Lair + /* 0x20 */ SCENE_SYATEKI_MIZU, // Town Shooting Gallery + /* 0x21 */ SCENE_HAKUGIN, // Snowhead Temple + /* 0x22 */ SCENE_ROMANYMAE, // Milk Road + /* 0x23 */ SCENE_PIRATE, // Pirates' Fortress Interior + /* 0x24 */ SCENE_SYATEKI_MORI, // Swamp Shooting Gallery + /* 0x25 */ SCENE_SINKAI, // Pinnacle Rock + /* 0x26 */ SCENE_YOUSEI_IZUMI, // Fairy's Fountain + /* 0x27 */ SCENE_KINSTA1, // Swamp Spider House + /* 0x28 */ SCENE_KINDAN2, // Oceanside Spider House + /* 0x29 */ SCENE_TENMON_DAI, // Astral Observatory + /* 0x2A */ SCENE_LAST_DEKU, // Moon Deku Trial + /* 0x2B */ SCENE_22DEKUCITY, // Deku Palace + /* 0x2C */ SCENE_KAJIYA, // Mountain Smithy + /* 0x2D */ SCENE_00KEIKOKU, // Termina Field + /* 0x2E */ SCENE_POSTHOUSE, // Post Office + /* 0x2F */ SCENE_LABO, // Marine Research Lab + /* 0x30 */ SCENE_DANPEI2TEST, // Beneath the Graveyard (Day 3) and Dampe's House /* 0x31 */ SCENE_UNSET_31, - /* 0x32 */ SCENE_16GORON_HOUSE, - /* 0x33 */ SCENE_33ZORACITY, - /* 0x34 */ SCENE_8ITEMSHOP, - /* 0x35 */ SCENE_F01, - /* 0x36 */ SCENE_INISIE_BS, - /* 0x37 */ SCENE_30GYOSON, - /* 0x38 */ SCENE_31MISAKI, - /* 0x39 */ SCENE_TAKARAKUJI, + /* 0x32 */ SCENE_16GORON_HOUSE, // Goron Shrine + /* 0x33 */ SCENE_33ZORACITY, // Zora Hall + /* 0x34 */ SCENE_8ITEMSHOP, // Trading Post + /* 0x35 */ SCENE_F01, // Romani Ranch + /* 0x36 */ SCENE_INISIE_BS, // Twinmold's Lair + /* 0x37 */ SCENE_30GYOSON, // Great Bay Coast + /* 0x38 */ SCENE_31MISAKI, // Zora Cape + /* 0x39 */ SCENE_TAKARAKUJI, // Lottery Shop /* 0x3A */ SCENE_UNSET_3A, - /* 0x3B */ SCENE_TORIDE, - /* 0x3C */ SCENE_FISHERMAN, - /* 0x3D */ SCENE_GORONSHOP, - /* 0x3E */ SCENE_DEKU_KING, - /* 0x3F */ SCENE_LAST_GORON, - /* 0x40 */ SCENE_24KEMONOMITI, - /* 0x41 */ SCENE_F01_B, - /* 0x42 */ SCENE_F01C, - /* 0x43 */ SCENE_BOTI, - /* 0x44 */ SCENE_HAKUGIN_BS, - /* 0x45 */ SCENE_20SICHITAI, - /* 0x46 */ SCENE_21MITURINMAE, - /* 0x47 */ SCENE_LAST_ZORA, - /* 0x48 */ SCENE_11GORONNOSATO2, - /* 0x49 */ SCENE_SEA, - /* 0x4A */ SCENE_35TAKI, - /* 0x4B */ SCENE_REDEAD, - /* 0x4C */ SCENE_BANDROOM, - /* 0x4D */ SCENE_11GORONNOSATO, - /* 0x4E */ SCENE_GORON_HAKA, - /* 0x4F */ SCENE_SECOM, - /* 0x50 */ SCENE_10YUKIYAMANOMURA, - /* 0x51 */ SCENE_TOUGITES, - /* 0x52 */ SCENE_DANPEI, - /* 0x53 */ SCENE_IKANAMAE, - /* 0x54 */ SCENE_DOUJOU, - /* 0x55 */ SCENE_MUSICHOUSE, - /* 0x56 */ SCENE_IKNINSIDE, - /* 0x57 */ SCENE_MAP_SHOP, - /* 0x58 */ SCENE_F40, - /* 0x59 */ SCENE_F41, - /* 0x5A */ SCENE_10YUKIYAMANOMURA2, - /* 0x5B */ SCENE_14YUKIDAMANOMITI, - /* 0x5C */ SCENE_12HAKUGINMAE, - /* 0x5D */ SCENE_17SETUGEN, - /* 0x5E */ SCENE_17SETUGEN2, - /* 0x5F */ SCENE_SEA_BS, - /* 0x60 */ SCENE_RANDOM, - /* 0x61 */ SCENE_YADOYA, - /* 0x62 */ SCENE_KONPEKI_ENT, - /* 0x63 */ SCENE_INSIDETOWER, - /* 0x64 */ SCENE_26SARUNOMORI, - /* 0x65 */ SCENE_LOST_WOODS, - /* 0x66 */ SCENE_LAST_LINK, - /* 0x67 */ SCENE_SOUGEN, - /* 0x68 */ SCENE_BOMYA, - /* 0x69 */ SCENE_KYOJINNOMA, - /* 0x6A */ SCENE_KOEPONARACE, - /* 0x6B */ SCENE_GORONRACE, - /* 0x6C */ SCENE_TOWN, - /* 0x6D */ SCENE_ICHIBA, - /* 0x6E */ SCENE_BACKTOWN, - /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY, + /* 0x3B */ SCENE_TORIDE, // Pirates' Fortress Moat + /* 0x3C */ SCENE_FISHERMAN, // Fisherman's Hut + /* 0x3D */ SCENE_GORONSHOP, // Goron Shop + /* 0x3E */ SCENE_DEKU_KING, // Deku King's Chamber + /* 0x3F */ SCENE_LAST_GORON, // Moon Goron Trial + /* 0x40 */ SCENE_24KEMONOMITI, // Road to Southern Swamp + /* 0x41 */ SCENE_F01_B, // Doggy Racetrack + /* 0x42 */ SCENE_F01C, // Cucco Shack + /* 0x43 */ SCENE_BOTI, // Ikana Graveyard + /* 0x44 */ SCENE_HAKUGIN_BS, // Goht's Lair + /* 0x45 */ SCENE_20SICHITAI, // Southern Swamp (poison) + /* 0x46 */ SCENE_21MITURINMAE, // Woodfall + /* 0x47 */ SCENE_LAST_ZORA, // Moon Zora Trial + /* 0x48 */ SCENE_11GORONNOSATO2, // Goron Village (spring) + /* 0x49 */ SCENE_SEA, // Great Bay Temple + /* 0x4A */ SCENE_35TAKI, // Waterfall Rapids + /* 0x4B */ SCENE_REDEAD, // Beneath the Well + /* 0x4C */ SCENE_BANDROOM, // Zora Hall Rooms + /* 0x4D */ SCENE_11GORONNOSATO, // Goron Village (winter) + /* 0x4E */ SCENE_GORON_HAKA, // Goron Graveyard + /* 0x4F */ SCENE_SECOM, // Sakon's Hideout + /* 0x50 */ SCENE_10YUKIYAMANOMURA, // Mountain Village (winter) + /* 0x51 */ SCENE_TOUGITES, // Ghost Hut + /* 0x52 */ SCENE_DANPEI, // Deku Shrine + /* 0x53 */ SCENE_IKANAMAE, // Road to Ikana + /* 0x54 */ SCENE_DOUJOU, // Swordsman's School + /* 0x55 */ SCENE_MUSICHOUSE, // Music Box House + /* 0x56 */ SCENE_IKNINSIDE, // Igos du Ikana's Lair + /* 0x57 */ SCENE_MAP_SHOP, // Tourist Information + /* 0x58 */ SCENE_F40, // Stone Tower + /* 0x59 */ SCENE_F41, // Inverted Stone Tower + /* 0x5A */ SCENE_10YUKIYAMANOMURA2, // Mountain Village (spring) + /* 0x5B */ SCENE_14YUKIDAMANOMITI, // Path to Snowhead + /* 0x5C */ SCENE_12HAKUGINMAE, // Snowhead + /* 0x5D */ SCENE_17SETUGEN, // Path to Goron Village (winter) + /* 0x5E */ SCENE_17SETUGEN2, // Path to Goron Village (spring) + /* 0x5F */ SCENE_SEA_BS, // Gyorg's Lair + /* 0x60 */ SCENE_RANDOM, // Secret Shrine + /* 0x61 */ SCENE_YADOYA, // Stock Pot Inn + /* 0x62 */ SCENE_KONPEKI_ENT, // Great Bay Cutscene + /* 0x63 */ SCENE_INSIDETOWER, // Clock Tower Interior + /* 0x64 */ SCENE_26SARUNOMORI, // Woods of Mystery + /* 0x65 */ SCENE_LOST_WOODS, // Lost Woods (Intro) + /* 0x66 */ SCENE_LAST_LINK, // Moon Link Trial + /* 0x67 */ SCENE_SOUGEN, // The Moon + /* 0x68 */ SCENE_BOMYA, // Bomb Shop + /* 0x69 */ SCENE_KYOJINNOMA, // Giants' Chamber + /* 0x6A */ SCENE_KOEPONARACE, // Gorman Track + /* 0x6B */ SCENE_GORONRACE, // Goron Racetrack + /* 0x6C */ SCENE_TOWN, // East Clock Town + /* 0x6D */ SCENE_ICHIBA, // West Clock Town + /* 0x6E */ SCENE_BACKTOWN, // North Clock Town + /* 0x6F */ SCENE_CLOCKTOWER, // South Clock Town + /* 0x70 */ SCENE_ALLEY, // Laundry Pool /* 0x71 */ SCENE_MAX } SceneId; From f0311e6ca4f65d29c11b896b1fc48584ac5607bb Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 27 Sep 2022 10:28:39 -0700 Subject: [PATCH 45/73] Document EnSyatekiCrow (#1063) * Document EnSyatekiCrow * Simplify static var names * Respond to Elliptic's review --- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 201 +++++++++--------- .../ovl_En_Syateki_Crow/z_en_syateki_crow.h | 33 +-- tools/disasm/functions.txt | 16 +- tools/disasm/variables.txt | 8 +- 4 files changed, 130 insertions(+), 128 deletions(-) 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 ef8973295..6b05f739d 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,6 @@ #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) @@ -17,14 +16,14 @@ void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play); void EnSyatekiCrow_Update(Actor* thisx, PlayState* play); void EnSyatekiCrow_Draw(Actor* thisx, PlayState* play); -void func_809CA5D4(EnSyatekiCrow* this); -void func_809CA67C(EnSyatekiCrow* this, PlayState* play); -void func_809CA71C(EnSyatekiCrow* this); -void func_809CA840(EnSyatekiCrow* this, PlayState* play); -void func_809CA8E4(EnSyatekiCrow* this, PlayState* play); -void func_809CABC0(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_SetupWaitForSpawn(EnSyatekiCrow* this); +void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this); +void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play); -static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; const ActorInit En_Syateki_Crow_InitVars = { ACTOR_EN_SYATEKI_CROW, @@ -72,12 +71,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -static Vec3f D_809CB0C0 = { 0.0f, 20.0f, 0.0f }; - -static Vec3f D_809CB0CC = { 0.0f, 0.0f, 0.0f }; - -static Vec3f D_809CB0D8 = { 2500.0f, 0.0f, 0.0f }; - void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; EnSyatekiCrow* this = THIS; @@ -97,9 +90,9 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { Actor_ProcessInitChain(&this->actor, sInitChain); SkelAnime_InitFlex(play, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, OBJECT_CROW_LIMB_MAX); - Collider_InitJntSph(play, &this->unk_23C); - Collider_SetJntSph(play, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); - this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); if ((path == NULL) || (EN_SYATEKI_CROW_GET_NUMBER(&this->actor) >= 0x80)) { @@ -107,108 +100,110 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { return; } - 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); + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->currentPointIndex = 1; + this->maxPointIndex = path->count; + this->deathTimer = 20; + this->waitTimer = 0; + EnSyatekiCrow_SetupWaitForSpawn(this); } void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play) { EnSyatekiCrow* this = THIS; - Collider_DestroyJntSph(play, &this->unk_23C); + Collider_DestroyJntSph(play, &this->collider); } -void func_809CA5D4(EnSyatekiCrow* this) { +void EnSyatekiCrow_SetupWaitForSpawn(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->currentPointIndex = 1; this->actor.draw = NULL; - this->actionFunc = func_809CA67C; + this->actionFunc = EnSyatekiCrow_WaitForSpawn; } -void func_809CA67C(EnSyatekiCrow* this, PlayState* play) { +/** + * Waits until the shooting gallery man sets the appropriate Guay flag to spawn. + */ +void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_1C2 == 1) && + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true) && (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)))) { - func_809CA71C(this); + EnSyatekiCrow_SetupWaitToMove(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - this->unk_1C2 = 1; + this->isActive = true; } if ((syatekiMan->guayFlags == 0) && (syatekiMan->guayFlags == 0)) { - this->unk_1C2 = 1; + this->isActive = true; } } -void func_809CA71C(EnSyatekiCrow* this) { - Vec3f sp24; - s16 temp; +void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this) { + Vec3f targetPos; - 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.world.pos.x = this->pathPoints[0].x; + this->actor.world.pos.y = this->pathPoints[0].y; + this->actor.world.pos.z = this->pathPoints[0].z; + targetPos.x = this->pathPoints[this->currentPointIndex].x; + targetPos.y = this->pathPoints[this->currentPointIndex].y; + targetPos.z = this->pathPoints[this->currentPointIndex].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); + this->actor.world.rot.x = this->actor.shape.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &targetPos); this->actor.draw = EnSyatekiCrow_Draw; - this->actionFunc = func_809CA840; + this->actionFunc = EnSyatekiCrow_WaitToMove; } -void func_809CA840(EnSyatekiCrow* this, PlayState* play) { - if (((EN_SYATEKI_CROW_GET_PARAM_F(&this->actor) * 20) + 20) < this->unk_1BC) { +/** + * Waits until the wait timer reaches a certain point, then starts flying forward. + * How long the Guay should wait is controlled by its params. + */ +void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play) { + if (((EN_SYATEKI_CROW_GET_WAIT_MOD(&this->actor) * 20) + 20) < this->waitTimer) { 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->waitTimer = 0; + this->actor.speedXZ = EN_SYATEKI_CROW_GET_SPEED_MOD(&this->actor) + 6.0f; this->actor.gravity = -0.5f; - this->actionFunc = func_809CA8E4; + this->actionFunc = EnSyatekiCrow_Fly; } else { - this->unk_1BC++; + this->waitTimer++; } } -void func_809CA8E4(EnSyatekiCrow* this, PlayState* play) { - Vec3f sp34; - f32 sp30; +void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { + Vec3f targetPoint; + f32 distToTarget; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - func_809CA5D4(this); + EnSyatekiCrow_SetupWaitForSpawn(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; + targetPoint.x = this->pathPoints[this->currentPointIndex].x; + targetPoint.y = this->pathPoints[this->currentPointIndex].y; + targetPoint.z = this->pathPoints[this->currentPointIndex].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); + distToTarget = Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPoint); + this->yawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPoint); + this->pitchTarget = Math_Vec3f_Pitch(&this->actor.world.pos, &targetPoint); - if (sp30 > 100.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_1C0, 5, 0x3000, 0x100); + if (distToTarget > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->yawTarget, 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); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 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 if (this->currentPointIndex < (this->maxPointIndex - 1)) { + this->currentPointIndex++; } else { - this->unk_1C2 = 0; + this->isActive = false; syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); - func_809CA5D4(this); + EnSyatekiCrow_SetupWaitForSpawn(this); } SkelAnime_Update(&this->skelAnime); @@ -218,21 +213,21 @@ void func_809CA8E4(EnSyatekiCrow* this, PlayState* play) { } } -void func_809CAAF8(EnSyatekiCrow* this) { +void EnSyatekiCrow_SetupDead(EnSyatekiCrow* this) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; syatekiMan->score += 60; - this->unk_1C2 = 0; + this->isActive = false; 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.bgCheckFlags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->actionFunc = func_809CABC0; + this->actionFunc = EnSyatekiCrow_Dead; } -void func_809CABC0(EnSyatekiCrow* this, PlayState* play) { +void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); @@ -243,30 +238,34 @@ void func_809CABC0(EnSyatekiCrow* this, PlayState* play) { this->actor.shape.rot.z += 0x1780; } - if (this->unk_1C4 > 20) { - func_800B3030(play, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, 0); + if (this->deathTimer > 20) { + func_800B3030(play, &this->actor.world.pos, &sZeroVec, &sZeroVec, this->actor.scale.x * 10000.0f, 0, 0); syatekiMan->guayHitCounter++; syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); - func_809CA5D4(this); + EnSyatekiCrow_SetupWaitForSpawn(this); } - this->unk_1C4++; + this->deathTimer++; } -void func_809CACD0(EnSyatekiCrow* this, PlayState* play) { - if (this->actionFunc == func_809CA8E4) { - if (this->unk_23C.base.acFlags & AC_HIT) { +static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; + +static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; + +void EnSyatekiCrow_UpdateDamage(EnSyatekiCrow* this, PlayState* play) { + if (this->actionFunc == EnSyatekiCrow_Fly) { + if (this->collider.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(play, &this->actor.world.pos, &D_809CB0C0, &D_809CB0CC, 5, 1); - func_809CAAF8(this); + this->deathTimer = 0; + this->collider.base.acFlags &= ~AC_HIT; + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 1); + EnSyatekiCrow_SetupDead(this); } else { - this->unk_23C.elements->dim.worldSphere.center.x = this->actor.world.pos.x; - this->unk_23C.elements->dim.worldSphere.center.y = + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].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(play, &play->colChkCtx, &this->unk_23C.base); + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } @@ -276,39 +275,41 @@ void EnSyatekiCrow_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if (this->actionFunc != func_809CABC0) { + if (this->actionFunc != EnSyatekiCrow_Dead) { Actor_MoveWithoutGravity(&this->actor); } else { Actor_MoveWithGravity(&this->actor); } - func_809CACD0(this, play); + EnSyatekiCrow_UpdateDamage(this, play); } s32 EnSyatekiCrow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSyatekiCrow* this = THIS; if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { - rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { - rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); } return false; } +static Vec3f sBodyOffset = { 2500.0f, 0.0f, 0.0f }; + void EnSyatekiCrow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSyatekiCrow* this = THIS; - Vec3f* sp1C; + Vec3f* bodyPartPos; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_MultVec3f(&D_809CB0D8, &this->unk_144[0]); - this->unk_144[0].y -= 20.0f; + Matrix_MultVec3f(&sBodyOffset, &this->bodyPartsPos[0]); + this->bodyPartsPos[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_MultVec3f(&D_809CB050, sp1C); - sp1C->y -= 20.0f; + bodyPartPos = &this->bodyPartsPos[(limbIndex >> 1) - 1]; + Matrix_MultVec3f(&sZeroVec, bodyPartPos); + bodyPartPos->y -= 20.0f; } } 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 05eec4ad0..e70a3dd21 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 @@ -2,11 +2,12 @@ #define Z_EN_SYATEKI_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.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_WAIT_MOD(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_CROW_GET_SPEED_MOD(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_CROW_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_CROW_PARAMS(number, unkF0, unkF) (((number << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unkF & 0xF)) +#define EN_SYATEKI_CROW_PARAMS(number, speedMod, waitMod) (((number << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) struct EnSyatekiCrow; @@ -14,21 +15,21 @@ typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, PlayState*); typedef struct EnSyatekiCrow { /* 0x000 */ Actor actor; - /* 0x144 */ Vec3f unk_144[4]; + /* 0x144 */ Vec3f bodyPartsPos[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; + /* 0x1BC */ s16 waitTimer; + /* 0x1BE */ s16 pitchTarget; + /* 0x1C0 */ s16 yawTarget; + /* 0x1C2 */ s16 isActive; + /* 0x1C4 */ s16 deathTimer; + /* 0x1C8 */ Vec3s* pathPoints; + /* 0x1CC */ s16 currentPointIndex; + /* 0x1CE */ s16 maxPointIndex; + /* 0x1D0 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x206 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x23C */ ColliderJntSph collider; + /* 0x25C */ ColliderJntSphElement colliderElements[1]; } EnSyatekiCrow; // size = 0x29C extern const ActorInit En_Syateki_Crow_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index edd85dc51..40a824f15 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9125,14 +9125,14 @@ 0x809CA27C:("BgIcicle_Draw",), 0x809CA3F0:("EnSyatekiCrow_Init",), 0x809CA5A8:("EnSyatekiCrow_Destroy",), - 0x809CA5D4:("func_809CA5D4",), - 0x809CA67C:("func_809CA67C",), - 0x809CA71C:("func_809CA71C",), - 0x809CA840:("func_809CA840",), - 0x809CA8E4:("func_809CA8E4",), - 0x809CAAF8:("func_809CAAF8",), - 0x809CABC0:("func_809CABC0",), - 0x809CACD0:("func_809CACD0",), + 0x809CA5D4:("EnSyatekiCrow_SetupWaitForSpawn",), + 0x809CA67C:("EnSyatekiCrow_WaitForSpawn",), + 0x809CA71C:("EnSyatekiCrow_SetupWaitToMove",), + 0x809CA840:("EnSyatekiCrow_WaitToMove",), + 0x809CA8E4:("EnSyatekiCrow_Fly",), + 0x809CAAF8:("EnSyatekiCrow_SetupDead",), + 0x809CABC0:("EnSyatekiCrow_Dead",), + 0x809CACD0:("EnSyatekiCrow_UpdateDamage",), 0x809CADE8:("EnSyatekiCrow_Update",), 0x809CAE5C:("EnSyatekiCrow_OverrideLimbDraw",), 0x809CAF2C:("EnSyatekiCrow_PostLimbDraw",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 82acecd8d..c07dd39b2 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -9945,15 +9945,15 @@ 0x809CA31C:("D_809CA31C","UNK_TYPE1","",0x1), 0x809CA320:("D_809CA320","f32","",0x4), 0x809CA324:("D_809CA324","f32","",0x4), - 0x809CB050:("D_809CB050","UNK_TYPE1","",0x1), + 0x809CB050:("sZeroVec","UNK_TYPE1","",0x1), 0x809CB05C:("En_Syateki_Crow_InitVars","UNK_TYPE1","",0x1), 0x809CB07C:("D_809CB07C","UNK_TYPE1","",0x1), 0x809CB0A0:("D_809CB0A0","UNK_TYPE1","",0x1), 0x809CB0AC:("D_809CB0AC","UNK_PTR","",0x4), 0x809CB0B0:("D_809CB0B0","UNK_TYPE1","",0x1), - 0x809CB0C0:("D_809CB0C0","UNK_TYPE1","",0x1), - 0x809CB0CC:("D_809CB0CC","UNK_TYPE1","",0x1), - 0x809CB0D8:("D_809CB0D8","UNK_TYPE1","",0x1), + 0x809CB0C0:("sVelocity","UNK_TYPE1","",0x1), + 0x809CB0CC:("sAccel","UNK_TYPE1","",0x1), + 0x809CB0D8:("sBodyOffset","UNK_TYPE1","",0x1), 0x809CB0F0:("D_809CB0F0","f32","",0x4), 0x809CB0F4:("D_809CB0F4","f32","",0x4), 0x809CB0F8:("D_809CB0F8","f32","",0x4), From aa5498231886fc93ed3f78a61362e9266d0f955b Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 27 Sep 2022 12:50:02 -0700 Subject: [PATCH 46/73] EnGrasshopper (Dragonflies) OK and documented, object_grasshopper documented (#1043) * EnGrasshopper (Dragonflies) OK and documented, object_grasshopper documented * Type macro * Limb enum for sJntSphElementsInit * Respond to hensldm's review * Use TATL_HINT_ID enum * Respond to reviews * Increase size of shadowBodyPartsPos to 24 * Change 14 to a define --- assets/xml/objects/object_grasshopper.xml | 138 +- spec | 3 +- .../ovl_En_Grasshopper/z_en_grasshopper.c | 1153 +++++++++++++++-- .../ovl_En_Grasshopper/z_en_grasshopper.h | 65 +- src/overlays/actors/ovl_En_Pp/z_en_pp.c | 8 +- src/overlays/actors/ovl_En_Pp/z_en_pp.h | 2 +- tools/disasm/functions.txt | 56 +- tools/disasm/variables.txt | 26 +- undefined_syms.txt | 5 - 9 files changed, 1256 insertions(+), 200 deletions(-) diff --git a/assets/xml/objects/object_grasshopper.xml b/assets/xml/objects/object_grasshopper.xml index 3ef7b8e64..f08536c90 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -1,67 +1,79 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 7f44f277e..8cfc30556 100644 --- a/spec +++ b/spec @@ -2173,8 +2173,7 @@ beginseg name "ovl_En_Grasshopper" compress include "build/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.o" - include "build/data/ovl_En_Grasshopper/ovl_En_Grasshopper.data.o" - include "build/data/ovl_En_Grasshopper/ovl_En_Grasshopper.reloc.o" + include "build/src/overlays/actors/ovl_En_Grasshopper/ovl_En_Grasshopper_reloc.o" endseg beginseg 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 be274690c..aa2ce4915 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -5,6 +5,7 @@ */ #include "z_en_grasshopper.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -15,41 +16,125 @@ void EnGrasshopper_Destroy(Actor* thisx, PlayState* play); void EnGrasshopper_Update(Actor* thisx, PlayState* play); void EnGrasshopper_Draw(Actor* thisx, PlayState* play); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_809A8CDC = { - /* Deku Nut */ DMG_ENTRY(1, 0xF), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(0, 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(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(1, 0xF), - /* Zora barrier */ DMG_ENTRY(1, 0xF), - /* 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, 0xE), +void EnGrasshopper_ChangeAnim(EnGrasshopper* this, s32 animIndex); +void EnGrasshopper_RaiseTail(EnGrasshopper* this); +void EnGrasshopper_LowerTail(EnGrasshopper* this); +void EnGrasshopper_DecideAction(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupFly(EnGrasshopper* this); +void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupBank(EnGrasshopper* this); +void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupBounced(EnGrasshopper* this); +void EnGrasshopper_Bounced(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupApproachPlayer(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupAttack(EnGrasshopper* this); +void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupWaitAfterAttack(EnGrasshopper* this); +void EnGrasshopper_WaitAfterAttack(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_Damaged(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupFall(EnGrasshopper* this); +void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_InitializeEffect(EnGrasshopper* this, Vec3f* pos); +void EnGrasshopper_UpdateEffects(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_DrawEffects(EnGrasshopper* this, PlayState* play); + +typedef enum { + /* 0 */ EN_GRASSHOPPER_ACTION_FLY, + /* 1 */ EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES, + /* 2 */ EN_GRASSHOPPER_ACTION_BANK, + /* 3 */ EN_GRASSHOPPER_ACTION_BOUNCED, + /* 4 */ EN_GRASSHOPPER_ACTION_DECIDE_ACTION, + /* 5 */ EN_GRASSHOPPER_ACTION_APPROACH_PLAYER, + /* 6 */ EN_GRASSHOPPER_ACTION_ATTACK, + /* 7 */ EN_GRASSHOPPER_ACTION_WAIT_AFTER_ATTACK, + /* 8 */ EN_GRASSHOPPER_ACTION_DAMAGED, + /* 9 */ EN_GRASSHOPPER_ACTION_DEAD, + /* 10 */ EN_GRASSHOPPER_ACTION_FALL, +} EnGrasshopperAction; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_DECISION_ATTACK, + /* 1 */ EN_GRASSHOPPER_DECISION_FLY, + /* 2 */ EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES, // Never used in the final game +} EnGrasshopperNextAction; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_BANK_STATE_BANKING, + /* 1 */ EN_GRASSHOPPER_BANK_STATE_DONE, +} EnGrasshopperBankState; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_ANIM_RAISE_TAIL, + /* 1 */ EN_GRASSHOPPER_ANIM_LOWER_TAIL, + /* 2 */ EN_GRASSHOPPER_ANIM_FLY, + /* 3 */ EN_GRASSHOPPER_ANIM_ATTACK, + /* 4 */ EN_GRASSHOPPER_ANIM_HOVER, + /* 5 */ EN_GRASSHOPPER_ANIM_DAMAGE, + /* 6 */ EN_GRASSHOPPER_ANIM_DEAD, + /* 7 */ EN_GRASSHOPPER_ANIM_FALL, +} EnGrasshopperAnim; + +static s32 sOccupiedIndices[] = { + false, false, false, false, false, +}; + +static s8 sLimbIndexToShadowBodyPartsIndex[DRAGONFLY_LIMB_MAX] = { + -1, -1, 0, 1, 2, 3, 4, 5, -1, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1, 12, 13, -1, -1, -1, +}; + +static s8 sParentBodyParts[DRAGONFLY_LIMB_MAX] = { + -1, -1, -1, 0, 1, 2, 3, -1, -1, -1, -1, 6, -1, -1, 8, -1, -1, 10, -1, -1, 12, -1, -1, -1, +}; + +static u8 sShadowSizes[DRAGONFLY_LIMB_MAX] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +typedef enum { + /* 0x0 */ EN_GRASSHOPPER_DMGEFF_IMMUNE, // Deals no damage + /* 0x2 */ EN_GRASSHOPPER_DMGEFF_FIRE = 0x2, // Damages and sets the Dragonfly on fire + /* 0x3 */ EN_GRASSHOPPER_DMGEFF_FREEZE, // Damages and freezes the Dragonfly in ice + /* 0x4 */ EN_GRASSHOPPER_DMGEFF_LIGHT_ORB, // Damages and surrounds the Dragonfly with light orbs + /* 0xE */ EN_GRASSHOPPER_DMGEFF_HOOK = 0xE, // If hit by the Hookshot, it pulls the Dragonfly towards the player + /* 0xF */ EN_GRASSHOPPER_DMGEFF_NONE, // Deals regular damage with no extra effect +} EnDragonflyDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_HOOK), + /* Goron punch */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_HOOK), }; const ActorInit En_Grasshopper_InitVars = { @@ -64,92 +149,996 @@ const ActorInit En_Grasshopper_InitVars = { (ActorFunc)EnGrasshopper_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809A8D1C[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { DRAGONFLY_LIMB_THORAX, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x07, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 6, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x07, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { DRAGONFLY_LIMB_TAIL_TIP, { { 0, 0, 0 }, 0 }, 0 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809A8D64 = { - { COLTYPE_HIT2, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_809A8D1C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT2, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnGrasshopper_Init(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; + s32 i; -extern DamageTable D_809A8CDC; -extern ColliderJntSphElementInit D_809A8D1C[2]; -extern ColliderJntSphInit D_809A8D64; + this->actor.hintId = TATL_HINT_ID_DRAGONFLY; + this->actor.targetMode = 4; + this->actor.colChkInfo.mass = 60; + this->actor.colChkInfo.health = 2; -extern UNK_TYPE D_06000F9C; + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].dim.modelSphere.radius = 1; + this->collider.elements[0].dim.scale = 22.0f; + this->collider.elements[1].dim.modelSphere.radius = 1; + this->collider.elements[1].dim.scale = 16.0f; + this->collider.elements[1].dim.modelSphere.center.x = 1000; + this->collider.elements[0].dim.modelSphere.center.x = this->collider.elements[0].dim.modelSphere.center.y = + this->collider.elements[0].dim.modelSphere.center.z = this->collider.elements[1].dim.modelSphere.center.y = + this->collider.elements[1].dim.modelSphere.center.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Init.s") + this->actor.flags |= ACTOR_FLAG_200; + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 1.0f); + this->actor.colChkInfo.damageTable = &sDamageTable; + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.home.pos); + this->action = EN_GRASSHOPPER_ACTION_FLY; + this->index = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Destroy.s") + for (i = 0; i < ARRAY_COUNT(sOccupiedIndices); i++) { + if (!sOccupiedIndices[i]) { + this->index = i; + sOccupiedIndices[i] = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6524.s") + // Deciding a random index like this if all indices are occupied causes a bug in EnGrasshopper_Destroy. + if (this->index < 0) { + this->index = Rand_ZeroFloat(4.99f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A65D8.s") + SkelAnime_Init(play, &this->skelAnime, &gDragonflySkel, &gDragonflyFlyAnim, this->jointTable, this->morphTable, + DRAGONFLY_LIMB_MAX); + this->type = EN_GRASSHOPPER_GET_TYPE(&this->actor); + if (this->type < EN_GRASSHOPPER_TYPE_UNUSED_NORMAL) { + this->type = EN_GRASSHOPPER_TYPE_NORMAL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6628.s") + if (this->type != EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED) { + this->dragonflyScale = 0.01f; + } else { + this->dragonflyScale = 0.0f; + Actor_SetScale(&this->actor, 0.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.world.pos); + this->flyingHomePos.y += 90.0f; + this->collider.elements[0].dim.modelSphere.radius = this->collider.elements[1].dim.modelSphere.radius = + this->type; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6668.s") + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + EnGrasshopper_SetupFly(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6754.s") +void EnGrasshopper_Destroy(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A67A4.s") + Collider_DestroyJntSph(play, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6B6C.s") + //! @bug If the dragonfly selected a random index in EnGrasshopper_Init (because all indices were occupied), + //! then two dragonflies will have the same index. When one of those dragonflies sharing an index is destroyed, + //! it will mark the index as unoccupied, when it still occupied by at least one dragonfly. + sOccupiedIndices[this->index] = false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6E18.s") +static AnimationHeader* sAnimations[] = { + &gDragonflyRaiseTailAnim, // EN_GRASSHOPPER_ANIM_RAISE_TAIL + &gDragonflyLowerTailAnim, // EN_GRASSHOPPER_ANIM_LOWER_TAIL + &gDragonflyFlyAnim, // EN_GRASSHOPPER_ANIM_FLY + &gDragonflyAttackAnim, // EN_GRASSHOPPER_ANIM_ATTACK + &gDragonflyHoverAnim, // EN_GRASSHOPPER_ANIM_HOVER + &gDragonflyDamageAnim, // EN_GRASSHOPPER_ANIM_DAMAGE + &gDragonflyDeadAnim, // EN_GRASSHOPPER_ANIM_DEAD + &gDragonflyFallAnim, // EN_GRASSHOPPER_ANIM_FALL +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6E74.s") +static u8 sAnimationModes[] = { + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_RAISE_TAIL + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_LOWER_TAIL + ANIMMODE_LOOP, // EN_GRASSHOPPER_ANIM_FLY + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_ATTACK + ANIMMODE_LOOP, // EN_GRASSHOPPER_ANIM_HOVER + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_DAMAGE + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_DEAD + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_FALL +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6F8C.s") +void EnGrasshopper_ChangeAnim(EnGrasshopper* this, s32 animIndex) { + f32 morphFrames; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A700C.s") + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + morphFrames = 0.0f; + if ((animIndex == EN_GRASSHOPPER_ANIM_ATTACK) || (animIndex == EN_GRASSHOPPER_ANIM_HOVER) || + (animIndex == EN_GRASSHOPPER_ANIM_DAMAGE)) { + morphFrames = -3.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7134.s") + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], + morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A71CC.s") +void EnGrasshopper_RaiseTail(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_RAISE_TAIL); + if (this->decision != EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES) { + this->decision = EN_GRASSHOPPER_DECISION_FLY; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7494.s") + this->action = EN_GRASSHOPPER_ACTION_DECIDE_ACTION; + this->actionFunc = EnGrasshopper_DecideAction; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A753C.s") +void EnGrasshopper_LowerTail(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_LOWER_TAIL); + this->action = EN_GRASSHOPPER_ACTION_DECIDE_ACTION; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->actionFunc = EnGrasshopper_DecideAction; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7844.s") +void EnGrasshopper_DecideAction(EnGrasshopper* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A78EC.s") + if (curFrame >= this->endFrame) { + if (this->decision == EN_GRASSHOPPER_DECISION_ATTACK) { + EnGrasshopper_SetupAttack(this); + } else { + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.world.pos); + this->flyingHomePos.y = this->actor.floorHeight + 90.0f; + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FLY); + if (this->decision != EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + EnGrasshopper_SetupFly(this); + } else { + EnGrasshopper_SetupApproachPlayer(this, play); + } + } else { + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A797C.s") +void EnGrasshopper_SetupFly(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FLY); + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + this->action = EN_GRASSHOPPER_ACTION_FLY; + this->actionFunc = EnGrasshopper_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7A8C.s") +void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play) { + f32 diffX; + f32 diffZ; + f32 targetSpeed; + Vec3f collisionCheckPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7AE4.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + diffX = this->flyingHomePos.x - this->actor.world.pos.x; + diffZ = this->flyingHomePos.z - this->actor.world.pos.z; + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + collisionCheckPos.x = (Math_SinS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.x; + collisionCheckPos.y = this->actor.world.pos.y; + collisionCheckPos.z = (Math_CosS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7BBC.s") + if (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) { + this->shouldTurn = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7C98.s") + if (BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { + this->shouldTurn = true; + } else { + this->shouldTurn = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7CE0.s") + //! @bug Unreachable code. To get here, the type must NOT be EN_GRASSHOPPER_TYPE_WOODFALL + if (this->type == EN_GRASSHOPPER_TYPE_WOODFALL) { + if (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) < 600.0f) { + this->shouldTurn = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8044.s") + if (this->shouldTurn) { + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + this->targetRot.y = Math_Atan2S(diffX, diffZ); + this->timer = Rand_S16Offset(30, 30); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Update.s") + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && !(gSaveContext.eventInf[4] & 2) && !this->shouldTurn && + (this->actor.xzDistToPlayer < 200.0f)) { + EnGrasshopper_SetupApproachPlayer(this, play); + } else { + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + this->targetRot.z *= 0.8f; + if (this->waitTimer != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 0.5f); + } else { + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + targetSpeed = (this->index * 0.1f) + 4.0f; + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.7f); + Math_ApproachF(&this->rotationalVelocity, 2000.0f, 1.0f, 50.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); + if (this->timer == 0) { + if (Rand_ZeroFloat(1.0f) < 0.3f) { + this->waitTimer = Rand_S16Offset(10, 10); + this->rotationalVelocity = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A847C.s") + this->targetRot.y = Math_Atan2S(diffX, diffZ); + this->timer = Rand_S16Offset(30, 70); + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Draw.s") +/** + * Unused in the final game. Makes the dragonfly roam the area in a very wide circular arc. + */ +void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { + f32 diffX; + f32 diffZ; + f32 targetSpeed; + s16 rotationSpeed; + s32 pad; + Vec3f collisionCheckPos; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8870.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + EnGrasshopper_SetupFly(this); + } else { + diffX = player->actor.world.pos.x - this->actor.world.pos.x; + diffZ = player->actor.world.pos.z - this->actor.world.pos.z; + this->bobPhase += 0xAF0; + this->targetPosY = player->actor.world.pos.y + 60.0f; + this->baseFlyHeight = Math_SinS(this->bobPhase) * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8924.s") + if (this->timer == 0) { + this->baseFlyHeight = randPlusMinusPoint5Scaled(10.0f); + this->timer = Rand_S16Offset(30, 30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8A64.s") + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + collisionCheckPos.x = (Math_SinS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.x; + collisionCheckPos.y = this->actor.world.pos.y; + collisionCheckPos.z = (Math_CosS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.z; + + if ((this->actor.bgCheckFlags & 8) || BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { + EnGrasshopper_SetupBank(this); + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_RaiseTail(this); + } else if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.elements[0].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_SetupBounced(this); + } else { + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + rotationSpeed = this->index + 70; + targetSpeed = (this->index * 0.05f) + 4.0f; + this->targetRot.y = Math_Atan2S(diffX, diffZ); + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, rotationSpeed, 0xFA0, 0xA); + } + } +} + +/** + * Unused in the final game. + */ +void EnGrasshopper_SetupBank(EnGrasshopper* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + this->targetBankRot.y = this->actor.world.rot.y + 0x8000; + this->action = EN_GRASSHOPPER_ACTION_BANK; + this->bankState = EN_GRASSHOPPER_BANK_STATE_BANKING; + this->actor.speedXZ = 2.0f; + this->actionFunc = EnGrasshopper_Bank; +} + +/** + * Unused in the final game. Makes the dragonfly perform a wide banking turn on its side, then + * it flies forward for 100 frames. + */ +void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + switch (this->bankState) { + case EN_GRASSHOPPER_BANK_STATE_BANKING: + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetBankRot.y, 0x64, 0x3E8, 0x3E8); + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 0x64, 0x1F40, 0xBB8); + if (fabsf(this->actor.world.rot.y - (f32)this->targetBankRot.y) < 10.0f) { + this->postBankTimer = 100; + this->bankState = EN_GRASSHOPPER_BANK_STATE_DONE; + } + break; + + case EN_GRASSHOPPER_BANK_STATE_DONE: + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 0x64, 0x1F40, 0xBB8); + if (this->postBankTimer == 0) { + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } + break; + } +} + +/** + * Unused in the final game. + */ +void EnGrasshopper_SetupBounced(EnGrasshopper* this) { + this->targetRot.y = -this->actor.yawTowardsPlayer; + this->timer = Rand_S16Offset(30, 30); + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + this->action = EN_GRASSHOPPER_ACTION_BOUNCED; + this->actionFunc = EnGrasshopper_Bounced; +} + +/** + * Unused in the final game. Makes the dragonfly rotate away from the player, then go + * back to roaming in circles. + */ +void EnGrasshopper_Bounced(EnGrasshopper* this, PlayState* play) { + f32 targetSpeed; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + targetSpeed = (this->index * 0.05f) + 7.0f; + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + this->targetRot.z *= 0.8f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); + if (this->timer == 0) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } +} + +void EnGrasshopper_SetupApproachPlayer(EnGrasshopper* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + this->timer = 50; + this->action = EN_GRASSHOPPER_ACTION_APPROACH_PLAYER; + this->approachSpeed = 0.0f; + this->targetApproachPos.x = (Math_SinS(player->actor.shape.rot.y) * 130.0f) + player->actor.world.pos.x; + this->targetApproachPos.z = (Math_CosS(player->actor.shape.rot.y) * 130.0f) + player->actor.world.pos.z; + this->actionFunc = EnGrasshopper_ApproachPlayer; +} + +/** + * Approaches the player in preparation for an attack. It will also attack if the timer reaches 0. + */ +void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play) { + Player* player = GET_PLAYER(play); + WaterBox* waterBox; + Vec3f splashPos; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + this->bobPhase += 0xAF0; + this->targetApproachPos.y = (Math_SinS(this->bobPhase) * 10.0f) + (player->actor.world.pos.y + 120.0f); + + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.shape.rot.y, 0xA, 0xFA0, 0xA); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + Math_ApproachF(&this->actor.world.pos.x, this->targetApproachPos.x, 0.3f, this->approachSpeed); + Math_ApproachF(&this->actor.world.pos.y, this->targetApproachPos.y, 0.1f, this->approachSpeed); + Math_ApproachF(&this->actor.world.pos.z, this->targetApproachPos.z, 0.3f, this->approachSpeed); + Math_ApproachF(&this->approachSpeed, 7.0f, 0.3f, 1.0f); + + if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, + &waterBox)) { + if (this->tailTipPos.y < this->waterSurface) { + if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { + this->splashCount++; + Math_Vec3f_Copy(&splashPos, &this->tailTipPos); + splashPos.x += randPlusMinusPoint5Scaled(20.0f); + splashPos.z += randPlusMinusPoint5Scaled(20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (((s32)Rand_ZeroOne() * 100) + 400)); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + } + } else { + this->splashCount = 0; + } + } + + if ((this->timer == 0) || ((fabsf(this->targetApproachPos.x - this->actor.world.pos.x) <= 10.0f) && + (fabsf(this->targetApproachPos.y - this->actor.world.pos.y) <= 20.0f) && + (fabsf(this->targetApproachPos.z - this->actor.world.pos.z) <= 10.0f))) { + EnGrasshopper_LowerTail(this); + } +} + +void EnGrasshopper_SetupAttack(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_ATTACK); + this->approachSpeed = 0.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + this->actor.speedXZ = 3.0f; + this->baseFlyHeight = this->actor.world.pos.y; + this->collider.elements[0].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + this->collider.elements[1].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_ATTACK); + this->action = EN_GRASSHOPPER_ACTION_ATTACK; + this->actionFunc = EnGrasshopper_Attack; +} + +void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + Vec3f hitPos; + Vec3f diff; + f32 playerToHitPosDist; + s32 i; + WaterBox* waterBox; + Vec3f splashPos; + + for (i = 0; i < 6; i++) { + EnGrasshopper_InitializeEffect(this, &this->tailTipPos); + } + + if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, + &waterBox)) { + if (this->tailTipPos.y < this->waterSurface) { + if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { + this->splashCount++; + Math_Vec3f_Copy(&splashPos, &this->tailTipPos); + splashPos.x += randPlusMinusPoint5Scaled(20.0f); + splashPos.z += randPlusMinusPoint5Scaled(20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, ((s32)Rand_ZeroOne() * 100) + 400); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + } + } else { + this->splashCount = 0; + } + } + + this->bobPhase += 0xAF0; + this->targetApproachPos.y = (Math_SinS(this->bobPhase) * 10.0f) + (player->actor.world.pos.y + 60.0f); + + hitPos.x = this->collider.elements[1].info.bumper.hitPos.x; + hitPos.y = this->collider.elements[1].info.bumper.hitPos.y; + hitPos.z = this->collider.elements[1].info.bumper.hitPos.z; + diff.x = hitPos.x - player->actor.world.pos.x; + diff.y = hitPos.y - player->actor.world.pos.y; + diff.z = hitPos.z - player->actor.world.pos.z; + playerToHitPosDist = sqrtf(SQXYZ(diff)); + + if ((this->collider.base.atFlags & AT_BOUNCED) || + ((player->stateFlags1 & PLAYER_STATE1_400000) && (playerToHitPosDist <= 60.0f) && + ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) < 0x2000) && + ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) > -0x2000))) { + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + } + + Math_ApproachF(&this->actor.world.pos.y, this->targetApproachPos.y, 0.1f, this->approachSpeed); + Math_ApproachF(&this->approachSpeed, 10.0f, 0.1f, 1.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + if (curFrame >= this->endFrame) { + EnGrasshopper_SetupWaitAfterAttack(this); + } +} + +void EnGrasshopper_SetupWaitAfterAttack(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_HOVER); + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + this->action = EN_GRASSHOPPER_ACTION_WAIT_AFTER_ATTACK; + this->waitTimer = 20; + this->actor.speedXZ = 0.0f; + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + this->actionFunc = EnGrasshopper_WaitAfterAttack; +} + +/** + * Hover in place for a bit after an attack before raising the tail back up. + */ +void EnGrasshopper_WaitAfterAttack(EnGrasshopper* this, PlayState* play) { + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + if (this->waitTimer == 0) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_RaiseTail(this); + } +} + +void EnGrasshopper_SetupDamaged(EnGrasshopper* this, PlayState* play) { + Vec3f damagedVelocity; + + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DAMAGE); + this->actor.speedXZ = 0.0f; + this->actor.flags |= ACTOR_FLAG_1; + this->approachSpeed = 0.0f; + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-20.0f, &damagedVelocity); + Math_Vec3f_Copy(&this->damagedVelocity, &damagedVelocity); + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer != 0)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->action = EN_GRASSHOPPER_ACTION_DAMAGED; + this->actionFunc = EnGrasshopper_Damaged; +} + +void EnGrasshopper_Damaged(EnGrasshopper* this, PlayState* play) { + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + if (this->actor.colorFilterTimer == 0) { + EnGrasshopper_RaiseTail(this); + } +} + +void EnGrasshopper_SetupDead(EnGrasshopper* this, PlayState* play) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.speedXZ = 0.0f; + this->approachSpeed = 0.0f; + this->actor.velocity.y = 5.0f; + this->actor.gravity = -0.5f; + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer == 0)) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Enemy_StartFinishingBlow(play, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DEAD); + this->action = EN_GRASSHOPPER_ACTION_DEAD; + this->actionFunc = EnGrasshopper_Dead; +} + +/** + * Plays the death animation before transitioning to falling from the sky. + */ +void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer < 2)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (curFrame >= this->endFrame) { + this->actor.flags &= ~ACTOR_FLAG_10; + EnGrasshopper_SetupFall(this); + } +} + +void EnGrasshopper_SetupFall(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FALL); + this->action = EN_GRASSHOPPER_ACTION_FALL; + this->actor.speedXZ = 0.0f; + this->approachSpeed = 0.0f; + this->actionFunc = EnGrasshopper_Fall; +} + +/** + * Falls from the sky and bursts into flames once it touches land or water. + */ +void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play) { + WaterBox* waterBox; + f32 waterSurface; + s32 isUnderWater = false; + + this->actor.shape.rot.y += 0x1388; + if ((this->actor.floorHeight <= -32000.0f) || (this->actor.floorHeight >= 32000.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox)) { + if (this->actor.world.pos.y < waterSurface) { + Vec3f splashPos; + s32 i; + + for (i = 0; i < 3; i++) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.x += randPlusMinusPoint5Scaled((i * 5.0f) + 20.0f); + splashPos.z += randPlusMinusPoint5Scaled((i * 5.0f) + 20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (((s32)Rand_ZeroOne() * 100) + 400)); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + isUnderWater = true; + } + } + + if ((BgCheck_SphVsFirstPoly(&play->colCtx, &this->tailTipPos, 40.0f)) && + (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer != 0)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (isUnderWater || (BgCheck_SphVsFirstPoly(&play->colCtx, &this->tailTipPos, 10.0f))) { + Vec3f firePos; + Vec3f sFireVelocityAndAccel[] = { + { 1.0f, 0.0f, 0.5f }, { 1.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, 0.5f }, + { -1.0f, 0.0f, -0.5f }, { 0.5f, 0.0f, 1.0f }, { -0.5f, 0.0f, 1.0f }, + { 0.5f, 0.0f, -1.0f }, { -0.5f, 0.0f, -1.0f }, { 0.0f, 0.0f, 0.0f }, + }; + s32 i; + + for (i = 0; i < ARRAY_COUNT(sFireVelocityAndAccel); i++) { + Math_Vec3f_Copy(&firePos, &this->actor.world.pos); + firePos.x += randPlusMinusPoint5Scaled(30.0f); + if (!isUnderWater) { + firePos.y = this->actor.floorHeight; + } else if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + firePos.y = waterSurface; + } + + firePos.z += randPlusMinusPoint5Scaled(30.0f); + func_800B3030(play, &firePos, &sFireVelocityAndAccel[i], &sFireVelocityAndAccel[i], 100, 0, 2); + } + + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 10, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } +} + +void EnGrasshopper_UpdateDamage(EnGrasshopper* this, PlayState* play) { + s32 pad; + s16 attackDealsDamage = false; + + if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT)) { + this->collider.base.acFlags &= ~AC_HIT; + if ((this->action != EN_GRASSHOPPER_ACTION_DAMAGED) && (this->action != EN_GRASSHOPPER_ACTION_DEAD) && + (this->action != EN_GRASSHOPPER_ACTION_FALL)) { + if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_NONE) { + attackDealsDamage = true; + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_FIRE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + attackDealsDamage = true; + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_FREEZE) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_BLUE_FIRE) || (this->drawDmgEffTimer == 0)) { + Actor_ApplyDamage(&this->actor); + attackDealsDamage = false; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + if (this->actor.colChkInfo.health <= 0) { + EnGrasshopper_SetupDead(this, play); + return; + } + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_LIGHT_ORB) { + Actor_SetColorFilter(&this->actor, 0x8000, 255, 0, 25); + this->drawDmgEffTimer = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&play->actorCtx, play, 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); + attackDealsDamage = true; + } + } + } + + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DAMAGE); + EnGrasshopper_SetupDamaged(this, play); + } else { + EnGrasshopper_SetupDead(this, play); + } + } +} + +void EnGrasshopper_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnGrasshopper* this = THIS; + + SkelAnime_Update(&this->skelAnime); + EnGrasshopper_UpdateDamage(this, play); + this->actionFunc(this, play); + + Actor_SetFocus(&this->actor, 0.0f); + Actor_SetScale(&this->actor, this->dragonflyScale); + + DECR(this->timer); + DECR(this->waitTimer); + DECR(this->postBankTimer); + DECR(this->drawDmgEffTimer); + + Actor_MoveWithGravity(&this->actor); + this->actor.world.pos.x += this->damagedVelocity.x; + this->actor.world.pos.y += this->damagedVelocity.y; + this->actor.world.pos.z += this->damagedVelocity.z; + Math_ApproachZeroF(&this->damagedVelocity.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->damagedVelocity.y, 1.0f, 2.0f); + Math_ApproachZeroF(&this->damagedVelocity.z, 1.0f, 2.0f); + if ((this->action != EN_GRASSHOPPER_ACTION_FALL) && (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 0x1D); + } + + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->type == EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED) { + f32 targetScale = this->type * 0.01f; + + if (targetScale >= 0.018f) { + targetScale = 0.018f; + } + + Math_ApproachF(&this->dragonflyScale, targetScale, 0.1f, 0.01f); + } + + if ((this->action != EN_GRASSHOPPER_ACTION_FALL) && (this->action != EN_GRASSHOPPER_ACTION_APPROACH_PLAYER)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 5, 0x3E8, 5); + } + + EnGrasshopper_UpdateEffects(this, play); + if ((this->action != EN_GRASSHOPPER_ACTION_DEAD) && (this->action != EN_GRASSHOPPER_ACTION_FALL)) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + if ((this->action == EN_GRASSHOPPER_ACTION_APPROACH_PLAYER) || (this->action == EN_GRASSHOPPER_ACTION_ATTACK)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + } +} + +void EnGrasshopper_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnGrasshopper* this = THIS; + Vec3f sEffectOffsetFromTailTop = { 500.0f, 0.0f, 0.0f }; + Vec3f sZeroVec3f = { 0.0f, 0.0f, 0.0f }; + + Matrix_Push(); + + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + if ((s8)(sLimbIndexToShadowBodyPartsIndex[limbIndex] >= 0)) { + Matrix_MultVec3f(&sZeroVec3f, &this->shadowBodyPartsPos[sLimbIndexToShadowBodyPartsIndex[limbIndex]]); + } + } + + if (limbIndex == DRAGONFLY_LIMB_TAIL_TIP) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&gZeroVec3f, &this->tailTipPos); + Matrix_MultVec3f(&sEffectOffsetFromTailTop, &this->effectBasePos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); + if ((limbIndex == DRAGONFLY_LIMB_ROOT) || (limbIndex == DRAGONFLY_LIMB_TAIL_SEGMENT_2) || + (limbIndex == DRAGONFLY_LIMB_TAIL_TIP) || (limbIndex == DRAGONFLY_LIMB_BACK_LEFT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_BACK_RIGHT_UPPER_LEG) || (limbIndex == DRAGONFLY_LIMB_FRONT_LEFT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_FRONT_LEFT_FOOT) || (limbIndex == DRAGONFLY_LIMB_FRONT_RIGHT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_HEAD) || + //! @bug: These do not check for valid limbs. Limb index 24 is DRAGONFLY_LIMB_MAX, so it (and any index + //! larger than it) is not tied to an actual limb. + (limbIndex == 24) || (limbIndex == 25) || + // While checking for DRAGONFLY_LIMB_ROOT twice is not a bug by itself, it causes another bug below. + (limbIndex == DRAGONFLY_LIMB_ROOT)) { + //! @bug: This code only works properly if all 12 elements of bodyPartsPos are updated every frame, since + //! otherwise bodyPartsPosIndex will be non-zero at the end of a frame. Despite the fact that there are 12 + //! checks in the above if-statement, only 9 of them are valid and non-duplicate, so only 9 elements of + //! bodyPartsPos are updated on each frame. As a result, three elements in bodyPartsPos will either be (0, 0, 0) + //! or be a value carried over from the previous frame. + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } + + Matrix_Pop(); +} + +// We need to pass in 14 into SubS_GenShadowTex for the bodyPartsNum, NOT the actual size of the +// parent body parts array. This is both necessary to match and to prevent extra dots from being +// drawn with the shadow. +#define SHADOW_BODY_PARTS_NUM 14 + +void EnGrasshopper_Draw(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnGrasshopper_PostLimbDraw, + &this->actor); + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(this->shadowBodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + SHADOW_BODY_PARTS_NUM, sShadowSizes, sParentBodyParts); + //! FAKE: Needed to fix some regs and stack + //! https://decomp.me/scratch/4wJBW + if ((shadowTex && shadowTex) && shadowTex) {} + } + + SubS_DrawShadowTex(&this->actor, &play->state, shadowTex); + } + + if (this->drawDmgEffTimer != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; + + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + this->drawDmgEffScale += 0.3f; + if (this->drawDmgEffScale > 0.5f) { + this->drawDmgEffScale = 0.5f; + } + + Math_ApproachF(&this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, 0.1f, 0.04f); + } else { + this->drawDmgEffScale = 0.8f; + this->drawDmgEffFrozenSteamScale = 0.8f; + } + + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, drawDmgEffAlpha, + this->drawDmgEffType); + } + + EnGrasshopper_DrawEffects(this, play); +} + +void EnGrasshopper_InitializeEffect(EnGrasshopper* this, Vec3f* pos) { + EnGrasshopperEffect* effect = this->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->timer = 10; + effect->velocity.x = randPlusMinusPoint5Scaled(20.0f); + effect->velocity.y = randPlusMinusPoint5Scaled(20.0f); + effect->velocity.z = randPlusMinusPoint5Scaled(20.0f); + effect->yaw = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnGrasshopper_UpdateEffects(EnGrasshopper* this, PlayState* play) { + EnGrasshopperEffect* effect = this->effects; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x = this->effectBasePos.x + effect->velocity.x; + effect->pos.y = this->effectBasePos.y + effect->velocity.y; + effect->pos.z = this->effectBasePos.z + effect->velocity.z; + if (effect->timer != 0) { + effect->timer--; + effect->lightningIndex++; + Math_ApproachF(&effect->scale.x, 0.1f, 0.1f, 0.05f); + if (effect->lightningIndex >= 8) { + effect->lightningIndex = 0; + } + } else { + Math_ApproachZeroF(&effect->scale.x, 0.1f, 0.1f); + if (effect->scale.x < 0.2f) { + effect->isEnabled = 0; + } + } + + effect->scale.y = effect->scale.z = effect->scale.x; + } + } +} + +static TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + +void EnGrasshopper_DrawEffects(EnGrasshopper* this, PlayState* play) { + s32 pad[2]; + EnGrasshopperEffect* effect; + s16 i; + MtxF mfResult; + MtxF mfTrans; + MtxF mfScale; + MtxF mfRot; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + Mtx* mtx; + + OPEN_DISPS(play->state.gfxCtx); + + effect = this->effects; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + SkinMatrix_SetTranslate(&mfTrans, effect->pos.x, effect->pos.y, effect->pos.z); + SkinMatrix_SetScale(&mfScale, effect->scale.x, effect->scale.y, effect->scale.z); + SkinMatrix_SetRotateRPY(&mfRot, 0, 0, effect->yaw); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->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(play->state.gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLightningTextures[effect->lightningIndex])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, Lib_SegmentedToVirtual(gEffLightningDL)); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h index dc8e95008..d414e4100 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h @@ -2,16 +2,77 @@ #define Z_EN_GRASSHOPPER_H #include "global.h" +#include "objects/object_grasshopper/object_grasshopper.h" + +#define EN_GRASSHOPPER_GET_TYPE(thisx) ((thisx)->params) struct EnGrasshopper; typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, PlayState*); +typedef enum EnGrasshopperType { + /* -1 */ EN_GRASSHOPPER_TYPE_UNUSED_NORMAL = -1, // Acts exactly like EN_GRASSHOPPER_TYPE_NORMAL + /* 0 */ EN_GRASSHOPPER_TYPE_NORMAL, + /* 1 */ EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED, // Spawned by EnEncount1 + /* 2 */ EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM, + /* 3 */ EN_GRASSHOPPER_TYPE_WOODFALL, +} EnGrasshopperType; + +typedef struct EnGrasshopperEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ f32 yaw; + /* 0x20 */ Vec3f scale; + /* 0x2C */ s16 timer; + /* 0x2E */ s16 lightningIndex; +} EnGrasshopperEffect; // size = 0x30 + +#define EN_GRASSHOPPER_EFFECT_COUNT 100 + typedef struct EnGrasshopper { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[DRAGONFLY_LIMB_MAX]; + /* 0x0218 */ Vec3s morphTable[DRAGONFLY_LIMB_MAX]; /* 0x02A8 */ EnGrasshopperActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x15C4]; + /* 0x02AC */ u8 decision; + /* 0x02AD */ u8 shouldTurn; + /* 0x02AE */ UNK_TYPE1 unk_2AE[2]; + /* 0x02B0 */ s16 timer; + /* 0x02B2 */ s16 waitTimer; + /* 0x02B4 */ s16 postBankTimer; + /* 0x02B6 */ s16 drawDmgEffTimer; + /* 0x02B8 */ s16 drawDmgEffType; + /* 0x02BC */ f32 drawDmgEffScale; + /* 0x02C0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02C4 */ Vec3f bodyPartsPos[12]; + /* 0x0354 */ s16 bodyPartsPosIndex; + /* 0x0356 */ s16 splashCount; + /* 0x0358 */ s16 action; + /* 0x035A */ s16 index; // Has a minor effect on speed for some reason. + /* 0x035C */ s16 bankState; + /* 0x035E */ s16 type; + /* 0x0360 */ f32 dragonflyScale; + /* 0x0364 */ f32 rotationalVelocity; + /* 0x0368 */ f32 endFrame; + /* 0x036C */ f32 approachSpeed; + /* 0x0370 */ f32 baseFlyHeight; + /* 0x0374 */ f32 targetPosY; + /* 0x0376 */ Vec3s targetRot; + /* 0x0380 */ Vec3f flyingHomePos; + /* 0x038C */ s16 bobPhase; + /* 0x038E */ UNK_TYPE1 unk_38E[0x26]; + /* 0x03B4 */ Vec3f targetApproachPos; + /* 0x03C0 */ Vec3f tailTipPos; + /* 0x03CC */ Vec3f effectBasePos; + /* 0x03D8 */ Vec3f shadowBodyPartsPos[DRAGONFLY_LIMB_MAX]; + /* 0x04F8 */ f32 waterSurface; + /* 0x04FC */ Vec3f damagedVelocity; + /* 0x0508 */ Vec3s targetBankRot; + /* 0x0510 */ ColliderJntSph collider; + /* 0x0530 */ ColliderJntSphElement colliderElements[2]; + /* 0x0570 */ EnGrasshopperEffect effects[EN_GRASSHOPPER_EFFECT_COUNT]; } EnGrasshopper; // size = 0x1870 extern const ActorInit En_Grasshopper_InitVars; 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 7587e38ca..5d04b7567 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -1539,10 +1539,10 @@ void EnPp_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, (limbIndex == HIPLOOP_LIMB_CENTER_WING_BASE) || (limbIndex == HIPLOOP_LIMB_CENTER_WING_MIDDLE) || (limbIndex == HIPLOOP_LIMB_BACK_LEFT_LOWER_LEG) || (limbIndex == HIPLOOP_LIMB_RIGHT_EYE) || (limbIndex == HIPLOOP_LIMB_LEFT_EYE)) { - Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosCount]); - this->bodyPartsPosCount++; - if (this->bodyPartsPosCount >= ARRAY_COUNT(this->bodyPartsPos)) { - this->bodyPartsPosCount = 0; + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; } if ((this->action == EN_PP_ACTION_SPAWN_BODY_PARTS) && (this->deadBodyPartsSpawnedCount < 6) && diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.h b/src/overlays/actors/ovl_En_Pp/z_en_pp.h index 291c6473b..d181c08de 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.h +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.h @@ -67,7 +67,7 @@ typedef struct EnPp { /* 0x400 */ f32 attackRange; /* 0x404 */ s32 hasBeenDamaged; /* 0x408 */ Vec3f bodyPartsPos[11]; - /* 0x48C */ s16 bodyPartsPosCount; + /* 0x48C */ s16 bodyPartsPosIndex; /* 0x490 */ f32 maskAccelY; /* 0x494 */ ColliderJntSph maskCollider; /* 0x4B4 */ ColliderJntSphElement maskColliderElements[1]; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 40a824f15..11d38fc43 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8751,36 +8751,36 @@ 0x809A610C:("ObjBoyo_Draw",), 0x809A6280:("EnGrasshopper_Init",), 0x809A64E0:("EnGrasshopper_Destroy",), - 0x809A6524:("func_809A6524",), - 0x809A65D8:("func_809A65D8",), - 0x809A6628:("func_809A6628",), - 0x809A6668:("func_809A6668",), - 0x809A6754:("func_809A6754",), - 0x809A67A4:("func_809A67A4",), - 0x809A6B6C:("func_809A6B6C",), - 0x809A6E18:("func_809A6E18",), - 0x809A6E74:("func_809A6E74",), - 0x809A6F8C:("func_809A6F8C",), - 0x809A700C:("func_809A700C",), - 0x809A7134:("func_809A7134",), - 0x809A71CC:("func_809A71CC",), - 0x809A7494:("func_809A7494",), - 0x809A753C:("func_809A753C",), - 0x809A7844:("func_809A7844",), - 0x809A78EC:("func_809A78EC",), - 0x809A797C:("func_809A797C",), - 0x809A7A8C:("func_809A7A8C",), - 0x809A7AE4:("func_809A7AE4",), - 0x809A7BBC:("func_809A7BBC",), - 0x809A7C98:("func_809A7C98",), - 0x809A7CE0:("func_809A7CE0",), - 0x809A8044:("func_809A8044",), + 0x809A6524:("EnGrasshopper_ChangeAnim",), + 0x809A65D8:("EnGrasshopper_RaiseTail",), + 0x809A6628:("EnGrasshopper_LowerTail",), + 0x809A6668:("EnGrasshopper_DecideAction",), + 0x809A6754:("EnGrasshopper_SetupFly",), + 0x809A67A4:("EnGrasshopper_Fly",), + 0x809A6B6C:("EnGrasshopper_RoamInCircles",), + 0x809A6E18:("EnGrasshopper_SetupBank",), + 0x809A6E74:("EnGrasshopper_Turn",), + 0x809A6F8C:("EnGrasshopper_SetupBounced",), + 0x809A700C:("EnGrasshopper_Bounced",), + 0x809A7134:("EnGrasshopper_SetupApproachPlayer",), + 0x809A71CC:("EnGrasshopper_ApproachPlayer",), + 0x809A7494:("EnGrasshopper_SetupAttack",), + 0x809A753C:("EnGrasshopper_Attack",), + 0x809A7844:("EnGrasshopper_SetupWaitAfterAttack",), + 0x809A78EC:("EnGrasshopper_WaitAfterAttack",), + 0x809A797C:("EnGrasshopper_SetupDamaged",), + 0x809A7A8C:("EnGrasshopper_Damaged",), + 0x809A7AE4:("EnGrasshopper_SetupDead",), + 0x809A7BBC:("EnGrasshopper_Dead",), + 0x809A7C98:("EnGrasshopper_SetupFall",), + 0x809A7CE0:("EnGrasshopper_Fall",), + 0x809A8044:("EnGrasshopper_UpdateDamage",), 0x809A8224:("EnGrasshopper_Update",), - 0x809A847C:("func_809A847C",), + 0x809A847C:("EnGrasshopper_PostLimbDraw",), 0x809A8640:("EnGrasshopper_Draw",), - 0x809A8870:("func_809A8870",), - 0x809A8924:("func_809A8924",), - 0x809A8A64:("func_809A8A64",), + 0x809A8870:("EnGrasshopper_InitializeEffect",), + 0x809A8924:("EnGrasshopper_UpdateEffects",), + 0x809A8A64:("EnGrasshopper_DrawEffects",), 0x809A9110:("func_809A9110",), 0x809A91FC:("func_809A91FC",), 0x809A92D0:("func_809A92D0",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index c07dd39b2..26cb0b9fb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -9525,20 +9525,20 @@ 0x809A61E0:("D_809A61E0","f32","",0x4), 0x809A61E4:("D_809A61E4","f32","",0x4), 0x809A61E8:("D_809A61E8","f32","",0x4), - 0x809A8C80:("D_809A8C80","UNK_TYPE4","",0x4), - 0x809A8C94:("D_809A8C94","UNK_TYPE1","",0x1), - 0x809A8CAC:("D_809A8CAC","UNK_TYPE1","",0x1), - 0x809A8CC4:("D_809A8CC4","UNK_TYPE1","",0x1), - 0x809A8CDC:("D_809A8CDC","UNK_TYPE1","",0x1), + 0x809A8C80:("sOccupiedIndices","UNK_TYPE4","",0x4), + 0x809A8C94:("sLimbIndexToShadowBodyPartsIndex","UNK_TYPE1","",0x1), + 0x809A8CAC:("sParentBodyParts","UNK_TYPE1","",0x1), + 0x809A8CC4:("sShadowSizes","UNK_TYPE1","",0x1), + 0x809A8CDC:("sDamageTable","UNK_TYPE1","",0x1), 0x809A8CFC:("En_Grasshopper_InitVars","UNK_TYPE1","",0x1), - 0x809A8D1C:("D_809A8D1C","UNK_TYPE1","",0x1), - 0x809A8D64:("D_809A8D64","UNK_TYPE1","",0x1), - 0x809A8D74:("D_809A8D74","UNK_TYPE1","",0x1), - 0x809A8D94:("D_809A8D94","UNK_TYPE1","",0x1), - 0x809A8D9C:("D_809A8D9C","UNK_TYPE4","",0x4), - 0x809A8E08:("D_809A8E08","UNK_TYPE4","",0x4), - 0x809A8E14:("D_809A8E14","UNK_TYPE4","",0x4), - 0x809A8E20:("D_809A8E20","UNK_TYPE1","",0x1), + 0x809A8D1C:("sJntSphElementsInit","UNK_TYPE1","",0x1), + 0x809A8D64:("sJntSphInit","UNK_TYPE1","",0x1), + 0x809A8D74:("sAnimations","UNK_TYPE1","",0x1), + 0x809A8D94:("sAnimationModes","UNK_TYPE1","",0x1), + 0x809A8D9C:("sFireVelocityAndAccel","UNK_TYPE4","",0x4), + 0x809A8E08:("sEffectOffsetFromTailTop","UNK_TYPE4","",0x4), + 0x809A8E14:("sZeroVec3f","UNK_TYPE4","",0x4), + 0x809A8E20:("sLightningTextures","UNK_TYPE1","",0x1), 0x809A8E40:("D_809A8E40","f32","",0x4), 0x809A8E44:("D_809A8E44","f32","",0x4), 0x809A8E48:("D_809A8E48","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 5cb5cdf0b..658dd5f05 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1069,11 +1069,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Grasshopper - -D_06000F9C = 0x06000F9C; -D_06003F00 = 0x06003F00; - // ovl_En_Hgo D_0600B644 = 0x0600B644; From 91d4e29dfab60d4ced001cce7993d60b5f5c705b Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 27 Sep 2022 14:48:57 -0700 Subject: [PATCH 47/73] Document object_zos (Evan) (#1091) * Name all but one DList * Name keyboard textures * Finish object * Respond to Elliptic's review * Respond to Anghelo's review * Comments for animations in array * Respond to Engineer's review --- assets/xml/objects/object_zos.xml | 145 ++++++++++-------- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 175 +++++++++++++--------- src/overlays/actors/ovl_En_Zos/z_en_zos.h | 11 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 2 +- 5 files changed, 189 insertions(+), 146 deletions(-) diff --git a/assets/xml/objects/object_zos.xml b/assets/xml/objects/object_zos.xml index 016831ac5..a1364a842 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -1,69 +1,84 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 1419a7ecd..1b7be4e0b 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -5,7 +5,6 @@ */ #include "z_en_zos.h" -#include "objects/object_zos/object_zos.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) @@ -16,7 +15,7 @@ void EnZos_Destroy(Actor* thisx, PlayState* play); void EnZos_Update(Actor* thisx, PlayState* play); void EnZos_Draw(Actor* thisx, PlayState* play); -void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2); +void EnZos_ChangeAnim(EnZos* this, s16 arg1, u8 arg2); void func_80BBB2C4(EnZos* this, PlayState* play); void func_80BBB354(EnZos* this, PlayState* play); void func_80BBB4CC(EnZos* this, PlayState* play); @@ -34,6 +33,23 @@ void func_80BBC24C(EnZos* this, PlayState* play); void func_80BBC298(EnZos* this, PlayState* play); void func_80BBC37C(EnZos* this, PlayState* play); +typedef enum { + /* 0 */ EN_ZOS_ANIM_LEAN_ON_KEYBOARD, + /* 1 */ EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, + /* 2 */ EN_ZOS_ANIM_HANDS_ON_HIPS, + /* 3 */ EN_ZOS_ANIM_TALK_FOOT_TAP, + /* 4 */ EN_ZOS_ANIM_TALK_LOOK_DOWN, + /* 5 */ EN_ZOS_ANIM_TALK_ARMS_OUT, + /* 6 */ EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, + /* 7 */ EN_ZOS_ANIM_PLAY_RIGHT, + /* 8 */ EN_ZOS_ANIM_PLAY_LEFT, + /* 9 */ EN_ZOS_ANIM_INSPIRED, + /* 10 */ EN_ZOS_ANIM_SLOW_PLAY, + /* 11 */ EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED, + /* 12 */ EN_ZOS_ANIM_PLAY_LEFT_SHORTENED, + /* 13 */ EN_ZOS_ANIM_MAX +} EnZosAnimation; + const ActorInit En_Zos_InitVars = { ACTOR_EN_ZOS, ACTORCAT_NPC, @@ -73,14 +89,14 @@ void EnZos_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80BBBDE0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - SkelAnime_InitFlex(play, &this->skelAnime, &object_zos_Skel_015238, &object_zos_Anim_00A164, this->jointTable, - this->morphTable, 18); - Animation_PlayLoop(&this->skelAnime, &object_zos_Anim_00A164); + SkelAnime_InitFlex(play, &this->skelAnime, &gEvanSkel, &gEvanLeanOnKeyboardAnim, this->jointTable, this->morphTable, + EVAN_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEvanLeanOnKeyboardAnim); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_2B6 = 0; this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; - func_80BBAE84(this, 0, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: @@ -93,12 +109,12 @@ void EnZos_Init(Actor* thisx, PlayState* play) { } else { this->actionFunc = func_80BBC14C; } - func_80BBAE84(this, 0, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); break; case ENZOS_F_2: this->actionFunc = func_80BBC37C; - func_80BBAE84(this, 7, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, ANIMMODE_ONCE); this->unk_2BC = -1; this->unk_2B6 |= 0x40; break; @@ -118,23 +134,34 @@ void EnZos_Destroy(Actor* thisx, PlayState* play) { gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } -void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { - static AnimationHeader* sAnimations[] = { - &object_zos_Anim_00A164, &object_zos_Anim_01621C, &object_zos_Anim_016980, &object_zos_Anim_007C40, - &object_zos_Anim_008630, &object_zos_Anim_0090CC, &object_zos_Anim_009830, &object_zos_Anim_005E04, - &object_zos_Anim_007334, &object_zos_Anim_0048D4, &object_zos_Anim_001CFC, &object_zos_Anim_005E04, - &object_zos_Anim_007334, - }; - f32 phi_f0; +static AnimationHeader* sAnimations[] = { + &gEvanLeanOnKeyboardAnim, // EN_ZOS_ANIM_LEAN_ON_KEYBOARD + &gEvanLeanOnKeyboardAndSighAnim, // EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH + &gEvanHandsOnHipsAnim, // EN_ZOS_ANIM_HANDS_ON_HIPS + &gEeanTalkFootTapAnim, // EN_ZOS_ANIM_TALK_FOOT_TAP + &gEvanTalkLookDownAnim, // EN_ZOS_ANIM_TALK_LOOK_DOWN + &gEvanTalkArmsOutAnim, // EN_ZOS_ANIM_TALK_ARMS_OUT + &gEvanTalkHandsOnHipsAnim, // EN_ZOS_ANIM_TALK_HANDS_ON_HIPS + &gEvanPlayRightAnim, // EN_ZOS_ANIM_PLAY_RIGHT + &gEvanPlayLeftAnim, // EN_ZOS_ANIM_PLAY_LEFT + &gEvanInspiredAnim, // EN_ZOS_ANIM_INSPIRED + &gEvanSlowPlayAnim, // EN_ZOS_ANIM_SLOW_PLAY + &gEvanPlayRightAnim, // EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED + &gEvanPlayLeftAnim, // EN_ZOS_ANIM_PLAY_LEFT_SHORTENED +}; - if ((arg1 != this->unk_2B8) && (arg1 >= 0) && (arg1 < 13)) { - if (arg1 > 10) { - phi_f0 = 29.0f; +void EnZos_ChangeAnim(EnZos* this, s16 animIndex, u8 animMode) { + f32 endFrame; + + if ((animIndex != this->animIndex) && (animIndex >= EN_ZOS_ANIM_LEAN_ON_KEYBOARD) && + (animIndex < EN_ZOS_ANIM_MAX)) { + if (animIndex > EN_ZOS_ANIM_SLOW_PLAY) { + endFrame = 29.0f; } else { - phi_f0 = Animation_GetLastFrame(sAnimations[arg1]); + endFrame = Animation_GetLastFrame(sAnimations[animIndex]); } - Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, phi_f0, arg2, -5.0f); - this->unk_2B8 = arg1; + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, endFrame, animMode, -5.0f); + this->animIndex = animIndex; this->unk_2B6 &= ~0x80; } } @@ -153,19 +180,19 @@ s32 func_80BBAFFC(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { switch ((s16)Rand_ZeroFloat(4.0f)) { case 0: - func_80BBAE84(this, 7, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, ANIMMODE_ONCE); break; case 1: - func_80BBAE84(this, 8, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_LEFT, ANIMMODE_ONCE); break; case 2: - func_80BBAE84(this, 11, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED, ANIMMODE_ONCE); break; default: - func_80BBAE84(this, 12, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_LEFT_SHORTENED, ANIMMODE_ONCE); break; } return true; @@ -176,9 +203,9 @@ s32 func_80BBAFFC(EnZos* this, PlayState* play) { void func_80BBB0D4(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (Rand_ZeroFloat(1.0f) < 0.9f) { - func_80BBAE84(this, 0, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); } else { - func_80BBAE84(this, 1, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, ANIMMODE_ONCE); } SkelAnime_Update(&this->skelAnime); } @@ -190,31 +217,31 @@ void func_80BBB15C(EnZos* this, PlayState* play) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (this->unk_2B6 & 4) { textId = 0x123E; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1231; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } } else { this->unk_2B6 &= ~2; if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1244; gSaveContext.save.weekEventReg[39] |= 0x10; - func_80BBAE84(this, 4, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 0x10; } } @@ -261,11 +288,11 @@ void func_80BBB414(EnZos* this, PlayState* play) { switch (action) { case 1: - func_80BBAE84(this, 1, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, ANIMMODE_LOOP); break; case 2: - func_80BBAE84(this, 10, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_SLOW_PLAY, ANIMMODE_LOOP); break; } } @@ -304,7 +331,7 @@ void func_80BBB574(EnZos* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x124B: - if (this->unk_2B8 == 9) { + if (this->animIndex == EN_ZOS_ANIM_INSPIRED) { play->msgCtx.msgLength = 0; this->unk_2B6 |= 0x20; } else { @@ -315,12 +342,12 @@ void func_80BBB574(EnZos* this, PlayState* play) { case 0x124C: play->msgCtx.msgLength = 0; this->actionFunc = func_80BBB4CC; - func_80BBAE84(this, 10, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_SLOW_PLAY, ANIMMODE_LOOP); break; case 0x124D: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); func_80151938(play, 0x124E); break; @@ -346,7 +373,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { if (sp24 == 25) { player->actor.textId = 0x1232; - func_80BBAE84(this, 5, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); this->unk_2B6 |= 8; gSaveContext.save.weekEventReg[40] |= 0x20; } else if (gSaveContext.save.weekEventReg[39] & 8) { @@ -354,7 +381,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { } else { player->actor.textId = 0x1237; gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -364,7 +391,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { } else { func_80151938(play, 0x1237); gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -382,7 +409,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->unk_2B6 & 0x80) && (this->actor.yawTowardsPlayer == this->actor.shape.rot.y)) { - func_80BBAE84(this, 3, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_FOOT_TAP, ANIMMODE_LOOP); } } @@ -402,7 +429,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1244: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -412,18 +439,18 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1239: case 0x1246: - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1233: - func_80BBAE84(this, 5, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: - func_80BBAE84(this, 3, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_FOOT_TAP, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -434,7 +461,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1243: case 0x1249: - func_80BBAE84(this, 2, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; @@ -443,7 +470,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1234: case 0x123D: case 0x1242: - func_80BBAE84(this, 2, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); Actor_ProcessTalkRequest(&this->actor, &play->state); func_801477B4(play); this->actionFunc = func_80BBBDE0; @@ -451,7 +478,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { break; case 0x1236: - func_80BBAE84(this, 2, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; @@ -473,17 +500,17 @@ void func_80BBBB84(EnZos* this, PlayState* play) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(play, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[41] & 0x10) { Message_StartTextbox(play, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); } else { gSaveContext.save.weekEventReg[41] |= 0x10; Message_StartTextbox(play, 0x124B, &this->actor); this->actionFunc = func_80BBB574; - func_80BBAE84(this, 9, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_INSPIRED, ANIMMODE_ONCE); this->unk_2B6 |= 0x10; } } else { @@ -494,7 +521,7 @@ void func_80BBBB84(EnZos* this, PlayState* play) { void func_80BBBCBC(EnZos* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80BBAE84(this, 5, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); Message_StartTextbox(play, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { @@ -519,7 +546,7 @@ void func_80BBBDE0(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == thisx->shape.rot.y) { - func_80BBAE84(this, 0, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } @@ -567,10 +594,10 @@ void func_80BBBFBC(EnZos* this, PlayState* play) { textId = 0x1259; gSaveContext.save.weekEventReg[78] |= 0x80; } - func_80BBAE84(this, 5, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); } else { textId = 0x1258; - func_80BBAE84(this, 6, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); } Message_StartTextbox(play, textId, &this->actor); } @@ -583,7 +610,7 @@ void func_80BBC070(EnZos* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_80BBAE84(this, 2, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; @@ -591,7 +618,7 @@ void func_80BBC070(EnZos* this, PlayState* play) { break; case TEXT_STATE_CLOSING: - func_80BBAE84(this, 2, ANIMMODE_LOOP); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; break; @@ -605,7 +632,7 @@ void func_80BBC14C(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == this->actor.shape.rot.y) { - func_80BBAE84(this, 0, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } @@ -628,7 +655,7 @@ void func_80BBC24C(EnZos* this, PlayState* play) { func_80BBB0D4(this, play); if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; - func_80BBAE84(this, 7, ANIMMODE_ONCE); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, ANIMMODE_ONCE); } } @@ -675,13 +702,13 @@ void EnZos_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if (DECR(this->unk_2AE) == 0) { - this->unk_2AE = Rand_S16Offset(60, 60); + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); } - this->unk_2AC = this->unk_2AE; - if (this->unk_2AC >= 3) { - this->unk_2AC = 0; + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; } } @@ -692,16 +719,16 @@ s32 func_80BBC4E4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s void func_80BBC500(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f D_80BBC750 = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 9) { + if (limbIndex == EVAN_LIMB_HEAD) { Matrix_MultVec3f(&D_80BBC750, &thisx->focus.pos); } } void EnZos_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80BBC75C[] = { - object_zos_Tex_010918, - object_zos_Tex_011118, - object_zos_Tex_011918, + static TexturePtr sEyeTextures[] = { + gEvanEyeOpenTex, + gEvanEyeHalfTex, + gEvanEyeClosedTex, }; EnZos* this = THIS; Gfx* gfx; @@ -716,15 +743,15 @@ void EnZos_Draw(Actor* thisx, PlayState* play) { gfx = POLY_OPA_DISP; - gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80BBC75C[this->unk_2AC])); + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); 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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&gfx[2], object_zos_DL_0136E0); - gSPDisplayList(&gfx[3], object_zos_DL_013088); + gSPDisplayList(&gfx[2], gEvanUnknownWhiteTriangleDL); + gSPDisplayList(&gfx[3], gEvanKeyboardDL); POLY_OPA_DISP = &gfx[4]; diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.h b/src/overlays/actors/ovl_En_Zos/z_en_zos.h index 99125aad3..bf5a9c07b 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.h +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.h @@ -2,6 +2,7 @@ #define Z_EN_ZOS_H #include "global.h" +#include "objects/object_zos/object_zos.h" struct EnZos; @@ -16,15 +17,15 @@ enum { typedef struct EnZos { /* 0x000 */ Actor actor; - /* 0x144 */ Vec3s jointTable[18]; - /* 0x1B0 */ Vec3s morphTable[18]; + /* 0x144 */ Vec3s jointTable[EVAN_LIMB_MAX]; + /* 0x1B0 */ Vec3s morphTable[EVAN_LIMB_MAX]; /* 0x21C */ SkelAnime skelAnime; /* 0x260 */ ColliderCylinder collider; - /* 0x2AC */ s16 unk_2AC; - /* 0x2AE */ s16 unk_2AE; + /* 0x2AC */ s16 eyeIndex; + /* 0x2AE */ s16 blinkTimer; /* 0x2B0 */ UNK_TYPE1 unk2B0[6]; /* 0x2B6 */ u16 unk_2B6; - /* 0x2B8 */ s16 unk_2B8; + /* 0x2B8 */ s16 animIndex; /* 0x2BA */ s16 unk_2BA; /* 0x2BC */ s16 unk_2BC; /* 0x2C0 */ EnZosActionFunc actionFunc; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 11d38fc43..d741d7408 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15387,7 +15387,7 @@ 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), - 0x80BBAE84:("func_80BBAE84",), + 0x80BBAE84:("EnZos_ChangeAnim",), 0x80BBAF5C:("func_80BBAF5C",), 0x80BBAFFC:("func_80BBAFFC",), 0x80BBB0D4:("func_80BBB0D4",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 26cb0b9fb..0ea237d4b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15606,7 +15606,7 @@ 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), 0x80BBC750:("D_80BBC750","UNK_TYPE1","",0x1), - 0x80BBC75C:("D_80BBC75C","UNK_TYPE1","",0x1), + 0x80BBC75C:("sEyeTextures","UNK_TYPE1","",0x1), 0x80BBC770:("D_80BBC770","f32","",0x4), 0x80BBC774:("jtbl_80BBC774","UNK_PTR","",0x4), 0x80BBF800:("En_S_Goro_InitVars","ActorInit","",0x20), From 5e860dd3e7989e6ea1712e9b250a1e47fbcfe692 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 28 Sep 2022 18:47:46 -0400 Subject: [PATCH 48/73] `z_parameter`: Hud Visibility (#942) * Begin interface alpha docs * More Interface Alpha * cleanup docs * Minor fixes * Apply Discord Discussions * More discussions * More suggestions from OoT * fix merge --- include/functions.h | 5 +- include/z64save.h | 38 +- include/z64scene.h | 8 +- src/code/z_actor.c | 28 +- src/code/z_bgcheck.c | 6 +- src/code/z_common_data.c | 2 +- src/code/z_demo.c | 12 +- src/code/z_game_over.c | 8 +- src/code/z_kaleido_setup.c | 2 +- src/code/z_map_exp.c | 4 +- src/code/z_message.c | 2 +- src/code/z_parameter.c | 765 +++++++++++++++++- src/code/z_play.c | 4 +- src/code/z_player_lib.c | 19 +- src/code/z_room.c | 22 +- src/code/z_scene.c | 12 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 18 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 2 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 2 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 4 +- .../actors/ovl_Door_Spiral/z_door_spiral.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 4 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 6 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 4 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 12 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 2 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 8 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 6 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 4 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 4 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 4 +- src/overlays/actors/ovl_En_Test2/z_en_test2.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 4 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 4 +- .../actors/ovl_En_Viewer/z_en_viewer.c | 6 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 8 +- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 14 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 4 +- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 4 +- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 4 +- src/overlays/gamestates/ovl_select/z_select.c | 8 +- .../ovl_kaleido_scope/z_kaleido_item.c | 8 +- tools/disasm/functions.txt | 8 +- tools/namefixer.py | 6 + tools/sizes/code_functions.csv | 8 +- 53 files changed, 960 insertions(+), 169 deletions(-) diff --git a/include/functions.h b/include/functions.h index 05db21f4f..f04ab1981 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1823,10 +1823,7 @@ void func_8010EA9C(s32 arg0, s32 arg1); // void func_8010EBA0(void); // void func_8010EC54(void); void func_8010EE74(PlayState* play, s32 day); -void Interface_ChangeAlpha(u16 param_1); -// void func_8010EF9C(void); -// void func_8010F0D4(void); -// void func_8010F1A8(void); +void Interface_SetHudVisibility(u16 hudVisibility); // void func_80110038(void); // void func_80111CB4(void); // void func_801129E4(void); diff --git a/include/z64save.h b/include/z64save.h index 12b525f4d..57801684f 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -54,6 +54,34 @@ typedef enum { #define MAGIC_NORMAL_METER 0x30 #define MAGIC_DOUBLE_METER (2 * MAGIC_NORMAL_METER) +typedef enum { + /* 0 */ HUD_VISIBILITY_IDLE, + /* 1 */ HUD_VISIBILITY_NONE, + /* 2 */ HUD_VISIBILITY_NONE_ALT, // Identical to HUD_VISIBILITY_NONE + /* 3 */ HUD_VISIBILITY_HEARTS_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 4 */ HUD_VISIBILITY_A, + /* 5 */ HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 6 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 7 */ HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED, // Only raises button alphas if not disabled + /* 8 */ HUD_VISIBILITY_B, + /* 9 */ HUD_VISIBILITY_HEARTS_MAGIC, + /* 10 */ HUD_VISIBILITY_B_ALT, + /* 11 */ HUD_VISIBILITY_HEARTS, + /* 12 */ HUD_VISIBILITY_A_B_MINIMAP, + /* 13 */ HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 14 */ HUD_VISIBILITY_HEARTS_MAGIC_C, + /* 15 */ HUD_VISIBILITY_ALL_NO_MINIMAP, + /* 16 */ HUD_VISIBILITY_A_B_C, + /* 17 */ HUD_VISIBILITY_B_MINIMAP, + /* 18 */ HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP, + /* 19 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP, + /* 20 */ HUD_VISIBILITY_B_MAGIC, + /* 21 */ HUD_VISIBILITY_A_B, + /* 22 */ HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP, + /* 50 */ HUD_VISIBILITY_ALL = 50, + /* 52 */ HUD_VISIBILITY_NONE_INSTANT = 52 +} HudVisibility; + typedef struct SramContext { /* 0x00 */ u8* readBuff; /* 0x04 */ u8 *saveBuf; @@ -251,11 +279,11 @@ typedef struct SaveContext { /* 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" + /* 0x3F1E */ u8 hudVisibilityForceButtonAlphasByStatus; // if btn alphas are updated through Interface_UpdateButtonAlphas, instead update them through Interface_UpdateButtonAlphasByStatus "ck_fg" + /* 0x3F20 */ u16 nextHudVisibility; // triggers the hud to change visibility to the requested value. Reset to HUD_VISIBILITY_IDLE when target is reached "alpha_type" + /* 0x3F22 */ u16 hudVisibility; // current hud visibility "prev_alpha_type" + /* 0x3F24 */ u16 hudVisibilityTimer; // number of frames in the transition to a new hud visibility. Used to step alpha "alpha_count" + /* 0x3F26 */ u16 prevHudVisibility; // used to store and recover hud visibility for pause menu and text boxes "last_time_type" /* 0x3F28 */ s16 magicState; // determines magic meter behavior on each frame "magic_flag" /* 0x3F2A */ s16 isMagicRequested; // a request to add magic has been given "recovery_magic_flag" /* 0x3F2C */ s16 magicFlag; // Set to 0 in func_80812D94(), otherwise unused "keep_magic_flag" diff --git a/include/z64scene.h b/include/z64scene.h index 649a4e011..180405f30 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -271,7 +271,7 @@ typedef struct { } Room; // size = 0x14 typedef struct { - /* 0x00 */ Room currRoom; + /* 0x00 */ Room curRoom; /* 0x14 */ Room prevRoom; /* 0x28 */ void* roomMemPages[2]; // In a scene with transitions, roomMemory is split between two pages that toggle each transition. This is one continuous range, as the second page allocates from the end /* 0x30 */ u8 activeMemPage; // 0 - First page in memory, 1 - Second page @@ -843,11 +843,11 @@ typedef enum { #define SCENE_CMD_SPECIAL_FILES(elfMessageFile, keepObjectId) \ { SCENE_CMD_ID_SPECIAL_FILES, elfMessageFile, CMD_W(keepObjectId) } -#define SCENE_CMD_ROOM_BEHAVIOR(currRoomUnk3, currRoomUnk2, currRoomUnk5, msgCtxunk12044, enablePosLights, \ +#define SCENE_CMD_ROOM_BEHAVIOR(curRoomUnk3, curRoomUnk2, curRoomUnk5, msgCtxunk12044, enablePosLights, \ kankyoContextUnkE2) \ { \ - SCENE_CMD_ID_ROOM_BEHAVIOR, currRoomUnk3, \ - currRoomUnk2 | _SHIFTL(currRoomUnk5, 8, 1) | _SHIFTL(msgCtxunk12044, 10, 1) | \ + SCENE_CMD_ID_ROOM_BEHAVIOR, curRoomUnk3, \ + curRoomUnk2 | _SHIFTL(curRoomUnk5, 8, 1) | _SHIFTL(msgCtxunk12044, 10, 1) | \ _SHIFTL(enablePosLights, 11, 1) | _SHIFTL(kankyoContextUnkE2, 12, 1) \ } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 61e4dc807..0195ac650 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1336,7 +1336,7 @@ s32 func_800B715C(PlayState* play) { } void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { - if ((play->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { + if ((play->roomCtx.curRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { @@ -2499,7 +2499,7 @@ void Actor_Draw(PlayState* play, Actor* actor) { OPEN_DISPS(play->state.gfxCtx); light = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); - if ((actor->flags & ACTOR_FLAG_10000000) && (play->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) { + if ((actor->flags & ACTOR_FLAG_10000000) && (play->roomCtx.curRoom.enablePosLights || (MREG(93) != 0))) { light->enablePosLights = true; } @@ -2669,7 +2669,7 @@ void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors) { gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); // temp_s1_5 = spAC; - if (play->roomCtx.currRoom.unk5 == 0) { + if (play->roomCtx.curRoom.unk5 == 0) { // temp_s1_5->words.w0 = 0xFC61E6C3; // temp_s1_5->words.w1 = 0x11CF9FCF; // phi_s1 = temp_s1_5 + 8; @@ -2719,7 +2719,7 @@ void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors) { // temp_a0_2 = &spAC; // if (sp34->unk_6E5 == 0) { - if (play->roomCtx.currRoom.unk5 == 0) { + if (play->roomCtx.curRoom.unk5 == 0) { // temp_s1_10->unk_0 = 0xFC119623; // temp_s1_10->unk_4 = 0xFF2FFFFF; // phi_s1_4 = temp_s1_10 + 8; @@ -2882,8 +2882,8 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { actor->isDrawn = false; if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { if ((actor->flags & ACTOR_FLAG_80) && - ((play->roomCtx.currRoom.unk5 == 0) || (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || - (actor->room != play->roomCtx.currRoom.num))) { + ((play->roomCtx.curRoom.unk5 == 0) || (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || + (actor->room != play->roomCtx.curRoom.num))) { if (Actor_RecordUndrawnActor(play, actor)) {} } else { Actor_Draw(play, actor); @@ -2960,7 +2960,7 @@ void func_800BA798(PlayState* play, ActorContext* actorCtx) { actor = actorCtx->actorLists[i].first; while (actor != NULL) { - if ((actor->room >= 0) && (actor->room != play->roomCtx.currRoom.num) && + if ((actor->room >= 0) && (actor->room != play->roomCtx.curRoom.num) && (actor->room != play->roomCtx.prevRoom.num)) { if (!actor->isDrawn) { actor = Actor_Delete(actorCtx, actor, play); @@ -3091,9 +3091,9 @@ Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove->next = NULL; actorToRemove->prev = NULL; - if ((actorToRemove->room == play->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && + if ((actorToRemove->room == play->roomCtx.curRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { - Flags_SetClearTemp(play, play->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.curRoom.num); } return newHead; @@ -3180,8 +3180,8 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 } objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); - if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) && - Flags_GetClear(play, play->roomCtx.currRoom.num) && (actorInit->id != ACTOR_BOSS_05))) { + if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num) && + (actorInit->id != ACTOR_BOSS_05))) { Actor_FreeOverlay(&gActorOverlayTable[index]); return NULL; } @@ -3219,7 +3219,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 actor->parent = parent; parent->child = actor; } else { - actor->room = play->roomCtx.currRoom.num; + actor->room = play->roomCtx.curRoom.num; } actor->home.pos.x = x; @@ -3267,10 +3267,10 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { for (i = 0; i < numTransitionActors; transitionActorList++, i++) { if (transitionActorList->id >= 0) { if ((transitionActorList->sides[0].room >= 0 && - (play->roomCtx.currRoom.num == transitionActorList->sides[0].room || + (play->roomCtx.curRoom.num == transitionActorList->sides[0].room || play->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) || (transitionActorList->sides[1].room >= 0 && - (play->roomCtx.currRoom.num == transitionActorList->sides[1].room || + (play->roomCtx.curRoom.num == transitionActorList->sides[1].room || play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e73dd7f6e..1b8dbfb2e 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4404,7 +4404,7 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = 0x3F & (curWaterBox->properties >> 13); - if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) { + if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { if (curWaterBox->properties & 0x80000) { continue; } @@ -4489,7 +4489,7 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, waterBox = &colHeader->waterBoxes[i]; room = WATERBOX_ROOM(waterBox->properties); - if (!(room == play->roomCtx.currRoom.num || room == 0x3F)) { + if (!(room == play->roomCtx.curRoom.num || room == 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { @@ -4631,7 +4631,7 @@ s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = WATERBOX_ROOM(curWaterBox->properties); - if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) { + if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { if ((curWaterBox->properties & 0x80000) != 0) { if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 955f54870..c970282a8 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -16,7 +16,7 @@ void SaveContext_Init(void) { gSaveContext.skyboxTime = 0; gSaveContext.dogIsLost = true; gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; - gSaveContext.unk_3F26 = 50; + gSaveContext.prevHudVisibility = HUD_VISIBILITY_ALL; gSaveContext.options.language = 1; gSaveContext.options.audioSetting = 0; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 4b571cadd..4453bd674 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -105,7 +105,7 @@ s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) { } void func_800EA258(PlayState* play, CutsceneContext* csCtx) { - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_SetLetterboxTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); @@ -115,7 +115,7 @@ void func_800EA258(PlayState* play, CutsceneContext* csCtx) { void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { func_800ED980(play, csCtx); - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_SetLetterboxTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); @@ -215,7 +215,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c D_801F6D30.a = 255 * progress; break; case 0xC: - play->roomCtx.currRoom.segment = NULL; + play->roomCtx.curRoom.segment = NULL; break; case 0xD: if (play->state.frames & 8) { @@ -561,7 +561,7 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* gSaveContext.cutsceneTransitionControl = 1; if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { - gSaveContext.unk_3F1E = 1; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; } gSaveContext.save.cutscene = 0; @@ -1078,7 +1078,7 @@ void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdText } if (originalCsFrames == csCtx->frames) { - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); D_801BB124 = 0; D_801BB128 = 0; func_80161C0C(); @@ -1451,7 +1451,7 @@ void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { csCtx->unk_18 = 0xFFFF; if (gSaveContext.cutsceneTrigger == 0) { - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_SetLetterboxTarget(32); ShrinkWindow_SetLetterboxMagnitude(0x20); csCtx->state++; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index dcbe71a1c..394a10600 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -57,10 +57,10 @@ void GameOver_Update(PlayState* play) { gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; - gSaveContext.unk_3F1E = 0; - gSaveContext.unk_3F20 = 0; - gSaveContext.unk_3F22 = 0; - gSaveContext.unk_3F24 = 0; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibilityTimer = 0; Kankyo_InitGameOverLights(play); sGameOverTimer = 20; Rumble_Request(0.0f, 126, 124, 63); diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 50022849e..1135f2de9 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -81,7 +81,7 @@ void KaleidoSetup_Update(PlayState* play) { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && !(play->actorCtx.flags & ACTORCTX_FLAG_2)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { - gSaveContext.unk_3F26 = gSaveContext.unk_3F22; + gSaveContext.prevHudVisibility = gSaveContext.hudVisibility; pauseCtx->itemDescriptionOn = false; pauseCtx->state = 1; func_800F4A10(play); diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 5135a3c41..40ffb4213 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -177,7 +177,7 @@ void Map_Init(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; s32 dungeonIndex; - func_80105C40(play->roomCtx.currRoom.num); + func_80105C40(play->roomCtx.curRoom.num); interfaceCtx->unk_278 = -1; interfaceCtx->dungeonOrBossAreaMapIndex = -1; interfaceCtx->mapSegment = THA_AllocEndAlign16(&play->state.heap, 0x1000); @@ -208,7 +208,7 @@ void Map_Init(PlayState* play) { } gSaveContext.dungeonIndex = dungeonIndex; - Map_InitRoomData(play, play->roomCtx.currRoom.num); + Map_InitRoomData(play, play->roomCtx.curRoom.num); } } diff --git a/src/code/z_message.c b/src/code/z_message.c index f98d3cf3a..4b4ac82a5 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -360,7 +360,7 @@ void func_80151A68(PlayState* play, u16 textId) { XREG(77) = 0x3C; XREG(76) = 0x1C; msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); } } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 403a69c51..679b8abf4 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -281,13 +281,770 @@ void func_8010EBA0(s16 timer, s16 timerId); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EE74.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_ChangeAlpha.s") +void Interface_SetHudVisibility(u16 hudVisibility) { + if (gSaveContext.hudVisibility != hudVisibility) { + gSaveContext.hudVisibility = hudVisibility; + gSaveContext.nextHudVisibility = hudVisibility; + gSaveContext.hudVisibilityTimer = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EF9C.s") +/** + * Sets the button alphas to be dimmed for disabled buttons, or to the requested alpha for non-disabled buttons + */ +void Interface_UpdateButtonAlphasByStatus(PlayState* play, s16 risingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010F0D4.s") + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if (interfaceCtx->bAlpha != 70) { + interfaceCtx->bAlpha = 70; + } + } else { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010F1A8.s") + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] == BTN_DISABLED) { + if (interfaceCtx->cLeftAlpha != 70) { + interfaceCtx->cLeftAlpha = 70; + } + } else { + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] == BTN_DISABLED) { + if (interfaceCtx->cDownAlpha != 70) { + interfaceCtx->cDownAlpha = 70; + } + } else { + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] == BTN_DISABLED) { + if (interfaceCtx->cRightAlpha != 70) { + interfaceCtx->cRightAlpha = 70; + } + } else { + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + if (interfaceCtx->aAlpha != 70) { + interfaceCtx->aAlpha = 70; + } + } else { + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + } +} + +/** + * Lower button alphas on the HUD to the requested value + * If (gSaveContext.hudVisibilityForceButtonAlphasByStatus), then instead update button alphas + * depending on button status + */ +void Interface_UpdateButtonAlphas(PlayState* play, s16 dimmingAlpha, s16 risingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + if (gSaveContext.hudVisibilityForceButtonAlphasByStatus) { + Interface_UpdateButtonAlphasByStatus(play, risingAlpha); + return; + } + + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } +} + +void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 risingAlpha = 255 - dimmingAlpha; + + switch (gSaveContext.nextHudVisibility) { + case HUD_VISIBILITY_NONE: + case HUD_VISIBILITY_NONE_ALT: + case HUD_VISIBILITY_B: + if (gSaveContext.nextHudVisibility == HUD_VISIBILITY_B) { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } else { + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_WITH_OVERWRITE: + // aAlpha is immediately overwritten in Interface_UpdateButtonAlphas + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha + 0); + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + // aAlpha is immediately overwritten below + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (play->sceneNum == SCENE_SPOT00) { + if (interfaceCtx->minimapAlpha < 170) { + interfaceCtx->minimapAlpha = risingAlpha; + } else { + interfaceCtx->minimapAlpha = 170; + } + } else if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + Interface_UpdateButtonAlphasByStatus(play, risingAlpha); + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_ALT: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_MINIMAP: + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if (interfaceCtx->bAlpha != 70) { + interfaceCtx->bAlpha = 70; + } + } else { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_C: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_ALL_NO_MINIMAP: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_C: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_MINIMAP: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_MAGIC: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B: + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + } + + if ((play->roomCtx.curRoom.unk3 == 1) && (interfaceCtx->minimapAlpha >= 255)) { + interfaceCtx->minimapAlpha = 255; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80110038.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index 346f34692..5a60a615e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -377,7 +377,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance), - this->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, + this->roomCtx.curRoom.num, playerParams, &player->actor.world.pos, player->actor.shape.rot.y); } } @@ -427,7 +427,7 @@ void func_80169FDC(GameState* thisx) { s32 func_80169FFC(GameState* thisx) { PlayState* this = (PlayState*)thisx; - return this->roomCtx.currRoom.mesh->type0.type != 1; + return this->roomCtx.curRoom.mesh->type0.type != 1; } s32 FrameAdvance_IsEnabled(GameState* thisx) { diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 8ced31cb7..c8d1c802f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -389,7 +389,7 @@ void func_80123140(PlayState* play, Player* player) { IREG(69) = bootRegs[16]; MREG(95) = bootRegs[17]; - if (play->roomCtx.currRoom.unk3 == 2) { + if (play->roomCtx.curRoom.unk3 == 2) { R_RUN_SPEED_LIMIT = 500; } @@ -508,20 +508,23 @@ s32 func_8012364C(PlayState* play, Player* player, s32 arg2) { if (arg2 == 1) { return (gSaveContext.buttonStatus[1] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] - : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] - : ITEM_NONE; + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] + : ITEM_NONE; } if (arg2 == 2) { return (gSaveContext.buttonStatus[2] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] - : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] - : ITEM_NONE; + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] + : ITEM_NONE; } return (gSaveContext.buttonStatus[3] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] - : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] - : ITEM_NONE; + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] + : ITEM_NONE; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123810.s") @@ -865,7 +868,7 @@ s32 func_801242DC(PlayState* play) { TextTriggerEntry* triggerEntry; s32 envIndex; - if (play->roomCtx.currRoom.unk2 == 3) { // Room is hot + if (play->roomCtx.curRoom.unk2 == 3) { // Room is hot envIndex = 0; } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->unk_AD8 > 80)) { envIndex = 3; diff --git a/src/code/z_room.c b/src/code/z_room.c index 169d6d5b5..e0c2a035d 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -64,8 +64,8 @@ void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { void Room_Init(PlayState* play, RoomContext* roomCtx) { s32 i; - roomCtx->currRoom.num = -1; - roomCtx->currRoom.segment = NULL; + roomCtx->curRoom.num = -1; + roomCtx->curRoom.segment = NULL; roomCtx->unk78 = 1; roomCtx->unk79 = 0; for (i = 0; i < 3; i++) { @@ -79,9 +79,9 @@ s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { if (roomCtx->unk31 == 0) { s32 size; - roomCtx->prevRoom = roomCtx->currRoom; - roomCtx->currRoom.num = index; - roomCtx->currRoom.segment = NULL; + roomCtx->prevRoom = roomCtx->curRoom; + roomCtx->curRoom.num = index; + roomCtx->curRoom.segment = NULL; roomCtx->unk31 = 1; size = play->roomList[index].vromEnd - play->roomList[index].vromStart; @@ -103,15 +103,15 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { if (roomCtx->unk31 == 1) { if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { roomCtx->unk31 = 0; - roomCtx->currRoom.segment = roomCtx->activeRoomVram; + roomCtx->curRoom.segment = roomCtx->activeRoomVram; // TODO: Segment number enum gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); - Scene_ProcessHeader(play, (SceneCmd*)roomCtx->currRoom.segment); + Scene_ProcessHeader(play, (SceneCmd*)roomCtx->curRoom.segment); func_80123140(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); - if (((play->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && + if (((play->sceneNum != SCENE_IKANA) || (roomCtx->curRoom.num != 1)) && (play->sceneNum != SCENE_IKNINSIDE)) { play->envCtx.lightSettingOverride = 0xFF; play->envCtx.unk_E0 = 0; @@ -142,9 +142,9 @@ void func_8012EBF8(PlayState* play, RoomContext* roomCtx) { roomCtx->prevRoom.segment = NULL; func_800BA798(play, &play->actorCtx); Actor_SpawnTransitionActors(play, &play->actorCtx); - if (roomCtx->currRoom.num > -1) { - Map_InitRoomData(play, roomCtx->currRoom.num); + if (roomCtx->curRoom.num > -1) { + Map_InitRoomData(play, roomCtx->curRoom.num); Minimap_SavePlayerRoomInitInfo(play); } - func_801A3CD8(play->roomCtx.currRoom.echo); + func_801A3CD8(play->roomCtx.curRoom.echo); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index da05eac2b..75616e8a5 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -234,17 +234,17 @@ void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x08: Room Behavior void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) { - play->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1; - play->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; - play->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; + play->roomCtx.curRoom.unk3 = cmd->roomBehavior.gpFlag1; + play->roomCtx.curRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; + play->roomCtx.curRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; - play->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xB) & 1; + play->roomCtx.curRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xB) & 1; play->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xC) & 1; } // SceneTableEntry Header Command 0x0A: Mesh Header void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) { - play->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); + play->roomCtx.curRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List @@ -446,7 +446,7 @@ void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x16: Echo Setting void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) { - play->roomCtx.currRoom.echo = cmd->echoSettings.echo; + play->roomCtx.curRoom.echo = cmd->echoSettings.echo; } // SceneTableEntry Header Command 0x18: Alternate Header List= 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 53a3300d4..8e0c025e2 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 @@ -340,14 +340,14 @@ void func_80A2A1E0(BgDblueMovebg* this, PlayState* play) { Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); this->dyna.actor.shape.rot.y += this->unk_1CC; - if (play->roomCtx.currRoom.num == 0) { + if (play->roomCtx.curRoom.num == 0) { this->opaDList = gGreatBayTempleObjectGearShaftWithPlatformsDL; - } else if (play->roomCtx.currRoom.num == 8) { + } else if (play->roomCtx.curRoom.num == 8) { this->opaDList = NULL; } - if (play->roomCtx.currRoom.num != this->unk_170) { - if (play->roomCtx.currRoom.num != this->unk_171) { + if (play->roomCtx.curRoom.num != this->unk_170) { + if (play->roomCtx.curRoom.num != this->unk_171) { if ((play->roomCtx.prevRoom.num != this->unk_170) && (play->roomCtx.prevRoom.num != this->unk_171)) { D_80A2BBF4.unk_01 = 0; Actor_MarkForDeath(&this->dyna.actor); @@ -628,8 +628,8 @@ void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { s32 pad; s32 temp_v0_3; - if (play->roomCtx.currRoom.num != this->unk_170) { - if (play->roomCtx.currRoom.num != this->unk_171) { + if (play->roomCtx.curRoom.num != this->unk_170) { + if (play->roomCtx.curRoom.num != this->unk_171) { if ((play->roomCtx.prevRoom.num != this->unk_170) && (play->roomCtx.prevRoom.num != this->unk_171)) { D_80A2BBF4.unk_00 = 0; Actor_MarkForDeath(&this->dyna.actor); @@ -669,7 +669,7 @@ void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { this->dyna.actor.shape.rot.x += this->unk_1CC; if (this->unk_160 == 8) { - if (play->roomCtx.currRoom.num == 8) { + if (play->roomCtx.curRoom.num == 8) { func_80A2ABD0(this, play); this->unk_172 |= 0x20; } else { @@ -677,9 +677,9 @@ void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { } } - if (play->roomCtx.currRoom.num == 0) { + if (play->roomCtx.curRoom.num == 0) { this->opaDList = gGreatBayTempleObjectWaterwheelDL; - } else if (play->roomCtx.currRoom.num == 8) { + } else if (play->roomCtx.curRoom.num == 8) { this->opaDList = gGreatBayTempleObjectWaterwheelWithFakeGearDL; } 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 e7d96d205..ca8ad214f 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -155,7 +155,7 @@ void Boss04_Init(Actor* thisx, PlayState* play2) { s16 phi_s0_2; s32 pad; - if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { Actor_MarkForDeath(&this->actor); return; } 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 177c5784d..87b1e52b9 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -915,7 +915,7 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); if ((play->csCtx.state == 0) && ((play->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || - (play->roomCtx.currRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || + (play->roomCtx.curRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; } 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 b5f75efaa..4aa36cfdd 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -553,9 +553,9 @@ void func_808A1884(DoorShutter* this, PlayState* play) { play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)].sides[(sp44.z < 0.0f) ? 0 : 1].room; if (room != this->actor.room) { - Room temp = play->roomCtx.currRoom; + Room temp = play->roomCtx.curRoom; - play->roomCtx.currRoom = play->roomCtx.prevRoom; + play->roomCtx.curRoom = play->roomCtx.prevRoom; play->roomCtx.prevRoom = temp; play->roomCtx.activeMemPage ^= 1; } 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 f43f7c58c..93cd492e6 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -116,7 +116,7 @@ s32 DoorSpiral_SetSpiralType(DoorSpiral* this, PlayState* play) { this->spiralType = doorObjectInfo->spiralType; if ((this->spiralType == SPIRAL_DAMPES_HOUSE) || - ((this->spiralType == SPIRAL_WOODFALL_TEMPLE) && play->roomCtx.currRoom.enablePosLights)) { + ((this->spiralType == SPIRAL_WOODFALL_TEMPLE) && play->roomCtx.curRoom.enablePosLights)) { if (this->spiralType == SPIRAL_WOODFALL_TEMPLE) { this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; } 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 ca3e1a9fd..ba1c846b9 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -598,7 +598,7 @@ void func_808B9F10(DoorWarp1* this, PlayState* play) { if ((this->unk_203 == 0) && func_808B866C(this, play) && !Play_InCsMode(play) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(play); - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); func_800B7298(play, &this->dyna.actor, 9); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; @@ -871,7 +871,7 @@ void func_808BA550(DoorWarp1* this, PlayState* play) { play->envCtx.lightSettings.fogNear = -500.0f * temp_f0; if (play->envCtx.lightSettings.fogNear < -300) { - play->roomCtx.currRoom.segment = NULL; + play->roomCtx.curRoom.segment = NULL; } } } 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 392f9a441..6cc0b2e72 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -339,7 +339,7 @@ void EnBigslime_Init(Actor* thisx, PlayState* play2) { this->gekkoCollider.base.ocFlags1 &= ~OC1_NO_PUSH; this->actor.params = CLAMP(this->actor.params, 1, 4); - if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { Actor_MarkForDeath(&this->actor); if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { @@ -2497,7 +2497,7 @@ void EnBigslime_Despawn(EnBigslime* this, PlayState* play) { } if (!this->isDespawned) { - Flags_SetClearTemp(play, play->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.curRoom.num); this->isDespawned = true; } 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 5d5b01ee8..d4fe409cd 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -301,7 +301,7 @@ void func_80871058(EnBom* this, PlayState* play) { void func_808714D4(EnBom* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actionFunc = func_80871058; - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); 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 2aabec27f..8bd1b7e0e 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -5166,7 +5166,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamAt.y = mainCam->at.y; sSubCamAt.z = mainCam->at.z; D_8090CD4C = 2; - Interface_ChangeAlpha(12); + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); sSubCamVelFactor = 0.0f; // fallthrough case 2: 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 07de01c12..45206159e 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -393,7 +393,7 @@ void EnFsn_EndInteraction(EnFsn* this, PlayState* play) { Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -1157,7 +1157,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item = this->items[this->cursorIndex]; 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 6b0a7e3b9..66f57f323 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -820,7 +820,7 @@ void func_8096326C(EnFu* this, PlayState* play) { void func_809632D0(EnFu* this) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } gSaveContext.save.weekEventReg[8] &= (u8)~1; 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 17bec0df6..a82434c21 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -806,11 +806,11 @@ void func_80B110F8(EnGb2* this, PlayState* play) { void func_80B111AC(EnGb2* this, PlayState* play) { s32 index; - if (play->roomCtx.currRoom.num == 1) { + if (play->roomCtx.curRoom.num == 1) { return; } - switch (play->roomCtx.currRoom.num) { + switch (play->roomCtx.curRoom.num) { case 2: index = 1; break; @@ -837,7 +837,7 @@ void func_80B111AC(EnGb2* this, PlayState* play) { } void func_80B11268(EnGb2* this, PlayState* play) { - if (play->roomCtx.currRoom.num == 1) { + if (play->roomCtx.curRoom.num == 1) { this->unk_290 = 0; this->unk_282[0] = this->actor.cutscene; if (Flags_GetClear(play, 2) && Flags_GetClear(play, 3) && Flags_GetClear(play, 4) && Flags_GetClear(play, 5)) { 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 3faf24a1c..6e36d1130 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -328,8 +328,8 @@ s32 func_8094E054(EnGm* this, PlayState* play, s32 arg2) { s32 func_8094E0F8(EnGm* this, PlayState* play) { s32 ret = false; - if ((this->unk_260 != play->roomCtx.currRoom.num) && (play->roomCtx.unk31 == 0)) { - this->unk_260 = play->roomCtx.currRoom.num; + if ((this->unk_260 != play->roomCtx.curRoom.num) && (play->roomCtx.unk31 == 0)) { + this->unk_260 = play->roomCtx.curRoom.num; this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, play); this->actor.draw = NULL; this->unk_3FC = 1; 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 3579f23cc..7aa060a96 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -138,9 +138,9 @@ void EnHoll_Destroy(Actor* thisx, PlayState* play) { } void EnHoll_ChangeRooms(PlayState* play) { - Room tempRoom = play->roomCtx.currRoom; + Room tempRoom = play->roomCtx.curRoom; - play->roomCtx.currRoom = play->roomCtx.prevRoom; + play->roomCtx.curRoom = play->roomCtx.prevRoom; play->roomCtx.prevRoom = tempRoom; play->roomCtx.activeMemPage ^= 1; } @@ -204,7 +204,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { s32 unclampedAlpha = EN_HOLL_SCALE_ALPHA(playerDistFromCentralPlane); this->alpha = CLAMP(unclampedAlpha, 0, 255); - if (play->roomCtx.currRoom.num != this->actor.room) { + if (play->roomCtx.curRoom.num != this->actor.room) { EnHoll_ChangeRooms(play); } } @@ -239,7 +239,7 @@ void EnHoll_TransparentIdle(EnHoll* this, PlayState* play) { this->actor.room = room; - if ((this->actor.room != play->roomCtx.currRoom.num) && + if ((this->actor.room != play->roomCtx.curRoom.num) && Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; } @@ -264,7 +264,7 @@ void EnHoll_VerticalBgCoverIdle(EnHoll* this, PlayState* play) { this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; - if ((this->actor.room != play->roomCtx.currRoom.num) && + if ((this->actor.room != play->roomCtx.curRoom.num) && Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; this->bgCoverAlphaActive = true; @@ -287,7 +287,7 @@ void EnHoll_VerticalIdle(EnHoll* this, PlayState* play) { s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; - if ((this->actor.room != play->roomCtx.currRoom.num) && + if ((this->actor.room != play->roomCtx.curRoom.num) && Room_StartRoomTransition(play, &play->roomCtx, this->actor.room)) { this->actionFunc = EnHoll_RoomTransitionIdle; } 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 b44d1bb29..26c5bbbbc 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -532,7 +532,7 @@ void func_8095E95C(EnIshi* this, PlayState* play) { s32 sp2C; if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; if (ENISHI_GET_1(&this->actor) == 1) { Flags_SetSwitch(play, ENISHI_GET_FE00(&this->actor)); } 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 dc3ecc56c..a737c5008 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -510,7 +510,7 @@ void EnKusa_LiftedUp(EnKusa* this, PlayState* play) { s32 bgId; if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.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); @@ -683,7 +683,7 @@ void EnKusa_Update(Actor* thisx, PlayState* play2) { } else { this->actor.shape.yOffset = 0.0f; } - if ((kusaGameplayFrames != play->gameplayFrames) && (play->roomCtx.currRoom.unk3 == 0)) { + if ((kusaGameplayFrames != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { EnKusa_Sway(); kusaGameplayFrames = play->gameplayFrames; } @@ -695,7 +695,7 @@ void EnKusa_DrawBush(Actor* thisx, PlayState* play2) { if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { - if ((play->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && + if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); } @@ -724,7 +724,7 @@ void EnKusa_DrawGrass(Actor* thisx, PlayState* play) { if (this->isCut) { Gfx_DrawDListOpa(play, gKusaStump); } else { - if ((play->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((play->roomCtx.curRoom.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]); } 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 435d31972..4ed5b82a0 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -1033,7 +1033,7 @@ void func_80A5D9C8(EnKusa2* this, PlayState* play) { D_80A5EAFC.z = Math_SinS(D_80A5EB04.z) * 1000.0f; if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; this->actor.colChkInfo.mass = 80; this->actor.home.rot.y = this->actor.world.rot.y; this->actor.velocity.y = 12.5f; @@ -1289,7 +1289,7 @@ void func_80A5E604(Actor* thisx, PlayState* play) { } else { this->actor.draw = func_80A5E6F0; - if (play->roomCtx.currRoom.unk3 == 0) { + if (play->roomCtx.curRoom.unk3 == 0) { func_80A5B508(); } func_80A5CAF4(&D_80A5F1C0); @@ -1352,7 +1352,7 @@ void EnKusa2_Draw(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (this->actor.projectedPos.z <= 1200.0f) { - if ((play->roomCtx.currRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && + if ((play->roomCtx.curRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } 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 f71a25621..da72fc308 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -135,7 +135,7 @@ void EnMag_Init(Actor* thisx, PlayState* play) { this->unk11F02 = 30; this->unk11F00 = this->state = MAG_STATE_INITIAL; - if (gSaveContext.unk_3F1E != 0) { + if (gSaveContext.hudVisibilityForceButtonAlphasByStatus) { this->mainTitleAlpha = 210; this->unk11F32 = 255; this->copyrightAlpha = 255; @@ -158,7 +158,7 @@ void EnMag_Init(Actor* thisx, PlayState* play) { this->displayEffectEnvColor[1] = 255; this->displayEffectEnvColor[2] = 155; - gSaveContext.unk_3F1E = 0; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; gSaveContext.transFadeDuration = 1; 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 c24bf7601..8e2c5260b 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -185,7 +185,7 @@ void func_80965DB4(EnMm* this, PlayState* play) { void func_8096611C(EnMm* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { EnMm_SetupAction(this, func_80965DB4); - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); gSaveContext.unk_1014 = 0; 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 ef46c5e81..618a30986 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -302,7 +302,7 @@ void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -985,7 +985,7 @@ void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; EnOssan_SetupAction(this, EnOssan_BuyItemWithFanfare); } 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 2ff9d814e..b1b3d9cbc 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -190,7 +190,7 @@ void EnPametfrog_Init(Actor* thisx, PlayState* play) { GEKKO_LIMB_MAX); Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colElement); this->params = CLAMP(this->actor.params, 1, 4); - if (Flags_GetClear(play, play->roomCtx.currRoom.num)) { + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { Actor_MarkForDeath(&this->actor); if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { @@ -963,7 +963,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, PlayState* play) { this->collider.base.ocFlags1 &= ~OC1_ON; func_800B0DE0(play, &vec1, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 800, 50); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); - Flags_SetClearTemp(play, play->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.curRoom.num); for (i = 0; i < 25; i++) { vel.x = randPlusMinusPoint5Scaled(5.0f); 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 4f17b9880..b69877758 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -442,7 +442,7 @@ void EnSob1_EndInteraction(PlayState* play, EnSob1* this) { Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -933,7 +933,7 @@ void EnSob1_SetupBuyItemWithFanfare(PlayState* play, EnSob1* this) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; EnSob1_SetupAction(this, EnSob1_BuyItemWithFanfare); } 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 54c3f0609..c9151d621 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -96,7 +96,7 @@ void EnTest2_Update(Actor* thisx, PlayState* play) { Actor_SetObjectDependency(play, &this->actor); this->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); } - if (play->roomCtx.currRoom.unk5) { + if (play->roomCtx.curRoom.unk5) { this->actor.update = EnTest2_UpdateForLens; } else { this->actor.update = Actor_Noop; 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 f0f94a494..88547581f 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -507,9 +507,9 @@ void func_80A42F20(EnTest4* this, PlayState* play) { if (sCurrentCs >= 0) { ActorCutscene_Stop(sCurrentCs); } - gSaveContext.unk_3F22 = 0; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; gSaveContext.eventInf[1] &= (u8)~0x80; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } } 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 ed9d2870c..03b10590c 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -762,7 +762,7 @@ void func_80AF2938(EnTest7* this, PlayState* play) { player->stateFlags2 |= 0x20000000; this->unk_144 |= 2; this->unk_148.unk_04 = 30.0f; - if (play->roomCtx.currRoom.unk3 != 1) { + if (play->roomCtx.curRoom.unk3 != 1) { func_80AF082C(this, func_80AF2AE8); } else { func_80AF082C(this, func_80AF2EC8); 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 39a16dea9..71abb140a 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -219,7 +219,7 @@ void EnTrt_EndInteraction(PlayState* play, EnTrt* this) { Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -653,7 +653,7 @@ void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->actionFunc = EnTrt_BuyItemWithFanfare; } 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 43c2dc1e5..926f88f70 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -102,7 +102,7 @@ void func_8089F17C(EnViewer* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 xzDist = fabsf(this->actor.xzDistToPlayer); - if ((((play->roomCtx.currRoom.num == this->actor.room) && (xzDist <= this->unk_148)) && + if ((((play->roomCtx.curRoom.num == this->actor.room) && (xzDist <= this->unk_148)) && (this->actor.playerHeightRel <= this->unk_150)) && (this->actor.world.pos.y <= player->actor.world.pos.y)) { xzDist = this->actor.playerHeightRel / this->unk_150; @@ -117,7 +117,7 @@ void func_8089F218(EnViewer* this, PlayState* play) { f32 xzDist = fabsf(this->actor.xzDistToPlayer); f32 temp; - if ((play->roomCtx.currRoom.num == this->actor.room) && (xzDist <= this->unk_148) && + if ((play->roomCtx.curRoom.num == this->actor.room) && (xzDist <= this->unk_148) && (this->actor.playerHeightRel <= this->unk_150) && (this->actor.world.pos.y <= player->actor.world.pos.y)) { temp = (xzDist - this->unk_14C) / (this->unk_148 - this->unk_14C); func_8089F014(this, play, temp); @@ -135,7 +135,7 @@ void func_8089F2C4(EnViewer* this, PlayState* play) { if (this->unk_14C == 0.0f) { this->unk_14C = 0.1f; } - if ((play->roomCtx.currRoom.num == this->actor.room) && (sp20.x < fabsf(this->unk_148))) { + if ((play->roomCtx.curRoom.num == this->actor.room) && (sp20.x < fabsf(this->unk_148))) { temp = sp20.z / this->unk_14C; func_8089F014(this, play, temp); } else { 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 b699cd9af..79961ad82 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -387,7 +387,7 @@ void func_80A1C5E8(ObjFlowerpot* this, PlayState* play) { } void func_80A1C62C(ObjFlowerpot* this, PlayState* play) { - if (!(this->unk_1EA & 4) && (play->roomCtx.currRoom.num != this->unk_1EC)) { + if (!(this->unk_1EA & 4) && (play->roomCtx.curRoom.num != this->unk_1EC)) { this->unk_1EA |= 4; } } @@ -536,7 +536,7 @@ void func_80A1CC0C(ObjFlowerpot* this, PlayState* play) { func_80A1C62C(this, play); if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; if (fabsf(this->actor.speedXZ) < 0.1f) { func_80A1C818(this); func_800B8E58(GET_PLAYER(play), NA_SE_PL_PUT_DOWN_POT); @@ -653,7 +653,7 @@ void ObjFlowerpot_Update(Actor* thisx, PlayState* play2) { func_80A1C554(this); - if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.currRoom.unk3 == 0)) { + if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { func_80A1B3D0(); D_80A1D830 = play->gameplayFrames; } @@ -678,7 +678,7 @@ void ObjFlowerpot_Draw(Actor* thisx, PlayState* play) { } if (!(this->unk_1EA & 2)) { - if ((play->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A1B840(&D_80A1D838[this->unk_1EB]); 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 3289699b0..384d1cbad 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -420,8 +420,8 @@ void func_80B9D0FC(ObjHunsui* this, PlayState* play) { void func_80B9D120(ObjHunsui* this, PlayState* play) { if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && - (this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && - ((this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num))) { + (this->unk_16C != play->roomCtx.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + ((this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num))) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -525,8 +525,8 @@ void func_80B9D4D0(ObjHunsui* this, PlayState* play) { void func_80B9D508(ObjHunsui* this, PlayState* play) { if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && - (this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && - (this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { + (this->unk_16C != play->roomCtx.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -544,7 +544,7 @@ void func_80B9D508(ObjHunsui* this, PlayState* play) { func_80B9D094(this, play); if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && - (play->roomCtx.currRoom.num == 8)) { + (play->roomCtx.curRoom.num == 8)) { func_80B9D334(this, play); } @@ -572,8 +572,8 @@ void func_80B9D714(ObjHunsui* this, PlayState* play) { s16 cs; f32 sp28; - if ((this->unk_16C != play->roomCtx.currRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && - (this->unk_16D != play->roomCtx.currRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { + if ((this->unk_16C != play->roomCtx.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { Actor_MarkForDeath(&this->dyna.actor); } else { if (Flags_GetSwitch(play, this->unk_168)) { 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 6f98958b1..e2a71db92 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -127,7 +127,7 @@ void func_80926318(ObjKibako* this, PlayState* play) { } void func_80926394(ObjKibako* this, PlayState* play) { - if ((this->isDropCollected == 0) && (play->roomCtx.currRoom.num != this->unk199)) { + if ((this->isDropCollected == 0) && (play->roomCtx.curRoom.num != this->unk199)) { this->isDropCollected = 1; } } @@ -339,7 +339,7 @@ void ObjKibako_Held(ObjKibako* this, PlayState* play) { func_80926394(this, play); if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; if (fabsf(this->actor.speedXZ) < 0.1f) { ObjKibako_SetupIdle(this); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; 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 937a61d79..74fa8fd57 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -296,7 +296,7 @@ void func_80B39908(ObjSnowball2* this, PlayState* play) { } void func_80B39B28(ObjSnowball2* this, PlayState* play) { - if ((this->unk_1AE == 0) && (play->roomCtx.currRoom.num != this->unk_1AF)) { + if ((this->unk_1AE == 0) && (play->roomCtx.curRoom.num != this->unk_1AF)) { this->unk_1AE = 1; } } @@ -416,7 +416,7 @@ void func_80B39FA8(ObjSnowball2* this, PlayState* play) { } if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; this->actor.speedXZ *= 3.8f; this->actor.velocity.y *= 0.4f; this->actor.gravity = -2.8f; 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 acba9ec31..20c172803 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -166,7 +166,7 @@ s32 ObjTsubo_IsSceneNotGohtOrTwinmold(ObjTsubo* this, PlayState* play) { } void func_8092788C(ObjTsubo* this, PlayState* play) { - if (!this->unk_197 && (play->roomCtx.currRoom.num != this->homeRoom)) { + if (!this->unk_197 && (play->roomCtx.curRoom.num != this->homeRoom)) { this->unk_197 = true; } } @@ -527,7 +527,7 @@ void func_80928D80(ObjTsubo* this, PlayState* play) { func_8092788C(this, play); if (Actor_HasNoParent(&this->actor, play)) { - this->actor.room = play->roomCtx.currRoom.num; + this->actor.room = play->roomCtx.curRoom.num; Actor_MoveWithGravity(&this->actor); this->actor.flags &= ~ACTOR_FLAG_4000000; Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 898b1f351..b4cfe295c 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -23,10 +23,10 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; - gSaveContext.unk_3F1E = 0; - gSaveContext.unk_3F20 = 0; - gSaveContext.unk_3F22 = 0; - gSaveContext.unk_3F24 = 0; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibilityTimer = 0; Audio_QueueSeqCmd(NA_BGM_STOP); gSaveContext.save.entrance = entrance; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index 888f715c0..7f57ac7a3 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -584,13 +584,13 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if ((cursorItem != (u32)PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; - gSaveContext.unk_3F22 = 0; - Interface_ChangeAlpha(50); + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; - gSaveContext.unk_3F22 = 0; - Interface_ChangeAlpha(50); + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d741d7408..c5cd94e37 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2100,10 +2100,10 @@ 0x8010EBA0:("func_8010EBA0",), 0x8010EC54:("func_8010EC54",), 0x8010EE74:("func_8010EE74",), - 0x8010EF68:("Interface_ChangeAlpha",), - 0x8010EF9C:("func_8010EF9C",), - 0x8010F0D4:("func_8010F0D4",), - 0x8010F1A8:("func_8010F1A8",), + 0x8010EF68:("Interface_SetHudVisibility",), + 0x8010EF9C:("Interface_UpdateButtonAlphasByStatus",), + 0x8010F0D4:("Interface_UpdateButtonAlphas",), + 0x8010F1A8:("Interface_UpdateHudAlphas",), 0x80110038:("func_80110038",), 0x80111CB4:("func_80111CB4",), 0x801129E4:("func_801129E4",), diff --git a/tools/namefixer.py b/tools/namefixer.py index af17edc3c..3008c0143 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -483,6 +483,7 @@ wordReplace = { "func_80169E6C": "Play_SetupRespawnPoint", "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", + "Interface_ChangeAlpha": "Interface_SetHudVisibility", "func_80112B40": "Interface_LoadItemIconImpl", "func_80112BE4": "Interface_LoadItemIcon", "func_80114978": "Item_CheckObtainability", @@ -644,6 +645,11 @@ wordReplace = { "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", + "gSaveContext.unk_3F1E": "gSaveContext.hudVisibilityForceButtonAlphasByStatus", + "gSaveContext.unk_3F20": "gSaveContext.nextHudVisibility", + "gSaveContext.unk_3F22": "gSaveContext.hudVisibility", + "gSaveContext.unk_3F24": "gSaveContext.hudVisibilityTimer", + "gSaveContext.unk_3F26": "gSaveContext.prevHudVisibility", "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 50a3309c4..6d0e03cd1 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1614,10 +1614,10 @@ asm/non_matchings/code/z_parameter/func_8010EB50.s,func_8010EB50,0x8010EB50,0x14 asm/non_matchings/code/z_parameter/func_8010EBA0.s,func_8010EBA0,0x8010EBA0,0x2D asm/non_matchings/code/z_parameter/func_8010EC54.s,func_8010EC54,0x8010EC54,0x88 asm/non_matchings/code/z_parameter/func_8010EE74.s,func_8010EE74,0x8010EE74,0x3D -asm/non_matchings/code/z_parameter/Interface_ChangeAlpha.s,Interface_ChangeAlpha,0x8010EF68,0xD -asm/non_matchings/code/z_parameter/func_8010EF9C.s,func_8010EF9C,0x8010EF9C,0x4E -asm/non_matchings/code/z_parameter/func_8010F0D4.s,func_8010F0D4,0x8010F0D4,0x35 -asm/non_matchings/code/z_parameter/func_8010F1A8.s,func_8010F1A8,0x8010F1A8,0x3A4 +asm/non_matchings/code/z_parameter/Interface_SetHudVisibility.s,Interface_SetHudVisibility,0x8010EF68,0xD +asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphasByStatus.s,Interface_UpdateButtonAlphasByStatus,0x8010EF9C,0x4E +asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphas.s,Interface_UpdateButtonAlphas,0x8010F0D4,0x35 +asm/non_matchings/code/z_parameter/Interface_UpdateHudAlphas.s,Interface_UpdateHudAlphas,0x8010F1A8,0x3A4 asm/non_matchings/code/z_parameter/func_80110038.s,func_80110038,0x80110038,0x71F asm/non_matchings/code/z_parameter/func_80111CB4.s,func_80111CB4,0x80111CB4,0x34C asm/non_matchings/code/z_parameter/func_801129E4.s,func_801129E4,0x801129E4,0x44 From cc52da995246bea3810c96ecd2deaba7851691c1 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Wed, 28 Sep 2022 22:47:38 -0300 Subject: [PATCH 49/73] ovl_Obj_Swprize OK (#1021) * ovl_Obj_Swprize OK * Co-authored-by: mzxrules mzxrules@users.noreply.github.com * pr review * pr review * pr review --- spec | 3 +- .../actors/ovl_Obj_Swprize/z_obj_swprize.c | 118 +++++++++++++++--- .../actors/ovl_Obj_Swprize/z_obj_swprize.h | 5 +- tools/disasm/functions.txt | 4 +- 4 files changed, 109 insertions(+), 21 deletions(-) diff --git a/spec b/spec index 8cfc30556..813e821ce 100644 --- a/spec +++ b/spec @@ -5097,8 +5097,7 @@ beginseg name "ovl_Obj_Swprize" compress include "build/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.o" - include "build/data/ovl_Obj_Swprize/ovl_Obj_Swprize.data.o" - include "build/data/ovl_Obj_Swprize/ovl_Obj_Swprize.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Swprize/ovl_Obj_Swprize_reloc.o" endseg beginseg 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 4472c4fc3..6a50a018f 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -14,12 +14,15 @@ void ObjSwprize_Init(Actor* thisx, PlayState* play); void ObjSwprize_Destroy(Actor* thisx, PlayState* play); void ObjSwprize_Update(Actor* thisx, PlayState* play); +void ObjSwprize_DoNothing(ObjSwprize* this, PlayState* play); void func_80C25654(ObjSwprize* this, PlayState* play); +void func_80C25640(ObjSwprize* this); +void func_80C25698(ObjSwprize* this); void func_80C256AC(ObjSwprize* this, PlayState* play); +void func_80C25710(ObjSwprize* this); void func_80C2572C(ObjSwprize* this, PlayState* play); -void func_80C25794(ObjSwprize* this, PlayState* play); +void ObjSwprize_SetupDoNothing(ObjSwprize* this); -#if 0 const ActorInit Obj_Swprize_InitVars = { ACTOR_OBJ_SWPRIZE, ACTORCAT_PROP, @@ -32,30 +35,113 @@ const ActorInit Obj_Swprize_InitVars = { (ActorFunc)NULL, }; -#endif +s16 D_80C257F0[] = { 2, 0x14, 1, 8 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25360.s") +s16 D_80C257F8[] = { -0x888, 0, 0x888 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C253D0.s") +void func_80C25360(ObjSwprize* this, Vec3f* vec) { + 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, vec); + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Init.s") +void func_80C253D0(ObjSwprize* this, PlayState* play) { + Actor* thisx = &this->actor; + s32 i; + Actor* collectible; + Vec3f sp78; + s32 type = OBJ_SWPRIZE_GET_TYPE(thisx); + s32 temp_s0 = D_80C257F0[type]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Destroy.s") + func_80C25360(this, &sp78); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25640.s") + if (type == 2) { + for (i = 0; i < 3; i++) { + collectible = Item_DropCollectible(play, &thisx->world.pos, temp_s0); + if (collectible != NULL) { + if (sp78.y < 0.98f) { + collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; + collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->world.rot.y = Math_FAtan2F(sp78.z, sp78.x) + D_80C257F8[i]; + } else { + collectible->world.rot.y = i * (0x10000 / 3); + } + } + } + } else { + collectible = Item_DropCollectible(play, &thisx->world.pos, temp_s0); + if ((collectible != NULL) && (sp78.y < 0.98f)) { + collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; + collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->world.rot.y = Math_FAtan2F(sp78.z, sp78.x); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25654.s") +void ObjSwprize_Init(Actor* thisx, PlayState* play) { + ObjSwprize* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25698.s") + if (Flags_GetSwitch(play, OBJ_SWPRIZE_GET_SWITCH_FLAG(&this->actor))) { + ObjSwprize_SetupDoNothing(this); + } else { + func_80C25640(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C256AC.s") +void ObjSwprize_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25710.s") +void func_80C25640(ObjSwprize* this) { + this->actionFunc = func_80C25654; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C2572C.s") +void func_80C25654(ObjSwprize* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJ_SWPRIZE_GET_SWITCH_FLAG(&this->actor))) { + func_80C25698(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25780.s") +void func_80C25698(ObjSwprize* this) { + this->actionFunc = func_80C256AC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25794.s") +void func_80C256AC(ObjSwprize* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C253D0(this, play); + func_80C25710(this); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Update.s") +void func_80C25710(ObjSwprize* this) { + this->timer = 40; + this->actionFunc = func_80C2572C; +} + +void func_80C2572C(ObjSwprize* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + if (this->timer == 0) { + ActorCutscene_Stop(this->actor.cutscene); + ObjSwprize_SetupDoNothing(this); + } + } +} + +void ObjSwprize_SetupDoNothing(ObjSwprize* this) { + this->actionFunc = ObjSwprize_DoNothing; +} + +void ObjSwprize_DoNothing(ObjSwprize* this, PlayState* play) { +} + +void ObjSwprize_Update(Actor* thisx, PlayState* play) { + ObjSwprize* this = THIS; + + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h index 29654f992..5b7cd2e09 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h @@ -3,6 +3,9 @@ #include "global.h" +#define OBJ_SWPRIZE_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) +#define OBJ_SWPRIZE_GET_TYPE(thisx) (((thisx)->params >> 8) & 3) + struct ObjSwprize; typedef void (*ObjSwprizeActionFunc)(struct ObjSwprize*, PlayState*); @@ -10,7 +13,7 @@ typedef void (*ObjSwprizeActionFunc)(struct ObjSwprize*, PlayState*); typedef struct ObjSwprize { /* 0x000 */ Actor actor; /* 0x144 */ ObjSwprizeActionFunc actionFunc; - /* 0x148 */ char unk_148[0x4]; + /* 0x148 */ s16 timer; } ObjSwprize; // size = 0x14C extern const ActorInit Obj_Swprize_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c5cd94e37..aa494f594 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -17125,8 +17125,8 @@ 0x80C256AC:("func_80C256AC",), 0x80C25710:("func_80C25710",), 0x80C2572C:("func_80C2572C",), - 0x80C25780:("func_80C25780",), - 0x80C25794:("func_80C25794",), + 0x80C25780:("ObjSwprize_SetupDoNothing",), + 0x80C25794:("ObjSwprize_DoNothing",), 0x80C257A4:("ObjSwprize_Update",), 0x80C258A0:("func_80C258A0",), 0x80C2590C:("func_80C2590C",), From 084bafcfccd6acdf2e0a48a4b298b9a9091cab04 Mon Sep 17 00:00:00 2001 From: StickyThwomp <89738536+StickyThwomp@users.noreply.github.com> Date: Wed, 28 Sep 2022 21:57:00 -0500 Subject: [PATCH 50/73] ovl_En_Nimotsu OK and documented (#1028) * Done-ish, looking for feedback. * Finished decompile and rename of ovl_En_Nimotsu (Bomb shop bag) * Revert unk->pad rename, leaving as unknown. * Swap the reloc include to the src version * Style/type updates from review comments * Changes from review: - Remove extra whitespace - Remove unnecessary include - Hex->Dec for alpha value. * Changes from review, Texture name and comment formatting * More changes from review, whitespace and dustTimer->timer rename. --- assets/xml/objects/object_boj.xml | 6 +- spec | 3 +- .../actors/ovl_En_Nimotsu/z_en_nimotsu.c | 96 ++++++++++++++++--- .../actors/ovl_En_Nimotsu/z_en_nimotsu.h | 5 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 2 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 4 - 7 files changed, 93 insertions(+), 25 deletions(-) diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index cfb10e97a..20c661bb5 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -87,8 +87,8 @@ - - - + + + diff --git a/spec b/spec index 813e821ce..c894dabef 100644 --- a/spec +++ b/spec @@ -4567,8 +4567,7 @@ beginseg name "ovl_En_Nimotsu" compress include "build/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.o" - include "build/data/ovl_En_Nimotsu/ovl_En_Nimotsu.data.o" - include "build/data/ovl_En_Nimotsu/ovl_En_Nimotsu.reloc.o" + include "build/src/overlays/actors/ovl_En_Nimotsu/ovl_En_Nimotsu_reloc.o" endseg beginseg 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 966f3671b..11872a0a1 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -5,6 +5,7 @@ */ #include "z_en_nimotsu.h" +#include "assets/objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,8 @@ void EnNimotsu_Destroy(Actor* thisx, PlayState* play); void EnNimotsu_Update(Actor* thisx, PlayState* play); void EnNimotsu_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnNimotsu_UpdateCollision(EnNimotsu* this, PlayState* play); + const ActorInit En_Nimotsu_InitVars = { ACTOR_EN_NIMOTSU, ACTORCAT_PROP, @@ -28,25 +30,93 @@ const ActorInit En_Nimotsu_InitVars = { (ActorFunc)EnNimotsu_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE1FB0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 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_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnNimotsu_UpdateCollision(EnNimotsu* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -extern ColliderCylinderInit D_80BE1FB0; +void EnNimotsu_Init(Actor* thisx, PlayState* play) { + EnNimotsu* this = THIS; -extern UNK_TYPE D_06013380; + Collider_InitCylinder(play, &this->collider); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/func_80BE1C80.s") + this->timer = 10; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Init.s") + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Destroy.s") +void EnNimotsu_Destroy(Actor* thisx, PlayState* play) { + EnNimotsu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Update.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Draw.s") +void EnNimotsu_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnNimotsu* this = THIS; + Vec3f dustPosition; + + Actor_MoveWithGravity(&this->actor); + + if (!(this->dustDone & 1) && (this->actor.bgCheckFlags & 1)) { + if (DECR(this->timer) == 0) { + this->dustDone |= 1; + } + + if ((play->state.frames % 3) == 0) { + dustPosition.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + dustPosition.y = this->actor.world.pos.y; + dustPosition.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(play, &this->actor, &dustPosition, 20.0f, 0, 2.0f, 0, 0, 0); + } + } + + EnNimotsu_UpdateCollision(this, play); +} + +void EnNimotsu_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnNimotsu* this = THIS; + Vec3f position; + Vec3f scale; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gBombShopBagDL); + func_8012C2DC(play->state.gfxCtx); + + position.x = this->actor.world.pos.x + 7.0f; + position.y = this->actor.world.pos.y; + position.z = this->actor.world.pos.z + 2.0f; + + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; + + func_800BC620(&position, &scale, 255, play); + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h index 634697736..e839c9393 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h @@ -7,7 +7,10 @@ struct EnNimotsu; typedef struct EnNimotsu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x98]; + /* 0x144 */ UNK_TYPE1 unk_144[0x48]; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u16 dustDone; + /* 0x1DA */ s16 timer; } EnNimotsu; // size = 0x1DC extern const ActorInit En_Nimotsu_InitVars; 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 10cdec079..fbacce266 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1542,7 +1542,7 @@ void EnSuttari_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* } else { func_8012C28C(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_013380); + gSPDisplayList(POLY_OPA_DISP++, gBombShopBagDL); CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index aa494f594..a83588b66 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16061,7 +16061,7 @@ 0x80BE16B4:("EnTab_PostLimbDraw",), 0x80BE1704:("EnTab_TransformLimbDraw",), 0x80BE1810:("EnTab_Draw",), - 0x80BE1C80:("func_80BE1C80",), + 0x80BE1C80:("EnNimotsu_UpdateCollision",), 0x80BE1CEC:("EnNimotsu_Init",), 0x80BE1D5C:("EnNimotsu_Destroy",), 0x80BE1D88:("EnNimotsu_Update",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 658dd5f05..aae06790f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1223,10 +1223,6 @@ D_06008C40 = 0x06008C40; D_060001E4 = 0x060001E4; D_06001EE8 = 0x06001EE8; -// ovl_En_Nimotsu - -D_06013380 = 0x06013380; - // ovl_En_Nwc D_060000E8 = 0x060000E8; From 8f2fe9b3c703418e6b4a3a420b9a026f1ef94210 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 29 Sep 2022 08:57:44 -0400 Subject: [PATCH 51/73] `z_parameter`: Timers (#1031) * import timers from parameter branch * more cleanup * small namechange * improved docs * more cleanup * one more namechange * another small cleanup... * fix destroy * plurals * revert graphic function names * PR suggestions, better docs * revert namechange, better postman timer name * oops * fix merge * fix merge * fix bss * PR Suggestions --- include/functions.h | 27 +- include/regs.h | 2 + include/variables.h | 26 +- include/z64player.h | 10 +- include/z64save.h | 81 +- src/boot_O2_g3/idle.c | 1 - src/code/code_8012EC80.c | 2 +- src/code/z_bgcheck.c | 1 + src/code/z_game_over.c | 6 +- src/code/z_map_exp.c | 4 +- src/code/z_parameter.c | 730 +++++++++++++++++- src/code/z_player_lib.c | 25 +- src/code/z_sram_NES.c | 44 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 16 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 14 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 25 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 10 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- .../z_en_horse_game_check.c | 14 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 1 - .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 8 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 1 - src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 22 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 35 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.h | 5 + .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 16 +- .../z_en_syateki_dekunuts.c | 3 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 44 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 4 +- .../ovl_Obj_Roomtimer/z_obj_roomtimer.c | 10 +- src/overlays/gamestates/ovl_select/z_select.c | 14 +- tools/disasm/functions.txt | 24 +- tools/disasm/variables.txt | 28 +- tools/namefixer.py | 13 + tools/sizes/code_functions.csv | 24 +- 37 files changed, 1016 insertions(+), 282 deletions(-) diff --git a/include/functions.h b/include/functions.h index f04ab1981..8396d4a41 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1651,7 +1651,7 @@ s16 func_80105318(void); void func_8010549C(PlayState* play, void* segmentAddress); void func_8010565C(PlayState* play, u8 num, void* segmentAddress); void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); -void func_80105A40(void); +void func_80105A40(PlayState* play); void func_80105B34(PlayState* play); void func_80105C40(s16 arg0); // void func_80105FE0(void); @@ -1728,7 +1728,7 @@ s32 func_8010A0A4(PlayState* play); // void func_8010A2AC(PlayState* play); void Minimap_SavePlayerRoomInitInfo(PlayState* play); void Map_InitRoomData(PlayState* play, s16 room); -// void Map_Destroy(void); +void Map_Destroy(PlayState* play); // void Map_Init(PlayState* play); // void Minimap_Draw(PlayState* play); // void Map_Update(PlayState* play); @@ -1811,17 +1811,13 @@ Gfx* func_8010CD98(Gfx* displayListHead, void* texture, s16 textureWidth, s16 te // void func_8010CFBC(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); // void func_8010D2D4(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11); // void func_8010D480(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16); -// void func_8010D7D0(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); +Gfx* func_8010D7D0(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); // void func_8010D9F4(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, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); Gfx* func_8010DC58(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, u16 i); // void func_8010DE38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // void func_8010E028(void); -// void func_8010E968(void); -void func_8010E9F0(s16 arg0, s16 arg1); -void func_8010EA9C(s32 arg0, s32 arg1); -// void func_8010EB50(void); -// void func_8010EBA0(void); -// void func_8010EC54(void); +void Interface_StartTimer(s16 timerId, s16 seconds); +void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState); void func_8010EE74(PlayState* play, s32 day); void Interface_SetHudVisibility(u16 hudVisibility); // void func_80110038(void); @@ -1870,17 +1866,14 @@ void func_8011B4E0(PlayState* play, s32 arg1); // void func_8011B9E0(void); // void func_8011BF70(void); // void func_8011C4C4(void); -void func_8011C808(PlayState* play); -// void func_8011C898(void); -// void func_8011CA64(void); -// void func_8011E3B4(void); +void Interface_StartMoonCrash(PlayState* play); // void func_8011E730(void); // void func_8011F0E0(UNK_TYPE4 ctxt); // void func_80120F90(void); // void func_80121000(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_TYPE1 param_8, UNK_TYPE1 param_9, UNK_TYPE1 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14); // void func_80121064(void); // void func_801210E0(void); -// void func_80121F94(void); +void Interface_Destroy(PlayState* play); void func_80121FC4(PlayState* play); Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); @@ -1947,7 +1940,7 @@ s32 Player_ActionToExplosive(Player* player, s32 actionParam); s32 Player_GetExplosiveHeld(Player* player); s32 func_80124278(Actor* actor, s32 arg1); s32 func_801242B4(Player* player); -s32 func_801242DC(PlayState* play); +s32 Player_GetEnvTimerType(PlayState* play); void func_80124420(Player* player); void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2); void func_801246F4(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor); @@ -2703,8 +2696,8 @@ void Main(void* arg); u32 Padmgr_GetControllerBitmask(void); void func_80174F24(void (*arg0)(void*), void* arg1); void func_80174F44(void (*arg0)(void*), void* arg1); -// void func_80174F7C(void); -// void func_80174F9C(void); +void func_80174F7C(void (*arg0)(s32), void* arg1); +void func_80174F9C(void (*arg0)(s32), void* arg1); // OSMesgQueue* Padmgr_GetEventCallback(void); // void func_80175008(void); void Padmgr_SetEventCallback(OSMesg pvParm1); diff --git a/include/regs.h b/include/regs.h index aa3ba523b..cf15b236a 100644 --- a/include/regs.h +++ b/include/regs.h @@ -71,6 +71,8 @@ #define R_A_ICON_X XREG(20) #define R_A_BTN_COLOR(i) XREG(22 + i) #define R_MAGIC_CONSUME_TIMER_GIANTS_MASK XREG(41) +#define R_MOON_CRASH_TIMER_Y XREG(80) +#define R_MOON_CRASH_TIMER_X XREG(81) #define R_MINIMAP_DISABLED XREG(95) #define R_B_LABEL_DD WREG(0) #define R_OW_MINIMAP_X WREG(29) diff --git a/include/variables.h b/include/variables.h index 05602af8f..1ee739c4a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1031,21 +1031,21 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE2 sMagicMeterOutlinePrimBlue; // extern UNK_TYPE2 sMagicBorderRatio; // extern UNK_TYPE2 sMagicBorderStep; -// extern UNK_TYPE2 D_801BF8DC; -// extern UNK_TYPE2 D_801BF8E0; -// extern UNK_TYPE2 D_801BF8E4; -// extern UNK_TYPE4 D_801BF8E8; -// extern UNK_TYPE4 D_801BF8F0; +// extern UNK_TYPE2 sEnvTimerType; +// extern UNK_TYPE2 sEnvTimerActive; +// extern UNK_TYPE2 sPostmanBunnyHoodState; +// extern UNK_TYPE4 sTimerPausedOsTime; +// extern UNK_TYPE4 sBottleTimerPausedOsTime; // extern UNK_TYPE4 D_801BF8F4; // extern UNK_TYPE4 D_801BF8F8; // extern UNK_TYPE4 D_801BF8FC; // extern UNK_TYPE4 D_801BF930; // extern UNK_TYPE4 D_801BF934; -// extern UNK_TYPE1 D_801BF968; +// extern UNK_TYPE1 sIsTimerPaused; // extern UNK_TYPE1 D_801BF96A; -// extern UNK_TYPE1 D_801BF96C; +// extern UNK_TYPE1 sIsBottleTimerPaused; // extern UNK_TYPE1 D_801BF96E; -// extern UNK_TYPE2 D_801BF970; +// extern UNK_TYPE2 sTimerId; // extern UNK_TYPE1 D_801BF972; // extern UNK_TYPE2 D_801BF974; // extern UNK_TYPE2 D_801BF978; @@ -1083,7 +1083,7 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE2 D_801BFA4C; // extern UNK_TYPE2 D_801BFA64; // extern UNK_TYPE2 D_801BFA74; -// extern UNK_TYPE4 D_801BFA84; +// extern UNK_TYPE4 sPostmanTimerInputBtnAPressed; // extern UNK_TYPE1 D_801BFAB0; // extern UNK_TYPE1 D_801BFAB8; // extern UNK_TYPE1 D_801BFAC4; @@ -1135,15 +1135,15 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE2 D_801BFCA8; // extern UNK_TYPE1 D_801BFCB8; // extern UNK_TYPE4 D_801BFCC4; -// extern UNK_TYPE2 D_801BFCE4; -// extern UNK_TYPE2 D_801BFCE8; +// extern UNK_TYPE2 sTimerStateTimer; +// extern UNK_TYPE2 sTimerDigits; // extern UNK_TYPE2 D_801BFCEA; // extern UNK_TYPE2 D_801BFCEC; // extern UNK_TYPE2 D_801BFCEE; // extern UNK_TYPE2 D_801BFCF0; // extern UNK_TYPE2 D_801BFCF2; // extern UNK_TYPE2 D_801BFCF4; -// extern UNK_TYPE2 D_801BFCF8; +// extern UNK_TYPE2 sTimerBeepSfxSeconds; // extern UNK_TYPE2 D_801BFCFC; // extern UNK_TYPE2 D_801BFD0C; // extern UNK_TYPE1 D_801BFD1C; @@ -3151,7 +3151,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F57B4; // extern UNK_TYPE1 D_801F5834; // extern NmiBuff* gNMIBuffer; -// extern UNK_TYPE1 D_801F5850; +// extern UNK_TYPE1 sPostmanTimerInput; // extern UNK_TYPE1 D_801F58B0; // extern UNK_TYPE1 D_801F59AC; // extern UNK_TYPE1 D_801F59B0; diff --git a/include/z64player.h b/include/z64player.h index f49f30688..2f101b558 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -70,6 +70,14 @@ typedef enum { /* 0x19 */ PLAYER_MASK_MAX } PlayerMask; +typedef enum { + /* 0 */ PLAYER_ENV_TIMER_NONE, + /* 1 */ PLAYER_ENV_TIMER_HOTROOM, + /* 2 */ PLAYER_ENV_TIMER_UNDERWATER_FLOOR, + /* 3 */ PLAYER_ENV_TIMER_SWIMMING, + /* 4 */ PLAYER_ENV_TIMER_UNDERWATER_FREE +} PlayerEnvTimerType; + typedef enum PlayerActionParam { /* -1 */ PLAYER_AP_MINUS1 = -1, /* 0x00 */ PLAYER_AP_NONE, @@ -594,7 +602,7 @@ typedef struct Player { /* 0xAD0 */ f32 linearVelocity; /* 0xAD4 */ s16 currentYaw; /* 0xAD6 */ s16 targetYaw; - /* 0xAD8 */ u16 unk_AD8; + /* 0xAD8 */ u16 underwaterTimer; /* 0xADA */ s8 meleeWeaponAnimation; /* 0xADB */ s8 meleeWeaponState; /* 0xADC */ s8 unk_ADC; diff --git a/include/z64save.h b/include/z64save.h index 57801684f..fc24aa5b6 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -2,6 +2,7 @@ #define Z64SAVE_H #include "ultra64.h" +#include "z64item.h" #include "z64math.h" #include "os.h" @@ -54,6 +55,56 @@ typedef enum { #define MAGIC_NORMAL_METER 0x30 #define MAGIC_DOUBLE_METER (2 * MAGIC_NORMAL_METER) +#define SECONDS_TO_TIMER(seconds) ((seconds) * 100) + +#define OSTIME_TO_TIMER(osTime) ((osTime) * 64 / 3000 / 10000) +#define OSTIME_TO_TIMER_ALT(osTime) ((osTime) / 10000 * 64 / 3000) + +// 1 centisecond = 10 milliseconds = 1/100 seconds +#define SECONDS_TO_TIMER_PRECISE(seconds, centiSeconds) ((seconds) * 100 + (centiSeconds)) + +typedef enum { + /* 0 */ TIMER_ID_POSTMAN, // postman's counting minigame + /* 1 */ TIMER_ID_MINIGAME_1, // minigame timer + /* 2 */ TIMER_ID_2, + /* 3 */ TIMER_ID_MOON_CRASH, // timer used for mooncrash on the clocktower roof + /* 4 */ TIMER_ID_MINIGAME_2, // minigame timer + /* 5 */ TIMER_ID_ENV, // environmental timer (underwater or hot room) + /* 6 */ TIMER_ID_GORON_RACE_UNUSED, + /* 7 */ TIMER_ID_MAX, + /* 99 */ TIMER_ID_NONE = 99, +} TimerId; + +typedef enum { + /* 0 */ TIMER_COUNT_DOWN, + /* 1 */ TIMER_COUNT_UP +} TimerDirection; + +typedef enum { + /* 0 */ TIMER_STATE_OFF, + /* 1 */ TIMER_STATE_START, + /* 2 */ TIMER_STATE_HOLD_TIMER, // Hold timer frozen at the screen center + /* 3 */ TIMER_STATE_MOVING_TIMER, // Move timer to a target location + /* 4 */ TIMER_STATE_COUNTING, + /* 5 */ TIMER_STATE_STOP, + /* 6 */ TIMER_STATE_6, // like `TIMER_STATE_STOP` but with extra minigame checks + /* 7 */ TIMER_STATE_7, // stopped but still update `timerCurTimes` + /* 8 */ TIMER_STATE_ENV_START, + /* 9 */ TIMER_STATE_ALT_START, + /* 10 */ TIMER_STATE_10, // precursor to `TIMER_STATE_ALT_COUNTING` + /* 11 */ TIMER_STATE_ALT_COUNTING, + /* 12 */ TIMER_STATE_12, // Updated paused time? + /* 13 */ TIMER_STATE_POSTMAN_START, + /* 14 */ TIMER_STATE_POSTMAN_COUNTING, + /* 15 */ TIMER_STATE_POSTMAN_STOP, + /* 16 */ TIMER_STATE_POSTMAN_END +} TimerState; + +typedef enum { + /* 0 */ BOTTLE_TIMER_STATE_OFF, + /* 1 */ BOTTLE_TIMER_STATE_COUNTING +} BottleTimerState; + typedef enum { /* 0 */ HUD_VISIBILITY_IDLE, /* 1 */ HUD_VISIBILITY_NONE, @@ -242,11 +293,11 @@ typedef struct SaveContext { /* 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 + /* 0x101A */ u8 bottleTimerStates[BOTTLE_MAX]; // See the `BottleTimerState` enum. "bottle_status" + /* 0x1020 */ OSTime bottleTimerStartOsTimes[BOTTLE_MAX]; // The osTime when the timer starts. "bottle_ostime" + /* 0x1050 */ u64 bottleTimerTimeLimits[BOTTLE_MAX]; // The original total time given before the timer expires, in centiseconds (1/100th sec). "bottle_sub" + /* 0x1080 */ u64 bottleTimerCurTimes[BOTTLE_MAX]; // The remaining time left before the timer expires, in centiseconds (1/100th sec). "bottle_time" + /* 0x10B0 */ OSTime bottleTimerPausedOsTimes[BOTTLE_MAX]; // The cumulative osTime spent with the timer paused. "bottle_stop_time" /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo /* 0x3CA0 */ s32 fileNum; // "file_no" /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" @@ -265,16 +316,16 @@ typedef struct SaveContext { /* 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" + /* 0x3DC8 */ OSTime postmanTimerStopOsTime; // The osTime when the timer stops for the postman minigame. "get_time" + /* 0x3DD0 */ u8 timerStates[TIMER_ID_MAX]; // See the `TimerState` enum. "event_fg" + /* 0x3DD7 */ u8 timerDirections[TIMER_ID_MAX]; // See the `TimerDirection` enum. "calc_flag" + /* 0x3DE0 */ u64 timerCurTimes[TIMER_ID_MAX]; // For countdown, the remaining time left. For countup, the time since the start. In centiseconds (1/100th sec). "event_ostime" + /* 0x3E18 */ u64 timerTimeLimits[TIMER_ID_MAX]; // The original total time given for the timer to count from, in centiseconds (1/100th sec). "event_sub" + /* 0x3E50 */ OSTime timerStartOsTimes[TIMER_ID_MAX]; // The osTime when the timer starts. "func_time" + /* 0x3E88 */ u64 timerStopTimes[TIMER_ID_MAX]; // The total amount of time taken between the start and end of the timer, in centiseconds (1/100th sec). "func_end_time" + /* 0x3EC0 */ OSTime timerPausedOsTimes[TIMER_ID_MAX]; // The cumulative osTime spent with the timer paused. "func_stop_time" + /* 0x3EF8 */ s16 timerX[TIMER_ID_MAX]; // "event_xp" + /* 0x3F06 */ s16 timerY[TIMER_ID_MAX]; // "event_yp" /* 0x3F14 */ s16 unk_3F14; // "character_change" /* 0x3F16 */ u8 seqIndex; // "old_bgm" /* 0x3F17 */ u8 nightSeqIndex; // "old_env" 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/code_8012EC80.c b/src/code/code_8012EC80.c index ee2070610..a29a8279e 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -688,7 +688,7 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.timerCurTimes[timerId]; for (i = 0; i < 8; i++) { gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 1b8dbfb2e..f9b23ac79 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" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 394a10600..9fc3dee25 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -18,14 +18,14 @@ static s16 sGameOverTimer = 0; void GameOver_Update(PlayState* play) { GameOverContext* gameOverCtx = &play->gameOverCtx; - s16 i; + s16 timerId; switch (gameOverCtx->state) { case GAMEOVER_DEATH_START: func_801477B4(play); - for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { - gSaveContext.unk_3DD0[i] = 0; + for (timerId = 0; timerId < TIMER_ID_MAX; timerId++) { + gSaveContext.timerStates[timerId] = TIMER_STATE_OFF; } gSaveContext.eventInf[1] &= ~1; diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 40ffb4213..ffad44e6e 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -169,8 +169,8 @@ void Map_InitRoomData(PlayState* play, s16 room) { } } -void Map_Destroy(void) { - func_80105A40(); +void Map_Destroy(PlayState* play) { + func_80105A40(play); } void Map_Init(PlayState* play) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 679b8abf4..ef108c43a 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,8 +1,11 @@ #include "global.h" + #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" #include "misc/story_static/story_static.h" + #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" +#include "overlays/actors/ovl_En_Mm3/z_en_mm3.h" typedef struct { /* 0x00 */ u8 scene; @@ -11,7 +14,7 @@ typedef struct { /* 0x03 */ u8 flags3; } RestrictionFlags; -Input D_801F5850[4]; +Input sPostmanTimerInput[4]; RestrictionFlags sRestrictionFlags[] = { { SCENE_20SICHITAI2, 0x00, 0x00, 0x00 }, @@ -167,23 +170,21 @@ s16 sExtraItemBases[] = { ITEM_NUT, // ITEM_NUT_UPGRADE_30 }; -s16 D_801BF8DC = 0; -s16 D_801BF8E0 = 0; -s16 D_801BF8E4 = 0; - -OSTime D_801BF8E8 = 0; -OSTime D_801BF8F0 = 0; +s16 sEnvTimerType = PLAYER_ENV_TIMER_NONE; +s16 sEnvTimerActive = false; +s16 sPostmanBunnyHoodState = POSTMAN_MINIGAME_BUNNY_HOOD_OFF; +OSTime sTimerPausedOsTime = 0; +OSTime sBottleTimerPausedOsTime = 0; OSTime D_801BF8F8[] = { 0, 0, 0, 0, 0, 0, 0, }; OSTime D_801BF930[] = { 0, 0, 0, 0, 0, 0, 0, }; +u8 sIsTimerPaused = false; +u8 sIsBottleTimerPaused = false; +s16 sTimerId = TIMER_ID_NONE; -u8 D_801BF968 = false; -u8 D_801BF96C = false; - -s16 D_801BF970 = 99; s16 D_801BF974 = 0; s16 D_801BF978 = 10; s16 D_801BF97C = 255; @@ -264,20 +265,112 @@ s16 D_801BFA74[] = { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E028.s") -s32 D_801BFA84 = 0; +s32 sPostmanTimerInputBtnAPressed = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E968.s") +void Interface_PostmanTimerCallback(s32 arg0) { + s32 btnAPressed; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E9F0.s") + func_80175E68(&sPostmanTimerInput[0], 0); + btnAPressed = CHECK_BTN_ALL(sPostmanTimerInput[0].cur.button, BTN_A); + if ((btnAPressed != sPostmanTimerInputBtnAPressed) && btnAPressed) { + gSaveContext.postmanTimerStopOsTime = osGetTime(); + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_STOP; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EA9C.s") + sPostmanTimerInputBtnAPressed = btnAPressed; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EB50.s") +void Interface_StartTimer(s16 timerId, s16 seconds) { + gSaveContext.timerX[timerId] = 115; + gSaveContext.timerY[timerId] = 80; -void func_8010EBA0(s16 timer, s16 timerId); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EBA0.s") + sEnvTimerActive = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EC54.s") + gSaveContext.timerCurTimes[timerId] = SECONDS_TO_TIMER(seconds); + gSaveContext.timerTimeLimits[timerId] = gSaveContext.timerCurTimes[timerId]; + + if (gSaveContext.timerCurTimes[timerId] != SECONDS_TO_TIMER(0)) { + gSaveContext.timerDirections[timerId] = TIMER_COUNT_DOWN; + } else { + gSaveContext.timerDirections[timerId] = TIMER_COUNT_UP; + } + + gSaveContext.timerStates[timerId] = TIMER_STATE_START; +} + +void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) { + gSaveContext.timerX[TIMER_ID_POSTMAN] = 115; + gSaveContext.timerY[TIMER_ID_POSTMAN] = 80; + + sPostmanBunnyHoodState = bunnyHoodState; + + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(seconds); + gSaveContext.timerTimeLimits[TIMER_ID_POSTMAN] = gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]; + + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] != SECONDS_TO_TIMER(0)) { + gSaveContext.timerDirections[TIMER_ID_POSTMAN] = TIMER_COUNT_DOWN; + } else { + gSaveContext.timerDirections[TIMER_ID_POSTMAN] = TIMER_COUNT_UP; + } + + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_START; + gSaveContext.timerStopTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN] = 0; +} + +// Unused, goron race actually uses TIMER_ID_MINIGAME_2 +void Interface_StartGoronRaceTimer(s32 arg0) { + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + // Goron race started + if (gSaveContext.eventInf[1] & 1) { + gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(2, 39); + } else { + gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(0, 1); + } + } +} + +void Interface_StartBottleTimer(s16 seconds, s16 timerId) { + gSaveContext.bottleTimerStates[timerId] = BOTTLE_TIMER_STATE_COUNTING; + gSaveContext.bottleTimerCurTimes[timerId] = SECONDS_TO_TIMER(seconds); + gSaveContext.bottleTimerTimeLimits[timerId] = gSaveContext.bottleTimerCurTimes[timerId]; + gSaveContext.bottleTimerStartOsTimes[timerId] = osGetTime(); + gSaveContext.bottleTimerPausedOsTimes[timerId] = 0; + sBottleTimerPausedOsTime = 0; +} + +u32 Interface_GetCompressedTimerDigits(s16 timerId) { + u64 time; + s16 timerArr[6]; + + time = gSaveContext.timerCurTimes[timerId]; + + // 6 minutes + timerArr[0] = time / SECONDS_TO_TIMER(360); + time -= timerArr[0] * SECONDS_TO_TIMER(360); + + // minutes + timerArr[1] = time / SECONDS_TO_TIMER(60); + time -= timerArr[1] * SECONDS_TO_TIMER(60); + + // 10 seconds + timerArr[2] = time / SECONDS_TO_TIMER(10); + time -= timerArr[2] * SECONDS_TO_TIMER(10); + + // seconds + timerArr[3] = time / SECONDS_TO_TIMER(1); + time -= timerArr[3] * SECONDS_TO_TIMER(1); + + // 100 milliseconds + timerArr[4] = time / SECONDS_TO_TIMER_PRECISE(0, 10); + time -= timerArr[4] * SECONDS_TO_TIMER_PRECISE(0, 10); + + // 10 milliseconds + timerArr[5] = time; + + return (timerArr[0] << 0x14) | (timerArr[1] << 0x10) | (timerArr[2] << 0xC) | (timerArr[3] << 8) | + (timerArr[4] << 4) | timerArr[5]; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EE74.s") @@ -1440,7 +1533,7 @@ u8 Item_Give(PlayState* play, u8 item) { for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { if (gSaveContext.save.inventory.items[slot + i] == ITEM_BOTTLE) { if (item == ITEM_HOT_SPRING_WATER) { - func_8010EBA0(60, i); + Interface_StartBottleTimer(60, i); } if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { @@ -1754,7 +1847,7 @@ void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn) { gSaveContext.buttonStatus[btn] = BTN_ENABLED; if (item == ITEM_HOT_SPRING_WATER) { - func_8010EBA0(60, GET_CUR_FORM_BTN_SLOT(btn) - SLOT_BOTTLE_1); + Interface_StartBottleTimer(60, GET_CUR_FORM_BTN_SLOT(btn) - SLOT_BOTTLE_1); } } @@ -2220,7 +2313,8 @@ void Magic_Update(PlayState* play) { !Play_InCsMode(play)) { if ((gSaveContext.save.playerData.magic == 0) || - ((func_801242DC(play) >= 2) && (func_801242DC(play) <= 4)) || + ((Player_GetEnvTimerType(play) >= PLAYER_ENV_TIMER_UNDERWATER_FLOOR) && + (Player_GetEnvTimerType(play) <= PLAYER_ENV_TIMER_UNDERWATER_FREE)) || ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) != ITEM_LENS) && (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) != ITEM_LENS) && (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) != ITEM_LENS)) || @@ -2512,25 +2606,582 @@ TexturePtr D_801BFCC4[] = { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C4C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C808.s") +void Interface_StartMoonCrash(PlayState* play) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + Audio_QueueSeqCmd(0xE0000100); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C898.s") + gSaveContext.save.day = 4; + gSaveContext.save.daysElapsed = 4; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 10; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 12); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; +} -s16 D_801BFCE4 = 0; -s16 D_801BFCE8[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -s16 D_801BFCF8 = 99; -s16 D_801BFCFC[] = { - // timer digit width - 16, 25, 34, 42, 51, 60, 68, 77, -}; -s16 D_801BFD0C[] = { - // digit width - 9, 9, 8, 9, 9, 8, 9, 9, -}; +void Interface_GetTimerDigits(u64 timer, s16* timerArr) { + u64 time = timer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011CA64.s") + // 6 minutes + timerArr[0] = time / SECONDS_TO_TIMER(360); + time -= timerArr[0] * SECONDS_TO_TIMER(360); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E3B4.s") + // minutes + timerArr[1] = time / SECONDS_TO_TIMER(60); + time -= timerArr[1] * SECONDS_TO_TIMER(60); + + // 10 seconds + timerArr[3] = time / SECONDS_TO_TIMER(10); + time -= timerArr[3] * SECONDS_TO_TIMER(10); + + // seconds + timerArr[4] = time / SECONDS_TO_TIMER(1); + time -= timerArr[4] * SECONDS_TO_TIMER(1); + + // 100 milliseconds + timerArr[6] = time / SECONDS_TO_TIMER_PRECISE(0, 10); + time -= timerArr[6] * SECONDS_TO_TIMER_PRECISE(0, 10); + + // 10 milliseconds + timerArr[7] = time; +} + +#define IS_POSTMAN_TIMER_DRAWN \ + (((sTimerId == TIMER_ID_POSTMAN) && \ + (gSaveContext.timerStates[TIMER_ID_POSTMAN] == TIMER_STATE_POSTMAN_COUNTING) && \ + (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_OFF) && \ + (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] < SECONDS_TO_TIMER(3))) || \ + (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_ON)) + +/** + * Update and draw the timers + */ +void Interface_DrawTimers(PlayState* play) { + static s16 sTimerStateTimer = 0; + static s16 sTimerDigits[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + static s16 sTimerBeepSfxSeconds = 99; + static s16 sTimerDigitsOffsetX[] = { + 16, 25, 34, 42, 51, 60, 68, 77, + }; + static s16 sTimerDigitsWidth[] = { + 9, 9, 8, 9, 9, 8, 9, 9, + }; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); + OSTime osTime; + OSTime timerOsTime; + s16 j; + s16 i; + + OPEN_DISPS(play->state.gfxCtx); + + // Not satisfying any of these conditions will pause the timer + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + ((msgCtx->msgMode == 0) || + ((msgCtx->msgMode != 0) && (msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && + !(player->stateFlags1 & PLAYER_STATE1_200) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { + + // Account for osTime when the timer is paused + if (sIsTimerPaused) { + osTime = osGetTime(); + + for (j = 0; j < TIMER_ID_MAX; j++) { + if (gSaveContext.timerStates[j] == TIMER_STATE_COUNTING) { + gSaveContext.timerPausedOsTimes[j] = + gSaveContext.timerPausedOsTimes[j] + (osTime - sTimerPausedOsTime); + } + } + sIsTimerPaused = false; + } + + sTimerId = TIMER_ID_NONE; + + // Update all timer states + for (i = 0; i < TIMER_ID_MAX; i++) { + if (gSaveContext.timerStates[i] == TIMER_STATE_OFF) { + continue; + } + + sTimerId = i; + + // Process the timer for the postman counting minigame + if (sTimerId == TIMER_ID_POSTMAN) { + switch (gSaveContext.timerStates[TIMER_ID_POSTMAN]) { + case TIMER_STATE_POSTMAN_START: + if (gSaveContext.timerDirections[TIMER_ID_POSTMAN] != TIMER_COUNT_DOWN) { + gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN] = osGetTime(); + } + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_COUNTING; + sPostmanTimerInputBtnAPressed = true; + func_80174F7C(Interface_PostmanTimerCallback, NULL); + break; + + case TIMER_STATE_POSTMAN_STOP: + timerOsTime = gSaveContext.postmanTimerStopOsTime; + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = + OSTIME_TO_TIMER(timerOsTime - ((void)0, gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN]) - + ((void)0, gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN])); + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_END; + func_80174F9C(Interface_PostmanTimerCallback, NULL); + break; + + case TIMER_STATE_POSTMAN_COUNTING: + case TIMER_STATE_POSTMAN_END: + break; + } + break; + } + + // process the remaining timers + switch (gSaveContext.timerStates[sTimerId]) { + case TIMER_STATE_START: + case TIMER_STATE_ALT_START: + sTimerStateTimer = 20; + if (interfaceCtx->unk_280 != 0) { + + // Set the timer position + gSaveContext.timerX[sTimerId] = 26; + + if (interfaceCtx->magicAlpha != 255) { + gSaveContext.timerY[sTimerId] = 22; + } else if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + gSaveContext.timerY[sTimerId] = 54; + } else { + gSaveContext.timerY[sTimerId] = 46; + } + + if ((interfaceCtx->unk_280 == 8) || (interfaceCtx->unk_280 == 30)) { + if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_START) { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + } else { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_ALT_COUNTING; + D_801BF8F8[sTimerId] = osGetTime(); + D_801BF930[sTimerId] = 0; + } + + gSaveContext.timerStartOsTimes[sTimerId] = osGetTime(); + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[sTimerId] = 0; + } + } else { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_HOLD_TIMER; + } + break; + + case TIMER_STATE_HOLD_TIMER: + sTimerStateTimer--; + if (sTimerStateTimer == 0) { + sTimerStateTimer = 20; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_MOVING_TIMER; + } + break; + + case TIMER_STATE_MOVING_TIMER: + // Move the timer from the center of the screen to the timer location where it will count. + if (sTimerId == TIMER_ID_MOON_CRASH) { + j = ((((void)0, gSaveContext.timerX[sTimerId]) - R_MOON_CRASH_TIMER_X) / sTimerStateTimer); + gSaveContext.timerX[sTimerId] = ((void)0, gSaveContext.timerX[sTimerId]) - j; + j = ((((void)0, gSaveContext.timerY[sTimerId]) - R_MOON_CRASH_TIMER_Y) / sTimerStateTimer); + gSaveContext.timerY[sTimerId] = ((void)0, gSaveContext.timerY[sTimerId]) - j; + } else { + j = ((((void)0, gSaveContext.timerX[sTimerId]) - 26) / sTimerStateTimer); + gSaveContext.timerX[sTimerId] = ((void)0, gSaveContext.timerX[sTimerId]) - j; + + j = (gSaveContext.save.playerData.healthCapacity > 0xA0) + ? ((((void)0, gSaveContext.timerY[sTimerId]) - 54) / sTimerStateTimer) + : ((((void)0, gSaveContext.timerY[sTimerId]) - 46) / sTimerStateTimer); + gSaveContext.timerY[sTimerId] = ((void)0, gSaveContext.timerY[sTimerId]) - j; + } + + sTimerStateTimer--; + if (sTimerStateTimer == 0) { + sTimerStateTimer = 20; + + if (sTimerId == TIMER_ID_MOON_CRASH) { + gSaveContext.timerY[sTimerId] = R_MOON_CRASH_TIMER_Y; + } else { + gSaveContext.timerX[sTimerId] = 26; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + gSaveContext.timerY[sTimerId] = 54; + } else { + gSaveContext.timerY[sTimerId] = 46; + } + } + + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + gSaveContext.timerStartOsTimes[sTimerId] = osGetTime(); + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[sTimerId] = 0; + } + // fallthrough + case TIMER_STATE_COUNTING: + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) && + (sTimerId == TIMER_ID_MOON_CRASH)) { + gSaveContext.timerX[TIMER_ID_MOON_CRASH] = R_MOON_CRASH_TIMER_X; + gSaveContext.timerY[TIMER_ID_MOON_CRASH] = R_MOON_CRASH_TIMER_Y; + } + break; + + case TIMER_STATE_10: + D_801BF8F8[sTimerId] = osGetTime(); + D_801BF930[sTimerId] = 0; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_ALT_COUNTING; + // fallthrough + case TIMER_STATE_ALT_COUNTING: + D_801BF930[sTimerId] = osGetTime() - D_801BF8F8[sTimerId]; + break; + + case TIMER_STATE_12: + osTime = osGetTime(); + + gSaveContext.timerPausedOsTimes[sTimerId] = + gSaveContext.timerPausedOsTimes[sTimerId] + osTime - D_801BF8F8[sTimerId]; + D_801BF930[sTimerId] = 0; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + break; + + case TIMER_STATE_ENV_START: + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(gSaveContext.save.playerData.health >> 1); + gSaveContext.timerDirections[sTimerId] = TIMER_COUNT_DOWN; + gSaveContext.timerTimeLimits[sTimerId] = gSaveContext.timerCurTimes[sTimerId]; + sTimerStateTimer = 20; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_MOVING_TIMER; + break; + + case TIMER_STATE_STOP: + osTime = osGetTime(); + + gSaveContext.timerStopTimes[sTimerId] = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId])); + + gSaveContext.timerStates[sTimerId] = TIMER_STATE_OFF; + + if (sTimerId == TIMER_ID_MOON_CRASH) { + gSaveContext.save.day = 4; + if ((play->sceneNum == SCENE_OKUJOU) && (gSaveContext.sceneSetupIndex == 3)) { + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); + gSaveContext.nextCutsceneIndex = 0xFFF0; + play->transitionTrigger = TRANS_TRIGGER_START; + } else { + Interface_StartMoonCrash(play); + } + } else if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + gSaveContext.timerX[TIMER_ID_GORON_RACE_UNUSED] = 115; + gSaveContext.timerY[TIMER_ID_GORON_RACE_UNUSED] = 80; + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] <= TIMER_STATE_10) { + gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] = TIMER_STATE_MOVING_TIMER; + } + } + break; + + case TIMER_STATE_6: + osTime = osGetTime(); + + gSaveContext.timerStopTimes[sTimerId] = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId])); + + if ((gSaveContext.minigameState == 1) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120)) { + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(120); + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); + } + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES) && + (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120))) { + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); + } + gSaveContext.timerStates[sTimerId] = TIMER_STATE_7; + + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + gSaveContext.timerX[TIMER_ID_GORON_RACE_UNUSED] = 115; + gSaveContext.timerY[TIMER_ID_GORON_RACE_UNUSED] = 80; + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] <= TIMER_STATE_10) { + gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] = TIMER_STATE_MOVING_TIMER; + } + gSaveContext.timerStates[sTimerId] = TIMER_STATE_OFF; + } + break; + } + break; + } + + // Update timer counting + if ((sTimerId != TIMER_ID_NONE) && gSaveContext.timerStates[sTimerId]) { // != TIMER_STATE_OFF + if (gSaveContext.timerDirections[sTimerId] == TIMER_COUNT_DOWN) { + sTimerDigits[0] = sTimerDigits[1] = sTimerDigits[3] = sTimerDigits[4] = sTimerDigits[6] = 0; + + // Used to index the counter colon + sTimerDigits[2] = sTimerDigits[5] = 10; + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_10) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_ALT_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { + osTime = osGetTime(); + + osTime = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerPausedOsTimes[sTimerId]) - + D_801BF930[sTimerId] - ((void)0, gSaveContext.timerStartOsTimes[sTimerId])); + } else if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_7) { + osTime = gSaveContext.timerStopTimes[sTimerId]; + } else { + osTime = 0; + } + + // Check how much unpaused time has passed + if (osTime == 0) { + // No unpaused time has passed since the start of the timer. + gSaveContext.timerCurTimes[sTimerId] = gSaveContext.timerTimeLimits[sTimerId] - osTime; + } else if (osTime <= gSaveContext.timerTimeLimits[sTimerId]) { + // Time has passed, but the time limit has not been exceeded + if (osTime >= gSaveContext.timerTimeLimits[sTimerId]) { + // The time is exactly at the time limit. No time remaining. + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(0); + } else { + // Update the time remaining + gSaveContext.timerCurTimes[sTimerId] = gSaveContext.timerTimeLimits[sTimerId] - osTime; + } + } else { + // Time has passed, and the time limit has been exceeded. + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[sTimerId] = TIMER_STATE_STOP; + if (sEnvTimerActive) { + gSaveContext.save.playerData.health = 0; + play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 2)); + } + sEnvTimerActive = false; + } + + Interface_GetTimerDigits(((void)0, gSaveContext.timerCurTimes[sTimerId]), sTimerDigits); + + // Use seconds to determine when to beep + if (gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(60)) { + if ((sTimerBeepSfxSeconds != sTimerDigits[4]) && (sTimerDigits[4] == 1)) { + play_sound(NA_SE_SY_MESSAGE_WOMAN); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if (gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(10)) { + if ((sTimerBeepSfxSeconds != sTimerDigits[4]) && ((sTimerDigits[4] % 2) != 0)) { + play_sound(NA_SE_SY_WARNING_COUNT_N); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if (sTimerBeepSfxSeconds != sTimerDigits[4]) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else { // TIMER_COUNT_UP + sTimerDigits[0] = sTimerDigits[1] = sTimerDigits[3] = sTimerDigits[4] = sTimerDigits[6] = 0; + + // Used to index the counter colon + sTimerDigits[2] = sTimerDigits[5] = 10; + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { + osTime = osGetTime(); + osTime = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId]) - D_801BF930[sTimerId]); + } else if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_7) { + osTime = gSaveContext.timerStopTimes[sTimerId]; + } else if (sTimerId == TIMER_ID_POSTMAN) { + osTime = gSaveContext.timerCurTimes[sTimerId]; + } else { + osTime = SECONDS_TO_TIMER(0); + } + + if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (osTime >= SECONDS_TO_TIMER(120)) { + osTime = SECONDS_TO_TIMER(120); + } + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES) && + (osTime >= SECONDS_TO_TIMER(120))) { + osTime = SECONDS_TO_TIMER(120); + } + + // Update the time remaining with the total amount of time since the start of the timer, + gSaveContext.timerCurTimes[sTimerId] = osTime; + + Interface_GetTimerDigits(osTime, sTimerDigits); + + // Use seconds to determine when to beep + if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if ((gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(110)) && + (sTimerBeepSfxSeconds != sTimerDigits[4])) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES)) { + if ((((void)0, gSaveContext.timerCurTimes[sTimerId]) > + (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) && + (sTimerBeepSfxSeconds != sTimerDigits[4])) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } + } + + // Draw timer + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); + OVERLAY_DISP = + func_8010CD98(OVERLAY_DISP, gTimerClockIconTex, 0x10, 0x10, ((void)0, gSaveContext.timerX[sTimerId]), + ((void)0, gSaveContext.timerY[sTimerId]) + 2, 0x10, 0x10, 1 << 10, 1 << 10); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, + 0, PRIMITIVE, 0); + + if (IS_POSTMAN_TIMER_DRAWN || (gSaveContext.timerStates[sTimerId] <= TIMER_STATE_12)) { + // Set the timer color + if (gSaveContext.timerStates[sTimerId]) { // != TIMER_STATE_OFF + if (sTimerId == TIMER_ID_2) { + if ((gSaveContext.timerCurTimes[sTimerId] == SECONDS_TO_TIMER(0)) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if ((gSaveContext.minigameState == 1) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (gSaveContext.timerCurTimes[sTimerId] >= SECONDS_TO_TIMER(110)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES)) { + if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= + (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - + SECONDS_TO_TIMER(9))) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if ((gSaveContext.timerCurTimes[sTimerId] < SECONDS_TO_TIMER(10)) && + (gSaveContext.timerDirections[sTimerId] == TIMER_COUNT_DOWN) && + (gSaveContext.timerStates[sTimerId] != TIMER_STATE_ALT_COUNTING)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } + + // Draw the timer + if (sTimerId == TIMER_ID_POSTMAN) { + if (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_ON) { + // draw sTimerDigits[3] (10s of seconds) to sTimerDigits[6] (100s of milliseconds) + for (j = 0; j < 4; j++) { + OVERLAY_DISP = func_8010D7D0( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } else { + // draw sTimerDigits[3] (10s of seconds) to sTimerDigits[7] (10s of milliseconds) + for (j = 0; j < 5; j++) { + OVERLAY_DISP = func_8010D7D0( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } + } else { + // draw sTimerDigits[3] (6s of minutes) to sTimerDigits[7] (10s of milliseconds) + for (j = 0; j < 8; j++) { + OVERLAY_DISP = func_8010D7D0( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } + } + } + + } else if (!sIsTimerPaused) { + sTimerPausedOsTime = osGetTime(); + sIsTimerPaused = true; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_UpdateBottleTimers(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + s16 i; + s16 j; + u64 osTime; + s32 pad[2]; + + // Not satisfying any of these conditions will pause the bottle timer + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + ((msgCtx->msgMode == 0) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || + ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) { + + // Account for osTime when the timer is paused + if (sIsBottleTimerPaused) { + osTime = osGetTime(); + + for (j = BOTTLE_FIRST; j < BOTTLE_MAX; j++) { + if (gSaveContext.bottleTimerStates[j] == BOTTLE_TIMER_STATE_COUNTING) { + gSaveContext.bottleTimerPausedOsTimes[j] += osTime - sBottleTimerPausedOsTime; + } + } + + sIsBottleTimerPaused = false; + } + + sTimerId = TIMER_ID_NONE; + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.bottleTimerStates[i] == BOTTLE_TIMER_STATE_COUNTING) { + osTime = osGetTime(); + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + osTime = OSTIME_TO_TIMER_ALT(osTime - ((void)0, gSaveContext.bottleTimerPausedOsTimes[i]) - + ((void)0, gSaveContext.bottleTimerStartOsTimes[i])); + + if (osTime == 0) { + // No unpaused time has passed since the start of the timer. + gSaveContext.bottleTimerCurTimes[i] = gSaveContext.bottleTimerTimeLimits[i] - osTime; + } else if (osTime <= gSaveContext.bottleTimerTimeLimits[i]) { + // Time has passed, but the time limit has not been exceeded + if (osTime >= gSaveContext.bottleTimerTimeLimits[i]) { + // The time is exactly at the time limit. No time remaining. + gSaveContext.bottleTimerCurTimes[i] = SECONDS_TO_TIMER(0); + } else { + // Update the time remaining + gSaveContext.bottleTimerCurTimes[i] = gSaveContext.bottleTimerTimeLimits[i] - osTime; + } + } else { + // Time has passed, and the time limit has been exceeded. + gSaveContext.bottleTimerCurTimes[i] = SECONDS_TO_TIMER(0); + + if (gSaveContext.save.inventory.items[i + SLOT_BOTTLE_1] == ITEM_HOT_SPRING_WATER) { + Inventory_UpdateItem(play, i + SLOT_BOTTLE_1, ITEM_SPRING_WATER); + Message_StartTextbox(play, 0xFA, NULL); + } + gSaveContext.bottleTimerStates[i] = BOTTLE_TIMER_STATE_OFF; + } + } + } + } else if (!sIsBottleTimerPaused) { + sBottleTimerPausedOsTime = osGetTime(); + sIsBottleTimerPaused = true; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E730.s") @@ -2589,6 +3240,9 @@ s16 D_801BFD9C = 0; #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121F94.s") +void Interface_Destroy(PlayState* play) { + Map_Destroy(play); + func_80174F9C(Interface_PostmanTimerCallback, NULL); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121FC4.s") diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index c8d1c802f..3da84fe78 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -860,39 +860,40 @@ s32 func_80124278(Actor* actor, s32 actionParam) { } s32 func_801242B4(Player* player) { - return (player->stateFlags1 & PLAYER_STATE1_8000000) && player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER; + return (player->stateFlags1 & PLAYER_STATE1_8000000) && (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER); } -s32 func_801242DC(PlayState* play) { +s32 Player_GetEnvTimerType(PlayState* play) { Player* player = GET_PLAYER(play); TextTriggerEntry* triggerEntry; - s32 envIndex; + s32 envTimerType; if (play->roomCtx.curRoom.unk2 == 3) { // Room is hot - envIndex = 0; - } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->unk_AD8 > 80)) { - envIndex = 3; + envTimerType = PLAYER_ENV_TIMER_HOTROOM - 1; + } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->underwaterTimer > 80)) { + envTimerType = PLAYER_ENV_TIMER_UNDERWATER_FREE - 1; } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { if ((player->transformation == PLAYER_FORM_ZORA) && (player->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && (player->actor.bgCheckFlags & 1)) { - envIndex = 1; + envTimerType = PLAYER_ENV_TIMER_UNDERWATER_FLOOR - 1; } else { - envIndex = 2; + envTimerType = PLAYER_ENV_TIMER_SWIMMING - 1; } } else { - return 0; + return PLAYER_ENV_TIMER_NONE; } // Trigger general textboxes under certain conditions, like "It's so hot in here!". Unused in MM - triggerEntry = &sEnvironmentTextTriggers[envIndex]; + triggerEntry = &sEnvironmentTextTriggers[envTimerType]; if (!Player_InCsMode(play)) { - if ((triggerEntry->flag) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && (envIndex == 0)) { + if ((triggerEntry->flag) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && + (envTimerType == (PLAYER_ENV_TIMER_HOTROOM - 1))) { Message_StartTextbox(play, triggerEntry->textId, NULL); gSaveContext.textTriggerFlags |= triggerEntry->flag; } } - return envIndex + 1; + return envTimerType + 1; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124420.s") diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index ed7945ec3..5d018a995 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -219,13 +219,13 @@ void Sram_ActivateOwl(u8 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.horseBackBalloonHighScore = SECONDS_TO_TIMER(60); SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(39); SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(10); - gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds - gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds - gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds + gSaveContext.save.dekuPlaygroundHighScores[0] = SECONDS_TO_TIMER(75); + gSaveContext.save.dekuPlaygroundHighScores[1] = SECONDS_TO_TIMER(75); + gSaveContext.save.dekuPlaygroundHighScores[2] = SECONDS_TO_TIMER(76); } /** @@ -646,7 +646,7 @@ Inventory sSaveDefaultInventory = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dungeonKeys { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, - // defenceHearts + // defenseHearts 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, @@ -792,7 +792,7 @@ Inventory sSaveDebugInventory = { { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, // dungeonKeys { 8, 8, 8, 8, 8, 8, 8, 8, 8 }, - // defenceHearts + // defenseHearts 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, @@ -894,13 +894,13 @@ void func_80144A94(SramContext* sramCtx) { 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; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } D_801BDAA0 = 1; @@ -969,13 +969,13 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { 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; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } if (gSaveContext.save.isFirstCycle) { @@ -1598,7 +1598,7 @@ void func_80147068(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; } } @@ -1635,7 +1635,7 @@ void func_80147198(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); gSaveContext.save.isOwlSave = false; 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 120c9ea49..f149a97d6 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1045,11 +1045,11 @@ void DmStk_Init(Actor* thisx, PlayState* play) { if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_ROOFTOP, 0)) { if (gSaveContext.sceneSetupIndex == 0) { - if (gSaveContext.unk_3DD0[3] == 0) { + if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // Starts a 5 minute (300 second) timer until the moon falls. - func_8010E9F0(3, 300); - XREG(80) = 200; - XREG(81) = 115; + Interface_StartTimer(TIMER_ID_MOON_CRASH, 300); + R_MOON_CRASH_TIMER_Y = 200; + R_MOON_CRASH_TIMER_X = 115; } if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { @@ -1062,12 +1062,12 @@ void DmStk_Init(Actor* thisx, PlayState* play) { } else if (gSaveContext.sceneSetupIndex == 3) { this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; - if (gSaveContext.unk_3DD0[3] == 0) { + if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // 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; + Interface_StartTimer(TIMER_ID_MOON_CRASH, 60); + R_MOON_CRASH_TIMER_Y = 200; + R_MOON_CRASH_TIMER_X = 115; } this->actor.world.pos.y = 120.0f; 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 dcc6312bc..4834256d6 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -402,7 +402,7 @@ void EnAz_Destroy(Actor* thisx, PlayState* play2) { EnAz* this = THIS; if (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) { - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } Collider_DestroyCylinder(play2, &this->collider); } @@ -1486,11 +1486,11 @@ void func_80A97D5C(EnAz* this, PlayState* play) { gSaveContext.minigameScore = (this->unk_374 & 2) ? 25 : 20; play->interfaceCtx.unk_280 = 1; if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { - func_8010E9F0(4, 120); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); } else if (gSaveContext.save.weekEventReg[25] & 1) { - func_8010E9F0(4, 100); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 100); } else { - func_8010E9F0(4, 110); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 110); } this->actionFunc = func_80A97E48; } @@ -1547,7 +1547,7 @@ void func_80A97F9C(EnAz* this, PlayState* play) { } else { gSaveContext.save.weekEventReg[24] |= 1; } - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_374 &= ~0x10; play->nextEntrance = Entrance_CreateFromSpawn(2); gSaveContext.nextCutsceneIndex = 0; @@ -1557,8 +1557,8 @@ void func_80A97F9C(EnAz* this, PlayState* play) { this->actor.speedXZ = 0.0f; func_80A979DC(this, play); } else { - if (gSaveContext.unk_3DE0[4] == 0) { - gSaveContext.unk_3DD0[4] = 5; + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_374 |= 0x4000; func_80A97A28(this, play); } 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 cb33ce422..9b421dfd4 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -220,7 +220,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); thisx->room = -1; - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_3B0 |= 1; this->actionFunc = func_80A72438; @@ -821,7 +821,7 @@ void func_80A73244(EnDno* this, PlayState* play) { this->unk_328 = 2; this->actor.speedXZ = 0.0f; Flags_UnsetSwitch(play, ENDNO_GET_3F80(&this->actor)); - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->unk_44E = 0; this->actionFunc = func_80A732C8; } 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 66f57f323..1704451ec 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -401,7 +401,8 @@ void func_80962340(EnFu* this, PlayState* play) { Message_StartTextbox(play, 0x287E, &this->actor); this->unk_552 = 0x287E; } - } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { + } else if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) && + (this->unk_552 != 0x2888)) { Message_StartTextbox(play, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { @@ -644,7 +645,7 @@ void func_80962A10(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; - func_8010E9F0(4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); } else { @@ -681,7 +682,7 @@ void func_80962BCC(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; player->stateFlags3 |= 0x400000; - func_8010E9F0(4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); @@ -712,7 +713,7 @@ void func_80962D60(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; player->stateFlags3 |= 0x400000; - func_8010E9F0(4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); @@ -760,11 +761,11 @@ void func_80962F4C(EnFu* this, PlayState* play) { break; } - if (gSaveContext.unk_3DE0[4] < 2000) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(20)) { s16 val = D_80964B00[this->unk_542] + 200; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); - } else if (gSaveContext.unk_3DE0[4] < 4000) { + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(40)) { s16 val = D_80964B00[this->unk_542] + 100; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); @@ -776,12 +777,12 @@ void func_80962F4C(EnFu* this, PlayState* play) { if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && (player->actor.bgCheckFlags & 1)) || - (gSaveContext.unk_3DE0[4] < 1) || (this->unk_548 == this->unk_54C)) { + (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] <= SECONDS_TO_TIMER(0)) || (this->unk_548 == this->unk_54C)) { player->stateFlags3 &= ~0x400000; func_80961E88(play); player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { - if (gSaveContext.unk_3DE0[4] == 0) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { Message_StartTextbox(play, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { @@ -789,15 +790,15 @@ void func_80962F4C(EnFu* this, PlayState* play) { this->unk_552 = 0x2888; } func_801A2C20(); - gSaveContext.unk_3DE0[4] = 0; - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_548 = 0; func_809632D0(this); } else { this->unk_548 = 0; func_801A2C20(); - gSaveContext.unk_3DE0[4] = 0; - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(play, 1); this->unk_54A = 3; 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 a82434c21..45d6661eb 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -459,7 +459,7 @@ void func_80B10240(EnGb2* this, PlayState* play) { D_80B119B0[this->unk_280].unk_04.y, D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, this->unk_27E); if (this->unk_280 == 0) { - func_8010E9F0(1, 180); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 180); } this->actionFunc = func_80B10344; } else { @@ -487,7 +487,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { if (this->unk_26C & 0x200) { if (this->unk_280 == 3) { this->unk_26C &= ~0x200; - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; func_800FE498(); gSaveContext.eventInf[4] |= 0x40; func_80B0FE7C(play); @@ -506,7 +506,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { } if (gSaveContext.save.playerData.health < 49) { - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x20; @@ -519,8 +519,8 @@ void func_80B10344(EnGb2* this, PlayState* play) { } func_80B0FE7C(play); - } else if (gSaveContext.unk_3DE0[1] == 0) { - gSaveContext.unk_3DD0[1] = 5; + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x10; 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 4c74a779c..9f3f424d5 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -645,7 +645,7 @@ void func_80B51760(EnGk* this, PlayState* play) { this->unk_1E4 |= 2; } } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && - (gSaveContext.save.entrance != 0xD010)) { + (gSaveContext.save.entrance != ENTRANCE(GORON_RACETRACK, 1))) { func_800B863C(&this->actor, play); } 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 1d2d0352c..99d4eca14 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 @@ -121,7 +121,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { return false; } - func_8010E9F0(4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); play->interfaceCtx.unk_280 = 1; this->horse1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, 0x7FFF, 0, @@ -145,7 +145,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { } s32 func_808F8E94(EnHorseGameCheck* this, PlayState* play) { - gSaveContext.unk_3DD0[4] = 0; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; return true; } @@ -247,11 +247,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { return true; } - if (gSaveContext.unk_3DE0[4] >= 0x4650) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(180)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_4); this->unk_174 = 60; } @@ -284,7 +284,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -317,7 +317,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -346,7 +346,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_2); this->unk_174 = 60; } 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 c351f83c6..2ac167235 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -4,7 +4,6 @@ * 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_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 8957cfc21..f88e7c074 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 @@ -155,7 +155,7 @@ void func_80C13BB8(EnJgameTsn* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->actor.flags & ACTOR_FLAG_10000) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.unk_3DE0[4] > 0) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] > SECONDS_TO_TIMER(0)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; @@ -287,7 +287,7 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) { play->interfaceCtx.unk_280 = 1; func_80112AFC(play); gSaveContext.save.weekEventReg[90] |= 0x20; - func_8010E9F0(4, 0x78); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); this->actionFunc = func_80C1418C; } @@ -352,7 +352,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { func_80C14030(this); } - if (gSaveContext.unk_3DE0[4] == 0) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { Message_StartTextbox(play, 0x10A1, &this->actor); this->unk_300 = 0x10A1; player->stateFlags1 |= 0x20; @@ -479,7 +479,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { case 0x10A1: func_801477B4(play); gSaveContext.minigameState = 3; - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; gSaveContext.save.weekEventReg[90] &= (u8)~0x20; func_80C144E4(this); break; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index a737c5008..9d0c41295 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,7 +4,6 @@ * 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_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index a10b26514..47f0997eb 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -674,7 +674,7 @@ void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, PlayState* play) { // "You're feeling confident" Message_StartTextbox(play, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; - } else if ((gSaveContext.unk_3DE0[4] < 115 * 100)) { // timer < 115 seconds + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(115)) { func_800B8614(&this->actor, play, 100.0f); } } @@ -689,7 +689,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play) { Player* player = GET_PLAYER(play); play->interfaceCtx.unk_280 = 1; - func_8010E9F0(4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); gSaveContext.save.weekEventReg[8] |= 1; func_80112AFC(play); player->stateFlags1 |= 0x20; @@ -717,9 +717,9 @@ void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) { play->interfaceCtx.unk_25C = 1; } - if ((gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) // timer >= 2 minutes - || (this->poppedBalloonCounter == 10)) { - gSaveContext.unk_3DD0[4] = 6; + if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) || + (this->poppedBalloonCounter == 10)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; EnMa4_SetupHorsebackGameEnd(this, play); D_80AC0258 = 0; } @@ -898,13 +898,13 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); Message_StartTextbox(play, 0x336D, &this->actor); this->textId = 0x336D; } else { - time = gSaveContext.unk_3DE0[4]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [Score] New record! gSaveContext.save.horseBackBalloonHighScore = time; @@ -943,12 +943,12 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { Message_StartTextbox(play, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.unk_3DE0[4]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); @@ -970,12 +970,12 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { Message_StartTextbox(play, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.unk_3DE0[4]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record gSaveContext.save.horseBackBalloonHighScore = time; 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 0f7308826..6909183f3 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -249,13 +249,14 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { break; case 0x2791: - if (gSaveContext.unk_3DE0[0] == 1000) { + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { Message_StartTextbox(play, 0x2792, &this->actor); this->unk_2B4 = 0x2792; - } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { + } else if ((gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] >= SECONDS_TO_TIMER(15))) { Message_StartTextbox(play, 0x2797, &this->actor); this->unk_2B4 = 0x2797; - } else if ((gSaveContext.unk_3DE0[0] <= 1050) && (gSaveContext.unk_3DE0[0] >= 950)) { + } else if ((gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] <= SECONDS_TO_TIMER_PRECISE(10, 50)) && + (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] >= SECONDS_TO_TIMER_PRECISE(9, 50))) { Message_StartTextbox(play, 0x2795, &this->actor); this->unk_2B4 = 0x2795; } else { @@ -301,7 +302,7 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { } else if ((this->unk_2AC > 0) && (this->unk_2B4 == 0x2791)) { this->unk_2AC--; if (this->unk_2AC == 0) { - if (gSaveContext.unk_3DE0[0] == 1000) { + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { func_801A3098(0x922); } else { play_sound(NA_SE_SY_ERROR); @@ -342,9 +343,9 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) { player->stateFlags1 |= 0x20; if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { - func_8010EA9C(0, 2); + Interface_StartPostmanTimer(0, POSTMAN_MINIGAME_BUNNY_HOOD_ON); } else { - func_8010EA9C(0, 0); + Interface_StartPostmanTimer(0, POSTMAN_MINIGAME_BUNNY_HOOD_OFF); } func_801477B4(play); play_sound(NA_SE_SY_START_SHOT); @@ -381,18 +382,20 @@ void func_80A6FBA0(EnMm3* this) { void func_80A6FBFC(EnMm3* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (gSaveContext.unk_3DD0[0] == 0x10) { + if (gSaveContext.timerStates[TIMER_ID_POSTMAN] == TIMER_STATE_POSTMAN_END) { player->stateFlags1 &= ~0x20; this->actor.flags |= ACTOR_FLAG_10000; - 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; + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] > SECONDS_TO_TIMER(15)) { + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(15); + } else if ((((void)0, gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]) >= + (OSTime)(SECONDS_TO_TIMER_PRECISE(10, -5) - XREG(16))) && + (((void)0, gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]) <= + (OSTime)(SECONDS_TO_TIMER_PRECISE(10, 5) + XREG(17)))) { + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(10); } - } else if (gSaveContext.unk_3DE0[0] > 1500) { - gSaveContext.unk_3DD0[0] = 15; - gSaveContext.unk_3DC8 = osGetTime(); + } else if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] > SECONDS_TO_TIMER(15)) { + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_STOP; + gSaveContext.postmanTimerStopOsTime = osGetTime(); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -401,7 +404,7 @@ void func_80A6FBFC(EnMm3* this, PlayState* play) { Message_StartTextbox(play, 0x2791, &this->actor); this->unk_2B4 = 0x2791; this->unk_2AC = 7; - gSaveContext.unk_3DD0[0] = 0; + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_OFF; this->actor.flags &= ~ACTOR_FLAG_10000; play_sound(NA_SE_SY_START_SHOT); func_80A6F9C8(this); 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 b6f653935..1cc1946f5 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -7,6 +7,11 @@ struct EnMm3; typedef void (*EnMm3ActionFunc)(struct EnMm3*, PlayState*); +typedef enum { + /* 0 */ POSTMAN_MINIGAME_BUNNY_HOOD_OFF, + /* 2 */ POSTMAN_MINIGAME_BUNNY_HOOD_ON = 2 +} PostmanMinigameBunnyHoodState; + typedef struct EnMm3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; 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 eb6d4ab42..ed67013d8 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 @@ -253,7 +253,7 @@ s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType * Displays the text which says that the player has made a false start. */ void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { - gSaveContext.unk_3DD0[4] = 0; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start func_800B7298(play, &this->actor, 7); Audio_QueueSeqCmd(0x101400FF); @@ -314,7 +314,7 @@ void EnMttag_RaceStart(EnMttag* this, PlayState* play) { gSaveContext.eventInf[1] |= 8; } else { if (DECR(this->timer) == 60) { - func_8010E9F0(4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); play->interfaceCtx.unk_280 = 1; Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); play->envCtx.unk_E4 = 0xFE; @@ -359,14 +359,14 @@ void EnMttag_Race(EnMttag* this, PlayState* play) { s32 playerCheatStatus; if (EnMttag_IsInFinishLine(playerPos)) { - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_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; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); this->timer = 55; @@ -456,7 +456,7 @@ void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { if (play->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); - gSaveContext.unk_3DD0[4] = 0; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); gSaveContext.eventInf[1] &= (u8)~8; gSaveContext.eventInf[1] |= 4; @@ -502,12 +502,14 @@ void EnMttag_Init(Actor* thisx, PlayState* play) { void EnMttag_Destroy(Actor* thisx, PlayState* play) { EnMttag* this = THIS; - if (gSaveContext.unk_3DD0[4] != 6) { - gSaveContext.unk_3DD0[4] = 5; + + if (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] != TIMER_STATE_6) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } void EnMttag_Update(Actor* thisx, PlayState* play) { EnMttag* this = THIS; + this->actionFunc(this, play); } 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 51a941b28..1d504dc62 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 @@ -271,7 +271,8 @@ void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play) { void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { + if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] <= SECONDS_TO_TIMER(0)) || + (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { func_80A2C3AC(this); } 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 7852aa24b..5433aeec7 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 @@ -154,7 +154,7 @@ static s32 sSwampTargetActorListLengths[] = { }; static Vec3f sSwampPlayerPos = { 0.0f, 10.0f, 140.0f }; -static Vec3f sTownFierceDietyPlayerPos = { -20.0f, 20.0f, 198.0f }; +static Vec3f sTownFierceDeityPlayerPos = { -20.0f, 20.0f, 198.0f }; static Vec3f sTownPlayerPos = { -20.0f, 40.0f, 175.0f }; /** @@ -1012,7 +1012,7 @@ void EnSyatekiMan_Swamp_StartGame(EnSyatekiMan* this, PlayState* play) { this->guayHitCounter = 0; this->currentWave = 0; this->perGameVar2.bonusDekuScrubHitCounter = 0; - func_8010E9F0(1, 100); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 100); this->actor.draw = NULL; this->actionFunc = EnSyatekiMan_Swamp_RunGame; } @@ -1061,9 +1061,9 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->perGameVar1.guaySpawnTimer++; - if (gSaveContext.unk_3DE0[1] == 0) { - gSaveContext.unk_3DE0[1] = 0; - gSaveContext.unk_3DD0[1] = 5; + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->actor.draw = EnSyatekiMan_Draw; this->flagsIndex = 0; this->currentWave = 0; @@ -1082,10 +1082,10 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; if (this->score == 2120) { func_8011B4E0(play, 2); - gSaveContext.unk_3DD0[1] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_6; this->actionFunc = EnSyatekiMan_Swamp_AddBonusPoints; } else { - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->actionFunc = EnSyatekiMan_Swamp_EndGame; } } @@ -1148,15 +1148,15 @@ void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { player->stateFlags1 |= 0x20; if (play->interfaceCtx.unk_286 == 0) { - if (gSaveContext.unk_3DE0[1] == 0) { - gSaveContext.unk_3DE0[1] = 0; - gSaveContext.unk_3DD0[1] = 5; + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->flagsIndex = 0; this->currentWave = 0; this->actionFunc = EnSyatekiMan_Swamp_EndGame; sBonusTimer = 0; } else if (sBonusTimer > 10) { - gSaveContext.unk_3E88[1] += 100; + gSaveContext.timerStopTimes[TIMER_ID_MINIGAME_1] += SECONDS_TO_TIMER(1); play->interfaceCtx.unk_25C += 10; this->score += 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); @@ -1171,7 +1171,7 @@ void EnSyatekiMan_Town_MovePlayerAndSayHighScore(EnSyatekiMan* this, PlayState* Vec3f targetPlayerPos; if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { - targetPlayerPos = sTownFierceDietyPlayerPos; + targetPlayerPos = sTownFierceDeityPlayerPos; } else { targetPlayerPos = sTownPlayerPos; } @@ -1198,7 +1198,7 @@ void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { if (sGameStartTimer == 30) { if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { - player->actor.world.pos = sTownFierceDietyPlayerPos; + player->actor.world.pos = sTownFierceDeityPlayerPos; } else { player->actor.world.pos = sTownPlayerPos; } @@ -1220,7 +1220,7 @@ void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { this->perGameVar1.octorokState = SG_OCTO_STATE_INITIAL; this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; sGameStartTimer = 30; - func_8010E9F0(1, 75); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 75); this->actor.draw = NULL; this->actionFunc = EnSyatekiMan_Town_RunGame; } @@ -1292,7 +1292,8 @@ static const s32 sOctorokFlagsPerWave[] = { void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { static s32 sModFromLosingTime = 0; Player* player = GET_PLAYER(play); - s32 timer = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; // unit is tenths of a second + s32 timer = + (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1]) * 0.1f) + 1.0f; // unit is tenths of a second if (timer <= 750) { s32 waveTimer; // unit is hundredths of a second @@ -1302,9 +1303,10 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { // begin hiding. This code will ultimately correct waveTimer such that its value is not affected by // hitting Blue Octoroks. if (sModFromLosingTime == 0) { - waveTimer = ((void)0, gSaveContext.unk_3DE0[1]) % 500; + waveTimer = ((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1]) % SECONDS_TO_TIMER(5); } else { - waveTimer = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; + waveTimer = (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1]) + SECONDS_TO_TIMER_PRECISE(2, 50)) % + SECONDS_TO_TIMER(5); } // Octoroks begin hiding four seconds after a wave begins. @@ -1314,7 +1316,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { if (this->perGameVar2.octorokHitType != SG_OCTO_HIT_TYPE_NONE) { if (this->perGameVar2.octorokHitType == SG_OCTO_HIT_TYPE_BLUE) { - gSaveContext.unk_3E18[1] -= 250; + gSaveContext.timerTimeLimits[TIMER_ID_MINIGAME_1] -= SECONDS_TO_TIMER_PRECISE(2, 50); sModFromLosingTime = (sModFromLosingTime + 25) % 50; } @@ -1336,11 +1338,11 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { } } - if (gSaveContext.unk_3DE0[1] == 0) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { this->flagsIndex = 0; this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; - gSaveContext.unk_3DE0[1] = 0; - gSaveContext.unk_3DD0[1] = 5; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; player->stateFlags1 |= 0x20; sModFromLosingTime = 0; this->actor.draw = EnSyatekiMan_Draw; 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 88547581f..f33a1f693 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -388,7 +388,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { func_80A41FA4(this, play); } else if (temp_a0 == CLOCK_TIME(6, 0)) { if (CURRENT_DAY == 3) { - func_8011C808(play); + Interface_StartMoonCrash(play); Actor_MarkForDeath(&this->actor); gSaveContext.eventInf[1] |= 0x80; } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && 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 b6dea09f3..0a013410b 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 @@ -90,7 +90,7 @@ void func_80AC9FE4(EnTimeTag* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->actionFunc = func_80AC9FD4; - gSaveContext.unk_3DD0[3] = 0; + gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; 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; @@ -107,7 +107,7 @@ void func_80ACA0A8(EnTimeTag* this, PlayState* play) { if (this->actor.cutscene != -1) { this->actionFunc = func_80AC9FE4; ActorCutscene_SetIntentToPlay(this2->actor.cutscene); - gSaveContext.unk_3DD0[3] = 0; + gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; } play->msgCtx.ocarinaMode = 4; } 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 b39187c75..0ce2f38a1 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -45,14 +45,14 @@ void ObjRoomtimer_Init(Actor* thisx, PlayState* play) { void ObjRoomtimer_Destroy(Actor* thisx, PlayState* play) { ObjRoomtimer* this = THIS; - if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] > 0) { - gSaveContext.unk_3DD0[4] = 5; + if ((this->actor.params != 0x1FF) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] >= TIMER_STATE_START)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } void func_80973CD8(ObjRoomtimer* this, PlayState* play) { if (this->actor.params != 0x1FF) { - func_8010E9F0(4, this->actor.params); + Interface_StartTimer(TIMER_ID_MINIGAME_2, this->actor.params); } func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); @@ -62,11 +62,11 @@ void func_80973CD8(ObjRoomtimer* this, PlayState* play) { void func_80973D3C(ObjRoomtimer* this, PlayState* play) { if (Flags_GetClearTemp(play, this->actor.room)) { if (this->actor.params != 0x1FF) { - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_80973DE0; - } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { + } else if ((this->actor.params != 0x1FF) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] == TIMER_STATE_OFF)) { play_sound(NA_SE_OC_ABYSS); func_80169EFC(&play->state); Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index b4cfe295c..5d418c0fc 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -507,13 +507,13 @@ void MapSelect_UpdateMenu(MapSelectState* this) { if (this->verticalInputAccumulator == 0) { if (CHECK_BTN_ALL(controller1->press.button, BTN_A) || CHECK_BTN_ALL(controller1->press.button, BTN_START)) { - for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3EC0); 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; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } gSaveContext.minigameState = 0; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a83588b66..331f5c193 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2093,12 +2093,12 @@ 0x8010DC58:("func_8010DC58",), 0x8010DE38:("func_8010DE38",), 0x8010E028:("func_8010E028",), - 0x8010E968:("func_8010E968",), - 0x8010E9F0:("func_8010E9F0",), - 0x8010EA9C:("func_8010EA9C",), - 0x8010EB50:("func_8010EB50",), - 0x8010EBA0:("func_8010EBA0",), - 0x8010EC54:("func_8010EC54",), + 0x8010E968:("Interface_PostmanTimerCallback",), + 0x8010E9F0:("Interface_StartTimer",), + 0x8010EA9C:("Interface_StartPostmanTimer",), + 0x8010EB50:("Interface_StartGoronRaceTimer",), + 0x8010EBA0:("Interface_StartBottleTimer",), + 0x8010EC54:("Interface_GetCompressedTimerDigits",), 0x8010EE74:("func_8010EE74",), 0x8010EF68:("Interface_SetHudVisibility",), 0x8010EF9C:("Interface_UpdateButtonAlphasByStatus",), @@ -2156,16 +2156,16 @@ 0x8011B9E0:("func_8011B9E0",), 0x8011BF70:("func_8011BF70",), 0x8011C4C4:("func_8011C4C4",), - 0x8011C808:("func_8011C808",), - 0x8011C898:("func_8011C898",), - 0x8011CA64:("func_8011CA64",), - 0x8011E3B4:("func_8011E3B4",), + 0x8011C808:("Interface_StartMoonCrash",), + 0x8011C898:("Interface_GetTimerDigits",), + 0x8011CA64:("Interface_DrawTimers",), + 0x8011E3B4:("Interface_UpdateBottleTimers",), 0x8011E730:("func_8011E730",), 0x8011F0E0:("func_8011F0E0",), 0x80120F90:("func_80120F90",), 0x80121064:("func_80121064",), 0x801210E0:("func_801210E0",), - 0x80121F94:("func_80121F94",), + 0x80121F94:("Interface_Destroy",), 0x80121FC4:("func_80121FC4",), 0x801224E0:("Path_GetByIndex",), 0x80122524:("Path_OrientAndGetDistSq",), @@ -2232,7 +2232,7 @@ 0x80124258:("Player_GetExplosiveHeld",), 0x80124278:("func_80124278",), 0x801242B4:("func_801242B4",), - 0x801242DC:("func_801242DC",), + 0x801242DC:("Player_GetEnvTimerType",), 0x80124420:("func_80124420",), 0x80124618:("func_80124618",), 0x801246F4:("func_801246F4",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0ea237d4b..55609668b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1074,16 +1074,16 @@ 0x801BF8A8:("sMagicMeterOutlinePrimBlue","UNK_TYPE2","",0x2), 0x801BF8AC:("sMagicBorderRatio","UNK_TYPE2","",0x2), 0x801BF8B0:("sMagicBorderStep","UNK_TYPE2","",0x2), - 0x801BF8DC:("D_801BF8DC","UNK_TYPE2","",0x2), - 0x801BF8E0:("D_801BF8E0","UNK_TYPE2","",0x2), - 0x801BF8E4:("D_801BF8E4","UNK_TYPE2","",0x2), - 0x801BF8E8:("D_801BF8E8","UNK_TYPE4","",0x4), - 0x801BF8F0:("D_801BF8F0","u64","",0x8), + 0x801BF8DC:("sEnvTimerType","UNK_TYPE2","",0x2), + 0x801BF8E0:("sEnvTimerActive","UNK_TYPE2","",0x2), + 0x801BF8E4:("sPostmanBunnyHoodState","UNK_TYPE2","",0x2), + 0x801BF8E8:("sTimerPausedOsTime","UNK_TYPE4","",0x4), + 0x801BF8F0:("sBottleTimerPausedOsTime","u64","",0x8), 0x801BF8F8:("D_801BF8F8","u64","[7]",0x38), 0x801BF930:("D_801BF930","u64","[7]",0x38), - 0x801BF968:("D_801BF968","UNK_TYPE4","",0x4), - 0x801BF96C:("D_801BF96C","UNK_TYPE4","",0x4), - 0x801BF970:("D_801BF970","UNK_TYPE4","",0x4), + 0x801BF968:("sIsTimerPaused","UNK_TYPE4","",0x4), + 0x801BF96C:("sIsBottleTimerPaused","UNK_TYPE4","",0x4), + 0x801BF970:("sTimerId","UNK_TYPE4","",0x4), 0x801BF974:("D_801BF974","UNK_TYPE4","",0x4), 0x801BF978:("D_801BF978","UNK_TYPE4","",0x4), 0x801BF97C:("D_801BF97C","UNK_TYPE4","",0x4), @@ -1113,7 +1113,7 @@ 0x801BFA4C:("D_801BFA4C","UNK_TYPE2","",0x2), 0x801BFA64:("D_801BFA64","UNK_TYPE2","",0x2), 0x801BFA74:("D_801BFA74","UNK_TYPE2","",0x2), - 0x801BFA84:("D_801BFA84","UNK_TYPE4","",0x4), + 0x801BFA84:("sPostmanTimerInputBtnAPressed","UNK_TYPE4","",0x4), 0x801BFAB0:("sDoActionTextures","UNK_TYPE1","",0x1), 0x801BFAB8:("magicBorderColors","UNK_TYPE1","",0x1), 0x801BFAC4:("magicBorderIndices","UNK_TYPE1","",0x1), @@ -1161,9 +1161,9 @@ 0x801BFCA8:("D_801BFCA8","UNK_TYPE2","",0x2), 0x801BFCB8:("D_801BFCB8","UNK_TYPE1","",0x1), 0x801BFCC4:("D_801BFCC4","UNK_TYPE4","",0x4), - 0x801BFCE4:("D_801BFCE4","UNK_TYPE4","",0x4), - 0x801BFCE8:("D_801BFCE8","u16","[8]",0x10), - 0x801BFCF8:("D_801BFCF8","UNK_TYPE4","",0x4), + 0x801BFCE4:("sTimerStateTimer","UNK_TYPE4","",0x4), + 0x801BFCE8:("sTimerDigits","u16","[8]",0x10), + 0x801BFCF8:("sTimerBeepSfxSeconds","UNK_TYPE4","",0x4), 0x801BFCFC:("D_801BFCFC","UNK_TYPE4","",0x4), 0x801BFD0C:("D_801BFD0C","UNK_TYPE4","",0x4), 0x801BFD1C:("D_801BFD1C","UNK_TYPE1","",0x1), @@ -4002,7 +4002,7 @@ 0x801F57B4:("D_801F57B4","UNK_TYPE1","",0x1), 0x801F5834:("D_801F5834","UNK_TYPE1","",0x1), 0x801F5840:("gNMIBuffer","s32*","",0x4), - 0x801F5850:("D_801F5850","UNK_TYPE1","",0x1), + 0x801F5850:("sPostmanTimerInput","UNK_TYPE1","",0x1), 0x801F58B0:("D_801F58B0","UNK_TYPE1","",0x1), 0x801F59AC:("D_801F59AC","UNK_TYPE1","",0x1), 0x801F59B0:("D_801F59B0","UNK_TYPE1","",0x1), @@ -9920,7 +9920,7 @@ 0x809C9464:("sSwampTargetActorLists","UNK_PTR","",0x4), 0x809C946C:("sSwampTargetActorListLengths","UNK_TYPE1","",0x1), 0x809C9474:("sSwampPlayerPos","UNK_TYPE4","",0x4), - 0x809C9480:("sTownFierceDietyPlayerPos","UNK_TYPE4","",0x4), + 0x809C9480:("sTownFierceDeityPlayerPos","UNK_TYPE4","",0x4), 0x809C948C:("sTownPlayerPos","UNK_TYPE4","",0x4), 0x809C9498:("sGameStartTimer","s16","",0x2), 0x809C949C:("sHasSpawnedGuaysForThisWave","UNK_TYPE2","",0x2), diff --git a/tools/namefixer.py b/tools/namefixer.py index 3008c0143..4152c8d97 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -483,6 +483,9 @@ wordReplace = { "func_80169E6C": "Play_SetupRespawnPoint", "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", + "func_8010E9F0": "Interface_StartTimer", + "func_8010EA9C": "Interface_StartPostmanTimer", + "func_80121F94": "Interface_Destroy", "Interface_ChangeAlpha": "Interface_SetHudVisibility", "func_80112B40": "Interface_LoadItemIconImpl", "func_80112BE4": "Interface_LoadItemIcon", @@ -697,6 +700,7 @@ wordReplace = { "player->unk_394": "player->csMode", "player->swordQuads": "player->meleeWeaponQuads", "player->blureEffectIndex": "player->meleeWeaponEffectIndex", + "player->unk_AD8": "player->underwaterTimer", "player->swordAnimation": "player->meleeWeaponAnimation", "player->swordState": "player->meleeWeaponState", "player->swordInfo": "player->meleeWeaponInfo", @@ -726,6 +730,15 @@ wordReplace = { "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", "play->nextEntranceIndex": "play->nextEntrance", + "gSaveContext.unk_3DC8": "gSaveContext.timerOsTime", + "gSaveContext.unk_3DD0": "gSaveContext.timerStates", + "gSaveContext.unk_3DD7": "gSaveContext.timerDirections", + "gSaveContext.unk_3DE0": "gSaveContext.timerCurTimes", + "gSaveContext.unk_3E18": "gSaveContext.timerTimeLimits", + "gSaveContext.unk_3E50": "gSaveContext.timerStartOsTimes", + "gSaveContext.unk_3E88": "gSaveContext.timerStopTimes", + "gSaveContext.unk_3EC0": "gSaveContext.timerPausedOsTimes", + "play->sceneLoadFlag": "play->transitionTrigger", "play->unk_18B4A": "play->transitionMode", "play->unk_1887F": "play->transitionType", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 6d0e03cd1..52cb53a60 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1607,12 +1607,12 @@ asm/non_matchings/code/z_parameter/func_8010D9F4.s,func_8010D9F4,0x8010D9F4,0x99 asm/non_matchings/code/z_parameter/func_8010DC58.s,func_8010DC58,0x8010DC58,0x78 asm/non_matchings/code/z_parameter/func_8010DE38.s,func_8010DE38,0x8010DE38,0x7C asm/non_matchings/code/z_parameter/func_8010E028.s,func_8010E028,0x8010E028,0x250 -asm/non_matchings/code/z_parameter/func_8010E968.s,func_8010E968,0x8010E968,0x22 -asm/non_matchings/code/z_parameter/func_8010E9F0.s,func_8010E9F0,0x8010E9F0,0x2B -asm/non_matchings/code/z_parameter/func_8010EA9C.s,func_8010EA9C,0x8010EA9C,0x2D -asm/non_matchings/code/z_parameter/func_8010EB50.s,func_8010EB50,0x8010EB50,0x14 -asm/non_matchings/code/z_parameter/func_8010EBA0.s,func_8010EBA0,0x8010EBA0,0x2D -asm/non_matchings/code/z_parameter/func_8010EC54.s,func_8010EC54,0x8010EC54,0x88 +asm/non_matchings/code/z_parameter/Interface_PostmanTimerCallback.s,Interface_PostmanTimerCallback,0x8010E968,0x22 +asm/non_matchings/code/z_parameter/Interface_StartTimer.s,Interface_StartTimer,0x8010E9F0,0x2B +asm/non_matchings/code/z_parameter/Interface_StartPostmanTimer.s,Interface_StartPostmanTimer,0x8010EA9C,0x2D +asm/non_matchings/code/z_parameter/Interface_StartGoronRaceTimer.s,Interface_StartGoronRaceTimer,0x8010EB50,0x14 +asm/non_matchings/code/z_parameter/Interface_StartBottleTimer.s,Interface_StartBottleTimer,0x8010EBA0,0x2D +asm/non_matchings/code/z_parameter/Interface_GetCompressedTimerDigits.s,Interface_GetCompressedTimerDigits,0x8010EC54,0x88 asm/non_matchings/code/z_parameter/func_8010EE74.s,func_8010EE74,0x8010EE74,0x3D asm/non_matchings/code/z_parameter/Interface_SetHudVisibility.s,Interface_SetHudVisibility,0x8010EF68,0xD asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphasByStatus.s,Interface_UpdateButtonAlphasByStatus,0x8010EF9C,0x4E @@ -1670,16 +1670,16 @@ asm/non_matchings/code/z_parameter/func_8011B5C0.s,func_8011B5C0,0x8011B5C0,0x10 asm/non_matchings/code/z_parameter/func_8011B9E0.s,func_8011B9E0,0x8011B9E0,0x164 asm/non_matchings/code/z_parameter/func_8011BF70.s,func_8011BF70,0x8011BF70,0x155 asm/non_matchings/code/z_parameter/func_8011C4C4.s,func_8011C4C4,0x8011C4C4,0xD1 -asm/non_matchings/code/z_parameter/func_8011C808.s,func_8011C808,0x8011C808,0x24 -asm/non_matchings/code/z_parameter/func_8011C898.s,func_8011C898,0x8011C898,0x73 -asm/non_matchings/code/z_parameter/func_8011CA64.s,func_8011CA64,0x8011CA64,0x654 -asm/non_matchings/code/z_parameter/func_8011E3B4.s,func_8011E3B4,0x8011E3B4,0xDF +asm/non_matchings/code/z_parameter/Interface_StartMoonCrash.s,Interface_StartMoonCrash,0x8011C808,0x24 +asm/non_matchings/code/z_parameter/Interface_GetTimerDigits.s,Interface_GetTimerDigits,0x8011C898,0x73 +asm/non_matchings/code/z_parameter/Interface_DrawTimers.s,Interface_DrawTimers,0x8011CA64,0x654 +asm/non_matchings/code/z_parameter/Interface_UpdateBottleTimers.s,Interface_UpdateBottleTimers,0x8011E3B4,0xDF asm/non_matchings/code/z_parameter/func_8011E730.s,func_8011E730,0x8011E730,0x26C asm/non_matchings/code/z_parameter/func_8011F0E0.s,func_8011F0E0,0x8011F0E0,0x7AC asm/non_matchings/code/z_parameter/func_80120F90.s,func_80120F90,0x80120F90,0x35 asm/non_matchings/code/z_parameter/func_80121064.s,func_80121064,0x80121064,0x1F asm/non_matchings/code/z_parameter/func_801210E0.s,func_801210E0,0x801210E0,0x3AD -asm/non_matchings/code/z_parameter/func_80121F94.s,func_80121F94,0x80121F94,0xC +asm/non_matchings/code/z_parameter/Interface_Destroy.s,Interface_Destroy,0x80121F94,0xC asm/non_matchings/code/z_parameter/func_80121FC4.s,func_80121FC4,0x80121FC4,0x147 asm/non_matchings/code/z_path/func_801224E0.s,func_801224E0,0x801224E0,0x11 asm/non_matchings/code/z_path/func_80122524.s,func_80122524,0x80122524,0x2A @@ -1746,7 +1746,7 @@ asm/non_matchings/code/z_player_lib/Player_ActionToExplosive.s,Player_ActionToEx asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s,Player_GetExplosiveHeld,0x80124258,0x8 asm/non_matchings/code/z_player_lib/func_80124278.s,func_80124278,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA -asm/non_matchings/code/z_player_lib/func_801242DC.s,func_801242DC,0x801242DC,0x51 +asm/non_matchings/code/z_player_lib/Player_GetEnvTimerType.s,Player_GetEnvTimerType,0x801242DC,0x51 asm/non_matchings/code/z_player_lib/func_80124420.s,func_80124420,0x80124420,0x7E asm/non_matchings/code/z_player_lib/func_80124618.s,func_80124618,0x80124618,0x37 asm/non_matchings/code/z_player_lib/func_801246F4.s,func_801246F4,0x801246F4,0x5F From 7ed0d14bfe71b845a4ad3f857fc8852ea9cec10e Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Thu, 29 Sep 2022 17:29:25 -0700 Subject: [PATCH 52/73] `En_Ru`: OK (Unused OoT Ruto) (#1035) * Ruto: OK * Ruto: better walking water sfx function name and less fake match * Ruto: formater pls * Ruto: Requested changes, better display list documentation * Ruto: requested changes * Ruto: formater pass * Ruto: casts were removeable * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Ru/z_en_ru.c Co-authored-by: Derek Hensley * Ruto: array size fix * Ruto: data shuffle solved * Ruto: requested name changes * Ru: requested changes * Ru: count instead of size Co-authored-by: Isghj8 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Derek Hensley --- assets/xml/objects/object_ru2.xml | 168 +++++++------ spec | 3 +- src/overlays/actors/ovl_En_Ru/z_en_ru.c | 298 +++++++++++++++++++++--- src/overlays/actors/ovl_En_Ru/z_en_ru.h | 27 ++- tools/disasm/functions.txt | 16 +- 5 files changed, 400 insertions(+), 112 deletions(-) diff --git a/assets/xml/objects/object_ru2.xml b/assets/xml/objects/object_ru2.xml index 08f182bb9..72510149c 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -1,78 +1,98 @@  + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index c894dabef..48b1695ac 100644 --- a/spec +++ b/spec @@ -2638,8 +2638,7 @@ beginseg name "ovl_En_Ru" compress include "build/src/overlays/actors/ovl_En_Ru/z_en_ru.o" - include "build/data/ovl_En_Ru/ovl_En_Ru.data.o" - include "build/data/ovl_En_Ru/ovl_En_Ru.reloc.o" + include "build/src/overlays/actors/ovl_En_Ru/ovl_En_Ru_reloc.o" endseg beginseg 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 0333cb011..1a57cba7b 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -15,9 +15,8 @@ void EnRu_Destroy(Actor* thisx, PlayState* play); void EnRu_Update(Actor* thisx, PlayState* play); void EnRu_Draw(Actor* thisx, PlayState* play); -void func_80A38DF4(EnRu* this, PlayState* play); +void EnRu_DoNothing(EnRu* this, PlayState* play); -#if 0 const ActorInit En_Ru_InitVars = { ACTOR_EN_RU, ACTORCAT_NPC, @@ -30,18 +29,29 @@ const ActorInit En_Ru_InitVars = { (ActorFunc)EnRu_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A39450 = { - { 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_80A3947C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80A39488 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -76,34 +86,268 @@ static DamageTable D_80A39488 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gAdultRutoIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAdultRutoIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoRaisingArmsUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoCrossingArmsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoLookingDownLeftAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoIdleHandsOnHipsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoHeadTurnDownLeftAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoSwimmingUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +}; -extern ColliderCylinderInit D_80A39450; -extern CollisionCheckInfoInit2 D_80A3947C; -extern DamageTable D_80A39488; +// in PostLimbdraw, converts limbIndex to bodyPartsPos index +static s8 sBodyPartPosIndices[] = { + -1, -1, 12, 13, 14, -1, 9, 10, 11, -1, 0, 6, -1, -1, 7, 8, 2, -1, -1, 3, 4, 2, 1, +}; -extern UNK_TYPE D_0600C700; +static s8 sRuBodyParts[RU_BODYPARTSPOS_COUNT] = { + 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A389A0.s") +static u8 sRuShadowSizes[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38A68.s") +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 } +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38B7C.s") +s32 EnRu_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { + s16 lastFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38BF0.s") + if ((animIndex >= 0) && (animIndex < ARRAY_COUNT(sAnimationInfo))) { + lastFrame = sAnimationInfo[animIndex].frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38C70.s") + ret = true; + if (lastFrame < 0) { + lastFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38DF4.s") + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, lastFrame, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Init.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Destroy.s") +// En_Zo has a copy of this function +s32 EnRu_PlayWalkingSound(EnRu* this, PlayState* play) { + u8 leftWasGrounded; + u8 rightWasGrounded; + s32 waterSfxId; + s16 sfxId; + u8 isFootGrounded; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Update.s") + leftWasGrounded = this->isLeftFootGrounded; + rightWasGrounded = this->isRightFootGrounded; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38FB4.s") + if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.depthInWater < 20.0f) { + waterSfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + } else { + waterSfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A390F8.s") + sfxId = waterSfxId + SFX_FLAG; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Draw.s") + } else { + sfxId = SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; + } + + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->leftFootPos, -6.0f); + + if (this->isLeftFootGrounded && !leftWasGrounded && isFootGrounded) { + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->rightFootPos, -6.0f); + if (this->isRightFootGrounded && !rightWasGrounded && isFootGrounded) { + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + + return false; +} + +// This function is only ever called with eyeStateMax == 3 +void EnRu_UpdateEyes(EnRu* this, s32 eyeStateMax) { + if (DECR(this->blinkTimer) == 0) { + this->eyeState++; + if (this->eyeState >= eyeStateMax) { + this->eyeState = 0; + this->blinkTimer = Rand_S16Offset(30, 30); + } + } +} + +void EnRu_UpdateCollider(EnRu* this, PlayState* play) { + 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(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnRu_UpdateModel(EnRu* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + + // Head and Torso tracking to Player if in front of Ru. + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + Vec3f playerPos; + + playerPos.x = player->actor.world.pos.x; + playerPos.y = player->bodyPartsPos[7].y + 3.0f; + playerPos.z = player->actor.world.pos.z; + SubS_TrackPoint(&playerPos, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); + + } else { // smooth her back to facing forward + 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); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); + } + + EnRu_UpdateEyes(this, 3); + EnRu_PlayWalkingSound(this, play); + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, RU2_LIMB_MAX); +} + +void EnRu_DoNothing(EnRu* this, PlayState* play) { +} + +void EnRu_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnRu* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gAdultRutoSkel, NULL, this->jointTable, this->morphTable, RU2_LIMB_MAX); + EnRu_ChangeAnim(&this->skelAnime, 0); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->path = SubS_GetPathByIndex(play, RU_GET_PATH(thisx), 0x3F); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnRu_DoNothing; + this->actor.gravity = -4.0f; +} + +void EnRu_Destroy(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +void EnRu_Update(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnRu_UpdateModel(this, play); + EnRu_UpdateCollider(this, play); +} + +s32 EnRu_OverrideLimbdraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnRu* this = THIS; + + if (limbIndex == RU2_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 == RU2_LIMB_TORSO) { + Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == RU2_LIMB_TORSO) || (limbIndex == RU2_LIMB_LEFT_UPPER_ARM) || + (limbIndex == RU2_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnRu_PostLimbdraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnRu* this = THIS; + Vec3f headFocus = { 800.0f, 0, 0 }; + Vec3f bodyPartPos = { 0, 0, 0 }; + + if (sBodyPartPosIndices[limbIndex] >= 0) { + Matrix_MultVec3f(&bodyPartPos, &this->bodyPartsPos[sBodyPartPosIndices[limbIndex]]); + } + if (limbIndex == RU2_LIMB_HEAD) { + Matrix_MultVec3f(&headFocus, &thisx->focus.pos); + } + + if (limbIndex == RU2_LIMB_LEFT_FOOT) { + Matrix_MultVec3f(&bodyPartPos, &this->leftFootPos); + } + if (limbIndex == RU2_LIMB_RIGHT_FOOT) { + Matrix_MultVec3f(&bodyPartPos, &this->rightFootPos); + } +} + +// This is a copy of displaylist found in En_Zo +static Gfx sTransparencyDlist[] = { + gsDPSetRenderMode(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)), + gsDPSetAlphaCompare(G_AC_THRESHOLD), + gsSPEndDisplayList(), +}; + +void EnRu_Draw(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + s32 i; + TexturePtr eyeTextures[] = { gAdultRutoEyeOpenTex, gAdultRutoEyeHalfTex, gAdultRutoEyeClosedTex }; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + gDPPipeSync(POLY_OPA_DISP++); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeState])); + + // only runs the last command of the display list, which is gsSPEndDisplayList + gSPSegment(POLY_OPA_DISP++, 0x0C, &sTransparencyDlist[2]); + + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRu_OverrideLimbdraw, EnRu_PostLimbdraw, &this->actor, POLY_OPA_DISP); + + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(&this->bodyPartsPos[0], &this->actor.world.pos, shadowTex, (i / 5.0f), + (ARRAY_COUNT(sRuBodyParts)), sRuShadowSizes, sRuBodyParts); + } + + SubS_DrawShadowTex(&this->actor, &play->state, shadowTex); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.h b/src/overlays/actors/ovl_En_Ru/z_en_ru.h index 29c903aff..b1144f88d 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.h +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.h @@ -2,15 +2,40 @@ #define Z_EN_RU_H #include "global.h" +#include "objects/object_ru2/object_ru2.h" + +#define RU_GET_PATH(thisx) ((thisx->params & 0x7E00) >> 9) struct EnRu; typedef void (*EnRuActionFunc)(struct EnRu*, PlayState*); +#define RU_BODYPARTSPOS_COUNT 15 + typedef struct EnRu { /* 0x000 */ Actor actor; /* 0x144 */ EnRuActionFunc actionFunc; - /* 0x148 */ char unk_148[0x30C]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 pad1D8[0x4]; + /* 0x1DC */ Path* path; // path is prepared in EnRu_Init, but unused after + /* 0x1E0 */ UNK_TYPE1 pad1E0[0x4]; + /* 0x1E4 */ Vec3f leftFootPos; + /* 0x1F0 */ Vec3f rightFootPos; + /* 0x1FC */ u8 isLeftFootGrounded; + /* 0x1FD */ u8 isRightFootGrounded; + /* 0x1FE */ Vec3s jointTable[RU2_LIMB_MAX]; + /* 0x288 */ Vec3s morphTable[RU2_LIMB_MAX]; + /* 0x312 */ Vec3s trackTarget; + /* 0x318 */ Vec3s headRot; + /* 0x31E */ Vec3s torsoRot; + /* 0x324 */ UNK_TYPE1 pad324[0x12]; + /* 0x336 */ s16 limbRotTableY[RU2_LIMB_MAX]; + /* 0x364 */ s16 limbRotTableZ[RU2_LIMB_MAX]; + /* 0x394 */ Vec3f bodyPartsPos[RU_BODYPARTSPOS_COUNT]; + /* 0x348 */ UNK_TYPE1 padUNK[6]; + /* 0x44E */ s16 eyeState; + /* 0x450 */ s16 blinkTimer; } EnRu; // size = 0x454 extern const ActorInit En_Ru_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 331f5c193..3984924be 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10254,17 +10254,17 @@ 0x80A3862C:("DmZl_OverrideLimbDraw",), 0x80A38648:("DmZl_PostLimbDraw",), 0x80A3869C:("DmZl_Draw",), - 0x80A389A0:("func_80A389A0",), - 0x80A38A68:("func_80A38A68",), - 0x80A38B7C:("func_80A38B7C",), - 0x80A38BF0:("func_80A38BF0",), - 0x80A38C70:("func_80A38C70",), - 0x80A38DF4:("func_80A38DF4",), + 0x80A389A0:("EnRu_ChangeAnim",), + 0x80A38A68:("EnRu_PlayWalkingSound",), + 0x80A38B7C:("EnRu_UpdateEyes",), + 0x80A38BF0:("EnRu_UpdateCollider",), + 0x80A38C70:("EnRu_UpdateModel",), + 0x80A38DF4:("EnRu_DoNothing",), 0x80A38E04:("EnRu_Init",), 0x80A38F10:("EnRu_Destroy",), 0x80A38F3C:("EnRu_Update",), - 0x80A38FB4:("func_80A38FB4",), - 0x80A390F8:("func_80A390F8",), + 0x80A38FB4:("EnRu_OverrideLimbdraw",), + 0x80A390F8:("EnRu_PostLimbdraw",), 0x80A39204:("EnRu_Draw",), 0x80A396B0:("func_80A396B0",), 0x80A3970C:("EnElfgrp_Init",), From 08be0b3bd4f8c2e7955e94dd2714e1c8e4ef9594 Mon Sep 17 00:00:00 2001 From: Karen Craig Date: Thu, 29 Sep 2022 21:23:59 -0400 Subject: [PATCH 53/73] EnTg OK and documented, object_mu documented (#1042) * EnTg_Init matches * Destroy matches * Cleanup header, add commented out functions * EnTg_Update matches * Match another function * Working on func_8098FEA8 * Almost match function, format * Match func_8098FEA8 * Match func_8098F8A8 * EnTg_Draw matches * Match func_8099000C * Match func_8098FBB4, almost got func_8098FBD0? * Match func_8098FBD0 * Match func_8098F800 * Working on func_8098FA70 * figured out one other block, at least * A little closer * Match func_8098FA70 with help from discord yay * Match func_8098FD50 * Add extern data i missed * Prep for data * Replace data from objects_mu.h * Add data * Remove comments' * Rename two draw functions * Run format.sh * Fix space * Rename global static variables * Renamings to match master * Undo some renamings to get diff * Name variables in func_8098F800 * Rename EnTg_ChangeAnimation * Rename UpdateCollider * Add comments for me * More renaming * Renaming * Lots of renaming struct vars * Rename heartStartPos * Rename EnTgHeartInfo * Rename heart stuff * Cleanup comments * Comment cleanup * Rename functions * Remove commeneted out bit of spec * Naming things in object_mu * Name animations * Name dlists * Name textures * Finish naming textures * Comments * Format * Fix name from merging * Revert rename_sym mac changes * Cleanup and remove static data * cleanup comments * Whoops, fix spec file * Rename heart DLs * Apply suggestions from code review Co-authored-by: Derek Hensley * Fixing renamed things * Format * Fix struct * Standardize Effect struct naming * More renaming and cleanup * Apply suggestions from code review Co-authored-by: Derek Hensley * Format * Rename gEffHeartText * Format * Rename LowerArm -> Forearm * Apply suggestions from code review Co-authored-by: Tom Overton * Rename enTgHeartEffect -> effects * Cleanup structs * Rename gDropRecoveryHeartTex * Rename individual EnTgHeartEffect as effect singular, rename len to numEffects * Rename heartVelocityVec -> heartVelocity and flag -> isMaterialApplied * Remove struct address leading zeros, use UNK_TYPE1 type * Rename EnTg_DrawHeart -> EnTg_DrawHearts * Replace unused variable with pad * Remove extra header, make sAnimationInfo a list Co-authored-by: Derek Hensley Co-authored-by: Tom Overton --- assets/xml/objects/object_mu.xml | 117 ++++++------ spec | 3 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 22 +-- src/overlays/actors/ovl_En_Tg/z_en_tg.c | 230 ++++++++++++++++++++---- src/overlays/actors/ovl_En_Tg/z_en_tg.h | 20 ++- tools/disasm/functions.txt | 18 +- 6 files changed, 299 insertions(+), 111 deletions(-) diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index 1f246b07b..37886e8f5 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -1,62 +1,63 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 48b1695ac..0b500363a 100644 --- a/spec +++ b/spec @@ -2029,8 +2029,7 @@ beginseg name "ovl_En_Tg" compress include "build/src/overlays/actors/ovl_En_Tg/z_en_tg.o" - include "build/data/ovl_En_Tg/ovl_En_Tg.data.o" - include "build/data/ovl_En_Tg/ovl_En_Tg.reloc.o" + include "build/src/overlays/actors/ovl_En_Tg/ovl_En_Tg_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 1704451ec..8ab640253 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -74,13 +74,13 @@ static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; static AnimationInfo sAnimationInfo[] = { - { &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 }, + { &gHoneyAndDarlingIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingCupCheeksLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingHugLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingGameDanceLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHoneyAndDarlingHoldHandsLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gHoneyAndDarlingHoldHandsLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHoneyAndDarlingSurpiseAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -194,8 +194,8 @@ void EnFu_Init(Actor* thisx, PlayState* play) { if (fuKaiten != NULL) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_mu_Skel_00B2B0, &object_mu_Anim_001F74, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(play, &this->skelAnime, &gHoneyAndDarlingSkel, &gHoneyAndDarlingCupCheeksLoopAnim, + this->jointTable, this->morphTable, HONEY_AND_DARLING_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -1454,7 +1454,7 @@ void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len) { for (i = 0; i < len; i++, ptr++) { if (ptr->unk_36 == 1) { if (!flag) { - gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0A0); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartMaterialDL); flag = true; } Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); @@ -1463,7 +1463,7 @@ void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0E0); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartModelDL); } } 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 c090a050d..f4c970ea8 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -1,10 +1,11 @@ /* * File: z_en_tg.c * Overlay: ovl_En_Tg - * Description: Target Game (Honey & Darling) + * Description: Target Game (Honey & Darling) - End Credits Scene */ #include "z_en_tg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,9 +16,11 @@ void EnTg_Destroy(Actor* thisx, PlayState* play); void EnTg_Update(Actor* thisx, PlayState* play); void EnTg_Draw(Actor* thisx, PlayState* play); -void func_8098FA70(EnTg* this, PlayState* play); +void EnTg_Idle(EnTg* this, PlayState* play); +void EnTg_UpdateHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects); +void EnTg_DrawHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects); +void EnTg_SpawnHeart(EnTg* this, EnTgHeartEffect* effect, Vec3f* heartStartPos, s32 numEffects); -#if 0 const ActorInit En_Tg_InitVars = { ACTOR_EN_TG, ACTORCAT_NPC, @@ -30,18 +33,29 @@ const ActorInit En_Tg_InitVars = { (ActorFunc)EnTg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809901C0 = { - { 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_809901EC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809901F8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -76,37 +90,193 @@ static DamageTable D_809901F8 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gHoneyAndDarlingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_809901C0; -extern CollisionCheckInfoInit2 D_809901EC; -extern DamageTable D_809901F8; +void EnTg_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s16 animIndex) { + f32 endFrame; -extern UNK_TYPE D_0600B0E0; -extern UNK_TYPE D_0600B2B0; + animationInfo += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F800.s") + if (animationInfo->frameCount < 0) { + endFrame = Animation_GetLastFrame(animationInfo->animation); + } else { + endFrame = animationInfo->frameCount; + } + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F8A8.s") +void EnTg_UpdateCollider(EnTg* this, PlayState* play) { + 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(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F928.s") +void EnTg_UpdateSkelAnime(EnTg* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Init.s") +void EnTg_Init(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gHoneyAndDarlingSkel, NULL, this->jointTable, this->morphTable, + HONEY_AND_DARLING_LIMB_MAX); + EnTg_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnTg_Idle; + this->actor.gravity = -4.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FA70.s") +void EnTg_Destroy(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Update.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FBB4.s") +/** + * The actor spins, and a heart is spawned above the actor every 12 frames. + */ +void EnTg_Idle(EnTg* this, PlayState* play) { + Vec3f heartStartPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FBD0.s") + this->actor.shape.rot.y += sREG(0) + 0x258; + this->actor.world.rot = this->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Draw.s") + if (DECR(this->spawnHeartTimer) == 0) { + this->spawnHeartTimer = 12; + heartStartPos = this->actor.world.pos; + heartStartPos.y += 62.0f; + EnTg_SpawnHeart(this, this->effects, &heartStartPos, ARRAY_COUNT(this->effects)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FD50.s") +void EnTg_Update(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FEA8.s") + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnTg_UpdateSkelAnime(this, play); + EnTg_UpdateHearts(play, this->effects, ARRAY_COUNT(this->effects)); + EnTg_UpdateCollider(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8099000C.s") +s32 EnTg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnTg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTg* this = THIS; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == HONEY_AND_DARLING_LIMB_MAN_HEAD) { + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); + } +} + +void EnTg_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnTg* this = THIS; + + Matrix_Push(); + EnTg_DrawHearts(play, this->effects, ARRAY_COUNT(this->effects)); + Matrix_Pop(); + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 0, 50, 160, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 255, 255, 255, 0)); + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTg_OverrideLimbDraw, EnTg_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Spawns a heart at the first effects array index that's not enabled. + * Because of the frame counts, only two hearts are ever spawned at a time. + */ +void EnTg_SpawnHeart(EnTg* this, EnTgHeartEffect* effect, Vec3f* heartStartPos, s32 numEffects) { + Vec3f heartVelocity = { 0.0f, 1.5f, 0.0f }; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 i; + + for (i = 0; i < numEffects && effect->isEnabled; i++, effect++) {} + + if (i < numEffects) { + effect->isEnabled = true; + effect->pos = *heartStartPos; + effect->velocity = heartVelocity; + effect->unusedZeroVec = zeroVec; + effect->scale = 0.01f; + effect->pos.x += 4.0f * Math_SinS(this->actor.shape.rot.y); + effect->pos.z += 4.0f * Math_CosS(this->actor.shape.rot.y); + effect->timer = 16; + } +} + +/** + * The heart path is curvy as it floats up because of the use of Math_SinS and Math_CosS. + */ +void EnTg_UpdateHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); + s32 i; + + for (i = 0; i < numEffects; i++, effect++) { + if (effect->isEnabled == true) { + if (DECR(effect->timer) == 0) { + effect->isEnabled = false; + } + effect->pos.y += effect->velocity.y; + effect->pos.x += 2.0f * Math_SinS(effect->angle); + effect->pos.z += 2.0f * Math_CosS(effect->angle); + + Matrix_Push(); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYS(yaw, MTXMODE_APPLY); + Matrix_MultVec3f(&zeroVec, &effect->pos); + Matrix_Pop(); + + effect->angle += 0x1770; + } + } +} + +void EnTg_DrawHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects) { + s32 i; + s32 isMaterialApplied = false; + + OPEN_DISPS(play->state.gfxCtx); + + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + for (i = 0; i < numEffects; i++, effect++) { + if (effect->isEnabled == true) { + if (!isMaterialApplied) { + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartMaterialDL); + isMaterialApplied = true; + } + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartModelDL); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.h b/src/overlays/actors/ovl_En_Tg/z_en_tg.h index 2798b99b3..3cdcb57f1 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.h +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.h @@ -2,15 +2,33 @@ #define Z_EN_TG_H #include "global.h" +#include "objects/object_mu/object_mu.h" struct EnTg; typedef void (*EnTgActionFunc)(struct EnTg*, PlayState*); +typedef struct EnTgHeartEffect { + /* 0x00 */ u8 isEnabled; + /* 0x01 */ u8 timer; + /* 0x04 */ f32 scale; + /* 0x08 */ UNK_TYPE1 unk8[0xC]; + /* 0x14 */ Vec3f pos; + /* 0x20 */ Vec3f unusedZeroVec; + /* 0x2C */ Vec3f velocity; + /* 0x38 */ s16 angle; +} EnTgHeartEffect; // size = 0x3C + typedef struct EnTg { /* 0x000 */ Actor actor; /* 0x144 */ EnTgActionFunc actionFunc; - /* 0x148 */ char unk_148[0x400]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 unk1D8[0x18]; + /* 0x1F0 */ Vec3s jointTable[HONEY_AND_DARLING_LIMB_MAX]; + /* 0x26E */ Vec3s morphTable[HONEY_AND_DARLING_LIMB_MAX]; + /* 0x2EC */ s16 spawnHeartTimer; + /* 0x2F0 */ EnTgHeartEffect effects[10]; } EnTg; // size = 0x548 extern const ActorInit En_Tg_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3984924be..4526760d5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8412,19 +8412,19 @@ 0x8098F66C:("func_8098F66C",), 0x8098F680:("func_8098F680",), 0x8098F6FC:("ObjMure3_Update",), - 0x8098F800:("func_8098F800",), - 0x8098F8A8:("func_8098F8A8",), - 0x8098F928:("func_8098F928",), + 0x8098F800:("EnTg_ChangeAnim",), + 0x8098F8A8:("EnTg_UpdateCollider",), + 0x8098F928:("EnTg_UpdateSkelAnime",), 0x8098F954:("EnTg_Init",), 0x8098FA44:("EnTg_Destroy",), - 0x8098FA70:("func_8098FA70",), + 0x8098FA70:("EnTg_Idle",), 0x8098FB28:("EnTg_Update",), - 0x8098FBB4:("func_8098FBB4",), - 0x8098FBD0:("func_8098FBD0",), + 0x8098FBB4:("EnTg_OverrideLimbDraw",), + 0x8098FBD0:("EnTg_PostLimbDraw",), 0x8098FC2C:("EnTg_Draw",), - 0x8098FD50:("func_8098FD50",), - 0x8098FEA8:("func_8098FEA8",), - 0x8099000C:("func_8099000C",), + 0x8098FD50:("EnTg_SpawnHeart",), + 0x8098FEA8:("EnTg_UpdateHearts",), + 0x8099000C:("EnTg_DrawHearts",), 0x80990310:("EnWf_Init",), 0x80990784:("EnWf_Destroy",), 0x809907D4:("func_809907D4",), From 3a723efb15c4d3e044edda7979b1cde5588c0aeb Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 29 Sep 2022 19:22:59 -0700 Subject: [PATCH 54/73] SceneNum -> SceneId (#1036) * sceneNum -> sceneId * horse data scene -> sceneId * Clean up scene table * format * PR comments * Some more * It helps if you actually save the file * PR * Remove comment * Format * Conflicts --- include/functions.h | 8 +- include/variables.h | 2 +- include/z64.h | 2 +- include/z64save.h | 4 +- include/z64scene.h | 2 +- include/z64schedule.h | 12 +- src/code/code_8012EC80.c | 54 +- src/code/z_actor.c | 6 +- src/code/z_bgcheck.c | 14 +- src/code/z_elf_message.c | 4 +- src/code/z_map_exp.c | 26 +- src/code/z_message.c | 2 +- src/code/z_message_nes.c | 2 +- src/code/z_parameter.c | 14 +- src/code/z_play.c | 26 +- src/code/z_player_lib.c | 2 +- src/code/z_room.c | 3 +- src/code/z_scene.c | 16 +- src/code/z_scene_table.c | 1275 +++++++++-------- src/code/z_schedule.c | 8 +- src/code/z_snap.c | 4 +- src/code/z_sram_NES.c | 20 +- src/code/z_vr_box.c | 2 +- src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c | 2 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 2 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 6 +- .../actors/ovl_Dm_Char02/z_dm_char02.c | 2 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 4 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 2 +- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 28 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 10 +- .../actors/ovl_Door_Spiral/z_door_spiral.c | 4 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 46 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 4 +- src/overlays/actors/ovl_En_Bat/z_en_bat.c | 2 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 2 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 12 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 10 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 2 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 4 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 4 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 12 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 9 +- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 5 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 18 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 8 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 4 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 2 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 6 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 16 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 6 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 4 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 16 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 4 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 2 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 12 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 10 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 12 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 4 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 20 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 4 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 3 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 2 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 6 +- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 4 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 2 +- .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 4 +- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 5 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 2 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 10 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 2 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 16 +- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 2 +- .../actors/ovl_Obj_Wturn/z_obj_wturn.c | 6 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 2 +- tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 4 +- tools/namefixer.py | 1 + tools/sizes/code_functions.csv | 6 +- 90 files changed, 975 insertions(+), 964 deletions(-) diff --git a/include/functions.h b/include/functions.h index 8396d4a41..05fd4ed45 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2087,7 +2087,7 @@ s32 Inventory_GetBtnBItem(PlayState* play); void Inventory_ChangeEquipment(s16 value); u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment); void Inventory_ChangeUpgrade(s16 upgrade, u32 value); -s32 Inventory_IsMapVisible(s16 sceneNum); +s32 Inventory_IsMapVisible(s16 sceneId); void Inventory_SetMapVisibility(s16 tingleIndex); void Inventory_SaveDekuPlaygroundHighScore(s16 timerId); void Inventory_IncrementSkullTokenCount(s16 sceneIndex); @@ -2173,8 +2173,8 @@ void Scene_DrawConfig5(PlayState* play); void Scene_DrawConfigMatAnimManualStep(PlayState* play); void Scene_DrawConfigGreatBayTemple(PlayState* play); EntranceTableEntry* Entrance_GetTableEntry(u16 entrance); -s32 Entrance_GetSceneNum(u16 entrance); -s32 Entrance_GetSceneNumAbsolute(u16 entrance); +s32 Entrance_GetSceneId(u16 entrance); +s32 Entrance_GetSceneIdAbsolute(u16 entrance); s32 Entrance_GetSpawnNum(u16 entrance); s32 Entrance_GetTransitionFlags(u16 entrance); s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output); @@ -2557,7 +2557,7 @@ s32 Play_ChangeCameraSetting(PlayState* play, s16 camId, s16 setting); void func_80169AFC(PlayState* play, s16 camId, s16 arg2); u16 Play_GetActorCsCamSetting(PlayState* play, s32 csCamDataIndex); Vec3s* Play_GetActorCsCamFuncData(PlayState* play, s32 csCamDataIndex); -s16 Play_GetOriginalSceneNumber(s16 sceneNum); +s16 Play_GetOriginalSceneId(s16 sceneId); 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); diff --git a/include/variables.h b/include/variables.h index 1ee739c4a..07e80b2ca 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1312,7 +1312,7 @@ extern u32 gGsFlagsShift[]; extern void* gItemIcons[]; extern u8 gItemSlots[]; extern s16 gItemPrices[]; -extern u16 gScenesPerRegion[11][27]; +extern u16 gSceneIdsPerRegion[11][27]; extern u32 D_801C2410[]; extern s16 gPlayerFormObjectIndices[8]; extern RomFile gObjectTable[643]; diff --git a/include/z64.h b/include/z64.h index e161b723f..69e89d629 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1084,7 +1084,7 @@ typedef struct { struct PlayState { /* 0x00000 */ GameState state; - /* 0x000A4 */ s16 sceneNum; + /* 0x000A4 */ s16 sceneId; /* 0x000A6 */ u8 sceneConfig; /* 0x000A7 */ char unk_A7[0x9]; /* 0x000B0 */ void* sceneSegment; diff --git a/include/z64save.h b/include/z64save.h index fc24aa5b6..15984d45c 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -165,7 +165,7 @@ typedef struct Inventory { } Inventory; // size = 0x88 typedef struct HorseData { - /* 0x0 */ s16 scene; // "spot_no" + /* 0x0 */ s16 sceneId; // "spot_no" /* 0x2 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" /* 0x8 */ s16 yaw; // "horse_a" } HorseData; // size = 0xA @@ -226,7 +226,7 @@ typedef struct SavePlayerData { /* 0x20 */ u8 unk_20; // "first_memory" /* 0x22 */ u16 owlActivationFlags; // "memory_warp_point" /* 0x24 */ u8 unk_24; // "last_warp_pt" - /* 0x26 */ s16 savedSceneNum; // "scene_data_ID" + /* 0x26 */ s16 savedSceneId; // "scene_data_ID" } SavePlayerData; // size = 0x28 typedef struct Save { diff --git a/include/z64scene.h b/include/z64scene.h index 180405f30..6b8849381 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -316,7 +316,7 @@ typedef struct { } EntranceEntry; // size = 0x2 typedef struct { - /* 0x0 */ s8 sceneNum; + /* 0x0 */ s8 sceneId; /* 0x1 */ s8 spawnNum; /* 0x2 */ u16 flags; } EntranceTableEntry; // size = 0x4 diff --git a/include/z64schedule.h b/include/z64schedule.h index cff6224f4..69906e584 100644 --- a/include/z64schedule.h +++ b/include/z64schedule.h @@ -42,8 +42,8 @@ typedef enum { /* 0x07 */ SCHEDULE_CMD_ID_NOP, // No-Op /* 0x08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch /* 0x09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value - /* 0x0A */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch - /* 0x0B */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch + /* 0x0A */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneId and branches if so, short range branch + /* 0x0B */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneId and branches if so, long range branch /* 0x0C */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch /* 0x0D */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch /* 0x0E */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values @@ -130,15 +130,15 @@ typedef struct { typedef struct { /* 0x0 */ ScheduleCmdBase base; - /* 0x1 */ u8 sceneH; - /* 0x2 */ u8 sceneL; + /* 0x1 */ u8 sceneIdH; + /* 0x2 */ u8 sceneIdL; /* 0x3 */ s8 offset; } ScheduleCmdCheckNotInSceneS; // size = 0x4 typedef struct { /* 0x0 */ ScheduleCmdBase base; - /* 0x1 */ u8 sceneH; - /* 0x2 */ u8 sceneL; + /* 0x1 */ u8 sceneIdH; + /* 0x2 */ u8 sceneIdL; /* 0x3 */ u8 offsetH; /* 0x4 */ u8 offsetL; } ScheduleCmdCheckNotInSceneL; // size = 0x5 diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index a29a8279e..278ef0830 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -365,7 +365,7 @@ s16 gItemPrices[] = { }; // Used to map scene indexes to their region in Termina -u16 gScenesPerRegion[11][27] = { +u16 gSceneIdsPerRegion[11][27] = { // Great Bay { SCENE_30GYOSON, @@ -522,7 +522,7 @@ void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { gSaveContext.save.inventory.upgrades = upgrades; } -s32 Inventory_IsMapVisible(s16 sceneNum) { +s32 Inventory_IsMapVisible(s16 sceneId) { s16 index = 0; /** @@ -530,30 +530,30 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { * increment to the next index of scenesVisible so that every scene gets a unique flag in scenesVisible, * 224 bits were allocated to this although there are only 112 scenes */ - if (sceneNum >= 0x20) { - if (sceneNum < 0x40) { + if (sceneId >= 0x20) { + if (sceneId < 0x40) { index = 1; - } else if (sceneNum < 0x60) { + } else if (sceneId < 0x60) { index = 2; - } else if (sceneNum < 0x80) { + } else if (sceneId < 0x80) { index = 3; - } else if (sceneNum < 0xA0) { + } else if (sceneId < 0xA0) { index = 4; - } else if (sceneNum < 0xC0) { + } else if (sceneId < 0xC0) { index = 5; - } else if (sceneNum < 0xE0) { + } else if (sceneId < 0xE0) { index = 6; } } - if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneId - (index << 5)]) { return true; } return false; } -static u16 sScenesPerTingleMap[6][12] = { +static u16 sSceneIdsPerTingleMap[6][12] = { { // Clock Town Tingle Map SCENE_00KEIKOKU, @@ -630,11 +630,11 @@ static u16 sScenesPerTingleMap[6][12] = { void Inventory_SetMapVisibility(s16 tingleIndex) { s16 i = 0; s16 index = 0; - u16(*tingleMapSceneIndices)[] = &sScenesPerTingleMap[tingleIndex]; + u16(*tingleMapSceneIds)[] = &sSceneIdsPerTingleMap[tingleIndex]; if ((tingleIndex >= 0) && (tingleIndex < 6)) { while (true) { - if ((*tingleMapSceneIndices)[i] == 0xFFFF) { + if ((*tingleMapSceneIds)[i] == 0xFFFF) { break; } @@ -643,38 +643,38 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { * increment to the next index of scenesVisible so that every scene gets a unique flag in scenesVisible, * 224 bits were allocated to this although there are only 112 scenes */ - if (((s16)(*tingleMapSceneIndices)[i]) < 0x20) { + if (((s16)(*tingleMapSceneIds)[i]) < 0x20) { index = 0; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x40) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x40) { index = 1; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x60) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x60) { index = 2; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x80) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x80) { index = 3; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xA0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xA0) { index = 4; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xC0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xC0) { index = 5; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xE0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xE0) { index = 6; } gSaveContext.save.scenesVisible[index] = - gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIds)[i] - (index << 5)]; i++; } - if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { + if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[0]) { gSaveContext.save.mapsVisible |= 3; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { + } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[1]) { gSaveContext.save.mapsVisible |= 0x1C; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { + } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[2]) { gSaveContext.save.mapsVisible |= 0xE0; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { + } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[3]) { gSaveContext.save.mapsVisible |= 0x100; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { + } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[4]) { gSaveContext.save.mapsVisible |= 0x1E00; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { + } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[5]) { gSaveContext.save.mapsVisible |= 0x6000; } } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 0195ac650..e82e5d2b9 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2235,7 +2235,7 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto s32 i; gSaveContext.save.weekEventReg[92] |= 0x80; - cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)]; + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneId(play->sceneId)]; bzero(actorCtx, sizeof(ActorContext)); ActorOverlayTable_Init(); @@ -2252,8 +2252,8 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto actorCtx->sceneFlags.chest = cycleFlags->chest; actorCtx->sceneFlags.switches[0] = cycleFlags->switch0; actorCtx->sceneFlags.switches[1] = cycleFlags->switch1; - if (play->sceneNum == SCENE_INISIE_R) { - cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneNum]; + if (play->sceneId == SCENE_INISIE_R) { + cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneId]; } actorCtx->sceneFlags.collectible[0] = cycleFlags->collectible; actorCtx->sceneFlags.clearedRoom = cycleFlags->clearedRoom; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index f9b23ac79..130fdc970 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -47,7 +47,7 @@ u8 D_801B46C0[] = { /* 0x0E */ 1 }; -s16 sSmallMemScenes[] = { +s16 sSmallMemSceneIds[] = { SCENE_F01, }; @@ -1463,10 +1463,10 @@ u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLo * Returns whether the current scene should reserve less memory for it's collision lookup */ s32 BgCheck_IsSmallMemScene(PlayState* play) { - s16* i; + s16* sceneId; - for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) { - if (play->sceneNum == *i) { + for (sceneId = sSmallMemSceneIds; sceneId < sSmallMemSceneIds + ARRAY_COUNT(sSmallMemSceneIds); sceneId++) { + if (play->sceneId == *sceneId) { return true; } } @@ -1505,7 +1505,7 @@ s32 BgCheck_GetSpecialSceneMaxObjects(PlayState* play, s32* maxNodes, s32* maxPo s32 i; for (i = 0; i < ARRAY_COUNT(sCustomDynapolyMem); i++) { - if (play->sceneNum == sCustomDynapolyMem[i].sceneId) { + if (play->sceneId == sCustomDynapolyMem[i].sceneId) { *maxNodes = sCustomDynapolyMem[i].maxNodes; *maxPolygons = sCustomDynapolyMem[i].maxPolygons; *maxVertices = sCustomDynapolyMem[i].maxVertices; @@ -1542,7 +1542,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader s32 useCustomSubdivisions; s32 i; - if (BgCheck_TryGetCustomMemsize(play->sceneNum, &customMemSize)) { + if (BgCheck_TryGetCustomMemsize(play->sceneId, &customMemSize)) { colCtx->memSize = customMemSize; } else { colCtx->memSize = 0x23000; @@ -1555,7 +1555,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader useCustomSubdivisions = false; for (i = 0; i < ARRAY_COUNT(sSceneSubdivisionList); i++) { - if (play->sceneNum == sSceneSubdivisionList[i].sceneId) { + if (play->sceneId == sSceneSubdivisionList[i].sceneId) { colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x; colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y; colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 25d6f8ca8..11e4a2743 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -20,7 +20,7 @@ u16 ElfMessage_GetFirstCycleHint(PlayState* play) { if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } - if (play->sceneNum == SCENE_YOUSEI_IZUMI) { + if (play->sceneId == SCENE_YOUSEI_IZUMI) { return 0; } return 0x21D; @@ -29,7 +29,7 @@ u16 ElfMessage_GetFirstCycleHint(PlayState* play) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { - if (play->sceneNum != SCENE_OKUJOU) { + if (play->sceneId != SCENE_OKUJOU) { return 0x244; } return 0; diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index ffad44e6e..2b5eb1aac 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -5,7 +5,7 @@ s16 sMinimapInitPosX = 0; s16 sMinimapInitPosZ = 0; s16 sMinimapInitDir = 0; -s32 sDungeonAndBossScenes[] = { +s32 sDungeonAndBossSceneIds[] = { SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, SCENE_MITURIN_BS, SCENE_HAKUGIN_BS, SCENE_SEA_BS, SCENE_INISIE_BS, }; @@ -17,8 +17,8 @@ s32 sDungeonAndBossScenes[] = { s32 Map_GetDungeonOrBossAreaIndex(PlayState* play) { s32 i; - for (i = 0; i < ARRAY_COUNT(sDungeonAndBossScenes); i++) { - if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonAndBossScenes[i]) { + for (i = 0; i < ARRAY_COUNT(sDungeonAndBossSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sDungeonAndBossSceneIds[i]) { return i; } } @@ -45,7 +45,7 @@ s32 func_8010A0A4(PlayState* play) { return true; } -s32 sDungeonScenes[] = { +s32 sDungeonSceneIds[] = { SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, }; @@ -56,8 +56,8 @@ s32 sDungeonScenes[] = { s32 Map_GetDungeonAreaIndex(PlayState* play) { s32 i; - for (i = 0; i < ARRAY_COUNT(sDungeonScenes); i++) { - if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonScenes[i]) { + for (i = 0; i < ARRAY_COUNT(sDungeonSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sDungeonSceneIds[i]) { return i; } } @@ -76,7 +76,7 @@ s32 Map_IsInDungeonArea(PlayState* play) { return true; } -s32 sBossScenes[] = { +s32 sBossSceneIds[] = { SCENE_MITURIN_BS, // DUNGEON_INDEX_WOODFALL_TEMPLE SCENE_HAKUGIN_BS, // DUNGEON_INDEX_SNOWHEAD_TEMPLE SCENE_SEA_BS, // DUNGEON_INDEX_GREAT_BAY_TEMPLE @@ -90,8 +90,8 @@ s32 sBossScenes[] = { s32 Map_GetBossAreaIndex(PlayState* play) { s32 i; - for (i = 0; i < ARRAY_COUNT(sBossScenes); i++) { - if (Play_GetOriginalSceneNumber(play->sceneNum) == sBossScenes[i]) { + for (i = 0; i < ARRAY_COUNT(sBossSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sBossSceneIds[i]) { return i; } } @@ -120,7 +120,7 @@ s32 func_8010A238(PlayState* play) { s32 i; for (i = 0; i < ARRAY_COUNT(D_801BF5A4); i++) { - if (Play_GetOriginalSceneNumber(play->sceneNum) == D_801BF5A4[i]) { + if (Play_GetOriginalSceneId(play->sceneId) == D_801BF5A4[i]) { return i; } } @@ -156,7 +156,7 @@ void Map_InitRoomData(PlayState* play, s16 room) { if (room >= 0) { if (Map_IsInDungeonOrBossArea(play)) { - gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].rooms |= gBitFlags[room]; + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].rooms |= gBitFlags[room]; interfaceCtx->mapRoomNum = room; interfaceCtx->dungeonOrBossAreaMapIndex = mapIndex; } @@ -189,7 +189,7 @@ void Map_Init(PlayState* play) { if (Map_IsInDungeonOrBossArea(play)) { dungeonIndex = Map_GetDungeonOrBossAreaIndex(play); gSaveContext.mapIndex = dungeonIndex; - switch (play->sceneNum) { + switch (play->sceneId) { case SCENE_MITURIN_BS: dungeonIndex = DUNGEON_INDEX_WOODFALL_TEMPLE; break; @@ -243,7 +243,7 @@ void Map_Update(PlayState* play) { if (Map_IsInDungeonArea(play)) { floor = func_80109124(player->actor.world.pos.y); if (floor != -1) { - gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].unk_14 |= + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].unk_14 |= gBitFlags[FLOOR_INDEX_MAX - floor]; XREG(94) = FLOOR_INDEX_MAX - floor; if (interfaceCtx->mapRoomNum != sLastRoomNum) { diff --git a/src/code/z_message.c b/src/code/z_message.c index 4b4ac82a5..cb00d8cd2 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -267,7 +267,7 @@ void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { s16 phi_v0; s16 phi_s0; - if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) { + if ((func_8010A0A4(play) != 0) || (play->sceneId == SCENE_SECOM)) { phi_v0 = 0xA; } else { phi_v0 = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 1ac301f20..fef293b46 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -254,7 +254,7 @@ void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decod s16 currentArea; s16 stringLimit; - if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) { + if ((func_8010A0A4(play) != 0) || (play->sceneId == SCENE_SECOM)) { currentArea = 10; } else { currentArea = play->pauseCtx.cursorPoint[PAUSE_WORLD_MAP]; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index ef108c43a..eb110c0c7 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -621,7 +621,7 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { interfaceCtx->magicAlpha = risingAlpha; } - if (play->sceneNum == SCENE_SPOT00) { + if (play->sceneId == SCENE_SPOT00) { if (interfaceCtx->minimapAlpha < 170) { interfaceCtx->minimapAlpha = risingAlpha; } else { @@ -1173,7 +1173,7 @@ u8 Item_Give(PlayState* play, u8 item) { if (item == ITEM_SKULL_TOKEN) { SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_SKULL_TOKEN); - Inventory_IncrementSkullTokenCount(play->sceneNum); + Inventory_IncrementSkullTokenCount(play->sceneId); return ITEM_NONE; } else if (item == ITEM_TINGLE_MAP) { @@ -2863,7 +2863,7 @@ void Interface_DrawTimers(PlayState* play) { if (sTimerId == TIMER_ID_MOON_CRASH) { gSaveContext.save.day = 4; - if ((play->sceneNum == SCENE_OKUJOU) && (gSaveContext.sceneSetupIndex == 3)) { + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneSetupIndex == 3)) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; @@ -2892,7 +2892,7 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(120); gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); } - } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES) && + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES) && (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120))) { gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); } @@ -3001,7 +3001,7 @@ void Interface_DrawTimers(PlayState* play) { if (osTime >= SECONDS_TO_TIMER(120)) { osTime = SECONDS_TO_TIMER(120); } - } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES) && + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES) && (osTime >= SECONDS_TO_TIMER(120))) { osTime = SECONDS_TO_TIMER(120); } @@ -3018,7 +3018,7 @@ void Interface_DrawTimers(PlayState* play) { play_sound(NA_SE_SY_WARNING_COUNT_E); sTimerBeepSfxSeconds = sTimerDigits[4]; } - } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES)) { + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES)) { if ((((void)0, gSaveContext.timerCurTimes[sTimerId]) > (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) && (sTimerBeepSfxSeconds != sTimerDigits[4])) { @@ -3056,7 +3056,7 @@ void Interface_DrawTimers(PlayState* play) { } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); } - } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneNum == SCENE_DEKUTES)) { + } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES)) { if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); diff --git a/src/code/z_play.c b/src/code/z_play.c index 5a60a615e..bb04f23c0 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -302,38 +302,38 @@ Vec3s* Play_GetActorCsCamFuncData(PlayState* this, s32 csCamDataIndex) { * 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) { +s16 Play_GetOriginalSceneId(s16 sceneId) { // Inverted Stone Tower Temple -> Stone Tower Temple - if (sceneNum == SCENE_INISIE_R) { + if (sceneId == SCENE_INISIE_R) { return SCENE_INISIE_N; } // Purified Southern Swamp -> Poisoned Sothern Swamp - if (sceneNum == SCENE_20SICHITAI2) { + if (sceneId == SCENE_20SICHITAI2) { return SCENE_20SICHITAI; } // Spring Mountain Village -> Winter Mountain Village - if (sceneNum == SCENE_10YUKIYAMANOMURA2) { + if (sceneId == SCENE_10YUKIYAMANOMURA2) { return SCENE_10YUKIYAMANOMURA; } // Spring Goron Village -> Winter Goron Village - if (sceneNum == SCENE_11GORONNOSATO2) { + if (sceneId == SCENE_11GORONNOSATO2) { return SCENE_11GORONNOSATO; } // Spring Path to Goron Village -> Winter Path to Goron Village - if (sceneNum == SCENE_17SETUGEN2) { + if (sceneId == SCENE_17SETUGEN2) { return SCENE_17SETUGEN; } // Inverted Stone Tower -> Stone Tower - if (sceneNum == SCENE_F41) { + if (sceneId == SCENE_F41) { return SCENE_F40; } - return sceneNum; + return sceneId; } /** @@ -344,13 +344,13 @@ void Play_SaveCycleSceneFlags(GameState* thisx) { PlayState* this = (PlayState*)thisx; CycleSceneFlags* cycleSceneFlags; - cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(this->sceneNum)]; + cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneId(this->sceneId)]; cycleSceneFlags->chest = this->actorCtx.sceneFlags.chest; cycleSceneFlags->switch0 = this->actorCtx.sceneFlags.switches[0]; cycleSceneFlags->switch1 = this->actorCtx.sceneFlags.switches[1]; - if (this->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple - cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneNum]; + if (this->sceneId == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneId]; } cycleSceneFlags->collectible = this->actorCtx.sceneFlags.collectible[0]; @@ -375,7 +375,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) PlayState* this = (PlayState*)thisx; Player* player = GET_PLAYER(this); - if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos + if (this->sceneId != SCENE_KAKUSIANA) { // Grottos Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance), this->roomCtx.curRoom.num, playerParams, &player->actor.world.pos, player->actor.shape.rot.y); @@ -384,7 +384,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) // Override respawn data in Sakon's Hideout void func_80169ECC(PlayState* this) { - if (this->sceneNum == SCENE_SECOM) { + if (this->sceneId == SCENE_SECOM) { this->nextEntrance = ENTRANCE(IKANA_CANYON, 6); gSaveContext.respawnFlag = -7; } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 3da84fe78..0888be7c5 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -30,7 +30,7 @@ void func_80127B64(struct_801F58B0 arg0[], UNK_TYPE arg1, Vec3f* arg2); s32 func_801226E0(PlayState* play, s32 arg1) { if (arg1 == 0) { Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_DOWN, 0xBFF); - if (play->sceneNum == SCENE_KAKUSIANA) { + if (play->sceneId == SCENE_KAKUSIANA) { return 1; } } diff --git a/src/code/z_room.c b/src/code/z_room.c index e0c2a035d..e198e95ed 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -111,8 +111,7 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { func_80123140(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); - if (((play->sceneNum != SCENE_IKANA) || (roomCtx->curRoom.num != 1)) && - (play->sceneNum != SCENE_IKNINSIDE)) { + if (((play->sceneId != SCENE_IKANA) || (roomCtx->curRoom.num != 1)) && (play->sceneId != SCENE_IKNINSIDE)) { play->envCtx.lightSettingOverride = 0xFF; play->envCtx.unk_E0 = 0; } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 75616e8a5..a3a4e331d 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -28,12 +28,12 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { u32 spaceSize; s32 i; - if (play->sceneNum == SCENE_CLOCKTOWER || play->sceneNum == SCENE_TOWN || play->sceneNum == SCENE_BACKTOWN || - play->sceneNum == SCENE_ICHIBA) { + if (play->sceneId == SCENE_CLOCKTOWER || play->sceneId == SCENE_TOWN || play->sceneId == SCENE_BACKTOWN || + play->sceneId == SCENE_ICHIBA) { spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN; - } else if (play->sceneNum == SCENE_MILK_BAR) { + } else if (play->sceneId == SCENE_MILK_BAR) { spaceSize = OBJECT_SPACE_SIZE_MILK_BAR; - } else if (play->sceneNum == SCENE_00KEIKOKU) { + } else if (play->sceneId == SCENE_00KEIKOKU) { spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD; } else { spaceSize = OBJECT_SPACE_SIZE_DEFAULT; @@ -497,23 +497,23 @@ void Scene_HeaderCmdSetAreaVisitedFlag(PlayState* play, SceneCmd* cmd) { s16 i = 0; while (true) { - if (gScenesPerRegion[i][j] == 0xFFFF) { + if (gSceneIdsPerRegion[i][j] == 0xFFFF) { i++; j = 0; - if (i == ARRAY_COUNT(gScenesPerRegion)) { + if (i == ARRAY_COUNT(gSceneIdsPerRegion)) { break; } } - if (play->sceneNum == gScenesPerRegion[i][j]) { + if (play->sceneId == gSceneIdsPerRegion[i][j]) { break; } j++; } - if (i < ARRAY_COUNT(gScenesPerRegion)) { + if (i < ARRAY_COUNT(gSceneIdsPerRegion)) { gSaveContext.save.mapsVisited = (gBitFlags[i] | gSaveContext.save.mapsVisited) | gSaveContext.save.mapsVisited; } } diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 108689978..ed4549966 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -123,15 +123,15 @@ SceneTableEntry gSceneTable[] = { }; static EntranceTableEntry sMayorsResidenceEntrance0[] = { - { 0x12, 0x00, 0x4102 }, + { SCENE_SONCHONOIE, 0, 0x4102 }, }; static EntranceTableEntry sMayorsResidenceEntrance1[] = { - { 0x12, 0x01, 0x4102 }, + { SCENE_SONCHONOIE, 1, 0x4102 }, }; static EntranceTableEntry sMayorsResidenceEntrance2[] = { - { 0x12, 0x02, 0x4102 }, + { SCENE_SONCHONOIE, 2, 0x4102 }, }; static EntranceTableEntry* sMayorsResidenceEntranceTable[] = { @@ -141,7 +141,7 @@ static EntranceTableEntry* sMayorsResidenceEntranceTable[] = { }; static EntranceTableEntry sMajorasLairEntrance0[] = { - { 0xF5, 0x00, 0x0387 }, + { -SCENE_LAST_BS, 0, 0x0387 }, }; static EntranceTableEntry* sMajorasLairEntranceTable[] = { @@ -149,7 +149,7 @@ static EntranceTableEntry* sMajorasLairEntranceTable[] = { }; static EntranceTableEntry sMagicHagsPotionShopEntrance0[] = { - { 0x0A, 0x00, 0x4102 }, + { SCENE_WITCH_SHOP, 0, 0x4102 }, }; static EntranceTableEntry* sMagicHagsPotionShopEntranceTable[] = { @@ -157,11 +157,11 @@ static EntranceTableEntry* sMagicHagsPotionShopEntranceTable[] = { }; static EntranceTableEntry sRanchHouseEntrance0[] = { - { 0x10, 0x00, 0x0102 }, + { SCENE_OMOYA, 0, 0x0102 }, }; static EntranceTableEntry sRanchHouseEntrance1[] = { - { 0x10, 0x01, 0x4102 }, + { SCENE_OMOYA, 1, 0x4102 }, }; static EntranceTableEntry* sRanchHouseEntranceTable[] = { @@ -170,7 +170,7 @@ static EntranceTableEntry* sRanchHouseEntranceTable[] = { }; static EntranceTableEntry sHoneyAndDarlingsShopEntrance0[] = { - { 0x11, 0x00, 0x4102 }, + { SCENE_BOWLING, 0, 0x4102 }, }; static EntranceTableEntry* sHoneyAndDarlingsShopEntranceTable[] = { @@ -178,11 +178,11 @@ static EntranceTableEntry* sHoneyAndDarlingsShopEntranceTable[] = { }; static EntranceTableEntry sBeneathTheGraveryardEntrance0[] = { - { 0xF4, 0x00, 0x4102 }, + { -SCENE_HAKASHITA, 0, 0x4102 }, }; static EntranceTableEntry sBeneathTheGraveryardEntrance1[] = { - { 0xF4, 0x01, 0x4102 }, + { -SCENE_HAKASHITA, 1, 0x4102 }, }; static EntranceTableEntry* sBeneathTheGraveryardEntranceTable[] = { @@ -191,47 +191,47 @@ static EntranceTableEntry* sBeneathTheGraveryardEntranceTable[] = { }; static EntranceTableEntry sSouthernSwampClearedEntrance0[] = { - { 0x00, 0x00, 0xCA14 }, + { SCENE_20SICHITAI2, 0, 0xCA14 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance1[] = { - { 0x00, 0x01, 0x4102 }, + { SCENE_20SICHITAI2, 1, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance2[] = { - { 0x00, 0x02, 0xC102 }, + { SCENE_20SICHITAI2, 2, 0xC102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance3[] = { - { 0x00, 0x03, 0x4102 }, + { SCENE_20SICHITAI2, 3, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance4[] = { - { 0x00, 0x04, 0x4102 }, + { SCENE_20SICHITAI2, 4, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance5[] = { - { 0x00, 0x05, 0x4102 }, + { SCENE_20SICHITAI2, 5, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance6[] = { - { 0x00, 0x06, 0x0102 }, + { SCENE_20SICHITAI2, 6, 0x0102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance7[] = { - { 0x00, 0x07, 0x4102 }, + { SCENE_20SICHITAI2, 7, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance8[] = { - { 0x00, 0x08, 0x4102 }, + { SCENE_20SICHITAI2, 8, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance9[] = { - { 0x00, 0x09, 0x4A14 }, + { SCENE_20SICHITAI2, 9, 0x4A14 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance10[] = { - { 0x00, 0x0A, 0x4A14 }, + { SCENE_20SICHITAI2, 10, 0x4A14 }, }; static EntranceTableEntry* sSouthernSwampClearedEntranceTable[] = { @@ -242,19 +242,19 @@ static EntranceTableEntry* sSouthernSwampClearedEntranceTable[] = { }; static EntranceTableEntry sCuriosityShopEntrance0[] = { - { 0x0D, 0x00, 0x4102 }, + { SCENE_AYASHIISHOP, 0, 0x4102 }, }; static EntranceTableEntry sCuriosityShopEntrance1[] = { - { 0x0D, 0x01, 0x0102 }, + { SCENE_AYASHIISHOP, 1, 0x0102 }, }; static EntranceTableEntry sCuriosityShopEntrance2[] = { - { 0x0D, 0x02, 0x8A95 }, + { SCENE_AYASHIISHOP, 2, 0x8A95 }, }; static EntranceTableEntry sCuriosityShopEntrance3[] = { - { 0x0D, 0x03, 0x8102 }, + { SCENE_AYASHIISHOP, 3, 0x8102 }, }; static EntranceTableEntry* sCuriosityShopEntranceTable[] = { @@ -265,113 +265,113 @@ static EntranceTableEntry* sCuriosityShopEntranceTable[] = { }; static EntranceTableEntry sIkanaCanyonEntrance0[] = { - { 0x13, 0x00, 0xCA14 }, { 0x13, 0x00, 0x8A14 }, { 0x13, 0x00, 0x0A14 }, - { 0x13, 0x00, 0x4A14 }, { 0x13, 0x00, 0x8102 }, + { SCENE_IKANA, 0, 0xCA14 }, { SCENE_IKANA, 0, 0x8A14 }, { SCENE_IKANA, 0, 0x0A14 }, + { SCENE_IKANA, 0, 0x4A14 }, { SCENE_IKANA, 0, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance1[] = { - { 0x13, 0x01, 0x4102 }, - { 0x13, 0x01, 0x4102 }, - { 0x13, 0x01, 0xCA14 }, - { 0x13, 0x01, 0x4102 }, + { SCENE_IKANA, 1, 0x4102 }, + { SCENE_IKANA, 1, 0x4102 }, + { SCENE_IKANA, 1, 0xCA14 }, + { SCENE_IKANA, 1, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance2[] = { - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance3[] = { - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance4[] = { - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance5[] = { - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance6[] = { - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance7[] = { - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance8[] = { - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance9[] = { - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance10[] = { - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance11[] = { - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance12[] = { - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance13[] = { - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance14[] = { - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance15[] = { - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x0183 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x0183 }, }; static EntranceTableEntry* sIkanaCanyonEntranceTable[] = { @@ -382,66 +382,66 @@ static EntranceTableEntry* sIkanaCanyonEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressEntrance0[] = { - { 0x14, 0x00, 0x8102 }, - { 0x14, 0x00, 0x8102 }, - { 0x14, 0x00, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance1[] = { - { 0x14, 0x01, 0x8102 }, - { 0x14, 0x01, 0x8102 }, + { SCENE_KAIZOKU, 1, 0x8102 }, + { SCENE_KAIZOKU, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance2[] = { - { 0x14, 0x02, 0x8102 }, + { SCENE_KAIZOKU, 2, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance3[] = { - { 0x14, 0x03, 0x8102 }, + { SCENE_KAIZOKU, 3, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance4[] = { - { 0x14, 0x04, 0x8102 }, + { SCENE_KAIZOKU, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance5[] = { - { 0x14, 0x05, 0x8102 }, + { SCENE_KAIZOKU, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance6[] = { - { 0x14, 0x06, 0x8102 }, + { SCENE_KAIZOKU, 6, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance7[] = { - { 0x14, 0x07, 0x8102 }, + { SCENE_KAIZOKU, 7, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance8[] = { - { 0x14, 0x08, 0x8102 }, + { SCENE_KAIZOKU, 8, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance9[] = { - { 0x14, 0x09, 0x8102 }, + { SCENE_KAIZOKU, 9, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance10[] = { - { 0x14, 0x0A, 0x8A95 }, + { SCENE_KAIZOKU, 10, 0x8A95 }, }; static EntranceTableEntry sPiratesFortressEntrance11[] = { - { 0x14, 0x0B, 0x8102 }, + { SCENE_KAIZOKU, 11, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance12[] = { - { 0x14, 0x0C, 0x8102 }, + { SCENE_KAIZOKU, 12, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance13[] = { - { 0x14, 0x0D, 0x8102 }, + { SCENE_KAIZOKU, 13, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance14[] = { - { 0x14, 0x0E, 0x8102 }, + { SCENE_KAIZOKU, 14, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressEntranceTable[] = { @@ -452,8 +452,8 @@ static EntranceTableEntry* sPiratesFortressEntranceTable[] = { }; static EntranceTableEntry sMilkBarEntrance0[] = { - { 0x15, 0x00, 0x4102 }, { 0x15, 0x00, 0x8102 }, { 0x15, 0x00, 0x8102 }, - { 0x15, 0x00, 0x8102 }, { 0x15, 0x00, 0x8102 }, + { SCENE_MILK_BAR, 0, 0x4102 }, { SCENE_MILK_BAR, 0, 0x8102 }, { SCENE_MILK_BAR, 0, 0x8102 }, + { SCENE_MILK_BAR, 0, 0x8102 }, { SCENE_MILK_BAR, 0, 0x8102 }, }; static EntranceTableEntry* sMilkBarEntranceTable[] = { @@ -461,11 +461,11 @@ static EntranceTableEntry* sMilkBarEntranceTable[] = { }; static EntranceTableEntry sStoneTowerTempleEntrance0[] = { - { 0xEA, 0x00, 0xC102 }, + { -SCENE_INISIE_N, 0, 0xC102 }, }; static EntranceTableEntry sStoneTowerTempleEntrance1[] = { - { 0xEA, 0x01, 0x4102 }, + { -SCENE_INISIE_N, 1, 0x4102 }, }; static EntranceTableEntry* sStoneTowerTempleEntranceTable[] = { @@ -474,11 +474,11 @@ static EntranceTableEntry* sStoneTowerTempleEntranceTable[] = { }; static EntranceTableEntry sTreasureChestShopEntrance0[] = { - { 0x17, 0x00, 0x4102 }, + { SCENE_TAKARAYA, 0, 0x4102 }, }; static EntranceTableEntry sTreasureChestShopEntrance1[] = { - { 0x17, 0x01, 0x0102 }, + { SCENE_TAKARAYA, 1, 0x0102 }, }; static EntranceTableEntry* sTreasureChestShopEntranceTable[] = { @@ -487,15 +487,15 @@ static EntranceTableEntry* sTreasureChestShopEntranceTable[] = { }; static EntranceTableEntry sStoneTowerTempleInvertedEntrance0[] = { - { 0xE8, 0x00, 0xC102 }, + { -SCENE_INISIE_R, 0, 0xC102 }, }; static EntranceTableEntry sStoneTowerTempleInvertedEntrance1[] = { - { 0xE8, 0x01, 0x8102 }, + { -SCENE_INISIE_R, 1, 0x8102 }, }; static EntranceTableEntry sStoneTowerTempleInvertedEntrance2[] = { - { 0xE8, 0x02, 0x8102 }, + { -SCENE_INISIE_R, 2, 0x8102 }, }; static EntranceTableEntry* sStoneTowerTempleInvertedEntranceTable[] = { @@ -505,22 +505,22 @@ static EntranceTableEntry* sStoneTowerTempleInvertedEntranceTable[] = { }; static EntranceTableEntry sClockTowerRooftopEntrance0[] = { - { 0xE7, 0x00, 0x0102 }, - { 0xE7, 0x00, 0x8102 }, - { 0xE7, 0x00, 0x0102 }, - { 0xE7, 0x00, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x8102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, }; static EntranceTableEntry sClockTowerRooftopEntrance1[] = { - { 0xE7, 0x01, 0x0102 }, - { 0xE7, 0x01, 0x0102 }, - { 0xE7, 0x01, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, }; static EntranceTableEntry sClockTowerRooftopEntrance2[] = { - { 0xE7, 0x02, 0x858B }, - { 0xE7, 0x02, 0x858B }, - { 0xE7, 0x02, 0x8102 }, + { -SCENE_OKUJOU, 2, 0x858B }, + { -SCENE_OKUJOU, 2, 0x858B }, + { -SCENE_OKUJOU, 2, 0x8102 }, }; static EntranceTableEntry* sClockTowerRooftopEntranceTable[] = { @@ -530,24 +530,24 @@ static EntranceTableEntry* sClockTowerRooftopEntranceTable[] = { }; static EntranceTableEntry sOpeningDungeonEntrance0[] = { - { 0xE6, 0x00, 0x0102 }, - { 0xE6, 0x00, 0x8102 }, + { -SCENE_OPENINGDAN, 0, 0x0102 }, + { -SCENE_OPENINGDAN, 0, 0x8102 }, }; static EntranceTableEntry sOpeningDungeonEntrance1[] = { - { 0xE6, 0x01, 0x0102 }, + { -SCENE_OPENINGDAN, 1, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance2[] = { - { 0xE6, 0x02, 0x0102 }, + { -SCENE_OPENINGDAN, 2, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance3[] = { - { 0xE6, 0x03, 0x0102 }, + { -SCENE_OPENINGDAN, 3, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance4[] = { - { 0xE6, 0x04, 0x058B }, + { -SCENE_OPENINGDAN, 4, 0x058B }, }; static EntranceTableEntry* sOpeningDungeonEntranceTable[] = { @@ -556,15 +556,15 @@ static EntranceTableEntry* sOpeningDungeonEntranceTable[] = { }; static EntranceTableEntry sWoodfallTempleEntrance0[] = { - { 0xE5, 0x00, 0x4102 }, + { -SCENE_MITURIN, 0, 0x4102 }, }; static EntranceTableEntry sWoodfallTempleEntrance1[] = { - { 0xE5, 0x01, 0x0102 }, + { -SCENE_MITURIN, 1, 0x0102 }, }; static EntranceTableEntry sWoodfallTempleEntrance2[] = { - { 0xE5, 0x02, 0x0102 }, + { -SCENE_MITURIN, 2, 0x0102 }, }; static EntranceTableEntry* sWoodfallTempleEntranceTable[] = { @@ -574,13 +574,13 @@ static EntranceTableEntry* sWoodfallTempleEntranceTable[] = { }; static EntranceTableEntry sPathToMountainVillageEntrance0[] = { - { 0x1C, 0x00, 0x8A14 }, - { 0x1C, 0x00, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 0, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 0, 0x8A14 }, }; static EntranceTableEntry sPathToMountainVillageEntrance1[] = { - { 0x1C, 0x01, 0x8A14 }, - { 0x1C, 0x01, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 1, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 1, 0x8A14 }, }; static EntranceTableEntry* sPathToMountainVillageEntranceTable[] = { @@ -589,31 +589,31 @@ static EntranceTableEntry* sPathToMountainVillageEntranceTable[] = { }; static EntranceTableEntry sIkanaCastleEntrance0[] = { - { 0xE3, 0x00, 0x4102 }, + { -SCENE_CASTLE, 0, 0x4102 }, }; static EntranceTableEntry sIkanaCastleEntrance1[] = { - { 0xE3, 0x01, 0x4102 }, + { -SCENE_CASTLE, 1, 0x4102 }, }; static EntranceTableEntry sIkanaCastleEntrance2[] = { - { 0xE3, 0x02, 0x8102 }, + { -SCENE_CASTLE, 2, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance3[] = { - { 0xE3, 0x03, 0x8102 }, + { -SCENE_CASTLE, 3, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance4[] = { - { 0xE3, 0x04, 0x8102 }, + { -SCENE_CASTLE, 4, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance5[] = { - { 0xE3, 0x05, 0x8102 }, + { -SCENE_CASTLE, 5, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance6[] = { - { 0xE3, 0x06, 0x8102 }, + { -SCENE_CASTLE, 6, 0x8102 }, }; static EntranceTableEntry* sIkanaCastleEntranceTable[] = { @@ -622,11 +622,11 @@ static EntranceTableEntry* sIkanaCastleEntranceTable[] = { }; static EntranceTableEntry sDekuScrubPlaygroundEntrance0[] = { - { 0x1E, 0x00, 0x0102 }, + { SCENE_DEKUTES, 0, 0x0102 }, }; static EntranceTableEntry sDekuScrubPlaygroundEntrance1[] = { - { 0x1E, 0x01, 0x0102 }, + { SCENE_DEKUTES, 1, 0x0102 }, }; static EntranceTableEntry* sDekuScrubPlaygroundEntranceTable[] = { @@ -635,7 +635,7 @@ static EntranceTableEntry* sDekuScrubPlaygroundEntranceTable[] = { }; static EntranceTableEntry sOdolwasLairEntrance0[] = { - { 0xE1, 0x00, 0x8102 }, + { -SCENE_MITURIN_BS, 0, 0x8102 }, }; static EntranceTableEntry* sOdolwasLairEntranceTable[] = { @@ -643,11 +643,11 @@ static EntranceTableEntry* sOdolwasLairEntranceTable[] = { }; static EntranceTableEntry sTownShootingGalleryEntrance0[] = { - { 0x20, 0x00, 0x4102 }, + { SCENE_SYATEKI_MIZU, 0, 0x4102 }, }; static EntranceTableEntry sTownShootingGalleryEntrance1[] = { - { 0x20, 0x01, 0x0102 }, + { SCENE_SYATEKI_MIZU, 1, 0x0102 }, }; static EntranceTableEntry* sTownShootingGalleryEntranceTable[] = { @@ -656,11 +656,11 @@ static EntranceTableEntry* sTownShootingGalleryEntranceTable[] = { }; static EntranceTableEntry sSnowheadTempleEntrance0[] = { - { 0xDF, 0x00, 0x4102 }, + { -SCENE_HAKUGIN, 0, 0x4102 }, }; static EntranceTableEntry sSnowheadTempleEntrance1[] = { - { 0xDF, 0x01, 0x4102 }, + { -SCENE_HAKUGIN, 1, 0x4102 }, }; static EntranceTableEntry* sSnowheadTempleEntranceTable[] = { @@ -669,31 +669,31 @@ static EntranceTableEntry* sSnowheadTempleEntranceTable[] = { }; static EntranceTableEntry sMilkRoadEntrance0[] = { - { 0x22, 0x00, 0xCA14 }, + { SCENE_ROMANYMAE, 0, 0xCA14 }, }; static EntranceTableEntry sMilkRoadEntrance1[] = { - { 0x22, 0x01, 0x4A14 }, + { SCENE_ROMANYMAE, 1, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance2[] = { - { 0x22, 0x02, 0x4A14 }, + { SCENE_ROMANYMAE, 2, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance3[] = { - { 0x22, 0x03, 0x4A14 }, + { SCENE_ROMANYMAE, 3, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance4[] = { - { 0x22, 0x04, 0x4A14 }, + { SCENE_ROMANYMAE, 4, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance5[] = { - { 0x22, 0x05, 0x0102 }, + { SCENE_ROMANYMAE, 5, 0x0102 }, }; static EntranceTableEntry sMilkRoadEntrance6[] = { - { 0x22, 0x06, 0x0102 }, + { SCENE_ROMANYMAE, 6, 0x0102 }, }; static EntranceTableEntry* sMilkRoadEntranceTable[] = { @@ -702,67 +702,67 @@ static EntranceTableEntry* sMilkRoadEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressInteriorEntrance0[] = { - { 0x23, 0x00, 0x8102 }, + { SCENE_PIRATE, 0, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance1[] = { - { 0x23, 0x01, 0x8102 }, + { SCENE_PIRATE, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance2[] = { - { 0x23, 0x02, 0x8102 }, + { SCENE_PIRATE, 2, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance3[] = { - { 0x23, 0x03, 0x8102 }, + { SCENE_PIRATE, 3, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance4[] = { - { 0x23, 0x04, 0x8102 }, + { SCENE_PIRATE, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance5[] = { - { 0x23, 0x05, 0x8102 }, + { SCENE_PIRATE, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance6[] = { - { 0x23, 0x06, 0x8102 }, + { SCENE_PIRATE, 6, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance7[] = { - { 0x23, 0x07, 0x8102 }, + { SCENE_PIRATE, 7, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance8[] = { - { 0x23, 0x08, 0x8102 }, + { SCENE_PIRATE, 8, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance9[] = { - { 0x23, 0x09, 0x8993 }, + { SCENE_PIRATE, 9, 0x8993 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance10[] = { - { 0x23, 0x0A, 0x8102 }, + { SCENE_PIRATE, 10, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance11[] = { - { 0x23, 0x0B, 0x8102 }, + { SCENE_PIRATE, 11, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance12[] = { - { 0x23, 0x0C, 0x8102 }, + { SCENE_PIRATE, 12, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance13[] = { - { 0x23, 0x0D, 0x8102 }, + { SCENE_PIRATE, 13, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance14[] = { - { 0x23, 0x0E, 0x8102 }, + { SCENE_PIRATE, 14, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance15[] = { - { 0x23, 0x0F, 0x8102 }, + { SCENE_PIRATE, 15, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressInteriorEntranceTable[] = { @@ -775,7 +775,7 @@ static EntranceTableEntry* sPiratesFortressInteriorEntranceTable[] = { }; static EntranceTableEntry sSwampShootingGalleryEntrance0[] = { - { 0x24, 0x00, 0x4102 }, + { SCENE_SYATEKI_MORI, 0, 0x4102 }, }; static EntranceTableEntry* sSwampShootingGalleryEntranceTable[] = { @@ -783,11 +783,11 @@ static EntranceTableEntry* sSwampShootingGalleryEntranceTable[] = { }; static EntranceTableEntry sPinnacleRockEntrance0[] = { - { 0x25, 0x00, 0x4A14 }, + { SCENE_SINKAI, 0, 0x4A14 }, }; static EntranceTableEntry sPinnacleRockEntrance1[] = { - { 0x25, 0x01, 0x0A14 }, + { SCENE_SINKAI, 1, 0x0A14 }, }; static EntranceTableEntry* sPinnacleRockEntranceTable[] = { @@ -796,44 +796,44 @@ static EntranceTableEntry* sPinnacleRockEntranceTable[] = { }; static EntranceTableEntry sFairyFountainEntrance0[] = { - { 0x26, 0x00, 0x4102 }, - { 0x26, 0x00, 0x8102 }, + { SCENE_YOUSEI_IZUMI, 0, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 0, 0x8102 }, }; static EntranceTableEntry sFairyFountainEntrance1[] = { - { 0x26, 0x01, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 1, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance2[] = { - { 0x26, 0x02, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 2, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance3[] = { - { 0x26, 0x03, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 3, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance4[] = { - { 0x26, 0x04, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 4, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance5[] = { - { 0x26, 0x05, 0x8183 }, + { SCENE_YOUSEI_IZUMI, 5, 0x8183 }, }; static EntranceTableEntry sFairyFountainEntrance6[] = { - { 0x26, 0x06, 0x858B }, + { SCENE_YOUSEI_IZUMI, 6, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance7[] = { - { 0x26, 0x07, 0x858B }, + { SCENE_YOUSEI_IZUMI, 7, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance8[] = { - { 0x26, 0x08, 0x858B }, + { SCENE_YOUSEI_IZUMI, 8, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance9[] = { - { 0x26, 0x09, 0x858B }, + { SCENE_YOUSEI_IZUMI, 9, 0x858B }, }; static EntranceTableEntry* sFairyFountainEntranceTable[] = { @@ -843,7 +843,7 @@ static EntranceTableEntry* sFairyFountainEntranceTable[] = { }; static EntranceTableEntry sSwampSpiderHouseEntrance0[] = { - { 0xD9, 0x00, 0x4102 }, + { -SCENE_KINSTA1, 0, 0x4102 }, }; static EntranceTableEntry* sSwampSpiderHouseEntranceTable[] = { @@ -851,7 +851,7 @@ static EntranceTableEntry* sSwampSpiderHouseEntranceTable[] = { }; static EntranceTableEntry sOceansideSpiderHouseEntrance0[] = { - { 0xD8, 0x00, 0x4102 }, + { -SCENE_KINDAN2, 0, 0x4102 }, }; static EntranceTableEntry* sOceansideSpiderHouseEntranceTable[] = { @@ -859,15 +859,15 @@ static EntranceTableEntry* sOceansideSpiderHouseEntranceTable[] = { }; static EntranceTableEntry sAstralObservatoryEntrance0[] = { - { 0x29, 0x00, 0x0102 }, + { SCENE_TENMON_DAI, 0, 0x0102 }, }; static EntranceTableEntry sAstralObservatoryEntrance1[] = { - { 0x29, 0x01, 0x4102 }, + { SCENE_TENMON_DAI, 1, 0x4102 }, }; static EntranceTableEntry sAstralObservatoryEntrance2[] = { - { 0x29, 0x02, 0x8115 }, + { SCENE_TENMON_DAI, 2, 0x8115 }, }; static EntranceTableEntry* sAstralObservatoryEntranceTable[] = { @@ -877,7 +877,7 @@ static EntranceTableEntry* sAstralObservatoryEntranceTable[] = { }; static EntranceTableEntry sMoonDekuTrialEntrance0[] = { - { 0xD6, 0x00, 0x0387 }, + { -SCENE_LAST_DEKU, 0, 0x0387 }, }; static EntranceTableEntry* sMoonDekuTrialEntranceTable[] = { @@ -885,47 +885,47 @@ static EntranceTableEntry* sMoonDekuTrialEntranceTable[] = { }; static EntranceTableEntry sDekuPalaceEntrance0[] = { - { 0x2B, 0x00, 0x4102 }, + { SCENE_22DEKUCITY, 0, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance1[] = { - { 0x2B, 0x01, 0x8A14 }, + { SCENE_22DEKUCITY, 1, 0x8A14 }, }; static EntranceTableEntry sDekuPalaceEntrance2[] = { - { 0x2B, 0x02, 0xC102 }, + { SCENE_22DEKUCITY, 2, 0xC102 }, }; static EntranceTableEntry sDekuPalaceEntrance3[] = { - { 0x2B, 0x03, 0xC102 }, + { SCENE_22DEKUCITY, 3, 0xC102 }, }; static EntranceTableEntry sDekuPalaceEntrance4[] = { - { 0x2B, 0x04, 0x4102 }, + { SCENE_22DEKUCITY, 4, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance5[] = { - { 0x2B, 0x05, 0x4102 }, + { SCENE_22DEKUCITY, 5, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance6[] = { - { 0x2B, 0x06, 0x4102 }, + { SCENE_22DEKUCITY, 6, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance7[] = { - { 0x2B, 0x07, 0x4102 }, + { SCENE_22DEKUCITY, 7, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance8[] = { - { 0x2B, 0x08, 0x4102 }, + { SCENE_22DEKUCITY, 8, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance9[] = { - { 0x2B, 0x09, 0x4102 }, + { SCENE_22DEKUCITY, 9, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance10[] = { - { 0x2B, 0x0A, 0x4102 }, + { SCENE_22DEKUCITY, 10, 0x4102 }, }; static EntranceTableEntry* sDekuPalaceEntranceTable[] = { @@ -935,7 +935,7 @@ static EntranceTableEntry* sDekuPalaceEntranceTable[] = { }; static EntranceTableEntry sMountainSmithyEntrance0[] = { - { 0x2C, 0x00, 0x4102 }, + { SCENE_KAJIYA, 0, 0x4102 }, }; static EntranceTableEntry* sMountainSmithyEntranceTable[] = { @@ -943,79 +943,81 @@ static EntranceTableEntry* sMountainSmithyEntranceTable[] = { }; static EntranceTableEntry sTerminaFieldEntrance0[] = { - { 0x2D, 0x00, 0x4102 }, { 0xD3, 0x00, 0x0A14 }, { 0xD3, 0x00, 0x0A14 }, { 0xD3, 0x00, 0x058B }, - { 0x2D, 0x00, 0x0A14 }, { 0x2D, 0x00, 0x0A14 }, { 0x2D, 0x00, 0x058B }, { 0x2D, 0x00, 0x8102 }, - { 0x2D, 0x00, 0x0102 }, { 0x2D, 0x00, 0x8102 }, + { SCENE_00KEIKOKU, 0, 0x4102 }, { -SCENE_00KEIKOKU, 0, 0x0A14 }, { -SCENE_00KEIKOKU, 0, 0x0A14 }, + { -SCENE_00KEIKOKU, 0, 0x058B }, { SCENE_00KEIKOKU, 0, 0x0A14 }, { SCENE_00KEIKOKU, 0, 0x0A14 }, + { SCENE_00KEIKOKU, 0, 0x058B }, { SCENE_00KEIKOKU, 0, 0x8102 }, { SCENE_00KEIKOKU, 0, 0x0102 }, + { SCENE_00KEIKOKU, 0, 0x8102 }, }; static EntranceTableEntry sTerminaFieldEntrance1[] = { - { 0x2D, 0x01, 0xCA14 }, { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x058B }, { 0xD3, 0x01, 0x858B }, - { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x058B }, { 0x2D, 0x01, 0x858B }, - { 0x2D, 0x01, 0x0102 }, { 0x2D, 0x01, 0x8102 }, + { SCENE_00KEIKOKU, 1, 0xCA14 }, { SCENE_00KEIKOKU, 1, 0x0A14 }, { SCENE_00KEIKOKU, 1, 0x058B }, + { -SCENE_00KEIKOKU, 1, 0x858B }, { SCENE_00KEIKOKU, 1, 0x0A14 }, { SCENE_00KEIKOKU, 1, 0x0A14 }, + { SCENE_00KEIKOKU, 1, 0x058B }, { SCENE_00KEIKOKU, 1, 0x858B }, { SCENE_00KEIKOKU, 1, 0x0102 }, + { SCENE_00KEIKOKU, 1, 0x8102 }, }; static EntranceTableEntry sTerminaFieldEntrance2[] = { - { 0x2D, 0x02, 0xCA14 }, { 0xD3, 0x02, 0x0A14 }, { 0xD3, 0x02, 0x0A14 }, - { 0xD3, 0x02, 0x058B }, { 0x2D, 0x02, 0x0A14 }, { 0x2D, 0x02, 0x0A14 }, + { SCENE_00KEIKOKU, 2, 0xCA14 }, { -SCENE_00KEIKOKU, 2, 0x0A14 }, { -SCENE_00KEIKOKU, 2, 0x0A14 }, + { -SCENE_00KEIKOKU, 2, 0x058B }, { SCENE_00KEIKOKU, 2, 0x0A14 }, { SCENE_00KEIKOKU, 2, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance3[] = { - { 0x2D, 0x03, 0xCA14 }, { 0xD3, 0x03, 0x0A14 }, { 0xD3, 0x03, 0x0A14 }, - { 0xD3, 0x03, 0x058B }, { 0x2D, 0x03, 0x0A14 }, { 0x2D, 0x03, 0x0A14 }, + { SCENE_00KEIKOKU, 3, 0xCA14 }, { -SCENE_00KEIKOKU, 3, 0x0A14 }, { -SCENE_00KEIKOKU, 3, 0x0A14 }, + { -SCENE_00KEIKOKU, 3, 0x058B }, { SCENE_00KEIKOKU, 3, 0x0A14 }, { SCENE_00KEIKOKU, 3, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance4[] = { - { 0x2D, 0x04, 0xCA14 }, { 0xD3, 0x04, 0x0A14 }, { 0xD3, 0x04, 0x0A14 }, - { 0xD3, 0x04, 0x058B }, { 0x2D, 0x04, 0x0A14 }, { 0x2D, 0x04, 0x0A14 }, + { SCENE_00KEIKOKU, 4, 0xCA14 }, { -SCENE_00KEIKOKU, 4, 0x0A14 }, { -SCENE_00KEIKOKU, 4, 0x0A14 }, + { -SCENE_00KEIKOKU, 4, 0x058B }, { SCENE_00KEIKOKU, 4, 0x0A14 }, { SCENE_00KEIKOKU, 4, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance5[] = { - { 0x2D, 0x05, 0xCA14 }, { 0xD3, 0x05, 0x0A14 }, { 0xD3, 0x05, 0x0A14 }, - { 0xD3, 0x05, 0x858B }, { 0x2D, 0x05, 0x0A14 }, { 0x2D, 0x05, 0x0A14 }, + { SCENE_00KEIKOKU, 5, 0xCA14 }, { -SCENE_00KEIKOKU, 5, 0x0A14 }, { -SCENE_00KEIKOKU, 5, 0x0A14 }, + { -SCENE_00KEIKOKU, 5, 0x858B }, { SCENE_00KEIKOKU, 5, 0x0A14 }, { SCENE_00KEIKOKU, 5, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance6[] = { - { 0x2D, 0x06, 0x4102 }, { 0xD3, 0x06, 0x0A14 }, { 0xD3, 0x06, 0x0A14 }, - { 0xD3, 0x06, 0x858B }, { 0x2D, 0x06, 0x0A14 }, { 0x2D, 0x06, 0x0A14 }, + { SCENE_00KEIKOKU, 6, 0x4102 }, { -SCENE_00KEIKOKU, 6, 0x0A14 }, { -SCENE_00KEIKOKU, 6, 0x0A14 }, + { -SCENE_00KEIKOKU, 6, 0x858B }, { SCENE_00KEIKOKU, 6, 0x0A14 }, { SCENE_00KEIKOKU, 6, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance7[] = { - { 0x2D, 0x07, 0x4102 }, { 0xD3, 0x07, 0x0A14 }, { 0xD3, 0x07, 0x0A14 }, - { 0xD3, 0x07, 0x858B }, { 0x2D, 0x07, 0x0A14 }, { 0x2D, 0x07, 0x0A14 }, + { SCENE_00KEIKOKU, 7, 0x4102 }, { -SCENE_00KEIKOKU, 7, 0x0A14 }, { -SCENE_00KEIKOKU, 7, 0x0A14 }, + { -SCENE_00KEIKOKU, 7, 0x858B }, { SCENE_00KEIKOKU, 7, 0x0A14 }, { SCENE_00KEIKOKU, 7, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance8[] = { - { 0x2D, 0x08, 0x4102 }, { 0xD3, 0x08, 0x0A14 }, { 0xD3, 0x08, 0x0A14 }, - { 0xD3, 0x08, 0x058B }, { 0x2D, 0x08, 0x0A14 }, { 0x2D, 0x08, 0x0A14 }, + { SCENE_00KEIKOKU, 8, 0x4102 }, { -SCENE_00KEIKOKU, 8, 0x0A14 }, { -SCENE_00KEIKOKU, 8, 0x0A14 }, + { -SCENE_00KEIKOKU, 8, 0x058B }, { SCENE_00KEIKOKU, 8, 0x0A14 }, { SCENE_00KEIKOKU, 8, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance9[] = { - { 0x2D, 0x09, 0x4102 }, { 0xD3, 0x09, 0x0A14 }, { 0xD3, 0x09, 0x0A14 }, - { 0xD3, 0x09, 0x058B }, { 0x2D, 0x09, 0x0A14 }, { 0x2D, 0x09, 0x0A14 }, + { SCENE_00KEIKOKU, 9, 0x4102 }, { -SCENE_00KEIKOKU, 9, 0x0A14 }, { -SCENE_00KEIKOKU, 9, 0x0A14 }, + { -SCENE_00KEIKOKU, 9, 0x058B }, { SCENE_00KEIKOKU, 9, 0x0A14 }, { SCENE_00KEIKOKU, 9, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance10[] = { - { 0x2D, 0x0A, 0x8A95 }, { 0xD3, 0x0A, 0x0A14 }, { 0xD3, 0x0A, 0x0A14 }, - { 0xD3, 0x0A, 0x058B }, { 0x2D, 0x0A, 0x0A14 }, { 0x2D, 0x0A, 0x0A95 }, + { SCENE_00KEIKOKU, 10, 0x8A95 }, { -SCENE_00KEIKOKU, 10, 0x0A14 }, { -SCENE_00KEIKOKU, 10, 0x0A14 }, + { -SCENE_00KEIKOKU, 10, 0x058B }, { SCENE_00KEIKOKU, 10, 0x0A14 }, { SCENE_00KEIKOKU, 10, 0x0A95 }, }; static EntranceTableEntry sTerminaFieldEntrance11[] = { - { 0x2D, 0x0B, 0x4A14 }, { 0xD3, 0x0B, 0x0A14 }, { 0xD3, 0x0B, 0x0A14 }, - { 0xD3, 0x0B, 0x058B }, { 0x2D, 0x0B, 0x0A14 }, { 0x2D, 0x0B, 0x0A14 }, + { SCENE_00KEIKOKU, 11, 0x4A14 }, { -SCENE_00KEIKOKU, 11, 0x0A14 }, { -SCENE_00KEIKOKU, 11, 0x0A14 }, + { -SCENE_00KEIKOKU, 11, 0x058B }, { SCENE_00KEIKOKU, 11, 0x0A14 }, { SCENE_00KEIKOKU, 11, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance12[] = { - { 0x2D, 0x0C, 0x0A14 }, { 0xD3, 0x0C, 0x0A14 }, { 0xD3, 0x0C, 0x0A14 }, - { 0xD3, 0x0C, 0x058B }, { 0x2D, 0x0C, 0x0A14 }, { 0x2D, 0x0C, 0x0A14 }, + { SCENE_00KEIKOKU, 12, 0x0A14 }, { -SCENE_00KEIKOKU, 12, 0x0A14 }, { -SCENE_00KEIKOKU, 12, 0x0A14 }, + { -SCENE_00KEIKOKU, 12, 0x058B }, { SCENE_00KEIKOKU, 12, 0x0A14 }, { SCENE_00KEIKOKU, 12, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance13[] = { - { 0x2D, 0x0D, 0x0A14 }, { 0xD3, 0x0D, 0x0A14 }, { 0xD3, 0x0D, 0x0A14 }, - { 0xD3, 0x0D, 0x058B }, { 0x2D, 0x0D, 0x0A14 }, { 0x2D, 0x0D, 0x0A14 }, + { SCENE_00KEIKOKU, 13, 0x0A14 }, { -SCENE_00KEIKOKU, 13, 0x0A14 }, { -SCENE_00KEIKOKU, 13, 0x0A14 }, + { -SCENE_00KEIKOKU, 13, 0x058B }, { SCENE_00KEIKOKU, 13, 0x0A14 }, { SCENE_00KEIKOKU, 13, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance14[] = { - { 0x2D, 0x0E, 0x858B }, + { SCENE_00KEIKOKU, 14, 0x858B }, }; static EntranceTableEntry* sTerminaFieldEntranceTable[] = { @@ -1026,7 +1028,7 @@ static EntranceTableEntry* sTerminaFieldEntranceTable[] = { }; static EntranceTableEntry sPostOfficeEntrance0[] = { - { 0x2E, 0x00, 0x4102 }, + { SCENE_POSTHOUSE, 0, 0x4102 }, }; static EntranceTableEntry* sPostOfficeEntranceTable[] = { @@ -1034,7 +1036,7 @@ static EntranceTableEntry* sPostOfficeEntranceTable[] = { }; static EntranceTableEntry sMarineResearchLabEntrance0[] = { - { 0x2F, 0x00, 0x4102 }, + { SCENE_LABO, 0, 0x4102 }, }; static EntranceTableEntry* sMarineResearchLabEntranceTable[] = { @@ -1042,11 +1044,11 @@ static EntranceTableEntry* sMarineResearchLabEntranceTable[] = { }; static EntranceTableEntry sDampesHouseEntrance0[] = { - { 0x30, 0x00, 0x4102 }, + { SCENE_DANPEI2TEST, 0, 0x4102 }, }; static EntranceTableEntry sDampesHouseEntrance1[] = { - { 0x30, 0x01, 0x0102 }, + { SCENE_DANPEI2TEST, 1, 0x0102 }, }; static EntranceTableEntry* sDampesHouseEntranceTable[] = { @@ -1055,23 +1057,23 @@ static EntranceTableEntry* sDampesHouseEntranceTable[] = { }; static EntranceTableEntry sGoronShrineEntrance0[] = { - { 0x32, 0x00, 0x4102 }, - { 0x32, 0x00, 0x4102 }, + { SCENE_16GORON_HOUSE, 0, 0x4102 }, + { SCENE_16GORON_HOUSE, 0, 0x4102 }, }; static EntranceTableEntry sGoronShrineEntrance1[] = { - { 0x32, 0x01, 0x0102 }, - { 0x32, 0x01, 0x0102 }, + { SCENE_16GORON_HOUSE, 1, 0x0102 }, + { SCENE_16GORON_HOUSE, 1, 0x0102 }, }; static EntranceTableEntry sGoronShrineEntrance2[] = { - { 0x32, 0x02, 0x058B }, - { 0x32, 0x02, 0x058B }, + { SCENE_16GORON_HOUSE, 2, 0x058B }, + { SCENE_16GORON_HOUSE, 2, 0x058B }, }; static EntranceTableEntry sGoronShrineEntrance3[] = { - { 0x32, 0x03, 0x0102 }, - { 0x32, 0x03, 0x0102 }, + { SCENE_16GORON_HOUSE, 3, 0x0102 }, + { SCENE_16GORON_HOUSE, 3, 0x0102 }, }; static EntranceTableEntry* sGoronShrineEntranceTable[] = { @@ -1082,40 +1084,40 @@ static EntranceTableEntry* sGoronShrineEntranceTable[] = { }; static EntranceTableEntry sZoraHallEntrance0[] = { - { 0x33, 0x00, 0x4993 }, - { 0x33, 0x00, 0x8102 }, + { SCENE_33ZORACITY, 0, 0x4993 }, + { SCENE_33ZORACITY, 0, 0x8102 }, }; static EntranceTableEntry sZoraHallEntrance1[] = { - { 0x33, 0x01, 0x4102 }, + { SCENE_33ZORACITY, 1, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance2[] = { - { 0x33, 0x02, 0x4102 }, + { SCENE_33ZORACITY, 2, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance3[] = { - { 0x33, 0x03, 0x4102 }, + { SCENE_33ZORACITY, 3, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance4[] = { - { 0x33, 0x04, 0x4102 }, + { SCENE_33ZORACITY, 4, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance5[] = { - { 0x33, 0x05, 0x4102 }, + { SCENE_33ZORACITY, 5, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance6[] = { - { 0x33, 0x06, 0x4102 }, + { SCENE_33ZORACITY, 6, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance7[] = { - { 0x33, 0x07, 0x058B }, + { SCENE_33ZORACITY, 7, 0x058B }, }; static EntranceTableEntry sZoraHallEntrance8[] = { - { 0x33, 0x08, 0x8183 }, + { SCENE_33ZORACITY, 8, 0x8183 }, }; static EntranceTableEntry* sZoraHallEntranceTable[] = { @@ -1124,11 +1126,11 @@ static EntranceTableEntry* sZoraHallEntranceTable[] = { }; static EntranceTableEntry sTradingPostEntrance0[] = { - { 0x34, 0x00, 0x4102 }, + { SCENE_8ITEMSHOP, 0, 0x4102 }, }; static EntranceTableEntry sTradingPostEntrance1[] = { - { 0x34, 0x01, 0x0102 }, + { SCENE_8ITEMSHOP, 1, 0x0102 }, }; static EntranceTableEntry* sTradingPostEntranceTable[] = { @@ -1137,52 +1139,52 @@ static EntranceTableEntry* sTradingPostEntranceTable[] = { }; static EntranceTableEntry sRomaniRanchEntrance0[] = { - { 0x35, 0x00, 0x4A14 }, { 0x35, 0x00, 0x0A14 }, { 0x35, 0x00, 0x8102 }, { 0x35, 0x00, 0x858B }, - { 0x35, 0x00, 0x858B }, { 0x35, 0x00, 0x0102 }, { 0x35, 0x00, 0x8102 }, + { SCENE_F01, 0, 0x4A14 }, { SCENE_F01, 0, 0x0A14 }, { SCENE_F01, 0, 0x8102 }, { SCENE_F01, 0, 0x858B }, + { SCENE_F01, 0, 0x858B }, { SCENE_F01, 0, 0x0102 }, { SCENE_F01, 0, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance1[] = { - { 0x35, 0x01, 0x0A14 }, + { SCENE_F01, 1, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance2[] = { - { 0x35, 0x02, 0x0102 }, + { SCENE_F01, 2, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance3[] = { - { 0x35, 0x03, 0x0102 }, + { SCENE_F01, 3, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance4[] = { - { 0x35, 0x04, 0x8102 }, + { SCENE_F01, 4, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance5[] = { - { 0x35, 0x05, 0x8102 }, + { SCENE_F01, 5, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance6[] = { - { 0x35, 0x06, 0x0A14 }, + { SCENE_F01, 6, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance7[] = { - { 0x35, 0x07, 0x0A14 }, + { SCENE_F01, 7, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance8[] = { - { 0x35, 0x08, 0x0A14 }, + { SCENE_F01, 8, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance9[] = { - { 0x35, 0x09, 0x0102 }, + { SCENE_F01, 9, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance10[] = { - { 0x35, 0x0A, 0x0102 }, + { SCENE_F01, 10, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance11[] = { - { 0x35, 0x0B, 0x0102 }, + { SCENE_F01, 11, 0x0102 }, }; static EntranceTableEntry* sRomaniRanchEntranceTable[] = { @@ -1192,23 +1194,23 @@ static EntranceTableEntry* sRomaniRanchEntranceTable[] = { }; static EntranceTableEntry sTwinmoldsLairEntrance0[] = { - { 0xCA, 0x00, 0x0102 }, + { -SCENE_INISIE_BS, 0, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance1[] = { - { 0xCA, 0x01, 0x0102 }, + { -SCENE_INISIE_BS, 1, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance2[] = { - { 0xCA, 0x02, 0x0102 }, + { -SCENE_INISIE_BS, 2, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance3[] = { - { 0xCA, 0x03, 0x0102 }, + { -SCENE_INISIE_BS, 3, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance4[] = { - { 0xCA, 0x04, 0x0102 }, + { -SCENE_INISIE_BS, 4, 0x0102 }, }; static EntranceTableEntry* sTwinmoldsLairEntranceTable[] = { @@ -1217,74 +1219,74 @@ static EntranceTableEntry* sTwinmoldsLairEntranceTable[] = { }; static EntranceTableEntry sGreatBayCoastEntrance0[] = { - { 0x37, 0x00, 0xCA14 }, - { 0x37, 0x00, 0xCA14 }, - { 0x37, 0x00, 0x8102 }, + { SCENE_30GYOSON, 0, 0xCA14 }, + { SCENE_30GYOSON, 0, 0xCA14 }, + { SCENE_30GYOSON, 0, 0x8102 }, }; static EntranceTableEntry sGreatBayCoastEntrance1[] = { - { 0x37, 0x01, 0xCA14 }, - { 0x37, 0x01, 0xCA14 }, + { SCENE_30GYOSON, 1, 0xCA14 }, + { SCENE_30GYOSON, 1, 0xCA14 }, }; static EntranceTableEntry sGreatBayCoastEntrance2[] = { - { 0x37, 0x02, 0x4993 }, - { 0x37, 0x02, 0x4993 }, + { SCENE_30GYOSON, 2, 0x4993 }, + { SCENE_30GYOSON, 2, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance3[] = { - { 0x37, 0x03, 0x4A14 }, - { 0x37, 0x03, 0x4A14 }, + { SCENE_30GYOSON, 3, 0x4A14 }, + { SCENE_30GYOSON, 3, 0x4A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance4[] = { - { 0x37, 0x04, 0x4102 }, - { 0x37, 0x04, 0x4102 }, + { SCENE_30GYOSON, 4, 0x4102 }, + { SCENE_30GYOSON, 4, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance5[] = { - { 0x37, 0x05, 0x4993 }, - { 0x37, 0x05, 0x4993 }, + { SCENE_30GYOSON, 5, 0x4993 }, + { SCENE_30GYOSON, 5, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance6[] = { - { 0x37, 0x06, 0x4993 }, - { 0x37, 0x06, 0x4993 }, + { SCENE_30GYOSON, 6, 0x4993 }, + { SCENE_30GYOSON, 6, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance7[] = { - { 0x37, 0x07, 0x4102 }, - { 0x37, 0x07, 0x4102 }, + { SCENE_30GYOSON, 7, 0x4102 }, + { SCENE_30GYOSON, 7, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance8[] = { - { 0x37, 0x08, 0x4102 }, - { 0x37, 0x08, 0x4102 }, + { SCENE_30GYOSON, 8, 0x4102 }, + { SCENE_30GYOSON, 8, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance9[] = { - { 0x37, 0x09, 0x058B }, - { 0x37, 0x09, 0x058B }, + { SCENE_30GYOSON, 9, 0x058B }, + { SCENE_30GYOSON, 9, 0x058B }, }; static EntranceTableEntry sGreatBayCoastEntrance10[] = { - { 0x37, 0x0A, 0x858B }, - { 0x37, 0x0A, 0x858B }, + { SCENE_30GYOSON, 10, 0x858B }, + { SCENE_30GYOSON, 10, 0x858B }, }; static EntranceTableEntry sGreatBayCoastEntrance11[] = { - { 0x37, 0x0B, 0x0A14 }, - { 0x37, 0x0B, 0x0A14 }, + { SCENE_30GYOSON, 11, 0x0A14 }, + { SCENE_30GYOSON, 11, 0x0A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance12[] = { - { 0x37, 0x0C, 0x0A14 }, - { 0x37, 0x0C, 0x0A14 }, + { SCENE_30GYOSON, 12, 0x0A14 }, + { SCENE_30GYOSON, 12, 0x0A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance13[] = { - { 0x37, 0x0D, 0x0A14 }, - { 0x37, 0x0D, 0x0A14 }, + { SCENE_30GYOSON, 13, 0x0A14 }, + { SCENE_30GYOSON, 13, 0x0A14 }, }; static EntranceTableEntry* sGreatBayCoastEntranceTable[] = { @@ -1295,53 +1297,53 @@ static EntranceTableEntry* sGreatBayCoastEntranceTable[] = { }; static EntranceTableEntry sZoraCapeEntrance0[] = { - { 0x38, 0x00, 0x8A14 }, - { 0x38, 0x00, 0x8A14 }, + { SCENE_31MISAKI, 0, 0x8A14 }, + { SCENE_31MISAKI, 0, 0x8A14 }, }; static EntranceTableEntry sZoraCapeEntrance1[] = { - { 0x38, 0x01, 0x4993 }, - { 0x38, 0x01, 0x4993 }, + { SCENE_31MISAKI, 1, 0x4993 }, + { SCENE_31MISAKI, 1, 0x4993 }, }; static EntranceTableEntry sZoraCapeEntrance2[] = { - { 0x38, 0x02, 0x4102 }, - { 0x38, 0x02, 0x4102 }, + { SCENE_31MISAKI, 2, 0x4102 }, + { SCENE_31MISAKI, 2, 0x4102 }, }; static EntranceTableEntry sZoraCapeEntrance3[] = { - { 0x38, 0x03, 0x0993 }, - { 0x38, 0x03, 0x0993 }, + { SCENE_31MISAKI, 3, 0x0993 }, + { SCENE_31MISAKI, 3, 0x0993 }, }; static EntranceTableEntry sZoraCapeEntrance4[] = { - { 0x38, 0x04, 0x4102 }, - { 0x38, 0x04, 0x4102 }, + { SCENE_31MISAKI, 4, 0x4102 }, + { SCENE_31MISAKI, 4, 0x4102 }, }; static EntranceTableEntry sZoraCapeEntrance5[] = { - { 0x38, 0x05, 0x0102 }, - { 0x38, 0x05, 0x0102 }, + { SCENE_31MISAKI, 5, 0x0102 }, + { SCENE_31MISAKI, 5, 0x0102 }, }; static EntranceTableEntry sZoraCapeEntrance6[] = { - { 0x38, 0x06, 0x0A14 }, - { 0x38, 0x06, 0x0A14 }, + { SCENE_31MISAKI, 6, 0x0A14 }, + { SCENE_31MISAKI, 6, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance7[] = { - { 0x38, 0x07, 0x0A14 }, - { 0x38, 0x07, 0x0A14 }, + { SCENE_31MISAKI, 7, 0x0A14 }, + { SCENE_31MISAKI, 7, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance8[] = { - { 0x38, 0x08, 0x0A14 }, - { 0x38, 0x08, 0x0A14 }, + { SCENE_31MISAKI, 8, 0x0A14 }, + { SCENE_31MISAKI, 8, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance9[] = { - { 0x38, 0x09, 0x0A14 }, - { 0x38, 0x09, 0x0A14 }, + { SCENE_31MISAKI, 9, 0x0A14 }, + { SCENE_31MISAKI, 9, 0x0A14 }, }; static EntranceTableEntry* sZoraCapeEntranceTable[] = { @@ -1350,7 +1352,7 @@ static EntranceTableEntry* sZoraCapeEntranceTable[] = { }; static EntranceTableEntry sLotteryShopEntrance0[] = { - { 0x39, 0x00, 0x4102 }, + { SCENE_TAKARAKUJI, 0, 0x4102 }, }; static EntranceTableEntry* sLotteryShopEntranceTable[] = { @@ -1358,31 +1360,31 @@ static EntranceTableEntry* sLotteryShopEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressExteriorEntrance0[] = { - { 0x3B, 0x00, 0x4993 }, + { SCENE_TORIDE, 0, 0x4993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance1[] = { - { 0x3B, 0x01, 0x8102 }, + { SCENE_TORIDE, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance2[] = { - { 0x3B, 0x02, 0x8993 }, + { SCENE_TORIDE, 2, 0x8993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance3[] = { - { 0x3B, 0x03, 0x8993 }, + { SCENE_TORIDE, 3, 0x8993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance4[] = { - { 0x3B, 0x04, 0x8102 }, + { SCENE_TORIDE, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance5[] = { - { 0x3B, 0x05, 0x8102 }, + { SCENE_TORIDE, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance6[] = { - { 0x3B, 0x06, 0x8102 }, + { SCENE_TORIDE, 6, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressExteriorEntranceTable[] = { @@ -1392,7 +1394,7 @@ static EntranceTableEntry* sPiratesFortressExteriorEntranceTable[] = { }; static EntranceTableEntry sFishermansHutEntrance0[] = { - { 0x3C, 0x00, 0x4102 }, + { SCENE_FISHERMAN, 0, 0x4102 }, }; static EntranceTableEntry* sFishermansHutEntranceTable[] = { @@ -1400,7 +1402,7 @@ static EntranceTableEntry* sFishermansHutEntranceTable[] = { }; static EntranceTableEntry sGoronShopEntrance0[] = { - { 0x3D, 0x00, 0x4102 }, + { SCENE_GORONSHOP, 0, 0x4102 }, }; static EntranceTableEntry* sGoronShopEntranceTable[] = { @@ -1408,20 +1410,20 @@ static EntranceTableEntry* sGoronShopEntranceTable[] = { }; static EntranceTableEntry sDekuKingsChamberEntrance0[] = { - { 0xC2, 0x00, 0xC102 }, - { 0xC2, 0x00, 0x8102 }, + { -SCENE_DEKU_KING, 0, 0xC102 }, + { -SCENE_DEKU_KING, 0, 0x8102 }, }; static EntranceTableEntry sDekuKingsChamberEntrance1[] = { - { 0xC2, 0x01, 0xC102 }, + { -SCENE_DEKU_KING, 1, 0xC102 }, }; static EntranceTableEntry sDekuKingsChamberEntrance2[] = { - { 0xC2, 0x02, 0x858B }, + { -SCENE_DEKU_KING, 2, 0x858B }, }; static EntranceTableEntry sDekuKingsChamberEntrance3[] = { - { 0xC2, 0x03, 0x0102 }, + { -SCENE_DEKU_KING, 3, 0x0102 }, }; static EntranceTableEntry* sDekuKingsChamberEntranceTable[] = { @@ -1432,7 +1434,7 @@ static EntranceTableEntry* sDekuKingsChamberEntranceTable[] = { }; static EntranceTableEntry sMoonGoronTrialEntrance0[] = { - { 0xC1, 0x00, 0x0387 }, + { -SCENE_LAST_GORON, 0, 0x0387 }, }; static EntranceTableEntry* sMoonGoronTrialEntranceTable[] = { @@ -1440,15 +1442,15 @@ static EntranceTableEntry* sMoonGoronTrialEntranceTable[] = { }; static EntranceTableEntry sRoadToSouthernSwampEntrance0[] = { - { 0x40, 0x00, 0x8A14 }, + { SCENE_24KEMONOMITI, 0, 0x8A14 }, }; static EntranceTableEntry sRoadToSouthernSwampEntrance1[] = { - { 0x40, 0x01, 0x8A14 }, + { SCENE_24KEMONOMITI, 1, 0x8A14 }, }; static EntranceTableEntry sRoadToSouthernSwampEntrance2[] = { - { 0x40, 0x02, 0x0102 }, + { SCENE_24KEMONOMITI, 2, 0x0102 }, }; static EntranceTableEntry* sRoadToSouthernSwampEntranceTable[] = { @@ -1458,11 +1460,11 @@ static EntranceTableEntry* sRoadToSouthernSwampEntranceTable[] = { }; static EntranceTableEntry sDoggyRacetrackEntrance0[] = { - { 0x41, 0x00, 0xC102 }, + { SCENE_F01_B, 0, 0xC102 }, }; static EntranceTableEntry sDoggyRacetrackEntrance1[] = { - { 0x41, 0x01, 0x0A14 }, + { SCENE_F01_B, 1, 0x0A14 }, }; static EntranceTableEntry* sDoggyRacetrackEntranceTable[] = { @@ -1471,12 +1473,12 @@ static EntranceTableEntry* sDoggyRacetrackEntranceTable[] = { }; static EntranceTableEntry sCuccoShackEntrance0[] = { - { 0x42, 0x00, 0xC102 }, - { 0x42, 0x00, 0x8102 }, + { SCENE_F01C, 0, 0xC102 }, + { SCENE_F01C, 0, 0x8102 }, }; static EntranceTableEntry sCuccoShackEntrance1[] = { - { 0x42, 0x01, 0x0A14 }, + { SCENE_F01C, 1, 0x0A14 }, }; static EntranceTableEntry* sCuccoShackEntranceTable[] = { @@ -1485,28 +1487,28 @@ static EntranceTableEntry* sCuccoShackEntranceTable[] = { }; static EntranceTableEntry sIkanaGraveyardEntrance0[] = { - { 0x43, 0x00, 0x4A14 }, - { 0x43, 0x00, 0x8102 }, + { SCENE_BOTI, 0, 0x4A14 }, + { SCENE_BOTI, 0, 0x8102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance1[] = { - { 0x43, 0x01, 0x4102 }, + { SCENE_BOTI, 1, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance2[] = { - { 0x43, 0x02, 0x4102 }, + { SCENE_BOTI, 2, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance3[] = { - { 0x43, 0x03, 0x4102 }, + { SCENE_BOTI, 3, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance4[] = { - { 0x43, 0x04, 0x4102 }, + { SCENE_BOTI, 4, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance5[] = { - { 0x43, 0x05, 0x058B }, + { SCENE_BOTI, 5, 0x058B }, }; static EntranceTableEntry* sIkanaGraveyardEntranceTable[] = { @@ -1515,7 +1517,7 @@ static EntranceTableEntry* sIkanaGraveyardEntranceTable[] = { }; static EntranceTableEntry sGohtsLairEntrance0[] = { - { 0xBC, 0x00, 0x8102 }, + { -SCENE_HAKUGIN_BS, 0, 0x8102 }, }; static EntranceTableEntry* sGohtsLairEntranceTable[] = { @@ -1523,47 +1525,47 @@ static EntranceTableEntry* sGohtsLairEntranceTable[] = { }; static EntranceTableEntry sSouthernSwampPoisonedEntrance0[] = { - { 0x45, 0x00, 0xCA14 }, + { SCENE_20SICHITAI, 0, 0xCA14 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance1[] = { - { 0x45, 0x01, 0x4102 }, + { SCENE_20SICHITAI, 1, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance2[] = { - { 0x45, 0x02, 0xC102 }, + { SCENE_20SICHITAI, 2, 0xC102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance3[] = { - { 0x45, 0x03, 0x4102 }, + { SCENE_20SICHITAI, 3, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance4[] = { - { 0x45, 0x04, 0x4102 }, + { SCENE_20SICHITAI, 4, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance5[] = { - { 0x45, 0x05, 0x4102 }, + { SCENE_20SICHITAI, 5, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance6[] = { - { 0x45, 0x06, 0x0102 }, + { SCENE_20SICHITAI, 6, 0x0102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance7[] = { - { 0x45, 0x07, 0x4102 }, + { SCENE_20SICHITAI, 7, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance8[] = { - { 0x45, 0x08, 0x4102 }, + { SCENE_20SICHITAI, 8, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance9[] = { - { 0x45, 0x09, 0x4A14 }, + { SCENE_20SICHITAI, 9, 0x4A14 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance10[] = { - { 0x45, 0x0A, 0x4A14 }, + { SCENE_20SICHITAI, 10, 0x4A14 }, }; static EntranceTableEntry* sSouthernSwampPoisonedEntranceTable[] = { @@ -1574,33 +1576,33 @@ static EntranceTableEntry* sSouthernSwampPoisonedEntranceTable[] = { }; static EntranceTableEntry sWoodfallEntrance0[] = { - { 0x46, 0x00, 0xC102 }, - { 0x46, 0x00, 0x0183 }, - { 0x46, 0x00, 0xC102 }, + { SCENE_21MITURINMAE, 0, 0xC102 }, + { SCENE_21MITURINMAE, 0, 0x0183 }, + { SCENE_21MITURINMAE, 0, 0xC102 }, }; static EntranceTableEntry sWoodfallEntrance1[] = { - { 0x46, 0x01, 0x4102 }, - { 0x46, 0x01, 0x0183 }, - { 0x46, 0x01, 0x4102 }, + { SCENE_21MITURINMAE, 1, 0x4102 }, + { SCENE_21MITURINMAE, 1, 0x0183 }, + { SCENE_21MITURINMAE, 1, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance2[] = { - { 0x46, 0x02, 0x4102 }, - { 0x46, 0x02, 0x0183 }, - { 0x46, 0x02, 0x4102 }, + { SCENE_21MITURINMAE, 2, 0x4102 }, + { SCENE_21MITURINMAE, 2, 0x0183 }, + { SCENE_21MITURINMAE, 2, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance3[] = { - { 0x46, 0x03, 0x4102 }, - { 0x46, 0x03, 0x0183 }, - { 0x46, 0x03, 0x4102 }, + { SCENE_21MITURINMAE, 3, 0x4102 }, + { SCENE_21MITURINMAE, 3, 0x0183 }, + { SCENE_21MITURINMAE, 3, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance4[] = { - { 0x46, 0x04, 0x4102 }, - { 0x46, 0x04, 0x0183 }, - { 0x46, 0x04, 0x4102 }, + { SCENE_21MITURINMAE, 4, 0x4102 }, + { SCENE_21MITURINMAE, 4, 0x0183 }, + { SCENE_21MITURINMAE, 4, 0x4102 }, }; static EntranceTableEntry* sWoodfallEntranceTable[] = { @@ -1608,11 +1610,11 @@ static EntranceTableEntry* sWoodfallEntranceTable[] = { }; static EntranceTableEntry sMoonZoraTrialEntrance0[] = { - { 0xB9, 0x00, 0x0387 }, + { -SCENE_LAST_ZORA, 0, 0x0387 }, }; static EntranceTableEntry sMoonZoraTrialEntrance1[] = { - { 0xB9, 0x01, 0x0102 }, + { -SCENE_LAST_ZORA, 1, 0x0102 }, }; static EntranceTableEntry* sMoonZoraTrialEntranceTable[] = { @@ -1621,24 +1623,24 @@ static EntranceTableEntry* sMoonZoraTrialEntranceTable[] = { }; static EntranceTableEntry sGoronVillageSpringEntrance0[] = { - { 0x48, 0x00, 0xC102 }, - { 0x48, 0x00, 0x8102 }, + { SCENE_11GORONNOSATO2, 0, 0xC102 }, + { SCENE_11GORONNOSATO2, 0, 0x8102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance1[] = { - { 0x48, 0x01, 0x4102 }, + { SCENE_11GORONNOSATO2, 1, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance2[] = { - { 0x48, 0x02, 0x4102 }, + { SCENE_11GORONNOSATO2, 2, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance3[] = { - { 0x48, 0x03, 0x4102 }, + { SCENE_11GORONNOSATO2, 3, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance4[] = { - { 0x48, 0x04, 0x0A14 }, + { SCENE_11GORONNOSATO2, 4, 0x0A14 }, }; static EntranceTableEntry* sGoronVillageSpringEntranceTable[] = { @@ -1647,15 +1649,15 @@ static EntranceTableEntry* sGoronVillageSpringEntranceTable[] = { }; static EntranceTableEntry sGreatBayTempleEntrance0[] = { - { 0xB7, 0x00, 0x4102 }, + { -SCENE_SEA, 0, 0x4102 }, }; static EntranceTableEntry sGreatBayTempleEntrance1[] = { - { 0xB7, 0x01, 0x0102 }, + { -SCENE_SEA, 1, 0x0102 }, }; static EntranceTableEntry sGreatBayTempleEntrance2[] = { - { 0xB7, 0x02, 0x0102 }, + { -SCENE_SEA, 2, 0x0102 }, }; static EntranceTableEntry* sGreatBayTempleEntranceTable[] = { @@ -1665,19 +1667,19 @@ static EntranceTableEntry* sGreatBayTempleEntranceTable[] = { }; static EntranceTableEntry sWaterfallRapidsEntrance0[] = { - { 0x4A, 0x00, 0x4102 }, + { SCENE_35TAKI, 0, 0x4102 }, }; static EntranceTableEntry sWaterfallRapidsEntrance1[] = { - { 0x4A, 0x01, 0x0A14 }, + { SCENE_35TAKI, 1, 0x0A14 }, }; static EntranceTableEntry sWaterfallRapidsEntrance2[] = { - { 0x4A, 0x02, 0x0A14 }, + { SCENE_35TAKI, 2, 0x0A14 }, }; static EntranceTableEntry sWaterfallRapidsEntrance3[] = { - { 0x4A, 0x03, 0x0A14 }, + { SCENE_35TAKI, 3, 0x0A14 }, }; static EntranceTableEntry* sWaterfallRapidsEntranceTable[] = { @@ -1688,11 +1690,11 @@ static EntranceTableEntry* sWaterfallRapidsEntranceTable[] = { }; static EntranceTableEntry sBeneathTheWellEntrance0[] = { - { 0xB5, 0x00, 0x4102 }, + { -SCENE_REDEAD, 0, 0x4102 }, }; static EntranceTableEntry sBeneathTheWellEntrance1[] = { - { 0xB5, 0x01, 0x4102 }, + { -SCENE_REDEAD, 1, 0x4102 }, }; static EntranceTableEntry* sBeneathTheWellEntranceTable[] = { @@ -1701,31 +1703,31 @@ static EntranceTableEntry* sBeneathTheWellEntranceTable[] = { }; static EntranceTableEntry sZoraHallRoomsEntrance0[] = { - { 0x4C, 0x00, 0x0102 }, + { SCENE_BANDROOM, 0, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance1[] = { - { 0x4C, 0x01, 0x0102 }, + { SCENE_BANDROOM, 1, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance2[] = { - { 0x4C, 0x02, 0x0102 }, + { SCENE_BANDROOM, 2, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance3[] = { - { 0x4C, 0x03, 0x0102 }, + { SCENE_BANDROOM, 3, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance4[] = { - { 0x4C, 0x04, 0x858B }, + { SCENE_BANDROOM, 4, 0x858B }, }; static EntranceTableEntry sZoraHallRoomsEntrance5[] = { - { 0x4C, 0x05, 0x0102 }, + { SCENE_BANDROOM, 5, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance6[] = { - { 0x4C, 0x06, 0x0102 }, + { SCENE_BANDROOM, 6, 0x0102 }, }; static EntranceTableEntry* sZoraHallRoomsEntranceTable[] = { @@ -1734,23 +1736,23 @@ static EntranceTableEntry* sZoraHallRoomsEntranceTable[] = { }; static EntranceTableEntry sGoronVillageWinterEntrance0[] = { - { 0x4D, 0x00, 0xC102 }, + { SCENE_11GORONNOSATO, 0, 0xC102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance1[] = { - { 0x4D, 0x01, 0x4102 }, + { SCENE_11GORONNOSATO, 1, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance2[] = { - { 0x4D, 0x02, 0x4102 }, + { SCENE_11GORONNOSATO, 2, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance3[] = { - { 0x4D, 0x03, 0x4102 }, + { SCENE_11GORONNOSATO, 3, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance4[] = { - { 0x4D, 0x04, 0x0A14 }, + { SCENE_11GORONNOSATO, 4, 0x0A14 }, }; static EntranceTableEntry* sGoronVillageWinterEntranceTable[] = { @@ -1759,11 +1761,11 @@ static EntranceTableEntry* sGoronVillageWinterEntranceTable[] = { }; static EntranceTableEntry sGoronGraveryardEntrance0[] = { - { 0x4E, 0x00, 0x4102 }, + { SCENE_GORON_HAKA, 0, 0x4102 }, }; static EntranceTableEntry sGoronGraveryardEntrance1[] = { - { 0x4E, 0x01, 0x058B }, + { SCENE_GORON_HAKA, 1, 0x058B }, }; static EntranceTableEntry* sGoronGraveryardEntranceTable[] = { @@ -1772,7 +1774,7 @@ static EntranceTableEntry* sGoronGraveryardEntranceTable[] = { }; static EntranceTableEntry sSakonsHideoutEntrance0[] = { - { 0x4F, 0x00, 0x4102 }, + { SCENE_SECOM, 0, 0x4102 }, }; static EntranceTableEntry* sSakonsHideoutEntranceTable[] = { @@ -1780,39 +1782,39 @@ static EntranceTableEntry* sSakonsHideoutEntranceTable[] = { }; static EntranceTableEntry sMountainVillageWinterEntrance0[] = { - { 0x50, 0x00, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 0, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance1[] = { - { 0x50, 0x01, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 1, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance2[] = { - { 0x50, 0x02, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA, 2, 0xCA14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance3[] = { - { 0x50, 0x03, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 3, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance4[] = { - { 0x50, 0x04, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA, 4, 0xCA14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance5[] = { - { 0x50, 0x05, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 5, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance6[] = { - { 0x50, 0x06, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 6, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance7[] = { - { 0x50, 0x07, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 7, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance8[] = { - { 0x50, 0x08, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 8, 0x4A14 }, }; static EntranceTableEntry* sMountainVillageWinterEntranceTable[] = { @@ -1822,15 +1824,15 @@ static EntranceTableEntry* sMountainVillageWinterEntranceTable[] = { }; static EntranceTableEntry sGhostHutEntrance0[] = { - { 0x51, 0x00, 0x4102 }, + { SCENE_TOUGITES, 0, 0x4102 }, }; static EntranceTableEntry sGhostHutEntrance1[] = { - { 0x51, 0x01, 0x0102 }, + { SCENE_TOUGITES, 1, 0x0102 }, }; static EntranceTableEntry sGhostHutEntrance2[] = { - { 0x51, 0x02, 0x0102 }, + { SCENE_TOUGITES, 2, 0x0102 }, }; static EntranceTableEntry* sGhostHutEntranceTable[] = { @@ -1840,15 +1842,15 @@ static EntranceTableEntry* sGhostHutEntranceTable[] = { }; static EntranceTableEntry sDekuShrineEntrance0[] = { - { 0x52, 0x00, 0x4102 }, + { SCENE_DANPEI, 0, 0x4102 }, }; static EntranceTableEntry sDekuShrineEntrance1[] = { - { 0x52, 0x01, 0x0102 }, + { SCENE_DANPEI, 1, 0x0102 }, }; static EntranceTableEntry sDekuShrineEntrance2[] = { - { 0x52, 0x02, 0x0102 }, + { SCENE_DANPEI, 2, 0x0102 }, }; static EntranceTableEntry* sDekuShrineEntranceTable[] = { @@ -1858,15 +1860,15 @@ static EntranceTableEntry* sDekuShrineEntranceTable[] = { }; static EntranceTableEntry sRoadToIkanaEntrance0[] = { - { 0x53, 0x00, 0x8A14 }, + { SCENE_IKANAMAE, 0, 0x8A14 }, }; static EntranceTableEntry sRoadToIkanaEntrance1[] = { - { 0x53, 0x01, 0x8A14 }, + { SCENE_IKANAMAE, 1, 0x8A14 }, }; static EntranceTableEntry sRoadToIkanaEntrance2[] = { - { 0x53, 0x02, 0x0A14 }, + { SCENE_IKANAMAE, 2, 0x0A14 }, }; static EntranceTableEntry* sRoadToIkanaEntranceTable[] = { @@ -1876,7 +1878,7 @@ static EntranceTableEntry* sRoadToIkanaEntranceTable[] = { }; static EntranceTableEntry sMusicBoxHouseEntrance0[] = { - { 0x55, 0x00, 0x4102 }, + { SCENE_MUSICHOUSE, 0, 0x4102 }, }; static EntranceTableEntry* sMusicBoxHouseEntranceTable[] = { @@ -1884,8 +1886,8 @@ static EntranceTableEntry* sMusicBoxHouseEntranceTable[] = { }; static EntranceTableEntry sIgosDuIkanasLairEntrance0[] = { - { 0xAA, 0x00, 0x8102 }, - { 0xAA, 0x00, 0x8102 }, + { -SCENE_IKNINSIDE, 0, 0x8102 }, + { -SCENE_IKNINSIDE, 0, 0x8102 }, }; static EntranceTableEntry* sIgosDuIkanasLairEntranceTable[] = { @@ -1893,7 +1895,7 @@ static EntranceTableEntry* sIgosDuIkanasLairEntranceTable[] = { }; static EntranceTableEntry sSwordmansSchoolEntrance0[] = { - { 0x54, 0x00, 0x4102 }, + { SCENE_DOUJOU, 0, 0x4102 }, }; static EntranceTableEntry* sSwordmansSchoolEntranceTable[] = { @@ -1901,15 +1903,15 @@ static EntranceTableEntry* sSwordmansSchoolEntranceTable[] = { }; static EntranceTableEntry sTouristInformationEntrance0[] = { - { 0x57, 0x00, 0x4102 }, + { SCENE_MAP_SHOP, 0, 0x4102 }, }; static EntranceTableEntry sTouristInformationEntrance1[] = { - { 0x57, 0x01, 0x0102 }, + { SCENE_MAP_SHOP, 1, 0x0102 }, }; static EntranceTableEntry sTouristInformationEntrance2[] = { - { 0x57, 0x02, 0x0102 }, + { SCENE_MAP_SHOP, 2, 0x0102 }, }; static EntranceTableEntry* sTouristInformationEntranceTable[] = { @@ -1919,19 +1921,19 @@ static EntranceTableEntry* sTouristInformationEntranceTable[] = { }; static EntranceTableEntry sStoneTowerEntrance0[] = { - { 0x58, 0x00, 0x4102 }, + { SCENE_F40, 0, 0x4102 }, }; static EntranceTableEntry sStoneTowerEntrance1[] = { - { 0x58, 0x01, 0xCA14 }, + { SCENE_F40, 1, 0xCA14 }, }; static EntranceTableEntry sStoneTowerEntrance2[] = { - { 0x58, 0x02, 0xC102 }, + { SCENE_F40, 2, 0xC102 }, }; static EntranceTableEntry sStoneTowerEntrance3[] = { - { 0x58, 0x03, 0x4A14 }, + { SCENE_F40, 3, 0x4A14 }, }; static EntranceTableEntry* sStoneTowerEntranceTable[] = { @@ -1942,11 +1944,11 @@ static EntranceTableEntry* sStoneTowerEntranceTable[] = { }; static EntranceTableEntry sStoneTowerInvertedEntrance0[] = { - { 0x59, 0x00, 0x4A14 }, + { SCENE_F41, 0, 0x4A14 }, }; static EntranceTableEntry sStoneTowerInvertedEntrance1[] = { - { 0x59, 0x01, 0xC102 }, + { SCENE_F41, 1, 0xC102 }, }; static EntranceTableEntry* sStoneTowerInvertedEntranceTable[] = { @@ -1955,40 +1957,40 @@ static EntranceTableEntry* sStoneTowerInvertedEntranceTable[] = { }; static EntranceTableEntry sMountainVillageSpringEntrance0[] = { - { 0x5A, 0x00, 0x4A14 }, - { 0x5A, 0x00, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 0, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 0, 0x4A14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance1[] = { - { 0x5A, 0x01, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 1, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance2[] = { - { 0x5A, 0x02, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 2, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance3[] = { - { 0x5A, 0x03, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 3, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance4[] = { - { 0x5A, 0x04, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 4, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance5[] = { - { 0x5A, 0x05, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 5, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance6[] = { - { 0x5A, 0x06, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 6, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance7[] = { - { 0x5A, 0x07, 0x458B }, + { SCENE_10YUKIYAMANOMURA2, 7, 0x458B }, }; static EntranceTableEntry sMountainVillageSpringEntrance8[] = { - { 0x5A, 0x08, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 8, 0x4A14 }, }; static EntranceTableEntry* sMountainVillageSpringEntranceTable[] = { @@ -1998,13 +2000,13 @@ static EntranceTableEntry* sMountainVillageSpringEntranceTable[] = { }; static EntranceTableEntry sPathToSnowheadEntrance0[] = { - { 0x5B, 0x00, 0xCA14 }, - { 0x5B, 0x00, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 0, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 0, 0xCA14 }, }; static EntranceTableEntry sPathToSnowheadEntrance1[] = { - { 0x5B, 0x01, 0xCA14 }, - { 0x5B, 0x01, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 1, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 1, 0xCA14 }, }; static EntranceTableEntry* sPathToSnowheadEntranceTable[] = { @@ -2013,23 +2015,23 @@ static EntranceTableEntry* sPathToSnowheadEntranceTable[] = { }; static EntranceTableEntry sSnowheadEntrance0[] = { - { 0x5C, 0x00, 0xCA14 }, - { 0x5C, 0x00, 0xCA14 }, + { SCENE_12HAKUGINMAE, 0, 0xCA14 }, + { SCENE_12HAKUGINMAE, 0, 0xCA14 }, }; static EntranceTableEntry sSnowheadEntrance1[] = { - { 0x5C, 0x01, 0x4102 }, - { 0x5C, 0x01, 0x4102 }, + { SCENE_12HAKUGINMAE, 1, 0x4102 }, + { SCENE_12HAKUGINMAE, 1, 0x4102 }, }; static EntranceTableEntry sSnowheadEntrance2[] = { - { 0x5C, 0x02, 0x4102 }, - { 0x5C, 0x02, 0x4102 }, + { SCENE_12HAKUGINMAE, 2, 0x4102 }, + { SCENE_12HAKUGINMAE, 2, 0x4102 }, }; static EntranceTableEntry sSnowheadEntrance3[] = { - { 0x5C, 0x03, 0x4102 }, - { 0x5C, 0x03, 0x4102 }, + { SCENE_12HAKUGINMAE, 3, 0x4102 }, + { SCENE_12HAKUGINMAE, 3, 0x4102 }, }; static EntranceTableEntry* sSnowheadEntranceTable[] = { @@ -2040,15 +2042,15 @@ static EntranceTableEntry* sSnowheadEntranceTable[] = { }; static EntranceTableEntry sPathToGoronVillageWinterEntrance0[] = { - { 0x5D, 0x00, 0x8A14 }, + { SCENE_17SETUGEN, 0, 0x8A14 }, }; static EntranceTableEntry sPathToGoronVillageWinterEntrance1[] = { - { 0x5D, 0x01, 0x8102 }, + { SCENE_17SETUGEN, 1, 0x8102 }, }; static EntranceTableEntry sPathToGoronVillageWinterEntrance2[] = { - { 0x5D, 0x02, 0x0102 }, + { SCENE_17SETUGEN, 2, 0x0102 }, }; static EntranceTableEntry* sPathToGoronVillageWinterEntranceTable[] = { @@ -2058,15 +2060,15 @@ static EntranceTableEntry* sPathToGoronVillageWinterEntranceTable[] = { }; static EntranceTableEntry sPathToGoronVillageSpringEntrance0[] = { - { 0x5E, 0x00, 0x8A14 }, + { SCENE_17SETUGEN2, 0, 0x8A14 }, }; static EntranceTableEntry sPathToGoronVillageSpringEntrance1[] = { - { 0x5E, 0x01, 0x8102 }, + { SCENE_17SETUGEN2, 1, 0x8102 }, }; static EntranceTableEntry sPathToGoronVillageSpringEntrance2[] = { - { 0x5E, 0x02, 0x0102 }, + { SCENE_17SETUGEN2, 2, 0x0102 }, }; static EntranceTableEntry* sPathToGoronVillageSpringEntranceTable[] = { @@ -2076,11 +2078,11 @@ static EntranceTableEntry* sPathToGoronVillageSpringEntranceTable[] = { }; static EntranceTableEntry sGyorgsLairEntrance0[] = { - { 0xA1, 0x00, 0x8102 }, + { -SCENE_SEA_BS, 0, 0x8102 }, }; static EntranceTableEntry sGyorgsLairEntrance1[] = { - { 0xA1, 0x01, 0x8102 }, + { -SCENE_SEA_BS, 1, 0x8102 }, }; static EntranceTableEntry* sGyorgsLairEntranceTable[] = { @@ -2089,7 +2091,7 @@ static EntranceTableEntry* sGyorgsLairEntranceTable[] = { }; static EntranceTableEntry sSecretShrineEntrance0[] = { - { 0xA0, 0x00, 0x4102 }, + { -SCENE_RANDOM, 0, 0x4102 }, }; static EntranceTableEntry* sSecretShrineEntranceTable[] = { @@ -2097,28 +2099,28 @@ static EntranceTableEntry* sSecretShrineEntranceTable[] = { }; static EntranceTableEntry sStockPotInnEntrance0[] = { - { 0x61, 0x00, 0x4102 }, - { 0x61, 0x00, 0x8102 }, + { SCENE_YADOYA, 0, 0x4102 }, + { SCENE_YADOYA, 0, 0x8102 }, }; static EntranceTableEntry sStockPotInnEntrance1[] = { - { 0x61, 0x01, 0x4102 }, + { SCENE_YADOYA, 1, 0x4102 }, }; static EntranceTableEntry sStockPotInnEntrance2[] = { - { 0x61, 0x02, 0x0102 }, + { SCENE_YADOYA, 2, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance3[] = { - { 0x61, 0x03, 0x0102 }, + { SCENE_YADOYA, 3, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance4[] = { - { 0x61, 0x04, 0x0102 }, + { SCENE_YADOYA, 4, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance5[] = { - { 0x61, 0x05, 0x0102 }, + { SCENE_YADOYA, 5, 0x0102 }, }; static EntranceTableEntry* sStockPotInnEntranceTable[] = { @@ -2127,7 +2129,7 @@ static EntranceTableEntry* sStockPotInnEntranceTable[] = { }; static EntranceTableEntry sGreatBayCutsceneEntrance0[] = { - { 0x62, 0x00, 0x4102 }, + { SCENE_KONPEKI_ENT, 0, 0x4102 }, }; static EntranceTableEntry* sGreatBayCutsceneEntranceTable[] = { @@ -2135,31 +2137,31 @@ static EntranceTableEntry* sGreatBayCutsceneEntranceTable[] = { }; static EntranceTableEntry sClockTowerInteriorEntrance0[] = { - { 0x63, 0x00, 0x0102 }, + { SCENE_INSIDETOWER, 0, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance1[] = { - { 0x63, 0x01, 0x0102 }, + { SCENE_INSIDETOWER, 1, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance2[] = { - { 0x63, 0x02, 0x058B }, + { SCENE_INSIDETOWER, 2, 0x058B }, }; static EntranceTableEntry sClockTowerInteriorEntrance3[] = { - { 0x63, 0x03, 0x0102 }, + { SCENE_INSIDETOWER, 3, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance4[] = { - { 0x63, 0x04, 0x058B }, + { SCENE_INSIDETOWER, 4, 0x058B }, }; static EntranceTableEntry sClockTowerInteriorEntrance5[] = { - { 0x63, 0x05, 0x0102 }, + { SCENE_INSIDETOWER, 5, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance6[] = { - { 0x63, 0x06, 0x858B }, + { SCENE_INSIDETOWER, 6, 0x858B }, }; static EntranceTableEntry* sClockTowerInteriorEntranceTable[] = { @@ -2169,7 +2171,7 @@ static EntranceTableEntry* sClockTowerInteriorEntranceTable[] = { }; static EntranceTableEntry sWoodsOfMysteryEntrance0[] = { - { 0x64, 0x00, 0x4102 }, + { SCENE_26SARUNOMORI, 0, 0x4102 }, }; static EntranceTableEntry* sWoodsOfMysteryEntranceTable[] = { @@ -2177,24 +2179,24 @@ static EntranceTableEntry* sWoodsOfMysteryEntranceTable[] = { }; static EntranceTableEntry sLostWoodsEntrance0[] = { - { 0x9B, 0x00, 0x858B }, - { 0x9B, 0x00, 0x8183 }, - { 0x9B, 0x00, 0x858B }, - { 0x9B, 0x00, 0x8102 }, + { -SCENE_LOST_WOODS, 0, 0x858B }, + { -SCENE_LOST_WOODS, 0, 0x8183 }, + { -SCENE_LOST_WOODS, 0, 0x858B }, + { -SCENE_LOST_WOODS, 0, 0x8102 }, }; static EntranceTableEntry sLostWoodsEntrance1[] = { - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, }; static EntranceTableEntry sLostWoodsEntrance2[] = { - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, }; static EntranceTableEntry* sLostWoodsEntranceTable[] = { @@ -2204,7 +2206,7 @@ static EntranceTableEntry* sLostWoodsEntranceTable[] = { }; static EntranceTableEntry sMoonLinkTrialEntrance0[] = { - { 0x66, 0x00, 0x0387 }, + { SCENE_LAST_LINK, 0, 0x0387 }, }; static EntranceTableEntry* sMoonLinkTrialEntranceTable[] = { @@ -2212,7 +2214,7 @@ static EntranceTableEntry* sMoonLinkTrialEntranceTable[] = { }; static EntranceTableEntry sTheMoonEntrance0[] = { - { 0x67, 0x00, 0x0387 }, + { SCENE_SOUGEN, 0, 0x0387 }, }; static EntranceTableEntry* sTheMoonEntranceTable[] = { @@ -2220,11 +2222,11 @@ static EntranceTableEntry* sTheMoonEntranceTable[] = { }; static EntranceTableEntry sBombShopEntrance0[] = { - { 0x68, 0x00, 0x4102 }, + { SCENE_BOMYA, 0, 0x4102 }, }; static EntranceTableEntry sBombShopEntrance1[] = { - { 0x68, 0x01, 0x0102 }, + { SCENE_BOMYA, 1, 0x0102 }, }; static EntranceTableEntry* sBombShopEntranceTable[] = { @@ -2233,9 +2235,10 @@ static EntranceTableEntry* sBombShopEntranceTable[] = { }; static EntranceTableEntry sGiantsChamberEntrance0[] = { - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, }; static EntranceTableEntry* sGiantsChamberEntranceTable[] = { @@ -2243,27 +2246,27 @@ static EntranceTableEntry* sGiantsChamberEntranceTable[] = { }; static EntranceTableEntry sGormanTrackEntrance0[] = { - { 0x6A, 0x00, 0x4A14 }, + { SCENE_KOEPONARACE, 0, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance1[] = { - { 0x6A, 0x01, 0x4A14 }, + { SCENE_KOEPONARACE, 1, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance2[] = { - { 0x6A, 0x02, 0x4A14 }, + { SCENE_KOEPONARACE, 2, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance3[] = { - { 0x6A, 0x03, 0x4A14 }, + { SCENE_KOEPONARACE, 3, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance4[] = { - { 0x6A, 0x04, 0x0102 }, + { SCENE_KOEPONARACE, 4, 0x0102 }, }; static EntranceTableEntry sGormanTrackEntrance5[] = { - { 0x6A, 0x05, 0x0A14 }, + { SCENE_KOEPONARACE, 5, 0x0A14 }, }; static EntranceTableEntry* sGormanTrackEntranceTable[] = { @@ -2272,18 +2275,18 @@ static EntranceTableEntry* sGormanTrackEntranceTable[] = { }; static EntranceTableEntry sGoronRacetrackEntrance0[] = { - { 0x6B, 0x00, 0x4102 }, - { 0x6B, 0x00, 0x4102 }, + { SCENE_GORONRACE, 0, 0x4102 }, + { SCENE_GORONRACE, 0, 0x4102 }, }; static EntranceTableEntry sGoronRacetrackEntrance1[] = { - { 0x6B, 0x01, 0x8A14 }, - { 0x6B, 0x01, 0x8A14 }, + { SCENE_GORONRACE, 1, 0x8A14 }, + { SCENE_GORONRACE, 1, 0x8A14 }, }; static EntranceTableEntry sGoronRacetrackEntrance2[] = { - { 0x6B, 0x02, 0x0A14 }, - { 0x6B, 0x02, 0x0A14 }, + { SCENE_GORONRACE, 2, 0x0A14 }, + { SCENE_GORONRACE, 2, 0x0A14 }, }; static EntranceTableEntry* sGoronRacetrackEntranceTable[] = { @@ -2293,57 +2296,57 @@ static EntranceTableEntry* sGoronRacetrackEntranceTable[] = { }; static EntranceTableEntry sEastClockTownEntrance0[] = { - { 0x6C, 0x00, 0x4102 }, - { 0x6C, 0x00, 0x8102 }, - { 0x6C, 0x00, 0x058B }, + { SCENE_TOWN, 0, 0x4102 }, + { SCENE_TOWN, 0, 0x8102 }, + { SCENE_TOWN, 0, 0x058B }, }; static EntranceTableEntry sEastClockTownEntrance1[] = { - { 0x6C, 0x01, 0xCA14 }, + { SCENE_TOWN, 1, 0xCA14 }, }; static EntranceTableEntry sEastClockTownEntrance2[] = { - { 0x6C, 0x02, 0x4102 }, + { SCENE_TOWN, 2, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance3[] = { - { 0x6C, 0x03, 0xC102 }, + { SCENE_TOWN, 3, 0xC102 }, }; static EntranceTableEntry sEastClockTownEntrance4[] = { - { 0x6C, 0x04, 0x4102 }, + { SCENE_TOWN, 4, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance5[] = { - { 0x6C, 0x05, 0xC102 }, + { SCENE_TOWN, 5, 0xC102 }, }; static EntranceTableEntry sEastClockTownEntrance6[] = { - { 0x6C, 0x06, 0x4102 }, + { SCENE_TOWN, 6, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance7[] = { - { 0x6C, 0x07, 0x4102 }, + { SCENE_TOWN, 7, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance8[] = { - { 0x6C, 0x08, 0x4102 }, + { SCENE_TOWN, 8, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance9[] = { - { 0x6C, 0x09, 0x4102 }, + { SCENE_TOWN, 9, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance10[] = { - { 0x6C, 0x0A, 0x4102 }, + { SCENE_TOWN, 10, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance11[] = { - { 0x6C, 0x0B, 0x4102 }, + { SCENE_TOWN, 11, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance12[] = { - { 0x6C, 0x0C, 0x4102 }, + { SCENE_TOWN, 12, 0x4102 }, }; static EntranceTableEntry* sEastClockTownEntranceTable[] = { @@ -2354,44 +2357,44 @@ static EntranceTableEntry* sEastClockTownEntranceTable[] = { }; static EntranceTableEntry sWestClockTownEntrance0[] = { - { 0x6D, 0x00, 0x4102 }, - { 0x6D, 0x00, 0x8102 }, + { SCENE_ICHIBA, 0, 0x4102 }, + { SCENE_ICHIBA, 0, 0x8102 }, }; static EntranceTableEntry sWestClockTownEntrance1[] = { - { 0x6D, 0x01, 0xC102 }, + { SCENE_ICHIBA, 1, 0xC102 }, }; static EntranceTableEntry sWestClockTownEntrance2[] = { - { 0x6D, 0x02, 0xCA14 }, + { SCENE_ICHIBA, 2, 0xCA14 }, }; static EntranceTableEntry sWestClockTownEntrance3[] = { - { 0x6D, 0x03, 0x4102 }, + { SCENE_ICHIBA, 3, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance4[] = { - { 0x6D, 0x04, 0x4102 }, + { SCENE_ICHIBA, 4, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance5[] = { - { 0x6D, 0x05, 0x4102 }, + { SCENE_ICHIBA, 5, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance6[] = { - { 0x6D, 0x06, 0x4102 }, + { SCENE_ICHIBA, 6, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance7[] = { - { 0x6D, 0x07, 0x4102 }, + { SCENE_ICHIBA, 7, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance8[] = { - { 0x6D, 0x08, 0x4102 }, + { SCENE_ICHIBA, 8, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance9[] = { - { 0x6D, 0x09, 0x4A14 }, + { SCENE_ICHIBA, 9, 0x4A14 }, }; static EntranceTableEntry* sWestClockTownEntranceTable[] = { @@ -2401,36 +2404,36 @@ static EntranceTableEntry* sWestClockTownEntranceTable[] = { }; static EntranceTableEntry sNorthClockTownEntrance0[] = { - { 0x6E, 0x00, 0x4102 }, - { 0x6E, 0x00, 0x458B }, + { SCENE_BACKTOWN, 0, 0x4102 }, + { SCENE_BACKTOWN, 0, 0x458B }, }; static EntranceTableEntry sNorthClockTownEntrance1[] = { - { 0x6E, 0x01, 0xC102 }, + { SCENE_BACKTOWN, 1, 0xC102 }, }; static EntranceTableEntry sNorthClockTownEntrance2[] = { - { 0x6E, 0x02, 0xC102 }, + { SCENE_BACKTOWN, 2, 0xC102 }, }; static EntranceTableEntry sNorthClockTownEntrance3[] = { - { 0x6E, 0x03, 0x4102 }, + { SCENE_BACKTOWN, 3, 0x4102 }, }; static EntranceTableEntry sNorthClockTownEntrance4[] = { - { 0x6E, 0x04, 0x4102 }, + { SCENE_BACKTOWN, 4, 0x4102 }, }; static EntranceTableEntry sNorthClockTownEntrance5[] = { - { 0x6E, 0x05, 0x8A14 }, + { SCENE_BACKTOWN, 5, 0x8A14 }, }; static EntranceTableEntry sNorthClockTownEntrance6[] = { - { 0x6E, 0x06, 0x8A14 }, + { SCENE_BACKTOWN, 6, 0x8A14 }, }; static EntranceTableEntry sNorthClockTownEntrance7[] = { - { 0x6E, 0x07, 0x8A14 }, + { SCENE_BACKTOWN, 7, 0x8A14 }, }; static EntranceTableEntry* sNorthClockTownEntranceTable[] = { @@ -2439,51 +2442,51 @@ static EntranceTableEntry* sNorthClockTownEntranceTable[] = { }; static EntranceTableEntry sSouthClockTownEntrance0[] = { - { 0x6F, 0x00, 0x4102 }, - { 0x6F, 0x00, 0x8102 }, - { 0x6F, 0x00, 0x0A14 }, - { 0x6F, 0x00, 0x0102 }, + { SCENE_CLOCKTOWER, 0, 0x4102 }, + { SCENE_CLOCKTOWER, 0, 0x8102 }, + { SCENE_CLOCKTOWER, 0, 0x0A14 }, + { SCENE_CLOCKTOWER, 0, 0x0102 }, }; static EntranceTableEntry sSouthClockTownEntrance1[] = { - { 0x6F, 0x01, 0x4102 }, - { 0x6F, 0x01, 0x8102 }, + { SCENE_CLOCKTOWER, 1, 0x4102 }, + { SCENE_CLOCKTOWER, 1, 0x8102 }, }; static EntranceTableEntry sSouthClockTownEntrance2[] = { - { 0x6F, 0x02, 0xC102 }, + { SCENE_CLOCKTOWER, 2, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance3[] = { - { 0x6F, 0x03, 0xCA14 }, + { SCENE_CLOCKTOWER, 3, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance4[] = { - { 0x6F, 0x04, 0xC102 }, + { SCENE_CLOCKTOWER, 4, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance5[] = { - { 0x6F, 0x05, 0xC102 }, + { SCENE_CLOCKTOWER, 5, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance6[] = { - { 0x6F, 0x06, 0xCA14 }, + { SCENE_CLOCKTOWER, 6, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance7[] = { - { 0x6F, 0x07, 0xCA14 }, + { SCENE_CLOCKTOWER, 7, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance8[] = { - { 0x6F, 0x08, 0x4A14 }, + { SCENE_CLOCKTOWER, 8, 0x4A14 }, }; static EntranceTableEntry sSouthClockTownEntrance9[] = { - { 0x6F, 0x09, 0x4A14 }, + { SCENE_CLOCKTOWER, 9, 0x4A14 }, }; static EntranceTableEntry sSouthClockTownEntrance10[] = { - { 0x6F, 0x0A, 0x058B }, + { SCENE_CLOCKTOWER, 10, 0x058B }, }; static EntranceTableEntry* sSouthClockTownEntranceTable[] = { @@ -2493,15 +2496,15 @@ static EntranceTableEntry* sSouthClockTownEntranceTable[] = { }; static EntranceTableEntry sLaundryPoolEntrance0[] = { - { 0x70, 0x00, 0xCA14 }, + { SCENE_ALLEY, 0, 0xCA14 }, }; static EntranceTableEntry sLaundryPoolEntrance1[] = { - { 0x70, 0x01, 0x4A14 }, + { SCENE_ALLEY, 1, 0x4A14 }, }; static EntranceTableEntry sLaundryPoolEntrance2[] = { - { 0x70, 0x02, 0x4102 }, + { SCENE_ALLEY, 2, 0x4102 }, }; static EntranceTableEntry* sLaundryPoolEntranceTable[] = { @@ -2511,71 +2514,71 @@ static EntranceTableEntry* sLaundryPoolEntranceTable[] = { }; static EntranceTableEntry sGrottosEntrance0[] = { - { 0x07, 0x00, 0x0102 }, + { SCENE_KAKUSIANA, 0, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance1[] = { - { 0x07, 0x01, 0x0102 }, + { SCENE_KAKUSIANA, 1, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance2[] = { - { 0x07, 0x02, 0x0102 }, + { SCENE_KAKUSIANA, 2, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance3[] = { - { 0x07, 0x03, 0x0102 }, + { SCENE_KAKUSIANA, 3, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance4[] = { - { 0x07, 0x04, 0x0102 }, + { SCENE_KAKUSIANA, 4, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance5[] = { - { 0x07, 0x05, 0x0102 }, + { SCENE_KAKUSIANA, 5, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance6[] = { - { 0x07, 0x06, 0x0102 }, + { SCENE_KAKUSIANA, 6, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance7[] = { - { 0x07, 0x07, 0x0102 }, + { SCENE_KAKUSIANA, SCENE_KAKUSIANA, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance8[] = { - { 0x07, 0x08, 0x0102 }, + { SCENE_KAKUSIANA, 8, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance9[] = { - { 0x07, 0x09, 0x0102 }, + { SCENE_KAKUSIANA, 9, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance10[] = { - { 0x07, 0x0A, 0x0102 }, + { SCENE_KAKUSIANA, 10, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance11[] = { - { 0x07, 0x0B, 0x0102 }, + { SCENE_KAKUSIANA, 11, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance12[] = { - { 0x07, 0x0C, 0x0102 }, + { SCENE_KAKUSIANA, 12, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance13[] = { - { 0x07, 0x0D, 0x0102 }, + { SCENE_KAKUSIANA, 13, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance14[] = { - { 0x07, 0x0E, 0x0102 }, + { SCENE_KAKUSIANA, 14, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance15[] = { - { 0x07, 0x0F, 0x0102 }, + { SCENE_KAKUSIANA, 15, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance16[] = { - { 0x07, 0x10, 0x0102 }, + { SCENE_KAKUSIANA, 16, 0x0102 }, }; static EntranceTableEntry* sGrottosEntranceTable[] = { @@ -2586,63 +2589,73 @@ static EntranceTableEntry* sGrottosEntranceTable[] = { }; static EntranceTableEntry sCutsceneEntrance0[] = { - { 0xF8, 0x00, 0x0102 }, { 0xF8, 0x00, 0x0102 }, { 0xF8, 0x00, 0x8102 }, { 0xF8, 0x00, 0x0102 }, - { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, - { 0xF8, 0x00, 0x0183 }, { 0xF8, 0x00, 0x0183 }, { 0xF8, 0x00, 0x8102 }, { 0xF8, 0x00, 0x0102 }, + { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x8102 }, + { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x058B }, + { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x0183 }, + { -SCENE_SPOT00, 0, 0x0183 }, { -SCENE_SPOT00, 0, 0x8102 }, { -SCENE_SPOT00, 0, 0x0102 }, }; static EntranceTableEntry sCutsceneEntrance1[] = { - { 0xF8, 0x01, 0x0183 }, { 0xF8, 0x01, 0x0102 }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x0102 }, - { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x058B }, - { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x0102 }, + { -SCENE_SPOT00, 1, 0x0183 }, { -SCENE_SPOT00, 1, 0x0102 }, { -SCENE_SPOT00, 1, 0x8102 }, + { -SCENE_SPOT00, 1, 0x0102 }, { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x058B }, + { -SCENE_SPOT00, 1, 0x058B }, { -SCENE_SPOT00, 1, 0x058B }, { -SCENE_SPOT00, 1, 0x058B }, + { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x0102 }, }; static EntranceTableEntry sCutsceneEntrance2[] = { - { 0xF8, 0x02, 0x0183 }, { 0xF8, 0x02, 0x0102 }, { 0xF8, 0x02, 0x8102 }, { 0xF8, 0x02, 0x0102 }, - { 0xF8, 0x02, 0x8102 }, { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x058B }, - { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x858B }, { 0xF8, 0x02, 0x8102 }, + { -SCENE_SPOT00, 2, 0x0183 }, { -SCENE_SPOT00, 2, 0x0102 }, { -SCENE_SPOT00, 2, 0x8102 }, + { -SCENE_SPOT00, 2, 0x0102 }, { -SCENE_SPOT00, 2, 0x8102 }, { -SCENE_SPOT00, 2, 0x058B }, + { -SCENE_SPOT00, 2, 0x058B }, { -SCENE_SPOT00, 2, 0x058B }, { -SCENE_SPOT00, 2, 0x058B }, + { -SCENE_SPOT00, 2, 0x858B }, { -SCENE_SPOT00, 2, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance3[] = { - { 0xF8, 0x03, 0x0183 }, { 0xF8, 0x03, 0x0102 }, { 0xF8, 0x03, 0x8102 }, { 0xF8, 0x03, 0x0102 }, - { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, - { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x8102 }, + { -SCENE_SPOT00, 3, 0x0183 }, { -SCENE_SPOT00, 3, 0x0102 }, { -SCENE_SPOT00, 3, 0x8102 }, + { -SCENE_SPOT00, 3, 0x0102 }, { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, + { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, + { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance4[] = { - { 0xF8, 0x04, 0x0183 }, { 0xF8, 0x04, 0x0102 }, { 0xF8, 0x04, 0x8102 }, { 0xF8, 0x04, 0x0102 }, - { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, - { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x8102 }, + { -SCENE_SPOT00, 4, 0x0183 }, { -SCENE_SPOT00, 4, 0x0102 }, { -SCENE_SPOT00, 4, 0x8102 }, + { -SCENE_SPOT00, 4, 0x0102 }, { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, + { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, + { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance5[] = { - { 0xF8, 0x05, 0x0183 }, { 0xF8, 0x05, 0x0102 }, { 0xF8, 0x05, 0x8102 }, { 0xF8, 0x05, 0x0102 }, - { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, - { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x858B }, { 0xF8, 0x05, 0x8102 }, + { -SCENE_SPOT00, 5, 0x0183 }, { -SCENE_SPOT00, 5, 0x0102 }, { -SCENE_SPOT00, 5, 0x8102 }, + { -SCENE_SPOT00, 5, 0x0102 }, { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, + { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, + { -SCENE_SPOT00, 5, 0x858B }, { -SCENE_SPOT00, 5, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance6[] = { - { 0xF8, 0x06, 0x0183 }, { 0xF8, 0x06, 0x0102 }, { 0xF8, 0x06, 0x8102 }, { 0xF8, 0x06, 0x0102 }, - { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, - { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x858B }, { 0xF8, 0x06, 0x8102 }, + { -SCENE_SPOT00, 6, 0x0183 }, { -SCENE_SPOT00, 6, 0x0102 }, { -SCENE_SPOT00, 6, 0x8102 }, + { -SCENE_SPOT00, 6, 0x0102 }, { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, + { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, + { -SCENE_SPOT00, 6, 0x858B }, { -SCENE_SPOT00, 6, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance7[] = { - { 0xF8, 0x07, 0x0183 }, { 0xF8, 0x07, 0x0102 }, { 0xF8, 0x07, 0x8102 }, { 0xF8, 0x07, 0x0102 }, - { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, - { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x858B }, { 0xF8, 0x07, 0x8102 }, + { -SCENE_SPOT00, 7, 0x0183 }, { -SCENE_SPOT00, 7, 0x0102 }, { -SCENE_SPOT00, 7, 0x8102 }, + { -SCENE_SPOT00, 7, 0x0102 }, { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, + { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, + { -SCENE_SPOT00, 7, 0x858B }, { -SCENE_SPOT00, 7, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance8[] = { - { 0xF8, 0x08, 0x0183 }, { 0xF8, 0x08, 0x0102 }, { 0xF8, 0x08, 0x8102 }, { 0xF8, 0x08, 0x0102 }, - { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, - { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x858B }, { 0xF8, 0x08, 0x8102 }, + { -SCENE_SPOT00, 8, 0x0183 }, { -SCENE_SPOT00, 8, 0x0102 }, { -SCENE_SPOT00, 8, 0x8102 }, + { -SCENE_SPOT00, 8, 0x0102 }, { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, + { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, + { -SCENE_SPOT00, 8, 0x858B }, { -SCENE_SPOT00, 8, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance9[] = { - { 0xF8, 0x09, 0x0183 }, { 0xF8, 0x09, 0x0102 }, { 0xF8, 0x09, 0x8102 }, { 0xF8, 0x09, 0x0102 }, - { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, - { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x858B }, { 0xF8, 0x09, 0x8102 }, + { -SCENE_SPOT00, 9, 0x0183 }, { -SCENE_SPOT00, 9, 0x0102 }, { -SCENE_SPOT00, 9, 0x8102 }, + { -SCENE_SPOT00, 9, 0x0102 }, { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, + { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, + { -SCENE_SPOT00, 9, 0x858B }, { -SCENE_SPOT00, 9, 0x8102 }, }; static EntranceTableEntry* sCutsceneEntranceTable[] = { @@ -2783,19 +2796,19 @@ EntranceTableEntry* Entrance_GetTableEntry(u16 entrance) { /** * Returns the scene index from a given entrance index. */ -s32 Entrance_GetSceneNum(u16 entrance) { +s32 Entrance_GetSceneId(u16 entrance) { EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); - return tableEntry->sceneNum; + return tableEntry->sceneId; } /** * Returns the absolute value scene index (since for some reason some of them are negative) from a given entrance index. */ -s32 Entrance_GetSceneNumAbsolute(u16 entrance) { +s32 Entrance_GetSceneIdAbsolute(u16 entrance) { EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); - return ABS_ALT(tableEntry->sceneNum); + return ABS_ALT(tableEntry->sceneId); } /** diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c index cfc6293ba..6a2492631 100644 --- a/src/code/z_schedule.c +++ b/src/code/z_schedule.c @@ -130,9 +130,9 @@ s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleOutput* output) s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; - s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + s16 sceneId = (cmd->sceneIdH << 8) | cmd->sceneIdL; - if (scene != play->sceneNum) { + if (sceneId != play->sceneId) { *script += cmd->offset; } @@ -141,9 +141,9 @@ s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleOutput* outp s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; - s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + s16 sceneId = (cmd->sceneIdH << 8) | cmd->sceneIdL; - if (scene != play->sceneNum) { + if (sceneId != play->sceneId) { *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); } diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 7a234ca22..5d37e3eac 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -21,7 +21,7 @@ s32 Snap_RecordPictographedActors(PlayState* play) { gSaveContext.save.pictoFlags0 = 0; gSaveContext.save.pictoFlags1 = 0; - if (play->sceneNum == SCENE_20SICHITAI) { + if (play->sceneId == SCENE_20SICHITAI) { Snap_SetFlag(PICTOGRAPH_IN_SWAMP); } @@ -30,7 +30,7 @@ s32 Snap_RecordPictographedActors(PlayState* play) { seen = 0; // Actors which must be pictographed in a specific scene - switch (play->sceneNum) { + switch (play->sceneId) { case SCENE_20SICHITAI: if ((actor->id == ACTOR_EN_MNK) || (actor->id == ACTOR_EN_BIGOKUTA)) { seen = PICTO_SEEN_IN_SCENE; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5d018a995..73b0a0af0 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -248,7 +248,7 @@ void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene */ void Sram_SaveEndOfCycle(PlayState* play) { - s16 sceneNum; + s16 sceneId; s32 j; s32 i; u8 slot; @@ -264,13 +264,13 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.save.playerData.deaths = 999; } - sceneNum = Play_GetOriginalSceneNumber(play->sceneNum); + sceneId = Play_GetOriginalSceneId(play->sceneId); Play_SaveCycleSceneFlags(&play->state); - play->actorCtx.sceneFlags.chest &= D_801C5FC0[sceneNum][2]; - play->actorCtx.sceneFlags.switches[0] &= D_801C5FC0[sceneNum][0]; - play->actorCtx.sceneFlags.switches[1] &= D_801C5FC0[sceneNum][1]; - play->actorCtx.sceneFlags.collectible[0] &= D_801C5FC0[sceneNum][3]; + play->actorCtx.sceneFlags.chest &= D_801C5FC0[sceneId][2]; + play->actorCtx.sceneFlags.switches[0] &= D_801C5FC0[sceneId][0]; + play->actorCtx.sceneFlags.switches[1] &= D_801C5FC0[sceneId][1]; + play->actorCtx.sceneFlags.collectible[0] &= D_801C5FC0[sceneId][3]; play->actorCtx.sceneFlags.clearedRoom = 0; for (i = 0; i < SCENE_MAX; i++) { @@ -608,7 +608,7 @@ SavePlayerData sSaveDefaultPlayerData = { 0xFF, // unk_20 0x0000, // owlActivationFlags 0xFF, // unk_24 - SCENE_SPOT00, // savedSceneNum + SCENE_SPOT00, // savedSceneId }; ItemEquips sSaveDefaultItemEquips = { @@ -679,7 +679,7 @@ void Sram_InitNewSave(void) { 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.sceneId = SCENE_F01; gSaveContext.save.horseData.pos.x = -1420; gSaveContext.save.horseData.pos.y = 257; gSaveContext.save.horseData.pos.z = -1285; @@ -708,7 +708,7 @@ SavePlayerData sSaveDebugPlayerData = { 0xFF, // unk_20 0, // owlActivationFlags 0xFF, // unk_24 - SCENE_SPOT00, // savedSceneNum + SCENE_SPOT00, // savedSceneId }; ItemEquips sSaveDebugItemEquips = { @@ -839,7 +839,7 @@ void Sram_InitDebugSave(void) { gSaveContext.save.hasTatl = true; - gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.sceneId = SCENE_F01; gSaveContext.save.horseData.pos.x = -1420; gSaveContext.save.horseData.pos.y = 257; gSaveContext.save.horseData.pos.z = -1285; diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 7975b1c85..6dd46633c 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -75,7 +75,7 @@ void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) skyboxCtx->envB = 40; // Inverted Stone Tower Temple and Inverted Stone Tower - if ((play->sceneNum == SCENE_F41) || (play->sceneNum == SCENE_INISIE_R)) { + if ((play->sceneId == SCENE_F41) || (play->sceneId == SCENE_INISIE_R)) { skyboxCtx->rotZ = 3.15000009537f; } } 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 541a4d93d..58d27d448 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -162,7 +162,7 @@ void DmAh_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.01f); this->unk_27C |= 1; - if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { this->unk_280 = func_80C1D78C(play); func_80C1D410(this, 1); this->actionFunc = func_80C1D92C; 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 4cd28f454..5e03eb74c 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -183,7 +183,7 @@ void func_80C1C958(DmAn* this, PlayState* play) { this->unk_2AE |= 1; this->actor.draw = func_80C1D0B0; - if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { this->unk_2B4 = func_80C1C8E8(play); func_80C1C4D8(this, play, 1); this->actionFunc = func_80C1CC80; 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 87b1e52b9..cd130e218 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -449,7 +449,7 @@ void func_80AA5E2C(DmChar00* this, PlayState* play) { void func_80AA5EBC(DmChar00* this, PlayState* play) { if (play->csCtx.state != 0) { - switch (play->sceneNum) { + switch (play->sceneId) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { func_80AA561C(this, play); @@ -527,7 +527,7 @@ void DmChar00_Init(Actor* thisx, PlayState* play) { s32 pad; DmChar00* this = THIS; - if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { Actor_MarkForDeath(thisx); } @@ -914,7 +914,7 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { s32 pad; Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); - if ((play->csCtx.state == 0) && ((play->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || + if ((play->csCtx.state == 0) && ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || (play->roomCtx.curRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; 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 5a6695816..da67e6f1c 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -75,7 +75,7 @@ void DmChar02_PlaySfxForDroppingOcarinaCutscene(DmChar02* this, PlayState* play) } void DmChar02_PlaySfxForCutscenes(DmChar02* this, PlayState* play) { - if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { DmChar02_PlaySfxForDroppingOcarinaCutscene(this, play); } } 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 44e5732ad..c0cb24281 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -544,7 +544,7 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { - if (play->sceneNum == SCENE_OKUJOU) { + if (play->sceneId == SCENE_OKUJOU) { if (gSaveContext.sceneSetupIndex == 2) { if (play->csCtx.currentCsIndex == 0) { func_80AAD3F8(this, play); @@ -552,7 +552,7 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { func_80AAD450(this, play); } } - } else if (play->sceneNum == SCENE_SPOT00) { + } else if (play->sceneId == SCENE_SPOT00) { if (gSaveContext.sceneSetupIndex == 9) { if ((play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 255)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); 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 b51f4df8d..1ed25ede2 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -183,7 +183,7 @@ void func_80C248A8(DmGm* this, PlayState* play) { this->unk_2AE |= 1; this->actor.draw = func_80C25000; - if ((play->sceneNum == SCENE_YADOYA) && (play->curSpawn == 4)) { + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { this->unk_2B4 = func_80C24838(play); func_80C24428(this, play, 1); this->actionFunc = func_80C24BD0; 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 4e3915af0..910293b77 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -95,7 +95,7 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; this->actionFunc(this, play); - if ((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { // This actor is responsible for playing the fairy sound during the exposition in the intro, // during the transition to Lost Woods, before Ocarina gets stolen. func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); 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 f149a97d6..5988d1913 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -917,7 +917,7 @@ void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, PlayState* play) { */ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { if (play->csCtx.state != 0) { - switch (play->sceneNum) { + switch (play->sceneId) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); @@ -1028,13 +1028,13 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->fogG = play->lightCtx.unk8; this->fogB = play->lightCtx.unk9; - if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { this->alpha = 0; this->fogN = 0; this->fogF = 1000; this->fogScale = 1.0f; this->actionFunc = DmStk_DoNothing; - } else if (play->sceneNum == SCENE_OKUJOU) { + } else if (play->sceneId == SCENE_OKUJOU) { this->alpha = 255; this->fogN = 996; this->fogF = 1000; @@ -1088,7 +1088,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - } else if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { + } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } @@ -1101,7 +1101,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->animIndex = SK_ANIM_BENT_OVER_HEAD_TWITCH; this->actionFunc = DmStk_WaitForTelescope; } else { - if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { Actor_MarkForDeath(&this->actor); } @@ -1127,8 +1127,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); - if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1316,7 +1315,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { if (play->csCtx.frames == play->csCtx.actorActions[actorActionIndex]->startFrame) { if (this->csAction != play->csCtx.actorActions[actorActionIndex]->action) { this->csAction = play->csCtx.actorActions[actorActionIndex]->action; - if (play->sceneNum == SCENE_CLOCKTOWER) { + if (play->sceneId == SCENE_CLOCKTOWER) { this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { this->handType = SK_HAND_TYPE_DEFAULT; @@ -1685,7 +1684,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; } else if (((this->animIndex >= SK_ANIM_HUDDLE_WITH_FAIRIES) && (this->animIndex <= SK_ANIM_DRAW)) || ((this->animIndex >= SK_ANIM_PLAY_FLUTE) && (this->animIndex <= SK_ANIM_CARTWHEEL)) || - ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { this->maskType = SK_MASK_TYPE_NO_MASK; if ((this->animIndex == SK_ANIM_HOLD_UP_MASK_START) || (this->animIndex == SK_ANIM_HOLD_UP_MASK_LOOP)) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; @@ -1777,7 +1776,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if (play->sceneNum == SCENE_OKUJOU) { + if (play->sceneId == SCENE_OKUJOU) { DmStk_UpdateCollision(this, play); } @@ -1824,8 +1823,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { } } - if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1888,7 +1886,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_MASK_TYPE_NORMAL: - if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.frames < 1400)) { if (this->fogN == this->fogF) { this->fogF = this->fogN; @@ -1950,7 +1948,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot case SK_HAND_TYPE_HOLDING_OCARINA: gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); - if ((play->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; @@ -1988,7 +1986,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_HAND_TYPE_HOLDING_OCARINA: - if ((play->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { + if ((play->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); 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 4aa36cfdd..6bf8adc72 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -100,7 +100,7 @@ static InitChainEntry sInitChain[] = { }; typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 0x02 */ u8 index; } ShutterSceneInfo; // size = 0x4 @@ -114,8 +114,8 @@ ShutterSceneInfo D_808A2258[] = { }; typedef struct { - /* 0x00 */ s16 dungeonScene; - /* 0x02 */ s16 bossScene; + /* 0x00 */ s16 dungeonSceneId; + /* 0x02 */ s16 bossSceneId; /* 0x04 */ u8 index; } BossDoorInfo; // size = 0x6 @@ -209,7 +209,7 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { ShutterSceneInfo* shutterSceneInfo = &D_808A2258[0]; for (i = 0; i < ARRAY_COUNT(D_808A2258) - 1; i++, shutterSceneInfo++) { - if (play->sceneNum == shutterSceneInfo->sceneNum) { + if (play->sceneId == shutterSceneInfo->sceneId) { break; } } @@ -222,7 +222,7 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; for (i = 0; i < ARRAY_COUNT(D_808A22A0) - 1; i++, bossDoorInfo++) { - if ((play->sceneNum == bossDoorInfo->dungeonScene) || (play->sceneNum == bossDoorInfo->bossScene)) { + if ((play->sceneId == bossDoorInfo->dungeonSceneId) || (play->sceneId == bossDoorInfo->bossSceneId)) { break; } } 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 93cd492e6..be9b5c093 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -54,7 +54,7 @@ typedef struct { // Maps scenes to SpiralObjectType typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 0x02 */ u8 objectType; } SpiralSceneInfo; @@ -147,7 +147,7 @@ s32 DoorSpiral_GetObjectType(PlayState* play) { s32 type; for (i = 0; i < ARRAY_COUNT(spiralSceneInfo); sceneInfo++, i++) { - if (play->sceneNum == sceneInfo->sceneNum) { + if (play->sceneId == sceneInfo->sceneId) { break; } } 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 ba1c846b9..03531bb31 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -75,13 +75,13 @@ void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { s32 func_808B849C(DoorWarp1* this, PlayState* play) { s32 ret = 0; - if ((play->sceneNum == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if ((play->sceneId == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { ret = 1; - } else if ((play->sceneNum == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + } else if ((play->sceneId == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { ret = 2; - } else if ((play->sceneNum == SCENE_SEA_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + } else if ((play->sceneId == SCENE_SEA_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { ret = 3; - } else if ((play->sceneNum == SCENE_INISIE_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + } else if ((play->sceneId == SCENE_INISIE_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { ret = 4; } return ret; @@ -161,8 +161,8 @@ void DoorWarp1_Init(Actor* thisx, PlayState* play) { break; } - if ((play->sceneNum == SCENE_MITURIN_BS) || (play->sceneNum == SCENE_HAKUGIN_BS) || - (play->sceneNum == SCENE_INISIE_BS) || (play->sceneNum == SCENE_SEA_BS)) { + if ((play->sceneId == SCENE_MITURIN_BS) || (play->sceneId == SCENE_HAKUGIN_BS) || + (play->sceneId == SCENE_INISIE_BS) || (play->sceneId == SCENE_SEA_BS)) { func_800FE484(); play->interfaceCtx.restrictions.unk_312 = 1; play->interfaceCtx.restrictions.songOfSoaring = 1; @@ -268,7 +268,7 @@ void func_808B8E78(DoorWarp1* this, PlayState* play) { this->unk_1A8 = 0.0f; this->unk_1AC = 0.0f; this->unk_1A4 = 700.0f; - if (play->sceneNum == SCENE_INISIE_N) { + if (play->sceneId == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); } else if (gSaveContext.save.weekEventReg[86] & 0x80) { this->unk_1D4 = 0; @@ -307,12 +307,12 @@ void func_808B90CC(DoorWarp1* this, PlayState* play) { s16 sp2E = 0; f32 phi_f0 = 0.0f; - if (play->sceneNum == SCENE_MITURIN) { + if (play->sceneId == SCENE_MITURIN) { sp2E = -10; phi_f0 = -5.0f; - } else if (play->sceneNum == SCENE_HAKUGIN) { + } else if (play->sceneId == SCENE_HAKUGIN) { sp2E = -20; - } else if (play->sceneNum == SCENE_SEA) { + } else if (play->sceneId == SCENE_SEA) { sp2E = -20; } @@ -551,7 +551,7 @@ void func_808B9CE8(DoorWarp1* this, PlayState* play) { return; } - switch (play->sceneNum) { + switch (play->sceneId) { case SCENE_MITURIN_BS: gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); @@ -635,16 +635,16 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { u8 phi_a0; s32 phi_v0_3; - if ((play->sceneNum == SCENE_MITURIN_BS) || (play->sceneNum == SCENE_HAKUGIN_BS) || - (play->sceneNum == SCENE_INISIE_BS) || (play->sceneNum == SCENE_SEA_BS)) { - D_801F4DE2 = play->sceneNum; - if (play->sceneNum == SCENE_MITURIN_BS) { + if ((play->sceneId == SCENE_MITURIN_BS) || (play->sceneId == SCENE_HAKUGIN_BS) || + (play->sceneId == SCENE_INISIE_BS) || (play->sceneId == SCENE_SEA_BS)) { + D_801F4DE2 = play->sceneId; + if (play->sceneId == SCENE_MITURIN_BS) { phi_v0_2 = 0; - } else if (play->sceneNum == SCENE_HAKUGIN_BS) { + } else if (play->sceneId == SCENE_HAKUGIN_BS) { phi_v0_2 = 1; - } else if (play->sceneNum == SCENE_INISIE_BS) { + } else if (play->sceneId == SCENE_INISIE_BS) { phi_v0_2 = 2; - } else if (play->sceneNum == SCENE_SEA_BS) { + } else if (play->sceneId == SCENE_SEA_BS) { phi_v0_2 = 3; } else { phi_v0_2 = 0; @@ -882,7 +882,7 @@ void func_808BAAF4(DoorWarp1* this, PlayState* play) { f32 phi_f2; phi_f2 = 200.0f; - if (play->sceneNum == SCENE_SEA) { + if (play->sceneId == SCENE_SEA) { phi_f2 = 85.0f; } @@ -1039,12 +1039,12 @@ void func_808BB4F4(DoorWarp1* this, PlayState* play2) { return; } - if (play->sceneNum != SCENE_MITURIN) { - if (play->sceneNum == SCENE_HAKUGIN) { + if (play->sceneId != SCENE_MITURIN) { + if (play->sceneId == SCENE_HAKUGIN) { sp60 = 1; - } else if (play->sceneNum == SCENE_SEA) { + } else if (play->sceneId == SCENE_SEA) { sp60 = 2; - } else if (play->sceneNum == SCENE_INISIE_R) { + } else if (play->sceneId == SCENE_INISIE_R) { sp60 = 3; } } 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 4d783942d..dcbbee65d 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -503,12 +503,12 @@ void EnBaba_FinishInit(EnBaba* this, PlayState* play) { this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; - if (play->sceneNum == SCENE_BOMYA) { + if (play->sceneId == SCENE_BOMYA) { this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnBaba_Idle; - } else if (play->sceneNum == SCENE_BACKTOWN) { + } else if (play->sceneId == SCENE_BACKTOWN) { if ((BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE) && (gSaveContext.save.entrance != ENTRANCE(NORTH_CLOCK_TOWN, 7)) && (BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor) != 0x3F)) { 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 fe1eb9fd8..5bec14e3e 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -178,7 +178,7 @@ void EnBat_Destroy(Actor* thisx, PlayState* play) { } s32 EnBat_IsGraveyardOnSecondDay(PlayState* play) { - if ((CURRENT_DAY == 2) && (play->sceneNum == SCENE_BOTI)) { + if ((CURRENT_DAY == 2) && (play->sceneId == SCENE_BOTI)) { return true; } else { return false; 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 4f8f28f3c..ba7273f59 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -485,7 +485,7 @@ s32 EnBigokuta_IsNearSwampBoat(EnBigokuta* this, PlayState* play) { void EnBigokuta_CheckOneHitKill(EnBigokuta* this, PlayState* play) { if ((this->bodyCollider.base.acFlags & AC_ON) && ((this->bodyCollider.base.acFlags & AC_HIT) || - ((play->sceneNum == SCENE_20SICHITAI || play->sceneNum == SCENE_20SICHITAI2) && + ((play->sceneId == SCENE_20SICHITAI || play->sceneId == SCENE_20SICHITAI2) && EnBigokuta_IsNearSwampBoat(this, play)))) { Enemy_StartFinishingBlow(play, &this->picto.actor); 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 31e326409..6abf4da13 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -176,7 +176,7 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { s32 func_80B3E69C(EnDai* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_12HAKUGINMAE) && (play->csCtx.currentCsIndex == 0) && + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_12HAKUGINMAE) && (play->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(play, 20); 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 ef93a501a..de2c586e9 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -335,11 +335,11 @@ void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { } if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || - ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (play->sceneNum == SCENE_CLOCKTOWER) { + } else if (play->sceneId == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); @@ -397,11 +397,11 @@ void EnDg_PlaySfxGrowl(EnDg* this, f32 frame) { void EnDg_SetupIdleMove(EnDg* this, PlayState* play) { if (!(this->actor.bgCheckFlags & 0x20)) { if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || - ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == SCENE_OMOYA))) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); - } else if (play->sceneNum == SCENE_CLOCKTOWER) { + } else if (play->sceneId == SCENE_CLOCKTOWER) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); @@ -1319,7 +1319,7 @@ void EnDg_Init(Actor* thisx, PlayState* play) { this->index = ENDG_GET_INDEX(&this->actor); this->behavior = DOG_BEHAVIOR_INITIAL; this->grabState = DOG_GRAB_STATE_NONE; - if (play->sceneNum == SCENE_F01_B) { + if (play->sceneId == SCENE_F01_B) { this->sitAfterThrowTimer = 100; EnDg_UpdateTextId(this); } @@ -1340,7 +1340,7 @@ void EnDg_Update(Actor* thisx, PlayState* play) { Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; this->selectedDogIndex = sSelectedRacetrackDogInfo.index; - if (!(player->stateFlags1 & 0x20) || (play->sceneNum != SCENE_CLOCKTOWER)) { + if (!(player->stateFlags1 & 0x20) || (play->sceneId != SCENE_CLOCKTOWER)) { if (EnDg_ShouldReactToNonHumanPlayer(this, play)) { EnDg_ChooseActionForForm(this, play); } else if (this->behavior != DOG_BEHAVIOR_DEFAULT) { 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 65c11e035..c17acf8cc 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -551,7 +551,7 @@ void func_8089B580(EnDinofos* this, PlayState* play) { } if (this->skelAnime.curFrame > 35.0f) { - if ((play->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { + if ((play->sceneId == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { play->envCtx.lightSettingOverride = 11; } @@ -562,7 +562,7 @@ void func_8089B580(EnDinofos* this, PlayState* play) { } } - if ((play->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { + if ((play->sceneId == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { play->envCtx.lightSettingOverride = 0xFF; } @@ -1053,7 +1053,7 @@ void func_8089CB10(EnDinofos* this, PlayState* play) { worldSphere->center.z = this->limbPos[10].z; } - if (play->sceneNum == SCENE_MITURIN) { + if (play->sceneId == SCENE_MITURIN) { play->envCtx.lightSettingOverride = 11; } @@ -1114,7 +1114,7 @@ void func_8089CBEC(EnDinofos* this, PlayState* play) { void func_8089CF00(EnDinofos* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; - if (play->sceneNum == SCENE_MITURIN) { + if (play->sceneId == SCENE_MITURIN) { play->envCtx.lightSettingOverride = 255; } this->actionFunc = func_8089CF70; @@ -1285,7 +1285,7 @@ s32 func_8089D60C(EnDinofos* this, PlayState* play) { func_8089ACEC(this, play); func_8089AD70(this); - if (play->sceneNum == SCENE_MITURIN) { + if (play->sceneId == SCENE_MITURIN) { play->envCtx.lightSettingOverride = 255; } 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 7afd4e224..008674292 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -447,7 +447,7 @@ void func_80A52074(EnDnk* this, PlayState* play) { } void func_80A52134(EnDnk* this, PlayState* play) { - if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneNum == SCENE_SPOT00) && + if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 2)) { func_80A52074(this, play); } 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 667a20b9b..63371ee2f 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -250,7 +250,7 @@ void func_80B3D11C(EnDnp* this, PlayState* play) { s32 temp_v0; s32 val; - if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (play->sceneNum == SCENE_MITURIN) && + if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (play->sceneId == SCENE_MITURIN) && (play->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; gSaveContext.save.weekEventReg[29] |= 0x40; @@ -373,7 +373,7 @@ void EnDnp_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.0085f); SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; - if ((play->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { + if ((play->sceneId == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; func_80B3CC38(this, 1); } 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 d9bc5cee1..892eab09c 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -290,7 +290,7 @@ const ActorInit En_Door_InitVars = { }; typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 0x02 */ u8 dListIndex; /* 0x04 */ s16 objectId; } EnDoorInfo; @@ -405,7 +405,7 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) { objectInfo = &sObjInfo[17 + this->switchFlag]; } else { for (i = 0; i < ARRAY_COUNT(sObjInfo) - 34; i++, objectInfo++) { - if (play->sceneNum == objectInfo->sceneNum) { + if (play->sceneId == objectInfo->sceneId) { break; } } 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 c7ea4f5b0..f55137367 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -903,13 +903,13 @@ void func_8088E850(EnElf* this, PlayState* play) { func_8088D660(this, &nextPos, 0.2f); } - if ((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0) && ((play->csCtx.frames == 149) || (play->csCtx.frames == 381) || (play->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } - if ((play->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && + if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } 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 61457bf50..897641a9e 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -205,13 +205,13 @@ s32 func_80A39C1C(PlayState* play, s32 arg1) { } if (arg1 == 0) { - if (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1) { + if (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1) { return 25; } return 24; } - temp_v1 = (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + temp_v1 = (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; if (temp_v1 < 10) { temp_v1 = 10; } else if (temp_v1 > 25) { @@ -227,13 +227,13 @@ void func_80A39CD4(PlayState* play, s32 arg1, s32 arg2) { if (arg1 == 0) { if (arg2 == 25) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 1; } else { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~1; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~1; } } else { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= arg2 << ((arg1 * 5) - 4); } } 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 fc1bdce22..54ea52a45 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -315,7 +315,8 @@ void EnFall_Setup(EnFall* this, PlayState* play) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { static s32 sGiantsCutsceneState = 0; - if (play->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && play->csCtx.currentCsIndex == 0) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 1) && + (play->csCtx.currentCsIndex == 0)) { switch (sGiantsCutsceneState) { case 0: if (play->csCtx.state != 0) { @@ -408,7 +409,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } } - if (play->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { + if (play->sceneId == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { switch (play->csCtx.currentCsIndex) { case 0: switch (play->csCtx.frames) { @@ -452,7 +453,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { - if (play->csCtx.state != 0 && play->sceneNum == SCENE_OKUJOU) { + if (play->csCtx.state != 0 && play->sceneId == SCENE_OKUJOU) { func_800B9010(&this->actor, NA_SE_EV_MOON_FALL - SFX_FLAG); } } @@ -574,7 +575,7 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (play->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 2) { + if (play->sceneId == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 2) { play->skyboxCtx.rotY -= 0.05f; } 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 268768660..d5dc5469a 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -167,7 +167,7 @@ Actor* func_8091D944(EnFish* this, PlayState* play) { } s32 func_8091DA14(EnFish* this, PlayState* play) { - return play->sceneNum == SCENE_LABO && func_8091D944(this, play); + return (play->sceneId == SCENE_LABO) && func_8091D944(this, play); } void EnFish_Init(Actor* thisx, PlayState* play) { @@ -853,7 +853,8 @@ void func_8091F5A4(Actor* thisx, PlayState* play) { func_8091D7C4(this); Actor_MoveWithGravity(&this->actor); if (this->unk_248 != 0) { - u32 temp = (play->sceneNum ^ SCENE_LABO) != 0; + u32 temp = (play->sceneId != SCENE_LABO); + phi_f0 = BREG(1) + 10.0f; if (temp) { 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 ebbaaca7f..a9aaedaa1 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -213,15 +213,15 @@ void func_80B3B294(EnGg2* this, PlayState* play) { Vec3s sp30; if (this->unk_2F1 == 0) { - if (play->sceneNum == SCENE_11GORONNOSATO) { + if (play->sceneId == SCENE_11GORONNOSATO) { gSaveContext.save.weekEventReg[20] |= 4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (play->sceneNum == SCENE_17SETUGEN) { + } else if (play->sceneId == SCENE_17SETUGEN) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] |= 8; gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (play->sceneNum == SCENE_10YUKIYAMANOMURA) { + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] |= 0x10; @@ -239,15 +239,15 @@ void func_80B3B294(EnGg2* this, PlayState* play) { this->unk_1DC++; } else { this->unk_2F1 = 1; - if (play->sceneNum == SCENE_11GORONNOSATO) { + if (play->sceneId == SCENE_11GORONNOSATO) { gSaveContext.save.weekEventReg[20] |= 4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (play->sceneNum == SCENE_17SETUGEN) { + } else if (play->sceneId == SCENE_17SETUGEN) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] |= 8; gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (play->sceneNum == SCENE_10YUKIYAMANOMURA) { + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { gSaveContext.save.weekEventReg[20] &= (u8)~4; gSaveContext.save.weekEventReg[20] &= (u8)~8; gSaveContext.save.weekEventReg[20] |= 0x10; @@ -380,14 +380,14 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { this->unk_2EC = 20; this->unk_2EA = 0; - if (play->sceneNum == SCENE_11GORONNOSATO) { + if (play->sceneId == SCENE_11GORONNOSATO) { 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 (play->sceneNum == SCENE_17SETUGEN) { + } else if (play->sceneId == SCENE_17SETUGEN) { if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && !(gSaveContext.save.weekEventReg[20] & 0x10)) { gSaveContext.save.weekEventReg[20] &= (u8)~4; @@ -397,7 +397,7 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { } else { Actor_MarkForDeath(&this->actor); } - } else if (play->sceneNum == SCENE_10YUKIYAMANOMURA) { + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && !(gSaveContext.save.weekEventReg[20] & 0x10)) { gSaveContext.save.weekEventReg[20] &= (u8)~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 9f3f424d5..601faff4b 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -118,7 +118,7 @@ Color_RGBA8 D_80B533A4 = { 50, 150, 150, 0 }; u16 func_80B50410(EnGk* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->sceneNum == SCENE_17SETUGEN2) { + if (play->sceneId == SCENE_17SETUGEN2) { if (player->transformation == PLAYER_FORM_GORON) { if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { switch (this->unk_31C) { @@ -164,7 +164,7 @@ u16 func_80B50410(EnGk* this, PlayState* play) { this->unk_1E4 |= 1; return 0xE81; } - } else if (play->sceneNum == SCENE_GORONRACE) { + } else if (play->sceneId == SCENE_GORONRACE) { if (player->transformation == PLAYER_FORM_GORON) { if (!(gSaveContext.save.weekEventReg[41] & 4)) { if (this->unk_31C == 0xE88) { @@ -1018,7 +1018,7 @@ void EnGk_Init(Actor* thisx, PlayState* play) { if (ENGK_GET_F(&this->actor) == ENGK_F_1) { this->unk_2E4 = 5; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); - if (play->sceneNum == SCENE_17SETUGEN2) { + if (play->sceneId == SCENE_17SETUGEN2) { if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { Actor_MarkForDeath(&this->actor); } else { @@ -1026,7 +1026,7 @@ void EnGk_Init(Actor* thisx, PlayState* play) { this->path = SubS_GetPathByIndex(play, ENGK_GET_F0(&this->actor), 0xF); this->actionFunc = func_80B51760; } - } else if (play->sceneNum == SCENE_GORONRACE) { + } else if (play->sceneId == SCENE_GORONRACE) { if (gSaveContext.save.weekEventReg[33] & 0x80) { if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { this->actionFunc = func_80B51760; 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 6e36d1130..b10f78ac3 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -762,7 +762,7 @@ s32 func_8094EFC4(EnGm* this, PlayState* play) { if (play->csCtx.state != 0) { if (this->unk_3F8 == 0) { - if ((play->sceneNum == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { + if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { func_8094E054(this, play, 0); this->unk_258 = 255; } @@ -771,7 +771,7 @@ s32 func_8094EFC4(EnGm* this, PlayState* play) { } ret = true; } else if (this->unk_3F8 != 0) { - if (play->sceneNum == SCENE_MILK_BAR) { + if (play->sceneId == SCENE_MILK_BAR) { this->unk_400 = 0; } this->unk_3F8 = 0; 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 e5775d129..5fc1d4c70 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, PlayState* play) { if (((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || - (!(gSaveContext.save.weekEventReg[22] & 4) && (play->sceneNum == SCENE_16GORON_HOUSE) && + (!(gSaveContext.save.weekEventReg[22] & 4) && (play->sceneId == SCENE_16GORON_HOUSE) && (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { ret = true; } @@ -710,7 +710,7 @@ s32 func_80A12868(EnGo* this, PlayState* play) { s32 func_80A12954(EnGo* this, PlayState* play) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != 0) && (this->actor.draw != NULL) && - (play->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; @@ -1411,7 +1411,7 @@ void func_80A144F4(EnGo* this, PlayState* play) { void func_80A145AC(EnGo* this, PlayState* play) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && - (((play->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) || !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, play); 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 de0880e96..cf32db0bc 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -330,7 +330,7 @@ void func_80B23934(EnHanabi* this, PlayState* play) { } } - if ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && (play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 610)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); } 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 7aa060a96..0e58e2b85 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -170,7 +170,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { EnHoll_SetPlayerSide(play, this, &transformedPlayerPos); playerDistFromCentralPlane = fabsf(transformedPlayerPos.z); - if (play->sceneNum == SCENE_IKANA) { + if (play->sceneId == SCENE_IKANA) { enHollBottom = EN_HOLL_BOTTOM_IKANA; enHollHalfwidth = EN_HOLL_HALFWIDTH_IKANA; } @@ -209,7 +209,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { } } } - } else if ((this->type == EN_HOLL_TYPE_DEFAULT) && (play->sceneNum == SCENE_26SARUNOMORI) && + } else if ((this->type == EN_HOLL_TYPE_DEFAULT) && (play->sceneId == SCENE_26SARUNOMORI) && (sInstancePlayingSound == NULL)) { sInstancePlayingSound = this; } @@ -225,7 +225,7 @@ void EnHoll_TransparentIdle(EnHoll* this, PlayState* play) { Actor_OffsetOfPointInActorCoords(&this->actor, &transformedPlayerPos, useViewEye ? &play->view.eye : &player->actor.world.pos); - enHollTop = (play->sceneNum == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; + enHollTop = (play->sceneId == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; if ((transformedPlayerPos.y > EN_HOLL_BOTTOM_DEFAULT) && (transformedPlayerPos.y < enHollTop) && (fabsf(transformedPlayerPos.x) < EN_HOLL_HALFWIDTH_TRANSPARENT)) { 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 259594d56..4388c7c73 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -792,7 +792,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->stateFlags = 0; } - if (((play->sceneNum == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || + if (((play->sceneId == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneSetupIndex(play))) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -878,7 +878,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { func_80112AFC(play); } else if (thisx->params == ENHORSE_14) { func_808846F0(this, play); - if ((play->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { Actor_MarkForDeath(&this->actor); } } else if (thisx->params == ENHORSE_16) { @@ -3498,7 +3498,7 @@ void EnHorse_ObstructMovement(EnHorse* this, PlayState* play, s32 obstacleType, this->unk_1EC |= 0x80; this->actor.world.pos = this->actor.prevPos; this->actor.speedXZ = 0.0f; - } else if ((play->sceneNum != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { + } else if ((play->sceneId != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { this->unk_1EC &= ~2; this->actor.world.pos = this->lastPos; this->stateFlags |= ENHORSE_OBSTACLE; @@ -3822,7 +3822,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { } if (((movingFast == false) && (intersectDist < 80.0f)) || ((movingFast == true) && (intersectDist < 150.0f))) { - if ((play->sceneNum != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && (this->playerControlled == true)) { + if ((play->sceneId != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && (this->playerControlled == true)) { if (movingFast == false) { this->stateFlags |= ENHORSE_FORCE_REVERSING; } else if (movingFast == true) { @@ -3876,7 +3876,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist, &this->actor.world.pos) > 40.0f)) { if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && - (play->sceneNum != SCENE_KOEPONARACE)) { + (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); } @@ -3888,7 +3888,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || (func_800C99D4(&play->colCtx, obstacleFloor, bgId) == 7)) { if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && - (this->action != ENHORSE_ACTION_STOPPING) && (play->sceneNum != SCENE_KOEPONARACE)) { + (this->action != ENHORSE_ACTION_STOPPING) && (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); } @@ -3951,13 +3951,13 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || (func_800C99D4(&play->colCtx, obstacleFloor, bgId) == 7)) { if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && - (play->sceneNum != SCENE_KOEPONARACE)) { + (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); } } else if (behindObstacleHeight < -70.0f) { if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && - (play->sceneNum != SCENE_KOEPONARACE)) { + (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); } 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 bb5ec72ee..b7ad5c9dd 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -948,7 +948,7 @@ void EnJg_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { - if ((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && (play->csCtx.currentCsIndex == 0)) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animIndex = EN_JG_ANIM_IDLE; 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 6d7cc29ea..3acbece16 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -238,10 +238,10 @@ void EnKakasi_CheckAnimationSfx(EnKakasi* this) { void EnKakasi_CheckPlayerPosition(EnKakasi* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->sceneNum == SCENE_8ITEMSHOP) { + if (play->sceneId == SCENE_8ITEMSHOP) { player->actor.world.pos.x = -50.0f; player->actor.world.pos.z = 155.0f; - } else if (play->sceneNum == SCENE_TENMON_DAI) { + } else if (play->sceneId == SCENE_TENMON_DAI) { player->actor.world.pos.x = 60.0f; player->actor.world.pos.z = -190.0f; } @@ -998,7 +998,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { tempWorldPos.x += randPlusMinusPoint5Scaled(2.0f); tempWorldPos.z += randPlusMinusPoint5Scaled(2.0f); - if (play->sceneNum == SCENE_8ITEMSHOP) { + if (play->sceneId == SCENE_8ITEMSHOP) { EffectSsGSplash_Spawn(play, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); SoundSource_PlaySfxAtFixedWorldPos(play, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); 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 ad85d9edb..78d903207 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, PlayState* play) { } s32 func_80B33E64(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1; } s32 func_80B33E8C(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 2))) { return true; } return false; 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 de2d1c207..c9349b2c5 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -151,33 +151,33 @@ ObjIcePoly* EnKgy_FindIceBlock(PlayState* play) { } void func_80B40C74(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 2; } else { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~2; } } void func_80B40D00(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= 4; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 4; } void func_80B40D30(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~7; } s32 func_80B40D64(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1; } s32 func_80B40D8C(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 4; + return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 4; } s32 func_80B40DB4(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 2))) { return true; } return false; 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 cb25445b9..dc5e75579 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, PlayState* play) { } s32 func_80959524(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 7; + return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 7; } void func_8095954C(EnMk* this, PlayState* play) { 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 b2fee9d8d..fd3146032 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -731,7 +731,7 @@ void func_80AD16A8(EnOsn* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); } - if ((this->unk_1EC == 5) && (play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } @@ -795,7 +795,7 @@ void EnOsn_Init(Actor* thisx, PlayState* play) { this->unk_1EA |= 1; } this->unk_1F0 = 1; - if (play->sceneNum == SCENE_INSIDETOWER) { + if (play->sceneId == SCENE_INSIDETOWER) { if ((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { this->actionFunc = func_80AD16A8; 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 3995207e9..75bcbc8e8 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1017,7 +1017,7 @@ s32 func_80AF86F0(EnPm* this, PlayState* play) { s32 func_80AF87C4(EnPm* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 9) && + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 9) && (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); 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 56201271b..088e06149 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,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { this->unk_3F8 = 0; } - if ((play->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } 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 62cb638d9..ea4f7be32 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,7 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((play->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } 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 6e7915539..408ca1b2f 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -654,7 +654,7 @@ void EnSsh_Init(Actor* thisx, PlayState* play) { this->actor.gravity = 0.0f; this->initialYaw = this->actor.world.rot.y; EnSsh_SetupAction(this, EnSsh_Start); - if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { Actor_MarkForDeath(&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 4354e7f58..1d9ddf4e9 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -113,7 +113,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { break; case ENSTH_F_2: - if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { this->actionFunc = func_80B67DA0; } else { Actor_MarkForDeath(&this->actor); @@ -148,7 +148,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { break; case ENSTH_F_5: - if (!(gSaveContext.save.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(play->sceneNum) < 30)) { + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(play->sceneId) < 30)) { Actor_MarkForDeath(&this->actor); return; } @@ -446,7 +446,7 @@ void func_80B67984(EnSth* this, PlayState* play) { sp1E = 0x918; } func_80B670A4(this, 2); - } else if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { + } else if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { this->unk_29C |= 4; sp1E = 0x919; @@ -559,7 +559,7 @@ void func_80B67DA0(EnSth* this, PlayState* play) { void func_80B67E20(Actor* thisx, PlayState* play) { EnSth* this = THIS; - if (Inventory_GetSkullTokenCount(play->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { this->actor.update = func_80B680A8; this->actor.draw = func_80B6849C; this->actor.flags |= ACTOR_FLAG_1; @@ -580,7 +580,7 @@ void EnSth_Update(Actor* thisx, PlayState* play) { Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); this->unk_29A = 1; if ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || - (gSaveContext.save.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(play->sceneNum) >= 30)) { + (gSaveContext.save.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(play->sceneId) >= 30)) { func_80B670A4(this, 3); } } else { @@ -610,7 +610,7 @@ void EnSth_Update(Actor* thisx, PlayState* play) { break; } - if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(play->sceneNum) < 30)) { + if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(play->sceneId) < 30)) { this->actor.update = func_80B67E20; this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_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 fbacce266..bbce2ee6c 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -942,7 +942,7 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { this->morphTable, 16); this->actor.draw = EnSuttari_Draw; this->actor.flags |= ACTOR_FLAG_1; - if (play->sceneNum == SCENE_IKANA) { + if (play->sceneId == SCENE_IKANA) { this->flags1 |= 1; if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { this->animIndex = 2; @@ -958,7 +958,7 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { this->actionFunc = func_80BACEE0; return; } - } else if (play->sceneNum == SCENE_BACKTOWN) { + } else if (play->sceneId == SCENE_BACKTOWN) { if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } @@ -974,7 +974,7 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = func_80BAD004; return; - } else if (play->sceneNum == SCENE_ICHIBA) { + } else if (play->sceneId == SCENE_ICHIBA) { if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; @@ -984,7 +984,7 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; - } else if (play->sceneNum == SCENE_AYASHIISHOP) { + } else if (play->sceneId == SCENE_AYASHIISHOP) { if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; @@ -1461,7 +1461,7 @@ void EnSuttari_Init(Actor* thisx, PlayState* play) { void EnSuttari_Destroy(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; - if ((play->sceneNum == SCENE_BACKTOWN) && !(this->flags2 & 4)) { + if ((play->sceneId == SCENE_BACKTOWN) && !(this->flags2 & 4)) { Audio_QueueSeqCmd(0x101400FF); } Collider_DestroyCylinder(play, &this->collider); 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 5433aeec7..a504ab521 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 @@ -179,7 +179,7 @@ void EnSyatekiMan_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); - if (play->sceneNum == SCENE_SYATEKI_MORI) { + if (play->sceneId == SCENE_SYATEKI_MORI) { SkelAnime_InitFlex(play, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { @@ -205,7 +205,7 @@ void EnSyatekiMan_Init(Actor* thisx, PlayState* play) { this->eyeIndex = 0; this->blinkTimer = 0; - if (play->sceneNum == SCENE_SYATEKI_MORI) { + if (play->sceneId == SCENE_SYATEKI_MORI) { this->path = path; EnSyatekiMan_Swamp_SpawnTargetActors(this, play, sSwampTargetActorLists[this->swampTargetActorListIndex], actorListLength); @@ -247,9 +247,9 @@ s32 EnSyatekiMan_MovePlayerToPos(PlayState* play, Vec3f pos) { } void EnSyatekiMan_SetupIdle(EnSyatekiMan* this, PlayState* play) { - if (play->sceneNum == SCENE_SYATEKI_MORI) { + if (play->sceneId == SCENE_SYATEKI_MORI) { this->actionFunc = EnSyatekiMan_Swamp_Idle; - } else if (play->sceneNum == SCENE_SYATEKI_MIZU) { + } else if (play->sceneId == SCENE_SYATEKI_MIZU) { this->actionFunc = EnSyatekiMan_Town_Idle; } } @@ -1447,7 +1447,7 @@ void EnSyatekiMan_Update(Actor* thisx, PlayState* play) { s32 EnSyatekiMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnSyatekiMan* this = THIS; - if ((play->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { + if ((play->sceneId == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { *dList = gTownShootingGalleryManHeadDL; } @@ -1481,7 +1481,7 @@ void EnSyatekiMan_Draw(Actor* thisx, PlayState* play) { EnSyatekiMan* this = THIS; s32 pad; - if (play->sceneNum == SCENE_SYATEKI_MIZU) { + if (play->sceneId == SCENE_SYATEKI_MIZU) { sEyeTextures[0] = gTownShootingGalleryManEyeOpenTex; sEyeTextures[1] = gTownShootingGalleryManEyeClosedTex; sEyeTextures[2] = gTownShootingGalleryManEyeClosedTex; 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 f33a1f693..805a6f8bf 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -436,7 +436,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || - (play->sceneNum == SCENE_CLOCKTOWER))) { + (play->sceneId == SCENE_CLOCKTOWER))) { s32 playerParams; u32 entrance = gSaveContext.save.entrance; @@ -448,7 +448,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, entrance, player->unk_3CE, playerParams, &player->unk_3C0, player->unk_3CC); - if ((play->sceneNum == SCENE_TENMON_DAI) || (play->sceneNum == SCENE_00KEIKOKU)) { + if ((play->sceneId == SCENE_TENMON_DAI) || (play->sceneId == SCENE_00KEIKOKU)) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); } else { play->nextEntrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0); 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 03b10590c..fcbb0223b 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -658,7 +658,7 @@ void func_80AF2350(EnTest7* this, PlayState* play) { this->unk_148.unk_10 -= 0x2EE0; - if (play->sceneNum == SCENE_SECOM) { + if (play->sceneId == SCENE_SECOM) { play->nextEntrance = ENTRANCE(IKANA_CANYON, 6); } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { func_80169F78(&play->state); 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 0a013410b..04e44bb16 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 @@ -284,7 +284,7 @@ void func_80ACA840(EnTimeTag* this, PlayState* play) { s16 temp_ft4; s16 temp_hi; - if ((play->sceneNum != SCENE_YADOYA) || (INV_CONTENT(ITEM_ROOM_KEY) != ITEM_ROOM_KEY)) { + if ((play->sceneId != 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) { 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 6dda48fc7..a55c899ef 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -184,15 +184,15 @@ void EnToto_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - if (play->sceneNum == SCENE_MILK_BAR && - (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { + if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(play, &this->skelAnime, &object_zm_Skel_00A978, - ((play->sceneNum == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), + ((play->sceneId == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); func_80BA36C0(this, play, 0); this->actor.shape.rot.x = 0; @@ -220,7 +220,7 @@ void func_80BA383C(EnToto* this, PlayState* play) { void func_80BA3930(EnToto* this, PlayState* play) { AnimationHeader* animationHeader = &object_zm_Anim_00C880; - if (play->sceneNum == SCENE_SONCHONOIE) { + if (play->sceneId == SCENE_SONCHONOIE) { animationHeader = &object_zm_Anim_003AA8; } Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); @@ -242,7 +242,7 @@ void func_80BA39C8(EnToto* this, PlayState* play) { func_80BA383C(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80BA36C0(this, play, 1); - if (play->sceneNum != SCENE_SONCHONOIE) { + if (play->sceneId != SCENE_SONCHONOIE) { Flags_SetSwitch(play, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { Flags_SetSwitch(play, this->actor.home.rot.x); @@ -252,9 +252,9 @@ void func_80BA39C8(EnToto* this, PlayState* play) { } //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro - if ((play->sceneNum == SCENE_MILK_BAR && - !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || - (play->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { + if (((play->sceneId == SCENE_MILK_BAR) && + !((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < 0xED02))) || + ((play->sceneId != SCENE_MILK_BAR) && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; this->actor.flags |= ACTOR_FLAG_10000; @@ -262,7 +262,7 @@ void func_80BA39C8(EnToto* this, PlayState* play) { } else { this->actor.flags &= ~ACTOR_FLAG_10000; func_800B8614(&this->actor, play, 50.0f); - if (play->sceneNum == SCENE_SONCHONOIE) { + if (play->sceneId == SCENE_SONCHONOIE) { if (player->transformation == PLAYER_FORM_DEKU) { if (!Flags_GetSwitch(play, this->actor.home.rot.x)) { this->text = D_80BA5068; @@ -286,7 +286,7 @@ void func_80BA39C8(EnToto* this, PlayState* play) { } void func_80BA3BFC(EnToto* this, PlayState* play) { - if (play->sceneNum == SCENE_SONCHONOIE) { + if (play->sceneId == SCENE_SONCHONOIE) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_000C80, -4.0f); this->unk2B4 = 0; } 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 1f521d250..ac6a4f476 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -752,7 +752,7 @@ void func_80AD4DB4(EnTrt2* this, PlayState* play) { return; } - if ((play->sceneNum == SCENE_20SICHITAI) || (play->sceneNum == SCENE_20SICHITAI2)) { + if ((play->sceneId == SCENE_20SICHITAI) || (play->sceneId == SCENE_20SICHITAI2)) { if (gSaveContext.save.day == 2) { if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { gSaveContext.save.weekEventReg[15] |= 0x80; @@ -790,7 +790,7 @@ void func_80AD4FE4(EnTrt2* this, PlayState* play) { D_80AD5910[this->unk_3B2](this, play); Actor_MoveWithGravity(&this->actor); - if (play->sceneNum != SCENE_20SICHITAI) { + if (play->sceneId != SCENE_20SICHITAI) { Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } 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 092c693f2..ec6f12aeb 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 @@ -351,8 +351,7 @@ void func_80966FEC(EnWeatherTag* this, PlayState* play) { D_801F4E7A = distance; } - // unique pirates fortress behavior? - if ((play->sceneNum == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((play->sceneId == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) { EnWeatherTag_SetupAction(this, func_80967060); } } 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 508734a9b..bda36c0b6 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -207,7 +207,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || - (play->sceneNum != SCENE_30GYOSON))) { + (play->sceneId != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; } 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 f20b953ba..fba4baf7a 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -206,13 +206,13 @@ void EnZoraegg_Destroy(Actor* thisx, PlayState* play) { } s32 func_80B319A8(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 & 7; + return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 7; } void func_80B319D0(PlayState* play, s32 arg1) { if ((arg1 < 8) && (arg1 >= 0)) { - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 &= ~7; - gSaveContext.save.permanentSceneFlags[play->sceneNum].unk_14 |= arg1; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= arg1; } } 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 5783118de..6c6d6e02a 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -60,7 +60,7 @@ void ObjDemo_Init(Actor* thisx, PlayState* play) { } void func_80983634(PlayState* play) { - if ((play->sceneNum == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + if ((play->sceneId == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { Audio_QueueSeqCmd(0x100100FF); } } @@ -88,7 +88,7 @@ void func_80983704(ObjDemo* this, PlayState* play) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - if (play->sceneNum == SCENE_CASTLE) { + if (play->sceneId == SCENE_CASTLE) { Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000); } this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); 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 249e7ffde..19d35ffff 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, PlayState* play) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); Flags_SetSwitch(play, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && - ((play->sceneNum == SCENE_17SETUGEN) || (play->sceneNum == SCENE_17SETUGEN2))) { + ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_17SETUGEN2))) { gSaveContext.save.weekEventReg[19] |= 2; } 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 0210b5ba7..2ba1e4352 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, PlayState* play) { thisx->shape.rot.z = -0x500; if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) || - ((play->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { + ((play->sceneId == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { Actor_MarkForDeath(thisx); return; } @@ -205,7 +205,7 @@ void func_80931A38(ObjIcePoly* this, PlayState* play) { this->actionFunc = func_80931E58; this->actor.focus.rot.y = this->actor.yawTowardsPlayer; - if (play->sceneNum == SCENE_00KEIKOKU) { + if (play->sceneId == SCENE_00KEIKOKU) { Actor* actor = NULL; do { 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 497d9a219..7758fc5bc 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 @@ -36,11 +36,10 @@ void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(play, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); - if (((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && - (play->csCtx.currentCsIndex == 0)) { + if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && (play->csCtx.currentCsIndex == 0)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); - } else if ((play->sceneNum == SCENE_17SETUGEN) || (play->sceneNum == SCENE_10YUKIYAMANOMURA)) { + } else if ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_10YUKIYAMANOMURA)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); } else { Actor_MarkForDeath(&this->actor); 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 4c56bb794..7cc7add22 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -71,7 +71,7 @@ void ObjNozoki_Init(Actor* thisx, PlayState* play) { this->dyna.actor.shape.rot.z = 0; this->unk_15F = this->dyna.actor.cutscene; - if (play->sceneNum == SCENE_AYASHIISHOP) { + if (play->sceneId == SCENE_AYASHIISHOP) { this->unk_15C = 4; ObjNozoki_SetupAction(this, func_80BA3230); this->dyna.actor.colChkInfo.cylRadius = -40; 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 02743db29..c31168f72 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -348,7 +348,7 @@ void ObjSwitch_Init(Actor* thisx, PlayState* play) { DynaPolyActor_LoadMesh(play, &this->dyna, &gFloorSwitchCol); } if (type == OBJSWITCH_TYPE_FLOOR) { - if (play->sceneNum == SCENE_SECOM) { + if (play->sceneId == SCENE_SECOM) { this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; } else { @@ -357,7 +357,7 @@ void ObjSwitch_Init(Actor* thisx, PlayState* play) { } } if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { - if (play->sceneNum == SCENE_SECOM) { + if (play->sceneId == SCENE_SECOM) { Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; this->color.r = color->r; @@ -584,7 +584,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_ONCE: case OBJSWITCH_SUBTYPE_SYNC: if (!Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { - if (play->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if ((play->sceneId == SCENE_SECOM) && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { ObjSwitch_SetSwitchFlagState(this, play, true); } else { ObjSwitch_FloorSwitchRiseUpInit(this); @@ -595,7 +595,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_RESET: case OBJSWITCH_SUBTYPE_RESET_INVERTED: if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && - (!Player_InCsMode(play) || play->sceneNum == SCENE_SECOM)) { + (!Player_InCsMode(play) || (play->sceneId == SCENE_SECOM))) { if (this->floorSwitchReleaseTimer <= 0) { if (subType == OBJSWITCH_SUBTYPE_RESET) { ObjSwitch_SetSwitchFlagState(this, play, false); @@ -607,7 +607,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { } } } else { - if (play->sceneNum == SCENE_SECOM) { + if (play->sceneId == SCENE_SECOM) { this->floorSwitchReleaseTimer = 2; } else { this->floorSwitchReleaseTimer = 6; 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 780c31c9a..62cb40275 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, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(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 74c121656..34d43d354 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -121,9 +121,9 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, PlayState* play) { this->opaDList = gClockTowerExteriorGearDL; ObjTokeidai_SetupClockOrExteriorGear(this); - if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { @@ -140,9 +140,9 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_Clock_Init(this); - if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { @@ -175,9 +175,9 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, PlayState* play) { this->spotlightIntensity = 0; } - if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -448,9 +448,9 @@ void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { if (Cutscene_CheckActorAction(play, 132) != 0 && play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { gSaveContext.save.weekEventReg[8] |= 0x40; - if (((play->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); gSaveContext.save.cutscene = 0; 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 20c172803..9d635d7eb 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -162,7 +162,7 @@ void func_80927818(ObjTsubo* this, PlayState* play, s32 arg2) { } s32 ObjTsubo_IsSceneNotGohtOrTwinmold(ObjTsubo* this, PlayState* play) { - return (play->sceneNum != SCENE_HAKUGIN_BS) && (play->sceneNum != SCENE_INISIE_BS); + return (play->sceneId != SCENE_HAKUGIN_BS) && (play->sceneId != SCENE_INISIE_BS); } void func_8092788C(ObjTsubo* this, PlayState* play) { 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 83e06a1a3..aea3bc7f1 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -42,8 +42,8 @@ void func_808A7968(ObjWturn* this, PlayState* play) { if (play->msgCtx.ocarinaMode >= 28 && play->msgCtx.ocarinaMode < 39) { Flags_UnsetSwitch(play, this->actor.params); Actor_MarkForDeath(&this->actor); - } else if ((Flags_GetSwitch(play, this->actor.params) && (play->sceneNum == SCENE_F40)) || - (!Flags_GetSwitch(play, this->actor.params) && (play->sceneNum == SCENE_F41))) { + } else if ((Flags_GetSwitch(play, this->actor.params) && (play->sceneId == SCENE_F40)) || + (!Flags_GetSwitch(play, this->actor.params) && (play->sceneId == SCENE_F41))) { func_808A7A24(this); } } @@ -112,7 +112,7 @@ void func_808A7C78(ObjWturn* this, PlayState* play) { play->transitionType = TRANS_TYPE_64; gSaveContext.nextTransitionType = TRANS_TYPE_03; gSaveContext.nextCutsceneIndex = 0; - if (play->sceneNum == SCENE_F40) { + if (play->sceneId == SCENE_F40) { play->nextEntrance = ENTRANCE(STONE_TOWER_INVERTED, 0); } else { play->nextEntrance = ENTRANCE(STONE_TOWER, 1); 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 4057ff817..264167db5 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -588,7 +588,7 @@ void func_808DD970(Actor* thisx, PlayState* play2) { ObjectKankyo* this = THIS; f32 tempA; - if (play->sceneNum == SCENE_KYOJINNOMA) { + if (play->sceneId == SCENE_KYOJINNOMA) { phi_f26 = 1.0f; } else { tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(play)); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4526760d5..825059e33 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2495,8 +2495,8 @@ 0x80131F90:("Scene_DrawConfigMatAnimManualStep",), 0x80131FC0:("Scene_DrawConfigGreatBayTemple",), 0x801322C0:("Entrance_GetTableEntry",), - 0x8013230C:("Entrance_GetSceneNum",), - 0x80132338:("Entrance_GetSceneNumAbsolute",), + 0x8013230C:("Entrance_GetSceneId",), + 0x80132338:("Entrance_GetSceneIdAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), 0x801323D0:("Schedule_CheckFlagS",), @@ -3024,7 +3024,7 @@ 0x80169BF8:("func_80169BF8",), 0x80169C64:("Play_GetActorCsCamSetting",), 0x80169C84:("Play_GetActorCsCamFuncData",), - 0x80169CBC:("Play_GetOriginalSceneNumber",), + 0x80169CBC:("Play_GetOriginalSceneId",), 0x80169D40:("Play_SaveCycleSceneFlags",), 0x80169DCC:("Play_SetRespawnData",), 0x80169E6C:("Play_SetupRespawnPoint",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 55609668b..daa1356f2 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1342,8 +1342,8 @@ 0x801C1E6C:("gItemIcons","UNK_PTR","[131]",0x20C), 0x801C2078:("gItemSlots","u8","[80]",0x50), 0x801C20C8:("gItemPrices","UNK_TYPE1","",0x1), - 0x801C212C:("gScenesPerRegion","SceneIdList","[]",0x252), - 0x801C2380:("sScenesPerTingleMap","u16","[]",0x90), + 0x801C212C:("gSceneIdsPerRegion","SceneIdList","[]",0x252), + 0x801C2380:("sSceneIdsPerTingleMap","u16","[]",0x90), 0x801C2410:("D_801C2410","UNK_TYPE1","",0x1), 0x801C2650:("tatlMessageFiles","RomFile","[2]",0x10), 0x801C2660:("sceneTextureFiles","RomFile","[9]",0x48), diff --git a/tools/namefixer.py b/tools/namefixer.py index 4152c8d97..eab13f0b9 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -729,6 +729,7 @@ wordReplace = { "play->actorCtx.unk3": "play->actorCtx.lensActive", "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", "play->nextEntranceIndex": "play->nextEntrance", + "play->sceneNum": "play->sceneId", "gSaveContext.unk_3DC8": "gSaveContext.timerOsTime", "gSaveContext.unk_3DD0": "gSaveContext.timerStates", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 52cb53a60..ecdba5264 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2009,8 +2009,8 @@ asm/non_matchings/code/z_scene_proc/Scene_DrawConfig5.s,Scene_DrawConfig5,0x8013 asm/non_matchings/code/z_scene_proc/Scene_DrawConfigMatAnimManualStep.s,Scene_DrawConfigMatAnimManualStep,0x80131F90,0xC asm/non_matchings/code/z_scene_proc/Scene_DrawConfigGreatBayTemple.s,Scene_DrawConfigGreatBayTemple,0x80131FC0,0xC0 asm/non_matchings/code/z_scene_table/Entrance_GetTableEntry.s,Entrance_GetTableEntry,0x801322C0,0x13 -asm/non_matchings/code/z_scene_table/Entrance_GetSceneNum.s,Entrance_GetSceneNum,0x8013230C,0xB -asm/non_matchings/code/z_scene_table/Entrance_GetSceneNumAbsolute.s,Entrance_GetSceneNumAbsolute,0x80132338,0xF +asm/non_matchings/code/z_scene_table/Entrance_GetSceneId.s,Entrance_GetSceneId,0x8013230C,0xB +asm/non_matchings/code/z_scene_table/Entrance_GetSceneIdAbsolute.s,Entrance_GetSceneIdAbsolute,0x80132338,0xF asm/non_matchings/code/z_scene_table/Entrance_GetSpawnNum.s,Entrance_GetSpawnNum,0x80132374,0xB asm/non_matchings/code/z_scene_table/Entrance_GetTransitionFlags.s,Entrance_GetTransitionFlags,0x801323A0,0xC asm/non_matchings/code/code_801323D0/func_801323D0.s,func_801323D0,0x801323D0,0x16 @@ -2538,7 +2538,7 @@ asm/non_matchings/code/z_play/Play_GetCameraUID.s,Play_GetCameraUID,0x80169BC4,0 asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B asm/non_matchings/code/z_play/Play_GetActorCsCamSetting.s,Play_GetActorCsCamSetting,0x80169C64,0x8 asm/non_matchings/code/z_play/Play_GetActorCsCamFuncData.s,Play_GetActorCsCamFuncData,0x80169C84,0xE -asm/non_matchings/code/z_play/Play_GetOriginalSceneNumber.s,Play_GetOriginalSceneNumber,0x80169CBC,0x21 +asm/non_matchings/code/z_play/Play_GetOriginalSceneId.s,Play_GetOriginalSceneId,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 From 1af942ae12499c90bb4ebe2d37988d2234f8605e Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 07:49:35 -0400 Subject: [PATCH 55/73] Audio Sequences: Scene/Ambience/SeqFlags Functions OK (#1033) * import audio scene seq docs * cleanup * fix scene cmd * small fixes * more PR suggestions * missed comment * rename spot to resume * cleanup comments * SEQ_IO_VAL_NONE * Empty-Commit * another PR suggestion --- include/functions.h | 54 +- include/sequence.h | 210 +-- include/variables.h | 4 +- include/z64.h | 9 +- include/z64audio.h | 11 +- include/z64save.h | 4 +- include/z64scene.h | 16 +- src/code/audio/audio_seqplayer.c | 12 +- src/code/audio/code_8019AF00.c | 1656 +++++++++++------ src/code/audio/code_801A5BD0.c | 2 +- src/code/audio/code_801A7B10.c | 4 +- src/code/game.c | 2 +- src/code/graph.c | 2 +- src/code/z_common_data.c | 4 +- src/code/z_demo.c | 30 +- src/code/z_game_over.c | 6 +- src/code/z_scene.c | 9 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 4 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 4 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 2 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 4 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 16 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h | 2 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 4 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 2 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 2 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 6 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 4 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 8 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 6 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 2 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 6 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.c | 4 +- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 2 +- src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 6 +- src/overlays/gamestates/ovl_select/z_select.c | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 4 +- tools/disasm/functions.txt | 58 +- tools/disasm/variables.txt | 18 +- tools/namefixer.py | 13 + tools/sizes/code_functions.csv | 58 +- 50 files changed, 1445 insertions(+), 855 deletions(-) diff --git a/include/functions.h b/include/functions.h index 05fd4ed45..67ad8ec3c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3158,7 +3158,7 @@ OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); void AudioOcarina_TerminaWallGenerateNotes(void); void AudioOcarina_PlayLongScarecrowAfterCredits(void); -void func_8019E014(void); +void Audio_Update(void); // void func_8019E110(void); void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex); void play_sound(u16 sfxId); @@ -3224,31 +3224,27 @@ void func_801A1F88(void); void func_801A1FB4(u8 playerIndex, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); -// void func_801A2544(void); -// void func_801A257C(void); -void func_801A25E4(u16 seqId, u8 dayMinusOne); -// void func_801A2670(void); -// void func_801A2778(void); +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne); +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne); // void func_801A27E8(void); // void func_801A281C(void); 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(u16 seqId); -void func_801A2D54(u16 seqId); +void Audio_PlaySequenceInCutscene(u16 seqId); +void Audio_StopSequenceInCutscene(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 bgmId); -void func_801A2ED8(void); -// void func_801A2F88(void); +void Audio_PlayBgm_StorePrevBgm(u16 seqId); +void Audio_RestorePrevBgm(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 seqId); +void Audio_PlayFanfare(u16 seqId); // void func_801A312C(void); 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 Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 ioPort, u8 ioData); +void Audio_SetSequenceMode(u8 seqMode); +void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); void func_801A3A7C(s32 arg0); @@ -3261,11 +3257,11 @@ void func_801A3CD8(s8 param_1); void func_801A3D98(s8 audioSetting); // void func_801A3E38(void); // void func_801A3EC0(void); -void Audio_SetCutsceneFlag(u8 flag); +void Audio_SetCutsceneFlag(s8 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); -void audio_setBGM(u32 bgmID); +void Audio_SetSpec(u32 specId); void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); // void func_801A41F8(void); @@ -3276,15 +3272,13 @@ void func_801A4058(UNK_TYPE arg0); void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 arg0); void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); -// void func_801A44C4(void); +// void Audio_ResetRequestedSceneSeqId(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(u8 channelIndexRange, u8 port, u8 val); -// void func_801A48E0(void); -void func_801A4A28(u8 natureSeqId); -// void Audio_SetNatureAmbienceRandomBend(void); +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); +void Audio_PlayAmbience(u8 ambienceId); void Audio_Init(void); void func_801A4D00(void); // void func_801A4D50(void); @@ -3297,7 +3291,7 @@ void func_801A4D00(void); // void func_801A4FD8(void); void func_801A5080(u16 arg0); u16 func_801A5100(void); -// void func_801A5118(void); +void func_801A5118(void); UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A5228(void); // void func_801A5390(void); @@ -3328,17 +3322,17 @@ u8 AudioSfx_IsPlaying(u32 sfxId); void AudioSfx_Reset(void); void Audio_StartSequence(u8 playerIndex, u8 seqId, u8 seqArgs, u16 fadeTimer); -// void func_801A7D04(void); +void Audio_StopSequence(u8 playerIndex, u16 fadeTimer); // void func_801A7D84(void); void Audio_QueueSeqCmd(u32 cmd); -// void func_801A89D0(void); -s32 func_801A8A50(s32 param1); -// void func_801A8ABC(void); +void func_801A89D0(void); +u16 Audio_GetActiveSequence(u8 playerIndex); +s32 func_801A8ABC(u32 cmdVal, u32 cmdMask); void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); -// void func_801A8D5C(void); +void func_801A8D5C(void); // void func_801A8E90(void); -// void func_801A9768(void); -// void func_801A982C(void); +u8 func_801A9768(void); +u8 func_801A982C(void); // void func_801A99B8(void); // void func_801A9A74(void); diff --git a/include/sequence.h b/include/sequence.h index d46e96aea..857609d4b 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -4,7 +4,7 @@ #define NA_BGM_STOP 0x100000FF #define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises +#define NA_BGM_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -40,7 +40,7 @@ #define NA_BGM_GET_ITEM 0x22 // Item Catch #define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT #define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_TIMED_MINI_GAME 0x25 // Playing a timed Minigame #define NA_BGM_GORON_RACE 0x26 // Goron Race #define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" #define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" @@ -134,11 +134,12 @@ #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 + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_AMBIENCE, + /* 0xFF */ SEQ_PLAYER_INVALID = 0xFF } SequencePlayerId; typedef enum { @@ -160,119 +161,120 @@ typedef enum { } 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 + /* 0x0 */ AMBIENCE_CHANNEL_STREAM_0, + /* 0x1 */ AMBIENCE_CHANNEL_CRITTER_0, + /* 0x2 */ AMBIENCE_CHANNEL_CRITTER_1, + /* 0x3 */ AMBIENCE_CHANNEL_CRITTER_2, + /* 0x4 */ AMBIENCE_CHANNEL_CRITTER_3, + /* 0x5 */ AMBIENCE_CHANNEL_CRITTER_4, + /* 0x6 */ AMBIENCE_CHANNEL_CRITTER_5, + /* 0x7 */ AMBIENCE_CHANNEL_CRITTER_6, + /* 0x8 */ AMBIENCE_CHANNEL_CRITTER_7, + /* 0xC */ AMBIENCE_CHANNEL_STREAM_1 = 12, + /* 0xD */ AMBIENCE_CHANNEL_SOUND_MODE, + /* 0xE */ AMBIENCE_CHANNEL_RAIN, + /* 0xF */ AMBIENCE_CHANNEL_LIGHTNING +} AmbienceChannelIndex; // playerIndex = SEQ_PLAYER_AMBIENCE 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 + /* 0x00 */ AMBIENCE_ID_00, + /* 0x01 */ AMBIENCE_ID_01, + /* 0x02 */ AMBIENCE_ID_02, + /* 0x03 */ AMBIENCE_ID_03, + /* 0x04 */ AMBIENCE_ID_04, + /* 0x05 */ AMBIENCE_ID_05, + /* 0x06 */ AMBIENCE_ID_06, + /* 0x07 */ AMBIENCE_ID_07, + /* 0x08 */ AMBIENCE_ID_08, + /* 0x09 */ AMBIENCE_ID_09, + /* 0x0A */ AMBIENCE_ID_0A, + /* 0x0B */ AMBIENCE_ID_0B, + /* 0x0C */ AMBIENCE_ID_0C, + /* 0x0D */ AMBIENCE_ID_0D, + /* 0x0E */ AMBIENCE_ID_0E, + /* 0x0F */ AMBIENCE_ID_0F, + /* 0x10 */ AMBIENCE_ID_10, + /* 0x11 */ AMBIENCE_ID_11, + /* 0x12 */ AMBIENCE_ID_12, + /* 0x13 */ AMBIENCE_ID_13, + /* 0xFF */ AMBIENCE_ID_DISABLED = 0xFF +} AmbienceId; // playerIndex = SEQ_PLAYER_AMBIENCE typedef enum { - /* 0x00 */ NATURE_STREAM_0, - /* 0x01 */ NATURE_STREAM_1, - /* 0x02 */ NATURE_STREAM_2, - /* 0x03 */ NATURE_STREAM_3 -} NatureStreamId; + /* 0x00 */ AMBIENCE_STREAM_0, + /* 0x01 */ AMBIENCE_STREAM_1, + /* 0x02 */ AMBIENCE_STREAM_2, + /* 0x03 */ AMBIENCE_STREAM_3 +} AmbienceStreamId; 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; + /* 0x00 */ AMBIENCE_CRITTER_00, + /* 0x01 */ AMBIENCE_CRITTER_01, + /* 0x02 */ AMBIENCE_CRITTER_02, + /* 0x03 */ AMBIENCE_CRITTER_03, + /* 0x04 */ AMBIENCE_CRITTER_04, + /* 0x05 */ AMBIENCE_CRITTER_05, + /* 0x06 */ AMBIENCE_CRITTER_06, + /* 0x07 */ AMBIENCE_CRITTER_07, + /* 0x08 */ AMBIENCE_CRITTER_08, + /* 0x09 */ AMBIENCE_CRITTER_09, + /* 0x0A */ AMBIENCE_CRITTER_10, + /* 0x0B */ AMBIENCE_CRITTER_11, + /* 0x0C */ AMBIENCE_CRITTER_12, + /* 0x0D */ AMBIENCE_CRITTER_13, + /* 0x0E */ AMBIENCE_CRITTER_14, + /* 0x0F */ AMBIENCE_CRITTER_15, + /* 0x10 */ AMBIENCE_CRITTER_16, + /* 0x11 */ AMBIENCE_CRITTER_17, + /* 0x12 */ AMBIENCE_CRITTER_18, + /* 0x13 */ AMBIENCE_CRITTER_19 +} AmbienceCritterId; -#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 AMBIENCE_IO_CRITTER_0_TYPE(type) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_0_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_0_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_0_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_1_TYPE(type) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_1_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_1_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_1_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_2_TYPE(type) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_2_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_2_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_2_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_3_TYPE(type) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_3_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_3_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_3_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_4_TYPE(type) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_4_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_4_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_4_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_5_TYPE(type) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_5_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_5_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_5_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_CRITTER_6_TYPE(type) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_6_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_6_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_6_PORT5(reverb) AMBIENCE_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 AMBIENCE_IO_STREAM_0_TYPE(type) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_0_PORT3(data) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_0_PORT4(data) AMBIENCE_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 AMBIENCE_IO_STREAM_1_TYPE(type) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_1_PORT3(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_1_PORT4(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data -#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_RAIN_PORT4(data) AMBIENCE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data -#define NATURE_IO_ENTRIES_END 0xFF +#define AMBIENCE_IO_ENTRIES_END 0xFF #endif diff --git a/include/variables.h b/include/variables.h index 07e80b2ca..c7ea263f2 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3416,7 +3416,7 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD434; // extern UNK_TYPE1 D_801FD435; // extern UNK_TYPE1 D_801FD436; -// extern UNK_TYPE1 D_801FD438; +// extern UNK_TYPE1 sPrevAmbienceSeqId; // extern UNK_TYPE1 D_801FD43A; // extern UNK_TYPE1 D_801FD43B; // extern UNK_TYPE1 D_801FD43E; @@ -3477,7 +3477,7 @@ extern ActiveSfx gActiveSfx[7][3]; // extern UNK_TYPE1 D_8020001E; // extern UNK_TYPE1 D_802000C9; // extern UNK_TYPE1 D_802000D4; -// extern UNK_TYPE1 D_80200140; +extern ActiveSequence gActiveSeqs[]; // extern UNK_TYPE1 D_8020034A; // extern UNK_TYPE1 D_80200B88; // extern UNK_TYPE1 D_80200BBA; diff --git a/include/z64.h b/include/z64.h index 69e89d629..5589e7cad 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1056,10 +1056,9 @@ struct FireObj { }; // size = 0x8B typedef struct { - /* 0x0 */ u8 seqIndex; - /* 0x1 */ u8 nightSeqIndex; - /* 0x2 */ u8 unk_02; -} SoundContext; // size = 0x3 + /* 0x0 */ u8 seqId; + /* 0x1 */ u8 ambienceId; +} SequenceContext; // size = 0x2 typedef struct { /* 0x0 */ s32 enabled; @@ -1095,7 +1094,7 @@ struct PlayState { /* 0x00800 */ Camera* cameraPtrs[NUM_CAMS]; /* 0x00810 */ s16 activeCamId; /* 0x00812 */ s16 nextCamera; - /* 0x00814 */ SoundContext soundCtx; + /* 0x00814 */ SequenceContext sequenceCtx; /* 0x00818 */ LightContext lightCtx; /* 0x00828 */ FrameAdvanceContext frameAdvCtx; /* 0x00830 */ CollisionContext colCtx; diff --git a/include/z64audio.h b/include/z64audio.h index fc9bf9f4c..c5045e34f 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -9,6 +9,7 @@ #define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) #define SEQ_NUM_CHANNELS 16 +#define SEQ_IO_VAL_NONE -1 typedef enum { /* 0 */ SEQPLAYER_STATE_0, @@ -51,9 +52,9 @@ typedef enum { typedef enum { /* 0 */ SOUNDMODE_STEREO, /* 1 */ SOUNDMODE_HEADSET, - /* 2 */ SOUNDMODE_SURROUND, + /* 2 */ SOUNDMODE_SURROUND_EXTERNAL, /* 3 */ SOUNDMODE_MONO, - /* 4 */ SOUNDMODE_SURROUND_EXTERNAL, + /* 4 */ SOUNDMODE_SURROUND, } SoundMode; typedef enum { @@ -1068,7 +1069,7 @@ typedef struct { /* 0x204 */ u16 unk_28; /* 0x206 */ u16 unk_250; /* 0x208 */ u16 unk_252; - /* 0x20A */ u16 unk_254; + /* 0x20A */ u16 seqId; /* 0x20C */ u16 unk_256; /* 0x20E */ u16 unk_258; /* 0x210 */ u8 unk_260; @@ -1080,7 +1081,7 @@ typedef struct { /* 0x219 */ u8 unk_4D; /* 0x21A */ u8 unk_4E; /* 0x21B */ u8 unk_21B; -} unk_D_8016E750; // size = 0x21C +} ActiveSequence; // size = 0x21C typedef struct { /* 0x0 */ u8 unk_0; @@ -1095,7 +1096,7 @@ typedef enum { /* 4 */ BANK_SYSTEM, /* 5 */ BANK_OCARINA, /* 6 */ BANK_VOICE -} SoundBankTypes; +} SfxBankType; typedef enum { /* 0 */ SFX_STATE_EMPTY, diff --git a/include/z64save.h b/include/z64save.h index 15984d45c..df78cc169 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -327,8 +327,8 @@ typedef struct SaveContext { /* 0x3EF8 */ s16 timerX[TIMER_ID_MAX]; // "event_xp" /* 0x3F06 */ s16 timerY[TIMER_ID_MAX]; // "event_yp" /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F16 */ u8 seqId; // "old_bgm" + /* 0x3F17 */ u8 ambienceId; // "old_env" /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" /* 0x3F1E */ u8 hudVisibilityForceButtonAlphasByStatus; // if btn alphas are updated through Interface_UpdateButtonAlphas, instead update them through Interface_UpdateButtonAlphasByStatus "ck_fg" /* 0x3F20 */ u16 nextHudVisibility; // triggers the hud to change visibility to the requested value. Reset to HUD_VISIBILITY_IDLE when target is reached "alpha_type" diff --git a/include/z64scene.h b/include/z64scene.h index 6b8849381..18d7b81f9 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -153,16 +153,16 @@ typedef struct { typedef struct { /* 0x0 */ u8 code; - /* 0x1 */ u8 bgmId; - /* 0x2 */ UNK_TYPE1 pad2[4]; - /* 0x6 */ u8 nighttimeSFX; - /* 0x7 */ u8 musicSeq; + /* 0x1 */ u8 specId; + /* 0x2 */ UNK_TYPE1 unk_02[4]; + /* 0x6 */ u8 ambienceId; + /* 0x7 */ u8 seqId; } SCmdSoundSettings; // size = 0x8 typedef struct { /* 0x0 */ u8 code; /* 0x1 */ u8 data1; - /* 0x2 */ UNK_TYPE1 pad2[5]; + /* 0x2 */ UNK_TYPE1 unk_02[5]; /* 0x7 */ u8 echo; } SCmdEchoSettings; // size = 0x8 @@ -817,7 +817,7 @@ typedef enum { /* 0x1D */ SCENE_CMD_ID_UNUSED_1D, /* 0x1E */ SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO, /* 0x1F */ SCENE_CMD_MAX -} SceneCommandTypeID; +} SceneCommandTypeId; #define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \ { SCENE_CMD_ID_SPAWN_LIST, numSpawns, CMD_PTR(spawnList) } @@ -887,8 +887,8 @@ typedef enum { #define SCENE_CMD_END() \ { SCENE_CMD_ID_END, 0, CMD_W(0) } -#define SCENE_CMD_SOUND_SETTINGS(audioSessionId, nighttimeSfx, bgmId) \ - { SCENE_CMD_ID_SOUND_SETTINGS, audioSessionId, CMD_BBBB(0, 0, nighttimeSfx, bgmId) } +#define SCENE_CMD_SOUND_SETTINGS(specId, ambienceId, seqId) \ + { SCENE_CMD_ID_SOUND_SETTINGS, specId, CMD_BBBB(0, 0, ambienceId, seqId) } #define SCENE_CMD_ECHO_SETTINGS(echo) \ { SCENE_CMD_ID_ECHO_SETTINGS, 0, CMD_BBBB(0, 0, 0, echo) } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index ea5c5ed5e..a8573e33d 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -315,7 +315,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->freqScale = 1.0f; for (i = 0; i < ARRAY_COUNT(channel->soundScriptIO); i++) { - channel->soundScriptIO[i] = -1; + channel->soundScriptIO[i] = SEQ_IO_VAL_NONE; } channel->unused = false; @@ -1791,12 +1791,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0x10: // channel: load sample if (lowBits < 8) { - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, &channel->soundScriptIO[lowBits]) == -1) {} } else { lowBits -= 8; - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100, &channel->soundScriptIO[lowBits]) == -1) {} } @@ -1805,7 +1805,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0x60: // channel: io read value scriptState->value = channel->soundScriptIO[lowBits]; if (lowBits < 2) { - channel->soundScriptIO[lowBits] = -1; + channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE; } break; @@ -2150,7 +2150,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { case 0x80: // seqPlayer: io read value seqScript->value = seqPlayer->soundScriptIO[cmdLowBits]; if (cmdLowBits < 2) { - seqPlayer->soundScriptIO[cmdLowBits] = -1; + seqPlayer->soundScriptIO[cmdLowBits] = SEQ_IO_VAL_NONE; } break; @@ -2286,7 +2286,7 @@ void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { seqPlayer->applyBend = false; for (j = 0; j < ARRAY_COUNT(seqPlayer->soundScriptIO); j++) { - seqPlayer->soundScriptIO[j] = -1; + seqPlayer->soundScriptIO[j] = SEQ_IO_VAL_NONE; } seqPlayer->muteFlags = MUTE_FLAGS_SOFTEN | MUTE_FLAGS_STOP_NOTES; diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index b896facbc..007d7ca85 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -5,12 +5,6 @@ typedef struct { /* 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; @@ -67,8 +61,30 @@ typedef struct { } FreqLerp; // size = 0x10 s32 AudioOcarina_MemoryGameNextNote(void); + +void AudioSfx_ProcessSfxSettings(void); +void func_8019FEDC(void); +void Audio_StepFreqLerp(FreqLerp* lerp); + s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); -void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + +void Audio_StartMorningSceneSequence(u16 seqId); +void Audio_StartSceneSequence(u16 seqId); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); +void func_801A4428(u8 reverbIndex); +void func_801A3038(void); +void Audio_PlayAmbience(u8 ambienceId); +void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume); + +void Audio_UpdateRiverSoundVolumes(void); +void func_801A1290(void); +void func_801A1904(void); +void func_801A1E0C(void); +void func_801A2090(void); +void Audio_UpdateSceneSequenceResumePoint(void); +void func_801A312C(void); +void func_801A3AC0(void); +void Audio_ResetRequestedSceneSeqId(void); // Sfx bss SfxSettings sSfxSettings[8]; @@ -90,7 +106,7 @@ u8 sGanonsTowerVol; f32* sSfxVolumeCur; f32 sSfxVolumeTarget; f32 sSfxVolumeRate; -u16 sSceneSeqId1; +u16 sRequestedSceneSeqId; SfxChannelState sSfxChannelState[16]; // Sequence bss @@ -99,7 +115,7 @@ u8 D_801FD3A9; u8 sRiverSoundBgmTimer; u8 sFanfareState; u16 sFanfareSeqId; -u8 sMuteOnlySfxAndNatureSeq; +u8 sMuteOnlySfxAndAmbienceSeq; u8 sAllPlayersMutedExceptOcaAndSys; u8 sAudioPauseState; u8 sSpatialSeqIsActive[4]; @@ -125,7 +141,7 @@ u8 sSpatialSubBgmFadeTimer; u8 D_801FD434; u8 sSpatialSeqPlayerIndex; u8 sSpatialSeqFadeTimer; -u16 D_801FD438; +u16 sPrevAmbienceSeqId; // AudioOcarina bss OcarinaStaff sPlayingStaff; @@ -202,11 +218,14 @@ s8 sAudioCodeReverb = 0; // Sequence Data u8 sPrevSeqMode = 0; -f32 sAudioEnemyDist = 0.0f; -s8 sAudioEnemyVol = 127; +f32 sBgmEnemyDist = 0.0f; +s8 sBgmEnemyVolume = 127; u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; -u8 sBgmPlayerIOPort7 = 0; -u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; + +#define SEQ_RESUME_POINT_NONE 0xC0 +u8 sSeqResumePoint = 0; +u8 sPrevSceneSeqId = NA_BGM_GENERAL_SFX; + u32 sNumFramesStill = 0; u32 sNumFramesMoving = 0; u8 sAudioBaseFilter = 0; @@ -217,768 +236,893 @@ s8 gUnderwaterSfxReverbAdd = 0; Vec3f* sRiverSoundBgmPos = NULL; f32 sRiverSoundXZDistToPlayer = 2000.0f; u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; + +// Allows enemy bgm +#define SEQ_FLAG_ENEMY (1 << 0) + +#define SEQ_FLAG_FANFARE (1 << 1) +#define SEQ_FLAG_FANFARE_KAMARO (1 << 2) + +// required for Audio_RestorePrevBgm to restore a sequence after Audio_PlayBgm_StorePrevBgm +#define SEQ_FLAG_RESTORE (1 << 3) + +/** + * These two sequence flags work together to implement a “resume playing from where you left off” system for scene + * sequences when leaving and returning to a scene. For a scene to resume playing from the point where it left off, it + * must have `SEQ_FLAG_RESUME` attached to it. Then, if the scene changes and the new scene sequence contain + * `SEQ_FLAG_RESUME_PREV`, the point from the previous scene sequence will be stored. Then, when returning to the + * scene with the sequence `SEQ_FLAG_RESUME`, then the sequence will resume playing from where it left off. + * + * TODO: Confirm which sequences properly implement this system after sequence extraction + */ +#define SEQ_FLAG_RESUME (1 << 4) +#define SEQ_FLAG_RESUME_PREV (1 << 5) + +/** + * Will write a value of 1 to ioPort 7 when called through the scene. How it's used depends on the sequence: + * NA_BGM_FILE_SELECT - ioPort 7 skips the harp intro when a value of 1 is written to it. + */ +#define SEQ_FLAG_SKIP_HARP_INTRO (1 << 6) + +// Unused, repurposed for SubBgm +#define SEQ_FLAG_NO_AMBIENCE (1 << 7) + 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 + SEQ_FLAG_FANFARE | SEQ_FLAG_ENEMY, // NA_BGM_GENERAL_SFX + SEQ_FLAG_ENEMY, // NA_BGM_AMBIENCE + SEQ_FLAG_ENEMY, // NA_BGM_TERMINA_FIELD + SEQ_FLAG_RESTORE, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + SEQ_FLAG_ENEMY, // NA_BGM_STONE_TOWER_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_INV_STONE_TOWER_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_0 + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + SEQ_FLAG_ENEMY, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + SEQ_FLAG_FANFARE, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_REGION + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + SEQ_FLAG_ENEMY, // 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 + SEQ_FLAG_SKIP_HARP_INTRO, // NA_BGM_FILE_SELECT + SEQ_FLAG_RESUME, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + SEQ_FLAG_RESTORE, // NA_BGM_BOSS + SEQ_FLAG_ENEMY, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + SEQ_FLAG_RESUME_PREV, // NA_BGM_INSIDE_A_HOUSE + SEQ_FLAG_FANFARE, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_ITEM + SEQ_FLAG_FANFARE, // NA_BGM_GATE_OPEN + SEQ_FLAG_FANFARE, // NA_BGM_GET_HEART + SEQ_FLAG_RESTORE, // 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 + SEQ_FLAG_FANFARE, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + SEQ_FLAG_SKIP_HARP_INTRO, // 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 + SEQ_FLAG_FANFARE, // NA_BGM_OCA_EPONA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SUNS + SEQ_FLAG_FANFARE, // NA_BGM_OCA_TIME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_STORM + SEQ_FLAG_RESUME, // NA_BGM_ZORA_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GET_NEW_MASK + SEQ_FLAG_RESTORE, // NA_BGM_MINI_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + SEQ_FLAG_ENEMY, // NA_BGM_CAVERN + SEQ_FLAG_RESUME | SEQ_FLAG_ENEMY, // NA_BGM_MILK_BAR + SEQ_FLAG_FANFARE, // 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 + SEQ_FLAG_RESUME_PREV, // NA_BGM_SHOP + SEQ_FLAG_FANFARE, // NA_BGM_OWL + SEQ_FLAG_RESUME_PREV, // NA_BGM_MINI_GAME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SOARING + SEQ_FLAG_FANFARE, // NA_BGM_OCA_HEALING + SEQ_FLAG_FANFARE, // NA_BGM_INVERTED_SONG_OF_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONG_OF_DOUBLE_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONATA_OF_AWAKENING + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_BOSSA_NOVA + SEQ_FLAG_FANFARE, // NA_BGM_ELEGY_OF_EMPTINESS + SEQ_FLAG_FANFARE, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_FAIRY + SEQ_FLAG_FANFARE, // NA_BGM_BREMEN_MARCH + SEQ_FLAG_FANFARE, // NA_BGM_BALLAD_OF_THE_WIND_FISH + SEQ_FLAG_RESTORE, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_RIFF + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SONATA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_NEW_WAVE + SEQ_FLAG_FANFARE, // NA_BGM_OCA_ELEGY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_GUITAR_BASS_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_INDIGO_GO_SESSION + SEQ_FLAG_ENEMY, // NA_BGM_SNOWHEAD_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_SAXOPHONE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + SEQ_FLAG_FANFARE, // NA_BGM_BASS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_DRUMS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_PLAY + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + SEQ_FLAG_FANFARE_KAMARO, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + SEQ_FLAG_FANFARE, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + SEQ_FLAG_FANFARE, // NA_BGM_DUNGEON_APPEAR + SEQ_FLAG_FANFARE, // NA_BGM_WOODFALL_CLEAR + SEQ_FLAG_FANFARE, // 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] = { +s8 sSpecReverbs[] = { 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 +#define AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX 33 + +typedef struct { + /* 0x0 */ u16 initChannelMask; // bitwise flag for 16 channels, channels to initialize + /* 0x2 */ u16 initMuteChannelMask; // bitwise flag for 16 channels, channels to mute upon initialization + /* 0x4 */ u8 channelProperties[3 * AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX + 1]; +} AmbienceDataIO; // size = 0x68 + +AmbienceDataIO sAmbienceData[20] = { + // AMBIENCE_ID_00 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 1 + // AMBIENCE_ID_01 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 2 + // AMBIENCE_ID_02 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 3 + // AMBIENCE_ID_03 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(32), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 4 + // AMBIENCE_ID_04 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // Channel 14 - NATURE_IO_RAIN_PORT4(63), + AMBIENCE_IO_RAIN_PORT4(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 5 + // AMBIENCE_ID_05 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 6 + // AMBIENCE_ID_06 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 7 + // AMBIENCE_ID_07 { - 0xC001, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 8 + // AMBIENCE_ID_08 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 9 + // AMBIENCE_ID_09 { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(2), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 10 + // AMBIENCE_ID_0A { - 0xC081, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_6_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_6_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_6_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_6_PORT5(32), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 11 + // AMBIENCE_ID_0B { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_3), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(2), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 12 + // AMBIENCE_ID_0C { - 0xC007, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_1_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 13 + // AMBIENCE_ID_0D { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 14 + // AMBIENCE_ID_0E { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 15 + // AMBIENCE_ID_0F { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 16 + // AMBIENCE_ID_10 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 17 + // AMBIENCE_ID_11 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 18 + // AMBIENCE_ID_12 { - 0xC000, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 19 + // AMBIENCE_ID_13 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_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), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, @@ -3256,7 +3400,7 @@ u8 sRequestCustomSequence = false; void AudioOcarina_SetCustomSequence(void) { // Never passes true as sRequestCustomSequence is never set true if (sRequestCustomSequence && gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].enabled && - ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == 0xFF)) { + ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) { gAudioContext.seqPlayers[SEQ_PLAYER_FANFARE].seqData = sCustomSequenceScript; sRequestCustomSequence = false; } @@ -3477,17 +3621,46 @@ void AudioOcarina_ResetStaffs(void) { D_801D8534 = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DFF8.s") +void Audio_Noop1(s32 arg0) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E000.s") +void Audio_Noop2(s32 arg0, s32 arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E00C.s") +void Audio_Noop3(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E014.s") +void Audio_Update(void) { + if ((func_801A9768() == 0) && (func_801A982C() == 0)) { + AudioOcarina_SetCustomSequence(); + AudioOcarina_Update(); + func_801A5118(); + Audio_StepFreqLerp(&sRiverFreqScaleLerp); + Audio_StepFreqLerp(&sWaterfallFreqScaleLerp); + Audio_UpdateRiverSoundVolumes(); + Audio_UpdateSceneSequenceResumePoint(); + func_801A312C(); + func_8019FEDC(); + func_801A1E0C(); + func_801A1904(); + func_801A2090(); + func_801A3AC0(); + func_801A1290(); + Audio_ResetRequestedSceneSeqId(); + AudioSfx_ProcessRequests(); + func_801A89D0(); + AudioSfx_ProcessActiveSfx(); + func_801A8D5C(); + AudioSfx_ProcessSfxSettings(); + AudioThread_ScheduleProcessCmds(); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E0FC.s") +void Audio_Noop4(s32 arg0) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E104.s") +void Audio_Noop5(s32 arg0, s32 arg1) { +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E110.s") @@ -3582,7 +3755,7 @@ s8 AudioSfx_ComputeReverb(u8 bankId, u8 entryIndex, u8 channelIndex) { if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) { scriptAdd = gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1]; - if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] < 0) { + if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] <= SEQ_IO_VAL_NONE) { scriptAdd = 0; } } @@ -3815,7 +3988,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { case BANK_ENV: case BANK_ENEMY: case BANK_VOICE: - if (sSoundMode == SOUNDMODE_SURROUND) { + if (sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) { combFilterGain = AudioSfx_ComputeCombFilter(*entry->posY, entry->sfxParams); } // fallthrough @@ -3826,7 +3999,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { panSigned = AudioSfx_ComputePanSigned(*entry->posX, *entry->posZ, entry->token); freqScale = AudioSfx_ComputeFreqScale(bankId, entryIndex) * *entry->freqScale; - if (sSoundMode == SOUNDMODE_SURROUND) { + if (sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) { if (*entry->posZ >= 0.0f) { if (*entry->posZ < 200.0f) { zVolume = 32.0f - ((*entry->posZ / 300.0f) * 32.0f); @@ -3859,7 +4032,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { ((entry->sfxFlags & SFX_FLAG2_APPLY_LOWPASS_FILTER) >> 2)) * 2); filter &= 0xFF; - } else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST)) { + } else if ((sSoundMode == SOUNDMODE_SURROUND_EXTERNAL) && !(entry->sfxParams & SFX_FLAG_VOLUME_NO_DIST)) { filter = AudioSfx_ComputeSurroundSoundFilter(behindScreenZ, entry, panSigned); } break; @@ -4189,7 +4362,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { 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) { + (u8)SEQ_IO_VAL_NONE) { // Higher volume leads to lower reverb reverb = (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - @@ -4350,9 +4523,51 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) { } } -u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; -void Audio_SplitBgmChannels(s8 volumeSplit); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") +/** + * Turns on and off channels from both bgm players in a way that splits + * equally between the two bgm channels. Split based on note priority + */ +void Audio_SplitBgmChannels(s8 volumeSplit) { + u8 volume; + u8 notePriority; + u16 channelBits; + u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; + u8 i; + u8 channelIndex; + + if ((Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + for (i = 0; i < ARRAY_COUNT(sBgmPlayers); i++) { + if (i == 0) { + // Main Bgm SeqPlayer + volume = volumeSplit; + } else { + // Sub Bgm SeqPlayer + volume = 0x7F - volumeSplit; + } + + if (volume > 100) { + notePriority = 11; + } else if (volume < 20) { + notePriority = 2; + } else { + notePriority = ((volume - 20) / 10) + 2; + } + + channelBits = 0; + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (gAudioContext.seqPlayers[sBgmPlayers[i]].channels[channelIndex]->notePriority < notePriority) { + // If the note currently playing in the channel is a high enough priority, + // then keep the channel on by setting a channelBit + // If this condition fails, then the channel will be shut off + channelBits += (1 << channelIndex); + } + } + + Audio_QueueSeqCmd(0xA0000000 | ((u32)(sBgmPlayers[i]) << 24) | ((u32)(channelBits))); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -4404,7 +4619,7 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { if (sRiverSoundBgmPos == NULL) { sRiverSoundBgmPos = pos; - func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); } else { prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); if (dist < prevDist) { @@ -4441,15 +4656,80 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2544.s") +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) { + Audio_StartMorningSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | (u32)(dayMinusOne)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A257C.s") +void Audio_StartMorningSceneSequence(u16 seqId) { + if (seqId != NA_BGM_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_AMBIENCE) << 24) | ((0) << 16)); + Audio_StartSceneSequence(seqId); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 0, 1); + } else { + Audio_PlayAmbience(AMBIENCE_ID_08); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A25E4.s") +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne) { + if (sRequestedSceneSeqId != seqId) { + if (seqId == NA_BGM_AMBIENCE) { + Audio_PlayAmbience(AMBIENCE_ID_08); + } else if ((seqId != NA_BGM_FINAL_HOURS) || (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + Audio_StartSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | + (u32)(dayMinusOne)); + } + sRequestedSceneSeqId = seqId; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2670.s") +void Audio_StartSceneSequence(u16 seqId) { + u8 fadeInDuration = 0; + u8 skipHarpIntro; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2778.s") + if ((sSeqFlags[sPrevSceneSeqId] & SEQ_FLAG_RESUME_PREV) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + // Resume the sequence from the point where it left off last time it was played in the scene + if ((sSeqResumePoint & 0x3F) != 0) { + fadeInDuration = 30; + } + + // Write the sequence resumePoint to resume from into ioPort 7 + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, fadeInDuration, 7, sSeqResumePoint); + + sSeqResumePoint = 0; + } else { + // Start the sequence from the beginning + + // Writes to ioPort 7. See `SEQ_FLAG_SKIP_HARP_INTRO` for writing a value of 1 to ioPort 7. + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_SKIP_HARP_INTRO) { + skipHarpIntro = 1; + } else { + skipHarpIntro = (u8)SEQ_IO_VAL_NONE; + } + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, skipHarpIntro); + + if (!(sSeqFlags[seqId] & SEQ_FLAG_RESUME_PREV)) { + // Reset the sequence resumePoint + sSeqResumePoint = SEQ_RESUME_POINT_NONE; + } + } + sPrevSceneSeqId = seqId & 0xFF; +} + +void Audio_UpdateSceneSequenceResumePoint(void) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) { + // Get the current point to resume from + sSeqResumePoint = gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3]; + } else { + // Initialize the point to resume from to the start of the sequence + sSeqResumePoint = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A27E8.s") @@ -4463,35 +4743,238 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C44.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C88.s") +void Audio_PlaySequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_PlayFanfare(seqId); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else { + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, SEQ_IO_VAL_NONE); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0); + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") +void Audio_StopSequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((0) << 16)); + } else { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") +s32 Audio_IsSequencePlaying(u8 seqId) { + u8 playerIndex = SEQ_PLAYER_BGM_MAIN; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") + if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE) { + playerIndex = SEQ_PLAYER_FANFARE; + } else if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + playerIndex = SEQ_PLAYER_FANFARE; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2ED8.s") + if (seqId == (Audio_GetActiveSequence(playerIndex) & 0xFF)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2F88.s") +void Audio_PlayBgm_StorePrevBgm(u16 seqId) { + u16 curSeqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2FC4.s") + if (curSeqId == NA_BGM_DISABLED) { + curSeqId = NA_BGM_GENERAL_SFX; + } + + if (curSeqId != seqId) { + Audio_SetSequenceMode(SEQ_MODE_IGNORE); + + // Ensure the sequence about to be stored isn't also storing a separate sequence + if (!(sSeqFlags[curSeqId] & SEQ_FLAG_RESTORE)) { + sPrevMainBgmSeqId = curSeqId; + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | (u32)(seqId + 0x8000)); + } +} + +/** + * To be used in conjunction with Audio_PlayBgm_StorePrevBgm + */ +void Audio_RestorePrevBgm(void) { + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && + (sSeqFlags[Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) || (sPrevMainBgmSeqId == NA_BGM_GENERAL_SFX)) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } else { + if (sPrevMainBgmSeqId == NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = sPrevAmbienceSeqId; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + sPrevMainBgmSeqId = NA_BGM_DISABLED; + } +} + +// Unused +void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if (seqId != NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = seqId; + } + + Audio_PlayAmbience(ambienceId); +} + +// Unused +void Audio_ForceRestorePreviousBgm(void) { + if (sPrevMainBgmSeqId != NA_BGM_DISABLED) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + + sPrevMainBgmSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3000.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3038.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3098.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A312C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3238.s") +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { + u16 flaggedSeqId; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A32CC.s") + Audio_QueueSeqCmd(0x70000000 | ((u32)(playerIndex) << 24) | ((u32)(ioPort) << 0x10) | (u32)(ioData)); + if ((seqId & 0xFF) < 2) { + flaggedSeqId = seqId; + } else { + flaggedSeqId = seqId | 0x8000; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(playerIndex) << 24) | ((u32)(fadeInDuration) << 0x10) | (u32)(flaggedSeqId)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3590.s") +void Audio_SetSequenceMode(u8 seqMode) { + s32 volumeFadeInTimer; + u16 seqId; + u8 volumeFadeOutTimer; + + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) && (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + // clang-format off + if (sAudioCutsceneFlag || sSpatialSeqIsActive[SEQ_PLAYER_BGM_SUB]) { \ + seqMode = SEQ_MODE_IGNORE; + } + // clang-format on + + seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if ((seqId == NA_BGM_DISABLED) || (sSeqFlags[(u8)(seqId & 0xFF)] & SEQ_FLAG_ENEMY) || + ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY)) { + if (seqMode != (sPrevSeqMode & 0x7F)) { + if (seqMode == SEQ_MODE_ENEMY) { + // If only seqMode = SEQ_MODE_ENEMY (Start) + if (gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume < 0) { + volumeFadeInTimer = -(gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume); + } else { + volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, volumeFadeInTimer); + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + + if (seqId >= NA_BGM_TERMINA_FIELD) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - sBgmEnemyVolume, 10); + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + } else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) { + // If only sPrevSeqMode = SEQ_MODE_ENEMY (End) + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((10) << 16)); + + if (seqMode == SEQ_MODE_IGNORE) { + volumeFadeOutTimer = 0; + } else { + volumeFadeOutTimer = 10; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer); + Audio_SplitBgmChannels(0); + } + + sPrevSeqMode = seqMode + 0x80; + } else { + if (seqMode == SEQ_MODE_ENEMY) { + // If both seqMode = sPrevSeqMode = SEQ_MODE_ENEMY + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) && + (seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_ENEMY)) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + sPrevSeqMode = seqMode + 0x80; + } + } + } + } else { + // Remnant of OoT's Hyrule Field Sequence + if (seqMode == SEQ_MODE_DEFAULT) { + if (sPrevSeqMode == SEQ_MODE_STILL) { + sNumFramesMoving = 0; + } + sNumFramesStill = 0; + sNumFramesMoving++; + } else { + sNumFramesStill++; + } + + if ((seqMode == SEQ_MODE_STILL) && (sNumFramesStill < 30) && (sNumFramesMoving > 20)) { + seqMode = SEQ_MODE_DEFAULT; + } + + sPrevSeqMode = seqMode; + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 0x10) | (u32)(seqMode)); + } + } +} + +void Audio_UpdateEnemyBgmVolume(f32 dist) { + f32 adjDist; + u16 seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if (sPrevSeqMode == (SEQ_MODE_ENEMY | 0x80)) { + if (dist != sBgmEnemyDist) { + // clamp (dist - 150.0f) between 0 and 350 + if (dist < 150.0f) { + adjDist = 0.0f; + } else if (dist > 500.0f) { + adjDist = 350.0f; + } else { + adjDist = dist - 150.0f; + } + + sBgmEnemyVolume = ((350.0f - adjDist) * 127.0f) / 350.0f; + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, 10); + + if ((seqId >= NA_BGM_TERMINA_FIELD) && !(sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sBgmEnemyVolume), 10); + } + } + + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + sBgmEnemyDist = dist; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A36F0.s") @@ -4521,7 +5004,9 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") +void Audio_SetCutsceneFlag(s8 flag) { + sAudioCutsceneFlag = flag; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") @@ -4529,7 +5014,7 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3FFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/audio_setBGM.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4058.s") @@ -4551,7 +5036,9 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44C4.s") +void Audio_ResetRequestedSceneSeqId(void) { + sRequestedSceneSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44D4.s") @@ -4562,14 +5049,111 @@ f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A479C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A47DC.s") +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { + u8 firstChannelIndex; + u8 lastChannelIndex; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A48E0.s") + if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && func_801A8ABC(NA_BGM_AMBIENCE, 0xF00000FF)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4A28.s") + // channelIndexRange = 01 on ioPort 1 + if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + D_801FD3A8 = 0; + } -u32 Audio_SetNatureAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s") + firstChannelIndex = channelIndexRange >> 4; + lastChannelIndex = channelIndexRange & 0xF; + + if (firstChannelIndex == 0) { + firstChannelIndex = channelIndexRange & 0xF; + } + + for (channelIndex = firstChannelIndex; channelIndex <= lastChannelIndex; channelIndex++) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } +} + +void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) { + u8 channelIndex; + + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_0) << 0x10) | + (u32)(1)); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_4) << 0x10) | + (u32)((u8)(initChannelMask >> 8))); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_5) << 0x10) | + (u32)((u8)(initChannelMask & 0xFF))); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1); + + if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) { + Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0); + AudioThread_QueueCmdS32(0xF8 << 24, 0); + } + + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 1); + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(0) << 0x10) | (u32)(NA_BGM_AMBIENCE)); + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (!(initMuteChannelMask & (1 << channelIndex)) && (initChannelMask & (1 << channelIndex))) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_1) << 16) | + ((u32)(channelIndex) << 8) | (u32)(1)); + } + } +} + +void Audio_PlayAmbience(u8 ambienceId) { + u8 i = 0; + u8 channelIndex; + u8 ioPort; + u8 ioData; + + if (!((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_DISABLED) && + (sSeqFlags[gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE))) { + if (gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) { + sPrevAmbienceSeqId = gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId; + } + + Audio_StartAmbience(sAmbienceData[ambienceId].initChannelMask, sAmbienceData[ambienceId].initMuteChannelMask); + + while ((sAmbienceData[ambienceId].channelProperties[i] != 0xFF) && + (i < ARRAY_COUNT(sAmbienceData[ambienceId].channelProperties))) { + channelIndex = sAmbienceData[ambienceId].channelProperties[i++]; + ioPort = sAmbienceData[ambienceId].channelProperties[i++]; + ioData = sAmbienceData[ambienceId].channelProperties[i++]; + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } + + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_7) << 16) | + ((u32)(AMBIENCE_CHANNEL_SOUND_MODE) << 8) | (u32)(sSoundMode)); + } +} + +u32 Audio_SetAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel) { + u32 seqScriptValOut = seqScriptValIn; + + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].applyBend = true; + + if ((seqScriptValIn == 0) || (seqScriptValIn == 0xFF)) { + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0f; + } else { + seqScriptValOut = AudioThread_NextRandom(); + gAudioContext.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0293 - ((gAudioContext.audioRandom & 0xF) / 144.0f); + + return seqScriptValOut; + } + +#ifdef AVOID_UB + return seqScriptValOut; +#endif +} void Audio_Init(void) { AudioLoad_Init(NULL, 0); @@ -4587,7 +5171,7 @@ void AudioSfx_Init(u16 fadeTimer) { } AudioThread_QueueCmdS32(0xE4000000, AudioSfx_SetFreqAndStereoBits); - AudioThread_QueueCmdS32(0xE4000001, Audio_SetNatureAmbienceRandomBend); + AudioThread_QueueCmdS32(0xE4000001, Audio_SetAmbienceRandomBend); } #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 4cf1147bf..d76970829 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -671,7 +671,7 @@ void AudioSfx_PlayActiveSfx(u8 bankId) { // "one-frame" sfx entry->state = SFX_STATE_PLAYING_ONE_FRAME; } - } else if ((u8)channel->soundScriptIO[1] == 0xFF) { + } else if ((u8)channel->soundScriptIO[1] == (u8)SEQ_IO_VAL_NONE) { // Signal from seq 0 that the sfx is finished playing. Remove entry AudioSfx_RemoveBankEntry(bankId, entryIndex); } else if (entry->state == SFX_STATE_PLAYING_REFRESH) { diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index f2f37a013..3f8446036 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -2,7 +2,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D04.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D84.s") @@ -10,7 +10,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89D0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8A50.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8ABC.s") diff --git a/src/code/game.c b/src/code/game.c index da21de17f..73352379f 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -225,7 +225,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g void GameState_Destroy(GameState* gameState) { AudioMgr_StopAllSfxExceptSystem(); - func_8019E014(); + Audio_Update(); osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); if (gameState->destroy != NULL) { diff --git a/src/code/graph.c b/src/code/graph.c index 654d2c5f7..869740e4b 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -232,7 +232,7 @@ void Graph_UpdateGame(GameState* gameState) { Game_UpdateInput(gameState); Game_IncrementFrameCount(gameState); if (SREG(20) < 3) { - func_8019E014(); + Audio_Update(); } } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index c970282a8..0e682231f 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -6,8 +6,8 @@ void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(SaveContext)); gSaveContext.save.playerForm = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 4453bd674..69995db16 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -152,7 +152,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c break; case 0x2: if (isStartFrame) { - func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); Environment_AddLightningBolts(play, 3); D_801F4E68 = 1; } @@ -376,14 +376,14 @@ void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmd // Command 0x12C: Plays a sequence (Background music or Fanfare) void Cutscene_Command_PlaySequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { if (csCtx->frames == cmd->startFrame) { - func_801A2C88(cmd->sequence - 1); + Audio_PlaySequenceInCutscene(cmd->sequence - 1); } } // Command 0x12D: Stops a sequence (Background music or Fanfare) void Cutscene_Command_StopSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - func_801A2D54(cmd->sequence - 1); + Audio_StopSequenceInCutscene(cmd->sequence - 1); } } @@ -403,9 +403,7 @@ void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCm // Command 0x12E: Play Ambience sequence void Cutscene_Command_PlayAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { if (csCtx->frames == cmd->startFrame) { - // Audio_PlayNatureAmbienceSequence - // nightSeqIndex is natureAmbienceId - func_801A4A28(play->soundCtx.nightSeqIndex); + Audio_PlayAmbience(play->sequenceCtx.ambienceId); } } @@ -455,29 +453,27 @@ void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { break; case 4: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); - func_801A246C(SEQ_PLAYER_NATURE, 1); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_1); + func_801A246C(SEQ_PLAYER_AMBIENCE, 1); break; case 5: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); - func_801A246C(SEQ_PLAYER_NATURE, 0); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_0); + func_801A246C(SEQ_PLAYER_AMBIENCE, 0); break; case 6: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); - func_801A246C(SEQ_PLAYER_NATURE, 2); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_2); + func_801A246C(SEQ_PLAYER_AMBIENCE, 2); break; case 7: - // Audio_GetActiveSequence - seqId = func_801A8A50(0); + seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); break; case 8: if (seqId != NA_BGM_DISABLED) { - // Audio_PlayBgmForDayScene - func_801A25E4(seqId, dayMinusOne); + Audio_PlaySceneSequence(seqId, dayMinusOne); } break; } @@ -647,7 +643,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB // Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding // mask void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(SEQ_PLAYER_BGM_MAIN, true) != 0xFF)) { switch (cmd->base) { case 1: Cutscene_TerminatorImpl(play, csCtx, cmd); diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 9fc3dee25..776dc75d7 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -46,8 +46,8 @@ void GameOver_Update(PlayState* play) { gSaveContext.unk_3DC0 = 2000; gSaveContext.save.playerData.tatlTimer = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; @@ -67,7 +67,7 @@ void GameOver_Update(PlayState* play) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != NA_BGM_GAME_OVER) { + if (Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) { func_80169F78(&play->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index a3a4e331d..ce5ddf769 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -436,11 +436,12 @@ void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x15: Sound Settings= void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { - play->soundCtx.seqIndex = cmd->soundSettings.musicSeq; - play->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; + play->sequenceCtx.seqId = cmd->soundSettings.seqId; + play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId; - if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { - audio_setBGM(cmd->soundSettings.bgmId); + if (gSaveContext.seqId == (u8)NA_BGM_DISABLED || + Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { + Audio_SetSpec(cmd->soundSettings.specId); } } 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 ca8ad214f..f26bc505f 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -521,7 +521,7 @@ void func_809ED224(Boss04* this) { this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; - func_801A2ED8(); + Audio_RestorePrevBgm(); this->unk_1F6 = 10; } @@ -759,7 +759,7 @@ void Boss04_Update(Actor* thisx, PlayState* play2) { if (D_809EE4D0 != 0) { D_809EE4D0--; if (D_809EE4D0 == 0) { - func_801A2E54(0x38); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } } 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 5988d1913..9a0f95004 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -670,7 +670,7 @@ void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, PlayState* play) { void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, PlayState* play) { switch (play->csCtx.frames) { case 5: - func_801A4A28(12); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 660: @@ -688,7 +688,7 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) { switch (play->csCtx.frames) { case 5: - func_801A4A28(12); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 45: 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 6bf8adc72..65df579ce 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -537,7 +537,7 @@ void func_808A1784(DoorShutter* this, PlayState* play) { } else { DoorShutter_SetupAction(this, func_808A1090); } - func_801A2ED8(); + Audio_RestorePrevBgm(); } } 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 33f8225d3..575cf2d35 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 @@ -671,7 +671,7 @@ void func_809C2730(EnAob01* this, PlayState* play) { void func_809C2788(EnAob01* this, PlayState* play) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, play)) { - if (func_801A8A50(0) != 0x41) { + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) { play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; play->transitionType = TRANS_TYPE_64; 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 4834256d6..3f35a5e35 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -1426,7 +1426,7 @@ void func_80A97AB4(EnAz* this, PlayState* play) { if (play->msgCtx.choiceIndex == 0) { func_8019F208(); play->msgCtx.msgMode = 0x44; - func_800FD750(NA_BGM_MINI_GAME_2); + func_800FD750(NA_BGM_TIMED_MINI_GAME); func_80A94AB8(this, play, 1); func_80A979DC(this, play); } else { @@ -1466,7 +1466,7 @@ void func_80A97C4C(EnAz* this, PlayState* play) { func_80A97410(this, play); if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { gSaveContext.save.weekEventReg[24] &= (u8)~1; - func_800FD750(NA_BGM_MINI_GAME_2); + func_800FD750(NA_BGM_TIMED_MINI_GAME); play->nextEntrance = Entrance_CreateFromSpawn(1); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; 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 20a868bc6..62e1df422 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -220,7 +220,7 @@ void EnBigpo_Init(Actor* thisx, PlayState* play2) { if (thisx->params == ENBIGPO_REGULAR) { // the well poe, starts immediately thisx->flags &= ~ACTOR_FLAG_10; // always update OFF - this->unkBool204 = true; + this->storePrevBgm = true; EnBigpo_InitWellBigpo(this); } else if (thisx->params == ENBIGPO_SUMMONED) { // dampe type EnBigpo_InitDampeMainPo(this); @@ -439,9 +439,9 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, PlayState* play) { */ void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; } @@ -525,9 +525,9 @@ void EnBigpo_WarpingIn(EnBigpo* this, PlayState* play) { this->mainColor.a = this->idleTimer * (255.0f / 32.0f); if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } EnBigpo_SetupIdleFlying(this); } @@ -1124,7 +1124,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, PlayState* play) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type - func_801A2ED8(); + Audio_RestorePrevBgm(); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); 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 9117bd97c..9b84784f4 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -30,7 +30,7 @@ typedef struct EnBigpo { /* 0x188 */ Vec3s jointTable[ENBIGPO_LIMBCOUNT]; /* 0x1C4 */ Vec3s morphTable[ENBIGPO_LIMBCOUNT]; /* 0x200 */ EnBigPoActionFunc actionFunc; - /* 0x204 */ u8 unkBool204; // need to know what func_801A2E54 does to know what this is + /* 0x204 */ u8 storePrevBgm; /* 0x206 */ s16 idleTimer; // frame counter /* 0x208 */ s16 unk208; // facing rotY? /* 0x20A */ s16 rotVelocity; 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 6cc0b2e72..98212382b 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1005,7 +1005,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, PlayState* play) { } else if (this->isAnimUpdate) { Animation_PlayLoop(&this->skelAnime, &gGekkoNervousIdleAnim); EnBigslime_UpdateCameraIntroCs(this, play, 25); - func_801A2E54(0x38); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); EnBigslime_InitFallMinislime(this); play->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; @@ -2620,7 +2620,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { if (Actor_ApplyDamage(&this->actor) == 0) { func_800BE504(&this->actor, &this->gekkoCollider); - func_801A2ED8(); + Audio_RestorePrevBgm(); Enemy_StartFinishingBlow(play, &this->actor); this->gekkoCollider.base.acFlags &= ~AC_ON; EnBigslime_GekkoThaw(this, play); 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 a9d9756be..25f5de3e1 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -691,7 +691,7 @@ void func_80C02740(EnBomjimb* this, PlayState* play) { gSaveContext.save.bombersCaughtNum++; if (gSaveContext.save.bombersCaughtNum > 4) { - func_801A3098(0x922); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); } 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 10c28b6eb..bc33adc0c 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -482,7 +482,7 @@ void EnBox_WaitOpen(EnBox* this, PlayState* play) { 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); + Audio_PlayFanfare(NA_BGM_OPEN_CHEST | 0x900); } if (this->getItemId == GI_STRAY_FAIRY) { 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 c17acf8cc..bf2f5e7ce 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -511,7 +511,7 @@ void func_8089B3D4(EnDinofos* this, PlayState* play) { Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } subCamAt.x = this->actor.world.pos.x; @@ -530,7 +530,7 @@ void func_8089B3D4(EnDinofos* this, PlayState* play) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; @@ -1279,7 +1279,7 @@ s32 func_8089D60C(EnDinofos* this, PlayState* play) { } if (this->actor.cutscene != -1) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } } 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 fa465afbe..12d804fba 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -493,7 +493,7 @@ void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { // You found a Stray Fairy! Message_StartTextbox(play, 0x11, NULL); if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } } } 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 8ab640253..c0be81361 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -538,7 +538,7 @@ void func_80962660(EnFu* this, PlayState* play) { player->stateFlags1 |= 0x20; this->unk_53C = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(play); @@ -799,7 +799,7 @@ void func_80962F4C(EnFu* this, PlayState* play) { func_801A2C20(); gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(play, 1); this->unk_54A = 3; func_809632D0(this); 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 d71e4c193..ffd45eaf9 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -387,7 +387,7 @@ void EnIk_Idle(EnIk* this, PlayState* play) { } } else if (this->colliderCylinder.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->actor.hintId = TATL_HINT_ID_IRON_KNUCKLE; this->colliderCylinder.base.acFlags &= ~AC_HIT; this->invincibilityFrames = 12; @@ -786,7 +786,7 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { isArmorBroken = true; } else { Enemy_StartFinishingBlow(play, &this->actor); - func_801A2ED8(); + Audio_RestorePrevBgm(); } } if (isArmorBroken == true) { 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 2ac167235..2050c7316 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1989,7 +1989,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, PlayState* play) { if (this->actionTimer == 100) { - func_801A3098(NA_BGM_CLEAR_EVENT); + Audio_PlayFanfare(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { 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 e90b2decc..49d7a06fb 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 @@ -881,7 +881,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(NA_BGM_FAILURE_1); + Audio_PlayFanfare(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; 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 6909183f3..ac3c8322e 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -303,7 +303,7 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { this->unk_2AC--; if (this->unk_2AC == 0) { if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { - func_801A3098(0x922); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_ERROR); } 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 f1bfcd57f..8b636787d 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -356,7 +356,7 @@ void func_8095AE60(EnOwl* this, PlayState* play) { void func_8095AEC0(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (func_8095A978(this, play, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -385,7 +385,7 @@ void func_8095AF2C(EnOwl* this, PlayState* play) { void func_8095AFEC(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (func_8095A978(this, play, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -500,7 +500,7 @@ void func_8095B574(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -713,7 +713,7 @@ void func_8095BE0C(EnOwl* this, PlayState* play) { func_8095A920(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; - func_801A3098(NA_BGM_OWL); + Audio_PlayFanfare(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { 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 b1b3d9cbc..4be8ad3c1 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, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(play)) { if (!this->unk_2AE) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1255,7 +1255,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } @@ -1267,7 +1267,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { @@ -1303,7 +1303,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { EnPametfrog_ApplyMagicArrowEffects(this, play); Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; - func_801A2ED8(); + Audio_RestorePrevBgm(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { EnPametfrog_ApplyElectricStun(this); 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 1d504dc62..5a2503808 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 @@ -377,7 +377,7 @@ void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { 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); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); } 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 a504ab521..42f205bca 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 @@ -395,7 +395,7 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) func_80123F2C(play, 80); this->shootingGameState = SG_GAME_STATE_RUNNING; this->actionFunc = EnSyatekiMan_Swamp_StartGame; - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); break; case 0xA32: // You have to try harder! @@ -753,7 +753,7 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) func_80112AFC(play); func_80123F2C(play, 0x63); this->shootingGameState = SG_GAME_STATE_RUNNING; - func_801A2BB8(NA_BGM_MINI_GAME_2); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); this->actionFunc = EnSyatekiMan_Town_StartGame; break; @@ -1349,7 +1349,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { func_801A2C20(); this->actionFunc = EnSyatekiMan_Town_EndGame; if (this->score == 50) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(play, 1); } } 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 647b21182..b6a0f9ed4 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 @@ -424,7 +424,7 @@ void EnSyatekiWf_Update(Actor* thisx, PlayState* play2) { 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); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); func_80A20858(this, play); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); 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 ba375f583..c0f0a3e89 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -690,7 +690,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { break; case 110: - func_801A3098(0x4A); + Audio_PlayFanfare(NA_BGM_SONG_OF_DOUBLE_TIME); break; case 38: 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 fcbb0223b..e1223cddb 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -409,7 +409,7 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) { } else { func_80AF082C(this, func_80AF19A8); EnTest7_SetupAction(this, func_80AF2854); - func_801A2E54(NA_BGM_SONG_OF_SOARING); + Audio_PlayBgm_StorePrevBgm(NA_BGM_SONG_OF_SOARING); } if (play->playerActorCsIds[8] == -1) { @@ -677,8 +677,8 @@ void func_80AF2350(EnTest7* this, PlayState* play) { play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_02; - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } void func_80AF24D8(EnTest7* this, PlayState* play, f32 arg2) { 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 4f302e268..1ba5e6ebc 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 @@ -247,8 +247,8 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); func_801A4058(5); if (1) {} - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } } 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 6c6d6e02a..6cc8e2d04 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -60,7 +60,7 @@ void ObjDemo_Init(Actor* thisx, PlayState* play) { } void func_80983634(PlayState* play) { - if ((play->sceneId == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + if ((play->sceneId == SCENE_CASTLE) && (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) { Audio_QueueSeqCmd(0x100100FF); } } 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 9bae7169e..7cb4f310f 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -751,7 +751,7 @@ void ObjUm_Init(Actor* thisx, PlayState* play) { ObjUm_SetupAction(this, ObjUm_PostMilkRunStartCs); this->unk_354 = 0; ObjUm_RotatePlayer(this, play, 0); - func_801A3098(NA_BGM_CLEAR_EVENT); + Audio_PlayFanfare(NA_BGM_CLEAR_EVENT); } else { this->type = OBJ_UM_TYPE_TERMINA_FIELD; ObjUm_SetupAction(this, ObjUm_TerminaFieldIdle); @@ -1295,9 +1295,9 @@ void ObjUm_RunMinigame(ObjUm* this, PlayState* play) { switch (ObjUm_UpdatePath(this, play)) { case OBJUM_PATH_STATE_1: case OBJUM_PATH_STATE_FINISH: - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.save.weekEventReg[31] &= (u8)~0x80; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; if (!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) { if (!this->areAllPotsBroken) { diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 5d418c0fc..6ae0f5b6c 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -41,8 +41,8 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { } gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = 0xFFFF; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 352997f94..62d2a36d0 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -128,8 +128,8 @@ void ConsoleLogo_Main(GameState* thisx) { ConsoleLogo_UpdateCounters(this); ConsoleLogo_Draw(&this->state); if (this->exit) { - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.gameMode = 1; STOP_GAMESTATE(&this->state); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 825059e33..571812b3f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3851,12 +3851,12 @@ 0x8019D8E4:("AudioOcarina_CreateCustomSequence",), 0x8019DF28:("AudioOcarina_ResetInstrument",), 0x8019DF64:("AudioOcarina_ResetStaffs",), - 0x8019DFF8:("func_8019DFF8",), - 0x8019E000:("func_8019E000",), - 0x8019E00C:("func_8019E00C",), - 0x8019E014:("func_8019E014",), - 0x8019E0FC:("func_8019E0FC",), - 0x8019E104:("func_8019E104",), + 0x8019DFF8:("Audio_Noop1",), + 0x8019E000:("Audio_Noop2",), + 0x8019E00C:("Audio_Noop3",), + 0x8019E014:("Audio_Update",), + 0x8019E0FC:("Audio_Noop4",), + 0x8019E104:("Audio_Noop5",), 0x8019E110:("func_8019E110",), 0x8019E14C:("AudioSfx_ComputeVolume",), 0x8019E324:("AudioSfx_ComputeReverb",), @@ -3938,32 +3938,32 @@ 0x801A21FC:("Audio_PlaySariaBgm",), 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), - 0x801A2544:("func_801A2544",), - 0x801A257C:("func_801A257C",), - 0x801A25E4:("func_801A25E4",), - 0x801A2670:("func_801A2670",), - 0x801A2778:("func_801A2778",), + 0x801A2544:("Audio_PlayMorningSceneSequence",), + 0x801A257C:("Audio_StartMorningSceneSequence",), + 0x801A25E4:("Audio_PlaySceneSequence",), + 0x801A2670:("Audio_StartSceneSequence",), + 0x801A2778:("Audio_UpdateSceneSequenceResumePoint",), 0x801A27E8:("func_801A27E8",), 0x801A281C:("func_801A281C",), 0x801A29D4:("func_801A29D4",), 0x801A2BB8:("func_801A2BB8",), 0x801A2C20:("func_801A2C20",), 0x801A2C44:("func_801A2C44",), - 0x801A2C88:("func_801A2C88",), - 0x801A2D54:("func_801A2D54",), + 0x801A2C88:("Audio_PlaySequenceInCutscene",), + 0x801A2D54:("Audio_StopSequenceInCutscene",), 0x801A2DE0:("Audio_IsSequencePlaying",), - 0x801A2E54:("func_801A2E54",), - 0x801A2ED8:("func_801A2ED8",), - 0x801A2F88:("func_801A2F88",), - 0x801A2FC4:("func_801A2FC4",), + 0x801A2E54:("Audio_PlayBgm_StorePrevBgm",), + 0x801A2ED8:("Audio_RestorePrevBgm",), + 0x801A2F88:("Audio_PlayAmbience_StorePrevBgm",), + 0x801A2FC4:("Audio_ForceRestorePreviousBgm",), 0x801A3000:("func_801A3000",), 0x801A3038:("func_801A3038",), - 0x801A3098:("func_801A3098",), + 0x801A3098:("Audio_PlayFanfare",), 0x801A312C:("func_801A312C",), 0x801A31EC:("func_801A31EC",), - 0x801A3238:("func_801A3238",), - 0x801A32CC:("func_801A32CC",), - 0x801A3590:("func_801A3590",), + 0x801A3238:("Audio_PlaySequenceWithSeqPlayerIO",), + 0x801A32CC:("Audio_SetSequenceMode",), + 0x801A3590:("Audio_UpdateEnemyBgmVolume",), 0x801A36F0:("func_801A36F0",), 0x801A3950:("func_801A3950",), 0x801A39F8:("func_801A39F8",), @@ -3982,7 +3982,7 @@ 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), - 0x801A400C:("audio_setBGM",), + 0x801A400C:("Audio_SetSpec",), 0x801A4058:("func_801A4058",), 0x801A41C8:("func_801A41C8",), 0x801A41F8:("func_801A41F8",), @@ -3993,15 +3993,15 @@ 0x801A4380:("Audio_SetSfxVolumeExceptSystemAndOcarinaBanks",), 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), - 0x801A44C4:("func_801A44C4",), + 0x801A44C4:("Audio_ResetRequestedSceneSeqId",), 0x801A44D4:("func_801A44D4",), 0x801A46F8:("func_801A46F8",), 0x801A4748:("func_801A4748",), 0x801A479C:("func_801A479C",), - 0x801A47DC:("func_801A47DC",), - 0x801A48E0:("func_801A48E0",), - 0x801A4A28:("func_801A4A28",), - 0x801A4B80:("Audio_SetNatureAmbienceRandomBend",), + 0x801A47DC:("Audio_SetAmbienceChannelIO",), + 0x801A48E0:("Audio_StartAmbience",), + 0x801A4A28:("Audio_PlayAmbience",), + 0x801A4B80:("Audio_SetAmbienceRandomBend",), 0x801A4C30:("Audio_Init",), 0x801A4C54:("AudioSfx_Init",), 0x801A4D00:("func_801A4D00",), @@ -4053,11 +4053,11 @@ 0x801A78E4:("AudioSfx_IsPlaying",), 0x801A794C:("AudioSfx_Reset",), 0x801A7B10:("Audio_StartSequence",), - 0x801A7D04:("func_801A7D04",), + 0x801A7D04:("Audio_StopSequence",), 0x801A7D84:("func_801A7D84",), 0x801A89A8:("Audio_QueueSeqCmd",), 0x801A89D0:("func_801A89D0",), - 0x801A8A50:("func_801A8A50",), + 0x801A8A50:("Audio_GetActiveSequence",), 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index daa1356f2..edf51ff57 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2280,11 +2280,11 @@ 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), - 0x801D66C4:("sAudioEnemyDist","f32","",0x4), - 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66C4:("sBgmEnemyDist","f32","",0x4), + 0x801D66C8:("sBgmEnemyVolume","UNK_TYPE1","",0x1), 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), - 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), - 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D0:("sSeqResumePoint","UNK_TYPE1","",0x1), + 0x801D66D4:("sPrevSceneSeqId","UNK_TYPE1","",0x1), 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), @@ -2297,7 +2297,7 @@ 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), - 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6794:("sAmbienceData","UNK_TYPE1","",0x1), 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), @@ -4255,14 +4255,14 @@ 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), - 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A0:("sRequestedSceneSeqId","UNK_TYPE1","",0x1), 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), - 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndAmbienceSeq","UNK_TYPE1","",0x1), 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), @@ -4288,7 +4288,7 @@ 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), - 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), + 0x801FD438:("sPrevAmbienceSeqId","UNK_TYPE1","",0x1), 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), @@ -4346,7 +4346,7 @@ 0x8020001E:("D_8020001E","UNK_TYPE1","",0x1), 0x802000C9:("D_802000C9","UNK_TYPE1","",0x1), 0x802000D4:("D_802000D4","UNK_TYPE1","",0x1), - 0x80200140:("D_80200140","UNK_TYPE1","",0x1), + 0x80200140:("gActiveSeqs","UNK_TYPE1","",0x1), 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), diff --git a/tools/namefixer.py b/tools/namefixer.py index eab13f0b9..f78717d40 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -148,6 +148,17 @@ wordReplace = { "func_801A5BD0": "AudioSfx_MuteBanks", "func_801A72CC": "AudioSfx_StopByPos", "Audio_StopSfxByPos": "AudioSfx_StopByPos", + "func_801A3098": "Audio_PlayFanfare", + "func_801A8A50": "Audio_GetActiveSequence", + "func_801A2E54": "Audio_PlayBgm_StorePrevBgm", + "func_801A2ED8": "Audio_RestorePrevBgm", + "func_801A2544": "Audio_PlayMorningSceneSequence", + "func_801A25E4": "Audio_PlaySceneSequence", + "func_801A3238": "Audio_PlaySequenceWithSeqPlayerIO", + "func_801A32CC": "Audio_SetSequenceMode", + "func_801A3590": "Audio_UpdateEnemyBgmVolume", + "func_801A47DC": "Audio_SetAmbienceChannelIO", + "func_801A4A28": "Audio_PlayAmbience", "func_801A7328": "AudioSfx_StopByPosAndId", "func_801A75E8": "AudioSfx_StopById", "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", @@ -690,6 +701,8 @@ wordReplace = { "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "gSaveContext.seqIndex": "gSaveContext.seqId", + "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index ecdba5264..dcb030e31 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3367,12 +3367,12 @@ asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayCustomSequence.s,AudioOcar asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s,AudioOcarina_CreateCustomSequence,0x8019D8E4,0x191 asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetInstrument.s,AudioOcarina_ResetInstrument,0x8019DF28,0xF asm/non_matchings/code/code_8019AF00/AudioOcarina_ResetStaffs.s,AudioOcarina_ResetStaffs,0x8019DF64,0x25 -asm/non_matchings/code/code_8019AF00/func_8019DFF8.s,func_8019DFF8,0x8019DFF8,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E000.s,func_8019E000,0x8019E000,0x3 -asm/non_matchings/code/code_8019AF00/func_8019E00C.s,func_8019E00C,0x8019E00C,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E014.s,func_8019E014,0x8019E014,0x3A -asm/non_matchings/code/code_8019AF00/func_8019E0FC.s,func_8019E0FC,0x8019E0FC,0x2 -asm/non_matchings/code/code_8019AF00/func_8019E104.s,func_8019E104,0x8019E104,0x3 +asm/non_matchings/code/code_8019AF00/Audio_Noop1.s,Audio_Noop1,0x8019DFF8,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop2.s,Audio_Noop2,0x8019E000,0x3 +asm/non_matchings/code/code_8019AF00/Audio_Noop3.s,Audio_Noop3,0x8019E00C,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Update.s,Audio_Update,0x8019E014,0x3A +asm/non_matchings/code/code_8019AF00/Audio_Noop4.s,Audio_Noop4,0x8019E0FC,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop5.s,Audio_Noop5,0x8019E104,0x3 asm/non_matchings/code/code_8019AF00/func_8019E110.s,func_8019E110,0x8019E110,0xF asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeVolume.s,AudioSfx_ComputeVolume,0x8019E14C,0x76 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeReverb.s,AudioSfx_ComputeReverb,0x8019E324,0x63 @@ -3454,32 +3454,32 @@ asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x 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 -asm/non_matchings/code/code_8019AF00/func_801A25E4.s,func_801A25E4,0x801A25E4,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2670.s,func_801A2670,0x801A2670,0x42 -asm/non_matchings/code/code_8019AF00/func_801A2778.s,func_801A2778,0x801A2778,0x1C +asm/non_matchings/code/code_8019AF00/Audio_PlayMorningSceneSequence.s,Audio_PlayMorningSceneSequence,0x801A2544,0xE +asm/non_matchings/code/code_8019AF00/Audio_StartMorningSceneSequence.s,Audio_StartMorningSceneSequence,0x801A257C,0x1A +asm/non_matchings/code/code_8019AF00/Audio_PlaySceneSequence.s,Audio_PlaySceneSequence,0x801A25E4,0x23 +asm/non_matchings/code/code_8019AF00/Audio_StartSceneSequence.s,Audio_StartSceneSequence,0x801A2670,0x42 +asm/non_matchings/code/code_8019AF00/Audio_UpdateSceneSequenceResumePoint.s,Audio_UpdateSceneSequenceResumePoint,0x801A2778,0x1C asm/non_matchings/code/code_8019AF00/func_801A27E8.s,func_801A27E8,0x801A27E8,0xD asm/non_matchings/code/code_8019AF00/func_801A281C.s,func_801A281C,0x801A281C,0x6E asm/non_matchings/code/code_8019AF00/func_801A29D4.s,func_801A29D4,0x801A29D4,0x79 asm/non_matchings/code/code_8019AF00/func_801A2BB8.s,func_801A2BB8,0x801A2BB8,0x1A asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x9 asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 -asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 -asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceInCutscene.s,Audio_PlaySequenceInCutscene,0x801A2C88,0x33 +asm/non_matchings/code/code_8019AF00/Audio_StopSequenceInCutscene.s,Audio_StopSequenceInCutscene,0x801A2D54,0x23 asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D -asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 -asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C -asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF -asm/non_matchings/code/code_8019AF00/func_801A2FC4.s,func_801A2FC4,0x801A2FC4,0xF +asm/non_matchings/code/code_8019AF00/Audio_PlayBgm_StorePrevBgm.s,Audio_PlayBgm_StorePrevBgm,0x801A2E54,0x21 +asm/non_matchings/code/code_8019AF00/Audio_RestorePrevBgm.s,Audio_RestorePrevBgm,0x801A2ED8,0x2C +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience_StorePrevBgm.s,Audio_PlayAmbience_StorePrevBgm,0x801A2F88,0xF +asm/non_matchings/code/code_8019AF00/Audio_ForceRestorePreviousBgm.s,Audio_ForceRestorePreviousBgm,0x801A2FC4,0xF asm/non_matchings/code/code_8019AF00/func_801A3000.s,func_801A3000,0x801A3000,0xE asm/non_matchings/code/code_8019AF00/func_801A3038.s,func_801A3038,0x801A3038,0x18 -asm/non_matchings/code/code_8019AF00/func_801A3098.s,func_801A3098,0x801A3098,0x25 +asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s,Audio_PlayFanfare,0x801A3098,0x25 asm/non_matchings/code/code_8019AF00/func_801A312C.s,func_801A312C,0x801A312C,0x30 asm/non_matchings/code/code_8019AF00/func_801A31EC.s,func_801A31EC,0x801A31EC,0x13 -asm/non_matchings/code/code_8019AF00/func_801A3238.s,func_801A3238,0x801A3238,0x25 -asm/non_matchings/code/code_8019AF00/func_801A32CC.s,func_801A32CC,0x801A32CC,0xB1 -asm/non_matchings/code/code_8019AF00/func_801A3590.s,func_801A3590,0x801A3590,0x58 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceWithSeqPlayerIO.s,Audio_PlaySequenceWithSeqPlayerIO,0x801A3238,0x25 +asm/non_matchings/code/code_8019AF00/Audio_SetSequenceMode.s,Audio_SetSequenceMode,0x801A32CC,0xB1 +asm/non_matchings/code/code_8019AF00/Audio_UpdateEnemyBgmVolume.s,Audio_UpdateEnemyBgmVolume,0x801A3590,0x58 asm/non_matchings/code/code_8019AF00/func_801A36F0.s,func_801A36F0,0x801A36F0,0x98 asm/non_matchings/code/code_8019AF00/func_801A3950.s,func_801A3950,0x801A3950,0x2A asm/non_matchings/code/code_8019AF00/func_801A39F8.s,func_801A39F8,0x801A39F8,0x21 @@ -3498,7 +3498,7 @@ asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFl 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 -asm/non_matchings/code/code_8019AF00/audio_setBGM.s,audio_setBGM,0x801A400C,0x13 +asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s,Audio_SetSpec,0x801A400C,0x13 asm/non_matchings/code/code_8019AF00/func_801A4058.s,func_801A4058,0x801A4058,0x5C asm/non_matchings/code/code_8019AF00/func_801A41C8.s,func_801A41C8,0x801A41C8,0xC asm/non_matchings/code/code_8019AF00/func_801A41F8.s,func_801A41F8,0x801A41F8,0x29 @@ -3509,15 +3509,15 @@ asm/non_matchings/code/code_8019AF00/func_801A4348.s,func_801A4348,0x801A4348,0x asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBanks.s,Audio_SetSfxVolumeExceptSystemAndOcarinaBanks,0x801A4380,0x2A asm/non_matchings/code/code_8019AF00/func_801A4428.s,func_801A4428,0x801A4428,0x1F asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s,Audio_PreNMI,0x801A44A4,0x8 -asm/non_matchings/code/code_8019AF00/func_801A44C4.s,func_801A44C4,0x801A44C4,0x4 +asm/non_matchings/code/code_8019AF00/Audio_ResetRequestedSceneSeqId.s,Audio_ResetRequestedSceneSeqId,0x801A44C4,0x4 asm/non_matchings/code/code_8019AF00/func_801A44D4.s,func_801A44D4,0x801A44D4,0x89 asm/non_matchings/code/code_8019AF00/func_801A46F8.s,func_801A46F8,0x801A46F8,0x14 asm/non_matchings/code/code_8019AF00/func_801A4748.s,func_801A4748,0x801A4748,0x15 asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x10 -asm/non_matchings/code/code_8019AF00/func_801A47DC.s,func_801A47DC,0x801A47DC,0x41 -asm/non_matchings/code/code_8019AF00/func_801A48E0.s,func_801A48E0,0x801A48E0,0x52 -asm/non_matchings/code/code_8019AF00/func_801A4A28.s,func_801A4A28,0x801A4A28,0x56 -asm/non_matchings/code/code_8019AF00/Audio_SetNatureAmbienceRandomBend.s,Audio_SetNatureAmbienceRandomBend,0x801A4B80,0x2C +asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceChannelIO.s,Audio_SetAmbienceChannelIO,0x801A47DC,0x41 +asm/non_matchings/code/code_8019AF00/Audio_StartAmbience.s,Audio_StartAmbience,0x801A48E0,0x52 +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience.s,Audio_PlayAmbience,0x801A4A28,0x56 +asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceRandomBend.s,Audio_SetAmbienceRandomBend,0x801A4B80,0x2C asm/non_matchings/code/code_8019AF00/Audio_Init.s,Audio_Init,0x801A4C30,0x9 asm/non_matchings/code/code_8019AF00/AudioSfx_Init.s,AudioSfx_Init,0x801A4C54,0x2B asm/non_matchings/code/code_8019AF00/func_801A4D00.s,func_801A4D00,0x801A4D00,0x14 @@ -3569,11 +3569,11 @@ asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessActiveSfx.s,AudioSfx_Proces asm/non_matchings/code/code_801A5BD0/AudioSfx_IsPlaying.s,AudioSfx_IsPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_Reset.s,AudioSfx_Reset,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s,Audio_StartSequence,0x801A7B10,0x7D -asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 +asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s,Audio_StopSequence,0x801A7D04,0x20 asm/non_matchings/code/code_801A7B10/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA asm/non_matchings/code/code_801A7B10/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 -asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x1B +asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s,Audio_GetActiveSequence,0x801A8A50,0x1B 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 From 6ff53e448b669b2894f543868367a4a65ebf8a69 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:50:59 -0300 Subject: [PATCH 56/73] ovl_Oceff_Wipe OK (#1008) * ovl_Oceff_Wipe Decompiled * format * format * pr review * renaming * renamings * renamings * magic * pr review --- assets/xml/overlays/ovl_Oceff_Wipe.xml | 10 ++ spec | 4 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 99 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.h | 7 +- 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe.xml b/assets/xml/overlays/ovl_Oceff_Wipe.xml new file mode 100644 index 000000000..17a056175 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/spec b/spec index 0b500363a..6b4395bb1 100644 --- a/spec +++ b/spec @@ -1730,9 +1730,7 @@ beginseg name "ovl_Oceff_Wipe" compress include "build/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.data.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.bss.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe/ovl_Oceff_Wipe_reloc.o" endseg beginseg 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 661c13a1b..ef1fa1035 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -15,7 +15,6 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play); void OceffWipe_Update(Actor* thisx, PlayState* play); void OceffWipe_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe_InitVars = { ACTOR_OCEFF_WIPE, ACTORCAT_ITEMACTION, @@ -28,12 +27,100 @@ const ActorInit Oceff_Wipe_InitVars = { (ActorFunc)OceffWipe_Draw, }; -#endif +UNK_TYPE4 D_80977200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Init.s") +void OceffWipe_Init(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Destroy.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Update.s") +void OceffWipe_Destroy(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe_Update(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe/ovl_Oceff_Wipe.c" + +static u8 sAlphaIndices[] = { + 0x01, 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x20, 0x12, 0x01, + 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x12, 0x21, 0x01, 0x02, +}; + +void OceffWipe_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFF; + OceffWipe* this = THIS; + f32 z; + s32 pad; + u8 alphaTable[3]; + s32 i; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + OPEN_DISPS(play->state.gfxCtx); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * 1360.0f; + } else { + z = 1360.0f; + } + + if (this->counter >= 80) { + alphaTable[0] = 0; + alphaTable[1] = (100 - this->counter) * 8; + alphaTable[2] = (100 - this->counter) * 12; + } else { + alphaTable[0] = 0; + alphaTable[1] = 160; + alphaTable[2] = 255; + } + + for (i = 0; i < 20; i++) { + vtxPtr = sSongOfTimeFrustumVtx; + vtxPtr[i * 2 + 0].v.cn[3] = alphaTable[(sAlphaIndices[i] & 0xF0) >> 4]; + vtxPtr[i * 2 + 1].v.cn[3] = alphaTable[sAlphaIndices[i] & 0xF]; + } + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->actor.params != OCEFF_WIPE_ZL) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 128); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 0, 255, 128); + } + + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0 - scroll, scroll * -2, 32, + 32, 1, 0 - scroll, scroll * -2, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h index 5b7e34837..6828c996d 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h @@ -3,11 +3,16 @@ #include "global.h" +typedef enum { + /* 0x0 */ OCEFF_WIPE_ZL, + /* 0x1 */ OCEFF_WIPE_SOT +} OceffWipeType; + struct OceffWipe; typedef struct OceffWipe { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe; // size = 0x148 extern const ActorInit Oceff_Wipe_InitVars; From 1be5a7d2c7e63880faaf10d359c15ada7673f386 Mon Sep 17 00:00:00 2001 From: SonicDcer <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 30 Sep 2022 12:37:01 -0300 Subject: [PATCH 57/73] ovl_Oceff_Wipe5 OK (#1011) * progress * progress * ovl_Oceff_Wipe5 OK * Co-authored-by: Derek-Hensley hensley.derek58@gmail.com * Co-authored-by: Synray synray@users.noreply.github.com * Co-authored-by: darkeye darkeye@users.noreply.github.com * pr review * pr review * Magic_Reset * fixes --- assets/xml/overlays/ovl_Oceff_Wipe5.xml | 9 ++ spec | 4 +- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 103 +++++++++++++++++- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h | 4 +- 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe5.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe5.xml b/assets/xml/overlays/ovl_Oceff_Wipe5.xml new file mode 100644 index 000000000..52f197428 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe5.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spec b/spec index 6b4395bb1..b4a8a6108 100644 --- a/spec +++ b/spec @@ -4363,9 +4363,7 @@ beginseg name "ovl_Oceff_Wipe5" compress include "build/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.data.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.bss.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5_reloc.o" endseg beginseg 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 1bef04db8..951ba1c39 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -15,7 +15,6 @@ void OceffWipe5_Destroy(Actor* thisx, PlayState* play); void OceffWipe5_Update(Actor* thisx, PlayState* play); void OceffWipe5_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Oceff_Wipe5_InitVars = { ACTOR_OCEFF_WIPE5, ACTORCAT_ITEMACTION, @@ -28,12 +27,104 @@ const ActorInit Oceff_Wipe5_InitVars = { (ActorFunc)OceffWipe5_Draw, }; -#endif +UNK_TYPE4 D_80BC9260; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Init.s") +void OceffWipe5_Init(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = play->cameraPtrs[play->activeCamId]->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Update.s") +void OceffWipe5_Destroy(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe5_Update(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.c" + +static u8 sPrimColors[] = { + 255, 255, 200, 255, 255, 200, 200, 255, 255, 255, 255, 200, 255, 200, 255, +}; + +static u8 sEnvColors[] = { + 50, 200, 0, 255, 50, 0, 0, 100, 255, 255, 150, 0, 255, 0, 200, +}; + +void OceffWipe5_Draw(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + f32 z; + s32 pad; + s32 i; + s32 pad2; + Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye; + Camera* cam = GET_ACTIVE_CAM(play); + Vec3f quakeOffset; + u8 alpha; + s32 colorIndex = OCEFF_WIPE5_GET_SONG_TYPE(thisx) * 3; + f32 phi_fv1 = 1220.0f; + + if ((((OCEFF_WIPE5_GET_SONG_TYPE(thisx) == 2) && (play->sceneId == SCENE_LABO)) && + ((play->csCtx.currentCsIndex == 0) || (play->csCtx.currentCsIndex == 1))) && + (play->csCtx.state != 0)) { + phi_fv1 = 1150.0f; + } + + if (colorIndex >= 13) { + colorIndex = 0; + } + + Camera_GetQuakeOffset(&quakeOffset, cam); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * phi_fv1; + } else { + z = phi_fv1; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + for (i = 1; i < ARRAY_COUNT(gOceff5Vtx); i += 2) { + gOceff5Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + 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_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sPrimColors[colorIndex], sPrimColors[colorIndex + 1], + sPrimColors[colorIndex + 2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[colorIndex], sEnvColors[colorIndex + 1], sEnvColors[colorIndex + 2], + 255); + + AnimatedMat_Draw(play, gOceff5TexAnim); + + gSPDisplayList(POLY_XLU_DISP++, &gOceff5DL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h index 063d0386b..05424ea1e 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h @@ -3,11 +3,13 @@ #include "global.h" +#define OCEFF_WIPE5_GET_SONG_TYPE(thisx) ((thisx)->params & 0xF) + struct OceffWipe5; typedef struct OceffWipe5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe5; // size = 0x148 extern const ActorInit Oceff_Wipe5_InitVars; From 42a8bf68765830f94e2625eef6c5d52f648a9664 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 12:15:43 -0700 Subject: [PATCH 58/73] Document BgCraceMovebg (sliding doors in Deku Shrine) and object_crace_object (#1101) * Document BgCraceMovebg (sliding doors in Deku Shrine) and object_crace_object * Respond to Elliptic's review * Fix build issue * Respond to Elliptic's second review * ACTUALLY put the BSS above the data, forgot the InitVars were data * Respond to hensldm's review --- assets/xml/objects/object_crace_object.xml | 9 +- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c | 334 ++++++++++-------- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h | 35 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 27 +- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 21 +- tools/disasm/functions.txt | 32 +- tools/disasm/variables.txt | 10 +- 7 files changed, 265 insertions(+), 203 deletions(-) diff --git a/assets/xml/objects/object_crace_object.xml b/assets/xml/objects/object_crace_object.xml index 06c007989..af0cb89e0 100644 --- a/assets/xml/objects/object_crace_object.xml +++ b/assets/xml/objects/object_crace_object.xml @@ -1,8 +1,9 @@  + - - - - + + + + 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 1a0cb5058..9a4f0849a 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 @@ -5,6 +5,7 @@ */ #include "z_bg_crace_movebg.h" +#include "overlays/actors/ovl_En_Dno/z_en_dno.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,22 +16,30 @@ void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play); void BgCraceMovebg_Update(Actor* thisx, PlayState* play); void BgCraceMovebg_Draw(Actor* thisx, PlayState* play); -s32 func_80A7090C(PlayState* play); -void func_80A70970(BgCraceMovebg* this, PlayState* play); -void func_80A7099C(BgCraceMovebg* this, PlayState* play); -void func_80A709E4(BgCraceMovebg* this, PlayState* play); -void func_80A70A08(BgCraceMovebg* this, PlayState* play); -void func_80A70A84(BgCraceMovebg* this, PlayState* play); -void func_80A70A9C(BgCraceMovebg* this, PlayState* play); -void func_80A70C04(BgCraceMovebg* this, PlayState* play); -void func_80A70D74(BgCraceMovebg* this, PlayState* play); -void func_80A70DA8(BgCraceMovebg* this, PlayState* play); -void func_80A70E2C(BgCraceMovebg* this, PlayState* play); -void func_80A70E70(BgCraceMovebg* this, PlayState* play); -void func_80A70F14(BgCraceMovebg* this, PlayState* play); -void func_80A70F2C(BgCraceMovebg* this, PlayState* play); -void func_80A70FF4(BgCraceMovebg* this, PlayState* play); -void func_80A71040(BgCraceMovebg* this, PlayState* play); +s32 BgCraceMovebg_GetRaceStatus(PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play); + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT, + /* 1 */ BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE, + /* 2 */ BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE +} BgCraceMovebgRaceStatus; + +u8 sIsLoaded[32]; const ActorInit Bg_Crace_Movebg_InitVars = { ACTOR_BG_CRACE_MOVEBG, @@ -44,13 +53,14 @@ const ActorInit Bg_Crace_Movebg_InitVars = { (ActorFunc)BgCraceMovebg_Draw, }; -static u8 D_80A710A0 = 0; -static u8 D_80A710A4 = 0; +static u8 sHasInitializedIsLoaded = 0; +static u8 sLoadedDoorCount = 0; + static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -static Vec3f D_80A710AC[] = { 0.0f, 0.0f, 1.0f }; -u8 D_80A711B0[32]; + +static Vec3f sUnitVecZ = { 0.0f, 0.0f, 1.0f }; void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; @@ -58,122 +68,138 @@ void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { s32 j; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (D_80A710A0 == 0) { - for (i = 0; i < ARRAY_COUNT(D_80A711B0); i++) { - D_80A711B0[i] = 0; + if (!sHasInitializedIsLoaded) { + for (i = 0; i < ARRAY_COUNT(sIsLoaded); i++) { + sIsLoaded[i] = 0; } - D_80A710A0 = 1; + sHasInitializedIsLoaded = true; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_crace_object_Colheader_000E00); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDekuShrineSlidingDoorCol); - this->unk184 = this->dyna.actor.world.rot.x; - this->unk16C = this->dyna.actor.world.rot.z; + this->index = BG_CRACE_MOVEBG_GET_INDEX(&this->dyna.actor); + this->openSpeed = BG_CRACE_MOVEBG_GET_OPEN_SPEED(&this->dyna.actor); this->dyna.actor.world.rot.x = 0; this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; this->dyna.actor.flags |= ACTOR_FLAG_10000000; - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - for (j = 0; j < D_80A710A4; j++) { - if (D_80A711B0[j] == this->unk184) { - this->unk170 |= 8; + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + for (j = 0; j < sLoadedDoorCount; j++) { + if (sIsLoaded[j] == this->index) { + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED; Actor_MarkForDeath(&this->dyna.actor); return; } } - if (D_80A710A4 < ARRAY_COUNT(D_80A711B0)) { - D_80A711B0[(s32)D_80A710A4++] = this->unk184; + + if (sLoadedDoorCount < ARRAY_COUNT(sIsLoaded)) { + sIsLoaded[(s32)sLoadedDoorCount] = this->index; + sLoadedDoorCount++; } + this->dyna.actor.room = -1; - switch (func_80A7090C(play)) { - case 0: - func_80A70D74(this, play); + switch (BgCraceMovebg_GetRaceStatus(play)) { + case BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; - case 1: - func_80A70D74(this, play); + + case BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; - case 2: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - func_80A70D74(this, play); + + case BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE: + // Makes sure no lingering switch flags are set from the last time the player did a race. + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); break; } break; - case 1: - func_80A70970(this, play); + + case BG_CRACE_MOVEBG_TYPE_OPENING: + BgCraceMovebg_OpeningDoor_SetupIdle(this, play); break; + default: Actor_MarkForDeath(&this->dyna.actor); break; } } -s32 func_80A7090C(PlayState* play) { +s32 BgCraceMovebg_GetRaceStatus(PlayState* play) { s32 pad; - s32 returnVal = 0; - Actor* tempActor = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); + s32 raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT; + Actor* butler = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); - if (tempActor != NULL) { - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_3F80(tempActor))) { - returnVal = 2; + if (butler != NULL) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(butler))) { + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE; } else { - returnVal = 1; + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE; } } - return returnVal; + + return raceStatus; } -void func_80A70970(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 0.0f; - this->unk160 = 0.0f; - this->actionFunc = func_80A7099C; +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->actionFunc = BgCraceMovebg_OpeningDoor_Idle; } -void func_80A7099C(BgCraceMovebg* this, PlayState* play) { - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { - func_80A709E4(this, play); +/** + * Wait for this door's switch flag to be set, then start opening. + */ +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play) { + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_OpeningDoor_SetupOpen(this, play); } } -void func_80A709E4(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70A08; - this->unk164 = 180.0f; +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_OpeningDoor_Open; } -void func_80A70A08(BgCraceMovebg* this, PlayState* play) { +/** + * Silde open, then do nothing. + */ +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); - Math_SmoothStepToF(&this->unk160, this->unk164, 2.0f, this->unk16C, 0.01f); - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - if (this->unk160 == this->unk164) { - func_80A70A84(this, play); + Math_SmoothStepToF(&this->doorHeight, this->targetDoorHeight, 2.0f, this->openSpeed, 0.01f); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + if (this->doorHeight == this->targetDoorHeight) { + BgCraceMovebg_OpeningDoor_SetupDoNothing(this, play); } } -void func_80A70A84(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70A9C; +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_OpeningDoor_DoNothing; } -void func_80A70A9C(BgCraceMovebg* this, PlayState* play) { +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { } void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); - if (!(this->unk170 & 0x8)) { - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx) + 1); + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED)) { + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) + 1); break; - case 1: - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(thisx)); + + case BG_CRACE_MOVEBG_TYPE_OPENING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); break; } } @@ -183,117 +209,147 @@ void BgCraceMovebg_Update(Actor* thisx, PlayState* play) { BgCraceMovebg* this = THIS; s32 pad; Player* player = GET_PLAYER(play); - s16 tempRot; + s16 yawDiff; - switch (BGCRACEMOVEBG_GET_F(&this->dyna.actor)) { - case 0: - case 2: - tempRot = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; - if ((tempRot >= -0x4000) && (tempRot <= 0x4000)) { + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + yawDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; + if ((yawDiff >= -0x4000) && (yawDiff <= 0x4000)) { this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; } else { this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y + 0x8000; } + break; + default: - this->actionFunc(this, play); - Math_Vec3f_Copy(&this->unk188, &player->bodyPartsPos[0]); + break; } + + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->prevPlayerPos, &player->bodyPartsPos[0]); } -void func_80A70C04(BgCraceMovebg* this, PlayState* play) { +/** + * Updates this door's flags if the player has moved beyond it. If the door is of type + * BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING, then nothing happens here, so the door never + * knows the player has moved beyond it. + */ +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Vec3f intersect; - Vec3f diff; + Vec3f posDiff; - if ((BGCRACEMOVEBG_GET_F(&this->dyna.actor) != 2) && - SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, D_80A710AC, &this->unk188, + if ((BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor) != BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING) && + SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, &sUnitVecZ, &this->prevPlayerPos, &player->bodyPartsPos[0], &intersect)) { Matrix_RotateYS(-this->dyna.actor.home.rot.y, MTXMODE_NEW); - Math_Vec3f_Diff(&player->bodyPartsPos[0], &this->dyna.actor.home.pos, &diff); - Matrix_MultVec3f(&diff, &this->unk178); - if (fabsf(this->unk178.x) < 100.0f && this->unk178.y >= -10.0f && this->unk178.y <= 180.0f) { - if (this->unk178.z < 0.0f) { - Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - this->unk170 |= 2; + Math_Vec3f_Diff(&player->bodyPartsPos[0], &this->dyna.actor.home.pos, &posDiff); + Matrix_MultVec3f(&posDiff, &this->intersectionOffsetFromHome); + + if (fabsf(this->intersectionOffsetFromHome.x) < 100.0f && this->intersectionOffsetFromHome.y >= -10.0f && + this->intersectionOffsetFromHome.y <= 180.0f) { + if (this->intersectionOffsetFromHome.z < 0.0f) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; } else { - Flags_UnsetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1); - this->unk170 &= ~2; + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags &= ~BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; } } } } -void func_80A70D74(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 180.0f; - this->unk160 = 180.0f; - this->actionFunc = func_80A70DA8; +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_Idle; } -void func_80A70DA8(BgCraceMovebg* this, PlayState* play) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (this->unk170 & 1) { - func_80A70E2C(this, play); +/** + * Wait for the Deku Butler to move beyond the door, or wait for this door's switch flag + * to be set. In either case, start closing; how long to wait before closing depends on + * what triggered it to close. + */ +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR) { + BgCraceMovebg_ClosingDoor_SetupWaitToClose(this, play); } - if (Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor))) { - func_80A70F14(this, play); + + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_ClosingDoor_SetupClose(this, play); } } -void func_80A70E2C(BgCraceMovebg* this, PlayState* play) { - this->unk174 = BGCRACEMOVEBG_GET_F800(&this->dyna.actor) * 10; - this->unk164 = 180.0f; - this->unk160 = 180.0f; - this->actionFunc = func_80A70E70; +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play) { + this->closeWaitTimer = BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(&this->dyna.actor) * 10; + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_WaitToClose; } -void func_80A70E70(BgCraceMovebg* this, PlayState* play) { - if (this->unk174 > 0) { - this->unk174--; +/** + * Wait until the closeWaitTimer reaches 0, then set the door's switch flag and start closing. + */ +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play) { + if (this->closeWaitTimer > 0) { + this->closeWaitTimer--; } - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (this->unk174 <= 0) { - this->unk160 = 180.0f; - this->unk164 = 0.0f; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->closeWaitTimer <= 0) { + this->doorHeight = 180.0f; + this->targetDoorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; - Flags_SetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor)); - func_80A70F14(this, play); + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor)); + BgCraceMovebg_ClosingDoor_SetupClose(this, play); } } -void func_80A70F14(BgCraceMovebg* this, PlayState* play) { - this->actionFunc = func_80A70F2C; +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_ClosingDoor_Close; } -void func_80A70F2C(BgCraceMovebg* this, PlayState* play) { - this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->unk160; - func_80A70C04(this, play); - if (Math_StepToF(&this->unk160, 0.0f, 1.0f)) { - if (!(this->unk170 & 2) && !Flags_GetSwitch(play, BGCRACEMOVEBG_GET_7F0(&this->dyna.actor) + 1)) { +/** + * Slowly slide closed, then check to see if the player is beyond the door. If the player has + * not moved beyond the door, trigger a voidout. Otherwise, do nothing. + */ +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (Math_StepToF(&this->doorHeight, 0.0f, 1.0f)) { + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR) && + !Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1)) { play->unk_18845 = 1; func_80169FDC(&play->state); play_sound(NA_SE_OC_ABYSS); } - func_80A70FF4(this, play); + + BgCraceMovebg_ClosingDoor_SetupDoNothing(this, play); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_CLOSE_S - SFX_FLAG); } } -void func_80A70FF4(BgCraceMovebg* this, PlayState* play) { - this->unk164 = 0.0f; - this->unk160 = 0.0f; +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - this->actionFunc = func_80A71040; + this->actionFunc = BgCraceMovebg_ClosingDoor_DoNothing; } -void func_80A71040(BgCraceMovebg* this, PlayState* play) { +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { } void BgCraceMovebg_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_crace_object_DL_0003A0); + Gfx_DrawDListOpa(play, gDekuShrineSlidingDoorDL); } diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h index 4faca7ba2..fb24b10d3 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h @@ -8,23 +8,34 @@ struct BgCraceMovebg; typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, PlayState*); -#define BGCRACEMOVEBG_GET_F(thisx) (((thisx)->params) & 0xF) -#define BGCRACEMOVEBG_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) -#define BGCRACEMOVEBG_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) -#define BGCRACEMOVEBG_GET_F800(thisx) (((thisx)->params >> 0xB) & 0x1F) +#define BG_CRACE_MOVEBG_GET_TYPE(thisx) (((thisx)->params) & 0xF) +#define BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 4) & 0x7F) +#define BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(thisx) (((thisx)->params >> 0xB) & 0x1F) +#define BG_CRACE_MOVEBG_GET_INDEX(thisx) ((thisx)->world.rot.x) +#define BG_CRACE_MOVEBG_GET_OPEN_SPEED(thisx) ((thisx)->world.rot.z) + +#define BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR (1 << 0) +#define BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR (1 << 1) +#define BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED (1 << 3) + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_TYPE_CLOSING, + /* 1 */ BG_CRACE_MOVEBG_TYPE_OPENING, + /* 2 */ BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING // Not triggered to close by the Deku Butler, and triggers a voidout no matter which side of the door they're on. +} BgCraceMovebgType; typedef struct BgCraceMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgCraceMovebgActionFunc actionFunc; - /* 0x160 */ f32 unk160; - /* 0x164 */ f32 unk164; + /* 0x160 */ f32 doorHeight; + /* 0x164 */ f32 targetDoorHeight; /* 0x168 */ UNK_TYPE1 pad168[0x4]; - /* 0x16C */ f32 unk16C; - /* 0x170 */ s32 unk170; - /* 0x174 */ s32 unk174; - /* 0x178 */ Vec3f unk178; - /* 0x184 */ u8 unk184; - /* 0x188 */ Vec3f unk188; + /* 0x16C */ f32 openSpeed; + /* 0x170 */ s32 stateFlags; + /* 0x174 */ s32 closeWaitTimer; + /* 0x178 */ Vec3f intersectionOffsetFromHome; + /* 0x184 */ u8 index; + /* 0x188 */ Vec3f prevPlayerPos; } BgCraceMovebg; // size = 0x194 extern const ActorInit Bg_Crace_Movebg_InitVars; 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 9b421dfd4..5877c5fd2 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -122,8 +122,8 @@ void func_80A714B4(EnDno* this, PlayState* play) { do { actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { - Flags_SetSwitch(play, ENDNO_GET_7F0(actor)); + if (BG_CRACE_MOVEBG_GET_TYPE(actor) == BG_CRACE_MOVEBG_TYPE_OPENING) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(actor)); } actor = actor->next; } @@ -152,14 +152,15 @@ void func_80A715DC(EnDno* this, PlayState* play) { do { crace = (BgCraceMovebg*)SubS_FindActor(play, &crace->dyna.actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { - if (ENDNO_GET_F(&crace->dyna.actor) == ENDNO_GET_F_0 && !(crace->unk170 & 1)) { + if (BG_CRACE_MOVEBG_GET_TYPE(&crace->dyna.actor) == BG_CRACE_MOVEBG_TYPE_CLOSING && + !(crace->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR)) { if (SubS_LineSegVsPlane(&crace->dyna.actor.home.pos, &crace->dyna.actor.home.rot, &D_80A73B2C, &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->dyna.actor.home.pos, &sp7C); Matrix_RotateYS(-crace->dyna.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->unk170 |= 1; + crace->stateFlags |= BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR; } } } @@ -174,7 +175,7 @@ void func_80A71788(EnDno* this, PlayState* play) { do { actor = SubS_FindActor(play, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - Flags_UnsetSwitch(play, ENDNO_GET_7F0(actor)); + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(actor)); actor = actor->next; } } while (actor != NULL); @@ -212,8 +213,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { this->unk_468 = 99; this->skelAnime.playSpeed = 0.0f; - switch (ENDNO_GET_C000(thisx)) { - case ENDNO_GET_C000_0: + switch (EN_DNO_GET_C000(thisx)) { + case EN_DNO_GET_C000_0: func_80A71788(this, play); if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); @@ -228,7 +229,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { } break; - case ENDNO_GET_C000_1: + case EN_DNO_GET_C000_1: if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { @@ -502,7 +503,7 @@ void func_80A72438(EnDno* this, PlayState* play) { this->unk_452 = 1; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; - if (Flags_GetSwitch(play, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { this->unk_454 = 1.0f; } this->actionFunc = func_80A724B8; @@ -549,7 +550,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { 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(play, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { Message_StartTextbox(play, 0x801, &this->actor); } else if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { Message_StartTextbox(play, 0x806, &this->actor); @@ -692,13 +693,13 @@ void func_80A72C04(EnDno* this, PlayState* play) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); SubS_ActorPathing_Init(play, &this->unk_334, &this->actor, &this->actorPath, play->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + EN_DNO_GET_7F(&this->actor), 1, 0, 1, 0); SubS_ActorPathing_ComputePointInfo(play, &this->actorPath); this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; - Flags_SetSwitch(play, ENDNO_GET_3F80(&this->actor)); + Flags_SetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); this->actionFunc = func_80A730A0; } @@ -820,7 +821,7 @@ void func_80A73244(EnDno* this, PlayState* play) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; this->actor.speedXZ = 0.0f; - Flags_UnsetSwitch(play, ENDNO_GET_3F80(&this->actor)); + Flags_UnsetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->unk_44E = 0; this->actionFunc = func_80A732C8; 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 bf357cad6..2e417a7a0 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -7,21 +7,14 @@ struct EnDno; typedef void (*EnDnoActionFunc)(struct EnDno*, PlayState*); -#define ENDNO_GET_F(thisx) ((thisx)->params & 0xF) -#define ENDNO_GET_7F(thisx) ((thisx)->params & 0x7F) -#define ENDNO_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) -#define ENDNO_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) -#define ENDNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) +#define EN_DNO_GET_7F(thisx) ((thisx)->params & 0x7F) +#define EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(thisx) (((thisx)->params >> 7) & 0x7F) +#define EN_DNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) -enum { - /* 0x0 */ ENDNO_GET_F_0, - /* 0x1 */ ENDNO_GET_F_1, -}; - -enum { - /* 0x0 */ ENDNO_GET_C000_0, - /* 0x1 */ ENDNO_GET_C000_1, -}; +typedef enum { + /* 0x0 */ EN_DNO_GET_C000_0, + /* 0x1 */ EN_DNO_GET_C000_1, +} EnDnoUnkC000; typedef struct EnDno { /* 0x000 */ Actor actor; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 571812b3f..4415b571d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10960,24 +10960,24 @@ 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), - 0x80A7090C:("func_80A7090C",), - 0x80A70970:("func_80A70970",), - 0x80A7099C:("func_80A7099C",), - 0x80A709E4:("func_80A709E4",), - 0x80A70A08:("func_80A70A08",), - 0x80A70A84:("func_80A70A84",), - 0x80A70A9C:("func_80A70A9C",), + 0x80A7090C:("BgCraceMovebg_GetRaceStatus",), + 0x80A70970:("BgCraceMovebg_OpeningDoor_SetupIdle",), + 0x80A7099C:("BgCraceMovebg_OpeningDoor_WaitToOpen",), + 0x80A709E4:("BgCraceMovebg_OpeningDoor_SetupOpen",), + 0x80A70A08:("BgCraceMovebg_OpeningDoor_Open",), + 0x80A70A84:("BgCraceMovebg_OpeningDoor_SetupDoNothing",), + 0x80A70A9C:("BgCraceMovebg_OpeningDoor_DoNothing",), 0x80A70AAC:("BgCraceMovebg_Destroy",), 0x80A70B60:("BgCraceMovebg_Update",), - 0x80A70C04:("func_80A70C04",), - 0x80A70D74:("func_80A70D74",), - 0x80A70DA8:("func_80A70DA8",), - 0x80A70E2C:("func_80A70E2C",), - 0x80A70E70:("func_80A70E70",), - 0x80A70F14:("func_80A70F14",), - 0x80A70F2C:("func_80A70F2C",), - 0x80A70FF4:("func_80A70FF4",), - 0x80A71040:("func_80A71040",), + 0x80A70C04:("BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor",), + 0x80A70D74:("BgCraceMovebg_ClosingDoor_SetupIdle",), + 0x80A70DA8:("BgCraceMovebg_ClosingDoor_Idle",), + 0x80A70E2C:("BgCraceMovebg_ClosingDoor_SetupWaitToClose",), + 0x80A70E70:("BgCraceMovebg_ClosingDoor_WaitToClose",), + 0x80A70F14:("BgCraceMovebg_ClosingDoor_SetupClose",), + 0x80A70F2C:("BgCraceMovebg_ClosingDoor_Close",), + 0x80A70FF4:("BgCraceMovebg_ClosingDoor_SetupDoNothing",), + 0x80A71040:("BgCraceMovebg_ClosingDoor_DoNothing",), 0x80A71050:("BgCraceMovebg_Draw",), 0x80A711D0:("func_80A711D0",), 0x80A71424:("func_80A71424",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index edf51ff57..3578b52a5 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12095,12 +12095,12 @@ 0x80A70510:("jtbl_80A70510","UNK_PTR","",0x4), 0x80A7056C:("jtbl_80A7056C","UNK_PTR","",0x4), 0x80A71080:("Bg_Crace_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80A710A0:("D_80A710A0","UNK_TYPE1","",0x1), - 0x80A710A4:("D_80A710A4","UNK_TYPE1","",0x1), - 0x80A710A8:("D_80A710A8","UNK_TYPE1","",0x1), - 0x80A710AC:("D_80A710AC","UNK_TYPE1","",0x1), + 0x80A710A0:("sHasInitializedIsLoaded","UNK_TYPE1","",0x1), + 0x80A710A4:("sLoadedDoorCount","UNK_TYPE1","",0x1), + 0x80A710A8:("sInitChain","UNK_TYPE1","",0x1), + 0x80A710AC:("sUnitVecZ","UNK_TYPE1","",0x1), 0x80A710C0:("D_80A710C0","f32","",0x4), - 0x80A711B0:("D_80A711B0","UNK_TYPE1","",0x1), + 0x80A711B0:("sIsLoaded","UNK_TYPE1","",0x1), 0x80A739A0:("D_80A739A0","UNK_PTR","",0x4), 0x80A73AE0:("En_Dno_InitVars","UNK_TYPE1","",0x1), 0x80A73B00:("D_80A73B00","UNK_TYPE1","",0x1), From 15b9f83bd8980cbc3fc27373cba72826946395da Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 13:17:34 -0700 Subject: [PATCH 59/73] Document object_dnj (Deku Butler) (#1100) --- assets/xml/objects/object_dnj.xml | 174 ++++++++-------- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 242 ++++++++++++++-------- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 7 +- 3 files changed, 246 insertions(+), 177 deletions(-) diff --git a/assets/xml/objects/object_dnj.xml b/assets/xml/objects/object_dnj.xml index 95b563913..3b4f27579 100644 --- a/assets/xml/objects/object_dnj.xml +++ b/assets/xml/objects/object_dnj.xml @@ -1,86 +1,96 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 5877c5fd2..685c3a511 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -11,7 +11,6 @@ #include "z_en_dno.h" #include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_dnj/object_dnj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -44,17 +43,50 @@ void func_80A732C8(EnDno* this, PlayState* play); s32 EnDno_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +typedef enum { + /* 0 */ EN_DNO_ANIM_START_RACE_START, + /* 1 */ EN_DNO_ANIM_START_RACE_END, + /* 2 */ EN_DNO_ANIM_FLY, + /* 3 */ EN_DNO_ANIM_FAREWELL, + /* 4 */ EN_DNO_ANIM_GREETING, + /* 5 */ EN_DNO_ANIM_GREETING_WITH_CANDLE, + /* 6 */ EN_DNO_ANIM_PRAYER_LOOP, + /* 7 */ EN_DNO_ANIM_CLOSE_PARASOL, + /* 8 */ EN_DNO_ANIM_OPEN_PARASOL, + /* 9 */ EN_DNO_ANIM_IMPLORE_LOOP, + /* 10 */ EN_DNO_ANIM_IMPLORE_END, + /* 11 */ EN_DNO_ANIM_TALK, + /* 12 */ EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, + /* 13 */ EN_DNO_ANIM_IDLE, + /* 14 */ EN_DNO_ANIM_IDLE_WITH_CANDLE, + /* 15 */ EN_DNO_ANIM_PRAYER_START, + /* 16 */ EN_DNO_ANIM_IMPLORE_START, + /* 17 */ EN_DNO_ANIM_SHOCK_START, + /* 18 */ EN_DNO_ANIM_SHOCK_LOOP, + /* 19 */ EN_DNO_ANIM_GRIEVE, +} EnDnoAnimation; + static AnimationSpeedInfo sAnimations[] = { - { &object_dnj_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dnj_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dnj_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dnj_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dnj_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerStartRaceStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerStartRaceEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerFlyAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerFarewellAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingWithCandleAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerPrayerLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerCloseParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerOpenParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerImploreEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerTalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerTalkWithParasolAndCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleWithCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerPrayerStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerGrieveAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { @@ -199,14 +231,15 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dnj_Skel_00E1F8, &object_dnj_Anim_007CA4, - this->jointTable, this->morphTable, 28); + SkelAnime_InitFlex(play, &this->skelAnime, &gDekuButlerSkel, &gDekuButlerIdleAnim, this->jointTable, + this->morphTable, DEKU_BUTLER_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, - sAnimations[14].morphFrames); + Animation_Change(&this->skelAnime, sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation), + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].mode, + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; @@ -219,7 +252,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); thisx->room = -1; gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); @@ -233,7 +267,8 @@ void EnDno_Init(Actor* thisx, PlayState* play) { if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); this->unk_460 = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); @@ -261,7 +296,7 @@ void EnDno_Destroy(Actor* thisx, PlayState* play) { void func_80A71B04(EnDno* this, PlayState* play) { this->unk_452 = 0; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GRIEVE, &this->animIndex); this->actionFunc = EnDno_DoNothing; } @@ -274,54 +309,57 @@ void func_80A71B68(EnDno* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } this->actionFunc = func_80A71C3C; } void func_80A71C3C(EnDno* this, PlayState* play) { - switch (this->unk_32C) { - case 9: - case 16: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_LOOP: + case EN_DNO_ANIM_IMPLORE_START: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, &this->animIndex); break; - case 3: - case 10: + case EN_DNO_ANIM_FAREWELL: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } break; - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } - case 6: + case EN_DNO_ANIM_PRAYER_LOOP: Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 2, 0xE38, 0x222); break; } - if ((this->unk_32C == 13) && (this->actor.xzDistToPlayer <= 120.0f)) { + if ((this->animIndex == EN_DNO_ANIM_IDLE) && (this->actor.xzDistToPlayer <= 120.0f)) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.shape.rot.y, 0x2000, 0x16C); } else { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); } - if ((this->unk_32C != 3) && (this->unk_32C != 15) && (this->unk_32C != 6)) { + if ((this->animIndex != EN_DNO_ANIM_FAREWELL) && (this->animIndex != EN_DNO_ANIM_PRAYER_START) && + (this->animIndex != EN_DNO_ANIM_PRAYER_LOOP)) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); } @@ -366,7 +404,8 @@ void func_80A71F18(EnDno* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { switch (this->textId) { case 0x80B: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_START, + &this->animIndex); case 0x811: Message_StartTextbox(play, this->textId, &this->actor); @@ -374,10 +413,13 @@ void func_80A71F18(EnDno* this, PlayState* play) { case 0x80C: case 0x80F: - if (this->unk_32C == 13) { - 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); + if (this->animIndex == EN_DNO_ANIM_IDLE) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GREETING, + &this->animIndex); + } else if ((this->animIndex == EN_DNO_ANIM_GREETING) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_TALK, + &this->animIndex); Message_StartTextbox(play, this->textId, &this->actor); } break; @@ -387,19 +429,21 @@ void func_80A71F18(EnDno* this, PlayState* play) { case TEXT_STATE_3: if (play->msgCtx.currentTextId == 0x80B) { - switch (this->unk_32C) { - case 16: + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(play); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); func_80A71B68(this, play); } break; @@ -412,24 +456,27 @@ void func_80A71F18(EnDno* this, PlayState* play) { case TEXT_STATE_DONE: switch (play->msgCtx.currentTextId) { case 0x80B: - switch (this->unk_32C) { - case 16: + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } break; - case 9: + case EN_DNO_ANIM_IMPLORE_LOOP: if (Message_ShouldAdvance(play)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, + &this->animIndex); play->msgCtx.msgMode = 0x44; } break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(play); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); func_80A71B68(this, play); } break; @@ -449,13 +496,15 @@ void func_80A71F18(EnDno* this, PlayState* play) { break; case 0x80E: - if (this->unk_32C == 11) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); - } else if (this->unk_32C == 3) { + if (this->animIndex == EN_DNO_ANIM_TALK) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_FAREWELL, + &this->animIndex); + } else if (this->animIndex == EN_DNO_ANIM_FAREWELL) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); } - } else if ((this->unk_32C == 13) && Message_ShouldAdvance(play)) { + } else if ((this->animIndex == EN_DNO_ANIM_IDLE) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80A71B68(this, play); } @@ -475,14 +524,16 @@ void func_80A71F18(EnDno* this, PlayState* play) { break; } - switch (this->unk_32C) { - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + switch (this->animIndex) { + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, + &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } break; } @@ -501,7 +552,7 @@ void func_80A71F18(EnDno* this, PlayState* play) { void func_80A72438(EnDno* this, PlayState* play) { this->unk_452 = 1; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, &this->animIndex); this->actor.textId = 0; if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { this->unk_454 = 1.0f; @@ -545,11 +596,13 @@ void func_80A725F8(EnDno* this, PlayState* play) { case TEXT_STATE_NONE: switch (this->unk_328) { case 0: - if (this->unk_32C == 14) { + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); } - } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor))) { Message_StartTextbox(play, 0x801, &this->actor); } else if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { @@ -557,7 +610,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { } else { Message_StartTextbox(play, 0x800, &this->actor); } - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); } break; @@ -578,7 +632,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { case TEXT_STATE_CLOSING: case TEXT_STATE_3: if (((play->msgCtx.currentTextId == 0x800) || (play->msgCtx.currentTextId == 0x801)) && - (this->unk_32C == 8)) { + (this->animIndex == EN_DNO_ANIM_OPEN_PARASOL)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; @@ -592,7 +646,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, &this->animIndex); Message_StartTextbox(play, 0x803, &this->actor); } } @@ -608,7 +663,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { play->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_OPEN_PARASOL, + &this->animIndex); } break; @@ -632,15 +688,17 @@ void func_80A725F8(EnDno* this, PlayState* play) { break; case 0x804: - if (this->unk_32C == 14) { + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { if (Message_ShouldAdvance(play)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, play); this->unk_3B0 |= 0x40; } } - } else if ((this->unk_32C == 5) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { func_801477B4(play); func_80A72438(this, play); } @@ -661,7 +719,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { } void func_80A72AE4(EnDno* this, PlayState* play) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); func_80A714B4(this, play); this->actionFunc = func_80A72B3C; } @@ -688,7 +746,7 @@ void func_80A72BA4(EnDno* this, PlayState* play) { } void func_80A72C04(EnDno* this, PlayState* play) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); 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); @@ -767,27 +825,26 @@ s32 EnDno_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { } void func_80A730A0(EnDno* this, PlayState* play) { - f32 temp_f10; s32 phi_a2; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { phi_a2 = -1; - switch (this->unk_32C) { - case 0: + switch (this->animIndex) { + case EN_DNO_ANIM_START_RACE_START: if (this->unk_44E >= 20) { - phi_a2 = 1; + phi_a2 = EN_DNO_ANIM_START_RACE_END; } else { this->unk_44E = 20; } break; - case 1: - phi_a2 = 2; + case EN_DNO_ANIM_START_RACE_END: + phi_a2 = EN_DNO_ANIM_FLY; break; } if (phi_a2 >= 0) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } @@ -799,8 +856,7 @@ void func_80A730A0(EnDno* this, PlayState* play) { 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; + this->actor.world.pos.y += Math_SinS(this->unk_3AC) * (4.0f + Math_SinS(this->unk_3AE)); this->unk_3AC += 4500; this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -834,11 +890,12 @@ void func_80A732C8(EnDno* this, PlayState* play) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_CLOSE_PARASOL, &this->animIndex); } } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); func_80A72438(this, play); } else { if (this->skelAnime.curFrame >= 20.0f) { @@ -880,15 +937,16 @@ void func_80A73408(EnDno* this, PlayState* play) { } if (sp33) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); } - if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && + (this->animIndex == EN_DNO_ANIM_SHOCK_START)) { if (0) {}; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_SHOCK_LOOP, &this->animIndex); } } @@ -982,7 +1040,7 @@ void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, gSPMatrix(gfxOpa, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfxOpa[1], *dList); - POLY_OPA_DISP = gfxOpa + 2; + POLY_OPA_DISP = &gfxOpa[2]; CLOSE_DISPS(play->state.gfxCtx); } @@ -1007,7 +1065,7 @@ void EnDno_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, gDPSetEnvColor(&gfxXlu[3], 255, 0, 0, 0); gSPDisplayList(&gfxXlu[4], gEffFire1DL); - POLY_XLU_DISP = gfxXlu + 5; + POLY_XLU_DISP = &gfxXlu[5]; Matrix_Pop(); 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 2e417a7a0..db07a969b 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -2,6 +2,7 @@ #define Z_EN_DNO_H #include "global.h" +#include "objects/object_dnj/object_dnj.h" struct EnDno; @@ -21,10 +22,10 @@ typedef struct EnDno { /* 0x144 */ EnDnoActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Vec3s jointTable[28]; - /* 0x280 */ Vec3s morphTable[28]; + /* 0x1D8 */ Vec3s jointTable[DEKU_BUTLER_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[DEKU_BUTLER_LIMB_MAX]; /* 0x328 */ s32 unk_328; - /* 0x32C */ s32 unk_32C; + /* 0x32C */ s32 animIndex; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; /* 0x340 */ ActorPathing actorPath; From b080fb370032738769467242c7a1a7945f972836 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 20:51:49 -0400 Subject: [PATCH 60/73] z_kaleido_mask.c Ok and Documented (Pause Menu Mask Page) (#1093) * import mask docs * cleanup * some PR * fix merge from master * fix merge * move cursor result --- include/z64.h | 11 +- include/z64save.h | 2 +- src/code/flg_set.c | 8 +- src/code/z_sram_NES.c | 4 +- src/overlays/actors/ovl_En_Js/z_en_js.c | 32 +- .../ovl_kaleido_scope/z_kaleido_debug.c | 4 +- .../ovl_kaleido_scope/z_kaleido_item.c | 161 ++-- .../ovl_kaleido_scope/z_kaleido_mask.c | 827 +++++++++++++++++- .../ovl_kaleido_scope/z_kaleido_scope.h | 22 + tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 18 +- 11 files changed, 930 insertions(+), 165 deletions(-) diff --git a/include/z64.h b/include/z64.h index 5589e7cad..96302ed0c 100644 --- a/include/z64.h +++ b/include/z64.h @@ -440,13 +440,12 @@ typedef struct { /* 0x220 */ f32 unk_220; /* 0x224 */ u16 alpha; /* 0x226 */ s16 offsetY; - /* 0x228 */ s32 unk_228; - /* 0x22C */ s32 unk_22C; - /* 0x230 */ s32 stickRelX; - /* 0x234 */ s32 stickRelY; + /* 0x228 */ UNK_TYPE1 unk_228[0x8]; + /* 0x230 */ s32 stickAdjX; + /* 0x234 */ s32 stickAdjY; /* 0x238 */ s16 cursorPoint[5]; - /* 0x242 */ s16 cursorX[5]; - /* 0x24C */ s16 cursorY[5]; + /* 0x242 */ s16 cursorXIndex[5]; + /* 0x24C */ s16 cursorYIndex[5]; /* 0x256 */ s16 unk_256; /* 0x258 */ s16 cursorSpecialPos; /* 0x25A */ s16 pageSwitchTimer; diff --git a/include/z64save.h b/include/z64save.h index df78cc169..74cf31c8e 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -368,7 +368,7 @@ typedef struct SaveContext { /* 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 dungeonIndex; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon + /* 0x48CA */ u8 masksGivenOnMoon[27]; // bit-packed, masks given away on the Moon. "mask_mask_bit" } SaveContext; // size = 0x48C8 typedef enum ButtonStatus { diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 0bc978160..a22b62a0e 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -1,6 +1,6 @@ /** * File: flg_set.c - * Description: Event Editor, used to view and edit weekEventReg, eventInf and maskMaskBit flags. + * Description: Event Editor, used to view and edit weekEventReg, eventInf and masksGivenOnMoon flags. * Controls: * + Left and Right: select different flags/bits in array element * + Up and Down: select array element (byte) 1 up/down @@ -123,9 +123,9 @@ static FlagSetEntry sFlagEntries[] = { { &gSaveContext.eventInf[6], "event_inf[6]" }, { &gSaveContext.eventInf[7], "event_inf[7]" }, - { &gSaveContext.maskMaskBit[0], "mask_mask_bit[0]" }, - { &gSaveContext.maskMaskBit[1], "mask_mask_bit[1]" }, - { &gSaveContext.maskMaskBit[2], "mask_mask_bit[2]" }, + { &gSaveContext.masksGivenOnMoon[0], "mask_mask_bit[0]" }, + { &gSaveContext.masksGivenOnMoon[1], "mask_mask_bit[1]" }, + { &gSaveContext.masksGivenOnMoon[2], "mask_mask_bit[2]" }, { NULL, NULL }, // used in the code to detect array end }; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 73b0a0af0..6f9006146 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -292,8 +292,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.cycleSceneFlags[i].collectible = 0; } - for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { - gSaveContext.maskMaskBit[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.masksGivenOnMoon); i++) { + gSaveContext.masksGivenOnMoon[i] = 0; } if (gSaveContext.save.weekEventReg[84] & 0x20) { 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 4e35a5158..457f62d77 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -272,7 +272,7 @@ s32 func_80968E38(s32 arg0) { s32 i; s32 count; u8 mask; - u8* maskMaskBit = gSaveContext.maskMaskBit; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; if (((arg0 < 0) || (arg0 >= 9))) { return 0; @@ -282,21 +282,21 @@ s32 func_80968E38(s32 arg0) { arg0 *= 3; for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } arg0++; for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } arg0++; for (mask = 1, i = 0; i < 5; i++, mask <<= 1) { - if (maskMaskBit[arg0] & mask) { + if (masksGivenOnMoon[arg0] & mask) { count++; } } @@ -373,15 +373,15 @@ s32 EnJs_GetRemainingMasks(void) { } void EnJs_TakeMask(s32 actionParams, s32 childType) { - u8* maskMaskBit = gSaveContext.maskMaskBit; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; s32 temp = 0; if ((childType >= 0) && (childType < 9)) { actionParams -= PLAYER_AP_MASK_TRUTH; childType *= 3; if (actionParams < 8) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; return; } @@ -389,8 +389,8 @@ void EnJs_TakeMask(s32 actionParams, s32 childType) { childType++; temp++; if (actionParams < 8) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; return; } @@ -398,8 +398,8 @@ void EnJs_TakeMask(s32 actionParams, s32 childType) { childType++; temp++; if (actionParams < 6) { - maskMaskBit[childType] |= 1 << actionParams; - maskMaskBit[temp] |= 1 << actionParams; + masksGivenOnMoon[childType] |= 1 << actionParams; + masksGivenOnMoon[temp] |= 1 << actionParams; } } } @@ -457,15 +457,15 @@ s32 func_8096933C(s32 arg0) { } void func_80969400(s32 arg0) { - u8* maskMaskBit = gSaveContext.maskMaskBit; - u8* temp_v0 = &gSaveContext.maskMaskBit[arg0 * 3]; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; + u8* temp_v0 = &gSaveContext.masksGivenOnMoon[arg0 * 3]; if ((arg0 >= 0) && (arg0 < 9)) { - maskMaskBit[0] &= ~temp_v0[0]; - maskMaskBit[1] &= ~temp_v0[1]; + masksGivenOnMoon[0] &= ~temp_v0[0]; + masksGivenOnMoon[1] &= ~temp_v0[1]; temp_v0[2] &= 0xF; - maskMaskBit[2] &= ~temp_v0[2]; + masksGivenOnMoon[2] &= ~temp_v0[2]; temp_v0[0] = 0; temp_v0[1] = 0; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 9f6a58a86..c1f67b079 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -663,8 +663,8 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { s16 value; s32 dBtnInput = input->cur.button & (BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); - pauseCtx->stickRelX = input->rel.stick_x; - pauseCtx->stickRelY = input->rel.stick_y; + pauseCtx->stickAdjX = input->rel.stick_x; + pauseCtx->stickAdjY = input->rel.stick_y; // Handles navigating the menu to different sections with the D-Pad // When the same direction is held, registers the input periodically based on a timer diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index 7f57ac7a3..be23b56de 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -7,13 +7,6 @@ #include "z_kaleido_scope.h" #include "interface/parameter_static/parameter_static.h" -typedef enum { - /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, - /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, - /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, - /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN -} EquipState; - s16 sEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; // Timer to hold magic arrow icon over magic arrow slot before moving when equipping. @@ -355,8 +348,8 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { u16 cursorSlot; u8 magicArrowIndex; s16 cursorPoint; - s16 cursorX; - s16 cursorY; + s16 cursorXIndex; + s16 cursorYIndex; s16 oldCursorPoint; s16 moveCursorResult; s16 pad2; @@ -366,7 +359,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && !pauseCtx->itemDescriptionOn) { - moveCursorResult = 0; + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; @@ -376,87 +369,87 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // cursor is currently on a slot pauseCtx->cursorColorSet = 2; - if (ABS_ALT(pauseCtx->stickRelX) > 30) { + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; - cursorX = pauseCtx->cursorX[PAUSE_ITEM]; - cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; // Search for slot to move to - while (moveCursorResult == 0) { - if (pauseCtx->stickRelX < -30) { + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { // move cursor left pauseCtx->unk_298 = 4.0f; - if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { - pauseCtx->cursorX[PAUSE_ITEM]--; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorXIndex[PAUSE_ITEM]--; pauseCtx->cursorPoint[PAUSE_ITEM]--; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; - if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { - pauseCtx->cursorY[PAUSE_ITEM] = 0; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; } pauseCtx->cursorPoint[PAUSE_ITEM] = - pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { - pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } - if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); - moveCursorResult = 2; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; } } - } else if (pauseCtx->stickRelX > 30) { + } else if (pauseCtx->stickAdjX > 30) { // move cursor right pauseCtx->unk_298 = 4.0f; - if (pauseCtx->cursorX[PAUSE_ITEM] <= 4) { - pauseCtx->cursorX[PAUSE_ITEM]++; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] <= 4) { + pauseCtx->cursorXIndex[PAUSE_ITEM]++; pauseCtx->cursorPoint[PAUSE_ITEM]++; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; - if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { - pauseCtx->cursorY[PAUSE_ITEM] = 0; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; } pauseCtx->cursorPoint[PAUSE_ITEM] = - pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { - pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } - if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); - moveCursorResult = 2; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; } } } } - if (moveCursorResult == 1) { + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } } } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { - if (pauseCtx->stickRelX > 30) { + if (pauseCtx->stickAdjX > 30) { func_80821A04(play); - cursorY = 0; - cursorX = 0; + cursorYIndex = 0; + cursorXIndex = 0; cursorPoint = 0; // top row, left column (SLOT_OCARINA) // Search for slot to move to @@ -464,24 +457,24 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Check if current cursor has an item in its slot if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; - moveCursorResult = 1; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; break; } // move 1 row down and retry - cursorY++; + cursorYIndex++; cursorPoint += 6; - if (cursorY < 4) { + if (cursorYIndex < 4) { continue; } // move 1 column right and retry - cursorY = 0; - cursorPoint = cursorX + 1; - cursorX = cursorPoint; - if (cursorX < 6) { + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { continue; } @@ -491,35 +484,35 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { } } } else { // PAUSE_CURSOR_PAGE_RIGHT - if (pauseCtx->stickRelX < -30) { + if (pauseCtx->stickAdjX < -30) { func_80821A04(play); - cursorX = 5; + cursorXIndex = 5; cursorPoint = 5; // top row, right columne (SLOT_TRADE_DEED) - cursorY = 0; + cursorYIndex = 0; // Search for slot to move to while (true) { // Check if current cursor has an item in its slot if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; - pauseCtx->cursorX[PAUSE_ITEM] = cursorX; - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; - moveCursorResult = 1; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; break; } // move 1 row down and retry - cursorY++; + cursorYIndex++; cursorPoint += 6; - if (cursorY < 4) { + if (cursorYIndex < 4) { continue; } // move 1 column left and retry - cursorY = 0; - cursorPoint = cursorX - 1; - cursorX = cursorPoint; - if (cursorX >= 0) { + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { continue; } @@ -532,35 +525,35 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if (pauseCtx->cursorSpecialPos == 0) { // move cursor up/down - if (ABS_ALT(pauseCtx->stickRelY) > 30) { - moveCursorResult = 0; + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; - cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; - while (moveCursorResult == 0) { - if (pauseCtx->stickRelY > 30) { + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { // move cursor up - moveCursorResult = 2; - if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { - pauseCtx->cursorY[PAUSE_ITEM]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorYIndex[PAUSE_ITEM]--; pauseCtx->unk_298 = 4.0f; pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; } - } else if (pauseCtx->stickRelY < -30) { + } else if (pauseCtx->stickAdjY < -30) { // move cursor down - moveCursorResult = 2; - if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { - pauseCtx->cursorY[PAUSE_ITEM]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 3) { + pauseCtx->cursorYIndex[PAUSE_ITEM]++; pauseCtx->unk_298 = 4.0f; pauseCtx->cursorPoint[PAUSE_ITEM] += 6; - moveCursorResult = 1; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; } else { - pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; } } @@ -570,9 +563,9 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; pauseCtx->cursorColorSet = 2; - if (moveCursorResult == 1) { + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; - } else if (moveCursorResult != 2) { + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } @@ -683,7 +676,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { (msgCtx->msgLength == 0)) { // Give description on item through a message box pauseCtx->itemDescriptionOn = true; - if (pauseCtx->cursorY[PAUSE_ITEM] < 2) { + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 2) { func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 3); } else { func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 1); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index f8f61c5dc..cedcbf8f3 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -1,59 +1,810 @@ /* * File: z_kaleido_mask.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Mask Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +s16 sMaskEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -s32 D_8082B600 = 0; +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sMaskEquipMagicArrowSlotHoldTimer = 0; -s32 D_8082B604 = 0; +// Number of frames to move icon from slot to target position when equipping. +s16 sMaskEquipAnimTimer = 10; -s16 D_8082B608 = 10; - -s32 D_8082B60C[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00010000, - 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, - 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, 0x00000000, 0x00010000, 0x00000001, - 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, +u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_MASK_SLOTS] = { + // Fierce Deity + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + false, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + false, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + false, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Goron + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Zora + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Deku + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Human + { + true, // SLOT_MASK_POSTMAN + true, // SLOT_MASK_ALL_NIGHT + true, // SLOT_MASK_BLAST + true, // SLOT_MASK_STONE + true, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + true, // SLOT_MASK_KEATON + true, // SLOT_MASK_BREMEN + true, // SLOT_MASK_BUNNY + true, // SLOT_MASK_DON_GERO + true, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + true, // SLOT_MASK_ROMANI + true, // SLOT_MASK_CIRCUS_LEADER + true, // SLOT_MASK_KAFEIS_MASK + true, // SLOT_MASK_COUPLE + true, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + true, // SLOT_MASK_KAMARO + true, // SLOT_MASK_GIBDO + true, // SLOT_MASK_GARO + true, // SLOT_MASK_CAPTAIN + true, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, }; -s32 D_8082B684[] = { - 0x01010004, 0x02020180, 0x01040210, 0x00100201, 0x00080110, 0x02040220, 0x00400080, 0x00020102, 0x00010240, - 0x01200108, 0x00200140, 0x02080280, 0x00FF0064, 0x00FF0000, 0x00000064, 0x00FF0000, 0x000000FF, 0x00640000, +#define SET_MOON_MASK_BIT(masksGivenOnMoonIndex, masksGivenOnMoonFlag) \ + ((masksGivenOnMoonIndex) << 8 | (masksGivenOnMoonFlag)) +#define CHECK_GIVEN_MASK_ON_MOON(maskIndex) \ + (gSaveContext.masksGivenOnMoon[sMasksGivenOnMoonBits[maskIndex] >> 8] & (u8)sMasksGivenOnMoonBits[maskIndex]) + +u16 sMasksGivenOnMoonBits[] = { + SET_MOON_MASK_BIT(1, 0x1), // SLOT_MASK_POSTMAN + SET_MOON_MASK_BIT(0, 0x4), // SLOT_MASK_ALL_NIGHT + SET_MOON_MASK_BIT(2, 0x2), // SLOT_MASK_BLAST + SET_MOON_MASK_BIT(1, 0x80), // SLOT_MASK_STONE + SET_MOON_MASK_BIT(1, 0x4), // SLOT_MASK_GREAT_FAIRY + SET_MOON_MASK_BIT(2, 0x10), // SLOT_MASK_DEKU + SET_MOON_MASK_BIT(0, 0x10), // SLOT_MASK_KEATON + SET_MOON_MASK_BIT(2, 0x1), // SLOT_MASK_BREMEN + SET_MOON_MASK_BIT(0, 0x8), // SLOT_MASK_BUNNY + SET_MOON_MASK_BIT(1, 0x10), // SLOT_MASK_DON_GERO + SET_MOON_MASK_BIT(2, 0x4), // SLOT_MASK_SCENTS + SET_MOON_MASK_BIT(2, 0x20), // SLOT_MASK_GORON + SET_MOON_MASK_BIT(0, 0x40), // SLOT_MASK_ROMANI + SET_MOON_MASK_BIT(0, 0x80), // SLOT_MASK_CIRCUS_LEADER + SET_MOON_MASK_BIT(0, 0x2), // SLOT_MASK_KAFEIS_MASK + SET_MOON_MASK_BIT(1, 0x2), // SLOT_MASK_COUPLE + SET_MOON_MASK_BIT(0, 0x1), // SLOT_MASK_TRUTH + SET_MOON_MASK_BIT(2, 0x40), // SLOT_MASK_ZORA + SET_MOON_MASK_BIT(1, 0x20), // SLOT_MASK_KAMARO + SET_MOON_MASK_BIT(1, 0x8), // SLOT_MASK_GIBDO + SET_MOON_MASK_BIT(0, 0x20), // SLOT_MASK_GARO + SET_MOON_MASK_BIT(1, 0x40), // SLOT_MASK_CAPTAIN + SET_MOON_MASK_BIT(2, 0x8), // SLOT_MASK_GIANT + SET_MOON_MASK_BIT(2, 0X80), // SLOT_MASK_FIERCE_DEITY }; -u8 D_8082B6CC[] = { 0x35, 0x33, 0x34, 0x32, 0xFF }; +s16 sMaskMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMaskMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMaskMagicArrowEffectsB[] = { 0, 255, 100 }; -s16 D_8082B6D4[] = { - 0x0294, - 0x0384, - 0x0474, - 0x0000, +void KaleidoScope_DrawMaskSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MASK] * 4, pauseCtx->maskVtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = NUM_MASK_SLOTS * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) >= NUM_ITEM_SLOTS) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j], 4, 0); + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < NUM_MASK_SLOTS; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS]) != ITEM_NONE) { + if (!CHECK_GIVEN_MASK_ON_MOON(i)) { + if ((pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MASK) && + (pauseCtx->cursorSpecialPos == 0) && + gMaskPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, + sMaskMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], pauseCtx->alpha); + + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + + } else if (i == pauseCtx->cursorSlot[PAUSE_MASK]) { + // Increase the size of the selected item + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j + 0], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32( + play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS])], + 32, 32, 0); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sMaskPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, }; -s16 D_8082B6DC[] = { - 0x044C, - 0x0398, - 0x044C, - 0x0000, -}; +void KaleidoScope_UpdateMaskCursor(PlayState* play) { + Input* input = CONTROLLER1(&play->state); + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + s16 cursorPoint; + s16 cursorXIndex; + s16 cursorYIndex; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; -s16 D_8082B6E4 = 0; + pauseCtx->cursorColorSet = 0; + pauseCtx->nameColorSet = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FF80.s") + if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MASK) && + !pauseCtx->itemDescriptionOn) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808204AC.s") + cursorItem = pauseCtx->cursorItem[PAUSE_MASK]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80820FA4.s") + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = 2; + + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + // Search for slot to move to + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] != 0) { + pauseCtx->cursorXIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] <= 4) { + pauseCtx->cursorXIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } + } + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + func_80821A04(play); + cursorYIndex = 0; + cursorXIndex = 0; + cursorPoint = 0; // top row, left column (SLOT_MASK_POSTMAN) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column right and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + //! FAKE: + if (1) {} + if (pauseCtx->stickAdjX < -30) { + func_80821A04(play); + cursorXIndex = 5; + cursorPoint = 5; // top row, right column (SLOT_MASK_DEKU) + cursorYIndex = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column left and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { + // move cursor up + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] != 0) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK] -= 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } else if (pauseCtx->stickAdjY < -30) { + // move cursor down + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 3) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK] += 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_MASK]; + pauseCtx->cursorColorSet = 2; + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = 0; + } + + if ((cursorItem != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + pauseCtx->cursorItem[PAUSE_MASK] = cursorItem; + pauseCtx->cursorSlot[PAUSE_MASK] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && + CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a mask is not unequipped while being used + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + + if ((Player_GetEnvTimerType(play) >= PLAYER_ENV_TIMER_UNDERWATER_FLOOR) && + (Player_GetEnvTimerType(play) <= PLAYER_ENV_TIMER_UNDERWATER_FREE) && + ((cursorSlot == (SLOT_MASK_DEKU - NUM_ITEM_SLOTS)) || + (cursorSlot == (SLOT_MASK_GORON - NUM_ITEM_SLOTS)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot + NUM_ITEM_SLOTS; + pauseCtx->unk_200 = 0xF; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->maskVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->maskVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sMaskEquipMagicArrowSlotHoldTimer = 0; + sMaskEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sMaskEquipAnimTimer = 10; + play_sound(NA_SE_SY_DECIDE); + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == 6) && + (pauseCtx->unk_200 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && + (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_MASK]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->unk_200 == 0xF) && (pauseCtx->pageIndex == PAUSE_MASK)) { + pauseCtx->cursorColorSet = 2; + } +} + +s16 sMaskCButtonPosX[] = { 660, 900, 1140 }; +s16 sMaskCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateMaskEquip(PlayState* play) { + static s16 sMaskEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sMaskEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sMaskEquipMagicArrowBowSlotHoldTimer--; + + if (sMaskEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sMaskEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sMaskEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[12]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sMaskEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[12].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[12].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + if (pauseCtx->equipAnimX >= sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sMaskEquipAnimTimer--; + if (sMaskEquipAnimTimer == 0) { + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sMaskEquipState++; + sMaskEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip mask onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if mask is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if mask is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if mask is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Equip mask on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->unk_200 = 0; + sMaskEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sMaskEquipMagicArrowSlotHoldTimer--; + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index 19e3c8719..94724154f 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -22,6 +22,13 @@ typedef enum { /* 2 */ PAUSE_EQUIP_C_RIGHT } PauseEquipCButton; +typedef enum { + /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, + /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, + /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, + /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN +} EquipState; + typedef enum { /* 0 */ DEBUG_EDITOR_NONE, /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, @@ -29,6 +36,16 @@ typedef enum { /* 3 */ DEBUG_EDITOR_EVENTS } DebugEditor; +// To be used for Item-Page cursor and Mask-Page cursor +typedef enum { + /* 0 */ PAUSE_CURSOR_RESULT_NONE, + /* 1 */ PAUSE_CURSOR_RESULT_SLOT, + /* 2 */ PAUSE_CURSOR_RESULT_SPECIAL_POS +} PauseMoveCursorResult; + +#define NUM_ITEM_SLOTS 24 +#define NUM_MASK_SLOTS 24 + #define PAUSE_PROMPT_YES 0 #define PAUSE_PROMPT_NO 4 @@ -43,6 +60,11 @@ void KaleidoScope_DrawItemSelect(PlayState* play); void KaleidoScope_UpdateItemCursor(PlayState* play); void KaleidoScope_UpdateItemEquip(PlayState* play); +// Mask +void KaleidoScope_DrawMaskSelect(PlayState* play); +void KaleidoScope_UpdateMaskCursor(PlayState* play); +void KaleidoScope_UpdateMaskEquip(PlayState* play); + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4415b571d..4bcf89f80 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4214,9 +4214,9 @@ 0x8081E118:("func_8081E118",), 0x8081E7D8:("func_8081E7D8",), 0x8081FB1C:("func_8081FB1C",), - 0x8081FF80:("func_8081FF80",), - 0x808204AC:("func_808204AC",), - 0x80820FA4:("func_80820FA4",), + 0x8081FF80:("KaleidoScope_DrawMaskSelect",), + 0x808204AC:("KaleidoScope_UpdateMaskCursor",), + 0x80820FA4:("KaleidoScope_UpdateMaskEquip",), 0x80821730:("KaleidoScope_UpdatePrompt",), 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3578b52a5..ff7987c6f 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4725,15 +4725,15 @@ 0x8082B5CC:("D_8082B5CC","UNK_TYPE1","",0x1), 0x8082B5E0:("D_8082B5E0","UNK_TYPE1","",0x1), 0x8082B5F4:("D_8082B5F4","UNK_TYPE2","",0x2), - 0x8082B600:("D_8082B600","UNK_TYPE2","",0x2), - 0x8082B604:("D_8082B604","UNK_TYPE2","",0x2), - 0x8082B608:("D_8082B608","UNK_TYPE2","",0x2), - 0x8082B60C:("D_8082B60C","UNK_TYPE1","",0x1), - 0x8082B684:("D_8082B684","UNK_TYPE2","",0x2), - 0x8082B6CC:("D_8082B6CC","UNK_TYPE1","",0x1), - 0x8082B6D4:("D_8082B6D4","UNK_TYPE1","",0x1), - 0x8082B6DC:("D_8082B6DC","UNK_TYPE1","",0x1), - 0x8082B6E4:("D_8082B6E4","UNK_TYPE2","",0x2), + 0x8082B600:("sMaskEquipState","UNK_TYPE2","",0x2), + 0x8082B604:("sMaskEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B608:("sMaskEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B60C:("gMaskPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B684:("sMasksGivenOnMoonBits","UNK_TYPE2","",0x2), + 0x8082B6CC:("sMaskPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B6D4:("sMaskCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B6DC:("sMaskCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B6E4:("sMaskEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), 0x8082B6F0:("sPromptAlphaTargets","UNK_TYPE1","",0x1), 0x8082B6F4:("sPromptAlphaTargetIndex","UNK_TYPE2","",0x2), 0x8082B6F8:("sPromptAlphaTimer","UNK_TYPE2","",0x2), From ab5fd663ccddc0670773a047f4a30bf014a7dad4 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:01:39 -0400 Subject: [PATCH 61/73] Quake & Distortion Cleanup (#1102) * quake cleanup * cleanup * more cleanup * remove cast * q comes before r... * unname goron function, leave it to another PR * PR Suggestions --- include/functions.h | 37 +-- include/z64.h | 57 ---- include/z64bgcheck.h | 5 - include/z64quake.h | 69 ++++ src/code/z_actor.c | 23 +- src/code/z_bgcheck.c | 16 +- src/code/z_camera.c | 1 + src/code/z_demo.c | 7 +- src/code/z_play.c | 1 + src/code/z_quake.c | 298 +++++++++++------- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 24 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 10 +- .../z_bg_ikana_rotaryroom.c | 25 +- .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 12 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 10 +- .../ovl_Bg_Open_Shutter/z_bg_open_shutter.c | 22 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.c | 1 + .../actors/ovl_Door_Shutter/z_door_shutter.c | 14 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 13 +- .../actors/ovl_En_Bigpamet/z_en_bigpamet.c | 15 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 11 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 13 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 10 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 10 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 26 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 2 +- .../ovl_En_Stop_heishi/z_en_stop_heishi.c | 1 + src/overlays/actors/ovl_En_Test6/z_en_test6.c | 13 +- .../actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c | 17 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 27 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 1 + .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 16 +- src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 12 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 10 +- .../actors/ovl_player_actor/z_player.c | 1 + .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- tools/disasm/functions.txt | 24 +- tools/disasm/variables.txt | 2 +- tools/namefixer.py | 5 +- tools/sizes/code_functions.csv | 22 +- 40 files changed, 496 insertions(+), 389 deletions(-) create mode 100644 include/z64quake.h diff --git a/include/functions.h b/include/functions.h index 67ad8ec3c..b19b75af9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -745,8 +745,8 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 s32 Actor_IsTargeted(PlayState* play, Actor* actor); s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play); -void func_800BC770(PlayState* play, s16 y, s16 countdown); -void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed); +void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed); void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown); void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); @@ -923,7 +923,7 @@ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -1958,37 +1958,6 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); void func_80128B74(PlayState* play, Player* player, s32 limbIndex); void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); -f32 Quake_Random(void); -void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation); -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_GetFreeIndex(void); -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx); -void Quake_Remove(QuakeRequest* req); -QuakeRequest* Quake_GetRequest(s16 idx); -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value); -u32 Quake_SetSpeed(s16 idx, s16 value); -u32 Quake_SetCountdown(s16 idx, s16 value); -s16 Quake_GetCountdown(s16 idx); -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset); -void Quake_Init(void); -s16 Quake_Add(Camera* camera, u32 callbackIdx); -u32 Quake_RemoveFromIdx(s16 idx); -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); -void Distortion_Init(PlayState* play); -void Distortion_SetCountdown(s16 countdown); -s16 Distortion_GetCountdown(void); -s16 Distortion_GetType(void); -void Distortion_SetType(s32 type); -void Distortion_ClearType(s32 type); -s32 Distortion_GetUnderwaterCurrentSpeed(Player* player); -void Distortion_Update(void); -s32 Quake_NumActiveQuakes(void); Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); diff --git a/include/z64.h b/include/z64.h index 96302ed0c..ceb91bfb8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -896,63 +896,6 @@ typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags); -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; -} ShakeInfo; // size = 0x1C - -typedef struct { - /* 0x00 */ s16 randIdx; - /* 0x02 */ s16 countdownMax; - /* 0x04 */ Camera* camera; - /* 0x08 */ u32 callbackIdx; - /* 0x0C */ s16 verticalMag; - /* 0x0E */ s16 horizontalMag; - /* 0x10 */ s16 zoom; - /* 0x12 */ s16 rollOffset; - /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane - /* 0x1A */ s16 speed; - /* 0x1C */ s16 isShakePerpendicular; - /* 0x1E */ s16 countdown; - /* 0x20 */ s16 camId; -} QuakeRequest; // size = 0x24 - -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; - /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used -} QuakeCamCalc; // size = 0x20 - -typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); - -#define QUAKE_SPEED (1 << 0) -#define QUAKE_VERTICAL_MAG (1 << 1) -#define QUAKE_HORIZONTAL_MAG (1 << 2) -#define QUAKE_ZOOM (1 << 3) -#define QUAKE_ROLL_OFFSET (1 << 4) -#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) -#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) -#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) -#define QUAKE_COUNTDOWN (1 << 8) -#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) - -typedef struct { - /* 0x0 */ PlayState* play; - /* 0x4 */ s32 type; // bitfield, highest set bit determines type - /* 0x8 */ s16 countdown; - /* 0xA */ s16 state; -} DistortionContext; // size = 0xC - -typedef enum { - /* 0 */ DISTORTION_INACTIVE, - /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP -} DistortionState; - typedef struct { /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. /* 0x001 */ UNK_TYPE1 pad1[0x13]; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index b42938354..c2a9bab7c 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -56,11 +56,6 @@ struct DynaPolyActor; // CollisionContext flags #define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 -typedef enum { - /* 0 */ CONVEYOR_WATER, - /* 1 */ CONVEYOR_FLOOR -} ConveyorType; - typedef struct { /* 0x0 */ Vec3s pos; } BgVertex; // size = 0x6 diff --git a/include/z64quake.h b/include/z64quake.h new file mode 100644 index 000000000..468f56793 --- /dev/null +++ b/include/z64quake.h @@ -0,0 +1,69 @@ +#ifndef Z64QUAKE_H +#define Z64QUAKE_H + +#include "z64math.h" + +struct PlayState; +struct Camera; + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; + /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used +} QuakeCamCalc; // size = 0x20 + +#define QUAKE_SPEED (1 << 0) +#define QUAKE_VERTICAL_MAG (1 << 1) +#define QUAKE_HORIZONTAL_MAG (1 << 2) +#define QUAKE_ZOOM (1 << 3) +#define QUAKE_ROLL_OFFSET (1 << 4) +#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) +#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) +#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) +#define QUAKE_COUNTDOWN (1 << 8) +#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) + +typedef enum { + /* 1 */ QUAKE_TYPE_1 = 1, + /* 2 */ QUAKE_TYPE_2, + /* 3 */ QUAKE_TYPE_3, + /* 4 */ QUAKE_TYPE_4, + /* 5 */ QUAKE_TYPE_5, + /* 6 */ QUAKE_TYPE_6 +} QuakeType; + +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown); +s16 Quake_GetCountdown(s16 quakeIndex); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset); +s16 Quake_Add(Camera* camera, u32 type); +s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); +u32 Quake_Remove(s16 quakeIndex); +s32 Quake_NumActiveQuakes(void); +void Quake_Init(void); + +#define DISTORTION_TYPE_0 (1 << 0) +#define DISTORTION_TYPE_2 (1 << 2) +#define DISTORTION_TYPE_3 (1 << 3) +#define DISTORTION_TYPE_4 (1 << 4) +#define DISTORTION_TYPE_5 (1 << 5) +#define DISTORTION_TYPE_6 (1 << 6) +#define DISTORTION_TYPE_7 (1 << 7) +#define DISTORTION_TYPE_8 (1 << 8) +#define DISTORTION_TYPE_9 (1 << 9) +#define DISTORTION_TYPE_A (1 << 10) +#define DISTORTION_TYPE_B (1 << 11) + +void Distortion_SetCountdown(s16 countdown); +s16 Distortion_GetCountdown(void); +s16 Distortion_GetType(void); +void Distortion_SetType(s32 type); +void Distortion_ClearType(s32 type); +void Distortion_Init(PlayState* play); +void Distortion_Update(void); + +#endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index e82e5d2b9..389f7a051 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -5,6 +5,7 @@ #include "global.h" #include "z64load.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" @@ -3777,20 +3778,20 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_800BC770(PlayState* play, s16 y, s16 countdown) { - s16 idx = Quake_Add(&play->mainCamera, 3); +void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, 20000); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } -void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed) { - s16 idx = Quake_Add(&play->mainCamera, 3); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, speed); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } // Actor_RequestRumble? @@ -3800,7 +3801,7 @@ void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) { } else { Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(play, y, countdown); + Actor_AddQuake(play, y, countdown); } typedef struct { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 130fdc970..7f4247b0d 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4331,18 +4331,22 @@ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* } /** - * SurfaceType Get Conveyor Surface Type - * Return type 0 (CONVEYOR_WATER) if 'poly' is a surface that will only move player underwater - * Return type 1 (CONVEYOR_FLOOR) if `poly` is a surface that must be stood on to move player + * Checks if poly is a floor conveyor + * + * A conveyor surface is enabled with non-zero speed. + * When enabled, the conveyor will exhibit two types of behaviour depending on the return value: + * + * If true, then it is a floor conveyor and will push player only while being stood on + * If false, then it is a water conveyor and will push player only while in water */ -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { - return CONVEYOR_FLOOR; + return true; } if (poly == NULL) { - return CONVEYOR_WATER; + return false; } flags = poly->flags_vIB & 0x2000; return !!flags; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 027b78a4a..c26947b21 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" /** * Returns the absolute value for floats diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 69995db16..7dd357fbd 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" @@ -191,7 +192,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x8: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -281,7 +282,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x1A: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 30000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -333,7 +334,7 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c case 0x24: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); diff --git a/src/code/z_play.c b/src/code/z_play.c index bb04f23c0..06ec9c21e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64quake.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 7caa0f426..2b66a39f8 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,7 +1,46 @@ #include "global.h" +#include "z64quake.h" + +typedef struct { + /* 0x00 */ s16 randIndex; + /* 0x02 */ s16 countdownMax; + /* 0x04 */ Camera* camera; + /* 0x08 */ u32 type; + /* 0x0C */ s16 verticalMag; + /* 0x0E */ s16 horizontalMag; + /* 0x10 */ s16 zoom; + /* 0x12 */ s16 rollOffset; + /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane + /* 0x1A */ s16 speed; + /* 0x1C */ s16 isShakePerpendicular; + /* 0x1E */ s16 countdown; + /* 0x20 */ s16 camId; +} QuakeRequest; // size = 0x24 + +typedef struct { + /* 0x0 */ PlayState* play; + /* 0x4 */ s32 type; // bitfield, highest set bit determines type + /* 0x8 */ s16 countdown; + /* 0xA */ s16 state; +} DistortionRequest; // size = 0xC + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; +} ShakeInfo; // size = 0x1C + +typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); + +typedef enum { + /* 0 */ DISTORTION_INACTIVE, + /* 1 */ DISTORTION_ACTIVE, + /* 2 */ DISTORTION_SETUP +} DistortionState; QuakeRequest sQuakeRequest[4]; -DistortionContext sDistortionContext; +DistortionRequest sDistortionRequest; static s16 sIsQuakeInitialized = true; static s16 sQuakeRequestCount = 0; @@ -51,7 +90,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPert shake->zoom = req->zoom * verticalPertubation; } -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -61,7 +100,7 @@ s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -71,7 +110,7 @@ s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) { f32 perpendicularPertubation; req->countdown--; @@ -80,7 +119,7 @@ s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { return 1; } -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax); @@ -91,7 +130,7 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random(); @@ -101,7 +140,7 @@ s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax); @@ -117,7 +156,7 @@ s16 Quake_GetFreeIndex(void) { s32 min = 0x10000; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - if (sQuakeRequest[i].callbackIdx == 0) { + if (sQuakeRequest[i].type == 0) { ret = i; break; } @@ -131,43 +170,43 @@ s16 Quake_GetFreeIndex(void) { return ret; } -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { - s16 idx = Quake_GetFreeIndex(); - QuakeRequest* req = &sQuakeRequest[idx]; +QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) { + s16 index = Quake_GetFreeIndex(); + QuakeRequest* req = &sQuakeRequest[index]; __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; req->camId = camera->camId; - req->callbackIdx = callbackIdx; + req->type = type; req->isShakePerpendicular = true; - req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; + req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index; sQuakeRequestCount++; return req; } -void Quake_Remove(QuakeRequest* req) { - req->callbackIdx = 0; +void Quake_RemoveRequest(QuakeRequest* req) { + req->type = 0; req->countdown = -1; sQuakeRequestCount--; } -QuakeRequest* Quake_GetRequest(s16 idx) { - QuakeRequest* req = &sQuakeRequest[idx & 3]; +QuakeRequest* Quake_GetRequest(s16 quakeIndex) { + QuakeRequest* req = &sQuakeRequest[quakeIndex & 3]; - if (req->callbackIdx == 0) { + if (req->type == 0) { return NULL; } - if (idx != req->randIdx) { + if (quakeIndex != req->randIndex) { return NULL; } return req; } -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req == NULL) { return false; @@ -176,62 +215,75 @@ u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { case QUAKE_SPEED: req->speed = value; break; + case QUAKE_VERTICAL_MAG: req->verticalMag = value; break; + case QUAKE_HORIZONTAL_MAG: req->horizontalMag = value; break; + case QUAKE_ZOOM: req->zoom = value; break; + case QUAKE_ROLL_OFFSET: req->rollOffset = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_X: req->shakePlaneOffset.x = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Y: req->shakePlaneOffset.y = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Z: req->shakePlaneOffset.z = value; break; + case QUAKE_COUNTDOWN: req->countdown = value; req->countdownMax = req->countdown; break; + case QUAKE_IS_SHAKE_PERPENDICULAR: req->isShakePerpendicular = value; break; + + default: + break; } + return true; } } -u32 Quake_SetSpeed(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->speed = value; + req->speed = speed; return true; } return false; } -u32 Quake_SetCountdown(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->countdown = value; + req->countdown = countdown; req->countdownMax = req->countdown; return true; } return false; } -s16 Quake_GetCountdown(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +s16 Quake_GetCountdown(s16 quakeIndex) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { return req->countdown; @@ -239,8 +291,8 @@ s16 Quake_GetCountdown(s16 idx) { return 0; } -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->verticalMag = verticalMag; @@ -252,8 +304,8 @@ u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, return false; } -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->isShakePerpendicular = isShakePerpendicular; @@ -267,29 +319,35 @@ void Quake_Init(void) { s16 i; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - sQuakeRequest[i].callbackIdx = 0; + sQuakeRequest[i].type = 0; sQuakeRequest[i].countdown = 0; } sIsQuakeInitialized = true; sQuakeRequestCount = 0; } -s16 Quake_Add(Camera* camera, u32 callbackIdx) { - return Quake_AddImpl(camera, callbackIdx)->randIdx; +s16 Quake_Add(Camera* camera, u32 type) { + return Quake_AddImpl(camera, type)->randIndex; } -u32 Quake_RemoveFromIdx(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_Remove(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - Quake_Remove(req); + Quake_RemoveRequest(req); return true; } return false; } static QuakeCallbackFunc sQuakeCallbacks[] = { - NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6, + NULL, + Quake_CallbackType1, + Quake_CallbackType2, + Quake_CallbackType3, + Quake_CallbackType4, + Quake_CallbackType5, + Quake_CallbackType6, }; s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { @@ -299,7 +357,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { f32 absSpeedDiv; f32 maxCurr; f32 maxNext; - s32 idx; + s32 index; s32 ret; u32 eq; Vec3f originVec; @@ -323,16 +381,16 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { } ret = 0; - for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { - req = &sQuakeRequest[idx]; - if (req->callbackIdx != 0) { + for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) { + req = &sQuakeRequest[index]; + if (req->type != 0) { if (play->cameraPtrs[req->camId] == NULL) { - Quake_Remove(req); + Quake_RemoveRequest(req); } else { eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; - if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { - Quake_Remove(req); + if (sQuakeCallbacks[req->type](req, &shake) == 0) { + Quake_RemoveRequest(req); } else if (eq == 0) { if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) { camData->atOffset.x = shake.atOffset.x; @@ -383,35 +441,35 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { } void Distortion_Init(PlayState* play) { - sDistortionContext.play = play; + sDistortionRequest.play = play; View_ClearDistortion(&play->view); - sDistortionContext.type = 0; - sDistortionContext.countdown = 0; - sDistortionContext.state = DISTORTION_INACTIVE; + sDistortionRequest.type = 0; + sDistortionRequest.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; } void Distortion_SetCountdown(s16 countdown) { - sDistortionContext.countdown = countdown; - sDistortionContext.state = DISTORTION_SETUP; + sDistortionRequest.countdown = countdown; + sDistortionRequest.state = DISTORTION_SETUP; } s16 Distortion_GetCountdown(void) { - return sDistortionContext.countdown; + return sDistortionRequest.countdown; } s16 Distortion_GetType(void) { - return sDistortionContext.type; + return sDistortionRequest.type; } void Distortion_SetType(s32 type) { - if (sDistortionContext.type < type) { - sDistortionContext.type = type; + if (sDistortionRequest.type < type) { + sDistortionRequest.type = type; } } void Distortion_ClearType(s32 type) { - if (sDistortionContext.type == type) { - sDistortionContext.type = 0; + if (sDistortionRequest.type == type) { + sDistortionRequest.type = 0; } } @@ -419,9 +477,9 @@ void Distortion_ClearType(s32 type) { * Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed */ s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) { - if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly, - player->actor.floorBgId) == CONVEYOR_WATER) { - return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly, + if (!SurfaceType_IsFloorConveyor(&sDistortionRequest.play->colCtx, player->actor.floorPoly, + player->actor.floorBgId)) { + return SurfaceType_GetConveyorSpeed(&sDistortionRequest.play->colCtx, player->actor.floorPoly, player->actor.floorBgId); } return 0; @@ -446,14 +504,14 @@ void Distortion_Update(void) { f32 zScale; f32 speed; Player* player; - PlayState* play = sDistortionContext.play; + PlayState* play = sDistortionRequest.play; PosRot playerPosRot; Camera* camera = GET_ACTIVE_CAM(play); f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f); - if (sDistortionContext.type != 0) { - if (sDistortionContext.type & 0x800) { - sDistortionContext.countdown = 2; + if (sDistortionRequest.type != 0) { + if (sDistortionRequest.type & DISTORTION_TYPE_B) { + sDistortionRequest.countdown = 2; depthPhase = 0x3F0; screenPlanePhase = 0x156; @@ -469,11 +527,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.6f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / 60.0f; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x400) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_A) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x3F0; screenPlanePhase = 0x156; } @@ -490,11 +548,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.4f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 0.5f; - } else if (sDistortionContext.type & 0x200) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_9) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x1FC; screenPlanePhase = 0x156; } @@ -511,11 +569,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.1f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x100) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_8) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x2710; screenPlanePhase = 0x3E8; } @@ -532,15 +590,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - if (sDistortionContext.countdown < 5) { - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + if (sDistortionRequest.countdown < 5) { + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x80) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_7) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x4B0; screenPlanePhase = 0x7D0; } @@ -557,11 +615,11 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x40) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_6) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -578,15 +636,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.3f; - if (sDistortionContext.countdown < 4) { - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + if (sDistortionRequest.countdown < 4) { + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x20) { - sDistortionContext.countdown = 2; - if (sDistortionContext.state == DISTORTION_SETUP) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_5) { + sDistortionRequest.countdown = 2; + if (sDistortionRequest.state == DISTORTION_SETUP) { depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -609,9 +667,9 @@ void Distortion_Update(void) { zScaleFactor = 1.0f; xyScaleFactor = 1.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x10) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_4) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x760; screenPlanePhase = 0x1BC; } @@ -628,14 +686,14 @@ void Distortion_Update(void) { zScale = 0.2f; speed = 0.25f; - countdownRatio = sDistortionContext.countdown / (f32)countdownMax; + countdownRatio = sDistortionRequest.countdown / (f32)countdownMax; zScaleFactor = xyScaleFactor = countdownRatio; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 8) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_3) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; player = GET_PLAYER(play); if (player != NULL) { @@ -656,18 +714,21 @@ void Distortion_Update(void) { zScale = 0.03f; speed = 0.33f; break; + case 2: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + case 1: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + default: xScale = -0.06f; yScale = 0.1f; @@ -683,11 +744,11 @@ void Distortion_Update(void) { } zScaleFactor = -xyScaleFactor; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 4) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_2) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; player = GET_PLAYER(play); depthPhaseStep = 359.2f; @@ -703,18 +764,21 @@ void Distortion_Update(void) { zScale = 0.08f; speed = 0.18f; break; + case 2: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.12f; break; + case 1: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.08f; break; + default: xScale = 0.12f; yScale = 0.12f; @@ -731,12 +795,12 @@ void Distortion_Update(void) { xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f); zScaleFactor = 0.9f - xyScaleFactor; - } else if (sDistortionContext.type & 1) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_0) { // Gives a small mirage-like appearance depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; depthPhaseStep = 0.0f; screenPlanePhaseStep = 150.0f; @@ -759,29 +823,29 @@ void Distortion_Update(void) { depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionDirRot(&sDistortionContext.play->view, + View_SetDistortionDirRot(&sDistortionRequest.play->view, Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); - View_SetDistortionScale(&sDistortionContext.play->view, + View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, (Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f); - View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor); + View_SetDistortionSpeed(&sDistortionRequest.play->view, speed * speedScaleFactor); - sDistortionContext.state = DISTORTION_ACTIVE; + sDistortionRequest.state = DISTORTION_ACTIVE; - } else if (sDistortionContext.state != DISTORTION_INACTIVE) { + } else if (sDistortionRequest.state != DISTORTION_INACTIVE) { View_ClearDistortion(&play->view); - sDistortionContext.state = DISTORTION_INACTIVE; - sDistortionContext.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; + sDistortionRequest.countdown = 0; } - if (sDistortionContext.countdown != 0) { - sDistortionContext.countdown--; - if (sDistortionContext.countdown == 0) { - sDistortionContext.type = 0; + if (sDistortionRequest.countdown != 0) { + sDistortionRequest.countdown--; + if (sDistortionRequest.countdown == 0) { + sDistortionRequest.type = 0; } } } @@ -790,16 +854,16 @@ s32 Quake_NumActiveQuakes(void) { QuakeRequest* req = sQuakeRequest; s32 numActiveQuakes = 0; - if (req[0].callbackIdx != 0) { + if (req[0].type != 0) { numActiveQuakes++; } - if (req[1].callbackIdx != 0) { + if (req[1].type != 0) { numActiveQuakes++; } - if (req[2].callbackIdx != 0) { + if (req[2].type != 0) { numActiveQuakes++; } - if (req[3].callbackIdx != 0) { + if (req[3].type != 0) { numActiveQuakes++; } 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 0c273c739..ec2fd9e9c 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 @@ -6,6 +6,7 @@ #include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" @@ -509,7 +510,7 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* s32 pad; Vec3f sp44; s32 pad2[2]; - s16 quake; + s16 quakeIndex; if (this->unk_170 == 0) { for (i = 0; i < unkStruct->count; i++) { @@ -520,10 +521,12 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* sp44.y = this->unk_16C + unkStruct1->unk_14.y; sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150); - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 7, 0, 0, 0); - Quake_SetCountdown(quake, 12); + + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + if (this->unk_179 <= 0) { func_8019F128(NA_SE_EV_STONEDOOR_STOP); this->unk_179 = 40; @@ -538,15 +541,16 @@ void func_80A9C18C(BgHakuginPost* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Camera* activeCam = GET_ACTIVE_CAM(play); - s16 quake; + s16 quakeIndex; Rumble_Request(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), 255, 20, 150); - quake = Quake_Add(activeCam, 3); - Quake_SetSpeed(quake, 17232); - Quake_SetQuakeValues(quake, 6, 0, 0, 0); - Quake_SetCountdown(quake, 20); + + quakeIndex = Quake_Add(activeCam, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 6, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); } void func_80A9C228(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { 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 e619aa7e0..4f1434dc2 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 "z64quake.h" #include "assets/objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -226,11 +227,12 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->dyna.actor); Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); if (this->dyna.actor.bgCheckFlags & 2) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); - 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 { 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 77bf92531..fb29ca2bb 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,6 +5,7 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "z64quake.h" #include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" #include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" #include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" @@ -831,11 +832,11 @@ void func_80B81A80(Actor* thisx, PlayState* play) { func_80B81B84(this); } else if (this->unk_584 == 15) { - s16 sp26 = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(sp26, 0x7B30); - Quake_SetQuakeValues(sp26, 6, 0, 100, 0); - Quake_SetCountdown(sp26, 22); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, 6, 0, 100, 0); + Quake_SetCountdown(quakeIndex, 22); } } @@ -858,11 +859,11 @@ void func_80B81BA0(Actor* thisx, PlayState* play) { thisx->shape.rot.x += 0x1F4; if (!(this->unk_584 & 7)) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x7B30); - Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); - Quake_SetCountdown(quake, 15); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quakeIndex, 15); } if (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { @@ -928,11 +929,11 @@ void func_80B81DC8(Actor* thisx, PlayState* play) { ActorCutscene_Stop(this->dyna.actor.cutscene); func_80B818B4(this); } else if (this->unk_584 == 19) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, 5, 0, 40, 60); - Quake_SetCountdown(quake, 17); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 40, 60); + Quake_SetCountdown(quakeIndex, 17); } } 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 ec17965c6..b3da7b2bf 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 @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_shutter.h" +#include "z64quake.h" #include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -144,16 +145,17 @@ void func_80BD59F8(BgIkanaShutter* this) { void func_80BD5A18(BgIkanaShutter* this, PlayState* play) { s32 pad[2]; - s16 quake; + s16 quakeIndex; this->dyna.actor.velocity.y += -5.0f; this->dyna.actor.velocity.y *= 0.978f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(quake, 0x5420); - Quake_SetQuakeValues(quake, 4, 0, 0, 0); - Quake_SetCountdown(quake, 12); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + func_80BD5828(this); } } 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 0bc385cb7..017f9ef04 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 @@ -5,6 +5,7 @@ */ #include "z_bg_iknin_susceil.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" @@ -70,11 +71,12 @@ void func_80C0A838(BgIkninSusceil* this, PlayState* play) { void func_80C0A86C(BgIkninSusceil* this, PlayState* play, s16 verticalMag, s16 countdown, s32 arg4) { s32 pad; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); - Quake_SetSpeed(quake, 0x7B30); - Quake_SetQuakeValues(quake, verticalMag, 0, 0, 0); - Quake_SetCountdown(quake, countdown); if (arg4 == 1) { Rumble_Request(SQ(100.0f), 255, 20, 150); } else if (arg4 == 2) { 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 b54e7a583..22cf4968f 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,6 +6,7 @@ #include "z_bg_open_shutter.h" #include "objects/object_open_obj/object_open_obj.h" +#include "z64quake.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) @@ -105,7 +106,7 @@ void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { } void func_80ACAD88(BgOpenShutter* this, PlayState* play) { - s32 quake; + s32 doorDirection; if (this->unk_15C != 0) { Player* player = GET_PLAYER(play); @@ -118,10 +119,10 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play) { } else { Player* player = GET_PLAYER(play); - quake = func_80ACABA8(this, play); - if (quake > 0) { + doorDirection = func_80ACABA8(this, play); + if (doorDirection > 0) { player->doorType = 2; - player->doorDirection = quake; + player->doorDirection = doorDirection; player->doorActor = &this->dyna.actor; func_80122F28(player); } @@ -142,18 +143,21 @@ void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { s32 pad; - s16 quake; + s16 quakeIndex; Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); - quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); - Quake_SetSpeed(quake, -0x7F18); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + this->unk_15C = 0; this->actionFunc = func_80ACAD88; } 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 75f530c48..efb46a892 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -5,6 +5,7 @@ */ #include "z_boss_hakugin.h" +#include "z64quake.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) 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 65df579ce..b2ffe1dcb 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,7 @@ */ #include "z_door_shutter.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bdoor/object_bdoor.h" @@ -599,7 +600,7 @@ s32 func_808A1A70(DoorShutter* this) { } void func_808A1B48(DoorShutter* this, PlayState* play) { - s16 quake; + s16 quakeIndex; if (func_808A1A70(this)) { if (this->actor.velocity.y > 20.0f) { @@ -607,11 +608,14 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { Actor_SpawnFloorDustRing(play, &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(play, CAM_ID_MAIN), 3); - Quake_SetSpeed(quake, -32536); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, play); } } 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 88ddcd0f8..ec464815e 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -6,6 +6,7 @@ */ #include "z_en_ani.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -209,7 +210,7 @@ void EnAni_LandOnFoot(EnAni* this, PlayState* play) { void EnAni_FallToGround(EnAni* this, PlayState* play) { s32 pad; - s16 quakeValue; + s16 quakeIndex; if (this->actor.bgCheckFlags & 1) { // hit the ground this->actor.flags &= ~ACTOR_FLAG_10; @@ -219,10 +220,12 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) { // 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(play->cameraPtrs[CAM_ID_MAIN], 3); - Quake_SetSpeed(quakeValue, 0x6978); - Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); - Quake_SetCountdown(quakeValue, 0x14); + + quakeIndex = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 27000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); } 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 d24b2df49..bf6e46e36 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -5,6 +5,7 @@ */ #include "z_en_bigpamet.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -518,7 +519,7 @@ void func_80A28760(EnBigpamet* this) { } void func_80A287E8(EnBigpamet* this, PlayState* play) { - s16 quake; + s16 quakeIndex; this->actor.shape.rot.y += 0x3B00; func_800B9010(&this->actor, NA_SE_EN_B_PAMET_ROLL - SFX_FLAG); @@ -538,12 +539,16 @@ void func_80A287E8(EnBigpamet* this, PlayState* play) { } if (this->actor.bgCheckFlags & 8) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + this->actor.velocity.y = this->unk_29E * 0.375f; - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, 15, 0, 0, 0); - Quake_SetCountdown(quake, 10); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_80A27B58(this); func_80A27DD8(this, play); func_80A28970(this); 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 98212382b..e56997051 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -5,6 +5,7 @@ */ #include "z_en_bigslime.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" @@ -743,12 +744,14 @@ void EnBigslime_EndThrowMinislime(EnBigslime* this) { void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { s32 i; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 15); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 15, 0, 0, 0); - Quake_SetCountdown(quake, 15); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->gekkoCollider.base.acFlags &= ~(AC_ON | AC_HIT); 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 5fc1d4c70..2b855edab 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -5,6 +5,7 @@ */ #include "z_en_go.h" +#include "z64quake.h" #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/object_taisou/object_taisou.h" @@ -1045,16 +1046,16 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { return ret; } -void func_80A136B8(PlayState* play, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); +void func_80A136B8(PlayState* play, s16 speed, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); - Quake_SetCountdown(sp26, arg3); - Quake_SetSpeed(sp26, arg1); - Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); } void func_80A13728(EnGo* this, PlayState* play) { - func_80A136B8(play, 0x6C77, 7, 20); + func_80A136B8(play, 27767, 7, 20); play->actorCtx.unk2 = 4; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 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 df491dd22..1f173114d 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -5,6 +5,7 @@ */ #include "z_en_goroiwa.h" +#include "z64quake.h" #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -450,10 +451,11 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) { if (this->unk_1CA == 0) { if (this->actor.xzDistToPlayer < 400.0f) { - s16 sp72 = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(sp72, 0x4350); - Quake_SetQuakeValues(sp72, 3, 0, 0, 0); - Quake_SetCountdown(sp72, 7); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); } this->unk_1C4 = 0.0f; 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 26c5bbbbc..57c18ad7b 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -5,6 +5,7 @@ */ #include "z_en_ishi.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -594,11 +595,12 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { } if (sp70 == 1) { - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 0x4350); - Quake_SetQuakeValues(quake, 3, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } 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 4be8ad3c1..0582b7ca8 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -5,6 +5,7 @@ */ #include "z_en_pametfrog.h" +#include "z64quake.h" #include "z64rumble.h" #include "overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" @@ -1222,11 +1223,14 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) { // Zooms in on Snapper spawn point Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); - this->quake = Quake_Add(GET_ACTIVE_CAM(play), 6); - Quake_SetSpeed(this->quake, 18000); - Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); - Quake_SetCountdown(this->quake, 15); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + Quake_SetSpeed(this->quakeIndex, 18000); + Quake_SetQuakeValues(this->quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 15); + Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10); + this->timer = 40; this->actionFunc = EnPametfrog_SnapperSpawn; } @@ -1244,12 +1248,16 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { this->actor.params = GEKKO_GET_SNAPPER; - Quake_RemoveFromIdx(this->quake); - this->quake = Quake_Add(GET_ACTIVE_CAM(play), 3); - Quake_SetSpeed(this->quake, 20000); - Quake_SetQuakeValues(this->quake, 17, 0, 0, 0); - Quake_SetCountdown(this->quake, 12); + + Quake_Remove(this->quakeIndex); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(this->quakeIndex, 20000); + Quake_SetQuakeValues(this->quakeIndex, 17, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 12); + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); + this->actionFunc = EnPametfrog_TransitionGekkoSnapper; } 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 3f3e82165..81af17129 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -32,7 +32,7 @@ typedef struct EnPametfrog { /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; /* 0x2B2 */ s16 params; - /* 0x2B4 */ s16 quake; + /* 0x2B4 */ s16 quakeIndex; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; /* 0x2BA */ s16 subCamId; 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 ec412ce79..062422026 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 @@ -5,6 +5,7 @@ */ #include "z_en_stop_heishi.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) 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 c0f0a3e89..23dccca0f 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 "z64quake.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -396,7 +397,7 @@ void func_80A916F0(EnTest6* this, PlayState* play) { ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); Actor_MarkForDeath(&this->actor); } @@ -462,7 +463,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { } } func_80A90C08(0x78); - Distortion_SetType(0x20); + Distortion_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(80); play->unk_18844 = 1; this->unk_274 = 95; @@ -517,7 +518,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { if (this->unk_27A == 10) { this->unk_14C = 0.1f; func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); play->unk_18844 = 0; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); @@ -617,7 +618,7 @@ void func_80A92118(EnTest6* this, PlayState* play) { ActorCutscene_Stop(play->playerActorCsIds[8]); func_800B7298(play, NULL, 6); func_80A90C34(); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); Actor_MarkForDeath(&this->actor); } @@ -684,7 +685,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 115: func_80A90C08(0x14); - Distortion_SetType(0x20); + Distortion_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(90); this->unk_274 = 2; break; @@ -715,7 +716,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 14: case 15: func_80A90C08(0x32); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); this->unk_274 = 0; break; 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 769266e97..5fc5d6b31 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_chikuwa.h" +#include "z64quake.h" #include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -158,9 +159,9 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { ObjChikuwa* this = THIS; ObjChikuwaStruct* temp; f32 temp_fs0; - s16 var_s2; + s16 quakeVerticalMag; s32 i; - s32 quake; + s32 quakeIndex; this->unk_29E++; @@ -173,16 +174,16 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { func_809B17D0(play, this, &temp->unk_00); temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos); if (temp_fs0 < SQ(240.0f)) { - quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); if (temp_fs0 < SQ(120.0f)) { - var_s2 = 4; + quakeVerticalMag = 4; } else { - var_s2 = 3; + quakeVerticalMag = 3; } - Quake_SetSpeed(quake, 0x4350); - Quake_SetQuakeValues(quake, var_s2, 0, 0, 0); - Quake_SetCountdown(quake, 7); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); } } } 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 050207492..77b704a6c 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -5,6 +5,7 @@ */ #include "z_obj_dhouse.h" +#include "z64quake.h" #include "objects/object_dhouse/object_dhouse.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) @@ -454,23 +455,23 @@ void func_80B139D8(ObjDhouse* this) { void func_80B139F4(ObjDhouse* this, PlayState* play) { Camera* camera = GET_ACTIVE_CAM(play); - s16 quake; + s16 quakeIndex; 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); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 8, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 62); } this->unk_1370--; 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 c0537940c..467dfa8b8 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 "z64quake.h" #include "assets/objects/object_hariko/object_hariko.h" #define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) 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 19d35ffff..38f3164e3 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_hugebombiwa.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_bombiwa/object_bombiwa.h" @@ -292,13 +293,14 @@ void func_80A54600(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) { } } -void func_80A54980(ObjHugebombiwa* this, PlayState* play, s32 arg2) { +void ObjHugebombiwa_AddQuake(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, arg2, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } @@ -514,7 +516,7 @@ void func_80A55064(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A53E60(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); if ((play->gameplayFrames % 4) == 0) { - func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -610,7 +612,7 @@ void func_80A55564(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A54600(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); if ((play->gameplayFrames % 4) == 0) { - func_80A54980(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } 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 f7056b147..4668bfffd 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -5,6 +5,7 @@ */ #include "z_obj_lift.h" +#include "z64quake.h" #include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -125,17 +126,18 @@ void func_8093D760(ObjLift* this) { void func_8093D7A0(ObjLift* this, PlayState* play) { s32 pad; - s16 quake; + s16 quakeIndex; if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { if (this->timer <= 0) { if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { func_8093D9C0(this); } else { - quake = Quake_Add(GET_ACTIVE_CAM(play), 1); - Quake_SetSpeed(quake, 10000); - Quake_SetQuakeValues(quake, 2, 0, 0, 0); - Quake_SetCountdown(quake, 20); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); + Quake_SetSpeed(quakeIndex, 10000); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + func_8093D88C(this); } } 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 62cb40275..2c8e42c7d 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 @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_step.h" +#include "z64quake.h" #include "z64rumble.h" #include "objects/object_tokei_step/object_tokei_step.h" @@ -62,11 +63,12 @@ void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { void ObjTokeiStep_AddQuake(ObjTokeiStep* this, PlayState* play) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 1, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 1, 0, 0, 0); - Quake_SetCountdown(quake, 7); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e8a872802..681438463 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5,6 +5,7 @@ */ #include "global.h" +#include "z64quake.h" #include "z64rumble.h" #define THIS ((Player*)thisx) 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 9dab9c61a..bd8a40ed8 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 @@ -91,7 +91,7 @@ void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this) { BgCheck_EntityRaycastFloor2_1(play, &play->colCtx, &colPoly, &this->pos); speed = SurfaceType_GetConveyorSpeed(&play->colCtx, colPoly, BGCHECK_SCENE); - if ((speed != 0) && !SurfaceType_GetConveyorType(&play->colCtx, colPoly, BGCHECK_SCENE)) { + if ((speed != 0) && !SurfaceType_IsFloorConveyor(&play->colCtx, colPoly, BGCHECK_SCENE)) { direction = SurfaceType_GetConveyorDirection(&play->colCtx, colPoly, BGCHECK_SCENE) << 0xA; rVecAdjMax = sVecAdjMaximums[speed - 1]; this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4bcf89f80..3b949a49c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -859,8 +859,8 @@ 0x800BC5B8:("Actor_IsTargeted",), 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), - 0x800BC770:("func_800BC770",), - 0x800BC7D8:("func_800BC7D8",), + 0x800BC770:("Actor_AddQuake",), + 0x800BC7D8:("Actor_AddQuakeWithSpeed",), 0x800BC848:("func_800BC848",), 0x800BC8B8:("Actor_DrawDoorLock",), 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), @@ -1075,7 +1075,7 @@ 0x800C9CEC:("SurfaceType_IsHookshotSurface",), 0x800C9D14:("SurfaceType_IsIgnoredByEntities",), 0x800C9D50:("SurfaceType_IsIgnoredByProjectiles",), - 0x800C9D8C:("SurfaceType_GetConveyorType",), + 0x800C9D8C:("SurfaceType_IsFloorConveyor",), 0x800C9DDC:("func_800C9DDC",), 0x800C9E18:("SurfaceType_GetConveyorSpeed",), 0x800C9E40:("SurfaceType_GetConveyorDirection",), @@ -2282,15 +2282,15 @@ 0x8012A038:("PreNMI_Init",), 0x8012A080:("Quake_Random",), 0x8012A0AC:("Quake_UpdateShakeInfo",), - 0x8012A2B8:("Quake_Callback1",), - 0x8012A340:("Quake_Callback5",), - 0x8012A3B4:("Quake_Callback6",), - 0x8012A438:("Quake_Callback3",), - 0x8012A4D0:("Quake_Callback2",), - 0x8012A540:("Quake_Callback4",), + 0x8012A2B8:("Quake_CallbackType1",), + 0x8012A340:("Quake_CallbackType5",), + 0x8012A3B4:("Quake_CallbackType6",), + 0x8012A438:("Quake_CallbackType3",), + 0x8012A4D0:("Quake_CallbackType2",), + 0x8012A540:("Quake_CallbackType4",), 0x8012A5D8:("Quake_GetFreeIndex",), 0x8012A638:("Quake_AddImpl",), - 0x8012A6F0:("Quake_Remove",), + 0x8012A6F0:("Quake_RemoveRequest",), 0x8012A718:("Quake_GetRequest",), 0x8012A774:("Quake_SetValue",), 0x8012A8A8:("Quake_SetSpeed",), @@ -2300,7 +2300,7 @@ 0x8012A9E0:("Quake_SetQuakeValues2",), 0x8012AA48:("Quake_Init",), 0x8012AA9C:("Quake_Add",), - 0x8012AAC0:("Quake_RemoveFromIdx",), + 0x8012AAC0:("Quake_Remove",), 0x8012AB08:("Quake_Calc",), 0x8012AE68:("Distortion_Init",), 0x8012AEAC:("Distortion_SetCountdown",), @@ -10620,7 +10620,7 @@ 0x80A53E60:("func_80A53E60",), 0x80A541F4:("func_80A541F4",), 0x80A54600:("func_80A54600",), - 0x80A54980:("func_80A54980",), + 0x80A54980:("ObjHugebombiwa_AddQuake",), 0x80A54A0C:("func_80A54A0C",), 0x80A54AC0:("ObjHugebombiwa_Init",), 0x80A54BC4:("ObjHugebombiwa_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ff7987c6f..9e02cf981 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4015,7 +4015,7 @@ 0x801F59F4:("D_801F59F4","UNK_TYPE1","",0x1), 0x801F59F8:("D_801F59F8","UNK_TYPE1","",0x1), 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), - 0x801F5A90:("sDistortionContext","DistortionContext","",0xc), + 0x801F5A90:("sDistortionRequest","DistortionRequest","",0xc), 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), diff --git a/tools/namefixer.py b/tools/namefixer.py index f78717d40..b43287971 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -295,6 +295,7 @@ wordReplace = { "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", "func_800B90F4": "Actor_DeactivateLens", + "func_800BC770": "Actor_AddQuake", "zelda_malloc": "ZeldaArena_Malloc", "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", @@ -411,6 +412,7 @@ wordReplace = { "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", + "SurfaceType_GetConveyorType": "SurfaceType_IsFloorConveyor", "func_800C9704": "SurfaceType_GetBgCamIndex", "func_800C9924": "BgCheck_GetBgCamFuncData", "func_800C99AC": "SurfaceType_GetSceneExitIndex", @@ -422,7 +424,7 @@ wordReplace = { "func_800C9CEC": "SurfaceType_IsHookshotSurface", "func_800C9D14": "SurfaceType_IsIgnoredByEntities", "func_800C9D50": "SurfaceType_IsIgnoredByProjectiles", - "func_800C9D8C": "SurfaceType_GetConveyorType", + "func_800C9D8C": "SurfaceType_IsFloorConveyor", "func_800C9E18": "SurfaceType_GetConveyorSpeed", "func_800C9E40": "SurfaceType_GetConveyorDirection", "func_800C9E88": "SurfaceType_IsWallDamage", @@ -545,6 +547,7 @@ wordReplace = { "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", "func_8012F22C": "Inventory_GetSkullTokenCount", + "Quake_RemoveFromIdx": "Quake_Remove", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index dcb030e31..968fa65d3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -373,8 +373,8 @@ asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDir asm/non_matchings/code/z_actor/Actor_IsTargeted.s,Actor_IsTargeted,0x800BC5B8,0xD asm/non_matchings/code/z_actor/Actor_OtherIsTargeted.s,Actor_OtherIsTargeted,0x800BC5EC,0xD asm/non_matchings/code/z_actor/func_800BC620.s,func_800BC620,0x800BC620,0x54 -asm/non_matchings/code/z_actor/func_800BC770.s,func_800BC770,0x800BC770,0x1A -asm/non_matchings/code/z_actor/func_800BC7D8.s,func_800BC7D8,0x800BC7D8,0x1C +asm/non_matchings/code/z_actor/Actor_AddQuake.s,Actor_AddQuake,0x800BC770,0x1A +asm/non_matchings/code/z_actor/Actor_AddQuakeWithSpeed.s,Actor_AddQuakeWithSpeed,0x800BC7D8,0x1C asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C asm/non_matchings/code/z_actor/Actor_DrawDoorLock.s,Actor_DrawDoorLock,0x800BC8B8,0xA6 asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShieldParticlesMetal,0x800BCB50,0x8 @@ -589,7 +589,7 @@ asm/non_matchings/code/z_bgcheck/SurfaceType_GetEcho.s,SurfaceType_GetEcho,0x800 asm/non_matchings/code/z_bgcheck/SurfaceType_IsHookshotSurface.s,SurfaceType_IsHookshotSurface,0x800C9CEC,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByEntities.s,SurfaceType_IsIgnoredByEntities,0x800C9D14,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByProjectiles.s,SurfaceType_IsIgnoredByProjectiles,0x800C9D50,0xF -asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorType.s,SurfaceType_GetConveyorType,0x800C9D8C,0x14 +asm/non_matchings/code/z_bgcheck/SurfaceType_IsFloorConveyor.s,SurfaceType_IsFloorConveyor,0x800C9D8C,0x14 asm/non_matchings/code/z_bgcheck/func_800C9DDC.s,func_800C9DDC,0x800C9DDC,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorSpeed.s,SurfaceType_GetConveyorSpeed,0x800C9E18,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorDirection.s,SurfaceType_GetConveyorDirection,0x800C9E40,0x12 @@ -1796,15 +1796,15 @@ asm/non_matchings/code/z_prenmi/PreNMI_Destroy.s,PreNMI_Destroy,0x8012A02C,0x3 asm/non_matchings/code/z_prenmi/PreNMI_Init.s,PreNMI_Init,0x8012A038,0x12 asm/non_matchings/code/z_quake/Quake_Random.s,Quake_Random,0x8012A080,0xB asm/non_matchings/code/z_quake/Quake_UpdateShakeInfo.s,Quake_UpdateShakeInfo,0x8012A0AC,0x83 -asm/non_matchings/code/z_quake/Quake_Callback1.s,Quake_Callback1,0x8012A2B8,0x22 -asm/non_matchings/code/z_quake/Quake_Callback5.s,Quake_Callback5,0x8012A340,0x1D -asm/non_matchings/code/z_quake/Quake_Callback6.s,Quake_Callback6,0x8012A3B4,0x21 -asm/non_matchings/code/z_quake/Quake_Callback3.s,Quake_Callback3,0x8012A438,0x26 -asm/non_matchings/code/z_quake/Quake_Callback2.s,Quake_Callback2,0x8012A4D0,0x1C -asm/non_matchings/code/z_quake/Quake_Callback4.s,Quake_Callback4,0x8012A540,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType1.s,Quake_CallbackType1,0x8012A2B8,0x22 +asm/non_matchings/code/z_quake/Quake_CallbackType5.s,Quake_CallbackType5,0x8012A340,0x1D +asm/non_matchings/code/z_quake/Quake_CallbackType6.s,Quake_CallbackType6,0x8012A3B4,0x21 +asm/non_matchings/code/z_quake/Quake_CallbackType3.s,Quake_CallbackType3,0x8012A438,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType2.s,Quake_CallbackType2,0x8012A4D0,0x1C +asm/non_matchings/code/z_quake/Quake_CallbackType4.s,Quake_CallbackType4,0x8012A540,0x26 asm/non_matchings/code/z_quake/Quake_GetFreeIndex.s,Quake_GetFreeIndex,0x8012A5D8,0x18 asm/non_matchings/code/z_quake/Quake_AddImpl.s,Quake_AddImpl,0x8012A638,0x2E -asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012A6F0,0xA +asm/non_matchings/code/z_quake/Quake_RemoveRequest.s,Quake_RemoveRequest,0x8012A6F0,0xA asm/non_matchings/code/z_quake/Quake_GetRequest.s,Quake_GetRequest,0x8012A718,0x17 asm/non_matchings/code/z_quake/Quake_SetValue.s,Quake_SetValue,0x8012A774,0x4D asm/non_matchings/code/z_quake/Quake_SetSpeed.s,Quake_SetSpeed,0x8012A8A8,0x12 @@ -1814,7 +1814,7 @@ asm/non_matchings/code/z_quake/Quake_SetQuakeValues.s,Quake_SetQuakeValues,0x801 asm/non_matchings/code/z_quake/Quake_SetQuakeValues2.s,Quake_SetQuakeValues2,0x8012A9E0,0x1A asm/non_matchings/code/z_quake/Quake_Init.s,Quake_Init,0x8012AA48,0x15 asm/non_matchings/code/z_quake/Quake_Add.s,Quake_Add,0x8012AA9C,0x9 -asm/non_matchings/code/z_quake/Quake_RemoveFromIdx.s,Quake_RemoveFromIdx,0x8012AAC0,0x12 +asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012AAC0,0x12 asm/non_matchings/code/z_quake/Quake_Calc.s,Quake_Calc,0x8012AB08,0xD8 asm/non_matchings/code/z_quake/Distortion_Init.s,Distortion_Init,0x8012AE68,0x11 asm/non_matchings/code/z_quake/Distortion_SetCountdown.s,Distortion_SetCountdown,0x8012AEAC,0xA From 4935ec7ba1f5c25d44f956174be058a150196d25 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 30 Sep 2022 19:34:28 -0700 Subject: [PATCH 62/73] Rename SetupIndex to Layer (#1099) * Rename setupIndex to Layer * () --- include/functions.h | 2 +- include/z64save.h | 2 +- include/z64scene.h | 2 +- src/code/z_demo.c | 12 +++--- src/code/z_parameter.c | 4 +- src/code/z_scene.c | 4 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 2 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 26 ++++++------- .../actors/ovl_Dm_Char01/z_dm_char01.c | 8 ++-- .../actors/ovl_Dm_Char05/z_dm_char05.c | 6 +-- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 38 +++++++++---------- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 6 +-- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 7 ++-- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 2 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 +-- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 6 +-- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 4 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +- .../z_en_horse_link_child.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 3 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 2 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 3 +- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 2 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 3 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 22 ++++------- .../gamestates/ovl_opening/z_opening.c | 2 +- tools/disasm/functions.txt | 2 +- tools/namefixer.py | 4 +- tools/sizes/code_functions.csv | 2 +- 38 files changed, 99 insertions(+), 107 deletions(-) diff --git a/include/functions.h b/include/functions.h index b19b75af9..99e030cde 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1356,7 +1356,7 @@ void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex); void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex); -s32 Cutscene_GetSceneSetupIndex(PlayState* play); +s32 Cutscene_GetSceneLayer(PlayState* play); s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd); s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd); u8 Cutscene_IsPlaying(PlayState* play); diff --git a/include/z64save.h b/include/z64save.h index 74cf31c8e..c35747972 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -304,7 +304,7 @@ typedef struct SaveContext { /* 0x3CA6 */ u8 unk_3CA6; /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CAC */ s32 sceneLayer; // "counter" /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" diff --git a/include/z64scene.h b/include/z64scene.h index 18d7b81f9..9658c4f4d 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -767,7 +767,7 @@ typedef enum { /* * 0xFE00: Index into sSceneEntranceTable (Scene) * 0x01F0: Index into the scenes specific entrance table (Spawn) -* 0x000F: Index into the specific entrance table (Layer), stored seperately in sceneSetupIndex +* 0x000F: Index into the specific entrance table (Layer), stored seperately in sceneLayer */ #define ENTRANCE(scene, spawn) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4)) diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 7dd357fbd..6c83e8391 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1497,7 +1497,7 @@ void func_800EDBE0(PlayState* play) { sp24 = play->loadedScene; if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + - ((void)0, gSaveContext.sceneSetupIndex)) & + ((void)0, gSaveContext.sceneLayer)) & 0x4000) != 0) { func_80151A68(play, sp24->titleTextId); } @@ -1608,13 +1608,13 @@ void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 ac actor->shape.rot.y = actor->world.rot.y; } -s32 Cutscene_GetSceneSetupIndex(PlayState* play) { - s32 sceneSetupIndex = 0; +s32 Cutscene_GetSceneLayer(PlayState* play) { + s32 sceneLayer = 0; - if (gSaveContext.sceneSetupIndex > 0) { - sceneSetupIndex = gSaveContext.sceneSetupIndex; + if (gSaveContext.sceneLayer > 0) { + sceneLayer = gSaveContext.sceneLayer; } - return sceneSetupIndex; + return sceneLayer; } s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index eb110c0c7..3a2da402c 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2264,7 +2264,7 @@ void Magic_Update(PlayState* play) { // Add magic until magicFillTarget is reached gSaveContext.save.playerData.magic += 0x10; - if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneSetupIndex < 4)) { + if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneLayer < 4)) { play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); } @@ -2863,7 +2863,7 @@ void Interface_DrawTimers(PlayState* play) { if (sTimerId == TIMER_ID_MOON_CRASH) { gSaveContext.save.day = 4; - if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneSetupIndex == 3)) { + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 3)) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index ce5ddf769..7b88d4520 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -455,9 +455,9 @@ void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; - if (gSaveContext.sceneSetupIndex != 0) { + if (gSaveContext.sceneLayer != 0) { altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); - altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; + altHeader = altHeaderList[gSaveContext.sceneLayer - 1]; if (altHeader != NULL) { Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader)); 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 81397039d..c0e9bdc42 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,7 +131,7 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((play->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 4) && + if ((play->csCtx.state != 0) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } 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 cd130e218..82e5157f6 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -451,13 +451,13 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { if (play->csCtx.state != 0) { switch (play->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { func_80AA561C(this, play); } break; case SCENE_OPENINGDAN: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { func_80AA5720(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -469,7 +469,7 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_OKUJOU: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { func_80AA58CC(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -477,7 +477,7 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { } else if (play->csCtx.currentCsIndex == 2) { func_80AA5960(this, play); } - } else if (gSaveContext.sceneSetupIndex == 2) { + } else if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { func_80AA59E4(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -487,13 +487,13 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_00KEIKOKU: - if (gSaveContext.sceneSetupIndex == 3) { + if (gSaveContext.sceneLayer == 3) { if (play->csCtx.currentCsIndex == 0) { func_80AA5AF4(this, play); } else if (play->csCtx.currentCsIndex == 2) { func_80AA5E2C(this, play); } - } else if (gSaveContext.sceneSetupIndex == 7) { + } else if (gSaveContext.sceneLayer == 7) { if (play->csCtx.currentCsIndex == 0) { func_80AA5BF8(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -503,19 +503,19 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { break; case SCENE_MITURIN: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { func_80AA5DC8(this, play); } break; case SCENE_INSIDETOWER: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { func_80AA5D10(this, play); } break; case SCENE_PIRATE: - if ((gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { func_80AA5D6C(this, play); } break; @@ -853,7 +853,7 @@ void func_80AA62FC(DmChar00* this, PlayState* play) { void func_80AA67F8(DmChar00* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state == 0) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { if (this->unk_261 != 42) { this->unk_261 = 42; func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); @@ -914,9 +914,9 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { s32 pad; Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); - if ((play->csCtx.state == 0) && ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || - (play->roomCtx.curRoom.num != 0) || (play->csCtx.currentCsIndex != 1) || - (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + if ((play->csCtx.state == 0) && + ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneLayer != 0) || (play->roomCtx.curRoom.num != 0) || + (play->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 900530f4d..2f715afed 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -73,7 +73,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { break; } - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { play->envCtx.unk_1F = 5; play->envCtx.unk_20 = 5; } @@ -87,7 +87,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryPoisonWaterDamageCol); this->unk_34D = true; - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { this->unk_34C = 1; this->actionFunc = func_80AA8C28; } else { @@ -97,7 +97,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { break; case DMCHAR01_1: - if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneLayer == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -411,7 +411,7 @@ void DmChar01_Draw(Actor* thisx, PlayState* play) { break; case 1: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWoodfallSceneryPurifiedWaterTexAnim)); Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); 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 c0cb24281..5b6613813 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -545,7 +545,7 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { if (play->sceneId == SCENE_OKUJOU) { - if (gSaveContext.sceneSetupIndex == 2) { + if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { func_80AAD3F8(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -553,11 +553,11 @@ void func_80AAD4A8(DmChar05* this, PlayState* play) { } } } else if (play->sceneId == SCENE_SPOT00) { - if (gSaveContext.sceneSetupIndex == 9) { + if (gSaveContext.sceneLayer == 9) { if ((play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 255)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } - } else if ((gSaveContext.sceneSetupIndex == 0xB) && (play->csCtx.frames == 115)) { + } else if ((gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 115)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); } } 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 910293b77..7a4142971 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -95,7 +95,7 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; this->actionFunc(this, play); - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0) && (play->csCtx.frames == 480)) { // This actor is responsible for playing the fairy sound during the exposition in the intro, // during the transition to Lost Woods, before Ocarina gets stolen. func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); 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 9a0f95004..2be56dda3 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -919,23 +919,23 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { if (play->csCtx.state != 0) { switch (play->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); - } else if (gSaveContext.sceneSetupIndex == 0) { + } else if (gSaveContext.sceneLayer == 0) { DmStk_PlaySfxForIntroCutsceneSecondPart(this, play); - } else if ((gSaveContext.sceneSetupIndex == 2) && (play->csCtx.currentCsIndex == 0)) { + } else if ((gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, play); } break; case SCENE_CLOCKTOWER: - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { DmStk_PlaySfxForTitleCutscene(this, play); } break; case SCENE_OPENINGDAN: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForCurseCutsceneFirstPart(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -945,7 +945,7 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { break; case SCENE_OKUJOU: - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -955,7 +955,7 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { } else if (play->csCtx.currentCsIndex == 3) { DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, play); } - } else if (gSaveContext.sceneSetupIndex == 2) { + } else if (gSaveContext.sceneLayer == 2) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -965,13 +965,13 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { break; case SCENE_00KEIKOKU: - if (gSaveContext.sceneSetupIndex == 3) { + if (gSaveContext.sceneLayer == 3) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForShiveringInRainCutscene(this, play); } else if (play->csCtx.currentCsIndex == 2) { DmStk_PlaySfxForPlayingWithFairiesCutscene(this, play); } - } else if (gSaveContext.sceneSetupIndex == 7) { + } else if (gSaveContext.sceneLayer == 7) { if (play->csCtx.currentCsIndex == 0) { DmStk_PlaySfxForEndingCutsceneFirstPart(this, play); } else if (play->csCtx.currentCsIndex == 1) { @@ -1028,7 +1028,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->fogG = play->lightCtx.unk8; this->fogB = play->lightCtx.unk9; - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { this->alpha = 0; this->fogN = 0; this->fogF = 1000; @@ -1044,7 +1044,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_ROOFTOP, 0)) { - if (gSaveContext.sceneSetupIndex == 0) { + if (gSaveContext.sceneLayer == 0) { if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // Starts a 5 minute (300 second) timer until the moon falls. Interface_StartTimer(TIMER_ID_MOON_CRASH, 300); @@ -1060,7 +1060,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion2; } - } else if (gSaveContext.sceneSetupIndex == 3) { + } else if (gSaveContext.sceneLayer == 3) { this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { // This code is called when the Giants fail to stop the moon. @@ -1088,7 +1088,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 0)) { + } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0)) { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { Actor_MarkForDeath(&this->actor); } @@ -1127,7 +1127,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1684,7 +1684,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; } else if (((this->animIndex >= SK_ANIM_HUDDLE_WITH_FAIRIES) && (this->animIndex <= SK_ANIM_DRAW)) || ((this->animIndex >= SK_ANIM_PLAY_FLUTE) && (this->animIndex <= SK_ANIM_CARTWHEEL)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7))) { this->maskType = SK_MASK_TYPE_NO_MASK; if ((this->animIndex == SK_ANIM_HOLD_UP_MASK_START) || (this->animIndex == SK_ANIM_HOLD_UP_MASK_LOOP)) { this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; @@ -1823,7 +1823,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1886,7 +1886,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_MASK_TYPE_NORMAL: - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1) && (play->csCtx.frames < 1400)) { if (this->fogN == this->fogF) { this->fogF = this->fogN; @@ -1948,7 +1948,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot case SK_HAND_TYPE_HOLDING_OCARINA: gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); - if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { + if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; @@ -1986,7 +1986,7 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot break; case SK_HAND_TYPE_HOLDING_OCARINA: - if ((play->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { + if ((play->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneLayer != 1)) { gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); 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 008674292..50a027efa 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -448,7 +448,7 @@ void func_80A52074(EnDnk* this, PlayState* play) { void func_80A52134(EnDnk* this, PlayState* play) { if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && - (gSaveContext.sceneSetupIndex == 2)) { + (gSaveContext.sceneLayer == 2)) { func_80A52074(this, play); } } 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 f55137367..c9b393980 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -903,14 +903,14 @@ void func_8088E850(EnElf* this, PlayState* play) { func_8088D660(this, &nextPos, 0.2f); } - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && ((play->csCtx.frames == 149) || (play->csCtx.frames == 381) || (play->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } - if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (play->csCtx.currentCsIndex == 4) && (play->csCtx.frames == 95)) { + if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 4) && + (play->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { 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 54ea52a45..d7d3e446e 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -315,8 +315,7 @@ void EnFall_Setup(EnFall* this, PlayState* play) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { static s32 sGiantsCutsceneState = 0; - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 1) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { switch (sGiantsCutsceneState) { case 0: if (play->csCtx.state != 0) { @@ -409,7 +408,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } } - if (play->sceneId == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 2)) { switch (play->csCtx.currentCsIndex) { case 0: switch (play->csCtx.frames) { @@ -575,7 +574,7 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (play->sceneId == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 2) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 2)) { play->skyboxCtx.rotY -= 0.05f; } 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 7021b0e0c..7d2819ff9 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -220,7 +220,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { this->sfxId = 0xFFFF; if (GIANT_TYPE_IS_CHAMBER_OR_ENDING(type)) { - switch (gSaveContext.sceneSetupIndex) { + switch (gSaveContext.sceneLayer) { case 0: case 10: this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE2 - SFX_FLAG; 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 b10f78ac3..c85815ee7 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -762,7 +762,7 @@ s32 func_8094EFC4(EnGm* this, PlayState* play) { if (play->csCtx.state != 0) { if (this->unk_3F8 == 0) { - if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneSetupIndex == 2)) { + if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneLayer == 2)) { func_8094E054(this, play, 0); this->unk_258 = 255; } 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 2b855edab..8692fbba1 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -539,7 +539,7 @@ s32 func_80A1222C(EnGo* this, PlayState* play) { (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || (!(gSaveContext.save.weekEventReg[22] & 4) && (play->sceneId == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { + (gSaveContext.sceneLayer == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -711,7 +711,7 @@ s32 func_80A12868(EnGo* this, PlayState* play) { s32 func_80A12954(EnGo* this, PlayState* play) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != 0) && (this->actor.draw != NULL) && - (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; @@ -1412,7 +1412,7 @@ void func_80A144F4(EnGo* this, PlayState* play) { void func_80A145AC(EnGo* this, PlayState* play) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && - (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) || !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, play); 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 cf32db0bc..f9085e825 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -323,15 +323,15 @@ void func_80B23910(EnHanabi* this, PlayState* play) { } void func_80B23934(EnHanabi* this, PlayState* play) { - if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneSetupIndex == 7)) { + if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneLayer == 7)) { if (play->csCtx.frames > 1650) { func_80B236C8(this, play); func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && - (play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 610)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0) && + (play->csCtx.frames == 610)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); } } 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 83e0935f5..07b256487 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -158,8 +158,8 @@ void func_80BCF398(EnHg* this, PlayState* play) { !Cutscene_CheckActorAction(play, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && play->csCtx.currentCsIndex == 0) && - (play->csCtx.frames == 20 || play->csCtx.frames == 60)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && + ((play->csCtx.frames == 20) || (play->csCtx.frames == 60))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } 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 83fbe5988..53e4e91c3 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -287,7 +287,7 @@ s32 func_80BD0898(EnHgo* this, PlayState* play) { case 1: if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { this->unk_312 = 1; - if ((gSaveContext.sceneSetupIndex == 0) && + if ((gSaveContext.sceneLayer == 0) && ((play->csCtx.currentCsIndex == 2) || (play->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } 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 4388c7c73..a9b233aa5 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -793,7 +793,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { } if (((play->sceneId == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || - ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneSetupIndex(play))) { + ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && Cutscene_GetSceneLayer(play))) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -1569,7 +1569,7 @@ void EnHorse_Stopping(EnHorse* this, PlayState* play) { 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.entrance != ENTRANCE(ROMANI_RANCH, 0)) || !Cutscene_GetSceneSetupIndex(play))) { + ((gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0)) || !Cutscene_GetSceneLayer(play))) { if (this->stateFlags & ENHORSE_DRAW) { if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); 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 398bac6ca..d5b23bdae 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 @@ -158,7 +158,7 @@ void EnHorseLinkChild_Init(Actor* thisx, PlayState* play) { this->unk_1E8 = 0; this->unk_1E4 = 0; - if (gSaveContext.sceneSetupIndex >= 4) { + if (gSaveContext.sceneLayer >= 4) { func_808DEFE8(this); } else { func_808DEFE8(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 b7ad5c9dd..60ebb2474 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -948,8 +948,7 @@ void EnJg_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0)) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animIndex = EN_JG_ANIM_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; 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 47f0997eb..0860857c8 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -207,7 +207,7 @@ void EnMa4_Init(Actor* thisx, PlayState* play) { this->hasBow = false; } - if (Cutscene_GetSceneSetupIndex(play) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneLayer(play) != 0) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; EnMa4_InitHorsebackGame(this, play); 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 da72fc308..b7199cb1d 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -393,7 +393,7 @@ void EnMag_Update(Actor* thisx, PlayState* play) { play->transitionType = TRANS_TYPE_02; play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.cutscene = 0; - gSaveContext.sceneSetupIndex = 0; + gSaveContext.sceneLayer = 0; } this->unk11F54 = 15; this->unk11F56 = 25; 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 fd3146032..1f9cb3da8 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -731,7 +731,7 @@ void func_80AD16A8(EnOsn* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); } - if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } 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 75bcbc8e8..1f5aebe64 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1017,7 +1017,7 @@ s32 func_80AF86F0(EnPm* this, PlayState* play) { s32 func_80AF87C4(EnPm* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 9) && + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 9) && (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); 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 088e06149..bfb701484 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,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { this->unk_3F8 = 0; } - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } 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 ea4f7be32..d0c02e4fa 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,7 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } 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 bda36c0b6..0ea1d448f 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -206,8 +206,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || - (play->sceneId != SCENE_30GYOSON))) { + ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneLayer != 0) || (play->sceneId != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; } 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 7758fc5bc..33de74100 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 @@ -36,7 +36,7 @@ void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(play, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); - if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && (play->csCtx.currentCsIndex == 0)) { + if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7)) && (play->csCtx.currentCsIndex == 0)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); } else if ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_10YUKIYAMANOMURA)) { 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 2c8e42c7d..6d4923043 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 @@ -195,8 +195,7 @@ void ObjTokeiStep_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(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 34d43d354..421f5dcf0 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -121,10 +121,8 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, PlayState* play) { this->opaDList = gClockTowerExteriorGearDL; ObjTokeidai_SetupClockOrExteriorGear(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -140,10 +138,8 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_Clock_Init(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } 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; @@ -175,10 +171,8 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, PlayState* play) { this->spotlightIntensity = 0; } - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -448,9 +442,9 @@ void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { if (Cutscene_CheckActorAction(play, 132) != 0 && play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { gSaveContext.save.weekEventReg[8] |= 0x40; - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); gSaveContext.save.cutscene = 0; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index b7e5ec378..42336b9bc 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -17,7 +17,7 @@ void TitleSetup_SetupTitleScreen(TitleSetupState* this) { gSaveContext.save.entrance = sOpeningEntrances[D_801BB12C]; gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = sOpeningCutscenes[D_801BB12C]; - gSaveContext.sceneSetupIndex = 0; + gSaveContext.sceneLayer = 0; gSaveContext.save.time = CLOCK_TIME(8, 0); gSaveContext.save.day = 1; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3b949a49c..b71390a05 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1578,7 +1578,7 @@ 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), - 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE1D8:("Cutscene_GetSceneLayer",), 0x800EE200:("Cutscene_GetActorActionIndex",), 0x800EE29C:("Cutscene_CheckActorAction",), 0x800EE2F4:("Cutscene_IsPlaying",), diff --git a/tools/namefixer.py b/tools/namefixer.py index b43287971..a5d13493b 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -533,10 +533,11 @@ wordReplace = { "func_800EDF24": "Cutscene_ActorTranslateAndYaw", "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", - "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE1D8": "Cutscene_GetSceneLayer", "func_800EE200": "Cutscene_GetActorActionIndex", "func_800EE29C": "Cutscene_CheckActorAction", "func_800EE2F4": "Cutscene_IsPlaying", + "Cutscene_GetSceneSetupIndex": "Cutscene_GetSceneLayer", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_80114E90": "Inventory_HasEmptyBottle", @@ -704,6 +705,7 @@ wordReplace = { "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "gSaveContext.sceneSetupIndex": "gSaveContext.sceneLayer", "gSaveContext.seqIndex": "gSaveContext.seqId", "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 968fa65d3..33b82cef0 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1092,7 +1092,7 @@ asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate, 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_GetSceneLayer.s,Cutscene_GetSceneLayer,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 From bbc8aec36a6359025892dc2c4d477c5aa6554c3d Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 30 Sep 2022 19:55:05 -0700 Subject: [PATCH 63/73] (Mostly) document EnSyatekiDekunuts (Shooting Gallery Deku Scrub) (#1095) * (Mostly) document EnSyatekiDekunuts (Shooting Gallery Deku Scrub) * Respond to Elliptic's review --- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 10 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.h | 4 +- .../z_en_syateki_dekunuts.c | 358 ++++++++++-------- .../z_en_syateki_dekunuts.h | 33 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 27 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 6 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.h | 4 +- tools/disasm/functions.txt | 34 +- tools/disasm/variables.txt | 18 +- 9 files changed, 280 insertions(+), 214 deletions(-) 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 6b05f739d..f3bce9c4f 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,7 +83,7 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_CROW_GET_NUMBER(&this->actor); i++) { + for (i = 0; i < EN_SYATEKI_CROW_GET_INDEX(&this->actor); i++) { path = &play->setupPathList[path->unk1]; } @@ -95,7 +95,7 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { this->collider.elements[0].dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); - if ((path == NULL) || (EN_SYATEKI_CROW_GET_NUMBER(&this->actor) >= 0x80)) { + if ((path == NULL) || (EN_SYATEKI_CROW_GET_INDEX(&this->actor) >= 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -133,7 +133,7 @@ void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true) && - (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)))) { + (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)))) { EnSyatekiCrow_SetupWaitToMove(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { this->isActive = true; @@ -202,7 +202,7 @@ void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { this->currentPointIndex++; } else { this->isActive = false; - syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); EnSyatekiCrow_SetupWaitForSpawn(this); } @@ -241,7 +241,7 @@ void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { if (this->deathTimer > 20) { func_800B3030(play, &this->actor.world.pos, &sZeroVec, &sZeroVec, this->actor.scale.x * 10000.0f, 0, 0); syatekiMan->guayHitCounter++; - syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_NUMBER(&this->actor)); + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); EnSyatekiCrow_SetupWaitForSpawn(this); } 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 e70a3dd21..f7a876285 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 @@ -6,8 +6,8 @@ #define EN_SYATEKI_CROW_GET_WAIT_MOD(thisx) ((thisx)->params & 0xF) #define EN_SYATEKI_CROW_GET_SPEED_MOD(thisx) (((thisx)->params & 0xF0) >> 4) -#define EN_SYATEKI_CROW_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_CROW_PARAMS(number, speedMod, waitMod) (((number << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) +#define EN_SYATEKI_CROW_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_CROW_PARAMS(index, speedMod, waitMod) (((index << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) struct EnSyatekiCrow; 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 5a2503808..5e6f5925a 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 @@ -17,22 +17,27 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play); -void func_80A2BE54(EnSyatekiDekunuts* this); -void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2BFC4(EnSyatekiDekunuts* this); -void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C150(EnSyatekiDekunuts* this); -void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C1AC(EnSyatekiDekunuts* this); -void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C27C(EnSyatekiDekunuts* this); -void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C3AC(EnSyatekiDekunuts* this); -void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C478(EnSyatekiDekunuts* this); -void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play); -void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play); + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL, + /* 1 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP, +} EnSyatekiDekunutsHeaddressType; const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, @@ -66,7 +71,17 @@ static ColliderCylinderInit sCylinderInit = { { 48, 80, 0, { 0, 0, 0 } }, }; -static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; +static Cylinder16 sBonusDekuScrubColliderDimensions[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_ANIM_UP, + /* 1 */ EN_SYATEKI_DEKUNUTS_ANIM_BURROW, + /* 2 */ EN_SYATEKI_DEKUNUTS_ANIM_IDLE, // unused + /* 3 */ EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND, + /* 4 */ EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE, + /* 5 */ EN_SYATEKI_DEKUNUTS_ANIM_DIE, + /* 6 */ EN_SYATEKI_DEKUNUTS_ANIM_UNBURROW, // unused +} EnSyatekiDekunutsAnimation; static AnimationInfo sAnimationInfo[] = { { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, @@ -85,10 +100,10 @@ static InitChainEntry sInitChain[] = { }; void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { - static s32 D_80A2CB9C = 1; + static s32 sDrawFlowers = true; // This makes it so only one EnSyatekiDekunuts draws all the flowers. EnSyatekiDekunuts* this = THIS; PlayState* play = play2; - s32 phi_v0; + s32 unkPathComparison; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; s32 i; @@ -97,16 +112,16 @@ void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { Actor_SetScale(&this->actor, 0.01f); - this->collider.dim = D_80A2CADC[0]; - phi_v0 = 3; + this->collider.dim = sBonusDekuScrubColliderDimensions[0]; + unkPathComparison = 3; } else { Actor_SetScale(&this->actor, 0.02f); - phi_v0 = 1; + unkPathComparison = 1; } - while (path->unk2 != phi_v0) { + while (path->unk2 != unkPathComparison) { path = &play->setupPathList[path->unk1]; } @@ -114,29 +129,30 @@ void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { path = &play->setupPathList[path->unk1]; } - if (D_80A2CB9C == 1) { - this->unk_1EC = 1; - D_80A2CB9C = 0; + if (sDrawFlowers == true) { + this->shouldDrawFlowers = true; + sDrawFlowers = false; } else { - this->unk_1EC = 0; + this->shouldDrawFlowers = false; } Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, this->morphTable, DEKU_SCRUB_LIMB_MAX); + if (path == NULL) { Actor_MarkForDeath(&this->actor); return; } - this->unk_1E4 = Lib_SegmentedToVirtual(path->points); - this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_NUMBER(&this->actor); - this->unk_1EA = path->count; - this->unk_1D8 = 0; + this->flowerPos = Lib_SegmentedToVirtual(path->points); + this->index = EN_SYATEKI_DEKUNUTS_GET_INDEX(&this->actor); + this->flowerCount = path->count; + this->timer = 0; this->unk_1DC = 0; - this->unk_1DA = 0; - func_80A2BE54(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitForSpawn(this); } void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { @@ -145,7 +161,7 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80A2BE54(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; @@ -153,218 +169,252 @@ void func_80A2BE54(EnSyatekiDekunuts* this) { this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; - this->unk_1D8 = 0; + this->timer = 0; this->unk_1DC = 0; - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->unk_1E2 = 1; + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->isAlive = true; } - this->actionFunc = func_80A2BF18; + this->actionFunc = EnSyatekiDekunuts_WaitForSpawn; } -void func_80A2BF18(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits until the shooting gallery man sets the appropriate Deku Scrub flag to spawn. + */ +void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_1E2 == 1) && - ((syatekiMan->dekuScrubFlags & (1 << this->unk_1E8)) != 0)) { - func_80A2BFC4(this); + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isAlive == true) && + (syatekiMan->dekuScrubFlags & (1 << this->index))) { + EnSyatekiDekunuts_SetupSpawn(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - this->unk_1E2 = 1; + this->isAlive = true; } - if ((syatekiMan->dekuScrubFlags == 0) && (syatekiMan->guayFlags == 0) && - (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { - this->unk_1E2 = 1; + if (!syatekiMan->dekuScrubFlags && !syatekiMan->guayFlags && + (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS)) { + this->isAlive = true; } } -void func_80A2BFC4(EnSyatekiDekunuts* this) { - Vec3f sp14; +/** + * Positions the Deku Scrub to match up with its flower, then sets it up to start waiting. + */ +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this) { + Vec3f pos; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - 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->timer = 0; + pos.x = this->flowerPos[this->index].x; + pos.y = this->flowerPos[this->index].y; + pos.z = this->flowerPos[this->index].z; + this->actor.world.pos = this->actor.prevPos = pos; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - this->unk_1EE = 140 - (syatekiMan->currentWave * 20); + this->timeToBurrow = 140 - (syatekiMan->currentWave * 20); - if ((syatekiMan->currentWave & 1) != 0) { - this->unk_1F0 = 1; - this->unk_1F2 = 0; + if ((syatekiMan->currentWave % 2) != 0) { + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP; + this->headdressRotZ = 0; } else { - this->unk_1F0 = 0; + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL; } - this->actionFunc = func_80A2C0F8; + this->actionFunc = EnSyatekiDekunuts_Spawn; } -void func_80A2C0F8(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits 20 frames, then plays a sound and starts the process of making the Deku Scrubs emerge. + */ +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan; - if (this->unk_1DA > 20) { + if (this->waitTimer > 20) { syatekiMan = (EnSyatekiMan*)this->actor.parent; Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); - this->unk_1DA = 0; - func_80A2C150(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C150(EnSyatekiDekunuts* this) { - this->unk_1D8 = 0; - this->actionFunc = func_80A2C168; +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this) { + this->timer = 0; + this->actionFunc = EnSyatekiDekunuts_WaitToEmerge; } -void func_80A2C168(EnSyatekiDekunuts* this, PlayState* play) { - if (this->unk_1DA > 20) { - func_80A2C1AC(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then makes the Deku Scrubs emerge from underground. + */ +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupEmerge(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C1AC(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_UP); this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = func_80A2C208; + this->actionFunc = EnSyatekiDekunuts_Emerge; } -void func_80A2C208(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Waits until the animation for coming out of the ground is done playing, then makes the + * Deku Scrubs look around. If the headdress should be flipped up, then this will also + * adjust the headdress's rotation. + */ +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A2C27C(this); + EnSyatekiDekunuts_SetupLookAround(this); } - if (this->unk_1F0 == 1) { - Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + if (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP) { + Math_SmoothStepToS(&this->headdressRotZ, -0x8000, 5, 0x1000, 0x100); } - this->unk_1D8++; + this->timer++; } -void func_80A2C27C(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->actionFunc = func_80A2C2E0; +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->actionFunc = EnSyatekiDekunuts_LookAround; } else { - this->actionFunc = func_80A2C33C; + this->actionFunc = EnSyatekiDekunuts_BonusLookAround; } } -void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Looks around back and forth until the timer reaches the time to burrow or until the game ends. + * No matter which occurs, the Deku Scrubs burrow underground afterwards. + */ +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { - func_80A2C3AC(this); + if ((this->timeToBurrow < this->timer) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { + EnSyatekiDekunuts_SetupBurrow(this); } - this->unk_1D8++; + this->timer++; } -void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Looks around back and forth until the game ends, then burrow underground afterwards. + */ +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + // There are some cases where the minigame timer can reach 0, but the shooting game state is + // still SG_GAME_STATE_RUNNING. This check just makes absolutely sure that once the game is + // over, these Deku Scrubs will burrow. if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] <= SECONDS_TO_TIMER(0)) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { - func_80A2C3AC(this); + EnSyatekiDekunuts_SetupBurrow(this); } - if (this->unk_1D8 < 11) { - this->unk_1D8++; + if (this->timer <= 10) { + this->timer++; } } -void func_80A2C3AC(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); - this->actionFunc = func_80A2C3F0; +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_BURROW); + this->actionFunc = EnSyatekiDekunuts_Burrow; } -void func_80A2C3F0(EnSyatekiDekunuts* this, PlayState* play) { +/** + * Burrow underground. After 160 frames have passed since the Deku Scrub first emerged *and* + * after the burrowing animation is complete, this sets up the Deku Scrub to emerge again. + */ +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) { - if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_1D8 = 0; - func_80A2C150(this); + if ((this->timer > 160) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->timer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1D8++; + this->timer++; } } else { - func_80A2C478(this); + EnSyatekiDekunuts_SetupGameEnd(this); } } -void func_80A2C478(EnSyatekiDekunuts* this) { - this->actionFunc = func_80A2C48C; +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this) { + this->actionFunc = EnSyatekiDekunuts_GameEnd; } -void func_80A2C48C(EnSyatekiDekunuts* this, PlayState* play) { - if (this->unk_1DA > 20) { - func_80A2BE54(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then resets the Deku Scrub back to its initial state. + */ +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupWaitForSpawn(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C4D0(EnSyatekiDekunuts* this, PlayState* play) { - static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; - static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; +void EnSyatekiDekunuts_SetupDead(EnSyatekiDekunuts* this, PlayState* play) { + static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 2); syatekiMan->score += 100; syatekiMan->perGameVar2.bonusDekuScrubHitCounter++; } else { - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 0); syatekiMan->score += 30; syatekiMan->dekuScrubHitCounter++; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); - this->unk_1E2 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); - this->unk_1D8 = 160; - this->actionFunc = func_80A2C5DC; + this->isAlive = false; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE); + this->timer = 160; + this->actionFunc = EnSyatekiDekunuts_Dead; } -void func_80A2C5DC(EnSyatekiDekunuts* this, PlayState* play) { - static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; - static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play) { + static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEnvColor = { 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, sAnimationInfo, 5); + if (this->timer == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DIE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); - this->unk_1D8--; - } else if (this->unk_1D8 < 160) { - Vec3f sp40; + this->timer--; + } else if (this->timer < 160) { + Vec3f pos; - 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(play, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 18.0f; + pos.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(play, &pos, &gZeroVec3f, &gZeroVec3f, &sPrimColor, &sEnvColor, 200, 0, 13); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); - sp40.y = this->actor.world.pos.y + 10.0f; - EffectSsHahen_SpawnBurst(play, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + pos.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(play, &pos, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - syatekiMan->dekuScrubFlags &= ~(1 << this->unk_1E8); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + syatekiMan->dekuScrubFlags &= ~(1 << this->index); } - func_80A2BE54(this); + EnSyatekiDekunuts_SetupWaitForSpawn(this); } - } else if (this->unk_1D8 < 160) { - this->unk_1D8--; + } else if (this->timer < 160) { + this->timer--; } } @@ -374,16 +424,17 @@ void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - 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) { + if ((this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) && (this->timer < this->timeToBurrow) && + (this->timer > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->isAlive == true)) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); } this->collider.base.acFlags &= ~AC_HIT; - func_80A2C4D0(this, play); + EnSyatekiDekunuts_SetupDead(this, play); } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -399,8 +450,9 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dLi Actor* thisx) { EnSyatekiDekunuts* this = THIS; - if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { - rot->z += this->unk_1F2; + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && + (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP)) { + rot->z += this->headdressRotZ; } return false; @@ -408,24 +460,24 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dLi void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play) { EnSyatekiDekunuts* this = THIS; - Vec3f temp_f20; + Vec3f flowerPos; s32 i; - if (this->actionFunc != func_80A2BF18) { + if (this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) { SkelAnime_DrawOpa(play, 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; + if (this->shouldDrawFlowers == true) { + for (i = 0; i < this->flowerCount; i++) { + flowerPos.x = this->flowerPos[i].x; + flowerPos.y = this->flowerPos[i].y; + flowerPos.z = this->flowerPos[i].z; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Translate(flowerPos.x, flowerPos.y, flowerPos.z, MTXMODE_NEW); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); 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 447dcaee7..51baf398f 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 @@ -4,10 +4,15 @@ #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_NUMBER(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_INDEX(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, number, unkF) (((unkFF00 << 8) & 0xFF00) | ((number << 4) & 0xF0) | (unkF & 0xF)) +#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, index, type) (((unkFF00 << 8) & 0xFF00) | ((index << 4) & 0xF0) | (type & 0xF)) + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_TYPE_NORMAL, // Worth 30 points + /* 1 */ EN_SYATEKI_DEKUNUTS_TYPE_BONUS, // Worth 100 points +} EnSyatekiDekunutsType; struct EnSyatekiDekunuts; @@ -18,18 +23,18 @@ typedef struct EnSyatekiDekunuts { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ s16 unk_1D8; - /* 0x1DA */ s16 unk_1DA; - /* 0x1CD */ s16 unk_1DC; + /* 0x1D8 */ s16 timer; + /* 0x1DA */ s16 waitTimer; + /* 0x1CD */ s16 unk_1DC; // Initialized, but never used /* 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; + /* 0x1E2 */ s16 isAlive; + /* 0x1E4 */ Vec3s* flowerPos; + /* 0x1E8 */ s16 index; + /* 0x1EA */ s16 flowerCount; + /* 0x1EC */ s16 shouldDrawFlowers; + /* 0x1EE */ s16 timeToBurrow; + /* 0x1F0 */ s16 headdressType; + /* 0x1F2 */ s16 headdressRotZ; /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; 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 42f205bca..838eaa2a5 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 @@ -103,13 +103,20 @@ typedef struct { static SwampTargetActorEntry sNormalSwampTargetActorList[] = { { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(1, 3, 0) }, { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_WF_PARAMS(0, 2, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 0) }, @@ -129,8 +136,10 @@ static SwampTargetActorEntry sNormalSwampTargetActorList[] = { static SwampTargetActorEntry sUnusedSwampTargetActorList[] = { { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 0) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(1, 0, 0) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, 1) }, - { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, 1) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(2, 0, 2) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(3, 0, 2) }, { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, EN_SYATEKI_CROW_PARAMS(0, 0, 3) }, 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 b6a0f9ed4..c9caedf01 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 @@ -151,7 +151,7 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { path = &play->setupPathList[path->unk1]; } - for (i = 0; i < EN_SYATEKI_WF_GET_NUMBER(&this->actor); i++) { + for (i = 0; i < EN_SYATEKI_WF_GET_INDEX(&this->actor); i++) { path = &play->setupPathList[path->unk1]; } @@ -224,7 +224,7 @@ void func_80A201CC(EnSyatekiWf* this) { this->actor.draw = NULL; this->unk_2A4 = 1; this->unk_298 = 0; - syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor)); + syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_INDEX(&this->actor)); this->actionFunc = func_80A20284; } @@ -236,7 +236,7 @@ void func_80A20284(EnSyatekiWf* this, PlayState* play) { if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_298 == 1)) { func_80A200E0(this); func_80A2030C(this); - } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_NUMBER(&this->actor))) { + } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_INDEX(&this->actor))) { this->unk_298 = 1; } } 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 4de182a10..9e01dca3d 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 @@ -5,8 +5,8 @@ #include "objects/object_wf/object_wf.h" #define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) -#define EN_SYATEKI_WF_GET_NUMBER(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_WF_PARAMS(number, unkF0, unused) (((number << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) +#define EN_SYATEKI_WF_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_WF_PARAMS(index, unkF0, unused) (((index << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) struct EnSyatekiWf; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b71390a05..519550a83 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10063,23 +10063,23 @@ 0x80A2B390:("BgDblueMovebg_Draw",), 0x80A2BC00:("EnSyatekiDekunuts_Init",), 0x80A2BE28:("EnSyatekiDekunuts_Destroy",), - 0x80A2BE54:("func_80A2BE54",), - 0x80A2BF18:("func_80A2BF18",), - 0x80A2BFC4:("func_80A2BFC4",), - 0x80A2C0F8:("func_80A2C0F8",), - 0x80A2C150:("func_80A2C150",), - 0x80A2C168:("func_80A2C168",), - 0x80A2C1AC:("func_80A2C1AC",), - 0x80A2C208:("func_80A2C208",), - 0x80A2C27C:("func_80A2C27C",), - 0x80A2C2E0:("func_80A2C2E0",), - 0x80A2C33C:("func_80A2C33C",), - 0x80A2C3AC:("func_80A2C3AC",), - 0x80A2C3F0:("func_80A2C3F0",), - 0x80A2C478:("func_80A2C478",), - 0x80A2C48C:("func_80A2C48C",), - 0x80A2C4D0:("func_80A2C4D0",), - 0x80A2C5DC:("func_80A2C5DC",), + 0x80A2BE54:("EnSyatekiDekunuts_SetupWaitForSpawn",), + 0x80A2BF18:("EnSyatekiDekunuts_WaitForSpawn",), + 0x80A2BFC4:("EnSyatekiDekunuts_SetupSpawn",), + 0x80A2C0F8:("EnSyatekiDekunuts_Spawn",), + 0x80A2C150:("EnSyatekiDekunuts_SetupWaitToEmerge",), + 0x80A2C168:("EnSyatekiDekunuts_WaitToEmerge",), + 0x80A2C1AC:("EnSyatekiDekunuts_SetupEmerge",), + 0x80A2C208:("EnSyatekiDekunuts_Emerge",), + 0x80A2C27C:("EnSyatekiDekunuts_SetupLookAround",), + 0x80A2C2E0:("EnSyatekiDekunuts_LookAround",), + 0x80A2C33C:("EnSyatekiDekunuts_BonusLookAround",), + 0x80A2C3AC:("EnSyatekiDekunuts_SetupBurrow",), + 0x80A2C3F0:("EnSyatekiDekunuts_Burrow",), + 0x80A2C478:("EnSyatekiDekunuts_SetupGameEnd",), + 0x80A2C48C:("EnSyatekiDekunuts_GameEnd",), + 0x80A2C4D0:("EnSyatekiDekunuts_SetupDead",), + 0x80A2C5DC:("EnSyatekiDekunuts_Dead",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 9e02cf981..eac44b02d 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -11112,15 +11112,15 @@ 0x80A2BBF4:("D_80A2BBF4","UNK_TYPE1","",0x1), 0x80A2BBF5:("D_80A2BBF5","UNK_TYPE1","",0x1), 0x80A2CA90:("En_Syateki_Dekunuts_InitVars","UNK_TYPE1","",0x1), - 0x80A2CAB0:("D_80A2CAB0","UNK_TYPE1","",0x1), - 0x80A2CADC:("D_80A2CADC","UNK_TYPE4","",0x4), - 0x80A2CAE8:("D_80A2CAE8","UNK_PTR","",0x4), - 0x80A2CB90:("D_80A2CB90","UNK_TYPE1","",0x1), - 0x80A2CB9C:("D_80A2CB9C","UNK_TYPE4","",0x4), - 0x80A2CBA0:("D_80A2CBA0","UNK_TYPE1","",0x1), - 0x80A2CBAC:("D_80A2CBAC","UNK_TYPE1","",0x1), - 0x80A2CBB8:("D_80A2CBB8","UNK_TYPE1","",0x1), - 0x80A2CBBC:("D_80A2CBBC","UNK_TYPE1","",0x1), + 0x80A2CAB0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A2CADC:("sBonusDekuScrubColliderDimensions","UNK_TYPE4","",0x4), + 0x80A2CAE8:("sAnimationInfo","UNK_PTR","",0x4), + 0x80A2CB90:("sInitChain","UNK_TYPE1","",0x1), + 0x80A2CB9C:("sDrawFlowers","UNK_TYPE4","",0x4), + 0x80A2CBA0:("sVelocity","UNK_TYPE1","",0x1), + 0x80A2CBAC:("sAccel","UNK_TYPE1","",0x1), + 0x80A2CBB8:("sPrimColor","UNK_TYPE1","",0x1), + 0x80A2CBBC:("sEnvColor","UNK_TYPE1","",0x1), 0x80A2CBC0:("D_80A2CBC0","f32","",0x4), 0x80A2D1C0:("Elf_Msg3_InitVars","UNK_TYPE1","",0x1), 0x80A2D1E0:("D_80A2D1E0","UNK_TYPE1","",0x1), From c3c08e944cc9548726b73a0d699ede34ba4e1017 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 1 Oct 2022 08:14:06 -0700 Subject: [PATCH 64/73] EnWiz (Wizrobe) OK and documented, EnWizFire (Wizrobe Magic) documented, object_wiz documented (#1054) * Good start * Limb draw stuff OK * A ton more functions * func_80A477E8 OK * func_80A456A0 OK * func_80A460A4 OK * func_80A46990 OK * func_80A46414 OK * EnWiz_Update OK * func_80A45CD8 OK Co-authored-by: petrie911 * EnWiz_Draw OK * Use generated reloc and object symbols * Document object stuff related to Wizzrobe itself * Some more names * A bunch more names * Name even more stuff (sensing a pattern?) * Document damage tables and damage effects * Bunch of stuff mostly related to ghosts * Name all struct vars and functions * Fix WizFire build issue * Split up dmgFlags * Apparently it's spelled "Wizrobe" in this game * Name all assets EXCEPT the ones used by wiz_fire * Apparently, the blob is vertices * Name all remaining variables * Some function comments * (Probably) the final touches on EnWiz docs before PR * Name a ton of stuff in EnWizFire * Finish naming everything in EnWizFire * Finish documentation * Respond to Engineer's clean-up review * Respond to Anghelo's first review * Use TATL_HINT_ID enum * Enum comments for animations, and better names for some damage effects * Fix build after merging master * Respond to Elliptic's review * Define INITIAL_CUR_PLATFORM_INDEX * Drop _CUR_ from the name * Rename one of the enum values * Respond to Elliptic's WizFire review * Every switch has a default --- assets/xml/objects/object_wiz.xml | 242 ++- spec | 3 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 4 +- src/overlays/actors/ovl_En_Wiz/z_en_wiz.c | 1607 +++++++++++++++-- src/overlays/actors/ovl_En_Wiz/z_en_wiz.h | 73 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 33 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h | 11 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 716 ++++---- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h | 83 +- tools/disasm/functions.txt | 72 +- tools/disasm/variables.txt | 32 +- undefined_syms.txt | 8 - 12 files changed, 2178 insertions(+), 706 deletions(-) diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 2928083aa..51fcae3a7 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -1,102 +1,148 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index b4a8a6108..9ad5e4cca 100644 --- a/spec +++ b/spec @@ -2715,8 +2715,7 @@ beginseg name "ovl_En_Wiz" compress include "build/src/overlays/actors/ovl_En_Wiz/z_en_wiz.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.data.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz/ovl_En_Wiz_reloc.o" endseg beginseg 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 198166b00..58d5a6f5f 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -241,10 +241,10 @@ void EnFz_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider3); if ((this->actor.parent != NULL) && (this->unk_BC4 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && - (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->unk_448 != 0)) { + (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->freezard != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_448 = 0; + wiz->freezard = NULL; } } 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 82cc5f2e2..0abf1fe56 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -1,10 +1,12 @@ /* * File: z_en_wiz.c * Overlay: ovl_En_Wiz - * Description: Wizzrobe + * Description: Wizrobe */ #include "z_en_wiz.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h" #define FLAGS \ (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ @@ -17,7 +19,67 @@ void EnWiz_Destroy(Actor* thisx, PlayState* play); void EnWiz_Update(Actor* thisx, PlayState* play); void EnWiz_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupAppear(EnWiz* this, PlayState* play); +void EnWiz_Appear(EnWiz* this, PlayState* play); +void EnWiz_SetupDance(EnWiz* this); +void EnWiz_Dance(EnWiz* this, PlayState* play); +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupWindUp(EnWiz* this); +void EnWiz_WindUp(EnWiz* this, PlayState* play); +void EnWiz_SetupAttack(EnWiz* this); +void EnWiz_Attack(EnWiz* this, PlayState* play); +void EnWiz_SetupDisappear(EnWiz* this); +void EnWiz_Disappear(EnWiz* this, PlayState* play); +void EnWiz_Damaged(EnWiz* this, PlayState* play); +void EnWiz_SetupDead(EnWiz* this); +void EnWiz_Dead(EnWiz* this, PlayState* play); + +// This number is almost-entirely arbirary, with the only requirement being +// that cannot be a valid curPlatformIndex. Any negative number, or any number +// larger than 10, would work just as well. +#define INITIAL_PLATFORM_INDEX 777 + +typedef enum { + /* 1 */ EN_WIZ_ACTION_APPEAR = 1, + /* 2 */ EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS, + /* 3 */ EN_WIZ_ACTION_DISAPPEAR, + /* 4 */ EN_WIZ_ACTION_DAMAGED, + /* 5 */ EN_WIZ_ACTION_DEAD, + /* 6 */ EN_WIZ_ACTION_BURST_INTO_FLAMES, + /* 7 */ EN_WIZ_ACTION_RUN_IN_CIRCLES, + /* 8 */ EN_WIZ_ACTION_ATTACK, + /* 9 */ EN_WIZ_ACTION_DANCE, +} EnWizAction; + +typedef enum { + /* 0 */ EN_WIZ_INTRO_CS_NOT_STARTED, + /* 1 */ EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM, + /* 2 */ EN_WIZ_INTRO_CS_APPEAR, + /* 3 */ EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE, + /* 4 */ EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN, + /* 5 */ EN_WIZ_INTRO_CS_RUN_IN_CIRCLES, + /* 6 */ EN_WIZ_INTRO_CS_DISAPPEAR, + /* 7 */ EN_WIZ_INTRO_CS_END +} EnWizIntroCutsceneState; + +typedef enum { + /* 0 */ EN_WIZ_FIGHT_STATE_FIRST_PHASE, + /* 1 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE, + /* 2 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE, + /* 3 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND, +} EnWizFightState; + +typedef enum { + /* 0 */ EN_WIZ_ANIM_IDLE, + /* 1 */ EN_WIZ_ANIM_RUN, + /* 2 */ EN_WIZ_ANIM_DANCE, + /* 3 */ EN_WIZ_ANIM_WIND_UP, + /* 4 */ EN_WIZ_ANIM_ATTACK, + /* 5 */ EN_WIZ_ANIM_DAMAGE, +} EnWizAnimation; + const ActorInit En_Wiz_InitVars = { ACTOR_EN_WIZ, ACTORCAT_ENEMY, @@ -30,199 +92,1470 @@ const ActorInit En_Wiz_InitVars = { (ActorFunc)EnWiz_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[10] = { -static ColliderJntSphElementInit D_80A48B50[10] = { +static ColliderJntSphElementInit sJntSphElementsInit[10] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A48CB8 = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_80A48B50, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A48CC8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 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_UNK1, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 35, 130, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48CF4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* 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(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_WIZ_DMGEFF_IMMUNE, // Deals no damage + /* 0x1 */ EN_WIZ_DMGEFF_UNK1, // Deals no damage. Was probably originally intended for destroying ghosts. + /* 0x2 */ EN_WIZ_DMGEFF_FIRE, // Damages and sets Ice Wizrobes on fire + /* 0x3 */ EN_WIZ_DMGEFF_FREEZE, // Damages and surrounds Fire Wizrobes with ice + /* 0x4 */ EN_WIZ_DMGEFF_LIGHT_ORB, // Damages and surrounds the Wizrobe with light orbs + /* 0xF */ EN_WIZ_DMGEFF_NONE = 0xF, // Deals regular damage and has no special effect +} EnWizDamageEffect; + +static DamageTable sFireWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48D14 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* 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(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), +static DamageTable sIceWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(2, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -#endif +void EnWiz_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -extern ColliderJntSphElementInit D_80A48B50[10]; -extern ColliderJntSphInit D_80A48CB8; -extern ColliderCylinderInit D_80A48CC8; -extern DamageTable D_80A48CF4; -extern DamageTable D_80A48D14; + SkelAnime_InitFlex(play, &this->skelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->jointTable, this->morphTable, + WIZROBE_LIMB_MAX); + SkelAnime_InitFlex(play, &this->ghostSkelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->ghostBaseJointTable, + this->ghostMorphTable, WIZROBE_LIMB_MAX); + Actor_SetScale(&this->actor, 0.0f); + this->platformLightAlpha = 0; + this->alpha = 255; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 3; + this->unk_450 = 1.0f; + this->actor.shape.yOffset = 700.0f; + Collider_InitAndSetJntSph(play, &this->ghostColliders, &this->actor, &sJntSphInit, this->ghostColliderElements); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->staffFlameScroll = Rand_S16Offset(0, 7); + this->switchFlag = EN_WIZ_GET_SWITCHFLAG(&this->actor); + this->type = EN_WIZ_GET_TYPE(&this->actor); -extern UNK_TYPE D_0600211C; -extern UNK_TYPE D_060025F0; -extern UNK_TYPE D_060066C0; + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Init.s") + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.damageTable = &sFireWizrobeDamageTable; + this->actor.colChkInfo.health = 8; + this->actor.flags &= ~ACTOR_FLAG_100000; + } else { + this->actor.colChkInfo.damageTable = &sIceWizrobeDamageTable; + this->actor.colChkInfo.health = 6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Destroy.s") + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A455C4.s") + this->actor.hintId = TATL_HINT_ID_WIZROBE; + this->curPlatformIndex = INITIAL_PLATFORM_INDEX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A456A0.s") + // Setting the radius and scale to zero here effectively disables all of the ghost colliders. + this->ghostColliders.elements[0].dim.modelSphere.radius = 0; + this->ghostColliders.elements[0].dim.scale = 0.0f; + this->ghostColliders.elements[0].dim.modelSphere.center.x = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.y = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A45CD8.s") + this->actionFunc = EnWiz_StartIntroCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A460A4.s") +void EnWiz_Destroy(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46280.s") + Collider_DestroyCylinder(play, &this->collider); + Collider_DestroyJntSph(play, &this->ghostColliders); + if (this->type != EN_WIZ_TYPE_FIRE_NO_BGM) { + Audio_RestorePrevBgm(); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A462F8.s") +static AnimationHeader* sAnimations[] = { + &gWizrobeIdleAnim, // EN_WIZ_ANIM_IDLE + &gWizrobeRunAnim, // EN_WIZ_ANIM_RUN + &gWizrobeDanceAnim, // EN_WIZ_ANIM_DANCE + &gWizrobeWindUpAnim, // EN_WIZ_ANIM_WIND_UP + &gWizrobeAttackAnim, // EN_WIZ_ANIM_ATTACK + &gWizrobeDamageAnim, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46414.s") +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, // EN_WIZ_ANIM_IDLE + ANIMMODE_LOOP, // EN_WIZ_ANIM_RUN + ANIMMODE_LOOP, // EN_WIZ_ANIM_DANCE + ANIMMODE_LOOP, // EN_WIZ_ANIM_WIND_UP + ANIMMODE_LOOP, // EN_WIZ_ANIM_ATTACK + ANIMMODE_ONCE, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4668C.s") +void EnWiz_ChangeAnim(EnWiz* this, s32 animIndex, s32 updateGhostAnim) { + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], + -2.0f); + if (updateGhostAnim) { + Animation_Change(&this->ghostSkelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, + sAnimationModes[animIndex], -2.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46764.s") +/** + * Responsible for moving the camera around and making the Wizrobe run in circles during the intro cutscene. + */ +void EnWiz_HandleIntroCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + Vec3f eyeNext; + Vec3f atNext; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A468CC.s") + if (this->introCutsceneState < EN_WIZ_INTRO_CS_DISAPPEAR) { + subCam = Play_GetCamera(play, this->subCamId); + switch (this->introCutsceneState) { + case EN_WIZ_INTRO_CS_NOT_STARTED: + this->introCutsceneTimer = 100; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + this->introCutsceneState++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46990.s") + case EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if ((fabsf(subCam->eye.x - eyeNext.x) < 2.0f) && (fabsf(subCam->eye.y - eyeNext.y) < 2.0f) && + (fabsf(subCam->eye.z - eyeNext.z) < 2.0f) && (fabsf(subCam->at.x - atNext.x) < 2.0f) && + (fabsf(subCam->at.y - atNext.y) < 2.0f) && (fabsf(subCam->at.z - atNext.z) < 2.0f)) { + Player* player = GET_PLAYER(play); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46C88.s") + this->actor.world.rot.y = this->actor.shape.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46CC4.s") + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46DDC.s") + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46E24.s") + this->introCutsceneTimer = 40; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47000.s") + case EN_WIZ_INTRO_CS_APPEAR: + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 20; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A470D8.s") + case EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->actor.world.rot.y) * 160.0f; + eyeNext.y += 70.0f; + eyeNext.z += Math_CosS(this->actor.world.rot.y) * 140.0f; + atNext.x += -10.0f; + atNext.y += 100.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 10; + this->introCutsceneState++; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47298.s") + case EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN: + if (this->introCutsceneTimer == 0) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_RUN, false); + this->rotationalVelocity = 0; + this->introCutsceneTimer = 34; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A473B8.s") + case EN_WIZ_INTRO_CS_RUN_IN_CIRCLES: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->introCutsceneTimer == 0) { + this->animLoopCounter = this->introCutsceneCameraAngle = 0; + this->introCutsceneState = EN_WIZ_INTRO_CS_DISAPPEAR; + } else { + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4767C.s") + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A476C8.s") + default: + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A477E8.s") + if (this->musicStartTimer < 11) { + this->musicStartTimer++; + if ((this->type != EN_WIZ_TYPE_FIRE_NO_BGM) && (this->musicStartTimer == 11)) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Update.s") +/** + * Chooses which platform the Wizrobe should appear at, and updates its position accordingly. + * It also updates the position and alpha of all the ghosts. + */ +void EnWiz_SelectPlatform(EnWiz* this, PlayState* play) { + Actor* prop; + s32 i; + s32 j; + s16 ghostAlpha; + s16 type; + s16 curPlatformIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47FCC.s") + for (i = 0; i < ARRAY_COUNT(this->platforms); i++) { + this->platforms[i] = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A48138.s") + prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; + i = 0; + while (prop != NULL) { + if (prop->id != ACTOR_EN_WIZ_BROCK) { + prop = prop->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Draw.s") + this->platforms[i] = prop; + i++; + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + type = this->type; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + prop->colChkInfo.health = type + EN_WIZ_BROCK_PLATFORM_TYPE_FIRE; + prop = prop->next; + } else { + prop->colChkInfo.health = EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE; + prop = prop->next; + } + } + + if (this->action != EN_WIZ_ACTION_DEAD) { + this->platformCount = i; + if (i < 0) { + i = 0; + } else if (this->platformCount > 10) { + this->platformCount = 10; + } + + curPlatformIndex = Rand_ZeroFloat(i); + while ((this->curPlatformIndex == curPlatformIndex) || ((s16)i == curPlatformIndex)) { + curPlatformIndex = Rand_ZeroFloat(i); + if (1) {} + } + + this->curPlatformIndex = curPlatformIndex; + switch (this->fightState) { + case EN_WIZ_FIGHT_STATE_FIRST_PHASE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + break; + + case EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[0]->world.pos); + for (i = 0, ghostAlpha = 128; i < this->platformCount; i++, ghostAlpha -= 10) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->actor.world.pos); + this->ghostAlpha[i] = ghostAlpha; + } + break; + + default: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + for (i--; i >= 0; i--) { + if (curPlatformIndex != i) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->platforms[i]->world.pos); + this->ghostRot[i] = this->actor.world.rot; + this->ghostAlpha[i] = 100; + this->ghostNextPlatformIndex[i] = i; + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } else { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + break; + } + } +} + +/** + * Makes the ghosts run around the room from platform to platform. + */ +void EnWiz_MoveGhosts(EnWiz* this) { + s32 i; + s32 ghostNextPlatformIndex; + s32 playSfx = false; + + for (i = 0; i < this->platformCount; i++) { + if (this->ghostPos[i].x != 0.0f && this->ghostPos[i].z != 0.0f) { + f32 diffX; + f32 diffZ; + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + diffX = this->platforms[ghostNextPlatformIndex]->world.pos.x - this->ghostPos[i].x; + diffZ = this->platforms[ghostNextPlatformIndex]->world.pos.z - this->ghostPos[i].z; + playSfx++; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + this->ghostNextPlatformIndex[i]--; + if (this->ghostNextPlatformIndex[i] < 0) { + this->ghostNextPlatformIndex[i] = this->platformCount - 1; + } + } + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + Math_ApproachF(&this->ghostPos[i].x, this->platforms[ghostNextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].y, this->platforms[ghostNextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].z, this->platforms[ghostNextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + this->ghostRot[i].y = + Math_Vec3f_Yaw(&this->ghostPos[i], &this->platforms[ghostNextPlatformIndex]->world.pos); + } + } + + if (playSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + } +} + +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_SetupAppear(this, play); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnWiz_SetupAppear(EnWiz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 i; + s16 angle; + + this->action = EN_WIZ_ACTION_APPEAR; + + if (this->timer == 0) { + EnWiz_SelectPlatform(this, play); + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_NOT_STARTED) { + angle = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); + this->actor.shape.rot.y = angle; + this->actor.world.rot.y = angle; + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } + + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + } + + this->actionFunc = EnWiz_Appear; + } +} + +/** + * Makes the Wizrobe grow in scale and become more opaque. + * During the first phase, it also increases the alpha for the platform's light. + * If the player gets too close during the first phase, this will set up the Wizrobe to disappear. + */ +void EnWiz_Appear(EnWiz* this, PlayState* play) { + Vec3f staffTargetFlameScale = { 0.006f, 0.006f, 0.006f }; + Player* player = GET_PLAYER(play); + + EnWiz_HandleIntroCutscene(this, play); + + if (this->introCutsceneState >= EN_WIZ_INTRO_CS_APPEAR) { + SkelAnime_Update(&this->skelAnime); + + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->introCutsceneState >= EN_WIZ_INTRO_CS_DISAPPEAR) && + ((this->actor.xzDistToPlayer < 200.0f) || + ((player->unk_D57 != 0) && + ((ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x7D0)) && + (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, BINANG_ADD(player->actor.shape.rot.y, 0x8000))) < + 0x7D0)))) { + EnWiz_SetupDisappear(this); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xBB8, 0); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); + if (!this->shouldStartTimer) { + this->timer = 20; + this->shouldStartTimer = true; + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + + if (this->timer == 0) { + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.01f); + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + } + + if (this->scale < 0.0138f) { + return; + } else { + this->action = EN_WIZ_ACTION_RUN_IN_CIRCLES; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1013A22; + Math_Vec3f_Copy(&this->staffTargetFlameScale, &staffTargetFlameScale); + this->targetPlatformLightAlpha = 0; + + if (this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) { + this->timer = 0; + this->introCutsceneTimer = 20; + EnWiz_SetupDisappear(this); + } else if (this->introCutsceneState >= EN_WIZ_INTRO_CS_END) { + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + this->actionFunc = EnWiz_SetupSecondPhaseCutscene; + } else { + EnWiz_SetupDance(this); + } + } + } + } + } +} + +void EnWiz_SetupDance(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + this->rotationalVelocity = 0; + this->animLoopCounter = 0; + this->action = EN_WIZ_ACTION_DANCE; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE) { + Animation_Change(&this->ghostSkelAnime, &gWizrobeRunAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gWizrobeRunAnim), + ANIMMODE_LOOP, 0.0f); + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND; + } + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_Dance; +} + +/** + * Makes the Wizrobe spin around and dance until there are no active projectiles + * and it completes at least three loops of its dancing animation. + */ +void EnWiz_Dance(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + this->actor.world.rot.y += this->rotationalVelocity; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + if (this->endFrame <= curFrame) { + if (this->animLoopCounter < 10) { + this->animLoopCounter++; + } + } + + if ((this->animLoopCounter >= 3) && (!this->hasActiveProjectile)) { + this->targetPlatformLightAlpha = 0; + EnWiz_SetupWindUp(this); + } +} + +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play) { + s16 secondPhaseCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + + if (!ActorCutscene_GetCanPlayNext(secondPhaseCutscene)) { + ActorCutscene_SetIntentToPlay(secondPhaseCutscene); + } else { + ActorCutscene_StartAndSetFlag(secondPhaseCutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(secondPhaseCutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS; + this->nextPlatformIndex = 1; + this->hasRunToEveryPlatform = false; + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_SecondPhaseCutscene; + } +} + +/** + * Makes the Wizrobe run between every platform in the room once before returning to its + * original platform and disappearing. Ghosts trail behind the Wizrobe as it runs. + */ +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + subCam = Play_GetCamera(play, this->subCamId); + Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->platforms[this->nextPlatformIndex] != NULL) { + f32 diffX = this->actor.world.pos.x - this->platforms[this->nextPlatformIndex]->world.pos.x; + f32 diffZ = this->actor.world.pos.z - this->platforms[this->nextPlatformIndex]->world.pos.z; + s32 pad; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + if (!this->hasRunToEveryPlatform) { + this->nextPlatformIndex++; + if (this->nextPlatformIndex >= this->platformCount) { + this->hasRunToEveryPlatform = true; + this->nextPlatformIndex = 0; + } + } else { + f32 diffX = this->actor.world.pos.x - this->ghostPos[this->platformCount].x; + f32 diffZ = this->actor.world.pos.z - this->ghostPos[this->platformCount].z; + s32 pad; + s32 i; + + this->actor.flags |= ACTOR_FLAG_8000000; + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 20.0f) { + for (i = 0; i < this->platformCount; i++) { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + + this->nextPlatformIndex = 0; + this->platformCount = 0; + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->timer = 0; + ActorCutscene_Stop(ActorCutscene_GetAdditionalCutscene(this->actor.cutscene)); + this->actor.flags &= ~ACTOR_FLAG_100000; + EnWiz_SetupDisappear(this); + return; + } + } + } + } + + Math_Vec3f_Copy(this->ghostPos, &this->actor.world.pos); + this->ghostRot[0].y = this->actor.world.rot.y; + Math_ApproachF(&this->actor.world.pos.x, this->platforms[this->nextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.y, this->platforms[this->nextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.z, this->platforms[this->nextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + for (i = this->platformCount; i > 0; i--) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->ghostPos[i - 1]); + this->ghostRot[i].y = this->ghostRot[i - 1].y; + } + + this->actor.world.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &this->platforms[this->nextPlatformIndex]->world.pos); +} + +void EnWiz_SetupWindUp(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_WIND_UP, false); + this->animLoopCounter = 0; + this->actionFunc = EnWiz_WindUp; +} + +/** + * Plays the wind up animation for at least two animation loops before attacking. + */ +void EnWiz_WindUp(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostRot[i].y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + } + } + + if (this->endFrame <= curFrame) { + this->animLoopCounter++; + if (this->animLoopCounter >= 2) { + EnWiz_SetupAttack(this); + } + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); +} + +void EnWiz_SetupAttack(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_ATTACK, false); + this->timer = 0; + this->shouldStartTimer = false; + this->action = EN_WIZ_ACTION_ATTACK; + this->actionFunc = EnWiz_Attack; +} + +/** + * Spawns an EnWizFire projectile that is pointed at the player, then disappears. + */ +void EnWiz_Attack(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } + + if (this->timer == 0) { + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) && (!this->hasActiveProjectile)) { + Player* player = GET_PLAYER(play); + Vec3f pos; + s32 type = this->type; + + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + pos.y += 60.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WIZ_FIRE, pos.x, pos.y, pos.z, + Math_Vec3f_Pitch(&pos, &player->actor.world.pos), + Math_Vec3f_Yaw(&pos, &player->actor.world.pos), 0, type * 4); + this->hasActiveProjectile = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_MAGIC_FIRE); + } + + if ((curFrame >= 8.0f) && !this->shouldStartTimer) { + this->timer = 3; + this->shouldStartTimer = true; + } + + if (this->endFrame <= curFrame) { + EnWiz_SetupDisappear(this); + } + } +} + +void EnWiz_SetupDisappear(EnWiz* this) { + if (this->action != EN_WIZ_ACTION_DAMAGED) { + this->rotationalVelocity = 0x2710; + this->timer = 0; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, false); + this->action = EN_WIZ_ACTION_DISAPPEAR; + } else { + this->rotationalVelocity = 0x2710; + this->actor.world.rot.y += this->rotationalVelocity; + } + + this->targetPlatformLightAlpha = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnWiz_Disappear; +} + +/** + * Spin the Wizrobe around and shrink it so that it disappears into its platform. + * Afterwards, set it up to appear again. + */ +void EnWiz_Disappear(EnWiz* this, PlayState* play) { + s32 i; + + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + this->actor.world.rot.y += this->rotationalVelocity; + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) || (this->action == EN_WIZ_ACTION_DAMAGED)) { + Math_ApproachZeroF(&this->scale, 0.3f, 0.01f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 5, 50, 0); + } else { + Math_ApproachZeroF(&this->scale, 0.3f, 0.001f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 50, 0); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_Vec3f_Copy(&this->staffTargetFlameScale, &gZeroVec3f); + if (this->scale < 0.001f) { + this->scale = 0.0f; + + if ((this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) && (this->introCutsceneTimer == 0)) { + this->introCutsceneState = EN_WIZ_INTRO_CS_END; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100000; + } + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_DISAPPEAR) { + this->alpha = 0; + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1000202; + } + + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnWiz_SetupAppear; + } + } +} + +void EnWiz_SetupDamaged(EnWiz* this, PlayState* play) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->timer = 20; + + if ((this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && (this->actor.colChkInfo.health <= 0)) { + Enemy_StartFinishingBlow(play, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DEAD); + this->timer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DAMAGE); + } + + this->scale = 0.015f; + this->platformCount = 0; + this->targetPlatformLightAlpha = 0; + if ((this->drawDmgEffTimer != 0) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->timer = 0; + } + + this->rotationalVelocity = 0x4E20; + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + this->rotationalVelocity = 0; + this->timer = 0; + } + + this->action = EN_WIZ_ACTION_DAMAGED; + this->actionFunc = EnWiz_Damaged; +} + +/** + * Spins the Wizrobe around quickly and makes it jump in the air if it was defeated or if + * it was damaged in a certain way. Afterwards, the Wizrobe either disappears or dies. + */ +void EnWiz_Damaged(EnWiz* this, PlayState* play) { + s32 i; + + if ((this->drawDmgEffTimer < 50) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 1.0f, 0.7f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->rotationalVelocity = 0x4E20; + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + } + + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffTimer < 30) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (!this->isDead && (this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->actor.colChkInfo.health <= 0)) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->isDead = true; + } + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + + if ((this->timer == 1) || + ((this->actor.velocity.y < 0.0f) && + (this->actor.world.pos.y < (this->platforms[this->curPlatformIndex]->world.pos.y + 11.0f)))) { + this->timer = 0; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->drawDmgEffTimer = this->timer; + this->drawDmgEffType = this->timer; + + if (this->actor.colChkInfo.health <= 0) { + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE; + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.health = 8; + } else { + this->actor.colChkInfo.health = 6; + } + + EnWiz_SetupDisappear(this); + } else { + EnWiz_SetupDead(this); + } + } else { + EnWiz_SetupDisappear(this); + } + + this->actor.flags |= ACTOR_FLAG_8000000; + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); +} + +void EnWiz_SetupDead(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + this->rotationalVelocity = 0x2710; + this->action = EN_WIZ_ACTION_DEAD; + this->timer = 0; + this->actionFunc = EnWiz_Dead; +} + +/** + * Slows the Wizrobe's rotation to a stop, then makes it burst into flames. + * If the Wizrobe has a switch flag, it will set that switch flag when it dies. + */ +void EnWiz_Dead(EnWiz* this, PlayState* play) { + s32 i; + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + if (this->rotationalVelocity < 0x1E) { + Math_SmoothStepToS(&this->alpha, 0, 10, 30, 20); + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostAlpha[i], 0, 10, 30, 20); + } + + this->action = EN_WIZ_ACTION_BURST_INTO_FLAMES; + } + + if (this->alpha < 30) { + EnWiz_SelectPlatform(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + } +} + +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; +static Color_RGBA8 sDustEnvTimer = { 180, 180, 180, 255 }; + +void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) { + s32 i; + s32 attackDealsDamage = false; + + if (this->collider.base.acFlags & AC_HIT) { + this->ghostColliders.base.acFlags &= ~AC_HIT; + if (this->action < EN_WIZ_ACTION_RUN_IN_CIRCLES) { + return; + } + + switch (this->actor.colChkInfo.damageEffect) { + case EN_WIZ_DMGEFF_NONE: + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FIRE: + if (this->type == EN_WIZ_TYPE_ICE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FREEZE: + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + break; + + case EN_WIZ_DMGEFF_LIGHT_ORB: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->drawDmgEffTimer == 0)) { + Actor_Spawn(&play->actorCtx, play, 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); + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + attackDealsDamage = true; + } + break; + } + + this->alpha = 255; + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + return; + } + } + + if ((this->platformCount != 0) && (this->fightState != EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE)) { + for (i = 0; i < this->platformCount; i++) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; + s32 j; + + // If the player throws a Deku Nut or hits a ghost's collider (something that is impossible + // in the final game, since EnWiz_Init effectively disables them), then the below code will + // "destroy" the ghost by turning into a cloud of smoke. + if ((iREG(50) != 0) || (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) { + //! @bug: If a single ghost is destroyed, then changing the fight state here will cause + //! strange behavior; the ghosts will stand still and pretend to attack the player like + //! the real Wizrobe. Since Deku Nuts destroy all ghosts at once, and since the ghost + //! colliders are effectively disabled, this doesn't cause any problems in the final + //! game, but it becomes an issue if the ghost colliders are enabled. + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->ghostColliders.base.acFlags &= ~BUMP_HIT; + if (this->ghostPos[i].x != .0f || this->ghostPos[i].z != .0f) { + for (j = 0; j < 9; j++) { + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; + scaleStep = Rand_S16Offset(20, 10); + Math_Vec3f_Copy(&pos, &this->ghostPos[i]); + pos.x += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + pos.y += 70.0f + randPlusMinusPoint5Scaled(30.0f); + pos.z += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + func_800B0DE0(play, &pos, &velocity, &accel, &sDustPrimColor, &sDustEnvTimer, + Rand_S16Offset(350, 100), scaleStep); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->ghostPos[i], 50, NA_SE_EN_WIZ_LAUGH); + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + } + } +} + +void EnWiz_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + s32 i; + s32 j; + + if (this->action != EN_WIZ_ACTION_APPEAR) { + SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&this->ghostSkelAnime); + } + + Actor_SetFocus(&this->actor, 60.0f); + Actor_SetScale(&this->actor, this->scale); + EnWiz_UpdateDamage(this, play); + this->actionFunc(this, play); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + DECR(this->timer); + DECR(this->introCutsceneTimer); + DECR(this->drawDmgEffTimer); + + this->collider.dim.radius = 35; + this->collider.dim.height = 130; + this->collider.dim.yShift = 0; + if (this->action >= EN_WIZ_ACTION_RUN_IN_CIRCLES) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->ghostColliders.base); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + Math_ApproachF(&this->staffFlameScale.x, this->staffTargetFlameScale.x, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.y, this->staffTargetFlameScale.y, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.z, this->staffTargetFlameScale.z, 0.3f, 0.002f); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->platformCount = 0; + } else if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->ghostBaseJointTable); j++) { + this->ghostJointTables[i][j] = this->ghostBaseJointTable[j]; + } + } + } else { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } + } +} + +void EnWiz_PostLimbDrawOpa(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + EnWiz* this = THIS; + + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + + Collider_UpdateSpheres(limbIndex, &this->ghostColliders); + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_PostLimbDrawXlu(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + s32 pad; + EnWiz* this = THIS; + + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + } else { + if (this->timer == 0) { + Vec3f flamePos; + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &flamePos); + flamePos.x += randPlusMinusPoint5Scaled(4.0f); + flamePos.y += randPlusMinusPoint5Scaled(7.0f); + flamePos.z += randPlusMinusPoint5Scaled(5.0f); + func_800B3030(play, &flamePos, &gZeroVec3f, &gZeroVec3f, ((Rand_ZeroFloat(1.0f) * 50.0f) + 70.0f), 10, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &flamePos, 10, NA_SE_EN_EXTINCT); + } + + if ((limbIndex >= WIZROBE_LIMB_RIGHT_FOOT) && (this->timer == 0)) { + this->timer = 4; + } + } + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->action == EN_WIZ_ACTION_BURST_INTO_FLAMES) || (this->alpha != 255)) { + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + } else { + Scene_SetRenderModeXlu(play, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->alpha); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawOpa, &this->actor); + } + + if (this->drawDmgEffTimer != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; + + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + this->drawDmgEffScale += 0.3f; + if (this->drawDmgEffScale > 0.5f) { + this->drawDmgEffScale = 0.5f; + } + + Math_ApproachF(&this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, 0.1f, 0.04f); + } else { + this->drawDmgEffScale = 0.8f; + this->drawDmgEffFrozenSteamScale = 0.8f; + } + + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->platformCount > 0) { + s32 i; + s16 platformCount; + + Matrix_Push(); + + platformCount = this->platformCount; + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + platformCount = 10; + } + + for (i = 0; i < platformCount; i++) { + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->ghostPos[i].x != 0.0f) && (this->ghostPos[i].z != 0.0f)) { + Matrix_Translate(this->ghostPos[i].x, this->ghostPos[i].y + 10.0f, this->ghostPos[i].z, MTXMODE_NEW); + Matrix_Scale(this->scale, this->scale, this->scale, MTXMODE_APPLY); + Matrix_RotateYS(this->ghostRot[i].y, MTXMODE_APPLY); + Matrix_RotateXS(this->ghostRot[i].x, MTXMODE_APPLY); + Matrix_RotateZS(this->ghostRot[i].z, MTXMODE_APPLY); + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->ghostAlpha[i]); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->ghostSkelAnime.skeleton, this->ghostJointTables[i], + this->ghostSkelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + this->ghostColliders.elements[i + 1].dim.worldSphere.center.x = this->ghostPos[i].x; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.y = this->ghostPos[i].y + 50.0f; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.z = this->ghostPos[i].z; + this->ghostColliders.elements[i + 1].dim.worldSphere.radius = + this->ghostColliders.elements[0].dim.modelSphere.radius; + this->ghostColliders.elements[i + 1].dim.scale = this->ghostColliders.elements[0].dim.scale; + } + } + + Matrix_Pop(); + } + + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + // Draw the light emanating from the Wizrobe's platform + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Matrix_Push(); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizrobePlatformLightTexAnim)); + Matrix_Translate(this->platformLightPos.x, this->platformLightPos.y, this->platformLightPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->platformLightAlpha); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 100, 255); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 0, 255, 255); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobePlatformLightDL); + + Matrix_Pop(); + } + + // Draw the flame at the tip of the Wizrobe's staff + Matrix_Translate(this->staffFlamePos.x, this->staffFlamePos.y, this->staffFlamePos.z, MTXMODE_NEW); + Matrix_Scale(this->staffFlameScale.x, this->staffFlameScale.y, this->staffFlameScale.z, MTXMODE_APPLY); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((this->staffFlameScroll * 10) - (play->state.frames * 20)) % 512, 32, 128)); + gDPPipeSync(POLY_XLU_DISP++); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 255, 255); + } + + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h index a1ae32032..3d18abab2 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -2,6 +2,16 @@ #define Z_EN_WIZ_H #include "global.h" +#include "objects/object_wiz/object_wiz.h" + +#define EN_WIZ_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define EN_WIZ_GET_TYPE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_WIZ_TYPE_FIRE, + /* 1 */ EN_WIZ_TYPE_ICE, + /* 2 */ EN_WIZ_TYPE_FIRE_NO_BGM, // does not request the mini-boss BGM +} EnWizType; struct EnWiz; @@ -9,15 +19,62 @@ typedef void (*EnWizActionFunc)(struct EnWiz*, PlayState*); typedef struct EnWiz { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x268]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WIZROBE_LIMB_MAX]; + /* 0x200 */ Vec3s morphTable[WIZROBE_LIMB_MAX]; + /* 0x278 */ SkelAnime ghostSkelAnime; + /* 0x2BC */ Vec3s ghostBaseJointTable[WIZROBE_LIMB_MAX]; + /* 0x334 */ Vec3s ghostMorphTable[WIZROBE_LIMB_MAX]; /* 0x3AC */ EnWizActionFunc actionFunc; - /* 0x3B0 */ char unk_3B0[0xA]; - /* 0x3BA */ s16 unk_3BA; - /* 0x3BC */ char unk_3BC[0x8C]; - /* 0x448 */ s32 unk_448; - /* 0x44C */ char unk_44C[0x2FE]; - /* 0x74A */ s16 unk_74A; - /* 0x74C */ char unk_74C[0x634]; + /* 0x3B0 */ s16 action; + /* 0x3B2 */ s16 timer; + /* 0x3B4 */ s16 introCutsceneTimer; + /* 0x3B6 */ s16 fightState; + /* 0x3B8 */ s16 staffFlameScroll; + /* 0x3BA */ s16 hasActiveProjectile; + /* 0x3BC */ s16 hasRunToEveryPlatform; // used for the second phase cutscene to make sure the Wizrobe visits every platform + /* 0x3BE */ s16 unk_3BE; // unused, inferred from surrounding members + /* 0x3C0 */ s16 rotationalVelocity; + /* 0x3C2 */ s16 alpha; + /* 0x3C4 */ s16 platformLightAlpha; + /* 0x3C6 */ s16 targetPlatformLightAlpha; + /* 0x3C8 */ s16 introCutsceneCameraAngle; + /* 0x3CA */ u8 shouldStartTimer; + /* 0x3CB */ u8 introCutsceneState; + /* 0x3CC */ s32 musicStartTimer; + /* 0x3D0 */ f32 endFrame; + /* 0x3D4 */ f32 scale; + /* 0x3D8 */ Vec3f staffFlamePos; + /* 0x3E4 */ Vec3f staffFlameScale; + /* 0x3F0 */ Vec3f staffTargetFlameScale; + /* 0x3FC */ Vec3f unk_3FC; // unused, inferred from surrounding members + /* 0x408 */ Vec3f unk_408; // unused, inferred from surrounding members + /* 0x414 */ Vec3f platformLightPos; + /* 0x420 */ Actor* platforms[10]; + /* 0x448 */ Actor* freezard; + /* 0x44C */ s16 animLoopCounter; + /* 0x450 */ f32 unk_450; // set to 1.0f, but never used + /* 0x454 */ ColliderJntSph ghostColliders; + /* 0x474 */ ColliderJntSphElement ghostColliderElements[10]; + /* 0x6F4 */ ColliderCylinder collider; + /* 0x740 */ s32 platformCount; + /* 0x744 */ s32 nextPlatformIndex; // used for the second phase cutscene to dictate where the Wizrobe should run to next + /* 0x748 */ s16 curPlatformIndex; + /* 0x74A */ s16 type; + /* 0x74C */ s16 switchFlag; + /* 0x74E */ s16 subCamId; + /* 0x750 */ s16 isDead; + /* 0x752 */ s16 drawDmgEffTimer; + /* 0x754 */ s16 drawDmgEffType; + /* 0x758 */ f32 drawDmgEffScale; + /* 0x75C */ f32 drawDmgEffFrozenSteamScale; + /* 0x760 */ Vec3f bodyPartsPos[12]; + /* 0x7F0 */ s16 bodyPartsPosIndex; + /* 0x7F2 */ s16 ghostAlpha[10]; + /* 0x806 */ s16 ghostNextPlatformIndex[10]; + /* 0x81C */ Vec3f ghostPos[10]; + /* 0x894 */ Vec3s ghostRot[10]; + /* 0x8D0 */ Vec3s ghostJointTables[10][WIZROBE_LIMB_MAX]; } EnWiz; // size = 0xD80 extern const ActorInit En_Wiz_InitVars; 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 d49e71c08..ce13687a7 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 @@ -1,7 +1,7 @@ /* * File: z_en_wiz_brock.c * Overlay: ovl_En_Wiz_Brock - * Description: Wizzrobe Warp Platform + * Description: Wizrobe Warp Platform */ #include "z_en_wiz_brock.h" @@ -11,13 +11,6 @@ #define THIS ((EnWizBrock*)thisx) -typedef enum { - PLATFORM_TYPE_INACTIVE, - PLATFORM_TYPE_FIRE, - PLATFORM_TYPE_ICE, - PLATFORM_TYPE_MAX, -} PlatformType; - void EnWizBrock_Init(Actor* thisx, PlayState* play); void EnWizBrock_Destroy(Actor* thisx, PlayState* play); void EnWizBrock_Update(Actor* thisx, PlayState* play); @@ -26,7 +19,7 @@ void EnWizBrock_Draw(Actor* thisx, PlayState* play); void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play); void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play); -s16 platformCount = 0; +s16 sPlatformIndex = 0; const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, @@ -45,13 +38,13 @@ void EnWizBrock_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + CollisionHeader_GetVirtual(&gWizrobePlatformCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->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->platformIndex = sPlatformIndex++; 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; @@ -68,12 +61,12 @@ void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play) { } /** - * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * @brief Checks the platform status, when the Wizrobe is defeated, which triggers timer to * count up to 30 at which point the platforms are despawned. */ void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play) { - if (this->platformType == PLATFORM_TYPE_INACTIVE) { - if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + if (this->platformType == EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != EN_WIZ_BROCK_PLATFORM_TYPE_MAX) { this->platformType = this->dyna.actor.colChkInfo.health; } } @@ -115,30 +108,30 @@ void EnWizBrock_Draw(Actor* thisx, PlayState* play) { Scene_SetRenderModeXlu(play, 0, 1); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - Gfx_DrawDListOpa(play, gWizzrobePlatform); + Gfx_DrawDListOpa(play, gWizrobePlatformDL); } else { Scene_SetRenderModeXlu(play, 1, 2); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); - Gfx_DrawDListXlu(play, gWizzrobePlatform); + Gfx_DrawDListXlu(play, gWizrobePlatformDL); } CLOSE_DISPS(play->state.gfxCtx); - if (this->platformType != PLATFORM_TYPE_INACTIVE) { + if (this->platformType != EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWizrobePlatformCenterTexAnim)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - if (this->platformType == PLATFORM_TYPE_FIRE) { + if (this->platformType == EN_WIZ_BROCK_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(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + gSPDisplayList(POLY_XLU_DISP++, &gWizrobePlatformCenterDL); CLOSE_DISPS(play->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 0f0150697..3b23d08b0 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 @@ -3,6 +3,13 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE, + /* 1 */ EN_WIZ_BROCK_PLATFORM_TYPE_FIRE, + /* 2 */ EN_WIZ_BROCK_PLATFORM_TYPE_ICE, + /* 3 */ EN_WIZ_BROCK_PLATFORM_TYPE_MAX, +} EnWizBrockPlatformType; + struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, PlayState*); @@ -12,8 +19,8 @@ typedef struct EnWizBrock { /* 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 + /* 0x1A6 */ s16 unk_1A6; // set to 0, but never used + /* 0x1A8 */ s16 platformIndex; // Numeric identifier for platform /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 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 666a5156b..eea112f89 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 @@ -1,7 +1,7 @@ /* * File: z_en_wiz_fire.c * Overlay: ovl_En_Wiz_Fire - * Description: Wizzrobe Fire/Ice Attack + * Description: Wizrobe Fire/Ice Attack */ #include "z_en_wiz_fire.h" @@ -17,18 +17,25 @@ void EnWizFire_Destroy(Actor* thisx, PlayState* play); void EnWizFire_Update(Actor* thisx, PlayState* play); void EnWizFire_Draw(Actor* thisx, PlayState* play); -void func_80A4984C(EnWizFire* this, PlayState* play); -void func_80A49A44(EnWizFire* this, PlayState* play); -void func_80A49F38(EnWizFire* this, PlayState* play); -void func_80A49FD8(EnWizFire* this, PlayState* play); -void func_80A4A11C(EnWizFire* this, PlayState* play); -void func_80A4A608(EnWizFire* this, PlayState* play); -void func_80A4BAB4(Actor* thisx, PlayState* play); -void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); -void func_80A4BDDC(EnWizFire* this, PlayState* play); -void func_80A4BF78(EnWizFire* this, PlayState* play); +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_Pool(EnWizFire* this, PlayState* play); +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play); +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play); +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel); +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play); +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play); -static s32 D_80A4C1C0 = 0; +typedef enum { + /* 0 */ EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_ACTION_SMALL_FLAME, + /* 2 */ EN_WIZ_FIRE_ACTION_POOL, + /* 3 */ EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE, +} EnWizFireAction; + +static s32 sPoolHitByIceArrow = false; const ActorInit En_Wiz_Fire_InitVars = { ACTOR_EN_WIZ_FIRE, @@ -66,48 +73,52 @@ void EnWizFire_Init(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->unk_162 = this->actor.params; + this->type = EN_WIZ_FIRE_GET_TYPE(&this->actor); this->actor.targetMode = 3; - this->unk_172 = 10; - this->unk_1FC = 255.0f; + this->wallCheckTimer = 10; + this->alpha = 255.0f; this->actor.flags &= ~ACTOR_FLAG_1; if (!Player_HasMirrorShieldEquipped(play)) { this->collider.info.toucher.dmgFlags = 0x20000000; } - switch (this->unk_162) { - case 4: - this->unk_166 = 1; + switch (this->type) { + case EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE: + this->isIceType = true; this->collider.info.toucher.damage = 8; this->collider.info.toucher.effect = 2; this->collider.info.bumper.dmgFlags = (0x1000000 | 0x800 | 0x200 | 0x2); - this->unk_162 = 0; - - case 0: - if (this->unk_162 == 4) { - this->unk_162 = 0; + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; + // fallthrough + case EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE: + if (this->type == EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE) { + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; this->collider.info.toucher.damage = 8; } - - case 1: - case 3: - this->actionFunc = func_80A4984C; + // fallthrough + case EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE: + case EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE: + this->actionFunc = EnWiz_SetupMoveMagicProjectile; break; - case 2: - this->actor.draw = func_80A4BAB4; - this->unk_170 = Rand_S16Offset(0, 10000); - this->unk_160 = 1; + case EN_WIZ_FIRE_TYPE_SMALL_FLAME: + this->actor.draw = EnWizFire_DrawSmallFlame; + this->smallFlameScroll = Rand_S16Offset(0, 10000); + this->action = EN_WIZ_FIRE_ACTION_SMALL_FLAME; this->collider.info.toucher.damage = 2; - this->actionFunc = func_80A49F38; + this->actionFunc = EnWiz_SetupSmallFlame; + break; + + default: + break; } } void EnWizFire_Destroy(Actor* thisx, PlayState* play) { EnWizFire* this = THIS; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { play->envCtx.lightSettings.fogColor[2] = 0; play->envCtx.lightSettings.fogColor[1] = play->envCtx.lightSettings.fogColor[2]; play->envCtx.lightSettings.fogColor[0] = play->envCtx.lightSettings.fogColor[2]; @@ -122,146 +133,159 @@ void EnWizFire_Destroy(Actor* thisx, PlayState* play) { play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.fogColor[2]; play->envCtx.lightSettings.fogNear = play->envCtx.lightSettings.fogColor[2]; } + Collider_DestroyCylinder(play, &this->collider); } -void func_80A4984C(EnWizFire* this, PlayState* play) { - Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_178); i++) { - this->unk_178[i] = this->actor.world.pos; + for (i = 0; i < ARRAY_COUNT(this->magicProjectilePos); i++) { + this->magicProjectilePos[i] = this->actor.world.pos; } - this->unk_16E = 0; + this->lowestUsedIndex = 0; + 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; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; } else { - sp44.z = 12.0f; + velocity.z = 12.0f; } - Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_MultVec3f(&velocity, &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) { + this->timer = 50; + + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { this->actor.velocity.y = 10.0f; this->actor.gravity = -1.0f; - this->unk_150 = 0.01f; + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; - this->unk_168 = 100; + this->targetScale = 0.02f; + this->timer = 100; } - this->unk_160 = 0; - this->actionFunc = func_80A49A44; + + this->action = EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE; + this->actionFunc = EnWiz_MoveMagicProjectile; } -void func_80A49A44(EnWizFire* this, PlayState* play) { - Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; +/** + * Moves all types of magic projectiles around, including arcing ones created by the + * Fire Wizrobe's attack or ones reflected by the Mirror Shield. + */ +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; this->actor.world.rot.z += 5000; - if (this->unk_162 != 0) { - this->unk_150 = 0.01f; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; + this->targetScale = 0.02f; } - if ((this->unk_168 == 0) && (this->unk_14C < 0.001f)) { + if ((this->timer == 0) && (this->scale < 0.001f)) { Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if (this->unk_168 == 0) { - this->unk_150 = 0.0f; + if (this->timer == 0) { + this->targetScale = 0.0f; } - Math_ApproachF(&this->unk_14C, this->unk_150, 0.2f, 0.01f); + Math_ApproachF(&this->scale, this->targetScale, 0.2f, 0.01f); - if (this->unk_172 == 0) { - if ((this->actor.bgCheckFlags & 8) && (this->unk_162 == 0) && (this->unk_168 != 0) && + if (this->wallCheckTimer == 0) { + if ((this->actor.bgCheckFlags & 8) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0) && (this->actor.bgCheckFlags & 8)) { - D_80A4C1C0 = 0; - this->unk_168 = 0; - this->unk_150 = 0.0f; + sPoolHitByIceArrow = false; + this->timer = 0; + this->targetScale = 0.0f; } } - if ((this->actor.bgCheckFlags & 1) && (this->unk_16A == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->poolTimer == 0)) { s32 i; - s16 phi_s0; - s32 temp; + s16 arcingProjectileRotY; + s32 pad; - if (this->unk_162 == 1) { - this->unk_16A = 10; + if (this->type == EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE) { + this->increaseLowestUsedIndexTimer = 10; Matrix_Push(); Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); - sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultVec3f(&sp54, &this->actor.velocity); + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + Matrix_MultVec3f(&velocity, &this->actor.velocity); Matrix_Pop(); this->actor.velocity.y = 6.0f; this->actor.gravity = -0.7f; - if (this->unk_164 == 0) { + if (!this->hasSpawnedSmallFlame) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); - this->unk_164 = 1; + this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, + EN_WIZ_FIRE_TYPE_SMALL_FLAME); + this->hasSpawnedSmallFlame = true; } - this->unk_168 = 0; - this->unk_14C = 0.0f; + this->timer = 0; + this->scale = 0.0f; Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if ((this->unk_162 == 0) && (this->unk_168 != 0)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->actor.floorBgId == BGCHECK_SCENE) { - this->unk_16A = 100; - if (this->unk_166 == 0) { - phi_s0 = 0; + this->poolTimer = 100; + if (!this->isIceType) { + arcingProjectileRotY = 0; for (i = 0; i < 5; i++) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); - phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); + this->actor.world.pos.y, this->actor.world.pos.z, 0, arcingProjectileRotY, 0, + EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE); + arcingProjectileRotY += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); } Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - this->unk_16A = Rand_S16Offset(70, 30); - if (this->unk_16A != 0) { + this->poolTimer = Rand_S16Offset(70, 30); + if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); } - } else if (this->unk_16A != 0) { + } else if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_168 = 0; - this->unk_160 = 2; - this->unk_14C = 0.0f; - this->actionFunc = func_80A4A11C; + this->timer = 0; + this->action = EN_WIZ_FIRE_ACTION_POOL; + this->scale = 0.0f; + this->actionFunc = EnWiz_Pool; } + return; } } - if ((this->unk_162 != 3) && (this->unk_168 != 0)) { + if ((this->type != EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; + this->timer = 0; + this->hitByIceArrow = true; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } @@ -272,104 +296,111 @@ void func_80A49A44(EnWizFire* this, PlayState* play) { this->collider.base.atFlags |= AT_TYPE_PLAYER; this->collider.info.toucher.dmgFlags = 0x20; this->collider.info.toucher.damage = 2; - this->unk_168 = 100; - this->unk_162 = 3; + this->timer = 100; + this->type = EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE; this->actor.velocity.x *= -1.0f; this->actor.velocity.y *= -0.5f; this->actor.velocity.z *= -1.0f; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { - ((EnWiz*)this->actor.parent)->unk_3BA = 0; + ((EnWiz*)this->actor.parent)->hasActiveProjectile = false; } } } } -void func_80A49F38(EnWizFire* this, PlayState* play) { - this->unk_150 = 0.02f; - this->unk_168 = Rand_S16Offset(50, 50); - this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->unk_158 = randPlusMinusPoint5Scaled(1.0f) * 0.005f; - this->unk_15C = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->actionFunc = func_80A49FD8; +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play) { + this->targetScale = 0.02f; + this->timer = Rand_S16Offset(50, 50); + this->scaleMod.x = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->scaleMod.y = randPlusMinusPoint5Scaled(1.0f) * 0.005f; + this->scaleMod.z = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->actionFunc = EnWiz_SmallFlame; } -void func_80A49FD8(EnWizFire* this, PlayState* play) { - if (this->unk_168 > 10) { - Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); +/** + * Manages the small flame that is created when the arcing projectiles from the Fire Wizrobe's + * attack hit the floor. + */ +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play) { + if (this->timer > 10) { + Math_ApproachF(&this->scale, this->targetScale, 0.3f, 0.01f); } else { - Math_ApproachF(&this->unk_14C, 2.0f * this->unk_150, 0.2f, 0.002f); - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 35.0f); - if ((this->unk_168 == 0) && (this->unk_1FC < 2.0f)) { + Math_ApproachF(&this->scale, 2.0f * this->targetScale, 0.2f, 0.002f); + Math_ApproachZeroF(&this->alpha, 1.0f, 35.0f); + if ((this->timer == 0) && (this->alpha < 2.0f)) { Actor_MarkForDeath(&this->actor); } return; } if (this->collider.base.acFlags & AC_HIT) { - if (this->unk_168 != 0) { + if (this->timer != 0) { this->collider.base.acFlags &= ~AC_HIT; - if (this->unk_168 > 10) { - this->unk_168 -= 10; + if (this->timer > 10) { + this->timer -= 10; } if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; + this->timer = 0; + this->hitByIceArrow = true; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } } - if (this->unk_168 != 0) { + if (this->timer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } } -void func_80A4A11C(EnWizFire* this, PlayState* play) { +/** + * Manages the pool of fire or ice that is created when a magic projectile hits the floor. + */ +void EnWiz_Pool(EnWizFire* this, PlayState* play) { s32 pad; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL) && (this->actor.parent->colChkInfo.health == 0)) { - this->unk_16A = 0; - this->unk_174 = 1; + this->poolTimer = 0; + this->playerHitByIceProjectile = true; } - this->unk_16E++; + this->lowestUsedIndex++; - if (this->unk_16E > 10) { - this->unk_16E = 10; + if (this->lowestUsedIndex > 10) { + this->lowestUsedIndex = 10; } - if (this->unk_16A != 0) { - Math_ApproachF(&this->unk_200, 60.0f, 0.5f, 10.0f); - if (this->unk_166 == 1) { - Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp34; + if (this->poolTimer != 0) { + Math_ApproachF(&this->blendScale, 60.0f, 0.5f, 10.0f); + if (this->isIceType == true) { + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; - sp40.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - sp40.y = 0.23f; - sp40.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.y = 0.23f; + accel.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - Math_Vec3f_Copy(&sp34, &this->actor.world.pos); - sp34.x += randPlusMinusPoint5Scaled(150.0f); - sp34.z += randPlusMinusPoint5Scaled(150.0f); + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += randPlusMinusPoint5Scaled(150.0f); + pos.z += randPlusMinusPoint5Scaled(150.0f); - Math_ApproachF(&this->unk_1F0, 0.022f, 0.3f, 0.01f); - this->collider.dim.radius = this->unk_1F0 * 4300.0f; + Math_ApproachF(&this->poolScale, 0.022f, 0.3f, 0.01f); + this->collider.dim.radius = this->poolScale * 4300.0f; this->collider.dim.height = 30; this->collider.dim.yShift = 15; - func_80A4BC74(this, &sp34, &sp40); + EnWizFire_InitializeEffect(this, &pos, &accel); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); return; } - Math_ApproachF(&this->unk_1F0, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F8, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F4, 0.02f, 0.3f, 0.2f); - this->collider.dim.radius = this->unk_1F0 * 4000.0f; - this->collider.dim.height = this->unk_1F4 * 1850.0f; + Math_ApproachF(&this->poolScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->fireSmokeScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->bigFlameScale, 0.02f, 0.3f, 0.2f); + this->collider.dim.radius = this->poolScale * 4000.0f; + this->collider.dim.height = this->bigFlameScale * 1850.0f; this->collider.dim.yShift = -15; if (this->collider.dim.height < 2) { @@ -378,231 +409,228 @@ void func_80A4A11C(EnWizFire* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((D_80A4C1C0 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { - D_80A4C1C0 = 1; - this->unk_148 = 1; - this->unk_16A = 0; + if (!sPoolHitByIceArrow && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { + sPoolHitByIceArrow = true; + this->hitByIceArrow = true; + this->poolTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; Actor_SetFocus(&this->actor, 0.0f); return; } - Math_ApproachZeroF(&this->unk_200, 0.2f, 3.0f); + Math_ApproachZeroF(&this->blendScale, 0.2f, 3.0f); - if (this->unk_166 == 1) { - Math_ApproachZeroF(&this->unk_1F0, 0.046f, 0.001f); + if (this->isIceType == true) { + Math_ApproachZeroF(&this->poolScale, 0.046f, 0.001f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - if (this->unk_164 == 0) { - if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->unk_1F0 < 0.05f)) { + if (!this->shouldPoolFadeOut) { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->poolScale < 0.05f)) { EnWiz* wiz = (EnWiz*)this->actor.parent; this->collider.dim.yShift = -15; - this->unk_164 = 1; - wiz->unk_3BA = 0; + this->shouldPoolFadeOut = true; + wiz->hasActiveProjectile = false; } } - if ((this->unk_164 != 0) && (this->unk_1F0 < 0.05f)) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 5.0f); + if (this->shouldPoolFadeOut && (this->poolScale < 0.05f)) { + Math_ApproachZeroF(&this->alpha, 1.0f, 5.0f); } - if ((this->unk_1F0 < 0.001f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; + if ((this->poolScale < 0.001f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; Actor_MarkForDeath(&this->actor); } + return; } - Math_ApproachZeroF(&this->unk_1F4, 0.1f, 0.01f); + Math_ApproachZeroF(&this->bigFlameScale, 0.1f, 0.01f); - if (this->unk_1F4 < 0.01f) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 10.0f); - if ((this->unk_1FC < 10.0f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && - (this->actor.parent->update != NULL)) { + if (this->bigFlameScale < 0.01f) { + Math_ApproachZeroF(&this->alpha, 1.0f, 10.0f); + if ((this->alpha < 10.0f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } + Actor_MarkForDeath(&this->actor); } } } -void func_80A4A608(EnWizFire* this, PlayState* play) { - if (this->unk_16A == 0) { - this->unk_16A = 2; - this->unk_16E++; - if (this->unk_16E >= 6) { - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ)) { +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play) { + if (this->increaseLowestUsedIndexTimer == 0) { + this->increaseLowestUsedIndexTimer = 2; + this->lowestUsedIndex++; + if (this->lowestUsedIndex >= 6) { + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - D_80A4C1C0 = 0; + sPoolHitByIceArrow = false; if (wiz->actor.update != NULL) { - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } } + Actor_MarkForDeath(&this->actor); } } } void EnWizFire_Update(Actor* thisx, PlayState* play2) { - static Color_RGB8 D_80A4C234[] = { - { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, - { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, + // These are AmbientColor, DiffuseColor1, DiffuseColor2, and fogColor + static Color_RGB8 lightSettingsColors[] = { + { 100, 40, 40 }, { 180, 120, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, // Fire + { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, // Ice }; - static Color_RGBA8 D_80A4C24C = { 250, 250, 250, 255 }; - static Color_RGBA8 D_80A4C250 = { 180, 180, 180, 255 }; PlayState* play = play2; EnWizFire* this = THIS; Player* player = GET_PLAYER(play); s32 j; - s16 temp_s0; - s16 idx; + s16 randomScale; + s16 index; - Actor_SetScale(&this->actor, this->unk_14C); - func_80A4BDDC(this, play); - this->unk_204 = this->unk_200 / 60.0f; + Actor_SetScale(&this->actor, this->scale); + EnWizFire_UpdateEffects(this, play); + this->blendScaleFrac = this->blendScale / 60.0f; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor* wiz = this->actor.parent; - if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && (((EnWiz*)wiz)->unk_74A != 2)) { - f32 phi_f0; + if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && + (((EnWiz*)wiz)->type != EN_WIZ_TYPE_FIRE_NO_BGM)) { + f32 fogNear; - idx = this->unk_166 * 4; - - phi_f0 = 970.0f; - if (this->unk_166 == 0) { - phi_f0 = 968.0f; + index = this->isIceType * 4; + fogNear = 970.0f; + if (!this->isIceType) { + fogNear = 968.0f; } - play->envCtx.lightSettings.fogNear = (phi_f0 - (s16)play->envCtx.unk_C4.fogNear) * this->unk_204; + play->envCtx.lightSettings.fogNear = (fogNear - (s16)play->envCtx.unk_C4.fogNear) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.ambientColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.ambientColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.ambientColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.ambientColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.ambientColor[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.ambientColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.ambientColor[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.diffuseColor1[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor1[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor1[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.diffuseColor2[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor2[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.diffuseColor2[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor[2]) * this->blendScaleFrac; - idx++; + index++; play->envCtx.lightSettings.fogColor[0] = - ((f32)D_80A4C234[idx].r - play->envCtx.unk_C4.fogColor[0]) * this->unk_204; + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.fogColor[0]) * this->blendScaleFrac; play->envCtx.lightSettings.fogColor[1] = - ((f32)D_80A4C234[idx].g - play->envCtx.unk_C4.fogColor[1]) * this->unk_204; + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.fogColor[1]) * this->blendScaleFrac; play->envCtx.lightSettings.fogColor[2] = - ((f32)D_80A4C234[idx].b - play->envCtx.unk_C4.fogColor[2]) * this->unk_204; + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.fogColor[2]) * this->blendScaleFrac; } } - this->unk_170++; + this->smallFlameScroll++; this->actionFunc(this, play); this->actor.shape.yOffset = 10.0f; Actor_UpdatePos(&this->actor); - this->unk_178[0] = this->actor.world.pos; + this->magicProjectilePos[0] = this->actor.world.pos; - for (j = 8; j >= 0; j--) { - this->unk_178[j + 1] = this->unk_178[j]; + for (j = ARRAY_COUNT(this->magicProjectilePos) - 2; j >= 0; j--) { + this->magicProjectilePos[j + 1] = this->magicProjectilePos[j]; } this->actor.velocity.y += this->actor.gravity; - if (this->unk_172 != 0) { - this->unk_172--; - } - - if (this->unk_168 != 0) { - this->unk_168--; - } - - if (this->unk_16C != 0) { - this->unk_16C--; - } - - if (this->unk_16A != 0) { - this->unk_16A--; - } + DECR(this->wallCheckTimer); + DECR(this->timer); + DECR(this->steamSpawnTimer); + DECR(this->poolTimer); Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, 0x1D); - if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - f32 sp54; + if ((this->hitByIceArrow || sPoolHitByIceArrow) && (this->steamSpawnTimer == 0)) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; s32 i; - sp70.x = 0.0f; - sp70.y = 1.0f; - sp70.z = 0.0f; - sp64.x = 0.0f; - sp64.y = 1.0f; - sp64.z = 0.0f; + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; - sp54 = Rand_S16Offset(20, 10); - if (this->unk_162 == 0) { - sp54 = Rand_S16Offset(40, 20); + scaleStep = Rand_S16Offset(20, 10); + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + scaleStep = Rand_S16Offset(40, 20); } - this->unk_16C = Rand_S16Offset(2, 2); + this->steamSpawnTimer = Rand_S16Offset(2, 2); for (i = 0; i < 2; i++) { - temp_s0 = Rand_S16Offset(20, 20); - sp58.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.x; - sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; - temp_s0 = Rand_S16Offset(20, 20); - sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; - func_800B0DE0(play, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + static Color_RGBA8 sSteamPrimColor = { 250, 250, 250, 255 }; + static Color_RGBA8 sSteamEnvColor = { 180, 180, 180, 255 }; + + randomScale = Rand_S16Offset(20, 20); + pos.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * randomScale) + this->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; + randomScale = Rand_S16Offset(20, 20); + pos.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * randomScale) + this->actor.world.pos.z; + func_800B0DE0(play, &pos, &velocity, &accel, &sSteamPrimColor, &sSteamEnvColor, Rand_S16Offset(350, 100), + scaleStep); } } - if (this->unk_160 < 2) { - this->collider.dim.radius = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.height = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.yShift = (this->unk_14C * -0.75f) - 5.0f; + if (this->action < EN_WIZ_FIRE_ACTION_POOL) { + this->collider.dim.radius = (this->scale * 15.0f) + 25.0f; + this->collider.dim.height = (this->scale * 15.0f) + 25.0f; + this->collider.dim.yShift = (this->scale * -0.75f) - 5.0f; } - if (this->unk_162 == 2) { + if (this->type == EN_WIZ_FIRE_TYPE_SMALL_FLAME) { this->collider.dim.radius = 10; - this->collider.dim.height = this->unk_14C * 5000.0f; + this->collider.dim.height = this->scale * 5000.0f; this->collider.dim.yShift = 0; } if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); if (player->invincibilityTimer > 0) { player->invincibilityTimer += 40; - if (this->unk_166 != 0) { + if (this->isIceType) { player->invincibilityTimer += 50; - this->unk_174 = 1; + this->playerHitByIceProjectile = true; } } } @@ -612,7 +640,8 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { player->unk_AE8 = 90; } - if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { + if (!this->hitByIceArrow && !sPoolHitByIceArrow && + ((this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) || (this->alpha > 200.0f))) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (player->invincibilityTimer == 0) { @@ -621,61 +650,63 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { } } -void func_80A4B0C8(EnWizFire* this, PlayState* play) { +void EnWizFire_DrawIcePool(EnWizFire* this, PlayState* play) { s32 pad; OPEN_DISPS(play->state.gfxCtx); - if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); 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); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005190); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames & 0x7F, -play->state.frames & 0x7F, 0x20, - 0x40, 1, play->state.frames & 0xFF, play->state.frames & 0xFF, 0x10, 0x10)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames & 0x7F, -play->state.frames & 0x7F, 32, + 64, 1, play->state.frames & 0xFF, play->state.frames & 0xFF, 16, 16)); Matrix_RotateYS(0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolShineDL); } - func_80A4BF78(this, play); + EnWizFire_DrawEffects(this, play); CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4B33C(EnWizFire* this, PlayState* play2) { +void EnWizFire_DrawFirePoolAndFlame(EnWizFire* this, PlayState* play2) { PlayState* play = play2; OPEN_DISPS(play->state.gfxCtx); - if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); + 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); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, -play->state.frames % 128, 0, 0x20, 0x20, 1, (play->state.frames * 2) % 128, 0, 0x20, 0x20)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFirePoolDL); Matrix_Pop(); + Matrix_Push(); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -684,16 +715,17 @@ void func_80A4B33C(EnWizFire* this, PlayState* play2) { Gfx_TwoTexScroll(play->state.gfxCtx, 0, play->state.frames % 128, (-play->state.frames * 6) % 256, 0x20, 0x40, 1, (play->state.frames * 2) % 128, (-play->state.frames * 6) % 256, 0x20, 0x40)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->alpha); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); - Matrix_Scale(this->unk_1F8, this->unk_1F8, this->unk_1F8, MTXMODE_APPLY); + Matrix_Scale(this->fireSmokeScale, this->fireSmokeScale, this->fireSmokeScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFireSmokeDL); Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); @@ -704,10 +736,10 @@ void func_80A4B33C(EnWizFire* this, PlayState* play2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); - Matrix_Scale(this->unk_1F4, this->unk_1F4, this->unk_1F4, MTXMODE_APPLY); + Matrix_Scale(this->bigFlameScale, this->bigFlameScale, this->bigFlameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeBigFlameDL); } CLOSE_DISPS(play->state.gfxCtx); @@ -724,11 +756,11 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { func_8012C2DC(play->state.gfxCtx); Matrix_Push(); - for (i = 9; i >= this->unk_16E; i--) { - f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); + for (i = ARRAY_COUNT(this->magicProjectilePos) - 1; i >= this->lowestUsedIndex; i--) { + f32 scale = this->actor.scale.x - (i * -0.0019f); - if (temp_f20 > 0.0f) { - if (this->unk_166 == 0) { + if (scale > 0.0f) { + if (!this->isIceType) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255 - (i * 25), 0, 255 - (i * 25)); gDPSetEnvColor(POLY_XLU_DISP++, 255 - (i * 25), 0, 0, 0); } else { @@ -736,14 +768,14 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - 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_Translate(this->magicProjectilePos[i].x, this->magicProjectilePos[i].y + this->actor.shape.yOffset, + this->magicProjectilePos[i].z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeMagicProjectileDL); } } @@ -751,92 +783,92 @@ void EnWizFire_Draw(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); - if (this->unk_166 == 0) { - func_80A4B33C(this, play); + if (!this->isIceType) { + EnWizFire_DrawFirePoolAndFlame(this, play); } else { - func_80A4B0C8(this, play); + EnWizFire_DrawIcePool(this, play); } } -void func_80A4BAB4(Actor* thisx, PlayState* play) { +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play) { s32 pad; EnWizFire* this = THIS; OPEN_DISPS(play->state.gfxCtx); 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, + Matrix_Scale(this->scale + this->scaleMod.x, this->scale + this->scaleMod.y, this->scale + this->scaleMod.z, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, - (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, this->smallFlameScroll & 0x7F, + (-this->smallFlameScroll * 10) & 0x7F, 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeSmallFlameDL); CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel) { s16 i; - EnWizFireStruct* ptr = this->unk_254; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 == 0) { - ptr->unk_00 = 1; - Math_Vec3f_Copy(&ptr->unk_1C, &gZeroVec3f); - ptr->unk_01 = Rand_ZeroFloat(100.0f); - ptr->unk_10 = *arg1; - ptr->unk_28 = *arg2; - ptr->unk_0C = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; - ptr->unk_08 = 0; - ptr->unk_06 = 0; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + Math_Vec3f_Copy(&effect->velocity, &gZeroVec3f); + effect->smokeScroll = Rand_ZeroFloat(100.0f); + effect->pos = *pos; + effect->accel = *accel; + effect->scale = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; + effect->shouldDecreaseAlpha = 0; + effect->alpha = 0; break; } } } -void func_80A4BDDC(EnWizFire* this, PlayState* play) { +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play) { s32 i; - EnWizFireStruct* ptr = &this->unk_254[0]; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 != 0) { - ptr->unk_01++; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->smokeScroll++; - ptr->unk_10.x += ptr->unk_1C.x; - ptr->unk_10.y += ptr->unk_1C.y; - ptr->unk_10.z += ptr->unk_1C.z; + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; - ptr->unk_1C.x += ptr->unk_28.x; - ptr->unk_1C.y += ptr->unk_28.y; - ptr->unk_1C.z += ptr->unk_28.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (ptr->unk_08 == 0) { - ptr->unk_06 += 10; - if (ptr->unk_06 >= 100) { - ptr->unk_08 = 1; + if (!effect->shouldDecreaseAlpha) { + effect->alpha += 10; + if (effect->alpha >= 100) { + effect->shouldDecreaseAlpha = true; } } else { - ptr->unk_06 -= 8; - if (ptr->unk_06 <= 0) { - ptr->unk_06 = 0; - ptr->unk_00 = 0; + effect->alpha -= 8; + if (effect->alpha <= 0) { + effect->alpha = 0; + effect->isEnabled = false; } } } } } -void func_80A4BF78(EnWizFire* this, PlayState* play) { +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play) { s16 i; - u8 flag; - EnWizFireStruct* ptr = &this->unk_254[0]; + u8 materialFlag; + EnWizFireEffect* effect = &this->effects[0]; GraphicsContext* gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -844,27 +876,27 @@ void func_80A4BF78(EnWizFire* this, PlayState* play) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); - flag = false; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 != 0) { - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000E70); - flag++; + materialFlag = false; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + if (!materialFlag) { + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeMaterialDL); + materialFlag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, effect->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, (ptr->unk_01 * 0xF) & 0xFF, - 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (effect->smokeScroll * 3) & 0x7F, + (effect->smokeScroll * 0xF) & 0xFF, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); + 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); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000FD8); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeModelDL); } } diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h index b628404bb..180192d4c 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h @@ -3,52 +3,65 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE, + /* 2 */ EN_WIZ_FIRE_TYPE_SMALL_FLAME, + /* 3 */ EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE, + /* 4 */ EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE +} EnWizFireType; + +#define EN_WIZ_FIRE_GET_TYPE(thisx) ((thisx)->params) + struct EnWizFire; typedef void (*EnWizFireActionFunc)(struct EnWizFire*, PlayState*); typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x01 */ u8 unk_01; + /* 0x00 */ u8 isEnabled; + /* 0x01 */ u8 smokeScroll; /* 0x02 */ UNK_TYPE1 unk02[0x4]; - /* 0x06 */ s16 unk_06; - /* 0x08 */ s16 unk_08; - /* 0x0A */ UNK_TYPE1 unk0A[0x2]; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ Vec3f unk_10; - /* 0x1C */ Vec3f unk_1C; - /* 0x28 */ Vec3f unk_28; -} EnWizFireStruct; // size = 0x34 + /* 0x06 */ s16 alpha; + /* 0x08 */ s16 shouldDecreaseAlpha; + /* 0x0C */ f32 scale; + /* 0x10 */ Vec3f pos; + /* 0x1C */ Vec3f velocity; + /* 0x28 */ Vec3f accel; +} EnWizFireEffect; // size = 0x34 typedef struct EnWizFire { /* 0x0000 */ Actor actor; /* 0x0144 */ EnWizFireActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ f32 unk_154; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ u8 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; - /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172; - /* 0x0174 */ s8 unk_174; - /* 0x0178 */ Vec3f unk_178[10]; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ f32 unk_1FC; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; + /* 0x0148 */ u8 hitByIceArrow; + /* 0x014C */ f32 scale; + /* 0x0150 */ f32 targetScale; + /* 0x0154 */ Vec3f scaleMod; + /* 0x0160 */ s16 action; + /* 0x0162 */ s16 type; + /* 0x0164 */ union { + u8 shouldPoolFadeOut; + u8 hasSpawnedSmallFlame; + }; + /* 0x0166 */ s16 isIceType; + /* 0x0168 */ s16 timer; + /* 0x016A */ union { + s16 poolTimer; + s16 increaseLowestUsedIndexTimer; + }; + /* 0x016C */ s16 steamSpawnTimer; + /* 0x016E */ s16 lowestUsedIndex; + /* 0x0170 */ s16 smallFlameScroll; + /* 0x0172 */ s16 wallCheckTimer; // The projectile won't check for impacts with walls until this is zero + /* 0x0174 */ s8 playerHitByIceProjectile; // Set, but never used + /* 0x0178 */ Vec3f magicProjectilePos[10]; + /* 0x01F0 */ f32 poolScale; + /* 0x01F4 */ f32 bigFlameScale; + /* 0x01F8 */ f32 fireSmokeScale; + /* 0x01FC */ f32 alpha; + /* 0x0200 */ f32 blendScale; + /* 0x0204 */ f32 blendScaleFrac; /* 0x0208 */ ColliderCylinder collider; - /* 0x0254 */ EnWizFireStruct unk_254[200]; + /* 0x0254 */ EnWizFireEffect effects[200]; } EnWizFire; // size = 0x2AF4 extern const ActorInit En_Wiz_Fire_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 519550a83..ef47869a5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10441,31 +10441,31 @@ 0x80A45164:("EnSekihi_Draw",), 0x80A45360:("EnWiz_Init",), 0x80A45568:("EnWiz_Destroy",), - 0x80A455C4:("func_80A455C4",), - 0x80A456A0:("func_80A456A0",), - 0x80A45CD8:("func_80A45CD8",), - 0x80A460A4:("func_80A460A4",), - 0x80A46280:("func_80A46280",), - 0x80A462F8:("func_80A462F8",), - 0x80A46414:("func_80A46414",), - 0x80A4668C:("func_80A4668C",), - 0x80A46764:("func_80A46764",), - 0x80A468CC:("func_80A468CC",), - 0x80A46990:("func_80A46990",), - 0x80A46C88:("func_80A46C88",), - 0x80A46CC4:("func_80A46CC4",), - 0x80A46DDC:("func_80A46DDC",), - 0x80A46E24:("func_80A46E24",), - 0x80A47000:("func_80A47000",), - 0x80A470D8:("func_80A470D8",), - 0x80A47298:("func_80A47298",), - 0x80A473B8:("func_80A473B8",), - 0x80A4767C:("func_80A4767C",), - 0x80A476C8:("func_80A476C8",), - 0x80A477E8:("func_80A477E8",), + 0x80A455C4:("EnWiz_ChangeAnim",), + 0x80A456A0:("EnWiz_HandleIntroCutscene",), + 0x80A45CD8:("EnWiz_SelectPlatform",), + 0x80A460A4:("EnWiz_MoveGhosts",), + 0x80A46280:("EnWiz_StartIntroCutscene",), + 0x80A462F8:("EnWiz_SetupAppear",), + 0x80A46414:("EnWiz_Appear",), + 0x80A4668C:("EnWiz_SetupDance",), + 0x80A46764:("EnWiz_Dance",), + 0x80A468CC:("EnWiz_SetupSecondPhaseCutscene",), + 0x80A46990:("EnWiz_SecondPhaseCutscene",), + 0x80A46C88:("EnWiz_SetupWindUp",), + 0x80A46CC4:("EnWiz_WindUp",), + 0x80A46DDC:("EnWiz_SetupAttack",), + 0x80A46E24:("EnWiz_Attack",), + 0x80A47000:("EnWiz_SetupDisappear",), + 0x80A470D8:("EnWiz_Disappear",), + 0x80A47298:("EnWiz_SetupDamaged",), + 0x80A473B8:("EnWiz_Damaged",), + 0x80A4767C:("EnWiz_SetupDead",), + 0x80A476C8:("EnWiz_Dead",), + 0x80A477E8:("EnWiz_UpdateDamage",), 0x80A47C6C:("EnWiz_Update",), - 0x80A47FCC:("func_80A47FCC",), - 0x80A48138:("func_80A48138",), + 0x80A47FCC:("EnWiz_PostLimbDrawOpa",), + 0x80A48138:("EnWiz_PostLimbDrawXlu",), 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), @@ -10475,20 +10475,20 @@ 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), 0x80A497D4:("EnWizFire_Destroy",), - 0x80A4984C:("func_80A4984C",), - 0x80A49A44:("func_80A49A44",), - 0x80A49F38:("func_80A49F38",), - 0x80A49FD8:("func_80A49FD8",), - 0x80A4A11C:("func_80A4A11C",), - 0x80A4A608:("func_80A4A608",), + 0x80A4984C:("EnWiz_SetupMoveMagicProjectile",), + 0x80A49A44:("EnWiz_MoveMagicProjectile",), + 0x80A49F38:("EnWiz_SetupSmallFlame",), + 0x80A49FD8:("EnWiz_SmallFlame",), + 0x80A4A11C:("EnWiz_Pool",), + 0x80A4A608:("EnWiz_KillMagicProjectile",), 0x80A4A698:("EnWizFire_Update",), - 0x80A4B0C8:("func_80A4B0C8",), - 0x80A4B33C:("func_80A4B33C",), + 0x80A4B0C8:("EnWizFire_DrawIcePool",), + 0x80A4B33C:("EnWizFire_DrawFirePoolAndFlame",), 0x80A4B804:("EnWizFire_Draw",), - 0x80A4BAB4:("func_80A4BAB4",), - 0x80A4BC74:("func_80A4BC74",), - 0x80A4BDDC:("func_80A4BDDC",), - 0x80A4BF78:("func_80A4BF78",), + 0x80A4BAB4:("EnWizFire_DrawSmallFlame",), + 0x80A4BC74:("EnWizFire_InitializeEffect",), + 0x80A4BDDC:("EnWizFire_UpdateEffects",), + 0x80A4BF78:("EnWizFire_DrawEffects",), 0x80A4C490:("EffChange_Init",), 0x80A4C54C:("EffChange_Destroy",), 0x80A4C578:("EffChange_SetColors",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index eac44b02d..57d876acb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -11517,18 +11517,18 @@ 0x80A452A4:("D_80A452A4","UNK_TYPE1","",0x1), 0x80A452B0:("D_80A452B0","UNK_TYPE4","",0x4), 0x80A48B30:("En_Wiz_InitVars","UNK_TYPE1","",0x1), - 0x80A48B50:("D_80A48B50","UNK_TYPE1","",0x1), - 0x80A48CB8:("D_80A48CB8","UNK_PTR","",0x4), - 0x80A48CC8:("D_80A48CC8","UNK_TYPE1","",0x1), - 0x80A48CF4:("D_80A48CF4","UNK_TYPE1","",0x1), - 0x80A48D14:("D_80A48D14","UNK_TYPE1","",0x1), - 0x80A48D34:("D_80A48D34","UNK_TYPE1","",0x1), - 0x80A48D4C:("D_80A48D4C","UNK_TYPE1","",0x1), - 0x80A48D54:("D_80A48D54","UNK_TYPE4","",0x4), - 0x80A48D60:("D_80A48D60","UNK_TYPE1","",0x1), - 0x80A48D64:("D_80A48D64","UNK_TYPE1","",0x1), - 0x80A48D68:("D_80A48D68","UNK_TYPE4","",0x4), - 0x80A48D74:("D_80A48D74","UNK_TYPE4","",0x4), + 0x80A48B50:("sJntSphElementsInit","UNK_TYPE1","",0x1), + 0x80A48CB8:("sJntSphInit","UNK_PTR","",0x4), + 0x80A48CC8:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A48CF4:("sFireWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D14:("sIceWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D34:("sAnimations","UNK_TYPE1","",0x1), + 0x80A48D4C:("sAnimationModes","UNK_TYPE1","",0x1), + 0x80A48D54:("staffTargetFlameScale","UNK_TYPE4","",0x4), + 0x80A48D60:("sDustPrimColor","UNK_TYPE1","",0x1), + 0x80A48D64:("sDustEnvTimer","UNK_TYPE1","",0x1), + 0x80A48D68:("staffFlamePos","UNK_TYPE4","",0x4), + 0x80A48D74:("staffFlamePos","UNK_TYPE4","",0x4), 0x80A48D80:("jtbl_80A48D80","UNK_PTR","",0x4), 0x80A48D98:("D_80A48D98","f32","",0x4), 0x80A48D9C:("D_80A48D9C","f32","",0x4), @@ -11556,15 +11556,15 @@ 0x80A495F8:("D_80A495F8","f32","",0x4), 0x80A495FC:("D_80A495FC","f32","",0x4), 0x80A49600:("D_80A49600","f32","",0x4), - 0x80A4C1C0:("D_80A4C1C0","UNK_TYPE4","",0x4), + 0x80A4C1C0:("sPoolHitByIceArrow","UNK_TYPE4","",0x4), 0x80A4C1C4:("En_Wiz_Fire_InitVars","UNK_TYPE1","",0x1), 0x80A4C1E4:("D_80A4C1E4","UNK_TYPE1","",0x1), 0x80A4C210:("D_80A4C210","UNK_TYPE4","",0x4), 0x80A4C21C:("D_80A4C21C","UNK_TYPE4","",0x4), 0x80A4C228:("D_80A4C228","UNK_TYPE4","",0x4), - 0x80A4C234:("D_80A4C234","UNK_TYPE1","",0x1), - 0x80A4C24C:("D_80A4C24C","UNK_TYPE1","",0x1), - 0x80A4C250:("D_80A4C250","UNK_TYPE1","",0x1), + 0x80A4C234:("lightSettingsColors","UNK_TYPE1","",0x1), + 0x80A4C24C:("sSteamPrimColor","UNK_TYPE1","",0x1), + 0x80A4C250:("sSteamEnvColor","UNK_TYPE1","",0x1), 0x80A4C260:("jtbl_80A4C260","UNK_PTR","",0x4), 0x80A4C274:("D_80A4C274","f32","",0x4), 0x80A4C278:("D_80A4C278","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index aae06790f..073840341 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1375,14 +1375,6 @@ D_060014C0 = 0x060014C0; D_060015B0 = 0x060015B0; D_06001E20 = 0x06001E20; -// ovl_En_Wiz - -D_06001860 = 0x06001860; -D_0600211C = 0x0600211C; -D_060025F0 = 0x060025F0; -D_060066C0 = 0x060066C0; -D_0600B320 = 0x0600B320; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 82afae675b47fbbd90bad9bcd6e38325158082dc Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 1 Oct 2022 09:08:47 -0700 Subject: [PATCH 65/73] Replace player animation names with original names derived from OoT3D/MM3D (#1103) --- assets/xml/misc/link_animetion.xml | 1350 ++++++++--------- assets/xml/objects/gameplay_keep.xml | 1350 ++++++++--------- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 6 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 2 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 2 +- 5 files changed, 1355 insertions(+), 1355 deletions(-) diff --git a/assets/xml/misc/link_animetion.xml b/assets/xml/misc/link_animetion.xml index 788e0a49d..2bb5826dd 100644 --- a/assets/xml/misc/link_animetion.xml +++ b/assets/xml/misc/link_animetion.xml @@ -1,699 +1,699 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 03ed9eef5..354c710bb 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -71,701 +71,701 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + 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 1e92e1f77..399a8f659 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -411,7 +411,7 @@ void EnMinifrog_NextFrogReturned(EnMinifrog* this, PlayState* play) { this->actionFunc = EnMinifrog_ContinueChoirCutscene; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); } } @@ -442,7 +442,7 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { this->flags &= ~0x100; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00DEA8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); } else if (this->timer <= 0) { this->actionFunc = EnMinifrog_NextFrogReturned; this->timer = 30; @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, PlayState* play) { this->timer = 5; func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00E2A8, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_pn_gakkiplay, 0); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } 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 860ad9d0c..ffa557746 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -323,7 +323,7 @@ s32 func_80BE0D60(EnTab* this, PlayState* play) { this->unk_320++; if (this->unk_320 == 1) { - play->setPlayerTalkAnim(play, &gameplay_keep_Linkanim_00D568, 2); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_demo_bikkuri, 2); } else if (this->unk_320 > 20) { play->setPlayerTalkAnim(play, NULL, 0); this->unk_320 = 0; 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 d28a06fa0..11474f01e 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -68,7 +68,7 @@ static ColliderCylinderInit sCylinderInit = { // assumption: draw uses two different skeleton functions, might be incompatible static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; +static LinkAnimationHeader* gLinkAnimations[] = { &gPlayerAnim_link_normal_wait_free, &gPlayerAnim_alink_dance_loop }; static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; From 84d77d5101f08433f14e15e1c5fd0e5e51b5f6c0 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 1 Oct 2022 21:00:52 -0700 Subject: [PATCH 66/73] EnMThunder Ok with some docs (#1082) * Match EnMThunder_Init * Match func_808B53C0 * Match func_808B65BC * Match func_808B6310 * Match func_808B5EEC * Matched func_808B60D4 * Match func_808B5F68 * Match func_808B5984 * Matched func_808B58CC * Matched EnMThunder_Destroy * Matched EnMThunder_Update * Matched EnMThunder_Draw * Matched data * Doc WIP * Code docs * Assets * PR * Rename one more function from OoT WIP docs * Update src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * PR Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/gameplay_keep.xml | 29 +- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h | 2 +- .../actors/ovl_En_M_Thunder/z_en_m_thunder.c | 546 +++++++++++++++++- .../actors/ovl_En_M_Thunder/z_en_m_thunder.h | 27 +- src/overlays/actors/ovl_En_St/z_en_st.c | 4 +- tools/disasm/functions.txt | 16 +- 9 files changed, 583 insertions(+), 50 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 354c710bb..ee2bed429 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -915,18 +915,23 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 99e030cde..41f3308eb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3146,7 +3146,7 @@ void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered); // void func_8019F7D8(void); // void func_8019F830(void); void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); -// void func_8019F900(void); +void func_8019F900(Vec3f* pos, u8 chargeLevel); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); void func_8019FB0C(Vec3f* arg0, u16 sfxId, f32 arg2, s32 arg3); diff --git a/spec b/spec index 9ad5e4cca..e2ea0c1b3 100644 --- a/spec +++ b/spec @@ -984,8 +984,7 @@ beginseg name "ovl_En_M_Thunder" compress include "build/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.data.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.reloc.o" + include "build/src/overlays/actors/ovl_En_M_Thunder/ovl_En_M_Thunder_reloc.o" endseg beginseg 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 b2d896a14..c517ad007 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -71,7 +71,7 @@ void EffDust_Init(Actor* thisx, PlayState* play) { this->dz = 0.8f; this->scalingFactor = 0.5f; break; - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: case EFF_DUST_TYPE_3: this->actionFunc = func_80919230; this->actor.draw = func_809199FC; @@ -203,7 +203,7 @@ void func_80919230(EffDust* this, PlayState* play) { if (this->distanceTraveled[i] >= 1.0f) { theta = randPlusMinusPoint5Scaled(0x10000); switch (this->actor.params) { - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: this->initialPositions[i].x = (Rand_ZeroOne() * 4500.0f) + 700.0f; if (this->initialPositions[i].x > 3000.0f) { this->initialPositions[i].y = (3000.0f * Rand_ZeroOne()) * Math_SinS(theta); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h index ec864ea4d..d73b5ce0e 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -24,7 +24,7 @@ typedef struct EffDust { typedef enum { /* 0x0 */ EFF_DUST_TYPE_0, /* 0x1 */ EFF_DUST_TYPE_1, - /* 0x2 */ EFF_DUST_TYPE_2, + /* 0x2 */ EFF_DUST_TYPE_SPIN_ATTACK_CHARGE, /* 0x3 */ EFF_DUST_TYPE_3, /* 0x4 */ EFF_DUST_TYPE_4, /* 0x5 */ EFF_DUST_TYPE_5 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 b509cf789..fbfb17040 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,6 +6,8 @@ #include "z_en_m_thunder.h" #include "z64rumble.h" +#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -16,7 +18,17 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play); void EnMThunder_Update(Actor* thisx, PlayState* play); void EnMThunder_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play); + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1); + +void EnMThunder_Charge(EnMThunder* this, PlayState* play); +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play); + +#define ENMTHUNDER_TYPE_MAX 4 + const ActorInit En_M_Thunder_InitVars = { ACTOR_EN_M_THUNDER, ACTORCAT_ITEMACTION, @@ -29,39 +41,533 @@ const ActorInit En_M_Thunder_InitVars = { (ActorFunc)EnMThunder_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B7120 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x01000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x01000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 200, 200, 0, { 0, 0, 0 } }, }; -#endif +static u8 sDamages[] = { + 1, 2, 3, 4, // Regular + 1, 2, 3, 4, // Great Spin +}; -extern ColliderCylinderInit D_808B7120; +static u16 sChargingSfxIds[] = { + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SPIN_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SPIN_REGULAR + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B53C0.s") +static f32 sScales[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Init.s") +typedef enum { + /* 0 */ ENMTHUNDER_SUBTYPE_SPIN_GREAT, + /* 1 */ ENMTHUNDER_SUBTYPE_SPIN_REGULAR, + /* 2 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT, + /* 3 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +} EnMThunderSubType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Destroy.s") +void EnMThunder_UnkType_Setup(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5890.s") + this->actor.update = EnMThunder_UnkType_Update; + this->isCharging = false; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + this->scaleTarget = 2; + this->actionFunc = EnMThunder_UnkType_Attack; + this->timer = 8; + this->lightColorFrac = 1.0f; + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + this->actor.child = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B58CC.s") +void EnMThunder_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5984.s") + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->type = ENMTHUNDER_GET_TYPE(&this->actor); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 255, 0); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5EEC.s") + if (this->type == ENMTHUNDER_TYPE_UNK) { + EnMThunder_UnkType_Setup(this, play); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5F68.s") + this->collider.dim.radius = 0; + this->collider.dim.height = 40; + this->collider.dim.yShift = -20; + this->timer = 8; + this->scroll = 0.0f; + this->actor.world.pos = player->bodyPartsPos[0]; + this->lightColorFrac = 0.0f; + this->adjustLightsArg1 = 0.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.room = -1; + Actor_SetScale(&this->actor, 0.1f); + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B60D4.s") + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (!gSaveContext.save.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_NOW))) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B6310.s") + player->stateFlags2 &= ~PLAYER_STATE2_20000; + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Update.s") + if (gSaveContext.save.weekEventReg[23] & 2) { + player->unk_B08[0] = 1.0f; + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } else { + player->unk_B08[0] = 0.5f; + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B65BC.s") + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + this->scaleTarget = 12; + this->collider.info.toucher.dmgFlags = DMG_SWORD_BEAM; + this->collider.info.toucher.damage = 3; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Draw.s") + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + } else { + this->actionFunc = EnMThunder_Charge; + } + + this->actor.child = NULL; +} + +void EnMThunder_Destroy(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + if (this->isCharging) { + Magic_Reset(play); + } + + Collider_DestroyCylinder(play, &this->collider); + EnMThunder_AdjustLights(play, 0.0f); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); +} + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1) { + func_800FD2B4(play, arg1, 850.0f, 0.2f, 0.0f); +} + +void EnMThunder_Spin_AttackNoMagic(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_MarkForDeath(&this->actor); + } else if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMThunder_Charge(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Actor* child = this->actor.child; + + this->unk1B0 = player->unk_B08[0]; + this->actor.world.pos = player->bodyPartsPos[0]; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + + if (!this->isCharging && (player->unk_B08[0] >= 0.1f)) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_WAIT_PREVIEW))) { + EnMThunder_Spin_AttackNoMagic(this, play); + this->actionFunc = EnMThunder_Spin_AttackNoMagic; + this->chargingAlpha = 0; + this->adjustLightsArg1 = 0.0f; + this->lightColorFrac = 0.0f; + return; + } + this->isCharging = true; + } + + if (player->unk_B08[0] >= 0.1f) { + Rumble_Request(0.0f, (s32)(player->unk_B08[0] * 150.0f), 2, (s32)(player->unk_B08[0] * 150.0f)); + } + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if ((child != NULL) && (child->update != NULL)) { + child->parent = NULL; + } + + if (player->unk_B08[0] <= 0.15f) { + if ((player->unk_B08[0] >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_MarkForDeath(&this->actor); + return; + } + + player->stateFlags2 &= ~PLAYER_STATE2_20000; + + if (ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) { + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + } + + if (player->unk_B08[0] < 0.85f) { + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } else { + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } + + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } + + AudioSfx_PlaySfx(sChargingSfxIds[this->subtype], &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + + return; + } + + if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + if (this->actor.child != NULL) { + this->actor.child->parent = NULL; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (player->unk_B08[0] > 0.15f) { + this->chargingAlpha = 255; + if (this->actor.child == NULL) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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, + EFF_DUST_TYPE_SPIN_ATTACK_CHARGE); + } + this->adjustLightsArg1 += (((player->unk_B08[0] - 0.15f) * 1.5f) - this->adjustLightsArg1) * 0.5f; + } else if (player->unk_B08[0] > .1f) { + this->chargingAlpha = (s32)((player->unk_B08[0] - .1f) * 255.0f * 20.0f); + this->lightColorFrac = (player->unk_B08[0] - .1f) * 10.0f; + } else { + this->chargingAlpha = 0; + } + + if (player->unk_B08[0] > 0.85f) { + func_8019F900(&player->actor.projectedPos, 2); + } else if (player->unk_B08[0] > 0.15f) { + func_8019F900(&player->actor.projectedPos, 1); + } else if (player->unk_B08[0] > 0.1f) { + func_8019F900(&player->actor.projectedPos, 0); + } + + if (Play_InCsMode(play)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_808B5EEC(EnMThunder* this, PlayState* play) { + if (this->timer < 2) { + if (this->chargingAlpha < 40) { + this->chargingAlpha = 0; + } else { + this->chargingAlpha -= 40; + } + } + + this->scroll += 2.0f * this->alphaFrac; + + if (this->adjustLightsArg1 < this->lightColorFrac) { + this->adjustLightsArg1 = F32_LERPIMP(this->adjustLightsArg1, this->lightColorFrac, 0.1f); + } else { + this->adjustLightsArg1 = this->lightColorFrac; + } +} + +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_MarkForDeath(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + this->collider.dim.radius = this->actor.scale.x * 30.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; + this->timer--; + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); + + if (Play_InCsMode(play)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play) { + s32 pad[2]; + f32 sp2C; + + if (this->lightColorFrac > (9.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 9.0f); + } + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.05f)) { + Actor_MarkForDeath(&this->actor); + } else { + sp2C = -80.0f * Math_CosS(this->actor.world.rot.x); + + this->actor.world.pos.x += sp2C * Math_SinS(this->actor.shape.rot.y); + this->actor.world.pos.z += sp2C * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.y += -80.0f * Math_SinS(this->actor.world.rot.x); + + Math_SmoothStepToF(&this->actor.scale.x, this->scaleTarget, 0.6f, 2.0f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + this->collider.dim.radius = this->actor.scale.x * 5.0f; + + 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; + + this->collider.dim.pos.x = + (Math_SinS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.x) + this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = + (Math_CosS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.z) + this->actor.world.pos.z; + + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->timer--; + } + + func_808B5EEC(this, play); +} + +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play) { + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_MarkForDeath(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); +} + +void EnMThunder_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + EnMThunder_AdjustLights(play, this->adjustLightsArg1); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); + f32 scale; + s32 y2Scroll; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0xFF - ((u16)(s32)(this->scroll * 30.0f) & 0xFF), 0, 64, + 32, 1, 0xFF - ((u16)(s32)(this->scroll * 20.0f) & 0xFF), 0, 8, 8)); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 16, 64, 1, 0, + 0x1FF - ((u16)(s32)(this->scroll * 10.0f) & 0x1FF), 32, 128)); + break; + + default: + break; + } + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + default: + break; + } + + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + + if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-1.2f, -0.8f, -0.6f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-0.7f, -0.6f, -0.4f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } + + if (this->unk1B0 >= 0.85f) { + scale = (sScales[play->gameplayFrames & 7] * 6.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); + y2Scroll = 40; + } else { + scale = (sScales[play->gameplayFrames & 7] * 2.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + y2Scroll = 20; + } + + Matrix_Scale(1.0f, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->gameplayFrames * 5) & 0xFF, 0, 32, 32, 1, + (play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * y2Scroll) & 0xFF, 8, 8)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackChargingDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h index 14d022770..7ac851e92 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h @@ -5,13 +5,36 @@ struct EnMThunder; +#define ENMTHUNDER_GET_TYPE(thisx) ((thisx)->params & 0xFF) +#define ENMTHUNDER_GET_MAGIC_COST(thisx) (((thisx)->params & 0xFF00) >> 8) + +typedef enum { + /* 0x00 */ ENMTHUNDER_TYPE_KOKIRI_SWORD, + /* 0x01 */ ENMTHUNDER_TYPE_RAZOR_SWORD, + /* 0x02 */ ENMTHUNDER_TYPE_GILDED_SWORD, + /* 0x03 */ ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD, + /* 0x80 */ ENMTHUNDER_TYPE_UNK = 0x80 +} EnMThunderType; + typedef void (*EnMThunderActionFunc)(struct EnMThunder*, PlayState*); typedef struct EnMThunder { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ LightNode* lightNode; + /* 0x194 */ LightInfo lightInfo; + /* 0x1A4 */ f32 lightColorFrac; + /* 0x1A8 */ f32 alphaFrac; + /* 0x1AC */ f32 scroll; + /* 0x1B0 */ f32 unk1B0; + /* 0x1B4 */ f32 adjustLightsArg1; /* 0x1B8 */ EnMThunderActionFunc actionFunc; - /* 0x1BC */ char unk_1BC[0x8]; + /* 0x1BC */ u16 timer; + /* 0x1BE */ u8 subtype; + /* 0x1BF */ u8 type; + /* 0x1C0 */ u8 chargingAlpha; + /* 0x1C1 */ u8 scaleTarget; + /* 0x1C2 */ u8 isCharging; } EnMThunder; // size = 0x1C4 extern const ActorInit En_M_Thunder_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 7d0dcbf11..ecc2b85b2 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -260,8 +260,8 @@ void func_808A54B0(EnSt* this, PlayState* play) { } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(255 * temp_f0)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ef47869a5..a465f7599 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5947,18 +5947,18 @@ 0x808B5230:("EnMFire1_Init",), 0x808B5294:("EnMFire1_Destroy",), 0x808B52C0:("EnMFire1_Update",), - 0x808B53C0:("func_808B53C0",), + 0x808B53C0:("EnMThunder_UnkType_Setup",), 0x808B545C:("EnMThunder_Init",), 0x808B5820:("EnMThunder_Destroy",), - 0x808B5890:("func_808B5890",), - 0x808B58CC:("func_808B58CC",), - 0x808B5984:("func_808B5984",), + 0x808B5890:("EnMThunder_AdjustLights",), + 0x808B58CC:("EnMThunder_Spin_AttackNoMagic",), + 0x808B5984:("EnMThunder_Charge",), 0x808B5EEC:("func_808B5EEC",), - 0x808B5F68:("func_808B5F68",), - 0x808B60D4:("func_808B60D4",), - 0x808B6310:("func_808B6310",), + 0x808B5F68:("EnMThunder_Spin_Attack",), + 0x808B60D4:("EnMThunder_SwordBeam_Attack",), + 0x808B6310:("EnMThunder_UnkType_Attack",), 0x808B63E8:("EnMThunder_Update",), - 0x808B65BC:("func_808B65BC",), + 0x808B65BC:("EnMThunder_UnkType_Update",), 0x808B677C:("EnMThunder_Draw",), 0x808B7360:("BgBreakwall_SetupAction",), 0x808B736C:("func_808B736C",), From 063d24f491e137778bdd6c65f0942d8ce74a2a91 Mon Sep 17 00:00:00 2001 From: chloe!! <47910150+chloebangbang@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:07:07 -0500 Subject: [PATCH 67/73] ovl_En_Door_Etc OK (#994) * ovl_En_Door_Etc OK * review fixes * more review fixes * name yawDiff variables * various vixes * Update src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c Co-authored-by: Chloe <> Co-authored-by: EllipticEllipsis --- spec | 3 +- .../actors/ovl_En_Door_Etc/z_en_door_etc.c | 222 ++++++++++++++++-- .../actors/ovl_En_Door_Etc/z_en_door_etc.h | 11 +- tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 6 +- 5 files changed, 219 insertions(+), 29 deletions(-) diff --git a/spec b/spec index e2ea0c1b3..80141af9c 100644 --- a/spec +++ b/spec @@ -3198,8 +3198,7 @@ beginseg name "ovl_En_Door_Etc" compress include "build/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.data.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.reloc.o" + include "build/src/overlays/actors/ovl_En_Door_Etc/ovl_En_Door_Etc_reloc.o" endseg beginseg 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 0d3612145..98e9d2b8f 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 @@ -5,6 +5,7 @@ */ #include "z_en_door_etc.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +15,11 @@ void EnDoorEtc_Init(Actor* thisx, PlayState* play); void EnDoorEtc_Destroy(Actor* thisx, PlayState* play); void EnDoorEtc_Update(Actor* thisx, PlayState* play); -#if 0 +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play); +void func_80AC21A0(EnDoorEtc* this, PlayState* play); +void func_80AC2354(EnDoorEtc* this, PlayState* play); +void EnDoorEtc_Draw(Actor* thisx, PlayState* play); + const ActorInit En_Door_Etc_InitVars = { ACTOR_EN_DOOR_ETC, ACTORCAT_DOOR, @@ -27,42 +32,219 @@ const ActorInit En_Door_Etc_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AC25A0 = { - { 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, + }, { 100, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC2634[] = { +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x2 */ u8 dListIndex; + /* 0x4 */ s16 objectId; +} EnDoorEtcInfo; // size = 0x6 + +EnDoorEtcInfo sObjInfo[] = { + { SCENE_MITURIN, 1, OBJECT_NUMA_OBJ }, + { -1, 0, GAMEPLAY_KEEP }, + { -1, 13, GAMEPLAY_FIELD_KEEP }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, +}; + +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 +void EnDoorEtc_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + s32 objectIndex; + EnDoorEtcInfo* objectInfo = sObjInfo; + s32 i; + EnDoorEtc* this = THIS; -extern ColliderCylinderInit D_80AC25A0; -extern InitChainEntry D_80AC2634[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.x = -0x4000; + this->angle = 0; + for (i = 0; i < 15; i++, objectInfo++) { + if (play->sceneId == objectInfo->sceneId) { + break; + } + } + if ((i >= 15) && (Object_GetIndex(&play->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + objectIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->objectIndex = objectIndex; + this->dListIndex = objectInfo->dListIndex; + if (this->actor.objBankIndex == this->objectIndex) { + EnDoorEtc_WaitForObject(this, play); + } else { + this->actionFunc = EnDoorEtc_WaitForObject; + } + } + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Init.s") +void EnDoorEtc_Destroy(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2044.s") +/** + * Calculates if the distance between `a` and `b` is greater than distance `c` + */ +s32 EnDoorEtc_IsDistanceGreater(Vec3f* a, Vec3f* b, f32 c) { + f32 dx = b->x - a->x; + f32 dy = b->y - a->y; + f32 dz = b->z - a->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC20A8.s") + return ((SQ(dx) + SQ(dy) + SQ(dz)) < SQ(c)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2118.s") +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.objBankIndex = this->objectIndex; + this->actionFunc = func_80AC2354; + this->actor.draw = EnDoorEtc_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2154.s") +void func_80AC2118(EnDoorEtc* this, PlayState* play) { + if (this->angle < 0) { + this->angle += 0x100; + } else { + this->angle = 0; + this->actionFunc = func_80AC21A0; + this->unk_1F4 &= ~1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC21A0.s") +void func_80AC2154(EnDoorEtc* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else if (this->angle > -0x4000) { + this->angle -= 0x800; + } else { + this->angle = -0x4000; + this->actionFunc = func_80AC2118; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2354.s") +void func_80AC21A0(EnDoorEtc* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f playerOffsetFromDoor; + s32 pad; + s16 yawDiff; + s32 yawDiffAbs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Update.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &playerOffsetFromDoor, &player->actor.world.pos); + if (this->unk_1A1 == 0) { + if ((!Player_InCsMode(play)) && + ((fabsf(playerOffsetFromDoor.y) < 20.0f) && fabsf(playerOffsetFromDoor.x) < 20.0f) && + (fabsf(playerOffsetFromDoor.z) < 50.0f)) { + yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; + if (playerOffsetFromDoor.z > 0.0f) { + yawDiff = 0x8000 - yawDiff; + } + yawDiffAbs = ABS_ALT(yawDiff); + if (yawDiffAbs < 0x3000) { + player->doorDirection = (playerOffsetFromDoor.z >= 0.0f) ? 1.0f : -1.0f; + player->doorActor = &this->actor; + player->doorType = -1; + } + } + } + if ((this->actor.textId == 0x239B) && Flags_GetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor))) { + Flags_UnsetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor)); + this->actionFunc = func_80AC2154; + this->actor.textId = 0x1800; // "It won't budge!" + this->unk_1F4 |= 1; + this->timer = 0x5A; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC24A8.s") +void func_80AC2354(EnDoorEtc* this, PlayState* play) { + Actor* door = play->actorCtx.actorLists[ACTORCAT_DOOR].first; + + while (door != NULL) { + if ((door->id != ACTOR_EN_DOOR) || + !EnDoorEtc_IsDistanceGreater(&door->world.pos, &this->actor.world.pos, 10.0f)) { + door = door->next; + } else { + this->actor.world.pos.x = door->world.pos.x; + this->actor.world.pos.y = door->world.pos.y; + this->actor.world.pos.z = door->world.pos.z; + this->actor.shape.rot.y = door->shape.rot.y; + this->actor.world.rot.y = door->world.rot.y; + Actor_MarkForDeath(door); + this->actionFunc = func_80AC21A0; + this->actor.textId = 0x239B; + Actor_SetFocus(&this->actor, 70.0f); + break; + } + } +} + +void EnDoorEtc_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnDoorEtc* this = THIS; + + this->actionFunc(this, play); + if (this->unk_1F4 & 1) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnDoorEtc_Draw(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(-2900.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->angle, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h index 18d525f44..cbcdf2f54 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h @@ -5,11 +5,20 @@ struct EnDoorEtc; +#define ENDOORETC_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, PlayState*); typedef struct EnDoorEtc { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xB4]; + /* 0x144 */ char pad_144[0x5D]; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 objectIndex; + /* 0x1A3 */ u8 dListIndex; // Never read, inferred from ovl_En_Door + /* 0x1A4 */ s16 angle; + /* 0x1A6 */ s16 timer; + /* 0x1A8 */ ColliderCylinder collider; + /* 0x1F4 */ u8 unk_1F4; /* 0x1F8 */ EnDoorEtcActionFunc actionFunc; } EnDoorEtc; // size = 0x1FC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a465f7599..594ce3427 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11902,14 +11902,14 @@ 0x80AC1D14:("EnPoFusen_Draw",), 0x80AC1ED0:("EnDoorEtc_Init",), 0x80AC2018:("EnDoorEtc_Destroy",), - 0x80AC2044:("func_80AC2044",), - 0x80AC20A8:("func_80AC20A8",), + 0x80AC2044:("EnDoorEtc_IsDistanceGreater",), + 0x80AC20A8:("EnDoorEtc_WaitForObject",), 0x80AC2118:("func_80AC2118",), 0x80AC2154:("func_80AC2154",), 0x80AC21A0:("func_80AC21A0",), 0x80AC2354:("func_80AC2354",), 0x80AC2430:("EnDoorEtc_Update",), - 0x80AC24A8:("func_80AC24A8",), + 0x80AC24A8:("EnDoorEtc_Draw",), 0x80AC26F0:("EnBigokuta_Init",), 0x80AC2874:("EnBigokuta_Destroy",), 0x80AC28B4:("EnBigokuta_SetupCutsceneCamera",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 57d876acb..97cf77e76 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12869,9 +12869,9 @@ 0x80AC1E00:("D_80AC1E00","f32","",0x4), 0x80AC1E04:("D_80AC1E04","f32","",0x4), 0x80AC2580:("En_Door_Etc_InitVars","UNK_TYPE1","",0x1), - 0x80AC25A0:("D_80AC25A0","UNK_TYPE1","",0x1), - 0x80AC25CC:("D_80AC25CC","UNK_TYPE2","",0x2), - 0x80AC2634:("D_80AC2634","UNK_TYPE1","",0x1), + 0x80AC25A0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80AC25CC:("sObjInfo","UNK_TYPE2","",0x2), + 0x80AC2634:("sInitChain","UNK_TYPE1","",0x1), 0x80AC2650:("D_80AC2650","f32","",0x4), 0x80AC4510:("En_Bigokuta_InitVars","UNK_TYPE1","",0x1), 0x80AC4530:("D_80AC4530","UNK_TYPE1","",0x1), From 841da5f13818741c1a50cd16605ad4934b9de36e Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:32:57 -0400 Subject: [PATCH 68/73] View & Shrink_Window Docs (#1049) * view and shrink_window docs * cleanup * move func declaration to header * move struct to local * PR Suggestions * g to s --- include/functions.h | 41 --- include/variables.h | 2 - include/z64.h | 7 - include/z64shrink_window.h | 23 ++ include/z64view.h | 41 ++- src/code/speed_meter.c | 1 + src/code/z_camera.c | 2 + src/code/z_demo.c | 9 +- src/code/z_eventmgr.c | 1 + src/code/z_game_over.c | 3 +- src/code/z_kaleido_scope_call.c | 3 +- src/code/z_kaleido_setup.c | 6 +- src/code/z_message.c | 4 +- src/code/z_parameter.c | 2 +- src/code/z_play.c | 2 + src/code/z_quake.c | 9 +- src/code/z_shrink_window.c | 93 ++++--- src/code/z_view.c | 247 ++++++++++-------- src/overlays/actors/ovl_Boss_01/z_boss_01.c | 1 + src/overlays/actors/ovl_Boss_02/z_boss_02.c | 5 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 3 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 3 +- src/overlays/actors/ovl_Boss_07/z_boss_07.c | 1 + src/overlays/actors/ovl_En_Bsb/z_en_bsb.c | 1 + .../actors/ovl_En_Fishing/z_en_fishing.c | 3 +- .../actors/ovl_En_Knight/z_en_knight.c | 1 + .../actors/ovl_player_actor/z_player.c | 1 + .../gamestates/ovl_daytelop/z_daytelop.c | 2 + .../ovl_file_choose/z_file_choose_NES.c | 2 + .../gamestates/ovl_opening/z_opening.c | 2 + src/overlays/gamestates/ovl_select/z_select.c | 4 +- src/overlays/gamestates/ovl_title/z_title.c | 8 +- .../ovl_kaleido_scope/z_kaleido_scope_NES.c | 1 + tools/disasm/functions.txt | 50 ++-- tools/disasm/variables.txt | 4 +- tools/sizes/code_functions.csv | 50 ++-- 36 files changed, 362 insertions(+), 276 deletions(-) create mode 100644 include/z64shrink_window.h diff --git a/include/functions.h b/include/functions.h index 41f3308eb..c79fc333f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2261,35 +2261,6 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); -void View_ViewportToVp(Vp* dest, Viewport* src); -void View_Init(View* view, GraphicsContext* gfxCtx); -void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); -void View_SetScale(View* view, f32 scale); -void View_GetScale(View* view, f32* scale); -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar); -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar); -void View_SetViewport(View* view, Viewport* viewport); -void View_GetViewport(View* view, Viewport* viewport); -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry); -void View_SyncAndWriteScissor(View* view, Gfx** gfx); -void View_SetScissorForLetterbox(View* view); -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ); -s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); -s32 View_SetDistortionSpeed(View* view, f32 speed); -s32 View_InitDistortion(View* view); -s32 View_ClearDistortion(View* view); -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed); -s32 View_StepDistortion(View* view, Mtx* projectionMtx); -void View_RenderView(View* view, s32 uParm2); -s32 View_RenderToPerspectiveMatrix(View* view); -s32 View_RenderToOrthographicMatrix(View* view); -s32 func_8013FBC8(View* view); -s32 func_8013FD74(View* view); -s32 func_80140024(View* view); -s32 func_801400CC(View* view, Gfx** gfxp); void func_80140260(OSViMode* vimode); // void func_8014026C(OSViMode* param_1, UNK_TYPE1 param_2, s32 param_3, s32 param_4, s32 param_5, s32 param_6, s32 param_7, s32 param_8, UNK_TYPE4 param_9, s32 param_10, s16 param_11, u32 param_12, UNK_TYPE4 param_13); // void func_80140730(void); @@ -2399,18 +2370,6 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId); void func_8015E7EC(PlayState* play, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); -void ShrinkWindow_SetLetterboxTarget(s32 target); -s32 ShrinkWindow_GetLetterboxTarget(void); -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetLetterboxMagnitude(void); -void ShrinkWindow_SetPillarboxTarget(s32 target); -s32 ShrinkWindow_GetPillarboxTarget(void); -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetPillarboxMagnitude(void); -void ShrinkWindow_Init(void); -void ShrinkWindow_Destroy(void); -void ShrinkWindow_Update(s32 framerateDivisor); -void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); diff --git a/include/variables.h b/include/variables.h index c7ea263f2..ae97a6c51 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3181,8 +3181,6 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -extern ShrinkWindowContext gShrinkWindowContext; -extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; extern void (*sKaleidoScopeUpdateFunc)(PlayState* play); diff --git a/include/z64.h b/include/z64.h index ceb91bfb8..d03879072 100644 --- a/include/z64.h +++ b/include/z64.h @@ -286,13 +286,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x0 */ s8 letterboxTarget; - /* 0x1 */ s8 letterboxMagnitude; - /* 0x2 */ s8 pillarboxTarget; - /* 0x3 */ s8 pillarboxMagnitude; -} ShrinkWindowContext; // size = 0x4 - typedef void(*osCreateThread_func)(void*); typedef enum { diff --git a/include/z64shrink_window.h b/include/z64shrink_window.h new file mode 100644 index 000000000..2742fb602 --- /dev/null +++ b/include/z64shrink_window.h @@ -0,0 +1,23 @@ +#ifndef Z64SHRINK_WINDOW_H +#define Z64SHRINK_WINDOW_H + +#include "PR/ultratypes.h" + +struct GraphicsContext; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Letterbox_GetSizeTarget(void); +void ShrinkWindow_Letterbox_SetSize(s32 size); +s32 ShrinkWindow_Letterbox_GetSize(void); + +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void); +void ShrinkWindow_Pillarbox_SetSize(s32 size); +s32 ShrinkWindow_Pillarbox_GetSize(void); + +void ShrinkWindow_Init(void); +void ShrinkWindow_Destroy(void); +void ShrinkWindow_Update(s32 framerateDivisor); +void ShrinkWindow_Draw(GraphicsContext* gfxCtx); + +#endif diff --git a/include/z64view.h b/include/z64view.h index 98ca1ab19..f0661d947 100644 --- a/include/z64view.h +++ b/include/z64view.h @@ -33,16 +33,27 @@ typedef struct View { /* 0x0E0 */ Mtx unkE0; /* 0x120 */ Mtx* projectionPtr; /* 0x124 */ Mtx* viewingPtr; - /* 0x128 */ Vec3f distortionDirRot; + /* 0x128 */ Vec3f distortionOrientation; /* 0x134 */ Vec3f distortionScale; /* 0x140 */ f32 distortionSpeed; - /* 0x144 */ Vec3f curDistortionDirRot; + /* 0x144 */ Vec3f curDistortionOrientation; /* 0x150 */ Vec3f curDistortionScale; - /* 0x15C */ u16 normal; // used to normalize the projection matrix + /* 0x15C */ u16 perspNorm; // used to normalize the projection matrix /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective /* 0x164 */ s32 unk164; } View; // size = 0x168 +#define VIEW_VIEWING (1 << 0) +#define VIEW_VIEWPORT (1 << 1) +#define VIEW_PROJECTION_PERSPECTIVE (1 << 2) +#define VIEW_PROJECTION_ORTHO (1 << 3) +#define VIEW_ALL (VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE | VIEW_PROJECTION_ORTHO) + +#define VIEW_FORCE_VIEWING (VIEW_VIEWING << 4) +#define VIEW_FORCE_VIEWPORT (VIEW_VIEWPORT << 4) +#define VIEW_FORCE_PROJECTION_PERSPECTIVE (VIEW_PROJECTION_PERSPECTIVE << 4) +#define VIEW_FORCE_PROJECTION_ORTHO (VIEW_PROJECTION_ORTHO << 4) + #define SET_FULLSCREEN_VIEWPORT(view) \ { \ Viewport viewport; \ @@ -54,4 +65,28 @@ typedef struct View { } \ (void)0 +void View_Init(View* view, struct GraphicsContext* gfxCtx); +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); +void View_SetScale(View* view, f32 scale); +void View_GetScale(View* view, f32* scale); +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetViewport(View* view, Viewport* viewport); +void View_GetViewport(View* view, Viewport* viewport); + +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ); +s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); +s32 View_SetDistortionSpeed(View* view, f32 speed); +s32 View_InitDistortion(View* view); +s32 View_ClearDistortion(View* view); +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed); + +void View_Apply(View* view, s32 mask); +s32 View_ApplyOrthoToOverlay(View* view); +s32 View_ApplyPerspectiveToOverlay(View* view); +s32 View_UpdateViewingMatrix(View* view); +s32 View_ApplyTo(View* view, Gfx** gfxp); + #endif diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index 9f04de110..5ad1cdbe0 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64view.h" #include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s") diff --git a/src/code/z_camera.c b/src/code/z_camera.c index c26947b21..da8a5f35a 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" /** * Returns the absolute value for floats diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 6c83e8391..1fa041be1 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,6 +1,7 @@ #include "global.h" #include "z64quake.h" #include "z64rumble.h" +#include "z64shrink_window.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx); @@ -107,7 +108,7 @@ s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) { void func_800EA258(PlayState* play, CutsceneContext* csCtx) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; @@ -117,7 +118,7 @@ void func_800EA258(PlayState* play, CutsceneContext* csCtx) { void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { func_800ED980(play, csCtx); Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; @@ -1449,8 +1450,8 @@ void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.cutsceneTrigger == 0) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - ShrinkWindow_SetLetterboxTarget(32); - ShrinkWindow_SetLetterboxMagnitude(0x20); + ShrinkWindow_Letterbox_SetSizeTarget(32); + ShrinkWindow_Letterbox_SetSize(32); csCtx->state++; } diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 7128368ac..5b8b8dce3 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64shrink_window.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F1460.s") diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 776dc75d7..857250eec 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,5 +1,6 @@ #include "global.h" #include "z64rumble.h" +#include "z64shrink_window.h" void GameOver_Init(PlayState* play) { play->gameOverCtx.state = GAMEOVER_INACTIVE; @@ -86,7 +87,7 @@ void GameOver_Update(PlayState* play) { gameOverCtx->state++; sGameOverTimer = 0; Kankyo_InitGameOverLights(play); - ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_Letterbox_SetSizeTarget(32); break; case GAMEOVER_REVIVE_RUMBLE: sGameOverTimer = 50; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index d7905e4dd..9cea42691 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,5 +1,6 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "z64shrink_window.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" void (*sKaleidoScopeUpdateFunc)(PlayState* play); @@ -36,7 +37,7 @@ void KaleidoScopeCall_Update(PlayState* play) { if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { if (pauseCtx->state == 1 || pauseCtx->state == 19) { - if (ShrinkWindow_GetLetterboxMagnitude() == 0) { + if (ShrinkWindow_Letterbox_GetSize() == 0) { R_PAUSE_MENU_MODE = 1; pauseCtx->unk_200 = 0; pauseCtx->unk_208 = 0; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 1135f2de9..0109dc4ab 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" s16 D_801BDB00[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_MASK, PAUSE_ITEM }; @@ -91,8 +93,8 @@ void KaleidoSetup_Update(PlayState* play) { if (pauseCtx->state == 1) { Game_SetFramerateDivisor(&play->state, 2); - if (ShrinkWindow_GetLetterboxTarget() != 0) { - ShrinkWindow_SetLetterboxTarget(0); + if (ShrinkWindow_Letterbox_GetSizeTarget() != 0) { + ShrinkWindow_Letterbox_SetSizeTarget(0); } func_801A3AEC(1); } diff --git a/src/code/z_message.c b/src/code/z_message.c index cb00d8cd2..94f1e5992 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,4 +1,6 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "message_data_static.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" @@ -489,7 +491,7 @@ u8 Message_GetState(MessageContext* msgCtx) { void func_80152C64(View* view) { SET_FULLSCREEN_VIEWPORT(view); - func_8013FBC8(view); + View_ApplyOrthoToOverlay(view); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 3a2da402c..4620dd816 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,5 +1,5 @@ #include "global.h" - +#include "z64view.h" #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" #include "misc/story_static/story_static.h" diff --git a/src/code/z_play.c b/src/code/z_play.c index 06ec9c21e..47bb97a60 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,5 +1,7 @@ #include "global.h" #include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 2b66a39f8..964935ea1 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,5 +1,6 @@ #include "global.h" #include "z64quake.h" +#include "z64view.h" typedef struct { /* 0x00 */ s16 randIndex; @@ -823,10 +824,10 @@ void Distortion_Update(void) { depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionDirRot(&sDistortionRequest.play->view, - Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), - Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), - Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); + View_SetDistortionOrientation(&sDistortionRequest.play->view, + Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), + Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), + Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 5bfca86d9..acbdb5c5b 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -4,70 +4,78 @@ */ #include "prevent_bss_reordering.h" #include "global.h" +#include "z64shrink_window.h" -ShrinkWindowContext gShrinkWindowContext; -ShrinkWindowContext* gShrinkWindowContextPtr; +typedef struct { + /* 0x0 */ s8 letterboxTarget; + /* 0x1 */ s8 letterboxSize; + /* 0x2 */ s8 pillarboxTarget; + /* 0x3 */ s8 pillarboxSize; +} ShrinkWindow; // size = 0x4 -void ShrinkWindow_SetLetterboxTarget(s32 target) { - gShrinkWindowContextPtr->letterboxTarget = target; +ShrinkWindow sShrinkWindow; +ShrinkWindow* sShrinkWindowPtr; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->letterboxTarget = target; } -s32 ShrinkWindow_GetLetterboxTarget(void) { - return gShrinkWindowContextPtr->letterboxTarget; +s32 ShrinkWindow_Letterbox_GetSizeTarget(void) { + return sShrinkWindowPtr->letterboxTarget; } -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->letterboxMagnitude = magnitude; +void ShrinkWindow_Letterbox_SetSize(s32 size) { + sShrinkWindowPtr->letterboxSize = size; } -s32 ShrinkWindow_GetLetterboxMagnitude(void) { - return gShrinkWindowContextPtr->letterboxMagnitude; +s32 ShrinkWindow_Letterbox_GetSize(void) { + return sShrinkWindowPtr->letterboxSize; } -void ShrinkWindow_SetPillarboxTarget(s32 target) { - gShrinkWindowContextPtr->pillarboxTarget = target; +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->pillarboxTarget = target; } -s32 ShrinkWindow_GetPillarboxTarget(void) { - return gShrinkWindowContextPtr->pillarboxTarget; +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void) { + return sShrinkWindowPtr->pillarboxTarget; } -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->pillarboxMagnitude = magnitude; +void ShrinkWindow_Pillarbox_SetSize(s32 size) { + sShrinkWindowPtr->pillarboxSize = size; } -s32 ShrinkWindow_GetPillarboxMagnitude(void) { - return gShrinkWindowContextPtr->pillarboxMagnitude; +s32 ShrinkWindow_Pillarbox_GetSize(void) { + return sShrinkWindowPtr->pillarboxSize; } void ShrinkWindow_Init(void) { - gShrinkWindowContextPtr = &gShrinkWindowContext; - bzero(gShrinkWindowContextPtr, sizeof(gShrinkWindowContext)); + sShrinkWindowPtr = &sShrinkWindow; + bzero(sShrinkWindowPtr, sizeof(sShrinkWindow)); } void ShrinkWindow_Destroy(void) { - gShrinkWindowContextPtr = NULL; + sShrinkWindowPtr = NULL; } void ShrinkWindow_Update(s32 framerateDivisor) { - s32 step = ((framerateDivisor == 3) ? 10 : 30 / framerateDivisor); - s32 nextMagnitude; + s32 step = (framerateDivisor == 3) ? 10 : (30 / framerateDivisor); + s32 nextSize; - nextMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->letterboxTarget, step); - gShrinkWindowContextPtr->letterboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->letterboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->letterboxTarget, step); + sShrinkWindowPtr->letterboxSize = nextSize; - nextMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->pillarboxTarget, step); - gShrinkWindowContextPtr->pillarboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->pillarboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->pillarboxTarget, step); + sShrinkWindowPtr->pillarboxSize = nextSize; } void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { Gfx* gfx; - s8 letterboxMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - s8 pillarboxMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; + s8 letterboxSize = sShrinkWindowPtr->letterboxSize; + s8 pillarboxSize = sShrinkWindowPtr->pillarboxSize; - if (letterboxMagnitude > 0) { + if (letterboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -76,23 +84,23 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetCycleType(gfx++, G_CYC_FILL); gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxMagnitude - 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxSize - 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, 0, letterboxMagnitude, gScreenWidth, letterboxMagnitude + 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude - 1, gScreenWidth, - gScreenHeight - letterboxMagnitude); + gDPFillRectangle(gfx++, 0, letterboxSize, gScreenWidth, letterboxSize + 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize - 1, gScreenWidth, gScreenHeight - letterboxSize); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; CLOSE_DISPS(gfxCtx); } - if (pillarboxMagnitude > 0) { + + if (pillarboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -102,17 +110,16 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, pillarboxMagnitude - 1, gScreenHeight - 1); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude, 0, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, pillarboxSize - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize, 0, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, pillarboxMagnitude, 0, pillarboxMagnitude + 2, gScreenHeight); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude - 2, 0, gScreenWidth - pillarboxMagnitude, - gScreenHeight); + gDPFillRectangle(gfx++, pillarboxSize, 0, pillarboxSize + 2, gScreenHeight); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize - 2, 0, gScreenWidth - pillarboxSize, gScreenHeight); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; diff --git a/src/code/z_view.c b/src/code/z_view.c index 915c196b7..105e6643a 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -1,4 +1,9 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" + +s32 View_ApplyPerspective(View* view); +s32 View_ApplyOrtho(View* view); void View_ViewportToVp(Vp* dest, Viewport* src) { s32 width = src->rightX - src->leftX; @@ -13,41 +18,45 @@ void View_ViewportToVp(Vp* dest, Viewport* src) { dest->vp.vtrans[2] = 0x01FF; dest->vp.vtrans[3] = 0; - if (src->leftX == 0 && src->rightX == 576 && src->topY == 0 && src->bottomY) {} + if ((src->leftX == 0) && (src->rightX == SCREEN_WIDTH_HIGH_RES) && (src->topY == 0) && + (src->bottomY == SCREEN_HEIGHT_HIGH_RES)) {} } void View_Init(View* view, GraphicsContext* gfxCtx) { view->gfxCtx = gfxCtx; + view->viewport.topY = 0; - view->viewport.bottomY = 240; + view->viewport.bottomY = SCREEN_HEIGHT; view->viewport.leftX = 0; - view->viewport.rightX = 320; + view->viewport.rightX = SCREEN_WIDTH; + view->magic = 0x56494557; // "VIEW" - view->unk164 = 0; - view->flags = 1 | 2 | 4; - - if (1) { - ; - } + if (1) {} view->scale = 1.0f; - view->up.y = 1.0f; view->fovy = 60.0f; - view->eye.x = 0.0f; - view->eye.y = 0.0f; - view->at.x = 0.0f; - view->up.x = 0.0f; - view->up.z = 0.0f; view->zNear = 10.0f; view->zFar = 12800.0f; + + view->eye.x = 0.0f; + view->eye.y = 0.0f; view->eye.z = -1.0f; + view->at.x = 0.0f; + + view->up.x = 0.0f; + view->up.y = 1.0f; + view->up.z = 0.0f; + + view->unk164 = 0; + view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; + View_InitDistortion(view); } -void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { - if (eye->x == at->x && eye->z == at->z) { +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { + if ((eye->x == at->x) && (eye->z == at->z)) { eye->z += 0.1f; up->z = 0.0f; up->x = 0.0f; @@ -57,17 +66,21 @@ void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; - view->flags |= 1; + view->flags |= VIEW_VIEWING; } -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { +/* + * Unused. View_LookAt is always used instead. This version is similar but + * is missing the input sanitization and the update to the flags. + */ +void View_LookAtUnsafe(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; } void View_SetScale(View* view, f32 scale) { - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; view->scale = scale; } @@ -75,28 +88,32 @@ void View_GetScale(View* view, f32* scale) { *scale = view->scale; } -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; } -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar) { +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; } -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 8; + view->flags |= VIEW_PROJECTION_ORTHO; view->scale = 1.0f; } -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { +/* + * Identical to View_GetPerspective, and never called. + * Named as it seems to fit the "set, get" pattern. + */ +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; @@ -104,14 +121,14 @@ void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { void View_SetViewport(View* view, Viewport* viewport) { view->viewport = *viewport; - view->flags |= 2; + view->flags |= VIEW_VIEWPORT; } void View_GetViewport(View* view, Viewport* viewport) { *viewport = view->viewport; } -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { +void View_SetScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { Gfx* gfxp = *gfx; gDPSetScissor(gfxp++, G_SC_NON_INTERLACE, ulx, uly, lrx, lry); @@ -119,7 +136,7 @@ void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { *gfx = gfxp; } -void View_SyncAndWriteScissor(View* view, Gfx** gfx) { +void View_ClearScissor(View* view, Gfx** gfx) { Gfx* gfxp = *gfx; s32 ulx = view->viewport.leftX; s32 uly = view->viewport.topY; @@ -127,12 +144,12 @@ void View_SyncAndWriteScissor(View* view, Gfx** gfx) { s32 lry = view->viewport.bottomY; gDPPipeSync(gfxp++); - View_WriteScissor(&gfxp, ulx, uly, lrx, lry); + View_SetScissor(&gfxp, ulx, uly, lrx, lry); *gfx = gfxp; } -void View_SetScissorForLetterbox(View* view) { +void View_ApplyLetterbox(View* view) { s32 letterboxY; s32 letterboxX; s32 pad1; @@ -143,20 +160,21 @@ void View_SetScissorForLetterbox(View* view) { OPEN_DISPS(view->gfxCtx); - letterboxY = ShrinkWindow_GetLetterboxMagnitude(); + letterboxY = ShrinkWindow_Letterbox_GetSize(); + letterboxX = -1; // The following is optimized to varX = 0 but affects codegen if (letterboxX < 0) { letterboxX = 0; } - if (letterboxX > 160) { - letterboxX = 160; + if (letterboxX > (SCREEN_WIDTH / 2)) { + letterboxX = SCREEN_WIDTH / 2; } if (letterboxY < 0) { letterboxY = 0; - } else if (letterboxY > 120) { - letterboxY = 120; + } else if (letterboxY > (SCREEN_HEIGHT / 2)) { + letterboxY = SCREEN_HEIGHT / 2; } ulx = view->viewport.leftX + letterboxX; @@ -166,31 +184,31 @@ void View_SetScissorForLetterbox(View* view) { gDPPipeSync(POLY_OPA_DISP++); { - s32 pad3; + s32 pad2; Gfx* polyOpa; polyOpa = POLY_OPA_DISP; - View_WriteScissor(&polyOpa, ulx, uly, lrx, lry); + View_SetScissor(&polyOpa, ulx, uly, lrx, lry); POLY_OPA_DISP = polyOpa; } gDPPipeSync(POLY_XLU_DISP++); { Gfx* polyXlu; - s32 pad4; + s32 pad3; polyXlu = POLY_XLU_DISP; - View_WriteScissor(&polyXlu, ulx, uly, lrx, lry); + View_SetScissor(&polyXlu, ulx, uly, lrx, lry); POLY_XLU_DISP = polyXlu; } CLOSE_DISPS(view->gfxCtx); } -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ) { - view->distortionDirRot.x = dirRotX; - view->distortionDirRot.y = dirRotY; - view->distortionDirRot.z = dirRotZ; +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ) { + view->distortionOrientation.x = rotX; + view->distortionOrientation.y = rotY; + view->distortionOrientation.z = rotZ; return 1; } @@ -207,22 +225,22 @@ s32 View_SetDistortionSpeed(View* view, f32 speed) { } s32 View_InitDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; - view->curDistortionDirRot = view->distortionDirRot; + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; return 1; } s32 View_ClearDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; @@ -230,8 +248,8 @@ s32 View_ClearDistortion(View* view) { return 1; } -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed) { - view->distortionDirRot = dirRot; +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed) { + view->distortionOrientation = orientation; view->distortionScale = scale; view->distortionSpeed = speed; return 1; @@ -242,17 +260,19 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { if (view->distortionSpeed == 0.0f) { return false; - } else if (view->distortionSpeed == 1.0f) { - view->curDistortionDirRot = view->distortionDirRot; + } + + if (view->distortionSpeed == 1.0f) { + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; } else { - view->curDistortionDirRot.x = - F32_LERPIMP(view->curDistortionDirRot.x, view->distortionDirRot.x, view->distortionSpeed); - view->curDistortionDirRot.y = - F32_LERPIMP(view->curDistortionDirRot.y, view->distortionDirRot.y, view->distortionSpeed); - view->curDistortionDirRot.z = - F32_LERPIMP(view->curDistortionDirRot.z, view->distortionDirRot.z, view->distortionSpeed); + view->curDistortionOrientation.x = + F32_LERPIMP(view->curDistortionOrientation.x, view->distortionOrientation.x, view->distortionSpeed); + view->curDistortionOrientation.y = + F32_LERPIMP(view->curDistortionOrientation.y, view->distortionOrientation.y, view->distortionSpeed); + view->curDistortionOrientation.z = + F32_LERPIMP(view->curDistortionOrientation.z, view->distortionOrientation.z, view->distortionSpeed); view->curDistortionScale.x = F32_LERPIMP(view->curDistortionScale.x, view->distortionScale.x, view->distortionSpeed); @@ -264,29 +284,32 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { 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_RotateXFApply(view->curDistortionOrientation.x); + Matrix_RotateYF(view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionOrientation.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateXFApply(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionOrientation.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionOrientation.x); Matrix_ToMtx(projectionMtx); return true; } -void View_RenderView(View* view, s32 uParm2) { - uParm2 = (view->flags & uParm2) | uParm2 >> 4; +/** + * Apply view to POLY_OPA_DISP, POLY_XLU_DISP (and OVERLAY_DISP if ortho) + */ +void View_Apply(View* view, s32 mask) { + mask = (view->flags & mask) | (mask >> 4); - if (uParm2 & 8) { - View_RenderToOrthographicMatrix(view); + if (mask & VIEW_PROJECTION_ORTHO) { + View_ApplyOrtho(view); } else { - View_RenderToPerspectiveMatrix(view); + View_ApplyPerspective(view); } } -s32 View_RenderToPerspectiveMatrix(View* view) { +s32 View_ApplyPerspective(View* view) { f32 aspect; s32 width; s32 height; @@ -297,36 +320,39 @@ s32 View_RenderToPerspectiveMatrix(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + // Viewport + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + // Perspective projection + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); view->projection = *projection; View_StepDistortion(view, projection); - gSPPerspNormalize(POLY_OPA_DISP++, view->normal); + gSPPerspNormalize(POLY_OPA_DISP++, view->perspNorm); gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPPerspNormalize(POLY_XLU_DISP++, view->normal); + gSPPerspNormalize(POLY_XLU_DISP++, view->perspNorm); gSPMatrix(POLY_XLU_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + // View matrix (look-at) + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; - if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { + if ((view->eye.x == view->at.x) && (view->eye.y == view->at.y) && (view->eye.z == view->at.z)) { view->eye.z += 2.0f; } @@ -343,24 +369,24 @@ s32 View_RenderToPerspectiveMatrix(View* view) { return 1; } -s32 View_RenderToOrthographicMatrix(View* view) { +s32 View_ApplyOrtho(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx = view->gfxCtx; OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -376,7 +402,10 @@ s32 View_RenderToOrthographicMatrix(View* view) { return 1; } -s32 func_8013FBC8(View* view) { +/** + * Apply scissor, viewport and projection (ortho) to OVERLAY_DISP. + */ +s32 View_ApplyOrthoToOverlay(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx; @@ -385,7 +414,7 @@ s32 func_8013FBC8(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -395,26 +424,29 @@ s32 func_8013FBC8(View* view) { s32 pad; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale); view->projection = *projection; - gSPMatrix(OVERLAY_DISP++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); CLOSE_DISPS(gfxCtx); return 1; } -s32 func_8013FD74(View* view) { +/** + * Apply scissor, viewport, view and projection (perspective) to OVERLAY_DISP. + */ +s32 View_ApplyPerspectiveToOverlay(View* view) { f32 aspect; s32 width; s32 height; @@ -428,7 +460,7 @@ s32 func_8013FD74(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -438,28 +470,30 @@ s32 func_8013FD74(View* view) { Gfx* overlay; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); + view->projection = *projection; - gSPPerspNormalize(OVERLAY_DISP++, view->normal); + gSPPerspNormalize(OVERLAY_DISP++, view->perspNorm); gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; + // This check avoids a divide-by-zero in guLookAt if eye == at if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { view->eye.z += 2.0f; } @@ -476,7 +510,10 @@ s32 func_8013FD74(View* view) { return 1; } -s32 func_80140024(View* view) { +/** + * Just updates view's view matrix from its eye/at/up vectors. + */ +s32 View_UpdateViewingMatrix(View* view) { guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); @@ -486,22 +523,22 @@ s32 func_80140024(View* view) { return 1; } -s32 func_801400CC(View* view, Gfx** gfxp) { +s32 View_ApplyTo(View* view, Gfx** gfxp) { Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; Viewport* viewport = &view->viewport; Mtx* projection; Vp* vp; - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, viewport); view->vp = *vp; - View_SyncAndWriteScissor(view, &gfx); + View_ClearScissor(view, &gfx); gSPViewport(gfx++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -509,7 +546,7 @@ s32 func_801400CC(View* view, Gfx** gfxp) { view->projection = *projection; - gSPMatrix(gfx++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); *gfxp = gfx; return 1; 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 11790f377..40800569f 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -6,6 +6,7 @@ #include "z_boss_01.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) 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 9808e68a4..b3ab79b20 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -6,6 +6,7 @@ #include "z_boss_02.h" #include "z64rumble.h" +#include "z64shrink_window.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/gameplay_keep/gameplay_keep.h" @@ -2033,7 +2034,7 @@ void func_809DD934(Boss02* this, PlayState* play) { Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); Matrix_MultVecY(1.0f, &this->subCamUp); Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); } } @@ -2241,6 +2242,6 @@ void func_809DEAC4(Boss02* this, PlayState* play) { Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &subCamEye, &this->subCamUp); this->subCamUp.z = this->subCamUp.x = 0.0f; this->subCamUp.y = 1.0f; - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(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 f26bc505f..8eb73d84d 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,6 +5,7 @@ */ #include "z_boss_04.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -399,7 +400,7 @@ void func_809EC568(Boss04* this, PlayState* play) { if (this->subCamId != SUB_CAM_ID_DONE) { Vec3f subCamAt; - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); if (this->subCamAtOscillator != 0) { this->subCamAtOscillator--; } 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 045a76995..3aadce42c 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -6,6 +6,7 @@ #include "prevent_bss_reordering.h" #include "z_boss_06.h" +#include "z64shrink_window.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_knight/object_knight.h" @@ -339,7 +340,7 @@ void func_809F24C8(Boss06* this, PlayState* play) { } if (this->subCamId != SUB_CAM_ID_DONE) { - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } 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 9b988da18..923c838fc 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -5,6 +5,7 @@ */ #include "z_boss_07.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) 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 5a3ce9cf8..4ad558a0a 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -6,6 +6,7 @@ #include "z_en_bsb.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) 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 8bd1b7e0e..baa65bfa3 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -6,6 +6,7 @@ #include "z_en_fishing.h" #include "z64rumble.h" +#include "z64shrink_window.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" @@ -5170,7 +5171,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { sSubCamVelFactor = 0.0f; // fallthrough case 2: - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; 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 095ca5a98..17d0e3752 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -5,6 +5,7 @@ */ #include "z_en_knight.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 681438463..1f92e8825 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -7,6 +7,7 @@ #include "global.h" #include "z64quake.h" #include "z64rumble.h" +#include "z64shrink_window.h" #define THIS ((Player*)thisx) diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index ad5230253..201030862 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -5,6 +5,8 @@ */ #include "z_daytelop.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "misc/daytelop_static/daytelop_static.h" #include "interface/icon_item_gameover_static/icon_item_gameover_static.h" diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 657a2530f..da9144e7c 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -6,6 +6,8 @@ #include "z_file_choose.h" #include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 42336b9bc..fc5d05be2 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -5,6 +5,8 @@ */ #include "z_opening.h" +#include "z64shrink_window.h" +#include "z64view.h" void TitleSetup_SetupTitleScreen(TitleSetupState* this) { static s32 sOpeningEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 6ae0f5b6c..2e8bbb802 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -5,6 +5,8 @@ */ #include "z_select.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" @@ -1026,7 +1028,7 @@ void MapSelect_Draw(MapSelectState* this) { func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); - View_RenderView(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); if (!this->state.running) { MapSelect_DrawLoadingScreen(this); } else { diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 62d2a36d0..2b23bf565 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -5,6 +5,8 @@ */ #include "z_title.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "misc/nintendo_rogo_static/nintendo_rogo_static.h" @@ -44,9 +46,9 @@ void ConsoleLogo_RenderView(ConsoleLogoState* this, f32 x, f32 y, f32 z) { up.x = up.z = 0.0f; at.x = at.y = at.z = 0.0f; up.y = 1.0f; - func_8013F0D0(view, 30.0f, 10.0f, 12800.0f); - View_SetViewOrientation(view, &eye, &at, &up); - View_RenderView(view, 0xF); + View_SetPerspective(view, 30.0f, 10.0f, 12800.0f); + View_LookAt(view, &eye, &at, &up); + View_Apply(view, VIEW_ALL); } void ConsoleLogo_Draw(GameState* thisx) { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index c02ebcad2..3b3de5937 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -5,6 +5,7 @@ */ #include "z_kaleido_scope.h" +#include "z64view.h" extern UNK_TYPE D_02001360; extern UNK_TYPE D_020044A0; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 594ce3427..8a146996d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2721,33 +2721,33 @@ 0x8013EE48:("Rumble_SetUpdateEnabled",), 0x8013EE60:("View_ViewportToVp",), 0x8013EEF4:("View_Init",), - 0x8013EF9C:("View_SetViewOrientation",), - 0x8013F050:("func_8013F050",), + 0x8013EF9C:("View_LookAt",), + 0x8013F050:("View_LookAtUnsafe",), 0x8013F0A0:("View_SetScale",), 0x8013F0C0:("View_GetScale",), - 0x8013F0D0:("func_8013F0D0",), - 0x8013F100:("func_8013F100",), - 0x8013F120:("func_8013F120",), - 0x8013F15C:("func_8013F15C",), + 0x8013F0D0:("View_SetPerspective",), + 0x8013F100:("View_GetPerspective",), + 0x8013F120:("View_SetOrtho",), + 0x8013F15C:("View_GetOrtho",), 0x8013F17C:("View_SetViewport",), 0x8013F1B0:("View_GetViewport",), - 0x8013F1D8:("View_WriteScissor",), - 0x8013F28C:("View_SyncAndWriteScissor",), - 0x8013F2F8:("View_SetScissorForLetterbox",), - 0x8013F3F8:("View_SetDistortionDirRot",), + 0x8013F1D8:("View_SetScissor",), + 0x8013F28C:("View_ClearScissor",), + 0x8013F2F8:("View_ApplyLetterbox",), + 0x8013F3F8:("View_SetDistortionOrientation",), 0x8013F420:("View_SetDistortionScale",), 0x8013F448:("View_SetDistortionSpeed",), 0x8013F45C:("View_InitDistortion",), 0x8013F4C0:("View_ClearDistortion",), 0x8013F4F4:("View_SetDistortion",), 0x8013F54C:("View_StepDistortion",), - 0x8013F6FC:("View_RenderView",), - 0x8013F748:("View_RenderToPerspectiveMatrix",), - 0x8013FA1C:("View_RenderToOrthographicMatrix",), - 0x8013FBC8:("func_8013FBC8",), - 0x8013FD74:("func_8013FD74",), - 0x80140024:("func_80140024",), - 0x801400CC:("func_801400CC",), + 0x8013F6FC:("View_Apply",), + 0x8013F748:("View_ApplyPerspective",), + 0x8013FA1C:("View_ApplyOrtho",), + 0x8013FBC8:("View_ApplyOrthoToOverlay",), + 0x8013FD74:("View_ApplyPerspectiveToOverlay",), + 0x80140024:("View_UpdateViewingMatrix",), + 0x801400CC:("View_ApplyTo",), 0x80140260:("func_80140260",), 0x8014026C:("func_8014026C",), 0x80140730:("func_80140730",), @@ -2892,14 +2892,14 @@ 0x80160B40:("PlayerCall_Destroy",), 0x80160B80:("PlayerCall_Update",), 0x80160BC0:("PlayerCall_Draw",), - 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), - 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), - 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), - 0x80160C3C:("ShrinkWindow_GetLetterboxMagnitude",), - 0x80160C50:("ShrinkWindow_SetPillarboxTarget",), - 0x80160C64:("ShrinkWindow_GetPillarboxTarget",), - 0x80160C78:("ShrinkWindow_SetPillarboxMagnitude",), - 0x80160C8C:("ShrinkWindow_GetPillarboxMagnitude",), + 0x80160C00:("ShrinkWindow_Letterbox_SetSizeTarget",), + 0x80160C14:("ShrinkWindow_Letterbox_GetSizeTarget",), + 0x80160C28:("ShrinkWindow_Letterbox_SetSize",), + 0x80160C3C:("ShrinkWindow_Letterbox_GetSize",), + 0x80160C50:("ShrinkWindow_Pillarbox_SetSizeTarget",), + 0x80160C64:("ShrinkWindow_Pillarbox_GetSizeTarget",), + 0x80160C78:("ShrinkWindow_Pillarbox_SetSize",), + 0x80160C8C:("ShrinkWindow_Pillarbox_GetSize",), 0x80160CA0:("ShrinkWindow_Init",), 0x80160CD4:("ShrinkWindow_Destroy",), 0x80160CE4:("ShrinkWindow_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 97cf77e76..a0b369264 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4046,8 +4046,8 @@ 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), - 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), - 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), + 0x801F6B40:("sShrinkWindow","ShrinkWindow","",0x4), + 0x801F6B44:("sShrinkWindowPtr","ShrinkWindow*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), 0x801F6B58:("D_801F6B58","UNK_TYPE1","",0x1), 0x801F6BF0:("sKaleidoAreaFaultClient","FaultAddrConvClient","",0xC), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 33b82cef0..f64c45241 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2235,33 +2235,33 @@ asm/non_matchings/code/code_8013EC10/Rumble_StateWipeRequests.s,Rumble_StateWipe asm/non_matchings/code/code_8013EC10/Rumble_SetUpdateEnabled.s,Rumble_SetUpdateEnabled,0x8013EE48,0x6 asm/non_matchings/code/z_view/View_ViewportToVp.s,View_ViewportToVp,0x8013EE60,0x25 asm/non_matchings/code/z_view/View_Init.s,View_Init,0x8013EEF4,0x2A -asm/non_matchings/code/z_view/View_SetViewOrientation.s,View_SetViewOrientation,0x8013EF9C,0x2D -asm/non_matchings/code/z_view/func_8013F050.s,func_8013F050,0x8013F050,0x14 +asm/non_matchings/code/z_view/View_LookAt.s,View_LookAt,0x8013EF9C,0x2D +asm/non_matchings/code/z_view/View_LookAtUnsafe.s,View_LookAtUnsafe,0x8013F050,0x14 asm/non_matchings/code/z_view/View_SetScale.s,View_SetScale,0x8013F0A0,0x8 asm/non_matchings/code/z_view/View_GetScale.s,View_GetScale,0x8013F0C0,0x4 -asm/non_matchings/code/z_view/func_8013F0D0.s,func_8013F0D0,0x8013F0D0,0xC -asm/non_matchings/code/z_view/func_8013F100.s,func_8013F100,0x8013F100,0x8 -asm/non_matchings/code/z_view/func_8013F120.s,func_8013F120,0x8013F120,0xF -asm/non_matchings/code/z_view/func_8013F15C.s,func_8013F15C,0x8013F15C,0x8 +asm/non_matchings/code/z_view/View_SetPerspective.s,View_SetPerspective,0x8013F0D0,0xC +asm/non_matchings/code/z_view/View_GetPerspective.s,View_GetPerspective,0x8013F100,0x8 +asm/non_matchings/code/z_view/View_SetOrtho.s,View_SetOrtho,0x8013F120,0xF +asm/non_matchings/code/z_view/View_GetOrtho.s,View_GetOrtho,0x8013F15C,0x8 asm/non_matchings/code/z_view/View_SetViewport.s,View_SetViewport,0x8013F17C,0xD asm/non_matchings/code/z_view/View_GetViewport.s,View_GetViewport,0x8013F1B0,0xA -asm/non_matchings/code/z_view/View_WriteScissor.s,View_WriteScissor,0x8013F1D8,0x2D -asm/non_matchings/code/z_view/View_SyncAndWriteScissor.s,View_SyncAndWriteScissor,0x8013F28C,0x1B -asm/non_matchings/code/z_view/View_SetScissorForLetterbox.s,View_SetScissorForLetterbox,0x8013F2F8,0x40 -asm/non_matchings/code/z_view/View_SetDistortionDirRot.s,View_SetDistortionDirRot,0x8013F3F8,0xA +asm/non_matchings/code/z_view/View_SetScissor.s,View_SetScissor,0x8013F1D8,0x2D +asm/non_matchings/code/z_view/View_ClearScissor.s,View_ClearScissor,0x8013F28C,0x1B +asm/non_matchings/code/z_view/View_ApplyLetterbox.s,View_ApplyLetterbox,0x8013F2F8,0x40 +asm/non_matchings/code/z_view/View_SetDistortionOrientation.s,View_SetDistortionOrientation,0x8013F3F8,0xA asm/non_matchings/code/z_view/View_SetDistortionScale.s,View_SetDistortionScale,0x8013F420,0xA asm/non_matchings/code/z_view/View_SetDistortionSpeed.s,View_SetDistortionSpeed,0x8013F448,0x5 asm/non_matchings/code/z_view/View_InitDistortion.s,View_InitDistortion,0x8013F45C,0x19 asm/non_matchings/code/z_view/View_ClearDistortion.s,View_ClearDistortion,0x8013F4C0,0xD asm/non_matchings/code/z_view/View_SetDistortion.s,View_SetDistortion,0x8013F4F4,0x16 asm/non_matchings/code/z_view/View_StepDistortion.s,View_StepDistortion,0x8013F54C,0x6C -asm/non_matchings/code/z_view/View_RenderView.s,View_RenderView,0x8013F6FC,0x13 -asm/non_matchings/code/z_view/View_RenderToPerspectiveMatrix.s,View_RenderToPerspectiveMatrix,0x8013F748,0xB5 -asm/non_matchings/code/z_view/View_RenderToOrthographicMatrix.s,View_RenderToOrthographicMatrix,0x8013FA1C,0x6B -asm/non_matchings/code/z_view/func_8013FBC8.s,func_8013FBC8,0x8013FBC8,0x6B -asm/non_matchings/code/z_view/func_8013FD74.s,func_8013FD74,0x8013FD74,0xAC -asm/non_matchings/code/z_view/func_80140024.s,func_80140024,0x80140024,0x2A -asm/non_matchings/code/z_view/func_801400CC.s,func_801400CC,0x801400CC,0x65 +asm/non_matchings/code/z_view/View_Apply.s,View_Apply,0x8013F6FC,0x13 +asm/non_matchings/code/z_view/View_ApplyPerspective.s,View_ApplyPerspective,0x8013F748,0xB5 +asm/non_matchings/code/z_view/View_ApplyOrtho.s,View_ApplyOrtho,0x8013FA1C,0x6B +asm/non_matchings/code/z_view/View_ApplyOrthoToOverlay.s,View_ApplyOrthoToOverlay,0x8013FBC8,0x6B +asm/non_matchings/code/z_view/View_ApplyPerspectiveToOverlay.s,View_ApplyPerspectiveToOverlay,0x8013FD74,0xAC +asm/non_matchings/code/z_view/View_UpdateViewingMatrix.s,View_UpdateViewingMatrix,0x80140024,0x2A +asm/non_matchings/code/z_view/View_ApplyTo.s,View_ApplyTo,0x801400CC,0x65 asm/non_matchings/code/z_vimode/func_80140260.s,func_80140260,0x80140260,0x3 asm/non_matchings/code/z_vimode/func_8014026C.s,func_8014026C,0x8014026C,0x131 asm/non_matchings/code/z_vimode/func_80140730.s,func_80140730,0x80140730,0x38 @@ -2406,14 +2406,14 @@ asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF 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 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxMagnitude.s,ShrinkWindow_GetLetterboxMagnitude,0x80160C3C,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxTarget.s,ShrinkWindow_SetPillarboxTarget,0x80160C50,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxTarget.s,ShrinkWindow_GetPillarboxTarget,0x80160C64,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxMagnitude.s,ShrinkWindow_SetPillarboxMagnitude,0x80160C78,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxMagnitude.s,ShrinkWindow_GetPillarboxMagnitude,0x80160C8C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSizeTarget.s,ShrinkWindow_Letterbox_SetSizeTarget,0x80160C00,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSizeTarget.s,ShrinkWindow_Letterbox_GetSizeTarget,0x80160C14,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSize.s,ShrinkWindow_Letterbox_SetSize,0x80160C28,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSize.s,ShrinkWindow_Letterbox_GetSize,0x80160C3C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSizeTarget.s,ShrinkWindow_Pillarbox_SetSizeTarget,0x80160C50,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSizeTarget.s,ShrinkWindow_Pillarbox_GetSizeTarget,0x80160C64,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSize.s,ShrinkWindow_Pillarbox_SetSize,0x80160C78,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSize.s,ShrinkWindow_Pillarbox_GetSize,0x80160C8C,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s,ShrinkWindow_Init,0x80160CA0,0xD asm/non_matchings/code/z_shrink_window/ShrinkWindow_Destroy.s,ShrinkWindow_Destroy,0x80160CD4,0x4 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Update.s,ShrinkWindow_Update,0x80160CE4,0x2D From aa3f1be55e0409e032062cc6779a6d5710941b85 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 2 Oct 2022 09:07:55 -0700 Subject: [PATCH 69/73] Object Tru Docs (Koume) (#1098) * Name everything in xml * Actor docs regarding assets * move header include * PR * Format * PR * MT animation enum * index () --- assets/xml/objects/object_trt.xml | 4 +- assets/xml/objects/object_tru.xml | 217 +++++++------- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 7 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 266 ++++++++++-------- src/overlays/actors/ovl_En_Tru/z_en_tru.h | 13 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 113 ++++---- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.h | 8 +- tools/disasm/functions.txt | 6 +- 8 files changed, 342 insertions(+), 292 deletions(-) diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index 826aa1ef0..9f024f9cb 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -51,10 +51,10 @@ - + - + -> diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index 138723ceb..db35ec604 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -1,108 +1,117 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 99c17772c..ced184e68 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 @@ -145,15 +145,14 @@ void EnJcMato_Update(Actor* thisx, PlayState* play) { } } -static Vec3f movement = { 0.0f, -2500.0f, 0.0f }; - void EnJcMato_Draw(Actor* thisx, PlayState* play) { + static Vec3f sOffset = { 0.0f, -2500.0f, 0.0f }; EnJcMato* this = THIS; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultVec3f(&movement, &this->pos); + gSPDisplayList(POLY_OPA_DISP++, gKoumeTargetDL); + Matrix_MultVec3f(&sOffset, &this->pos); CLOSE_DISPS(play->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 42cbdc22a..c54d924df 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -5,7 +5,7 @@ */ #include "z_en_tru.h" -#include "objects/object_tru/object_tru.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -24,6 +24,26 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play); void func_80A87FD0(EnTru* this, PlayState* play); void func_80A881E0(EnTru* this, PlayState* play); +typedef enum { + /* 0x00 */ KOUME_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_ANIM_TAKE, + /* 0x08 */ KOUME_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_ANIM_DRINK, + /* 0x0A */ KOUME_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_ANIM_HEALED, + /* 0x0C */ KOUME_ANIM_HOVER1, + /* 0x0D */ KOUME_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_ANIM_FLY, + /* 0x0F */ KOUME_ANIM_HOVER2, + /* 0x10 */ KOUME_ANIM_MAX +} KoumeAnimation; + static UNK_TYPE D_80A88910[] = { 0x0E08520C, 0x16100000, @@ -69,7 +89,6 @@ const ActorInit En_Tru_InitVars = { }; #include "overlays/ovl_En_Tru/ovl_En_Tru.c" -#include "objects/gameplay_keep/gameplay_keep.h" static Vec3f D_80A8B250 = { 0.0f, 0.02f, 0.0f }; @@ -107,22 +126,22 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -275,12 +294,12 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { for (i = 0; i < 30; i++, arg0++) { f32 alpha; - s32 idx; + s32 index; if ((arg0->unk_00 == 3) || (arg0->unk_00 == 4) || (arg0->unk_00 == 5)) { if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A820); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustMaterialDL); flag = true; } @@ -306,9 +325,9 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - idx = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); + index = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustModelDL); Matrix_Pop(); } @@ -414,21 +433,21 @@ s32 func_80A86770(EnTru* this) { return false; } -void func_80A868F8(EnTru* this) { - this->skelAnime.playSpeed = this->unk_358; +void EnTru_UpdateSkelAnime(EnTru* this) { + this->skelAnime.playSpeed = this->playSpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80A86924(EnTru* this, s32 arg1) { - s32 ret = false; +s32 EnTru_ChangeAnim(EnTru* this, s32 animIndex) { + s32 didChange = false; - if (arg1 != this->unk_37C) { - this->unk_37C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); - this->unk_358 = this->skelAnime.playSpeed; + if (animIndex != this->animIndex) { + this->animIndex = animIndex; + didChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->playSpeed = this->skelAnime.playSpeed; } - return ret; + return didChange; } void func_80A8697C(EnTru* this, PlayState* play) { @@ -497,7 +516,7 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); + gSPDisplayList(POLY_OPA_DISP++, gKoumePotionDL); Matrix_Pop(); @@ -515,7 +534,7 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); + gSPDisplayList(POLY_XLU_DISP++, gKoumeBottleDL); Matrix_Pop(); @@ -527,104 +546,105 @@ s32 func_80A86BAC(EnTru* this, PlayState* play) { s32 func_80A86DB8(EnTru* this) { if (this->unk_34E & 0x80) { - this->unk_36E = 2; + this->eyeTexIndex = 2; return false; } - switch (this->unk_37C) { - case 0: - case 1: - if (DECR(this->unk_36C) == 0) { + switch (this->animIndex) { + case KOUME_ANIM_INJURED_LYING_DOWN: + case KOUME_ANIM_INJURED_LYING_DOWN_MORPH: + if (DECR(this->blinkTimer) == 0) { s16 rand = Rand_S16Offset(40, 20); - if (this->unk_36E == 2) { - this->unk_36C = 8; + + if (this->eyeTexIndex == 2) { + this->blinkTimer = 8; } else { - this->unk_36C = rand; + this->blinkTimer = rand; } - if (this->unk_36E == 2) { - this->unk_36E = 1; + if (this->eyeTexIndex == 2) { + this->eyeTexIndex = 1; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } } return false; - case 2: + case KOUME_ANIM_TRY_GET_UP: if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 11.0f) && (this->skelAnime.curFrame <= 32.0f)) { - this->unk_36E = 0; + this->eyeTexIndex = 0; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } return false; - case 3: + case KOUME_ANIM_INJURED_RAISE_HEAD: if (Animation_OnFrame(&this->skelAnime, 31.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame <= 32.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; - case 9: + case KOUME_ANIM_DRINK: if (Animation_OnFrame(&this->skelAnime, 57.0f)) { - this->unk_36C = 0; - this->unk_36E = 0; + this->blinkTimer = 0; + this->eyeTexIndex = 0; } if (this->skelAnime.curFrame < 57.0f) { - if (DECR(this->unk_36C) == 0) { - this->unk_36C = Rand_S16Offset(8, 8); - this->unk_36E = 2; + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(8, 8); + this->eyeTexIndex = 2; } else { - this->unk_36E = 1; + this->eyeTexIndex = 1; } - } else if (DECR(this->unk_36C) == 0) { - this->unk_36E++; - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(20, 10); - this->unk_36E = 0; + } else if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(20, 10); + this->eyeTexIndex = 0; } } return false; - case 10: - this->unk_36E = 0; + case KOUME_ANIM_FINISHED_DRINKING: + this->eyeTexIndex = 0; return false; - case 11: + case KOUME_ANIM_HEALED: if (Animation_OnFrame(&this->skelAnime, 19.0f) || Animation_OnFrame(&this->skelAnime, 45.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 19.0f) && (this->skelAnime.curFrame <= 45.0f)) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 3; + this->eyeTexIndex = 3; } return false; - case 13: + case KOUME_ANIM_TAKE_OFF: if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame >= 19.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; default: - if (DECR(this->unk_36C) == 0) { - if ((this->unk_36E != 2) || !(this->unk_34E & 0x80)) { - this->unk_36E++; + if (DECR(this->blinkTimer) == 0) { + if ((this->eyeTexIndex != 2) || !(this->unk_34E & 0x80)) { + this->eyeTexIndex++; } - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(30, 30); - this->unk_36E = 0; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } return false; @@ -772,11 +792,12 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { break; case 2: - if ((this->unk_37C != 5) && (this->unk_37C != 6)) { - func_80A86924(this, 3); + if ((this->animIndex != KOUME_ANIM_INJURED_HEAD_UP) && + (this->animIndex != KOUME_ANIM_INJURED_HEAD_UP_MORPH)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_RAISE_HEAD); this->unk_364++; } else { - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -784,7 +805,7 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -806,7 +827,7 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { s32 func_80A8777C(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = 0; - s32 temp_v0; + s32 itemActionParam; switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_CHOICE: @@ -816,10 +837,10 @@ s32 func_80A8777C(Actor* thisx, PlayState* play) { } // Fallthrough case TEXT_STATE_16: - temp_v0 = func_80123810(play); - if ((temp_v0 == 35) || (temp_v0 == 36)) { + itemActionParam = func_80123810(play); + if ((itemActionParam == PLAYER_AP_BOTTLE_POTION_RED) || (itemActionParam == PLAYER_AP_BOTTLE_POTION_BLUE)) { this->unk_34E |= 8; - if (temp_v0 == 35) { + if (itemActionParam == PLAYER_AP_BOTTLE_POTION_RED) { this->unk_390 = 1; } else { this->unk_390 = 2; @@ -827,9 +848,9 @@ s32 func_80A8777C(Actor* thisx, PlayState* play) { this->unk_378 = func_80A87880; this->unk_364 = 0; ret = 1; - } else if (temp_v0 < 0) { + } else if (itemActionParam < PLAYER_AP_NONE) { ret = 3; - } else if (temp_v0 != 0) { + } else if (itemActionParam != PLAYER_AP_NONE) { ret = 2; } break; @@ -866,14 +887,14 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { this->unk_34E &= ~0x8; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_80A86924(this, 7); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE); this->unk_364++; break; case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 9); + EnTru_ChangeAnim(this, KOUME_ANIM_DRINK); this->actor.world.rot.y += 0x4000; } else if (Animation_OnFrame(&this->skelAnime, 12.0f) && !(this->unk_34E & 0x800)) { this->unk_34E |= 0x400; @@ -885,7 +906,7 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { case 4: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 10); + EnTru_ChangeAnim(this, KOUME_ANIM_FINISHED_DRINKING); ret = true; } else if (Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 32.0f) || Animation_OnFrame(&this->skelAnime, 52.0f)) { @@ -923,7 +944,7 @@ s32 func_80A87B48(Actor* thisx, PlayState* play) { switch (this->unk_364) { case 0: - func_80A86924(this, 11); + EnTru_ChangeAnim(this, KOUME_ANIM_HEALED); this->unk_364++; break; @@ -954,7 +975,7 @@ s32 func_80A87B48(Actor* thisx, PlayState* play) { if (player->exchangeItemId != 0) { player->exchangeItemId = 0; } - func_80A86924(this, 12); + EnTru_ChangeAnim(this, KOUME_ANIM_HOVER1); } } else { MREG(64) = 0; @@ -997,7 +1018,7 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { AudioSfx_StopById(NA_SE_EN_KOUME_MAGIC); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); - func_80A86924(this, 13); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE_OFF); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; this->unk_34E &= ~0x8; @@ -1010,7 +1031,7 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); break; } else { - func_80A86924(this, 14); + EnTru_ChangeAnim(this, KOUME_ANIM_FLY); this->actor.shape.rot.y = this->actor.world.rot.y; this->unk_362 = 20; this->unk_364++; @@ -1049,13 +1070,14 @@ void func_80A87FD0(EnTru* this, PlayState* play) { SubS_UpdateFlags(&this->unk_34E, 0, 7); } - if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->animIndex == KOUME_ANIM_TRY_GET_UP) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_362 = Rand_S16Offset(40, 20); - func_80A86924(this, 1); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN_MORPH); func_80A86460(this); - } else if (this->unk_37C != 2) { + } else if (this->animIndex != KOUME_ANIM_TRY_GET_UP) { if (DECR(this->unk_362) == 0) { - func_80A86924(this, 2); + EnTru_ChangeAnim(this, KOUME_ANIM_TRY_GET_UP); } } } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && @@ -1084,12 +1106,12 @@ void func_80A881E0(EnTru* this, PlayState* play) { } if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { - func_80A86924(this, 0); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); } else if (this->unk_34E & 0x80) { - func_80A86924(this, 0); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); func_80A86460(this); } else if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 6); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP_MORPH); } SubS_UpdateFlags(&this->unk_34E, 0, 7); @@ -1111,11 +1133,11 @@ void EnTru_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, 27); + SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_LIMB_MAX); Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - this->unk_37C = -1; - func_80A86924(this, 0); + this->animIndex = -1; + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); this->path = SubS_GetDayDependentPath(play, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; @@ -1126,7 +1148,7 @@ void EnTru_Init(Actor* thisx, PlayState* play) { this->unk_34E = 0; if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 5); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP); } else { this->unk_388 = PLAYER_AP_NONE; } @@ -1149,7 +1171,7 @@ void EnTru_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - func_80A868F8(this); + EnTru_UpdateSkelAnime(this); func_80A86B0C(this, play); func_80A86DB8(this); @@ -1165,7 +1187,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p s32 pad; EnTru* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOUME_LIMB_HEAD) { 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; @@ -1175,7 +1197,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } - if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { + if (!(this->unk_34E & 0x200) && (limbIndex == KOUME_LIMB_BROOM)) { *dList = NULL; } @@ -1185,7 +1207,7 @@ s32 EnTru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnTru_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnTru* this = THIS; - if (limbIndex == 19) { + if (limbIndex == KOUME_LIMB_RIGHT_HAND) { func_80A86BAC(this, play); } } @@ -1212,7 +1234,7 @@ void EnTru_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { overrideRot = false; } - if (limbIndex == 21) { + if (limbIndex == KOUME_LIMB_HEAD) { SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, overrideRot); Matrix_Pop(); @@ -1232,11 +1254,11 @@ void EnTru_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } void EnTru_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80A8B408[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, - object_tru_Tex_0197A0, + static TexturePtr sEyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, + gKoumeEyeHalfTex, }; s32 pad; EnTru* this = THIS; @@ -1245,8 +1267,8 @@ void EnTru_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A8B408[this->unk_36E])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTru_OverrideLimbDraw, EnTru_PostLimbDraw, 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 7e1c23380..711d5aeb6 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -2,6 +2,7 @@ #define Z_EN_TRU_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTru; @@ -31,12 +32,12 @@ typedef struct EnTru { /* 0x1EC */ Vec3f unk_1EC; /* 0x1F8 */ Vec3f unk_1F8; /* 0x204 */ Vec3s unk_204; - /* 0x20A */ Vec3s jointTable[27]; - /* 0x2AC */ Vec3s morphTable[27]; + /* 0x20A */ Vec3s jointTable[KOUME_LIMB_MAX]; + /* 0x2AC */ Vec3s morphTable[KOUME_LIMB_MAX]; /* 0x34E */ u16 unk_34E; /* 0x350 */ UNK_TYPE1 unk350[0x4]; /* 0x354 */ s32* unk_354; - /* 0x358 */ f32 unk_358; + /* 0x358 */ f32 playSpeed; /* 0x35C */ f32 unk_35C; /* 0x360 */ s16 unk_360; /* 0x362 */ s16 unk_362; @@ -44,13 +45,13 @@ typedef struct EnTru { /* 0x366 */ s16 unk_366; /* 0x368 */ s16 unk_368; /* 0x36A */ s16 unk_36A; - /* 0x36C */ s16 unk_36C; - /* 0x36E */ s16 unk_36E; + /* 0x36C */ s16 blinkTimer; + /* 0x36E */ s16 eyeTexIndex; /* 0x370 */ s16 unk_370; /* 0x372 */ s16 unk_372; /* 0x374 */ s16 unk_374; /* 0x378 */ EnTruUnkFunc unk_378; - /* 0x37C */ s32 unk_37C; + /* 0x37C */ s32 animIndex; /* 0x380 */ UNK_TYPE1 unk380[0x4]; /* 0x384 */ s32 unk_384; /* 0x388 */ s32 unk_388; 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 ac772a940..69725414a 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 @@ -20,6 +20,26 @@ void func_80B76A64(EnTruMt* this, PlayState* play); void func_80B76BB8(EnTruMt* this, PlayState* play); void func_80B76C38(EnTruMt* this, PlayState* play); +typedef enum { + /* 0x00 */ KOUME_MT_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_MT_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_MT_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_MT_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_MT_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_MT_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_MT_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_MT_ANIM_TAKE, + /* 0x08 */ KOUME_MT_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_MT_ANIM_DRINK, + /* 0x0A */ KOUME_MT_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_MT_ANIM_HEALED, + /* 0x0C */ KOUME_MT_ANIM_HOVER1, + /* 0x0D */ KOUME_MT_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_MT_ANIM_FLY, + /* 0x0F */ KOUME_MT_ANIM_HOVER2, + /* 0x10 */ KOUME_MT_ANIM_MAX +} KoumeMtAnimation; + const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -88,57 +108,57 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimationInfo[] = { - { &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 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { +s32 EnTruMt_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 endFrame; s16 startFrame; - s32 ret = false; + s32 didChange = false; - if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(sAnimationInfo))) { - endFrame = sAnimationInfo[arg1].frameCount; + if ((animIndex >= KOUME_MT_ANIM_INJURED_LYING_DOWN) && (animIndex < KOUME_MT_ANIM_MAX)) { + endFrame = sAnimationInfo[animIndex].frameCount; if (endFrame < 0) { - endFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); + endFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - startFrame = sAnimationInfo[arg1].startFrame; + startFrame = sAnimationInfo[animIndex].startFrame; if (startFrame < 0) { - startFrame = Animation_GetLastFrame(sAnimationInfo[arg1].animation); + startFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, sAnimationInfo[arg1].animation, sAnimationInfo[arg1].playSpeed, startFrame, - endFrame, sAnimationInfo[arg1].mode, sAnimationInfo[arg1].morphFrames); - ret = true; + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + startFrame, endFrame, sAnimationInfo[animIndex].mode, sAnimationInfo[animIndex].morphFrames); + didChange = true; } - return ret; + return didChange; } 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; + if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } } @@ -404,8 +424,7 @@ void EnTruMt_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, - OBJECT_TRU_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_LIMB_MAX); Collider_InitSphere(play, &this->collider); Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); @@ -421,7 +440,7 @@ void EnTruMt_Init(Actor* thisx, PlayState* play) { this->unk_328 = 0; this->actor.room = -1; this->path = SubS_GetPathByIndex(play, ENTRUMT_GET_FC00(&this->actor), 0x3F); - func_80B76030(&this->skelAnime, 14); + EnTruMt_ChangeAnim(&this->skelAnime, KOUME_MT_ANIM_FLY); this->actionFunc = func_80B76A64; } @@ -477,11 +496,11 @@ void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { s32 EnTruMt_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnTruMt* this = THIS; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultVec3f(&D_80B7765C, &this->unk_350); } return false; @@ -493,7 +512,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro MtxF* sp54; s32 phi_v0; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { if (this->unk_328 & 0x10) { phi_v0 = 1; } else { @@ -507,7 +526,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } - if (limbIndex == OBJECT_TRU_LIMB_0E) { + if (limbIndex == KOUME_LIMB_BROOM) { func_8012C28C(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); @@ -520,7 +539,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + gSPDisplayList(POLY_OPA_DISP++, gKoumeChainDL); CLOSE_DISPS(play->state.gfxCtx); @@ -545,7 +564,7 @@ void EnTruMt_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* ro void EnTruMt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTruMt* this = THIS; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { 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_RotateYS(this->unk_336.y, MTXMODE_APPLY); @@ -556,18 +575,18 @@ void EnTruMt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnTruMt_Draw(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; - TexturePtr sp48[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, + TexturePtr eyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, }; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, 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 670d0d728..54d58326e 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 @@ -16,16 +16,16 @@ typedef struct EnTruMt { /* 0x144 */ EnTruMtActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderSphere collider; - /* 0x1E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; - /* 0x286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x1E4 */ Vec3s jointTable[KOUME_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[KOUME_LIMB_MAX]; /* 0x328 */ u16 unk_328; /* 0x32A */ UNK_TYPE1 unk32A[0xC]; /* 0x336 */ Vec3s unk_336; /* 0x33C */ Vec3f unk_33C; /* 0x348 */ s16 unk_348; /* 0x34A */ s16 unk_34A; - /* 0x34C */ s16 unk_34C; - /* 0x34E */ s16 unk_34E; + /* 0x34C */ s16 eyeTexIndex; + /* 0x34E */ s16 blinkTimer; /* 0x350 */ Vec3f unk_350; /* 0x35C */ Vec3f unk_35C; /* 0x368 */ Path* path; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8a146996d..057170442 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11226,8 +11226,8 @@ 0x80A86460:("func_80A86460",), 0x80A86674:("func_80A86674",), 0x80A86770:("func_80A86770",), - 0x80A868F8:("func_80A868F8",), - 0x80A86924:("func_80A86924",), + 0x80A868F8:("EnTru_UpdateSkelAnime",), + 0x80A86924:("EnTru_ChangeAnim",), 0x80A8697C:("func_80A8697C",), 0x80A869DC:("func_80A869DC",), 0x80A86B0C:("func_80A86B0C",), @@ -14437,7 +14437,7 @@ 0x80B75658:("EnJg_OverrideLimbDraw",), 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), - 0x80B76030:("func_80B76030",), + 0x80B76030:("EnTruMt_ChangeAnim",), 0x80B76110:("func_80B76110",), 0x80B76188:("func_80B76188",), 0x80B761FC:("func_80B761FC",), From 3d5d39e74d8eca94be52657bacf017de4e9962c2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 2 Oct 2022 09:16:30 -0700 Subject: [PATCH 70/73] Document leftover pause joint tables (#1104) * Document leftover pause joint tables * Grab the other two joint tables * Document the deku stick thing * Add @bug to comment --- assets/xml/objects/gameplay_keep.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index ee2bed429..121dcfe5e 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -39,7 +39,7 @@ - + @@ -69,8 +69,26 @@ - - + + + + + + + + + + + + + + + + + + + + @@ -766,6 +784,7 @@ + From fdfe2842d9daf023c8ccdc8621489a44de3c1786 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 2 Oct 2022 10:10:31 -0700 Subject: [PATCH 71/73] Eff Srchball OK (#1092) * OK * Some docs and cleanup * flags -> params * Remove todo * Small cleanup * Description and dls * Format * bug tag * Update bug comment * Update src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c Co-authored-by: EllipticEllipsis * Format Co-authored-by: EllipticEllipsis --- assets/xml/objects/gameplay_keep.xml | 4 +- include/functions.h | 2 +- include/z64effect.h | 1 - spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 10 +-- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 4 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 4 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 4 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 8 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 19 +++-- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- .../z_eff_ss_solder_srch_ball.c | 80 +++++++++++++++++-- .../z_eff_ss_solder_srch_ball.h | 9 ++- 13 files changed, 111 insertions(+), 39 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 121dcfe5e..ca0aaeb3c 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1377,8 +1377,8 @@ - - + + diff --git a/include/functions.h b/include/functions.h index c79fc333f..9d21eca01 100644 --- a/include/functions.h +++ b/include/functions.h @@ -558,7 +558,7 @@ void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16* playerDetected, s16 params); void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); diff --git a/include/z64effect.h b/include/z64effect.h index dde996eb7..b4574592a 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -257,7 +257,6 @@ 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 80141af9c..2dce298d5 100644 --- a/spec +++ b/spec @@ -1869,8 +1869,7 @@ beginseg name "ovl_Effect_Ss_Solder_Srch_Ball" compress include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.data.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball_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 5fc51b0c3..bbdd528a4 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -702,16 +702,16 @@ void EffectSsKFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac // EffectSsSolderSrchBall Spawn Functions -void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, - s16* linkDetected, s16 drawFlag) { +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16* playerDetected, s16 flags) { EffectSsSolderSrchBallInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - initParams.unused = unused; - initParams.linkDetected = linkDetected; - initParams.drawFlag = drawFlag; + initParams.scale = scale; + initParams.playerDetected = playerDetected; + initParams.flags = flags; EffectSs_Spawn(play, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); } 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 12da39288..10b72634a 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -508,7 +508,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { 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); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); for (i = 0; i < play->envCtx.unk_F2[3]; i++) { worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; @@ -575,7 +575,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } 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 d771f3511..b7c698376 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -279,14 +279,14 @@ void EnEncount2_DrawEffects(EnEncount2* this, PlayState* play) { 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)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } CLOSE_DISPS(gfxCtx); 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 f9085e825..0f016f300 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -146,7 +146,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { 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); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); sp53 = 0xFF; if (sp53) {} @@ -181,7 +181,7 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { D_80B23C2C[arg0->unk_02 + 2], 255); } - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } 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 de053c46a..6fd949feb 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 @@ -5,6 +5,7 @@ */ #include "z_en_look_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #define FLAGS (ACTOR_FLAG_80000000) @@ -340,13 +341,14 @@ void EnLookNuts_Update(Actor* thisx, PlayState* play) { Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); if (!this->isPlayerDetected) { - s16 drawFlag = 1; + s16 effectFlags = SOLDERSRCHBALL_INVISIBLE; + if (gSaveContext.save.isNight) { - drawFlag = 0; + effectFlags = 0; } if (Player_GetMask(play) != PLAYER_MASK_STONE) { EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->isPlayerDetected, - drawFlag); + effectFlags); } } 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 bbce2ee6c..4f3882aa7 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -7,6 +7,7 @@ #include "z_en_suttari.h" #include "overlays/actors/ovl_En_Elf/z_en_elf.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #include "objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -444,12 +445,13 @@ void func_80BAAFDC(EnSuttari* this, PlayState* play) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; @@ -476,12 +478,13 @@ void func_80BAB1A0(EnSuttari* this, PlayState* play) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; 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 35a9b6e2e..427f74988 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -34,7 +34,7 @@ typedef struct EnSuttari { /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; /* 0x33A */ UNK_TYPE1 unk_33A[0xB6]; - /* 0x3F0 */ s16 unk3F0; + /* 0x3F0 */ s16 playerDetected; /* 0x3F2 */ s16 unk3F2; /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c index 04afcba3f..01224dd32 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c @@ -1,27 +1,93 @@ /* * File: z_eff_ss_solder_srch_ball.c * Overlay: ovl_Effect_Ss_Solder_Srch_Ball - * Description: + * Description: Vision sphere */ #include "z_eff_ss_solder_srch_ball.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rFlags regs[0] #define PARAMS ((EffectSsSolderSrchBallInitParams*)initParamsx) -s32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { EFFECT_SS_SOLDER_SRCH_BALL, EffectSsSolderSrchBall_Init, }; -#endif +u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSolderSrchBallInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->update = EffectSsSolderSrchBall_Update; + if (!(initParams->flags & SOLDERSRCHBALL_INVISIBLE)) { + this->draw = EffectSsSolderSrchBall_Draw; + } + this->life = 10; + this->rgScale = initParams->scale; + this->rFlags = initParams->flags; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Draw.s") + //! @bug actor field used to store an s16* + // This bug is purely cosmetic. Nothing external will ever read this as an Actor, so there are no unintended + // side-effects. + this->actor = (Actor*)initParams->playerDetected; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Update.s") +void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale = this->rgScale / 100.0f; + + func_8012C28C(gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, 255); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(20.0f * play->state.frames), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 diffX; + f32 diffY; + f32 diffZ; + s16* playerDetected = (s16*)this->actor; + Player* player = GET_PLAYER(play); + + diffX = player->actor.world.pos.x - this->pos.x; + diffY = player->actor.world.pos.y - this->pos.y; + diffZ = player->actor.world.pos.z - this->pos.z; + + if (this->rFlags >= SOLDERSRCHBALL_SMALL_DETECT_RADIUS) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 10.0f) && (sqrtf(SQ(diffY)) < 10.0f)) { + *playerDetected = true; + } + } else if (!BgCheck_SphVsFirstWall(&play->colCtx, &this->pos, 30.0f)) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 40.0f) && (sqrtf(SQ(diffY)) < 80.0f)) { + *playerDetected = true; + } + } else if (this->life > 1) { + this->life = 1; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h index 24b9f47fc..fb4fb4159 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h @@ -3,13 +3,16 @@ #include "global.h" +#define SOLDERSRCHBALL_INVISIBLE (1 << 0) +#define SOLDERSRCHBALL_SMALL_DETECT_RADIUS (1 << 1) + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; - /* 0x24 */ s16 unused; - /* 0x28 */ s16* linkDetected; - /* 0x2C */ s16 drawFlag; + /* 0x24 */ s16 scale; + /* 0x28 */ s16* playerDetected; + /* 0x2C */ s16 flags; } EffectSsSolderSrchBallInitParams; // size = 0x30 extern const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; From 0e2de439dd2882bb4e3585d918e040ba18b55b41 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 2 Oct 2022 19:31:55 +0100 Subject: [PATCH 72/73] Dm_Tag (#922) * Dm_Tag * PR * Fix * PR * PR --- spec | 3 +- src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c | 235 ++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h | 11 +- 3 files changed, 230 insertions(+), 19 deletions(-) diff --git a/spec b/spec index 2dce298d5..4dec1f228 100644 --- a/spec +++ b/spec @@ -5029,8 +5029,7 @@ beginseg name "ovl_Dm_Tag" compress include "build/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.data.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Tag/ovl_Dm_Tag_reloc.o" endseg beginseg 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 b74c43940..2c8bf046f 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -18,7 +18,6 @@ void func_80C229AC(DmTag* this, PlayState* play); void func_80C229EC(DmTag* this, PlayState* play); void func_80C229FC(DmTag* this, PlayState* play); -#if 0 const ActorInit Dm_Tag_InitVars = { ACTOR_DM_TAG, ACTORCAT_ITEMACTION, @@ -31,30 +30,236 @@ const ActorInit Dm_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +s32 D_80C22BF0[] = { + 0x0E28F00C, + 0x15090000, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22350.s") +s32 D_80C22BFC[] = { + 0x0900000E, 0x28F10C09, 0x00000E28, 0xF20C0900, 0x000E28F3, 0x0C090000, 0x0E28F40C, + 0x0900000E, 0x28F50C09, 0x00000E28, 0xF60C1511, 0x55040900, 0x00100000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22400.s") +s32 D_80C22C30[] = { + 0x0E28EF0C, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2247C.s") +Actor* func_80C22350(DmTag* this, PlayState* play, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C224D8.s") + while (true) { + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C227E8.s") + if ((foundActor == NULL) || (((this != (DmTag*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22880.s") + if (foundActor->next == NULL) { + foundActor = NULL; + break; + } + foundActor = foundActor->next; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2291C.s") +s32 func_80C22400(DmTag* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229AC.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_Dm_Tag/func_80C229EC.s") +s16 func_80C2247C(DmTag* this, s32 arg1) { + s32 i; + s16 cs = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229FC.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Init.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Destroy.s") +s32 func_80C224D8(DmTag* this, PlayState* play) { + s32 pad; + Actor* sp30; + Actor* sp2C; + s16 sp2A = this->actor.cutscene; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Update.s") + sp30 = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AN); + sp2C = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AH); + + switch (this->unk_1A4) { + case 0: + if (func_80C22400(this, sp2A)) { + if ((sp2C != NULL) && (sp2C->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), sp2C); + } + this->unk_1A4++; + ret = true; + } + break; + + case 1: + if ((sp30 != NULL) && (sp30->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(func_80C2247C(this, 0))), + sp30); + } + this->unk_1A4++; + ret = true; + break; + + case 2: + ActorCutscene_Stop(func_80C2247C(this, 0)); + if (func_80C22400(this, func_80C2247C(this, 1))) { + this->unk_1A4++; + ret = true; + } + break; + + case 3: + ActorCutscene_Stop(func_80C2247C(this, 1)); + if (func_80C22400(this, func_80C2247C(this, 2))) { + this->unk_1A4++; + ret = true; + } + break; + + case 4: + ActorCutscene_Stop(func_80C2247C(this, 2)); + if (func_80C22400(this, func_80C2247C(this, 3))) { + this->unk_1A4++; + ret = true; + } + break; + + case 5: + ActorCutscene_Stop(func_80C2247C(this, 3)); + if (func_80C22400(this, func_80C2247C(this, 4))) { + this->unk_1A4++; + ret = true; + } + break; + + case 6: + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 5); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + break; + } + return ret; +} + +s32 func_80C227E8(DmTag* this, PlayState* play) { + if (this->unk_1A4 == 0) { + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 4); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + } + return false; +} + +s32* func_80C22880(DmTag* this, PlayState* play) { + s32 time; + + switch (this->unk_18E) { + case 1: + time = gSaveContext.save.time - 0x3FFC; + if ((time >= 0xA54B) && (time < 0xB54A) && (gSaveContext.save.day == 2)) { + this->msgEventCallback = func_80C227E8; + return D_80C22BF0; + } + return D_80C22C30; + case 2: + this->msgEventCallback = func_80C224D8; + return D_80C22BFC; + } + return NULL; +} + +s32 func_80C2291C(DmTag* this, PlayState* play) { + s32 ret = false; + + if (this->unk_18C & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_18C |= 8; + SubS_UpdateFlags(&this->unk_18C, 0, 7); + this->msgEventScript = func_80C22880(this, play); + this->actionFunc = func_80C229FC; + ret = true; + } + } + return ret; +} + +void func_80C229AC(DmTag* this, PlayState* play) { + SubS_UpdateFlags(&this->unk_18C, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; +} + +void func_80C229EC(DmTag* this, PlayState* play) { +} + +void func_80C229FC(DmTag* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Init(Actor* thisx, PlayState* play) { + DmTag* this = (DmTag*)thisx; + Player* player = GET_PLAYER(play); + + if (gSaveContext.save.weekEventReg[85] & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { + player->stateFlags1 |= PLAYER_STATE1_20; + this->unk_18E = 2; + this->unk_18C = 0; + SubS_UpdateFlags(&this->unk_18C, 4, 7); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80C229EC; + } else if (this->actor.room == 2) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.targetMode = 1; + this->unk_18E = 1; + this->unk_18C = 0; + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Destroy(Actor* thisx, PlayState* play) { +} + +void DmTag_Update(Actor* thisx, PlayState* play) { + DmTag* this = THIS; + + func_80C2291C(this, play); + this->actionFunc(this, play); + func_8013C964(&this->actor, play, 40.0f, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_18C & 7); + Actor_SetFocus(&this->actor, 0.0f); +} diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h index fda9397c7..d68cd38d4 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h @@ -6,12 +6,19 @@ struct DmTag; typedef void (*DmTagActionFunc)(struct DmTag*, PlayState*); +typedef s32 (*DmTagMsgEventFunc)(struct DmTag*, PlayState*); typedef struct DmTag { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x44]; + /* 0x144 */ UNK_TYPE1 pad144[0x44]; /* 0x188 */ DmTagActionFunc actionFunc; - /* 0x18C */ char unk_18C[0x20]; + /* 0x18C */ u16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ s32* msgEventScript; + /* 0x194 */ s32 msgEventArg4; + /* 0x198 */ UNK_TYPE1 pad198[0xC]; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A8 */ DmTagMsgEventFunc msgEventCallback; } DmTag; // size = 0x1AC extern const ActorInit Dm_Tag_InitVars; From 3e32379c2bbce332dae9675954e28387480128f0 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 2 Oct 2022 15:24:10 -0400 Subject: [PATCH 73/73] audio_synthesis.c OK and Documented (#1090) * import synth docs * cleanup * small followup cleanup * PR Suggestions, small cleanup * fix bss * PR suggestion * fix enum * PR Suggestions --- include/PR/abi.h | 91 +- include/functions.h | 43 +- include/variables.h | 34 +- include/z64audio.h | 312 +-- spec | 1 - src/code/audio/audio_data.c | 93 +- src/code/audio/audio_heap.c | 264 +-- src/code/audio/audio_init_params.c | 182 +- src/code/audio/audio_load.c | 6 +- src/code/audio/audio_playback.c | 202 +- src/code/audio/audio_seqplayer.c | 49 +- src/code/audio/audio_synthesis.c | 1807 +++++++++++++++-- src/code/audio/code_8019AF00.c | 2 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 1 - tools/disasm/files.txt | 1 + tools/disasm/functions.txt | 138 +- tools/disasm/variables.txt | 18 +- tools/sizes/code_functions.csv | 138 +- 18 files changed, 2612 insertions(+), 770 deletions(-) diff --git a/include/PR/abi.h b/include/PR/abi.h index 49d539762..15ae5d911 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -53,6 +53,7 @@ #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 +#define A_ADPCM_SHORT 0x04 #define A_OUT 0x02 #define A_LEFT 0x02 #define A_RIGHT 0x00 @@ -331,13 +332,20 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(a2); \ } -#define aClearBuffer(pkt, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ - _a->words.w1 = (unsigned int)(c); \ -} +/* + * Clears DMEM by writing zeros. + * + * @param pkt pointer to an Acmd buffer + * @param dmem DMEM address to clear + * @param size number of bytes to clear (rounded up to the next multiple of 16) + */ +#define aClearBuffer(pkt, dmem, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(dmem, 0, 24); \ + _a->words.w1 = (uintptr_t)(size); \ + } #define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \ { \ @@ -368,14 +376,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ } -#define aLoadBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ - _a->words.w1 = (unsigned int)(s); \ -} +/* + * Loads a buffer to DMEM from any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param addrSrc Any physical source address, KSEG0, or KSEG1 + * @param dmemDest DMEM destination address + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aLoadBuffer(pkt, addrSrc, dmemDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemDest, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrSrc); \ + } #define aMix(pkt, f, g, i, o) \ { \ @@ -404,14 +419,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(s); \ } -#define aSaveBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ - _a->words.w1 = (unsigned int)(d); \ -} +/* + * Stores a buffer from DMEM to any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param dmemSrc DMEM source address + * @param addrDest Any physical source address, KSEG0, or KSEG1 + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aSaveBuffer(pkt, dmemSrc, addrDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrDest); \ + } #define aSegment(pkt, s, b) \ { \ @@ -501,14 +523,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(addr); \ } -#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ - _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ - _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ -} +/* + * Duplicates 128 bytes of data a specified number of times. + * + * @param pkt pointer to an Acmd buffer + * @param numCopies number of times to duplicate 128 bytes from src + * @param dmemSrc DMEM source address + * @param dmemDest DMEM destination address for the duplicates, size 128 * numCopies + */ +#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \ + } #define aAddMixer(pkt, count, dmemi, dmemo, a4) \ { \ diff --git a/include/functions.h b/include/functions.h index 9d21eca01..d42733a14 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2897,48 +2897,7 @@ s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* s32 osFlashWriteArray(u32 pageNum); s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq); -// void func_801877D0(void); -// void func_80187B64(void); -// void func_80187BEC(void); -// void func_80187DE8(void); -// void func_80187E58(void); -// void func_80187F00(void); -// void func_80187FB0(void); -// void func_80187FE8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188034(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188078(void); -// void func_801880C4(void); -// void func_801880E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188124(void); -// void func_8018814C(void); -// void func_80188174(void); -// void func_801881A8(void); -// void func_801881C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801881F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188264(void); -// void func_80188288(void); -// void func_801882A0(void); -// void func_80188304(void); -// void func_801884A0(void); -// void func_80188698(void); -// void func_8018883C(void); -// void func_801888E4(void); -// void func_801889A4(void); -// void func_80188A50(void); -// void func_80188AFC(void); -// void func_80188C48(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188CB4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188D28(void); -// void func_80188D68(void); -// void func_80188DDC(void); -// void func_80188FBC(void); -// void func_80189064(void); -// void func_80189620(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_8018A4B4(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_8018A768(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_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); +Acmd* AudioSynth_Update(Acmd* cmdStart, s32* numAbiCmds, s16* aiStart, s32 aiBufLen); void AudioHeap_DiscardFont(s32 fontId); void* AudioHeap_WritebackDCache(void* addr, size_t size); diff --git a/include/variables.h b/include/variables.h index ae97a6c51..a4914a441 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1557,11 +1557,11 @@ extern f32 gPitchFrequencies[]; extern u8 gDefaultShortNoteVelocityTable[]; extern u8 gDefaultShortNoteGateTimeTable[]; extern EnvelopePoint gDefaultEnvelope[]; -extern NoteSubEu gZeroNoteSub; -extern NoteSubEu gDefaultNoteSub; -extern u16 gHeadsetPanQuantization[]; -extern u16 gHeadsetPanQuantization[]; -extern s16 D_801D58A8[]; +extern NoteSampleState gZeroedSampleState; +extern NoteSampleState gDefaultSampleState; +extern u16 gHaasEffectDelaySize[]; +extern u16 gHaasEffectDelaySize[]; +extern s16 gInvalidAdpcmCodeBook[]; extern f32 gHeadsetPanVolume[]; extern f32 gStereoPanVolume[]; extern f32 gDefaultPanVolume[]; @@ -1721,21 +1721,7 @@ extern s8 gSfxDefaultReverb; extern u8 gAudioSpecId; // extern UNK_TYPE1 D_801DB4D8; // extern UNK_TYPE4 D_801DB4DC; -// extern UNK_TYPE1 D_801DB4E0; -// extern UNK_TYPE1 D_801DB528; -// extern UNK_TYPE1 D_801DB570; -// extern UNK_TYPE1 D_801DB5B8; -// extern UNK_TYPE1 D_801DB600; -// extern UNK_TYPE1 D_801DB648; -// extern UNK_TYPE1 D_801DB690; -// extern UNK_TYPE1 D_801DB6D8; -// extern UNK_TYPE1 D_801DB720; -// extern UNK_TYPE1 D_801DB750; -// extern UNK_TYPE1 D_801DB798; -// extern UNK_TYPE1 D_801DB870; -// extern UNK_TYPE1 D_801DB8B8; -// extern UNK_TYPE1 D_801DB900; -extern UNK_PTR D_801DB930; +extern ReverbSettings* gReverbSettingsTable[]; extern AudioSpec gAudioSpecs[21]; // rodata @@ -3483,10 +3469,10 @@ extern ActiveSequence gActiveSeqs[]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -extern void (*D_80208E68)(void); -extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); -extern s32 (*D_80208E70)(Sample*, s32, s8, s32); -extern Acmd* (*D_80208E74)(Acmd*, s32, s32); +extern void (*gCustomAudioUpdateFunction)(void); +extern u32 (*gCustomAudioSeqFunction)(s8 value, SequenceChannel* channel); +extern s32 (*gCustomAudioReverbFunction)(Sample*, s32, s8, s32); +extern Acmd* (*gCustomAudioSynthFunction)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64audio.h b/include/z64audio.h index c5045e34f..264e8d9e3 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -1,7 +1,7 @@ #ifndef Z64_AUDIO_H #define Z64_AUDIO_H -#define MK_AUDIO_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) +#define AUDIO_MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) #define NO_LAYER ((SequenceLayer*)(-1)) @@ -32,13 +32,45 @@ typedef enum { #define ADSR_GOTO -2 #define ADSR_RESTART -3 -#define AIBUF_LEN 0x580 +// size of a single sample point +#define SAMPLE_SIZE sizeof(s16) + +// Samples are processed in groups of 16 called a "frame" +#define SAMPLES_PER_FRAME ADPCMFSIZE + +// The length of one left/right channel is 13 frames +#define DMEM_1CH_SIZE (13 * SAMPLES_PER_FRAME * SAMPLE_SIZE) +// Both left and right channels +#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE) + +#define AIBUF_LEN (88 * SAMPLES_PER_FRAME) // number of samples +#define AIBUF_SIZE (AIBUF_LEN * SAMPLE_SIZE) // number of bytes + +// Filter sizes +#define FILTER_SIZE (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART1 (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART2 (8 * SAMPLE_SIZE) // Must be the same amount of samples as copied by aDuplicate() (audio microcode) #define WAVE_SAMPLE_COUNT 64 #define AUDIO_RELOCATED_ADDRESS_START K0BASE +#define REVERB_INDEX_NONE -1 + +typedef enum { + /* 0 */ REVERB_DATA_TYPE_SETTINGS, // Reverb Settings (Init) + /* 1 */ REVERB_DATA_TYPE_DELAY, // Reverb Delay (numSamples) + /* 2 */ REVERB_DATA_TYPE_DECAY, // Reverb Decay Ratio + /* 3 */ REVERB_DATA_TYPE_SUB_VOLUME, // Reverb Sub-Volume + /* 4 */ REVERB_DATA_TYPE_VOLUME, // Reverb Volume + /* 5 */ REVERB_DATA_TYPE_LEAK_RIGHT, // Reverb Leak Right Channel + /* 6 */ REVERB_DATA_TYPE_LEAK_LEFT, // Reverb Leak Left Channel + /* 7 */ REVERB_DATA_TYPE_FILTER_LEFT, // Reverb Left Filter + /* 8 */ REVERB_DATA_TYPE_FILTER_RIGHT, // Reverb Right Filter + /* 9 */ REVERB_DATA_TYPE_9 // Reverb Unk +} ReverbDataType; + typedef enum { /* 0x1 */ AUDIO_ERROR_NO_INST = 1, /* 0x3 */ AUDIO_ERROR_INVALID_INST_ID = 3, @@ -78,12 +110,14 @@ typedef enum { } SampleMedium; typedef enum { - /* 0 */ CODEC_ADPCM, - /* 1 */ CODEC_S8, + /* 0 */ CODEC_ADPCM, // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + /* 1 */ CODEC_S8, // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) /* 2 */ CODEC_S16_INMEMORY, - /* 3 */ CODEC_SMALL_ADPCM, + /* 3 */ CODEC_SMALL_ADPCM, // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte /* 4 */ CODEC_REVERB, - /* 5 */ CODEC_S16 + /* 5 */ CODEC_S16, + /* 6 */ CODEC_UNK6, + /* 7 */ CODEC_UNK7 // processed as uncompressed samples } SampleCodec; typedef enum { @@ -165,24 +199,28 @@ typedef struct { typedef struct { /* 0x00 */ u32 start; - /* 0x04 */ u32 end; + /* 0x04 */ u32 loopEnd; // numSamples into the sample where the loop ends /* 0x08 */ u32 count; - /* 0x0C */ u32 unk_0C; - /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned + /* 0x0C */ u32 sampleEnd; // total number of s16-samples in the + /* 0x10 */ s16 predictorState[16]; // only exists if count != 0. 8-byte aligned } AdpcmLoop; // size = 0x30 (or 0x10) +/** + * The procedure used to design the codeBook is based on an adaptive clustering algorithm. + * The size of the codeBook is (8 * order * numPredictors) and is 8-byte aligned + */ typedef struct { /* 0x00 */ s32 order; - /* 0x04 */ s32 npredictors; - /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned + /* 0x04 */ s32 numPredictors; + /* 0x08 */ s16 codeBook[1]; // a table of prediction coefficients that the coder selects from to optimize sound quality. } AdpcmBook; // size >= 0x8 typedef struct { /* 0x00 */ u32 unk_0 : 1; /* 0x00 */ u32 codec : 3; // The state of compression or decompression /* 0x00 */ u32 medium : 2; // Medium where sample is currently stored - /* 0x00 */ u32 unk_bit26 : 1; // Has the sample header been relocated (offsets to pointers) - /* 0x00 */ u32 isRelocated : 1; // Size of the sample + /* 0x00 */ u32 unk_bit26 : 1; + /* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers) /* 0x01 */ u32 size : 24; // Size of the sample /* 0x04 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either rom or ram /* 0x08 */ AdpcmLoop* loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram @@ -194,18 +232,23 @@ typedef struct { /* 0x04 */ f32 tuning; // frequency scale factor } TunedSample; // size = 0x8 +/** + * Stores an entry of decompressed samples in a reverb ring buffer. + * By storing the sample in a ring buffer, the time it takes to loop + * around back to the same sample acts as a delay, leading to an echo effect. + */ typedef struct { /* 0x00 */ s16 numSamplesAfterDownsampling; // never read - /* 0x02 */ s16 chunkLen; // never read + /* 0x02 */ s16 numSamples; // never read /* 0x04 */ s16* toDownsampleLeft; /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory /* 0x0C */ s32 startPos; // start pos in ring buffer - /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) - /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) - /* 0x14 */ u16 unk_14; - /* 0x16 */ u16 unk_16; - /* 0x18 */ u16 unk_18; -} ReverbRingBufferItem; // size = 0x1C + /* 0x10 */ s16 size; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 wrappedSize; // second length in ring buffer (from pos 0) + /* 0x14 */ u16 loadResamplePitch; + /* 0x16 */ u16 saveResamplePitch; + /* 0x18 */ u16 saveResampleNumSamples; +} ReverbBufferEntry; // size = 0x1C typedef struct { /* 0x000 */ u8 resampleFlags; @@ -213,35 +256,35 @@ typedef struct { /* 0x002 */ u8 framesToIgnore; /* 0x003 */ u8 curFrame; /* 0x004 */ u8 downsampleRate; - /* 0x005 */ s8 unk_05; - /* 0x006 */ u16 windowSize; - /* 0x008 */ s16 unk_08; - /* 0x00A */ s16 unk_0A; - /* 0x00C */ u16 unk_0C; - /* 0x00E */ u16 unk_0E; + /* 0x005 */ s8 mixReverbIndex; // mix in reverb from this index. set to 0xFF to not mix any + /* 0x006 */ u16 delayNumSamples; // number of samples between echos + /* 0x008 */ s16 mixReverbStrength; // the gain/amount to mix in reverb from mixReverbIndex + /* 0x00A */ s16 volume; + /* 0x00C */ u16 decayRatio; // determines how fast reverb dissipate + /* 0x00E */ u16 downsamplePitch; /* 0x010 */ s16 leakRtl; /* 0x012 */ s16 leakLtr; - /* 0x014 */ u16 unk_14; - /* 0x016 */ s16 unk_16; - /* 0x018 */ u8 unk_18; - /* 0x019 */ s8 unk_19; - /* 0x01A */ u16 unk_1A; - /* 0x01C */ u16 unk_1C; - /* 0x01E */ u8 unk_1E; - /* 0x020 */ s32 nextRingBufPos; - /* 0x024 */ s32 unk_24; // May be bufSizePerChan - /* 0x028 */ s16* leftRingBuf; - /* 0x02C */ s16* rightRingBuf; - /* 0x030 */ void* unk_30; - /* 0x034 */ void* unk_34; - /* 0x038 */ void* unk_38; - /* 0x03C */ void* unk_3C; - /* 0x040 */ ReverbRingBufferItem items[2][5]; - /* 0x158 */ ReverbRingBufferItem items2[2][5]; + /* 0x014 */ u16 subDelay; // number of samples between sub echos + /* 0x016 */ s16 subVolume; // strength of the sub echos + /* 0x018 */ u8 resampleEffectOn; + /* 0x019 */ s8 resampleEffectExtraSamples; + /* 0x01A */ u16 resampleEffectLoadUnk; + /* 0x01C */ u16 resampleEffectSaveUnk; + /* 0x01E */ u8 delayNumSamplesAfterDownsampling; + /* 0x020 */ s32 nextReverbBufPos; + /* 0x024 */ s32 delayNumSamplesUnk; // May be bufSizePerChan + /* 0x028 */ s16* leftReverbBuf; + /* 0x02C */ s16* rightReverbBuf; + /* 0x030 */ s16* leftLoadResampleBuf; + /* 0x034 */ s16* rightLoadResampleBuf; + /* 0x038 */ s16* leftSaveResampleBuf; + /* 0x03C */ s16* rightSaveResampleBuf; + /* 0x040 */ ReverbBufferEntry bufEntry[2][5]; + /* 0x158 */ ReverbBufferEntry subBufEntry[2][5]; /* 0x270 */ s16* filterLeft; /* 0x274 */ s16* filterRight; - /* 0x278 */ s16* unk_278; - /* 0x27C */ s16* unk_27C; + /* 0x278 */ s16* filterLeftInit; + /* 0x27C */ s16* filterRightInit; /* 0x280 */ s16* filterLeftState; /* 0x284 */ s16* filterRightState; /* 0x288 */ TunedSample tunedSample; @@ -363,28 +406,26 @@ typedef struct { /* 0x1C */ EnvelopePoint* envelope; } AdsrState; // size = 0x20 -typedef struct { - /* 0x0 */ u8 unused : 2; - /* 0x0 */ u8 bit2 : 2; - /* 0x0 */ u8 strongRight : 1; - /* 0x0 */ u8 strongLeft : 1; - /* 0x0 */ u8 stereoHeadsetEffects : 1; - /* 0x0 */ u8 usesHeadsetPanEffects : 1; +typedef union { + struct { + /* 0x0 */ u8 unused : 2; + /* 0x0 */ u8 type : 2; + /* 0x0 */ u8 strongRight : 1; + /* 0x0 */ u8 strongLeft : 1; + /* 0x0 */ u8 strongReverbRight : 1; + /* 0x0 */ u8 strongReverbLeft : 1; + }; + /* 0x0 */ u8 asByte; } StereoData; // size = 0x1 -typedef union { - /* 0x0 */ StereoData s; - /* 0x0 */ u8 asByte; -} Stereo; // size = 0x1 - typedef struct { - /* 0x00 */ u8 reverb; + /* 0x00 */ u8 targetReverbVol; /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; - /* 0x03 */ u8 unk_3; // Possibly part of stereo? - /* 0x04 */ Stereo stereo; - /* 0x05 */ u8 unk_4; - /* 0x06 */ u16 unk_6; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; + /* 0x05 */ u8 combFilterSize; + /* 0x06 */ u16 combFilterGain; /* 0x08 */ f32 freqScale; /* 0x0C */ f32 velocity; /* 0x10 */ s16* filter; @@ -421,7 +462,7 @@ typedef struct SequenceChannel { } changes; /* 0x02 */ u8 noteAllocPolicy; /* 0x03 */ u8 muteFlags; - /* 0x04 */ u8 reverb; // or dry/wet mix + /* 0x04 */ u8 targetReverbVol; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; /* 0x07 */ u8 fontId; @@ -432,12 +473,12 @@ typedef struct SequenceChannel { /* 0x0C */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x0D */ u8 velocityRandomVariance; /* 0x0E */ u8 gateTimeRandomVariance; - /* 0x0F */ u8 unk_0F; - /* 0x10 */ u8 unk_10; + /* 0x0F */ u8 combFilterSize; + /* 0x10 */ u8 surroundEffectIndex; /* 0x11 */ u8 unk_11; /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; - /* 0x22 */ u16 unk_20; + /* 0x22 */ u16 combFilterGain; /* 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. @@ -459,7 +500,7 @@ typedef struct SequenceChannel { /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" /* 0xD0 */ u8* sfxState; // SfxChannelState /* 0xD4 */ s16* filter; - /* 0xD8 */ Stereo stereo; + /* 0xD8 */ StereoData stereoData; /* 0xDC */ s32 startSamplePos; /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 @@ -474,15 +515,15 @@ typedef struct SequenceLayer { /* 0x00 */ u8 ignoreDrumPan : 1; /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? /* 0x00 */ u8 notePropertiesNeedInit : 1; - /* 0x01 */ Stereo stereo; + /* 0x01 */ StereoData stereoData; /* 0x02 */ u8 instOrWave; /* 0x03 */ u8 gateTime; /* 0x04 */ u8 semitone; /* 0x05 */ u8 portamentoTargetNote; /* 0x06 */ u8 pan; // 0..128 /* 0x07 */ u8 notePan; - /* 0x08 */ u8 unk_08; - /* 0x09 */ u8 unk_09; + /* 0x08 */ u8 surroundEffectIndex; + /* 0x09 */ u8 targetReverbVol; union { struct { /* 0x0A */ u16 bit_0 : 1; @@ -531,45 +572,37 @@ typedef struct SequenceLayer { } SequenceLayer; // size = 0x90 typedef struct { - /* 0x00 */ s16 adpcmdecState[0x10]; - /* 0x20 */ s16 finalResampleState[0x10]; - /* 0x40 */ s16 mixEnvelopeState[0x28]; - /* 0x90 */ s16 panResampleState[0x10]; - /* 0xB0 */ s16 panSamplesBuffer[0x20]; - /* 0xF0 */ s16 dummyResampleState[0x10]; -} NoteSynthesisBuffers; // size = 0x110 + /* 0x000 */ s16 adpcmState[16]; + /* 0x020 */ s16 finalResampleState[16]; + /* 0x040 */ s16 filterState[32]; + /* 0x080 */ s16 unusedState[16]; + /* 0x0A0 */ s16 haasEffectDelayState[32]; + /* 0x0E0 */ s16 combFilterState[128]; + /* 0x1E0 */ s16 surroundEffectState[128]; +} NoteSynthesisBuffers; // size = 0x2E0 typedef struct { - /* 0x00 */ u8 restart_bit0 : 1; - /* 0x00 */ u8 restart_bit1 : 1; - /* 0x00 */ u8 restart_bit2 : 1; - /* 0x00 */ u8 restart_bit3 : 1; - /* 0x00 */ u8 restart_bit4 : 1; - /* 0x00 */ u8 restart_bit5 : 1; - /* 0x00 */ u8 restart_bit6 : 1; - /* 0x00 */ u8 restart_bit7 : 1; + /* 0x00 */ u8 atLoopPoint : 1; + /* 0x00 */ u8 stopLoop : 1; /* 0x01 */ u8 sampleDmaIndex; - /* 0x02 */ u8 prevHeadsetPanRight; - /* 0x03 */ u8 prevHeadsetPanLeft; - /* 0x04 */ u8 reverbVol; + /* 0x02 */ u8 prevHaasEffectLeftDelaySize; + /* 0x03 */ u8 prevHaasEffectRightDelaySize; + /* 0x04 */ u8 curReverbVol; /* 0x05 */ u8 numParts; - /* 0x06 */ u16 samplePosFrac; - /* 0x08 */ u16 unk_08; - /* 0x0C */ s32 samplePosInt; + /* 0x06 */ u16 samplePosFrac; // Fractional part of the sample position + /* 0x08 */ u16 surroundEffectGain; + /* 0x0C */ s32 samplePosInt; // Integer part of the sample position /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; /* 0x14 */ s16 curVolLeft; /* 0x16 */ s16 curVolRight; - /* 0x18 */ u16 unk_14; - /* 0x1A */ u16 unk_16; - /* 0x1C */ u16 unk_18; - /* 0x1E */ u8 unk_1A; + /* 0x18 */ UNK_TYPE1 unk_14[0x6]; + /* 0x1E */ u8 combFilterNeedsInit; /* 0x1F */ u8 unk_1F; - /* 0x20 */ u16 unk_1C; - /* 0x22 */ u16 unk_1E; + /* 0x20 */ UNK_TYPE1 unk_20[0x4]; } NoteSynthesisState; // size = 0x24 typedef struct { - /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // MM Something else? + /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // Something else? /* 0x04 */ u32 time; /* 0x08 */ s16* curve; /* 0x0C */ f32 extent; @@ -603,67 +636,68 @@ typedef struct { /* 0x34 */ AdsrState adsr; /* 0x54 */ Portamento portamento; /* 0x60 */ VibratoState vibratoState; - /* 0x7C */ char unk_7C[0x8]; + /* 0x7C */ UNK_TYPE1 pad7C[0x4]; + /* 0x80 */ u8 unk_80; /* 0x84 */ u32 startSamplePos; -} NotePlaybackState; // size = 0x88 + /* 0x88 */ UNK_TYPE1 unk_BC[0x1C]; +} NotePlaybackState; // size = 0xA4 typedef struct { struct { /* 0x00 */ volatile u8 enabled : 1; /* 0x00 */ u8 needsInit : 1; - /* 0x00 */ u8 finished : 1; // ? + /* 0x00 */ u8 finished : 1; /* 0x00 */ u8 unused : 1; - /* 0x00 */ u8 stereoStrongRight : 1; - /* 0x00 */ u8 stereoStrongLeft : 1; - /* 0x00 */ u8 stereoHeadsetEffects : 1; - /* 0x00 */ u8 usesHeadsetPanEffects : 1; // ? + /* 0x00 */ u8 strongRight : 1; + /* 0x00 */ u8 strongLeft : 1; + /* 0x00 */ u8 strongReverbRight : 1; + /* 0x00 */ u8 strongReverbLeft : 1; } bitField0; struct { /* 0x01 */ u8 reverbIndex : 3; /* 0x01 */ u8 bookOffset : 2; /* 0x01 */ u8 isSyntheticWave : 1; /* 0x01 */ u8 hasTwoParts : 1; - /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; + /* 0x01 */ u8 useHaasEffect : 1; } bitField1; /* 0x02 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number - /* 0x03 */ u8 headsetPanRight; - /* 0x04 */ u8 headsetPanLeft; - /* 0x05 */ u8 reverbVol; + /* 0x03 */ u8 haasEffectLeftDelaySize; + /* 0x04 */ u8 haasEffectRightDelaySize; + /* 0x05 */ u8 targetReverbVol; /* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex - /* 0x07 */ u8 unk_07; + /* 0x07 */ u8 combFilterSize; /* 0x08 */ u16 targetVolLeft; /* 0x0A */ u16 targetVolRight; - /* 0x0C */ u16 resamplingRateFixedPoint; - /* 0x0E */ u16 unk_0E; + /* 0x0C */ u16 frequencyFixedPoint; + /* 0x0E */ u16 combFilterGain; union { /* 0x10 */ TunedSample* tunedSample; /* 0x10 */ s16* waveSampleAddr; // used for synthetic waves }; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_18; - /* 0x19 */ u8 unk_19; - /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; -} NoteSubEu; // size = 0x20 + /* 0x18 */ UNK_TYPE1 unk_18; + /* 0x19 */ u8 surroundEffectIndex; + /* 0x1A */ UNK_TYPE1 unk_1A[0x6]; +} NoteSampleState; // size = 0x20 typedef struct Note { /* 0x00 */ AudioListItem listItem; /* 0x10 */ NoteSynthesisState synthesisState; /* 0x34 */ NotePlaybackState playbackState; - /* 0xBC */ char unk_BC[0x1C]; - /* 0xD8 */ NoteSubEu noteSubEu; + /* 0xD8 */ NoteSampleState sampleState; } Note; // size = 0xF8 typedef struct { /* 0x00 */ u8 downsampleRate; - /* 0x02 */ u16 windowSize; - /* 0x04 */ u16 unk_4; - /* 0x06 */ u16 unk_6; - /* 0x08 */ u16 unk_8; - /* 0x0A */ u16 unk_A; + /* 0x02 */ u16 delayNumSamples; + /* 0x04 */ u16 decayRatio; // determines how fast reverb dissipates + /* 0x06 */ u16 subDelay; + /* 0x08 */ u16 subVolume; + /* 0x0A */ u16 volume; /* 0x0C */ u16 leakRtl; /* 0x0E */ u16 leakLtr; - /* 0x10 */ s8 unk_10; - /* 0x12 */ u16 unk_12; + /* 0x10 */ s8 mixReverbIndex; + /* 0x12 */ u16 mixReverbStrength; /* 0x14 */ s16 lowPassFilterCutoffLeft; /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 @@ -704,13 +738,13 @@ typedef struct { /* 0x00 */ s16 specUnk4; /* 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 maxAiBufNumSamples; - /* 0x0A */ s16 minAiBufNumSamples; + /* 0x06 */ s16 numSamplesPerFrameTarget; + /* 0x08 */ s16 numSamplesPerFrameMax; + /* 0x0A */ s16 numSamplesPerFrameMin; /* 0x0C */ s16 updatesPerFrame; // for each frame of the audio thread (default 60 fps), number of updates to process audio - /* 0x0E */ s16 samplesPerUpdate; - /* 0x10 */ s16 samplesPerUpdateMax; - /* 0x12 */ s16 samplesPerUpdateMin; + /* 0x0E */ s16 numSamplesPerUpdate; + /* 0x10 */ s16 numSamplesPerUpdateMax; + /* 0x12 */ s16 numSamplesPerUpdateMin; /* 0x14 */ s16 numSequencePlayers; /* 0x18 */ f32 resampleRate; /* 0x1C */ f32 updatesPerFrameInv; // inverse (reciprocal) of updatesPerFrame @@ -899,8 +933,8 @@ typedef struct { /* 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; - /* 0x0014 */ NoteSubEu* noteSubsEu; + /* 0x0010 */ s16* adpcmCodeBook; + /* 0x0014 */ NoteSampleState* sampleStateList; /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; /* 0x0B58 */ char unk_0B58[0x30]; /* 0x0B88 */ Sample* usedSamples[128]; @@ -1002,7 +1036,7 @@ typedef struct { /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; /* 0x7840 */ SequenceChannel sequenceChannelNone; - /* 0x7924 */ s32 noteSubEuOffset; + /* 0x7924 */ s32 sampleStateOffset; // Start of the list of sample states for this update. Resets after each audio frame. /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; /* 0x7978 */ u8 cmdWritePos; @@ -1023,17 +1057,17 @@ typedef struct { } AudioContext; // size = 0x81F8 typedef struct { - /* 0x00 */ u8 reverbVol; + /* 0x00 */ u8 targetReverbVol; /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; - /* 0x03 */ u8 unk_3; - /* 0x04 */ Stereo stereo; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; /* 0x08 */ f32 frequency; /* 0x0C */ f32 velocity; /* 0x10 */ char unk_0C[0x4]; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_14; - /* 0x1A */ u16 unk_16; + /* 0x18 */ u8 combFilterSize; + /* 0x1A */ u16 combFilterGain; } NoteSubAttributes; // size = 0x1A typedef struct { diff --git a/spec b/spec index 4dec1f228..100e615cf 100644 --- a/spec +++ b/spec @@ -608,7 +608,6 @@ beginseg pad_text include "build/src/code/audio/audio_data.o" include "build/src/code/audio/audio_synthesis.o" - include "build/data/code/audio_synthesis.data.o" include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" diff --git a/src/code/audio/audio_data.c b/src/code/audio/audio_data.c index 7238a4bfa..eb931262b 100644 --- a/src/code/audio/audio_data.c +++ b/src/code/audio/audio_data.c @@ -857,22 +857,99 @@ EnvelopePoint gDefaultEnvelope[] = { { ADSR_DISABLE, 0 }, }; -NoteSubEu gZeroNoteSub = { 0 }; +NoteSampleState gZeroedSampleState = { 0 }; -NoteSubEu gDefaultNoteSub = { - { 1, 1, 0, 0, 0, 0, 0, 0 }, { 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +NoteSampleState gDefaultSampleState = { + { true, true, false, false, false, false, false, false }, + { 0 }, + 0, // gain + 0, // haasEffectLeftDelaySize + 0, // haasEffectRightDelaySize + 0, // targetReverbVol + 0, // harmonicIndexCurAndPrev + 0, // combFilterSize + 0, // targetVolLeft + 0, // targetVolRight + 0, // frequencyFixedPoint + 0, // combFilterGain + NULL, // tunedSample + NULL, // filter + 0, // unk_18 + 0, // surroundEffectIndex + 0, // unk_1A }; -u16 gHeadsetPanQuantization[64] = { - 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, - 16, 14, 12, 10, 8, 6, 4, 2, 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, +u16 gHaasEffectDelaySize[64] = { + 30 * SAMPLE_SIZE, + 29 * SAMPLE_SIZE, + 28 * SAMPLE_SIZE, + 27 * SAMPLE_SIZE, + 26 * SAMPLE_SIZE, + 25 * SAMPLE_SIZE, + 24 * SAMPLE_SIZE, + 23 * SAMPLE_SIZE, + 22 * SAMPLE_SIZE, + 21 * SAMPLE_SIZE, + 20 * SAMPLE_SIZE, + 19 * SAMPLE_SIZE, + 18 * SAMPLE_SIZE, + 17 * SAMPLE_SIZE, + 16 * SAMPLE_SIZE, + 15 * SAMPLE_SIZE, + 14 * SAMPLE_SIZE, + 13 * SAMPLE_SIZE, + 12 * SAMPLE_SIZE, + 11 * SAMPLE_SIZE, + 10 * SAMPLE_SIZE, + 9 * SAMPLE_SIZE, + 8 * SAMPLE_SIZE, + 7 * SAMPLE_SIZE, + 6 * SAMPLE_SIZE, + 5 * SAMPLE_SIZE, + 4 * SAMPLE_SIZE, + 3 * SAMPLE_SIZE, + 2 * SAMPLE_SIZE, + 1 * SAMPLE_SIZE, + 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, }; s32 D_801D58A4 = 0; // clang-format off -s16 D_801D58A8[] = { +s16 gInvalidAdpcmCodeBook[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index 667cd1c40..8412220a3 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -10,7 +10,7 @@ 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); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit); #define gTatumsPerBeat (gAudioTatumInit[1]) @@ -421,7 +421,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -435,7 +435,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -491,7 +491,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -504,7 +504,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + gAudioContext.notes[i].sampleState.bitField0.enabled) { break; } } @@ -814,7 +814,7 @@ void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { void AudioHeap_UpdateReverbs(void) { s32 count; - s32 i; + s32 reverbIndex; s32 j; if (gAudioContext.audioBufferParameters.specUnk4 == 2) { @@ -823,9 +823,9 @@ void AudioHeap_UpdateReverbs(void) { count = 1; } - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { for (j = 0; j < count; j++) { - AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[reverbIndex]); } } } @@ -837,7 +837,7 @@ void AudioHeap_ClearAiBuffers(void) { s32 curAiBufferIndex = gAudioContext.curAiBufferIndex; s32 i; - gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.minAiBufNumSamples; + gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.numSamplesPerFrameMin; for (i = 0; i < AIBUF_LEN; i++) { gAudioContext.aiBuffers[curAiBufferIndex][i] = 0; @@ -870,7 +870,7 @@ s32 AudioHeap_ResetStep(void) { AudioHeap_UpdateReverbs(); } else { for (i = 0; i < gAudioContext.numNotes; i++) { - if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + if (gAudioContext.notes[i].sampleState.bitField0.enabled && gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { gAudioContext.notes[i].playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; @@ -907,7 +907,7 @@ s32 AudioHeap_ResetStep(void) { AudioHeap_Init(); gAudioContext.resetStatus = 0; for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufNumSamples); i++) { - gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.maxAiBufNumSamples; + gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.numSamplesPerFrameMax; for (j = 0; j < AIBUF_LEN; j++) { gAudioContext.aiBuffers[i][j] = 0; } @@ -930,8 +930,8 @@ void AudioHeap_Init(void) { size_t cachePoolSize; size_t miscPoolSize; u32 intMask; + s32 reverbIndex; s32 i; - s32 j; s32 pad2; AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications @@ -942,19 +942,22 @@ void AudioHeap_Init(void) { gAudioContext.audioBufferParameters.aiSamplingFreq = osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); - gAudioContext.audioBufferParameters.samplesPerFrameTarget = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget = ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); - gAudioContext.audioBufferParameters.minAiBufNumSamples = - gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; - gAudioContext.audioBufferParameters.maxAiBufNumSamples = - gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMin = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax = + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget + 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.numSamplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.numSamplesPerUpdate = + (gAudioContext.audioBufferParameters.numSamplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.numSamplesPerUpdateMax = + gAudioContext.audioBufferParameters.numSamplesPerUpdate + 8; + gAudioContext.audioBufferParameters.numSamplesPerUpdateMin = + gAudioContext.audioBufferParameters.numSamplesPerUpdate - 8; gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; gAudioContext.audioBufferParameters.updatesPerFrameInvScaled = (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; @@ -984,13 +987,13 @@ void AudioHeap_Init(void) { gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; - gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.maxAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.minAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.numSamplesPerFrameMin *= gAudioContext.audioBufferParameters.specUnk4; gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { - gAudioContext.audioBufferParameters.maxAiBufNumSamples -= 0x10; + gAudioContext.audioBufferParameters.numSamplesPerFrameMax -= 0x10; } // Determine the maximum allowable number of audio command list entries for the rsp microcode @@ -1037,13 +1040,13 @@ void AudioHeap_Init(void) { gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); AudioPlayback_NoteInitAll(); AudioPlayback_InitNoteFreeList(); - gAudioContext.noteSubsEu = + gAudioContext.sampleStateList = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * - gAudioContext.numNotes * sizeof(NoteSubEu)); + gAudioContext.numNotes * sizeof(NoteSampleState)); // Initialize audio binary interface command list buffer - for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { - gAudioContext.abiCmdBufs[j] = + for (i = 0; i < ARRAY_COUNT(gAudioContext.abiCmdBufs); i++) { + gAudioContext.abiCmdBufs[i] = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(Acmd)); } @@ -1052,20 +1055,20 @@ void AudioHeap_Init(void) { AudioHeap_InitAdsrDecayTable(); // Initialize reverbs - for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { - gAudioContext.synthesisReverbs[i].useReverb = 0; + for (reverbIndex = 0; reverbIndex < ARRAY_COUNT(gAudioContext.synthesisReverbs); reverbIndex++) { + gAudioContext.synthesisReverbs[reverbIndex].useReverb = 0; } gAudioContext.numSynthesisReverbs = spec->numReverbs; - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { - AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + AudioHeap_InitReverb(reverbIndex, &spec->reverbSettings[reverbIndex], true); } // Initialize sequence players AudioSeq_InitSequencePlayers(); - for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { - AudioSeq_InitSequencePlayerChannels(j); - AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_InitSequencePlayerChannels(i); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[i]); } // Initialize two additional caches on the audio heap to store individual audio samples @@ -1529,149 +1532,165 @@ void AudioHeap_DiscardSampleBanks(void) { } } -void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { - s32 windowSize; +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 isFirstInit) { + s32 delayNumSamples; SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; switch (dataType) { - case 0: - AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + case REVERB_DATA_TYPE_SETTINGS: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, false); break; - case 1: + + case REVERB_DATA_TYPE_DELAY: if (data < 4) { data = 4; } - windowSize = data * 64; - if (windowSize < 0x100) { - windowSize = 0x100; + delayNumSamples = data * 64; + if (delayNumSamples < (16 * SAMPLES_PER_FRAME)) { + delayNumSamples = 16 * SAMPLES_PER_FRAME; } - windowSize /= reverb->downsampleRate; + delayNumSamples /= 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 { + if (!isFirstInit) { + if (reverb->delayNumSamplesAfterDownsampling < (data / reverb->downsampleRate)) { break; } + if ((reverb->nextReverbBufPos >= delayNumSamples) || (reverb->delayNumSamplesUnk >= delayNumSamples)) { + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; + } } - reverb->windowSize = windowSize; + reverb->delayNumSamples = delayNumSamples; - 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) { + if ((reverb->downsampleRate != 1) || reverb->resampleEffectOn) { + reverb->downsamplePitch = 0x8000 / reverb->downsampleRate; + if (reverb->leftLoadResampleBuf == NULL) { + reverb->leftLoadResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightLoadResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->leftSaveResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightSaveResampleBuf = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(RESAMPLE_STATE)); + if (reverb->rightSaveResampleBuf == NULL) { reverb->downsampleRate = 1; } } } break; - case 2: - gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + + case REVERB_DATA_TYPE_DECAY: + gAudioContext.synthesisReverbs[reverbIndex].decayRatio = data; break; - case 3: - gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + + case REVERB_DATA_TYPE_SUB_VOLUME: + gAudioContext.synthesisReverbs[reverbIndex].subVolume = data; break; - case 4: - gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + + case REVERB_DATA_TYPE_VOLUME: + gAudioContext.synthesisReverbs[reverbIndex].volume = data; break; - case 5: + + case REVERB_DATA_TYPE_LEAK_RIGHT: gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; break; - case 6: + + case REVERB_DATA_TYPE_LEAK_LEFT: gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; break; - case 7: + + case REVERB_DATA_TYPE_FILTER_LEFT: 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); + if (isFirstInit || (reverb->filterLeftInit == NULL)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, + 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterLeftInit = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } - reverb->filterLeft = reverb->unk_278; - if (reverb->filterLeft != 0) { + reverb->filterLeft = reverb->filterLeftInit; + if (reverb->filterLeft != NULL) { AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); } } else { - reverb->filterLeft = 0; + reverb->filterLeft = NULL; - if (flags != 0) { - reverb->unk_278 = 0; + if (isFirstInit) { + reverb->filterLeftInit = NULL; } } - break; - case 8: + + case REVERB_DATA_TYPE_FILTER_RIGHT: 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); + if (isFirstInit || (reverb->filterRightInit == NULL)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed( + &gAudioContext.miscPool, 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterRightInit = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } - reverb->filterRight = reverb->unk_27C; - if (reverb->unk_27C != 0) { - AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + reverb->filterRight = reverb->filterRightInit; + if (reverb->filterRight != NULL) { + AudioHeap_LoadLowPassFilter(reverb->filterRight, data); } } else { - reverb->filterRight = 0; - if (flags != 0) { - reverb->unk_27C = 0; + reverb->filterRight = NULL; + if (isFirstInit) { + reverb->filterRightInit = NULL; } } break; - case 9: - reverb->unk_19 = data; + + case REVERB_DATA_TYPE_9: + reverb->resampleEffectExtraSamples = data; if (data == 0) { - reverb->unk_18 = false; + reverb->resampleEffectOn = false; } else { - reverb->unk_18 = true; + reverb->resampleEffectOn = true; } break; + default: break; } } -void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit) { 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)) { + if (isFirstInit) { + reverb->delayNumSamplesAfterDownsampling = settings->delayNumSamples / settings->downsampleRate; + reverb->leftLoadResampleBuf = NULL; + } else if (reverb->delayNumSamplesAfterDownsampling < (settings->delayNumSamples / 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->resampleEffectOn = false; + reverb->resampleEffectExtraSamples = 0; + reverb->resampleEffectLoadUnk = 0; + reverb->resampleEffectSaveUnk = 0; + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_DELAY, settings->delayNumSamples, isFirstInit); + reverb->decayRatio = settings->decayRatio; + reverb->volume = settings->volume; + reverb->subDelay = settings->subDelay * 64; + reverb->subVolume = settings->subVolume; reverb->leakRtl = settings->leakRtl; reverb->leakLtr = settings->leakLtr; - reverb->unk_05 = settings->unk_10; - reverb->unk_08 = settings->unk_12; - reverb->useReverb = 8; + reverb->mixReverbIndex = settings->mixReverbIndex; + reverb->mixReverbStrength = settings->mixReverbStrength; + reverb->useReverb = 8; // used as a boolean - if (flags != 0) { - reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); - reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + if (isFirstInit) { + reverb->leftReverbBuf = + AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->delayNumSamples * 2); + reverb->rightReverbBuf = + AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->delayNumSamples * 2); reverb->resampleFlags = 1; - reverb->nextRingBufPos = 0; - reverb->unk_24 = 0; + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; reverb->curFrame = 0; reverb->framesToIgnore = 2; } @@ -1681,12 +1700,13 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) reverb->tunedSample.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->sample.size = reverb->delayNumSamples * SAMPLE_SIZE; + reverb->sample.sampleAddr = (u8*)reverb->leftReverbBuf; reverb->loop.start = 0; reverb->loop.count = 1; - reverb->loop.end = reverb->windowSize; + reverb->loop.loopEnd = reverb->delayNumSamples; - AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); - AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_LEFT, settings->lowPassFilterCutoffLeft, isFirstInit); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_RIGHT, settings->lowPassFilterCutoffRight, + isFirstInit); } diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 81c49b30c..59c6658ac 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -1,12 +1,184 @@ #include "global.h" const s16 gAudioTatumInit[] = { - 0x1C00, // unused - 0x30, // gTatumsPerBeat + 0x1C00, // unused + TATUMS_PER_BEAT, // gTatumsPerBeat }; +// TODO: Extract from table? +#define NUM_SOUNDFONTS 41 +#define SFX_SEQ_SIZE 0xC6A0 +#define AMBIENCE_SEQ_SIZE 0xFC0 +#define SOUNDFONT_0_SIZE 0x81C0 +#define SOUNDFONT_1_SIZE 0x36D0 +#define SOUNDFONT_2_SIZE 0xCE0 + +// Sizes of everything on the init pool +#define AI_BUFFERS_SIZE (AIBUF_SIZE * ARRAY_COUNT(gAudioContext.aiBuffers)) +#define SOUNDFONT_LIST_SIZE (NUM_SOUNDFONTS * sizeof(SoundFont)) + +// 0x19BD0 +#define PERMANENT_POOL_SIZE \ + (SFX_SEQ_SIZE + AMBIENCE_SEQ_SIZE + SOUNDFONT_0_SIZE + SOUNDFONT_1_SIZE + SOUNDFONT_2_SIZE + 0x430) + const AudioHeapInitSizes gAudioHeapInitSizes = { - 0x137F00, // heapSize - 0x1C480, // initPoolSize - 0x1A000, // permanentPoolSize + ALIGN16(sizeof(gAudioHeap) - 0x100), // audio heap size + ALIGN16(PERMANENT_POOL_SIZE + AI_BUFFERS_SIZE + SOUNDFONT_LIST_SIZE + 0x40), // init pool size + ALIGN16(PERMANENT_POOL_SIZE), // permanent pool size +}; + +#define REVERB_INDEX_0_SETTINGS \ + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 } + +ReverbSettings reverbSettings0[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettings1[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettings2[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x38, 0x2800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 7, 7 }, +}; + +ReverbSettings reverbSettings3[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings4[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettings5[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5C00, 0, 0, 0x7FFF, 0x2000, 0x2000, REVERB_INDEX_NONE, 0x3000, 4, 4 }, +}; + +ReverbSettings reverbSettings6[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6000, 0, 0, 0x7FFF, 0x1000, 0x1000, REVERB_INDEX_NONE, 0x3000, 10, 10 }, +}; + +ReverbSettings reverbSettings7[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, +}; + +ReverbSettings reverbSettings8[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x5000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings9[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettingsA[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettingsB[3] = { + REVERB_INDEX_0_SETTINGS, +}; + +ReverbSettings reverbSettingsC[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsD[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsE[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettingsF[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings* gReverbSettingsTable[] = { + reverbSettings0, reverbSettings1, reverbSettings2, reverbSettings4, reverbSettings5, + reverbSettings6, reverbSettings7, reverbSettings8, reverbSettings9, reverbSettings3, +}; + +AudioSpec gAudioSpecs[21] = { + /* 0x0 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x1 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x2 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x3 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x4 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x5 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x6 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x7 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x8 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x9 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xA */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x2800, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xB */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xC */ + { 32000, 1, 28, 5, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xCC800 }, + /* 0xD */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsD, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xE */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsE, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xF */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4000, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x10 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x11 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings8, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x12 */ + { 32000, 1, 16, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x13 */ + { 22050, 1, 24, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x14 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettings2, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x3600, 0x2600, 0, 0, + 0xDC800 }, }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index c8e5ac5d1..ccdc7488d 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1218,9 +1218,9 @@ void AudioLoad_Init(void* heap, size_t heapSize) { s32 i; s32 j; - D_80208E68 = NULL; - D_80208E70 = NULL; - D_80208E74 = NULL; + gCustomAudioUpdateFunction = NULL; + gCustomAudioReverbFunction = NULL; + gCustomAudioSynthFunction = NULL; for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { gAudioContext.unk_29A8[i] = NULL; diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index e1a42b1ed..a7cc9a588 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -1,10 +1,10 @@ #include "global.h" -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput); void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item); void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer); -void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttributes* subAttrs) { +void AudioPlayback_InitSampleState(Note* note, NoteSampleState* sampleState, NoteSubAttributes* subAttrs) { f32 volLeft; f32 volRight; s32 halfPanIndex; @@ -13,45 +13,45 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut u8 strongRight; f32 vel; u8 pan; - u8 reverbVol; + u8 targetReverbVol; StereoData stereoData; s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects; vel = subAttrs->velocity; pan = subAttrs->pan; - reverbVol = subAttrs->reverbVol; - stereoData = subAttrs->stereo.s; + targetReverbVol = subAttrs->targetReverbVol; + stereoData = subAttrs->stereoData; - noteSubEu->bitField0 = note->noteSubEu.bitField0; - noteSubEu->bitField1 = note->noteSubEu.bitField1; - noteSubEu->waveSampleAddr = note->noteSubEu.waveSampleAddr; - noteSubEu->harmonicIndexCurAndPrev = note->noteSubEu.harmonicIndexCurAndPrev; + sampleState->bitField0 = note->sampleState.bitField0; + sampleState->bitField1 = note->sampleState.bitField1; + sampleState->waveSampleAddr = note->sampleState.waveSampleAddr; + sampleState->harmonicIndexCurAndPrev = note->sampleState.harmonicIndexCurAndPrev; - AudioPlayback_NoteSetResamplingRate(noteSubEu, subAttrs->frequency); + AudioPlayback_NoteSetResamplingRate(sampleState, subAttrs->frequency); pan &= 0x7F; - noteSubEu->bitField0.stereoStrongRight = false; - noteSubEu->bitField0.stereoStrongLeft = false; - noteSubEu->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; - noteSubEu->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; + sampleState->bitField0.strongRight = false; + sampleState->bitField0.strongLeft = false; + sampleState->bitField0.strongReverbRight = stereoData.strongReverbRight; + sampleState->bitField0.strongReverbLeft = stereoData.strongReverbLeft; if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_HEADSET)) { halfPanIndex = pan >> 1; if (halfPanIndex > 0x3F) { halfPanIndex = 0x3F; } - noteSubEu->headsetPanLeft = gHeadsetPanQuantization[halfPanIndex]; - noteSubEu->headsetPanRight = gHeadsetPanQuantization[0x3F - halfPanIndex]; - noteSubEu->bitField1.usesHeadsetPanEffects2 = true; + sampleState->haasEffectRightDelaySize = gHaasEffectDelaySize[halfPanIndex]; + sampleState->haasEffectLeftDelaySize = gHaasEffectDelaySize[0x3F - halfPanIndex]; + sampleState->bitField1.useHaasEffect = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; } else if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_STEREO)) { strongLeft = strongRight = false; - noteSubEu->headsetPanRight = 0; - noteSubEu->headsetPanLeft = 0; - noteSubEu->bitField1.usesHeadsetPanEffects2 = false; + sampleState->haasEffectLeftDelaySize = 0; + sampleState->haasEffectRightDelaySize = 0; + sampleState->bitField1.useHaasEffect = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[0x7F - pan]; @@ -62,37 +62,37 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut } // case 0: - noteSubEu->bitField0.stereoStrongRight = strongRight; - noteSubEu->bitField0.stereoStrongLeft = strongLeft; + sampleState->bitField0.strongRight = strongRight; + sampleState->bitField0.strongLeft = strongLeft; - switch (stereoData.bit2) { + switch (stereoData.type) { case 0: break; case 1: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; break; case 2: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight | strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft | strongLeft; break; case 3: - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight ^ strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft ^ strongLeft; break; } } else if (gAudioContext.soundMode == SOUNDMODE_MONO) { - noteSubEu->bitField0.stereoHeadsetEffects = false; - noteSubEu->bitField0.usesHeadsetPanEffects = false; + sampleState->bitField0.strongReverbRight = false; + sampleState->bitField0.strongReverbLeft = false; volLeft = 0.707f; // approx 1/sqrt(2) volRight = 0.707f; } else { - noteSubEu->bitField0.stereoStrongRight = stereoData.strongRight; - noteSubEu->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; volLeft = gDefaultPanVolume[pan]; volRight = gDefaultPanVolume[0x7F - pan]; } @@ -100,33 +100,33 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* noteSubEu, NoteSubAttribut vel = 0.0f > vel ? 0.0f : vel; vel = 1.0f < vel ? 1.0f : vel; - noteSubEu->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); - noteSubEu->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); + sampleState->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); + sampleState->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - noteSubEu->gain = subAttrs->gain; - noteSubEu->filter = subAttrs->filter; - noteSubEu->unk_07 = subAttrs->unk_14; - noteSubEu->unk_0E = subAttrs->unk_16; - noteSubEu->reverbVol = reverbVol; - noteSubEu->unk_19 = subAttrs->unk_3; + sampleState->gain = subAttrs->gain; + sampleState->filter = subAttrs->filter; + sampleState->combFilterSize = subAttrs->combFilterSize; + sampleState->combFilterGain = subAttrs->combFilterGain; + sampleState->targetReverbVol = targetReverbVol; + sampleState->surroundEffectIndex = subAttrs->surroundEffectIndex; } -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) { +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput) { f32 resamplingRate = 0.0f; if (resamplingRateInput < 2.0f) { - noteSubEu->bitField1.hasTwoParts = false; + sampleState->bitField1.hasTwoParts = false; resamplingRate = CLAMP_MAX(resamplingRateInput, 1.99998f); } else { - noteSubEu->bitField1.hasTwoParts = true; + sampleState->bitField1.hasTwoParts = true; if (resamplingRateInput > 3.99996f) { resamplingRate = 1.99998f; } else { resamplingRate = resamplingRateInput * 0.5f; } } - noteSubEu->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f); + sampleState->frequencyFixedPoint = (s32)(resamplingRate * 32768.0f); } void AudioPlayback_NoteInit(Note* note) { @@ -140,17 +140,17 @@ void AudioPlayback_NoteInit(Note* note) { note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL; - note->noteSubEu = gDefaultNoteSub; + note->sampleState = gDefaultSampleState; } void AudioPlayback_NoteDisable(Note* note) { - if (note->noteSubEu.bitField0.needsInit == true) { - note->noteSubEu.bitField0.needsInit = false; + if (note->sampleState.bitField0.needsInit == true) { + note->sampleState.bitField0.needsInit = false; } note->playbackState.priority = 0; - note->noteSubEu.bitField0.enabled = false; + note->sampleState.bitField0.enabled = false; note->playbackState.status = PLAYBACK_STATUS_0; - note->noteSubEu.bitField0.finished = false; + note->sampleState.bitField0.finished = false; note->playbackState.parentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED; @@ -161,8 +161,8 @@ void AudioPlayback_ProcessNotes(void) { s32 pad; s32 playbackStatus; NoteAttributes* attrs; - NoteSubEu* noteSubEu2; - NoteSubEu* noteSubEu; + NoteSampleState* sampleState; + NoteSampleState* noteSampleState; Note* note; NotePlaybackState* playbackState; NoteSubAttributes subAttrs; @@ -172,7 +172,7 @@ void AudioPlayback_ProcessNotes(void) { for (i = 0; i < gAudioContext.numNotes; i++) { note = &gAudioContext.notes[i]; - noteSubEu2 = &gAudioContext.noteSubsEu[gAudioContext.noteSubEuOffset + i]; + sampleState = &gAudioContext.sampleStateList[gAudioContext.sampleStateOffset + i]; playbackState = ¬e->playbackState; if (playbackState->parentLayer != NO_LAYER) { if ((u32)playbackState->parentLayer < 0x7FFFFFFF) { @@ -211,10 +211,12 @@ void AudioPlayback_ProcessNotes(void) { out: if (playbackState->priority != 0) { + //! FAKE: if (1) {} - noteSubEu = ¬e->noteSubEu; - if ((playbackState->status >= 1) || noteSubEu->bitField0.finished) { - if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || noteSubEu->bitField0.finished) { + noteSampleState = ¬e->sampleState; + if ((playbackState->status >= 1) || noteSampleState->bitField0.finished) { + if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || + noteSampleState->bitField0.finished) { if (playbackState->wantedParentLayer != NO_LAYER) { AudioPlayback_NoteDisable(note); if (playbackState->wantedParentLayer->channel != NULL) { @@ -260,14 +262,14 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.frequency = attrs->freqScale; subAttrs.velocity = attrs->velocity; subAttrs.pan = attrs->pan; - subAttrs.reverbVol = attrs->reverb; - subAttrs.stereo = attrs->stereo; + subAttrs.targetReverbVol = attrs->targetReverbVol; + subAttrs.stereoData = attrs->stereoData; subAttrs.gain = attrs->gain; subAttrs.filter = attrs->filter; - subAttrs.unk_14 = attrs->unk_4; - subAttrs.unk_16 = attrs->unk_6; - subAttrs.unk_3 = attrs->unk_3; - bookOffset = noteSubEu->bitField1.bookOffset; + subAttrs.combFilterSize = attrs->combFilterSize; + subAttrs.combFilterGain = attrs->combFilterGain; + subAttrs.surroundEffectIndex = attrs->surroundEffectIndex; + bookOffset = noteSampleState->bitField1.bookOffset; } else { SequenceLayer* layer = playbackState->parentLayer; SequenceChannel* channel = playbackState->parentLayer->channel; @@ -276,34 +278,35 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.velocity = layer->noteVelocity; subAttrs.pan = layer->notePan; - if (layer->unk_08 == 0x80) { - subAttrs.unk_3 = channel->unk_10; + if (layer->surroundEffectIndex == 0x80) { + subAttrs.surroundEffectIndex = channel->surroundEffectIndex; } else { - subAttrs.unk_3 = layer->unk_08; + subAttrs.surroundEffectIndex = layer->surroundEffectIndex; } - if (layer->stereo.s.bit2 == 0) { - subAttrs.stereo = channel->stereo; + if (layer->stereoData.type == 0) { + subAttrs.stereoData = channel->stereoData; } else { - subAttrs.stereo = layer->stereo; + subAttrs.stereoData = layer->stereoData; } if (layer->unk_0A.s.bit_2 == 1) { - subAttrs.reverbVol = channel->reverb; + subAttrs.targetReverbVol = channel->targetReverbVol; } else { - subAttrs.reverbVol = layer->unk_09; + subAttrs.targetReverbVol = layer->targetReverbVol; } if (layer->unk_0A.s.bit_9 == 1) { subAttrs.gain = channel->gain; } else { subAttrs.gain = 0; + //! FAKE: if (1) {} } subAttrs.filter = channel->filter; - subAttrs.unk_14 = channel->unk_0F; - subAttrs.unk_16 = channel->unk_20; + subAttrs.combFilterSize = channel->combFilterSize; + subAttrs.combFilterGain = channel->combFilterGain; bookOffset = channel->bookOffset & 0x7; if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { @@ -315,8 +318,8 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale; subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate; subAttrs.velocity *= scale; - AudioPlayback_InitNoteSub(note, noteSubEu2, &subAttrs); - noteSubEu->bitField1.bookOffset = bookOffset; + AudioPlayback_InitSampleState(note, sampleState, &subAttrs); + noteSampleState->bitField1.bookOffset = bookOffset; skip:; } } @@ -500,15 +503,15 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { channel = layer->channel; if (layer->unk_0A.s.bit_2 == 1) { - attrs->reverb = channel->reverb; + attrs->targetReverbVol = channel->targetReverbVol; } else { - attrs->reverb = layer->unk_09; + attrs->targetReverbVol = layer->targetReverbVol; } - if (layer->unk_08 == 0x80) { - attrs->unk_3 = channel->unk_10; + if (layer->surroundEffectIndex == 0x80) { + attrs->surroundEffectIndex = channel->surroundEffectIndex; } else { - attrs->unk_3 = layer->unk_08; + attrs->surroundEffectIndex = layer->surroundEffectIndex; } if (layer->unk_0A.s.bit_9 == 1) { @@ -526,20 +529,20 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->filter = attrs->filterBuf; } - attrs->unk_6 = channel->unk_20; - attrs->unk_4 = channel->unk_0F; + attrs->combFilterGain = channel->combFilterGain; + attrs->combFilterSize = channel->combFilterSize; if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { - note->noteSubEu.bitField0.finished = true; + note->sampleState.bitField0.finished = true; } - if (layer->stereo.asByte == 0) { - attrs->stereo = channel->stereo; + if (layer->stereoData.asByte == 0) { + attrs->stereoData = channel->stereoData; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; } note->playbackState.priority = channel->someOtherPriority; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; note->playbackState.priority = 1; } @@ -620,7 +623,7 @@ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveI // Save the pointer to the synthethic wave // waveId index starts at 128, there are WAVE_SAMPLE_COUNT samples to read from - note->noteSubEu.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; + note->sampleState.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; return harmonicIndex; } @@ -638,7 +641,7 @@ void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer) { curHarmonicIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); if (curHarmonicIndex != prevHarmonicIndex) { - note->noteSubEu.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; + note->sampleState.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; } } @@ -808,7 +811,7 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { s16 instId; SequenceChannel* channel = layer->channel; NotePlaybackState* playbackState = ¬e->playbackState; - NoteSubEu* noteSubEu = ¬e->noteSubEu; + NoteSampleState* noteSampleState = ¬e->sampleState; playbackState->prevParentLayer = NO_LAYER; playbackState->parentLayer = layer; @@ -825,28 +828,28 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { if (instId == 0xFF) { instId = channel->instOrWave; } - noteSubEu->tunedSample = layer->tunedSample; + noteSampleState->tunedSample = layer->tunedSample; if (instId >= 0x80 && instId < 0xC0) { - noteSubEu->bitField1.isSyntheticWave = true; + noteSampleState->bitField1.isSyntheticWave = true; } else { - noteSubEu->bitField1.isSyntheticWave = false; + noteSampleState->bitField1.isSyntheticWave = false; } - if (noteSubEu->bitField1.isSyntheticWave) { + if (noteSampleState->bitField1.isSyntheticWave) { AudioPlayback_BuildSyntheticWave(note, layer, instId); } else if (channel->startSamplePos == 1) { - playbackState->startSamplePos = noteSubEu->tunedSample->sample->loop->start; + playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->start; } else { playbackState->startSamplePos = channel->startSamplePos; - if (playbackState->startSamplePos >= noteSubEu->tunedSample->sample->loop->end) { + if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->loopEnd) { playbackState->startSamplePos = 0; } } playbackState->fontId = channel->fontId; playbackState->stereoHeadsetEffects = channel->stereoHeadsetEffects; - noteSubEu->bitField1.reverbIndex = channel->reverbIndex & 3; + noteSampleState->bitField1.reverbIndex = channel->reverbIndex & 3; } void func_801963E8(Note* note, SequenceLayer* layer) { @@ -987,7 +990,7 @@ void AudioPlayback_NoteInitAll(void) { for (i = 0; i < gAudioContext.numNotes; i++) { note = &gAudioContext.notes[i]; - note->noteSubEu = gZeroNoteSub; + note->sampleState = gZeroedSampleState; note->playbackState.priority = 0; note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.parentLayer = NO_LAYER; @@ -1002,7 +1005,8 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.startSamplePos = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + note->synthesisState.synthesisBuffers = + AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, sizeof(NoteSynthesisBuffers)); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, FILTER_SIZE); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index a8573e33d..bc5115f8f 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -282,17 +282,17 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->transposition = 0; channel->largeNotes = false; channel->bookOffset = 0; - channel->stereo.asByte = 0; + channel->stereoData.asByte = 0; channel->changes.asByte = 0xFF; channel->scriptState.depth = 0; channel->newPan = 0x40; channel->panChannelWeight = 0x80; - channel->unk_10 = 0xFF; + channel->surroundEffectIndex = 0xFF; channel->velocityRandomVariance = 0; channel->gateTimeRandomVariance = 0; channel->noteUnused = NULL; channel->reverbIndex = 0; - channel->reverb = 0; + channel->targetReverbVol = 0; channel->gain = 0; channel->notePriority = 3; channel->someOtherPriority = 1; @@ -308,8 +308,8 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->vibrato.vibratoExtentChangeDelay = 0; channel->vibrato.vibratoDelay = 0; channel->filter = NULL; - channel->unk_20 = 0; - channel->unk_0F = 0; + channel->combFilterGain = 0; + channel->combFilterSize = 0; channel->volume = 1.0f; channel->volumeScale = 1.0f; channel->freqScale = 1.0f; @@ -345,7 +345,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { layer->channel = channel; layer->adsr = channel->adsr; layer->adsr.decayIndex = 0; - layer->unk_09 = channel->reverb; + layer->targetReverbVol = channel->targetReverbVol; layer->enabled = true; layer->finished = false; layer->stopSomething = false; @@ -355,8 +355,8 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { layer->bit1 = false; layer->notePropertiesNeedInit = false; layer->gateTime = 0x80; - layer->unk_08 = 0x80; - layer->stereo.asByte = 0; + layer->surroundEffectIndex = 0x80; + layer->stereoData.asByte = 0; layer->portamento.mode = PORTAMENTO_MODE_OFF; layer->scriptState.depth = 0; layer->pan = 0x40; @@ -782,7 +782,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xCD: // layer: stereo effects - layer->stereo.asByte = AudioSeq_ScriptReadU8(state); + layer->stereoData.asByte = AudioSeq_ScriptReadU8(state); break; case 0xCE: // layer: bend pitch @@ -796,7 +796,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xF1: // layer: - layer->unk_08 = AudioSeq_ScriptReadU8(state); + layer->surroundEffectIndex = AudioSeq_ScriptReadU8(state); break; default: @@ -991,13 +991,14 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { if (layer->delay == 0) { if (layer->tunedSample != NULL) { - time = layer->tunedSample->sample->loop->end; + time = layer->tunedSample->sample->loop->loopEnd; } else { time = 0.0f; } time *= seqPlayer->tempo; time *= gAudioContext.unk_2870; time /= layer->freqScale; + //! FAKE: if (1) {} if (time > 0x7FFE) { time = 0x7FFE; @@ -1416,9 +1417,9 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->vibrato.vibratoDelay = cmd * 16; break; - case 0xD4: // channel: set reverb + case 0xD4: // channel: set reverb volume cmd = (u8)cmdArgs[0]; - channel->reverb = cmd; + channel->targetReverbVol = cmd; break; case 0xC6: // channel: set soundFont @@ -1491,7 +1492,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { } else { channel->stereoHeadsetEffects = false; } - channel->stereo.asByte = cmd & 0x7F; + channel->stereoData.asByte = cmd & 0x7F; break; case 0xD1: // channel: set note allocation policy @@ -1537,7 +1538,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { data += 4; channel->newPan = data[-3]; channel->panChannelWeight = data[-2]; - channel->reverb = data[-1]; + channel->targetReverbVol = data[-1]; channel->reverbIndex = data[0]; //! @bug: Not marking reverb state as changed channel->changes.s.pan = true; @@ -1551,7 +1552,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState); channel->newPan = AudioSeq_ScriptReadU8(scriptState); channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState); - channel->reverb = AudioSeq_ScriptReadU8(scriptState); + channel->targetReverbVol = AudioSeq_ScriptReadU8(scriptState); channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState); //! @bug: Not marking reverb state as changed channel->changes.s.pan = true; @@ -1569,8 +1570,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->adsr.sustain = 0; channel->velocityRandomVariance = 0; channel->gateTimeRandomVariance = 0; - channel->unk_0F = 0; - channel->unk_20 = 0; + channel->combFilterSize = 0; + channel->combFilterGain = 0; channel->bookOffset = 0; channel->startSamplePos = 0; channel->unk_E0 = 0; @@ -1651,8 +1652,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xBB: // channel: - channel->unk_0F = cmdArgs[0]; - channel->unk_20 = cmdArgs[1]; + channel->combFilterSize = cmdArgs[0]; + channel->combFilterGain = cmdArgs[1]; break; case 0xBC: // channel: add large @@ -1667,8 +1668,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { if (cmdArgs[0] < 5) { if (1) {} if (gAudioContext.unk_29A8[cmdArgs[0]] != NULL) { - D_80208E6C = gAudioContext.unk_29A8[cmdArgs[0]]; - scriptState->value = D_80208E6C(scriptState->value, channel); + gCustomAudioSeqFunction = gAudioContext.unk_29A8[cmdArgs[0]]; + scriptState->value = gCustomAudioSeqFunction(scriptState->value, channel); } } break; @@ -1693,7 +1694,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xA4: // channel: - channel->unk_10 = cmdArgs[0]; + channel->surroundEffectIndex = cmdArgs[0]; break; case 0xA5: // channel: @@ -2197,7 +2198,7 @@ void AudioSeq_ProcessSequences(s32 arg0) { SequencePlayer* seqPlayer; u32 i; - gAudioContext.noteSubEuOffset = + gAudioContext.sampleStateOffset = (gAudioContext.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioContext.numNotes; for (i = 0; i < (u32)gAudioContext.audioBufferParameters.numSequencePlayers; i++) { diff --git a/src/code/audio/audio_synthesis.c b/src/code/audio/audio_synthesis.c index 51842a33f..17b3ff4be 100644 --- a/src/code/audio/audio_synthesis.c +++ b/src/code/audio/audio_synthesis.c @@ -1,137 +1,1698 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801877D0.s") +// DMEM Addresses for the RSP +#define DMEM_TEMP 0x3B0 +#define DMEM_TEMP2 0x3C0 +#define DMEM_SURROUND_TEMP 0x4B0 +#define DMEM_UNCOMPRESSED_NOTE 0x570 +#define DMEM_HAAS_TEMP 0x5B0 +#define DMEM_COMB_TEMP 0x750 // = DMEM_TEMP + DMEM_2CH_SIZE + a bit more +#define DMEM_COMPRESSED_ADPCM_DATA 0x930 // = DMEM_LEFT_CH +#define DMEM_LEFT_CH 0x930 +#define DMEM_RIGHT_CH 0xAD0 +#define DMEM_WET_TEMP 0x3D0 +#define DMEM_WET_SCRATCH 0x710 // = DMEM_WET_TEMP + DMEM_2CH_SIZE +#define DMEM_WET_LEFT_CH 0xC70 +#define DMEM_WET_RIGHT_CH 0xE10 // = DMEM_WET_LEFT_CH + DMEM_1CH_SIZE + +typedef enum { + /* 0 */ HAAS_EFFECT_DELAY_NONE, + /* 1 */ HAAS_EFFECT_DELAY_LEFT, // Delay left channel so that right channel is heard first + /* 2 */ HAAS_EFFECT_DELAY_RIGHT // Delay right channel so that left channel is heard first +} HaasEffectDelaySide; + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 arg2, uintptr_t arg3); +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 dmem, s32 flags); +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags); +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags); +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad); +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide); + +s32 D_801D5FB0 = 0; + +u32 sEnvMixerOp = _SHIFTL(A_ENVMIXER, 24, 8); + +// Store the left dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerLeftHaasDmemDests = + AUDIO_MK_CMD(DMEM_HAAS_TEMP >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Store the right dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerRightHaasDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_HAAS_TEMP >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +u32 sEnvMixerDefaultDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Unused Data +u16 D_801D5FC4[] = { + 0x7FFF, 0xD001, 0x3FFF, 0xF001, 0x5FFF, 0x9001, 0x7FFF, 0x8001, +}; + +u8 sNumSamplesPerWavePeriod[] = { + WAVE_SAMPLE_COUNT / 1, // 1st harmonic + WAVE_SAMPLE_COUNT / 2, // 2nd harmonic + WAVE_SAMPLE_COUNT / 4, // 4th harmonic + WAVE_SAMPLE_COUNT / 8, // 8th harmonic +}; + +/** + * Add a collection of s16-samples as a single entry to the reverb buffer + */ +void AudioSynth_AddReverbBufferEntry(s32 numSamples, s32 updateIndex, s32 reverbIndex) { + SynthesisReverb* reverb; + ReverbBufferEntry* entry; + s32 extraSamples; + s32 numSamplesAfterDownsampling; + s32 reverbBufPos; + s32 temp_t2; + s32 temp_t4; + s32 count1; + s32 count2; + s32 nextReverbSubBufPos; + + reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + numSamplesAfterDownsampling = numSamples / gAudioContext.synthesisReverbs[reverbIndex].downsampleRate; + + // Apply resampling effect + if (gAudioContext.synthesisReverbs[reverbIndex].resampleEffectOn) { + if (reverb->downsampleRate == 1) { + count1 = 0; + count2 = 0; + + numSamplesAfterDownsampling += reverb->resampleEffectExtraSamples; + + entry->saveResampleNumSamples = numSamplesAfterDownsampling; + entry->loadResamplePitch = ((u16)numSamplesAfterDownsampling << 0xF) / numSamples; + entry->saveResamplePitch = (numSamples << 0xF) / (u16)numSamplesAfterDownsampling; + + while (true) { + temp_t2 = (entry->loadResamplePitch * numSamples * 2) + reverb->resampleEffectLoadUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamplesAfterDownsampling) && (count1 == 0)) { + entry->loadResamplePitch = + ((numSamplesAfterDownsampling << 0x10) - reverb->resampleEffectLoadUnk) / (numSamples * 2); + count1++; + } else { + count1++; + if (temp_t4 > numSamplesAfterDownsampling) { + entry->loadResamplePitch--; + } else if (temp_t4 < numSamplesAfterDownsampling) { + entry->loadResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectLoadUnk = temp_t2 & 0xFFFF; + + while (true) { + temp_t2 = (entry->saveResamplePitch * numSamplesAfterDownsampling * 2) + reverb->resampleEffectSaveUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamples) && (count2 == 0)) { + entry->saveResamplePitch = + ((numSamples << 0x10) - reverb->resampleEffectSaveUnk) / (numSamplesAfterDownsampling * 2); + count2++; + } else { + count2++; + if (temp_t4 > numSamples) { + entry->saveResamplePitch--; + } else if (temp_t4 < numSamples) { + entry->saveResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectSaveUnk = temp_t2 & 0xFFFF; + } + } + + extraSamples = (reverb->nextReverbBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + reverbBufPos = reverb->nextReverbBufPos; + + // Add a reverb entry + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos += numSamplesAfterDownsampling; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos = extraSamples; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + + // Add a sub-reverb entry + if (reverb->subDelay != 0) { + nextReverbSubBufPos = reverb->subDelay + reverbBufPos; + if (nextReverbSubBufPos >= reverb->delayNumSamples) { + nextReverbSubBufPos -= reverb->delayNumSamples; + } + + entry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + numSamplesAfterDownsampling = numSamples / reverb->downsampleRate; + extraSamples = (nextReverbSubBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = nextReverbSubBufPos; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = nextReverbSubBufPos; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + } +} + +/** + * Sync the sample states between the notes and the list + */ +void AudioSynth_SyncSampleStates(s32 updateIndex) { + NoteSampleState* noteSampleState; + NoteSampleState* sampleState; + s32 sampleStateBaseIndex; + s32 i; + + sampleStateBaseIndex = gAudioContext.numNotes * updateIndex; + for (i = 0; i < gAudioContext.numNotes; i++) { + noteSampleState = &gAudioContext.notes[i].sampleState; + sampleState = &gAudioContext.sampleStateList[sampleStateBaseIndex + i]; + if (noteSampleState->bitField0.enabled) { + noteSampleState->bitField0.needsInit = false; + } else { + sampleState->bitField0.enabled = false; + } + + noteSampleState->harmonicIndexCurAndPrev = 0; + } +} + +Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame) { + s32 numSamplesPerUpdate; + s16* curAiBufPos; + Acmd* curCmd = abiCmdStart; + s32 reverseUpdateIndex; + s32 reverbIndex; + SynthesisReverb* reverb; + + for (reverseUpdateIndex = gAudioContext.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + AudioSeq_ProcessSequences(reverseUpdateIndex - 1); + AudioSynth_SyncSampleStates(gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + } + + curAiBufPos = aiBufStart; + gAudioContext.adpcmCodeBook = NULL; + + // Process/Update all samples multiple times in a single frame + for (reverseUpdateIndex = gAudioContext.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + if (reverseUpdateIndex == 1) { + // Final Update + numSamplesPerUpdate = numSamplesPerFrame; + } else if ((numSamplesPerFrame / reverseUpdateIndex) >= + gAudioContext.audioBufferParameters.numSamplesPerUpdateMax) { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdateMax; + } else if ((numSamplesPerFrame / reverseUpdateIndex) <= + gAudioContext.audioBufferParameters.numSamplesPerUpdateMin) { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdateMin; + } else { + numSamplesPerUpdate = gAudioContext.audioBufferParameters.numSamplesPerUpdate; + } + + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + if (gAudioContext.synthesisReverbs[reverbIndex].useReverb) { + AudioSynth_AddReverbBufferEntry( + numSamplesPerUpdate, gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex, + reverbIndex); + } + } + + curCmd = AudioSynth_ProcessSamples(curAiBufPos, numSamplesPerUpdate, curCmd, + gAudioContext.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + numSamplesPerFrame -= numSamplesPerUpdate; + curAiBufPos += numSamplesPerUpdate * SAMPLE_SIZE; + } + + // Update reverb frame info + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + if (gAudioContext.synthesisReverbs[reverbIndex].framesToIgnore != 0) { + gAudioContext.synthesisReverbs[reverbIndex].framesToIgnore--; + } + gAudioContext.synthesisReverbs[reverbIndex].curFrame ^= 1; + } + + *numAbiCmds = curCmd - abiCmdStart; + return curCmd; +} + +void AudioSynth_DisableSampleStates(s32 updateIndex, s32 noteIndex) { + NoteSampleState* sampleState; + s32 i; + + for (i = updateIndex + 1; i < gAudioContext.audioBufferParameters.updatesPerFrame; i++) { + sampleState = &gAudioContext.sampleStateList[(gAudioContext.numNotes * i) + noteIndex]; + if (sampleState->bitField0.needsInit) { + break; + } + sampleState->bitField0.enabled = false; + } +} + +/** + * Load reverb samples from a different reverb index + */ +Acmd* AudioSynth_LoadMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +/** + * Save reverb samples from a different reverb index + */ +Acmd* AudioSynth_SaveMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +void AudioSynth_Noop1(void) { +} + +void AudioSynth_ClearBuffer(Acmd* cmd, s32 dmem, s32 size) { + aClearBuffer(cmd, dmem, size); +} + +void AudioSynth_Noop2(void) { +} + +void AudioSynth_Noop3(void) { +} + +void AudioSynth_Noop4(void) { +} + +void AudioSynth_Mix(Acmd* cmd, size_t size, s32 gain, s32 dmemIn, s32 dmemOut) { + aMix(cmd, size, gain, dmemIn, dmemOut); +} + +void AudioSynth_Noop5(void) { +} + +void AudioSynth_Noop6(void) { +} + +void AudioSynth_Noop7(void) { +} + +void AudioSynth_SetBuffer(Acmd* cmd, s32 flags, s32 dmemIn, s32 dmemOut, size_t size) { + aSetBuffer(cmd, flags, dmemIn, dmemOut, size); +} + +void AudioSynth_Noop8(void) { +} + +void AudioSynth_Noop9(void) { +} + +void AudioSynth_DMemMove(Acmd* cmd, s32 dmemIn, s32 dmemOut, size_t size) { + // aDMEMMove(cmd, dmemIn, dmemOut, size); + cmd->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(dmemIn, 0, 24); + cmd->words.w1 = _SHIFTL(dmemOut, 16, 16) | _SHIFTL(size, 0, 16); +} + +void AudioSynth_Noop10(void) { +} + +void AudioSynth_Noop11(void) { +} + +void AudioSynth_Noop12(void) { +} + +void AudioSynth_Noop13(void) { +} + +void AudioSynth_InterL(Acmd* cmd, s32 dmemIn, s32 dmemOut, s32 numSamples) { + // aInterl(cmd, dmemIn, dmemOut, numSamples); + cmd->words.w0 = _SHIFTL(A_INTERL, 24, 8) | _SHIFTL(numSamples, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} + +void AudioSynth_EnvSetup1(Acmd* cmd, s32 reverbVol, s32 rampReverb, s32 rampLeft, s32 rampRight) { + aEnvSetup1(cmd, reverbVol, rampReverb, rampLeft, rampRight); +} + +void AudioSynth_Noop14(void) { +} + +void AudioSynth_LoadBuffer(Acmd* cmd, s32 dmemDest, s32 size, void* addrSrc) { + aLoadBuffer(cmd, addrSrc, dmemDest, size); +} + +void AudioSynth_SaveBuffer(Acmd* cmd, s32 dmemSrc, s32 size, void* addrDest) { + aSaveBuffer(cmd, dmemSrc, addrDest, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187B64.s") +void AudioSynth_EnvSetup2(Acmd* cmd, s32 volLeft, s32 volRight) { + // aEnvSetup2(cmd, volLeft, volRight); + cmd->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); + cmd->words.w1 = _SHIFTL(volLeft, 16, 16) | _SHIFTL(volRight, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187BEC.s") +void AudioSynth_Noop15(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187DE8.s") +void AudioSynth_Noop16(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187E58.s") +void AudioSynth_Noop17(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187F00.s") +void AudioSynth_S8Dec(Acmd* cmd, s32 flags, s16* state) { + aS8Dec(cmd, flags, state); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FA8.s") +void AudioSynth_HiLoGain(Acmd* cmd, s32 gain, s32 dmemIn, s32 dmemOut, s32 size) { + // aHiLoGain(cmd, gain, size, dmemIn, dmemOut); + cmd->words.w0 = _SHIFTL(A_HILOGAIN, 24, 8) | _SHIFTL(gain, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FB0.s") +// Remnant of OoT +void AudioSynth_UnkCmd19(Acmd* cmd, s32 dmem1, s32 dmem2, s32 size, s32 arg4) { + cmd->words.w0 = _SHIFTL(A_SPNOOP, 24, 8) | _SHIFTL(arg4, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmem1, 16, 16) | _SHIFTL(dmem2, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD0.s") +void AudioSynth_Noop18(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD8.s") +void AudioSynth_Noop19(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE0.s") +void AudioSynth_Noop20(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE8.s") +void AudioSynth_Noop21(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018801C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188024.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018802C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188034.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188068.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188070.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018811C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018814C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188174.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188198.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188224.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018822C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188234.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018823C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188244.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018824C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188254.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018825C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188264.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801882A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188304.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801884A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188698.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018883C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801888E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801889A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188AFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188C48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188CB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188FBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189064.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189620.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A4B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018ACC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018AE34.s") +void AudioSynth_Noop22(void) { +} + +void AudioSynth_Noop23(void) { +} + +void AudioSynth_Noop24(void) { +} + +void AudioSynth_Noop25(void) { +} + +void AudioSynth_LoadFilterBuffer(Acmd* cmd, s32 flags, s32 buf, s16* addr) { + aFilter(cmd, flags, buf, addr); +} + +void AudioSynth_LoadFilterSize(Acmd* cmd, size_t size, s16* addr) { + aFilter(cmd, 2, size, addr); +} + +/** + * Leak some audio from the left reverb channel into the right reverb channel and vice versa (pan) + */ +Acmd* AudioSynth_LeakReverb(Acmd* cmd, SynthesisReverb* reverb) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_SCRATCH, DMEM_1CH_SIZE); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakRtl, DMEM_WET_RIGHT_CH, DMEM_WET_LEFT_CH); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakLtr, DMEM_WET_SCRATCH, DMEM_WET_RIGHT_CH); + + return cmd; +} + +Acmd* AudioSynth_LoadDownsampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + wrappedOffsetSize, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 numSamples = entry->numSamples; + u32 size = numSamples * SAMPLE_SIZE; + + // Left Resample + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->leftSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->leftReverbBuf); + } + + // Right Resample + aDMEMMove(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->rightSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->rightReverbBuf); + } + + return cmd; +} + +Acmd* AudioSynth_LoadResampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, wrappedOffsetSize + DMEM_WET_TEMP, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +/** + * Apply a filter (convolution) to each reverb channel. + */ +Acmd* AudioSynth_FilterReverb(Acmd* cmd, s32 size, SynthesisReverb* reverb) { + if (reverb->filterLeft != NULL) { + aFilter(cmd++, 2, size, reverb->filterLeft); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_LEFT_CH, reverb->filterLeftState); + } + + if (reverb->filterRight != NULL) { + aFilter(cmd++, 2, size, reverb->filterRight); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_RIGHT_CH, reverb->filterRightState); + } + + return cmd; +} + +/** + * Mix in reverb from a different reverb index + */ +Acmd* AudioSynth_MixOtherReverbIndex(Acmd* cmd, SynthesisReverb* reverb, s32 updateIndex) { + SynthesisReverb* mixReverb; + + if (reverb->mixReverbIndex >= gAudioContext.numSynthesisReverbs) { + return cmd; + } + + mixReverb = &gAudioContext.synthesisReverbs[reverb->mixReverbIndex]; + if (mixReverb->downsampleRate == 1) { + cmd = AudioSynth_LoadMixedReverbSamples(cmd, mixReverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->mixReverbStrength, DMEM_WET_LEFT_CH, DMEM_WET_TEMP); + cmd = AudioSynth_SaveMixedReverbSamples(cmd, mixReverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadDefaultReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_LoadSubReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 size, uintptr_t startAddr) { + s32 startAddrAlignDropped; + u32 endAddr; + s32 endAddrAlignDropped; + + endAddr = startAddr + size; + + endAddrAlignDropped = endAddr & 0xF; + if (endAddrAlignDropped != 0) { + aLoadBuffer(cmd++, (endAddr - endAddrAlignDropped), DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, DMEM_TEMP2, size); + aDMEMMove(cmd++, DMEM_TEMP + endAddrAlignDropped, size + DMEM_TEMP2, 0x10 - endAddrAlignDropped); + + size += (0x10 - endAddrAlignDropped); + dmem = DMEM_TEMP2; + } + + startAddrAlignDropped = startAddr & 0xF; + if (startAddrAlignDropped != 0) { + aLoadBuffer(cmd++, startAddr - startAddrAlignDropped, DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, startAddrAlignDropped + DMEM_TEMP, size); + + size += startAddrAlignDropped; + dmem = DMEM_TEMP; + } + + aSaveBuffer(cmd++, dmem, startAddr - startAddrAlignDropped, size); + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aLoadBuffer(cmd++, &reverb->leftReverbBuf[startPos], dmem, size); + aLoadBuffer(cmd++, &reverb->rightReverbBuf[startPos], dmem + DMEM_1CH_SIZE, size); + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aSaveBuffer(cmd++, dmem, &reverb->leftReverbBuf[startPos], size); + aSaveBuffer(cmd++, dmem + DMEM_1CH_SIZE, &reverb->rightReverbBuf[startPos], size); + + return cmd; +} + +void AudioSynth_Noop26(void) { +} + +Acmd* AudioSynth_LoadSubReverbSamplesWithoutDownsample(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + if (reverb->downsampleRate == 1) { + cmd = AudioSynth_LoadSubReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_LoadResampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } else { + cmd = AudioSynth_LoadDefaultReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + } else { + cmd = AudioSynth_LoadDownsampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s32 downsampleRate; + s32 numSamples; + + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_SaveResampledReverbSamples(cmd, reverb, updateIndex); + } else { + // Put the oldest samples in the ring buffer into the wet channels + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, + reverb); + } + } + } else { + //! FAKE: + if (1) {} + + downsampleRate = reverb->downsampleRate; + numSamples = 13 * SAMPLES_PER_FRAME; + + while (downsampleRate >= 2) { + aInterl(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH, numSamples); + aInterl(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_RIGHT_CH, numSamples); + downsampleRate >>= 1; + numSamples >>= 1; + } + + if (entry->size != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_RIGHT_CH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + } + + if (entry->wrappedSize != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_LEFT_CH, entry->wrappedSize, + reverb->leftReverbBuf); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_RIGHT_CH, entry->wrappedSize, + reverb->rightReverbBuf); + } + } + + reverb->resampleFlags = 0; + + return cmd; +} + +Acmd* AudioSynth_SaveSubReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +/** + * Process all samples embedded in a note. Every sample has numSamplesPerUpdate processed, + * and each of those are mixed together into both DMEM_LEFT_CH and DMEM_RIGHT_CH + */ +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 size; + u8 noteIndices[0x58]; + s16 noteCount = 0; + s16 reverbIndex; + SynthesisReverb* reverb; + s32 useReverb; + s32 sampleStateOffset = gAudioContext.numNotes * updateIndex; + s32 i; + + if (gAudioContext.numSynthesisReverbs == 0) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.sampleStateList[sampleStateOffset + i].bitField0.enabled) { + noteIndices[noteCount++] = i; + } + } + } else { + NoteSampleState* sampleState; + + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + for (i = 0; i < gAudioContext.numNotes; i++) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && (sampleState->bitField1.reverbIndex == reverbIndex)) { + noteIndices[noteCount++] = i; + } + } + } + + for (i = 0; i < gAudioContext.numNotes; i++) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && + (sampleState->bitField1.reverbIndex >= gAudioContext.numSynthesisReverbs)) { + noteIndices[noteCount++] = i; + } + } + } + + aClearBuffer(cmd++, DMEM_LEFT_CH, DMEM_2CH_SIZE); + + i = 0; + for (reverbIndex = 0; reverbIndex < gAudioContext.numSynthesisReverbs; reverbIndex++) { + s32 subDelay; + NoteSampleState* sampleState; + + reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + useReverb = reverb->useReverb; + if (useReverb) { + + // Loads reverb samples from DRAM (ringBuffer) into DMEM (DMEM_WET_LEFT_CH) + cmd = AudioSynth_LoadReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + + // Mixes reverb sample into the main dry channel + // reverb->volume is always set to 0x7FFF (audio spec), and DMEM_LEFT_CH is cleared before reverbs. + // So this is essentially a DMEMmove from DMEM_WET_LEFT_CH to DMEM_LEFT_CH + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->volume, DMEM_WET_LEFT_CH, DMEM_LEFT_CH); + + subDelay = reverb->subDelay; + if (subDelay != 0) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, DMEM_2CH_SIZE); + } + + // Decays reverb over time. The (+ 0x8000) here is -100% + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->decayRatio + 0x8000, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH); + + if (((reverb->leakRtl != 0) || (reverb->leakLtr != 0)) && (gAudioContext.soundMode != SOUNDMODE_MONO)) { + cmd = AudioSynth_LeakReverb(cmd, reverb); + } + + if (subDelay != 0) { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + cmd = AudioSynth_LoadSubReverbSamplesWithoutDownsample(cmd, numSamplesPerUpdate, reverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->subVolume, DMEM_WET_TEMP, DMEM_WET_LEFT_CH); + } + } + + while (i < noteCount) { + sampleState = &gAudioContext.sampleStateList[sampleStateOffset + noteIndices[i]]; + if (sampleState->bitField1.reverbIndex != reverbIndex) { + break; + } + cmd = AudioSynth_ProcessSample(noteIndices[i], sampleState, + &gAudioContext.notes[noteIndices[i]].synthesisState, aiBuf, + numSamplesPerUpdate, cmd, updateIndex); + i++; + } + + if (useReverb) { + if ((reverb->filterLeft != NULL) || (reverb->filterRight != NULL)) { + cmd = AudioSynth_FilterReverb(cmd, numSamplesPerUpdate * SAMPLE_SIZE, reverb); + } + + // Saves the wet channel sample from DMEM (DMEM_WET_LEFT_CH) into (ringBuffer) DRAM for future use + if (subDelay != 0) { + cmd = AudioSynth_SaveSubReverbSamples(cmd, reverb, updateIndex); + } else { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + } + } + } + + while (i < noteCount) { + cmd = AudioSynth_ProcessSample( + noteIndices[i], &gAudioContext.sampleStateList[sampleStateOffset + noteIndices[i]], + &gAudioContext.notes[noteIndices[i]].synthesisState, aiBuf, numSamplesPerUpdate, cmd, updateIndex); + i++; + } + + size = numSamplesPerUpdate * SAMPLE_SIZE; + aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, size); + + if (gCustomAudioSynthFunction != NULL) { + cmd = gCustomAudioSynthFunction(cmd, 2 * size, updateIndex); + } + aSaveBuffer(cmd++, DMEM_TEMP, aiBuf, 2 * size); + + return cmd; +} + +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 pad1[2]; + void* reverbAddrSrc; + Sample* sample; + AdpcmLoop* loopInfo; + s32 numSamplesUntilEnd; + s32 numSamplesInThisIteration; + s32 sampleFinished; + s32 loopToPoint; + s32 flags; + u16 frequencyFixedPoint; + s32 gain; + s32 frameIndex; + s32 skipBytes; + void* combFilterState; + s32 numSamplesToDecode; + s32 numFirstFrameSamplesToIgnore; + u8* sampleAddr; + u32 numSamplesToLoadFixedPoint; + s32 numSamplesToLoadAdj; + s32 numSamplesProcessed; + s32 sampleEndPos; + s32 numSamplesToProcess; + s32 dmemUncompressedAddrOffset2; + s32 pad2[3]; + s32 numSamplesInFirstFrame; + s32 numTrailingSamplesToIgnore; + s32 pad3[3]; + s32 frameSize; + s32 numFramesToDecode; + s32 skipInitialSamples; + s32 zeroOffset; + u8* samplesToLoadAddr; + s32 numParts; + s32 curPart; + s32 sampleDataChunkAlignPad; + s32 haasEffectDelaySide; + s32 numSamplesToLoadFirstPart; + u16 sampleDmemBeforeResampling; + s32 sampleAddrOffset; + s32 combFilterDmem; + s32 dmemUncompressedAddrOffset1; + Note* note; + u32 numSamplesToLoad; + u16 combFilterSize; + u16 combFilterGain; + s16* filter; + s32 bookOffset = sampleState->bitField1.bookOffset; + s32 finished = sampleState->bitField0.finished; + s32 sampleDataChunkSize; + s16 sampleDataDmemAddr; + + note = &gAudioContext.notes[noteIndex]; + flags = A_CONTINUE; + + // Initialize the synthesis state + if (sampleState->bitField0.needsInit == true) { + flags = A_INIT; + synthState->atLoopPoint = false; + synthState->stopLoop = false; + synthState->samplePosInt = note->playbackState.startSamplePos; + synthState->samplePosFrac = 0; + synthState->curVolLeft = 0; + synthState->curVolRight = 0; + synthState->prevHaasEffectLeftDelaySize = 0; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->curReverbVol = sampleState->targetReverbVol; + synthState->numParts = 0; + synthState->combFilterNeedsInit = true; + note->sampleState.bitField0.finished = false; + synthState->unk_1F = note->playbackState.unk_80; // Never set, never used + finished = false; + } + + // Process the sample in either one or two parts + numParts = sampleState->bitField1.hasTwoParts + 1; + + // Determine number of samples to load based on numSamplesPerUpdate and relative frequency + frequencyFixedPoint = sampleState->frequencyFixedPoint; + numSamplesToLoadFixedPoint = (frequencyFixedPoint * numSamplesPerUpdate * 2) + synthState->samplePosFrac; + numSamplesToLoad = numSamplesToLoadFixedPoint >> 16; + + if (numSamplesToLoad == 0) { + skipBytes = false; + } + + synthState->samplePosFrac = numSamplesToLoadFixedPoint & 0xFFFF; + + // Partially-optimized out no-op ifs required for matching. SM64 decomp + // makes it clear that this is how it should look. + if ((synthState->numParts == 1) && (numParts == 2)) { + } else if ((synthState->numParts == 2) && (numParts == 1)) { + } else { + } + + synthState->numParts = numParts; + + if (sampleState->bitField1.isSyntheticWave) { + cmd = AudioSynth_LoadWaveSamples(cmd, sampleState, synthState, numSamplesToLoad); + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2); + synthState->samplePosInt += numSamplesToLoad; + } else { + sample = sampleState->tunedSample->sample; + loopInfo = sample->loop; + + if (note->playbackState.status != PLAYBACK_STATUS_0) { + synthState->stopLoop = true; + } + + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleEndPos = loopInfo->sampleEnd; + } else { + sampleEndPos = loopInfo->loopEnd; + } + + sampleAddr = sample->sampleAddr; + numSamplesToLoadFirstPart = 0; + + // If the frequency requested is more than double that of the raw sample, + // then the sample processing is split into two parts. + for (curPart = 0; curPart < numParts; curPart++) { + numSamplesProcessed = 0; + dmemUncompressedAddrOffset1 = 0; + + // Adjust the number of samples to load only if there are two parts and an odd number of samples + if (numParts == 1) { + numSamplesToLoadAdj = numSamplesToLoad; + } else if (numSamplesToLoad & 1) { + // round down for the first part + // round up for the second part + numSamplesToLoadAdj = (numSamplesToLoad & ~1) + (curPart * 2); + } else { + numSamplesToLoadAdj = numSamplesToLoad; + } + + // Load the ADPCM codeBook + if ((sample->codec == CODEC_ADPCM) || (sample->codec == CODEC_SMALL_ADPCM)) { + if (gAudioContext.adpcmCodeBook != sample->book->codeBook) { + u32 numEntries; + + switch (bookOffset) { + case 1: + gAudioContext.adpcmCodeBook = &gInvalidAdpcmCodeBook[1]; + break; + + case 2: + case 3: + default: + gAudioContext.adpcmCodeBook = sample->book->codeBook; + break; + } + + numEntries = SAMPLES_PER_FRAME * sample->book->order * sample->book->numPredictors; + aLoadADPCM(cmd++, numEntries, gAudioContext.adpcmCodeBook); + } + } + + // Continue processing samples until the number of samples needed to load is reached + while (numSamplesProcessed != numSamplesToLoadAdj) { + sampleFinished = false; + loopToPoint = false; + dmemUncompressedAddrOffset2 = 0; + + numFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF; + numSamplesUntilEnd = sampleEndPos - synthState->samplePosInt; + + // Calculate number of samples to process this loop + numSamplesToProcess = numSamplesToLoadAdj - numSamplesProcessed; + + if ((numFirstFrameSamplesToIgnore == 0) && !synthState->atLoopPoint) { + numFirstFrameSamplesToIgnore = SAMPLES_PER_FRAME; + } + numSamplesInFirstFrame = SAMPLES_PER_FRAME - numFirstFrameSamplesToIgnore; + + // Determine the number of samples to decode based on whether the end will be reached or not. + if (numSamplesToProcess < numSamplesUntilEnd) { + // The end will not be reached. + numFramesToDecode = + (s32)(numSamplesToProcess - numSamplesInFirstFrame + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + numSamplesToDecode = numFramesToDecode * SAMPLES_PER_FRAME; + numTrailingSamplesToIgnore = numSamplesInFirstFrame + numSamplesToDecode - numSamplesToProcess; + } else { + // The end will be reached. + numSamplesToDecode = numSamplesUntilEnd - numSamplesInFirstFrame; + numTrailingSamplesToIgnore = 0; + if (numSamplesToDecode <= 0) { + numSamplesToDecode = 0; + numSamplesInFirstFrame = numSamplesUntilEnd; + } + numFramesToDecode = (numSamplesToDecode + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + if (loopInfo->count != 0) { + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleFinished = true; + } else { + // Loop around and restart + loopToPoint = true; + } + } else { + sampleFinished = true; + } + } + + // Set parameters based on compression type + switch (sample->codec) { + case CODEC_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + frameSize = 9; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_SMALL_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte + frameSize = 5; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_UNK7: + // 2 2-byte samples (4 bytes) processed without decompression + frameSize = 4; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_S8: + // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) + frameSize = 16; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_REVERB: + reverbAddrSrc = (void*)0xFFFFFFFF; + if (gCustomAudioReverbFunction != NULL) { + reverbAddrSrc = gCustomAudioReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex); + } + + if (reverbAddrSrc == (void*)0xFFFFFFFF) { + sampleFinished = true; + } else if (reverbAddrSrc == NULL) { + return cmd; + } else { + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE, + reverbAddrSrc); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + } + goto skip; + + case CODEC_S16_INMEMORY: + case CODEC_UNK6: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + case CODEC_S16: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + default: + break; + } + + // Move the compressed raw sample data from ram into the rsp (DMEM) + if (numFramesToDecode != 0) { + // Get the offset from the start of the sample to where the sample is currently playing from + frameIndex = (synthState->samplePosInt + skipInitialSamples - numFirstFrameSamplesToIgnore) / + SAMPLES_PER_FRAME; + sampleAddrOffset = frameIndex * frameSize; + + // Get the ram address of the requested sample chunk + if (sample->medium == MEDIUM_RAM) { + // Sample is already loaded into ram + samplesToLoadAddr = sampleAddr + (zeroOffset + sampleAddrOffset); + } else if (gAudioContext.unk_29B8) { // always false + return cmd; + } else if (sample->medium == MEDIUM_UNK) { + // This medium is unsupported so terminate processing this note + return cmd; + } else { + // This medium is not in ram, so dma the requested sample into ram + samplesToLoadAddr = + AudioLoad_DmaSampleData(sampleAddr + (zeroOffset + sampleAddrOffset), + ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME), flags, + &synthState->sampleDmaIndex, sample->medium); + } + + if (samplesToLoadAddr == NULL) { + // The ram address was unsuccessfully allocated + return cmd; + } + + // Move the raw sample chunk from ram to the rsp + // DMEM at the addresses before DMEM_COMPRESSED_ADPCM_DATA + sampleDataChunkAlignPad = (u32)samplesToLoadAddr & 0xF; + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aLoadBuffer(cmd++, samplesToLoadAddr - sampleDataChunkAlignPad, sampleDataDmemAddr, + sampleDataChunkSize); + } else { + numSamplesToDecode = 0; + sampleDataChunkAlignPad = 0; + } + + if (synthState->atLoopPoint) { + aSetLoop(cmd++, sample->loop->predictorState); + flags = A_LOOP; + synthState->atLoopPoint = false; + } + + numSamplesInThisIteration = numSamplesToDecode + numSamplesInFirstFrame - numTrailingSamplesToIgnore; + + if (numSamplesProcessed == 0) { + //! FAKE: + if (1) {} + skipBytes = numFirstFrameSamplesToIgnore * SAMPLE_SIZE; + } else { + dmemUncompressedAddrOffset2 = ALIGN16(dmemUncompressedAddrOffset1 + 8 * SAMPLE_SIZE); + } + + // Decompress the raw sample chunks in the rsp + // Goes from adpcm (compressed) sample data to pcm (uncompressed) sample data + switch (sample->codec) { + case CODEC_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_SMALL_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags | A_ADPCM_SHORT, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_S8: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + AudioSynth_SetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + AudioSynth_S8Dec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_UNK7: + default: + // No decompression + break; + } + + if (numSamplesProcessed != 0) { + aDMEMMove(cmd++, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2 + + (numFirstFrameSamplesToIgnore * SAMPLE_SIZE), + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + numSamplesInThisIteration * SAMPLE_SIZE); + } + + numSamplesProcessed += numSamplesInThisIteration; + + switch (flags) { + case A_INIT: + skipBytes = SAMPLES_PER_FRAME * SAMPLE_SIZE; + dmemUncompressedAddrOffset1 = (numSamplesToDecode + SAMPLES_PER_FRAME) * SAMPLE_SIZE; + break; + + case A_LOOP: + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + break; + + default: + if (dmemUncompressedAddrOffset1 != 0) { + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + } else { + dmemUncompressedAddrOffset1 = + (numFirstFrameSamplesToIgnore + numSamplesInThisIteration) * SAMPLE_SIZE; + } + break; + } + + flags = A_CONTINUE; + + skip: + + // Update what to do with the samples next + if (sampleFinished) { + if ((numSamplesToLoadAdj - numSamplesProcessed) != 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + (numSamplesToLoadAdj - numSamplesProcessed) * SAMPLE_SIZE); + } + finished = true; + note->sampleState.bitField0.finished = true; + AudioSynth_DisableSampleStates(updateIndex, noteIndex); + break; // break out of the for-loop + } else if (loopToPoint) { + synthState->atLoopPoint = true; + synthState->samplePosInt = loopInfo->start; + } else { + synthState->samplePosInt += numSamplesToProcess; + } + } + + switch (numParts) { + case 1: + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + skipBytes; + break; + + case 2: + switch (curPart) { + case 0: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE), + ALIGN8(numSamplesToLoadAdj / 2)); + numSamplesToLoadFirstPart = numSamplesToLoadAdj; + sampleDmemBeforeResampling = DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE); + if (finished) { + AudioSynth_ClearBuffer(cmd++, sampleDmemBeforeResampling + numSamplesToLoadFirstPart, + numSamplesToLoadAdj + SAMPLES_PER_FRAME); + } + break; + + case 1: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE) + numSamplesToLoadFirstPart, + ALIGN8(numSamplesToLoadAdj / 2)); + break; + + default: + break; + } + break; + + default: + break; + } + if (finished) { + break; + } + } + } + + // Update the flags for the signal processing below + flags = A_CONTINUE; + if (sampleState->bitField0.needsInit == true) { + sampleState->bitField0.needsInit = false; + flags = A_INIT; + } + + // Resample the decompressed mono-signal to the correct pitch + cmd = AudioSynth_FinalResample(cmd, synthState, numSamplesPerUpdate * SAMPLE_SIZE, frequencyFixedPoint, + sampleDmemBeforeResampling, flags); + + // UnkCmd19 was removed from the audio microcode + // This block performs no operation + if (bookOffset == 3) { + AudioSynth_UnkCmd19(cmd++, DMEM_TEMP, DMEM_TEMP, numSamplesPerUpdate * (s32)SAMPLE_SIZE, 0); + } + + // Apply the gain to the mono-signal to adjust the volume + gain = sampleState->gain; + if (gain != 0) { + // A gain of 0x10 (a UQ4.4 number) is equivalent to 1.0 and represents no volume change + if (gain < 0x10) { + gain = 0x10; + } + AudioSynth_HiLoGain(cmd++, gain, DMEM_TEMP, 0, (numSamplesPerUpdate + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + } + + // Apply the filter to the mono-signal + filter = sampleState->filter; + if (filter != 0) { + AudioSynth_LoadFilterSize(cmd++, numSamplesPerUpdate * SAMPLE_SIZE, filter); + AudioSynth_LoadFilterBuffer(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->filterState); + } + + // Apply the comb filter to the mono-signal by taking the signal with a small temporal offset, + // and adding it back to itself + combFilterSize = sampleState->combFilterSize; + combFilterGain = sampleState->combFilterGain; + combFilterState = synthState->synthesisBuffers->combFilterState; + if ((combFilterSize != 0) && (sampleState->combFilterGain != 0)) { + AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_COMB_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + combFilterDmem = DMEM_COMB_TEMP - combFilterSize; + if (synthState->combFilterNeedsInit) { + AudioSynth_ClearBuffer(cmd++, combFilterDmem, combFilterSize); + synthState->combFilterNeedsInit = false; + } else { + AudioSynth_LoadBuffer(cmd++, combFilterDmem, combFilterSize, combFilterState); + } + AudioSynth_SaveBuffer(cmd++, DMEM_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE) - combFilterSize, combFilterSize, + combFilterState); + AudioSynth_Mix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, combFilterGain, DMEM_COMB_TEMP, + combFilterDmem); + AudioSynth_DMemMove(cmd++, combFilterDmem, DMEM_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + } else { + synthState->combFilterNeedsInit = true; + } + + // Determine the behavior of the audio processing that leads to the haas effect + if ((sampleState->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_LEFT; + } else if ((sampleState->haasEffectRightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_RIGHT; + } else { + haasEffectDelaySide = HAAS_EFFECT_DELAY_NONE; + } + + // Apply an unknown effect based on the surround sound-mode + if (gAudioContext.soundMode == SOUNDMODE_SURROUND) { + sampleState->targetVolLeft = sampleState->targetVolLeft >> 1; + sampleState->targetVolRight = sampleState->targetVolRight >> 1; + if (sampleState->surroundEffectIndex != 0xFF) { + cmd = AudioSynth_ApplySurroundEffect(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, flags); + } + } + + // Split the mono-signal into left and right channels: + // Both for dry signal (to go to the speakers now) + // and for wet signal (to go to a reverb buffer to be stored, and brought back later to produce an echo) + cmd = AudioSynth_ProcessEnvelope(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, haasEffectDelaySide, + flags); + + // Apply the haas effect by delaying either the left or the right channel by a small amount + if (sampleState->bitField1.useHaasEffect) { + if (!(flags & A_INIT)) { + flags = A_CONTINUE; + } + cmd = AudioSynth_ApplyHaasEffect(cmd, sampleState, synthState, numSamplesPerUpdate * (s32)SAMPLE_SIZE, flags, + haasEffectDelaySide); + } + + return cmd; +} + +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, s32 haasDmem, s32 flags) { + s32 wetGain; + u16 dryGain; + s64 dmem = DMEM_SURROUND_TEMP; + f32 decayGain; + + AudioSynth_DMemMove(cmd++, haasDmem, DMEM_HAAS_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + dryGain = synthState->surroundEffectGain; + + if (flags == A_INIT) { + aClearBuffer(cmd++, dmem, sizeof(synthState->synthesisBuffers->surroundEffectState)); + synthState->surroundEffectGain = 0; + } else { + aLoadBuffer(cmd++, synthState->synthesisBuffers->surroundEffectState, dmem, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, dryGain, dmem, DMEM_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (dryGain ^ 0xFFFF), dmem, DMEM_RIGHT_CH); + + wetGain = (dryGain * synthState->curReverbVol) >> 7; + + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, wetGain, dmem, DMEM_WET_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (wetGain ^ 0xFFFF), dmem, DMEM_WET_RIGHT_CH); + } + + aSaveBuffer(cmd++, DMEM_SURROUND_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE), + synthState->synthesisBuffers->surroundEffectState, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + + decayGain = (sampleState->targetVolLeft + sampleState->targetVolRight) * (1.0f / 0x2000); + + if (decayGain > 1.0f) { + decayGain = 1.0f; + } + + decayGain = decayGain * gDefaultPanVolume[127 - sampleState->surroundEffectIndex]; + synthState->surroundEffectGain = ((decayGain * 0x7FFF) + synthState->surroundEffectGain) / 2; + + AudioSynth_DMemMove(cmd++, DMEM_HAAS_TEMP, haasDmem, numSamplesPerUpdate * SAMPLE_SIZE); + + return cmd; +} + +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags) { + if (pitch == 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_TEMP, size); + } else { + aSetBuffer(cmd++, 0, inpDmem, DMEM_TEMP, size); + aResample(cmd++, resampleFlags, pitch, synthState->synthesisBuffers->finalResampleState); + } + + return cmd; +} + +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags) { + u32 dmemDests; + u16 curVolLeft; + u16 targetVolLeft; + s32 curReverbVol; + u16 curVolRight; + s16 targetReverbVol; + s16 rampLeft; + s16 rampRight; + s16 rampReverb; + s16 curReverbVolAndFlags; + u16 targetVolRight; + f32 defaultPanVolume; + s32 pad; + + targetReverbVol = sampleState->targetReverbVol; + + curVolLeft = synthState->curVolLeft; + curVolRight = synthState->curVolRight; + + targetVolLeft = sampleState->targetVolLeft; + targetVolLeft <<= 4; + targetVolRight = sampleState->targetVolRight; + targetVolRight <<= 4; + + if ((gAudioContext.soundMode == SOUNDMODE_SURROUND) && (sampleState->surroundEffectIndex != 0xFF)) { + defaultPanVolume = gDefaultPanVolume[sampleState->surroundEffectIndex]; + targetVolLeft *= defaultPanVolume; + targetVolRight *= defaultPanVolume; + } + + if (targetVolLeft != curVolLeft) { + rampLeft = (targetVolLeft - curVolLeft) / (numSamplesPerUpdate >> 3); + } else { + rampLeft = 0; + } + + if (targetVolRight != curVolRight) { + rampRight = (targetVolRight - curVolRight) / (numSamplesPerUpdate >> 3); + } else { + rampRight = 0; + } + + curReverbVolAndFlags = synthState->curReverbVol; + curReverbVol = curReverbVolAndFlags & 0x7F; + + if (curReverbVolAndFlags != targetReverbVol) { + rampReverb = (((targetReverbVol & 0x7F) - curReverbVol) << 9) / (numSamplesPerUpdate >> 3); + synthState->curReverbVol = targetReverbVol; + } else { + rampReverb = 0; + } + + synthState->curVolLeft = curVolLeft + (rampLeft * (numSamplesPerUpdate >> 3)); + synthState->curVolRight = curVolRight + (rampRight * (numSamplesPerUpdate >> 3)); + + if (sampleState->bitField1.useHaasEffect) { + AudioSynth_ClearBuffer(cmd++, DMEM_HAAS_TEMP, DMEM_1CH_SIZE); + AudioSynth_EnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + AudioSynth_EnvSetup2(cmd++, curVolLeft, curVolRight); + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Store the left dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerLeftHaasDmemDests; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Store the right dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerRightHaasDmemDests; + break; + + default: // HAAS_EFFECT_DELAY_NONE + dmemDests = sEnvMixerDefaultDmemDests; + break; + } + } else { + aEnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + aEnvSetup2(cmd++, curVolLeft, curVolRight); + dmemDests = sEnvMixerDefaultDmemDests; + } + + aEnvMixer(cmd++, dmemSrc, numSamplesPerUpdate, (curReverbVolAndFlags & 0x80) >> 7, + sampleState->bitField0.strongReverbRight, sampleState->bitField0.strongReverbLeft, + sampleState->bitField0.strongRight, sampleState->bitField0.strongLeft, dmemDests, sEnvMixerOp); + + return cmd; +} + +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad) { + s32 numSamplesAvailable; + s32 harmonicIndexCurAndPrev = sampleState->harmonicIndexCurAndPrev; + s32 samplePosInt = synthState->samplePosInt; + s32 numDuplicates; + + if (sampleState->bitField1.bookOffset != 0) { + // Move the noise wave (that reads compiled assembly as samples) from ram to dmem + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(numSamplesToLoad * SAMPLE_SIZE), gWaveSamples[8]); + // Offset the address for the samples read by gWaveSamples[8] to the next set of samples + gWaveSamples[8] += numSamplesToLoad * SAMPLE_SIZE; + + return cmd; + } else { + // Move the synthetic wave from ram to dmem + aLoadBuffer(cmd++, sampleState->waveSampleAddr, DMEM_UNCOMPRESSED_NOTE, WAVE_SAMPLE_COUNT * SAMPLE_SIZE); + + // If the harmonic changes, map the offset in the wave from one harmonic to another for continuity + if (harmonicIndexCurAndPrev != 0) { + samplePosInt = (samplePosInt * sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev >> 2]) / + sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev & 3]; + } + + // Offset in the WAVE_SAMPLE_COUNT samples of gWaveSamples to start processing the wave for continuity + samplePosInt = (u32)samplePosInt % WAVE_SAMPLE_COUNT; + // Number of samples in the initial WAVE_SAMPLE_COUNT samples available to be used to process + numSamplesAvailable = WAVE_SAMPLE_COUNT - samplePosInt; + + // Require duplicates if there are more samples to load than available + if (numSamplesToLoad > numSamplesAvailable) { + // Duplicate (copy) the WAVE_SAMPLE_COUNT samples as many times as needed to reach numSamplesToLoad. + // (numSamplesToLoad - numSamplesAvailable) is the number of samples missing. + // Divide by WAVE_SAMPLE_COUNT, rounding up, to get the amount of duplicates + numDuplicates = ((numSamplesToLoad - numSamplesAvailable + WAVE_SAMPLE_COUNT - 1) / WAVE_SAMPLE_COUNT); + if (numDuplicates != 0) { + aDuplicate(cmd++, numDuplicates, DMEM_UNCOMPRESSED_NOTE, + DMEM_UNCOMPRESSED_NOTE + (WAVE_SAMPLE_COUNT * SAMPLE_SIZE)); + } + } + synthState->samplePosInt = samplePosInt; + } + + return cmd; +} + +/** + * The Haas Effect gives directionality to sound by applying a small (< 35ms) delay to either the left or right channel. + * The delay is small enough that the sound is still perceived as one sound, but the channel that is not delayed will + * reach our ear first and give a sense of directionality. The sound is directed towards the opposite side of the delay. + */ +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide) { + u16 dmemDest; + u16 pitch; + u8 prevHaasEffectDelaySize; + u8 haasEffectDelaySize; + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Delay the sample on the left channel + // This allows the right channel to be heard first + dmemDest = DMEM_LEFT_CH; + haasEffectDelaySize = sampleState->haasEffectLeftDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectLeftDelaySize; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->prevHaasEffectLeftDelaySize = haasEffectDelaySize; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Delay the sample on the right channel + // This allows the left channel to be heard first + dmemDest = DMEM_RIGHT_CH; + haasEffectDelaySize = sampleState->haasEffectRightDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectRightDelaySize; + synthState->prevHaasEffectRightDelaySize = haasEffectDelaySize; + synthState->prevHaasEffectLeftDelaySize = 0; + break; + + default: // HAAS_EFFECT_DELAY_NONE + return cmd; + } + + if (flags != A_INIT) { + // Slightly adjust the sample rate in order to fit a change in sample delay + if (haasEffectDelaySize != prevHaasEffectDelaySize) { + pitch = (((size << 0xF) / 2) - 1) / ((size + haasEffectDelaySize - prevHaasEffectDelaySize - 2) / 2); + aSetBuffer(cmd++, 0, DMEM_HAAS_TEMP, DMEM_TEMP, size + haasEffectDelaySize - prevHaasEffectDelaySize); + aResampleZoh(cmd++, pitch, 0); + } else { + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + } + + if (prevHaasEffectDelaySize != 0) { + aLoadBuffer(cmd++, synthState->synthesisBuffers->haasEffectDelayState, DMEM_HAAS_TEMP, + ALIGN16(prevHaasEffectDelaySize)); + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + prevHaasEffectDelaySize, + size + haasEffectDelaySize - prevHaasEffectDelaySize); + } else { + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP, size + haasEffectDelaySize); + } + } else { + // Just apply a delay directly + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + if (haasEffectDelaySize) { // != 0 + aClearBuffer(cmd++, DMEM_HAAS_TEMP, haasEffectDelaySize); + } + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + haasEffectDelaySize, size); + } + + if (haasEffectDelaySize) { // != 0 + // Save excessive samples for next iteration + aSaveBuffer(cmd++, DMEM_HAAS_TEMP + size, synthState->synthesisBuffers->haasEffectDelayState, + ALIGN16(haasEffectDelaySize)); + } + + aAddMixer(cmd++, ALIGN64(size), DMEM_HAAS_TEMP, dmemDest, 0x7FFF); + + return cmd; +} diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 007d7ca85..98be41397 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -4078,7 +4078,7 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) { } u32 AudioSfx_SetFreqAndStereoBits(u8 seqScriptValIn, SequenceChannel* channel) { - channel->stereo.asByte = sSfxChannelState[seqScriptValIn].stereoBits; + channel->stereoData.asByte = sSfxChannelState[seqScriptValIn].stereoBits; channel->freqScale = sSfxChannelState[seqScriptValIn].freqScale; channel->changes.s.freqScale = true; 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 4ed5b82a0..fdf3cc9ac 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,7 +4,6 @@ * 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/tools/disasm/files.txt b/tools/disasm/files.txt index ffa305cdd..c546c1f69 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -597,6 +597,7 @@ 0x801D9090 : "audio_sound_params", 0x801DB470 : "code_801A5BD0", 0x801DB4C0 : "code_801A7B10", + 0x801DB4E0 : "audio_init_params", # .rodata section 0x801DBDF0 : "z_en_item00", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 057170442..20fa0265c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3478,74 +3478,74 @@ 0x801872FC:("osFlashWriteBuffer",), 0x801873BC:("osFlashWriteArray",), 0x8018752C:("osFlashReadArray",), - 0x801877D0:("func_801877D0",), - 0x80187B64:("func_80187B64",), - 0x80187BEC:("func_80187BEC",), - 0x80187DE8:("func_80187DE8",), - 0x80187E58:("func_80187E58",), - 0x80187F00:("func_80187F00",), - 0x80187FA8:("func_80187FA8",), - 0x80187FB0:("func_80187FB0",), - 0x80187FD0:("func_80187FD0",), - 0x80187FD8:("func_80187FD8",), - 0x80187FE0:("func_80187FE0",), - 0x80187FE8:("func_80187FE8",), - 0x8018801C:("func_8018801C",), - 0x80188024:("func_80188024",), - 0x8018802C:("func_8018802C",), - 0x80188034:("func_80188034",), - 0x80188068:("func_80188068",), - 0x80188070:("func_80188070",), - 0x80188078:("func_80188078",), - 0x801880A4:("func_801880A4",), - 0x801880AC:("func_801880AC",), - 0x801880B4:("func_801880B4",), - 0x801880BC:("func_801880BC",), - 0x801880C4:("func_801880C4",), - 0x801880E8:("func_801880E8",), - 0x8018811C:("func_8018811C",), - 0x80188124:("func_80188124",), - 0x8018814C:("func_8018814C",), - 0x80188174:("func_80188174",), - 0x80188190:("func_80188190",), - 0x80188198:("func_80188198",), - 0x801881A0:("func_801881A0",), - 0x801881A8:("func_801881A8",), - 0x801881C4:("func_801881C4",), - 0x801881F8:("func_801881F8",), - 0x80188224:("func_80188224",), - 0x8018822C:("func_8018822C",), - 0x80188234:("func_80188234",), - 0x8018823C:("func_8018823C",), - 0x80188244:("func_80188244",), - 0x8018824C:("func_8018824C",), - 0x80188254:("func_80188254",), - 0x8018825C:("func_8018825C",), - 0x80188264:("func_80188264",), - 0x80188288:("func_80188288",), - 0x801882A0:("func_801882A0",), - 0x80188304:("func_80188304",), - 0x801884A0:("func_801884A0",), - 0x80188698:("func_80188698",), - 0x8018883C:("func_8018883C",), - 0x801888E4:("func_801888E4",), - 0x801889A4:("func_801889A4",), - 0x80188A50:("func_80188A50",), - 0x80188AFC:("func_80188AFC",), - 0x80188C48:("func_80188C48",), - 0x80188CB4:("func_80188CB4",), - 0x80188D20:("func_80188D20",), - 0x80188D28:("func_80188D28",), - 0x80188D68:("func_80188D68",), - 0x80188DDC:("func_80188DDC",), - 0x80188FBC:("func_80188FBC",), - 0x80189064:("func_80189064",), - 0x80189620:("func_80189620",), - 0x8018A4B4:("func_8018A4B4",), - 0x8018A768:("func_8018A768",), - 0x8018A808:("func_8018A808",), - 0x8018ACC4:("func_8018ACC4",), - 0x8018AE34:("func_8018AE34",), + 0x801877D0:("AudioSynth_AddReverbBufferEntry",), + 0x80187B64:("AudioSynth_SyncSampleStates",), + 0x80187BEC:("AudioSynth_Update",), + 0x80187DE8:("AudioSynth_DisableSampleStates",), + 0x80187E58:("AudioSynth_LoadMixedReverbSamples",), + 0x80187F00:("AudioSynth_SaveMixedReverbSamples",), + 0x80187FA8:("AudioSynth_Noop1",), + 0x80187FB0:("AudioSynth_ClearBuffer",), + 0x80187FD0:("AudioSynth_Noop2",), + 0x80187FD8:("AudioSynth_Noop3",), + 0x80187FE0:("AudioSynth_Noop4",), + 0x80187FE8:("AudioSynth_Mix",), + 0x8018801C:("AudioSynth_Noop5",), + 0x80188024:("AudioSynth_Noop6",), + 0x8018802C:("AudioSynth_Noop7",), + 0x80188034:("AudioSynth_SetBuffer",), + 0x80188068:("AudioSynth_Noop8",), + 0x80188070:("AudioSynth_Noop9",), + 0x80188078:("AudioSynth_DMemMove",), + 0x801880A4:("AudioSynth_Noop10",), + 0x801880AC:("AudioSynth_Noop11",), + 0x801880B4:("AudioSynth_Noop12",), + 0x801880BC:("AudioSynth_Noop13",), + 0x801880C4:("AudioSynth_InterL",), + 0x801880E8:("AudioSynth_EnvSetup1",), + 0x8018811C:("AudioSynth_Noop14",), + 0x80188124:("AudioSynth_LoadBuffer",), + 0x8018814C:("AudioSynth_SaveBuffer",), + 0x80188174:("AudioSynth_EnvSetup2",), + 0x80188190:("AudioSynth_Noop15",), + 0x80188198:("AudioSynth_Noop16",), + 0x801881A0:("AudioSynth_Noop17",), + 0x801881A8:("AudioSynth_S8Dec",), + 0x801881C4:("AudioSynth_HiLoGain",), + 0x801881F8:("AudioSynth_UnkCmd19",), + 0x80188224:("AudioSynth_Noop18",), + 0x8018822C:("AudioSynth_Noop19",), + 0x80188234:("AudioSynth_Noop20",), + 0x8018823C:("AudioSynth_Noop21",), + 0x80188244:("AudioSynth_Noop22",), + 0x8018824C:("AudioSynth_Noop23",), + 0x80188254:("AudioSynth_Noop24",), + 0x8018825C:("AudioSynth_Noop25",), + 0x80188264:("AudioSynth_LoadFilterBuffer",), + 0x80188288:("AudioSynth_LoadFilterSize",), + 0x801882A0:("AudioSynth_LeakReverb",), + 0x80188304:("AudioSynth_LoadDownsampledReverbSamples",), + 0x801884A0:("AudioSynth_SaveResampledReverbSamples",), + 0x80188698:("AudioSynth_LoadResampledReverbSamples",), + 0x8018883C:("AudioSynth_FilterReverb",), + 0x801888E4:("AudioSynth_MixOtherReverbIndex",), + 0x801889A4:("AudioSynth_LoadDefaultReverbSamples",), + 0x80188A50:("AudioSynth_LoadSubReverbSamples",), + 0x80188AFC:("AudioSynth_SaveResampledReverbSamplesImpl",), + 0x80188C48:("AudioSynth_LoadReverbSamplesImpl",), + 0x80188CB4:("AudioSynth_SaveReverbSamplesImpl",), + 0x80188D20:("AudioSynth_Noop26",), + 0x80188D28:("AudioSynth_LoadSubReverbSamplesWithoutDownsample",), + 0x80188D68:("AudioSynth_LoadReverbSamples",), + 0x80188DDC:("AudioSynth_SaveReverbSamples",), + 0x80188FBC:("AudioSynth_SaveSubReverbSamples",), + 0x80189064:("AudioSynth_ProcessSamples",), + 0x80189620:("AudioSynth_ProcessSample",), + 0x8018A4B4:("AudioSynth_ApplySurroundEffect",), + 0x8018A768:("AudioSynth_FinalResample",), + 0x8018A808:("AudioSynth_ProcessEnvelope",), + 0x8018ACC4:("AudioSynth_LoadWaveSamples",), + 0x8018AE34:("AudioSynth_ApplyHaasEffect",), 0x8018B0F0:("AudioHeap_CalculateAdsrDecay",), 0x8018B10C:("AudioHeap_InitAdsrDecayTable",), 0x8018B250:("AudioHeap_ResetLoadStatus",), @@ -3726,7 +3726,7 @@ 0x80194804:("func_80194804",), 0x80194840:("func_80194840",), 0x801948B0:("func_801948B0",), - 0x80194930:("AudioPlayback_InitNoteSub",), + 0x80194930:("AudioPlayback_InitSampleState",), 0x80194DB0:("AudioPlayback_NoteSetResamplingRate",), 0x80194E60:("AudioPlayback_NoteInit",), 0x80194F20:("AudioPlayback_NoteDisable",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index a0b369264..5c8147eef 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2220,11 +2220,11 @@ 0x801D57B4:("gDefaultShortNoteVelocityTable","UNK_TYPE1","",0x1), 0x801D57C4:("gDefaultShortNoteGateTimeTable","UNK_TYPE1","",0x1), 0x801D57D4:("gDefaultEnvelope","UNK_TYPE1","",0x1), - 0x801D57E4:("gZeroNoteSub","UNK_TYPE4","",0x4), - 0x801D5804:("gDefaultNoteSub","UNK_TYPE4","",0x4), - 0x801D5824:("gHeadsetPanQuantization","u16","[64]",0x80), + 0x801D57E4:("gZeroedSampleState","UNK_TYPE4","",0x4), + 0x801D5804:("gDefaultSampleState","UNK_TYPE4","",0x4), + 0x801D5824:("gHaasEffectDelaySize","u16","[64]",0x80), 0x801D58A4:("D_801D58A4","s32","",0x4), - 0x801D58A8:("D_801D58A8","s16","[64]",0x80), + 0x801D58A8:("gInvalidAdpcmCodeBook","s16","[64]",0x80), 0x801D5928:("gHeadsetPanVolume","f32","[128]",0x200), 0x801D5B28:("gStereoPanVolume","f32","[128]",0x200), 0x801D5D28:("gDefaultPanVolume","f32","[128]",0x200), @@ -2411,7 +2411,7 @@ 0x801DB870:("D_801DB870","UNK_TYPE1","",0x1), 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), - 0x801DB930:("D_801DB930","UNK_PTR","",0x4), + 0x801DB930:("gReverbSettingsTable","UNK_PTR","",0x4), 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), @@ -4354,10 +4354,10 @@ 0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1), 0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1), 0x80200C70:("gAudioContext","AudioContext","",0x81F8), - 0x80208E68:("D_80208E68","UNK_TYPE4","",0x4), - 0x80208E6C:("D_80208E6C","UNK_TYPE4","",0x4), - 0x80208E70:("D_80208E70","UNK_TYPE4","",0x4), - 0x80208E74:("D_80208E74","UNK_TYPE4","",0x4), + 0x80208E68:("gCustomAudioUpdateFunction","UNK_TYPE4","",0x4), + 0x80208E6C:("gCustomAudioSeqFunction","UNK_TYPE4","",0x4), + 0x80208E70:("gCustomAudioReverbFunction","UNK_TYPE4","",0x4), + 0x80208E74:("gCustomAudioSynthFunction","UNK_TYPE4","",0x4), 0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1), 0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1), 0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index f64c45241..9db0c0308 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2996,74 +2996,74 @@ asm/non_matchings/code/osFlash/func_80187284.s,func_80187284,0x80187284,0x1E asm/non_matchings/code/osFlash/func_801872FC.s,func_801872FC,0x801872FC,0x30 asm/non_matchings/code/osFlash/func_801873BC.s,func_801873BC,0x801873BC,0x5C asm/non_matchings/code/osFlash/func_8018752C.s,func_8018752C,0x8018752C,0x9D -asm/non_matchings/code/audio_synthesis/func_801877D0.s,func_801877D0,0x801877D0,0xE5 -asm/non_matchings/code/audio_synthesis/func_80187B64.s,func_80187B64,0x80187B64,0x22 -asm/non_matchings/code/audio_synthesis/func_80187BEC.s,func_80187BEC,0x80187BEC,0x7F -asm/non_matchings/code/audio_synthesis/func_80187DE8.s,func_80187DE8,0x80187DE8,0x1C -asm/non_matchings/code/audio_synthesis/func_80187E58.s,func_80187E58,0x80187E58,0x2A -asm/non_matchings/code/audio_synthesis/func_80187F00.s,func_80187F00,0x80187F00,0x2A -asm/non_matchings/code/audio_synthesis/func_80187FA8.s,func_80187FA8,0x80187FA8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FB0.s,func_80187FB0,0x80187FB0,0x8 -asm/non_matchings/code/audio_synthesis/func_80187FD0.s,func_80187FD0,0x80187FD0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FD8.s,func_80187FD8,0x80187FD8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE0.s,func_80187FE0,0x80187FE0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE8.s,func_80187FE8,0x80187FE8,0xD -asm/non_matchings/code/audio_synthesis/func_8018801C.s,func_8018801C,0x8018801C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188024.s,func_80188024,0x80188024,0x2 -asm/non_matchings/code/audio_synthesis/func_8018802C.s,func_8018802C,0x8018802C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188034.s,func_80188034,0x80188034,0xD -asm/non_matchings/code/audio_synthesis/func_80188068.s,func_80188068,0x80188068,0x2 -asm/non_matchings/code/audio_synthesis/func_80188070.s,func_80188070,0x80188070,0x2 -asm/non_matchings/code/audio_synthesis/func_80188078.s,func_80188078,0x80188078,0xB -asm/non_matchings/code/audio_synthesis/func_801880A4.s,func_801880A4,0x801880A4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880AC.s,func_801880AC,0x801880AC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880B4.s,func_801880B4,0x801880B4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880BC.s,func_801880BC,0x801880BC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880C4.s,func_801880C4,0x801880C4,0x9 -asm/non_matchings/code/audio_synthesis/func_801880E8.s,func_801880E8,0x801880E8,0xD -asm/non_matchings/code/audio_synthesis/func_8018811C.s,func_8018811C,0x8018811C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188124.s,func_80188124,0x80188124,0xA -asm/non_matchings/code/audio_synthesis/func_8018814C.s,func_8018814C,0x8018814C,0xA -asm/non_matchings/code/audio_synthesis/func_80188174.s,func_80188174,0x80188174,0x7 -asm/non_matchings/code/audio_synthesis/func_80188190.s,func_80188190,0x80188190,0x2 -asm/non_matchings/code/audio_synthesis/func_80188198.s,func_80188198,0x80188198,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A0.s,func_801881A0,0x801881A0,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A8.s,func_801881A8,0x801881A8,0x7 -asm/non_matchings/code/audio_synthesis/func_801881C4.s,func_801881C4,0x801881C4,0xD -asm/non_matchings/code/audio_synthesis/func_801881F8.s,func_801881F8,0x801881F8,0xB -asm/non_matchings/code/audio_synthesis/func_80188224.s,func_80188224,0x80188224,0x2 -asm/non_matchings/code/audio_synthesis/func_8018822C.s,func_8018822C,0x8018822C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188234.s,func_80188234,0x80188234,0x2 -asm/non_matchings/code/audio_synthesis/func_8018823C.s,func_8018823C,0x8018823C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188244.s,func_80188244,0x80188244,0x2 -asm/non_matchings/code/audio_synthesis/func_8018824C.s,func_8018824C,0x8018824C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188254.s,func_80188254,0x80188254,0x2 -asm/non_matchings/code/audio_synthesis/func_8018825C.s,func_8018825C,0x8018825C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188264.s,func_80188264,0x80188264,0x9 -asm/non_matchings/code/audio_synthesis/func_80188288.s,func_80188288,0x80188288,0x6 -asm/non_matchings/code/audio_synthesis/func_801882A0.s,func_801882A0,0x801882A0,0x19 -asm/non_matchings/code/audio_synthesis/func_80188304.s,func_80188304,0x80188304,0x67 -asm/non_matchings/code/audio_synthesis/func_801884A0.s,func_801884A0,0x801884A0,0x7E -asm/non_matchings/code/audio_synthesis/func_80188698.s,func_80188698,0x80188698,0x69 -asm/non_matchings/code/audio_synthesis/func_8018883C.s,func_8018883C,0x8018883C,0x2A -asm/non_matchings/code/audio_synthesis/func_801888E4.s,func_801888E4,0x801888E4,0x30 -asm/non_matchings/code/audio_synthesis/func_801889A4.s,func_801889A4,0x801889A4,0x2B -asm/non_matchings/code/audio_synthesis/func_80188A50.s,func_80188A50,0x80188A50,0x2B -asm/non_matchings/code/audio_synthesis/func_80188AFC.s,func_80188AFC,0x80188AFC,0x53 -asm/non_matchings/code/audio_synthesis/func_80188C48.s,func_80188C48,0x80188C48,0x1B -asm/non_matchings/code/audio_synthesis/func_80188CB4.s,func_80188CB4,0x80188CB4,0x1B -asm/non_matchings/code/audio_synthesis/func_80188D20.s,func_80188D20,0x80188D20,0x2 -asm/non_matchings/code/audio_synthesis/func_80188D28.s,func_80188D28,0x80188D28,0x10 -asm/non_matchings/code/audio_synthesis/func_80188D68.s,func_80188D68,0x80188D68,0x1D -asm/non_matchings/code/audio_synthesis/func_80188DDC.s,func_80188DDC,0x80188DDC,0x78 -asm/non_matchings/code/audio_synthesis/func_80188FBC.s,func_80188FBC,0x80188FBC,0x2A -asm/non_matchings/code/audio_synthesis/func_80189064.s,func_80189064,0x80189064,0x16F -asm/non_matchings/code/audio_synthesis/func_80189620.s,func_80189620,0x80189620,0x3A5 -asm/non_matchings/code/audio_synthesis/func_8018A4B4.s,func_8018A4B4,0x8018A4B4,0xAD -asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768,0x28 -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_synthesis/AudioSynth_AddReverbBufferEntry.s,AudioSynth_AddReverbBufferEntry,0x801877D0,0xE5 +asm/non_matchings/code/audio_synthesis/AudioSynth_SyncSampleStates.s,AudioSynth_SyncSampleStates,0x80187B64,0x22 +asm/non_matchings/code/audio_synthesis/AudioSynth_Update.s,AudioSynth_Update,0x80187BEC,0x7F +asm/non_matchings/code/audio_synthesis/AudioSynth_DisableSampleStates.s,AudioSynth_DisableSampleStates,0x80187DE8,0x1C +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadMixedReverbSamples.s,AudioSynth_LoadMixedReverbSamples,0x80187E58,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveMixedReverbSamples.s,AudioSynth_SaveMixedReverbSamples,0x80187F00,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop1.s,AudioSynth_Noop1,0x80187FA8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_ClearBuffer.s,AudioSynth_ClearBuffer,0x80187FB0,0x8 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop2.s,AudioSynth_Noop2,0x80187FD0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop3.s,AudioSynth_Noop3,0x80187FD8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop4.s,AudioSynth_Noop4,0x80187FE0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Mix.s,AudioSynth_Mix,0x80187FE8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop5.s,AudioSynth_Noop5,0x8018801C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop6.s,AudioSynth_Noop6,0x80188024,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop7.s,AudioSynth_Noop7,0x8018802C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_SetBuffer.s,AudioSynth_SetBuffer,0x80188034,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop8.s,AudioSynth_Noop8,0x80188068,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop9.s,AudioSynth_Noop9,0x80188070,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_DMemMove.s,AudioSynth_DMemMove,0x80188078,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop10.s,AudioSynth_Noop10,0x801880A4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop11.s,AudioSynth_Noop11,0x801880AC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop12.s,AudioSynth_Noop12,0x801880B4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop13.s,AudioSynth_Noop13,0x801880BC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_InterL.s,AudioSynth_InterL,0x801880C4,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup1.s,AudioSynth_EnvSetup1,0x801880E8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop14.s,AudioSynth_Noop14,0x8018811C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadBuffer.s,AudioSynth_LoadBuffer,0x80188124,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveBuffer.s,AudioSynth_SaveBuffer,0x8018814C,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup2.s,AudioSynth_EnvSetup2,0x80188174,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop15.s,AudioSynth_Noop15,0x80188190,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop16.s,AudioSynth_Noop16,0x80188198,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop17.s,AudioSynth_Noop17,0x801881A0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_S8Dec.s,AudioSynth_S8Dec,0x801881A8,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_HiLoGain.s,AudioSynth_HiLoGain,0x801881C4,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_UnkCmd19.s,AudioSynth_UnkCmd19,0x801881F8,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop18.s,AudioSynth_Noop18,0x80188224,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop19.s,AudioSynth_Noop19,0x8018822C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop20.s,AudioSynth_Noop20,0x80188234,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop21.s,AudioSynth_Noop21,0x8018823C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop22.s,AudioSynth_Noop22,0x80188244,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop23.s,AudioSynth_Noop23,0x8018824C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop24.s,AudioSynth_Noop24,0x80188254,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop25.s,AudioSynth_Noop25,0x8018825C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterBuffer.s,AudioSynth_LoadFilterBuffer,0x80188264,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterSize.s,AudioSynth_LoadFilterSize,0x80188288,0x6 +asm/non_matchings/code/audio_synthesis/AudioSynth_LeakReverb.s,AudioSynth_LeakReverb,0x801882A0,0x19 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDownsampledReverbSamples.s,AudioSynth_LoadDownsampledReverbSamples,0x80188304,0x67 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamples.s,AudioSynth_SaveResampledReverbSamples,0x801884A0,0x7E +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadResampledReverbSamples.s,AudioSynth_LoadResampledReverbSamples,0x80188698,0x69 +asm/non_matchings/code/audio_synthesis/AudioSynth_FilterReverb.s,AudioSynth_FilterReverb,0x8018883C,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_MixOtherReverbIndex.s,AudioSynth_MixOtherReverbIndex,0x801888E4,0x30 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDefaultReverbSamples.s,AudioSynth_LoadDefaultReverbSamples,0x801889A4,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamples.s,AudioSynth_LoadSubReverbSamples,0x80188A50,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamplesImpl.s,AudioSynth_SaveResampledReverbSamplesImpl,0x80188AFC,0x53 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamplesImpl.s,AudioSynth_LoadReverbSamplesImpl,0x80188C48,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamplesImpl.s,AudioSynth_SaveReverbSamplesImpl,0x80188CB4,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop26.s,AudioSynth_Noop26,0x80188D20,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamplesWithoutDownsample.s,AudioSynth_LoadSubReverbSamplesWithoutDownsample,0x80188D28,0x10 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamples.s,AudioSynth_LoadReverbSamples,0x80188D68,0x1D +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamples.s,AudioSynth_SaveReverbSamples,0x80188DDC,0x78 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveSubReverbSamples.s,AudioSynth_SaveSubReverbSamples,0x80188FBC,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSamples.s,AudioSynth_ProcessSamples,0x80189064,0x16F +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSample.s,AudioSynth_ProcessSample,0x80189620,0x3A5 +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplySurroundEffect.s,AudioSynth_ApplySurroundEffect,0x8018A4B4,0xAD +asm/non_matchings/code/audio_synthesis/AudioSynth_FinalResample.s,AudioSynth_FinalResample,0x8018A768,0x28 +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessEnvelope.s,AudioSynth_ProcessEnvelope,0x8018A808,0x12F +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadWaveSamples.s,AudioSynth_LoadWaveSamples,0x8018ACC4,0x5C +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplyHaasEffect.s,AudioSynth_ApplyHaasEffect,0x8018AE34,0xAF 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/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E @@ -3242,7 +3242,7 @@ asm/non_matchings/code/code_80194710/osAiSetNextBuffer.s,osAiSetNextBuffer,0x801 asm/non_matchings/code/code_80194710/func_80194804.s,func_80194804,0x80194804,0xF asm/non_matchings/code/code_80194710/func_80194840.s,func_80194840,0x80194840,0x1C asm/non_matchings/code/code_80194710/func_801948B0.s,func_801948B0,0x801948B0,0x20 -asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteSub.s,AudioPlayback_InitNoteSub,0x80194930,0x120 +asm/non_matchings/code/audio_playback/AudioPlayback_InitSampleState.s,AudioPlayback_InitSampleState,0x80194930,0x120 asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,AudioPlayback_NoteSetResamplingRate,0x80194DB0,0x2C asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30 asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19