From 039fc4623ecbaf14e3bce46db78efbdb3272c591 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 25 Sep 2021 17:22:51 +0100 Subject: [PATCH] En_Syateki_Man (#269) * En_Syateki_Man * a --- include/functions.h | 8 +- include/z64.h | 2 +- include/z64item.h | 10 +- spec | 3 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 14 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 1269 ++++++++++++++++- .../ovl_En_Syateki_Man/z_en_syateki_man.h | 37 +- tools/disasm/functions.txt | 4 +- 8 files changed, 1288 insertions(+), 59 deletions(-) diff --git a/include/functions.h b/include/functions.h index e16858aa1a..0948b502e9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2178,7 +2178,7 @@ void func_80115A14(s32 arg0, s16 arg1); // void func_80118BA4(void); // void func_80119030(void); // void func_80119610(void); -// void func_8011B4E0(void); +void func_8011B4E0(GlobalContext* globalCtx, s32 arg1); // void func_8011B5C0(void); // void func_8011B9E0(void); // void func_8011BF70(void); @@ -2238,7 +2238,7 @@ void func_80123D50(GlobalContext* globalCtx, Player* player, UNK_TYPE arg2, UNK_ void func_80123DA4(Player* player); // void func_80123DC0(void); void func_80123E90(GlobalContext* globalCtx, Actor* actor); -// void func_80123F2C(void); +void func_80123F2C(GlobalContext* globalCtx, s32 arg1); // void func_80123F48(void); // void func_80124020(void); u8 Player_GetMask(GlobalContext* globalCtx); @@ -3911,8 +3911,8 @@ void func_801A246C(u8 param_1, u8 param_2); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -// void func_801A2BB8(void); -// void func_801A2C20(void); +void func_801A2BB8(s32 arg0); +void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); // void func_801A2D54(void); diff --git a/include/z64.h b/include/z64.h index d6f097cfbf..3925281a62 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1559,7 +1559,7 @@ struct GlobalContext { /* 0x18784 */ s32 (*damagePlayer)(struct GlobalContext* globalCtx, s32 damage); /* 0x18788 */ void (*talkWithPlayer)(struct GlobalContext* globalCtx, Actor* actor); /* 0x1878C */ void (*unk_1878C)(struct GlobalContext* globalCtx); - /* 0x18790 */ void* unk_18790; //! @TODO: Determine function prototype + /* 0x18790 */ void (*unk_18790)(struct GlobalContext* globalCtx, s16 arg1, Actor* actor); /* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct GlobalContext* globalCtx, void* talkAnim, s32 arg2); /* 0x1879C */ s16 unk_1879C[10]; diff --git a/include/z64item.h b/include/z64item.h index 80002880a7..a5939c0dcb 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -89,9 +89,13 @@ typedef enum { /* 0x1B */ GI_BOMB_BAG_20, /* 0x1C */ GI_BOMB_BAG_30, /* 0x1D */ GI_BOMB_BAG_40, - /* 0x1E */ GI_ARROWS_SMALL, - /* 0x1F */ GI_ARROWS_MEDIUM, - /* 0x20 */ GI_ARROWS_LARGE, + /* 0x1E */ GI_ARROWS_10, + /* 0x1F */ GI_ARROWS_30, + /* 0x20 */ GI_ARROWS_40, + /* 0x21 */ GI_ARROWS_50, + /* 0x22 */ GI_QUIVER_30, + /* 0x23 */ GI_QUIVER_40, + /* 0x24 */ GI_QUIVER_50, /* 0x28 */ GI_NUTS_1 = 0x28, /* 0x2A */ GI_NUTS_10 = 0x2A, /* 0x32 */ GI_SHIELD_HERO = 0x32, diff --git a/spec b/spec index ae8b116fe0..0754aca9c9 100644 --- a/spec +++ b/spec @@ -2487,8 +2487,7 @@ beginseg name "ovl_En_Syateki_Man" compress include "build/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.o" - include "build/data/ovl_En_Syateki_Man/ovl_En_Syateki_Man.data.o" - include "build/data/ovl_En_Syateki_Man/ovl_En_Syateki_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Man/ovl_En_Syateki_Man_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 7e7f7e7d4c..9473ee3131 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -72,7 +72,7 @@ static ShopItemEntry sShopItemEntries[] = { EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06B6, 0X06B7, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06BA, 0X06BB, GI_ARROWS_LARGE, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06BA, 0X06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06B2, 0X06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, @@ -80,7 +80,7 @@ static ShopItemEntry sShopItemEntries[] = { EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06B4, 0X06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06B8, 0X06B9, GI_ARROWS_MEDIUM, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06B8, 0X06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06B0, 0X06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, @@ -88,9 +88,9 @@ static ShopItemEntry sShopItemEntries[] = { EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06D3, 0X06D4, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06D5, 0X06D6, GI_ARROWS_MEDIUM, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06D5, 0X06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06D7, 0X06D8, GI_ARROWS_LARGE, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06D7, 0X06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06CF, 0X06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, @@ -120,19 +120,19 @@ static ShopItemEntry sShopItemEntries[] = { EnGirlA_BuyFanfare }, { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X12DB, 0X12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X12DD, 0X12DE, GI_ARROWS_SMALL, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X12DD, 0X12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X12DF, 0X12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BC5, 0X0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BC7, 0X0BC8, GI_ARROWS_SMALL, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BC7, 0X0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BC9, 0X0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BCB, 0X0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BCD, 0X0BCE, GI_ARROWS_SMALL, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BCD, 0X0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BCF, 0X0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index ab927fb57c..67b0fe886d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1,3 +1,9 @@ +/* + * File: z_en_syateki_man.c + * Overlay: ovl_En_Syateki_Man + * Description: Shooting Gallery Man + */ + #include "z_en_syateki_man.h" #define FLAGS 0x08000019 @@ -28,7 +34,16 @@ void func_809C8808(EnSyatekiMan* this, GlobalContext* globalCtx); void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx); void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx); -#if 0 +extern UNK_PTR D_06005AC8; +extern UNK_PTR D_060062C8; +extern AnimationHeader D_0600D2F8; +extern AnimationHeader D_0600D9D0; +extern AnimationHeader D_0600DFEC; +extern FlexSkeletonHeader D_0600E7D0; +extern Gfx D_0600F2D0[]; +extern UNK_PTR D_0600FB90; +extern UNK_PTR D_06010390; + const ActorInit En_Syateki_Man_InitVars = { ACTOR_EN_SYATEKI_MAN, ACTORCAT_NPC, @@ -41,73 +56,1251 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -#endif +static ActorAnimationEntry sAnimations[] = { + { &D_0600D9D0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, + { &D_0600DFEC, 1.0f, 0.0f, 0.0f, 0, -8.0f }, + { &D_0600D2F8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, +}; -extern UNK_TYPE D_060062C8; -extern UNK_TYPE D_0600D2F8; -extern UNK_TYPE D_0600DFEC; -extern UNK_TYPE D_0600F2D0; +static s16 D_809C91C8[] = { + 0x00C1, + 0x0302, + 0x0019, + 0x0026, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C64C0.s") +static EnSyatekiManUnkStruct D_809C91D0[] = { + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x130 }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x20 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x0 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x10 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x20 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x30 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x40 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x1 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x11 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x0 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x100 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x200 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x300 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x420 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x520 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x601 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x702 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x801 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x902 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/EnSyatekiMan_Init.s") +static EnSyatekiManUnkStruct D_809C934C[] = { + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x0 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x100 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x1 }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, 0x11 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x202 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x302 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x3 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x103 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x423 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x204 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x304 }, + { ACTOR_EN_SYATEKI_CROW, -1000.0f, 200.0f, -700.0f, 0x424 }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x25 }, + { ACTOR_EN_SYATEKI_WF, -1000.0f, 200.0f, -700.0f, 0x136 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/EnSyatekiMan_Destroy.s") +static EnSyatekiManUnkStruct* D_809C9464[] = { + D_809C91D0, + D_809C934C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6720.s") +static s32 D_809C946C[] = { + ARRAY_COUNT(D_809C91D0), + ARRAY_COUNT(D_809C934C), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6810.s") +static Vec3f D_809C9474 = { 0.0f, 10.0f, 140.0f }; +static Vec3f D_809C9480 = { -20.0f, 20.0f, 198.0f }; +static Vec3f D_809C948C = { -20.0f, 40.0f, 175.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6848.s") +void func_809C64C0(EnSyatekiMan* this, GlobalContext* globalCtx2, EnSyatekiManUnkStruct arg2[], s32 arg3) { + GlobalContext* globalCtx = globalCtx2; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6A04.s") + for (i = 0; i < arg3; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, arg2[i].index, arg2[i].x, arg2[i].y, + arg2[i].z, 0, 0, 0, arg2[i].variable); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6C2C.s") +void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiMan* this = THIS; + s32 pad; + Path* sp34 = &globalCtx->setupPathList[ENSYATEKIMAN_GET_FF00(&this->actor)]; + s32 sp30 = D_809C946C[this->unk_194]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6E30.s") + this->actor.targetMode = 1; + Actor_SetScale(&this->actor, 0.01f); + if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600E7D0, &D_0600DFEC, this->jointTable, this->morphTable, 16); + } else { + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600E7D0, &D_0600D9D0, this->jointTable, this->morphTable, 16); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C6F98.s") + this->actor.colChkInfo.cylRadius = 100; + this->actionFunc = func_809C6810; + this->unk_26A = 0; + this->unk_270 = 15; + this->unk_27E = 0; + this->unk_26E = 0; + this->unk_190 = 0; + this->unk_272 = 0; + this->unk_274 = 0; + this->unk_280 = 0; + this->unk_278 = 0; + this->unk_27A = 0; + this->unk_284 = 0; + this->unk_194 = 0; + this->unk_282 = 0; + this->unk_264 = 0; + this->unk_266 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C72D8.s") + if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { + this->path = sp34; + func_809C64C0(this, globalCtx, D_809C9464[this->unk_194], sp30); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7380.s") +void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + gSaveContext.weekEventReg[63] &= (u8)~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7620.s") +s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { + Player* player = PLAYER; + f32 sp28; + f32 phi_f0; + s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7990.s") + sp28 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7A90.s") + if (sp28 < 5.0f) { + phi_f0 = 10.0f; + } else if (sp28 < 30.0f) { + phi_f0 = 40.0f; + } else { + phi_f0 = 80.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7C14.s") + globalCtx->actorCtx.unk268 = 1; + func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7D14.s") + if (sp28 < 5.0f) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7EB4.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C7FFC.s") +void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { + this->actionFunc = func_809C6848; + } else if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { + this->actionFunc = func_809C72D8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C80C0.s") +void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C81D0.s") + if (func_800B84D0(&this->actor, globalCtx)) { + u16 sp22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8488.s") + func_800BDC5C(&this->skelAnime, sAnimations, 2); + sp22 = Text_GetFaceReaction(globalCtx, 0x31); + if (sp22 != 0) { + func_801518B0(globalCtx, sp22, &this->actor); + this->unk_284 = sp22; + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (this->unk_282 == 0) { + this->unk_282 = 1; + func_801518B0(globalCtx, 0xA28, &this->actor); + this->unk_284 = 0xA28; + } else { + func_801518B0(globalCtx, 0xA29, &this->actor); + this->unk_284 = 0xA29; + } + } else { + switch (CURRENT_DAY) { + case 1: + func_801518B0(globalCtx, 0xA38, &this->actor); + this->unk_284 = 0xA38; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8610.s") + case 2: + func_801518B0(globalCtx, 0xA39, &this->actor); + this->unk_284 = 0xA39; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8710.s") + case 3: + func_801518B0(globalCtx, 0xA3A, &this->actor); + this->unk_284 = 0xA3A; + break; + } + } + this->actionFunc = func_809C6E30; + } else { + func_800B8614(&this->actor, globalCtx, 120.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8808.s") + if (player->actor.world.pos.z < 135.0f) { + player->actor.world.pos.z = 135.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C898C.s") +void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8BF0.s") + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (!CUR_UPG_VALUE(UPG_QUIVER)) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0xA30, &this->actor); + this->unk_284 = 0xA30; + } else if (gSaveContext.rupees < 20) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0xA31, &this->actor); + this->unk_284 = 0xA31; + if (this->unk_26A == 4) { + gSaveContext.minigameState = 3; + } + this->unk_26A = 3; + } else { + func_8019F208(); + func_801159EC(-20); + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26A = 7; + player->stateFlags1 |= 0x20; + this->actionFunc = func_809C7FFC; + } + } else { + func_8019F230(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8DE8.s") + switch (CURRENT_DAY) { + case 1: + func_801518B0(globalCtx, 0xA2D, &this->actor); + this->unk_284 = 0xA2D; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/EnSyatekiMan_Update.s") + case 2: + func_801518B0(globalCtx, 0xA2E, &this->actor); + this->unk_284 = 0xA2E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8EE4.s") + case 3: + func_801518B0(globalCtx, 0xA2F, &this->actor); + this->unk_284 = 0xA2F; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/func_809C8FAC.s") + if (this->unk_26A == 4) { + gSaveContext.minigameState = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Man/EnSyatekiMan_Draw.s") + this->unk_26A = 3; + } + } +} + +void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_80147624(globalCtx)) { + switch (this->unk_284) { + case 0xA28: + case 0xA29: + func_801518B0(globalCtx, 0xA2A, &this->actor); + this->unk_284 = 0xA2A; + break; + + case 0xA2B: + case 0xA2C: + case 0xA35: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->actor.freezeTimer = 0; + func_80112AFC(globalCtx); + globalCtx->interfaceCtx.hbaAmmo = 80; + func_80123F2C(globalCtx, 80); + this->unk_26A = 1; + this->actionFunc = func_809C80C0; + func_801A2BB8(0x25); + break; + + case 0xA32: + if (gSaveContext.weekEventReg[63] & 2) { + func_801477B4(globalCtx); + player->stateFlags1 &= ~0x20; + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_809C6848; + gSaveContext.minigameState = 3; + this->unk_26A = 0; + } else { + func_801518B0(globalCtx, 0xA33, &this->actor); + this->unk_284 = 0xA33; + } + break; + + case 0xA33: + func_801518B0(globalCtx, 0xA2A, &this->actor); + this->unk_284 = 0xA2A; + this->unk_26A = 4; + break; + + case 0xA34: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->actor.freezeTimer = 0; + gSaveContext.minigameState = 3; + player->stateFlags1 |= 0x20; + this->actionFunc = func_809C7A90; + func_809C7A90(this, globalCtx); + break; + } + } +} + +void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (player->stateFlags1 & 0x20) { + player->stateFlags1 |= 0x20; + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 2: + this->actionFunc = func_809C6848; + this->unk_26A = 0; + break; + + case 4: + func_809C6A04(this, globalCtx); + break; + + case 5: + func_809C6C2C(this, globalCtx); + break; + + case 6: + if (func_80147624(globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->stateFlags1 &= ~0x20; + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_809C6848; + this->unk_26A = 0; + } + break; + + case 0: + case 1: + case 3: + case 7: + case 8: + case 9: + case 10: + break; + } + + if (this->skelAnime.animCurrentSeg == &D_0600D2F8) { + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + func_800BDC5C(&this->skelAnime, sAnimations, 0); + } + } +} + +void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_HUMAN: + Actor_SetAllChestFlag(globalCtx, Actor_GetAllChestFlag(globalCtx) + 1); + if (CURRENT_DAY != 3) { + if (!(this->unk_282 & 1)) { + this->unk_282 |= 1; + func_801518B0(globalCtx, 0x3E8, &this->actor); + this->unk_284 = 0x3E8; + } else { + func_801518B0(globalCtx, 0x3E9, &this->actor); + this->unk_284 = 0x3E9; + } + } else if (!(this->unk_282 & 1)) { + this->unk_282 |= 1; + func_801518B0(globalCtx, 0x3EA, &this->actor); + this->unk_284 = 0x3EA; + } else { + func_801518B0(globalCtx, 0x3EB, &this->actor); + this->unk_284 = 0x3EB; + } + break; + + case PLAYER_FORM_DEKU: + if (CURRENT_DAY != 3) { + if (!(this->unk_282 & 2)) { + this->unk_282 |= 2; + func_801518B0(globalCtx, 0x3EC, &this->actor); + this->unk_284 = 0x3EC; + } else { + func_801518B0(globalCtx, 0x3ED, &this->actor); + this->unk_284 = 0x3ED; + } + } else if (!(this->unk_282 & 2)) { + this->unk_282 |= 2; + func_801518B0(globalCtx, 0x3EE, &this->actor); + this->unk_284 = 0x3EE; + } else { + func_801518B0(globalCtx, 0x3EF, &this->actor); + this->unk_284 = 0x3EF; + } + break; + + case PLAYER_FORM_ZORA: + if (CURRENT_DAY != 3) { + if (!(this->unk_282 & 8)) { + this->unk_282 |= 8; + func_801518B0(globalCtx, 0x3F0, &this->actor); + this->unk_284 = 0x3F0; + } else { + func_801518B0(globalCtx, 0x3F1, &this->actor); + this->unk_284 = 0x3F1; + } + } else if (!(this->unk_282 & 8)) { + this->unk_282 |= 8; + func_801518B0(globalCtx, 0x3F4, &this->actor); + this->unk_284 = 0x3F4; + } else { + func_801518B0(globalCtx, 0x3F5, &this->actor); + this->unk_284 = 0x3F5; + } + break; + + case PLAYER_FORM_GORON: + if (CURRENT_DAY != 3) { + if (!(this->unk_282 & 4)) { + this->unk_282 |= 4; + func_801518B0(globalCtx, 0x3F2, &this->actor); + this->unk_284 = 0x3F2; + } else { + func_801518B0(globalCtx, 0x3F3, &this->actor); + this->unk_284 = 0x3F3; + } + } else if (!(this->unk_282 & 4)) { + this->unk_282 |= 4; + func_801518B0(globalCtx, 0x3F4, &this->actor); + this->unk_284 = 0x3F4; + } else { + func_801518B0(globalCtx, 0x3F5, &this->actor); + this->unk_284 = 0x3F5; + } + break; + } +} + +void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); + + if (sp26 != 0) { + func_801518B0(globalCtx, sp26, &this->actor); + this->unk_284 = sp26; + } else { + func_809C6F98(this, globalCtx); + } + this->actionFunc = func_809C7990; + } else { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (!CUR_UPG_VALUE(UPG_QUIVER)) { + play_sound(NA_SE_SY_ERROR); + if (CURRENT_DAY != 3) { + func_801518B0(globalCtx, 0x3F9, &this->actor); + this->unk_284 = 0x3F9; + } else { + func_801518B0(globalCtx, 0x3FA, &this->actor); + this->unk_284 = 0x3FA; + } + } else if (gSaveContext.rupees < 20) { + play_sound(NA_SE_SY_ERROR); + if (CURRENT_DAY != 3) { + func_801518B0(globalCtx, 0x3FB, &this->actor); + this->unk_284 = 0x3FB; + } else { + func_801518B0(globalCtx, 0x3FC, &this->actor); + this->unk_284 = 0x3FC; + } + + if (this->unk_26A == 4) { + player->stateFlags3 &= ~0x400; + gSaveContext.minigameState = 3; + } + this->unk_26A = 3; + } else { + func_8019F208(); + func_801159EC(-20); + this->unk_26A = 2; + if (!(this->unk_282 & 0x10)) { + this->unk_282 |= 0x10; + func_801518B0(globalCtx, 0x3FD, &this->actor); + this->unk_284 = 0x3FD; + } else { + func_801518B0(globalCtx, 0x3FF, &this->actor); + this->unk_284 = 0x3FF; + } + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + } + } else { + func_8019F230(); + if (CURRENT_DAY != 3) { + func_801518B0(globalCtx, 0x3F7, &this->actor); + this->unk_284 = 0x3F7; + } else { + func_801518B0(globalCtx, 0x3F8, &this->actor); + this->unk_284 = 0x3F8; + } + + if (this->unk_26A == 4) { + player->stateFlags3 &= ~0x400; + gSaveContext.minigameState = 3; + } + this->unk_26A = 3; + } + } +} + +void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_80147624(globalCtx)) { + switch (this->unk_284) { + case 0x3E8: + case 0x3E9: + case 0x3EA: + case 0x3EB: + func_801518B0(globalCtx, 0x3F6, &this->actor); + this->unk_284 = 0x3F6; + break; + + case 0x3EC: + func_801518B0(globalCtx, 0x3ED, &this->actor); + this->unk_284 = 0x3ED; + break; + + case 0x3EE: + func_801518B0(globalCtx, 0x3EF, &this->actor); + this->unk_284 = 0x3EF; + break; + + case 0x3F0: + func_801518B0(globalCtx, 0x3F1, &this->actor); + this->unk_284 = 0x3F1; + break; + + case 0x3F2: + func_801518B0(globalCtx, 0x3F3, &this->actor); + this->unk_284 = 0x3F3; + break; + + case 0x3F4: + func_801518B0(globalCtx, 0x3F5, &this->actor); + this->unk_284 = 0x3F5; + break; + + case 0x3FD: + case 0x3FF: + if (this->unk_26A == 4U) { + if (this->unk_284 == 0x3FD) { + func_801518B0(globalCtx, 0x3FE, &this->actor); + this->unk_284 = 0x3FE; + } else { + func_801518B0(globalCtx, 0x400, &this->actor); + this->unk_284 = 0x400; + } + } else { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->actor.freezeTimer = 0; + this->unk_26A = 7; + player->stateFlags1 |= 0x20; + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_809C8710; + } + break; + + case 0x3FE: + case 0x400: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->actor.freezeTimer = 0; + this->unk_27E = 0; + func_80112AFC(globalCtx); + func_80123F2C(globalCtx, 0x63); + this->unk_26A = 1; + func_801A2BB8(0x25); + this->actionFunc = func_809C8808; + break; + + case 0x401: + if (gSaveContext.weekEventReg[63] & 2) { + func_801477B4(globalCtx); + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->unk_26A = 0; + this->actionFunc = func_809C72D8; + } else { + func_801518B0(globalCtx, 0x402, &this->actor); + this->unk_284 = 0x402; + } + break; + + case 0x403: + if (gSaveContext.weekEventReg[63] & 2) { + func_801477B4(globalCtx); + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->unk_26A = 0; + this->actionFunc = func_809C72D8; + } else { + func_801518B0(globalCtx, 0x404, &this->actor); + this->unk_284 = 0x404; + } + break; + + case 0x402: + case 0x404: + func_801518B0(globalCtx, 0x3F6, &this->actor); + this->unk_284 = 0x3F6; + this->unk_26A = 4; + break; + + case 0x405: + case 0x406: + case 0x407: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + player->actor.freezeTimer = 0; + gSaveContext.minigameState = 3; + this->actionFunc = func_809C7D14; + func_809C7D14(this, globalCtx); + break; + } + } +} + +void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (player->stateFlags1 & 0x20) { + player->stateFlags1 |= 0x20; + } + + switch (func_80152498(&globalCtx->msgCtx)) { + case 2: + this->actionFunc = func_809C72D8; + this->unk_26A = 0; + break; + + case 4: + func_809C7380(this, globalCtx); + break; + + case 5: + func_809C7620(this, globalCtx); + break; + + case 6: + if (func_80147624(globalCtx)) { + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + player->stateFlags1 &= ~0x20; + this->actionFunc = func_809C72D8; + this->unk_26A = 0; + } + break; + + case 0: + case 1: + case 3: + case 7: + case 8: + case 9: + case 10: + break; + } +} + +void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.weekEventReg[59] & 0x10)) { + gSaveContext.weekEventReg[59] |= 0x10; + } else if (!(gSaveContext.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { + gSaveContext.weekEventReg[32] |= 2; + } + this->actor.parent = NULL; + this->actionFunc = func_809C7C14; + } else { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { + func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + } else if (this->unk_280 < 0x884) { + func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); + } else if (!(gSaveContext.weekEventReg[32] & 2)) { + func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } else { + func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } + + player->actor.shape.rot.y = -0x8000; + player->actor.velocity.z = 0.0f; + player->actor.velocity.x = 0.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + } +} + +void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_800B84D0(&this->actor, globalCtx)) { + if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { + func_801518B0(globalCtx, 0xA36, &this->actor); + this->unk_284 = 0xA36; + } else { + func_801518B0(globalCtx, 0xA37, &this->actor); + this->unk_284 = 0xA37; + } + player->stateFlags1 &= ~0x20; + this->actor.flags &= ~0x10000; + this->unk_280 = 0; + this->unk_26A = 0; + this->actionFunc = func_809C6E30; + } else { + func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + } +} + +void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (Actor_HasParent(&this->actor, globalCtx)) { + if (this->unk_284 == 0x407) { + if (!(gSaveContext.weekEventReg[59] & 0x20)) { + gSaveContext.weekEventReg[59] |= 0x20; + } + } + + if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { + if (!(gSaveContext.weekEventReg[32] & 4)) { + gSaveContext.weekEventReg[32] |= 4; + } + } + this->actor.parent = NULL; + this->actionFunc = func_809C7EB4; + } else { + if (this->unk_284 == 0x407) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { + func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + } else { + func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } + } else if (!(gSaveContext.weekEventReg[32] & 4)) { + func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } else { + func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_GOLD, 500.0f, 100.0f); + } + + player->actor.shape.rot.y = -0x8000; + player->actor.velocity.z = 0.0f; + player->actor.velocity.x = 0.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + } +} + +void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (CURRENT_DAY != 3) { + if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + player->stateFlags1 &= ~0x20; + this->unk_280 = 0; + this->unk_26A = 0; + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_809C6810; + } + } else if (func_800B84D0(&this->actor, globalCtx)) { + func_801518B0(globalCtx, 0x408, &this->actor); + this->unk_284 = 0x408; + player->stateFlags1 &= ~0x20; + this->actor.flags &= ~0x10000; + this->unk_280 = 0; + this->unk_26A = 0; + this->actionFunc = func_809C7990; + } else { + func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + } +} + +void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_809C6720(globalCtx, D_809C9474)) { + player->stateFlags1 |= 0x20; + this->unk_26A = 2; + if (this->unk_282 != 2) { + this->unk_282 = 2; + func_801518B0(globalCtx, 0xA2B, &this->actor); + this->unk_284 = 0xA2B; + } else { + func_801518B0(globalCtx, 0xA2C, &this->actor); + this->unk_284 = 0xA2C; + } + this->actionFunc = func_809C6E30; + } +} + +void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { + static s16 D_809C9498 = 30; + Player* player = PLAYER; + + if (D_809C9498 > 0) { + player->actor.world.pos = D_809C9474; + player->actor.shape.rot.y = -0x8000; + player->actor.world.rot.y = player->actor.shape.rot.y; + globalCtx->unk_18790(globalCtx, -0x8000, &this->actor); + D_809C9498--; + } else { + D_809C9498 = 30; + this->unk_27E = 0; + this->unk_280 = 0; + player->stateFlags1 &= ~0x20; + Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + this->unk_272 = 0x1F; + this->unk_274 = 0; + this->unk_276 = 0; + this->unk_26C = 0; + this->unk_278 = 0; + this->unk_27A = 0; + this->unk_27C = 0; + this->unk_26E = 0; + func_8010E9F0(1, 100); + this->actor.draw = NULL; + this->actionFunc = func_809C81D0; + } +} + +void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx) { + static s16 D_809C949C = 0; + Player* player = PLAYER; + + if (((this->unk_272 == 0) || (this->unk_26C > 140)) && (D_809C949C == 0) && (this->unk_27C < 4)) { + D_809C949C = 1; + this->unk_26C = 0; + Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + this->unk_274 = D_809C91C8[this->unk_27E]; + if (this->unk_27E == 3) { + this->unk_27E = 0; + } else { + this->unk_27E++; + } + } else if ((this->unk_274 == 0) && (this->unk_272 == 0) && (D_809C949C == 1) && (this->unk_27C < 4)) { + if (this->unk_27A < 3) { + this->unk_27A = 0; + } + this->unk_26C = 0; + D_809C949C = 0; + this->unk_27C++; + if (this->unk_27C < 4) { + this->unk_272 = 31; + } + } + + if (this->unk_27A == 3) { + this->unk_27A = 0; + this->unk_276 |= 1; + } + + if (this->unk_278 == 10) { + this->unk_278 = 0; + this->unk_276 |= 2; + } + + this->unk_26C++; + if (gSaveContext.unk_3DE0[1] == 0) { + gSaveContext.unk_3DE0[1] = 0; + gSaveContext.unk_3DD0[1] = 5; + this->actor.draw = EnSyatekiMan_Draw; + this->unk_27E = 0; + this->unk_27C = 0; + player->stateFlags1 |= 0x20; + D_809C949C = 0; + func_801A2C20(); + this->actionFunc = func_809C8488; + } else if ((this->unk_27C == 4) && (this->unk_276 == 0) && (this->unk_26E == 2)) { + this->actor.draw = EnSyatekiMan_Draw; + this->unk_27E = 0; + this->unk_27C = 0; + player->stateFlags1 |= 0x20; + D_809C949C = 0; + func_801A2C20(); + this->unk_26A = 5; + if (this->unk_280 == 0x848) { + func_8011B4E0(globalCtx, 2); + gSaveContext.unk_3DD0[1] = 6; + this->actionFunc = func_809C8610; + } else { + gSaveContext.unk_3DD0[1] = 5; + this->actionFunc = func_809C8488; + } + } +} + +void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { + if ((this->unk_26A == 1) || (this->unk_26A == 5)) { + this->unk_190 = 0; + this->unk_272 = 0; + this->unk_274 = 0; + this->unk_276 = 0; + if (this->unk_270 <= 0) { + if ((s32)((gSaveContext.roomInf[127][6] & 0xFFFF0000) >> 0x10) < this->unk_280) { + gSaveContext.roomInf[127][6] = ((gSaveContext.roomInf[127][6]) & 0xFFFF) | ((u16)this->unk_280 << 0x10); + } + this->unk_270 = 15; + if (this->unk_280 >= 0x848) { + func_801518B0(globalCtx, 0xA34, &this->actor); + this->unk_284 = 0xA34; + this->unk_26A = 6; + } else if (this->unk_280 >= 0x7D0) { + if (gSaveContext.weekEventReg[63] & 2) { + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->unk_26A = 0; + gSaveContext.minigameState = 3; + this->actionFunc = func_809C6848; + return; + } + func_801518B0(globalCtx, 0xA35, &this->actor); + this->unk_284 = 0xA35; + this->unk_26A = 4; + this->unk_280 = 0; + } else { + func_801518B0(globalCtx, 0xA32, &this->actor); + this->unk_284 = 0xA32; + this->unk_26A = 6; + } + this->actionFunc = func_809C6E30; + } else { + this->unk_270--; + } + } + + if (this->unk_270 < 5) { + globalCtx->unk_1887C = -10; + } +} + +void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { + static s32 D_809C94A0 = 0; + Player* player = PLAYER; + + player->stateFlags1 |= 0x20; + if (globalCtx->interfaceCtx.unk_286 == 0) { + if (gSaveContext.unk_3DE0[1] == 0) { + gSaveContext.unk_3DE0[1] = 0; + gSaveContext.unk_3DD0[1] = 5; + this->unk_27E = 0; + this->unk_27C = 0; + this->actionFunc = func_809C8488; + D_809C94A0 = 0; + } else if (D_809C94A0 > 10) { + gSaveContext.unk_3E88[1] += 100; + globalCtx->interfaceCtx.unk_25C += 10; + this->unk_280 += 10; + Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + D_809C94A0 = 0; + } else { + D_809C94A0++; + } + } +} + +void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { + Vec3f sp24; + + if (gSaveContext.playerForm == PLAYER_FORM_FIERCE_DEITY) { + sp24 = D_809C9480; + } else { + sp24 = D_809C948C; + } + + if (func_809C6720(globalCtx, sp24)) { + if (this->unk_284 == 0x3FD) { + func_801518B0(globalCtx, 0x3FE, &this->actor); + this->unk_284 = 0x3FE; + } else { + func_801518B0(globalCtx, 0x400, &this->actor); + this->unk_284 = 0x400; + } + this->unk_26A = 2; + this->actionFunc = func_809C7990; + } +} + +void func_809C8808(EnSyatekiMan* this, GlobalContext* globalCtx) { + static s16 D_809C94A4 = 30; + Player* player = PLAYER; + + if (D_809C94A4 == 30) { + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + player->actor.world.pos = D_809C9480; + } else { + player->actor.world.pos = D_809C948C; + } + player->actor.prevPos = player->actor.world.pos; + player->actor.shape.rot.y = -0x8000; + player->actor.world.rot.y = player->actor.shape.rot.y; + globalCtx->unk_18790(globalCtx, -0x8000, &this->actor); + player->stateFlags1 |= 0x20; + D_809C94A4--; + } else if (D_809C94A4 > 0) { + player->actor.shape.rot.y = -0x8000; + player->actor.world.rot.y = player->actor.shape.rot.y; + D_809C94A4--; + } else if (D_809C94A4 == 0) { + player->stateFlags1 &= ~0x20; + this->unk_280 = 0; + this->unk_27E = 0; + this->unk_26C = 70; + this->unk_26E = 0; + D_809C94A4 = 30; + func_8010E9F0(1, 75); + this->actor.draw = NULL; + this->actionFunc = func_809C898C; + } +} + +void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { + static const s32 D_809C94D0[] = { + 0x00000111, 0x00000650, 0x00010025, 0x00011011, 0x00000984, 0x00004050, 0x00010211, 0x00022015, + 0x00026984, 0x00012852, 0x00011999, 0x00022895, 0x0000056A, 0x0002A451, 0x00004115, + }; + static s32 D_809C94A8 = 0; + Player* player = PLAYER; + s32 sp30; + s32 pad; + u64 sp20; + + sp20 = gSaveContext.unk_3DE0[1]; + sp30 = (sp20 * 0.1f) + 1.0f; + + if (sp30 < 0x2EF) { + s32 temp; + + // clang-format off + if (D_809C94A8 == 0) { + sp20 = gSaveContext.unk_3DE0[1]; temp = sp20 % 0x1F4; + } else { + sp20 = gSaveContext.unk_3DE0[1]; temp = (sp20 + 250) % 0x1F4; + } + //clang-format on + + if (temp < 100) { + this->unk_26C = 0x50; + } + + if (this->unk_26E != 0) { + if (this->unk_26E == 2) { + gSaveContext.unk_3E18[1] -= 250; + D_809C94A8 = (D_809C94A8 + 25) % 50; + } + this->unk_26E = 0; + } + + if (this->unk_26C == 0) { + this->unk_26C++; + } + + if ((D_809C94A8 == (sp30 % 50)) && (this->unk_26C >= 70)) { + if (this->unk_27E < 15) { + this->unk_190 = D_809C94D0[this->unk_27E++]; + Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + this->unk_26C = 0; + } + } + + if (gSaveContext.unk_3DE0[1] == 0) { + this->unk_27E = 0; + this->unk_26C = 80; + gSaveContext.unk_3DE0[1] = 0; + gSaveContext.unk_3DD0[1] = 5; + player->stateFlags1 |= 0x20; + D_809C94A8 = 0; + this->actor.draw = EnSyatekiMan_Draw; + func_801A2C20(); + this->actionFunc = func_809C8BF0; + if (this->unk_280 == 50) { + func_801A3098(0x922); + func_8011B4E0(globalCtx, 1); + } + } + } +} + +void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { + if (this->unk_26A == 1) { + this->unk_190 = 0; + if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { + Actor_SetAllChestFlag(globalCtx, this->unk_280); + this->unk_270 = 15; + if (((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { + if ((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) { + if (!(gSaveContext.weekEventReg[59] & 0x20)) { + func_801518B0(globalCtx, 0x407, &this->actor); + this->unk_284 = 0x407; + } else if (this->unk_280 == 50) { + func_801518B0(globalCtx, 0x405, &this->actor); + this->unk_284 = 0x405; + } else { + func_801518B0(globalCtx, 0x407, &this->actor); + this->unk_284 = 0x407; + } + } else if (this->unk_280 == 50) { + func_801518B0(globalCtx, 0x406, &this->actor); + this->unk_284 = 0x406; + } + gSaveContext.roomInf[127][6] = (gSaveContext.roomInf[127][6] & 0xFFFF0000) | (this->unk_280 & 0xFFFF); + this->unk_26A = 6; + } else { + if (CURRENT_DAY != 3) { + func_801518B0(globalCtx, 0x401, &this->actor); + this->unk_284 = 0x401; + } else { + func_801518B0(globalCtx, 0x403, &this->actor); + this->unk_284 = 0x403; + } + this->unk_26A = 4; + } + this->actionFunc = func_809C7990; + } else { + this->unk_270--; + } + } + + if (this->unk_270 < 5) { + globalCtx->unk_1887C = -10; + } +} + +void func_809C8DE8(EnSyatekiMan* this) { + switch (this->unk_266) { + case 1: + this->unk_264 = 2; + break; + + case 2: + this->unk_264 = 1; + break; + + case 40: + this->unk_266 = 0; + + default: + this->unk_264 = 0; + break; + } + + this->unk_266++; +} + +void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiMan* this = THIS; + + this->actionFunc(this, globalCtx); + func_809C8DE8(this); + this->actor.focus.pos.y = 70.0f; + Actor_SetHeight(&this->actor, 70.0f); + if (this->unk_26A != 1) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); + } +} + +s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiMan* this = THIS; + + if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == 15)) { + *dList = D_0600F2D0; + } + + if (limbIndex == 15) { + SysMatrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); + SysMatrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else if (limbIndex == 8) { + SysMatrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); + } + + return false; +} + +void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiMan* this = THIS; + Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; + + if (limbIndex == 15) { + SysMatrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static UNK_PTR D_809C94B8[] = { + &D_06005AC8, + &D_060062C8, + &D_060062C8, + }; + EnSyatekiMan* this = THIS; + s32 pad; + + if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { + D_809C94B8[0] = &D_0600FB90; + D_809C94B8[1] = &D_06010390; + D_809C94B8[2] = &D_06010390; + } else { + D_809C94B8[0] = &D_06005AC8; + D_809C94B8[1] = &D_060062C8; + D_809C94B8[2] = &D_060062C8; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index a80b2b3042..80f2a10687 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -7,11 +7,44 @@ struct EnSyatekiMan; typedef void (*EnSyatekiManActionFunc)(struct EnSyatekiMan*, GlobalContext*); +#define ENSYATEKIMAN_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +typedef struct { + /* 0x00 */ s16 index; + /* 0x04 */ f32 x; + /* 0x08 */ f32 y; + /* 0x0C */ f32 z; + /* 0x10 */ s32 variable; +} EnSyatekiManUnkStruct; + typedef struct EnSyatekiMan { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnSyatekiManActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xFC]; + /* 0x018C */ Path* path; + /* 0x0190 */ s32 unk_190; + /* 0x0194 */ s32 unk_194; + /* 0x0198 */ Vec3s jointTable[16]; + /* 0x01F8 */ Vec3s morphTable[16]; + /* 0x0258 */ Vec3s unk_258; + /* 0x025E */ Vec3s unk_25E; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ s16 unk_266; + /* 0x0268 */ UNK_TYPE1 unk268[0x2]; + /* 0x026A */ s16 unk_26A; + /* 0x026C */ s16 unk_26C; + /* 0x026E */ s16 unk_26E; + /* 0x0270 */ s16 unk_270; + /* 0x0272 */ s16 unk_272; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027A */ s16 unk_27A; + /* 0x027C */ s16 unk_27C; + /* 0x027E */ s16 unk_27E; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; } EnSyatekiMan; // size = 0x288 extern const ActorInit En_Syateki_Man_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index eba62a5cd7..8ba8afa25a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9113,8 +9113,8 @@ 0x809C8BF0:("func_809C8BF0",), 0x809C8DE8:("func_809C8DE8",), 0x809C8E44:("EnSyatekiMan_Update",), - 0x809C8EE4:("func_809C8EE4",), - 0x809C8FAC:("func_809C8FAC",), + 0x809C8EE4:("EnSyatekiMan_OverrideLimbDraw",), + 0x809C8FAC:("EnSyatekiMan_PostLimbDraw",), 0x809C9008:("EnSyatekiMan_Draw",), 0x809C9A60:("BgIcicle_Init",), 0x809C9B54:("BgIcicle_Destroy",),