From 72d24b999553517adcefee85ef25927c897718b3 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Mon, 26 Sep 2022 16:59:31 -0700 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] `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