From 456cf789acae16667fd92220dac4c1d58295d140 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 25 Sep 2021 12:47:18 -0300 Subject: [PATCH 01/86] Add `-I.` (#323) * Add `-I.` * IINC --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0d0326231..bc71a02e1 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,7 @@ LD := $(MIPS_BINUTILS_PREFIX)ld OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump +IINC := -Iinclude -Isrc -Iassets -Ibuild -I. ifeq ($(KEEP_MDEBUG),0) RM_MDEBUG = $(OBJCOPY) --remove-section .mdebug $@ else @@ -78,7 +79,7 @@ endif # Check code syntax with host compiler CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING -Iinclude -Isrc -Iassets -Ibuild -include stdarg.h $(CHECK_WARNINGS) +CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -include stdarg.h $(CHECK_WARNINGS) CPP := cpp ELF2ROM := tools/buildtools/elf2rom @@ -91,7 +92,7 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Isrc -Iassets -Ibuild -I. -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -Wab,-r4300_mul -woff 624,649,838,712 ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU 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 02/86] 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 e16858aa1..0948b502e 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 d6f097cfb..3925281a6 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 80002880a..a5939c0dc 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 ae8b116fe..0754aca9c 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 7e7f7e7d4..9473ee313 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 ab927fb57..67b0fe886 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 a80b2b304..80f2a1068 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 eba62a5cd..8ba8afa25 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",), From c72b5788a3fcb13d099880d5fb552af232142266 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Mon, 27 Sep 2021 22:41:07 +0100 Subject: [PATCH 03/86] sys_math, cosf OK and documented, sinf, coss, sins documented (#289) * OK, data imported, document * spec * Match cosf, document sinf and cosf * Some more documentation, switch fu back * Format * Little more documentation * Document coss too * Move macros * Review, add some .s * Fix headers, review --- include/convert.h | 2 + include/functions.h | 6 +-- include/macros.h | 5 ++- include/math.h | 3 +- include/variables.h | 2 +- spec | 1 - src/code/sys_math.c | 92 ++++++++++++++++++++++++++++++++++++++---- src/libultra/gu/cosf.c | 71 +++++++++++++++++++++++++++++++- src/libultra/gu/coss.c | 5 ++- src/libultra/gu/sinf.c | 88 ++++++++++++++++++++-------------------- src/libultra/gu/sins.c | 8 +++- tools/disasm/files.txt | 2 +- 12 files changed, 221 insertions(+), 64 deletions(-) diff --git a/include/convert.h b/include/convert.h index 31bdb034f..456e4b198 100644 --- a/include/convert.h +++ b/include/convert.h @@ -1,6 +1,8 @@ #ifndef _ULTRA64_CONVERT_H_ #define _ULTRA64_CONVERT_H_ +#include "stdint.h" + #define OS_CLOCK_RATE 62500000LL #define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) diff --git a/include/functions.h b/include/functions.h index 0948b502e..aba291a28 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3269,9 +3269,9 @@ void Check_ClearRGBA16(s16* buffer); // void Check_DrawRegionLockErrorMessage(void); // void Check_ExpansionPak(void); // void Check_RegionIsSupported(void); -f32 func_80179300(f32 param_1); -f32 func_80179400(s32 param_1); -f32 pow_int(f32 x, s32 pow); +f32 func_80179300(f32 n); +f32 func_80179400(s32 n); +f32 pow_int(f32 base, s32 exp); f32 sin_rad(f32 rad); f32 cos_rad(f32 rad); f32 Rand_ZeroFloat(f32 scale); diff --git a/include/macros.h b/include/macros.h index 36af1534b..e0e6c8e7c 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,8 +1,9 @@ #ifndef _MACROS_H_ #define _MACROS_H_ -#include "convert.h" #include "stdint.h" +#include "convert.h" +#include "z64.h" #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) @@ -116,6 +117,8 @@ extern GraphicsContext* __gfxCtx; #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)) + #define SWAP(type, a, b) \ { \ type _temp = (a); \ diff --git a/include/math.h b/include/math.h index 316bc5710..20fa352fa 100644 --- a/include/math.h +++ b/include/math.h @@ -12,12 +12,11 @@ #define DEGTORAD(x) ((x) * (M_PI / 180.0f)) typedef union { + f64 d; struct { u32 hi; u32 lo; } word; - - f64 d; } du; typedef union { diff --git a/include/variables.h b/include/variables.h index f2fd0f2b4..c6fb55982 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1670,7 +1670,7 @@ extern PadMgr* padmgrContext; // extern UNK_TYPE4 controllerInputsCaptured; // extern UNK_TYPE4 D_801D1538; extern UNK_PTR D_801D1540; -extern f32 D_801D1570[13]; +// extern f32 sFactorialTbl[13]; extern Vec3f D_801D15B0; extern Vec3s D_801D15BC; extern RSPMatrix D_801D1DE0; diff --git a/spec b/spec index 0754aca9c..6b028302d 100644 --- a/spec +++ b/spec @@ -633,7 +633,6 @@ beginseg include "build/src/code/sys_math.o" include "build/src/code/sys_math3d.o" include "build/data/code/sys_math3d.bss.o" - include "build/data/code/code_801D1570.data.o" include "build/data/code/code_801D15B0.data.o" include "build/src/code/sys_math_atan.o" include "build/src/code/sys_matrix.o" diff --git a/src/code/sys_math.c b/src/code/sys_math.c index 4142cd598..9b274c7e2 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -1,15 +1,93 @@ +/** + * Maths library: two factorials, integer power, wrappers for libultra's sins and coss (the main ones used), and some + * random functions moved from OoT's z_actor + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/func_80179300.s") +static f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f, + 5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/func_80179400.s") +// Rename to Math_FactorialF +/** + * Takes a float, returns the factorial of it(s trunctation), iteratively + * Unused + */ +f32 func_80179300(f32 n) { + f32 ret = 1.0f; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/pow_int.s") + //! @bug No check for negative argument. Will return 1.0f if the argument truncates to a negative int. + for (i = n; i > 1; i--) { + ret *= i; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/sin_rad.s") +// Rename to Math_Factorial +/** + * Takes an int and returns its factorial as a float. Uses the lookup table for n <= 12. + * Unused + */ +f32 func_80179400(s32 n) { + f32 ret; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/cos_rad.s") + //! @bug No check for negative argument. Will read the array out-of-bounds if the argument is negative. + //! (The OoT version does an unsigned check instead, which will return sFactorialTbl[12] for a negative argument.) + if (n > 12) { + ret = sFactorialTbl[12]; + for (i = 13; i <= n; i++) { + ret *= i; + } + } else { + ret = sFactorialTbl[n]; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/Rand_ZeroFloat.s") +// Rename to Math_PowF +/** + * Returns base^{exp} if exp is nonnegative and 1.0f otherwise. + * Unused + */ +f32 pow_int(f32 base, s32 exp) { + f32 ret = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/randPlusMinusPoint5Scaled.s") + while (exp > 0) { + exp--; + ret *= base; + } + + return ret; +} + +// Rename to Math_SinF +/** + * Takes an angle in radians and returns the sine. + */ +f32 sin_rad(f32 rad) { + return sins(RADF_TO_BINANG(rad)) * SHT_MINV; +} + +// Rename to Math_CosF +/** + * Takes an angle in radians and returns the cosine. + */ +f32 cos_rad(f32 rad) { + return coss(RADF_TO_BINANG(rad)) * SHT_MINV; +} + +/** + * Returns a pseudo-random floating-point number between 0.0f and scale. Originally in z_actor in OoT. + */ +f32 Rand_ZeroFloat(f32 scale) { + return Rand_ZeroOne() * scale; +} + +// Rename to Rand_CenteredFloat +/** + * Returns a pseudo-random floating-point number between (- scale / 2) and (scale / 2). Originally in z_actor in OoT. + */ +f32 randPlusMinusPoint5Scaled(f32 scale) { + return Rand_Centered() * scale; +} diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index c5af1c907..72d154d70 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -1,3 +1,70 @@ -#include "global.h" +#include "math.h" +#include "macros.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/cosf/__cosf.s") +// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 +// [https://mathworld.wolfram.com/MaclaurinSeries.html]. +// The commented versions do not match. +static const du P[] = { + { 1.0 }, // 1 + { -0.16666659550427756 }, // -1/3! = 1/6 + { 0.008333066246082155 }, // 1/5! = 1/120 + { -0.0001980960290193795 }, // -1/7! = -1/5040 + { 0.000002605780637968037 }, // 1/9! = 1/362880 +}; + +static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" + +static const du pihi = { 3.1415926218032837 }; + +static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi + +static const fu zero = { 0x00000000 }; + +/** + * Computes the cosine of a float, returning a float. It essentially computes sin(x+pi/2) by the same method as __sinf, + * without as many size checks. + */ +f32 __cosf(f32 x) { + f32 absx; + f64 dx; // x promoted to double + f64 xSq; // square of dx + f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 dn; // n promoted to double + s32 n; // number of multiples of pi away from the first half-period + f64 result; + s32 ix = *(s32*)&x; // Type-pun x into an s32, i.e. its IEEE-754 hex representation + s32 xpt = (ix >> 22); // Obtain the exponent of x (actually 2 * exponent + 127) + + xpt &= 0x1FF; // Remove the sign bit + + // |x| < 2^{28} (beyond this range, floats are too sparse to make the trig functions useable) + if (xpt < 310) { + absx = (x > 0) ? x : -x; + dx = absx; + + dn = dx * rpi.d + 0.5; + n = ROUND(dn); + dn = n; + + dn -= 0.5; + + dx -= dn * pihi.d; + dx -= dn * pilo.d; + + xSq = SQ(dx); + polyApprox = ((P[4].d * xSq + P[3].d) * xSq + P[2].d) * xSq + P[1].d; + result = dx + (dx * xSq) * polyApprox; // Actual Maclaurin polynomial for sin(x) + + if (n % 2 == 0) { + return (f32)result; + } + return -(f32)result; + } + + // if x is NaN + if (x != x) { + return __libm_qnan_f; + } + + return zero.f; +} diff --git a/src/libultra/gu/coss.c b/src/libultra/gu/coss.c index 466c36505..ebed28405 100644 --- a/src/libultra/gu/coss.c +++ b/src/libultra/gu/coss.c @@ -1,5 +1,8 @@ #include "global.h" -short coss(unsigned short x) { +/** + * Compute the sine of a hex angle and return a short, using the formula cos(x) = sin(x+pi). + */ +s16 coss(u16 x) { return sins(x + 0x4000); } diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index 01923221c..5f3455ec5 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -1,77 +1,79 @@ #include "math.h" +#include "macros.h" +// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 +// [https://mathworld.wolfram.com/MaclaurinSeries.html]. +// The commented versions do not match. static const du P[] = { - { 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 }, - { 0xBF29F6FF, 0xEEA56814 }, { 0x3EC5DBDF, 0x0E314BFE }, + { 1.0 }, // 1 + { -0.16666659550427756 }, // -1/3! = 1/6 + { 0.008333066246082155 }, // 1/5! = 1/120 + { -0.0001980960290193795 }, // -1/7! = -1/5040 + { 0.000002605780637968037 }, // 1/9! = 1/362880 }; -static const du rpi = { 0x3FD45F30, 0x6DC9C883 }; +static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" -static const du pihi = { 0x400921FB, 0x50000000 }; +static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 0x3E6110B4, 0x611A6263 }; +static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi static const fu zero = { 0x00000000 }; -extern float __libm_qnan_f; +/** + * Returns the sine of a float as a float, using the Maclaurin series and shifting. + */ +f32 __sinf(f32 x) { + f64 dx; // x promoted to double + f64 xSq; // square of dx + f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 dn; // n promoted to double + s32 n; // number of multiples of pi away from the first half-period + f64 result; + s32 ix = *(s32*)&x; // Type-pun x into an s32, i.e. its IEEE-754 hex representation + s32 xpt = (ix >> 22); // Obtain the exponent of x (actually 2 * exponent + 127) -float __sinf(float x) { - double dx; // double x - double xsq; // x squared - double poly; - double dn; - int n; - double result; - int ix; // int x - int xpt; - - ix = *(int*)&x; - xpt = (ix >> 22) & 0x1FF; + xpt &= 0x1FF; // Remove the sign bit + // |x| < 1 if (xpt < 255) { dx = x; + + // |x| > 2^{-12}: for x smaller in magnitude than this, sin(x) - x is too small for a float to register the + // error if (xpt >= 230) { - xsq = dx * dx; + xSq = SQ(dx); + polyApprox = ((P[4].d * xSq + P[3].d) * xSq + P[2].d) * xSq + P[1].d; - poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d; - - result = ((dx * xsq) * poly) + dx; - - return result; - } else { - return x; + result = dx + (dx * xSq) * polyApprox; + return (f32)result; } + return x; } + // |x| < 2^{28} (beyond this range, floats are too sparse to make the trig functions useable) if (xpt < 310) { dx = x; - dn = dx * rpi.d; - - if (dn >= 0) { - n = dn + 0.5; - } else { - n = dn - 0.5; - } - + n = ROUND(dn); dn = n; + // Bring x to the first half-period where the Maclaurin polynomial can be used dx -= dn * pihi.d; dx -= dn * pilo.d; - xsq = dx * dx; + xSq = SQ(dx); + polyApprox = ((P[4].d * xSq + P[3].d) * xSq + P[2].d) * xSq + P[1].d; + result = dx + (dx * xSq) * polyApprox; // Actual Maclaurin polynomial for sin(x) - poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d; - - result = ((dx * xsq) * poly) + dx; - - if ((n & 0x1) == 0) { - return result; - } else { - return -(float)result; + // add a minus sign if x is an odd number of multiples of pi away from the first half-period + if (n % 2 == 0) { + return (f32)result; } + return -(f32)result; } + // if x is NaN if (x != x) { return __libm_qnan_f; } diff --git a/src/libultra/gu/sins.c b/src/libultra/gu/sins.c index 6dd5f23fc..69b3b7e39 100644 --- a/src/libultra/gu/sins.c +++ b/src/libultra/gu/sins.c @@ -77,8 +77,12 @@ static s16 sintable[0x400] = { 0x7FFE, 0x7FFF, }; -short sins(unsigned short x) { - short val; +/** + * Compute the sine of a hex angle and return a short, using a lookup table for the first quadrant, extrapolating to the + * others using the equivalents of sin(pi-x) = sin(x) and sin(pi+x) = -sin(x). + */ +s16 sins(u16 x) { + s16 val; x >>= 4; if ((x & 0x400) != 0) { diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index c67e0b7a7..eb4be6eb3 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -561,7 +561,7 @@ 0x801D1520 : "graph", 0x801D1530 : "padmgr", 0x801D1540 : "speed_meter", - 0x801D1570 : "", + 0x801D1570 : "sys_math", 0x801D15B0 : "", 0x801D15D0 : "sys_math_atan", 0x801D1DE0 : "sys_matrix", From 1362615cc6bc264654f4efc619c98cf53723adf3 Mon Sep 17 00:00:00 2001 From: rylieb <31797144+rylieb@users.noreply.github.com> Date: Mon, 27 Sep 2021 15:41:36 -0600 Subject: [PATCH 04/86] Add ctags "tags" files to .gitignore for vim users (#328) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fbaba047c..e2078e841 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__/ CMakeLists.txt cmake-build-debug venv/ +tags # Project-specific ignores *.z64 From f642ed6eef04369fca72f106d87ff2c6f6475066 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Tue, 28 Sep 2021 01:07:09 +0100 Subject: [PATCH 05/86] boot_0x80086760 OK and documented (#288) * boot_80086760 OK, added fp header, resplit data * Some more documentation, data imported with unions * Sweep data under the rug * Move the fp header properly * Format * include/fp.h header guards Co-authored-by: Anghelo Carvajal * Engineer's review * Fix typo Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Rename header * while (true) Co-authored-by: Anghelo Carvajal Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/fixed_point.h | 34 ++++++ spec | 2 +- src/boot_O2/boot_80086760.c | 209 +++++++++++++++++++++++++++++++++--- tools/disasm/files.txt | 1 + tools/disasm/variables.txt | 4 +- 5 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 include/fixed_point.h diff --git a/include/fixed_point.h b/include/fixed_point.h new file mode 100644 index 000000000..bb7e96494 --- /dev/null +++ b/include/fixed_point.h @@ -0,0 +1,34 @@ +#ifndef FIXED_POINT_H +#define FIXED_POINT_H +#include "ultra64.h" + +extern f32 qNaN0x3FFFFF; +extern f32 qNaN0x10000; +extern f32 sNaN0x3FFFFF; + +f32 floorf(f32 x); +f64 floor(f64 x); +s32 lfloorf(f32 x); +s32 lfloor(f64 x); + +f32 ceilf(f32 x); +f64 ceil(f64 x); +s32 lceilf(f32 x); +s32 lceil(f64 x); + +f32 truncf(f32 x); +f64 trunc(f64 x); +s32 ltruncf(f32 x); +s32 ltrunc(f64 x); + +f32 nearbyintf(f32 x); +f64 nearbyint(f64 x); +s32 lnearbyintf(f32 x); +s32 lnearbyint(f64 x); + +f32 roundf(f32 x); +f64 round(f64 x); +s32 lroundf(f32 x); +s32 lround(f64 x); + +#endif diff --git a/spec b/spec index 6b028302d..41c7d61f8 100644 --- a/spec +++ b/spec @@ -43,8 +43,8 @@ beginseg include "build/data/boot/boot_800862E0.data.o" include "build/src/boot_O2/padsetup.o" include "build/src/boot_O2/boot_80086760.o" - include "build/data/boot/boot_80086760.bss.o" include "build/asm/boot/fp.text.o" + include "build/data/boot/fp.data.o" include "build/src/boot_O2/system_malloc.o" include "build/src/boot_O2/rand.o" include "build/src/boot_O2/__osMalloc.o" diff --git a/src/boot_O2/boot_80086760.c b/src/boot_O2/boot_80086760.c index b68013370..1a9b37453 100644 --- a/src/boot_O2/boot_80086760.c +++ b/src/boot_O2/boot_80086760.c @@ -1,27 +1,210 @@ +/** + * MathF library + * Contains tangent function, wrappers for a number of the handwritten functions in fp, and a suite of arctangents + */ #include "global.h" +#include "fixed_point.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086760.s") +extern f32 func_80086C70(f32 x); +extern f32 func_80086CA8(f32 x); +extern f32 func_80086D50(f32 x); +extern f32 func_80086CE0(f32 x); +extern f32 func_80086D18(f32 x); -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086794.s") +s32 gUseAtanContFrac; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_800867B4.s") +/** + * Tangent function computed using libultra __sinf and __cosf + */ +// Math_FTanF +f32 func_80086760(f32 x) { + return __sinf(x) / __cosf(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_800867D4.s") +// Unused +// Math_FFloorF +f32 func_80086794(f32 x) { + func_80086C70(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_800867F4.s") +// Unused +// Math_FCeilF +f32 func_800867B4(f32 x) { + func_80086CA8(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086814.s") +// Unused +// Math_FRoundF +f32 func_800867D4(f32 x) { + func_80086D50(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086834.s") +// Unused +// Math_FTruncF +f32 func_800867F4(f32 x) { + func_80086CE0(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086880.s") +// Math_FNearbyIntF +f32 func_80086814(f32 x) { + func_80086D18(x); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_800869A4.s") +/** + * Arctangent approximation using a Maclaurin series [https://mathworld.wolfram.com/MaclaurinSeries.html] + * (one quadrant, i.e. |x| < 1) + */ +// Math_FAtanTaylorQF +f32 func_80086834(f32 x) { + // Coefficients of Maclaurin series of arctangent + static const f32 coeffs[] = { + -1.0f / 3, +1.0f / 5, -1.0f / 7, +1.0f / 9, -1.0f / 11, +1.0f / 13, -1.0f / 15, +1.0f / 17, 0.0f, + }; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086AF0.s") + f32 poly = x; + f32 sq = SQ(x); + f32 exp = x * sq; + const f32* c = coeffs; + f32 term; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086B30.s") + // Calculate the series until adding more terms does not change the float + while (true) { + term = *c++ * exp; + if (poly + term == poly) { + break; + } + poly += term; + exp *= sq; + } -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086C18.s") + return poly; +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_80086760/func_80086C48.s") +/** + * Extends previous arctangent function to the rest of the real numbers. + * Uses the formulae arctan(x) = pi/2 - arctan(1/x) + * and arctan(x) = pi/4 - arctan( (1-x)/(1+x) ) + * to extend the range in which the series computed by func_80086834 is a good approximation + */ +// Math_FAtanTaylorF +f32 func_80086880(f32 x) { + f32 t; + f32 q; + + if (x > 0.0f) { + t = x; + } else if (x < 0.0f) { + t = -x; + } else if (x == 0.0f) { + return 0.0f; + } else { + return qNaN0x10000; + } + + if (t <= M_SQRT2 - 1.0f) { + return func_80086834(x); + } + + if (t >= M_SQRT2 + 1.0f) { + q = M_PI / 2 - func_80086834(1.0f / t); + } else { // in the interval (\sqrt{2} - 1, \sqrt{2} + 1) + q = M_PI / 4 - func_80086834((1.0f - t) / (1.0f + t)); + } + + if (x > 0.0f) { + return q; + } else { + return -q; + } +} + +/** + * Arctangent approximation using a continued fraction + * Cf. https://en.wikipedia.org/wiki/Gauss%27s_continued_fraction#The_series_2F1_2 , + * https://dlmf.nist.gov/4.25#E4 + */ +// Math_FAtanContFracF +f32 func_800869A4(f32 x) { + s32 sector; + f32 z; + f32 conv; + f32 sq; + s32 i; + + if (x >= -1.0f && x <= 1.0f) { + sector = 0; + } else if (x > 1.0f) { + sector = 1; + x = 1.0f / x; + } else if (x < -1.0f) { + sector = -1; + x = 1.0f / x; + } else { + return qNaN0x10000; + } + + // Builds the continued fraction from the innermost fraction out + sq = SQ(x); + conv = 0.0f; + z = 8.0f; + for (i = 8; i != 0; i--) { + conv = SQ(z) * sq / (2.0f * z + 1.0f + conv); + z -= 1.0f; + } + conv = x / (1.0f + conv); + + if (sector == 0) { + return conv; + } else if (sector > 0) { + return M_PI / 2 - conv; + } else { + return -M_PI / 2 - conv; + } +} + +// Math_FAtanF +/** + * Single-argument arctangent, only used by the two-argument function. + * Nothing else sets the bss variable gUseAtanContFrac, so the Maclaurin series is always used + */ +f32 func_80086AF0(f32 x) { + if (!gUseAtanContFrac) { + return func_80086880(x); + } else { + return func_800869A4(x); + } +} + +// Math_FAtan2F +/** + * Main two-argument arctangent function + */ +f32 func_80086B30(f32 y, f32 x) { + if (x == 0.0f) { + if (y == 0.0f) { + return 0.0f; + } else if (y > 0.0f) { + return M_PI / 2; + } else if (y < 0.0f) { + return -M_PI / 2; + } else { + return qNaN0x10000; + } + } else if (x >= 0.0f) { + return func_80086AF0(y / x); + } else if (y < 0.0f) { + return func_80086AF0(y / x) - M_PI; + } else { + return M_PI - func_80086AF0(-(y / x)); + } +} + +// Math_FAsinF +f32 func_80086C18(f32 x) { + return func_80086B30(x, sqrtf(1.0f - SQ(x))); +} + +// Math_FAcosF +f32 func_80086C48(f32 x) { + return M_PI / 2 - func_80086C18(x); +} diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index eb4be6eb3..ed536b318 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -257,6 +257,7 @@ 0x80096C40 : "stackcheck", 0x80096C50 : "gfxprint", 0x80097500 : "boot_800862E0", + 0x80097520 : "fp", 0x80097530 : "rand", 0x80097540 : "vimodeHpf", 0x800975E0 : "sins", diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 91bfbab47..cc79d6fe8 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -36,7 +36,9 @@ 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), 0x80097500:("D_80097500","UNK_TYPE4","",0x4), - 0x80097524:("D_80097524","UNK_TYPE4","",0x4), + 0x80097520:("qNaN0x3FFFFF","f32","",0x4), + 0x80097524:("qNaN0x10000","f32","",0x4), + 0x80097528:("sNaN0x3FFFFF","f32","",0x4), 0x80097530:("sRandInt","u32","",0x4), 0x80097540:("osViModeNtscHpf1","OSViMode","",0x50), 0x80097590:("osViModePalLan1","OSViMode","",0x50), From de4cf63f63109519d1ec876cb7217422ee244d09 Mon Sep 17 00:00:00 2001 From: emilybrooks Date: Mon, 27 Sep 2021 17:21:08 -0700 Subject: [PATCH 06/86] obj_aqua OK (#321) * setup * almost done * only 3 floating point registers swapped * forgot newline * Audio_PlaySoundAtPosition * review suggestions * missed a hex number * matched func_80ACBDFC --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 279 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h | 8 +- 4 files changed, 256 insertions(+), 36 deletions(-) diff --git a/include/functions.h b/include/functions.h index aba291a28..cc6513381 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1108,7 +1108,7 @@ u32 func_800C9D8C(CollisionContext* param_1, CollisionPoly* param_2, s32 param_3 u32 func_800C9E18(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9E40(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); u32 func_800C9E88(CollisionContext* colCtx, CollisionPoly* polygon, s32 index); -// void func_800C9EBC(GlobalContext* globalCtx, CollisionContext* colCtx, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 func_800C9EBC(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); s32 func_800CA1AC(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); s32 func_800CA1E8(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); // void func_800CA22C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); diff --git a/spec b/spec index 41c7d61f8..6c9cb749c 100644 --- a/spec +++ b/spec @@ -3584,8 +3584,7 @@ beginseg name "ovl_Obj_Aqua" compress include "build/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.o" - include "build/data/ovl_Obj_Aqua/ovl_Obj_Aqua.data.o" - include "build/data/ovl_Obj_Aqua/ovl_Obj_Aqua.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Aqua/ovl_Obj_Aqua_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index f0ea044c8..5c0aa5cb1 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_aqua.c + * Overlay: ovl_Obj_Aqua + * Description: Water poured out of a bottle + */ + #include "z_obj_aqua.h" #define FLAGS 0x00000010 @@ -9,11 +15,14 @@ void ObjAqua_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx); void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80ACBC70(ObjAqua* this); +void func_80ACBDCC(ObjAqua* this); void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx); void func_80ACBD48(ObjAqua* this, GlobalContext* globalCtx); void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx); -#if 0 +void func_80ACBD34(ObjAqua* this); + const ActorInit Obj_Aqua_InitVars = { ACTOR_OBJ_AQUA, ACTORCAT_ITEMACTION, @@ -26,55 +35,263 @@ const ActorInit Obj_Aqua_InitVars = { (ActorFunc)ObjAqua_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ACC2C0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { 6, 10, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACC2EC[] = { - ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), - ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +Vec3f D_80ACC308 = { 1.0f / 1000.0f, 7.0f / 10000.0f, 1.0f / 1000.0f }; +Vec3f D_80ACC314 = { 8.6f / 1000.0f, 8.0f / 10000.0f, 8.6f / 1000.0f }; +Vec3f D_80ACC320 = { 1.0f / 100.0f, 2.6f / 1000.0f, 1.0f / 100.0f }; -extern ColliderCylinderInit D_80ACC2C0; -extern InitChainEntry D_80ACC2EC[]; +extern Gfx D_0407D590[]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACB6A0.s") +void func_80ACB6A0(ObjAqua* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp58; + s32 angleOffset = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACB7F4.s") + sp58.y = this->actor.world.pos.y + this->actor.yDistToWater; + for (i = 0; i < 4; i++) { + sp58.x = this->actor.world.pos.x + Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; + sp58.z = this->actor.world.pos.z + Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 120); + angleOffset += 0x4000; + } + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACB940.s") +void func_80ACB7F4(ObjAqua* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f effectPos; + s32 angleOffset = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBA10.s") + effectPos.y = this->actor.floorHeight; + for (i = 0; i < 4; i++) { + effectPos.x = (this->actor.world.pos.x + Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f); + effectPos.z = (this->actor.world.pos.z + Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f); + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 0, 120); + angleOffset += 0x4000; + } + effectPos.x = this->actor.world.pos.x; + effectPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &effectPos, NULL, NULL, 0, 300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBA60.s") +void func_80ACB940(ObjAqua* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f effectPos; + Vec3f effectVel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/ObjAqua_Init.s") + effectVel.x = Rand_ZeroOne() - 0.5f; + effectVel.y = 2.0f; + effectVel.z = Rand_ZeroOne() - 0.5f; + effectPos.x = this->actor.world.pos.x + (effectVel.x * 40.0f); + effectPos.y = this->actor.world.pos.y; + effectPos.z = this->actor.world.pos.z + (effectVel.z * 40.0f); + EffectSsIceSmoke_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, (s32)(Rand_ZeroOne() * 24.0f) + 70); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/ObjAqua_Destroy.s") +void func_80ACBA10(ObjAqua* this) { + s32 pad; + MtxF sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBC70.s") + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &sp2C); + func_8018219C(&sp2C, &this->actor.shape.rot, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBC8C.s") +s32 func_80ACBA60(ObjAqua* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* waterBox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBD34.s") + if (func_800C9EBC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &waterBox, &bgId) && + (this->actor.world.pos.y < ySurface)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBD48.s") +void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjAqua* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBDCC.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.scale.x = 0.0009f; + this->actor.scale.y = 0.0005f; + this->actor.scale.z = 0.0009f; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); + if (1) {}; + this->actor.shape.shadowAlpha = 140; + this->alpha = 255; + if (func_80ACBA60(this, globalCtx)) { + for (i = 0; i < 8; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -4.0f, 4.0f, 4.0f, + (Rand_ZeroOne() * 0.09f) + 0.03f); + } + func_80ACBDCC(this); + } else { + func_80ACBC70(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/func_80ACBDFC.s") +void ObjAqua_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjAqua* this = THIS; + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/ObjAqua_Update.s") +void func_80ACBC70(ObjAqua* this) { + this->counter = 200; + this->actionFunc = func_80ACBC8C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Aqua/ObjAqua_Draw.s") +void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 0x21) { + if (this->actor.bgCheckFlags & 1) { + func_80ACB7F4(this, globalCtx); + func_80ACBA10(this); + Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOTTLE_WATERING); + func_80ACBD34(this); + } else { + func_80ACB6A0(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); + Actor_MarkForDeath(&this->actor); + } + } else if (this->counter <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80ACBD34(ObjAqua* this) { + this->actionFunc = func_80ACBD48; +} + +void func_80ACBD48(ObjAqua* this, GlobalContext* globalCtx) { + if ((AQUA_HOT(&this->actor) == 1) && (this->alpha > 90)) { + func_80ACB940(this, globalCtx); + } + if (this->alpha > 5) { + this->alpha -= 5; + } else { + this->alpha = 0; + } + if (this->actor.shape.shadowAlpha > 2) { + this->actor.shape.shadowAlpha -= 2; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80ACBDCC(ObjAqua* this) { + this->actor.gravity = -0.1f; + this->counter = 40; + this->alpha = 140; + this->actionFunc = func_80ACBDFC; +} + +void func_80ACBDFC(ObjAqua* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp = this->counter; + + this->alpha = (s32)(temp * 3.25f) + 10; + this->actor.shape.shadowAlpha = this->alpha; + this->unk_198 += 1000; + if (AQUA_HOT(&this->actor) == 1) { + f32 temp_f2 = this->actor.scale.x * 10000.0f; + + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, temp_f2 * -0.5f, temp_f2, temp_f2, + (Rand_ZeroOne() * 0.1f) + 0.03f); + } + if (this->counter <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjAqua* this = THIS; + s32 pad; + + if (this->counter > 0) { + this->counter--; + } + this->actionFunc(this, globalCtx); + if (this->actor.update) { + if (this->actionFunc == func_80ACBC8C) { + Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC308, 0.00006f); + } else if (this->actionFunc == func_80ACBD48) { + Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC314, 0.00095f); + } else { + Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC320, 0.0004f); + } + this->actor.velocity.y *= 0.9f; + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 4.0f, 0.0f, 5); + if (this->actionFunc != func_80ACBDFC) { + Collider_UpdateCylinder(&this->actor, &this->collider); + this->collider.dim.radius = this->actor.scale.x * 3000.0f; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjAqua* this = THIS; + s32 framesTemp; + s32 pad; + s16 yaw = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + framesTemp = ((globalCtx->gameplayFrames & 0x7FFFFFFF) * -0xA) & 0x1FF; + if (actionFuncTemp) { + framesTemp >>= 1; + } + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, framesTemp, 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 0); + if (actionFuncTemp) { + s16 rotation = Math_SinS(this->unk_198) * 8000.0f; + + SysMatrix_InsertZRotation_s(rotation, 1); + Matrix_Scale(1.3f, 1.0f, 1.0f, 1); + SysMatrix_InsertZRotation_s(rotation * -1, 1); + Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, 1); + } + Matrix_RotateY(yaw, 1); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h index dec966f0a..0c8bdc714 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h @@ -3,15 +3,19 @@ #include "global.h" +#define AQUA_HOT(thisx) ((thisx)->params & 1) + struct ObjAqua; typedef void (*ObjAquaActionFunc)(struct ObjAqua*, GlobalContext*); typedef struct ObjAqua { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ ObjAquaActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x8]; + /* 0x0194 */ s16 counter; + /* 0x0196 */ u8 alpha; + /* 0x0198 */ s16 unk_198; } ObjAqua; // size = 0x19C extern const ActorInit Obj_Aqua_InitVars; From a6d26c82f23c6176c4f32fe0351425829d3ca01e Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Tue, 28 Sep 2021 02:00:55 +0100 Subject: [PATCH 07/86] afterprenmi.c OK (#297) --- src/libultra/os/afterprenmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libultra/os/afterprenmi.c b/src/libultra/os/afterprenmi.c index 4c61fe0bf..b59814763 100644 --- a/src/libultra/os/afterprenmi.c +++ b/src/libultra/os/afterprenmi.c @@ -1,3 +1,6 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/afterprenmi/osAfterPreNMI.s") +s32 osAfterPreNMI(void) { + return __osSpSetPc(0); +} From 14ad66b4ed6079872fc4c546007a150ae658f3aa Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Tue, 28 Sep 2021 02:29:30 +0100 Subject: [PATCH 08/86] `ovl_title` OK (#311) * OK, asset XML made and symbols imported * Missed a GLOBAL_ASM * Remove data from spec * engineer's review * Correct arg * Un-format functions.h * Hopefully fix it --- assets/xml/static/nintendo_rogo_static.xml | 8 + include/functions.h | 28 +-- spec | 6 +- src/overlays/gamestates/ovl_title/z_title.c | 178 +++++++++++++++++++- src/overlays/gamestates/ovl_title/z_title.h | 21 ++- 5 files changed, 204 insertions(+), 37 deletions(-) create mode 100644 assets/xml/static/nintendo_rogo_static.xml diff --git a/assets/xml/static/nintendo_rogo_static.xml b/assets/xml/static/nintendo_rogo_static.xml new file mode 100644 index 000000000..ff6fc56fc --- /dev/null +++ b/assets/xml/static/nintendo_rogo_static.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/include/functions.h b/include/functions.h index cc6513381..e9a0074da 100644 --- a/include/functions.h +++ b/include/functions.h @@ -789,7 +789,7 @@ void func_800B75A0(CollisionPoly* param_1, Vec3f* param_2, s16* param_3); // UNK_TYPE4 func_800B7678(GlobalContext* globalCtx, Actor* param_2, s32 param_3, u32 param_4); void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); // void func_800B7E04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -s32 func_800B7FE0(f32* param_1, f32* param_2, f32* param_3, GraphicsContext* gfxCtx); +Hilite* func_800B7FE0(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); // void func_800B8018(void); void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 iParm3); void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 iParm3); @@ -1775,7 +1775,7 @@ void func_800FB320(GlobalContext* globalCtx, u8 param_2); void func_800FBF3C(GlobalContext* globalCtx); // void func_800FC158(void); // void func_800FC3DC(void); -// void func_800FC444(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6); +void func_800FC444(GraphicsContext* gfxCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4, UNK_TYPE arg5); // void func_800FC64C(void); // void func_800FD2B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); @@ -2831,8 +2831,8 @@ void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); // void func_80146628(void); // void func_80146AA0(void); // void func_80146DF8(void); -// void func_80146E40(void); -void Sram_Alloc(GameState* gamestate, SramContext* iParm2); +void func_80146E40(GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(GameState* gamestate, SramContext* sramCtx); // void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); // void func_80146EE8(void); // void func_80146F5C(void); @@ -2918,18 +2918,18 @@ void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_80160B40(void); // void func_80160B80(void); // void func_80160BC0(void); -void ShrinkWindow_SetLetterboxTarget(s8 target); -// s32 ShrinkWindow_GetLetterboxTarget(void); -void ShrinkWindow_SetLetterboxMagnitude(s8 magnitude); +void ShrinkWindow_SetLetterboxTarget(s32 target); +s32 ShrinkWindow_GetLetterboxTarget(void); +void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); s32 ShrinkWindow_GetLetterboxMagnitude(void); -void ShrinkWindow_SetPillarboxTarget(s8 target); -// s32 ShrinkWindow_GetPillarboxTarget(void); -void ShrinkWindow_SetPillarboxMagnitude(u8 magnitude); -// s32 ShrinkWindow_GetPillarboxMagnitude(void); -// void ShrinkWindow_Init(void); +void ShrinkWindow_SetPillarboxTarget(s32 target); +s32 ShrinkWindow_GetPillarboxTarget(void); +void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude); +s32 ShrinkWindow_GetPillarboxMagnitude(void); +void ShrinkWindow_Init(void); void ShrinkWindow_Fini(void); void ShrinkWindow_Step(s32 framerateDivisor); -void ShrinkWindow_Draw(GlobalContext* globalCtx); +void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); // void func_8016119C(void); // void func_8016122C(void); @@ -3186,7 +3186,7 @@ void func_80174AA0(ListAlloc* alloc); // void func_80174B20(void); void func_80174BA0(ListAlloc* alloc); void Main(void* arg); -// u32 Padmgr_GetControllerBitmask(void); +u32 Padmgr_GetControllerBitmask(void); // void func_80174F24(void); // void func_80174F44(void); // void func_80174F7C(void); diff --git a/spec b/spec index 6c9cb749c..0eb4cdf1f 100644 --- a/spec +++ b/spec @@ -697,8 +697,7 @@ beginseg compress address 0x80800000 include "build/src/overlays/gamestates/ovl_title/z_title.o" - include "build/data/ovl_title/ovl_title.data.o" - include "build/data/ovl_title/ovl_title.reloc.o" + include "build/src/overlays/gamestates/ovl_title/ovl_title_reloc.o" endseg beginseg @@ -8881,7 +8880,8 @@ beginseg name "nintendo_rogo_static" compress romalign 0x1000 - include "build/baserom/nintendo_rogo_static.o" + include "build/assets/static/nintendo_rogo_static/nintendo_rogo_static.o" + number 1 endseg beginseg diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 0d67be592..83e3f487a 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -1,22 +1,182 @@ /* * File: z_title.c * Overlay: ovl_title - * Description: + * Description: Nintendo 64 logo shown on startup */ #include "z_title.h" +#include "overlays/gamestates/ovl_opening/z_opening.h" +#include "static/nintendo_rogo_static/nintendo_rogo_static.h" -extern UNK_TYPE D_01002720; +void Title_UpdateCounters(TitleContext* this) { + if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) { + this->timer--; + this->visibleDuration--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_UpdateCounters.s") + if (this->timer == 0) { + this->timer = 400; + } + } else { + this->coverAlpha += this->addAlpha; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_RenderView.s") + if (this->coverAlpha <= 0) { + this->coverAlpha = 0; + this->addAlpha = 12; + } else if (this->coverAlpha >= 255) { + this->coverAlpha = 255; + this->exit = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_Draw.s") + this->uls = this->ult & 0x7F; + this->ult++; +} -void Title_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_Main.s") +void Title_RenderView(TitleContext* this, f32 x, f32 y, f32 z) { + View* view = &this->view; + Vec3f eye; + Vec3f at; + Vec3f up; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_Destroy.s") + eye.x = x; + eye.y = y; + eye.z = z; + up.x = up.z = 0.0f; + at.x = at.y = at.z = 0.0f; + up.y = 1.0f; + func_8013F0D0(view, 30.0f, 10.0f, 12800.0f); + View_SetViewOrientation(view, &eye, &at, &up); + View_RenderView(view, 0xF); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_title/Title_Init.s") +void Title_Draw(GameState* thisx) { + static s16 titleRotation = 0; + static Lights1 sTitleLights = gdSPDefLights1(100, 100, 100, 255, 255, 255, 69, 69, 69); + TitleContext* this = (TitleContext*)thisx; + u16 y; + u16 idx; + Vec3f lightDir; + Vec3f object; + Vec3f eye; + s32 pad[2]; + + OPEN_DISPS(this->gameState.gfxCtx); + + lightDir.x = 69.0f; + lightDir.y = 69.0f; + lightDir.z = 69.0f; + + object.x = 0.0f; + object.y = 0.0f; + object.z = 0.0f; + + eye.x = -4949.148f; + eye.y = 4002.5417f; + eye.z = 1119.0837f; + + func_800B7FE0(&object, &eye, &lightDir, this->gameState.gfxCtx); + + gSPSetLights1(POLY_OPA_DISP++, sTitleLights); + + Title_RenderView(this, 0.0f, 150.0f, 300.0f); + func_8012C28C(this->gameState.gfxCtx); + SysMatrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + SysMatrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); + + func_8012C628(this->gameState.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF2, G_RM_OPA_CI | CVG_DST_WRAP); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, PRIMITIVE, ENV_ALPHA, TEXEL0, 0, 0, 0, TEXEL0, PRIMITIVE, ENVIRONMENT, + COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 170, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 255, 128); + gDPLoadMultiBlock(POLY_OPA_DISP++, gNintendo64LogoTextShineTex, 0x100, 1, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, 2, 11); + + for (idx = 0, y = 94; idx < 16; idx++, y += 2) { + gDPLoadTextureBlock(POLY_OPA_DISP++, &((u8*)gNintendo64LogoTextTex)[0x180 * idx], G_IM_FMT_I, G_IM_SIZ_8b, 192, + 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + gDPSetTileSize(POLY_OPA_DISP++, 1, this->uls, (this->ult & 0x7F) - idx * 4, 0, 0); + gSPTextureRectangle(POLY_OPA_DISP++, 388, y << 2, 1156, (y + 2) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + + func_800FC444(this->gameState.gfxCtx, 0, 0, 0, this->coverAlpha, 2); + + titleRotation += 300; + + CLOSE_DISPS(this->gameState.gfxCtx); +} + +void Title_Main(GameState* thisx) { + TitleContext* this = (TitleContext*)thisx; + + func_8012CF0C(this->gameState.gfxCtx, 1, 1, 0, 0, 0); + + OPEN_DISPS(this->gameState.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); + + Title_UpdateCounters(this); + Title_Draw(&this->gameState); + if (this->exit) { + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.gameMode = 1; + + { + GameState* gameState = &this->gameState; + gameState->running = false; + } + SET_NEXT_GAMESTATE(&this->gameState, Opening_Init, OpeningContext); + } + + CLOSE_DISPS(this->gameState.gfxCtx); +} + +void Title_Destroy(GameState* thisx) { + TitleContext* this = (TitleContext*)thisx; + + func_80146E40(&this->gameState, &this->sramCtx); + ShrinkWindow_Fini(); + CIC6105_Nop80081828(); +} + +void Title_Init(GameState* thisx) { + TitleContext* this = (TitleContext*)thisx; + uintptr_t segmentSize = + (uintptr_t)_nintendo_rogo_staticSegmentRomEnd - (uintptr_t)_nintendo_rogo_staticSegmentRomStart; + + this->staticSegment = THA_AllocEndAlign16(&this->gameState.heap, segmentSize); + DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); + + Game_SetFramerateDivisor(thisx, 1); + SysMatrix_StateAlloc(thisx); + ShrinkWindow_Init(); + View_Init(&this->view, thisx->gfxCtx); + + thisx->main = Title_Main; + thisx->destroy = Title_Destroy; + this->exit = false; + + if (!(Padmgr_GetControllerBitmask() & 1)) { + gSaveContext.fileNum = 0xFEDC; + } else { + gSaveContext.fileNum = 0xFF; + } + + gSaveContext.unk_3F3F = 1; + Sram_Alloc(thisx, &this->sramCtx); + this->ult = 0; + this->timer = 20; + this->coverAlpha = 255; + this->addAlpha = -12; + this->visibleDuration = 60; +} diff --git a/src/overlays/gamestates/ovl_title/z_title.h b/src/overlays/gamestates/ovl_title/z_title.h index a3005f004..7f2f34425 100644 --- a/src/overlays/gamestates/ovl_title/z_title.h +++ b/src/overlays/gamestates/ovl_title/z_title.h @@ -1,5 +1,5 @@ -#ifndef _Z64_TITLE_H_ -#define _Z64_TITLE_H_ +#ifndef Z64_TITLE_H +#define Z64_TITLE_H #include "global.h" @@ -7,18 +7,17 @@ void Title_Init(GameState* thisx); void Title_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState state; + /* 0x000 */ GameState gameState; /* 0x0A4 */ u8* staticSegment; /* 0x0A8 */ View view; /* 0x210 */ SramContext sramCtx; - /* 0x238 */ s16 mode; - /* 0x23A */ s16 timer; - /* 0x23C */ s16 coverAlpha; - /* 0x23E */ s16 addAlpha; - /* 0x240 */ s16 visibleDuration; - /* 0x242 */ s16 ult; - /* 0x244 */ s16 uls; - /* 0x246 */ u8 exit; + /* 0x238 */ s16 timer; + /* 0x23A */ s16 coverAlpha; + /* 0x23C */ s16 addAlpha; + /* 0x23E */ s16 visibleDuration; + /* 0x240 */ s16 ult; + /* 0x242 */ s16 uls; + /* 0x244 */ u8 exit; } TitleContext; // size = 0x248 #endif From 27e41b73a82b5881fe2e901c7bd636671c903c3b Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 28 Sep 2021 03:17:28 +0100 Subject: [PATCH 09/86] En_Rd (#316) * En_Rd * PR * a --- include/functions.h | 4 +- spec | 3 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 1209 +++++++++++++++++++++-- src/overlays/actors/ovl_En_Rd/z_en_rd.h | 46 +- tools/disasm/functions.txt | 4 +- 5 files changed, 1184 insertions(+), 82 deletions(-) diff --git a/include/functions.h b/include/functions.h index e9a0074da..ecc2df884 100644 --- a/include/functions.h +++ b/include/functions.h @@ -887,13 +887,13 @@ Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2); // void func_800BC4EC(void); // void func_800BC5B8(void); s32 func_800BC5EC(GlobalContext* globalCtx, Actor* actor); -void func_800BC620(Vec3f* arg0, Vec3f* arg1, UNK_TYPE arg2, GlobalContext* globalCtx); +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 arg2, GlobalContext* globalCtx); // void func_800BC770(void); // void func_800BC7D8(void); // void func_800BC848(void); // void func_800BC8B8(void); // void func_800BCB50(void); -void func_800BCB70(Actor* actor, s16 arg1, s16 arg2, s16 arg3, s16 arg4); +void func_800BCB70(Actor* actor, u16 arg1, u16 arg2, s16 arg3, s16 arg4); void func_800BCBF4(Vec3f* uParm1, GlobalContext* globalCtx); void func_800BCC68(Vec3f* param_1, GlobalContext* globalCtx); UNK_RET func_800BCCDC(Vec3s* points, u8 pathcount, Vec3f* pos1, Vec3f* pos2, UNK_TYPE parm5); diff --git a/spec b/spec index 0eb4cdf1f..20a380cad 100644 --- a/spec +++ b/spec @@ -1182,8 +1182,7 @@ beginseg name "ovl_En_Rd" compress include "build/src/overlays/actors/ovl_En_Rd/z_en_rd.o" - include "build/data/ovl_En_Rd/ovl_En_Rd.data.o" - include "build/data/ovl_En_Rd/ovl_En_Rd.reloc.o" + include "build/src/overlays/actors/ovl_En_Rd/ovl_En_Rd_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index e0cb90c26..0e58c9029 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rd.c + * Overlay: ovl_En_Rd + * Description: Redead / Gibdo + */ + #include "z_en_rd.h" #define FLAGS 0x00000415 @@ -9,27 +15,57 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_808D41FC(GlobalContext* globalCtx); +void func_808D4308(EnRd* this); void func_808D43AC(EnRd* this, GlobalContext* globalCtx); +void func_808D45D4(EnRd* this); void func_808D4660(EnRd* this, GlobalContext* globalCtx); +void func_808D47DC(EnRd* this); void func_808D4868(EnRd* this, GlobalContext* globalCtx); void func_808D49E4(EnRd* this, GlobalContext* globalCtx); +void func_808D4A90(EnRd* this); void func_808D4B20(EnRd* this, GlobalContext* globalCtx); void func_808D4CA8(EnRd* this, GlobalContext* globalCtx); +void func_808D4DC4(EnRd* this); void func_808D4E60(EnRd* this, GlobalContext* globalCtx); void func_808D506C(EnRd* this, GlobalContext* globalCtx); +void func_808D53C0(EnRd* this, GlobalContext* globalCtx); void func_808D5440(EnRd* this, GlobalContext* globalCtx); +void func_808D5660(EnRd* this); void func_808D56E4(EnRd* this, GlobalContext* globalCtx); +void func_808D586C(EnRd* this); void func_808D58CC(EnRd* this, GlobalContext* globalCtx); +void func_808D5C54(EnRd* this); void func_808D5CCC(EnRd* this, GlobalContext* globalCtx); +void func_808D5D88(EnRd* this); void func_808D5DF4(EnRd* this, GlobalContext* globalCtx); +void func_808D5E98(EnRd* this); void func_808D5F18(EnRd* this, GlobalContext* globalCtx); +void func_808D6008(EnRd* this); void func_808D6054(EnRd* this, GlobalContext* globalCtx); +void func_808D60B0(EnRd* this); void func_808D6130(EnRd* this, GlobalContext* globalCtx); void func_808D6200(EnRd* this, GlobalContext* globalCtx); void func_808D6388(EnRd* this, GlobalContext* globalCtx); void func_808D65BC(EnRd* this, GlobalContext* globalCtx); -#if 0 +extern FlexSkeletonHeader D_060053E8; +extern AnimationHeader D_06006678; +extern AnimationHeader D_06006B08; +extern AnimationHeader D_06006EEC; +extern AnimationHeader D_060073A4; +extern AnimationHeader D_06007BBC; +extern AnimationHeader D_060081A8; +extern AnimationHeader D_06009298; +extern AnimationHeader D_06009900; +extern AnimationHeader D_0600A450; +extern AnimationHeader D_0600ABE0; +extern FlexSkeletonHeader D_06010B88; +extern AnimationHeader D_060113EC; +extern AnimationHeader D_060118D8; +extern AnimationHeader D_06011DB8; +extern AnimationHeader D_0601216C; + const ActorInit En_Rd_InitVars = { ACTOR_EN_RD, ACTORCAT_ENEMY, @@ -42,15 +78,27 @@ const ActorInit En_Rd_InitVars = { (ActorFunc)EnRd_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808D70E0 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7EFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7EFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 70, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808D710C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(2, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -85,126 +133,1139 @@ static DamageTable D_808D710C = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D712C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), }; -#endif +void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRd* this = THIS; + s32 pad; -extern ColliderCylinderInit D_808D70E0; -extern DamageTable D_808D710C; -extern InitChainEntry D_808D712C[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.targetMode = 0; + this->actor.colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->unk_3DA = this->unk_3D8 = 0; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 8; + this->unk_3DE = 255; + this->unk_3F1 = -1; + this->unk_3DC = ENRD_GET_FF00(thisx); -extern UNK_TYPE D_06006678; -extern UNK_TYPE D_06006EEC; -extern UNK_TYPE D_060073A4; -extern UNK_TYPE D_060081A8; -extern UNK_TYPE D_06009298; -extern UNK_TYPE D_06009900; -extern UNK_TYPE D_0600A450; -extern UNK_TYPE D_0600ABE0; -extern UNK_TYPE D_060113EC; -extern UNK_TYPE D_060118D8; -extern UNK_TYPE D_06011DB8; -extern UNK_TYPE D_0601216C; + if (ENRD_GET_80(&this->actor)) { + this->actor.params |= 0xFF00; + } else { + this->actor.params &= 0xFF; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/EnRd_Init.s") + if (this->actor.params >= ENRD_GET_MINUS_1) { + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06010B88, &D_0600ABE0, this->jointTable, this->morphTable, 26); + } else { + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/EnRd_Destroy.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4190.s") + if (this->actor.params >= ENRD_GET_MINUS_2) { + switch (this->actor.params) { + case 5: + if (!func_808D41FC(globalCtx)) { + func_808D45D4(this); + } else { + this->actor.hintId = 0x2A; + func_808D4308(this); + } + this->unkFunc = func_808D45D4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D41FC.s") + case 6: + if (!func_808D41FC(globalCtx)) { + func_808D47DC(this); + } else { + this->actor.hintId = 0x2A; + func_808D4308(this); + } + this->unkFunc = func_808D47DC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4260.s") + case 7: + if (!func_808D41FC(globalCtx)) { + func_808D4A90(this); + } else { + this->actor.hintId = 0x2A; + func_808D4308(this); + } + this->unkFunc = func_808D4A90; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4308.s") + default: + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + func_808D4308(this); + this->unkFunc = func_808D4308; + break; + } + } else { + func_808D4DC4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D43AC.s") + SkelAnime_FrameUpdateMatrix(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D45D4.s") + if (this->actor.params == ENRD_GET_3) { + this->actor.flags |= 0x80; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4660.s") + if (this->actor.params == ENRD_GET_4) { + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D47DC.s") + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 0xFF4B); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4868.s") +void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRd* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D49E4.s") + if (gSaveContext.unk_3F58 != 0) { + gSaveContext.unk_3F58 = 0; + } + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4A90.s") +void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { + Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4B20.s") + while (actor != NULL) { + if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { + actor = actor->next; + continue; + } else if (arg2 != 0) { + actor->parent = &this->actor; + } else if (this == (EnRd*)actor->parent) { + actor->parent = NULL; + } + actor = actor->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4CA8.s") +s32 func_808D41FC(GlobalContext* globalCtx) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO_MASK) || + (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAINS_HAT) || + (Player_GetMask(globalCtx) == PLAYER_MASK_GAROS_MASK)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4DC4.s") +void func_808D4260(EnRd* this, GlobalContext* globalCtx) { + if ((this->actor.params >= ENRD_GET_5) && (this->actionFunc != func_808D4660) && + (this->actionFunc != func_808D4868) && (this->actionFunc != func_808D4B20) && + (this->actionFunc != func_808D65BC) && (this->actionFunc != func_808D58CC) && + (this->actionFunc != func_808D6200) && (this->actionFunc != func_808D6388)) { + if (!func_808D41FC(globalCtx)) { + this->unkFunc(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4E60.s") +void func_808D4308(EnRd* this) { + if (this->actor.params != ENRD_GET_2) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600ABE0, -6.0f); + } else { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060081A8); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D4FE0.s") + this->unk_3EF = 0; + this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_808D43AC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D506C.s") +void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + if ((this->actor.params == ENRD_GET_2) && func_801378B8(&this->skelAnime, 0.0f)) { + if (Rand_ZeroOne() >= 0.5f) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060081A8); + } else { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06007BBC); + } + } else { + this->unk_3D6--; + if (this->unk_3D6 == 0) { + this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 10.0f; + this->skelAnime.animCurrentFrame = 0.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D53C0.s") + if (this->actor.parent != NULL) { + if (this->unk_3EC == 0) { + if (this->actor.params != ENRD_GET_2) { + func_808D5660(this); + } else { + func_808D6008(this); + } + } + } else { + if (this->unk_3EC != 0) { + if (this->actor.params != ENRD_GET_2) { + func_808D5C54(this); + } else { + func_808D6008(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5440.s") + this->unk_3EC = 0; + if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(globalCtx)) { + if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { + func_808D5C54(this); + } else { + func_808D6008(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5660.s") + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D56E4.s") +void func_808D45D4(EnRd* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0601216C, -6.0f); + this->unk_3EF = 14; + this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->unk_3E4 = 0; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_808D4660; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D586C.s") +void func_808D4660(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + if (this->unk_3EC != 0) { + func_808D5C54(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D58CC.s") + this->unk_3EC = 0; + if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = func_808D49E4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5C54.s") + if (func_808D41FC(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + func_808D4308(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5CCC.s") + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5D88.s") +void func_808D47DC(EnRd* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06011DB8, -6.0f); + this->unk_3EF = 15; + this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->unk_3E4 = 0; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_808D4868; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5DF4.s") +void func_808D4868(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + if (this->unk_3EC != 0) { + func_808D5C54(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5E98.s") + this->unk_3EC = 0; + if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = func_808D49E4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D5F18.s") + if (func_808D41FC(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + func_808D4308(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6008.s") + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6054.s") +void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D60B0.s") + this->unk_3E4++; + if (this->unk_3E4 > 10) { + if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { + func_808D5C54(this); + } else { + func_808D6008(this); + } + this->unk_3E4 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6130.s") +void func_808D4A90(EnRd* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060118D8, -6.0f); + this->unk_3EF = 16; + this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->unk_3E4 = 4370; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_808D4B20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D616C.s") +void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + if (this->unk_3EC != 0) { + func_808D5C54(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6200.s") + this->unk_3EC = 0; + if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + this->actionFunc = func_808D4CA8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6310.s") + if (func_808D41FC(globalCtx)) { + if (this->actor.params == ENRD_GET_MINUS_2) { + this->actor.hintId = 0x2D; + } else { + this->actor.hintId = 0x2A; + } + func_808D4308(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6388.s") + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D64D0.s") + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + this->unk_3E4 = 4370; + } else if (func_801378B8(&this->skelAnime, 15.0f)) { + this->unk_3E4 = 6554; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D65BC.s") + this->actor.world.rot.y -= this->unk_3E4; + this->actor.shape.rot.y = this->actor.world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D66A0.s") +void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6814.s") + this->actor.world.rot.y -= this->unk_3E4; + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6A94.s") + this->unk_3E4 -= 100; + if ((this->unk_3E4 < 2100) && (this->unk_3E4 >= 2000)) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + } else if (this->unk_3E4 < 1000) { + if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { + func_808D5C54(this); + } else { + func_808D6008(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6B64.s") +void func_808D4DC4(EnRd* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_0600ABE0, 0.0f, 0.0f, SkelAnime_GetFrameCount(&D_0600ABE0.common), 0, + -6.0f); + this->unk_3EF = 13; + this->unk_3D6 = 6; + this->actor.shape.rot.x = -0x4000; + this->actor.gravity = 0.0f; + this->actor.shape.yOffset = 0.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D4E60; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/EnRd_Update.s") +void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.shape.rot.x != -0x4000) { + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { + this->actor.gravity = -3.5f; + func_808D4308(this); + } + } else { + if (this->actor.world.pos.y == this->actor.home.pos.y) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6DA0.s") + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { + if (this->unk_3D6 != 0) { + this->unk_3D6--; + Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); + } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/func_808D6DFC.s") +void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { + f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rd/EnRd_Draw.s") + SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); + this->actor.speedXZ = 0.4f; + this->unk_3EF = 4; + this->actionFunc = func_808D506C; +} + +void func_808D506C(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 pad; + s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + + this->skelAnime.animPlaybackSpeed = this->actor.speedXZ; + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + + if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + func_808D53C0(this, globalCtx); + } + + if ((ABS_ALT(sp36) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { + if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & 0x4080)) { + if (this->unk_3ED == 0) { + if (!(this->unk_3DC & 0x80)) { + player->actor.freezeTimer = 40; + func_80123E90(globalCtx, &this->actor); + PLAYER->unk_A78 = &this->actor; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + } + this->unk_3ED = 60; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + } + } else { + func_808D53C0(this, globalCtx); + } + } + + if (this->unk_3EE != 0) { + this->unk_3EE--; + } + + if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && + Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + player->actor.freezeTimer = 0; + if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU)) { + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { + func_808D5D88(this); + } else { + func_808D53C0(this, globalCtx); + } + } else if (globalCtx->grabPlayer(globalCtx, player)) { + this->actor.flags &= ~1; + func_808D586C(this); + } + } else if (this->actor.params > ENRD_GET_0) { + if (this->actor.parent != NULL) { + func_808D5660(this); + } else { + this->unk_3EC = 0; + } + } + + if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, SkelAnime_GetFrameCount(&D_060113EC.common), 1, + -4.0f); + this->unk_3EF = 2; + this->actionFunc = func_808D5440; +} + +void func_808D5440(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 pad; + s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) >= 5.0f) { + Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 450, 0); + } else { + this->actor.speedXZ = 0.0f; + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 450, 0)) { + if (this->actor.params != ENRD_GET_2) { + func_808D4308(this); + } else { + func_808D60B0(this); + } + } + } + + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + + if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & 0x4080) && (player->transformation != PLAYER_FORM_GORON) && + (player->transformation != PLAYER_FORM_DEKU) && + (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { + this->actor.targetMode = 0; + func_808D4FE0(this, globalCtx); + } else if (this->actor.params > ENRD_GET_0) { + if (this->actor.parent != NULL) { + func_808D5660(this); + } else { + this->unk_3EC = 0; + } + } + + if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_808D5660(EnRd* this) { + f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); + + SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->unk_3EF = 3; + this->unk_3EC = 1; + this->actionFunc = func_808D56E4; +} + +void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { + s32 pad; + s16 yaw; + Vec3f sp2C; + + if (this->actor.parent != NULL) { + sp2C = this->actor.parent->world.pos; + yaw = Actor_YawToPoint(&this->actor, &sp2C); + + Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 250, 0); + if (Actor_DistanceToPoint(&this->actor, &sp2C) >= 45.0f) { + this->actor.speedXZ = 0.4f; + } else { + this->actor.speedXZ = 0.0f; + if (this->actor.params != ENRD_GET_2) { + func_808D4308(this); + } else { + func_808D60B0(this); + } + } + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + } else { + func_808D4FE0(this, globalCtx); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + + if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} + +void func_808D586C(EnRd* this) { + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06006EEC); + this->unk_3D6 = 0; + this->unk_3EB = 0; + this->unk_3EA = 200; + this->unk_3EF = 10; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D58CC; +} + +void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 pad; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->unk_3EB++; + } + + switch (this->unk_3EB) { + case 1: + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06006678); + this->unk_3EB++; + globalCtx->damagePlayer(globalCtx, -8); + func_8013ECE0(this->actor.xzDistToPlayer, 255, 1, 12); + this->unk_3EA = 20; + + case 0: + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 1500, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 1500, 0); + + case 2: + if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { + player->stateFlags2 &= ~0x80; + player->unk_AE8 = 100; + } + SkelAnime_ChangeAnim(&this->skelAnime, &D_06006B08, 0.5f, 0.0f, + SkelAnime_GetFrameCount(&D_06006B08.common), 3, 0.0f); + this->unk_3EB++; + this->unk_3EF = 4; + break; + } + + switch (player->transformation) { + case 0: + case 1: + case 2: + case 3: + break; + + case 4: + Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); + break; + } + + Math_SmoothStepToF(&this->actor.world.pos.x, + (Math_SinS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.x, 1.0f, 10.0f, + 0.0f); + Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f, 10.0f, 0.0f); + Math_SmoothStepToF(&this->actor.world.pos.z, + (Math_CosS(player->actor.shape.rot.y) * -25.0f) + player->actor.world.pos.z, 1.0f, 10.0f, + 0.0f); + Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 6000, 0); + + if (func_801378B8(&this->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + } + + this->unk_3EA--; + if (this->unk_3EA == 0) { + globalCtx->damagePlayer(globalCtx, -8); + func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); + this->unk_3EA = 20; + func_800B8E58(&player->actor, player->ageProperties->unk_92 + 0x6805); + } + break; + + case 3: + if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { + Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); + } + break; + + case 4: + if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { + Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); + } + this->actor.targetMode = 0; + this->actor.flags |= 1; + this->unk_3ED = 10; + this->unk_3EE = 15; + func_808D4FE0(this, globalCtx); + break; + } +} + +void func_808D5C54(EnRd* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, SkelAnime_GetFrameCount(&D_060073A4.common), 2, + 0.0f); + this->unk_3EF = 7; + this->actionFunc = func_808D5CCC; +} + +void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 temp_v0 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + + if (ABS_ALT(temp_v0) < 0x2008) { + if (!(this->unk_3DC & 0x80)) { + player->actor.freezeTimer = 60; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + func_80123E90(globalCtx, &this->actor); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + func_808D4FE0(this, globalCtx); + } +} + +void func_808D5D88(EnRd* this) { + this->unk_3EF = 8; + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009900, -6.0f); + this->actor.speedXZ = -2.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->unk_3EF = 8; + this->actionFunc = func_808D5DF4; +} + +void func_808D5DF4(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ += 0.15f; + } + + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_808D5E98(this); + } +} + +void func_808D5E98(EnRd* this) { + f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); + + SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->unk_3EF = 9; + this->unk_3D4 = 0; + this->actionFunc = func_808D5F18; +} + +void func_808D5F18(EnRd* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->unk_3D4 > 60) { + func_808D53C0(this, globalCtx); + this->unk_3D4 = 0; + } else { + this->unk_3D8 = Math_SinS(this->unk_3D4 * 4000) * (9583.0f * ((60 - this->unk_3D4) / 60.0f)); + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->unk_3D4++; + } +} + +void func_808D6008(EnRd* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_0600A450, -4.0f); + this->unk_3EF = 5; + this->actionFunc = func_808D6054; +} + +void func_808D6054(EnRd* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->actor.parent != NULL) { + func_808D5660(this); + } else { + func_808D5C54(this); + } + } +} + +void func_808D60B0(EnRd* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_0600A450, -1.0f, SkelAnime_GetFrameCount(&D_0600A450.common), 0.0f, 2, + -4.0f); + this->unk_3EF = 6; + this->actionFunc = func_808D6130; +} + +void func_808D6130(EnRd* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + func_808D4308(this); + } +} + +void func_808D616C(EnRd* this) { + this->actor.shape.yOffset = 0.0f; + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009900, -6.0f); + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ = -2.0f; + } + + this->actor.flags |= 1; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->unk_3EF = 11; + this->actionFunc = func_808D6200; +} + +void func_808D6200(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ += 0.15f; + } + + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->actor.parent != NULL) { + func_808D5660(this); + } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + func_808D53C0(this, globalCtx); + } else { + func_808D4FE0(this, globalCtx); + } + this->unk_3F1 = -1; + } +} + +void func_808D6310(EnRd* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009298, -1.0f); + this->unk_3EF = 12; + this->unk_3D6 = 300; + this->actor.flags &= ~1; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + this->actionFunc = func_808D6388; +} + +void func_808D6388(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.category != 6) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); + } + + Math_SmoothStepToS(&this->unk_3D8, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->unk_3DA, 0, 1, 2000, 0); + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->unk_3D6 == 0) { + if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { + Actor_SetSwitchFlag(globalCtx, this->unk_3DC & 0x7F); + } + + if (this->unk_3DE != 0) { + if (this->unk_3DE == 180) { + func_808D4190(globalCtx, this, 0); + } + this->actor.scale.y -= (75.0f / 1000000.0f); + this->unk_3DE -= 5; + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + this->unk_3D6--; + } + } else if (func_801378B8(&this->skelAnime, 33.0f) || func_801378B8(&this->skelAnime, 40.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } +} + +void func_808D64D0(EnRd* this) { + this->unk_3EF = 1; + this->unk_3D6 = 0xA; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + if (gSaveContext.unk_3F58 != 0) { + this->unk_3E9 = 1; + this->unk_3E0 = 600; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); + func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + } else if (this->unk_3F0 == 1) { + func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + } else if (this->unk_3F0 == 12) { + func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + } + this->actionFunc = func_808D65BC; +} + +void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { + if (this->unk_3D6 > 0) { + this->unk_3D6--; + } + + if (this->unk_3E9 != 0) { + if (this->unk_3E0 != 0) { + this->unk_3E0--; + if (this->unk_3E0 >= 255) { + func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + } + + if (this->unk_3E0 == 0) { + this->unk_3E9 = 0; + gSaveContext.unk_3F58 = 0; + } + } + } + + if (this->actor.colorFilterTimer == 0) { + if (this->actor.colChkInfo.health == 0) { + func_808D4190(globalCtx, this, 1); + func_808D6310(this); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } else { + func_808D616C(this); + } + } +} + +void func_808D66A0(EnRd* this, GlobalContext* globalCtx) { + s16 phi_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3DA; + s16 temp_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); + + phi_v0 -= this->unk_3D8; + phi_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); + + if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { + this->unk_3DA += ABS_ALT(temp_v0); + this->unk_3D8 += ABS_ALT(phi_v0); + } else { + this->unk_3DA -= ABS_ALT(temp_v0); + this->unk_3D8 -= ABS_ALT(phi_v0); + } + + this->unk_3DA = CLAMP(this->unk_3DA, -0x495F, 0x495F); + this->unk_3D8 = CLAMP(this->unk_3D8, -0x256F, 0x256F); +} + +void func_808D6814(EnRd* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + + if ((gSaveContext.unk_3F58 != 0) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && + (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { + func_808D64D0(this); + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->unk_3F0 = this->actor.colChkInfo.damageEffect; + + if (this->unk_3EF == 13) { + return; + } + + func_800BE258(&this->actor, &this->collider.info); + + if (player->unk_ADC != 0) { + this->unk_3F1 = player->unk_ADD; + } + + switch (this->unk_3F0) { + case 12: + if ((this->actionFunc != func_808D58CC) && + ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { + this->unk_3E6 = 40; + this->unk_3E8 = 30; + this->unk_294 = 1.0f; + func_808D64D0(this); + } + return; + + case 1: + func_808D64D0(this); + return; + + case 2: + func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + this->unk_3E6 = 180; + this->unk_3E8 = 0; + this->unk_3E9 = 0; + this->unk_3E0 = 0; + this->unk_294 = 1.0f; + break; + + case 4: + func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + this->unk_3E6 = 60; + this->unk_3E8 = 20; + this->unk_3E9 = 0; + this->unk_3E0 = 0; + this->unk_294 = 1.0f; + break; + + case 15: + func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + this->unk_3E9 = 0; + this->unk_3E0 = 0; + break; + + case 14: + func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + this->unk_3E9 = 0; + this->unk_3E0 = 0; + this->actor.colChkInfo.health = 0; + break; + + default: + return; + } + + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health == 0) { + func_808D4190(globalCtx, this, 1); + func_808D6310(this); + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x90); + } else { + func_808D616C(this); + } + } +} + +void func_808D6A94(EnRd* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if ((this->actor.colChkInfo.health > 0) && (this->unk_3EF != 10)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (((this->unk_3EF != 11) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && + ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_808D6B64(EnRd* this, GlobalContext* globalCtx) { + if (this->unk_3E6 > 0) { + this->unk_3E6--; + } + + if (this->unk_3E6 < 20) { + Math_SmoothStepToF(&this->unk_298, 0.0f, 0.5f, 0.03f, 0.0f); + this->unk_294 = this->unk_3E6 * 0.05f; + } else { + Math_SmoothStepToF(&this->unk_298, 0.5f, 0.1f, 0.02f, 0.0f); + } +} + +void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRd* this = THIS; + + func_808D6814(this, globalCtx); + if ((gSaveContext.unk_3F58 != 0) && (this->unk_3E9 == 0)) { + gSaveContext.unk_3F58 = 0; + } + + if ((this->unk_3F0 != 6) && ((this->unk_3EF != 13) || (this->unk_3F0 != 2))) { + if (this->unk_3ED != 0) { + this->unk_3ED--; + } + + this->actionFunc(this, globalCtx); + + if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); + } + + if (this->unk_3EF == 7) { + func_808D66A0(this, globalCtx); + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; + func_808D6A94(this, globalCtx); + func_808D4260(this, globalCtx); + func_808D6B64(this, globalCtx); +} + +s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnRd* this = THIS; + + if (limbIndex == 23) { + rot->y += this->unk_3D8; + } else if (limbIndex == 12) { + rot->y += this->unk_3DA; + } + return false; +} + +void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnRd* this = THIS; + + if ((this->unk_3E6 != 0) && + ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || + (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || + (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { + SysMatrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); + this->unk_290++; + } +} + +void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_808D7138 = { 0.25f, 0.25f, 0.25f }; + s32 pad; + EnRd* this = THIS; + Vec3f sp54 = this->actor.world.pos; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_290 = 0; + + if (this->unk_3DE == 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_3DE); + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + + POLY_OPA_DISP = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, + this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + + func_800BC620(&sp54, &D_808D7138, 255, globalCtx); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_3DE); + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + + POLY_XLU_DISP = + SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, + this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + func_800BC620(&sp54, &D_808D7138, this->unk_3DE, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_3E6 > 0) { + func_800BE680(globalCtx, &this->actor, this->unk_1DC, ARRAY_COUNT(this->unk_1DC), this->unk_298, 0.5f, + this->unk_294, this->unk_3E8); + } +} diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 69d723450..2c6637d76 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -6,12 +6,54 @@ struct EnRd; typedef void (*EnRdActionFunc)(struct EnRd*, GlobalContext*); +typedef void (*EnRdFunc)(struct EnRd*); + +#define ENRD_GET_80(thisx) ((thisx)->params & 0x80) +#define ENRD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +enum { + /* -2 */ ENRD_GET_MINUS_2 = -2, + /* -1 */ ENRD_GET_MINUS_1 = -1, + /* 0x00 */ ENRD_GET_0 = 0, + /* 0x01 */ ENRD_GET_1, + /* 0x02 */ ENRD_GET_2, + /* 0x03 */ ENRD_GET_3, + /* 0x04 */ ENRD_GET_4, + /* 0x05 */ ENRD_GET_5, +}; typedef struct EnRd { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x268]; + /* 0x018C */ EnRdFunc unkFunc; + /* 0x0190 */ ColliderCylinder collider; + /* 0x01DC */ Vec3f unk_1DC[15]; + /* 0x0290 */ s32 unk_290; + /* 0x0294 */ f32 unk_294; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ Vec3s jointTable[26]; + /* 0x0338 */ Vec3s morphTable[26]; + /* 0x03D4 */ s16 unk_3D4; + /* 0x03D6 */ s16 unk_3D6; + /* 0x03D8 */ s16 unk_3D8; + /* 0x03DA */ s16 unk_3DA; + /* 0x03DC */ s16 unk_3DC; + /* 0x03DE */ s16 unk_3DE; + /* 0x03E0 */ s16 unk_3E0; + /* 0x03E2 */ s16 unk_3E2; + /* 0x03E4 */ s16 unk_3E4; + /* 0x03E6 */ s16 unk_3E6; + /* 0x03E8 */ u8 unk_3E8; + /* 0x03E9 */ u8 unk_3E9; + /* 0x03EA */ u8 unk_3EA; + /* 0x03EB */ u8 unk_3EB; + /* 0x03EC */ u8 unk_3EC; + /* 0x03ED */ u8 unk_3ED; + /* 0x03EE */ u8 unk_3EE; + /* 0x03EF */ u8 unk_3EF; + /* 0x03F0 */ u8 unk_3F0; + /* 0x03F1 */ s8 unk_3F1; } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8ba8afa25..2ea8fe5f8 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6392,8 +6392,8 @@ 0x808D6A94:("func_808D6A94",), 0x808D6B64:("func_808D6B64",), 0x808D6C10:("EnRd_Update",), - 0x808D6DA0:("func_808D6DA0",), - 0x808D6DFC:("func_808D6DFC",), + 0x808D6DA0:("EnRd_OverrideLimbDraw",), + 0x808D6DFC:("EnRd_PostLimbDraw",), 0x808D6ED8:("EnRd_Draw",), 0x808D7550:("BgF40Flift_Init",), 0x808D75BC:("BgF40Flift_Destroy",), From 0f4bdbc0207bf7761b6a2836453784b6e6102b6c Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 28 Sep 2021 05:18:31 -0700 Subject: [PATCH 10/86] Obj_Etcetera (Deku Flower) OK and somewhat documented (#326) * Migrate data to C * ObjEtcetera_Init OK * ObjEtcetera_Destroy OK * ObjEtcetera_Update OK * func_80A7C690 OK * func_80A7C718 OK * func_80A7C168 OK * func_80A7BE8C OK * Make the draw functions take Actor* * CollisionCheck_SetAC should take a Collider * func_80A7BDC8 OK (with silly dummy label meme) * func_80A7C1F0 OK * unk_276 is almost certainly a u16 since I constantly have to cast it, so just retype it * func_80A7BF08 OK * Some minor cleanup * Convert D_80A7C80C to array of CollisionHeader* * Finish defining struct to prepare for func_80A7C308 * func_80A7C308 OK * Move gameplay_keep symbols to variables.h * Explanatory comment at the top * Type gameplay_keep animation headers too * Update the spec (why do I always forget this?) * Rename func_80A7BDC8 to ObjEtcetera_PerformFlutter (name still up for debate) * Name objIndex * Document the types of flowers * Name displayListPtr * Name burrowFlag and provide a macro * Name specialFlutterScale and clean up some things with newer understanding * Give the draw functions (bad) names * Name ObjEtcetera_Idle * Name ObjEtcetera_Setup (name sucks but oh well lol) * Name ObjEtcetera_ReturnToIdle. These names all suck but they're a start * Document some of ObjEtcetera_Idle's behavior * Name and document objectIds * Remove the burrow macro because it's frankly more confusing for now * Name the draw functions something slightly better * MUCH better names for things + more documentation * Clean up ObjEtcetera_Setup a bit * Call it NUMBER_OF_FLOWER_TYPES instead * A few more name changes * Link -> Player in comments * displayListPtr -> dList * Trailing commas + format * Move initialization of type up * Improve conditional check * Use BGCHECK_SCENE macro * Move initialization of floorBgId up * Use documentation comment style * Match ObjEtcetera_DoNormalOscillation without a dummy label * param_2 -> arg1 * Insert blank line after scoped pad * OBJETCETERA_TYPE -> DEKU_FLOWER_TYPE * Cleanup and rename enum * Break up ObjEtcetera_Setup a bit and convert DekuFlowerType to an s32 to remove warnings * Whoops, run format * Delete leading 0 on struct comments * Rename pad to requiredScopeTemp to match my other PR --- include/functions.h | 2 +- include/variables.h | 10 +- spec | 3 +- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.c | 305 ++++++++++++++++-- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.h | 24 +- tools/disasm/functions.txt | 16 +- undefined_syms.txt | 2 + 7 files changed, 324 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index ecc2df884..dc0d98e7e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1762,7 +1762,7 @@ void func_800F9824(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* v // void func_800FA39C(void); // void func_800FA3C4(void); // void func_800FA9FC(void); -// void func_800FAAB4(void); +void func_800FAAB4(GlobalContext* globalCtx, u8 arg1); // void func_800FAC20(void); // void func_800FAF74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_800FB010(void); diff --git a/include/variables.h b/include/variables.h index c6fb55982..ba99e95eb 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3954,8 +3954,14 @@ extern UNK_TYPE D_0400E3D8; extern UNK_TYPE D_0400E408; extern UNK_TYPE D_0400E410; extern UNK_TYPE D_0400E418; -extern UNK_TYPE D_0400EB7C; -extern UNK_TYPE D_040117A8; +extern CollisionHeader D_0400E710; // Pink Deku Flower collision +extern AnimationHeader D_0400EB7C; // Deku Flower intense flutter animation +extern Gfx D_0400ED80; // Pink Deku Flower display list +extern SkeletonHeader D_04011518; // Pink Deku Flower skeleton +extern AnimationHeader D_040117A8; // Deku Flower small flutter animation +extern CollisionHeader D_040118D8; // Gold Deku Flower collision +extern Gfx D_04011BD0; // Gold Deku Flower display list +extern SkeletonHeader D_040127E8; // Gold Deku Flower skeleton extern UNK_TYPE D_04012860; extern UNK_TYPE D_040128BC; extern UNK_TYPE D_04015FA0; diff --git a/spec b/spec index 20a380cad..e958e08d0 100644 --- a/spec +++ b/spec @@ -3206,8 +3206,7 @@ beginseg name "ovl_Obj_Etcetera" compress include "build/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.o" - include "build/data/ovl_Obj_Etcetera/ovl_Obj_Etcetera.data.o" - include "build/data/ovl_Obj_Etcetera/ovl_Obj_Etcetera.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Etcetera/ovl_Obj_Etcetera_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index 48e200ca1..b5272432e 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_etcetera.c + * Overlay: ovl_Obj_Etcetera + * Description: Deku Flower + */ + #include "z_obj_etcetera.h" #define FLAGS 0x00000010 @@ -8,12 +14,12 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80A7BF08(ObjEtcetera* this, GlobalContext* globalCtx); -void func_80A7C168(ObjEtcetera* this, GlobalContext* globalCtx); -void func_80A7C1F0(ObjEtcetera* this, GlobalContext* globalCtx); -void func_80A7C308(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx); +void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Etcetera_InitVars = { ACTOR_OBJ_ETCETERA, ACTORCAT_BG, @@ -26,35 +32,290 @@ const ActorInit Obj_Etcetera_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A7C790 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 14, 0, { 0, 0, 0 } }, }; -#endif - extern ColliderCylinderInit D_80A7C790; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/ObjEtcetera_Init.s") +static s16 objectIds[] = { + GAMEPLAY_KEEP, + GAMEPLAY_KEEP, + GAMEPLAY_KEEP, + GAMEPLAY_KEEP, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/ObjEtcetera_Destroy.s") +/** + * Most interactions with a Deku Flower cause it to slightly oscillate on the X and Z axes. + * When these small oscillations happen, the game determines how to scale the appropriate + * axes by using this table. + */ +static f32 oscillationTable[] = { + -1.0, -1.0, -1.0, -0.7, 0.0, 0.7, 1.0, 0.7, 0.0, -0.7, -1.0, -0.7, 0.0, 0.7, 1.0, 0.7, 0.0, -0.7, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7BDC8.s") +void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjEtcetera* this = THIS; + s32 objectIndex; + s32 type = DEKU_FLOWER_TYPE(&this->dyna.actor); + s32 floorBgId; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7BE8C.s") + if ((type < DEKU_FLOWER_TYPE_PINK) || (type >= DEKU_FLOWER_TYPE_MAX)) { + type = DEKU_FLOWER_TYPE_PINK; + } + objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[type]); + if (objectIndex >= 0) { + this->objIndex = objectIndex; + } + pos.x = this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y + 10.0f; + pos.z = this->dyna.actor.world.pos.z; + func_800C411C(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &floorBgId, &this->dyna.actor, &pos); + this->dyna.actor.floorBgId = floorBgId; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + this->actionFunc = ObjEtcetera_Setup; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->dyna.actor.scale.y = 0.02f; + this->burrowFlag = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7BF08.s") +void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjEtcetera* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7C168.s") + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7C1F0.s") +void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { + if (this->oscillationTimer > 0) { + s32 requiredScopeTemp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7C308.s") + Actor_SetScale(&this->dyna.actor, + (oscillationTable[globalCtx->gameplayFrames % 18] * (0.0001f * this->oscillationTimer)) + 0.01f); + this->dyna.actor.scale.y = 0.02f; + this->oscillationTimer--; + } else { + Actor_SetScale(&this->dyna.actor, 0.01f); + this->dyna.actor.scale.y = 0.02f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/ObjEtcetera_Update.s") +void ObjEtcetera_StartSmallFlutterAnimation(ObjEtcetera* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_040117A8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_040117A8.common), 2, + 0.0f); + this->dyna.actor.draw = ObjEtcetera_DrawAnimated; + this->actionFunc = ObjEtcetera_PlaySmallFlutterAnimation; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7C690.s") +void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { + s16 minOscillationTimer; + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Etcetera/func_80A7C718.s") + if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { + // Player is launching out of the Deku Flower + SkelAnime_ChangeAnim(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_0400EB7C.common), 2, + 0.0f); + this->dyna.actor.draw = ObjEtcetera_DrawAnimated; + this->actionFunc = ObjEtcetera_DoIntenseOscillation; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->dyna.actor.scale.y = 0.02f; + this->intenseOscillationScale = 0.003f; + this->oscillationTimer = 30; + this->burrowFlag &= ~1; + } else if ((player->stateFlags3 & 0x2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && + (this->dyna.actor.yDistToPlayer > 0.0f)) { + // Player is hovering above the Deku Flower + minOscillationTimer = 10 - (s32)(this->dyna.actor.yDistToPlayer * 0.05f); + if (this->oscillationTimer < minOscillationTimer) { + this->oscillationTimer = minOscillationTimer; + } + } else { + if (func_800CAF70(&this->dyna)) { + if (!(this->burrowFlag & 1)) { + // Player is walking onto the Deku Flower, or falling on it from a height + this->oscillationTimer = 10; + ObjEtcetera_StartSmallFlutterAnimation(this); + } else if ((player->actor.speedXZ > 0.1f) || ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & 0x100))) { + // Player is walking on top of the Deku Flower, is at the very start of burrowing, or is at the very + // start of launching + this->oscillationTimer = 10; + } + this->burrowFlag |= 1; + } else { + if (this->burrowFlag & 1) { + // Player is walking off the Deku Flower + this->oscillationTimer = 10; + ObjEtcetera_StartSmallFlutterAnimation(this); + } + this->burrowFlag &= ~1; + } + } + if ((this->collider.base.acFlags & AC_HIT)) { + this->oscillationTimer = 10; + ObjEtcetera_StartSmallFlutterAnimation(this); + } + ObjEtcetera_DoNormalOscillation(this, globalCtx); +} + +void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { + if (func_800CAF70(&this->dyna)) { + this->burrowFlag |= 1; + } else { + this->burrowFlag &= ~1; + } + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->dyna.actor.draw = ObjEtcetera_DrawIdle; + this->actionFunc = ObjEtcetera_Idle; + } + ObjEtcetera_DoNormalOscillation(this, globalCtx); +} + +void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { + // In order to match, we are seemingly required to access scale.x at one point + // without using this. We can create a thisx or dyna pointer to achieve that, but + // it's more likely they used dyna given that func_800CAF70 takes a DynaPolyActor. + DynaPolyActor* dyna = &this->dyna; + f32 scaleTemp; + + if (func_800CAF70(dyna)) { + this->burrowFlag |= 1; + } else { + this->burrowFlag &= ~1; + } + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->oscillationTimer > 0) { + this->oscillationTimer--; + } else { + this->dyna.actor.draw = ObjEtcetera_DrawIdle; + this->actionFunc = ObjEtcetera_Idle; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->dyna.actor.scale.y = 0.02f; + this->oscillationTimer = 0; + this->intenseOscillationScale = 0.0f; + return; + } + this->intenseOscillationScale *= 0.8f; + this->intenseOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; + scaleTemp = dyna->actor.scale.x + this->intenseOscillationScale; + Actor_SetScale(&this->dyna.actor, scaleTemp); + this->dyna.actor.scale.y = 2.0f * scaleTemp; +} + +void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { + CollisionHeader* colHeader = NULL; + s32 type; + CollisionHeader* collisionHeaders[] = { &D_0400E710, &D_0400E710, &D_040118D8, &D_040118D8 }; + s32 pad; + CollisionHeader* thisCollisionHeader; + + type = DEKU_FLOWER_TYPE(&this->dyna.actor); + if ((type < DEKU_FLOWER_TYPE_PINK) || (type >= DEKU_FLOWER_TYPE_MAX)) { + type = DEKU_FLOWER_TYPE_PINK; + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + this->dyna.actor.objBankIndex = this->objIndex; + Actor_SetObjectSegment(globalCtx, &this->dyna.actor); + BcCheck3_BgActorInit(&this->dyna, 1); + thisCollisionHeader = collisionHeaders[type]; + if (thisCollisionHeader != 0) { + BgCheck_RelocateMeshHeader(thisCollisionHeader, &colHeader); + } + this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); + + type = DEKU_FLOWER_TYPE(&this->dyna.actor); + switch (type) { + case DEKU_FLOWER_TYPE_PINK: + case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: + SkelAnime_Init(globalCtx, &this->skelAnime, &D_04011518, &D_0400EB7C, this->jointTable, + this->morphTable, 11); + this->dList = &D_0400ED80; + break; + case DEKU_FLOWER_TYPE_GOLD: + case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + this->dList = &D_04011BD0; + SkelAnime_Init(globalCtx, &this->skelAnime, &D_040127E8, &D_0400EB7C, this->jointTable, + this->morphTable, 11); + this->collider.dim.height = 20; + break; + } + + type = DEKU_FLOWER_TYPE(&this->dyna.actor); + switch (type) { + case DEKU_FLOWER_TYPE_PINK: + case DEKU_FLOWER_TYPE_GOLD: + this->dyna.actor.draw = ObjEtcetera_DrawIdle; + this->actionFunc = ObjEtcetera_Idle; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->dyna.actor.scale.y = 0.02f; + this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; + this->dyna.actor.targetMode = 3; + break; + case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: + case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + SkelAnime_ChangeAnim(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&D_0400EB7C.common), 2, 0.0f); + this->dyna.actor.draw = ObjEtcetera_DrawAnimated; + this->actionFunc = ObjEtcetera_DoIntenseOscillation; + Actor_SetScale(&this->dyna.actor, 0.0f); + this->oscillationTimer = 30; + this->intenseOscillationScale = 0.0f; + this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; + this->dyna.actor.targetMode = 3; + break; + } + } +} + +void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjEtcetera* this = THIS; + CollisionPoly* floorPoly; + u8 floorBgId = this->dyna.actor.floorBgId; + + if (floorBgId == BGCHECK_SCENE) { + floorPoly = this->dyna.actor.floorPoly; + if (floorPoly != NULL && this->burrowFlag & 1) { + func_800FAAB4(globalCtx, func_800C9C9C(&globalCtx->colCtx, floorPoly, floorBgId)); + } + } + this->actionFunc(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { + ObjEtcetera* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx) { + ObjEtcetera* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, NULL, NULL, &this->dyna.actor); +} diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h index 13f667c1c..f5642ff28 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h @@ -3,14 +3,32 @@ #include "global.h" +#define DEKU_FLOWER_TYPE(thisx) (((thisx)->params & 0xFF80) >> 7) + +typedef enum { + /* 0 */ DEKU_FLOWER_TYPE_PINK, + /* 1 */ DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB, + /* 2 */ DEKU_FLOWER_TYPE_GOLD, + /* 3 */ DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB, + /* 4 */ DEKU_FLOWER_TYPE_MAX, +} DekuFlowerType; + struct ObjEtcetera; typedef void (*ObjEtceteraActionFunc)(struct ObjEtcetera*, GlobalContext*); typedef struct ObjEtcetera { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; - /* 0x0280 */ ObjEtceteraActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ ColliderCylinder collider; + /* 0x1EC */ Vec3s jointTable[11]; + /* 0x22E */ Vec3s morphTable[11]; + /* 0x270 */ f32 intenseOscillationScale; + /* 0x274 */ s16 oscillationTimer; + /* 0x276 */ u16 burrowFlag; + /* 0x278 */ s8 objIndex; + /* 0x27C */ Gfx* dList; + /* 0x280 */ ObjEtceteraActionFunc actionFunc; } ObjEtcetera; // size = 0x284 extern const ActorInit Obj_Etcetera_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2ea8fe5f8..67d5f1632 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11103,15 +11103,15 @@ 0x80A7AFA8:("EnJso2_Draw",), 0x80A7BC70:("ObjEtcetera_Init",), 0x80A7BD80:("ObjEtcetera_Destroy",), - 0x80A7BDC8:("func_80A7BDC8",), - 0x80A7BE8C:("func_80A7BE8C",), - 0x80A7BF08:("func_80A7BF08",), - 0x80A7C168:("func_80A7C168",), - 0x80A7C1F0:("func_80A7C1F0",), - 0x80A7C308:("func_80A7C308",), + 0x80A7BDC8:("ObjEtcetera_DoNormalOscillation",), + 0x80A7BE8C:("ObjEtcetera_StartSmallFlutterAnimation",), + 0x80A7BF08:("ObjEtcetera_Idle",), + 0x80A7C168:("ObjEtcetera_PlaySmallFlutterAnimation",), + 0x80A7C1F0:("ObjEtcetera_DoIntenseOscillation",), + 0x80A7C308:("ObjEtcetera_Setup",), 0x80A7C5EC:("ObjEtcetera_Update",), - 0x80A7C690:("func_80A7C690",), - 0x80A7C718:("func_80A7C718",), + 0x80A7C690:("ObjEtcetera_DrawIdle",), + 0x80A7C718:("ObjEtcetera_DrawAnimated",), 0x80A7C990:("func_80A7C990",), 0x80A7CA18:("func_80A7CA18",), 0x80A7CBC4:("func_80A7CBC4",), diff --git a/undefined_syms.txt b/undefined_syms.txt index bf19c9814..a3ecdeade 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -379,8 +379,10 @@ D_0400E418 = 0x0400E418; D_0400E430 = 0x0400E430; D_0400EB7C = 0x0400EB7C; D_0400ED80 = 0x0400ED80; +D_0400E710 = 0x0400E710; D_04011518 = 0x04011518; D_040117A8 = 0x040117A8; +D_040118D8 = 0x040118D8; D_04011BD0 = 0x04011BD0; D_040127E8 = 0x040127E8; D_04012860 = 0x04012860; From edb1dd46757979c5fd755c4f27bce7a69842fc9a Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:28:06 +0100 Subject: [PATCH 11/86] En_Zot (#320) * En_Zot * PR --- include/functions.h | 8 +- include/macros.h | 1 + spec | 3 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 1399 ++++++++++++++++++++- src/overlays/actors/ovl_En_Zot/z_en_zot.h | 18 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 11 + 7 files changed, 1373 insertions(+), 71 deletions(-) diff --git a/include/functions.h b/include/functions.h index dc0d98e7e..c87bfe03c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -807,8 +807,8 @@ s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); u32 func_800B867C(Actor* actor, GlobalContext* globalCtx); UNK_TYPE4 func_800B86C8(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); s32 func_800B8708(GlobalContext* globalCtx); -// void func_800B8718(void); -// void func_800B874C(void); +s32 func_800B8718(Actor* actor, GlobalContext* globalCtx); +void func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3); // void func_800B8804(void); // void func_800B882C(void); // void func_800B886C(void); @@ -3792,7 +3792,7 @@ void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019B38C(void); // void func_8019B3D0(void); // void func_8019B4B8(void); -// void func_8019B544(void); +void func_8019B544(u16 arg0); // void func_8019B568(void); // void func_8019B5AC(void); // void func_8019B5EC(void); @@ -3804,7 +3804,7 @@ void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019C1D0(void); // void func_8019C268(void); // void func_8019C2E4(void); -// void func_8019C300(void); +void func_8019C300(s32 arg0); // void func_8019C398(void); // void func_8019C5A0(void); // void func_8019C8D8(void); diff --git a/include/macros.h b/include/macros.h index e0e6c8e7c..8b02cbfc5 100644 --- a/include/macros.h +++ b/include/macros.h @@ -56,6 +56,7 @@ #define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip]))) #define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[gSaveContext.playerForm == PLAYER_FORM_HUMAN ? 0 : gSaveContext.playerForm][button]) #define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg) - 4) diff --git a/spec b/spec index e958e08d0..daed42bf4 100644 --- a/spec +++ b/spec @@ -4484,8 +4484,7 @@ beginseg name "ovl_En_Zot" compress include "build/src/overlays/actors/ovl_En_Zot/z_en_zot.o" - include "build/data/ovl_En_Zot/ovl_En_Zot.data.o" - include "build/data/ovl_En_Zot/ovl_En_Zot.reloc.o" + include "build/src/overlays/actors/ovl_En_Zot/ovl_En_Zot_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 026a5a7bc..b49ccaef1 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zot.c + * Overlay: ovl_En_Zot + * Description: Great Bay - Zora With Directions to Zora Hall + */ + #include "z_en_zot.h" #define FLAGS 0x00000019 @@ -9,7 +15,36 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZot_Update(Actor* thisx, GlobalContext* globalCtx); void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2); +void func_80B97100(EnZot* this, GlobalContext* globalCtx); +void func_80B97240(EnZot* this, GlobalContext* globalCtx); +void func_80B97708(EnZot* this, GlobalContext* globalCtx); +void func_80B97B5C(EnZot* this, GlobalContext* globalCtx); +void func_80B97CC8(EnZot* this, GlobalContext* globalCtx); +void func_80B97FD0(EnZot* this, GlobalContext* globalCtx); +void func_80B980FC(EnZot* this, GlobalContext* globalCtx); +void func_80B98728(EnZot* this, GlobalContext* globalCtx); +void func_80B98998(EnZot* this, GlobalContext* globalCtx); +void func_80B98CA8(EnZot* this, GlobalContext* globalCtx); +void func_80B990A4(EnZot* this, GlobalContext* globalCtx); +void func_80B992C0(EnZot* this, GlobalContext* globalCtx); +void func_80B99384(EnZot* this, GlobalContext* globalCtx); + +extern AnimationHeader D_06002898; +extern AnimationHeader D_06004248; +extern UNK_PTR D_060050A0; +extern UNK_PTR D_060058A0; +extern UNK_PTR D_060060A0; +extern FlexSkeletonHeader D_0600D208; +extern AnimationHeader D_0600DE20; +extern AnimationHeader D_0600DF54; +extern AnimationHeader D_0600E400; +extern AnimationHeader D_0600EDF0; +extern AnimationHeader D_0600F4E8; +extern AnimationHeader D_0600FDF0; +extern AnimationHeader D_06010B18; +extern AnimationHeader D_06011424; + const ActorInit En_Zot_InitVars = { ACTOR_EN_ZOT, ACTORCAT_NPC, @@ -22,123 +57,1363 @@ const ActorInit En_Zot_InitVars = { (ActorFunc)EnZot_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B998E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { + s32 i; -extern ColliderCylinderInit D_80B998E0; + if ((this->path != NULL) && (this->path->count >= 5)) { + Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); -extern UNK_TYPE D_06004248; + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { + if (this->unk_2D8[i] == NULL) { + this->unk_2D8[i] = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_TSUBO, points->x, points->y, + points->z, 0, 0, 0, 0x13F); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B965D0.s") +void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnZot* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80B97100; + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_0600DE20); + this->unk_2F0 = 0; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Destroy.s") + this->unk_2F2 = 0; + this->unk_2F4 = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.world.rot.z = this->actor.shape.rot.z = 0; + this->actor.targetMode = 6; + this->actor.minVelocityY = -4.0f; + this->actor.gravity = -4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96BEC.s") + switch (ENZOT_GET_1F(thisx)) { + case 0: + this->actionFunc = func_80B97240; + this->actor.textId = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96CE4.s") + case 1: + this->actionFunc = func_80B97708; + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + this->unk_2D8[i] = NULL; + } + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + this->unk_2D4 = 0; + func_80B965D0(this, globalCtx); + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96D4C.s") + case 2: + case 3: + case 4: + this->actionFunc = func_80B97B5C; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96DF0.s") + case 5: + this->unk_2F2 |= 4; + this->actionFunc = func_80B97FD0; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + func_80B96BEC(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96E5C.s") + case 6: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 2, 0); + this->actor.colChkInfo.cylRadius = 0; + this->actor.shape.yOffset = -1400.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B96FB0.s") + case 7: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 0, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97100.s") + case 8: + this->actor.flags |= 0x2000000; + this->actionFunc = func_80B98CA8; + func_80B96BEC(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97110.s") + case 9: + this->actionFunc = func_80B990A4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97194.s") + case 10: + this->actionFunc = func_80B992C0; + func_80B96BEC(this, 1, 0); + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97240.s") + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + this->actionFunc = func_80B98998; + func_80B96BEC(this, 2, 0); + this->actor.colChkInfo.cylRadius = 0; + this->actor.shape.yOffset = -1400.0f; + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B972E8.s") + case 18: + this->actionFunc = func_80B99384; + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B973BC.s") + case 19: + func_80B96BEC(this, 7, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B975F8.s") + case 20: + func_80B96BEC(this, 8, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9765C.s") + case 21: + func_80B96BEC(this, 9, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97708.s") + case 22: + this->actionFunc = func_80B980FC; + if (ENZOT_GET_FC00(&this->actor) != 0x3F) { + this->path = &globalCtx->setupPathList[ENZOT_GET_FC00(&this->actor)]; + } else { + this->path = NULL; + } + this->actor.home.rot.x = this->actor.home.rot.z; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9787C.s") + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B979DC.s") +void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZot* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97A44.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + if (ENZOT_GET_1F(&this->actor) == 8) { + gSaveContext.weekEventReg[41] &= (u8)~0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97B5C.s") +void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { + static AnimationHeader* sAnimations[] = { + &D_0600DE20, &D_06002898, &D_0600F4E8, &D_0600E400, &D_0600FDF0, + &D_06010B18, &D_06011424, &D_0600EDF0, &D_0600DF54, &D_0600DF54, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97BF8.s") + if ((arg1 >= 0) && (arg1 < 10)) { + if (arg1 >= 8) { + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 0.0f, arg1 - 8, arg1 - 8, arg2, 0.0f); + } else { + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, + SkelAnime_GetFrameCount(&sAnimations[arg1]->common), arg2, -5.0f); + } + this->unk_2F0 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97C40.s") +s32 func_80B96CE4(EnZot* this) { + s32 i; + s32 count = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97CC8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + if (this->unk_2D8[i] == NULL) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97D6C.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97E0C.s") +void func_80B96D4C(EnZot* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97E4C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++) { + if ((this->unk_2D8[i] != NULL) && (this->unk_2D8[i]->update == NULL)) { + this->unk_2D8[i] = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B97FD0.s") +s32 func_80B96DF0(EnZot* this, GlobalContext* globalCtx) { + if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 100.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B980FC.s") +s32 func_80B96E5C(EnZot* this) { + Path* path = this->path; + Vec3s* points; + f32 temp_f12; + f32 temp_f14; + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98178.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98348.s") + points = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2D4]; + temp_f12 = points->x - this->actor.world.pos.x; + temp_f14 = points->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_f12, temp_f14); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 2000, 200); + phi_f2 = SQ(this->actor.speedXZ) * SQ(3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9849C.s") + if (this->unk_2D4 == 0) { + phi_f2 = SQ(20.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B9854C.s") + if ((SQ(temp_f12) + SQ(temp_f14)) < phi_f2) { + this->unk_2D4++; + if (this->unk_2D4 >= path->count) { + this->actor.world.pos.x = points->x; + this->actor.world.pos.z = points->z; + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B985EC.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98728.s") +s32 func_80B96FB0(EnZot* this) { + Path* path = this->path; + Vec3s* points; + f32 temp_f12; + f32 temp_f14; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98998.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98A4C.s") + points = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2D4]; + temp_f12 = points->x - this->actor.world.pos.x; + temp_f14 = points->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_f12, temp_f14); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 2000, 200); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98AD0.s") + if ((SQ(temp_f12) + SQ(temp_f14)) < SQ(10.0f)) { + if (this->unk_2F2 & 0x20) { + this->unk_2D4--; + if (this->unk_2D4 < 0) { + this->unk_2D4 = 1; + this->unk_2F2 &= ~0x20; + return true; + } + } else { + this->unk_2D4++; + if (this->unk_2D4 >= path->count) { + this->unk_2D4 = path->count - 1; + this->unk_2F2 |= 0x20; + return true; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98BF4.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98CA8.s") +void func_80B97100(EnZot* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98E10.s") +void func_80B97110(EnZot* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98F30.s") + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x125F; + if (gSaveContext.weekEventReg[28] & 0x80) { + textId = 0x1261; + } else { + gSaveContext.weekEventReg[28] |= 0x80; + } + } else { + textId = 0x125C; + if (gSaveContext.weekEventReg[28] & 0x40) { + textId = 0x125E; + } else { + gSaveContext.weekEventReg[28] |= 0x40; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B98F94.s") +void func_80B97194(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x125C: + case 0x125F: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B990A4.s") + case 0x125D: + case 0x125E: + case 0x1260: + case 0x1261: + func_801477B4(globalCtx); + this->actionFunc = func_80B97240; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99160.s") +void func_80B97240(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97194; + func_80B97110(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsActorFacingLink(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B991E4.s") +void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B992C0.s") + if (gSaveContext.weekEventReg[29] & 0x10) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x126A; + if (gSaveContext.weekEventReg[29] & 1) { + textId = 0x126D; + } else { + gSaveContext.weekEventReg[29] |= 1; + } + } else { + textId = 0x1267; + if (gSaveContext.weekEventReg[29] & 2) { + textId = 0x1269; + } else { + gSaveContext.weekEventReg[29] |= 2; + } + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x1265; + if (gSaveContext.weekEventReg[29] & 4) { + textId = 0x1266; + } else { + gSaveContext.weekEventReg[29] |= 4; + } + } else { + textId = 0x1262; + if (gSaveContext.weekEventReg[29] & 8) { + textId = 0x1264; + } else { + gSaveContext.weekEventReg[29] |= 8; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99384.s") +void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { + func_80B96D4C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x126E: + case 0x1270: + case 0x1273: + case 0x1274: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Update.s") + case 0x1272: + func_80151938(globalCtx, 0x126F); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99580.s") + case 0x126F: + func_801159EC(90); + func_80151938(globalCtx, 0x1270); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B995A4.s") + case 0x1275: + if (gSaveContext.rupees < 10) { + func_80151938(globalCtx, 0x1277); + } else { + func_80151938(globalCtx, 0x1278); + func_801159EC(-10); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/func_80B99758.s") + case 0x1276: + func_80151938(globalCtx, 0x1275); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zot/EnZot_Draw.s") + case 0x1271: + case 0x1277: + case 0x1278: + case 0x1279: + func_801477B4(globalCtx); + func_80B965D0(this, globalCtx); + this->actor.flags &= ~0x10000; + this->actor.textId = 0; + this->actionFunc = func_80B97708; + if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { + ActorCutscene_Stop(this->actor.cutscene); + } + this->unk_2F2 &= ~1; + break; + } + } + + if (this->unk_2F2 & 1) { + if (this->actor.cutscene == -1) { + this->unk_2F2 &= ~1; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_2F2 &= ~1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { + func_80B96D4C(this); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B973BC; + } else { + func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, 0); + } +} + +void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + func_80B96D4C(this); + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + u16 temp = globalCtx->msgCtx.unk11F04; + u32 temp2; + + if ((temp == 0x1262) || (temp == 0x1267) || (temp == 0x126A) || (temp == 0x126B)) { + temp2 = temp; + func_80151938(globalCtx, temp2 + 1); + } else { + func_801477B4(globalCtx); + this->actionFunc = func_80B97708; + } + } +} + +void func_80B97708(EnZot* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 phi_v1; + + func_80B96D4C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B9765C; + func_80B972E8(this, globalCtx); + return; + } + + if (!(player->stateFlags1 & 0x2000000)) { + phi_v1 = func_80B96CE4(this); + } else { + phi_v1 = 0; + } + + if (phi_v1 != 0) { + gSaveContext.weekEventReg[29] |= 0x10; + this->actor.flags |= 0x10000; + if (phi_v1 == 5) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.textId = 0x126E; + } else { + this->actor.textId = 0x1272; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.textId = 0x1273; + } else { + this->actor.textId = 0x1276; + } + this->unk_2F2 |= 1; + func_80B975F8(this, globalCtx); + this->actionFunc = func_80B975F8; + } else if (func_80B96DF0(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (this->actor.textId == 0) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + switch (ENZOT_GET_1F(&this->actor)) { + case 2: + if (gSaveContext.weekEventReg[37] & 0x40) { + textId = 0x127E; + } else { + textId = 0x127C; + gSaveContext.weekEventReg[37] |= 0x40; + } + break; + + case 3: + if (gSaveContext.weekEventReg[38] & 1) { + textId = 0x1284; + } else { + textId = 0x1282; + gSaveContext.weekEventReg[38] |= 1; + } + break; + + default: + if (gSaveContext.weekEventReg[38] & 4) { + textId = 0x128A; + } else { + textId = 0x1288; + gSaveContext.weekEventReg[38] |= 4; + } + break; + } + } else { + switch (ENZOT_GET_1F(&this->actor)) { + case 2: + if (gSaveContext.weekEventReg[37] & 0x20) { + textId = 0x127B; + } else { + textId = 0x1279; + gSaveContext.weekEventReg[37] |= 0x20; + } + break; + + case 3: + if (gSaveContext.weekEventReg[37] & 0x80) { + textId = 0x1281; + } else { + textId = 0x127F; + gSaveContext.weekEventReg[37] |= 0x80; + } + break; + + default: + if (gSaveContext.weekEventReg[38] & 2) { + textId = 0x1287; + } else { + textId = 0x1285; + gSaveContext.weekEventReg[38] |= 2; + } + break; + } + } + func_801518B0(globalCtx, textId, &this->actor); + } +} + +void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { + if (func_80B96E5C(this)) { + this->actionFunc = func_80B97B5C; + func_80B96BEC(this, 0, 0); + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 1.5f; + } +} + +void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1279: + case 0x127C: + case 0x127F: + case 0x1282: + case 0x1285: + case 0x1288: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x127D: + case 0x127E: + case 0x1283: + case 0x1284: + case 0x1289: + case 0x128A: + func_801477B4(globalCtx); + if (!(this->unk_2F2 & 2)) { + this->unk_2F2 |= 2; + this->actionFunc = func_80B979DC; + func_80B96BEC(this, 1, 0); + } else { + this->actionFunc = func_80B97B5C; + } + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B97B5C; + break; + } + } +} + +void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97A44; + func_80B9787C(this, globalCtx); + } else if (func_80B96DF0(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x128C; + } else { + textId = 0x128B; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80B97CC8; + } +} + +void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97C40; + func_801518B0(globalCtx, 0x128B, &this->actor); + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { + if (func_80B96E5C(this)) { + this->actionFunc = func_80B97CC8; + this->actor.speedXZ = 0.0f; + func_80B96BEC(this, 0, 0); + } else { + this->actor.speedXZ = 8.0f; + } + + if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 5.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ZORA_WALK); + } +} + +void func_80B97E0C(EnZot* this, GlobalContext* globalCtx) { + if (this->unk_2F2 & 0x40) { + this->actionFunc = func_80B97D6C; + func_80B96BEC(this, 3, 0); + } +} + +void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + if (this->unk_2F2 & 0x40) { + func_80B96BEC(this, 0, 0); + } + + if (!(this->unk_2F2 & 4)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x128C: + this->unk_2F2 &= ~4; + func_80B96BEC(this, 6, 2); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x128D: + case 0x128E: + case 0x128F: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1290: + func_801477B4(globalCtx); + this->actionFunc = func_80B97D6C; + this->unk_2F2 |= 4; + func_80B96BEC(this, 3, 0); + gSaveContext.weekEventReg[38] |= 8; + break; + + case 0x128B: + func_801477B4(globalCtx); + this->actionFunc = func_80B97FD0; + break; + } + } +} + +void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B97E4C; + func_80B97BF8(this, globalCtx); + } else if (gSaveContext.weekEventReg[38] & 8) { + if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + this->unk_2F2 |= 4; + this->actionFunc = func_80B97E0C; + func_80B96BEC(this, 6, 2); + } + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B980FC(EnZot* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.home.rot.x--; + } else if (func_80B96E5C(this)) { + this->actionFunc = func_80B97100; + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 8.0f; + if (this->unk_2F0 != 3) { + func_80B96BEC(this, 3, 0); + } + } +} + +void func_80B98178(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + s32 phi_v0; + + switch (ENZOT_GET_1F(&this->actor)) { + case 6: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (CURRENT_DAY == 3) { + textId = 0x129D; + } else if (gSaveContext.weekEventReg[39] & 1) { + textId = 0x129C; + } else { + textId = 0x129B; + gSaveContext.weekEventReg[39] |= 1; + } + } else if (gSaveContext.weekEventReg[38] & 0x80) { + textId = 0x1293; + } else { + textId = 0x1291; + gSaveContext.weekEventReg[38] |= 0x80; + } + break; + + case 7: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[39] & 4) { + textId = 0x12AA; + } else { + textId = 0x12A6; + gSaveContext.weekEventReg[39] |= 4; + } + } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + textId = 0x12A0; + } else if (gSaveContext.weekEventReg[39] & 2) { + textId = 0x12A5; + } else { + textId = 0x12A2; + gSaveContext.weekEventReg[39] |= 2; + } + break; + + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; + if (gSaveContext.weekEventReg[79] & 1) { + phi_v0 += 2; + } + + if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + phi_v0++; + } + textId = phi_v0 + 0x1302; + break; + + default: + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + textId = 0x129F; + } else { + textId = 0x1295; + } + break; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98348(EnZot* this, GlobalContext* globalCtx) { + s16 y; + + if (ENZOT_GET_1F(&this->actor) == 7) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (Actor_IsActorFacingLink(&this->actor, 0x3000)) { + this->unk_2F2 &= ~8; + } else { + this->unk_2F2 |= 8; + Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.x, 0, 6, 6200, 100); + y = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (y > 0) { + Math_SmoothStepToS(&this->unk_2C4.y, 0x3000, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, 0x1000, 6, 6200, 100); + } else { + Math_SmoothStepToS(&this->unk_2C4.y, -0x3000, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, -0x1000, 6, 6200, 100); + } + } +} + +void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + if (func_800B84D0(&this->actor, globalCtx)) { + if (this->unk_2D4 == 2) { + func_801518B0(globalCtx, 0x12AD, &this->actor); + } else { + func_801518B0(globalCtx, 0x12B0, &this->actor); + } + this->actionFunc = func_80B98728; + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B9849C; + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + func_800B8A1C(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); + } +} + +void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { + s32 temp_v0; + Player* player = PLAYER; + + func_80B98348(this, globalCtx); + if (func_80152498(&globalCtx->msgCtx) == 0x10) { + temp_v0 = func_80123810(globalCtx); + if (temp_v0 > 0) { + func_801477B4(globalCtx); + if ((temp_v0 == 0x13) && CHECK_QUEST_ITEM(25) && func_8013A4C4(4)) { + if (func_8013A4C4(5) && func_8013A4C4(6)) { + player->actor.textId = 0x12AE; + } else { + player->actor.textId = 0x12AC; + } + REMOVE_QUEST_ITEM(25); + } else { + player->actor.textId = 0x12AB; + } + this->actionFunc = func_80B98728; + } else if (temp_v0 < 0) { + func_80151938(globalCtx, 0x12AB); + this->actionFunc = func_80B98728; + } + } +} + +void func_80B98728(EnZot* this, GlobalContext* globalCtx) { + func_80B98348(this, globalCtx); + + switch (func_80152498(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0x1294); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1298); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1291: + case 0x1292: + case 0x1296: + case 0x1298: + case 0x1299: + case 0x129B: + case 0x129D: + case 0x129E: + case 0x12A0: + case 0x12A2: + case 0x12A3: + case 0x12A4: + case 0x12A6: + case 0x12A7: + case 0x12A8: + case 0x12AE: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12A9: + case 0x12AA: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80B985EC; + break; + + case 0x1294: + if (CURRENT_DAY == 3) { + func_80151938(globalCtx, 0x1296); + } else { + func_80151938(globalCtx, 0x1295); + } + break; + + case 0x12AB: + func_801477B4(globalCtx); + this->actionFunc = func_80B98998; + break; + + case 0x12AC: + func_801477B4(globalCtx); + this->unk_2D4 = 2; + this->actionFunc = func_80B9854C; + func_80B9854C(this, globalCtx); + break; + + case 0x12AF: + func_801477B4(globalCtx); + this->unk_2D4 = 4; + this->actionFunc = func_80B9854C; + func_80B9854C(this, globalCtx); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B98998; + this->actor.flags &= ~0x10000; + break; + } + } + break; + } +} + +void func_80B98998(EnZot* this, GlobalContext* globalCtx) { + this->unk_2F2 &= ~8; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98728; + func_80B98178(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsActorFacingLink(&this->actor, 0x7000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[39] & 0x80) { + textId = 0x12B6; + } else { + textId = 0x12B4; + gSaveContext.weekEventReg[39] |= 0x80; + } + } else if (gSaveContext.weekEventReg[39] & 0x40) { + textId = 0x12B3; + } else { + textId = 0x12B1; + gSaveContext.weekEventReg[39] |= 0x40; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12B1: + case 0x12B4: + case 0x12B7: + case 0x12B9: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12B8: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + gSaveContext.weekEventReg[41] &= (u8)~0x20; + func_8019C300(0); + break; + + case 0x12BA: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + gSaveContext.weekEventReg[41] |= 0x20; + func_8019C300(0); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B98CA8; + break; + } + } +} + +void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + if (gSaveContext.weekEventReg[41] & 0x20) { + func_801518B0(globalCtx, 0x12B7, &this->actor); + this->actionFunc = func_80B98AD0; + } else { + func_801518B0(globalCtx, 0x12B9, &this->actor); + this->actionFunc = func_80B98AD0; + } + } else { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->actor, globalCtx)) { + globalCtx->msgCtx.unk1202A = 4; + func_8019B544(0xFFFF); + this->actionFunc = func_80B98BF4; + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 120.0f); + } else if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98AD0; + func_80B98A4C(this, globalCtx); + } else { + if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { + func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); + } + } + + if (this->actor.xzDistToPlayer > 100.0f) { + gSaveContext.weekEventReg[41] &= (u8)~0x20; + } +} + +void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (gSaveContext.weekEventReg[40] & 4) { + textId = 0x12C5; + } else { + textId = 0x12C3; + gSaveContext.weekEventReg[40] |= 4; + } + } else if (gSaveContext.weekEventReg[40] & 2) { + textId = 0x12C2; + } else { + textId = 0x12C0; + gSaveContext.weekEventReg[40] |= 2; + } + } else { + if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { + if (this->unk_2F2 & 0x10) { + textId = 0x12BF; + } else { + textId = 0x12BE; + this->unk_2F2 |= 0x10; + } + } else if (gSaveContext.weekEventReg[40] & 1) { + textId = 0x12BC; + } else { + gSaveContext.weekEventReg[40] |= 1; + this->unk_2F2 |= 4; + textId = 0x12BB; + } + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B990A4; + } else { + func_800B8A1C(&this->actor, globalCtx, 2, 10000.0f, 50.0f); + } +} + +void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { + if (!(this->unk_2F2 & 4)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12BB: + this->unk_2F2 &= ~4; + + case 0x12BC: + case 0x12C0: + case 0x12C3: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x12BE: + func_801477B4(globalCtx); + this->actionFunc = func_80B98F30; + func_80B98F30(this, globalCtx); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B990A4; + break; + } + } +} + +void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B98F94; + func_80B98E10(this, globalCtx); + } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80B99160(EnZot* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[40] & 0x10) { + textId = 0x12CD; + } else { + textId = 0x12CA; + gSaveContext.weekEventReg[40] |= 0x10; + } + } else if (gSaveContext.weekEventReg[40] & 8) { + textId = 0x12C9; + } else { + textId = 0x12C6; + gSaveContext.weekEventReg[40] |= 8; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { + if (1) { + do { } while (0); } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + u16 temp = globalCtx->msgCtx.unk11F04; + u32 temp2; + + if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { + temp2 = temp; + func_80151938(globalCtx, temp2 + 1); + } else { + func_801477B4(globalCtx); + this->actionFunc = func_80B992C0; + func_80B96BEC(this, 1, 0); + } + } +} + +void func_80B992C0(EnZot* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B991E4; + func_80B99160(this, globalCtx); + this->actor.speedXZ = 0.0f; + func_80B96BEC(this, 0, 0); + } else { + if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + this->actor.speedXZ = 1.5f; + func_80B96FB0(this); + } +} + +void func_80B99384(EnZot* this, GlobalContext* globalCtx) { +} + +void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZot* this = THIS; + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + this->unk_2F2 &= ~0x40; + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2F0 != 0)) { + this->unk_2F2 |= 0x40; + } + + this->actionFunc(this, globalCtx); + if (!(this->unk_2F2 & 8)) { + if (!(this->unk_2F2 & 4) && func_80B96DF0(this, globalCtx)) { + func_800E9250(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2C4.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CA.y, 0, 6, 6200, 100); + } + } + + if (DECR(this->unk_2EE) == 0) { + this->unk_2EE = Rand_S16Offset(60, 60); + } + + this->unk_2EC = this->unk_2EE; + if (this->unk_2EC > 2) { + this->unk_2EC = 0; + } +} + +Gfx* func_80B99580(GraphicsContext* gfxCtx) { + Gfx* dList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(dList); + + return dList; +} + +s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZot* this = THIS; + s32 pad; + + if (limbIndex == 15) { + SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); + SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 8) { + SysMatrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + } + + if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && + ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13))) { + rot->y += (s16)(Math_SinS(globalCtx->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(globalCtx->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); + } + return false; +} + +void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B99934 = { 400.0f, 0.0f, 0.0f }; + EnZot* this = THIS; + + if (limbIndex == 15) { + SysMatrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + } +} + +void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { + UNK_PTR sp4C[] = { + &D_060050A0, + &D_060058A0, + &D_060060A0, + }; + EnZot* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk_2EC])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80B99580(globalCtx->state.gfxCtx)); + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnZot_OverrideLimbDraw, EnZot_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.h b/src/overlays/actors/ovl_En_Zot/z_en_zot.h index 0a5b8137a..06fb724ae 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.h +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.h @@ -7,9 +7,25 @@ struct EnZot; typedef void (*EnZotActionFunc)(struct EnZot*, GlobalContext*); +#define ENZOT_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENZOT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnZot { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ Vec3s unk_2C4; + /* 0x02CA */ Vec3s unk_2CA; + /* 0x02D0 */ Path* path; + /* 0x02D4 */ s32 unk_2D4; + /* 0x02D8 */ Actor* unk_2D8[5]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ u16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; /* 0x02F8 */ EnZotActionFunc actionFunc; } EnZot; // size = 0x2FC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 67d5f1632..2dd3d78eb 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14940,8 +14940,8 @@ 0x80B99384:("func_80B99384",), 0x80B99394:("EnZot_Update",), 0x80B99580:("func_80B99580",), - 0x80B995A4:("func_80B995A4",), - 0x80B99758:("func_80B99758",), + 0x80B995A4:("EnZot_OverrideLimbDraw",), + 0x80B99758:("EnZot_PostLimbDraw",), 0x80B99798:("EnZot_Draw",), 0x80B9A0B0:("ObjTree_Init",), 0x80B9A1BC:("ObjTree_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a3ecdeade..4441d7553 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3783,9 +3783,20 @@ D_06015238 = 0x06015238; // ovl_En_Zot +D_06002898 = 0x06002898; D_06004248 = 0x06004248; +D_060050A0 = 0x060050A0; +D_060058A0 = 0x060058A0; +D_060060A0 = 0x060060A0; D_0600D208 = 0x0600D208; D_0600DE20 = 0x0600DE20; +D_0600DF54 = 0x0600DF54; +D_0600E400 = 0x0600E400; +D_0600EDF0 = 0x0600EDF0; +D_0600F4E8 = 0x0600F4E8; +D_0600FDF0 = 0x0600FDF0; +D_06010B18 = 0x06010B18; +D_06011424 = 0x06011424; // ovl_En_Zov From 9478fc760f7b049ddbcc608c0d119cf593071408 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 28 Sep 2021 22:56:25 +0100 Subject: [PATCH 12/86] Thiefbird (#290) * Thiefbird * Fix enums * Rename funcs * PR --- include/functions.h | 2 +- spec | 4 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 1106 ++++++++++++++++- .../actors/ovl_En_Thiefbird/z_en_thiefbird.h | 32 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 3 + 6 files changed, 1081 insertions(+), 70 deletions(-) diff --git a/include/functions.h b/include/functions.h index c87bfe03c..b5ab76f9a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2142,7 +2142,7 @@ void func_80112B40(GlobalContext* globalCtx, s32 arg1); u32 Item_Give(GlobalContext* globalCtx, u8 param_2); // void func_801143CC(void); UNK_TYPE func_80114978(UNK_TYPE arg0); -// void func_801149A0(void); +void func_801149A0(s32 arg0, s16 arg1); // void func_80114A9C(void); // void func_80114B84(void); // void func_80114CA0(void); diff --git a/spec b/spec index daed42bf4..2ecd6ccbd 100644 --- a/spec +++ b/spec @@ -5308,9 +5308,7 @@ beginseg name "ovl_En_Thiefbird" compress include "build/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.o" - include "build/data/ovl_En_Thiefbird/ovl_En_Thiefbird.data.o" - include "build/data/ovl_En_Thiefbird/ovl_En_Thiefbird.bss.o" - include "build/data/ovl_En_Thiefbird/ovl_En_Thiefbird.reloc.o" + include "build/src/overlays/actors/ovl_En_Thiefbird/ovl_En_Thiefbird_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index ff11005fc..d0a7b9498 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -1,3 +1,9 @@ +/* + * File: z_en_thiefbird.c + * Overlay: ovl_En_Thiefbird + * Description: Takkuri + */ + #include "z_en_thiefbird.h" #define FLAGS 0x80001205 @@ -9,17 +15,39 @@ void EnThiefbird_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx); void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C11538(EnThiefbird* this); void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C118E4(EnThiefbird* this); void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx); void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C11DC0(EnThiefbird* this); void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx); void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C12308(EnThiefbird* this); void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C1242C(EnThiefbird* this); void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C126A8(EnThiefbird* this); void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx); +void func_80C12744(EnThiefbird* this); void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_06000088; +extern AnimationHeader D_06000278; +extern AnimationHeader D_06000604; +extern Gfx D_06003060[]; +extern Gfx D_060030D8[]; +extern UNK_PTR D_060033B0; +extern UNK_PTR D_06003D58; +extern UNK_TYPE D_06004348; +extern UNK_TYPE D_06004B88; +extern UNK_TYPE D_060055E0; +extern FlexSkeletonHeader D_060061A0; +extern AnimationHeader D_060063C4; + +static Vec3f D_80C13920; +static s32 D_80C1392C; + const ActorInit En_Thiefbird_InitVars = { ACTOR_EN_THIEFBIRD, ACTORCAT_ENEMY, @@ -32,33 +60,58 @@ const ActorInit En_Thiefbird_InitVars = { (ActorFunc)EnThiefbird_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_80C135C0[3] = { +static ColliderJntSphElementInit sJntSphElementsInit[3] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 24 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, { { 900, -600, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 12, { { 1200, 0, 0 }, 9 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80C1362C = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_80C135C0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 3, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80C1363C = { 24, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 24, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_80C13644 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -93,93 +146,1022 @@ static DamageTable D_80C13644 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C13670[] = { +static s16 D_80C13664[] = { ITEM00_ARROWS_10, ITEM00_BOMBS_B, ITEM00_RUPEE_GREEN, + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 35, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -#endif +void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { + EnThiefbird* this = THIS; + s32 i; + ColliderJntSphElementDim* dim; -extern ColliderJntSphElementInit D_80C135C0[3]; -extern ColliderJntSphInit D_80C1362C; -extern CollisionCheckInfoInit D_80C1363C; -extern DamageTable D_80C13644; -extern InitChainEntry D_80C13670[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060061A0, &D_06000604, this->jointTable, this->morphTable, 17); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -extern UNK_TYPE D_06000088; -extern UNK_TYPE D_06000278; -extern UNK_TYPE D_06000604; -extern UNK_TYPE D_06003060; -extern UNK_TYPE D_060033B0; -extern UNK_TYPE D_060063C4; + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + dim = &this->collider.elements[i].dim; + dim->worldSphere.radius = dim->modelSphere.radius; + dim->worldSphere.center.x = this->actor.world.pos.x; + dim->worldSphere.center.y = this->actor.world.pos.y; + dim->worldSphere.center.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/EnThiefbird_Init.s") + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 1500.0f, func_800B3FC0, 35.0f); + if (this->actor.params == 1) { + D_80C1392C = 1; + Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); + Actor_MarkForDeath(&this->actor); + } else if ((gSaveContext.roomInf[126][5] & 0xFF000000) >> 0x18) { + Actor_MarkForDeath(&this->actor); + } else { + func_80C11538(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/EnThiefbird_Destroy.s") +void EnThiefbird_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnThiefbird* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C10984.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C10B0C.s") +void func_80C10984(EnThiefbird* this, s32 arg1) { + s32 i; + EnThiefbirdUnkStruct* ptr = &this->unk_3F0[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C10DE8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { + if (ptr->unk_22 == 0) { + ptr->unk_22 = (s32)Rand_ZeroFloat(20.0f) + 40; + ptr->unk_00.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.focus.pos.x; + ptr->unk_00.y = randPlusMinusPoint5Scaled(30.0f) + this->actor.focus.pos.y; + ptr->unk_00.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.focus.pos.z; + ptr->unk_0C.x = randPlusMinusPoint5Scaled(5.0f); + ptr->unk_0C.y = Rand_ZeroOne() + 2.0f; + ptr->unk_0C.z = randPlusMinusPoint5Scaled(5.0f); + ptr->unk_1C = Rand_ZeroFloat(1000.0f); + ptr->unk_18 = (Rand_ZeroFloat(20.0f) + 40.0f) * 0.0001f; + ptr->unk_1E = Rand_Next() >> 0x10; + arg1--; + if (arg1 == 0) { + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C10E98.s") +s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { + static UNK_TYPE D_80C13680[] = { &D_06004348, &D_06004B88, &D_060055E0 }; + s32 isItemFound = false; + s32 phi_a3 = 0; + s32 i = 18; + s32 phi_t0_3; + s16 sp1E = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11338.s") + for (; i < ARRAY_COUNT(gSaveContext.inventory.items); i++) { + if ((gSaveContext.inventory.items[i] >= ITEM_BOTTLE) && (gSaveContext.inventory.items[i] <= ITEM_POTION_BLUE)) { + isItemFound = true; + sp1E = gSaveContext.inventory.items[i]; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11454.s") + if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + phi_a3 = CUR_EQUIP_VALUE_VOID(EQUIP_SWORD); + if (gSaveContext.inventory.items[gItemSlots[16]] == ITEM_SWORD_GREAT_FAIRY) { + phi_a3 += 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C114C0.s") + if (isItemFound && (phi_a3 != 0)) { + if (Rand_ZeroOne() < 0.6f) { + isItemFound = false; + } else { + phi_a3 = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11538.s") + if (isItemFound) { + func_801149A0(sp1E, i); + this->unk_3E8 = &D_060033B0; + if (!func_80152498(&globalCtx->msgCtx)) { + func_801518B0(globalCtx, 0xF4, NULL); + } + phi_t0_3 = 0x12; + } else if (phi_a3 != 0) { + if (phi_a3 >= 5) { + if (Rand_ZeroOne() < 0.5f) { + phi_a3 -= 4; + } else { + phi_a3 = 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11590.s") + phi_t0_3 = phi_a3 + 0x4C; + if (phi_a3 == 4) { + func_801149A0(16, 16); + this->unk_3E8 = &D_06003D58; + phi_t0_3 = 0x10; + } else { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; + TAKE_EQUIPPED_ITEM(EQUIP_SWORD); + this->unk_3E8 = D_80C13680[phi_a3 - 1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C118E4.s") + if (!func_80152498(&globalCtx->msgCtx)) { + func_801518B0(globalCtx, 0xF5, NULL); + } + } else { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C1193C.s") + if (!((gSaveContext.roomInf[126][5] & 0xFF000000) >> 0x18)) { + gSaveContext.roomInf[126][5] = (gSaveContext.roomInf[126][5] & 0xFFFFFF) | ((phi_t0_3 & 0xFF) << 0x18); + } else { + gSaveContext.roomInf[126][5] = (gSaveContext.roomInf[126][5] & 0xFF00FFFF) | ((phi_t0_3 & 0xFF) << 0x10); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11C60.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11D14.s") +void func_80C10DE8(s32 items[], s32 count, s32 item) { + s32 i; + s32 idx = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11DC0.s") + for (i = 0; i < count; i++) { + s32 j = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11DF0.s") + while (items[idx] != -1) { + idx = (idx + 5) % 8; + if (j == 8) { + break; + } + j++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C11F6C.s") + items[idx] = item; + idx = (idx + 5) % 8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C1215C.s") +s32 func_80C10E98(GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 phi_s0_2; + s32 phi_s2; + s32 spB0; + s32 spAC; + s32 spA8; + s16 phi_s3 = 0; + s32 spA0; + s32 pad2; + s32 sp98; + s32 i; + s32 sp74[8]; + s32 sp5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C12308.s") + for (i = 0; i < ARRAY_COUNT(sp74); i++) { + sp74[i] = ITEM00_NO_DROP; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C12378.s") + if (AMMO(ITEM_BOMB) >= 5) { + spB0 = 1; + sp74[1] = ITEM00_BOMBS_B; + if (1) {} + } else { + spB0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C1242C.s") + if (AMMO(ITEM_BOW) >= 10) { + spAC = 1; + sp74[5] = ITEM00_ARROWS_10; + } else { + spAC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C124B0.s") + sp98 = (gSaveContext.rupees / 4) * 3; + phi_s0_2 = sp98 / 50; + sp5C = (-spB0 - spAC); + sp5C += 8; + if (sp5C < phi_s0_2) { + phi_s0_2 = sp5C; + } + phi_s2 = phi_s0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C126A8.s") + for (i = 0; i < phi_s2; i++) { + if (Rand_ZeroOne() < 0.5f) { + phi_s0_2--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C126D8.s") + i = sp5C - phi_s0_2; + if (i) {} + sp5C = phi_s0_2 * 50; + sp98 -= sp5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C12744.s") + func_80C10DE8(sp74, phi_s0_2, ITEM00_RUPEE_PURPLE); + spA0 = sp98 / 20; + if (i < spA0) { + spA0 = i; + } + i -= spA0; + sp98 -= spA0 * 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C127F4.s") + func_80C10DE8(sp74, spA0, ITEM00_RUPEE_RED); + phi_s2 = sp98 / 5; + if (i < phi_s2) { + phi_s2 = i; + } + i -= phi_s2; + sp98 -= phi_s2 * 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C12B1C.s") + func_80C10DE8(sp74, phi_s2, ITEM00_RUPEE_BLUE); + if (i < sp98) { + spA8 = i; + } else { + spA8 = sp98; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C12D00.s") + func_80C10DE8(sp74, spA8, ITEM00_RUPEE_GREEN); + if ((spB0 + spAC + phi_s0_2 + spA0 + phi_s2 + spA8) == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/EnThiefbird_Update.s") + { + Vec3f sp64; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C130EC.s") + for (i = 0; i < ARRAY_COUNT(sp74); i++) { + sp64.x = (Math_SinS(phi_s3) * 40.0f) + player->actor.world.pos.x; + sp64.y = player->actor.world.pos.y + 20.0f; + sp64.z = (Math_CosS(phi_s3) * 40.0f) + player->actor.world.pos.z; + if (sp74[i] != ITEM00_NO_DROP) { + EnItem00* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, sp74[i]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C1315C.s") + if (temp_s1_5 != NULL) { + temp_s1_5->actor.velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; + temp_s1_5->actor.speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; + temp_s1_5->actor.world.rot.y = phi_s3; + } + phi_s3 += (s16)(0x10000 / (spB0 + spAC + phi_s0_2 + spA0 + phi_s2 + spA8)); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/func_80C13354.s") + AMMO(ITEM_BOMB) -= spB0 * 5; + AMMO(ITEM_BOW) -= spAC * 10; + func_801159EC(-((phi_s0_2 * 50) + (spA0 * 20) + (phi_s2 * 5) + spA8)); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Thiefbird/EnThiefbird_Draw.s") +void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + EnItem00* item = NULL; + f32 phi_f20 = 5000.0f; + s32 i; + f32 temp_f0; + + this->unk_3EC = NULL; + + do { + item = (EnItem00*)func_ActorCategoryIterateById(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); + if (item != NULL) { + if (item->unk152 > 0) { + if (Actor_XZDistanceBetweenActors(&player->actor, &item->actor) > 10.0f) { + for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { + if (item->actor.params == D_80C13664[i]) { + break; + } + } + + if (i != ARRAY_COUNT(D_80C13664)) { + temp_f0 = Actor_DistanceBetweenActors(&this->actor, &item->actor); + if (temp_f0 < phi_f20) { + this->unk_3EC = item; + phi_f20 = temp_f0; + } + } + } + } + item = (EnItem00*)item->actor.next; + } + } while (item != NULL); +} + +void func_80C11454(EnThiefbird* this) { + this->unk_18C = 10; + this->unk_3D8 = 0.5f; + this->unk_3DC = 0.75f; + this->unk_3D4 = 1.0f; + this->actor.flags &= ~0x200; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); +} + +void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { + if (this->unk_18C == 10) { + this->unk_18C = 0; + this->unk_3D4 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); + this->actor.flags |= 0x200; + } +} + +void func_80C11538(EnThiefbird* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000604, -4.0f); + this->unk_18E = 60; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = func_80C11590; +} + +void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 sp38; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + sp38 = func_801378B8(&this->skelAnime, 0.0f); + this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; + + if (this->actor.bgCheckFlags & 8) { + this->unk_192 = this->actor.wallYaw; + } else { + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 5, 0x300, 0x10) && (sp38 != 0) && + (Rand_ZeroOne() < 0.1f)) { + s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y; + + if (yaw > 0) { + this->unk_192 += Rand_S16Offset(4096, 4096); + } else { + this->unk_192 -= Rand_S16Offset(4096, 4096); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + } + + if ((this->actor.yDistToWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + this->unk_190 = -4096; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 75.0f)) { + this->unk_190 = -Rand_S16Offset(2048, 2048); + } else if ((this->actor.home.pos.y + 75.0f) < this->actor.world.pos.y) { + this->unk_190 = Rand_S16Offset(2048, 2048); + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_190, 10, 0x100, 8) && (sp38 != 0) && + (Rand_ZeroOne() < 0.1f)) { + if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->unk_190 -= Rand_S16Offset(0x400, 0x400); + } else { + this->unk_190 += Rand_S16Offset(0x400, 0x400); + } + + this->unk_190 = CLAMP(this->unk_190, -4096, 4096); + } + + if (this->unk_18E != 0) { + this->unk_18E--; + } + + if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.yDistToWater < -40.0f)) { + func_80C118E4(this); + } +} + +void func_80C118E4(EnThiefbird* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060063C4, -10.0f); + this->unk_18E = 300; + this->actionFunc = func_80C1193C; + this->actor.speedXZ = 5.0f; +} + +void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 pitch; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 1.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + } + + if (this->unk_18E != 0) { + this->unk_18E--; + } + + pitch = Actor_PitchBetweenActors(&this->actor, &player->actor); + pitch = CLAMP(pitch, -0x2800, 0x2800); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitch, 4, 0x800, 0x80); + if (this->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); + } else if (Actor_IsActorFacingLink(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { + s16 rot = BINANG_ROT180(this->actor.yawTowardsPlayer - player->actor.shape.rot.y); + + if (rot > 0x4000) { + rot = this->actor.yawTowardsPlayer + 0x3000; + } else if (rot < -0x4000) { + rot = this->actor.yawTowardsPlayer - 0x3000; + } else { + rot = this->actor.yawTowardsPlayer; + } + Math_SmoothStepToS(&this->actor.shape.rot.y, rot, 4, 0x1000, 0x100); + } + + if ((this->unk_18E == 0) || (player->stateFlags1 & 0x800000) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->collider.base.atFlags & AT_HIT) || + (this->actor.bgCheckFlags & 1) || (this->actor.yDistToWater > -40.0f)) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + if (!(this->collider.base.atFlags & AT_BOUNCED)) { + if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && + (!((gSaveContext.roomInf[126][5] & 0xFF000000) >> 0x18) || + !((gSaveContext.roomInf[126][5] & 0xFF0000) >> 0x10)) && + (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { + func_80C1242C(this); + } else if (func_80C10E98(globalCtx)) { + func_80C11338(this, globalCtx); + func_80C12744(this); + } else { + func_80C11538(this); + } + } else { + func_80C12308(this); + } + } else { + func_80C11538(this); + } + } +} + +void func_80C11C60(EnThiefbird* this) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000088); + this->actor.bgCheckFlags &= ~1; + this->actor.shape.rot.x = 0; + this->unk_18E = 40; + this->actor.velocity.y = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); + func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= 0x10; + this->unk_192 = 0x1C00; + this->actionFunc = func_80C11D14; +} + +void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { + this->actor.colorFilterTimer = 40; + if (this->unk_18E != 0) { + this->unk_18E--; + } + + if (this->unk_18C == 10) { + if (this->unk_18E < 38) { + func_80C114C0(this, globalCtx); + this->actor.speedXZ = 4.0f; + } else { + return; + } + } + + if (this->unk_18E < 20) { + Math_ScaledStepToS(&this->unk_192, 0, 0x200); + } + + this->actor.shape.rot.y += this->unk_192; + if (this->unk_18E == 0) { + func_80C11DC0(this); + } +} + +void func_80C11DC0(EnThiefbird* this) { + this->actor.flags &= ~1; + this->actionFunc = func_80C11DF0; + this->actor.gravity = -0.5f; +} + +void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { + s32 i; + s32 j; + + if (Math_ScaledStepToS(&this->actor.shape.rot.x, -0x8000, 0x800)) { + Math_ScaledStepToS(&this->unk_192, 0x1C00, 0x200); + this->actor.shape.rot.y += this->unk_192; + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + for (i = 0; i < ARRAY_COUNT(this->unk_350); i++) { + func_800B3030(globalCtx, &this->unk_350[i], &D_801D15B0, &D_801D15B0, 0x8C, 0, 0); + } + + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_ORANGE); + + for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { + for (j = 0; j < this->unk_196[i]; j++) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, D_80C13664[i]); + } + } + + Actor_MarkForDeath(&this->actor); + } +} + +void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000278, -4.0f); + func_80C10984(this, 15); + if (this->actor.colChkInfo.damageEffect != 3) { + this->actor.speedXZ = 4.0f; + } else { + this->actor.speedXZ = 0.0f; + } + + if (this->actor.colChkInfo.damageEffect == 5) { + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + } else if (this->actor.colChkInfo.damageEffect == 1) { + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + } else { + func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); + } + + this->collider.base.acFlags &= ~AC_ON; + if (this->unk_3E8 == 0) { + this->unk_190 = -0x1000; + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + } else { + this->unk_190 = Actor_PitchToPoint(&this->actor, &D_80C13920); + } + + this->unk_18E = 40; + if (Rand_ZeroOne() < 0.9f) { + Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + } + + if (Rand_ZeroOne() < 0.6f) { + Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + } + + if (Rand_ZeroOne() < 0.3f) { + Item_DropCollectible(globalCtx, &this->actor.focus.pos, ITEM00_RUPEE_GREEN); + } + this->actionFunc = func_80C1215C; +} + +void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { + f32 sp2C; + + if (this->unk_18E != 0) { + this->unk_18E--; + } + + if (this->unk_18C == 10) { + if (this->unk_18E < 38) { + func_80C114C0(this, globalCtx); + this->actor.speedXZ = 4.0f; + } else { + return; + } + } + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->actor.bgCheckFlags & 8) { + this->unk_192 = this->actor.wallYaw; + } else if (this->unk_3E8 == 0) { + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + } else { + this->unk_192 = Actor_YawToPoint(&this->actor, &D_80C13920); + this->unk_190 = Actor_PitchToPoint(&this->actor, &D_80C13920); + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_190, 5, 0x100, 0x10); + sp2C = (this->unk_18E * 153.6f) + 0x800; + this->actor.shape.rot.z = Math_SinS(this->unk_18E * 0x1999) * sp2C; + if (this->unk_18E == 0) { + if (this->unk_3E8 != 0) { + func_80C1242C(this); + } else if (this->unk_3EC != 0) { + func_80C12744(this); + } else { + func_80C11538(this); + } + } +} + +void func_80C12308(EnThiefbird* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000278, -4.0f); + func_80C10984(this, 15); + this->unk_190 = -0x1000; + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + this->unk_18E = 40; + this->actionFunc = func_80C12378; +} + +void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { + if (this->unk_18E != 0) { + this->unk_18E--; + } + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->actor.bgCheckFlags & 8) { + this->unk_192 = this->actor.wallYaw; + } else { + this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_190, 5, 0x100, 0x10); + + if (this->unk_18E == 0) { + func_80C11538(this); + } +} + +void func_80C1242C(EnThiefbird* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_06000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); + this->actor.flags |= 0x10; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = func_80C124B0; + this->actor.speedXZ = 12.0f; +} + +void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { + Actor* temp_v0; + s16 temp_v1; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->actor.bgCheckFlags & 8) { + this->unk_192 = this->actor.wallYaw; + } else { + this->unk_192 = Actor_YawToPoint(&this->actor, &D_80C13920); + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &D_80C13920), 6, 0x1000, 0x100); + temp_v0 = func_800BC270(globalCtx, &this->actor, 80.0f, 0x138B0); + if (temp_v0 != NULL) { + temp_v1 = temp_v0->world.rot.x - Actor_PitchToPoint(temp_v0, &this->actor.focus.pos); + if (ABS_ALT(temp_v1) < 0x1800) { + if (temp_v1 > 0) { + this->unk_3E0 = 25.0f; + } else { + this->unk_3E0 = -25.0f; + } + } + } + + if (!Math_StepToF(&this->unk_3E0, 0.0f, 5.0f)) { + this->actor.world.pos.x += + this->unk_3E0 * Math_SinS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y); + this->actor.world.pos.y += this->unk_3E0 * Math_CosS(this->actor.shape.rot.x); + this->actor.world.pos.x += + this->unk_3E0 * Math_SinS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); + } + + if (Actor_DistanceToPoint(&this->actor, &D_80C13920) < 1000.0f) { + func_80C126A8(this); + } +} + +void func_80C126A8(EnThiefbird* this) { + this->actor.flags &= ~1; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80C126D8; +} + +void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_ApproachS(&this->actor.shape.rot.x, 0x3000, 6, 0x1000); + if (this->actor.yDistToPlayer > 100.0f) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80C12744(EnThiefbird* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000604, -4.0f); + SkelAnime_ChangeAnim(&this->skelAnime, &D_06000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); + this->unk_190 = 0; + this->collider.base.acFlags |= AC_ON; + this->actor.flags |= 0x10; + this->actionFunc = func_80C127F4; + this->actor.speedXZ = 4.0f; + this->skelAnime.animPlaybackSpeed = 3.0f; +} + +void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 temp_v0; + f32 temp_f0; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((this->unk_3EC != NULL) && ((this->unk_3EC->actor.update == NULL) || (this->unk_3EC->unk152 == 0) || + (Actor_XZDistanceBetweenActors(&player->actor, &this->unk_3EC->actor) <= 10.0f))) { + this->unk_3EC = NULL; + } + + if (this->unk_190 == -0x3800) { + if (Math_ScaledStepToS(&this->unk_194, this->unk_190, 0xE00)) { + this->unk_190 = 0; + } + } else { + Math_ScaledStepToS(&this->unk_194, 0, 0x200); + } + + if (this->unk_3EC == NULL) { + func_80C11338(this, globalCtx); + } + + if (this->unk_3EC != NULL) { + if (this->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 3, 0x2000, 0x100); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, + 0x2000, 0x100); + } + temp_v0 = Math_Vec3f_Pitch(&this->unk_350[9], &this->unk_3EC->actor.world.pos); + temp_v0 = CLAMP(temp_v0, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, temp_v0, 4, 0x800, 0x80); + temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->unk_350[9]); + this->actor.speedXZ = (0.02f * temp_f0) + 2.0f; + this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); + if ((this->unk_3EC->actor.speedXZ <= 0.0f) && (temp_f0 < 40.0f)) { + s32 i; + + this->unk_3EC->unk152 = 0; + for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { + if (this->unk_3EC->actor.params == D_80C13664[i]) { + this->unk_196[i]++; + break; + } + } + this->unk_3EC = NULL; + this->unk_194 = 0x100; + this->unk_190 = -0x3800; + } + } else { + this->actor.speedXZ = 4.0f; + if (this->actor.bgCheckFlags & 8) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 6, 0x1000, 0x100); + } + + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 4, 0x800, 0x80); + if (this->unk_194 == 0) { + this->actor.flags &= ~0x10; + func_80C11538(this); + } + } +} + +void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { + ColliderJntSphElement* sph; + s32 i; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~AT_HIT; + func_800BE258(&this->actor, this->collider.elements); + func_80C114C0(this, globalCtx); + this->unk_194 = 0; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + if (this->collider.elements[i].info.bumperFlags & 2) { + break; + } + } + + if (this->actor.colChkInfo.damageEffect == 3) { + func_80C11454(this); + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_18C = 20; + this->unk_3D8 = 0.5f; + this->unk_3D4 = 4.0f; + if (i != ARRAY_COUNT(this->colliderElements)) { + sph = &this->collider.elements[i]; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sph->info.bumper.hitPos.x, + sph->info.bumper.hitPos.y, sph->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } else if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_18C = 0; + this->unk_3D8 = 0.5f; + this->unk_3D4 = 4.0f; + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_18C = 0x1E; + this->unk_3D8 = 0.5f; + this->unk_3D4 = 2.0f; + } + + if (this->unk_3E8 != 0) { + this->actor.colChkInfo.damage = 0; + } + + if (!Actor_ApplyDamage(&this->actor)) { + this->actor.colChkInfo.health = 0; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + func_80C10984(this, 40); + func_80C11C60(this); + } else { + func_80C11F6C(this, globalCtx); + } + } +} + +void func_80C12D00(EnThiefbird* this) { + static Vec3f D_80C1368C = { 0.0f, -0.15f, 0.0f }; + s32 i; + f32 phi_f20; + EnThiefbirdUnkStruct* ptr = &this->unk_3F0[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { + if (ptr->unk_22) { + ptr->unk_22--; + Math_Vec3f_Sum(&ptr->unk_00, &ptr->unk_0C, &ptr->unk_00); + Math_Vec3f_Sum(&ptr->unk_0C, &D_80C1368C, &ptr->unk_0C); + ptr->unk_1C++; + Math_StepToF(&ptr->unk_0C.x, 0.0f, 0.05f); + Math_StepToF(&ptr->unk_0C.z, 0.0f, 0.05f); + if (ptr->unk_0C.y < -0.5f) { + ptr->unk_0C.y = -0.5f; + } + + if ((i % 2) != 0) { + phi_f20 = -1.0f; + } else { + phi_f20 = 1.0f; + } + + ptr->unk_20 = Math_SinS(ptr->unk_1C * 0x7D0) * 0x2000; + ptr->unk_1E += (s16)(0x666 * fabsf(Math_SinS(ptr->unk_1C * 0xBB8)) * phi_f20); + } + } +} + +void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnThiefbird* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + func_80C12B1C(this, globalCtx); + this->actionFunc(this, globalCtx); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + if (this->actor.colChkInfo.health != 0) { + Actor_SetVelocityAndMoveXYRotation(&this->actor); + } else { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 25.0f, 50.0f, 7); + if (this->actionFunc == func_80C1193C) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_3D4 > 0.0f) { + if (this->unk_18C != 10) { + Math_StepToF(&this->unk_3D4, 0.0f, 0.05f); + this->unk_3D8 = (this->unk_3D4 + 1.0f) * 0.25f; + this->unk_3D8 = CLAMP_MAX(this->unk_3D8, 0.5f); + } else if (!Math_StepToF(&this->unk_3DC, 0.5f, 0.0125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + + func_80C12D00(this); + if (((this->skelAnime.animCurrentSeg == &D_06000604) && func_801378B8(&this->skelAnime, 13.0f)) || + ((this->skelAnime.animCurrentSeg == &D_06000278) && func_801378B8(&this->skelAnime, 1.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + } +} + +s32 EnThiefbird_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnThiefbird* this = THIS; + + if ((limbIndex == 10) || (limbIndex == 11)) { + this->unk_3E4 = *dList; + *dList = NULL; + } else if (limbIndex == 16) { + *dList = NULL; + } else if (limbIndex == 8) { + rot->z += this->unk_194; + } + + return false; +} + +void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static s8 D_80C13698[] = { + -1, 0, -1, 1, 3, -1, 2, 5, -1, -1, 7, 8, 9, -1, -1, 10, -1, + }; + EnThiefbird* this = THIS; + s32 pad; + Gfx* gfx; + s8 idx; + + Collider_UpdateSpheres(limbIndex, &this->collider); + if ((limbIndex == 10) || (limbIndex == 11)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->unk_3E4); + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 16) { + if (this->unk_3E8 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_3E8 == &D_060033B0) { + gfx = POLY_XLU_DISP; + } else { + gfx = POLY_OPA_DISP; + } + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->unk_3E8); + + if (this->unk_3E8 == &D_060033B0) { + POLY_XLU_DISP = &gfx[2]; + } else { + POLY_OPA_DISP = &gfx[2]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + + idx = D_80C13698[limbIndex]; + if (idx != -1) { + if (idx == 9) { + SysMatrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + } else { + SysMatrix_GetStateTranslation(&this->unk_350[idx]); + if ((idx == 3) || (idx == 5)) { + SysMatrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + } + } + } +} + +void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 i; + Gfx* gfx; + EnThiefbirdUnkStruct* ptr = &this->unk_3F0[0]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gSPDisplayList(&gfx[1], D_06003060); + gfx = &gfx[2]; + + for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { + if (ptr->unk_22 != 0) { + SysMatrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_RotateY(ptr->unk_1E, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); + SysMatrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_18, ptr->unk_18, 1.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], D_060030D8); + gfx = &gfx[2]; + } + } + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnThiefbird* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnThiefbird_OverrideLimbDraw, EnThiefbird_PostLimbDraw, &this->actor); + if (this->actor.colorFilterTimer > 0) { + func_800AE5A0(globalCtx); + } + func_80C13354(this, globalCtx); + func_800BE680(globalCtx, &this->actor, this->unk_350, 11, this->unk_3D8, this->unk_3DC, this->unk_3D4, + this->unk_18C); + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements[1].dim.worldSphere.center); +} diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 3a28d8dc9..7e3e3c32a 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -7,11 +7,39 @@ struct EnThiefbird; typedef void (*EnThiefbirdActionFunc)(struct EnThiefbird*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; +} EnThiefbirdUnkStruct; // size = 0x24 + typedef struct EnThiefbird { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x804]; + /* 0x018C */ u8 unk_18C; + /* 0x018E */ s16 unk_18E; + /* 0x0190 */ s16 unk_190; + /* 0x0192 */ s16 unk_192; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ s16 unk_196[6]; + /* 0x01A2 */ Vec3s jointTable[17]; + /* 0x0208 */ Vec3s morphTable[17]; + /* 0x0270 */ ColliderJntSph collider; + /* 0x0290 */ ColliderJntSphElement colliderElements[3]; + /* 0x0350 */ Vec3f unk_350[11]; + /* 0x03D4 */ f32 unk_3D4; + /* 0x03D8 */ f32 unk_3D8; + /* 0x03DC */ f32 unk_3DC; + /* 0x03E0 */ f32 unk_3E0; + /* 0x03E4 */ Gfx* unk_3E4; + /* 0x03E8 */ UNK_PTR unk_3E8; + /* 0x03EC */ EnItem00* unk_3EC; + /* 0x03F0 */ EnThiefbirdUnkStruct unk_3F0[40]; } EnThiefbird; // size = 0x990 extern const ActorInit En_Thiefbird_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2dd3d78eb..5e54d3c31 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16781,8 +16781,8 @@ 0x80C12B1C:("func_80C12B1C",), 0x80C12D00:("func_80C12D00",), 0x80C12ED4:("EnThiefbird_Update",), - 0x80C130EC:("func_80C130EC",), - 0x80C1315C:("func_80C1315C",), + 0x80C130EC:("EnThiefbird_OverrideLimbDraw",), + 0x80C1315C:("EnThiefbird_PostLimbDraw",), 0x80C13354:("func_80C13354",), 0x80C134D0:("EnThiefbird_Draw",), 0x80C13930:("EnJgameTsn_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 4441d7553..78dfbc492 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3549,6 +3549,9 @@ D_060033B0 = 0x060033B0; D_06003D58 = 0x06003D58; D_060061A0 = 0x060061A0; D_060063C4 = 0x060063C4; +D_06004348 = 0x06004348; +D_06004B88 = 0x06004B88; +D_060055E0 = 0x060055E0; // ovl_En_Tite From 1713e8a97d7fa550d0a4be63ee95c1a421816836 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Wed, 29 Sep 2021 00:50:04 +0000 Subject: [PATCH 13/86] ovl_En_Ending_Hero6 OK (#333) * All functions in z_en_ending_hero6.c matching * Add data to z_en_ending_hero6.c * Remove duplicate declarations * Add symbols to undefined_syms.txt * Address initial PR comments * Add heading, rename variables, and remove U suffix * Further variable renamings according to PR suggestions --- spec | 3 +- .../ovl_En_Ending_Hero6/z_en_ending_hero6.c | 170 ++++++++++++++++-- .../ovl_En_Ending_Hero6/z_en_ending_hero6.h | 13 +- tools/disasm/variables.txt | 14 +- undefined_syms.txt | 26 +++ 5 files changed, 204 insertions(+), 22 deletions(-) diff --git a/spec b/spec index 2ecd6ccbd..222c54f22 100644 --- a/spec +++ b/spec @@ -5518,8 +5518,7 @@ beginseg name "ovl_En_Ending_Hero6" compress include "build/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.o" - include "build/data/ovl_En_Ending_Hero6/ovl_En_Ending_Hero6.data.o" - include "build/data/ovl_En_Ending_Hero6/ovl_En_Ending_Hero6.reloc.o" + include "build/src/overlays/actors/ovl_En_Ending_Hero6/ovl_En_Ending_Hero6_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index 048e4c7a2..cfd596646 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero6.c + * Overlay: ovl_En_Ending_Hero6 + * Description: + */ + #include "z_en_ending_hero6.h" #define FLAGS 0x00000009 @@ -9,9 +15,40 @@ void EnEndingHero6_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx); void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80C23E18(EnEndingHero6* this, GlobalContext* globalCtx); +void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex); +void EnEndingHero6_SetupIdle(EnEndingHero6* this); +void EnEndingHero6_Idle(EnEndingHero6* this, GlobalContext* globalCtx); + +extern FlexSkeletonHeader D_0600B0CC; // object_dt +extern FlexSkeletonHeader D_06007908; // object_bai +extern FlexSkeletonHeader D_06007150; // object_toryo +extern FlexSkeletonHeader D_0600D640; // object_sdn +extern FlexSkeletonHeader D_0600A850; // object_daiku + +extern AnimationHeader D_06000BE0; // object_dt +extern AnimationHeader D_060011C0; // object_bai +extern AnimationHeader D_06000E50; // object_toryo +extern AnimationHeader D_06002A84; // object_sdn +extern AnimationHeader D_06002FA0; // object_daiku + +// object_daiku +extern Gfx D_060070C0[]; +extern Gfx D_06006FB0[]; +extern Gfx D_06006E80[]; +extern Gfx D_06006D70[]; +extern Gfx D_0600A390_dl[]; + +// object_dt +extern TexturePtr D_06007350; +extern TexturePtr D_06009590; +extern TexturePtr D_06009F90; +extern TexturePtr D_0600A790; +extern TexturePtr D_0600AB90; + +extern TexturePtr D_06007750; +extern TexturePtr D_0600A390_tex; +extern TexturePtr D_0600A490; -#if 0 const ActorInit En_Ending_Hero6_InitVars = { ACTOR_EN_ENDING_HERO6, ACTORCAT_NPC, @@ -24,20 +61,131 @@ const ActorInit En_Ending_Hero6_InitVars = { (ActorFunc)EnEndingHero6_Draw, }; -#endif +static FlexSkeletonHeader* sSkeletons[] = { &D_0600B0CC, &D_06007908, &D_06007150, &D_0600D640, &D_0600A850, + &D_0600A850, &D_0600A850, &D_0600A850, &D_0600A850 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/EnEndingHero6_Init.s") +static AnimationHeader* sAnimations[] = { &D_06000BE0, &D_060011C0, &D_06000E50, &D_06002A84, &D_06002FA0, + &D_06002FA0, &D_06002FA0, &D_06002FA0, &D_06002FA0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/EnEndingHero6_Destroy.s") +static s32 sLimbCounts[] = { 15, 20, 17, 17, 17, 17, 17, 17, 17 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/func_80C23D60.s") +void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx) { + EnEndingHero6* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/func_80C23DDC.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + SkelAnime_InitSV(globalCtx, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], + this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + EnEndingHero6_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/func_80C23E18.s") +void EnEndingHero6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/EnEndingHero6_Update.s") +void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex) { + this->animIndex = npcIndex; + this->frameCount = SkelAnime_GetFrameCount(&sAnimations[npcIndex]->common); + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, 0, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/func_80C23F14.s") +void EnEndingHero6_SetupIdle(EnEndingHero6* this) { + EnEndingHero6_InitSkelAnime(this, this->npcIndex); + this->isIdle = 1; + this->actionFunc = EnEndingHero6_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ending_Hero6/EnEndingHero6_Draw.s") +void EnEndingHero6_Idle(EnEndingHero6* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); +} + +void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { + EnEndingHero6* this = THIS; + + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->blinkTimer == 0) { + this->eyeState++; + if (this->eyeState >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); +} + +void EnEndingHero6_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Gfx* D_80C2426C[] = { D_060070C0, D_06006FB0, D_06006E80, D_06006D70, D_0600A390_dl }; + EnEndingHero6* this = THIS; + s32 index; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->npcIndex >= 4 && limbIndex == 15) { + index = this->npcIndex - 4; + gSPDisplayList(POLY_OPA_DISP++, D_80C2426C[index]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80C24280[] = { &D_06007350, &D_06009590, &D_06009F90, &D_0600A790, &D_0600AB90 }; + static TexturePtr D_80C24294[] = { &D_06007750, &D_0600A390_tex, &D_0600A490 }; + s32 pad; + EnEndingHero6* this = THIS; + s32 index = 0; + + if (this->isIdle == 1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->objectIndex >= 0 && Object_IsLoaded(&globalCtx->objectCtx, this->objectIndex)) { + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectIndex].segment); + + switch (this->npcIndex) { + case 4: + gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); + break; + case 5: + gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); + break; + case 6: + gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); + break; + case 7: + gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); + break; + case 8: + gDPSetEnvColor(POLY_OPA_DISP++, 245, 155, 0, 255); + break; + } + + if (this->npcIndex == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C24280[this->eyeState])); + + if (this->eyeState < 3) { + index = this->eyeState; + } + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C24294[index])); + } + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, + this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h index 2cbdb2980..4f8989634 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h @@ -9,9 +9,18 @@ typedef void (*EnEndingHero6ActionFunc)(struct EnEndingHero6*, GlobalContext*); typedef struct EnEndingHero6 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x134]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[20]; + /* 0x0200 */ Vec3s morphTable[20]; /* 0x0278 */ EnEndingHero6ActionFunc actionFunc; - /* 0x027C */ char unk_27C[0x18]; + /* 0x027C */ s32 animIndex; + /* 0x0280 */ s32 npcIndex; + /* 0x0284 */ s8 objectIndex; + /* 0x0286 */ s16 timer; + /* 0x0288 */ s16 blinkTimer; + /* 0x028A */ s16 eyeState; + /* 0x028C */ f32 frameCount; + /* 0x0290 */ s16 isIdle; } EnEndingHero6; // size = 0x294 extern const ActorInit En_Ending_Hero6_InitVars; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index cc79d6fe8..b12e417f1 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16988,13 +16988,13 @@ 0x80C23BD0:("En_Ending_Hero5_InitVars","UNK_TYPE1","",0x1), 0x80C23BF0:("D_80C23BF0","UNK_TYPE1","",0x1), 0x80C23C10:("jtbl_80C23C10","UNK_PTR","",0x4), - 0x80C241E0:("En_Ending_Hero6_InitVars","UNK_TYPE1","",0x1), - 0x80C24200:("D_80C24200","UNK_TYPE1","",0x1), - 0x80C24224:("D_80C24224","UNK_TYPE1","",0x1), - 0x80C24248:("D_80C24248","UNK_TYPE1","",0x1), - 0x80C2426C:("D_80C2426C","UNK_TYPE1","",0x1), - 0x80C24280:("D_80C24280","UNK_TYPE1","",0x1), - 0x80C24294:("D_80C24294","UNK_TYPE1","",0x1), + 0x80C241E0:("En_Ending_Hero6_InitVars","ActorInit","",0x20), + 0x80C24200:("D_80C24200","FlexSkeletonHeader*","[9]",0x24), + 0x80C24224:("D_80C24224","AnimationHeader*","[9]",0x24), + 0x80C24248:("D_80C24248","s32","[9]",0x24), + 0x80C2426C:("D_80C2426C","Gfx*","[5]",0x14), + 0x80C24280:("D_80C24280","TexturePtr","[5]",0x14), + 0x80C24294:("D_80C24294","TexturePtr","[3]",0xc), 0x80C242A0:("jtbl_80C242A0","UNK_PTR","",0x4), 0x80C250F0:("Dm_Gm_InitVars","UNK_TYPE1","",0x1), 0x80C25110:("D_80C25110","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 78dfbc492..57eb32e56 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2089,6 +2089,32 @@ D_060070C0 = 0x060070C0; D_0600A390 = 0x0600A390; D_0600A850 = 0x0600A850; +// ovl_En_Ending_Hero6 + +D_0600B0CC = 0x0600B0CC; +D_06007908 = 0x06007908; +D_06007150 = 0x06007150; +D_0600D640 = 0x0600D640; +D_0600A850 = 0x0600A850; +D_06000BE0 = 0x06000BE0; +D_060011C0 = 0x060011C0; +D_06000E50 = 0x06000E50; +D_06002A84 = 0x06002A84; +D_06002FA0 = 0x06002FA0; +D_060070C0 = 0x060070C0; +D_06006FB0 = 0x06006FB0; +D_06006E80 = 0x06006E80; +D_06006D70 = 0x06006D70; +D_0600A390_dl = 0x0600A390; +D_06007350 = 0x06007350; +D_06009590 = 0x06009590; +D_06009F90 = 0x06009F90; +D_0600A790 = 0x0600A790; +D_0600AB90 = 0x0600AB90; +D_06007750 = 0x06007750; +D_0600A390_tex = 0x0600A390; +D_0600A490 = 0x0600A490; + // ovl_En_Estone D_06010240 = 0x06010240; From ddc643f708543fafc73c55eddddf1f34c401cb02 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Wed, 29 Sep 2021 02:17:39 +0100 Subject: [PATCH 14/86] `ovl_opening` OK (#300) * ovl_opening OK * un-format z64save.h * Actually change the other uses of nextCutsceneIndex * format * Review * engineer's review * Get it to match again --- include/functions.h | 2 +- include/variables.h | 2 +- spec | 3 +- .../gamestates/ovl_opening/z_opening.c | 60 ++++++++++++++++--- .../gamestates/ovl_opening/z_opening.h | 4 +- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/include/functions.h b/include/functions.h index b5ab76f9a..cabbad7d5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2820,7 +2820,7 @@ void Sram_IncrementDay(void); u32 Sram_CalcChecksum(u8* data, u32 length); // void func_80144628(void); // void Sram_GenerateRandomSaveFields(void); -// void func_80144890(void); +void func_80144890(void); // void func_80144968(void); // void func_80144A94(void); // void func_80144E78(void); diff --git a/include/variables.h b/include/variables.h index ba99e95eb..6b37d9d5e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -910,7 +910,7 @@ extern UNK_TYPE1 D_801BA550; // extern UNK_TYPE1 D_801BB100; // extern UNK_TYPE2 D_801BB124; // extern UNK_TYPE2 D_801BB128; -// extern UNK_TYPE1 D_801BB12C; +extern u8 D_801BB12C; // extern UNK_TYPE1 D_801BB130; extern cutscene_update_func sCsStateHandlers1[5]; extern cutscene_update_func sCsStateHandlers2[5]; diff --git a/spec b/spec index 222c54f22..dfa4f4636 100644 --- a/spec +++ b/spec @@ -712,8 +712,7 @@ beginseg name "ovl_opening" compress include "build/src/overlays/gamestates/ovl_opening/z_opening.o" - include "build/data/ovl_opening/ovl_opening.data.o" - include "build/data/ovl_opening/ovl_opening.reloc.o" + include "build/src/overlays/gamestates/ovl_opening/ovl_opening_reloc.o" endseg beginseg diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index e086158fc..b19955071 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -1,18 +1,64 @@ /* * File: z_opening.c * Overlay: ovl_opening - * Description: + * Description: Initializes the game into the title screen */ #include "z_opening.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_SetupForTitleCutscene.s") +void Opening_SetupForTitleCutscene(OpeningContext* this) { + static s32 openingEntrances[] = { 0x1C00, 0x1C10 }; + static s32 openingCutscenes[] = { 0xFFFA, 0xFFFA }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/func_80803EA0.s") + gSaveContext.eventInf[1] &= (u8)~0x80; + gSaveContext.gameMode = 1; -void Opening_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Main.s") + func_80144890(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Destroy.s") + gSaveContext.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.sceneSetupIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_opening/Opening_Init.s") + gSaveContext.time = CLOCK_TIME(8, 0); + gSaveContext.day = 1; + + { + GameState* thisx = &this->gameState; + thisx->running = false; + } + SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); + gSaveContext.playerForm = PLAYER_FORM_HUMAN; +} + +void func_80803EA0(OpeningContext* this) { + SREG(33) |= 1; +} + +void Opening_Main(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + + func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + Opening_SetupForTitleCutscene(this); + func_80803EA0(this); +} + +void Opening_Destroy(GameState* thisx) { + ShrinkWindow_Fini(); +} + +void Opening_Init(GameState* thisx) { + OpeningContext* this = (OpeningContext*)thisx; + + Game_SetFramerateDivisor(&this->gameState, 1); + SysMatrix_StateAlloc(&this->gameState); + ShrinkWindow_Init(); + View_Init(&this->view, this->gameState.gfxCtx); + this->gameState.main = Opening_Main; + this->gameState.destroy = Opening_Destroy; + + gSaveContext.respawnFlag = 0; + gSaveContext.respawn[4].entranceIndex = 0xFF; + gSaveContext.respawn[5].entranceIndex = 0xFF; + gSaveContext.respawn[6].entranceIndex = 0xFF; + gSaveContext.respawn[7].entranceIndex = 0xFF; +} diff --git a/src/overlays/gamestates/ovl_opening/z_opening.h b/src/overlays/gamestates/ovl_opening/z_opening.h index 81a12f630..809767fe4 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.h +++ b/src/overlays/gamestates/ovl_opening/z_opening.h @@ -7,8 +7,8 @@ void Opening_Init(GameState* thisx); void Opening_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState common; - /* 0x0A4 */ UNK_TYPE1 padA4[0x4]; + /* 0x000 */ GameState gameState; + /* 0x0A4 */ UNK_TYPE1 unk_A4[0x4]; /* 0x0A8 */ View view; } OpeningContext; // size = 0x210 From 2f000058f50229ea8c0d95a75ef9f44276a4a4ca Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 28 Sep 2021 23:23:08 -0300 Subject: [PATCH 15/86] `ovl_select`: ZELDA MAP SELECT matched and documented (#310) * basic functions * errr * Progress, kinda * func_808016E8 * func_808019FC and func_80801A64 * Import data * Format * some progress * func_808013B8 * func_80801620 * fix stuff * func_80800930 * improve func_80800A44 a bit * At least it is equivalent now * matches! * small renames * Use generated reloc * move functions * Renaming a lot of stuff * Some functions renames * Rename members * Add translations for everything * Run formatter * Update include/alloca.h Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * review changes * review comments * Update src/overlays/gamestates/ovl_select/z_select.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/gamestates/ovl_select/z_select.h Co-authored-by: Kenix3 Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Kenix3 --- include/alloca.h | 7 + include/bgm.h | 6 + include/functions.h | 30 +- include/macros.h | 11 + include/variables.h | 2 +- include/z64.h | 1 + spec | 3 +- src/code/code_801A7B10.c | 2 +- src/code/z_sram_NES.c | 2 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 4 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 4 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 4 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 6 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 1 - src/overlays/gamestates/ovl_select/z_select.c | 930 +++++++++++++++++- src/overlays/gamestates/ovl_select/z_select.h | 31 +- tools/actorfixer.py | 1 + tools/disasm/functions.txt | 24 +- tools/disasm/variables.txt | 6 +- tools/sizes/code_functions.csv | 4 +- 21 files changed, 1013 insertions(+), 68 deletions(-) create mode 100644 include/alloca.h create mode 100644 include/bgm.h diff --git a/include/alloca.h b/include/alloca.h new file mode 100644 index 000000000..4e8720f7e --- /dev/null +++ b/include/alloca.h @@ -0,0 +1,7 @@ +#ifndef ALLOCA_H +#define ALLOCA_H + +void* alloca(u32); +#define alloca __builtin_alloca + +#endif diff --git a/include/bgm.h b/include/bgm.h new file mode 100644 index 000000000..4cd19c957 --- /dev/null +++ b/include/bgm.h @@ -0,0 +1,6 @@ +#ifndef BGM_H +#define BGM_H + +#define NA_BGM_STOP 0x100000FF + +#endif diff --git a/include/functions.h b/include/functions.h index cabbad7d5..5b3086c6d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -139,22 +139,22 @@ void StackCheck_Cleanup(StackEntry* entry); StackStatus StackCheck_GetState(StackEntry* entry); u32 StackCheck_CheckAll(void); u32 StackCheck_Check(StackEntry* entry); -// void GfxPrint_InitDlist(void); -// void GfxPrint_SetColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void GfxPrint_SetPosPx(void); -// void GfxPrint_SetPos(void); +void GfxPrint_InitDlist(GfxPrint*); +void GfxPrint_SetColor(GfxPrint*, u32, u32, u32, u32); +void GfxPrint_SetPosPx(GfxPrint*, s32, s32); +void GfxPrint_SetPos(GfxPrint*, s32, s32); void GfxPrint_SetBasePosPx(GfxPrint* this, s32 param_2, s32 param_3); void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c); void GfxPrint_PrintChar(GfxPrint* this, u8 c); -// void GfxPrint_PrintStringWithSize(void); -// void GfxPrint_PrintString(void); -// void GfxPrint_Callback(void); -// void GfxPrint_Init(void); -// void GfxPrint_Destroy(void); -// void GfxPrint_Open(void); -// void GfxPrint_Close(void); -// void GfxPrint_VPrintf(void); -// void GfxPrint_Printf(void); +void GfxPrint_PrintStringWithSize(GfxPrint*, const void*, size_t, size_t); +void GfxPrint_PrintString(GfxPrint*, const char*); +GfxPrint* GfxPrint_Callback(GfxPrint*, const char*, size_t); +void GfxPrint_Init(GfxPrint*); +void GfxPrint_Destroy(GfxPrint*); +void GfxPrint_Open(GfxPrint*, Gfx*); +Gfx* GfxPrint_Close(GfxPrint*); +void GfxPrint_VPrintf(GfxPrint*, const char*, va_list); +void GfxPrint_Printf(GfxPrint*, const char*, ...); // void MtxConv_F2L(void); // void MtxConv_L2F(void); void __assert(const char* file, u32 lineNum); @@ -2821,7 +2821,7 @@ u32 Sram_CalcChecksum(u8* data, u32 length); // void func_80144628(void); // void Sram_GenerateRandomSaveFields(void); void func_80144890(void); -// void func_80144968(void); +void Sram_InitDebugSave(void); // void func_80144A94(void); // void func_80144E78(void); // void func_8014546C(void); @@ -4014,7 +4014,7 @@ void func_801A7794(u32 param_1, u32 param_2, u32 param_3); // void func_801A7B10(void); // void func_801A7D04(void); // void func_801A7D84(void); -void func_801A89A8(s32 arg0); +void Audio_QueueSeqCmd(u32 arg0); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); diff --git a/include/macros.h b/include/macros.h index 8b02cbfc5..0beaf8a7b 100644 --- a/include/macros.h +++ b/include/macros.h @@ -26,6 +26,17 @@ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ (curState)->nextGameStateSize = sizeof(newStruct) +#define SET_FULLSCREEN_VIEWPORT(view) \ + { \ + Viewport viewport; \ + viewport.bottomY = SCREEN_HEIGHT; \ + viewport.rightX = SCREEN_WIDTH; \ + viewport.topY = 0; \ + viewport.leftX = 0; \ + View_SetViewport(view, &viewport); \ + } \ + (void)0 + #define PLAYER ((Player*)globalCtx->actorCtx.actorList[ACTORCAT_PLAYER].first) #define FIRST_ENEMY ((Actor*)globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first) diff --git a/include/variables.h b/include/variables.h index 6b37d9d5e..6d4cd7752 100644 --- a/include/variables.h +++ b/include/variables.h @@ -977,7 +977,7 @@ extern u8 kanfontOrdering[92]; // extern UNK_TYPE1 D_801BDBA0; // extern UNK_TYPE1 D_801BDBA4; // extern UNK_TYPE1 D_801BDBA8; -// extern UNK_TYPE1 D_801BDBB0; +extern u8 D_801BDBB0; // extern UNK_TYPE1 D_801BDBB4; // extern UNK_TYPE1 D_801BDBB8; // extern UNK_TYPE1 D_801BDBBC; diff --git a/include/z64.h b/include/z64.h index 3925281a6..a13ffedb6 100644 --- a/include/z64.h +++ b/include/z64.h @@ -16,6 +16,7 @@ #include "xstdio.h" #include "unk.h" +#include "bgm.h" #include "sfx.h" #include "color.h" #include "ichain.h" diff --git a/spec b/spec index dfa4f4636..8282b6bec 100644 --- a/spec +++ b/spec @@ -704,8 +704,7 @@ beginseg name "ovl_select" compress include "build/src/overlays/gamestates/ovl_select/z_select.o" - include "build/data/ovl_select/ovl_select.data.o" - include "build/data/ovl_select/ovl_select.reloc.o" + include "build/src/overlays/gamestates/ovl_select/ovl_select_reloc.o" endseg beginseg diff --git a/src/code/code_801A7B10.c b/src/code/code_801A7B10.c index a8bd825b7..707996820 100644 --- a/src/code/code_801A7B10.c +++ b/src/code/code_801A7B10.c @@ -6,7 +6,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D84.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89A8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89D0.s") diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 689382ba9..5b5b2f5f0 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144890.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144968.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144A94.s") diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 5879c5cb9..9f06cdc16 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -304,7 +304,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { func_801A5BD0(0x6F); - func_801A89A8(0xE0000101); + Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; func_80169EFC(globalCtx); /* Load new entrance? */ @@ -363,7 +363,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { case 0x4C20: /* Observatory from Termina Field telescope */ this->actor.flags |= 0x10000; func_801A5BD0(0); - func_801A89A8(0xE0000100); + Audio_QueueSeqCmd(0xE0000100); this->actor.params = ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE; func_809CCE98(this, globalCtx); break; 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 319bb02d8..bace8a29b 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -76,7 +76,7 @@ const ActorInit En_Fsn_InitVars = { (ActorFunc)EnFsn_Draw, }; -ActorAnimationEntryS sAnimations[] = { +static ActorAnimationEntryS sAnimations[] = { { &D_06012C34, 1.0f, 0, -1, 0, 0 }, { &D_060131FC, 1.0f, 0, -1, 0, 0 }, { &D_0600C58C, 1.0f, 0, -1, 2, 0 }, { &D_0600C58C, -1.0f, 0, -1, 2, 0 }, { &D_0600E3EC, 1.0f, 0, -1, 2, 0 }, { &D_0600F00C, 1.0f, 0, -1, 0, 0 }, { &D_0600CB3C, 1.0f, 0, -1, 2, 0 }, { &D_0600D354, 1.0f, 0, -1, 0, 0 }, { &D_060138B0, 1.0f, 0, -1, 2, 0 }, diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 613caad0a..1e5dd6e6e 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - func_801A89A8(0x800D); + Audio_QueueSeqCmd(0x800D); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - func_801A89A8(0x800D); + Audio_QueueSeqCmd(0x800D); func_80B46F88(this); } } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index a0d27353a..6f4c463cf 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -750,8 +750,8 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x8] &= (u8)~0x01; this->actionFunc = EnMa4_HorsebackGameEnd; - func_801A89A8(0x100000FF); - func_801A89A8(0x8041); + Audio_QueueSeqCmd(NA_BGM_STOP); + Audio_QueueSeqCmd(0x8041); } void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index fa872c109..eb7f9910a 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1144,7 +1144,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { this->textId = 0x2A31; func_801518B0(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; - func_801A89A8(0x8003); + Audio_QueueSeqCmd(0x8003); this->actionFunc = func_80BAD380; } else { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1205,7 +1205,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x21] |= 8; } this->actor.speedXZ = 0.0f; - func_801A89A8(0x101400FF); + Audio_QueueSeqCmd(0x101400FF); this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { @@ -1438,7 +1438,7 @@ void EnSuttari_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; if ((globalCtx->sceneNum == SCENE_BACKTOWN) && !(this->flags2 & 4)) { - func_801A89A8(0x101400FF); + Audio_QueueSeqCmd(0x101400FF); } Collider_DestroyCylinder(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 5a347da46..4db53de3c 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -44,7 +44,6 @@ const ActorInit En_Weather_Tag_InitVars = { extern f32 D_801F4E74; extern u8 D_801BDBB8; extern u8 D_801BDBB4; -extern u8 D_801BDBB0; extern u8 D_801F4E30; extern s16 D_801F4E7A; diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 20484f13b..da6808725 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -1,40 +1,934 @@ /* * File: z_select.c * Overlay: ovl_select - * Description: + * Description: Debug map select */ #include "z_select.h" +#include "alloca.h" +#include "overlays/gamestates/ovl_title/z_title.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/D_80802390.s") +void Select_LoadTitle(SelectContext* this) { + { + GameState* gameState = &this->state; + gameState->running = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80800910.s") + SET_NEXT_GAMESTATE(&this->state, Title_Init, TitleContext); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80800930.s") +void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { + if (gSaveContext.fileNum == 0xFF) { + Sram_InitDebugSave(); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80800A44.s") + gSaveContext.buttonStatus[0] = BTN_ENABLED; + gSaveContext.buttonStatus[1] = BTN_ENABLED; + gSaveContext.buttonStatus[2] = BTN_ENABLED; + gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.unk_3F1E = 0; + gSaveContext.unk_3F20 = 0; + gSaveContext.unk_3F22 = 0; + gSaveContext.unk_3F24 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_808013B8.s") + Audio_QueueSeqCmd(NA_BGM_STOP); + gSaveContext.entranceIndex = entranceIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/D_8080343C.s") + if (opt != 0) { + gSaveContext.entranceIndex = + Entrance_CreateIndex((s32)gSaveContext.entranceIndex >> 9, opt, gSaveContext.entranceIndex & 0xF); + } + if (gSaveContext.entranceIndex == 0xC000) { + gSaveContext.day = 0; + gSaveContext.time = CLOCK_TIME(6, 0) - 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80801594.s") + gSaveContext.respawn[0].entranceIndex = 0xFFFF; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.showTitleCard = true; + gSaveContext.respawnFlag = 0; + gSaveContext.respawn[4].entranceIndex = 0xFF; + gSaveContext.respawn[5].entranceIndex = 0xFF; + gSaveContext.respawn[6].entranceIndex = 0xFF; + gSaveContext.respawn[7].entranceIndex = 0xFF; + D_801BDBB0 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/D_80803588.s") + do { + GameState* gameState = &this->state; + gameState->running = false; + } while (0); + SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80801620.s") +// "Translation" ("Actual name") +static SceneSelectEntry sScenes[] = { + // " 0: OP Woods for Cutscene Use" (" 0: Forest Opening Scene") + { " 0:OP\x8Cデモ\x8Dヨウ シンリン", Select_LoadGame, 0x1C00 }, + // " 0-0: Lost Woods" (" 0-0: Lost Woods") + { " 0-0:\x8Dマヨイ ノ モリ", Select_LoadGame, 0xC400 }, + // " 1: Town Outskirts" (" 1: Termina Field") + { " 1:\x8Cタウン \x8Dコウガイ", Select_LoadGame, 0x5400 }, + // " 1-0: Astral Observatory" (" 1-0: Astral Observatory") + { " 1-0:\x8Dテンモンカンソクジョ", Select_LoadGame, 0x4C00 }, + // " 1 - 1: Astral Observatory Telescope" (" 1 - 1: Astral Observatory - Telescope") + { " 1-1:\x8Dテンモンカンソクジョ デ ボウエンキョウ", Select_LoadGame, 0x54A0 }, + // " 1 - 2: Ikana Graveyard" (" 1 - 2: Ikana Canyon Graveyard") + { " 1-2:\x8Cイカーナ \x8Dノ ハカバ", Select_LoadGame, 0x8000 }, + // " 2: Romani Ranch" (" 2: Romani Ranch") + { " 2:\x8Cロマニー \x8Dボクジョウ", Select_LoadGame, 0x6400 }, + // " 3: Milk Road" (" 3: Milk Road") + { " 3:\x8Cミルクロード", Select_LoadGame, 0x3E00 }, + // " 4: Main Building" (" 4: Ranch House") + { " 4:\x8Dオモヤ", Select_LoadGame, 0x610 }, + // " 5: Cow Shed" (" 5: Cow Shed") + { " 5:\x8Dウシゴヤ", Select_LoadGame, 0x600 }, + // " 6: Cucco Shed" (" 6: Cucco Shed") + { " 6:\x8Cコッコ \x8Dゴヤ", Select_LoadGame, 0x7E00 }, + // " 7: Dog Racing Area" (" 7: Doggy Racetrack") + { " 7:\x8Cドッグレース\x8Dジョウ", Select_LoadGame, 0x7C00 }, + // " 8: Gorman Track" (" 8: Gorman Track") + { " 8:\x8Cゴーマン トラック", Select_LoadGame, 0xCE00 }, + // " 10: Mountain Village -Winter-" (" 10: Mountain Village - Winter") + { " 10:\x8Dヤマザト -フユ-", Select_LoadGame, 0x9A00 }, + // " 10 - 0: Mountain Village -Spring-" (" 10 - 0: Mountain Village - Spring") + { " 10-0:\x8Dヤマザト -ハル-", Select_LoadGame, 0xAE00 }, + // " 10 - 1: Mountain Village Blacksmith" (" 10 - 1: Mountain Smithy") + { " 10-1:\x8Dヤマザト ノ カジヤ", Select_LoadGame, 0x5200 }, + // " 11: Goron Village -Winter-" (" 11: Goron Village - Winter") + { " 11:\x8Cゴロン\x8D ノ サト -フユ-", Select_LoadGame, 0x9400 }, + // " 11-0: Goron Village -Spring-" (" 11-0: Goron Village - Spring") + { " 11-0:\x8Cゴロン\x8D ノ サト -ハル-", Select_LoadGame, 0x8A00 }, + // " 11-1: Goron Shrine" (" 11-1: Goron Shrine") + { " 11-1:\x8Cゴロン\x8D ノ ホコラ", Select_LoadGame, 0x5E00 }, + // " 11-2: Lone Peak Shrine" (" 11-2: Lone Peak Shrine") + { " 11-2:\x8Dハナレヤマ ノ ホコラ", Select_LoadGame, 0x1500 }, + // " 11-3: Goron Shop" (" 11-3: Goron Shop") + { " 11-3:\x8Cゴロン \x8Dノ ミセ", Select_LoadGame, 0x7400 }, + // " 12: Snowhead" (" 12: Snowhead") + { " 12:\x8Cスノーヘッド", Select_LoadGame, 0xB200 }, + // " 13: Blizzard Path" (" 13: Path to Goron Village - Part 1") + { " 13:\x8Dフブキ ノ ミチ", Select_LoadGame, 0x3200 }, + // " 14: Snowball Path" (" 14: Path to Goron Village - Part 2") + { " 14:\x8Dユキダマ ノ ミチ", Select_LoadGame, 0xB000 }, + // " 15: Goron Racetrack" (" 15: Goron Racetrack") + { " 15:\x8Cゴロンレース \x8Dジョウ", Select_LoadGame, 0xD000 }, + // " 16: Goron Grave" (" 16: Darmani's Grave") + { " 16:\x8Cゴロン \x8Dノ ハカ", Select_LoadGame, 0x9600 }, + // " 17: Snow Field Battle -Winter-" (" 17: Path to Goron Village - Winter") + { " 17:\x8Dセツゲン \x8Cバトル \x8D-フユ-", Select_LoadGame, 0xB400 }, + // " 17-0: Snow Field Battle -Spring-" (" 17-0: Path to Goron Village - Spring") + { " 17-0:\x8Dセツゲン \x8Cバトル \x8D-ハル-", Select_LoadGame, 0xB600 }, + // " 20: Swampland" (" 20: Southern Swamp") + { " 20:\x8Dヌマチ", Select_LoadGame, 0x8400 }, + // " 20-0: Swampland - Afterwards" (" 20-0: Southern Swamp - After Odolwa") + { " 20-0:\x8Dヌマチ ソノゴ", Select_LoadGame, 0xC00 }, + // " 20-1: Swamp Tourist Information" (" 20-1: Tourist Information") + { " 20-1:\x8Dヌマ ノ カンコウアンナイ", Select_LoadGame, 0xA800 }, + // " 20-2: Magic Hags' Potion Shop" (" 20-2: Magic Hags' Potion Shop") + { " 20-2:\x8Dマホウオババ ノ クスリヤ", Select_LoadGame, 0x400 }, + // " 21: Wood Mountain" (" 21: Woodfall") + { " 21:\x8Cウッドマウンテン", Select_LoadGame, 0x8600 }, + // " 21-0: Deku Princess's Prison" (" 21-0: Deku Princess's Prison [Cutscene: Tatl Apologizes]") + { " 21-0:\x8Cデク\x8Dヒメ ノ ロウヤ", Select_LoadGame, 0x3010 }, + // " 22: Deku Castle" (" 22: Deku Palace") + { " 22:\x8Cデクナッツ \x8Dノ シロ", Select_LoadGame, 0x5000 }, + // " 22-0: Boe Hole 0" (" 22-0: Deku Palace Grotto 0 - Deku Baba & Butterflies, Entrance 1") + { " 22-0:\x8Cクロスケ \x8Dノ アナ0", Select_LoadGame, 0x1460 }, + // " 22-1: Boe Hole 1" (" 22-1: Deku Palace Grotto 1 - Deku Baba & Butterflies, Entrance 2") + { " 22-1:\x8Cクロスケ \x8Dノ アナ1", Select_LoadGame, 0x14E0 }, + // " 22-2: Boe Hole 2" (" 22-2: Deku Palace Grotto 2 - Skullwalltula Wall, Lower Entrance") + { " 22-2:\x8Cクロスケ \x8Dノ アナ2", Select_LoadGame, 0x1480 }, + // " 22-3: Boe Hole 3" (" 22-3: Deku Palace Grotto 3 - Skullwalltula Wall, Upper Entrance") + { " 22-3:\x8Cクロスケ \x8Dノ アナ3", Select_LoadGame, 0x14F0 }, + // " 22-4: Boe Hole 4" (" 22-4: Deku Palace Grotto 4 - Bean Seller") + { " 22-4:\x8Cクロスケ \x8Dノ アナ4", Select_LoadGame, 0x14C0 }, + // " 24: Beast Path" (" 24: Road to Swamp") + { " 24:\x8Dケモノミチ", Select_LoadGame, 0x7A00 }, + // " 24-0: Forest Shooting Gallery" (" 24-0: Swamp Shooting Gallery") + { " 24-0:\x8Dモリ ノ シャテキジョウ", Select_LoadGame, 0x4200 }, + // " 25: Deku King's Chamber" (" 25: Deku Palace Throne Room") + { " 25:\x8Cデク\x8Dオウ ノ マ", Select_LoadGame, 0x7600 }, + // " 26: Woods of Mystery" (" 26: Woods of Mystery") + { " 26:\x8Dフシギ ノ モリ", Select_LoadGame, 0xC200 }, + // " 30: Great Bay Coast" (" 30: Great Bay Coast - Entrance Area") + { " 30:\x8Cグレートベイ\x8D ノ カイガン", Select_LoadGame, 0x6800 }, + // " 30-0: Ocean Laboratory" (" 30-0: Marine Research Lab") + { " 30-0:\x8Dカイヨウ ケンキュウジョ", Select_LoadGame, 0x5800 }, + // " 30-1: Fisherman's House" (" 30-1: Fisherman's Hut") + { " 30-1:\x8Dリョウシ ノ イエ", Select_LoadGame, 0x7200 }, + // " 30-2: Pointed Rock" (" 30-2: Twin Pillars") + { " 30-2:\x8Dトンガリ イワ", Select_LoadGame, 0x4400 }, + // " 31: Cape" (" 31: Great Bay Coast - River Area") + { " 31:\x8Dミサキ", Select_LoadGame, 0x6A00 }, + // " 32: Outside of Pirates' Fortress" (" 32: Pirates' Fortress - Exterior") + { " 32:\x8Dカイゾクノトリデマエ", Select_LoadGame, 0x7000 }, + // " 32-0: Pirates' Fortress" (" 32-0: Pirates' Fortress - Courtyard") + { " 32-0:\x8Dカイゾクノトリデ", Select_LoadGame, 0x2200 }, + // " 32-1: Pirates' Fortress - Telescope" (" 32-1: Pirates' Fortress - Secret Entrance (Looking Through + // Telescope)") + { " 32-1:\x8Dカイゾクノトリデ ボウエンキョウ", Select_LoadGame, 0x22A0 }, + // " 32-2: Pirates' Fortress - Interior 0" (" 32-2: Pirates' Fortress - Throne Room") + { " 32-2:\x8Dカイゾクノトリデナイブ0", Select_LoadGame, 0x4000 }, + // " 32-3: Pirates' Fortress - Interior 1" (" 32-3: Pirates' Fortress - View of Throne Room, Wasp Nest") + { " 32-3:\x8Dカイゾクノトリデナイブ1", Select_LoadGame, 0x4010 }, + // " 32-4: Pirates' Fortress - Interior 2" (" 32-4: Pirates' Fortress - Tempting Treasure Chest, Leading to 32-5") + { " 32-4:\x8Dカイゾクノトリデナイブ2", Select_LoadGame, 0x4020 }, + // " 32-5: Pirates' Fortress - Interior 3" (" 32-5: Pirates' Fortress - Zora Egg Room, One Shell Blade") + { " 32-5:\x8Dカイゾクノトリデナイブ3", Select_LoadGame, 0x4030 }, + // " 32-6: Pirates' Fortress - Interior 4" (" 32-6: Pirates' Fortress - Oil Drum Room, Leading to 32-7") + { " 32-6:\x8Dカイゾクノトリデナイブ4", Select_LoadGame, 0x4040 }, + // " 32-7: Pirates' Fortress - Interior 5" (" 32-7: Pirates' Fortress - Zora Egg Room, One Shell Blade") + { " 32-7:\x8Dカイゾクノトリデナイブ5", Select_LoadGame, 0x4050 }, + // " 32-8: Pirates' Fortress - Interior 6" (" 32-8: Pirates' Fortress - Fenced Indoor Walkway, Leading to 32-9") + { " 32-8:\x8Dカイゾクノトリデナイブ6", Select_LoadGame, 0x4060 }, + // " 32-9: Pirates' Fortress - Interior 7" (" 32-9: Pirates' Fortress - Zora Egg Room, One Desbreko & Treasure + // Chest") + { " 32-9:\x8Dカイゾクノトリデナイブ7", Select_LoadGame, 0x4070 }, + // " 32-10: Pirates' Fortress - Interior 8" (" 32-10: Pirates' Fortress - End of Secret Entrance (Telescope + // Room)") + { " 32-10:\x8Dカイゾクノトリデナイブ8", Select_LoadGame, 0x4080 }, + // " 32-11: Pirates' Fortress - Interior 9" (" 32-11: Pirates' Fortress - Start of Secret Entrance") + { " 32-11:\x8Dカイゾクノトリデナイブ9", Select_LoadGame, 0x4090 }, + // " 33: Zora Shrine" (" 33: Zora Hall") + { " 33:\x8Cゾーラ \x8Dノ ホコラ", Select_LoadGame, 0x6000 }, + // " 33-0: Zora Shop" (" 33-0: Zora Shop") + { " 33-0:\x8Cゾーラ \x8Dノ ミセ", Select_LoadGame, 0x9250 }, + // " 33-1: Zora Waiting Room" (" 33-1: Mikau & Tijo's Room") + { " 33-1:\x8Cゾーラ \x8Dノ ヒカエシツ", Select_LoadGame, 0x9200 }, + // " 34: Great Bay" (" 34: Great Bay [Cutscene: Pirates Approach Temple]") + { " 34:\x8Cグレートベイ", Select_LoadGame, 0xBE00 }, + // " 35: Mountain Stream Above Falls" (" 35: Waterfall Rapids") + { " 35:\x8Dタキウエ ノ ケイリュウ", Select_LoadGame, 0x8E00 }, + // " 40: Rock Building Shaft" (" 40: Stone Tower") + { " 40:\x8Cロックビル\x8D ノ タテアナ", Select_LoadGame, 0xAA00 }, + // " 40-0: Heaven & Earth Are Overturned" (" 40-0: Stone Tower [Cutscene: Tower is Flipped]") + { " 40-0:\x8Dテンチ ギャクテン", Select_LoadGame, 0xAC00 }, + // " 41: Road to Ikana" (" 41: Road to Ikana") + { " 41:\x8Cイカーナ \x8Dヘノ ミチ", Select_LoadGame, 0xA000 }, + // " 42: Ancient Castle of Ikana" (" 42: Ancient Castle of Ikana") + { " 42:\x8Cイカーナ\x8D コジョウ", Select_LoadGame, 0x3400 }, + // " 42-0: Ancient Castle of Ikana - Interior" (" 42-0: Ancient Castle of Ikana - Interior") + { " 42-0:\x8Cイカーナ\x8D ノ コジョウ ナイブ", Select_LoadGame, 0x3430 }, + // " 42-B: Ancient Castle of Ikana - Boss Room" (" 42-B: Ikana King's Throne") + { " 42-B:\x8Cイカーナ\x8D ノ コジョウ \x8Cボス\x8Dベヤ", Select_LoadGame, 0xA600 }, + // " 43: Ikana Canyon" (" 43: Ikana Canyon") + { " 43:\x8Cイカーナ \x8Dケイコク", Select_LoadGame, 0x2000 }, + // " 43-0: Ikana Canyon Cave" (" 43-0: Sharp's Cave") + { " 43-0:\x8Cイカーナ \x8Dケイコク ドウクツ", Select_LoadGame, 0x20E0 }, + // " 43-1: Secom's House" (" 43-1: Sakon's Hideout") + { " 43-1:\x8Cセコム \x8Dノ イエ", Select_LoadGame, 0x9800 }, + // " 43-2: Music Box House" (" 43-2: Music Box House") + { " 43-2:\x8Cオルゴール ハウス", Select_LoadGame, 0xA400 }, + // " 50: Clock Town -East-" (" 50: East Clock Town") + { " 50:\x8Cクロックタウン \x8D-ヒガシ-", Select_LoadGame, 0xD200 }, + // " 50-0: Town Target Range" (" 50-0: Shooting Gallery") + { " 50-0:\x8Dマチ ノ シャテキジョウ", Select_LoadGame, 0x3A00 }, + // " 50-1: Honey and Darling's Shop" (" 50-1: Honey & Darling's Shop") + { " 50-1:\x8Cハニー アンド ダーリン \x8Dノ ミセ", Select_LoadGame, 0x800 }, + // " 50-2: Treasure Chest Shop" (" 50-2: Treasure Chest Shop") + { " 50-2:\x8Dタカラバコヤ", Select_LoadGame, 0x2800 }, + // " 50-3: Pots 'n' Pans Inn" (" 50-3: Stockpot Inn") + { " 50-3:\x8Cナベ\x8Dカマ テイ", Select_LoadGame, 0xBC00 }, + // " 50-4: Mayor's House" (" 50-4: The Mayor's Residence") + { " 50-4:\x8Dチョウチョウ ノ イエ", Select_LoadGame, 0 }, + // " 50-5: Milk Bar" (" 50-5: Milk Bar") + { " 50-5:\x8Cミルクバー", Select_LoadGame, 0x2400 }, + // " 51: Clock Town -West-" (" 51: West Clock Town") + { " 51:\x8Cクロックタウン \x8D-ニシ-", Select_LoadGame, 0xD400 }, + // " 51-0: Bomb Shop" (" 51-0: Bomb Shop") + { " 51-0:\x8Dバクダン ヤ", Select_LoadGame, 0xCA00 }, + // " 51-1: Maniac Mart" (" 51-1: Curiosity Shop") + { " 51-1:\x8Cマニ\x8Dヤ", Select_LoadGame, 0xE00 }, + // " 51-2: General Store" (" 51-2: Trading Post") + { " 51-2:\x8Dザッカ ヤ", Select_LoadGame, 0x6200 }, + // " 51-3: Sword Dojo" (" 51-3: Swordsman's School") + { " 51-3:\x8Dケンドウジョウ", Select_LoadGame, 0xA200 }, + // " 51-4: Post House" (" 51-4: Post Office") + { " 51-4:\x8Dポストハウス", Select_LoadGame, 0x5600 }, + // " 51-5: Lottery Shop" (" 51-5: Lottery Shop") + { " 51-5:\x8Dタカラクジヤ", Select_LoadGame, 0x6C00 }, + // " 52: Clock Town -North-" (" 52: North Clock Town") + { " 52:\x8Cクロックタウン \x8D-キタ-", Select_LoadGame, 0xD600 }, + // " 53: Clocktown -South-" (" 53: South Clock Town") + { " 53:\x8Cクロックタウン \x8D-ミナミ-", Select_LoadGame, 0xD800 }, + // " 53-0: Clock Tower Interior" (" 53-0: Clock Tower Interior") + { " 53-0:\x8Dトケイトウナイブ", Select_LoadGame, 0xC000 }, + // " 54: Clock Tower Rooftop" (" 54: Clock Tower Rooftop") + { " 54:\x8Dトケイトウ オクジョウ", Select_LoadGame, 0x2C00 }, + // " 55: Laundry Area" (" 55: Laundry Pool") + { " 55:\x8Dセンタクジョウ", Select_LoadGame, 0xDA00 }, + // " 55-0: Maniac Mart - Rear Entrance" (" 55-0: Curiosity Shop - Back Room") + { " 55-0:\x8Cマニ\x8Dヤ ノ ウラグチ", Select_LoadGame, 0xE10 }, + // " 55-1: Maniac Mart - Peephole" (" 55-1: Curiosity Shop Back Room - Peephole") + { " 55-1:\x8Cマニ\x8Dヤ ノ ノゾキアナ", Select_LoadGame, 0xE20 }, + // "100: Wood Mountain Temple" ("100: Woodfall Temple") + { "100:\x8Cウッドマウンテン \x8Dノ シンデン", Select_LoadGame, 0x3000 }, + // "100-B: Wood Mountain Temple - Boss" ("100-B: Odolwa's Lair") + { "100-B:\x8Cウッドマウンテン \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x3800 }, + // "101: Snowhead Temple" ("101: Snowhead Temple") + { "101:\x8Cスノーヘッド \x8Dノ シンデン", Select_LoadGame, 0x3C00 }, + // "101-B: Snowhead Temple - Boss" ("101-B: Goht's Lair") + { "101-B:\x8Cスノーヘッド \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x8200 }, + // "102: Great Bay Temple" ("102: Great Bay Temple") + { "102:\x8Cグレートベイ \x8Dノ シンデン", Select_LoadGame, 0x8C00 }, + // "102-B: Great Bay Temple - Boss" ("102-B: Gyorg's Lair") + { "102-B:\x8Cグレートベイ \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0xB800 }, + // "103: Rock Building Temple -Top Side-" ("103: Stone Tower Temple") + { "103:\x8Cロックビル \x8Dノ シンデン-オモテー", Select_LoadGame, 0x2600 }, + // "103-0: Rock Building Temple -Underside-" ("103-0: Stone Tower Temple - Flipped") + { "103-0:\x8Cロックビル \x8Dノ シンデン-ウラー", Select_LoadGame, 0x2A00 }, + // "103-B: Rock Building Temple - Boss" ("103-B: Twinmold's Lair") + { "103-B:\x8Cロックビル \x8Dノ シンデン\x8C-ボス-", Select_LoadGame, 0x6600 }, + // "104: Steppe" ("104: On the Moon") + { "104:\x8Cソウゲン", Select_LoadGame, 0xC800 }, + // "104-0: Last Deku Dungeon" ("104-0: Deku Trial") + { "104-0:\x8Cラスト デク ダンジョン", Select_LoadGame, 0x4E00 }, + // "104-1: Last Goron Dungeon" ("104-1: Goron Trial") + { "104-1:\x8Cラスト ゴロン ダンジョン", Select_LoadGame, 0x7800 }, + // "104-2: Last Zora Dungeon" ("104-2: Zora Trial") + { "104-2:\x8Cラスト ゾーラ ダンジョン", Select_LoadGame, 0x8800 }, + // "104-3: Last Link Dungeon" ("104-3: Link Trial") + { "104-3:\x8Cラスト リンク ダンジョン", Select_LoadGame, 0xC600 }, + // "104-B: Last Dungeon -Boss-" ("104-B: Majora's Lair") + { "104-B:\x8Cラストダンジョン -ボス-", Select_LoadGame, 0x200 }, + // "119: Deku Shrine" ("119: Deku Shrine") + { "119:\x8Cデクナッツ \x8Dノ ホコラ", Select_LoadGame, 0x9E00 }, + // "121: Secret Shrine" ("121: Secret Shrine") + { "121:\x8Dヒミツ ノ ホコラ", Select_LoadGame, 0xBA00 }, + // "122: Opening Dungeon" ("122: Pond Area [Cutscene: Falling of the Cliff]") + { "122:\x8Cオープニング ダンジョン", Select_LoadGame, 0x2E00 }, + // "123: Giants' Chamber" ("123: Giants' Chamber") + { "123:\x8Dキョジン ノ マ", Select_LoadGame, 0xCC00 }, + // "126: Deku Minigame" ("126: Deku Rupee Minigame") + { "126:\x8Cデクナッツ ミニゲーム", Select_LoadGame, 0x3600 }, + // "127-0: Fairy Fountain 0" ("127-0: Fairy Fountain - Clock Town") + { "127-0:\x8Dヨウセイ ノ イズミ 0", Select_LoadGame, 0x4600 }, + // "127-1: Fairy Fountain 1" ("127-1: Fairy Fountain - Woodfall") + { "127-1:\x8Dヨウセイ ノ イズミ 1", Select_LoadGame, 0x4610 }, + // "127-2: Fairy Fountain 2" ("127-2: Fairy Fountain - Snowhead") + { "127-2:\x8Dヨウセイ ノ イズミ 2", Select_LoadGame, 0x4620 }, + // "127-3: Fairy Fountain 3" ("127-3: Fairy Fountain - Great Bay Coast") + { "127-3:\x8Dヨウセイ ノ イズミ 3", Select_LoadGame, 0x4630 }, + // "127-4: Fairy Fountain 4" ("127-4: Fairy Fountain - Ikana Canyon") + { "127-4:\x8Dヨウセイ ノ イズミ 4", Select_LoadGame, 0x4640 }, + // "128: Swamp Spider Manor" ("128: Swamp Spider House") + { "128:\x8Dヌマ ノ クモヤカタ", Select_LoadGame, 0x4800 }, + // "129: Ocean Spider Manor" ("129: Oceanside Spider House") + { "129:\x8Dウミ ノ クモヤカタ", Select_LoadGame, 0x4A00 }, + // "130: Beneath the Graves - Dampe" ("130: Beneath the Graveyard") + { "130:\x8Dハカ ノ シタ-\x8Cダンペイ-", Select_LoadGame, 0x5A00 }, + // "131: Beneath the Well" ("131: Beneath the Well") + { "131:\x8Dイド ノ シタ", Select_LoadGame, 0x9000 }, + // "132: Ghost Hut" (" 132: Ghost Hut") + { "132:\x8Dユウレイゴヤ", Select_LoadGame, 0x9C00 }, + // "133-0: Beneath the Graves 0" ("133-0: Beneath the Graveyard - Part 1") + { "133-0:\x8Dハカ ノ シタ0", Select_LoadGame, 0xA00 }, + // "133-1: Beneath the Graves 1" ("133-1: Beneath the Graveyard - Part 2") + { "133-1:\x8Dハカ ノ シタ1", Select_LoadGame, 0xA10 }, + // "134-0: Secret Grotto 0" ("134-0: Secret Grotto - Four Gossip Stones") + { "134-0:\x8Dカクシアナ 0", Select_LoadGame, 0x1400 }, + // "134-1: Secret Grotto 1" ("134-1: Secret Grotto - Four Gossip Stones, Skulltula") + { "134-1:\x8Dカクシアナ 1", Select_LoadGame, 0x1410 }, + // "134-2: Secret Grotto 2" ("134-2: Secret Grotto - Four Gossip Stones, Water Puddles") + { "134-2:\x8Dカクシアナ 2", Select_LoadGame, 0x1420 }, + // "134-3: Secret Grotto 3" ("134-3: Secret Grotto - Four Gossip Stones, Water Puddle With Bugs") + { "134-3:\x8Dカクシアナ 3", Select_LoadGame, 0x1430 }, + // "134-4: Secret Grotto 4" ("134-4: Secret Grotto - Chest with Blue Rupee, Deku Babas") + { "134-4:\x8Dカクシアナ 4", Select_LoadGame, 0x1440 }, + // "134-5: Secret Grotto 5" ("134-5: Secret Grotto - Hot Spring, Deku Babas, Large Stones") + { "134-5:\x8Dカクシアナ5", Select_LoadGame, 0x1450 }, + // "134-7: Secret Grotto 7" ("134-7: Secret Grotto - Two Dondogos") + { "134-7:\x8Dカクシアナ 7", Select_LoadGame, 0x1470 }, + // "134-9: Secret Grotto 9" ("134-9: Secret Grotto - Tall Grass With Box, Pot, Bugs") + { "134-9:\x8Dカクシアナ 9", Select_LoadGame, 0x1490 }, + // "134-10: Secret Grotto 10" ("134-10: Secret Grotto - Two Cows Surrounded by Grass") + { "134-10:\x8Dカクシアナ10", Select_LoadGame, 0x14A0 }, + // "134-11: Secret Grotto 11" ("134-11: Secret Grotto - Watery Hole Filled with Underwater Babas, Fish") + { "134-11:\x8Dカクシアナ11", Select_LoadGame, 0x14B0 }, + // "134-13: Secret Grotto 13" ("134-13: Secret Grotto - Peahat in Center") + { "134-13:\x8Dカクシアナ13", Select_LoadGame, 0x14D0 }, + // "X 1: SPOT00" ("X 1: Opening [Cutscene: Opening Cutscene]") + { "X 1:SPOT00", Select_LoadGame, 0x1C00 }, + // "Title" ("Title Screen") + { "title", (void*)Select_LoadTitle, 0x0000 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_808016E8.s") +void Select_UpdateMenu(SelectContext* this) { + s32 playerForm; + Input* controller1 = CONTROLLER1(this); + s32 stickY; + s32 pad[2]; + s16 i; + s32 updateRate; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_8080194C.s") + if (this->verticalInputAccumulator == 0) { + if (CHECK_BTN_ALL(controller1->press.button, BTN_A) || CHECK_BTN_ALL(controller1->press.button, BTN_START)) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3EC0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + gSaveContext.minigameState = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_808019FC.s") + if (this->scenes[this->currentScene].loadFunc != NULL) { + this->scenes[this->currentScene].loadFunc(this, this->scenes[this->currentScene].entranceIndex, + this->opt); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/func_80801A64.s") + if (CHECK_BTN_ALL(controller1->press.button, BTN_B)) { + playerForm = gSaveContext.playerForm - 1; + if (playerForm < PLAYER_FORM_FIERCE_DEITY) { + playerForm = PLAYER_FORM_HUMAN; + } + gSaveContext.playerForm = playerForm; + } -void Select_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/Select_Main.s") + if (CHECK_BTN_ALL(controller1->press.button, BTN_Z)) { + if (gSaveContext.cutscene == 0x8000) { + gSaveContext.cutscene = 0; + } else if (gSaveContext.cutscene == 0) { + gSaveContext.cutscene = 0x8800; + } else if (gSaveContext.cutscene == 0x8800) { + gSaveContext.cutscene = 0xFFF0; + } else if (gSaveContext.cutscene == 0xFFF0) { + gSaveContext.cutscene = 0xFFF1; + } else if (gSaveContext.cutscene == 0xFFF1) { + gSaveContext.cutscene = 0xFFF2; + } else if (gSaveContext.cutscene == 0xFFF2) { + gSaveContext.cutscene = 0xFFF3; + } else if (gSaveContext.cutscene == 0xFFF3) { + gSaveContext.cutscene = 0xFFF4; + } else if (gSaveContext.cutscene == 0xFFF4) { + gSaveContext.cutscene = 0xFFF5; + } else if (gSaveContext.cutscene == 0xFFF5) { + gSaveContext.cutscene = 0xFFF6; + } else if (gSaveContext.cutscene == 0xFFF6) { + gSaveContext.cutscene = 0xFFF7; + } else if (gSaveContext.cutscene == 0xFFF7) { + gSaveContext.cutscene = 0xFFF8; + } else if (gSaveContext.cutscene == 0xFFF8) { + gSaveContext.cutscene = 0xFFF9; + } else if (gSaveContext.cutscene == 0xFFF9) { + gSaveContext.cutscene = 0xFFFA; + } else if (gSaveContext.cutscene == 0xFFFA) { + gSaveContext.cutscene = 0x8000; + } + } else if (CHECK_BTN_ALL(controller1->press.button, BTN_R)) { + if (gSaveContext.cutscene == 0x8000) { + gSaveContext.cutscene = 0xFFFA; + } else if (gSaveContext.cutscene == 0) { + gSaveContext.cutscene = 0x8000; + } else if (gSaveContext.cutscene == 0x8800) { + gSaveContext.cutscene = 0; + } else if (gSaveContext.cutscene == 0xFFF0) { + gSaveContext.cutscene = 0x8800; + } else if (gSaveContext.cutscene == 0xFFF1) { + gSaveContext.cutscene = 0xFFF0; + } else if (gSaveContext.cutscene == 0xFFF2) { + gSaveContext.cutscene = 0xFFF1; + } else if (gSaveContext.cutscene == 0xFFF3) { + gSaveContext.cutscene = 0xFFF2; + } else if (gSaveContext.cutscene == 0xFFF4) { + gSaveContext.cutscene = 0xFFF3; + } else if (gSaveContext.cutscene == 0xFFF5) { + gSaveContext.cutscene = 0xFFF4; + } else if (gSaveContext.cutscene == 0xFFF6) { + gSaveContext.cutscene = 0xFFF5; + } else if (gSaveContext.cutscene == 0xFFF7) { + gSaveContext.cutscene = 0xFFF6; + } else if (gSaveContext.cutscene == 0xFFF8) { + gSaveContext.cutscene = 0xFFF7; + } else if (gSaveContext.cutscene == 0xFFF9) { + gSaveContext.cutscene = 0xFFF8; + } else if (gSaveContext.cutscene == 0xFFFA) { + gSaveContext.cutscene = 0xFFF9; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/Select_Destroy.s") + gSaveContext.isNight = false; + if (gSaveContext.cutscene == 0x8800) { + gSaveContext.isNight = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_select/Select_Init.s") + if (CHECK_BTN_ALL(controller1->press.button, BTN_CUP)) { + this->opt--; + } + if (CHECK_BTN_ALL(controller1->press.button, BTN_CDOWN)) { + this->opt++; + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_CLEFT)) { + if (gSaveContext.day > 1) { + gSaveContext.day--; + } + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_CRIGHT)) { + if (gSaveContext.day < 4) { + gSaveContext.day++; + } + } + + updateRate = R_UPDATE_RATE; + stickY = controller1->rel.stick_y; + if (stickY != 0) { + this->verticalInput = (updateRate * stickY) / 7; + } else { + if (CHECK_BTN_ALL(controller1->press.button, BTN_DUP)) { + if (this->lockUp == true) { + this->timerUp = 0; + } + if (this->timerUp == 0) { + this->timerUp = 20; + this->lockUp = true; + + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = updateRate; + } + } + + if (CHECK_BTN_ALL(controller1->cur.button, BTN_DUP) && (this->timerUp == 0)) { + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = updateRate * 3; + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_DDOWN)) { + if (this->lockDown == true) { + this->timerDown = 0; + } + if (this->timerDown == 0) { + this->timerDown = 20; + this->lockDown = true; + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = -updateRate; + } + } + if (CHECK_BTN_ALL(controller1->cur.button, BTN_DDOWN) && (this->timerDown == 0)) { + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = -updateRate * 3; + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_DLEFT) || + CHECK_BTN_ALL(controller1->cur.button, BTN_DLEFT)) { + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = updateRate; + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_DRIGHT) || + CHECK_BTN_ALL(controller1->cur.button, BTN_DRIGHT)) { + play_sound(NA_SE_IT_SWORD_IMPACT); + this->verticalInput = -updateRate; + } + } + } + + if (CHECK_BTN_ALL(controller1->press.button, BTN_L)) { + this->pageDownIndex++; + this->pageDownIndex = + (this->pageDownIndex + ARRAY_COUNT(this->pageDownStops)) % ARRAY_COUNT(this->pageDownStops); + this->currentScene = this->topDisplayedScene = this->pageDownStops[this->pageDownIndex]; + } + + this->verticalInputAccumulator += this->verticalInput; + + if (this->verticalInputAccumulator < -7) { + this->verticalInput = 0; + this->verticalInputAccumulator = 0; + + this->currentScene++; + this->currentScene = (this->currentScene + this->count) % this->count; + + if (this->currentScene == ((this->topDisplayedScene + 19 + this->count) % this->count)) { + this->topDisplayedScene++; + this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + } + } + + if (this->verticalInputAccumulator > 7) { + this->verticalInput = 0; + this->verticalInputAccumulator = 0; + if (this->currentScene == this->topDisplayedScene) { + this->topDisplayedScene -= 2; + this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + } + + this->currentScene--; + this->currentScene = (this->currentScene + this->count) % this->count; + if (this->currentScene == ((this->topDisplayedScene + this->count) % this->count)) { + this->topDisplayedScene--; + this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + } + } + + this->currentScene = (this->currentScene + this->count) % this->count; + this->topDisplayedScene = (this->topDisplayedScene + this->count) % this->count; + + dREG(80) = this->currentScene; + dREG(81) = this->topDisplayedScene; + dREG(82) = this->pageDownIndex; + + if (this->timerUp != 0) { + this->timerUp--; + } + if (this->timerUp == 0) { + this->lockUp = false; + } + + if (this->timerDown != 0) { + this->timerDown--; + } + if (this->timerDown == 0) { + this->lockDown = false; + } +} + +void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { + s32 i; + + GfxPrint_SetColor(printer, 255, 155, 150, 255); + GfxPrint_SetPos(printer, 12, 2); + GfxPrint_Printf(printer, "ZELDA MAP SELECT"); + + GfxPrint_SetColor(printer, 255, 255, 255, 255); + for (i = 0; i < 20; i++) { + s32 sceneIndex; + char* sceneName; + + GfxPrint_SetPos(printer, 9, i + 4); + sceneIndex = (this->topDisplayedScene + i + this->count) % this->count; + if (sceneIndex == this->currentScene) { + GfxPrint_SetColor(printer, 255, 20, 20, 255); + } else { + GfxPrint_SetColor(printer, 200, 200, 55, 255); + } + + sceneName = this->scenes[sceneIndex].name; + if (sceneName == NULL) { + sceneName = "**Null**"; + } + GfxPrint_Printf(printer, "%s", sceneName); + } + + GfxPrint_SetColor(printer, 155, 55, 150, 255); + GfxPrint_SetPos(printer, 20, 26); + GfxPrint_Printf(printer, "OPT=%d", this->opt); +} + +// clang-format off +static const char* sLoadingMessages[] = { + // "Please wait a minute", + "\x8Dシバラクオマチクダサイ", + // "Hold on a sec", + "\x8Dチョット マッテネ", + // "Wait a moment", + "\x8Cウェイト ア モーメント", + // "Loading", + "\x8Cロード\x8Dチュウ", + // "Now working", + "\x8Dナウ ワーキング", + // "Now creating", + "\x8Dイマ ツクッテマス", + // "It's not broken", + "\x8Dコショウジャナイヨ", + // "Coffee Break", + "\x8Cコーヒー ブレイク", + // "Please set B side", + "\x8C" "Bメンヲセットシテクダサイ", + // "Be patient, now", + "\x8Dジット\x8Cガマン\x8Dノ\x8Cコ\x8Dデアッタ", + // "Please wait just a minute", + "\x8Dイマシバラクオマチクダサイ", + // "Don't worry, don't worry. Take a break, take a break", + "\x8Dアワテナイアワテナイ。ヒトヤスミヒトヤスミ。", +}; +// clang-format on + +void Select_PrintLoadingMessage(SelectContext* this, GfxPrint* printer) { + s32 index; + + GfxPrint_SetPos(printer, 10, 15); + GfxPrint_SetColor(printer, 255, 255, 255, 255); + + index = Rand_ZeroOne() * ARRAY_COUNT(sLoadingMessages); + GfxPrint_Printf(printer, "%s", sLoadingMessages[index]); +} + +// clang-format off +// Second column is unused +static const char* sFormLabel[][2] = { + // "17 (Adult)" // 17 (Daitetsujin) + {"\x8D""17(オトナ)", "\x8D""17(ダイテツジン)"}, + // "30 (Goron)" // 30 (Ice Cream -1) + {"\x8C""30(ゴロン)", "\x8C""30(アイスクリーム-1)"}, + // "78 (Zora)" // 78 (Carmen +1) + {"\x8C""78(ゾーラ)", "\x8C""78(カルメン+1)"}, + // "12 (Deku)" // 12 (Majestic) + {"\x8C""12(デクナッツ)", "\x8C""12(マジェスティック)"}, + // "5 (Child)" // 5 (NTT Kodomo) + {"\x8D""5(コドモ)", "\x8C""5(NTTコドモ)"}, +}; +// clang-format on + +void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 playerForm) { + s32 pad; + const char* age; + const char*(*ageTemp)[2]; + const char*(*phi_v1)[2]; + s32 phi_v0; + + if ((playerForm >= PLAYER_FORM_FIERCE_DEITY) && (playerForm < PLAYER_FORM_MAX)) { + ageTemp = &sFormLabel[playerForm]; + phi_v1 = ageTemp + 1; + + // This loop doesn't do anything + for (phi_v0 = 8; phi_v0 >= 0; phi_v0 -= 8) { + if (phi_v1 != 0) { + break; + } + phi_v1--; + } + if (phi_v1) {} + + age = (*ageTemp)[0]; + } else { + age = NULL; + } + + GfxPrint_SetPos(printer, 4, 26); + GfxPrint_SetColor(printer, 255, 255, 55, 255); + if (age != NULL) { + GfxPrint_Printf(printer, "Age:%s", age); + } else { + // clang-format off + GfxPrint_Printf(printer, "Age:" "???" "(%d)", playerForm); + // clang-format on + } +} + +void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csIndex) { + const char* stage; + const char* day; + + GfxPrint_SetPos(printer, 4, 25); + GfxPrint_SetColor(printer, 255, 255, 55, 255); + + // "-jara" used in these strings is a Kokiri speech quirk word + switch (csIndex) { + case 0: + // clang-format off + // "Afternoon-jara" + gSaveContext.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; + // clang-format on + break; + + case 0x8000: + // clang-format off + // "Morning-jara" + gSaveContext.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; + // clang-format on + break; + + case 0x8800: + gSaveContext.time = CLOCK_TIME(18, 1); + // "Night-jara" + stage = "\x8Dヨル \x8Cジャラ"; + break; + + case 0xFFF0: + // clang-format off + // "Cutscene 00" + gSaveContext.time = CLOCK_TIME(12, 0); stage = "デモ00"; + // clang-format on + break; + case 0xFFF1: + // "Cutscene 01" + stage = "デモ01"; + break; + case 0xFFF2: + // "Cutscene 02" + stage = "デモ02"; + break; + case 0xFFF3: + // "Cutscene 03" + stage = "デモ03"; + break; + case 0xFFF4: + // "Cutscene 04" + stage = "デモ04"; + break; + case 0xFFF5: + // "Cutscene 05" + stage = "デモ05"; + break; + case 0xFFF6: + // "Cutscene 06" + stage = "デモ06"; + break; + case 0xFFF7: + // "Cutscene 07" + stage = "デモ07"; + break; + case 0xFFF8: + // "Cutscene 08" + stage = "デモ08"; + break; + case 0xFFF9: + // "Cutscene 09" + stage = "デモ09"; + break; + case 0xFFFA: + // "Cutscene 0A" + stage = "デモ0A"; + break; + + default: + stage = "???"; + break; + } + gSaveContext.environmentTime = gSaveContext.time; + GfxPrint_Printf(printer, "Stage:\x8C%s", stage); + + GfxPrint_SetPos(printer, 23, 25); + GfxPrint_SetColor(printer, 255, 255, 55, 255); + + switch (gSaveContext.day) { + case 1: + // "The First Day" + day = "\x8Dサイショノヒ"; + break; + case 2: + // "The Next Day" + day = "\x8Dツギノヒ"; + break; + case 3: + // "The Final Day" + day = "\x8Dサイゴノヒ"; + break; + case 4: + // "Clear Day" + day = "\x8Dクリアーノヒ"; + break; + default: + gSaveContext.day = 1; + // "The First Day" + day = "\x8Dサイショノヒ"; + break; + } + + GfxPrint_Printf(printer, "Day:\x8D%s", day); +} + +void Select_DrawMenu(SelectContext* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + GfxPrint* printer; + + OPEN_DISPS(gfxCtx); + + func_8012C4C0(gfxCtx); + + printer = alloca(sizeof(GfxPrint)); + GfxPrint_Init(printer); + GfxPrint_Open(printer, POLY_OPA_DISP); + + Select_PrintMenu(this, printer); + Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.playerForm)); + Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.cutscene)); + + POLY_OPA_DISP = GfxPrint_Close(printer); + GfxPrint_Destroy(printer); + + CLOSE_DISPS(gfxCtx); +} + +void Select_DrawLoadingScreen(SelectContext* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + GfxPrint printer; + + OPEN_DISPS(gfxCtx); + + func_8012C4C0(gfxCtx); + + GfxPrint_Init(&printer); + GfxPrint_Open(&printer, POLY_OPA_DISP); + + Select_PrintLoadingMessage(this, &printer); + + POLY_OPA_DISP = GfxPrint_Close(&printer); + GfxPrint_Destroy(&printer); + + CLOSE_DISPS(gfxCtx); +} + +void Select_Draw(SelectContext* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + + func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + + SET_FULLSCREEN_VIEWPORT(&this->view); + View_RenderView(&this->view, 0xF); + if (!this->state.running) { + Select_DrawLoadingScreen(this); + } else { + Select_DrawMenu(this); + } +} + +void Select_Main(GameState* thisx) { + SelectContext* this = (SelectContext*)thisx; + + Select_UpdateMenu(this); + Select_Draw(this); +} + +void Select_Destroy(GameState* thisx) { + ShrinkWindow_Fini(); +} + +void Select_Init(GameState* thisx) { + SelectContext* this = (SelectContext*)thisx; + + this->state.main = Select_Main; + this->state.destroy = Select_Destroy; + + this->scenes = sScenes; + this->topDisplayedScene = 0; + this->currentScene = 0; + this->pageDownStops[0] = 0; + this->pageDownStops[1] = 19; + this->pageDownStops[2] = 37; + this->pageDownStops[3] = 51; + this->pageDownStops[4] = 59; + this->pageDownStops[5] = 73; + this->pageDownStops[6] = 91; + this->pageDownIndex = 0; + this->opt = 0; + this->count = ARRAY_COUNT(sScenes); + + ShrinkWindow_Init(); + View_Init(&this->view, this->state.gfxCtx); + this->view.flags = (0x08 | 0x02); + this->verticalInputAccumulator = 0; + this->verticalInput = 0; + this->timerUp = 0; + this->timerDown = 0; + this->lockUp = false; + this->lockDown = false; + this->unk_274 = 0; + + if ((dREG(80) >= 0) && (dREG(80) < this->count)) { + this->currentScene = dREG(80); + this->topDisplayedScene = dREG(81); + this->pageDownIndex = dREG(82); + } + + Game_SetFramerateDivisor(&this->state, 1); + gSaveContext.cutscene = 0; + gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.linkAge = 0; +} diff --git a/src/overlays/gamestates/ovl_select/z_select.h b/src/overlays/gamestates/ovl_select/z_select.h index 14e0023e1..a454a098b 100644 --- a/src/overlays/gamestates/ovl_select/z_select.h +++ b/src/overlays/gamestates/ovl_select/z_select.h @@ -3,12 +3,39 @@ #include "global.h" +struct SelectContext; + void Select_Init(GameState* thisx); void Select_Destroy(GameState* thisx); +typedef void (*Select_LoadFunc)(struct SelectContext*, u32, s32); + typedef struct { - GameState state; - char unk_A4[0x1DC]; + /* 0x00 */ char* name; + /* 0x04 */ Select_LoadFunc loadFunc; + /* 0x08 */ s32 entranceIndex; +} SceneSelectEntry; // size = 0xC + +typedef struct SelectContext { + /* 0x000 */ GameState state; + /* 0x0A8 */ View view; + /* 0x210 */ s32 count; + /* 0x214 */ SceneSelectEntry* scenes; + /* 0x218 */ s32 currentScene; + /* 0x21C */ s32 pageDownIndex; // Index of pageDownStops + /* 0x220 */ s32 pageDownStops[7]; + /* 0x23C */ char unk_23C[0xC]; + /* 0x248 */ s32 opt; // (Option): This name is the one the menu uses to show this value. It can be used to change in which entrance the player spawns in the selected scene + /* 0x24C */ s32 topDisplayedScene; // The scene which is currently at the top of the screen + /* 0x250 */ char unk_250[0xC]; + /* 0x25C */ s32 verticalInputAccumulator; + /* 0x260 */ s32 verticalInput; + /* 0x264 */ s32 timerUp; + /* 0x268 */ s32 timerDown; + /* 0x26C */ s32 lockUp; + /* 0x270 */ s32 lockDown; + /* 0x274 */ s32 unk_274; // unused + /* 0x278 */ UNK_TYPE1 unk_278[0x08]; } SelectContext; // size = 0x280 #endif diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 3f5bade7f..16100c926 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -20,6 +20,7 @@ animdict ={ "func_800F0568": "Audio_PlaySoundAtPosition", "func_8016970C": "Play_CameraSetAtEye", "func_800BBA88": "Enemy_StartFinishingBlow", + "func_801A89A8": "Audio_QueueSeqCmd", } def replace_anim(file): diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5e54d3c31..558565b7d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2796,7 +2796,7 @@ 0x80144628:("func_80144628",), 0x80144684:("Sram_GenerateRandomSaveFields",), 0x80144890:("func_80144890",), - 0x80144968:("func_80144968",), + 0x80144968:("Sram_InitDebugSave",), 0x80144A94:("func_80144A94",), 0x80144E78:("func_80144E78",), 0x8014546C:("func_8014546C",), @@ -4059,7 +4059,7 @@ 0x801A7B10:("func_801A7B10",), 0x801A7D04:("func_801A7D04",), 0x801A7D84:("func_801A7D84",), - 0x801A89A8:("func_801A89A8",), + 0x801A89A8:("Audio_QueueSeqCmd",), 0x801A89D0:("func_801A89D0",), 0x801A8A50:("func_801A8A50",), 0x801A8ABC:("func_801A8ABC",), @@ -4093,16 +4093,16 @@ 0x8080066C:("Title_Main",), 0x8080071C:("Title_Destroy",), 0x8080074C:("Title_Init",), - 0x80800910:("func_80800910",), - 0x80800930:("func_80800930",), - 0x80800A44:("func_80800A44",), - 0x808013B8:("func_808013B8",), - 0x80801594:("func_80801594",), - 0x80801620:("func_80801620",), - 0x808016E8:("func_808016E8",), - 0x8080194C:("func_8080194C",), - 0x808019FC:("func_808019FC",), - 0x80801A64:("func_80801A64",), + 0x80800910:("Select_LoadTitle",), + 0x80800930:("Select_LoadGame",), + 0x80800A44:("Select_UpdateMenu",), + 0x808013B8:("Select_PrintMenu",), + 0x80801594:("Select_PrintLoadingMessage",), + 0x80801620:("Select_PrintAgeSetting",), + 0x808016E8:("Select_PrintCutsceneSetting",), + 0x8080194C:("Select_DrawMenu",), + 0x808019FC:("Select_DrawLoadingScreen",), + 0x80801A64:("Select_Draw",), 0x80801AFC:("Select_Main",), 0x80801B28:("Select_Destroy",), 0x80801B4C:("Select_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b12e417f1..518d399eb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4609,9 +4609,9 @@ 0x80800868:("D_80800868","UNK_TYPE1","",0x1), 0x80800870:("D_80800870","UNK_TYPE1","",0x1), 0x80800880:("titleUnknownVector3f","Vec3f","",0xc), - 0x80801C80:("D_80801C80","UNK_PTR","",0x4), - 0x80802334:("D_80802334","UNK_PTR","",0x4), - 0x80802364:("D_80802364","UNK_PTR","",0x4), + 0x80801C80:("sScenes","UNK_PTR","",0x4), + 0x80802334:("sLoadingMessages","UNK_PTR","",0x4), + 0x80802364:("sFormLabel","UNK_PTR","",0x4), 0x80802390:("D_80802390","char","[]",0x1), 0x808023AC:("D_808023AC","char","[]",0x1), 0x808023C4:("D_808023C4","char","[]",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 4b031b6a4..e8f66fc01 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2310,7 +2310,7 @@ asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s,Sram_CalcChecksum,0x801445 asm/non_matchings/code/z_sram_NES/func_80144628.s,func_80144628,0x80144628,0x17 asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s,Sram_GenerateRandomSaveFields,0x80144684,0x83 asm/non_matchings/code/z_sram_NES/func_80144890.s,func_80144890,0x80144890,0x36 -asm/non_matchings/code/z_sram_NES/func_80144968.s,func_80144968,0x80144968,0x4B +asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s,Sram_InitDebugSave,0x80144968,0x4B asm/non_matchings/code/z_sram_NES/func_80144A94.s,func_80144A94,0x80144A94,0xF9 asm/non_matchings/code/z_sram_NES/func_80144E78.s,func_80144E78,0x80144E78,0x17D asm/non_matchings/code/z_sram_NES/func_8014546C.s,func_8014546C,0x8014546C,0x8B @@ -3573,7 +3573,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A794C.s,func_801A794C,0x801A794C,0x asm/non_matchings/code/code_801A7B10/func_801A7B10.s,func_801A7B10,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 asm/non_matchings/code/code_801A7B10/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 -asm/non_matchings/code/code_801A7B10/func_801A89A8.s,func_801A89A8,0x801A89A8,0xA +asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA asm/non_matchings/code/code_801A7B10/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x1B asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 From 96cd49b6d5d642be515bdfeb97048577d8486925 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Wed, 29 Sep 2021 00:08:54 -0300 Subject: [PATCH 16/86] `ovl_En_Test4` with 1 non-matching (#319) * Decompile update and stuff * Decompile some more * func_80A41FA4 non_matching * init is a disaster * Import bss * match func_80A41D70 * Improve func_80A42AB8 a bit * equivalent EnTest4_Init * Import data * CLOCK_TIME * Run formatter * func_80A42AB8 may be equivalent now, not completely sure * match func_80A42AB8 * Some minor renames * Name some struct members * Format * format in bigpo * fix merge issue * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Description: Day transition effects * Un-rename unk_144 * Update include/macros.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * sIsLoaded * Update src/overlays/actors/ovl_En_Test4/z_en_test4.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * review * format * daytemp Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- include/functions.h | 12 +- include/macros.h | 1 + include/variables.h | 4 +- include/z64item.h | 3 +- include/z64light.h | 4 +- include/z64player.h | 2 +- spec | 6 +- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 4 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 563 +++++++++++++++++- src/overlays/actors/ovl_En_Test4/z_en_test4.h | 12 +- tools/disasm/variables.txt | 22 +- tools/permuter_settings.toml | 1 + tools/sfxconvert.py | 4 +- 13 files changed, 596 insertions(+), 42 deletions(-) diff --git a/include/functions.h b/include/functions.h index 5b3086c6d..7a8421329 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1768,7 +1768,7 @@ void func_800FAAB4(GlobalContext* globalCtx, u8 arg1); // void func_800FB010(void); void func_800FB320(GlobalContext* globalCtx, u8 param_2); // void func_800FB388(void); -// void func_800FB758(void); +void func_800FB758(GlobalContext* globalCtx); // void func_800FB9B4(void); // void func_800FBCBC(void); // void func_800FBDEC(void); @@ -1814,7 +1814,7 @@ void func_800FE658(f32 arg0); // void func_800FEA50(void); void func_800FEAB0(void); // void func_800FEAC0(void); -// void func_800FEAF4(void); +void func_800FEAF4(EnvironmentContext* envCtx); void* Lib_MemCpy(void* dest, void* src, size_t size); void* Lib_MemSet(void* buffer, s32 value, size_t size); f32 Math_CosS(s16 angle); @@ -2127,7 +2127,7 @@ void func_8010E9F0(s16 arg0, s16 arg1); // void func_8010EB50(void); // void func_8010EBA0(void); // void func_8010EC54(void); -// void func_8010EE74(void); +void func_8010EE74(GlobalContext* globalCtx, s32 day); void Interface_ChangeAlpha(u16 param_1); // void func_8010EF9C(void); // void func_8010F0D4(void); @@ -2879,7 +2879,7 @@ void func_80150D08(GlobalContext* globalCtx, u32 uParm2); // void func_801514B0(void); void func_801518B0(GlobalContext* globalCtx, u16 textId, Actor* Actor); void func_80151938(GlobalContext* globalCtx, u16 textId); -void func_80151A68(GlobalContext* globalCtx, u16 param_2); +void func_80151A68(GlobalContext* globalCtx, u16 textId); void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); // void func_80151C9C(void); // void func_80151DA4(void); @@ -3058,7 +3058,7 @@ void func_80169EFC(GlobalContext* globalCtx); s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx); // UNK_TYPE4 func_8016A02C(s32 param_1, s32 param_2, s16* param_3); // void func_8016A0AC(void); -// void func_8016A168(void); +s32 func_8016A168(void); // void func_8016A178(void); // void func_8016A268(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6); void Play_Init(GameState* gameState); @@ -3871,7 +3871,7 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019FF9C(void); // void func_801A0048(void); // void func_801A00EC(void); -// void func_801A0124(void); +void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); void func_801A0204(UNK_TYPE); diff --git a/include/macros.h b/include/macros.h index 0beaf8a7b..fc03fa4ff 100644 --- a/include/macros.h +++ b/include/macros.h @@ -49,6 +49,7 @@ #define CURRENT_DAY (((void)0, gSaveContext.day) % 5) #define CLOCK_TIME(hr, min) ((s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60))) +#define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) #define SLOT(item) gItemSlots[item] #define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] diff --git a/include/variables.h b/include/variables.h index 6d4cd7752..57b03df07 100644 --- a/include/variables.h +++ b/include/variables.h @@ -949,7 +949,7 @@ extern GameStateOverlay daytelopGameStateInfo; // extern UNK_TYPE2 D_801BDA74; // extern UNK_TYPE2 D_801BDA78; // extern UNK_TYPE2 D_801BDA7C; -// extern UNK_TYPE4 D_801BDA9C; +extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; // extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; @@ -3312,7 +3312,7 @@ extern u8 actorCutsceneNextCutscenes[16]; extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4E74; // extern UNK_TYPE1 D_801F4E78; -// extern UNK_TYPE1 D_801F4E7A; +extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4E80; // extern UNK_TYPE1 D_801F4EE0; // extern UNK_TYPE1 D_801F4EE8; diff --git a/include/z64item.h b/include/z64item.h index a5939c0dc..11c0201d6 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -20,7 +20,8 @@ typedef enum { } UpgradeType; typedef enum { - /* 0x01 */ ITEM_BOW = 0x01, + /* 0x00 */ ITEM_OCARINA, + /* 0x01 */ ITEM_BOW, /* 0x06 */ ITEM_BOMB = 0x06, /* 0x07 */ ITEM_BOMBCHU, /* 0x08 */ ITEM_STICK, diff --git a/include/z64light.h b/include/z64light.h index 567fb84e6..90ee01fb0 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -93,9 +93,7 @@ typedef enum LightType { /* 0x02 */ LIGHT_POINT_GLOW } LightType; -typedef struct GlobalContext GlobalContext; - typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); -typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, GlobalContext* globalCtx); +typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct GlobalContext* globalCtx); #endif diff --git a/include/z64player.h b/include/z64player.h index 0e25fcd86..8bab2605f 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -176,7 +176,7 @@ typedef struct Player { /* 0x386 */ u16 unk_386; /* 0x388 */ Actor* unk_388; /* 0x38C */ s16 unk_38C; - /* 0x390 */ Actor* unk_390; + /* 0x390 */ Actor* rideActor; /* 0x394 */ u8 unk_394; /* 0x395 */ u8 unk_395; /* 0x396 */ u8 unk_396; diff --git a/spec b/spec index 8282b6bec..0faeb1229 100644 --- a/spec +++ b/spec @@ -2913,9 +2913,11 @@ beginseg name "ovl_En_Test4" compress include "build/src/overlays/actors/ovl_En_Test4/z_en_test4.o" - include "build/data/ovl_En_Test4/ovl_En_Test4.data.o" - include "build/data/ovl_En_Test4/ovl_En_Test4.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Test4/ovl_En_Test4_reloc.o" +#else include "build/data/ovl_En_Test4/ovl_En_Test4.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 234552143..7efae12fc 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -7,7 +7,9 @@ struct EnHorse; typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x450]; + /* 0x144 */ char unk_144[0x00C]; + /* 0x150 */ s32 unk_150; + /* 0x154 */ char unk_154[0x440]; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 05bcb647d..1abbd9617 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -1,4 +1,12 @@ +/* + * File: z_en_test4.c + * Overlay: ovl_En_Test4 + * Description: Day transition effects + */ + #include "z_en_test4.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" #define FLAGS 0x00100030 @@ -11,7 +19,6 @@ void EnTest4_Update(Actor* thisx, GlobalContext* globalCtx); void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx); void func_80A42F20(EnTest4* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test4_InitVars = { ACTOR_EN_TEST4, ACTORCAT_SWITCH, @@ -24,28 +31,558 @@ const ActorInit En_Test4_InitVars = { (ActorFunc)NULL, }; +static s32 sIsLoaded = false; +// "Night of ..." +static s16 sNightMessages1[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; +// "Dawn of ..." (Note: first two message are the same) +static s16 sDayMessages1[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; +// "Night of ..." +static s16 sNightMessages2[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; +// "Dawn of ..." (Note: first two message are the same) +static s16 sDayMessages2[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; +static u16 D_80A43364[] = { CLOCK_TIME(6, 0), CLOCK_TIME(18, 0) }; + +static s16 sCutscenes[2]; +static s16 sCurrentCs; + +void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { + if (this->unk_144 != 0) { + func_80151A68(globalCtx, sNightMessages1[CURRENT_DAY - 1]); + } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { + if (globalCtx->actorCtx.unk5 & 2) { + Sram_IncrementDay(); + gSaveContext.time = CLOCK_TIME(6, 0); + func_80151A68(globalCtx, sDayMessages1[CURRENT_DAY - 1]); + } else { + this->unk_144 = 0; + this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + } + + func_8010EE74(globalCtx, CURRENT_DAY); + D_801BDBC8 = 0xFE; + func_800FB758(globalCtx); + func_800FEAF4(&globalCtx->envCtx); + this->actionFunc = func_80A42AB8; + } + + if (gSaveContext.cutsceneTrigger == 0) { + if ((sCutscenes[this->unk_144] >= 0) && !(globalCtx->actorCtx.unk5 & 2)) { + this->actionFunc = func_80A42F20; + sCurrentCs = sCutscenes[this->unk_144]; + this->transitionCsTimer = 0; + gSaveContext.eventInf[1] |= 0x80; + } else if (this->unk_144 == 0) { + play_sound(NA_SE_EV_CHICKEN_CRY_M); + } else { + func_8019F128(NA_SE_EV_DOG_CRY_EVENING); + } + } else { + this->actionFunc = func_80A42AB8; + if (this->unk_144 == 0) { + this->unk_144 = 1; + } else { + this->unk_144 = 0; + } + + this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + } +} + +void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { + if (this->unk_144 != 0) { + func_80151A68(globalCtx, sNightMessages2[CURRENT_DAY - 1]); + } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { + Sram_IncrementDay(); + gSaveContext.time = CLOCK_TIME(6, 0); + func_8010EE74(globalCtx, CURRENT_DAY); + func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); + D_801BDBC8 = 0xFE; + func_800FB758(globalCtx); + func_800FEAF4(&globalCtx->envCtx); + this->actionFunc = func_80A42AB8; + } + + if (gSaveContext.cutsceneTrigger == 0) { + if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { + this->actionFunc = func_80A42F20; + sCurrentCs = sCutscenes[this->unk_144]; + this->transitionCsTimer = 0; + gSaveContext.eventInf[1] |= 0x80; + } else if (this->unk_144 == 0) { + play_sound(NA_SE_EV_CHICKEN_CRY_M); + } else { + func_8019F128(NA_SE_EV_DOG_CRY_EVENING); + } + } else { + this->actionFunc = func_80A42AB8; + if (this->unk_144 == 0) { + this->unk_144 = 1; + } else { + this->unk_144 = 0; + } + + this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + } +} + +// Bells on last day +void func_80A42198(EnTest4* this) { + if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { + if (gSaveContext.time < CLOCK_TIME(17, 30)) { + this->nextBellTime = CLOCK_TIME(17, 30); + } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + this->nextBellTime = CLOCK_TIME(17, 36); + } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + this->nextBellTime = CLOCK_TIME(17, 42); + } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + this->nextBellTime = CLOCK_TIME(17, 48); + } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + this->nextBellTime = CLOCK_TIME(17, 54); + } else { + this->nextBellTime = CLOCK_TIME(0, 0); + } + } else if (gSaveContext.time > CLOCK_TIME(6, 0)) { + this->nextBellTime = CLOCK_TIME(0, 0); + } else if (gSaveContext.time < CLOCK_TIME(0, 10)) { + this->nextBellTime = CLOCK_TIME(0, 10); + } else if (gSaveContext.time < CLOCK_TIME(0, 20)) { + this->nextBellTime = CLOCK_TIME(0, 20); + } else if (gSaveContext.time < CLOCK_TIME(0, 30)) { + this->nextBellTime = CLOCK_TIME(0, 30); + } else if (gSaveContext.time < CLOCK_TIME(0, 40)) { + this->nextBellTime = CLOCK_TIME(0, 40); + } else if (gSaveContext.time < CLOCK_TIME(0, 50)) { + this->nextBellTime = CLOCK_TIME(0, 50); + } else if (gSaveContext.time < CLOCK_TIME(1, 0)) { + this->nextBellTime = CLOCK_TIME(1, 0); + } else if (gSaveContext.time < CLOCK_TIME(1, 10)) { + this->nextBellTime = CLOCK_TIME(1, 10); + } else if (gSaveContext.time < CLOCK_TIME(1, 20)) { + this->nextBellTime = CLOCK_TIME(1, 20); + } else if (gSaveContext.time < CLOCK_TIME(1, 30) - 1) { + this->nextBellTime = CLOCK_TIME(1, 30) - 1; + } else if (gSaveContext.time < CLOCK_TIME(1, 40) - 1) { + this->nextBellTime = CLOCK_TIME(1, 40) - 1; + } else if (gSaveContext.time < CLOCK_TIME(1, 50) - 1) { + this->nextBellTime = CLOCK_TIME(1, 50) - 1; + } else if (gSaveContext.time < CLOCK_TIME(2, 0)) { + this->nextBellTime = CLOCK_TIME(2, 0); + } else if (gSaveContext.time < CLOCK_TIME(2, 10)) { + this->nextBellTime = CLOCK_TIME(2, 10); + } else if (gSaveContext.time < CLOCK_TIME(2, 20)) { + this->nextBellTime = CLOCK_TIME(2, 20); + } else if (gSaveContext.time < CLOCK_TIME(2, 30)) { + this->nextBellTime = CLOCK_TIME(2, 30); + } else if (gSaveContext.time < CLOCK_TIME(2, 40)) { + this->nextBellTime = CLOCK_TIME(2, 40); + } else if (gSaveContext.time < CLOCK_TIME(2, 50)) { + this->nextBellTime = CLOCK_TIME(2, 50); + } else if (gSaveContext.time < CLOCK_TIME(3, 0)) { + this->nextBellTime = CLOCK_TIME(3, 0); + } else if (gSaveContext.time < CLOCK_TIME(3, 10)) { + this->nextBellTime = CLOCK_TIME(3, 10); + } else if (gSaveContext.time < CLOCK_TIME(3, 20)) { + this->nextBellTime = CLOCK_TIME(3, 20); + } else if (gSaveContext.time < CLOCK_TIME(3, 30)) { + this->nextBellTime = CLOCK_TIME(3, 30); + } else if (gSaveContext.time < CLOCK_TIME(3, 40)) { + this->nextBellTime = CLOCK_TIME(3, 40); + } else if (gSaveContext.time < CLOCK_TIME(3, 50)) { + this->nextBellTime = CLOCK_TIME(3, 50); + } else if (gSaveContext.time < CLOCK_TIME(4, 0)) { + this->nextBellTime = CLOCK_TIME(4, 0); + } else if (gSaveContext.time < CLOCK_TIME(4, 10)) { + this->nextBellTime = CLOCK_TIME(4, 10); + } else if (gSaveContext.time < CLOCK_TIME(4, 20)) { + this->nextBellTime = CLOCK_TIME(4, 20); + } else if (gSaveContext.time < CLOCK_TIME(4, 30) - 1) { + this->nextBellTime = CLOCK_TIME(4, 30) - 1; + } else if (gSaveContext.time < CLOCK_TIME(4, 40) - 1) { + this->nextBellTime = CLOCK_TIME(4, 40) - 1; + } else if (gSaveContext.time < CLOCK_TIME(4, 50) - 1) { + this->nextBellTime = CLOCK_TIME(4, 50) - 1; + } else if (gSaveContext.time < CLOCK_TIME(5, 0)) { + this->nextBellTime = CLOCK_TIME(5, 0); + } else if (gSaveContext.time < CLOCK_TIME(5, 5)) { + this->nextBellTime = CLOCK_TIME(5, 5); + } else if (gSaveContext.time < CLOCK_TIME(5, 10)) { + this->nextBellTime = CLOCK_TIME(5, 10); + } else if (gSaveContext.time < CLOCK_TIME(5, 15) - 1) { + this->nextBellTime = CLOCK_TIME(5, 15) - 1; + } else if (gSaveContext.time < CLOCK_TIME(5, 20)) { + this->nextBellTime = CLOCK_TIME(5, 20); + } else if (gSaveContext.time < CLOCK_TIME(5, 25) - 1) { + this->nextBellTime = CLOCK_TIME(5, 25) - 1; + } else if (gSaveContext.time < CLOCK_TIME(5, 30)) { + this->nextBellTime = CLOCK_TIME(5, 30); + } else if (gSaveContext.time < CLOCK_TIME(5, 33) - 1) { + this->nextBellTime = CLOCK_TIME(5, 33) - 1; + } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + this->nextBellTime = CLOCK_TIME(5, 36); + } else if (gSaveContext.time < CLOCK_TIME(5, 39) - 1) { + this->nextBellTime = CLOCK_TIME(5, 39) - 1; + } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + this->nextBellTime = CLOCK_TIME(5, 42); + } else if (gSaveContext.time < CLOCK_TIME(5, 45)) { + this->nextBellTime = CLOCK_TIME(5, 45); + } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + this->nextBellTime = CLOCK_TIME(5, 48); + } else if (gSaveContext.time < CLOCK_TIME(5, 51)) { + this->nextBellTime = CLOCK_TIME(5, 51); + } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + this->nextBellTime = CLOCK_TIME(5, 54); + } else if (gSaveContext.time < CLOCK_TIME(5, 57)) { + this->nextBellTime = CLOCK_TIME(5, 57); + } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + this->nextBellTime = CLOCK_TIME(6, 0); + } +} + +// Bells on first and second day +void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { + gSaveContext.unk_3F64 = 1000.0f; + + if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time < CLOCK_TIME(18, 0))) { + if (gSaveContext.time < CLOCK_TIME(17, 30)) { + this->nextBellTime = CLOCK_TIME(17, 30); + } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + this->nextBellTime = CLOCK_TIME(17, 36); + } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + this->nextBellTime = CLOCK_TIME(17, 42); + } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + this->nextBellTime = CLOCK_TIME(17, 48); + } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + this->nextBellTime = CLOCK_TIME(17, 54); + } else { + this->nextBellTime = CLOCK_TIME(5, 30); + } + } else { + if (gSaveContext.time < CLOCK_TIME(5, 30)) { + this->nextBellTime = CLOCK_TIME(5, 30); + } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + this->nextBellTime = CLOCK_TIME(5, 36); + } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + this->nextBellTime = CLOCK_TIME(5, 42); + gSaveContext.unk_3F64 -= 50.0f; + } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + this->nextBellTime = CLOCK_TIME(5, 48); + gSaveContext.unk_3F64 -= 100.0f; + } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + this->nextBellTime = CLOCK_TIME(5, 54); + gSaveContext.unk_3F64 -= 150.0f; + } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + this->nextBellTime = CLOCK_TIME(17, 30); + gSaveContext.unk_3F64 -= 200.0f; + } else { + this->nextBellTime = CLOCK_TIME(17, 30); + } + + if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || + (gSaveContext.time >= CLOCK_TIME(17, 0))) { + gSaveContext.unk_3F64 = 1000.0f; + } + if (gSaveContext.unk_3F64 != 1000.0f) { + gSaveContext.unk_3F60 = 1; + } + } +} + +#ifdef NON_MATCHING +// 1 instruction in the wrong place +void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 dayTemp; + EnTest4* this = THIS; + Player* player = PLAYER; + s8 temp_v0 = this->actor.cutscene; + + sCutscenes[0] = temp_v0; + if (temp_v0 >= 0) { + ActorCutscene* temp_v0_2 = ActorCutscene_GetCutscene(sCutscenes[0]); + + gSaveContext.eventInf[5] |= 0x4; + sCutscenes[1] = temp_v0_2->additionalCutscene; + } else { + gSaveContext.eventInf[5] &= (u8)~0x4; + sCutscenes[1] = sCutscenes[0]; + } + + if (sIsLoaded || (gSaveContext.eventInf[2] & 0x80)) { + Actor_MarkForDeath(&this->actor); + } else { + sIsLoaded = true; + this->actor.room = -1; + gSaveContext.unk_3F60 = 0; + gSaveContext.unk_3F64 = 1000.0f; + if (CURRENT_DAY == 0) { + if (gSaveContext.time < CLOCK_TIME(6, 1)) { + gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.gameMode = 0; + do { + GameState* state = &globalCtx->state; + state->running = false; + } while (0); + SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + this->unk_144 = 1; + gSaveContext.time = CLOCK_TIME(6, 0); + Actor_MarkForDeath(&this->actor); + } else { + gSaveContext.day = 1; + dayTemp = gSaveContext.day; + gSaveContext.daysElapsed = dayTemp; + this->unk_144 = 1; + this->unk_146 = gSaveContext.time; + this->actionFunc = func_80A42AB8; + } + } else if (gSaveContext.time == CLOCK_TIME(6, 0)) { + this->unk_144 = 0; + func_80A41D70(this, globalCtx); + if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && + !(globalCtx->actorCtx.unk5 & 2)) { + player->stateFlags1 |= 0x200; + } + } else { + if ((gSaveContext.time > CLOCK_TIME(18, 0)) || (gSaveContext.time < CLOCK_TIME(6, 0))) { + this->unk_144 = 0; + } else { + this->unk_144 = 1; + } + this->unk_146 = gSaveContext.time; + this->actionFunc = func_80A42AB8; + } + } + + if (CURRENT_DAY == 3) { + func_80A42198(this); + } else { + func_80A425E4(this, globalCtx); + } + + this->lastBellTime = gSaveContext.time; + if ((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) { + gSaveContext.unk_3F60 = 0; + gSaveContext.unk_3F64 = 1000.0f; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/EnTest4_Init.s") #endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A41D70.s") +void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A41FA4.s") +void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A42198.s") + if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && + (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { + s16 temp_a2; + u16 temp_a0 = D_80A43364[this->unk_144]; + s16 temp_a3; + s16 bellDiff; + s16 new_var; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A425E4.s") + temp_a3 = gSaveContext.time - temp_a0; + temp_a2 = this->unk_146 - temp_a0; + bellDiff = this->lastBellTime - this->nextBellTime; + new_var = gSaveContext.time - this->nextBellTime; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/EnTest4_Init.s") + if ((temp_a3 * temp_a2) <= 0) { + gSaveContext.unk_3CA7 = 1; + if (globalCtx->actorCtx.unk5 & 0x4) { + globalCtx->actorCtx.unk5 &= ~0x4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/EnTest4_Destroy.s") + if (temp_a0 != CLOCK_TIME(6, 0)) { + func_80A41FA4(this, globalCtx); + } else if (temp_a0 == CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3) { + func_8011C808(globalCtx); + Actor_MarkForDeath(&this->actor); + gSaveContext.eventInf[1] |= 0x80; + } else if (((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { + func_80A41FA4(this, globalCtx); + } else { + gSaveContext.unk_3F64 = 0.0f; + func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, + &player->unk_3C0, player->unk_3CC); + func_80169EFC(globalCtx); + if (player->stateFlags1 & 0x800000) { + EnHorse* rideActor = (EnHorse*)player->rideActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A42AB8.s") + if ((rideActor->unk_150 == 0) || (rideActor->unk_150 == 2)) { + if (CURRENT_DAY < 3) { + D_801BDA9C = 1; + } else { + D_801BDA9C = 0; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A42F20.s") + gSaveContext.respawnFlag = -4; + gSaveContext.eventInf[2] |= 0x80; + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A430C8.s") + if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { + player->stateFlags1 |= 0x200; + this->unk_146 = gSaveContext.time; + } else { + if (this->unk_144 == 0) { + this->unk_144 = 1; + } else { + this->unk_144 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A431C8.s") + this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + } + } else if ((new_var * bellDiff) <= 0) { + func_801A0124(&this->actor.projectedPos, (this->actor.params >> 5) & 0xF); + this->lastBellTime = gSaveContext.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/func_80A4323C.s") + if (CURRENT_DAY == 3) { + if ((this->nextBellTime == CLOCK_TIME(0, 0)) && + ((gSaveContext.inventory.items[ITEM_OCARINA] == ITEM_NONE) || + (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { + s32 phi_v0; + u32 entranceIndex = gSaveContext.entranceIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/EnTest4_Update.s") + if ((globalCtx->actorCtx.unk5 & 2)) { + phi_v0 = 0xCFF; + } else { + phi_v0 = 0xBFF; + } + func_80169DCC(globalCtx, 1, entranceIndex, player->unk_3CE, phi_v0, &player->unk_3C0, + player->unk_3CC); + + if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { + globalCtx->nextEntranceIndex = 0x5400; + } else { + globalCtx->nextEntranceIndex = 0xD800; + } + gSaveContext.nextCutsceneIndex = 0xFFF1; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + player->stateFlags1 |= 0x200; + Actor_MarkForDeath(&this->actor); + } + func_80A42198(this); + } else { + func_80A425E4(this, globalCtx); + } + } + } +} + +void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { + if (!this->transitionCsTimer) { + if (sCurrentCs >= 0) { + if (ActorCutscene_GetCanPlayNext(sCurrentCs) == 0) { + ActorCutscene_SetIntentToPlay(sCurrentCs); + } else { + ActorCutscene_Start(sCurrentCs, &this->actor); + this->transitionCsTimer = 1; + } + } else { + this->transitionCsTimer = 1; + } + } else if (this->transitionCsTimer < 60) { + this->transitionCsTimer++; + if (this->transitionCsTimer == 10) { + if (this->unk_144 == 0) { + play_sound(NA_SE_EV_CHICKEN_CRY_M); + } else { + func_8019F128(NA_SE_EV_DOG_CRY_EVENING); + } + } + if (this->transitionCsTimer == 60) { + Player* player = PLAYER; + + gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.time; + globalCtx->numSetupActors = -globalCtx->numSetupActors; + player->stateFlags1 &= ~0x200; + } + } else { + this->actionFunc = func_80A42AB8; + if (this->unk_144 == 0) { + this->unk_144 = 1; + } else { + this->unk_144 = 0; + } + + if (sCurrentCs >= 0) { + ActorCutscene_Stop(sCurrentCs); + } + gSaveContext.unk_3F22 = 0; + gSaveContext.eventInf[1] &= (u8)~0x80; + Interface_ChangeAlpha(50); + } +} + +void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { + if ((CURRENT_DAY == 2) && (gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && + (globalCtx->envCtx.unk_F2[2] == 0)) { + // rain? + + D_801BDBB0 = 1; + func_800FD78C(globalCtx); + globalCtx->envCtx.unk_E3 = 1; + globalCtx->envCtx.unk_F2[0] = 0x3C; + } else { + if (globalCtx->envCtx.unk_F2[0] != 0) { + if ((globalCtx->state.frames % 4) == 0) { + globalCtx->envCtx.unk_F2[0]--; + if ((globalCtx->envCtx.unk_F2[0]) == 8) { + func_800FD858(globalCtx); + } + } + } + } + + if (D_801BDBB0 == 1) { + this->state = TEST4_STATE_1; + } +} + +void func_80A431C8(EnTest4* this, GlobalContext* globalCtx) { + if (((gSaveContext.time >= CLOCK_TIME(17, 30)) && (gSaveContext.time < CLOCK_TIME(23, 0)) && + (globalCtx->envCtx.unk_F2[0] != 0)) || + (globalCtx->envCtx.unk_F2[2] != 0)) { + D_801BDBB0 = 0; + globalCtx->envCtx.unk_E3 = 2; + } + + if (D_801BDBB0 == 0) { + this->state = TEST4_STATE_0; + } +} + +void func_80A4323C(EnTest4* this, GlobalContext* globalCtx) { + s32 temp_v0 = (this->actor.params >> 0xA) * 0x64; + + if (temp_v0 > 0) { + D_801F4E7A = temp_v0; + } +} + +void EnTest4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest4* this = THIS; + Player* player = PLAYER; + + if (!(player->stateFlags1 & 2)) { + this->actionFunc(this, globalCtx); + + if (func_800FE4B8(globalCtx) != 0) { + switch (this->state) { + case TEST4_STATE_0: + func_80A430C8(this, globalCtx); + break; + case TEST4_STATE_1: + func_80A431C8(this, globalCtx); + break; + } + } + func_80A4323C(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.h b/src/overlays/actors/ovl_En_Test4/z_en_test4.h index 54db025a8..4927c337e 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.h +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.h @@ -9,10 +9,20 @@ typedef void (*EnTest4ActionFunc)(struct EnTest4*, GlobalContext*); typedef struct EnTest4 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC]; + /* 0x0144 */ s8 unk_144; // 0 on night, 1 on day + /* 0x0145 */ u8 transitionCsTimer; + /* 0x0146 */ u16 unk_146; + /* 0x0148 */ u16 nextBellTime; // Next time the bell will sound + /* 0x014A */ u16 lastBellTime; // Last time the bell sounded + /* 0x014C */ u8 state; /* 0x0150 */ EnTest4ActionFunc actionFunc; } EnTest4; // size = 0x154 +typedef enum { + /* 0 */ TEST4_STATE_0, + /* 1 */ TEST4_STATE_1 +} EnTest4State; + extern const ActorInit En_Test4_InitVars; #endif // Z_EN_TEST4_H diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 518d399eb..a7bc54164 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -978,13 +978,13 @@ 0x801BDBA0:("D_801BDBA0","UNK_TYPE1","",0x1), 0x801BDBA4:("D_801BDBA4","UNK_TYPE1","",0x1), 0x801BDBA8:("D_801BDBA8","UNK_TYPE1","",0x1), - 0x801BDBB0:("D_801BDBB0","UNK_TYPE1","",0x1), + 0x801BDBB0:("D_801BDBB0","u8","",0x1), 0x801BDBB4:("D_801BDBB4","UNK_TYPE1","",0x1), 0x801BDBB8:("D_801BDBB8","UNK_TYPE1","",0x1), 0x801BDBBC:("D_801BDBBC","UNK_TYPE1","",0x1), 0x801BDBC0:("D_801BDBC0","UNK_TYPE1","",0x1), 0x801BDBC4:("D_801BDBC4","UNK_TYPE1","",0x1), - 0x801BDBC8:("D_801BDBC8","UNK_TYPE1","",0x1), + 0x801BDBC8:("D_801BDBC8","u8","",0x1), 0x801BDBCC:("D_801BDBCC","UNK_TYPE1","",0x1), 0x801BDCF4:("D_801BDCF4","UNK_TYPE1","",0x1), 0x801BE38E:("D_801BE38E","UNK_TYPE1","",0x1), @@ -4064,7 +4064,7 @@ 0x801F4E70:("D_801F4E70","UNK_TYPE1","",0x1), 0x801F4E74:("D_801F4E74","UNK_TYPE1","",0x1), 0x801F4E78:("D_801F4E78","UNK_TYPE1","",0x1), - 0x801F4E7A:("D_801F4E7A","UNK_TYPE1","",0x1), + 0x801F4E7A:("D_801F4E7A","s16","",0x2), 0x801F4E80:("D_801F4E80","UNK_TYPE1","",0x1), 0x801F4EE0:("D_801F4EE0","UNK_TYPE1","",0x1), 0x801F4EE8:("D_801F4EE8","UNK_TYPE1","",0x1), @@ -11773,14 +11773,14 @@ 0x80A41D68:("D_80A41D68","UNK_TYPE1","",0x1), 0x80A41D6C:("D_80A41D6C","UNK_TYPE1","",0x1), 0x80A43320:("En_Test4_InitVars","ActorInit","",0x20), - 0x80A43340:("D_80A43340","UNK_TYPE4","",0x4), - 0x80A43342:("D_80A43342","UNK_TYPE1","",0x1), - 0x80A4334A:("D_80A4334A","UNK_TYPE1","",0x1), - 0x80A43352:("D_80A43352","UNK_TYPE1","",0x1), - 0x80A4335A:("D_80A4335A","UNK_TYPE1","",0x1), - 0x80A43364:("D_80A43364","UNK_TYPE1","",0x1), - 0x80A434D0:("D_80A434D0","s16","[2]",0x4), - 0x80A434D4:("D_80A434D4","UNK_TYPE1","",0x1), + 0x80A43340:("sIsLoaded","s32","[3]",0x6), + 0x80A43342:("sNightMessages1","s16","[3]",0x6), + 0x80A4334A:("sDayMessages1","s16","[3]",0x6), + 0x80A43352:("sNightMessages2","s16","[3]",0x6), + 0x80A4335A:("sDayMessages2","s16","[3]",0x6), + 0x80A43364:("D_80A43364","u16","[2]",0x4), + 0x80A434D0:("sCutscenes","s16","[2]",0x4), + 0x80A434D4:("sCurrentCs","s16","",0x2), 0x80A449E0:("En_Bat_InitVars","UNK_TYPE1","",0x1), 0x80A44A00:("D_80A44A00","UNK_TYPE1","",0x1), 0x80A44A2C:("D_80A44A2C","UNK_TYPE1","",0x1), diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 82ce7cdfe..f5805056b 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -12,6 +12,7 @@ ABS = "int" SQ = "int" CLAMP = "int" CLOCK_TIME = "int" +CURRENT_DAY = "int" [decompme.compilers] "tools/ido_recomp/linux/7.1/cc" = "ido7.1" diff --git a/tools/sfxconvert.py b/tools/sfxconvert.py index 22044dd59..fbd7aa755 100755 --- a/tools/sfxconvert.py +++ b/tools/sfxconvert.py @@ -61,7 +61,9 @@ def fix_sfx_flag(id): if(id.endswith(' - SFX_FLAG')): splitdata = id.split('-') return splitdata[0].strip(), ' -' + splitdata[1] - if not(int(id,16) & 0x800): + if id.endswith("U"): + id = id[:-1] + if not(int(id, 16) & 0x800): newid = '0x' + format(int(id,16) + 0x800,'X') sfxFlag = ' - SFX_FLAG' else : From 5c06a6b240c2c7c314ef1b68a134b1c0ed370037 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Wed, 29 Sep 2021 23:27:07 +0100 Subject: [PATCH 17/86] Main OK (#329) * Main OK, use defines where known * Couple more defines * Tharo's review * Fix lifemeter bss --- include/functions.h | 10 ++-- include/regs.h | 102 ++++++++++++++++++++--------------------- include/variables.h | 4 +- include/z64.h | 16 ++++--- src/code/main.c | 71 +++++++++++++++++++++++++++- src/code/z_lifemeter.c | 1 + 6 files changed, 139 insertions(+), 65 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7a8421329..63ee51708 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1547,7 +1547,7 @@ s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); u8 func_800E9360(void); -// void static_context_init(void); +void static_context_init(void); // void func_800E9470(void); void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); void DebugDisplay_DrawObjects(GlobalContext* globalCtx); @@ -2089,8 +2089,8 @@ void func_8010A33C(GlobalContext* globalCtx, s16 param_2); // void func_8010BEF0(void); // void func_8010BF24(void); s32 func_8010BF58(Actor* actor, GlobalContext* globalCtx, s32* param_3, UNK_PTR param_4, s32* param_5); -// void Nmi_Init(void); -// void Nmi_SetPrenmiStart(void); +void Nmi_Init(void); +void Nmi_SetPrenmiStart(void); // s32 Nmi_GetPrenmiHasStarted(void); // void func_8010C1B0(void); f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); @@ -3267,8 +3267,8 @@ void Check_DrawI4Texture(u16* buffer, u32 x, u32 y, u32 width, u32 height, u8* t void Check_ClearRGBA16(s16* buffer); // void Check_DrawExpansionPakErrorMessage(void); // void Check_DrawRegionLockErrorMessage(void); -// void Check_ExpansionPak(void); -// void Check_RegionIsSupported(void); +void Check_ExpansionPak(void); +void Check_RegionIsSupported(void); f32 func_80179300(f32 n); f32 func_80179400(s32 n); f32 pow_int(f32 base, s32 exp); diff --git a/include/regs.h b/include/regs.h index d75e11cff..e39e53d69 100644 --- a/include/regs.h +++ b/include/regs.h @@ -43,57 +43,57 @@ #define bREG(r) BASE_REG(28, r) /* TODO: Actually confirm these, in case of miss-match it's at least a simple list to `sed` */ -#define R_ENABLE_ARENA_DBG SREG(0) -#define R_RUN_SPEED_LIMIT REG(45) -#define R_UPDATE_RATE SREG(30) -#define R_PAUSE_MENU_MODE SREG(94) -#define R_C_UP_ICON_X YREG(88) -#define R_C_UP_ICON_Y YREG(89) -#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) -#define R_C_BTN_COLOR(i) ZREG(39 + i) -#define R_B_BTN_COLOR(i) ZREG(43 + i) -#define R_START_LABEL_DD(i) ZREG(48 + i) -#define R_START_LABEL_Y(i) ZREG(51 + i) -#define R_START_LABEL_X(i) ZREG(54 + i) -#define R_C_UP_BTN_X ZREG(62) -#define R_C_UP_BTN_Y ZREG(63) -#define R_START_BTN_X ZREG(68) -#define R_START_BTN_Y ZREG(69) -#define R_ITEM_BTN_X(i) ZREG(70 + i) -#define R_ITEM_BTN_Y(i) ZREG(74 + i) -#define R_ITEM_BTN_DD(i) ZREG(78 + i) -#define R_ITEM_ICON_X(i) ZREG(82 + i) -#define R_ITEM_ICON_Y(i) ZREG(86 + i) -#define R_ITEM_ICON_DD(i) ZREG(90 + i) -#define R_A_BTN_Y XREG(16) -#define R_A_BTN_X XREG(17) -#define R_A_ICON_Y XREG(19) -#define R_A_ICON_X XREG(20) -#define R_A_BTN_COLOR(i) XREG(22 + i) -#define R_MAGIC_BAR_SMALL_Y XREG(48) -#define R_MAGIC_BAR_X XREG(49) -#define R_MAGIC_BAR_LARGE_Y XREG(50) -#define R_MAGIC_FILL_X XREG(51) -#define R_B_LABEL_DD WREG(0) -#define R_OW_MINIMAP_X WREG(29) -#define R_OW_MINIMAP_Y WREG(30) -#define R_MINIMAP_TOGGLED WREG(31) -#define R_B_LABEL_X(i) WREG(40 + i) -#define R_B_LABEL_Y(i) WREG(43 + i) -#define R_DGN_MINIMAP_X WREG(68) -#define R_DGN_MINIMAP_Y WREG(69) -#define R_MAP_INDEX VREG(11) -#define R_MAP_TEX_INDEX_BASE VREG(12) -#define R_MAP_TEX_INDEX VREG(13) -#define R_COMPASS_SCALE_X VREG(14) -#define R_COMPASS_SCALE_Y VREG(15) -#define R_COMPASS_OFFSET_X VREG(16) -#define R_COMPASS_OFFSET_Y VREG(17) -#define R_MINIMAP_COLOR(i) VREG(18 + i) -#define R_ITEM_AMMO_X(i) VREG(64 + i) -#define R_ITEM_AMMO_Y(i) VREG(68 + i) -#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) -#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) +#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT +#define R_RUN_SPEED_LIMIT REG(45) +#define R_UPDATE_RATE SREG(30) +#define R_PAUSE_MENU_MODE SREG(94) +#define R_C_UP_ICON_X YREG(88) +#define R_C_UP_ICON_Y YREG(89) +#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) +#define R_C_BTN_COLOR(i) ZREG(39 + i) +#define R_B_BTN_COLOR(i) ZREG(43 + i) +#define R_START_LABEL_DD(i) ZREG(48 + i) +#define R_START_LABEL_Y(i) ZREG(51 + i) +#define R_START_LABEL_X(i) ZREG(54 + i) +#define R_C_UP_BTN_X ZREG(62) +#define R_C_UP_BTN_Y ZREG(63) +#define R_START_BTN_X ZREG(68) +#define R_START_BTN_Y ZREG(69) +#define R_ITEM_BTN_X(i) ZREG(70 + i) +#define R_ITEM_BTN_Y(i) ZREG(74 + i) +#define R_ITEM_BTN_DD(i) ZREG(78 + i) +#define R_ITEM_ICON_X(i) ZREG(82 + i) +#define R_ITEM_ICON_Y(i) ZREG(86 + i) +#define R_ITEM_ICON_DD(i) ZREG(90 + i) +#define R_A_BTN_Y XREG(16) +#define R_A_BTN_X XREG(17) +#define R_A_ICON_Y XREG(19) +#define R_A_ICON_X XREG(20) +#define R_A_BTN_COLOR(i) XREG(22 + i) +#define R_MAGIC_BAR_SMALL_Y XREG(48) +#define R_MAGIC_BAR_X XREG(49) +#define R_MAGIC_BAR_LARGE_Y XREG(50) +#define R_MAGIC_FILL_X XREG(51) +#define R_B_LABEL_DD WREG(0) +#define R_OW_MINIMAP_X WREG(29) +#define R_OW_MINIMAP_Y WREG(30) +#define R_MINIMAP_TOGGLED WREG(31) +#define R_B_LABEL_X(i) WREG(40 + i) +#define R_B_LABEL_Y(i) WREG(43 + i) +#define R_DGN_MINIMAP_X WREG(68) +#define R_DGN_MINIMAP_Y WREG(69) +#define R_MAP_INDEX VREG(11) +#define R_MAP_TEX_INDEX_BASE VREG(12) +#define R_MAP_TEX_INDEX VREG(13) +#define R_COMPASS_SCALE_X VREG(14) +#define R_COMPASS_SCALE_Y VREG(15) +#define R_COMPASS_OFFSET_X VREG(16) +#define R_COMPASS_OFFSET_Y VREG(17) +#define R_MINIMAP_COLOR(i) VREG(18 + i) +#define R_ITEM_AMMO_X(i) VREG(64 + i) +#define R_ITEM_AMMO_Y(i) VREG(68 + i) +#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) +#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) #define R_FB_FILTER_TYPE SREG(80) #define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) diff --git a/include/variables.h b/include/variables.h index 57b03df07..2cf99e391 100644 --- a/include/variables.h +++ b/include/variables.h @@ -288,7 +288,7 @@ extern char gBuildMakeOption[]; // extern u8 sIdleThreadStack[0x400]; // extern StackEntry sIdleThreadInfo; // extern u8 sBootThreadStack[0x400]; -// extern IrqMgr gIrqMgr; +extern IrqMgr gIrqMgr; // extern u8 sIrqMgrStack[0x500]; // extern StackEntry sIrqMgrStackInfo; // extern OSThread gMainThread; @@ -1665,7 +1665,7 @@ extern u32 D_801D1510; extern u32 D_801D1514[3]; extern s32 gScreenWidth; extern s32 gScreenHeight; -// extern UNK_TYPE4 startHeapSize; +extern u32 startHeapSize; extern PadMgr* padmgrContext; // extern UNK_TYPE4 controllerInputsCaptured; // extern UNK_TYPE4 D_801D1538; diff --git a/include/z64.h b/include/z64.h index a13ffedb6..d3923d6c8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -46,16 +46,20 @@ #define Z_THREAD_ID_IDLE 1 #define Z_THREAD_ID_SLOWLY 2 #define Z_THREAD_ID_MAIN 3 +#define Z_THREAD_ID_GRAPH 4 #define Z_THREAD_ID_SCHED 5 #define Z_THREAD_ID_DMAMGR 18 #define Z_THREAD_ID_IRQMGR 19 -#define Z_PRIORITY_SLOWLY 5 -#define Z_PRIORITY_GRAPH 9 -#define Z_PRIORITY_IDLE 12 -#define Z_PRIORITY_MAIN 12 -#define Z_PRIORITY_DMAMGR 17 -#define Z_PRIORITY_IRQMGR 18 +#define Z_PRIORITY_SLOWLY 5 +#define Z_PRIORITY_GRAPH 9 +#define Z_PRIORITY_AUDIOMGR 11 +#define Z_PRIORITY_IDLE 12 +#define Z_PRIORITY_MAIN 12 +#define Z_PRIORITY_PADMGR 15 +#define Z_PRIORITY_SCHED 16 +#define Z_PRIORITY_DMAMGR 17 +#define Z_PRIORITY_IRQMGR 18 #define EQUIP_SLOT_B 0 #define EQUIP_SLOT_C_LEFT 1 diff --git a/src/code/main.c b/src/code/main.c index 59471ea19..75101c8ab 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -1,3 +1,72 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/main/Main.s") +void Main(void* arg) { + intptr_t fb; + intptr_t sysHeap; + s32 exit; + s16* msg; + + gScreenWidth = SCREEN_WIDTH; + gScreenHeight = SCREEN_HEIGHT; + + Nmi_Init(); + Fault_Start(); + Check_RegionIsSupported(); + Check_ExpansionPak(); + + sysHeap = gSystemHeap; + fb = 0x80780000; + startHeapSize = fb - sysHeap; + SystemArena_Init(sysHeap, startHeapSize); + + static_context_init(); + + R_ENABLE_ARENA_DBG = 0; + + osCreateMesgQueue(&siEventCallbackQueue, siEventCallbackBuffer, ARRAY_COUNT(siEventCallbackBuffer)); + osSetEventMesg(OS_EVENT_SI, &siEventCallbackQueue, NULL); + + osCreateMesgQueue(&mainIrqmgrCallbackQueue, mainIrqCallbackBuffer, ARRAY_COUNT(mainIrqCallbackBuffer)); + + StackCheck_Init(&schedStackEntry, schedStack, schedStack + sizeof(schedStack), 0, 0x100, "sched"); + Sched_Init(&schedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); + + CIC6105_AddRomInfoFaultPage(); + + IrqMgr_AddClient(&gIrqMgr, &mainIrqmgrCallbackNode, &mainIrqmgrCallbackQueue); + + StackCheck_Init(&audioStackEntry, audioStack, audioStack + sizeof(audioStack), 0, 0x100, "audio"); + AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &schedContext, &gIrqMgr); + + StackCheck_Init(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr"); + Padmgr_Start(&siEventCallbackQueue, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack)); + + AudioMgr_Unlock(&audioContext); + + StackCheck_Init(&graphStackEntry, graphStack, graphStack + sizeof(graphStack), 0, 0x100, "graph"); + osCreateThread(&graphOSThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, graphStack + sizeof(graphStack), + Z_PRIORITY_GRAPH); + osStartThread(&graphOSThread); + + exit = false; + + while (!exit) { + msg = NULL; + osRecvMesg(&mainIrqmgrCallbackQueue, (OSMesg)&msg, OS_MESG_BLOCK); + if (msg == NULL) { + break; + } + + switch (*msg) { + case OS_SC_PRE_NMI_MSG: + Nmi_SetPrenmiStart(); + break; + case OS_SC_NMI_MSG: + exit = true; + break; + } + } + + IrqMgr_RemoveClient(&gIrqMgr, &mainIrqmgrCallbackNode); + osDestroyThread(&graphOSThread); +} diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index bbfad829f..73a59f477 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "prevent_bss_reordering.h" static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; From ef875bc2214bcdf3d9afe090bc2994fd5ec18898 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Wed, 29 Sep 2021 23:42:24 +0100 Subject: [PATCH 18/86] Improve check new warnings (#308) * Change check_new_warnings to output stderr to console too * Colour warnings and functions in check_new_warnings * Remove unneeded prototype in EnDai * Add multithreading options, colour to output, help * Give Jenkins a script again * Test * Remove tput warnings, hopefully * Try -T dumb * Undo test warning --- Jenkinsfile | 6 +- Makefile | 2 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 1 - tools/warnings_count/check_new_warnings.sh | 101 +++++++++++++++++++-- tools/warnings_count/compare_warnings.py | 35 ------- tools/warnings_count/compare_warnings.sh | 42 +++++++++ 6 files changed, 141 insertions(+), 46 deletions(-) delete mode 100755 tools/warnings_count/compare_warnings.py create mode 100755 tools/warnings_count/compare_warnings.sh diff --git a/Jenkinsfile b/Jenkinsfile index 7212f269b..555504de4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { } stage('Check setup warnings') { steps { - sh 'python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_setup_current.txt tools/warnings_count/warnings_setup_new.txt' + sh 'bash -c "./tools/warnings_count/compare_warnings.sh setup"' } } stage('Disasm') { @@ -27,7 +27,7 @@ pipeline { } stage('Check disasm warnings') { steps { - sh 'python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_disasm_current.txt tools/warnings_count/warnings_disasm_new.txt' + sh 'bash -c "./tools/warnings_count/compare_warnings.sh disasm"' } } stage('Build') { @@ -37,7 +37,7 @@ pipeline { } stage('Check build warnings') { steps { - sh 'python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_build_current.txt tools/warnings_count/warnings_build_new.txt' + sh 'bash -c "./tools/warnings_count/compare_warnings.sh build"' } } stage('Report Progress') { diff --git a/Makefile b/Makefile index bc71a02e1..2a00a7694 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ endif # Check code syntax with host compiler CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -include stdarg.h $(CHECK_WARNINGS) +CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -include stdarg.h $(CHECK_WARNINGS) CPP := cpp ELF2ROM := tools/buildtools/elf2rom diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index c09c0dd3a..93d43230a 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -16,7 +16,6 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx); void EnDai_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B3F00C(EnDai* this, GlobalContext* globalCtx); -void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx); void func_80B3EF90(EnDai* this, GlobalContext* globalCtx); extern AnimationHeader D_060107B0; diff --git a/tools/warnings_count/check_new_warnings.sh b/tools/warnings_count/check_new_warnings.sh index d9c4ab1e4..7a196c28b 100755 --- a/tools/warnings_count/check_new_warnings.sh +++ b/tools/warnings_count/check_new_warnings.sh @@ -3,14 +3,103 @@ set -e # This script can be used when you want to test locally the amount of warnings produced by your changes before doing a PR. +# Terminal colour codes +# when $TERM is empty (non-interactive shell), then expand tput with '-T xterm-256color' +[[ ${TERM}=="" ]] && TPUTTERM='-T dumb' \ + || TPUTTERM='' + +declare -r BOLD=`tput ${TPUTTERM} bold` +declare -r RED=`tput ${TPUTTERM} setaf 1` +declare -r PURPLE=`tput ${TPUTTERM} setaf 5` +declare -r WHITE=`tput ${TPUTTERM} setaf 7` +declare -r BLINK=`tput ${TPUTTERM} blink` +declare -r RST=`tput ${TPUTTERM} sgr0` + + DIR="$(dirname "$(readlink -f "$0")")" cd "$DIR/../.." +COMPARE_WARNINGS="$DIR/compare_warnings.sh" + +usage () { + echo "Usage: $0 [-h] [-j jobs]" +} + +show_help () { + usage + echo " +Check for new warnings created. + +Optional arguments: + -h Display this message and exit. + -j N use N jobs (does not support plain -j because you shouldn't use it anyway) +" +} + +jobs=1 + +while getopts "hj:" opt +do + case $opt in + h) show_help + exit 0 + ;; + j) j_option_arg="$OPTARG" + if [[ ! "${j_option_arg}" =~ ^[0-9]*$ ]] + then + echo "Error: Option '-j' expects numeric argument, you gave: ${j_option_arg}" + exit 1 + fi + jobs="$j_option_arg" + ;; + ?) usage + exit 2 + ;; + esac +done +shift $(($OPTIND - 1)) + +# Confirm run with -j jobs +echo "This will run + make distclean + make setup + make disasm + make all +using $jobs threads. This may take some time." +read -r -p "Is this okay? [Y/n]" response +response=${response,,} # tolower +if !([[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]); then +exit 0 +fi + + + + +remove_ansi_codes () { + perl -pe ' + s/\e\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]//g; + s/\e[PX^_].*?\e\\//g; + s/\e\][^\a]*(?:\a|\e\\)//g; + s/\e[\[\]A-Z\\^_@]//g;' $1 +} + + +make_warnings () { + make $1 -j$jobs 2> >(tee tools/warnings_count/warnings_temp.txt) \ + && remove_ansi_codes tools/warnings_count/warnings_temp.txt > tools/warnings_count/warnings_$2_new.txt \ + && rm tools/warnings_count/warnings_temp.txt +} + + make distclean -make setup 2> tools/warnings_count/warnings_setup_new.txt -make disasm 2> tools/warnings_count/warnings_disasm_new.txt -make all 2> tools/warnings_count/warnings_build_new.txt +make_warnings setup setup +make_warnings disasm disasm +make_warnings all build + +echo " +$(tput ${TPUTTERM} setaf 3)(lots of make output ${TPUTTERM} here...) +$RST" +$COMPARE_WARNINGS setup +$COMPARE_WARNINGS disasm +$COMPARE_WARNINGS build -python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_setup_current.txt tools/warnings_count/warnings_setup_new.txt -python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_disasm_current.txt tools/warnings_count/warnings_disasm_new.txt -python3 tools/warnings_count/compare_warnings.py tools/warnings_count/warnings_build_current.txt tools/warnings_count/warnings_build_new.txt diff --git a/tools/warnings_count/compare_warnings.py b/tools/warnings_count/compare_warnings.py deleted file mode 100755 index 3f1142325..000000000 --- a/tools/warnings_count/compare_warnings.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 - -import argparse - - -def countFileLines(filename: str) -> int: - with open(filename) as f: - return len(f.readlines()) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('currentwarnings', help="Name of file which contains the current warnings of the repo.") - parser.add_argument('newwarnings', help="Name of file which contains the *new* warnings of the repo.") - args = parser.parse_args() - - currentLines = countFileLines(args.currentwarnings) - newLines = countFileLines(args.newwarnings) - if newLines > currentLines: - print() - print("There are more warnings now. Go fix them!") - print("\tCurrent warnings: " + str(currentLines)) - print("\tNew warnings: " + str(newLines)) - print() - print("If these warnings are needed to produce a matching build, run `tools/warnings_count/update_current_warnings.sh` and commit the updated files in `tools/warnings_count/`.") - print() - with open(args.newwarnings) as f: - print("Warnings:\n\n" + f.read()) - print() - exit(-1) - print("There are no new warnings. Good Job!") - - -if __name__ == "__main__": - main() diff --git a/tools/warnings_count/compare_warnings.sh b/tools/warnings_count/compare_warnings.sh new file mode 100755 index 000000000..080649d82 --- /dev/null +++ b/tools/warnings_count/compare_warnings.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Terminal colour codes +# when $TERM is empty (non-interactive shell), then expand tput with '-T xterm-256color' +[[ ${TERM}=="" ]] && TPUTTERM='-T dumb' \ + || TPUTTERM='' + +declare -r BOLD=`tput ${TPUTTERM} bold` +declare -r RED=`tput ${TPUTTERM} setaf 1` +declare -r PURPLE=`tput ${TPUTTERM} setaf 5` +declare -r WHITE=`tput ${TPUTTERM} setaf 7` +declare -r BLINK=`tput ${TPUTTERM} blink` +declare -r RST=`tput ${TPUTTERM} sgr0` + +read CURRENT_LINES CURRENT <<< $(wc -l "tools/warnings_count/warnings_$1_current.txt") +read NEW_LINES NEW <<< $(wc -l "tools/warnings_count/warnings_$1_new.txt") + +if [ $NEW_LINES -le $CURRENT_LINES ] +then + echo "${BOLD}No new warnings added in $1, well done.${RST} +" + exit 0 +else + CURRENT_NUM=$(grep -i 'warning' $CURRENT | wc -l) + NEW_NUM=$(grep -i 'warning' $NEW | wc -l) + EXTRA_NUM=$(( $NEW_NUM - $CURRENT_NUM )) + + echo "${BOLD}${RED}There are $EXTRA_NUM new warnings in $1, please fix them!${RST} +${BOLD}Current warnings:${RST}" + cat $CURRENT + echo "${BOLD} +Total current warnings: $CURRENT_NUM + +New warnings:${RST}" + cat "$NEW" + echo "${BOLD} +Total new warnings: $NEW_NUM ${RED} +Total extra warnings: $EXTRA_NUM ${RST} +${BOLD} +If these warnings are needed to produce a matching build, run 'tools/warnings_count/update_current_warnings.sh' and commit the updated files in 'tools/warnings_count/'.${RST}" + exit 1 +fi From 30987676884df00e563f64bde13f8c49a3f96b70 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 30 Sep 2021 01:09:13 +0100 Subject: [PATCH 19/86] sethwinterrupt OK (#301) --- include/functions.h | 2 +- src/libultra/os/sethwinterrupt.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index 63ee51708..65514ca8e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -479,7 +479,7 @@ void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); // void __osVoiceContWrite4(void); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); -// void __osSetHWIntrRoutine(void); +void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); void __osSetWatchLo(u32 value); f32 fmodf(f32 dividend, f32 divisor); diff --git a/src/libultra/os/sethwinterrupt.c b/src/libultra/os/sethwinterrupt.c index 86dfd2c64..6ba72be7a 100644 --- a/src/libultra/os/sethwinterrupt.c +++ b/src/libultra/os/sethwinterrupt.c @@ -1,3 +1,10 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/sethwinterrupt/__osSetHWIntrRoutine.s") +void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg) { + register s32 prevInt = __osDisableInt(); + + __osHwIntTable[idx].queue = queue; + __osHwIntTable[idx].msg = msg; + + __osRestoreInt(prevInt); +} From 9dfeec73458cc941e3345613710e4308e1ede7e5 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 29 Sep 2021 18:08:26 -0700 Subject: [PATCH 20/86] Fix some dummy label matches (#331) * Fix some dummy label matches * Remove dummy label in z_en_railgibud * Remove dummy label from z_door_ana.c * Remove dummy label from z_obj_raillift.c * Remove dummy label from z_en_minislime.c * A few more dummy label fixes * Run format, whoops * Add single line between pad and code * Add OPEN/CLOSE_DISPS to GameState_Draw * Add the padding in game.c too (how did I forget this???) * Run format.sh * pad -> requiredScopeTemp --- src/code/game.c | 55 +++++++++++-------- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 4 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 3 +- src/overlays/actors/ovl_En_In/z_en_in.c | 6 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 5 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 3 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 3 +- .../actors/ovl_Obj_Raillift/z_obj_raillift.c | 3 +- 8 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/code/game.c b/src/code/game.c index 4fe094497..eb26dee8a 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -68,14 +68,14 @@ void Game_Nop80173534(GameState* gamestate) { void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) { Gfx* nextDisplayList; - Gfx* _polyOpa; - // Unused vars impact regalloc - Gfx* temp_t2; - u32 temp_v1; + Gfx* polyOpa; - _polyOpa = gfxCtx->polyOpa.p; - nextDisplayList = Graph_GfxPlusOne(gfxCtx->polyOpa.p); - gSPDisplayList(gfxCtx->overlay.p++, nextDisplayList); + OPEN_DISPS(gfxCtx); + + polyOpa = POLY_OPA_DISP; + nextDisplayList = Graph_GfxPlusOne(POLY_OPA_DISP); + + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) { GameState_SetFBFilter(&nextDisplayList, (u32)gfxCtx->zbuffer); @@ -86,16 +86,22 @@ void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) { } gSPEndDisplayList(nextDisplayList++); - Graph_BranchDlist(_polyOpa, nextDisplayList); - gfxCtx->polyOpa.p = nextDisplayList; + Graph_BranchDlist(polyOpa, nextDisplayList); + POLY_OPA_DISP = nextDisplayList; -lblUnk:; // Label prevents reordering, if(1) around the above block don't seem to help unlike in OoT - func_800E9F78(gfxCtx); + // Block prevents reordering, if(1) around the above block don't seem to help unlike in OoT + { + s32 requiredScopeTemp; + + func_800E9F78(gfxCtx); + } if (R_ENABLE_ARENA_DBG != 0) { SpeedMeter_DrawTimeEntries(&D_801F7FF0, gfxCtx); SpeedMeter_DrawAllocEntries(&D_801F7FF0, gfxCtx, gamestate); } + + CLOSE_DISPS(gfxCtx); } void Game_ResetSegments(GraphicsContext* gfxCtx) { @@ -197,21 +203,24 @@ void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsC gamestate->nextGameStateInit = NULL; gamestate->nextGameStateSize = 0U; -lblUnk:; - Gamealloc_Init(&gamestate->alloc); - Game_InitHeap(gamestate, 0x100000); - Game_SetFramerateDivisor(gamestate, 3); + { + s32 requiredScopeTemp; - gameStateInit(gamestate); + Gamealloc_Init(&gamestate->alloc); + Game_InitHeap(gamestate, 0x100000); + Game_SetFramerateDivisor(gamestate, 3); - func_80140CE0(&D_801F8010); - func_801420C0(&D_801F8020); - func_801418B0(&sMonoColors); - func_80140898(&D_801F8048); - func_801773A0(&D_801F7FF0); - func_8013ED9C(); + gameStateInit(gamestate); - osSendMesg(&gamestate->gfxCtx->unk5C, NULL, 1); + func_80140CE0(&D_801F8010); + func_801420C0(&D_801F8020); + func_801418B0(&sMonoColors); + func_80140898(&D_801F8048); + func_801773A0(&D_801F7FF0); + func_8013ED9C(); + + osSendMesg(&gamestate->gfxCtx->unk5C, NULL, 1); + } } void Game_StateFini(GameState* gamestate) { diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 9370c4b14..ba8920246 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -129,13 +129,13 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { if (dooranaType == DOORANA_TYPE_ADJACENT) { + s32 requiredScopeTemp; + // 300 uses scene exit addresses, not static DoorAna entrance addresses, // eg. deku playground gets address in the NCT scene exit table entranceIndex = GET_DOORANA_ADJACENT_ENTRANCE(this); globalCtx->nextEntranceIndex = globalCtx->setupExitList[entranceIndex]; - lblUnk_808E03B8:; // required to convince compiler to not use delay slot - } else { // unused in vanilla, the highest params bits can directly index an address entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index aee46c2f1..7a4ab5471 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -244,6 +244,8 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v // Look for an available effect to allocate a light ray effect to. for (i = 0; i < ARRAY_COUNT(this->effect) - 1; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { + s32 requiredScopeTemp; + effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; effect->position = *position; @@ -271,7 +273,6 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v break; } - dummy:; } } diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 389028cc5..e2b0e91ca 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -500,6 +500,8 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { u16 textId = 0; if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADERS_MASK) { + s32 requiredScopeTemp; + if (!(gSaveContext.weekEventReg[63] & 0x40)) { return 0x34A9; } else if (this->unk4AC & 8) { @@ -507,7 +509,6 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { } else { textId = 0x34AF; } - dummy_label_895710:; // POSSIBLE FAKE MATCH } else { switch (arg2) { case 0: @@ -1259,9 +1260,10 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { return 1; } if (*arg3 == 1) { + s32 requiredScopeTemp; + player = PLAYER; func_808F5994(this, globalCtx, &player->actor.world.pos, 0xC80); - dummy_label_895711:; // POSSIBLE FAKE MATCH } else { rotDiff = this->actor.home.rot.y - this->actor.world.rot.y; if (rotDiff > 0x320) { diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 1e5dd6e6e..41d52159d 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2681,6 +2681,8 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { } if (this->rand == 0) { + s32 requiredScopeTemp; + if ((this->actor.xzDistToPlayer < 350.0f) && ((globalCtx->gameplayFrames & 0x60) != 0)) { player = PLAYER; temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f; @@ -2690,9 +2692,6 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = new_var3 * 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); } - - dummy:; - } else { substruct->unk26.x = 0; substruct->unk26.y = 0; diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 75fd10737..07b219fc8 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -324,6 +324,8 @@ void EnMinislime_IceArrowDamage(EnMinislime* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->shakeRefPos, &this->actor.world.pos); } else if (this->frozenTimer > 0) { if ((this->frozenTimer < 20) || ((this->frozenTimer < 40) && ((this->frozenTimer % 2) != 0))) { + s32 requiredScopeTemp; + invFrozenTimer = 1.0f / this->frozenTimer; randFloat = Rand_ZeroFloat(invFrozenTimer); randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; @@ -331,7 +333,6 @@ void EnMinislime_IceArrowDamage(EnMinislime* this, GlobalContext* globalCtx) { randFloat = Rand_ZeroFloat(invFrozenTimer); randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; this->actor.world.pos.z = randSign * (invFrozenTimer + randFloat) + this->shakeRefPos.z; - dummy:; // required for match } } } else { diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index b6dfea065..eb2bfc030 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -391,12 +391,13 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { case 1: if (this->unk_3F2 == 20) { + s16 requiredScopeTemp; + sp32 = player->ageProperties->unk_92 + 0x6805; globalCtx->damagePlayer(globalCtx, -8); func_800B8E58(&player->actor, sp32); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->unk_3F2 = 0; - label:; } else { this->unk_3F2++; } diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 67d3200f5..eb9202197 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -234,6 +234,8 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { } } if (OBJRAILLIFT_SHOULD_REACT_TO_WEIGHT(thisx)) { + s32 requiredScopeTemp; + this->isWeightOnPrev = this->isWeightOn; if (func_800CAF70(&this->dyna)) { this->isWeightOn = true; @@ -251,7 +253,6 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { target = this->isWeightOn ? -8.0f : 0.0f; Math_StepToF(&this->cycleSpeed, target, step); this->dyna.actor.shape.yOffset = ((Math_SinS(this->cycle) * this->maxHeight) + this->cycleSpeed) * 10.0f; - dummy:; } if (OBJRAILLIFT_GET_TYPE(thisx) == DEKU_FLOWER_PLATFORM && this->dyna.actor.child != NULL) { if (this->dyna.actor.child->update == NULL) { From f80b08450fe6ba7e54981fa104cc3790dca8e1d1 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 30 Sep 2021 02:55:41 +0100 Subject: [PATCH 21/86] ShrinkWindow OK (#303) * OK, small amount of documentation, import bss * Remove comments * Actually commit functions.txt * Add renames to actorfixer.py, review --- include/functions.h | 4 +- spec | 1 - src/code/z_shrink_window.c | 120 ++++++++++++++++-- .../gamestates/ovl_daytelop/z_daytelop.c | 4 +- .../gamestates/ovl_opening/z_opening.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- tools/actorfixer.py | 2 + tools/disasm/functions.txt | 4 +- 9 files changed, 119 insertions(+), 22 deletions(-) diff --git a/include/functions.h b/include/functions.h index 65514ca8e..4cfd6cfe2 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2927,8 +2927,8 @@ s32 ShrinkWindow_GetPillarboxTarget(void); void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude); s32 ShrinkWindow_GetPillarboxMagnitude(void); void ShrinkWindow_Init(void); -void ShrinkWindow_Fini(void); -void ShrinkWindow_Step(s32 framerateDivisor); +void ShrinkWindow_Destroy(void); +void ShrinkWindow_Update(s32 framerateDivisor); void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); // void func_8016119C(void); diff --git a/spec b/spec index 0faeb1229..a569dba5f 100644 --- a/spec +++ b/spec @@ -581,7 +581,6 @@ beginseg include "build/src/code/z_player_call.o" include "build/data/code/z_player_call.bss.o" include "build/src/code/z_shrink_window.o" - include "build/data/code/z_shrink_window.bss.o" include "build/src/code/db_camera.o" include "build/data/code/db_camera.bss.o" include "build/data/code/code_801D0B50.data.o" diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 3b2d86114..194ee5083 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -1,25 +1,121 @@ +/** + * File: z_shrink_window.c + * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s") +ShrinkWindowContext gShrinkWindowContext; +ShrinkWindowContext* gShrinkWindowContextPtr; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s") +void ShrinkWindow_SetLetterboxTarget(s32 target) { + gShrinkWindowContextPtr->letterboxTarget = target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s") +s32 ShrinkWindow_GetLetterboxTarget(void) { + return gShrinkWindowContextPtr->letterboxTarget; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxMagnitude.s") +void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude) { + gShrinkWindowContextPtr->letterboxMagnitude = magnitude; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxTarget.s") +s32 ShrinkWindow_GetLetterboxMagnitude(void) { + return gShrinkWindowContextPtr->letterboxMagnitude; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxTarget.s") +void ShrinkWindow_SetPillarboxTarget(s32 target) { + gShrinkWindowContextPtr->pillarboxTarget = target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxMagnitude.s") +s32 ShrinkWindow_GetPillarboxTarget(void) { + return gShrinkWindowContextPtr->pillarboxTarget; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxMagnitude.s") +void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude) { + gShrinkWindowContextPtr->pillarboxMagnitude = magnitude; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s") +s32 ShrinkWindow_GetPillarboxMagnitude(void) { + return gShrinkWindowContextPtr->pillarboxMagnitude; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_Fini.s") +void ShrinkWindow_Init(void) { + gShrinkWindowContextPtr = &gShrinkWindowContext; + bzero(gShrinkWindowContextPtr, sizeof(gShrinkWindowContext)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_Step.s") +void ShrinkWindow_Destroy(void) { + gShrinkWindowContextPtr = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_shrink_window/ShrinkWindow_Draw.s") +void ShrinkWindow_Update(s32 framerateDivisor) { + s32 step = ((framerateDivisor == 3) ? 10 : 30 / framerateDivisor); + s32 nextMagnitude; + + nextMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; + Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->letterboxTarget, step); + gShrinkWindowContextPtr->letterboxMagnitude = nextMagnitude; + + nextMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; + Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->pillarboxTarget, step); + gShrinkWindowContextPtr->pillarboxMagnitude = nextMagnitude; +} + +void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { + Gfx* gfx; + s8 letterboxMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; + s8 pillarboxMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; + + if (letterboxMagnitude > 0) { + OPEN_DISPS(gfxCtx); + + gfx = OVERLAY_DISP; + + gDPPipeSync(gfx++); + gDPSetCycleType(gfx++, G_CYC_FILL); + gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); + gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxMagnitude - 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude, gScreenWidth - 1, gScreenHeight - 1); + + gDPPipeSync(gfx++); + gDPSetCycleType(gfx++, G_CYC_1CYCLE); + gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); + gDPFillRectangle(gfx++, 0, letterboxMagnitude, gScreenWidth, letterboxMagnitude + 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude - 1, gScreenWidth, + gScreenHeight - letterboxMagnitude); + + gDPPipeSync(gfx++); + OVERLAY_DISP = gfx++; + + CLOSE_DISPS(gfxCtx); + } + if (pillarboxMagnitude > 0) { + OPEN_DISPS(gfxCtx); + + gfx = OVERLAY_DISP; + + gDPPipeSync(gfx++); + gDPSetCycleType(gfx++, G_CYC_FILL); + gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); + + gDPFillRectangle(gfx++, 0, 0, pillarboxMagnitude - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude, 0, gScreenWidth - 1, gScreenHeight - 1); + + gDPPipeSync(gfx++); + gDPSetCycleType(gfx++, G_CYC_1CYCLE); + gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); + + gDPFillRectangle(gfx++, pillarboxMagnitude, 0, pillarboxMagnitude + 2, gScreenHeight); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude - 2, 0, gScreenWidth - pillarboxMagnitude, + gScreenHeight); + + gDPPipeSync(gfx++); + OVERLAY_DISP = gfx++; + + CLOSE_DISPS(gfxCtx); + } +} diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index ba34c2448..d4c729d56 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -205,7 +205,7 @@ void Daytelop_Main(GameState* thisx) { } void Daytelop_Destroy(GameState* thisx) { - ShrinkWindow_Fini(); + ShrinkWindow_Destroy(); } void Daytelop_nop80815770(DaytelopContext* this) { @@ -227,7 +227,7 @@ void Daytelop_Init(GameState* thisx) { Game_SetFramerateDivisor(thisx, 1); SysMatrix_StateAlloc(thisx); - ShrinkWindow_Fini(); + ShrinkWindow_Destroy(); View_Init(&this->view, thisx->gfxCtx); thisx->main = Daytelop_Main; thisx->destroy = Daytelop_Destroy; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index b19955071..f3279db4e 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -43,7 +43,7 @@ void Opening_Main(GameState* thisx) { } void Opening_Destroy(GameState* thisx) { - ShrinkWindow_Fini(); + ShrinkWindow_Destroy(); } void Opening_Init(GameState* thisx) { diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index da6808725..d58f7ac85 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -887,7 +887,7 @@ void Select_Main(GameState* thisx) { } void Select_Destroy(GameState* thisx) { - ShrinkWindow_Fini(); + ShrinkWindow_Destroy(); } void Select_Init(GameState* thisx) { diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 83e3f487a..c8027fcbe 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -145,7 +145,7 @@ void Title_Destroy(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; func_80146E40(&this->gameState, &this->sramCtx); - ShrinkWindow_Fini(); + ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 16100c926..238c7f9c0 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -20,6 +20,8 @@ animdict ={ "func_800F0568": "Audio_PlaySoundAtPosition", "func_8016970C": "Play_CameraSetAtEye", "func_800BBA88": "Enemy_StartFinishingBlow", + "ShrinkWindow_Step": "ShrinkWindow_Update", + "ShrinkWindow_Fini": "ShrinkWindow_Destroy", "func_801A89A8": "Audio_QueueSeqCmd", } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 558565b7d..b64e05c56 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2901,8 +2901,8 @@ 0x80160C78:("ShrinkWindow_SetPillarboxMagnitude",), 0x80160C8C:("ShrinkWindow_GetPillarboxMagnitude",), 0x80160CA0:("ShrinkWindow_Init",), - 0x80160CD4:("ShrinkWindow_Fini",), - 0x80160CE4:("ShrinkWindow_Step",), + 0x80160CD4:("ShrinkWindow_Destroy",), + 0x80160CE4:("ShrinkWindow_Update",), 0x80160D98:("ShrinkWindow_Draw",), 0x80161180:("func_80161180",), 0x8016119C:("func_8016119C",), From bd9e21b165a2589b2bc066865b9557a447c926c0 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 30 Sep 2021 03:13:31 +0100 Subject: [PATCH 22/86] `z_nmi_buff` OK, `code_8010C1B0` split and OK (#334) * nmi_buff OK, code_8010C1B0 split and OK * COLD_RESET * spec * Fix lifemeter bss * Rename variable --- include/variables.h | 4 ++-- include/z64.h | 7 +++++++ spec | 2 +- src/code/code_8010C1B0.c | 20 ++++++++++++++++++++ src/code/main.c | 11 ++++++++--- src/code/z_nmi_buff.c | 29 +++++++++++++++++++++++++---- tools/disasm/files.txt | 1 + tools/disasm/variables.txt | 2 +- 8 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 src/code/code_8010C1B0.c diff --git a/include/variables.h b/include/variables.h index 2cf99e391..b3aa0a602 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3353,7 +3353,7 @@ extern Arena mainHeap; // extern UNK_TYPE1 D_801F5730; // extern UNK_TYPE1 D_801F57B4; // extern UNK_TYPE1 D_801F5834; -extern s32* gNMIBuffer; +// extern NmiBuff* gNMIBuffer; // extern UNK_TYPE1 D_801F5850; // extern UNK_TYPE1 D_801F58B0; // extern UNK_TYPE1 D_801F59AC; @@ -3440,7 +3440,7 @@ extern u64 lastRenderFrameTimestamp; extern OSMesgQueue siEventCallbackQueue; extern OSMesg siEventCallbackBuffer[1]; extern u32 gSegments[NUM_SEGMENTS]; -extern SchedContext schedContext; +extern SchedContext gSchedContext; extern IrqMgrClient mainIrqmgrCallbackNode; extern OSMesgQueue mainIrqmgrCallbackQueue; extern OSMesg mainIrqCallbackBuffer[60]; diff --git a/include/z64.h b/include/z64.h index d3923d6c8..3d61fe5ea 100644 --- a/include/z64.h +++ b/include/z64.h @@ -348,6 +348,13 @@ typedef struct { /* 0x14 */ u32 relocations[1]; } OverlayRelocationSection; // size >= 0x18 +typedef struct { + /* 0x00 */ u32 resetting; + /* 0x04 */ u32 resetCount; + /* 0x08 */ OSTime duration; + /* 0x10 */ OSTime resetTime; +} NmiBuff; // size >= 0x18 + typedef struct { /* 0x00 */ s16 intPart[16]; /* 0x20 */ u16 fracPart[16]; diff --git a/spec b/spec index a569dba5f..18ce776d0 100644 --- a/spec +++ b/spec @@ -523,7 +523,7 @@ beginseg include "build/src/code/z_msgevent.o" include "build/data/code/z_msgevent.data.o" include "build/src/code/z_nmi_buff.o" - include "build/data/code/z_nmi_buff.bss.o" + include "build/src/code/code_8010C1B0.o" include "build/src/code/z_olib.o" pad_text include "build/src/code/z_parameter.o" diff --git a/src/code/code_8010C1B0.c b/src/code/code_8010C1B0.c new file mode 100644 index 000000000..7141901e2 --- /dev/null +++ b/src/code/code_8010C1B0.c @@ -0,0 +1,20 @@ +#include "global.h" + +// Blocks the current thread until all currently queued scheduler tasks have been completed +void func_8010C1B0(void) { + OSScTask task; + OSMesgQueue queue; + OSMesg msg; + + task.next = NULL; + task.flags = OS_SC_RCP_MASK; + task.msgQ = &queue; + task.msg = NULL; + task.framebuffer = NULL; + task.list.t.type = M_NULTASK; + + osCreateMesgQueue(task.msgQ, &msg, 1); + osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); + Sched_SendEntryMsg(&gSchedContext); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); +} \ No newline at end of file diff --git a/src/code/main.c b/src/code/main.c index 75101c8ab..648536aef 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -1,3 +1,8 @@ +/** + * This file has unmigrated bss. It is not practical to migrate it until we have a better way of dealing with bss + * reordering than just prevent_bss_reordering.h: there is too much of it to control, and it cannot be split into + * separate files since most of it is at addresses ending in 8. + */ #include "global.h" void Main(void* arg) { @@ -29,18 +34,18 @@ void Main(void* arg) { osCreateMesgQueue(&mainIrqmgrCallbackQueue, mainIrqCallbackBuffer, ARRAY_COUNT(mainIrqCallbackBuffer)); StackCheck_Init(&schedStackEntry, schedStack, schedStack + sizeof(schedStack), 0, 0x100, "sched"); - Sched_Init(&schedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); + Sched_Init(&gSchedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); CIC6105_AddRomInfoFaultPage(); IrqMgr_AddClient(&gIrqMgr, &mainIrqmgrCallbackNode, &mainIrqmgrCallbackQueue); StackCheck_Init(&audioStackEntry, audioStack, audioStack + sizeof(audioStack), 0, 0x100, "audio"); - AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &schedContext, &gIrqMgr); + AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr); StackCheck_Init(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr"); Padmgr_Start(&siEventCallbackQueue, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack)); - + AudioMgr_Unlock(&audioContext); StackCheck_Init(&graphStackEntry, graphStack, graphStack + sizeof(graphStack), 0, 0x100, "graph"); diff --git a/src/code/z_nmi_buff.c b/src/code/z_nmi_buff.c index a12fa6591..205bd8d0f 100644 --- a/src/code/z_nmi_buff.c +++ b/src/code/z_nmi_buff.c @@ -1,9 +1,30 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_nmi_buff/Nmi_Init.s") +#define COLD_RESET 0 +#define NMI 1 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_nmi_buff/Nmi_SetPrenmiStart.s") +NmiBuff* gNMIBuffer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_nmi_buff/Nmi_GetPrenmiHasStarted.s") +void Nmi_Init(void) { + gNMIBuffer = (NmiBuff*)osAppNmiBuffer; + gNMIBuffer->resetting = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_nmi_buff/func_8010C1B0.s") + if (osResetType == COLD_RESET) { + gNMIBuffer->resetCount = 0; + gNMIBuffer->duration = 0; + } else { + gNMIBuffer->resetCount++; + gNMIBuffer->duration += gNMIBuffer->resetTime; + } + + gNMIBuffer->resetTime = 0; +} + +void Nmi_SetPrenmiStart(void) { + gNMIBuffer->resetting = true; + gNMIBuffer->resetTime = osGetTime(); +} + +u32 Nmi_GetPrenmiHasStarted(void) { + return gNMIBuffer->resetting; +} diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index ed536b318..a71ca3f09 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -398,6 +398,7 @@ 0x8010A000 : "z_map_exp", 0x8010A760 : "z_msgevent", 0x8010C0C0 : "z_nmi_buff", + 0x8010C1B0 : "code_8010C1B0", 0x8010C230 : "z_olib", 0x8010CB70 : "[PADDING]", 0x8010CB80 : "z_parameter", diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index a7bc54164..4f5da48f7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4189,7 +4189,7 @@ 0x801F8160:("siEventCallbackQueue","OSMesgQueue","",0x18), 0x801F8178:("siEventCallbackBuffer","OSMesg","[1]",0x4), 0x801F8180:("gSegments","u32","[16]",0x40), - 0x801F81C0:("schedContext","SchedContext","",0x338), + 0x801F81C0:("gSchedContext","SchedContext","",0x338), 0x801F84F8:("mainIrqmgrCallbackNode","IrqMgrClient","",0x8), 0x801F8500:("mainIrqmgrCallbackQueue","OSMesgQueue","",0x18), 0x801F8518:("mainIrqCallbackBuffer","OSMesg","[60]",0xf0), From fbd1a79942dc1af21959757ee9eec5d0ef22f0be Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 30 Sep 2021 06:34:45 -0700 Subject: [PATCH 23/86] Arrow_Ice OK (#314) * Migrate data and ArrowIce_Init OK * ArrowIce_Destroy OK (also define func_80115D5C in functions.h, maybe a bad thing???) * ArrowIce_SetupAction OK * func_809224DC OK * ArrowIce_Update OK * func_809227F4 OK (but with hacky float constant) * func_809225D0 OK and use float constant in func_809227F4 * func_80922628 OK * ArrowIce_Draw OK * Migrate D_80924200.s to C * Apply better names in ice_gfx, and document Draw slightly * Name struct vars to match OoT * Update function names to match OoT * Explain that arrow's timer and hitFlags came from OoT * Update spec + "migrate" bss to C * Do a hex -> decimal conversion I missed * Remove blank line in-between headers * Remove extraneous forward declare * Move initialization of arrow up one line * Remove parentheses * Use else if * Use decrement operation * Use decimal for an alpha calculation * Switch func_80115D5C to take GameState* * Put pad on the top of Draw * Move initialization of arrow up (again) * Early return from Update if we're killed * Extract assets instead of putting them in the repo * Add explanatory comment to top of file * += 1 -> ++ * Use VEC3F_LERPIMPDST macro * Force a jenkins rerun by adding a space * Remove the space from the last commit * Move literal to the back of the conditional * Respond to review feedback * Add ArrowIce_LerpFiredPosition to functions.txt --- assets/xml/overlays/ovl_Arrow_Ice.xml | 11 + include/functions.h | 2 +- spec | 4 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 222 ++++++++++++++++-- .../actors/ovl_Arrow_Ice/z_arrow_ice.h | 7 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.h | 5 +- tools/disasm/functions.txt | 8 +- 7 files changed, 229 insertions(+), 30 deletions(-) create mode 100644 assets/xml/overlays/ovl_Arrow_Ice.xml diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml new file mode 100644 index 000000000..e130bdd05 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/include/functions.h b/include/functions.h index 4cfd6cfe2..d682431ce 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2162,7 +2162,7 @@ void func_801159c0(s16 param_1); void func_801159EC(s16 arg0); void func_80115A14(s32 arg0, s16 arg1); // void Parameter_AddMagic(void); -// void func_80115D5C(void); +void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); // void func_80116088(void); // void func_80116114(void); diff --git a/spec b/spec index 18ce776d0..cdaf81c06 100644 --- a/spec +++ b/spec @@ -1414,9 +1414,7 @@ beginseg name "ovl_Arrow_Ice" compress include "build/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.o" - include "build/data/ovl_Arrow_Ice/ovl_Arrow_Ice.data.o" - include "build/data/ovl_Arrow_Ice/ovl_Arrow_Ice.bss.o" - include "build/data/ovl_Arrow_Ice/ovl_Arrow_Ice.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Ice/ovl_Arrow_Ice_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index a4dad8770..9d61ca292 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -1,4 +1,11 @@ +/* + * File: z_arrow_ice.c + * Overlay: ovl_Arrow_Ice + * Description: Ice Arrow. Spawned as a child of a normal arrow. + */ + #include "z_arrow_ice.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS 0x02000010 @@ -9,13 +16,14 @@ void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809224DC(ArrowIce* this, GlobalContext* globalCtx); -void func_80922628(ArrowIce* this, GlobalContext* globalCtx); -void func_809227F4(ArrowIce* this, GlobalContext* globalCtx); +void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); +void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); +void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc); +#include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" + +s32 unused; // Needed for bss -#if 0 const ActorInit Arrow_Ice_InitVars = { ACTOR_ARROW_ICE, ACTORCAT_ITEMACTION, @@ -28,33 +36,207 @@ const ActorInit Arrow_Ice_InitVars = { (ActorFunc)ArrowIce_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809241F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -#endif +extern Gfx D_0E0002E0[]; -extern InitChainEntry D_809241F0[]; +void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern UNK_TYPE D_0E0002E0; +void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowIce* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/D_80924200.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowIce_SetupAction(this, ArrowIce_Charge); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 100; + this->timer = 0; + this->blueingEffectMagnitude = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/ArrowIce_SetupAction.s") +void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + (void)"消滅"; // Unreferenced in retail, means "Disappearance" +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/ArrowIce_Init.s") +void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/ArrowIce_Destroy.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/func_809224DC.s") + if (this->radius < 10) { + this->radius++; + } + // copy position and rotation from arrow + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/func_809225D0.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_ICE - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/func_80922628.s") + // if arrow has no parent, player has fired the arrow + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowIce_SetupAction(this, ArrowIce_Fly); + this->alpha = 255; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/func_809227F4.s") +void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, icePos, scale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/ArrowIce_Update.s") +void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { + f32 scale; + f32 offset; + u16 timer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Ice/ArrowIce_Draw.s") + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = (scale - 50.0f) * (1.0f / 3.0f) + 10.0f; + } + + timer = this->timer; + if (timer != 0) { + this->timer--; + + if (this->timer >= 8) { + offset = ((this->timer - 8) * (1.0f / 24.0f)); + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height += ((2.0f - this->height) * 0.1f); + if (this->timer < 16) { + if (1) {} + this->alpha = ((this->timer * 35) - 280); + } + } + } + + if (this->timer >= 9) { + if (this->blueingEffectMagnitude < 1.0f) { + this->blueingEffectMagnitude += 0.25f; + } + } else { + if (this->blueingEffectMagnitude > 0.0f) { + this->blueingEffectMagnitude -= 0.125f; + } + } + + if (this->timer < 8) { + this->alpha = 0; + } + + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + } +} + +void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + f32 distanceScaled; + s32 pad; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + // copy position and rotation from arrow + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + distanceScaled = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + this->height = distanceScaled; + if (distanceScaled < 1.0f) { + this->height = 1.0f; + } + ArrowIce_LerpFiredPosition(&this->firedPos, &this->actor.world.pos, 0.05f); + + if (arrow->unk_261 & 1) { + Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_ICE); + ArrowIce_SetupAction(this, ArrowIce_Hit); + this->timer = 32; + this->alpha = 255; + } else if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + } else { + this->alpha -= 25; + } + } +} + +void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowIce* this = THIS; + + if ((globalCtx->msgCtx.unk11F22 == 0xE) || (globalCtx->msgCtx.unk11F22 == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } else { + this->actionFunc(this, globalCtx); + } +} + +void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ArrowIce* this = THIS; + Actor* transform; + u32 stateFrames = globalCtx->state.frames; + EnArrow* arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + SysMatrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + + // Draw blue effect over the screen when arrow hits + if (this->blueingEffectMagnitude > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, (s32)(this->blueingEffectMagnitude * 10.0f) & 0xFF, + (s32)(50.0f * this->blueingEffectMagnitude) & 0xFF, + (s32)(150.0f * this->blueingEffectMagnitude) & 0xFF); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gSPDisplayList(POLY_XLU_DISP++, D_0E0002E0); + } + + // Draw ice on the arrow + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); + SysMatrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + if (this->timer != 0) { + SysMatrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + SysMatrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); + SysMatrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sIceArrowDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1, + 511 - (stateFrames * 10) % 512, 511 - (stateFrames * 10) % 512, 4, 16)); + gSPDisplayList(POLY_XLU_DISP++, sIceArrowVtxDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h index 44a5ed945..a731d9d44 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h @@ -9,7 +9,12 @@ typedef void (*ArrowIceActionFunc)(struct ArrowIce*, GlobalContext*); typedef struct ArrowIce { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0144 */ s16 radius; + /* 0x0146 */ u16 timer; + /* 0x0148 */ u8 alpha; + /* 0x014C */ Vec3f firedPos; + /* 0x0158 */ f32 height; + /* 0x015C */ f32 blueingEffectMagnitude; /* 0x0160 */ ArrowIceActionFunc actionFunc; } ArrowIce; // size = 0x164 diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index e022d21a0..119507d4d 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -11,7 +11,10 @@ typedef struct EnArrow { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x7C]; /* 0x01C0 */ s32 unk_1C0; - /* 0x01C4 */ char unk_1C4[0xB0]; + /* 0x01C4 */ char unk_1C4[0x9C]; + /* 0x0260 */ u8 unk_260; // timer in OoT + /* 0x0261 */ u8 unk_261; // hitFlags in OoT + /* 0x0262 */ char unk_262[0x12]; /* 0x0274 */ EnArrowActionFunc actionFunc; } EnArrow; // size = 0x278 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b64e05c56..918da5570 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7014,10 +7014,10 @@ 0x80922430:("ArrowIce_SetupAction",), 0x8092243C:("ArrowIce_Init",), 0x809224B8:("ArrowIce_Destroy",), - 0x809224DC:("func_809224DC",), - 0x809225D0:("func_809225D0",), - 0x80922628:("func_80922628",), - 0x809227F4:("func_809227F4",), + 0x809224DC:("ArrowIce_Charge",), + 0x809225D0:("ArrowIce_LerpFiredPosition",), + 0x80922628:("ArrowIce_Hit",), + 0x809227F4:("ArrowIce_Fly",), 0x80922948:("ArrowIce_Update",), 0x8092299C:("ArrowIce_Draw",), 0x80924300:("ArrowLight_SetupAction",), From 48b91053ee5d1cfdba8d275b6a48cb3101978156 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Fri, 1 Oct 2021 01:13:09 +0100 Subject: [PATCH 24/86] resetglobalintmask OK (#298) --- src/libultra/os/resetglobalintmask.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libultra/os/resetglobalintmask.c b/src/libultra/os/resetglobalintmask.c index 3d93a17e7..c2561d712 100644 --- a/src/libultra/os/resetglobalintmask.c +++ b/src/libultra/os/resetglobalintmask.c @@ -1,3 +1,8 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/resetglobalintmask/__osResetGlobalIntMask.s") +void __osResetGlobalIntMask(u32 mask) { + register s32 prevInt = __osDisableInt(); + + __OSGlobalIntMask &= ~(mask & ~0x401); + __osRestoreInt(prevInt); +} From b5e9427db448a6e38540cf1a34907ae580330339 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Fri, 1 Oct 2021 01:50:11 +0100 Subject: [PATCH 25/86] Match last function in z_prenmi, add DISPS macros to ArmsHook (#305) * preNMI OK, added DISP macros to ArmsHook * Decimal colours in preNMI * SCREEN_WIDTH * engineer's review --- src/code/z_prenmi.c | 15 ++-- .../actors/ovl_Arms_Hook/z_arms_hook.c | 75 +++++++++---------- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index f0403b4f3..df55d2488 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -16,21 +16,20 @@ void PreNMI_Update(PreNMIContext* prenmiCtx) { prenmiCtx->timer--; } -#ifdef NON_MATCHING -// Minor reordering around call to func_8012C470 void PreNMI_Draw(PreNMIContext* prenmiCtx) { GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx; func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + + OPEN_DISPS(gfxCtx); + func_8012C470(gfxCtx); - gDPSetFillColor(gfxCtx->polyOpa.p++, - (GPACK_RGBA5551(0xFF, 0xFF, 0xFF, 1) << 16) | GPACK_RGBA5551(0xFF, 0xFF, 0xFF, 1)); - gDPFillRectangle(gfxCtx->polyOpa.p++, 0, prenmiCtx->timer + 100, 320 /*SCREEN_WIDTH*/ - 1, prenmiCtx->timer + 100); + gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); + gDPFillRectangle(POLY_OPA_DISP++, 0, prenmiCtx->timer + 100, SCREEN_WIDTH - 1, prenmiCtx->timer + 100); + + CLOSE_DISPS(gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_prenmi/PreNMI_Draw.s") -#endif void PreNMI_Main(PreNMIContext* prenmiCtx) { PreNMI_Update(prenmiCtx); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index ac175b7e4..07d68d030 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -287,50 +287,47 @@ static Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f }; void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { ArmsHook* this = THIS; - s32 pad; + f32 f0; Player* player = PLAYER; - Vec3f sp68; - Vec3f sp5C; - Vec3f sp50; - f32 sp4C; - f32 sp48; if (player->actor.draw != NULL && player->rightHandType == 0xB) { - // OPEN_DISP macro - { - GraphicsContext* sp44 = globalCtx->state.gfxCtx; - f32 f0; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + f32 sp4C; + f32 sp48; - if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - SysMatrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); - SysMatrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); - SysMatrix_MultiplyVector3fByState(&D_808C1C34, &sp50); - this->unk1C4 = 0; - } else { - SysMatrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); - SysMatrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); - SysMatrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); - } - func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); - func_8012C28C(globalCtx->state.gfxCtx); - func_80122868(globalCtx, player); + OPEN_DISPS(globalCtx->state.gfxCtx); - gSPMatrix(sp44->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(sp44->polyOpa.p++, D_0601D960); - SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); - sp48 = SQ(sp68.x) + SQ(sp68.z); - sp4C = sqrtf(sp48); - Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); - f0 = sqrtf(SQ(sp68.y) + sp48); - Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); - gSPMatrix(sp44->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(sp44->polyOpa.p++, D_040008D0); - func_801229A0(globalCtx, player); + if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { + SysMatrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); + SysMatrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); + SysMatrix_MultiplyVector3fByState(&D_808C1C34, &sp50); + this->unk1C4 = 0; + } else { + SysMatrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); + SysMatrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); + SysMatrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); } + func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); + func_8012C28C(globalCtx->state.gfxCtx); + func_80122868(globalCtx, player); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_0601D960); + SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); + sp48 = SQXZ(sp68); + sp4C = sqrtf(SQXZ(sp68)); + Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); + f0 = sqrtf(SQ(sp68.y) + sp48); + Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_040008D0); + func_801229A0(globalCtx, player); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } } From edcf4e40cbb2de55bbd2d5e49136f11d1d8b7753 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Fri, 1 Oct 2021 01:57:49 +0100 Subject: [PATCH 26/86] setglobalintmask OK (#299) --- src/libultra/os/setglobalintmask.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libultra/os/setglobalintmask.c b/src/libultra/os/setglobalintmask.c index 40b539b7f..6b7895d6d 100644 --- a/src/libultra/os/setglobalintmask.c +++ b/src/libultra/os/setglobalintmask.c @@ -1,3 +1,8 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/setglobalintmask/__osSetGlobalIntMask.s") +void __osSetGlobalIntMask(u32 mask) { + register s32 prevInt = __osDisableInt(); + + __OSGlobalIntMask |= mask; + __osRestoreInt(prevInt); +} From 00fe40be51dbeb9bcb1423c25403670fccbce8f9 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Mon, 4 Oct 2021 16:50:50 -0700 Subject: [PATCH 27/86] Run ./format.sh on master again (#348) --- src/boot_O2/gfxprint.c | 2 +- src/boot_O2/printutils.c | 2 +- src/code/code_8010C1B0.c | 2 +- src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/boot_O2/gfxprint.c b/src/boot_O2/gfxprint.c index f671c6f5c..f65d88200 100644 --- a/src/boot_O2/gfxprint.c +++ b/src/boot_O2/gfxprint.c @@ -180,6 +180,6 @@ void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { va_start(args, fmt); GfxPrint_VPrintf(this, fmt, args); - + va_end(args); } diff --git a/src/boot_O2/printutils.c b/src/boot_O2/printutils.c index 4f04fca14..ca62b91b7 100644 --- a/src/boot_O2/printutils.c +++ b/src/boot_O2/printutils.c @@ -9,6 +9,6 @@ void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) { va_start(args, fmt); PrintUtils_VPrintf(pfn, fmt, args); - + va_end(args); } diff --git a/src/code/code_8010C1B0.c b/src/code/code_8010C1B0.c index 7141901e2..12e0eadb4 100644 --- a/src/code/code_8010C1B0.c +++ b/src/code/code_8010C1B0.c @@ -17,4 +17,4 @@ void func_8010C1B0(void) { osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); osRecvMesg(&queue, NULL, OS_MESG_BLOCK); -} \ No newline at end of file +} diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index cfd596646..334856872 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -183,7 +183,7 @@ void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { } SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); + this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); } CLOSE_DISPS(globalCtx->state.gfxCtx); From f059baa87fbab47dd80ff8b9e3de927da1f1f134 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 11 Oct 2021 02:36:24 +0100 Subject: [PATCH 28/86] En_Owl (#271) * En_Owl * a * PR * a * Rebase --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 1171 +++++++++++++++++++-- src/overlays/actors/ovl_En_Owl/z_en_owl.h | 46 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 3 + 6 files changed, 1153 insertions(+), 78 deletions(-) diff --git a/include/functions.h b/include/functions.h index d682431ce..12bc34993 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2196,7 +2196,7 @@ void func_8011C808(GlobalContext* globalCtx); // void func_80121F94(void); void func_80121FC4(GlobalContext* globalCtx); s32 func_801224E0(s32 param_1, s16 param_2, s16 param_3); -// void func_80122524(void); +f32 func_80122524(Actor* actor, Path* path, s16 arg2, s16* arg3); // void func_801225CC(void); // void func_80122660(void); // UNK_TYPE4 func_80122670(s32* param_1, Input* input); diff --git a/spec b/spec index cdaf81c06..71bce5c37 100644 --- a/spec +++ b/spec @@ -1682,8 +1682,7 @@ beginseg name "ovl_En_Owl" compress include "build/src/overlays/actors/ovl_En_Owl/z_en_owl.o" - include "build/data/ovl_En_Owl/ovl_En_Owl.data.o" - include "build/data/ovl_En_Owl/ovl_En_Owl.reloc.o" + include "build/src/overlays/actors/ovl_En_Owl/ovl_En_Owl_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 19872cc69..36580181a 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -1,3 +1,9 @@ +/* + * File: z_en_owl.c + * Overlay: ovl_En_Owl + * Description: Kaepora Gaebora (Owl) + */ + #include "z_en_owl.h" #define FLAGS 0x00000019 @@ -26,8 +32,33 @@ void func_8095B960(EnOwl* this, GlobalContext* globalCtx); void func_8095BA84(EnOwl* this, GlobalContext* globalCtx); void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx); void func_8095BF20(EnOwl* this, GlobalContext* globalCtx); +void func_8095BF58(EnOwl* this, GlobalContext* globalCtx); +void func_8095C1C8(EnOwl* this, GlobalContext* globalCtx); +void func_8095C328(EnOwl* this); +void func_8095C408(EnOwl* this); +void func_8095C484(EnOwl* this); +void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx); +void func_8095D074(Actor* thisx, GlobalContext* globalCtx); +void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, + AnimationHeader* animationSeg, f32 transitionRate); + +typedef enum { + /* 0x00 */ OWL_REPEAT, + /* 0x01 */ OWL_OK +} EnOwlMessageChoice; + +extern AnimationHeader D_06001168; +extern Gfx D_06001200[]; +extern AnimationHeader D_06001ADC; +extern TexturePtr D_06008EB8; +extern TexturePtr D_060092B8; +extern TexturePtr D_060096B8; +extern FlexSkeletonHeader D_0600C5F8; +extern AnimationHeader D_0600C6D4; +extern AnimationHeader D_0600CB94; +extern AnimationHeader D_0600CDB0; +extern FlexSkeletonHeader D_060105C0; -#if 0 const ActorInit En_Owl_InitVars = { ACTOR_EN_OWL, ACTORCAT_NPC, @@ -40,137 +71,1137 @@ const ActorInit En_Owl_InitVars = { (ActorFunc)EnOwl_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095D2F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8095D31C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 2400, ICHAIN_STOP), }; -#endif +void func_8095A510(EnOwl* this, GlobalContext* globalCtx) { + this->unk_3FC = ENOWL_GET_F000(&this->actor); + if (this->unk_3FC == 15) { + this->unk_3FC = -1; + this->path = NULL; + } else { + this->unk_3F8 = 0; + this->path = &globalCtx->setupPathList[this->unk_3FC]; + } +} -extern ColliderCylinderInit D_8095D2F0; -extern InitChainEntry D_8095D31C[]; +void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOwl* this = THIS; + s32 i; + s16 cutscene = this->actor.cutscene; + s32 owlType; + s32 switchFlag; -extern UNK_TYPE D_06001168; -extern UNK_TYPE D_06001200; -extern UNK_TYPE D_06001ADC; -extern UNK_TYPE D_0600C6D4; -extern UNK_TYPE D_0600CB94; -extern UNK_TYPE D_0600CDB0; + for (i = 0; i < ARRAY_COUNT(this->unk_400); i++) { + this->unk_400[i] = cutscene; + if (cutscene != -1) { + this->actor.cutscene = cutscene; + cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095A510.s") + this->actor.cutscene = this->unk_400[0]; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (ENOWL_GET_TYPE(&this->actor) == ENOWL_GET_TYPE_30) { + Actor_SetScale(&this->actor, 0.1f); + this->actor.update = func_8095CCF4; + this->actor.draw = func_8095D074; + this->actor.flags &= ~1; + this->unk_3D8 = 0; + this->unk_3DA = 0x320; + this->unk_3DC = 0x12C; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/EnOwl_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + SkelAnime_InitSV(globalCtx, &this->skelAnime1, &D_0600C5F8, &D_06001ADC, this->jointTable1, this->morphTable1, 21); + SkelAnime_InitSV(globalCtx, &this->skelAnime2, &D_060105C0, &D_0600CDB0, this->jointTable2, this->morphTable2, 16); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.minVelocityY = -10.0f; + this->actor.targetArrowOffset = 500.0f; + EnOwl_ChangeMode(this, func_8095BF58, func_8095C484, &this->skelAnime2, &D_0600CDB0, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/EnOwl_Destroy.s") + this->actionFlags = 0; + this->unk_40D = 0; + this->unk_40A = 0; + this->unk_409 = 4; + this->unk_40B = this->unk_408 = 0; + this->unk_40C = 4; + this->unk_406 = -1; + owlType = ENOWL_GET_TYPE(&this->actor); + switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095A920.s") + switch (owlType) { + case ENOWL_GET_TYPE_1: + if ((switchFlag < 0x7F) && Flags_GetSwitch(globalCtx, switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095A978.s") + case ENOWL_GET_TYPE_2: + if (gSaveContext.inventory.items[14] == 14) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095A9FC.s") + case ENOWL_GET_TYPE_3: + if (CHECK_QUEST_ITEM(15)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AA70.s") + this->unk_3DA = 0; + this->unk_3F0 = this->actor.home.pos.y; + this->unk_3EC = this->actor.home.rot.y; + func_8095A510(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AAD0.s") + switch (owlType) { + case ENOWL_GET_TYPE_1: + this->actionFunc = func_8095AEC0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AB1C.s") + case ENOWL_GET_TYPE_2: + this->actionFunc = func_8095BE0C; + if (gSaveContext.weekEventReg[9] & 0x20) { + this->actor.textId = 0xBF0; + } else { + this->actor.textId = 0xBEA; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AB4C.s") + case ENOWL_GET_TYPE_3: + this->actionFunc = func_8095AFEC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095ABA8.s") + case ENOWL_GET_TYPE_1000: + this->actionFunc = func_8095BF20; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095ABF0.s") + default: + this->actionFlags |= 2; + this->unk_3DA = 0x20; + this->actionFunc = func_8095BF58; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AC50.s") +void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOwl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095ACEC.s") + if (ENOWL_GET_TYPE(&this->actor) != ENOWL_GET_TYPE_30) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AD54.s") +void func_8095A920(EnOwl* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AE00.s") + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 6, 0x3E8, 0xC8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AE60.s") +s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetDist, f32 arg4) { + if (func_800B84D0(&this->actor, globalCtx)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AEC0.s") + this->actor.textId = textId; + if (this->actor.xzDistToPlayer < targetDist) { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, targetDist, arg4, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AF2C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095AFEC.s") +s32 func_8095A9FC(EnOwl* this, GlobalContext* globalCtx, u16 textId) { + if (func_800B84D0(&this->actor, globalCtx)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B06C.s") + this->actor.textId = textId; + if (this->actor.xzDistToPlayer < 120.0f) { + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B0C8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B158.s") +void func_8095AA70(EnOwl* this) { + EnOwl_ChangeMode(this, func_8095C1C8, func_8095C484, &this->skelAnime1, &D_0600CB94, 0.0f); + this->eyeTexIndex = 0; + this->blinkTimer = Rand_S16Offset(60, 60); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B1E4.s") +void func_8095AAD0(EnOwl* this, GlobalContext* globalCtx) { + s32 switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B254.s") + if (switchFlag < 0x7F) { + Actor_SetSwitchFlag(globalCtx, switchFlag); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B2F8.s") + func_8095AA70(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B3DC.s") +void func_8095AB1C(EnOwl* this, GlobalContext* globalCtx) { + if ((this->unk_3DA % 64) == 0) { + func_8095AAD0(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B480.s") +void func_8095AB4C(EnOwl* this) { + if (randPlusMinusPoint5Scaled(1.0f) < 0.0f) { + this->actionFlags |= 0x20; + } else { + this->actionFlags &= ~0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B574.s") +// Unused? +void func_8095ABA8(EnOwl* this) { + func_8095AB4C(this); + this->unk_40B = 0; + this->unk_3DE = 0; + this->actionFlags |= 0x10; + this->unk_40C = 4; + this->unk_408 = 0; + this->unk_40A = 0; + this->unk_409 = 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B650.s") +void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { + if (func_800B867C(&this->actor, globalCtx)) { + Audio_QueueSeqCmd(0x110000FF); + func_8095AAD0(this, globalCtx); + this->actor.flags &= ~0x10000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B6C8.s") +// Unused? +void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { + if (func_800B867C(&this->actor, globalCtx)) { + Audio_QueueSeqCmd(0x110000FF); + if ((this->unk_3DA % 64) == 0) { + func_8095AAD0(this, globalCtx); + } else { + this->actionFlags &= ~2; + func_8095ABA8(this); + this->actionFunc = func_8095AB1C; + } + this->actor.flags &= ~0x10000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B76C.s") +void func_8095ACEC(EnOwl* this) { + this->actionFlags &= ~0x40; + if (this->unk_406 >= 0) { + if (ActorCutscene_GetCurrentIndex() == this->unk_400[this->unk_406]) { + ActorCutscene_Stop(this->unk_400[this->unk_406]); + } + this->unk_406 = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B960.s") +void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case OWL_REPEAT: + func_80151938(globalCtx, 0x7D1); + this->actionFunc = func_8095AE00; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095B9FC.s") + case OWL_OK: + func_80151938(globalCtx, 0x7D3); + this->actionFunc = func_8095ABF0; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095BA84.s") +void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x7D2); + this->actionFunc = func_8095AD54; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095BE0C.s") +void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_80151938(globalCtx, 0x7D1); + this->actionFunc = func_8095AE00; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095BF20.s") +void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); + if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { + func_801A3098(0x45); + this->actionFunc = func_8095AE60; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095BF58.s") +void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { + switch (func_80152498(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.unk11F04 == 0xBFE) { + func_8095ACEC(this); + func_801477B4(globalCtx); + this->actionFunc = func_8095ABF0; + } else { + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095BF78.s") + case 6: + func_8095ACEC(this); + this->actionFunc = func_8095ABF0; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C09C.s") +void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); + if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { + func_801A3098(0x45); + this->actionFunc = func_8095AF2C; + this->unk_406 = 0; + this->actionFlags |= 0x40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C1C8.s") +s32 func_8095B06C(EnOwl* this) { + if ((this->actor.world.pos.y + 2.0f) < this->unk_3F0) { + this->actor.world.pos.y += 2.0f; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C258.s") + if (this->unk_3F0 < (this->actor.world.pos.y - 2.0f)) { + this->actor.world.pos.y -= 2.0f; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C328.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C408.s") +void func_8095B0C8(EnOwl* this) { + s32 pad; + Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C484.s") + points += this->unk_3F8; + this->unk_3EC = Math_FAtan2F(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); + this->unk_3F0 = points->y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C510.s") +void func_8095B158(EnOwl* this) { + if (func_801378B8(&this->skelAnime1, 2.0f) || func_801378B8(&this->skelAnime1, 9.0f) || + func_801378B8(&this->skelAnime1, 23.0f) || func_801378B8(&this->skelAnime1, 40.0f) || + func_801378B8(&this->skelAnime1, 58.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095C568.s") +void func_8095B1E4(EnOwl* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ < 6.0f) { + this->actor.speedXZ += 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/EnOwl_Update.s") + if (this->actor.xzDistToPlayer > 6000.0f) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095CCF4.s") +void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ < 6.0f) { + this->actor.speedXZ += 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095CE18.s") + if (this->actionFlags & 1) { + EnOwl_ChangeMode(this, func_8095B1E4, func_8095C328, &this->skelAnime1, &D_06001ADC, 0.0f); + this->unk_3EA = 6; + this->actor.flags |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095CF44.s") + func_8095B158(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/EnOwl_Draw.s") +void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx) { + func_8095B06C(this); + if (this->skelAnime1.animCurrentFrame >= 18.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); + this->actor.shape.rot.y = this->actor.world.rot.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095D074.s") + if ((this->actor.shape.rot.y == this->unk_3EC) && (this->actionFlags & 1)) { + this->actionFunc = func_8095B254; + SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 19.0f, + SkelAnime_GetFrameCount(&D_06001168.common), 2, 0.0f); + this->unk_414 = func_8095C484; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Owl/func_8095D24C.s") + func_8095B158(this); +} + +void func_8095B3DC(EnOwl* this, GlobalContext* globalCtx) { + if (this->actionFlags & 1) { + this->actionFunc = func_8095B2F8; + SkelAnime_ChangeAnim(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + this->unk_414 = func_8095C408; + this->unk_3EC = 0x5500; + this->actor.world.pos.y += 100.0f; + this->unk_3F0 = this->actor.world.pos.y; + } +} + +void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (player->stateFlags3 & 0x10000000) { + this->actor.textId = 0xBF1; + EnOwl_ChangeMode(this, func_8095BF58, func_8095C484, &this->skelAnime2, &D_0600CDB0, 0.0f); + this->eyeTexIndex = 0; + this->actionFlags &= ~8; + this->blinkTimer = Rand_S16Offset(60, 60); + this->actor.home.rot.x = 0; + this->actionFlags |= 8; + func_8095ACEC(this); + this->unk_3F0 = this->actor.home.pos.y; + this->unk_3EC = this->actor.home.rot.y; + this->actor.world.pos = this->actor.home.pos; + func_8095A510(this, globalCtx); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_8095BE0C; + } +} + +void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_8095BA84; + func_801A3098(0x45); + this->actionFlags |= 0x40; + this->unk_406 = 2; + } else if (this->actor.xzDistToPlayer < 200.0f) { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, 0); + } else { + this->actor.flags &= ~0x10000; + } + func_8095B480(this, globalCtx); +} + +void func_8095B650(EnOwl* this, GlobalContext* globalCtx) { + if (this->actionFlags & 1) { + EnOwl_ChangeMode(this, func_8095B574, func_8095C484, &this->skelAnime2, &D_0600CDB0, 0.0f); + this->actor.textId = 0xBF5; + this->actionFlags &= ~8; + } + func_8095B480(this, globalCtx); +} + +void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx) { + if (this->actionFlags & 1) { + SkelAnime_ChangeAnim(this->skelAnime3, &D_0600CB94, -1.0f, SkelAnime_GetFrameCount(&D_0600CB94.common), 0.0f, 2, + 0.0f); + this->unk_414 = func_8095C484; + this->actionFunc = func_8095B650; + } + func_8095B158(this); + func_8095B480(this, globalCtx); +} + +void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp4A; + f32 sp44 = func_80122524(&this->actor, this->path, this->unk_3F8, &sp4A); + Vec3s* points; + + Math_SmoothStepToS(&this->actor.world.rot.y, sp4A, 6, 0x800, 0x200); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (sp44 < SQ(this->actor.speedXZ)) { + this->actor.speedXZ = 0.0f; + points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + points += this->unk_3F8; + + do { + this->actor.world.pos.x = points->x; + this->actor.world.pos.z = points->z; + } while(0); + + this->unk_3F8++; + if (this->path->count <= this->unk_3F8) { + this->actionFunc = func_8095B6C8; + return; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OWL, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0xF00); + this->actor.home.rot.x++; + if (this->actor.home.rot.x >= 3) { + func_8095ACEC(this); + } + func_8095B0C8(this); + } else if (sp44 < SQ(21.0f)) { + if (this->actor.speedXZ > 1.0f) { + this->actor.speedXZ -= 1.0f; + } else { + this->actor.speedXZ = 1.0f; + } + } else if (this->actor.speedXZ < 6.0f) { + this->actor.speedXZ += 1.0f; + } + + func_8095B06C(this); + func_8095B158(this); + func_8095B480(this, globalCtx); +} + +void func_8095B960(EnOwl* this, GlobalContext* globalCtx) { + if (this->skelAnime1.animCurrentFrame >= 18.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + func_8095B06C(this); + if (this->actor.shape.rot.y == this->unk_3EC) { + this->actionFunc = func_8095B76C; + } + + func_8095B158(this); + func_8095B480(this, globalCtx); +} + +void func_8095B9FC(EnOwl* this, GlobalContext* globalCtx) { + if (this->actionFlags & 1) { + this->actionFunc = func_8095B960; + SkelAnime_ChangeAnim(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + this->unk_414 = func_8095C408; + func_8095B0C8(this); + } +} + +void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); + + switch (func_80152498(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0xBEC: + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + if (gSaveContext.weekEventReg[9] & 0x40) { + func_80151938(globalCtx, 0xBF4); + } else { + gSaveContext.weekEventReg[9] |= 0x40; + func_80151938(globalCtx, 0xBED); + } + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0xBEF); + break; + } + break; + + case 0xBF2: + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0xBF4); + return; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0xBF3); + return; + } + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0xBEA: + gSaveContext.weekEventReg[9] |= 0x20; + func_80151938(globalCtx, 0xBEB); + break; + + case 0xBEB: + case 0xBF0: + func_80151938(globalCtx, 0xBEC); + break; + + case 0xBED: + case 0xBF4: + func_80151938(globalCtx, 0xBEE); + break; + + case 0xBEE: + func_801477B4(globalCtx); + Audio_QueueSeqCmd(0x110000FF); + EnOwl_ChangeMode(this, func_8095B9FC, func_8095C484, &this->skelAnime1, &D_0600CB94, 0.0f); + this->eyeTexIndex = 0; + this->blinkTimer = Rand_S16Offset(60, 60); + this->actionFlags |= 8; + this->actor.flags &= ~0x10000; + this->actor.home.rot.x = 0; + func_8095ACEC(this); + this->unk_406 = 0; + this->actionFlags |= 0x40; + break; + + case 0xBEF: + case 0xBF3: + func_801477B4(globalCtx); + Audio_QueueSeqCmd(0x110000FF); + func_8095ACEC(this); + this->actor.flags &= ~0x10000; + this->actor.textId = 0xBF0; + this->actionFunc = func_8095BE0C; + break; + + case 0xBF1: + func_80151938(globalCtx, 0xBF2); + break; + + case 0xBF5: + func_801477B4(globalCtx); + Audio_QueueSeqCmd(0x110000FF); + this->actor.flags &= ~0x10000; + EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &D_0600CB94, 0.0f); + this->eyeTexIndex = 0; + this->blinkTimer = Rand_S16Offset(60, 60); + this->actionFlags |= 8; + func_8095ACEC(this); + break; + } + } + break; + } +} + +void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_8095BA84; + func_801A3098(0x45); + this->unk_406 = 1; + this->actionFlags |= 0x40; + } else if (this->actor.textId == 0xBF0) { + if (this->actor.isTargeted) { + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + } + } else if (this->actor.xzDistToPlayer < 200.0f) { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + } else { + this->actor.flags &= ~0x10000; + } +} + +void func_8095BF20(EnOwl* this, GlobalContext* globalCtx) { + func_8095A9FC(this, globalCtx, 0x7D0); + this->actionFunc = func_8095ABF0; +} + +void func_8095BF58(EnOwl* this, GlobalContext* globalCtx) { + func_8095A920(this, globalCtx); +} + +void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { + this->actor.flags |= 0x20; + if (this->actor.xzDistToPlayer > 6000.0f) { + Actor_MarkForDeath(&this->actor); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x80, 0x40); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->actor.speedXZ < 16.0f) { + this->actor.speedXZ += 0.5f; + } + + if ((this->unk_3E4 + 1000.0f) < this->actor.world.pos.y) { + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y -= 0.4f; + } + } else if (this->actor.velocity.y < 4.0f) { + this->actor.velocity.y += 0.2f; + } +} + +void func_8095C09C(EnOwl* this, GlobalContext* globalCtx) { + if (this->skelAnime1.animCurrentFrame > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x400, 0x40); + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (this->skelAnime1.animCurrentFrame > 45.0f) { + this->actor.velocity.y = 2.0f; + this->actor.gravity = 0.0f; + this->actor.speedXZ = 8.0f; + } else if (this->skelAnime1.animCurrentFrame > 17.0f) { + this->actor.velocity.y = 6.0f; + this->actor.gravity = 0.0f; + this->actor.speedXZ = 4.0f; + } + + if (this->actionFlags & 1) { + EnOwl_ChangeMode(this, func_8095BF78, func_8095C328, &this->skelAnime1, &D_06001ADC, 0.0f); + this->unk_3EA = 6; + this->unk_3EC += 0x2000; + } + + func_8095B158(this); +} + +void func_8095C1C8(EnOwl* this, GlobalContext* globalCtx) { + if (this->actionFlags & 1) { + this->unk_3EA = 3; + EnOwl_ChangeMode(this, func_8095C09C, func_8095C484, &this->skelAnime1, &D_06001168, 0.0f); + this->unk_3EC = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_3E4 = this->actor.world.pos.y; + this->actor.velocity.y = 2.0f; + } + this->actionFlags |= 8; +} + +void func_8095C258(EnOwl* this) { + SkelAnime_FrameUpdateMatrix(this->skelAnime3); + if (this->unk_3EA > 0) { + this->unk_3EA--; + this->actor.shape.rot.z = Math_SinS(this->unk_3EA * 0x333) * 1000.0f; + } else { + this->unk_414 = func_8095C328; + this->unk_3EA = 6; + SkelAnime_ChangeAnim(this->skelAnime3, &D_06001ADC, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06001ADC.common), 2, + 5.0f); + } +} + +void func_8095C328(EnOwl* this) { + if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { + if (this->unk_3EA > 0) { + this->unk_3EA--; + SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(this->skelAnime3->genericSeg), 2, 0.0f); + } else { + this->unk_3EA = 160; + this->unk_414 = func_8095C258; + SkelAnime_ChangeAnim(this->skelAnime3, &D_0600C6D4, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_0600C6D4.common), + 0, 5.0f); + } + } +} + +void func_8095C408(EnOwl* this) { + if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { + SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 18.0f, 35.0f, 2, 0.0f); + this->actionFlags |= 1; + } else { + this->actionFlags &= ~1; + } +} + +void func_8095C484(EnOwl* this) { + if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { + SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(this->skelAnime3->genericSeg), 2, 0.0f); + this->actionFlags |= 1; + } else { + this->actionFlags &= ~1; + } +} + +s32 func_8095C510(EnOwl* this) { + s32 phi_v1; + + if (this->actionFlags & 2) { + phi_v1 = 0x20; + } else { + phi_v1 = 0; + } + + if (phi_v1 == (this->unk_3DA & 0x3F)) { + return true; + } + + if (this->actionFlags & 0x20) { + this->unk_3DA += 4; + } else { + this->unk_3DA -= 4; + } + + return false; +} + +void func_8095C568(EnOwl* this) { + if (this->actionFlags & 0x40) { + if ((this->unk_406 < 0) || (this->unk_400[this->unk_406] < 0)) { + this->actionFlags &= ~0x40; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_400[this->unk_406]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_400[this->unk_406])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_400[this->unk_406], &this->actor); + this->actionFlags &= ~0x40; + } else { + ActorCutscene_SetIntentToPlay(this->unk_400[this->unk_406]); + } + } +} + +void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOwl* this = THIS; + s16 sp36; + + if (this->actor.draw != NULL) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + if (this->unk_414 != NULL) { + this->unk_414(this); + } + + this->actionFunc(this, globalCtx); + func_8095C568(this); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.update != NULL) { + if ((this->skelAnime1.animCurrentSeg == &D_06001ADC) && func_801378B8(&this->skelAnime1, 4.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + } + + if (this->actionFlags & 2) { + this->eyeTexIndex = 2; + } else { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + this->eyeTexIndex = this->blinkTimer; + if (this->eyeTexIndex >= 3) { + this->eyeTexIndex = 0; + } + } + + if (!(this->actionFlags & 8)) { + sp36 = 0; + + if (this->actionFlags & 0x10) { + switch (this->unk_408) { + case 0: + this->unk_408 = 1; + this->unk_409 = 6; + break; + + case 1: + this->unk_409--; + if (this->unk_409 != 0) { + sp36 = Math_CosS(this->unk_409 * 0x2000) * 0x1000; + } else { + if (this->actionFlags & 2) { + this->unk_3DA = 0; + } else { + this->unk_3DA = 0x20; + } + + if (this->actionFlags & 0x20) { + this->unk_3DA -= 4; + } else { + this->unk_3DA += 4; + } + this->unk_408++; + } + + if (this->actionFlags & 0x20) { + sp36 = -sp36; + } + break; + + case 2: + if (func_8095C510(this)) { + this->actionFlags &= ~0x10; + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; + } + } else { + if (this->unk_40A > 0) { + this->unk_40A--; + } else { + if (this->unk_408 == 0) { + if (Rand_ZeroOne() < 0.3f) { + this->unk_408 = 4; + this->unk_409 = 12; + } else { + this->unk_408 = 1; + this->unk_409 = 4; + } + } + this->unk_409--; + + switch (this->unk_408) { + case 1: + sp36 = Math_SinS((-this->unk_409 * 0x1000) + 0x4000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_409 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); + this->unk_408 = 2; + } + break; + + case 2: + sp36 = 0x1388; + if (this->unk_409 <= 0) { + this->unk_408 = 3; + this->unk_409 = 4; + } + break; + + case 3: + sp36 = Math_SinS(this->unk_409 * 0x1000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; + + case 4: + sp36 = Math_SinS(this->unk_409 * 0x2000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; + } + + if (this->actionFlags & 0x20) { + sp36 = -sp36; + } + } + + if (this->unk_40D > 0) { + this->unk_40D--; + } else { + this->unk_40C--; + switch (this->unk_40B) { + case 0: + this->unk_3DE = (-this->unk_40C * 0x5DC) + 0x1770; + if (this->unk_40C <= 0) { + this->unk_40B = 1; + this->unk_40C = (s8)(Rand_ZeroFloat(15.0f) + 5.0f); + } + break; + + case 1: + this->unk_3DE = 0x1770; + if (this->unk_40C <= 0) { + this->unk_40B = 2; + this->unk_40C = 4; + } + break; + + case 2: + this->unk_3DE = this->unk_40C * 0x5DC; + if (this->unk_40C <= 0) { + this->unk_40B = 0; + this->unk_40C = 4; + this->unk_40D = (s32)Rand_ZeroFloat(40.0f) + 160; + } + break; + } + } + } + + if (sp36) {} + this->unk_3DC = (u16)((this->unk_3DA << 2) << 8) + sp36; + this->unk_3D8 = ABS(this->unk_3DC) >> 3; + } else { + this->unk_3DE = 0; + if (this->actionFlags & 2) { + this->unk_3DC = -0x8000; + } else { + this->unk_3DC = 0; + } + + this->unk_3D8 = ABS(this->unk_3DC) >> 3; + } + } +} + +void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx) { + EnOwl* this = THIS; + Player* player = PLAYER; + + if (player->stateFlags3 & 0x10000000) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.world.pos.y < (this->unk_3F0 - 1000.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos.y -= 1.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + if (this->actor.bgCheckFlags & 1) { + this->unk_3DA = (this->unk_3DA >> 3) * 7; + if (this->unk_3DC > 0) { + this->unk_3DC--; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->unk_3D8 += this->unk_3DA; + this->unk_3DA -= (s16)(this->unk_3D8 >> 6); +} + +s32 EnOwl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnOwl* this = THIS; + + switch (limbIndex) { + case 3: + rot->x += this->unk_3DC; + rot->z += this->unk_3D8; + rot->z -= this->unk_3DE; + break; + + case 2: + rot->z += this->unk_3DE; + break; + + case 4: + if (!(this->actionFlags & 8)) { + rot->y -= (s16)(this->unk_3D8 * 1.5f); + } + break; + + case 5: + if (!(this->actionFlags & 8)) { + rot->y += (s16)(this->unk_3D8 * 1.5f); + } + break; + } + + return false; +} + +void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnOwl* this = THIS; + Vec3f sp18; + + sp18.z = 0.0f; + if (this->actionFlags & 2) { + sp18.x = 700.0f; + sp18.y = 400.0f; + } else { + sp18.y = 0.0f; + sp18.x = 1400.0f; + } + + if (limbIndex == 3) { + SysMatrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr eyeTextures[] = { + &D_06008EB8, + &D_060092B8, + &D_060096B8, + }; + s32 pad; + EnOwl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); + + SkelAnime_DrawSV(globalCtx, this->skelAnime3->skeleton, this->skelAnime3->limbDrawTbl, this->skelAnime3->dListCount, + EnOwl_OverrideLimbDraw, EnOwl_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { + EnOwl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + SysMatrix_InsertTranslation(0.0f, 500.0f, 0.0f, 1); + SysMatrix_InsertXRotation_s(this->unk_3D8 - 0x4000, 1); + SysMatrix_InsertTranslation(0.0f, 0.0f, -500.0f, 1); + if (this->unk_3DC >= 0x20) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, D_06001200); + } else { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)(this->unk_3DC * 8)); + gSPDisplayList(POLY_XLU_DISP++, D_06001200); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, + AnimationHeader* animationSeg, f32 transitionRate) { + this->skelAnime3 = skelAnime; + SkelAnime_ChangeAnim(this->skelAnime3, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), 2, + transitionRate); + this->actionFunc = actionFunc; + this->unk_414 = unkFunc; +} diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.h b/src/overlays/actors/ovl_En_Owl/z_en_owl.h index f53d19361..ee9e1fdd8 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.h +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.h @@ -6,12 +6,54 @@ struct EnOwl; typedef void (*EnOwlActionFunc)(struct EnOwl*, GlobalContext*); +typedef void (*EnOwlFunc)(struct EnOwl*); + +#define ENOWL_GET_F000(thisx) (((thisx)->params & 0xF000) >> 0xC) +#define ENOWL_GET_TYPE(thisx) (((thisx)->params & 0xF80) >> 7) +#define ENOWL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + +typedef enum { + /* 0x001 */ ENOWL_GET_TYPE_1 = 1, + /* 0x002 */ ENOWL_GET_TYPE_2, + /* 0x003 */ ENOWL_GET_TYPE_3, + /* 0x01E */ ENOWL_GET_TYPE_30 = 30, + /* 0x3E8 */ ENOWL_GET_TYPE_1000 = 1000, +} EnOwlType; typedef struct EnOwl { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2CC]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime1; + /* 0x01D4 */ Vec3s jointTable1[21]; + /* 0x0252 */ Vec3s morphTable1[21]; + /* 0x02D0 */ SkelAnime skelAnime2; + /* 0x0314 */ Vec3s jointTable2[16]; + /* 0x0374 */ Vec3s morphTable2[16]; + /* 0x03D4 */ SkelAnime* skelAnime3; + /* 0x03D8 */ s16 unk_3D8; + /* 0x03DA */ s16 unk_3DA; + /* 0x03DC */ s16 unk_3DC; + /* 0x03DE */ s16 unk_3DE; + /* 0x03E0 */ s16 eyeTexIndex; + /* 0x03E2 */ s16 blinkTimer; + /* 0x03E4 */ f32 unk_3E4; + /* 0x03E8 */ u16 actionFlags; + /* 0x03EA */ s16 unk_3EA; + /* 0x03EC */ s16 unk_3EC; + /* 0x03F0 */ f32 unk_3F0; + /* 0x03F4 */ Path* path; + /* 0x03F8 */ s32 unk_3F8; + /* 0x03FC */ s32 unk_3FC; + /* 0x0400 */ s16 unk_400[3]; + /* 0x0406 */ s16 unk_406; + /* 0x0408 */ u8 unk_408; + /* 0x0409 */ u8 unk_409; + /* 0x040A */ u8 unk_40A; + /* 0x040B */ u8 unk_40B; + /* 0x040C */ u8 unk_40C; + /* 0x040D */ u8 unk_40D; /* 0x0410 */ EnOwlActionFunc actionFunc; - /* 0x0414 */ char unk_414[0x4]; + /* 0x0414 */ EnOwlFunc unk_414; } EnOwl; // size = 0x418 extern const ActorInit En_Owl_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 918da5570..ba1390e5c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7758,11 +7758,11 @@ 0x8095C568:("func_8095C568",), 0x8095C654:("EnOwl_Update",), 0x8095CCF4:("func_8095CCF4",), - 0x8095CE18:("func_8095CE18",), - 0x8095CF44:("func_8095CF44",), + 0x8095CE18:("EnOwl_OverrideLimbDraw",), + 0x8095CF44:("EnOwl_PostLimbDraw",), 0x8095CFC8:("EnOwl_Draw",), 0x8095D074:("func_8095D074",), - 0x8095D24C:("func_8095D24C",), + 0x8095D24C:("EnOwl_ChangeMode",), 0x8095D6E0:("func_8095D6E0",), 0x8095D758:("func_8095D758",), 0x8095D804:("func_8095D804",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 57eb32e56..ad8f975be 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3053,6 +3053,9 @@ D_0600C6D4 = 0x0600C6D4; D_0600CB94 = 0x0600CB94; D_0600CDB0 = 0x0600CDB0; D_060105C0 = 0x060105C0; +D_06008EB8 = 0x06008EB8; +D_060092B8 = 0x060092B8; +D_060096B8 = 0x060096B8; // ovl_En_Pamera From 1774416598c04452edc02c96b831d3a975ba4f67 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:21:17 +0100 Subject: [PATCH 29/86] En_Poh (#291) * En_Poh * PR * PR * Fix wrong float --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 965 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Poh/z_en_poh.h | 27 +- tools/disasm/functions.txt | 4 +- 5 files changed, 914 insertions(+), 87 deletions(-) diff --git a/include/functions.h b/include/functions.h index 12bc34993..d6042e3f5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -4002,7 +4002,7 @@ void func_801A5CFC(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* par // void func_801A7168(void); // void func_801A7284(void); void func_801A72CC(Vec3f* uParm1); -// void func_801A7328(void); +void func_801A7328(Vec3f* pos, u16 sfxId); // void func_801A7484(void); // void func_801A75E8(void); // void func_801A7720(void); diff --git a/spec b/spec index 71bce5c37..44097c913 100644 --- a/spec +++ b/spec @@ -4073,8 +4073,7 @@ beginseg name "ovl_En_Poh" compress include "build/src/overlays/actors/ovl_En_Poh/z_en_poh.o" - include "build/data/ovl_En_Poh/ovl_En_Poh.data.o" - include "build/data/ovl_En_Poh/ovl_En_Poh.reloc.o" + include "build/src/overlays/actors/ovl_En_Poh/ovl_En_Poh_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index ae56732b7..161067b29 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -1,3 +1,9 @@ +/* + * File: z_en_poh.c + * Overlay: ovl_En_Poh + * Description: Poe + */ + #include "z_en_poh.h" #define FLAGS 0x00001205 @@ -10,23 +16,46 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx); void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CB60(EnPoh* this); void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CD14(EnPoh* this); void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx); +void func_80B2CEC8(EnPoh* this); void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx); void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D0E8(EnPoh* this); void func_80B2D140(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D2C0(EnPoh* this); void func_80B2D300(EnPoh* this, GlobalContext* globalCtx); void func_80B2D628(EnPoh* this, GlobalContext* globalCtx); +void func_80B2D694(EnPoh* this); void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx); void func_80B2D7D4(EnPoh* this, GlobalContext* globalCtx); void func_80B2D980(EnPoh* this, GlobalContext* globalCtx); +void func_80B2DAD0(EnPoh* this); void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx); +void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx); void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx); +void func_80B2E0B0(EnPoh* this); void func_80B2E180(EnPoh* this, GlobalContext* globalCtx); +void func_80B2E1D8(EnPoh* this); void func_80B2E230(EnPoh* this, GlobalContext* globalCtx); +void func_80B2E3B0(EnPoh* this); void func_80B2E3F8(EnPoh* this, GlobalContext* globalCtx); +void func_80B2F328(Actor* thisx, GlobalContext* globalCtx); +void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx); + +extern AnimationHeader D_060001A8; +extern AnimationHeader D_060004EC; +extern AnimationHeader D_060006E0; +extern AnimationHeader D_06000A60; +extern AnimationHeader D_060011C4; +extern AnimationHeader D_060015B0; +extern Gfx D_06002608[]; +extern Gfx D_06002D28[]; +extern Gfx D_06003850[]; +extern SkeletonHeader D_060050D0; -#if 0 const ActorInit En_Poh_InitVars = { ACTOR_EN_POH, ACTORCAT_ENEMY, @@ -39,29 +68,54 @@ const ActorInit En_Poh_InitVars = { (ActorFunc)EnPoh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B2F680 = { - { COLTYPE_HIT3, AT_NONE, AC_NONE | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CBFFFE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_NONE | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CBFFFE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 40, 20, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B2F6AC[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 18, { { 0, 1400, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B2F6D0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80B2F6AC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B2F6E0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -96,123 +150,874 @@ static DamageTable D_80B2F6E0 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B2F700 = { 3, 25, 50, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 25, 50, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B2F708[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 68, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; -#endif +void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* this = THIS; + s32 pad; -extern ColliderCylinderInit D_80B2F680; -extern ColliderJntSphElementInit D_80B2F6AC[1]; -extern ColliderJntSphInit D_80B2F6D0; -extern DamageTable D_80B2F6E0; -extern CollisionCheckInfoInit D_80B2F700; -extern InitChainEntry D_80B2F708[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + Collider_InitAndSetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, this->colliderSphElements); + this->colliderSph.elements[0].dim.worldSphere.radius = 0; + this->colliderSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->colliderSph.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; + this->colliderSph.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_18D = 32; + this->unk_190 = Rand_S16Offset(700, 300); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + 255, 255, 255, 0); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_060050D0, &D_06000A60, this->jointTable, this->morphTable, 21); + this->actor.bgCheckFlags |= 0x400; + func_80B2D0E8(this); +} -extern UNK_TYPE D_060001A8; -extern UNK_TYPE D_060004EC; -extern UNK_TYPE D_060006E0; -extern UNK_TYPE D_06000A60; -extern UNK_TYPE D_060011C4; -extern UNK_TYPE D_060015B0; -extern UNK_TYPE D_06002608; -extern UNK_TYPE D_06002D28; +void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/EnPoh_Init.s") + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyJntSph(globalCtx, &this->colliderSph); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/EnPoh_Destroy.s") +void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { + Camera* activeCam = ACTIVE_CAM; + Vec3f sp20; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2C910.s") + if (activeCam != NULL) { + Math_Vec3f_Diff(&activeCam->eye, &activeCam->at, &sp20); + temp_f0 = Math3D_Vec3fMagnitude(&sp20); + if (temp_f0 > 1.0f) { + temp_f0 = 11.0f / temp_f0; + } else { + temp_f0 = 11.0f; + } + Math_Vec3f_ScaleAndStore(&sp20, temp_f0, vec); + } else { + Math_Vec3f_Copy(vec, &D_801D15B0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2C9B8.s") +void func_80B2C9B8(EnPoh* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CA4C.s") + Math_StepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f); + this->actor.world.pos.y += 2.5f * Math_SinS(this->unk_18D * 0x800); + if (this->unk_18D != 0) { + this->unk_18D--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CAA4.s") + if (!this->unk_18D) { + this->unk_18D = 32; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CB60.s") +void func_80B2CA4C(EnPoh* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060015B0); + this->unk_18E = Rand_S16Offset(2, 3); + this->actionFunc = func_80B2CAA4; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CBBC.s") +void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CD14.s") + func_80B2C9B8(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CD64.s") + if (this->actor.xzDistToPlayer < 200.0f) { + func_80B2CD14(this); + } else if (this->unk_18E == 0) { + func_80B2CB60(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CEC8.s") + if (this->unk_197 == 255) { + func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CF28.s") +void func_80B2CB60(EnPoh* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06000A60); + this->unk_18E = Rand_S16Offset(15, 3); + this->colliderCylinder.base.acFlags |= AC_ON; + this->actionFunc = func_80B2CBBC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2CFF8.s") +void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); + if (func_801378B8(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D07C.s") + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f) { + this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D0E8.s") + Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C); + func_80B2C9B8(this, globalCtx); + if ((this->actor.xzDistToPlayer < 200.0f) && (this->unk_18E < 19)) { + func_80B2CD14(this); + } else if (this->unk_18E == 0) { + if (Rand_ZeroOne() < 0.1f) { + func_80B2D694(this); + } else { + func_80B2CA4C(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D140.s") + if (this->unk_197 == 255) { + func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D2C0.s") +void func_80B2CD14(EnPoh* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06000A60); + this->actionFunc = func_80B2CD64; + this->unk_18E = 0; + this->actor.speedXZ = 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D300.s") +void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D5DC.s") + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->unk_18E != 0) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D628.s") + yawDiff = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; + if (yawDiff > 0x3000) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); + } else if (yawDiff < -0x3000) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x3000, 0x71C); + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D694.s") + func_80B2C9B8(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D6EC.s") + if (this->actor.xzDistToPlayer > 280.0f) { + func_80B2CB60(this); + } else if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 140.0f) && + !Actor_IsLinkFacingActor(&this->actor, 0x2AAA, globalCtx)) { + func_80B2CEC8(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D76C.s") + if (this->unk_197 == 255) { + func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D7D4.s") +void func_80B2CEC8(EnPoh* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060001A8, -6.0f); + this->unk_18E = 12; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + this->actionFunc = func_80B2CF28; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D924.s") +void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 0.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_KANTERA); + if (this->unk_18E != 0) { + this->unk_18E--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2D980.s") + func_80B2C9B8(this, globalCtx); + if (this->unk_18E >= 10) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xAAA); + } else if (this->unk_18E == 9) { + this->actor.speedXZ = 5.0f; + this->skelAnime.animPlaybackSpeed = 2.0f; + } else if (this->unk_18E == 0) { + func_80B2CB60(this); + this->unk_18E = 0x17; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2DAD0.s") +void func_80B2CFF8(EnPoh* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060004EC, -6.0f); + func_800BE504(&this->actor, &this->colliderCylinder); + this->colliderCylinder.base.acFlags &= ~AC_ON; + this->actor.speedXZ = 5.0f; + func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + this->actionFunc = func_80B2D07C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2DB44.s") +void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->actor.colChkInfo.health != 0) { + func_80B2DAD0(this); + } else { + func_80B2D2C0(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2DC50.s") +void func_80B2D0E8(EnPoh* this) { + this->unk_197 = 0; + this->actor.flags &= ~1; + SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, &D_060011C4, 0.0f); + this->actionFunc = func_80B2D140; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2DD2C.s") +void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->unk_197 = 255; + this->unk_190 = Rand_S16Offset(700, 300); + this->actor.flags |= 1; + func_80B2CB60(this); + } else if (this->skelAnime.animCurrentFrame > 10.0f) { + this->unk_197 = (this->skelAnime.animCurrentFrame - 10.0f) * 0.05f * 255.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2DDF8.s") + if ((this->skelAnime.animPlaybackSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + this->skelAnime.animPlaybackSpeed = 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E0B0.s") +void func_80B2D2C0(EnPoh* this) { + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_18E = 0; + this->actor.hintId = 0xFF; + this->actor.flags &= ~1; + this->actionFunc = func_80B2D300; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E180.s") +void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { + static Vec3f D_80B2F710 = { 0.0f, 3.0f, 0.0f }; + Vec3f sp44; + f32 sp40; + s32 pad; + s16 sp3A; + s16 sp38; + s16 sp36; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E1D8.s") + this->unk_18E++; + if (this->unk_18E < 8) { + sp38 = func_800DFCDC(ACTIVE_CAM) + 0x4800; + if (this->unk_18E < 5) { + sp3A = (this->unk_18E * 0x1000) - 0x4000; + sp44.y = (Math_SinS(sp3A) * 23.0f) + (this->actor.world.pos.y + 40.0f); + sp40 = Math_CosS(sp3A) * 23.0f; + sp44.x = (Math_SinS(sp38) * sp40) + this->actor.world.pos.x; + sp44.z = (Math_CosS(sp38) * sp40) + this->actor.world.pos.z; + } else { + sp44.y = this->actor.world.pos.y + 40.0f + (15.0f * (this->unk_18E - 5)); + sp44.x = (Math_SinS(sp38) * 23.0f) + this->actor.world.pos.x; + sp44.z = (Math_CosS(sp38) * 23.0f) + this->actor.world.pos.z; + } + sp36 = (this->unk_18E * 10) + 80; + func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; + sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; + func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + sp44.x = this->actor.world.pos.x; + sp44.z = this->actor.world.pos.z; + func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + } else if (this->unk_18E == 28) { + func_80B2DC50(this, globalCtx); + } else if (this->unk_18E > 18) { + this->actor.scale.x = (28 - this->unk_18E) * 0.001f; + this->actor.scale.y = (28 - this->unk_18E) * 0.001f; + this->actor.scale.z = (28 - this->unk_18E) * 0.001f; + this->actor.world.pos.y += 5.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E230.s") + if (this->unk_18E < 18) { + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E3B0.s") + if (this->unk_18E == 18) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E3F8.s") +void func_80B2D5DC(EnPoh* this) { + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000A60); + this->actionFunc = func_80B2D628; + this->actor.speedXZ = -5.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E438.s") +void func_80B2D628(EnPoh* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80B2CB60(this); + this->unk_18E = 23; + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.shape.rot.y += 0x1000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E55C.s") +void func_80B2D694(EnPoh* this) { + SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060015B0); + this->unk_192 = BINANG_ROT180(this->actor.world.rot.y); + this->actionFunc = func_80B2D6EC; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E6C0.s") +void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C)) { + func_80B2CB60(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2E8E0.s") + if (this->actor.xzDistToPlayer < 200.0f) { + func_80B2CD14(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/EnPoh_Update.s") + func_80B2C9B8(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2ED14.s") +void func_80B2D76C(EnPoh* this) { + this->unk_18C = 32; + this->unk_192 = 0x2000; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + this->colliderCylinder.base.acFlags &= ~AC_ON; + this->actionFunc = func_80B2D7D4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2EDD0.s") +void func_80B2D7D4(EnPoh* this, GlobalContext* globalCtx) { + if (this->unk_18C != 0) { + this->unk_18C--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/EnPoh_Draw.s") + this->actor.world.rot.y += this->unk_192; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2F328.s") + if (this->unk_18C < 16) { + Math_ScaledStepToS(&this->unk_192, 0, 0x200); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Poh/func_80B2F37C.s") + func_80B2C9B8(this, globalCtx); + this->unk_197 = this->unk_18C * (255.0f / 32.0f); + if (this->unk_18C == 0) { + this->unk_190 = Rand_S16Offset(100, 50); + this->colliderCylinder.info.bumper.dmgFlags = 0x40001; + func_80B2CB60(this); + } +} + +void func_80B2D924(EnPoh* this) { + this->unk_18C = 0; + this->unk_192 = 0x2000; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + this->colliderCylinder.base.acFlags &= ~AC_ON; + this->actionFunc = func_80B2D980; +} + +void func_80B2D980(EnPoh* this, GlobalContext* globalCtx) { + this->unk_18C++; + this->actor.world.rot.y -= this->unk_192; + if (this->unk_18C > 15) { + Math_ScaledStepToS(&this->unk_192, 0, 0x200); + } + + func_80B2C9B8(this, globalCtx); + this->unk_197 = this->unk_18C * (255.0f / 32.0f); + if (this->unk_18C == 32) { + this->unk_190 = Rand_S16Offset(700, 300); + this->unk_18C = 0; + this->colliderCylinder.info.bumper.dmgFlags = ~0x8340001; + func_80B2CB60(this); + } +} + +void func_80B2DAD0(EnPoh* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060006E0, -5.0f); + this->actor.speedXZ = 5.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + this->colliderCylinder.base.acFlags |= AC_ON; + this->unk_18E = 200; + this->actionFunc = func_80B2DB44; +} + +void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx) { + f32 sp24; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + sp24 = Math_SinS(this->unk_18D * 0x800) * 3.0f; + this->actor.world.pos.x -= sp24 * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.z += sp24 * Math_SinS(this->actor.shape.rot.y); + Math_ScaledStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 0x71C); + func_80B2C9B8(this, globalCtx); + this->unk_18E--; + if ((this->unk_18E == 0) || (this->actor.xzDistToPlayer > 250.0f)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80B2CB60(this); + } + func_800B9010(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); +} + +void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { + this->actor.update = func_80B2F328; + this->actor.draw = func_80B2F37C; + this->actor.shape.shadowDraw = NULL; + this->actor.world.pos.x = this->unk_3D8.wx; + this->actor.world.pos.y = this->unk_3D8.wy; + this->actor.world.pos.z = this->unk_3D8.wz; + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags |= 0x10; + this->actor.gravity = -1.0f; + this->actor.shape.yOffset = 1500.0f; + this->actor.world.pos.y -= 15.0f; + this->actor.shape.rot.x = -0x8000; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); + this->actor.flags &= ~(0x4 | 0x1); + this->actionFunc = func_80B2DD2C; +} + +void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx) { + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight <= BGCHECK_Y_MIN)) { + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO, 10, D_06002D28); + func_80B2E0B0(this); + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); +} + +void func_80B2DDF8(EnPoh* this, s32 arg1) { + f32 temp_f2; + + this->unk_197 = CLAMP(this->unk_197 + arg1, 0, 255); + + if (arg1 < 0) { + temp_f2 = this->unk_197 * (1.0f / 255.0f); + this->actor.scale.x = this->actor.scale.z = (0.0056000003f * temp_f2) + 0.0014000001f; + this->actor.scale.y = (0.007f - (0.007f * temp_f2)) + 0.007f; + } else { + temp_f2 = 1.0f; + this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = this->unk_197 * 0.000027450982f; + this->actor.world.pos.y = this->actor.home.pos.y + ((15.0f / 255.0f) * this->unk_197); + } + + this->unk_194 = 100.0f * temp_f2; + this->unk_195 = 0; + this->unk_196 = 150.0f * temp_f2; + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 100, 0, 150, this->unk_197 * (200.0f / 255.0f)); +} + +void func_80B2E0B0(EnPoh* this) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->unk_190 = 0; + this->actor.shape.rot.y = 0; + this->unk_194 = 0; + this->unk_197 = 0; + this->unk_195 = 0; + this->unk_196 = 200; + this->actor.shape.rot.x = 0; + this->actor.shape.yOffset = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.home.pos.y = this->actor.world.pos.y; + this->actor.scale.x = 0.0f; + this->actor.scale.y = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); + this->actionFunc = func_80B2E180; +} + +void func_80B2E180(EnPoh* this, GlobalContext* globalCtx) { + this->actor.home.pos.y += 2.0f; + func_80B2DDF8(this, 20); + if (this->unk_197 == 255) { + func_80B2E1D8(this); + } +} + +void func_80B2E1D8(EnPoh* this) { + this->actor.home.pos.y = this->actor.world.pos.y; + Actor_SetHeight(&this->actor, -10.0f); + this->unk_18E = 200; + this->unk_18D = 32; + this->actor.flags |= 1; + this->actionFunc = func_80B2E230; +} + +void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { + + if (Actor_HasParent(&this->actor, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_18E--; + if (this->unk_18E == 0) { + func_80B2E3B0(this); + return; + } + + func_800B8A1C(&this->actor, globalCtx, 0xBA, 35.0f, 60.0f); + this->actor.world.pos.y = (Math_SinS(this->unk_18D * 0x800) * 5.0f) + this->actor.home.pos.y; + if (this->unk_18D) { + this->unk_18D--; + } + + if (this->unk_18D == 0) { + this->unk_18D = 32; + } + + Actor_SetHeight(&this->actor, -10.0f); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 100, 0, 150, this->unk_197 * (40.0f / 51.0f)); +} + +void func_80B2E3B0(EnPoh* this) { + func_801A7328(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + this->actionFunc = func_80B2E3F8; +} + +void func_80B2E3F8(EnPoh* this, GlobalContext* globalCtx) { + func_80B2DDF8(this, -13); + if (this->unk_197 == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { + if (this->colliderCylinder.base.acFlags & AC_HIT) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); + } else if (this->actor.colChkInfo.damage != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + } + + if (this->actor.colChkInfo.damageEffect != 14) { + if (this->actor.colChkInfo.damageEffect == 15) { + func_80B2D924(this); + } else { + if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_298 = 4.0f; + this->unk_29C = 0.45f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->colliderCylinder.info.bumper.hitPos.x, + this->colliderCylinder.info.bumper.hitPos.y, + this->colliderCylinder.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + func_80B2CFF8(this); + } + } + } +} + +void func_80B2E55C(EnPoh* this) { + if ((this->actionFunc != func_80B2D980) && (this->actionFunc != func_80B2D7D4) && + (this->actionFunc != func_80B2D140)) { + if (this->unk_190 != 0) { + this->unk_190--; + } + + if (this->unk_197 == 255) { + if (this->actor.isTargeted) { + this->unk_18C++; + this->unk_18C = CLAMP_MAX(this->unk_18C, 20); + } else { + this->unk_18C = 0; + } + + if (((this->unk_18C == 20) || (this->unk_190 == 0)) && + ((this->actionFunc == func_80B2CAA4) || (this->actionFunc == func_80B2CBBC) || + (this->actionFunc == func_80B2CD64) || (this->actionFunc == func_80B2DB44) || + (this->actionFunc == func_80B2D6EC))) { + func_80B2D76C(this); + } + } else if ((this->unk_197 == 0) && (this->unk_190 == 0) && + ((this->actionFunc == func_80B2CAA4) || (this->actionFunc == func_80B2CBBC) || + (this->actionFunc == func_80B2CD64) || (this->actionFunc == func_80B2D6EC))) { + func_80B2D924(this); + } + } +} + +void func_80B2E6C0(EnPoh* this) { + if (this->actionFunc == func_80B2CF28) { + this->unk_194 = CLAMP_MAX((s16)(this->unk_194 + 5), 255); + this->unk_195 = CLAMP_MIN((s16)(this->unk_195 - 5), 50); + this->unk_196 = CLAMP_MIN((s16)(this->unk_196 - 5), 0); + } else if (this->actionFunc == func_80B2DB44) { + this->unk_194 = CLAMP_MAX((s16)(this->unk_194 + 5), 80); + this->unk_195 = CLAMP_MAX((s16)(this->unk_195 + 5), 255); + this->unk_196 = CLAMP_MAX((s16)(this->unk_196 + 5), 225); + } else if (this->actionFunc == func_80B2D07C) { + if ((this->actor.colorFilterTimer & 2) != 0) { + this->unk_194 = 0; + this->unk_195 = 0; + this->unk_196 = 0; + } else { + this->unk_194 = 80; + this->unk_195 = 255; + this->unk_196 = 225; + } + } else { + u8 temp; + + this->unk_194 = CLAMP_MAX((s16)(this->unk_194 + 5), 255); + this->unk_195 = CLAMP_MAX((s16)(this->unk_195 + 5), 255); + temp = this->unk_196; + if (this->unk_196 > 210) { + this->unk_196 = CLAMP_MIN((s16)(temp - 5), 210); + } else { + this->unk_196 = CLAMP_MAX((s16)(temp + 5), 210); + } + } +} + +void func_80B2E8E0(EnPoh* this) { + if ((this->actionFunc == func_80B2D140) && (this->skelAnime.animCurrentFrame < 12.0f)) { + this->unk_198 = this->unk_199 = this->unk_19A = (this->skelAnime.animCurrentFrame * 16.66f) + 55.0f; + this->unk_19B = this->skelAnime.animCurrentFrame * 16.666666f; + } else { + f32 rand = Rand_ZeroOne(); + + this->unk_198 = (s32)(rand * 30.0f) + 225; + this->unk_199 = (s32)(rand * 100.0f) + 155; + this->unk_19A = (s32)(rand * 160.0f) + 95; + this->unk_19B = 200; + } +} + +void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnPoh* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 pad; + + if (this->colliderSph.base.atFlags & AT_HIT) { + this->colliderSph.base.atFlags &= ~AT_HIT; + func_80B2D5DC(this); + } + + func_80B2E438(this, globalCtx); + func_80B2E55C(this); + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + if (this->colliderCylinder.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); + Actor_SetHeight(&this->actor, 42.0f); + + if ((this->actionFunc != func_80B2D07C) && (this->actionFunc != func_80B2D628)) { + if (this->actionFunc == func_80B2DB44) { + this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); + } else { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + + func_80B2E8E0(this); + this->actor.shape.shadowAlpha = this->unk_197; + if (this->unk_298 > 0.0f) { + Math_StepToF(&this->unk_298, 0.0f, 0.05f); + if (this->unk_197 != 255) { + if (this->unk_197 * (1.0f / 255.0f) < this->unk_197) { + this->unk_298 = this->unk_197 * (1.0f / 255.0f); + } + } + + this->unk_29C = (this->unk_298 + 1.0f) * (9.0f / 40.0f); + this->unk_29C = CLAMP_MAX(this->unk_29C, 0.45f); + } +} + +s32 EnPoh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPoh* this = THIS; + + if ((this->unk_197 == 0) || (limbIndex == 18) || ((this->actionFunc == func_80B2D300) && (this->unk_18E >= 2))) { + *dList = NULL; + } + + if (limbIndex == 19) { + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, this->unk_194, this->unk_195, this->unk_196, this->unk_197); + } + + return false; +} + +void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + static s8 D_80B2F71C[] = { + -1, -1, -1, -1, 4, 5, -1, -1, -1, 0, 1, -1, -1, -1, -1, -1, 2, -1, -1, 3, -1, + }; + static Vec3f D_80B2F734[] = { + { -600.0f, 500.0f, 1700.0f }, + { -600.0f, 500.0f, -1700.0f }, + { 1000.0f, 1700.0f, 0.0f }, + }; + s32 temp_s3; + Vec3f sp60; + EnPoh* this = THIS; + s32 pad; + + Collider_UpdateSpheres(limbIndex, &this->colliderSph); + if ((this->actionFunc == func_80B2D300) && (this->unk_18E >= 2) && (limbIndex == 5)) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, D_06002608); + } + + if (limbIndex == 18) { + if ((this->actionFunc == func_80B2D300) && (this->unk_18E >= 19) && (this->actor.scale.x != 0.0f)) { + Matrix_Scale(0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 1); + } + SysMatrix_CopyCurrentState(&this->unk_3D8); + func_80B2C910(&sp60, globalCtx); + Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x + (s32)sp60.x, + this->colliderSph.elements[0].dim.worldSphere.center.y + (s32)sp60.y, + this->colliderSph.elements[0].dim.worldSphere.center.z + (s32)sp60.z, this->unk_198, + this->unk_199, this->unk_19A, this->unk_19B * (200.0f / 255.0f)); + } + + temp_s3 = D_80B2F71C[limbIndex]; + if (temp_s3 != -1) { + if (temp_s3 < 4) { + SysMatrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + } else if (temp_s3 == 4) { + SysMatrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + } else { + s32 i; + Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; + Vec3f* vec2 = &D_80B2F734[0]; + + SysMatrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); + SysMatrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + + for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { + SysMatrix_MultiplyVector3fByState(vec2, vec); + } + } + } +} + +void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_80B2E6C0(this); + if ((this->unk_197 == 255) || (this->unk_197 == 0)) { + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], this->unk_194, this->unk_195, this->unk_196, this->unk_197); + gSPSegment(&gfx[2], 0x08, D_801AEFA0); + + gfx = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnPoh_OverrideLimbDraw, + EnPoh_PostLimbDraw, &this->actor, &gfx[3]); + + POLY_OPA_DISP = gfx; + } else { + gfx = POLY_XLU_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 255, 255, 255, this->unk_197); + gSPSegment(&gfx[2], 0x08, D_801AEF88); + + POLY_XLU_DISP = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, + EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, &gfx[3]); + + gfx = POLY_OPA_DISP; + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + } + + gDPPipeSync(&gfx[0]); + gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); + + SysMatrix_SetCurrentState(&this->unk_3D8); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], D_06002D28); + + POLY_OPA_DISP = &gfx[4]; + func_800BE680(globalCtx, &this->actor, this->unk_2A0, 10, this->actor.scale.x * 100.0f * this->unk_29C, 0.0f, + this->unk_298, 20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B2F328(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* this = THIS; + + this->actionFunc(this, globalCtx); + if (this->actionFunc != func_80B2DD2C) { + this->unk_190++; + } + + func_80B2E8E0(this); +} + +void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { + EnPoh* this = THIS; + s32 pad; + Vec3f sp7C; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80B2DD2C) { + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); + + func_80B2C910(&sp7C, globalCtx); + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x + sp7C.x, this->actor.world.pos.y + sp7C.y, + this->actor.world.pos.z + sp7C.z, this->unk_198, this->unk_199, this->unk_19A, 200); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], D_06002D28); + + POLY_OPA_DISP = &gfx[4]; + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_190 * -8) & 0x1FF, + 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); + gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); + + SysMatrix_InsertYRotation_f((func_800DFCDC(ACTIVE_CAM) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_06003850); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fe6776f60..fe579e027 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -9,9 +9,32 @@ typedef void (*EnPohActionFunc)(struct EnPoh*, GlobalContext*); typedef struct EnPoh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnPohActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x28C]; + /* 0x018C */ u8 unk_18C; + /* 0x018D */ u8 unk_18D; + /* 0x018E */ s16 unk_18E; + /* 0x0190 */ s16 unk_190; + /* 0x0192 */ s16 unk_192; + /* 0x0194 */ u8 unk_194; + /* 0x0195 */ u8 unk_195; + /* 0x0196 */ u8 unk_196; + /* 0x0197 */ u8 unk_197; + /* 0x0198 */ u8 unk_198; + /* 0x0199 */ u8 unk_199; + /* 0x019A */ u8 unk_19A; + /* 0x019B */ u8 unk_19B; + /* 0x019C */ Vec3s jointTable[21]; + /* 0x021A */ Vec3s morphTable[21]; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ f32 unk_29C; + /* 0x02A0 */ Vec3f unk_2A0[10]; + /* 0x0318 */ LightNode* lightNode; + /* 0x031C */ LightInfo lightInfo; + /* 0x032C */ ColliderCylinder colliderCylinder; + /* 0x0378 */ ColliderJntSph colliderSph; + /* 0x0398 */ ColliderJntSphElement colliderSphElements[1]; + /* 0x03D8 */ MtxF unk_3D8; } EnPoh; // size = 0x418 extern const ActorInit En_Poh_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ba1390e5c..191840f32 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13434,8 +13434,8 @@ 0x80B2E6C0:("func_80B2E6C0",), 0x80B2E8E0:("func_80B2E8E0",), 0x80B2EACC:("EnPoh_Update",), - 0x80B2ED14:("func_80B2ED14",), - 0x80B2EDD0:("func_80B2EDD0",), + 0x80B2ED14:("EnPoh_OverrideLimbDraw",), + 0x80B2EDD0:("EnPoh_PostLimbDraw",), 0x80B2F0A4:("EnPoh_Draw",), 0x80B2F328:("func_80B2F328",), 0x80B2F37C:("func_80B2F37C",), From 28523e2980c09989d37158674e511aedb8b547ab Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:11:11 +0100 Subject: [PATCH 30/86] Script to check global bss ordering (#339) * Script to check global bss ordering * Bit of cleanup * Format * Extremely important capilatisation correction * Review --- tools/global_bss_check.py | 207 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100755 tools/global_bss_check.py diff --git a/tools/global_bss_check.py b/tools/global_bss_check.py new file mode 100755 index 000000000..8f04493e0 --- /dev/null +++ b/tools/global_bss_check.py @@ -0,0 +1,207 @@ +#!/usr/bin/env python3 +import colorama +colorama.init() + +import argparse +import os +import re +import collections + +regex_fileDataEntry = re.compile(r"^\s+(?P
[^\s]+)\s+(?P0x[^\s]+)\s+(?P0x[^\s]+)\s+(?P[^\s]+)$") +regex_bssEntry = re.compile(r"^\s+(?P0x[^\s]+)\s+(?P[^\s]+)$") +regex_label = re.compile(r"^(?PL[0-9A-F]{8})$") + +VarInfo = collections.namedtuple("VarInfo", ["file", "vram"]) + +def parseMapFile(mapPath: str): + with open(mapPath) as f: + mapData = f.read() + startIndex = mapData.find("..makerom") + mapData = mapData[startIndex:] + # print(len(mapData)) + + symbolsDict = collections.OrderedDict() + + inFile = False + currentFile = "" + + mapLines = mapData.split("\n") + for line in mapLines: + if inFile: + if line.startswith(" "): + entryMatch = regex_bssEntry.search(line) + + # Find variable + if entryMatch is not None: + varName = entryMatch["name"] + varVram = int(entryMatch["vram"], 16) + + # Filter out jump table labels + labelMatch = regex_label.search(varName) + if labelMatch is None: + symbolsDict[varName] = VarInfo( currentFile, varVram ) + # print( symbolsDict[varName] ) + + else: + inFile = False + else: + if line.startswith(" .bss "): + inFile = False + entryMatch = regex_fileDataEntry.search(line) + + # Find file + if entryMatch is not None: + name = "/".join(entryMatch["name"].split("/")[1:]) + + # mapfile only contains .o files, so just strip the last character to replace it + # we assume all the .c files are in the src folder, and all others are .s (true for OoT/MM) + if name.split("/")[0] == "src": + name = name[:-1] + "c" + else: + name = name[:-1] + "s" + + size = int(entryMatch["size"], 16) + vram = int(entryMatch["vram"], 16) + + if size > 0: + inFile = True + currentFile = name + + return symbolsDict + + +Compared = collections.namedtuple("Compared", [ "buildAddress", "buildFile", "expectedAddress", "expectedFile", "diff"]) + +def compareMapFiles(mapFileBuild: str, mapFileExpected: str): + badFiles = set() + missingFiles = set() + + print("Build mapfile: " + mapFileBuild, file=os.sys.stderr) + print("Expected mapfile: " + mapFileExpected, file=os.sys.stderr) + print("", file=os.sys.stderr) + + if not os.path.exists(mapFileBuild): + print(f"{colorama.Fore.LIGHTRED_EX}error{colorama.Fore.RESET}: mapfile not found at {mapFileBuild}. Did you enter the correct path?", file=os.sys.stderr) + exit(1) + + if not os.path.exists(mapFileExpected): + print(f"{colorama.Fore.LIGHTRED_EX}error{colorama.Fore.RESET}: expected mapfile not found at {mapFileExpected}. Is 'expected' missing or in a different folder?", file=os.sys.stderr) + exit(1) + + buildMap = parseMapFile(mapFileBuild) + expectedMap = parseMapFile(mapFileExpected) + + comparedDict = collections.OrderedDict() + + for symbol in buildMap: + if symbol in expectedMap: + comparedDict[symbol] = Compared( buildMap[symbol].vram, buildMap[symbol].file, expectedMap[symbol].vram, expectedMap[symbol].file, buildMap[symbol].vram - expectedMap[symbol].vram ) + if comparedDict[symbol].diff != 0: + badFiles.add(buildMap[symbol].file) + + else: + missingFiles.add(buildMap[symbol].file) + comparedDict[symbol] = Compared( buildMap[symbol].vram, buildMap[symbol].file, -1, "", "Unknown" ) + + for symbol in expectedMap: + if not symbol in buildMap: + missingFiles.add(expectedMap[symbol].file) + comparedDict[symbol] = Compared( -1, "", expectedMap[symbol].vram, expectedMap[symbol].file, "Unknown" ) + + return badFiles, missingFiles, comparedDict + + +def printCsv(badFiles, missingFiles, comparedDict, printAll = True): + print("Symbol Name,Build Address,Build File,Expected Address,Expected File,Difference,GOOD/BAD/MISSING") + + # If it's bad or missing, don't need to do anything special. + # If it's good, check for if it's in a file with bad or missing stuff, and check if print all is on. If none of these, print it. + + for symbol in comparedDict: + symbolInfo = comparedDict[symbol] + symbolGood = colorama.Fore.RED + "BAD" + colorama.Fore.RESET + if type(symbolInfo.diff) != int: + symbolGood = colorama.Fore.YELLOW + "MISSING" + colorama.Fore.RESET + print(f"{symbol},{symbolInfo.buildAddress:X},{symbolInfo.buildFile},{symbolInfo.expectedAddress:X},{symbolInfo.expectedFile},{symbolInfo.diff},{symbolGood}") + continue + + if symbolInfo.diff == 0: + symbolGood = colorama.Fore.GREEN + "GOOD" + colorama.Fore.RESET + if (not symbolInfo.buildFile in badFiles and not symbolInfo.expectedFile in badFiles) and (not symbolInfo.buildFile in badFiles and not symbolInfo.expectedFile in badFiles) and not printAll: + continue + + if symbolInfo.buildFile != symbolInfo.expectedFile: + symbolGood += colorama.Fore.CYAN + " MOVED" + colorama.Fore.RESET + print(f"{symbol},{symbolInfo.buildAddress:X},{symbolInfo.buildFile},{symbolInfo.expectedAddress:X},{symbolInfo.expectedFile},{symbolInfo.diff:X},{symbolGood}") + + +def main(): + description = "Check that globally visible bss has not been reordered." + epilog = """\ + N.B. Since this script reads the map files, it can only see globally visible bss; in-function static bss must be examined with other tools. + """ + + parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("mapFile", help="Path to a map file.") + parser.add_argument("mapFileExpected", help="Path to the expected map file. Optional, default is 'expected/mapFile'.", nargs="?", default="") + parser.add_argument("-a", "--print-all", help="Print all bss, not just non-matching.", action="store_true") + parser.add_argument("-n", "--no-fun-allowed", help="Remove amusing messages.", action="store_true") + args = parser.parse_args() + + if args.mapFileExpected == "": + args.mapFileExpected = os.path.join("expected", args.mapFile) + + badFiles, missingFiles, comparedDict = compareMapFiles(args.mapFile, args.mapFileExpected) + printCsv(badFiles, missingFiles, comparedDict, args.print_all) + + if len(badFiles) + len(missingFiles) != 0: + print("", file=os.sys.stderr) + + if len(badFiles) != 0: + print(colorama.Fore.RED + " BAD" + colorama.Style.RESET_ALL) + + for file in badFiles: + print(f"bss reordering in {file}", file=os.sys.stderr) + print("", file=os.sys.stderr) + + if not args.no_fun_allowed: + print(colorama.Fore.LIGHTWHITE_EX + + " BSS is REORDERED!!\n" + " Oh! MY GOD!!" + + colorama.Style.RESET_ALL, file=os.sys.stderr) + print("", file=os.sys.stderr) + + if len(missingFiles) != 0: + print(colorama.Fore.YELLOW + " MISSING" + colorama.Style.RESET_ALL) + + for file in missingFiles: + print(f"Symbols missing from {file}", file=os.sys.stderr) + print("", file=os.sys.stderr) + + if not args.no_fun_allowed: + print(colorama.Fore.LIGHTWHITE_EX + " Error, should (not) be in here " + colorama.Style.RESET_ALL, file=os.sys.stderr) + print("", file=os.sys.stderr) + + print("Some files appear to be missing symbols. Have they been renamed or declared as static? You may need to remake 'expected'", file=os.sys.stderr) + + return 1 + + print("", file=os.sys.stderr) + print(colorama.Fore.GREEN + " GOOD" + colorama.Style.RESET_ALL, file=os.sys.stderr) + + if args.no_fun_allowed: + return 0 + + print("\n" + colorama.Fore.LIGHTWHITE_EX + + colorama.Back.RED + " " + colorama.Back.RESET + "\n" + + colorama.Back.RED + " CONGRATURATIONS! " + colorama.Back.RESET + "\n" + + colorama.Back.RED + " All Global BSS is correct. " + colorama.Back.RESET + "\n" + + colorama.Back.RED + " THANK YOU! " + colorama.Back.RESET + "\n" + + colorama.Back.RED + " You are great decomper! " + colorama.Back.RESET + "\n" + + colorama.Back.RED + " " + colorama.Style.RESET_ALL , file=os.sys.stderr) + + return 0 + +if __name__ == "__main__": + ret = main() + exit(ret) From a2666a6ee0d7394e6a4003110d878d171c0624f5 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:41:02 +0100 Subject: [PATCH 31/86] En_Sw (6 non-matching) (#295) * En_Sw * spec * Sw * Fix --- include/functions.h | 2 +- spec | 7 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 1241 ++++++++++++++++++++++- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 43 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 3 + 6 files changed, 1239 insertions(+), 59 deletions(-) diff --git a/include/functions.h b/include/functions.h index d6042e3f5..27066008c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2697,7 +2697,7 @@ Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, s32 actorCategory, s32 actorId); s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); // void func_8013BD40(void); -// void func_8013BEDC(void); +s32 func_8013BEDC(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32* arg3); // void func_8013C068(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8013C624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_8013C8B8(void); diff --git a/spec b/spec index 44097c913..8a587b0c0 100644 --- a/spec +++ b/spec @@ -1202,8 +1202,11 @@ beginseg name "ovl_En_Sw" compress include "build/src/overlays/actors/ovl_En_Sw/z_en_sw.o" - include "build/data/ovl_En_Sw/ovl_En_Sw.data.o" - include "build/data/ovl_En_Sw/ovl_En_Sw.reloc.o" + #ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Sw/ovl_En_Sw_reloc.o" + #else + include "build/data/ovl_En_Sw/ovl_En_Sw.reloc.o" + #endif endseg beginseg diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index b5244fd12..d49dd3757 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sw.c + * Overlay: ovl_En_Sw + * Description: Skullwalltula + */ + #include "z_en_sw.h" #define FLAGS 0x00000005 @@ -21,7 +27,21 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx); void func_808DB25C(EnSw* this, GlobalContext* globalCtx); void func_808DB2E0(EnSw* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_06000304; +extern Gfx D_06003FB0[]; +extern Gfx D_060043D8[]; +extern Gfx D_060045C0[]; +extern Gfx D_06004658[]; +extern Gfx D_060046F0[]; +extern Gfx D_06004788[]; +extern Gfx D_06004820[]; +extern Gfx D_060048B8[]; +extern Gfx D_06004950[]; +extern Gfx D_060049E8[]; +extern SkeletonHeader D_06005298; +extern AnimationHeader D_060055A8; +extern AnimationHeader D_06005B98; + const ActorInit En_Sw_InitVars = { ACTOR_EN_SW, ACTORCAT_NPC, @@ -34,18 +54,29 @@ const ActorInit En_Sw_InitVars = { (ActorFunc)EnSw_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808DB9E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 16 }, 100 }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808DBA0C = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808DBA18 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,11 +111,9 @@ static DamageTable D_808DBA18 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808DBA38 = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit2 = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808DBA44 = { +static DamageTable sDamageTable2 = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -119,89 +148,1195 @@ static DamageTable D_808DBA44 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; +static ActorAnimationEntryS sAnimations[] = { + { &D_06000304, 1.0f, 0, -1, 3, 0 }, + { &D_06000304, 1.0f, 0, -1, 3, -4 }, + { &D_060055A8, 1.0f, 0, -1, 1, -4 }, + { &D_06005B98, 1.0f, 0, -1, 1, -4 }, +}; + +void func_808D8940(EnSw* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808DBAA4 = { 170, 130, 90, 255 }; + static Color_RGBA8 D_808DBAA8 = { 100, 60, 20, 0 }; + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 temp_f4; + s16 temp_s0; + + temp_s0 = (Rand_ZeroOne() - 0.5f) * 0x10000; + spA0.y = this->actor.floorHeight; + + for (i = 0; i < 8; i++, temp_s0 += 0x1FFE) { + temp_f4 = (Rand_ZeroOne() * 4.0f) + 8.0f; + sp94.x = 0.0f; + sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; + sp94.z = Rand_ZeroOne() + 1.0f; + Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, temp_s0, &sp94, &spAC); + sp94.x = 0.0f; + sp94.y = 0.7f; + sp94.z = 2.0f; + Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, temp_s0, &sp94, &spB8); + spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); + spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); + func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808DBAA4, &D_808DBAA8, 60, 30, temp_f4); + } +} + +s32 func_808D8B58(EnSw* this) { + s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % ARRAY_COUNT(this->unk_464)) * 0x1555; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_464); i++, phi_s2 += 0x1555) { + if (this->unk_412 != 10) { + this->unk_464[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; + } else { + this->unk_464[i] = 80; + } + this->unk_47C[i] = this->unk_464[i]; + this->unk_418[i] = 0.45000002f; + if ((this->unk_412 == 0) || (this->unk_412 == 1) || (this->unk_412 == 10)) { + this->unk_380[i].y = (Rand_ZeroOne() - 0.5f) * 20.0f; + } else { + this->unk_380[i].y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + 10.0f; + } + this->unk_380[i].x = Math_SinS(phi_s2) * 10.0f; + this->unk_380[i].z = Math_CosS(phi_s2) * 10.0f; + } + this->unk_462 = 1; + return 0; +} + +s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { + s32 ret = false; + u8 sp53; + Vec3f sp44; + f32 sp40; + + if (arg2 < this->unk_462) { + if (this->unk_464[arg2] != 0) { + sp40 = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; + sp53 = this->unk_412; + Math_ApproachF(&this->unk_418[arg2], 0.3f, 0.3f, 0.5f); + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + sp44.x += this->unk_380[arg2].x; + sp44.y += this->unk_380[arg2].y; + sp44.z += this->unk_380[arg2].z; + if (sp53 == 10) { + if ((this->unk_47C[arg2] - this->unk_464[arg2]) < 20) { + sp53 = 11; + } + sp40 = 1.0f; + } + func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.3f, this->unk_418[arg2], sp40, sp53); + ret = true; + } + } + return ret; +} + +void func_808D8ED0(EnSw* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_380); i++) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += this->unk_380[i].x; + sp54.y += this->unk_380[i].y; + sp54.z += this->unk_380[i].z; + Math_Vec3f_Copy(&this->unk_380[i], &sp54); + } + func_800BF7CC(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); +} + +void func_808D8FC4(EnSw* this, GlobalContext* globalCtx) { + Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.world.pos); + this->collider.dim.worldSphere.radius = this->collider.dim.modelSphere.radius * this->collider.dim.scale; + if (!(this->unk_410 & 0x10) && (this->actor.colChkInfo.health != 0) && (DECR(this->unk_458) <= 10)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (!(this->unk_410 & 0x10) && (this->actor.colChkInfo.health != 0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->unk_410 & 4) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 func_808D90C4(EnSw* this) { + if (this->actor.colChkInfo.damage < this->actor.colChkInfo.health) { + this->actor.colChkInfo.health -= this->actor.colChkInfo.damage; + } else { + this->actor.colChkInfo.health = 0; + } + return this->actor.colChkInfo.health; +} + +void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { + Vec3f sp2C; + s16 sp2A; + s16 temp; + + if (arg1 == 1) { + sp2A = this->unk_494; + Math_ApproachS(&this->unk_494, this->unk_496, 4, 0xE38); + temp = this->unk_494 - sp2A; + } else { + temp = arg2; + } + + SysMatrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); + SysMatrix_MultiplyVector3fByState(&this->unk_350, &sp2C); + Math_Vec3f_Copy(&this->unk_350, &sp2C); + Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); +} + +s32 func_808D91C4(EnSw* this, CollisionPoly* arg1) { + f32 sp4C; + f32 temp_f12; + f32 temp_f0; + Vec3f sp38; + Vec3f sp2C; + + this->actor.floorPoly = arg1; + if (arg1 != 0) { + sp38.x = COLPOLY_GET_NORMAL(arg1->normal.x); + sp38.y = COLPOLY_GET_NORMAL(arg1->normal.y); + sp38.z = COLPOLY_GET_NORMAL(arg1->normal.z); + } else { + return false; + } + + temp_f12 = DOTXYZ(sp38, this->unk_368); + if (fabsf(temp_f12) >= 0.999f) { + return false; + } + + sp4C = func_80086C48(temp_f12); + if (sp4C < 0.001f) { + return false; + } + + Math3D_CrossProduct(&this->unk_368, &sp38, &sp2C); + temp_f0 = Math3D_Vec3fMagnitude(&sp2C); + if (temp_f0 < 0.001f) { + return false; + } + + Math_Vec3f_Scale(&sp2C, 1.0f / temp_f0); + SysMatrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); + SysMatrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); + Math_Vec3f_Copy(&this->unk_35C, &sp2C); + Math3D_CrossProduct(&this->unk_35C, &sp38, &this->unk_350); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_350); + if (temp_f0 < 0.001f) { + return false; + } + + Math_Vec3f_Scale(&this->unk_350, 1.0f / temp_f0); + Math_Vec3f_Copy(&this->unk_368, &sp38); + + return true; +} + +void func_808D93BC(EnSw* this) { + MtxF sp18; + + sp18.xx = this->unk_35C.x; + sp18.xy = this->unk_35C.y; + sp18.xz = this->unk_35C.z; + sp18.yx = this->unk_368.x; + sp18.yy = this->unk_368.y; + sp18.yz = this->unk_368.z; + sp18.zx = this->unk_350.x; + sp18.zy = this->unk_350.y; + sp18.zz = this->unk_350.z; + func_8018219C(&sp18, &this->actor.world.rot, 0); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +s32 func_808D9440(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, u32* arg5) { + s32 ret = false; + + if (func_800C55C4(&globalCtx->colCtx, arg1, arg2, arg3, arg4, 1, 1, 1, 1, arg5) && + !(func_800C9A4C(&globalCtx->colCtx, *arg4, *arg5) & 0x30)) { + ret = true; + } + return ret; +} + +#ifdef NON_MATCHING +void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4) { + CollisionPoly* spA4; + CollisionPoly* spA0; + s32 pad; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + u32 sp68; + u32 sp64; + s32 pad2; + f32 temp_f20; + s32 i; + + spA4 = NULL; + spA0 = NULL; + sp68 = 50; + sp64 = 50; + func_808D90F0(this, arg3, arg4); + this->actor.speedXZ = this->unk_44C; + if (1) {} + temp_f20 = this->actor.speedXZ + this->actor.speedXZ; + + sp90.x = this->actor.world.pos.x + (this->unk_368.x * 2.0f); + sp90.y = this->actor.world.pos.y + (this->unk_368.y * 2.0f); + sp90.z = this->actor.world.pos.z + (this->unk_368.z * 2.0f); + + sp84.x = this->actor.world.pos.x - (this->unk_368.x * 4.0f); + sp84.y = this->actor.world.pos.y - (this->unk_368.y * 4.0f); + sp84.z = this->actor.world.pos.z - (this->unk_368.z * 4.0f); + + if (func_808D9440(globalCtx, &sp90, &sp84, &sp6C, &spA0, &sp68)) { + sp84.x = (this->unk_350.x * temp_f20) + sp90.x; + sp84.y = (this->unk_350.y * temp_f20) + sp90.y; + sp84.z = (this->unk_350.z * temp_f20) + sp90.z; + if (func_808D9440(globalCtx, &sp90, &sp84, &sp78, &spA4, &sp64)) { + func_808D91C4(this, spA4); + Math_Vec3f_Copy(&this->actor.world.pos, &sp78); + this->actor.floorBgId = sp64; + this->actor.speedXZ = 0.0f; + } else { + if (spA0 != this->actor.floorPoly) { + func_808D91C4(this, spA0); + } + Math_Vec3f_Copy(&this->actor.world.pos, &sp6C); + this->actor.floorBgId = sp68; + } + } else { + temp_f20 *= 3.0f; + this->actor.speedXZ = 0.0f; + Math_Vec3f_Copy(&sp90, &sp84); + + for (i = 0; i < 3; i++) { + if (i == 0) { + sp84.x = sp90.x - (this->unk_350.x * temp_f20); + sp84.y = sp90.y - (this->unk_350.y * temp_f20); + sp84.z = sp90.z - (this->unk_350.z * temp_f20); + } else if (i == 1) { + sp84.x = sp90.x + (this->unk_35C.x * temp_f20); + sp84.y = sp90.y + (this->unk_35C.y * temp_f20); + sp84.z = sp90.z + (this->unk_35C.z * temp_f20); + } else { + sp84.x = sp90.x - (this->unk_35C.x * temp_f20); + sp84.y = sp90.y - (this->unk_35C.y * temp_f20); + sp84.z = sp90.z - (this->unk_35C.z * temp_f20); + } + + if (func_808D9440(globalCtx, &sp90, &sp84, &sp78, &spA4, &sp64)) { + func_808D91C4(this, spA4); + Math_Vec3f_Copy(&this->actor.world.pos, &sp78); + this->actor.floorBgId = sp64; + break; + } + } + } + + func_808D93BC(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + if (this->actor.speedXZ != 0.0f) { + this->unk_44C = this->actor.speedXZ; + } + + if (arg2 == 1) { + Actor_SetVelocityAndMoveXYRotation(&this->actor); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif -extern ColliderSphereInit D_808DB9E0; -extern CollisionCheckInfoInit2 D_808DBA0C; -extern DamageTable D_808DBA18; -extern CollisionCheckInfoInit2 D_808DBA38; -extern DamageTable D_808DBA44; +void func_808D9894(EnSw* this, Vec3f* vec) { + Vec3f sp5C; + MtxF sp1C; -extern UNK_TYPE D_06004788; -extern UNK_TYPE D_06005298; + sp1C.xx = this->unk_35C.x; + sp1C.yx = this->unk_35C.y; + sp1C.zx = this->unk_35C.z; + sp1C.wx = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D8940.s") + sp1C.xy = this->unk_368.x; + sp1C.yy = this->unk_368.y; + sp1C.zy = this->unk_368.z; + sp1C.wy = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D8B58.s") + sp1C.xz = this->unk_350.x; + sp1C.yz = this->unk_350.y; + sp1C.zz = this->unk_350.z; + sp1C.wz = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D8D60.s") + sp1C.xw = 0.0f; + sp1C.yw = 0.0f; + sp1C.zw = 0.0f; + sp1C.ww = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D8ED0.s") + SysMatrix_SetCurrentState(&sp1C); + sp5C.x = vec->x - this->actor.world.pos.x; + sp5C.y = vec->y - this->actor.world.pos.y; + sp5C.z = vec->z - this->actor.world.pos.z; + SysMatrix_MultiplyVector3fByState(&sp5C, vec); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D8FC4.s") +s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { + s32 ret = false; + u8 param = ENSW_GET_3FC(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D90C4.s") + if (ENSW_GET_3(&this->actor)) { + if ((param != 0x3F) && Actor_GetChestFlag(globalCtx, param)) { + ret = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D90F0.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D91C4.s") +s32 func_808D99C8(EnSw* this, GlobalContext* globalCtx) { + s32 phi_v1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D93BC.s") + if (ENSW_GET_3(&this->actor) || (this->unk_458 > 10) || (this->actor.colChkInfo.health == 0)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9440.s") + if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (globalCtx->actorCtx.unk1F5 != 0) && + (globalCtx->actorCtx.unk1F4 == 0)) { + this->actor.colChkInfo.damage = 4; + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9894.s") +s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { + s16 sp2E = 0; + f32 frame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9968.s") + if (DECR(this->unk_454) == 0) { + if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + frame = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + sp2E = (80.0f * frame) * this->unk_450; + } else { + if (this->unk_456 != 0) { + if (!ENSW_GET_3(&this->actor)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + } + this->unk_456--; + this->skelAnime.animCurrentFrame = 0.0f; + } else { + this->unk_454 = Rand_S16Offset(20, 20); + this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D99C8.s") + if (this->unk_456 % 2) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_450 = -1.0f; + } else { + this->unk_450 = 1.0f; + } + } + } + func_808D94D0(this, globalCtx, 0, 0, sp2E); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9A70.s") + return false; +} +#ifdef NON_MATCHING +s32 func_808D9C18(EnSw* this) { + Vec3f sp3C; + Vec3f sp30; + + if ((this->unk_498 == 0xF9) || (this->unk_498 == 0x82) || (this->unk_498 == 0xE4) || (this->unk_498 == 0xE5)) { + this->actor.velocity.x = this->actor.speedXZ; + this->actor.velocity.z = this->actor.speedXZ; + this->actor.velocity.x *= Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z *= Math_CosS(this->actor.world.rot.y); + } else { + this->actor.velocity.x = (this->actor.speedXZ * this->unk_350.x) + (this->actor.speedXZ * this->unk_368.x); + this->actor.velocity.y = 14.0f; + this->actor.velocity.z = (this->actor.speedXZ * this->unk_350.z) + (this->actor.speedXZ * this->unk_368.z); + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + sp30.x += this->actor.velocity.x; + sp30.y += this->actor.velocity.y; + sp30.z += this->actor.velocity.z; + this->actor.world.rot.x = 0; + this->actor.world.rot.z = 0; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); + } + + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_APPEAR); + + if (ENSW_GET_3(&this->actor) == 1) { + Actor_SetScale(&this->actor, 0.0f); + this->actor.world.rot.x = 0; + this->actor.world.rot.z = 0; + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->unk_410 |= 4; + } + + this->actor.gravity = -1.4f; + this->actor.parent = NULL; + return false; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9C18.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9DA0.s") +void func_808D9DA0(EnSw* this) { + static Vec3f D_808DBAAC = { 0.0f, 1.0f, 0.0f }; + s32 pad; + MtxF sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9E44.s") + SkinMatrix_SetRotateYRP(&sp24, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z); + SkinMatrix_Vec3fMtxFMultXYZ(&sp24, &D_808DBAAC, &this->unk_368); + this->unk_350.x = Math_SinS(this->actor.shape.rot.y); + this->unk_350.y = 0.0f; + this->unk_350.z = Math_CosS(this->actor.shape.rot.y); + this->unk_35C.x = Math_SinS(BINANG_ADD(this->actor.shape.rot.y, 0x4000)); + this->unk_35C.y = 0.0f; + this->unk_35C.z = Math_CosS(BINANG_ADD(this->actor.shape.rot.y, 0x4000)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9F08.s") +void func_808D9E44(EnSw* this) { + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9F78.s") + this->actor.shape.rot.z = -0x8000; + this->actor.shape.rot.x = 0; + this->actor.shape.rot.y = 0; + Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); + this->actor.gravity = -1.4f; + this->actor.velocity.y = 0.0f; + this->unk_456 = 2; + Math_Vec3f_Copy(&sp1C, &this->actor.world.pos); + sp1C.x += this->unk_368.x * 16.0f; + sp1C.y += this->unk_368.y * 16.0f; + sp1C.z += this->unk_368.z * 16.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA024.s") +void func_808D9F08(EnSw* this) { + this->unk_454 = Rand_S16Offset(20, 20); + this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; + this->unk_414 = 0.0f; + this->unk_45E = this->unk_460; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA08C.s") +void func_808D9F78(EnSw* this, GlobalContext* globalCtx, s32 arg2) { + if (arg2 != 0) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + } + Actor_SetScale(&this->actor, 0.02f); + func_808D9DA0(this); + this->actor.speedXZ = 10.0f; + this->unk_44C = 10.0f; + func_808D94D0(this, globalCtx, 0, 0, 0); + this->actor.speedXZ = 0.0f; + this->unk_44C = 0.0f; + this->unk_450 = 1.0f; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + this->unk_410 |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA350.s") +void func_808DA024(EnSw* this, GlobalContext* globalCtx) { + func_808D9DA0(this); + this->actor.speedXZ = 10.0f; + this->unk_44C = 10.0f; + func_808D94D0(this, globalCtx, 0, 0, 0); + this->actor.speedXZ = 0.0f; + this->unk_44C = 0.0f; + this->unk_450 = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA3F4.s") +s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { + s32 ret = 0; + s32 i; + if (func_808D99C8(this, globalCtx) || (this->collider.base.acFlags & AC_HIT)) { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.colChkInfo.damageEffect == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if (this->unk_412 == 10) { + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { this->unk_464[i] = 0; } + // clang-format on + + this->unk_45C = 0; + } else if (!func_808D90C4(this)) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->actor.flags &= ~1; + if (!ENSW_GET_3(&this->actor)) { + func_8013BC6C(&this->skelAnime, sAnimations, 3); + } + + switch (this->actor.colChkInfo.damageEffect) { + case 4: + this->unk_412 = 20; + this->unk_45C = 20; + func_808D8B58(this); + break; + + case 3: + this->unk_412 = 10; + this->unk_45C = 0; + func_808D8B58(this); + break; + + case 2: + this->unk_412 = 0; + this->unk_45C = 20; + func_808D8B58(this); + break; + + case 5: + this->unk_412 = 30; + this->unk_45C = 20; + func_808D8B58(this); + break; + + default: + this->unk_412 = 1; + this->unk_45C = 0; + break; + } + + if (!ENSW_GET_3(&this->actor) && (this->unk_412 != 10)) { + func_808D9E44(this); + } + this->unk_458 = 20; + this->unk_45A = 0; + func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + ret = true; + } else if (this->actor.colChkInfo.damageEffect == 1) { + if (this->unk_45A == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_45A = 40; + func_800BCB70(&this->actor, 0, 200, 0, this->unk_45A); + } + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DAMAGE); + this->unk_458 = 20; + this->unk_45A = 0; + func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + } + } + return ret; +} + +void func_808DA350(EnSw* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if ((player->stateFlags1 & 0x200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_LAUGH); + Math_Vec3f_Copy(&this->unk_374, &player->actor.world.pos); + this->unk_410 &= ~0x20; + this->unk_414 = 0.0f; + this->actionFunc = func_808DA3F4; + } else { + func_808D9A70(this, globalCtx); + } +} + +void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 temp_s1 = 0; + Vec3f sp38; + f32 temp_f16; + + if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + temp_f16 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + temp_s1 = (s16)(80.0f * temp_f16); + Math_Vec3f_Copy(&sp38, &this->unk_374); + func_808D9894(this, &sp38); + + temp_v0 = Math_FAtan2F(sp38.z, sp38.x); + if (ABS_ALT(temp_v0) < temp_s1) { + this->skelAnime.animCurrentFrame = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + this->unk_414 = 0.0f; + if (this->unk_410 & 0x20) { + this->actionFunc = func_808DA6FC; + } else { + this->actionFunc = func_808DA578; + } + temp_s1 = ABS_ALT(temp_v0); + } + temp_s1 *= (temp_v0 < 0) ? -1 : 1; + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + this->skelAnime.animCurrentFrame = 0.0f; + } + func_808D94D0(this, globalCtx, 0, 0, temp_s1); +} + +#ifdef NON_MATCHING +void func_808DA578(EnSw* this, GlobalContext* globalCtx) { + f32 temp_f0; + s32 test; + s32 test2; + Vec3f sp30; + + if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + temp_f0 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + this->unk_44C = 0.3f * temp_f0; + func_808D94D0(this, globalCtx, 1, 0, 0); + if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + Math_Vec3f_Copy(&sp30, &this->unk_374); + func_808D9894(this, &sp30); + func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp30.z, sp30.x)); + } + } else if (this->unk_410 & 0x20) { + Math_Vec3f_Copy(&this->unk_374, &this->actor.home.pos); + this->actionFunc = func_808DA3F4; + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + this->skelAnime.animCurrentFrame = 0.0f; + } + + temp_f0 = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); + if (!(this->unk_410 & 0x20)) { + test = this->unk_414; + test2 = temp_f0; + if ((test != 0) && (test < test2)) { + this->unk_410 |= 0x20; + } + } + this->unk_414 = temp_f0; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") +#endif +#ifdef NON_MATCHING +void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { + f32 sp4C; + s32 temp; + s32 temp2; + Vec3f sp38; + f32 temp_f0; + + if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + temp_f0 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + this->unk_44C = 0.14f * temp_f0; + func_808D94D0(this, globalCtx, 1, 0, 0); + if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + Math_Vec3f_Copy(&sp38, &this->unk_374); + func_808D9894(this, &sp38); + func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); + } + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + this->skelAnime.animCurrentFrame = 0.0f; + } + + sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); + temp = this->unk_414; + temp2 = sp4C; + if ((temp != 0) && (temp < temp2)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); + this->unk_454 = Rand_S16Offset(20, 20); + this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; + this->actionFunc = func_808DA350; + this->skelAnime.animCurrentFrame = 0.0f; + } + this->unk_414 = sp4C; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA89C.s") +void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { + if (this->unk_412 == 10) { + s32 i; + s32 count; + s16 phi_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DAA60.s") + for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { + if (this->unk_464[i] == 0) { + phi_a0 = 0; + } else { + this->unk_464[i]--; + phi_a0 = this->unk_464[i]; + } + if (phi_a0 == 0) { + count++; + } + } + if (count == ARRAY_COUNT(this->unk_464)) { + if (!ENSW_GET_3(&this->actor)) { + func_808D9E44(this); + } + this->unk_412 = 1; + func_808D8ED0(this, globalCtx); + } + return; + if (1) {} + } + + if (ENSW_GET_3(&this->actor)) { + this->actionFunc = func_808DAEB4; + return; + } + + if (this->actor.bgCheckFlags & 1) { + f32 temp_f2; + + this->actor.shape.yOffset = 400.0f; + temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.velocity.y = temp_f2; + this->unk_448 = temp_f2; + this->actor.speedXZ = 0.0f; + if ((s32)temp_f2 != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + } else { + this->actionFunc = func_808DAEB4; + this->actor.velocity.y = 0.0f; + } + if ((s32)this->actor.velocity.y >= 2) { + func_808D8940(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { + Vec3s* sp44; + s16 temp_v0; + s16 sp40; + Vec3f sp34; + f32 temp_f16; + + sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->unk_04); + sp40 = 0; + + if (DECR(this->unk_454) == 0) { + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) == 0) { + temp_f16 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + sp40 = 80.0f * temp_f16; + if (this->unk_45E == 0) { + Math_Vec3s_ToVec3f(&sp34, &sp44[this->unk_4A0]); + func_808D9894(this, &sp34); + temp_v0 = Math_FAtan2F(sp34.z, sp34.x); + if (ABS_ALT(temp_v0) < sp40) { + this->skelAnime.animCurrentFrame = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Math_Vec3s_ToVec3f(&this->unk_374, &sp44[this->unk_4A0]); + this->actionFunc = func_808DACF4; + this->unk_414 = 0.0f; + sp40 = ABS_ALT(temp_v0); + } + sp40 *= (temp_v0 < 0) ? -1 : 1; + } + } else { + if (this->unk_456 != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + this->unk_456--; + this->skelAnime.animCurrentFrame = 0.0f; + } else { + this->unk_454 = Rand_S16Offset(20, 20); + this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; + if (this->unk_45E != 0) { + this->unk_45E--; + } + } + + if (this->unk_456 % 2) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_450 = -1.0f; + } else { + this->unk_450 = 1.0f; + } + } + } + } + func_808D94D0(this, globalCtx, 0, 0, sp40); +} + +#ifdef NON_MATCHING +void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { + f32 sp4C; + f32 temp_f0; + s32 temp_f6; + + if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) == 0) { + Vec3f sp38; + f32 temp; + + temp = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + this->unk_44C = 0.1f * temp; + func_808D94D0(this, globalCtx, 1, 0, 0); + if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + + Math_Vec3f_Copy(&sp38, &this->unk_374); + func_808D9894(this, &sp38); + func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); + } + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + this->skelAnime.animCurrentFrame = 0.0f; + } + + sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); + temp_f6 = this->unk_414; + if ((temp_f6 != 0) && (temp_f6 < (s32)sp4C)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); + this->unk_4A0 += this->unk_49C; + if ((this->unk_4A0 >= this->unk_1E4->unk_00) || (this->unk_4A0 < 0)) { + this->unk_49C = -this->unk_49C; + this->unk_4A0 += this->unk_49C * 2; + } + + if (this->unk_410 & 8) { + func_808D9F08(this); + this->actionFunc = func_808DAA60; + } else { + this->actionFunc = func_808DB100; + } + } + this->unk_414 = sp4C; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") +#endif +#ifdef NON_MATCHING +void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { + Vec3f sp5C; + s32 i; + s32 count; + s16 phi_a0; + + if (this->unk_410 & 2) { + if (!ENSW_GET_3(&this->actor)) { + if ((this->unk_410 & 4) && (DECR(this->unk_45C) == 0)) { + this->unk_410 &= ~4; + } + + for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { + if (this->unk_464[i] == 0) { + phi_a0 = 0; + } else { + this->unk_464[i]--; + phi_a0 = this->unk_464[i]; + } + if (phi_a0 == 0) { + count++; + } + } + + if (count == ARRAY_COUNT(this->unk_464)) { + Actor_MarkForDeath(&this->actor); + } + } else { + Math_ApproachF(&this->actor.scale.x, 0.0f, 0.08f, 1.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + if ((s32)(this->actor.scale.x * 100.0f) == 0) { + + Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); + sp5C.x += this->unk_368.x * 10.0f; + sp5C.y += this->unk_368.y * 10.0f; + sp5C.z += this->unk_368.z * 10.0f; + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_SI, sp5C.x, sp5C.y, + sp5C.z, 0, 0, 0, this->actor.params) != NULL) { + play_sound(NA_SE_SY_KINSTA_MARK_APPEAR); + } + Actor_MarkForDeath(&this->actor); + } + func_808D94D0(this, globalCtx, 0, 0, 0x1554); + } + } else if (DECR(this->unk_45C) == 0) { + this->unk_410 |= 2; + if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + func_808D8B58(this); + this->unk_45C = 10; + } else { + this->unk_45C = 20; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DAEB4.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DB100.s") +void func_808DB100(EnSw* this, GlobalContext* globalCtx) { + if (this->actor.parent != NULL) { + this->unk_498 = this->actor.parent->id; + this->unk_456 = 0; + this->unk_454 = 0; + this->skelAnime.animCurrentFrame = 0.0f; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 4); + this->actionFunc = func_808DB25C; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DB25C.s") + if (!(this->unk_410 & 1)) { + func_808D9A70(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DB2E0.s") + if ((DECR(this->unk_454) == 0) && func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (this->unk_456 != 0) { + if (!ENSW_GET_3(&this->actor)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + } + this->unk_456--; + this->skelAnime.animCurrentFrame = 0.0f; + } else { + this->unk_454 = Rand_S16Offset(20, 20); + this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/EnSw_Init.s") +void func_808DB25C(EnSw* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_808D9C18(this); + this->actionFunc = func_808DB2E0; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/EnSw_Destroy.s") +void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/EnSw_Update.s") + if (this->actor.bgCheckFlags & 1) { + func_808D9F78(this, globalCtx, 0); + temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.velocity.x *= 0.5f; + this->actor.velocity.y = temp_f2; + this->unk_448 = temp_f2; + this->actor.velocity.z *= 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DB7F4.s") + if ((s32)temp_f2 != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + } else { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + Math_Vec3f_Copy(&this->actor.velocity, &D_801D15B0); + this->unk_410 &= ~(0x10 | 0x1); + this->actionFunc = func_808DB100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/EnSw_Draw.s") + if ((s32)this->actor.velocity.y >= 2) { + func_808D8940(this, globalCtx); + } + } + + Math_ApproachF(&this->actor.scale.x, 0.02f, 0.4f, 1.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + this->actor.velocity.y += this->actor.gravity; + Actor_ApplyMovement(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSw* this = THIS; + s32 pad; + + if (!func_808D9968(this, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06005298, NULL, this->jointTable, this->morphTable, 30); + func_8013BC6C(&this->skelAnime, sAnimations, 0); + this->skelAnime.animPlaybackSpeed = 4.0f; + + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + if (!ENSW_GET_3(&this->actor)) { + this->actor.hintId = 0x1F; + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->collider.info.toucher.damage = 8; + } else { + this->actor.hintId = 0x20; + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit2); + this->collider.info.toucher.damage = 16; + } + + this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + if (this->unk_1E4 != NULL) { + this->unk_4A0 = 1; + } + + switch (ENSW_GET_3(&this->actor)) { + case 0: + func_808D9F78(this, globalCtx, 1); + this->actionFunc = func_808DA350; + break; + + case 1: + this->actor.flags &= ~1; + this->actor.flags |= 0x10; + + if (this->actor.world.rot.z < 0) { + this->unk_460 = -thisx->world.rot.z; + } else { + this->unk_460 = thisx->world.rot.z; + } + + if (this->actor.world.rot.z >= 0) { + this->unk_410 |= 8; + } + + func_808DA024(this, globalCtx); + this->unk_410 |= (0x10 | 0x1); + this->unk_410 &= ~4; + this->actionFunc = func_808DB100; + break; + + case 2: + case 3: + this->actor.flags &= ~1; + this->actor.flags |= 0x10; + + if (this->actor.world.rot.z < 0) { + this->unk_460 = -thisx->world.rot.z; + } else { + this->unk_460 = thisx->world.rot.z; + } + + if (this->actor.world.rot.z >= 0) { + this->unk_410 |= 8; + } + + func_808D9F78(this, globalCtx, 1); + if (this->unk_1E4 != NULL) { + this->unk_49C = 1; + func_808D9F08(this); + this->actionFunc = func_808DAA60; + } else { + this->actionFunc = func_808DB100; + } + break; + } + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSw* this = THIS; + + Collider_DestroySphere(globalCtx, &this->collider); +} + +void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSw* this = THIS; + + if (func_808DA08C(this, globalCtx)) { + this->actionFunc = func_808DA89C; + } else if (DECR(this->unk_45A) == 0) { + this->actionFunc(this, globalCtx); + } + + if ((this->unk_412 != 10) || (this->unk_45A != 0)) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + } + + Actor_SetHeight(&this->actor, 0.0f); + func_808D8FC4(this, globalCtx); +} + +s32 EnSw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnSw* this = THIS; + + if (ENSW_GET_3(&this->actor)) { + switch (limbIndex) { + case 23: + *dList = D_06004788; + break; + + case 8: + *dList = D_060046F0; + break; + + case 14: + *dList = D_06004658; + break; + + case 11: + *dList = D_060045C0; + break; + + case 26: + *dList = D_06004820; + break; + + case 20: + *dList = D_060048B8; + break; + + case 17: + *dList = D_06004950; + break; + + case 29: + *dList = D_060049E8; + break; + + case 5: + *dList = D_06003FB0; + break; + + case 4: + *dList = D_060043D8; + break; + } + } + return false; +} + +void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSw* this = THIS; + s32 i; + s32 count; + + if (this->unk_410 & 4) { + if (ENSW_GET_3(&this->actor)) { + func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); + } + func_8012C28C(globalCtx->state.gfxCtx); + SysMatrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnSw_OverrideLimbDraw, NULL, + &this->actor); + } + + for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { + count += func_808D8D60(this, globalCtx, i); + } + + if (count != 0) { + this->unk_462 += 3; + } +} diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index e6d240569..b64b6d02a 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -7,11 +7,50 @@ struct EnSw; typedef void (*EnSwActionFunc)(struct EnSw*, GlobalContext*); +#define ENSW_GET_3(thisx) (((thisx)->params & 3) & 0xFF) +#define ENSW_GET_3FC(thisx) (((thisx)->params & 0x3FC) >> 2) +#define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) + +typedef struct { + u8 unk_00; + s32 unk_04; +} EnSwUnkStruct; + typedef struct EnSw { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnSwActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x318]; + /* 0x018C */ ColliderSphere collider; + /* 0x01E4 */ EnSwUnkStruct* unk_1E4; + /* 0x01E8 */ Vec3s jointTable[30]; + /* 0x029C */ Vec3s morphTable[30]; + /* 0x0350 */ Vec3f unk_350; + /* 0x035C */ Vec3f unk_35C; + /* 0x0368 */ Vec3f unk_368; + /* 0x0374 */ Vec3f unk_374; + /* 0x0380 */ Vec3f unk_380[12]; + /* 0x0410 */ u16 unk_410; + /* 0x0412 */ u8 unk_412; + /* 0x0414 */ f32 unk_414; + /* 0x0418 */ f32 unk_418[12]; + /* 0x0448 */ f32 unk_448; + /* 0x044C */ f32 unk_44C; + /* 0x0450 */ f32 unk_450; + /* 0x0454 */ s16 unk_454; + /* 0x0456 */ s16 unk_456; + /* 0x0458 */ s16 unk_458; + /* 0x045A */ s16 unk_45A; + /* 0x045C */ s16 unk_45C; + /* 0x045E */ s16 unk_45E; + /* 0x0460 */ s16 unk_460; + /* 0x0462 */ s16 unk_462; + /* 0x0464 */ s16 unk_464[12]; + /* 0x047C */ s16 unk_47C[12]; + /* 0x0494 */ s16 unk_494; + /* 0x0496 */ s16 unk_496; + /* 0x0468 */ s16 unk_498; + /* 0x049C */ s32 unk_49C; + /* 0x04A0 */ s32 unk_4A0; } EnSw; // size = 0x4A4 extern const ActorInit En_Sw_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 191840f32..11ec5164b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6457,7 +6457,7 @@ 0x808DB454:("EnSw_Init",), 0x808DB70C:("EnSw_Destroy",), 0x808DB738:("EnSw_Update",), - 0x808DB7F4:("func_808DB7F4",), + 0x808DB7F4:("EnSw_OverrideLimbDraw",), 0x808DB8DC:("EnSw_Draw",), 0x808DBE80:("ObjectKankyo_SetupAction",), 0x808DBE8C:("func_808DBE8C",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ad8f975be..0f47ec3a7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3471,6 +3471,9 @@ D_060048B8 = 0x060048B8; D_06004950 = 0x06004950; D_060049E8 = 0x060049E8; D_06005298 = 0x06005298; +D_06000304 = 0x06000304; +D_060055A8 = 0x060055A8; +D_06005B98 = 0x06005B98; // ovl_En_Syateki_Crow From d061f1c66653e0b35c3d2e8bd15ffdf5bf783877 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 11 Oct 2021 18:21:26 +0000 Subject: [PATCH 32/86] ovl_En_Elfbub OK (#340) * ovl_En_Elfbub matching * Address initial PR comments * Rename iterator variable to something more descriptive * Address further PR comments --- spec | 3 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 147 ++++++++++++++++-- .../actors/ovl_En_Elfbub/z_en_elfbub.h | 10 +- 3 files changed, 143 insertions(+), 17 deletions(-) diff --git a/spec b/spec index 8a587b0c0..158cca371 100644 --- a/spec +++ b/spec @@ -3595,8 +3595,7 @@ beginseg name "ovl_En_Elfbub" compress include "build/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.o" - include "build/data/ovl_En_Elfbub/ovl_En_Elfbub.data.o" - include "build/data/ovl_En_Elfbub/ovl_En_Elfbub.reloc.o" + include "build/src/overlays/actors/ovl_En_Elfbub/ovl_En_Elfbub_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 954e5fa06..7d492ac1d 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -1,3 +1,9 @@ +/* + * File: z_en_elfbub.c + * Overlay: ovl_En_Elfbub + * Description: Stray fairy in bubble + */ + #include "z_en_elfbub.h" #define FLAGS 0x00000001 @@ -9,7 +15,9 @@ void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx); void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx); +void EnElfbub_Idle(EnElfbub* this, GlobalContext* globalCtx); + const ActorInit En_Elfbub_InitVars = { ACTOR_EN_ELFBUB, ACTORCAT_MISC, @@ -22,27 +30,138 @@ const ActorInit En_Elfbub_InitVars = { (ActorFunc)EnElfbub_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ACE270 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 16, 32, 0, { 0, 0, 0 } }, }; -#endif +extern Gfx D_06001000[]; -extern ColliderCylinderInit D_80ACE270; +void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { + EnElfbub* this = THIS; + Actor* childActor; -extern UNK_TYPE D_06001000; + if (Flags_GetSwitch(globalCtx, ENELFBUB_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/EnElfbub_Init.s") + ActorShape_Init(&this->actor.shape, 16.0f, func_800B3FC0, 0.2f); + this->actor.hintId = 0x16; + Actor_SetScale(&this->actor, 1.25f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/EnElfbub_Destroy.s") + this->actionFunc = EnElfbub_Idle; + this->zRot = randPlusMinusPoint5Scaled(0x10000); + this->zRotDelta = 1000; + this->xScale = 0.08f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/func_80ACDE60.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/func_80ACE030.s") + childActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELFORG, + this->actor.world.pos.x, this->actor.world.pos.y + 12.0f, this->actor.world.pos.z, + this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, + ((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | 2); + if (childActor != NULL) { + childActor->parent = &this->actor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/EnElfbub_Update.s") + this->oscillationAngle = 0; + this->actor.flags &= ~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfbub/EnElfbub_Draw.s") +void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnElfbub* this = THIS; + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx) { + static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEnvColor = { 150, 150, 150, 0 }; + static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; + s32 effectCounter; + Vec3f velocity; + Vec3f pos; + + Math_SmoothStepToF(&this->xyScale, 3.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->xScale, 0.2f, 0.1f, 1000.0f, 0.0f); + this->zRotDelta += 1000; + this->zRot += this->zRotDelta; + this->popTimer--; + if (this->popTimer <= 0) { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z; + + for (effectCounter = 0; effectCounter < 20; effectCounter++) { + velocity.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + velocity.y = Rand_ZeroOne() * 7.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &pos, &velocity, &sAccel, &sPrimColor, &sEnvColor, + Rand_S16Offset(100, 50), 25, 0); + } + + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + Actor_MarkForDeath(&this->actor); + } +} + +void EnElfbub_Idle(EnElfbub* this, GlobalContext* globalCtx) { + s32 pad; + + this->zRot += this->zRotDelta; + this->actor.world.pos.y += Math_SinS(this->oscillationAngle); + this->oscillationAngle += 0x200; + + if (this->collider.base.acFlags & AC_HIT || this->collider.base.ocFlags1 & OC1_HIT) { + this->actionFunc = EnElfbub_Pop; + this->popTimer = 6; + return; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElfbub* this = THIS; + Collider_UpdateCylinder(&this->actor, &this->collider); + this->actionFunc(this, globalCtx); + Actor_SetHeight(&this->actor, this->actor.shape.yOffset); +} + +void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnElfbub* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + SysMatrix_InsertTranslation(0.0f, 0.0f, 1.0f, 1); + SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, 1); + SysMatrix_InsertZRotation_s(this->zRot, 1); + Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, 1); + SysMatrix_InsertZRotation_s(this->zRot * -1, 1); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_06001000); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h index 47151cf6f..62a4b69a6 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h @@ -3,13 +3,21 @@ #include "global.h" +#define ENELFBUB_GET_SWITCHFLAG(thisx) ((((thisx)->params) & 0xFE00) >> 9) + struct EnElfbub; typedef void (*EnElfbubActionFunc)(struct EnElfbub*, GlobalContext*); typedef struct EnElfbub { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ s16 zRot; + /* 0x0192 */ s16 zRotDelta; + /* 0x0194 */ s16 oscillationAngle; + /* 0x0196 */ s16 popTimer; + /* 0x0198 */ f32 xScale; + /* 0x019C */ f32 xyScale; /* 0x01A0 */ EnElfbubActionFunc actionFunc; } EnElfbub; // size = 0x1A4 From 565b1f7579876e08f2898fe07549cb348a222e93 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Mon, 11 Oct 2021 19:28:16 +0100 Subject: [PATCH 33/86] `flg_set.c` OK and documented (#335) * Draw OK, Update very much not * Flag table imported * Update OK * Actually OK this time * Begin documenting * Rename some stuff * Rename functions * spec * Review * Format * Anghelo's review * Fix lifemeter bss * Format * Missed one * idle.c bss --- include/functions.h | 40 ++--- include/variables.h | 8 +- include/z64.h | 5 + include/z64save.h | 5 +- spec | 3 +- src/boot_O2/gfxprint.c | 11 +- src/boot_O2/printutils.c | 11 +- src/boot_O2_g3/idle.c | 1 + src/code/flg_set.c | 313 ++++++++++++++++++++++++++++++++- src/code/pad_801DC9C0.c | 1 + tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 8 +- tools/sizes/code_functions.csv | 4 +- 13 files changed, 366 insertions(+), 48 deletions(-) create mode 100644 src/code/pad_801DC9C0.c diff --git a/include/functions.h b/include/functions.h index 27066008c..006179be6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -139,22 +139,22 @@ void StackCheck_Cleanup(StackEntry* entry); StackStatus StackCheck_GetState(StackEntry* entry); u32 StackCheck_CheckAll(void); u32 StackCheck_Check(StackEntry* entry); -void GfxPrint_InitDlist(GfxPrint*); -void GfxPrint_SetColor(GfxPrint*, u32, u32, u32, u32); -void GfxPrint_SetPosPx(GfxPrint*, s32, s32); -void GfxPrint_SetPos(GfxPrint*, s32, s32); -void GfxPrint_SetBasePosPx(GfxPrint* this, s32 param_2, s32 param_3); -void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c); -void GfxPrint_PrintChar(GfxPrint* this, u8 c); -void GfxPrint_PrintStringWithSize(GfxPrint*, const void*, size_t, size_t); -void GfxPrint_PrintString(GfxPrint*, const char*); -GfxPrint* GfxPrint_Callback(GfxPrint*, const char*, size_t); -void GfxPrint_Init(GfxPrint*); -void GfxPrint_Destroy(GfxPrint*); -void GfxPrint_Open(GfxPrint*, Gfx*); -Gfx* GfxPrint_Close(GfxPrint*); -void GfxPrint_VPrintf(GfxPrint*, const char*, va_list); -void GfxPrint_Printf(GfxPrint*, const char*, ...); +void GfxPrint_InitDlist(GfxPrint* printer); +void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a); +void GfxPrint_SetPosPx(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_SetBasePosPx(GfxPrint* printer, s32 x, s32 y); +void GfxPrint_PrintCharImpl(GfxPrint* printer, u8 c); +void GfxPrint_PrintChar(GfxPrint* printer, u8 c); +void GfxPrint_PrintStringWithSize(GfxPrint* printer, const void* buffer, size_t charSize, size_t charCount); +void GfxPrint_PrintString(GfxPrint* printer, const char* str); +GfxPrint* GfxPrint_Callback(GfxPrint* printer, const char* str, size_t size); +void GfxPrint_Init(GfxPrint* printer); +void GfxPrint_Destroy(GfxPrint* printer); +void GfxPrint_Open(GfxPrint* printer, Gfx* dList); +Gfx* GfxPrint_Close(GfxPrint* printer); +s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); +s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); // void MtxConv_F2L(void); // void MtxConv_L2F(void); void __assert(const char* file, u32 lineNum); @@ -236,8 +236,8 @@ u32 __osCheckArena(Arena* heap); void* proutSprintf(void* s, const char* buf, size_t n); s32 vsprintf(char* dst, char* fmt, va_list args); s32 sprintf(char* s, char* fmt, ...); -void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); -void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); +s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); +s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); void Sleep_Cycles(OSTime time); // void Sleep_Nsec(void); void Sleep_Usec(s32); @@ -681,8 +681,8 @@ void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* // void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); // void EffectSsIceBlock_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5); -void func_800B32D0(GameState* gamestate); -// void func_800B3644(void); +void FlagSet_Update(GameState* gamestate); +void FlagSet_Draw(GameState* gameState); void DLF_LoadGameState(GameStateOverlay* gameState); void DLF_FreeGameState(GameStateOverlay* gameState); void Actor_PrintLists(ActorContext* actorCtx); diff --git a/include/variables.h b/include/variables.h index b3aa0a602..eddb73875 100644 --- a/include/variables.h +++ b/include/variables.h @@ -418,10 +418,10 @@ extern EffectSsInfo EffectSS2Info; // extern UNK_TYPE1 D_801AE48C; // extern UNK_TYPE1 D_801AE490; extern EffectSsOverlay particleOverlayTable[39]; -extern UNK_PTR D_801AE8F0; -// extern UNK_TYPE4 D_801AEC70; -// extern UNK_TYPE4 D_801AEC74; -// extern UNK_TYPE4 D_801AEC78; +// extern FlagSetEntry sFlagEntries[]; +// extern s32 sEntryIndex; +// extern u32 sCurrentBit; +// extern s32 sTimer; extern Color_RGBA8 D_801AEC80; extern s801AEC84 D_801AEC84[13]; extern f32 actorMovementScale; diff --git a/include/z64.h b/include/z64.h index 3d61fe5ea..2b1badfd4 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1777,4 +1777,9 @@ typedef struct { /* 0x20 */ u16 fracPart[4][4]; } MatrixInternal; // size = 0x40 +typedef struct { + /* 0x00 */ u8* value; + /* 0x04 */ const char* name; +} FlagSetEntry; // size = 0x08 + #endif diff --git a/include/z64save.h b/include/z64save.h index d701d0a42..a1ec72ab9 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -175,8 +175,9 @@ typedef struct { /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" /* 0x3F68 */ u32 unk_3F68[5][120]; - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" - /* 0x48CA */ u8 unk_48CA[27]; + /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon + /* 0x48CD */ char unk_48CD[24]; } SaveContext; // size = 0x48C8 typedef enum { diff --git a/spec b/spec index 158cca371..9412e3b28 100644 --- a/spec +++ b/spec @@ -448,9 +448,8 @@ beginseg include "build/data/code/z_effect_soft_sprite.data.o" include "build/src/code/z_effect_soft_sprite_old_init.o" include "build/data/code/z_effect_soft_sprite_old_init.data.o" - include "build/data/code/flg_set_table.data.o" include "build/src/code/flg_set.o" - include "build/data/code/flg_set.data.o" + include "build/src/code/pad_801DC9C0.o" include "build/src/code/z_DLF.o" include "build/src/code/z_actor.o" include "build/data/code/z_actor.data.o" diff --git a/src/boot_O2/gfxprint.c b/src/boot_O2/gfxprint.c index f65d88200..a6f84a7a4 100644 --- a/src/boot_O2/gfxprint.c +++ b/src/boot_O2/gfxprint.c @@ -171,15 +171,18 @@ Gfx* GfxPrint_Close(GfxPrint* this) { return ret; } -void GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { - PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args); +s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { + return PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args); } -void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { +s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { + s32 ret; va_list args; va_start(args, fmt); - GfxPrint_VPrintf(this, fmt, args); + ret = GfxPrint_VPrintf(this, fmt, args); va_end(args); + + return ret; } diff --git a/src/boot_O2/printutils.c b/src/boot_O2/printutils.c index ca62b91b7..3fb8cf367 100644 --- a/src/boot_O2/printutils.c +++ b/src/boot_O2/printutils.c @@ -1,14 +1,17 @@ #include "global.h" -void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args) { - _Printf(*pfn, pfn, fmt, args); +s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args) { + return _Printf(*pfn, pfn, fmt, args); } -void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) { +s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) { + s32 ret; va_list args; va_start(args, fmt); - PrintUtils_VPrintf(pfn, fmt, args); + ret = PrintUtils_VPrintf(pfn, fmt, args); va_end(args); + + return ret; } diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 4be8a1094..f2cded98c 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/flg_set.c b/src/code/flg_set.c index b46433a70..490472d20 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -1,9 +1,314 @@ +/** + * File: flg_set.c + * Description: Event Editor, used to view and edit weekEventReg, eventInf and maskMaskBit flags. + * Controls: + * + Left and Right: select different flags/bits in array element + * + Up and Down: select array element (byte) 1 up/down + * C Up and Down: select array element (byte) 10 up/down + * A: toggle flag + * B: exit + * Hold Start and press B: clear all weekEventReg and eventInf flags + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/flg_set/func_800B32D0.s") +static FlagSetEntry sFlagEntries[] = { + { &gSaveContext.weekEventReg[0], "week_event_reg[0]" }, + { &gSaveContext.weekEventReg[1], "week_event_reg[1]" }, + { &gSaveContext.weekEventReg[2], "week_event_reg[2]" }, + { &gSaveContext.weekEventReg[3], "week_event_reg[3]" }, + { &gSaveContext.weekEventReg[4], "week_event_reg[4]" }, + { &gSaveContext.weekEventReg[5], "week_event_reg[5]" }, + { &gSaveContext.weekEventReg[6], "week_event_reg[6]" }, + { &gSaveContext.weekEventReg[7], "week_event_reg[7]" }, + { &gSaveContext.weekEventReg[8], "week_event_reg[8]" }, + { &gSaveContext.weekEventReg[9], "week_event_reg[9]" }, + { &gSaveContext.weekEventReg[10], "week_event_reg[10]" }, + { &gSaveContext.weekEventReg[11], "week_event_reg[11]" }, + { &gSaveContext.weekEventReg[12], "week_event_reg[12]" }, + { &gSaveContext.weekEventReg[13], "week_event_reg[13]" }, + { &gSaveContext.weekEventReg[14], "week_event_reg[14]" }, + { &gSaveContext.weekEventReg[15], "week_event_reg[15]" }, + { &gSaveContext.weekEventReg[16], "week_event_reg[16]" }, + { &gSaveContext.weekEventReg[17], "week_event_reg[17]" }, + { &gSaveContext.weekEventReg[18], "week_event_reg[18]" }, + { &gSaveContext.weekEventReg[19], "week_event_reg[19]" }, + { &gSaveContext.weekEventReg[20], "week_event_reg[20]" }, + { &gSaveContext.weekEventReg[21], "week_event_reg[21]" }, + { &gSaveContext.weekEventReg[22], "week_event_reg[22]" }, + { &gSaveContext.weekEventReg[23], "week_event_reg[23]" }, + { &gSaveContext.weekEventReg[24], "week_event_reg[24]" }, + { &gSaveContext.weekEventReg[25], "week_event_reg[25]" }, + { &gSaveContext.weekEventReg[26], "week_event_reg[26]" }, + { &gSaveContext.weekEventReg[27], "week_event_reg[27]" }, + { &gSaveContext.weekEventReg[28], "week_event_reg[28]" }, + { &gSaveContext.weekEventReg[29], "week_event_reg[29]" }, + { &gSaveContext.weekEventReg[30], "week_event_reg[30]" }, + { &gSaveContext.weekEventReg[31], "week_event_reg[31]" }, + { &gSaveContext.weekEventReg[32], "week_event_reg[32]" }, + { &gSaveContext.weekEventReg[33], "week_event_reg[33]" }, + { &gSaveContext.weekEventReg[34], "week_event_reg[34]" }, + { &gSaveContext.weekEventReg[35], "week_event_reg[35]" }, + { &gSaveContext.weekEventReg[36], "week_event_reg[36]" }, + { &gSaveContext.weekEventReg[37], "week_event_reg[37]" }, + { &gSaveContext.weekEventReg[38], "week_event_reg[38]" }, + { &gSaveContext.weekEventReg[39], "week_event_reg[39]" }, + { &gSaveContext.weekEventReg[40], "week_event_reg[40]" }, + { &gSaveContext.weekEventReg[41], "week_event_reg[41]" }, + { &gSaveContext.weekEventReg[42], "week_event_reg[42]" }, + { &gSaveContext.weekEventReg[43], "week_event_reg[43]" }, + { &gSaveContext.weekEventReg[44], "week_event_reg[44]" }, + { &gSaveContext.weekEventReg[45], "week_event_reg[45]" }, + { &gSaveContext.weekEventReg[46], "week_event_reg[46]" }, + { &gSaveContext.weekEventReg[47], "week_event_reg[47]" }, + { &gSaveContext.weekEventReg[48], "week_event_reg[48]" }, + { &gSaveContext.weekEventReg[49], "week_event_reg[49]" }, + { &gSaveContext.weekEventReg[50], "week_event_reg[50]" }, + { &gSaveContext.weekEventReg[51], "week_event_reg[51]" }, + { &gSaveContext.weekEventReg[52], "week_event_reg[52]" }, + { &gSaveContext.weekEventReg[53], "week_event_reg[53]" }, + { &gSaveContext.weekEventReg[54], "week_event_reg[54]" }, + { &gSaveContext.weekEventReg[55], "week_event_reg[55]" }, + { &gSaveContext.weekEventReg[56], "week_event_reg[56]" }, + { &gSaveContext.weekEventReg[57], "week_event_reg[57]" }, + { &gSaveContext.weekEventReg[58], "week_event_reg[58]" }, + { &gSaveContext.weekEventReg[59], "week_event_reg[59]" }, + { &gSaveContext.weekEventReg[60], "week_event_reg[60]" }, + { &gSaveContext.weekEventReg[61], "week_event_reg[61]" }, + { &gSaveContext.weekEventReg[62], "week_event_reg[62]" }, + { &gSaveContext.weekEventReg[63], "week_event_reg[63]" }, + { &gSaveContext.weekEventReg[64], "week_event_reg[64]" }, + { &gSaveContext.weekEventReg[65], "week_event_reg[65]" }, + { &gSaveContext.weekEventReg[66], "week_event_reg[66]" }, + { &gSaveContext.weekEventReg[67], "week_event_reg[67]" }, + { &gSaveContext.weekEventReg[68], "week_event_reg[68]" }, + { &gSaveContext.weekEventReg[69], "week_event_reg[69]" }, + { &gSaveContext.weekEventReg[70], "week_event_reg[70]" }, + { &gSaveContext.weekEventReg[71], "week_event_reg[71]" }, + { &gSaveContext.weekEventReg[72], "week_event_reg[72]" }, + { &gSaveContext.weekEventReg[73], "week_event_reg[73]" }, + { &gSaveContext.weekEventReg[74], "week_event_reg[74]" }, + { &gSaveContext.weekEventReg[75], "week_event_reg[75]" }, + { &gSaveContext.weekEventReg[76], "week_event_reg[76]" }, + { &gSaveContext.weekEventReg[77], "week_event_reg[77]" }, + { &gSaveContext.weekEventReg[78], "week_event_reg[78]" }, + { &gSaveContext.weekEventReg[79], "week_event_reg[79]" }, + { &gSaveContext.weekEventReg[80], "week_event_reg[80]" }, + { &gSaveContext.weekEventReg[81], "week_event_reg[81]" }, + { &gSaveContext.weekEventReg[82], "week_event_reg[82]" }, + { &gSaveContext.weekEventReg[83], "week_event_reg[83]" }, + { &gSaveContext.weekEventReg[84], "week_event_reg[84]" }, + { &gSaveContext.weekEventReg[85], "week_event_reg[85]" }, + { &gSaveContext.weekEventReg[86], "week_event_reg[86]" }, + { &gSaveContext.weekEventReg[87], "week_event_reg[87]" }, + { &gSaveContext.weekEventReg[88], "week_event_reg[88]" }, + { &gSaveContext.weekEventReg[89], "week_event_reg[89]" }, + { &gSaveContext.weekEventReg[90], "week_event_reg[90]" }, + { &gSaveContext.weekEventReg[91], "week_event_reg[91]" }, + { &gSaveContext.weekEventReg[92], "week_event_reg[92]" }, + { &gSaveContext.weekEventReg[93], "week_event_reg[93]" }, + { &gSaveContext.weekEventReg[94], "week_event_reg[94]" }, + { &gSaveContext.weekEventReg[95], "week_event_reg[95]" }, + { &gSaveContext.weekEventReg[96], "week_event_reg[96]" }, + { &gSaveContext.weekEventReg[97], "week_event_reg[97]" }, + { &gSaveContext.weekEventReg[98], "week_event_reg[98]" }, + { &gSaveContext.weekEventReg[99], "week_event_reg[99]" }, -#pragma GLOBAL_ASM("asm/non_matchings/code/flg_set/D_801DC120.s") + { &gSaveContext.eventInf[0], "event_inf[0]" }, + { &gSaveContext.eventInf[1], "event_inf[1]" }, + { &gSaveContext.eventInf[2], "event_inf[2]" }, + { &gSaveContext.eventInf[3], "event_inf[3]" }, + { &gSaveContext.eventInf[4], "event_inf[4]" }, + { &gSaveContext.eventInf[5], "event_inf[5]" }, + { &gSaveContext.eventInf[6], "event_inf[6]" }, + { &gSaveContext.eventInf[7], "event_inf[7]" }, -#pragma GLOBAL_ASM("asm/non_matchings/code/flg_set/func_800B3644.s") + { &gSaveContext.maskMaskBit[0], "mask_mask_bit[0]" }, + { &gSaveContext.maskMaskBit[1], "mask_mask_bit[1]" }, + { &gSaveContext.maskMaskBit[2], "mask_mask_bit[2]" }, -#pragma GLOBAL_ASM("asm/non_matchings/code/flg_set/D_801DC9B8.s") + { NULL, NULL }, // used in the code to detect array end +}; + +static s32 sEntryIndex = 0; +static u32 sCurrentBit = 0; +static s32 sTimer = 0; + +void FlagSet_Update(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Input* input = CONTROLLER1(globalCtx); + + /* Intra-byte navigation */ + + if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + sCurrentBit++; + sTimer = 10; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + sCurrentBit--; + sTimer = 10; + } + + if (sTimer == 0) { + if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) { + sCurrentBit++; + sTimer = 2; + } + if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) { + sCurrentBit--; + sTimer = 2; + } + } + + // Wrap cursor position at beginning/end of line + sCurrentBit %= 8; + + /* Navigation between bytes */ + + // + Up/Down scroll 1 at a time + if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { + sEntryIndex--; + if (sEntryIndex < 0) { + sEntryIndex = 0; + } + sTimer = 10; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + sEntryIndex++; + if (sFlagEntries[sEntryIndex].value == NULL) { // End of array + sEntryIndex--; + } + sTimer = 10; + } + + // C Up/Down scroll 10 at a time + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + sEntryIndex -= 10; + if (sEntryIndex < 0) { + sEntryIndex = 0; + } + sTimer = 10; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + sEntryIndex += 10; + if (sEntryIndex > 100) { + sEntryIndex = 100; + } + sTimer = 10; + } + + if (sTimer == 0) { + if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) { + sEntryIndex--; + if (sEntryIndex < 0) { + sEntryIndex = 0; + } + sTimer = 2; + + } else if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) { + sEntryIndex++; + if (sFlagEntries[sEntryIndex].value == NULL) { // End of array + sEntryIndex--; + } + sTimer = 2; + + } else if (CHECK_BTN_ALL(input->cur.button, BTN_CUP)) { + sEntryIndex -= 10; + if (sEntryIndex < 0) { + sEntryIndex = 0; + } + sTimer = 2; + + } else if (CHECK_BTN_ALL(input->cur.button, BTN_CDOWN)) { + sEntryIndex += 10; + if (sEntryIndex > 100) { + sEntryIndex = 100; + } + sTimer = 2; + } + } + + /* Other controls */ + + // A toggles the selected flag + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + *sFlagEntries[sEntryIndex].value ^= (1 << sCurrentBit); + } + + if (sTimer != 0) { + sTimer--; + } + + // Hold Start and press B will reset the first two flag arrays + if (CHECK_BTN_ALL(input->cur.button, BTN_START)) { + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + s16 i; + for (i = 0; i < ARRAY_COUNT(gSaveContext.weekEventReg); i++) { + gSaveContext.weekEventReg[i] = 0; + } + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + } + + // Pressing B will exit + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + globalCtx->pauseCtx.debugState = 0; + } +} + +extern s32 D_801ED890; + +void FlagSet_Draw(GameState* gameState) { + GraphicsContext* gfxCtx = gameState->gfxCtx; + Gfx* gfx; + Gfx* polyOpa; + + OPEN_DISPS(gfxCtx); + GfxPrint printer; + s32 pad; + + polyOpa = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(polyOpa); + gSPDisplayList(OVERLAY_DISP++, gfx); + + GfxPrint_Init(&printer); + GfxPrint_Open(&printer, gfx); + GfxPrint_SetColor(&printer, 250, 50, 50, 255); + GfxPrint_SetPos(&printer, 8, 13); + GfxPrint_Printf(&printer, sFlagEntries[sEntryIndex].name); + GfxPrint_SetPos(&printer, 12, 15); + + // Print the flag bits in the current byte, largest to smallest + for (D_801ED890 = 7; D_801ED890 >= 0; D_801ED890--) { + // Highlight current flag bit in white, rest in grey + if ((u32)D_801ED890 == sCurrentBit) { + GfxPrint_SetColor(&printer, 200, 200, 200, 255); + } else { + GfxPrint_SetColor(&printer, 100, 100, 100, 255); + } + + // Display 1 if flag set and 0 if not + if (*sFlagEntries[sEntryIndex].value & (1 << D_801ED890)) { + GfxPrint_Printf(&printer, "1"); + } else { + GfxPrint_Printf(&printer, "0"); + } + + // Add a space after each group of 4 + if ((D_801ED890 % 4) == 0) { + GfxPrint_Printf(&printer, " "); + } + } + + gfx = GfxPrint_Close(&printer); + GfxPrint_Destroy(&printer); + + gSPEndDisplayList(gfx++); + Graph_BranchDlist(polyOpa, gfx); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/code/pad_801DC9C0.c b/src/code/pad_801DC9C0.c new file mode 100644 index 000000000..f386919de --- /dev/null +++ b/src/code/pad_801DC9C0.c @@ -0,0 +1 @@ +static const char pad_801DC9C0[] = { 0 }; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 11ec5164b..99a4343a4 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -652,8 +652,8 @@ 0x800B31BC:("func_800B31BC",), 0x800B320C:("EffectSsIceSmoke_Spawn",), 0x800B326C:("EffectSsIceBlock_Spawn",), - 0x800B32D0:("func_800B32D0",), - 0x800B3644:("func_800B3644",), + 0x800B32D0:("FlagSet_Update",), + 0x800B3644:("FlagSet_Draw",), 0x800B3880:("DLF_LoadGameState",), 0x800B39A4:("DLF_FreeGameState",), 0x800B3AD0:("Actor_PrintLists",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 4f5da48f7..d6ae0cfab 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -424,10 +424,10 @@ 0x801AE48C:("D_801AE48C","Color_RGBA8","",0x4), 0x801AE490:("D_801AE490","Color_RGBA8","[4]",0x10), 0x801AE4A0:("particleOverlayTable","EffectSsOverlay","[39]",0x444), - 0x801AE8F0:("D_801AE8F0","UNK_PTR","",0x4), - 0x801AEC70:("D_801AEC70","UNK_TYPE4","",0x4), - 0x801AEC74:("D_801AEC74","UNK_TYPE4","",0x4), - 0x801AEC78:("D_801AEC78","UNK_TYPE4","",0x4), + 0x801AE8F0:("sFlagEntries","FlagSetEntry","[112]",0x8), + 0x801AEC70:("sEntryIndex","s32","",0x4), + 0x801AEC74:("sCurrentBit","u32","",0x4), + 0x801AEC78:("sTimer","s32","",0x4), 0x801AEC80:("D_801AEC80","Color_RGBA8","",0x4), 0x801AEC84:("D_801AEC84","s801AEC84","[13]",0x68), 0x801AECEC:("actorMovementScale","f32","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index e8f66fc01..0fdfe7519 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -166,8 +166,8 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsDeadDs_Spawn.s,Effe asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B31BC.s,func_800B31BC,0x800B31BC,0x14 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIceSmoke_Spawn.s,EffectSsIceSmoke_Spawn,0x800B320C,0x18 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIceBlock_Spawn.s,EffectSsIceBlock_Spawn,0x800B326C,0x19 -asm/non_matchings/code/flg_set/func_800B32D0.s,func_800B32D0,0x800B32D0,0xDD -asm/non_matchings/code/flg_set/func_800B3644.s,func_800B3644,0x800B3644,0x8F +asm/non_matchings/code/flg_set/FlagSet_Update.s,FlagSet_Update,0x800B32D0,0xDD +asm/non_matchings/code/flg_set/FlagSet_Draw.s,FlagSet_Draw,0x800B3644,0x8F asm/non_matchings/code/z_DLF/DLF_LoadGameState.s,DLF_LoadGameState,0x800B3880,0x49 asm/non_matchings/code/z_DLF/DLF_FreeGameState.s,DLF_FreeGameState,0x800B39A4,0x4B asm/non_matchings/code/z_actor/Actor_PrintLists.s,Actor_PrintLists,0x800B3AD0,0x35 From d2ce39d24b31dc4ef21c3cf236415a4164815e49 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Mon, 11 Oct 2021 15:56:08 -0300 Subject: [PATCH 34/86] Decomp sleep.c (#293) --- include/functions.h | 8 ++++---- src/boot_O2/sleep.c | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/functions.h b/include/functions.h index 006179be6..6bb4c0740 100644 --- a/include/functions.h +++ b/include/functions.h @@ -239,10 +239,10 @@ s32 sprintf(char* s, char* fmt, ...); s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); void Sleep_Cycles(OSTime time); -// void Sleep_Nsec(void); -void Sleep_Usec(s32); -void Sleep_Msec(u32 param_1); -// void Sleep_Sec(void); +void Sleep_Nsec(u32 nsec); +void Sleep_Usec(u32 usec); +void Sleep_Msec(u32 ms); +void Sleep_Sec(u32 sec); // void __osSetCause(void); s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags); // void osPfsFreeBlocks(void); diff --git a/src/boot_O2/sleep.c b/src/boot_O2/sleep.c index b794d08ca..01a85c5cc 100644 --- a/src/boot_O2/sleep.c +++ b/src/boot_O2/sleep.c @@ -1,11 +1,27 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Cycles.s") +void Sleep_Cycles(u64 time) { + OSMesgQueue mq; + OSMesg msg; + OSTimer timer; -#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Nsec.s") + osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK); + osSetTimer(&timer, time, 0, &mq, NULL); + osRecvMesg(&mq, NULL, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Usec.s") +void Sleep_Nsec(u32 nsec) { + Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec)); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Msec.s") +void Sleep_Usec(u32 usec) { + Sleep_Cycles(OS_USEC_TO_CYCLES(usec)); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Sec.s") +void Sleep_Msec(u32 ms) { + Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ULL); +} + +void Sleep_Sec(u32 sec) { + Sleep_Cycles(sec * OS_CPU_COUNTER); +} From 94e6ebaec9b9a6949cd0e2edeb57a21a16bc388e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:48:03 +0100 Subject: [PATCH 35/86] En_Fu (#343) * En_Fu * Fix non-matching, thanks Anon58 --- include/functions.h | 4 +- include/z64.h | 2 +- spec | 3 +- .../actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h | 3 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 1456 ++++++++++++++++- src/overlays/actors/ovl_En_Fu/z_en_fu.h | 41 +- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.h | 3 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.h | 3 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 + 11 files changed, 1449 insertions(+), 77 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6bb4c0740..685a24695 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2161,7 +2161,7 @@ void func_80115908(GlobalContext* globalCtx, u8 param_2); void func_801159c0(s16 param_1); void func_801159EC(s16 arg0); void func_80115A14(s32 arg0, s16 arg1); -// void Parameter_AddMagic(void); +void Parameter_AddMagic(GlobalContext* globalCtx, s16 arg1); void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); // void func_80116088(void); @@ -3388,7 +3388,7 @@ void SysMatrix_InsertXRotation_s(s16 rotation, s32 appendToState); void SysMatrix_InsertXRotation_f(f32 rotation, s32 appendToState); void SysMatrix_RotateStateAroundXAxis(f32 rotation); void SysMatrix_SetStateXRotation(f32 rotation); -void Matrix_RotateY(s16 rotation, u8 appendToState); +void Matrix_RotateY(s16 rotation, s32 appendToState); void SysMatrix_InsertYRotation_f(f32 rotation, s32 appendToState); void SysMatrix_InsertZRotation_s(s16 rotation, s32 appendToState); void SysMatrix_InsertZRotation_f(f32 rotation, s32 appendToState); diff --git a/include/z64.h b/include/z64.h index 2b1badfd4..0061eb547 100644 --- a/include/z64.h +++ b/include/z64.h @@ -964,7 +964,7 @@ typedef struct { /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; /* 0x12022 */ UNK_TYPE1 unk12022; - /* 0x12023 */ s8 unk12023; + /* 0x12023 */ u8 unk12023; /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; /* 0x1202A */ u16 unk1202A; /* 0x1202C */ UNK_TYPE1 pad1202C[0x2]; diff --git a/spec b/spec index 9412e3b28..a91f653cf 100644 --- a/spec +++ b/spec @@ -1721,8 +1721,7 @@ beginseg name "ovl_En_Fu" compress include "build/src/overlays/actors/ovl_En_Fu/z_en_fu.o" - include "build/data/ovl_En_Fu/ovl_En_Fu.data.o" - include "build/data/ovl_En_Fu/ovl_En_Fu.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu/ovl_En_Fu_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h index 45c78a181..ffb4cc8d8 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h @@ -7,7 +7,8 @@ struct BgFuMizu; typedef struct BgFuMizu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x20]; + /* 0x144 */ char unk_144[0x1C]; + /* 0x160 */ s16 unk_160; } BgFuMizu; // size = 0x164 extern const ActorInit Bg_Fu_Mizu_InitVars; 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 99c23126f..102fe9bc5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -1,3 +1,14 @@ +/* + * File: z_en_fu.c + * Overlay: ovl_En_Fu + * Description: Honey & Darling + */ + +#include "overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h" +#include "overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h" +#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" +#include "overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "z_en_fu.h" #define FLAGS 0x0A000019 @@ -9,7 +20,50 @@ void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFu_Update(Actor* thisx, GlobalContext* globalCtx); void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809622FC(EnFu* this); +void func_80962340(EnFu* this, GlobalContext* globalCtx); +void func_809628BC(EnFu* this); +void func_809628D0(EnFu* this, GlobalContext* globalCtx); +void func_809629F8(EnFu* this); +void func_80962A10(EnFu* this, GlobalContext* globalCtx); +void func_80962BA8(EnFu* this); +void func_80962BCC(EnFu* this, GlobalContext* globalCtx); +void func_80962D48(EnFu* this); +void func_80962D60(EnFu* this, GlobalContext* globalCtx); +void func_80962F10(EnFu* this); +void func_80962F4C(EnFu* this, GlobalContext* globalCtx); +void func_8096326C(EnFu* this, GlobalContext* globalCtx); +void func_809632D0(EnFu* this); +void func_80963350(EnFu* this, GlobalContext* globalCtx); +void func_80963540(EnFu* this); +void func_80963560(EnFu* this, GlobalContext* globalCtx); +void func_80963610(EnFu* this); +void func_80963630(EnFu* this, GlobalContext* globalCtx); +s32 func_80963810(GlobalContext* globalCtx, Vec3f pos); +s32 func_809638F8(GlobalContext* globalCtx); +void func_809639D0(EnFu* this, GlobalContext* globalCtx); +void func_80963DE4(EnFu* this, GlobalContext* globalCtx); +void func_80963EAC(EnFu* this, GlobalContext* globalCtx); +void func_80963F44(EnFu* this, GlobalContext* globalCtx); +void func_80963F88(EnFu* this, GlobalContext* globalCtx); +void func_80963FF8(EnFu* this, GlobalContext* globalCtx); +void func_8096413C(EnFu* this, GlobalContext* globalCtx); +void func_80964190(EnFu* this, GlobalContext* globalCtx); +void func_8096426C(EnFu* this, GlobalContext* globalCtx); +void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len); +void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len); +void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len); + +extern AnimationHeader D_06001F74; +extern AnimationHeader D_06002F64; +extern AnimationHeader D_06004904; +extern AnimationHeader D_06005304; +extern AnimationHeader D_060053E0; +extern Gfx D_0600B0A0[]; +extern Gfx D_0600B0E0[]; +extern FlexSkeletonHeader D_0600B2B0; +extern AnimationHeader D_0600BAC4; + const ActorInit En_Fu_InitVars = { ACTOR_EN_FU, ACTORCAT_NPC, @@ -22,126 +76,1400 @@ const ActorInit En_Fu_InitVars = { (ActorFunc)EnFu_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80964BD8 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static s32 D_80964B00[] = { 300, 100, 100 }; + +static Vec3f D_80964B0C = { 0.0f, 60.0f, -8.0f }; +static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; +static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; + +static ActorAnimationEntry sAnimations[] = { + { &D_060053E0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &D_06001F74, 1.0f, 0.0f, 0.0f, 0, -4.0f }, + { &D_06002F64, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &D_06004904, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &D_06005304, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &D_06005304, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &D_0600BAC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -#endif +void func_809616E0(EnFu* this, GlobalContext* globalCtx) { + s32 i; + f32 temp_f20; + f32 temp_f22; + s16 atan; + s16 spA0 = false; + Vec3f sp94; -extern ColliderCylinderInit D_80964BD8; + if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { + spA0 = true; + } + this->unk_54C = 0; -extern UNK_TYPE D_06001F74; -extern UNK_TYPE D_0600B0E0; + for (i = 0; i < this->unk_520; i++) { + temp_f20 = this->actor.world.pos.x - this->unk_538[i].x; + temp_f22 = this->actor.world.pos.z - this->unk_538[i].z; + atan = Math_FAtan2F(temp_f22, temp_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809616E0.s") + if (!spA0 || ((i % 2) != 0)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, this->unk_544, this->unk_538[i].x, this->unk_538[i].y, + this->unk_538[i].z, 0, atan, 0, i); + this->unk_54C++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809619D0.s") + if (this->unk_546 == 1) { + Vec3f sp88 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp7C = { 0.0f, 0.2f, 0.0f }; + Color_RGBA8 sp78 = { 255, 255, 255, 255 }; + Color_RGBA8 sp74 = { 198, 198, 198, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/EnFu_Init.s") + sp94.x = this->unk_538[i].x; + sp94.y = this->unk_538[i].y; + sp94.z = this->unk_538[i].z; + func_800B0EB0(globalCtx, &sp94, &sp88, &sp7C, &sp78, &sp74, 100, 150, 10); + sp94.x -= 0.1f * temp_f20; + sp94.z -= 0.1f * temp_f22; + func_800B3030(globalCtx, &sp94, &sp88, &sp7C, 100, 0, 3); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/EnFu_Destroy.s") +void func_809619D0(EnFu* this, GlobalContext* globalCtx) { + s32 i; + Path* path = &globalCtx->setupPathList[ENFU_GET_FF00(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961D10.s") + switch (CURRENT_DAY) { + case 1: + this->unk_542 = 2; + this->unk_544 = ACTOR_EN_FU_MATO; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961D7C.s") + case 2: + this->unk_542 = 1; + this->unk_544 = ACTOR_EN_FU_KAGO; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961E88.s") + case 3: + this->unk_542 = 0; + this->unk_544 = ACTOR_EN_FU_MATO; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961EC8.s") + default: + this->unk_544 = ACTOR_EN_FU_MATO; + this->unk_542 = 2; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961F00.s") + for (i = 0; i < this->unk_542; i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80961F38.s") + this->unk_520 = path->count; + this->unk_538 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + func_809616E0(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_8096209C.s") +void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFu* this = THIS; + Actor* fuKaiten = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809622FC.s") + while (fuKaiten != NULL) { + if (fuKaiten->id == ACTOR_BG_FU_KAITEN) { + this->actor.child = fuKaiten; + break; + } + fuKaiten = fuKaiten->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962340.s") + if (fuKaiten != NULL) { + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600B2B0, &D_06001F74, this->jointTable, this->morphTable, 21); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~1; + this->actor.gravity = -0.2f; + this->actor.shape.rot.y += 0x4000; + this->actor.world.rot = this->actor.shape.rot; + this->unk_546 = 0; + this->unk_54A = 1; + this->unk_54C = 0; + this->unk_53C = 0; + this->unk_53E = 0; + this->unk_540 = 0; + this->unk_54E = 0; + this->unk_550 = 0; + func_809622FC(this); + this->actor.targetMode = 6; + func_809619D0(this, globalCtx); + if (CURRENT_DAY == 2) { + Vec3f sp40 = this->actor.child->home.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962588.s") + this->unk_2D4 = (BgFuMizu*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_FU_MIZU, sp40.x, sp40.y, + sp40.z, 0, 0, 0, 0); + } else { + this->unk_2D4 = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962660.s") +void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809628BC.s") + gSaveContext.weekEventReg[63] &= (u8)~0x1; + gSaveContext.weekEventReg[8] &= (u8)~0x1; + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809628D0.s") +s32 func_80961D10(EnFu* this) { + if ((this->collider.base.acFlags & AC_HIT) && (this->unk_542 == 0)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809629F8.s") + if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->unk_542 == 2)) { + Actor* actor = this->collider.base.oc; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962A10.s") + if (actor->id == ACTOR_EN_BOM_CHU) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962BA8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962BCC.s") +void func_80961D7C(GlobalContext* globalCtx) { + Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962D48.s") + while (explosive != NULL) { + if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & 1)) { + EnBom* bomb = (EnBom*)explosive; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962D60.s") + if (bomb->actor.floorBgId != BGCHECK_SCENE) { + DynaPolyActor* fuKago = BgCheck_GetActorOfMesh(&globalCtx->colCtx, bomb->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962EBC.s") + if ((fuKago != NULL) && (fuKago->actor.id == ACTOR_EN_FU_KAGO)) { + Math_SmoothStepToF(&bomb->actor.world.pos.x, fuKago->actor.world.pos.x, 0.1f, 1.0f, 0.5f); + Math_SmoothStepToF(&bomb->actor.world.pos.z, fuKago->actor.world.pos.z, 0.1f, 1.0f, 0.5f); + } + } + } + explosive = explosive->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962F10.s") +void func_80961E88(GlobalContext* globalCtx) { + Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80962F4C.s") + while (explosive != NULL) { + Actor_MarkForDeath(explosive); + explosive = explosive->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963258.s") +void func_80961EC8(GlobalContext* globalCtx) { + Actor* fuMato = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_8096326C.s") + while (fuMato != NULL) { + if (fuMato->id == ACTOR_EN_FU_MATO) { + ((EnFuMato*)fuMato)->unk_30A = 1; + } + fuMato = fuMato->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809632D0.s") +void func_80961F00(GlobalContext* globalCtx) { + Actor* fuKago = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963350.s") + while (fuKago != NULL) { + if (fuKago->id == ACTOR_EN_FU_KAGO) { + ((EnFuKago*)fuKago)->unk_33C = 1; + } + fuKago = fuKago->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963540.s") +void func_80961F38(GlobalContext* globalCtx, Vec3f* arg1, s16* arg2, s16 arg3, s16 arg4, s16 arg5) { + Player* player = PLAYER; + s16 sp42; + s16 sp40; + Vec3f sp34 = player->actor.focus.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963560.s") + sp40 = Math_Vec3f_Yaw(arg1, &sp34) - arg3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963610.s") + if (arg5 < ABS_ALT(sp40)) { + Math_SmoothStepToS(&arg2[0], 0, 6, 6200, 100); + Math_SmoothStepToS(&arg2[1], 0, 6, 6200, 100); + } else { + sp42 = Math_Vec3f_Pitch(arg1, &sp34); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963630.s") + Math_SmoothStepToS(&arg2[0], sp42, 6, 6200, 100); + Math_SmoothStepToS(&arg2[1], sp40, 6, 6200, 100); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963810.s") + if (arg4 < ABS_ALT(arg2[1])) { + if (arg2[1] > 0) { + arg2[1] = arg4; + } else { + arg2[1] = -arg4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809638F8.s") + Math_SmoothStepToS(&arg2[2], 0, 6, 2000, 100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809639D0.s") +void func_8096209C(EnFu* this, GlobalContext* globalCtx) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963DE4.s") + if (this->unk_53C & 1) { + func_80961F38(globalCtx, &this->unk_508, this->unk_524, this->actor.shape.rot.y, 0x38E3, 0x6AAA); + } else { + Math_SmoothStepToS(&this->unk_524[0], 0, 6, 6000, 100); + Math_SmoothStepToS(&this->unk_524[1], 0, 6, 6000, 100); + Math_SmoothStepToS(&this->unk_524[2], 0, 6, 6000, 100); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963EAC.s") + if (this->unk_53C & 2) { + s16 rotY = BINANG_SUB(this->actor.shape.rot.y, 0x8000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963F44.s") + func_80961F38(globalCtx, &this->unk_514, this->unk_52A, rotY, 0x38E3, 0x5555); + } else { + Math_SmoothStepToS(&this->unk_52A[0], 0, 6, 6000, 100); + Math_SmoothStepToS(&this->unk_52A[1], 0, 6, 6000, 100); + Math_SmoothStepToS(&this->unk_52A[2], 0, 6, 6000, 100); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963F88.s") + if ((this->unk_53C & 1) && (this->unk_53C & 2)) { + sp34 = D_80964B24; + } else if (this->unk_53C & 1) { + sp34 = D_80964B0C; + } else if (this->unk_53C & 2) { + sp34 = D_80964B18; + } else { + sp34 = D_80964B24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80963FF8.s") + SysMatrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + SysMatrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); + SysMatrix_StatePop(); + this->actor.focus.pos.x += this->actor.world.pos.x; + this->actor.focus.pos.y += this->actor.world.pos.y; + this->actor.focus.pos.z += this->actor.world.pos.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80964034.s") +void func_809622FC(EnFu* this) { + func_800BDC5C(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80962340; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809640D8.s") +void func_80962340(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_8096413C.s") + if (this->unk_54A == 2) { + this->actor.flags |= 0x10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80964190.s") + if (func_800B84D0(&this->actor, globalCtx)) { + if (this->unk_54A == 2) { + if (this->unk_552 == 0x287D) { + if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + func_801518B0(globalCtx, 0x287E, &this->actor); + this->unk_552 = 0x287E; + } else if ((CURRENT_DAY == 3) && (gSaveContext.weekEventReg[22] & 0x10) && + (gSaveContext.weekEventReg[22] & 0x20)) { + if ((gSaveContext.weekEventReg[22] & 0x40)) { + func_801518B0(globalCtx, 0x2883, &this->actor); + this->unk_552 = 0x2883; + } else { + func_801518B0(globalCtx, 0x2880, &this->actor); + this->unk_552 = 0x2880; + } + } else { + func_801518B0(globalCtx, 0x287E, &this->actor); + this->unk_552 = 0x287E; + } + } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { + func_801518B0(globalCtx, 0x2886, &this->actor); + this->unk_552 = 0x2886; + } else { + func_801518B0(globalCtx, 0x2889, &this->actor); + this->unk_552 = 0x2889; + } + this->actor.flags &= ~0x10000; + player->stateFlags1 &= ~0x20; + this->unk_54A = 1; + } else { + func_801518B0(globalCtx, 0x283C, &this->actor); + this->unk_552 = 0x283C; + } + func_809628BC(this); + } else if (this->unk_54A == 2) { + func_800B8614(&this->actor, globalCtx, 500.0f); + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_SUB(this->actor.child->shape.rot.y, 0x4000), 10, 3000, 100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_8096426C.s") +void func_80962588(EnFu* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx) && (this->unk_552 == 0x2871)) { + if (1) {} + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.rupees >= 10) { + func_8019F208(); + func_801159EC(-10); + func_80963DE4(this, globalCtx); + } else { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0x2873, &this->actor); + this->unk_552 = 0x2873; + } + } else { + func_8019F230(); + func_801518B0(globalCtx, 0x2872, &this->actor); + this->unk_552 = 0x2872; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809642E0.s") +void func_80962660(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/EnFu_Update.s") + if (func_80147624(globalCtx)) { + switch (this->unk_552) { + case 0x283C: + func_80963F44(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809643FC.s") + case 0x283D: + func_809639D0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_8096450C.s") + case 0x283E: + case 0x283F: + case 0x2841: + case 0x2843: + case 0x2845: + func_80963F44(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/EnFu_Draw.s") + case 0x2846: + func_801518B0(globalCtx, 0x2849, &this->actor); + this->unk_552 = 0x2849; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80964694.s") + case 0x2847: + case 0x2849: + case 0x284B: + case 0x284D: + case 0x284F: + case 0x2851: + case 0x2853: + case 0x2855: + case 0x2857: + case 0x2859: + case 0x285B: + case 0x285D: + case 0x285F: + case 0x2861: + case 0x2863: + case 0x2865: + case 0x2867: + case 0x2869: + case 0x286B: + case 0x286D: + case 0x286F: + case 0x2873: + case 0x2875: + case 0x2877: + case 0x2879: + case 0x287B: + func_80963F44(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_809647EC.s") + case 0x2848: + case 0x284A: + case 0x284E: + case 0x2850: + case 0x2852: + case 0x2856: + case 0x2858: + case 0x285A: + case 0x285C: + case 0x285E: + case 0x2860: + case 0x2862: + case 0x2864: + case 0x2866: + case 0x2868: + case 0x286A: + case 0x286C: + case 0x286E: + func_801518B0(globalCtx, 0x2871, &this->actor); + this->unk_552 = 0x2871; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu/func_80964950.s") + case 0x2876: + case 0x2878: + case 0x287A: + case 0x287C: + func_801518B0(globalCtx, 0x287D, &this->actor); + this->unk_552 = 0x287D; + break; + + case 0x287D: + gSaveContext.weekEventReg[63] |= 0x1; + gSaveContext.weekEventReg[63] &= (u8)~0x2; + func_801477B4(globalCtx); + player->stateFlags1 |= 0x20; + this->unk_53C = 0; + func_800BDC5C(&this->skelAnime, sAnimations, 3); + func_801A2BB8(0x25); + if (this->unk_542 == 0) { + if (this->unk_546 == 1) { + func_80961EC8(globalCtx); + } + func_809629F8(this); + } else if (this->unk_542 == 1) { + if (this->unk_546 == 1) { + func_80961F00(globalCtx); + } + func_80962BA8(this); + } else if (this->unk_542 == 2) { + if (this->unk_546 == 1) { + func_80961EC8(globalCtx); + } + func_80962D48(this); + } + break; + + case 0x287E: + case 0x2880: + case 0x2883: + func_801477B4(globalCtx); + func_80963540(this); + func_80963560(this, globalCtx); + break; + + case 0x2886: + case 0x2889: + func_80963F44(this, globalCtx); + break; + } + } +} + +void func_809628BC(EnFu* this) { + this->actionFunc = func_809628D0; +} + +void func_809628D0(EnFu* this, GlobalContext* globalCtx) { + u8 sp27 = func_80152498(&globalCtx->msgCtx); + + switch (sp27) { + case 0: + case 1: + case 2: + case 3: + break; + + case 4: + func_80962588(this, globalCtx); + break; + + case 5: + func_80962660(this, globalCtx); + break; + + case 6: + if (func_80147624(globalCtx)) { + this->unk_54A = 1; + switch (this->unk_552) { + case 0x287F: + case 0x2881: + case 0x2882: + case 0x2884: + case 0x2887: + case 0x288A: + gSaveContext.weekEventReg[63] &= (u8)~0x1; + gSaveContext.weekEventReg[63] &= (u8)~0x2; + func_809622FC(this); + break; + + default: + func_809622FC(this); + break; + } + } + break; + } + + if (sp27 != 3) { + func_80964190(this, globalCtx); + func_8096426C(this, globalCtx); + } + + func_8096413C(this, globalCtx); +} + +void func_809629F8(EnFu* this) { + this->unk_54A = 0; + this->actionFunc = func_80962A10; +} + +void func_80962A10(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; + + this->unk_53C = 0; + if ((fuKaiten->rotationSpeed < 300) || (fuKaiten->bouceHeight < 40.0f) || (fuKaiten->bounceSpeed < 600)) { + Math_SmoothStepToS(&fuKaiten->rotationSpeed, 300, 10, 5, 5); + Math_SmoothStepToS(&fuKaiten->bounceSpeed, 600, 20, 10, 10); + Math_SmoothStepToF(&fuKaiten->bouceHeight, 40.0f, 0.1f, 1.0f, 1.0f); + return; + } + + play_sound(NA_SE_SY_FOUND); + player->stateFlags1 &= ~0x20; + func_8010E9F0(4, 60); + if (this->unk_546 == 1) { + func_809616E0(this, globalCtx); + } else { + this->unk_546 = 1; + } + + if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && gSaveContext.magicAcquired) { + s16 temp = gSaveContext.unk_3F30; + + Parameter_AddMagic(globalCtx, temp + (gSaveContext.doubleMagic * 48) + 48); + } + + func_80962F10(this); +} + +void func_80962BA8(EnFu* this) { + BgFuMizu* mizu = this->unk_2D4; + + this->unk_54A = 0; + mizu->unk_160 = 1; + this->actionFunc = func_80962BCC; +} + +void func_80962BCC(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; + + if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bouceHeight < 30.0f) || (fuKaiten->bounceSpeed < 600)) { + Math_SmoothStepToS(&fuKaiten->rotationSpeed, 100, 10, 5, 5); + Math_SmoothStepToS(&fuKaiten->bounceSpeed, 600, 20, 10, 10); + Math_SmoothStepToF(&fuKaiten->elevation, 10.0f, 0.1f, 1.0f, 1.0f); + Math_SmoothStepToF(&fuKaiten->bouceHeight, 30.0f, 0.1f, 1.0f, 1.0f); + return; + } + + play_sound(NA_SE_SY_FOUND); + player->stateFlags1 &= ~0x20; + player->stateFlags3 |= 0x400000; + func_8010E9F0(4, 60); + + if (this->unk_546 == 1) { + func_809616E0(this, globalCtx); + } else { + this->unk_546 = 1; + } + + globalCtx->unk_1887E = 30; + func_80962F10(this); +} + +void func_80962D48(EnFu* this) { + this->unk_54A = 0; + this->actionFunc = func_80962D60; +} + +void func_80962D60(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; + + if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bouceHeight < 40.0f) || (fuKaiten->bounceSpeed < 600)) { + Math_SmoothStepToS(&fuKaiten->rotationSpeed, 100, 10, 5, 5); + Math_SmoothStepToS(&fuKaiten->bounceSpeed, 600, 20, 10, 10); + Math_SmoothStepToF(&fuKaiten->bouceHeight, 40.0f, 0.1f, 1.0f, 1.0f); + return; + } + + play_sound(NA_SE_SY_FOUND); + player->stateFlags1 &= ~0x20; + player->stateFlags3 |= 0x400000; + func_8010E9F0(4, 60); + + if (this->unk_546 == 1) { + func_809616E0(this, globalCtx); + } else { + this->unk_546 = 1; + } + + globalCtx->unk_1887D = 30; + func_80962F10(this); +} + +void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { + if (this->unk_542 != 0) { + if (this->actor.cutscene != -1) { + func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + } + } +} + +void func_80962F10(EnFu* this) { + this->unk_548 = 0; + this->actor.flags &= ~1; + gSaveContext.weekEventReg[8] |= 1; + this->actionFunc = func_80962F4C; +} + +void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; + + switch (this->unk_542) { + case 0: + if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + player->stateFlags3 |= 0x400; + } + break; + + case 1: + globalCtx->unk_1887E = 30; + break; + + case 2: + globalCtx->unk_1887D = 30; + break; + } + + if (gSaveContext.unk_3DE0[4] < 2000) { + s16 val = D_80964B00[this->unk_542] + 200; + + Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); + } else if (gSaveContext.unk_3DE0[4] < 4000) { + s16 val = D_80964B00[this->unk_542] + 100; + + Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); + } + + if (func_80961D10(this)) { + func_801518B0(globalCtx, 0x288B, &this->actor); + } + + if ((!func_800CAF94((DynaPolyActor*)this->actor.child) && (player->actor.bgCheckFlags & 1)) || + (gSaveContext.unk_3DE0[4] < 1) || (this->unk_548 == this->unk_54C)) { + player->stateFlags3 &= ~0x400000; + func_80961E88(globalCtx); + player->stateFlags1 |= 0x20; + if (this->unk_548 < this->unk_54C) { + if (gSaveContext.unk_3DE0[4] == 0) { + func_801518B0(globalCtx, 0x2885, &this->actor); + this->unk_552 = 0x2885; + } else { + func_801518B0(globalCtx, 0x2888, &this->actor); + this->unk_552 = 0x2888; + } + func_801A2C20(); + gSaveContext.unk_3DE0[4] = 0; + gSaveContext.unk_3DD0[4] = 5; + this->unk_548 = 0; + func_809632D0(this); + } else { + this->unk_548 = 0; + func_801A2C20(); + gSaveContext.unk_3DE0[4] = 0; + gSaveContext.unk_3DD0[4] = 5; + func_801A3098(0x922); + func_8011B4E0(globalCtx, 1); + this->unk_54A = 3; + func_809632D0(this); + } + } + func_80962EBC(this, globalCtx); +} + +void func_80963258(EnFu* this) { + this->actionFunc = func_8096326C; +} + +void func_8096326C(EnFu* this, GlobalContext* globalCtx) { + func_80963FF8(this, globalCtx); + if (func_80963810(globalCtx, this->actor.world.pos)) { + func_809622FC(this); + } +} + +void func_809632D0(EnFu* this) { + if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + Interface_ChangeAlpha(50); + } + + gSaveContext.weekEventReg[8] &= (u8)~0x1; + + if (this->unk_2D4 != NULL) { + BgFuMizu* mizu = this->unk_2D4; + + mizu->unk_160 = 0; + } + + this->actor.flags |= 1; + this->actionFunc = func_80963350; +} + +void func_80963350(EnFu* this, GlobalContext* globalCtx) { + static s32 D_80964C24 = 0; + BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; + + if ((this->unk_54A == 0) && (((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + ((func_80152498(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { + func_801477B4(globalCtx); + this->unk_54A = 2; + D_80964C24 = 1; + } + + if ((this->unk_54A == 3) && (globalCtx->interfaceCtx.unk_286 == 0)) { + this->unk_54A = 2; + D_80964C24 = 1; + } + + if ((fuKaiten->rotationSpeed != 0) || (fuKaiten->bounceSpeed != 0) || (fuKaiten->bouceHeight > 0.0f) || + !func_809638F8(globalCtx)) { + Math_SmoothStepToS(&fuKaiten->rotationSpeed, 0, 10, 10, 5); + Math_SmoothStepToS(&fuKaiten->bounceSpeed, 0, 10, 15, 5); + Math_SmoothStepToF(&fuKaiten->bouceHeight, 0.0f, 0.1f, 1.0f, 1.0f); + Math_SmoothStepToF(&fuKaiten->elevation, 0.0f, 0.1f, 1.0f, 1.0f); + func_80962EBC(this, globalCtx); + } else if (D_80964C24 == 1) { + D_80964C24 = 0; + fuKaiten->bounce = 0; + func_80963F88(this, globalCtx); + globalCtx->actorCtx.unk268 = 1; + func_80963258(this); + } +} + +void func_80963540(EnFu* this) { + this->actor.child->freezeTimer = 10; + this->actionFunc = func_80963560; +} + +void func_80963560(EnFu* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_80963610(this); + } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { + 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); + } + this->actor.child->freezeTimer = 10; +} + +void func_80963610(EnFu* this) { + this->actor.child->freezeTimer = 10; + this->actionFunc = func_80963630; +} + +void func_80963630(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (func_800B84D0(&this->actor, globalCtx)) { + if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && + (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if (gSaveContext.weekEventReg[22] & 0x40) { + func_801518B0(globalCtx, 0x2884, &this->actor); + this->unk_552 = 0x2884; + } else if (!(gSaveContext.weekEventReg[22] & 0x80)) { + gSaveContext.weekEventReg[22] |= 0x80; + func_801518B0(globalCtx, 0x2882, &this->actor); + this->unk_552 = 0x2882; + } else { + func_801518B0(globalCtx, 0x2881, &this->actor); + this->unk_552 = 0x2881; + } + } else { + func_801518B0(globalCtx, 0x287F, &this->actor); + this->unk_552 = 0x287F; + } + + this->actor.flags &= ~0x10000; + this->actor.child->freezeTimer = 0; + func_809628BC(this); + + if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.weekEventReg[22] |= 0x10; + break; + + case 2: + gSaveContext.weekEventReg[22] |= 0x20; + break; + + case 3: + gSaveContext.weekEventReg[22] |= 0x40; + break; + } + } + player->stateFlags1 &= ~0x20; + } else { + this->actor.child->freezeTimer = 10; + func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + } +} + +s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { + Player* player = PLAYER; + f32 sp28; + f32 phi_f0; + s16 sp22; + + sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &pos); + sp28 = Math_Vec3f_DistXZ(&player->actor.world.pos, &pos); + + if (sp28 < 80.0f) { + phi_f0 = 10.0f; + } else if (sp28 < 90.0f) { + phi_f0 = 40.0f; + } else { + phi_f0 = 80.0f; + } + + globalCtx->actorCtx.unk268 = 1; + func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); + + if (sp28 < 80.0f) { + return true; + } + return false; +} + +s32 func_809638F8(GlobalContext* globalCtx) { + s32 ret = true; + + if (globalCtx->envCtx.unk_8C.diffuseColor1[0] > 25) { + globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.diffuseColor1[0] = 0; + } + + if (globalCtx->envCtx.unk_8C.diffuseColor1[1] > 25) { + globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.diffuseColor1[1] = 0; + } + + if (globalCtx->envCtx.unk_8C.diffuseColor1[2] > 25) { + globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.diffuseColor1[2] = 0; + } + + if (globalCtx->envCtx.unk_8C.ambientColor[0] > 25) { + globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.ambientColor[0] = 0; + } + + if (globalCtx->envCtx.unk_8C.ambientColor[1] > 25) { + globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.ambientColor[1] = 0; + } + + if (globalCtx->envCtx.unk_8C.ambientColor[2] > 25) { + globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + ret = false; + } else { + globalCtx->envCtx.unk_8C.ambientColor[2] = 0; + } + return ret; +} + +void func_809639D0(EnFu* this, GlobalContext* globalCtx) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + func_801518B0(globalCtx, 0x2853, &this->actor); + this->unk_552 = 0x2853; + } else if (gSaveContext.weekEventReg[22] & 0x10) { + func_801518B0(globalCtx, 0x284D, &this->actor); + this->unk_552 = 0x284D; + } else if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x284F, &this->actor); + this->unk_552 = 0x284F; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x2851, &this->actor); + this->unk_552 = 0x2851; + } + } else { + func_801518B0(globalCtx, 0x286F, &this->actor); + this->unk_552 = 0x286F; + } + break; + + case 2: + if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + func_801518B0(globalCtx, 0x286F, &this->actor); + this->unk_552 = 0x286F; + } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + func_801518B0(globalCtx, 0x2853, &this->actor); + this->unk_552 = 0x2853; + } else if (!(gSaveContext.weekEventReg[22] & 0x10)) { + if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x285B, &this->actor); + this->unk_552 = 0x285B; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x285D, &this->actor); + this->unk_552 = 0x285D; + } + } else if (gSaveContext.weekEventReg[22] & 0x20) { + func_801518B0(globalCtx, 0x2855, &this->actor); + this->unk_552 = 0x2855; + } else if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x2857, &this->actor); + this->unk_552 = 0x2857; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x2859, &this->actor); + this->unk_552 = 0x2859; + } + break; + + case 3: + if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + func_80963EAC(this, globalCtx); + } else { + func_801518B0(globalCtx, 0x2841, &this->actor); + this->unk_552 = 0x2841; + } + } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { + func_801518B0(globalCtx, 0x284B, &this->actor); + this->unk_552 = 0x284B; + } else if (gSaveContext.weekEventReg[22] & 0x40) { + if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + func_801518B0(globalCtx, 0x285F, &this->actor); + this->unk_552 = 0x285F; + } else { + func_801518B0(globalCtx, 0x2861, &this->actor); + this->unk_552 = 0x2861; + } + } else if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x2863, &this->actor); + this->unk_552 = 0x2863; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x2865, &this->actor); + this->unk_552 = 0x2865; + } + } else if ((gSaveContext.weekEventReg[22] & 0x10) || (gSaveContext.weekEventReg[22] & 0x20)) { + if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x2867, &this->actor); + this->unk_552 = 0x2867; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x2869, &this->actor); + this->unk_552 = 0x2869; + } + } else if (this->unk_53E == 1) { + func_801518B0(globalCtx, 0x286B, &this->actor); + this->unk_552 = 0x286B; + } else { + this->unk_53E = 1; + func_801518B0(globalCtx, 0x286D, &this->actor); + this->unk_552 = 0x286D; + } + break; + } +} + +void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { + switch (this->unk_542) { + case 0: + if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + func_801518B0(globalCtx, 0x2875, &this->actor); + this->unk_552 = 0x2875; + } else { + func_801518B0(globalCtx, 0x2877, &this->actor); + this->unk_552 = 0x2877; + } + break; + + case 1: + func_801518B0(globalCtx, 0x2879, &this->actor); + this->unk_552 = 0x2879; + break; + + case 2: + func_801518B0(globalCtx, 0x287B, &this->actor); + this->unk_552 = 0x287B; + break; + } +} + +void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { + if (gSaveContext.magicAcquired) { + if (this->unk_540 == 1) { + func_801518B0(globalCtx, 0x2847, &this->actor); + this->unk_552 = 0x2847; + } else { + this->unk_540 = 1; + func_801518B0(globalCtx, 0x2845, &this->actor); + this->unk_552 = 0x2845; + } + } else { + func_801518B0(globalCtx, 0x2843, &this->actor); + this->unk_552 = 0x2843; + } +} + +void func_80963F44(EnFu* this, GlobalContext* globalCtx) { + u16 sp1E = this->unk_552 + 1; + + func_801518B0(globalCtx, sp1E, &this->actor); + this->unk_552 = sp1E; +} + +void func_80963F88(EnFu* this, GlobalContext* globalCtx) { + if (this->unk_542 == 1) { + func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + globalCtx->unk_1887E = 0; + } else if (this->unk_542 == 2) { + globalCtx->unk_1887D = 0; + func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + } +} + +void func_80963FF8(EnFu* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (player->stateFlags1 & 0x100000) { + globalCtx->actorCtx.unk268 = 1; + globalCtx->actorCtx.unk278 = 0x8000; + } else { + globalCtx->actorCtx.unk268 = 1; + } +} + +void func_80964034(EnFu* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (DECR(this->unk_54E) == 0) { + this->unk_54E = 12; + sp2C = this->actor.world.pos; + sp2C.y += 62.0f; + func_80964694(this, this->unk_2D8, &sp2C, ARRAY_COUNT(this->unk_2D8)); + } + func_809647EC(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); +} + +void func_809640D8(EnFu* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80962A10) || (this->actionFunc == func_80962BCC) || + (this->actionFunc == func_80962D60) || (this->actionFunc == func_80962F4C) || + (this->actionFunc == func_80963350)) { + this->actor.shape.rot.y += 0x400; + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +void func_8096413C(EnFu* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_SUB(this->actor.yawTowardsPlayer, 0x4000), 5, 1000, 100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80964190(EnFu* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + switch (this->unk_552) { + case 0x2842: + case 0x2844: + case 0x2848: + func_800BDC5C(&this->skelAnime, sAnimations, 1); + break; + + case 0x2840: + case 0x2841: + case 0x2843: + case 0x2847: + case 0x2849: + case 0x284B: + case 0x284D: + case 0x284F: + case 0x2851: + case 0x2853: + case 0x2855: + case 0x2857: + case 0x2859: + case 0x285B: + case 0x285D: + case 0x2861: + case 0x2863: + case 0x2865: + case 0x2867: + case 0x2869: + case 0x286B: + case 0x286D: + case 0x2871: + func_800BDC5C(&this->skelAnime, sAnimations, 4); + break; + + case 0x2860: + func_800BDC5C(&this->skelAnime, sAnimations, 5); + break; + + case 0x285F: + func_800BDC5C(&this->skelAnime, sAnimations, 6); + break; + + case 0x287E: + case 0x2880: + case 0x2883: + func_800BDC5C(&this->skelAnime, sAnimations, 2); + break; + } + } +} + +void func_8096426C(EnFu* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + switch (this->unk_552) { + case 0x2840: + case 0x2841: + case 0x2843: + case 0x2847: + case 0x2849: + case 0x284D: + case 0x284F: + case 0x2851: + case 0x2853: + case 0x2855: + case 0x2857: + case 0x2859: + case 0x285B: + case 0x285D: + case 0x2861: + case 0x2863: + case 0x2865: + case 0x2867: + case 0x2869: + case 0x286B: + case 0x286D: + case 0x2871: + case 0x2875: + case 0x2877: + case 0x2879: + case 0x287B: + case 0x287D: + this->unk_53C = 1; + break; + + case 0x2848: + case 0x284A: + case 0x284E: + case 0x2850: + case 0x2852: + case 0x2856: + case 0x2858: + case 0x285A: + case 0x285C: + case 0x285E: + case 0x2860: + case 0x2862: + case 0x2864: + case 0x2866: + case 0x2868: + case 0x286A: + case 0x286C: + case 0x286E: + this->unk_53C = 2; + break; + + default: + this->unk_53C = 0; + break; + } + } +} + +void func_809642E0(EnFu* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->unk_542 == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFu* this = THIS; + + this->actionFunc(this, globalCtx); + + func_809642E0(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + func_8096209C(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + func_80961D7C(globalCtx); + func_809640D8(this, globalCtx); + func_80964034(this, globalCtx); +} + +s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnFu* this = THIS; + + if (limbIndex == 9) { + SysMatrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); + Matrix_RotateY(this->unk_524[2], MTXMODE_APPLY); + SysMatrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); + } else if (limbIndex == 20) { + SysMatrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); + Matrix_RotateY(this->unk_52A[2], MTXMODE_APPLY); + SysMatrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); + } + return false; +} + +void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80964C28 = { -2500.0f, 0.0f, 0.0f }; + static Vec3f D_80964C34 = { -3500.0f, 0.0f, 0.0f }; + EnFu* this = THIS; + + if (limbIndex == 9) { + SysMatrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); + } else if (limbIndex == 20) { + SysMatrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); + } +} + +void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFu* this = THIS; + + SysMatrix_StatePush(); + func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); + SysMatrix_StatePop(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 0, 50, 160, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { + Vec3f sp2C = { 0.0f, 1.5f, 0.0f }; + Vec3f sp20 = { 0.0f, 0.0f, 0.0f }; + s32 i = 0; + + while ((i < len) && (ptr->unk_36 != 0)) { + i++; + ptr++; + } + + if (i < len) { + ptr->unk_36 = 1; + ptr->unk_08 = *arg2; + ptr->unk_20 = sp2C; + ptr->unk_14 = sp20; + ptr->unk_00 = 0.01f; + + ptr->unk_08.x += 4.0f * Math_SinS(this->actor.shape.rot.y); + ptr->unk_08.z += 4.0f * Math_CosS(this->actor.shape.rot.y); + ptr->unk_37 = 16; + } +} + +void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { + Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; + s16 activeCam = func_800DFC68(ACTIVE_CAM); + s32 i; + + for (i = 0; i < len; i++, ptr++) { + if (ptr->unk_36 == 1) { + if (DECR(ptr->unk_37) == 0) { + ptr->unk_36 = false; + } + ptr->unk_08.y += ptr->unk_20.y; + ptr->unk_08.x += 2.0f * Math_SinS(ptr->unk_2C); + ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); + SysMatrix_StatePush(); + SysMatrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateY(activeCam, MTXMODE_APPLY); + SysMatrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); + SysMatrix_StatePop(); + ptr->unk_2C += 6000; + } + } +} + +void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { + s32 i; + s32 flag = false; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + for (i = 0; i < len; i++, ptr++) { + if (ptr->unk_36 == 1) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, D_0600B0A0); + flag = true; + } + SysMatrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_0405E6F0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_0600B0E0); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index 61aefe315..b16ea4620 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -7,11 +7,48 @@ struct EnFu; typedef void (*EnFuActionFunc)(struct EnFu*, GlobalContext*); +#define ENFU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ char unk_04[0x4]; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ char unk_2E[0x8]; + /* 0x36 */ u8 unk_36; + /* 0x37 */ u8 unk_37; +} EnFuUnkStruct; // size = 0x38 + typedef struct EnFu { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnFuActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x37C]; + /* 0x01D8 */ Vec3s jointTable[21]; + /* 0x0256 */ Vec3s morphTable[21]; + /* 0x02D4 */ BgFuMizu* unk_2D4; + /* 0x02D8 */ EnFuUnkStruct unk_2D8[10]; + /* 0x0508 */ Vec3f unk_508; + /* 0x0514 */ Vec3f unk_514; + /* 0x0520 */ s32 unk_520; + /* 0x0524 */ s16 unk_524[3]; + /* 0x052A */ s16 unk_52A[3]; + /* 0x0530 */ char unk530[0x8]; + /* 0x0538 */ Vec3s* unk_538; + /* 0x053C */ s16 unk_53C; + /* 0x053E */ s16 unk_53E; + /* 0x0540 */ s16 unk_540; + /* 0x0542 */ s16 unk_542; + /* 0x0544 */ s16 unk_544; + /* 0x0546 */ s16 unk_546; + /* 0x0548 */ s16 unk_548; + /* 0x054A */ s16 unk_54A; + /* 0x054C */ s16 unk_54C; + /* 0x054E */ s16 unk_54E; + /* 0x0550 */ s16 unk_550; + /* 0x0552 */ u16 unk_552; } EnFu; // size = 0x554 extern const ActorInit En_Fu_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index 2e5f62f4c..db37f2f2d 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -11,7 +11,8 @@ typedef struct EnFuKago { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1E0]; + /* 0x0160 */ char unk_160[0x1DC]; + /* 0x033C */ s16 unk_33C; } EnFuKago; // size = 0x340 extern const ActorInit En_Fu_Kago_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index 34b592021..51dbf177f 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -11,7 +11,8 @@ typedef struct EnFuMato { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1AC]; + /* 0x0160 */ char unk_160[0x1AA]; + /* 0x030A */ s16 unk_30A; } EnFuMato; // size = 0x30C extern const ActorInit En_Fu_Mato_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 67b0fe886..b17f6378d 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 @@ -626,7 +626,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { case 0x3FD: case 0x3FF: - if (this->unk_26A == 4U) { + if (this->unk_26A == 4) { if (this->unk_284 == 0x3FD) { func_801518B0(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 99a4343a4..e6e2507d6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7883,8 +7883,8 @@ 0x8096426C:("func_8096426C",), 0x809642E0:("func_809642E0",), 0x80964350:("EnFu_Update",), - 0x809643FC:("func_809643FC",), - 0x8096450C:("func_8096450C",), + 0x809643FC:("EnFu_OverrideLimbDraw",), + 0x8096450C:("EnFu_PostLimbDraw",), 0x80964570:("EnFu_Draw",), 0x80964694:("func_80964694",), 0x809647EC:("func_809647EC",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 0f47ec3a7..d6a0e05ee 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2252,9 +2252,14 @@ D_0601430C = 0x0601430C; // ovl_En_Fu D_06001F74 = 0x06001F74; +D_06002F64 = 0x06002F64; +D_06004904 = 0x06004904; +D_06005304 = 0x06005304; +D_060053E0 = 0x060053E0; D_0600B0A0 = 0x0600B0A0; D_0600B0E0 = 0x0600B0E0; D_0600B2B0 = 0x0600B2B0; +D_0600BAC4 = 0x0600BAC4; // ovl_En_Fu_Kago From 4c43661cf34544a6ffc6817912021de5679e8f42 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:25:20 +0100 Subject: [PATCH 36/86] Decompile the GameStateOverlay table (#337) * Decomp GameStateOverlayTable * spec * Review * gSchedContext * Format * Fix bss --- include/functions.h | 4 +- include/variables.h | 14 +- include/z64.h | 160 +++--------------- spec | 2 +- src/boot_O2_g3/fault_drawer.c | 2 +- src/boot_O2_g3/idle.c | 1 - src/code/z_game_dlftbls.c | 26 +++ .../ovl_file_choose/z_file_choose.h | 2 + 8 files changed, 58 insertions(+), 153 deletions(-) create mode 100644 src/code/z_game_dlftbls.c diff --git a/include/functions.h b/include/functions.h index 685a24695..8c8b76a3e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -107,7 +107,7 @@ void FaultDrawer_VPrintf(const char* str, char* args); void FaultDrawer_Printf(const char* fmt, ...); void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...); void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h); -void FaultDrawer_SetInputCallback(func_ptr func); +void FaultDrawer_SetInputCallback(void* func); void FaultDrawer_Init(void); void func_80084940(void); void func_80084968(void); @@ -3010,7 +3010,7 @@ void func_80165438(UNK_PTR param_1); // void func_80165EC0(void); // void func_80166060(void); Gfx* func_801660B8(GlobalContext* globalCtx, Gfx* gfx); -void Play_Fini(GlobalContext* globalCtx); +void Play_Fini(GameState* gameState); // void func_801663C4(void); // void func_80166644(void); // void func_801668B4(void); diff --git a/include/variables.h b/include/variables.h index eddb73875..7d6969543 100644 --- a/include/variables.h +++ b/include/variables.h @@ -937,13 +937,13 @@ extern s16 actorCutsceneReturnCamera; extern s16 D_801BD8C6; extern ColliderCylinderInit fireObjCollisionInit; extern FireObjLightParams D_801BD8FC[2]; -extern GameStateOverlay gGameStateOverlayTable; -extern GameStateOverlay D_801BD940; -extern GameStateOverlay titleGameStateInfo; -extern GameStateOverlay mainGameStateInfo; -extern GameStateOverlay openingGameStateInfo; -extern GameStateOverlay fileChooseGameStateInfo; -extern GameStateOverlay daytelopGameStateInfo; +extern GameStateOverlay gGameStateOverlayTable[]; +// extern GameStateOverlay D_801BD940; +// extern GameStateOverlay titleGameStateInfo; +// extern GameStateOverlay mainGameStateInfo; +// extern GameStateOverlay openingGameStateInfo; +// extern GameStateOverlay fileChooseGameStateInfo; +// extern GameStateOverlay daytelopGameStateInfo; // extern UNK_TYPE4 graphNumGameStates; // extern UNK_TYPE2 D_801BDA70; // extern UNK_TYPE2 D_801BDA74; diff --git a/include/z64.h b/include/z64.h index 0061eb547..6e179ebe2 100644 --- a/include/z64.h +++ b/include/z64.h @@ -411,10 +411,6 @@ typedef void*(*fault_address_converter_func)(void* addr, void* arg); typedef void(*fault_client_func)(void* arg1, void* arg2); -typedef unsigned long(*func)(void); - -typedef void(*func_ptr)(void); - typedef void(*osCreateThread_func)(void*); typedef void* (*PrintCallback)(void*, const char*, u32); @@ -540,7 +536,7 @@ typedef struct { /* 0x20 */ u16 printColors[10]; /* 0x34 */ u8 escCode; /* 0x35 */ u8 osSyncPrintfEnabled; - /* 0x38 */ func_ptr inputCallback; + /* 0x38 */ void* inputCallback; } FaultDrawer; // size = 0x3C typedef struct GfxPrint { @@ -564,19 +560,23 @@ typedef enum { GFXPRINT_OPEN = 0x80 } GfxPrintFlag; +typedef struct GameState GameState; + +typedef void (*GameStateFunc)(GameState* gameState); + typedef struct { - /* 0x00 */ void* loadedRamAddr; - /* 0x04 */ u32 vromStart; - /* 0x08 */ u32 vromEnd; - /* 0x0C */ void* vramStart; - /* 0x10 */ void* vramEnd; - /* 0x14 */ UNK_TYPE4 unk14; - /* 0x18 */ func_ptr init; - /* 0x1C */ func_ptr destroy; - /* 0x20 */ UNK_TYPE4 unk20; - /* 0x24 */ UNK_TYPE4 unk24; - /* 0x28 */ UNK_TYPE4 unk28; - /* 0x2C */ u32 instanceSize; + /* 0x00 */ void* loadedRamAddr; + /* 0x04 */ uintptr_t vromStart; // if applicable + /* 0x08 */ uintptr_t vromEnd; // if applicable + /* 0x0C */ void* vramStart; // if applicable + /* 0x10 */ void* vramEnd; // if applicable + /* 0x14 */ UNK_PTR unk_14; + /* 0x18 */ GameStateFunc init; // initializes and executes the given context + /* 0x1C */ GameStateFunc destroy; // deconstructs the context, and sets the next context to load + /* 0x20 */ UNK_PTR unk_20; + /* 0x24 */ UNK_PTR unk_24; + /* 0x28 */ UNK_TYPE unk_28; + /* 0x2C */ size_t instanceSize; } GameStateOverlay; // size = 0x30 typedef struct { @@ -985,14 +985,6 @@ typedef struct { /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 -typedef struct ActorBgMbarChair ActorBgMbarChair; - -typedef struct ActorEnBji01 ActorEnBji01; - -typedef struct ActorEnTest ActorEnTest; - -typedef struct ActorListEntry ActorListEntry; - typedef struct ArenaNode_t { /* 0x0 */ s16 magic; // Should always be 0x7373 /* 0x2 */ s16 isFree; @@ -1010,14 +1002,6 @@ typedef struct { /* 0x22 */ u8 flag; } Arena; // size = 0x24 -typedef struct ActorEnBom ActorEnBom; - -typedef struct ActorEnFirefly ActorEnFirefly; - -typedef struct ActorObjBell ActorObjBell; - -typedef struct ActorBgIknvObj ActorBgIknvObj; - typedef struct FaultAddrConvClient FaultAddrConvClient; struct FaultAddrConvClient { @@ -1059,8 +1043,6 @@ typedef struct FireObjLight FireObjLight; typedef struct GameAlloc GameAlloc; -typedef struct GameState GameState; - typedef struct PreNMIContext PreNMIContext; typedef struct GameAllocNode GameAllocNode; @@ -1077,8 +1059,6 @@ struct GameAlloc { /* 0x10 */ GameAllocNode* head; }; // size = 0x14 -typedef void (*GameStateFunc)(struct GameState* gameState); - struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; @@ -1374,11 +1354,11 @@ struct FireObjLight { /* 0x12 */ u8 unk12; }; // size = 0x13 -struct ActorListEntry { +typedef struct ActorListEntry { /* 0x0 */ s32 length; // number of actors loaded of this type /* 0x4 */ Actor* first; // pointer to first actor of this type /* 0x8 */ UNK_TYPE1 pad8[0x4]; -}; // size = 0xC +} ActorListEntry; // size = 0xC #define OS_SC_RETRACE_MSG 1 #define OS_SC_DONE_MSG 2 @@ -1642,108 +1622,6 @@ typedef struct { /* 0x8 */ s32 unk8; } struct_80133038_arg2; // size = 0xC -typedef struct { - /* 0x000 */ Actor base; - /* 0x144 */ ColliderQuad unk144; - /* 0x1C4 */ ColliderQuad unk1C4; - /* 0x244 */ Vec3f unk244; - /* 0x250 */ f32 unk250; - /* 0x254 */ f32 unk254; - /* 0x258 */ ActorFunc update; - /* 0x25C */ s16 unk25C; - /* 0x25E */ u16 unk25E; - /* 0x260 */ u8 unk260; - /* 0x261 */ UNK_TYPE1 pad261[0x3]; -} ActorArrowFire; // size = 0x264 - -struct ActorBgMbarChair { - /* 0x000 */ Actor base; - /* 0x144 */ UNK_TYPE1 pad144[0x18]; -}; // size = 0x15C - -struct ActorEnBji01 { - /* 0x000 */ Actor base; - /* 0x144 */ UNK_TYPE1 pad144[0x170]; -}; // size = 0x2B4 - -struct ActorEnBom { - /* 0x000 */ Actor base; - /* 0x144 */ ColliderCylinder unk144; - /* 0x190 */ ColliderJntSph unk190; - /* 0x1B0 */ ColliderJntSphElement unk1B0[1]; - /* 0x1F0 */ s16 unk1F0; - /* 0x1F2 */ UNK_TYPE1 pad1F2[0x6]; - /* 0x1F8 */ u8 unk1F8; - /* 0x1F9 */ u8 unk1F9; - /* 0x1FA */ UNK_TYPE1 pad1FA[0x2]; - /* 0x1FC */ u8 unk1FC; - /* 0x1FD */ UNK_TYPE1 pad1FD[0x3]; - /* 0x200 */ func_ptr unk200; -}; // size = 0x204 - -struct ActorEnFirefly { - /* 0x000 */ Actor base; - /* 0x144 */ UNK_TYPE1 pad144[0x1C]; - /* 0x160 */ f32 unk160; - /* 0x164 */ UNK_TYPE1 pad164[0x24]; - /* 0x188 */ func_ptr updateFunc; - /* 0x18C */ UNK_TYPE1 type; - /* 0x18D */ u8 unk18D; - /* 0x18E */ u8 unk18E; - /* 0x18F */ u8 unk18F; - /* 0x190 */ s16 unk190; - /* 0x192 */ UNK_TYPE1 pad192[0x152]; - /* 0x2E4 */ f32 unk2E4; - /* 0x2E8 */ f32 unk2E8; - /* 0x2EC */ f32 unk2EC; - /* 0x2F0 */ f32 unk2F0; - /* 0x2F4 */ UNK_TYPE1 pad2F4[0x28]; - /* 0x31C */ ColliderSphere collision; -}; // size = 0x374 - -struct ActorEnTest { - /* 0x000 */ Actor base; - /* 0x144 */ UNK_TYPE1 pad144[0x10]; - /* 0x154 */ f32 unk154; - /* 0x158 */ UNK_TYPE1 pad158[0xB0]; - /* 0x208 */ u8 unk208; - /* 0x209 */ UNK_TYPE1 pad209[0x1]; - /* 0x20A */ u8 unk20A; - /* 0x20B */ UNK_TYPE1 pad20B[0x1]; - /* 0x20C */ ActorEnTest20C unk20C[20]; -}; // size = 0x6BC - -typedef struct { - /* 0x000 */ Actor base; - /* 0x144 */ s8 unk144; - /* 0x145 */ u8 unk145; - /* 0x146 */ u16 unk146; - /* 0x148 */ u16 unk148; - /* 0x14A */ u16 unk14A; - /* 0x14C */ u8 unk14C; - /* 0x14D */ UNK_TYPE1 pad14D[0x3]; - /* 0x150 */ ActorFunc unk150; -} ActorEnTest4; // size = 0x154 - -struct ActorObjBell { - /* 0x000 */ Actor base; - /* 0x144 */ UNK_TYPE1 pad144[0x18]; - /* 0x15C */ ColliderSphere unk15C; - /* 0x1B4 */ ColliderSphere unk1B4; - /* 0x20C */ UNK_TYPE1 pad20C[0x2]; - /* 0x20E */ s16 unk20E; - /* 0x210 */ UNK_TYPE1 pad210[0x4]; - /* 0x214 */ s16 unk214; - /* 0x216 */ UNK_TYPE1 pad216[0x12]; -}; // size = 0x228 - -struct ActorBgIknvObj { - /* 0x000 */ DynaPolyActor bg; - /* 0x15C */ ColliderCylinder collision; - /* 0x1A8 */ u32 displayListAddr; - /* 0x1AC */ ActorFunc updateFunc; -}; // size = 0x1B0 - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/spec b/spec index a91f653cf..8ca54bfc5 100644 --- a/spec +++ b/spec @@ -497,7 +497,7 @@ beginseg include "build/data/code/code_801BD830.data.o" include "build/src/code/z_fireobj.o" include "build/data/code/z_fireobj.data.o" - include "build/data/code/code_801BD910.data.o" + include "build/src/code/z_game_dlftbls.o" include "build/src/code/z_horse.o" include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index 74a3b7e5e..4e6518d14 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -173,7 +173,7 @@ void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h) { sFaultDrawContext->h = h; } -void FaultDrawer_SetInputCallback(void (*callback)()) { +void FaultDrawer_SetInputCallback(void* callback) { sFaultDrawContext->inputCallback = callback; } diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index f2cded98c..4be8a1094 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c new file mode 100644 index 000000000..4e2590a6a --- /dev/null +++ b/src/code/z_game_dlftbls.c @@ -0,0 +1,26 @@ +#include "global.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" +#include "overlays/gamestates/ovl_opening/z_opening.h" +#include "overlays/gamestates/ovl_select/z_select.h" +#include "overlays/gamestates/ovl_title/z_title.h" + +#define GAMESTATE_OVERLAY(name, init, destroy, size) \ + { \ + NULL, SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), 0, init, destroy, 0, 0, 0, size \ + } +#define GAMESTATE_OVERLAY_INTERNAL(init, destroy, size) \ + { NULL, 0, 0, NULL, NULL, 0, init, destroy, 0, 0, 0, size } + +GameStateOverlay gGameStateOverlayTable[] = { + GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), + GAMESTATE_OVERLAY(select, Select_Init, Select_Destroy, sizeof(SelectContext)), + GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), + GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(GlobalContext)), + GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)), + GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)), + GAMESTATE_OVERLAY(daytelop, Daytelop_Init, Daytelop_Destroy, sizeof(DaytelopContext)), +}; + +s32 graphNumGameStates = ARRAY_COUNT(gGameStateOverlayTable); diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index bae203c68..d2e71587d 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -8,6 +8,7 @@ void FileChoose_Destroy(GameState* thisx); typedef struct { /* 0x00000 */ GameState state; + /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; /* 0x000AC */ u8* parameterSegment; /* 0x000B0 */ u8* titleSegment; @@ -16,6 +17,7 @@ typedef struct { /* 0x00248 */ SkyboxContext skyboxCtx; /* 0x00470 */ MessageContext msgCtx; /* 0x12550 */ Font font; + /* 0x242DC */ UNK_TYPE1 unk_242DC[4]; /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; From 3aeadb42b8a195b3d2f67ce71fcd184ddf26d856 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 13 Oct 2021 03:27:29 +1100 Subject: [PATCH 37/86] Macros: `PLAYER` -> `GET_PLAYER(globalCtx)` and `ACTIVE_CAM` -> `GET_ACTIVE_CAM(globalCtx)` (#283) * PLAYER -> GET_PLAYER(globalCtx), ACTIVE_CAM -> GET_ACTIVE_CAM(globalCtx) * formatter * PR Suggestions * `FIRST_ENEMY` -> `GET_FIRST_ENEMY(globalCtx)` * Fix merge conflicts --- include/macros.h | 7 ++-- src/code/code_800E8EA0.c | 4 +-- src/code/z_collision_check.c | 4 +-- src/code/z_effect_soft_sprite_old_init.c | 2 +- src/code/z_en_item00.c | 4 +-- src/code/z_quake.c | 6 ++-- src/code/z_room.c | 2 +- src/code/z_snap.c | 4 +-- .../actors/ovl_Arms_Hook/z_arms_hook.c | 6 ++-- .../ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c | 6 ++-- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 10 +++--- .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 2 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 8 ++--- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 2 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 6 ++-- .../actors/ovl_Door_Spiral/z_door_spiral.c | 10 +++--- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 6 ++-- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 24 ++++++------- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 2 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 2 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 4 +-- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 2 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 24 ++++++------- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 8 ++--- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 4 +-- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 6 ++-- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 10 +++--- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 8 ++--- .../actors/ovl_En_Firefly/z_en_firefly.c | 6 ++-- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 10 +++--- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 22 ++++++------ .../actors/ovl_En_Guruguru/z_en_guruguru.c | 8 ++--- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 6 ++-- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 6 ++-- src/overlays/actors/ovl_En_In/z_en_in.c | 8 ++--- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 20 +++++------ src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 16 ++++----- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 18 +++++----- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 2 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 2 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 4 +-- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 4 +-- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 22 ++++++------ src/overlays/actors/ovl_En_Owl/z_en_owl.c | 6 ++-- .../actors/ovl_En_Pamera/z_en_pamera.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 6 ++-- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 10 +++--- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 18 +++++----- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 16 ++++----- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 2 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 14 ++++---- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 18 +++++----- .../actors/ovl_En_Suttari/z_en_suttari.c | 20 +++++------ src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 36 +++++++++---------- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 8 ++--- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 10 +++--- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 14 ++++---- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 26 +++++++------- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 6 ++-- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 16 +++++---- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 4 +-- src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c | 2 +- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.c | 2 +- .../actors/ovl_Obj_Funen/z_obj_funen.c | 2 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 4 +-- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 2 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 4 +-- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 4 +-- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 2 +- 74 files changed, 301 insertions(+), 300 deletions(-) diff --git a/include/macros.h b/include/macros.h index fc03fa4ff..915a3fff3 100644 --- a/include/macros.h +++ b/include/macros.h @@ -17,8 +17,7 @@ #define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr)-0x80000000) #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) -// Currently most often called ctxt in MM, TODO: Refactor names when its used -#define ACTIVE_CAM globalCtx->cameraPtrs[globalCtx->activeCamera] +#define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera]) #define MAIN_CAM 0 #define SUBCAM_FREE 0 @@ -37,9 +36,9 @@ } \ (void)0 -#define PLAYER ((Player*)globalCtx->actorCtx.actorList[ACTORCAT_PLAYER].first) +#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorList[ACTORCAT_PLAYER].first) -#define FIRST_ENEMY ((Actor*)globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first) +#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorList[ACTORCAT_ENEMY].first) // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index ca2e9e841..754b8759d 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -54,7 +54,7 @@ s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4) } s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; s16 sVar3A; @@ -83,7 +83,7 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* } s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; s16 sVar3A; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 40ea71ee0..6ea0b2fcf 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -2913,8 +2913,8 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, /** * Iterates through all AT colliders, testing them for AC collisions with each AC collider, setting the info regarding * the collision for each AC and AT collider that collided. Then spawns hitmarks and plays sound effects for each - * successful collision. To collide, an AT collider must share a type (PLAYER, ENEMY, or BOMB) with the AC collider and - * the toucher and bumper elements that overlapped must share a dmgFlag. + * successful collision. To collide, an AT collider must share a type (AC_TYPE_PLAYER, AC_TYPE_ENEMY, or AC_TYPE_OTHER) + * with the AC collider and the toucher and bumper elements that overlapped must share a dmgFlag. */ void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) { Collider** col; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 39cc4af73..aa461153c 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -899,7 +899,7 @@ void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* #endif void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EffectSsFireTail_SpawnFlame(globalCtx, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, colorIntensity); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 13be40c0a..0a412c2da 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -403,7 +403,7 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { } void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->unk14A != 0) { if (Actor_HasParent(&this->actor, globalCtx) == 0) { @@ -439,7 +439,7 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { EnItem00* this = THIS; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 sp38 = player->stateFlags3 & 0x1000; s32 getItemId = GI_NONE; s32 pad2; diff --git a/src/code/z_quake.c b/src/code/z_quake.c index b45e02381..aeb8370ab 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -444,7 +444,7 @@ void Quake2_Update(void) { Player* player; GlobalContext* globalCtx = sQuake2Context.globalCtx; PosRot playerPosRot; - Camera* camera = globalCtx->cameraPtrs[globalCtx->activeCamera]; + Camera* camera = GET_ACTIVE_CAM(globalCtx); f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f); if (sQuake2Context.type != 0) { @@ -605,7 +605,7 @@ void Quake2_Update(void) { angle1 = 0x3F0; angle2 = 0x156; sQuake2Context.countdown = 2; - player = PLAYER; + player = GET_PLAYER(globalCtx); if (&player->actor != NULL) { func_800B8248(&playerPosRot, player); @@ -654,7 +654,7 @@ void Quake2_Update(void) { angle1 = 0x3F0; angle2 = 0x156; sQuake2Context.countdown = 2; - player = PLAYER; + player = GET_PLAYER(globalCtx); angle1Speed = 359.2f; angle2Speed = -18.5f; rotX = 0.0f; diff --git a/src/code/z_room.c b/src/code/z_room.c index 0a11f83fe..5f900ea87 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -114,7 +114,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { gSegments[3] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); Scene_ProcessHeader(globalCtx, (SceneCmd*)roomCtx->currRoom.segment); - func_80123140(globalCtx, PLAYER); + func_80123140(globalCtx, GET_PLAYER(globalCtx)); Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && diff --git a/src/code/z_snap.c b/src/code/z_snap.c index b6538a685..120861ff5 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -119,7 +119,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, s32 ret = 0; u32 unk2; - camera = ACTIVE_CAM; + camera = GET_ACTIVE_CAM(globalCtx); distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { @@ -148,7 +148,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, } actors[0] = actor; - actors[1] = &PLAYER->actor; + actors[1] = &GET_PLAYER(globalCtx)->actor; if (CollisionCheck_LineOCCheck(globalCtx, &globalCtx->colChkCtx, pos, &camera->eye, actors, 2) != 0) { func_8013A41C(0x3b); ret |= 0x3b; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 07d68d030..2e99b093f 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -72,7 +72,7 @@ void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) { if (this->actor.parent == NULL) { ArmsHook_SetupAction(this, ArmsHook_Shoot); func_800B6C04(&this->actor, 20.0f); - this->actor.parent = &PLAYER->actor; + this->actor.parent = &GET_PLAYER(globalCtx)->actor; this->timer = 26; } } @@ -120,7 +120,7 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { } void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->actor.parent == NULL) || (!func_801240C8(player))) { ArmsHook_DetachHookFromActor(this); @@ -288,7 +288,7 @@ static Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f }; void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { ArmsHook* this = THIS; f32 f0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx);; if (player->actor.draw != NULL && player->rightHandType == 0xB) { Vec3f sp68; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 55d5564c8..68371797b 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -59,7 +59,7 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = BgCtowerRot_CorridorRotate; return; } - player = PLAYER; + player = GET_PLAYER(globalCtx); if (this->dyna.actor.params == MAIN_DOOR) { BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06017410); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x4000; @@ -85,7 +85,7 @@ void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f offset; f32 rotZ; f32 offsetDiffZ; @@ -128,7 +128,7 @@ void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { } void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f offset; Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 7df92fc57..691cf9992 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -523,8 +523,8 @@ void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU sp44.x = this->dyna.actor.home.pos.x + unkStruct1->unk_14.x; sp44.y = this->unk_16C + unkStruct1->unk_14.y; sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; - func_8013ECE0(Math3D_DistanceSquared(&sp44, &PLAYER->actor.world.pos), 255, 20, 150); - quake = Quake_Add(ACTIVE_CAM, 3); + func_8013ECE0(Math3D_DistanceSquared(&sp44, &GET_PLAYER(globalCtx)->actor.world.pos), 255, 20, 150); + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 7, 0, 0, 0); Quake_SetCountdown(quake, 12); @@ -540,8 +540,8 @@ void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU void func_80A9C18C(BgHakuginPost* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; - Camera* activeCam = ACTIVE_CAM; + Player* player = GET_PLAYER(globalCtx); + Camera* activeCam = GET_ACTIVE_CAM(globalCtx); s16 quake; func_8013ECE0(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, @@ -814,7 +814,7 @@ void func_80A9CE00(BgHakuginPost* this) { void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); ColliderCylinder* collider; s32 yDiff; s32 i; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 6c590ab9d..986b8b8ae 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -146,7 +146,7 @@ void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx) { this->dyna.actor.velocity.y *= 0.978f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - quake = Quake_Add(ACTIVE_CAM, 3); + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quake, 0x5420); Quake_SetQuakeValues(quake, 4, 0, 0, 0); Quake_SetCountdown(quake, 12); diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index fa4bdd85d..123a1248f 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -49,7 +49,7 @@ static InitChainEntry sInitChain[] = { s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { s32 pad2[2]; Vec3f offset; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); @@ -66,7 +66,7 @@ void func_80C0A838(BgIkninSusceil* this, GlobalContext* globalCtx) { void func_80C0A86C(BgIkninSusceil* this, GlobalContext* globalCtx, s16 verticalMag, s16 countdown, s32 arg4) { s32 pad; - s16 quake = Quake_Add(ACTIVE_CAM, 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quake, 0x7B30); Quake_SetQuakeValues(quake, verticalMag, 0, 0, 0); @@ -84,7 +84,7 @@ s32 func_80C0A95C(BgIkninSusceil* this, GlobalContext* globalCtx) { s32 phi_t0 = true; s32 i; f32 new_var; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f offset; f32 temp1, temp2, temp3, temp4; @@ -218,7 +218,7 @@ void func_80C0AE5C(BgIkninSusceil* this, GlobalContext* globalCtx) { void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; BgIkninSusceil* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->unk168 == 0) && (this->unk166 > 0) && (player->stateFlags3 & 0x100) && (player->unk_B48 > 1000.0f)) { this->unk168 = 2; diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 063af19d2..72b196ab0 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -25,7 +25,7 @@ extern Gfx D_06000088[]; extern CollisionHeader D_060011C0; void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 cutsceneId = this->dyna.actor.cutscene; s16 prevTimer; diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index ba8920246..4db7316e4 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -118,7 +118,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 dooranaType = GET_DOORANA_TYPE(this); s8 pad[4]; s32 entranceIndex; @@ -187,7 +187,7 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } if ((this->actor.yDistToPlayer <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { - player = PLAYER; + player = GET_PLAYER(globalCtx); player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; } @@ -197,7 +197,7 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera])); + this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 e767e3f35..1978756a2 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -223,7 +223,7 @@ void DoorSpiral_WaitForObject(DoorSpiral* this, GlobalContext* globalCtx) { */ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 yOffset, f32 spiralWidth, f32 spiralHeight) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f target; Vec3f offset; @@ -244,7 +244,7 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 * Checks if the player should climb the stairs. */ s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(func_801233E4(globalCtx))) { SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; @@ -277,7 +277,7 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { if (this->shouldClimb) { DoorSpiral_SetupAction(this, DoorSpiral_PlayerClimb); } else if (DoorSpiral_PlayerShouldClimb(this, globalCtx)) { - player = PLAYER; + player = GET_PLAYER(globalCtx); player->doorType = 4; player->doorDirection = this->orientation; @@ -293,7 +293,7 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { * Player is climbing the stairs. */ void DoorSpiral_PlayerClimb(DoorSpiral* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(player->stateFlags1 & 0x20000000)) { DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); @@ -304,7 +304,7 @@ void DoorSpiral_PlayerClimb(DoorSpiral* this, GlobalContext* globalCtx) { void DoorSpiral_Update(Actor* thisx, GlobalContext* globalCtx) { DoorSpiral* this = (DoorSpiral*)thisx; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((!(player->stateFlags1 & 0x100004C0)) || (this->actionFunc == DoorSpiral_WaitForObject)) { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index b5a6f4c86..bfb2cc728 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -163,7 +163,7 @@ void func_80918FE4(EffDust* this, GlobalContext* globalCtx) { void func_80919230(EffDust* this, GlobalContext* globalCtx) { s16 theta; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor* parent = this->actor.parent; f32* distanceTraveled = this->distanceTraveled; s32 i; @@ -262,7 +262,7 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { s16 sp92; Vec3f activeCamEye; - activeCamEye = ACTIVE_CAM->eye; + activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; sp92 = Math_Vec3f_Yaw(&activeCamEye, &thisx->world.pos); OPEN_DISPS(gfxCtx); @@ -313,7 +313,7 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { Vec3f* initialPositions; s32 i; f32 aux; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); OPEN_DISPS(gfxCtx); func_8012C28C(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index f1da2dc1d..a639a10b8 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -513,7 +513,7 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; @@ -559,7 +559,7 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { } void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); DECR(this->idleTimer); @@ -611,7 +611,7 @@ void EnBigpo_SetupSpinAttack(EnBigpo* this) { } void EnBigpo_SpinAttack(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yawDiff; SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -636,7 +636,7 @@ void EnBigpo_SetupSpinDown(EnBigpo* this) { } void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 100.0f, 0.3f, 5.0f, 1.0f); @@ -699,7 +699,7 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer++; if (this->idleTimer < 8) { - cam = func_800DFCDC(ACTIVE_CAM) + 0x4800; + cam = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->idleTimer < 5) { unkTemp = (this->idleTimer << 0xC) - 0x4000; // 1.4.0...1 is NOT 1.4, the rodata demands it @@ -869,7 +869,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) s32 fireCount = 0; // count the number of possible fires we can find (4 in vanilla) - for (enemyPtr = FIRST_ENEMY; enemyPtr != NULL; enemyPtr = enemyPtr->next) { + for (enemyPtr = GET_FIRST_ENEMY(globalCtx); enemyPtr != NULL; enemyPtr = enemyPtr->next) { if (enemyPtr->id == ACTOR_EN_BIGPO && enemyPtr->params == ENBIGPO_POSSIBLEFIRE) { fireCount++; } @@ -887,7 +887,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) // for available possiblefires, pick three to be random fires for (fireIndex = 0; fireIndex < ARRAY_COUNT(this->fires); fireIndex++, fireCount--) { - enemyPtr = FIRST_ENEMY; + enemyPtr = GET_FIRST_ENEMY(globalCtx); randomIndex = ((s32)Rand_ZeroFloat(fireCount)) % fireCount; while (enemyPtr != NULL) { @@ -920,7 +920,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) } // remove unused fires - for (enemyPtr = FIRST_ENEMY; enemyPtr != NULL; enemyPtr = enemyPtr->next) { + for (enemyPtr = GET_FIRST_ENEMY(globalCtx); enemyPtr != NULL; enemyPtr = enemyPtr->next) { if (enemyPtr->id == ACTOR_EN_BIGPO && enemyPtr->params == ENBIGPO_POSSIBLEFIRE) { randomFirePo = (EnBigpo*)enemyPtr; randomFirePo->actionFunc = EnBigpo_Die; @@ -1227,7 +1227,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { */ void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = (EnBigpo*)thisx; - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(ACTIVE_CAM)); + this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); this->actionFunc(this, globalCtx); } @@ -1357,7 +1357,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(ACTIVE_CAM)), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1377,7 +1377,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { Gfx* dispHead; Vec3f vec1; Vec3f vec2; - Camera* cam = ACTIVE_CAM; + Camera* cam = GET_ACTIVE_CAM(globalCtx); if (cam != NULL) { Math_Vec3f_Diff(&cam->eye, &cam->at, &vec1); @@ -1437,7 +1437,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(ACTIVE_CAM)), MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 9f06cdc16..5cce23a9c 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -80,7 +80,7 @@ static struct_80B8E1A8 D_809CDC7C[] = { }; void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp58; s32 pad[2]; diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 7a4ab5471..e0c520f9f 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -509,7 +509,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Camera* camera; s32 pad; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 93d43230a..2bb487064 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -423,7 +423,7 @@ void func_80B3EE8C(EnDai* this, GlobalContext* globalCtx) { } void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.unk1202A == 3) && (globalCtx->msgCtx.unk1202E == 1)) { @@ -563,7 +563,7 @@ void EnDai_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { EnDai* this = THIS; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!func_80B3E7C8(this, globalCtx) && func_80B3E69C(this, globalCtx)) { func_80B3F044(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 4dd551259..69042a822 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -307,7 +307,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { - player = PLAYER; + player = GET_PLAYER(globalCtx); sp58.x = player->actor.world.pos.x; sp58.z = player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index a134bc874..cf3337c0a 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -167,7 +167,7 @@ void func_80989140(SkelAnime* skelAnime, ActorAnimationEntryS arg1[], s32 arg2) } void func_80989204(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; @@ -455,7 +455,7 @@ s32 func_80989FC8(GlobalContext* globalCtx) { } void func_8098A064(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags3 & 0x20000000) { if (D_8098C2A4.unk_00 == 99) { @@ -483,7 +483,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } s32 func_8098A1B4(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); switch (player->transformation) { case PLAYER_FORM_GORON: @@ -503,7 +503,7 @@ s32 func_8098A1B4(EnDg* this, GlobalContext* globalCtx) { } void func_8098A234(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(this->actor.bgCheckFlags & 0x20)) { switch (player->transformation) { @@ -562,7 +562,7 @@ void func_8098A234(EnDg* this, GlobalContext* globalCtx) { } void func_8098A468(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; @@ -586,7 +586,7 @@ void func_8098A468(EnDg* this, GlobalContext* globalCtx) { } void func_8098A55C(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_HUMAN) { func_80989E18(this, globalCtx); @@ -627,7 +627,7 @@ void func_8098A618(EnDg* this, GlobalContext* globalCtx) { } void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 phi_a1; if (this->actor.xzDistToPlayer < 250.0f) { @@ -678,7 +678,7 @@ void func_8098A89C(EnDg* this, GlobalContext* globalCtx) { } void func_8098A938(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; @@ -726,7 +726,7 @@ void func_8098AAAC(EnDg* this, GlobalContext* globalCtx) { } void func_8098AB48(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(this->actor.bgCheckFlags & 1)) { this->actionFunc = func_8098AF98; @@ -834,7 +834,7 @@ void func_8098AF98(EnDg* this, GlobalContext* globalCtx) { } void func_8098B004(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; @@ -1070,7 +1070,7 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { } void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->actor.bgCheckFlags & 1) { if (this->unk_280 & 0x10) { @@ -1147,7 +1147,7 @@ void EnDg_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { EnDg* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index add94bf4b..cf6a959b4 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -425,7 +425,7 @@ void func_8089AD70(EnDinofos* this) { } s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 temp_v1_2; Actor* temp_v0; @@ -480,7 +480,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { Camera* camera = Play_GetCamera(globalCtx, this->camId); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp3C; SkelAnime_ChangeAnim(&this->skelAnime, &D_06001CCC, 1.0f, SkelAnime_GetFrameCount(&D_06001CCC.common), @@ -712,7 +712,7 @@ void func_8089BB60(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->actionFunc != func_8089BD28) { s16 rotY = player->actor.shape.rot.y - this->actor.shape.rot.y; @@ -744,7 +744,7 @@ void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 phi_v0; f32 sp2C = 0.0f; 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 30b40c499..5c354d5d0 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -172,7 +172,7 @@ void func_80B3CD1C(EnDnp* this) { } s32 func_80B3CDA4(EnDnp* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_s0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Vec3f sp3C; Vec3f sp30; @@ -305,7 +305,7 @@ void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx) { } void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->unk_32E != 0) && (func_80152498(&globalCtx->msgCtx) == 2)) { Actor_MarkForDeath(&this->actor); 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 ac92ed454..861095e14 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -257,7 +257,7 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { } s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u16 temp = globalCtx->msgCtx.unk11F04; if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { @@ -297,7 +297,7 @@ s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { } void func_80A52C6C(EnDnq* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp34 = { 0.0f, 0.0f, 110.0f }; Vec3f sp28; @@ -335,7 +335,7 @@ s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { } void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (yaw <= 0x3800) { diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 1249e2430..7d33a75ad 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -128,7 +128,7 @@ void func_8092C6FC(EnDns* this, GlobalContext* globalCtx) { } void func_8092C740(EnDns* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Vec3f sp34; Vec3f sp28; @@ -171,7 +171,7 @@ void func_8092C934(EnDns* this) { } s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(gSaveContext.weekEventReg[23] & 0x20)) { if (player->transformation != PLAYER_FORM_DEKU) { @@ -260,7 +260,7 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { } s32 func_8092CC68(GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad[2]; s32 ret = false; s16 bgId; @@ -276,7 +276,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { } s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp3C = player->actor.world.pos; Vec3f sp30 = this->actor.world.pos; @@ -382,7 +382,7 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { } void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 sp22 = this->actor.world.rot.y; if (ENDNS_GET_4000(&this->actor)) { diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index a411f81ab..e913b669b 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -389,7 +389,7 @@ void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { } void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(yDiff) < 0x4000) { @@ -521,7 +521,7 @@ s32 func_8087721C(EnDodongo* this) { } s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; Vec3f sp44; @@ -571,7 +571,7 @@ void func_80877494(EnDodongo* this) { } void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp30; s16 temp_v1; @@ -827,7 +827,7 @@ void func_80878354(EnDodongo* this) { } void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp20; this->timer++; diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index a6297afed..6590796ae 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -194,7 +194,7 @@ void EnFirefly_Ignite(EnFirefly* this) { } s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 distFromHome; if (this->actor.params != KEESE_NORMAL_PERCH) { @@ -417,7 +417,7 @@ void EnFirefly_SetupDiveAttack(EnFirefly* this) { } void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f preyPos; SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -607,7 +607,7 @@ void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) { } void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f preyPos; SkelAnime_FrameUpdateMatrix(&this->skelAnime); 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 bace8a29b..291495635 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -708,7 +708,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->animationIdx == 4) { s16 curFrame = this->skelAnime.animCurrentFrame; @@ -807,7 +807,7 @@ void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); if (talkState == 5 && func_80147624(globalCtx)) { @@ -903,7 +903,7 @@ void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 itemGiven; u8 buttonItem; @@ -941,7 +941,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (talkState == 4 && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -989,7 +989,7 @@ void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { } this->actor.parent = NULL; if (ENFSN_IS_SHOP(&this->actor) && !this->isSelling) { - func_80123D50(globalCtx, PLAYER, 18, 21); + func_80123D50(globalCtx, GET_PLAYER(globalCtx), 18, 21); } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { 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 102fe9bc5..04ddc07a4 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -307,7 +307,7 @@ void func_80961F00(GlobalContext* globalCtx) { } void func_80961F38(GlobalContext* globalCtx, Vec3f* arg1, s16* arg2, s16 arg3, s16 arg4, s16 arg5) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 sp42; s16 sp40; Vec3f sp34 = player->actor.focus.pos; @@ -381,7 +381,7 @@ void func_809622FC(EnFu* this) { } void func_80962340(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->unk_54A == 2) { this->actor.flags |= 0x10000; @@ -451,7 +451,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { } void func_80962660(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_80147624(globalCtx)) { switch (this->unk_552) { @@ -636,7 +636,7 @@ void func_809629F8(EnFu* this) { } void func_80962A10(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; this->unk_53C = 0; @@ -674,7 +674,7 @@ void func_80962BA8(EnFu* this) { } void func_80962BCC(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bouceHeight < 30.0f) || (fuKaiten->bounceSpeed < 600)) { @@ -706,7 +706,7 @@ void func_80962D48(EnFu* this) { } void func_80962D60(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; if ((fuKaiten->rotationSpeed < 100) || (fuKaiten->bouceHeight < 40.0f) || (fuKaiten->bounceSpeed < 600)) { @@ -747,7 +747,7 @@ void func_80962F10(EnFu* this) { } void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; switch (this->unk_542) { @@ -895,7 +895,7 @@ void func_80963610(EnFu* this) { } void func_80963630(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && @@ -943,7 +943,7 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { } s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 sp28; f32 phi_f0; s16 sp22; @@ -1175,7 +1175,7 @@ void func_80963F88(EnFu* this, GlobalContext* globalCtx) { } void func_80963FF8(EnFu* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; @@ -1424,7 +1424,7 @@ void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - s16 activeCam = func_800DFC68(ACTIVE_CAM); + s16 activeCam = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); s32 i; for (i = 0; i < len; i++, ptr++) { diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 32c8cac05..b87748b8a 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -154,7 +154,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { SkelAnime_FrameUpdateMatrix(&this->skelAnime); if (this->unk270 != 0) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->textIdIndex = 3; if (player->transformation == PLAYER_FORM_DEKU) { @@ -178,7 +178,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { } void func_80BC701C(EnGuruguru* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->unk268 != 0) && (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU)) { @@ -191,7 +191,7 @@ void func_80BC701C(EnGuruguru* this, GlobalContext* globalCtx) { } void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->unk268 != 0) { SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -322,7 +322,7 @@ void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx) { void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { EnGuruguru* this = THIS; s32 yaw; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yawTemp; if (!gSaveContext.isNight) { diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 779e32edd..54c62e52d 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -178,7 +178,7 @@ void func_80BCF468(EnHg* this) { } void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; this->actor.speedXZ = 1.6f; @@ -202,7 +202,7 @@ void func_80BCF5F0(EnHg* this) { } void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos) < 200.0f) { func_80BCF468(this); @@ -351,7 +351,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->actor.colChkInfo.health == 1 && !(fabsf(this->actor.yDistToPlayer) >= 80.0f)) { if (player->stateFlags2 & 0x08000000) { 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 1d7dc33f6..ad9e4e873 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -106,7 +106,7 @@ void EnHoll_SetupAction(EnHoll* this) { } void EnHoll_SetPlayerSide(GlobalContext* globalCtx, EnHoll* this, Vec3f* transformedPlayerPos) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor_CalcOffsetOrientedToDrawRotation(&this->actor, transformedPlayerPos, &player->actor.world.pos); this->playerSide = (transformedPlayerPos->z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; @@ -217,7 +217,7 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { } void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 useViewEye = D_801D0D50 || globalCtx->csCtx.state != 0; Vec3f transformedPlayerPos; f32 enHollTop; @@ -307,7 +307,7 @@ void EnHoll_RoomTransitionIdle(EnHoll* this, GlobalContext* globalCtx) { void EnHoll_Update(Actor* thisx, GlobalContext* globalCtx) { EnHoll* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && !(player->stateFlags1 & 0x200)) { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index e2b0e91ca..e3b34d19f 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -251,7 +251,7 @@ s32 func_808F3310(EnIn* this, GlobalContext* globalCtx) { } s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->colliderJntSph.base.atFlags & AT_HIT) { this->colliderJntSph.base.atFlags &= ~AT_HIT; @@ -275,7 +275,7 @@ s32 func_808F33B8(void) { } void func_808F3414(EnIn* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp30; if (this->unk23D == 0) { @@ -1262,7 +1262,7 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { if (*arg3 == 1) { s32 requiredScopeTemp; - player = PLAYER; + player = GET_PLAYER(globalCtx); func_808F5994(this, globalCtx, &player->actor.world.pos, 0xC80); } else { rotDiff = this->actor.home.rot.y - this->actor.world.rot.y; @@ -1516,7 +1516,7 @@ void EnIn_Update(Actor* thisx, GlobalContext* globalCtx) { } void func_808F6334(EnIn* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 newUnk4C8; newUnk4C8 = func_80152498(&globalCtx->msgCtx); diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 41d52159d..a6aaa90c4 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2684,7 +2684,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { s32 requiredScopeTemp; if ((this->actor.xzDistToPlayer < 350.0f) && ((globalCtx->gameplayFrames & 0x60) != 0)) { - player = PLAYER; + player = GET_PLAYER(globalCtx); temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f; temp_v1 -= this->actor.shape.rot.x; substruct->unk26.x = CLAMP(temp_v1, -2500, 2500); @@ -2744,7 +2744,7 @@ void func_80B48DE4(EnInvadepoh* this) { void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; @@ -3092,7 +3092,7 @@ void func_80B49DA0(EnInvadepoh* this) { void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; @@ -3222,7 +3222,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk304, 6, this->behaviorInfo.unk4C, 40); if (this->actor.xzDistToPlayer < 300.0f) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); temp_v1_2 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); temp_v1_2 *= 0.85f; @@ -3318,7 +3318,7 @@ void func_80B4A7C0(EnInvadepoh* this) { void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; @@ -3554,7 +3554,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (sp38 && this->actor.update != NULL) { SkelAnime_FrameUpdateMatrix(&this->skelAnime); - player = PLAYER; + player = GET_PLAYER(globalCtx); Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.9f); @@ -3854,7 +3854,7 @@ void func_80B4BFFC(EnInvadepoh* this) { void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; @@ -3886,7 +3886,7 @@ void func_80B4C1BC(EnInvadepoh* this) { void func_80B4C218(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor* temp_v0; s16 temp_v1; s16 diff; @@ -4079,7 +4079,7 @@ void func_80B4CAB0(EnInvadepoh* this) { void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; @@ -4108,7 +4108,7 @@ void func_80B4CC70(EnInvadepoh* this) { void func_80B4CCCC(EnInvadepoh* this, GlobalContext* globalCtx) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v1; s16 diff; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 6a37e5e05..457178720 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -313,7 +313,7 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { } void func_80B411DC(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); switch (arg2) { case 0: @@ -508,7 +508,7 @@ void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_80B4163C(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { @@ -534,7 +534,7 @@ void func_80B41A48(EnKgy* this, GlobalContext* globalCtx) { void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { s32 temp_v0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); if (func_80152498(&globalCtx->msgCtx) == 0x10) { @@ -577,7 +577,7 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { } void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (&this->actor != player->targetActor) { this->actionFunc = func_80B42508; @@ -620,7 +620,7 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { u16 temp; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 3)) { func_80B40BC0(this, 4); @@ -758,7 +758,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC46: case 0xC55: - func_80123D50(globalCtx, PLAYER, 0x12, 0x15); + func_80123D50(globalCtx, GET_PLAYER(globalCtx), 0x12, 0x15); player->unk_A87 = 0; this->unk_29C &= ~0x8; globalCtx->msgCtx.unk11F10 = 0; @@ -842,7 +842,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; @@ -881,7 +881,7 @@ void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 6f4c463cf..b83fba1b4 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -160,7 +160,7 @@ void EnMa4_ChangeAnim(EnMa4* this, s32 index) { } void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 flag; if (this->unk_1D8.unk_00 == 0 && @@ -346,7 +346,7 @@ void EnMa4_SetupWait(EnMa4* this) { } void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { @@ -506,7 +506,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 aux; if (func_80147624(globalCtx) != 0) { @@ -708,7 +708,7 @@ void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); @@ -719,7 +719,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (globalCtx->interfaceCtx.unk_280 == 8) { this->actionFunc = EnMa4_HorsebackGameWait; @@ -729,7 +729,7 @@ void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { static s16 D_80AC0258 = 0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); player->stateFlags3 |= 0x400; EnMa4_HorsebackGameCheckPlayerInteractions(this, globalCtx); @@ -756,7 +756,7 @@ void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { static s32 sFrameCounter = 0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; @@ -848,7 +848,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { EnMa4_ChangeAnim(this, 7); } } else { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x20; func_800B85E0(&this->actor, globalCtx, 200.0f, -1); @@ -863,7 +863,7 @@ void EnMa4_SetupEndEponasSongCs(EnMa4* this) { } void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actor.flags |= 0x10000; if (func_800B84D0(&this->actor, globalCtx) != 0) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 1c9987a8e..b8f7f969b 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -1299,7 +1299,7 @@ void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { } void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 flag; SkelAnime_FrameUpdateMatrix(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 76ad7447c..786dee4ba 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -143,7 +143,7 @@ static void* sEyeTextures[] = { }; void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 flag = this->unk_32C == 2 ? true : false; if (this->unk_32C == 0 || this->actor.parent == NULL) { diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 41d80f637..d1f4a0d90 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -238,7 +238,7 @@ void EnMinifrog_SetCamera(EnMinifrog* this, GlobalContext* globalCtx) { Vec3f eye; s32 i; - eye = ACTIVE_CAM->eye; + eye = GET_ACTIVE_CAM(globalCtx)->eye; yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); vec5.x = this->actor.world.pos.x - (5.0f * Math_SinS(yaw) * Math_CosS(pitch)); diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 07b219fc8..18be1dc95 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -234,7 +234,7 @@ void EnMinislime_Disappear(EnMinislime* this, GlobalContext* globalCtx) { } void EnMinislime_SetupFall(EnMinislime* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yaw; this->collider.base.atFlags |= AT_ON; @@ -762,7 +762,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 2) { - player = PLAYER; + player = GET_PLAYER(globalCtx); vec1.x = this->actor.world.pos.x; vec1.z = this->actor.world.pos.z; vec1.y = player->actor.world.pos.y + player->actor.yDistToWater; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 1a6dfb9ea..f3af54caf 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -638,7 +638,7 @@ void EnNiw_SetupRunAway(EnNiw* this) { } void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f tempVec3f = D_808934E8; s16 temp298; f32 dX; @@ -736,7 +736,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = (EnNiw*)thisx; s8 pad0; s16 i; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 pad1; s16 featherCount; Vec3f pos; diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 45c8b9bf0..bae091c19 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -83,7 +83,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { EnNutsball* this = THIS; GlobalContext* globalCtx2 = globalCtx; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f worldPos; Vec3s worldRot; Vec3f spawnBurstPos; 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 d7f9e18bc..046f3bb80 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -197,7 +197,7 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { } void EnOssan_RotateHead(EnOssan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->actor.params == ENOSSAN_PART_TIME_WORKER) { if (player->transformation == PLAYER_FORM_ZORA) { @@ -262,7 +262,7 @@ void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { } void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_800B84D0(&this->actor, globalCtx); globalCtx->msgCtx.unk11F22 = 0x43; @@ -327,7 +327,7 @@ void EnOssan_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* t } void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); if (func_800B84D0(&this->actor, globalCtx)) { @@ -525,7 +525,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; u8 talkState = func_80152498(&globalCtx->msgCtx); s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnOssan_RotateHead(this, globalCtx); if (talkState == 5 && func_80147624(globalCtx)) { @@ -557,7 +557,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -583,7 +583,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u8 cursorIdx; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { @@ -944,7 +944,7 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx) } void EnOssan_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnOssan* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; @@ -1080,7 +1080,7 @@ void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnGirlA* item; if (talkState == 4) { @@ -1120,7 +1120,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1341,7 +1341,7 @@ void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { } u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); if (textId != 0) { @@ -1374,7 +1374,7 @@ u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) } u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x36); if (textId != 0) { diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 36580181a..04c9e0fd2 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -224,7 +224,7 @@ void EnOwl_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_8095A920(EnOwl* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 6, 0x3E8, 0xC8); @@ -485,7 +485,7 @@ void func_8095B3DC(EnOwl* this, GlobalContext* globalCtx) { } void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags3 & 0x10000000) { this->actor.textId = 0xBF1; @@ -1071,7 +1071,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx) { EnOwl* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags3 & 0x10000000) { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 7a99b804a..94f8605af 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -432,7 +432,7 @@ void func_80BD909C(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK && (this->actionFunc != func_80BD8758) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD8A7C) && 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 9e47e89bb..ca90a1fd4 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -972,7 +972,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; static Color_RGBA8 primColor = { 250, 250, 250, 255 }; static Color_RGBA8 envColor = { 180, 180, 180, 255 }; - s16 yaw = BINANG_ROT180(func_800DFCDC(ACTIVE_CAM)); + s16 yaw = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); Vec3f vec1; Vec3f vel; s32 i; @@ -1245,7 +1245,7 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) // Zooms in on Snapper spawn point Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); - this->quake = Quake_Add(ACTIVE_CAM, 6); + this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); Quake_SetSpeed(this->quake, 18000); Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); Quake_SetCountdown(this->quake, 15); @@ -1268,7 +1268,7 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { this->actor.params = GEKKO_GET_SNAPPER; Quake_RemoveFromIdx(this->quake); - this->quake = Quake_Add(ACTIVE_CAM, 3); + this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(this->quake, 20000); Quake_SetQuakeValues(this->quake, 17, 0, 0, 0); Quake_SetCountdown(this->quake, 12); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 161067b29..7e186e4a1 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -189,7 +189,7 @@ void EnPoh_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { - Camera* activeCam = ACTIVE_CAM; + Camera* activeCam = GET_ACTIVE_CAM(globalCtx); Vec3f sp20; f32 temp_f0; @@ -208,7 +208,7 @@ void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { } void func_80B2C9B8(EnPoh* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Math_StepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 1.0f); this->actor.world.pos.y += 2.5f * Math_SinS(this->unk_18D * 0x800); @@ -290,7 +290,7 @@ void func_80B2CD14(EnPoh* this) { } void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 yawDiff; SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -413,7 +413,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { this->unk_18E++; if (this->unk_18E < 8) { - sp38 = func_800DFCDC(ACTIVE_CAM) + 0x4800; + sp38 = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->unk_18E < 5) { sp3A = (this->unk_18E * 0x1000) - 0x4000; sp44.y = (Math_SinS(sp3A) * 23.0f) + (this->actor.world.pos.y + 40.0f); @@ -1013,7 +1013,7 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - SysMatrix_InsertYRotation_f((func_800DFCDC(ACTIVE_CAM) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + SysMatrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06003850); diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index eb2bfc030..8105dfb66 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -292,7 +292,7 @@ void func_80BA59F0(EnRailgibud* this) { } void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 rot = this->actor.shape.rot.y + this->unk_3E2 + this->unk_3E8; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); @@ -318,7 +318,7 @@ void func_80BA5AF0(EnRailgibud* this) { } void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); @@ -370,7 +370,7 @@ void func_80BA5DBC(EnRailgibud* this) { } void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player2 = PLAYER; + Player* player2 = GET_PLAYER(globalCtx); Player* player = player2; s32 sp34; u16 sp32; @@ -663,7 +663,7 @@ void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx) { } s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO_MASK) { return false; @@ -678,7 +678,7 @@ s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx) { } s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { return true; @@ -688,7 +688,7 @@ s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->unk_3FA != 1) && (this->collider.base.acFlags & AC_HIT)) { if (this->actionFunc == func_80BA57F8) { @@ -763,7 +763,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { } s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp40; f32 sp3C; f32 sp38 = 0.0f; @@ -795,7 +795,7 @@ void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA7234(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp30; if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 != 2)) { @@ -892,7 +892,7 @@ void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->actionFunc != func_80BA66C8) && ((this->actionFunc != func_80BA5E18) || (this->unk_3F0 == 2))) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 0e58c9029..ff35322f1 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -561,7 +561,7 @@ void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { } void func_808D506C(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; @@ -583,7 +583,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { if (!(this->unk_3DC & 0x80)) { player->actor.freezeTimer = 40; func_80123E90(globalCtx, &this->actor); - PLAYER->unk_A78 = &this->actor; + GET_PLAYER(globalCtx)->unk_A78 = &this->actor; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } this->unk_3ED = 60; @@ -634,7 +634,7 @@ void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { } void func_808D5440(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -733,7 +733,7 @@ void func_808D586C(EnRd* this) { } void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { @@ -826,7 +826,7 @@ void func_808D5C54(EnRd* this) { } void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v0 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; if (ABS_ALT(temp_v0) < 0x2008) { @@ -928,7 +928,7 @@ void func_808D616C(EnRd* this) { } void func_808D6200(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; @@ -1061,7 +1061,7 @@ void func_808D66A0(EnRd* this, GlobalContext* globalCtx) { void func_808D6814(EnRd* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((gSaveContext.unk_3F58 != 0) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { @@ -1145,7 +1145,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { } void func_808D6A94(EnRd* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->actor.colChkInfo.health > 0) && (this->unk_3EF != 10)) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index 673a5445f..691efcdf7 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -361,7 +361,7 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnSb* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->isDead) { if (this->actor.yDistToWater > 0.0f) { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 619827776..3901c8b24 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -233,7 +233,7 @@ Actor* func_80ADB040(GlobalContext* globalCtx) { f32 func_80ADB08C(GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Actor* sp18 = func_80ADB040(globalCtx); if (sp18 != NULL) { @@ -346,7 +346,7 @@ void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -425,7 +425,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u8 temp_v0 = func_80152498(&globalCtx->msgCtx); s32 temp_v0_2; @@ -704,7 +704,7 @@ void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { player->linearVelocity = 0.0f; @@ -727,7 +727,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; @@ -954,7 +954,7 @@ f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { EnSellnuts* this = THIS; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad2; if ((gSaveContext.weekEventReg[17] & 0x80) || (gSaveContext.weekEventReg[61] & 0x10)) { @@ -1040,7 +1040,7 @@ void EnSellnuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { EnSellnuts* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->unk_328++; if (player->transformation == PLAYER_FORM_DEKU) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index bb21a4e57..91efc860c 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -870,7 +870,7 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((this->unk_3DE != 6) && (this->unk_3DE != 7)) { if ((this->actor.bgCheckFlags & 0x60) && (this->actor.yDistToWater >= 40.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 6473c327a..8d501627a 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -195,7 +195,7 @@ s32 EnSob1_TestItemSelected(GlobalContext* globalCtx) { } u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->shopType == BOMB_SHOP) { if (gSaveContext.day == 1 && gSaveContext.time >= CLOCK_TIME(6, 00)) { @@ -231,7 +231,7 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { } u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->shopType == BOMB_SHOP) { switch (Player_GetMask(globalCtx)) { @@ -443,7 +443,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { } void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); @@ -522,7 +522,7 @@ void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupWalk(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->actor.world.pos.x >= 0.0f && player->actor.world.pos.x <= 390.0f) && (player->actor.world.pos.z >= 72.0f && player->actor.world.pos.z <= 365.0f)) { @@ -531,7 +531,7 @@ void EnSob1_SetupWalk(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->headRotTarget = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (func_800B84D0(&this->actor, globalCtx)) { @@ -782,7 +782,7 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -816,7 +816,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_ItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -938,7 +938,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; @@ -1096,7 +1096,7 @@ void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnGirlA* item; if ((func_80152498(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index eb7f9910a..ec18b9bd2 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -331,7 +331,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0: if (gSaveContext.weekEventReg[0x51] & 1) { this->textId = 0x1455; - ((EnElf*)PLAYER->tatlActor)->unk264 |= 8; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 8; this->flags2 |= 1; } else { this->textId = 0x1450; @@ -353,7 +353,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0x1453: this->flags1 |= 0x400; gSaveContext.weekEventReg[0x51] |= 1; - ((EnElf*)PLAYER->tatlActor)->unk264 |= 8; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 8; this->flags2 |= 1; this->textId = 0x1454; break; @@ -484,7 +484,7 @@ void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f sp30; if (this->flags1 & 0x80) { @@ -815,7 +815,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 curFrame = this->skelAnime.animCurrentFrame; s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); @@ -979,7 +979,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->animationIdx == 1 || this->animationIdx == 8) { this->animationIdx = 2; @@ -1006,7 +1006,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 target; this->unk3F2 = this->unk2DE; @@ -1037,7 +1037,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->unk3F2 = this->unk2DE; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { @@ -1170,7 +1170,7 @@ void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { this->flags1 |= 0x8000; @@ -1323,7 +1323,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } this->flags1 &= ~0x400; if (this->flags2 & 1) { - ((EnElf*)PLAYER->tatlActor)->unk264 |= 0x10; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 0x10; this->flags2 &= ~1; } globalCtx->msgCtx.unk11F22 = 0x43; @@ -1446,7 +1446,7 @@ void EnSuttari_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->actionFunc(this, globalCtx); if ((this->flags1 & 8) && (this->flags2 & 0x10) && (player->stateFlags1 & 0x10000000)) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index d49dd3757..d0a58410c 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -748,7 +748,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } void func_808DA350(EnSw* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_LAUGH); 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 b17f6378d..e44872127 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 @@ -175,7 +175,7 @@ void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 sp28; f32 phi_f0; s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); @@ -209,7 +209,7 @@ void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { u16 sp22; @@ -257,7 +257,7 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { @@ -314,7 +314,7 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_80147624(globalCtx)) { switch (this->unk_284) { @@ -373,7 +373,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x20) { player->stateFlags1 |= 0x20; @@ -524,7 +524,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { @@ -587,7 +587,7 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_80147624(globalCtx)) { switch (this->unk_284) { @@ -707,7 +707,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x20) { player->stateFlags1 |= 0x20; @@ -749,7 +749,7 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { if (!(gSaveContext.weekEventReg[59] & 0x10)) { @@ -778,7 +778,7 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { @@ -799,7 +799,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { if (this->unk_284 == 0x407) { @@ -836,7 +836,7 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { @@ -861,7 +861,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_809C6720(globalCtx, D_809C9474)) { player->stateFlags1 |= 0x20; @@ -880,7 +880,7 @@ void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { static s16 D_809C9498 = 30; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (D_809C9498 > 0) { player->actor.world.pos = D_809C9474; @@ -910,7 +910,7 @@ void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx) { static s16 D_809C949C = 0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (((this->unk_272 == 0) || (this->unk_26C > 140)) && (D_809C949C == 0) && (this->unk_27C < 4)) { D_809C949C = 1; @@ -1020,7 +1020,7 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { static s32 D_809C94A0 = 0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x20; if (globalCtx->interfaceCtx.unk_286 == 0) { @@ -1067,7 +1067,7 @@ void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C8808(EnSyatekiMan* this, GlobalContext* globalCtx) { static s16 D_809C94A4 = 30; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (D_809C94A4 == 30) { if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { @@ -1104,7 +1104,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { 0x00026984, 0x00012852, 0x00011999, 0x00022895, 0x0000056A, 0x0002A451, 0x00004115, }; static s32 D_809C94A8 = 0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 sp30; s32 pad; u64 sp20; 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 1abbd9617..f5f460141 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -292,7 +292,7 @@ void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { s32 dayTemp; EnTest4* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s8 temp_v0 = this->actor.cutscene; sCutscenes[0] = temp_v0; @@ -371,7 +371,7 @@ void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { @@ -496,7 +496,7 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } } if (this->transitionCsTimer == 60) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); gSaveContext.time += CLOCK_TIME_MINUTE; this->unk_146 = gSaveContext.time; @@ -568,7 +568,7 @@ void func_80A4323C(EnTest4* this, GlobalContext* globalCtx) { void EnTest4_Update(Actor* thisx, GlobalContext* globalCtx) { EnTest4* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (!(player->stateFlags1 & 2)) { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index d0a7b9498..d98657a29 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -311,7 +311,7 @@ void func_80C10DE8(s32 items[], s32 count, s32 item) { } s32 func_80C10E98(GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 phi_s0_2; s32 phi_s2; s32 spB0; @@ -419,7 +419,7 @@ s32 func_80C10E98(GlobalContext* globalCtx) { } void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnItem00* item = NULL; f32 phi_f20 = 5000.0f; s32 i; @@ -478,7 +478,7 @@ void func_80C11538(EnThiefbird* this) { } void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 sp38; SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -542,7 +542,7 @@ void func_80C118E4(EnThiefbird* this) { } void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 pitch; SkelAnime_FrameUpdateMatrix(&this->skelAnime); @@ -858,7 +858,7 @@ void func_80C12744(EnThiefbird* this) { } void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 temp_v0; f32 temp_f0; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 07f6cfce2..d15af5517 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -250,7 +250,7 @@ s32 func_80BA397C(EnToto* this, s16 arg1) { } void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_80BA383C(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx) != 0) { @@ -343,7 +343,7 @@ void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx) { return; } } else { - player = PLAYER; + player = GET_PLAYER(globalCtx); if (player->stateFlags1 & 0x400 && player->unk_AE7 != 0) { func_80151BB4(globalCtx, 48); func_80151BB4(globalCtx, 9); @@ -410,7 +410,7 @@ s32 func_80BA402C(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &PLAYER->actor); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &GET_PLAYER(globalCtx)->actor); return 1; } @@ -458,7 +458,7 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA42BC(EnToto* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u32 phi_s0 = 0; Vec3s* end = &D_80BA510C[3]; @@ -514,7 +514,7 @@ s32 func_80BA44D4(EnTotoUnkStruct2* arg0, Player* player) { } s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnTotoUnkStruct2* temp_s0; s32 i; u16 tmp; @@ -622,7 +622,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!func_801A2DE0(0x54)) { - actor = (Actor*)PLAYER; // Needed for regalloc, possible FAKE MATCH + actor = (Actor*)GET_PLAYER(globalCtx); // Needed for regalloc, possible FAKE MATCH actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); @@ -651,7 +651,7 @@ s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { Player* player; if (func_80BA40D4(this, globalCtx)) { - player = PLAYER; + player = GET_PLAYER(globalCtx); SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060028B8, -4.0f); if (player->transformation == PLAYER_FORM_ZORA) { if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { 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 dde048caf..06fe1bfd4 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -207,7 +207,7 @@ u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { } void EnTrt_EndInteraction(GlobalContext* globalCtx, EnTrt* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); @@ -332,7 +332,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->tmpGetMushroomCutscene = this->getMushroomCutscene; if (this->cutsceneState != ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -346,7 +346,7 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { this->textId = 0x884; func_801518B0(globalCtx, this->textId, &this->actor); gSaveContext.weekEventReg[0x35] |= 8; - func_80123D50(globalCtx, PLAYER, 18, 21); + func_80123D50(globalCtx, GET_PLAYER(globalCtx), 18, 21); break; case 0x888: this->textId = 0x889; @@ -372,7 +372,7 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - func_80123D50(globalCtx, PLAYER, 18, 21); + func_80123D50(globalCtx, GET_PLAYER(globalCtx), 18, 21); this->actionFunc = EnTrt_SetupItemGiven; } else { func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); @@ -439,7 +439,7 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; @@ -644,7 +644,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnTrt* this) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; @@ -749,7 +749,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((gSaveContext.weekEventReg[0x55] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40)) { this->textId = 0x88F; @@ -806,7 +806,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); this->flags &= ~ENTRT_FULLY_AWAKE; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_FIERCE_DEITY) { @@ -983,7 +983,7 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1032,7 +1032,7 @@ void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { func_801518B0(globalCtx, this->textId, &this->actor); @@ -1099,7 +1099,7 @@ void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); EnGirlA* item; if (talkState == 4) { @@ -1369,7 +1369,7 @@ void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = talkState = func_80152498(&globalCtx->msgCtx); - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 itemGiven; if (talkState == 5) { @@ -1696,7 +1696,7 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); Vec3f playerPos; Vec3f pos; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index df8a039e7..06ef6ef3f 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -163,8 +163,8 @@ void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) } void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { - Player* player = PLAYER; - Player* player2 = PLAYER; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f)) { EnTuboTrap_SpawnEffectsInWater(this, globalCtx); @@ -219,7 +219,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { static s8 sTransformationHeight[] = { 40, 40, 40, 25, 28, }; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 currentHeight; f32 transformationHeight; s16 startingRotation; diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 56b4e1143..dc8ea9ad1 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -95,7 +95,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { s16 phi_v1; do { - player = PLAYER; + player = GET_PLAYER(globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { func_80A66384(this, globalCtx); } else { diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 4db53de3c..401bf50b2 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -110,7 +110,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { // called WeatherTag_CheckEnableWeatherEffect in OOT, that's where "weatherMode" came from u8 func_80966608(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, u16 new24, u8 weatherMode) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u8 returnVal = 0; if (WEATHER_TAG_RANGE100(this) > Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { @@ -140,7 +140,7 @@ u8 func_80966608(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_ // called WeatherTag_CheckRestoreWeather in OOT u8 func_80966758(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_TYPE a4, u8 new1F, u8 new20, u16 new24) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u8 returnVal = 0; if (WEATHER_TAG_RANGE100(this) < Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { @@ -166,7 +166,7 @@ u8 func_80966758(EnWeatherTag* this, GlobalContext* globalCtx, UNK_TYPE a3, UNK_ // modify wind? void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); f32 distance; f32 partialResult; @@ -410,13 +410,14 @@ void EnWeatherTag_Unused_80967250(EnWeatherTag* this, GlobalContext* globalCtx) // WEATHERTAG_TYPE_WATERMURK: (pinnacle rock, zora cape, zora coast) void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 pad; f32 distance; f32 range; f32 strength = 0.0f; - func_800BCCDC(this->pathPoints, this->pathCount, &PLAYER->actor.world.pos, &this->actor.world.pos, 0); + func_800BCCDC(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, &this->actor.world.pos, + 0); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(this); @@ -441,7 +442,7 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_LOCALDAY2RAIN: rain proximity as approaching rainy scene // (milk road day 2 approaching ranch it rains, walking away towards termfield no rain) void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { @@ -465,7 +466,8 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { // WEATHERTAG_TYPE_LOCALDAY2RAIN 2 void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx) { - if ((WEATHER_TAG_RANGE100(this) + 10.0f) < Actor_XZDistanceBetweenActors(&PLAYER->actor, &this->actor)) { + if ((WEATHER_TAG_RANGE100(this) + 10.0f) < + Actor_XZDistanceBetweenActors(&GET_PLAYER(globalCtx)->actor, &this->actor)) { D_801BDBB0 = 0; EnWeatherTag_SetupAction(this, func_809674C8); } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index b49ccaef1..24ca09489 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -552,7 +552,7 @@ void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { } void func_80B97708(EnZot* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s32 phi_v1; func_80B96D4C(this); @@ -961,7 +961,7 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { s32 temp_v0; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); func_80B98348(this, globalCtx); if (func_80152498(&globalCtx->msgCtx) == 0x10) { diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index 0fba2130c..0d5a2c1b9 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -104,7 +104,7 @@ Actor* ObjBoyo_GetCollidedActor(ObjBoyo* this, GlobalContext* globalCtx, s32* nu if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { *num = 0; - return &PLAYER->actor; + return &GET_PLAYER(globalCtx)->actor; } if (this->collider.base.ocFlags1 & OC2_UNK1) { diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index b5272432e..4a74a3c80 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -128,7 +128,7 @@ void ObjEtcetera_StartSmallFlutterAnimation(ObjEtcetera* this) { void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { s16 minOscillationTimer; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index a1c51e097..04f4635a6 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -30,7 +30,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(func_800DFCDC(ACTIVE_CAM) - 0x8000), 1); + Matrix_RotateY((s16)(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - 0x8000), 1); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index e2a6b9c8b..7a20bab74 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -72,7 +72,7 @@ void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { } void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 distDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; if (func_800B84D0(&this->dyna.actor, globalCtx)) { @@ -129,7 +129,7 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { } void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); u8 stepTemp = Math_StepToS(&this->unk_168, 0x64, 1); this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + 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 9d6fc0a54..3fc376dc4 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -120,7 +120,7 @@ void func_80926318(ObjKibako* this, GlobalContext* globalCtx) { s32 pad; if (this->actor.xzDistToPlayer < 100.0f) { - angle = this->actor.yawTowardsPlayer - PLAYER->actor.world.rot.y; + angle = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; if (ABS_ALT(angle) >= 0x5556) { func_800B8A1C(&this->actor, globalCtx, 0, 36.0f, 30.0f); } diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 227c2b79c..3a803bc61 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -74,7 +74,7 @@ void func_80C0662C(ObjMoonStone* this) { } void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); s16 sp1A = this->actor.yawTowardsPlayer - 0x8000; sp1A -= player->actor.shape.rot.y; @@ -140,7 +140,7 @@ void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { ObjMoonStone* this = THIS; - Player* player = PLAYER; + Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x10000282) == 0) { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 997270a6b..597d47033 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -169,7 +169,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else { s32 interaction = OBJ_SYOKUDAI_INTERACTION_NONE; u32 flameColliderHurtboxDmgFlags = 0; - player = PLAYER; + player = GET_PLAYER(globalCtx); if (OBJ_SYOKUDAI_GET_START_LIT(thisx)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; @@ -311,7 +311,7 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); SysMatrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(ACTIVE_CAM) - thisx->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_0407D590); diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 7df2a0ecb..f6b0da869 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -66,7 +66,7 @@ void ObjTokeiStep_AddQuake(ObjTokeiStep* this, GlobalContext* globalCtx) { s32 pad[2]; s16 quake; - quake = Quake_Add(ACTIVE_CAM, 3); + quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); Quake_SetSpeed(quake, 0x4E20); Quake_SetQuakeValues(quake, 1, 0, 0, 0); Quake_SetCountdown(quake, 7); From 151e098e48fcd779a296cfbdcedd8f4528f96232 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 14 Oct 2021 16:25:14 +0100 Subject: [PATCH 38/86] `z_debug` OK (#330) * z_debug OK * Rename function * Remove duplicate struct * Update z64.h --- include/functions.h | 2 +- include/z64.h | 17 ++++++++++------- spec | 1 - src/code/main.c | 2 +- src/code/z_debug.c | 18 +++++++++++++++++- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/functions.h b/include/functions.h index 8c8b76a3e..173b44d26 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1547,7 +1547,7 @@ s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); u8 func_800E9360(void); -void static_context_init(void); +void GameInfo_Init(void); // void func_800E9470(void); void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); void DebugDisplay_DrawObjects(GlobalContext* globalCtx); diff --git a/include/z64.h b/include/z64.h index 6e179ebe2..e38d926a6 100644 --- a/include/z64.h +++ b/include/z64.h @@ -36,6 +36,7 @@ #include "z64scene.h" #include "z64save.h" #include "z64transition.h" +#include "regs.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -242,14 +243,16 @@ typedef struct { /* 0x11D88 */ u8 unk_11D88; } Font; // size = 0x11D8C +// Game Info aka. Static Context +// Data normally accessed through REG macros (see regs.h) typedef struct { - /* 0x0000 */ u8 unk0; - /* 0x0001 */ u8 unk1; - /* 0x0002 */ u8 unk2; - /* 0x0003 */ u8 unk3; - /* 0x0004 */ u32 unk4; - /* 0x0008 */ UNK_TYPE1 pad8[0xC]; - /* 0x0014 */ s16 data[2784]; // Accessed through REG macros + /* 0x00 */ u8 unk_00; // regPage;? // 1 is first page + /* 0x01 */ u8 unk_01; // regGroup;? // "register" group (R, RS, RO, RP etc.) + /* 0x02 */ u8 unk_02; // regCur;? // selected register within page + /* 0x03 */ u8 unk_03; // dpadLast;? + /* 0x04 */ u32 unk_04; // repeat;? + /* 0x08 */ UNK_TYPE1 pad_08[0xC]; + /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries } GameInfo; // size = 0x15D4 typedef struct { diff --git a/spec b/spec index 8ca54bfc5..b121ad83c 100644 --- a/spec +++ b/spec @@ -471,7 +471,6 @@ beginseg include "build/src/code/z_common_data.o" include "build/data/code/z_common_data.bss.o" include "build/src/code/z_debug.o" - include "build/data/code/z_debug.bss.o" include "build/src/code/z_debug_display.o" include "build/data/code/z_debug_display.data.o" include "build/data/code/z_debug_display.bss.o" diff --git a/src/code/main.c b/src/code/main.c index 648536aef..a2b859991 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -24,7 +24,7 @@ void Main(void* arg) { startHeapSize = fb - sysHeap; SystemArena_Init(sysHeap, startHeapSize); - static_context_init(); + GameInfo_Init(); R_ENABLE_ARENA_DBG = 0; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index e6f03bb5f..5848dfa71 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,3 +1,19 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/static_context_init.s") +GameInfo* gGameInfo; + +void GameInfo_Init(void) { + s32 i; + + gGameInfo = (GameInfo*)SystemArena_Malloc(sizeof(GameInfo)); + if (1) {} + gGameInfo->unk_00 = 0; + gGameInfo->unk_01 = 0; + gGameInfo->unk_02 = 0; + gGameInfo->unk_04 = 0; + gGameInfo->unk_03 = 0; + + for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { + gGameInfo->data[i] = 0; + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e6e2507d6..8cf4a77b5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1519,7 +1519,7 @@ 0x800E9138:("func_800E9138",), 0x800E9250:("func_800E9250",), 0x800E9360:("func_800E9360",), - 0x800E93E0:("static_context_init",), + 0x800E93E0:("GameInfo_Init",), 0x800E9470:("func_800E9470",), 0x800E9488:("DebugDisplay_AddObject",), 0x800E9564:("DebugDisplay_DrawObjects",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 0fdfe7519..d8ca54506 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1033,7 +1033,7 @@ asm/non_matchings/code/code_800E8EA0/func_800E8FA4.s,func_800E8FA4,0x800E8FA4,0x asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x46 asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 -asm/non_matchings/code/z_debug/static_context_init.s,static_context_init,0x800E93E0,0x24 +asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24 From 961913f18fb677ac6f95f0ab08c30bedaa616ec2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 23 Oct 2021 06:14:25 -0700 Subject: [PATCH 39/86] Format the misformatted files in master (#354) * Format the misformatted files in master * Correct arms_hook double-semicolon, since it was almost certainly just an accident --- src/code/flg_set.c | 2 +- src/code/z_debug.c | 2 +- src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 2 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 490472d20..780884c85 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -231,7 +231,7 @@ void FlagSet_Update(GameState* gameState) { } /* Other controls */ - + // A toggles the selected flag if (CHECK_BTN_ALL(input->press.button, BTN_A)) { *sFlagEntries[sEntryIndex].value ^= (1 << sCurrentBit); diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 5848dfa71..924a2ad30 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -12,7 +12,7 @@ void GameInfo_Init(void) { gGameInfo->unk_02 = 0; gGameInfo->unk_04 = 0; gGameInfo->unk_03 = 0; - + for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { gGameInfo->data[i] = 0; } diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 2e99b093f..4f9b88118 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -288,7 +288,7 @@ static Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f }; void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { ArmsHook* this = THIS; f32 f0; - Player* player = GET_PLAYER(globalCtx);; + Player* player = GET_PLAYER(globalCtx); if (player->actor.draw != NULL && player->rightHandType == 0xB) { Vec3f sp68; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 04c9e0fd2..381f4e90a 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -557,7 +557,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { do { this->actor.world.pos.x = points->x; this->actor.world.pos.z = points->z; - } while(0); + } while (0); this->unk_3F8++; if (this->path->count <= this->unk_3F8) { diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 7e186e4a1..ace41a2ba 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -1013,7 +1013,8 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - SysMatrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + SysMatrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), + MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06003850); From dcf44596d2c335c1ad82ea50f7e7d934e6bc1e52 Mon Sep 17 00:00:00 2001 From: Lucas Shaw <49287729+shawlucas@users.noreply.github.com> Date: Sun, 24 Oct 2021 10:59:14 -0400 Subject: [PATCH 40/86] Animation system updated, some more boot files decompiled (+6%), z_fcurve_data_skelanime decompiled (1 non-matching), some asm files split, etc (#89) * Progress on various files * gfxprint stuff * split some rodata, add iconv for rodata string parsing * z_std_dma rodata * 2 nonmatchings in gfxprint * mtxuty-cvt ok * more * match a function in idle.c * progress * Cleanup * Rename BgPolygon to CollisionPoly * progress * some effect stuff * more effect progress * updates * made suggested changes * z_effect_soft_sprite_old_init mostly ok * remove old effects enum * gamealloc.c OK * added more files * motor.c almost done * motor.c OK * updates * migration of two files * listalloc.c oK * z_fcurve_data_skelanime split * z_fcurve_data_skelanime.c decompiled * more files split * z_malloc.c OK * contpfs.c OK * fault.c rodata migrated * migrated fault_drawer rodata * update * update preprocess.py * renamed functions in z_skelanime * started z_skelanime cleanup * like halfway through fixing z_skelanime * animation system updated to meet oot standards * remove unused animation structs * rename matrix structs to fit oot * Add -woff 712 * fix diff_settings.py because i accidentally broke it before * fixed merge conflict, doesn't match though * It matches now * Updates * Fixed warnings...added gcc code syntax checking * Remove gcc check, added in Tharo's PR * warnings fixed (i think) * fixed all warnings i think * ok * not sure what to do * Fix all warnings i think (z_en_a_keep needs some file cleanup thouguh) * it matches if i do this * remove comment * accidentally put osPfsFreeBlocks in epilinkhandle.c * memcmp -> bcmp * change u32 size to size_t size, delete string.h because it caused unnecessary confusion with defining size_t twice * format.sh * MTXMODE_NEW and MTXMODE_APPLY to matrix functions * Made suggested changes * pragma sFaultDrawerFont instead of including in repo * add some functions to functions.h * Bss reordering fixed in z_collision_check...added hack to disasm.py * Updated z_en_a_keep.c * Missed suggestion in EnAObj_Destroy * . * update z_fcurve_Data_skelanime and z_skelanime with suggestions * devmgr.c ok * minor changes * Addressed comments * remove redundant file * gfxp -> dlist in game.c * updated actorfixer.py * fixed warnings in z_malloc * Change void* back to Actor* * format * Add the soft_sprit comments back * Rename SV->Flex * remove .common * run format * Update src/code/z_skelanime.c * u32 channel Co-authored-by: Lucas Shaw Co-authored-by: angie Co-authored-by: Kenix3 --- include/PR/mbi.h | 2 +- include/functions.h | 497 ++-- include/io/controller.h | 3 +- include/os.h | 7 +- include/os_internal.h | 10 + include/stdlib.h | 2 +- include/string.h | 7 - include/variables.h | 63 +- include/z64.h | 53 +- include/z64actor.h | 14 +- include/z64animation.h | 242 +- include/z64effect.h | 33 +- include/z64scene.h | 4 +- spec | 5 +- src/boot_O1/viextendvstart.c | 5 + src/boot_O2/__osMalloc.c | 8 +- src/boot_O2/__osMemset.c | 2 +- src/boot_O2/loadfragment2.c | 6 +- src/boot_O2/system_malloc.c | 14 +- src/boot_O2_g3/fault.c | 49 +- src/boot_O2_g3/fault_drawer.c | 6 +- src/boot_O2_g3/yaz0.c | 2 +- src/boot_O2_g3/z_std_dma.c | 8 +- src/code/PreRender.c | 4 +- src/code/TwoHeadArena.c | 10 +- src/code/TwoHeadGfxArena.c | 4 +- src/code/code_800F23E0.c | 5 - src/code/code_80122660.c | 5 - src/code/game.c | 181 +- src/code/gamealloc.c | 58 +- src/code/listalloc.c | 61 +- src/code/main.c | 22 +- src/code/padmgr.c | 2 +- src/code/sys_matrix.c | 68 +- src/code/z_DLF.c | 4 +- src/code/z_actor.c | 6 +- src/code/z_actor_dlftbls.c | 2 +- src/code/z_collision_check.c | 14 +- src/code/z_eff_footmark.c | 4 +- src/code/z_effect_soft_sprite.c | 4 +- src/code/z_effect_soft_sprite_old_init.c | 9 +- src/code/z_en_a_keep.c | 71 +- src/code/z_en_item00.c | 4 +- src/code/z_fcurve_data.c | 5 + src/code/z_fcurve_data_skelanime.c | 180 +- src/code/z_lights.c | 2 +- src/code/z_malloc.c | 53 +- src/code/z_pause.c | 5 + src/code/z_room.c | 2 +- src/code/z_scene.c | 12 +- src/code/z_skelanime.c | 2272 +++++++++-------- src/code/z_view.c | 24 +- src/code/z_vr_box.c | 18 +- src/libultra/io/contpfs.c | 307 ++- src/libultra/io/devmgr.c | 103 +- src/libultra/io/epilinkhandle.c | 11 +- src/libultra/io/epirawdma.c | 2 +- src/libultra/io/epirawread.c | 2 +- src/libultra/io/motor.c | 120 + src/libultra/io/pimgr.c | 6 +- src/libultra/io/pirawdma.c | 2 +- src/libultra/io/sprawdma.c | 2 +- src/libultra/libc/string.c | 2 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 18 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 15 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 12 +- .../actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 6 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 10 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 12 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 10 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h | 4 +- src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 12 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 22 +- .../actors/ovl_En_Baisen/z_en_baisen.c | 16 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 61 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 19 +- src/overlays/actors/ovl_En_Bu/z_en_bu.c | 8 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 4 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 58 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 63 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 26 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 36 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 96 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 48 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 148 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 32 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 36 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 85 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 46 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 28 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 46 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 80 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 8 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 6 +- .../ovl_En_Ending_Hero/z_en_ending_hero.c | 9 +- .../ovl_En_Ending_Hero/z_en_ending_hero.h | 4 +- .../ovl_En_Ending_Hero2/z_en_ending_hero2.c | 9 +- .../ovl_En_Ending_Hero2/z_en_ending_hero2.h | 4 +- .../ovl_En_Ending_Hero3/z_en_ending_hero3.c | 9 +- .../ovl_En_Ending_Hero3/z_en_ending_hero3.h | 4 +- .../ovl_En_Ending_Hero4/z_en_ending_hero4.c | 9 +- .../ovl_En_Ending_Hero4/z_en_ending_hero4.h | 4 +- .../ovl_En_Ending_Hero5/z_en_ending_hero5.c | 9 +- .../ovl_En_Ending_Hero5/z_en_ending_hero5.h | 4 +- .../ovl_En_Ending_Hero6/z_en_ending_hero6.c | 14 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 56 +- src/overlays/actors/ovl_En_Fg/z_en_fg.h | 4 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 50 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 23 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 51 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 40 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.h | 4 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 26 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 30 +- src/overlays/actors/ovl_En_Hg/z_en_hg.h | 4 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 60 +- src/overlays/actors/ovl_En_In/z_en_in.h | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 277 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.h | 4 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 56 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 35 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.h | 4 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 32 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.h | 4 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 37 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.h | 4 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 27 +- .../actors/ovl_En_Minifrog/z_en_minifrog.h | 4 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 29 +- src/overlays/actors/ovl_En_Niw/z_en_niw.h | 4 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 4 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 30 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 4 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 75 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 46 +- .../actors/ovl_En_Pamera/z_en_pamera.h | 4 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 148 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 4 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 22 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.h | 4 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 83 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 42 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 132 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 21 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 33 +- src/overlays/actors/ovl_En_Sb/z_en_sb.h | 4 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 46 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 47 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 51 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.h | 4 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 66 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 70 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 26 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 90 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.h | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 30 +- src/overlays/actors/ovl_En_Toto/z_en_toto.h | 4 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 42 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 32 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 4 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 16 +- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.c | 16 +- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 16 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 2 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 2 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 16 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 16 +- .../ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h | 4 +- .../gamestates/ovl_daytelop/z_daytelop.c | 2 +- .../gamestates/ovl_opening/z_opening.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 6 +- tools/actorfixer.py | 123 +- tools/disasm/files.txt | 6 +- tools/disasm/functions.txt | 316 +-- tools/disasm/variables.txt | 47 +- tools/sizes/boot_functions.csv | 6 +- tools/sizes/code_functions.csv | 106 +- 181 files changed, 4953 insertions(+), 3658 deletions(-) delete mode 100644 include/string.h create mode 100644 src/boot_O1/viextendvstart.c delete mode 100644 src/code/code_800F23E0.c delete mode 100644 src/code/code_80122660.c create mode 100644 src/code/z_fcurve_data.c create mode 100644 src/code/z_pause.c create mode 100644 src/libultra/io/motor.c diff --git a/include/PR/mbi.h b/include/PR/mbi.h index 85410c912..736018c56 100644 --- a/include/PR/mbi.h +++ b/include/PR/mbi.h @@ -92,7 +92,7 @@ #define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) #ifndef NULL -#define NULL 0 +#define NULL ((void*)0) #endif #endif /* !_MBI_H_ */ diff --git a/include/functions.h b/include/functions.h index 173b44d26..6801b986b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -14,22 +14,23 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 arg0); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DMARomToRam(u32 src, void* dst, u32 size); -void DmaMgr_DmaCallback0(OSPiHandle* pOParm1, OSIoMesg* pOParm2, s32 OParm3); +s32 DmaMgr_DMARomToRam(u32 src, void* dst, size_t size); +void DmaMgr_DmaCallback0(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); u32 DmaMgr_TranslateVromToRom(u32 vromAddr); s32 DmaMgr_FindDmaIndex(u32 vromAddr); const char* func_800809F4(u32 param_1); -void DmaMgr_ProcessMsg(DmaRequest* request); +void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, u32 size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); -s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, u32 size); +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, size_t size, UNK_TYPE4 unused, + OSMesgQueue* callback, void* callbackMesg); +s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(void* curSrcPos); s32 Yaz0_DecompressImpl(u8* hdr, u8* dst); -void Yaz0_Decompress(u32 romStart, void* dst, u32 size); +void Yaz0_Decompress(u32 romStart, void* dst, size_t size); void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* add, OSMesgQueue* msgQ); void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove); void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg); @@ -54,7 +55,7 @@ void rmonPrintf(const char* fmt, ...); void Fault_SleepImpl(u32 duration); void Fault_AddClient(FaultClient* client, fault_client_func callback, void* param0, void* param1); void Fault_RemoveClient(FaultClient* client); -void Fault_AddAddrConvClient(FaultAddrConvClient* client, fault_address_converter_func callback, void* param); +void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvFunc callback, void* param); void Fault_RemoveAddrConvClient(FaultAddrConvClient* client); void* Fault_ConvertAddress(void* addr); void Fault_Sleep(u32 duration); @@ -75,7 +76,7 @@ void osSyncPrintfThreadContext(OSThread* t); OSThread* Fault_FindFaultedThread(void); void Fault_Wait5Seconds(void); void Fault_WaitForButtonCombo(void); -void Fault_DrawMemDumpPage(char* title, u32* addr, u32 param_3); +void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3); void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1); void Fault_FindNextStackCall(u32** sp, u32** pc, u32** ra); void Fault_DrawStackTrace(OSThread* t, u32 flags); @@ -116,7 +117,7 @@ s32 Load_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 allocatedVRa void* Load_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart); void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr); -void* Load2_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd); +void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd); void PadUtils_Init(Input* input); void func_80085150(void); void PadUtils_ResetPressRel(Input* input); @@ -155,8 +156,8 @@ void GfxPrint_Open(GfxPrint* printer, Gfx* dList); Gfx* GfxPrint_Close(GfxPrint* printer); s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); -// void MtxConv_F2L(void); -// void MtxConv_L2F(void); +void MtxConv_F2L(MatrixInternal* m1, MtxF* m2); +void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); @@ -201,14 +202,14 @@ s32 func_80086D40(f64 param_1); f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -void* SystemArena_Malloc(u32 size); -void* SystemArena_MallocR(u32 size); -void* SystemArena_Realloc(void* oldPtr, u32 newSize); +void* SystemArena_Malloc(size_t size); +void* SystemArena_MallocR(size_t size); +void* SystemArena_Realloc(void* oldPtr, size_t newSize); void SystemArena_Free(void* ptr); -void* SystemArena_Calloc(u32 elements, u32 size); -void SystemArena_AnalyzeArena(u32* maxFreeBlock, u32* bytesFree, u32* bytesAllocated); +void* SystemArena_Calloc(u32 elements, size_t size); +void SystemArena_AnalyzeArena(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); u32 SystemArena_CheckArena(void); -void SystemArena_InitArena(void* start, u32 size); +void SystemArena_InitArena(void* start, size_t size); void SystemArena_Cleanup(void); u8 SystemArena_IsInitialized(void); s32 Rand_Next(void); @@ -223,15 +224,15 @@ void ArenaImpl_LockInit(Arena* heap); void ArenaImpl_Lock(Arena* heap); void ArenaImpl_Unlock(Arena* heap); ArenaNode* ArenaImpl_GetLastBlock(Arena* param_1); -void __osMallocInit(Arena* heap, void* heapBase, u32 heapSize); +void __osMallocInit(Arena* heap, void* heapBase, size_t heapSize); void __osMallocAddBlock(Arena* heap, void* start, s32 size); void __osMallocCleanup(Arena* heap); u8 __osMallocIsInitalized(Arena* heap); -void* __osMalloc(Arena* heap, u32 size); -void* __osMallocR(Arena* heap, u32 size); +void* __osMalloc(Arena* heap, size_t size); +void* __osMallocR(Arena* heap, size_t size); void __osFree(Arena* heap, void* ptr); -void* __osRealloc(Arena* heap, void* oldPtr, u32 newSize); -void __osAnalyzeArena(Arena* heap, u32* maxFreeBlock, u32* bytesFree, u32* bytesAllocated); +void* __osRealloc(Arena* heap, void* oldPtr, size_t newSize); +void __osAnalyzeArena(Arena* heap, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); u32 __osCheckArena(Arena* heap); void* proutSprintf(void* s, const char* buf, size_t n); s32 vsprintf(char* dst, char* fmt, va_list args); @@ -282,7 +283,7 @@ void __osDequeueThread(OSThread** param_1, OSThread* param_2); void osDestroyThread(OSThread* puParm1); // void __osVoiceCheckResult(void); void bzero(void* begin, s32 length); -// void osSetRumble(void); +s32 osSetRumble(OSPfs* pfs, u32 vibrate); // void osSetUpMempakWrite(void); // void osProbeRumblePak(void); void __osSiCreateAccessQueue(void); @@ -306,9 +307,9 @@ void __osInitialize_autodetect(void); void* osViGetNextFramebuffer(void); void guPerspectiveF(float mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); -s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, u32 size); +s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size); s32 __osSiRawStartDma(s32 direction, void* dramAddr); -// void osEPiLinkHandle(void); +s32 osEPiLinkHandle(OSPiHandle* handle); void osViBlack(u8 active); s32 __osSiRawReadIo(u32 devAddr, u32* data); OSId osGetThreadId(OSThread* t); @@ -334,14 +335,14 @@ void __osPiGetAccess(void); void __osPiRelAccess(void); void __osDevMgrMain(void* arg); // void func_8008C640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16, UNK_TYPE4 param_17, UNK_TYPE4 param_18); -s32 osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size); -// void __osSumcalc(void); -// void __osIdCheckSum(void); -// void __osRepairPackId(void); +s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size); +u16 __osSumcalc(u8* ptr, s32 length); +s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum); +s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid); // void __osCheckPackId(void); // void __osGetId(void); -// void __osCheckId(void); -// void __osPfsRWInode(void); +s32 __osCheckId(OSPfs* pfs); +s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank); u32 osGetCount(void); void guMtxL2F(MtxF* m1, Mtx* m2); u32 osGetMemSize(void); @@ -377,11 +378,11 @@ s32 __osSiDeviceBusy(void); s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); void osSetThreadPri(OSThread* t, OSPri pri); OSPri osGetThreadPri(OSThread* t); -s32 osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); +s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); void osViSwapBuffer(void* frameBufPtr); void guPositionF(float mf[4][4], f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); void guPosition(Mtx* m, f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); -s32 osEPiRawStartDma(OSPiHandle*, s32, u32, void*, u32); +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); OSYieldResult osSpTaskYielded(OSTask* task); s32 bcmp(void* __s1, void* __s2, size_t __n); OSTime osGetTime(void); @@ -426,7 +427,7 @@ s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern); s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status); OSPiHandle* osCartRomInit(void); // void guS2DInitBg(void); -// s32 __osPfsSelectBank(OSPfs* pfs, UNK_TYPE4 param_2); +s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); s32 osContSetCh(u8 ch); u32 __osSetFpcCsr(u32 value); u32 __osGetFpcCsr(void); @@ -483,16 +484,11 @@ void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); void __osSetWatchLo(u32 value); f32 fmodf(f32 dividend, f32 divisor); -void* __osMemset(void* ptr, s32 val, u32 size); +void* __osMemset(void* ptr, s32 val, size_t size); s32 __osStrcmp(const char* str1, const char* str2); char* __osStrcpy(char* dst, const char* src); void* __osMemcpy(void* dst, void* src, size_t size); -void EnAObj_Init(ActorEnAObj* this, GlobalContext* globalCtx); -void EnAObj_Destroy(ActorEnAObj* this, GlobalContext* globalCtx); -void EnAObj_Update1(ActorEnAObj* this, GlobalContext* globalCtx); -void EnAObj_Update2(ActorEnAObj* this, GlobalContext* globalCtx); -void EnAObj_Update(ActorEnAObj* this, GlobalContext* globalCtx); -void EnAObj_Draw(ActorEnAObj* this, GlobalContext* globalCtx); + // void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale); // void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx); // void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx); @@ -681,10 +677,10 @@ void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* // void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); // void EffectSsIceBlock_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5); -void FlagSet_Update(GameState* gamestate); +void FlagSet_Update(GameState* gameState); void FlagSet_Draw(GameState* gameState); -void DLF_LoadGameState(GameStateOverlay* gameState); -void DLF_FreeGameState(GameStateOverlay* gameState); +void Overlay_LoadGameState(GameStateOverlay* gameState); +void Overlay_FreeGameState(GameStateOverlay* gameState); void Actor_PrintLists(ActorContext* actorCtx); void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc func, f32 scale); void ActorShadow_Draw(Actor* actor, Lights* mapper, GlobalContext* globalCtx, Gfx* displayList, Color_RGBA8* color); @@ -1690,14 +1686,16 @@ s16 ActorCutscene_GetCurrentCamera(s16 index); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); // void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800F2478(void); -// void func_800F2620(void); -// void func_800F2650(void); -// void func_800F26C0(void); -// void func_800F26F0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800F2728(void); -// void func_800F29A0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800F2CD8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); +void SkelCurve_Clear(SkelAnimeCurve* skelCurve); +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, + TransformUpdateIndex* transUpdIdx); +void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, + f32 animCurFrame, f32 animSpeed); +s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init); void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); @@ -1919,16 +1917,16 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB); void Lights_GlowCheck(GlobalContext* globalCtx); void Lights_DrawGlow(GlobalContext* globalCtx); -void* zelda_malloc(u32 size); -void* zelda_mallocR(u32 size); -void* zelda_realloc(void* oldPtr, u32 newSize); -void zelda_free(void* param_1); -void* zelda_calloc(u32 num, u32 size); -void MainHeap_AnalyzeArena(u32* maxFreeBlock, u32* bytesFree, u32* bytesAllocated); -// s32 MainHeap_Check(void); -void MainHeap_Init(u32 base, u32 size); -// void MainHeap_Cleanup(void); -// u32 MainHeap_IsInitialized(void); +void* ZeldaArena_Malloc(size_t size); +void* ZeldaArena_MallocR(size_t size); +void* ZeldaArena_Realloc(void* oldPtr, size_t newSize); +void ZeldaArena_Free(void* param_1); +void* ZeldaArena_Calloc(u32 num, size_t size); +void ZeldaArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +void ZeldaArena_Check(); +void ZeldaArena_Init(void* start, size_t size); +void ZeldaArena_Cleanup(); +u8 ZeldaArena_IsInitialized(); // void func_80102E40(void); // void func_80102E90(void); // void func_80102EA4(void); @@ -2442,7 +2440,7 @@ void func_8012F1BC(s16 sceneIndex); s16 func_8012F22C(s16 sceneIndex); void func_8012F278(GlobalContext* globalCtx); s32 Object_Spawn(ObjectContext* objectCtx, s16 id); -void Object_InitBank(GameState* gamestate, ObjectContext* objectCtx); +void Object_InitBank(GameState* gameState, ObjectContext* objectCtx); void Object_UpdateBank(ObjectContext* objectCtx); s32 Object_GetIndex(ObjectContext* objectCtx, s16 id); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); @@ -2461,7 +2459,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd); -void Door_InitContext(GameState* gamestate, DoorContext* doorCtx); +void Door_InitContext(GameState* gameState, DoorContext* doorCtx); void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd); s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd); @@ -2544,96 +2542,115 @@ s32 Entrance_GetTransitionFlags(u16 entranceIndex); // void func_80132E9C(void); // void func_80132FDC(void); // void func_80133000(void); -s32 func_80133038(GlobalContext* globalCtx, UNK_PTR arg1, struct_80133038_arg2* arg2); -void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s32 dListIndex); -void SkelAnime_LodDraw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s32 dListIndex); -void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDrawSV overrideLimbDraw, PostLimbDrawSV postLimbDraw, Actor* actor, s32 dListIndex, RSPMatrix** mtx); -void SkelAnime_LodDrawSV(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, OverrideLimbDrawSV overrideLimbDraw, PostLimbDrawSV postLimbDraw, Actor* actor, s32 dListIndex); -void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor); -void SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor); -void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, RSPMatrix** limbMatricies); -void SkelAnime_DrawSV(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor); -void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkDraw, Actor* actor, RSPMatrix** mtx); -void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkDraw, Actor* actor); -void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); -s16 SkelAnime_GetTotalFrames(AnimationHeaderCommon* animationSeg); -s16 SkelAnime_GetFrameCount(AnimationHeaderCommon* animationSeg); -Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, RSPMatrix** mtx, Gfx* gfx); -Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx); -s32 func_80134FFC(s32 arg0, s32 arg1, Vec3s* dst); -s16 func_801353D4(AnimationHeaderCommon* animationSeg); -s16 SkelAnime_GetTotalFrames2(AnimationHeaderCommon* animationSeg); -s16 SkelAnime_GetFrameCount2(AnimationHeaderCommon* animationSeg); -void SkelAnime_InterpolateVec3s(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf); -void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx); -void func_801358D4(GlobalContext* globalCtx); -void func_801358F4(GlobalContext* globalCtx); -AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type); -void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimationHeader* linkAnimetionSeg, s32 frame, s32 limbCount, void* ram); -void SkelAnime_LoadAnimationType1(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); -void SkelAnime_LoadAnimationType2(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); -void SkelAnime_LoadAnimationType3(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); -void SkelAnime_LoadAnimationType4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); -void SkelAnime_LoadAnimationType5(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3); -void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry); -void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry); -void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry); -void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry); -void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry); -void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry); -void func_80135EE8(GlobalContext* globalCtx, AnimationContext* animationCtx); -void SkelAnime_InitLinkAnimetion(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* linkAnimationHeaderSeg, s32 flags, Vec3s* limbDrawTbl, Vec3s* transitionDrawTbl, s32 limbBufCount); -void func_801360A8(SkelAnime* skelAnime); -s32 func_801360E0(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 func_80136104(GlobalContext* globalCtx, SkelAnime* skelAnime); -void func_801361BC(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 func_80136288(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 func_8013631C(GlobalContext* globalCtx, SkelAnime* skelAnime); -void SkelAnime_SetTransition(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate); -void SkelAnime_ChangeLinkAnim(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); -void SkelAnime_ChangeLinkAnimDefaultStop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg); -void SkelAnime_ChangeLinkAnimPlaybackStop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed); -void SkelAnime_ChangeLinkAnimDefaultRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg); -void SkelAnime_ChangeLinkAnimPlaybackRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed); -void func_8013670C(GlobalContext* globalCtx, SkelAnime* skelAnime); -void func_8013673C(GlobalContext* globalCtx, SkelAnime* skelAnime); -void func_8013676C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 frame); -void func_801367B0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 frame); -void func_801367F4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame); -void func_8013682C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 transitionFrame, LinkAnimationHeader* LinkAnimationHeaderSeg2, f32 frame, f32 transitionRate, Vec3s* limbDrawTbl); -void func_801368CC(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, f32 transitionFrame, LinkAnimationHeader* LinkAnimationHeaderSeg2, f32 frame, f32 transitionRate, Vec3s* limbDrawTbl); -void SkelAnime_SetModeStop(SkelAnime* skelAnime); -s32 func_80136990(SkelAnime* skelAnime, f32 arg1, f32 updateRate); -s32 func_80136A48(SkelAnime* skelAnime, f32 arg1); -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount); -void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount); +UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038_arg2* arg2); +void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); +void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, + s32 lod); +void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, + Mtx** limbMatricies); +void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor, + Mtx** mtx); +void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor); +void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); +s16 Animation_GetLength(void* animation); +s16 Animation_GetLastFrame(void* animation); +Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, + Mtx** mtx, Gfx* gfx); +Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +s16 SkelAnime_GetFrameData2(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); +s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); +s16 Animation_GetLength2(LegacyAnimationHeader* animation); +s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation); +void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf); +void AnimationContext_Reset(AnimationContext* animationCtx); +void AnimationContext_SetNextQueue(GlobalContext* globalCtx); +void AnimationContext_DisableQueue(GlobalContext* globalCtx); +AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); +void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, + s32 limbCount, Vec3s* frameTable); +void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); +void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); +void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); +void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); +void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3); +void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data); +void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx); +void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, + Vec3s* morphTable, s32 limbBufCount); +void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime); +s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); +void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); +void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); +void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); +void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); +void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); +void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); +void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime); +void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime); +void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); +void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); +void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame); +void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); +void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); +void LinkAnimation_EndLoop(SkelAnime* skelAnime); +s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 arg1, f32 updateRate); +s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 arg1); +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); -void func_80136C84(SkelAnime* skelAnime); -s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime); -s32 func_80136CF4(SkelAnime* skelAnime); -s32 func_80136D98(SkelAnime* skelAnime); -void func_80136F04(SkelAnime* skelAnime); -s32 func_8013702C(SkelAnime* skelAnime); -s32 func_801370B0(SkelAnime* skelAnime); -s32 func_8013713C(SkelAnime* skelAnime); -void SkelAnime_ChangeAnimImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2); -void SkelAnime_ChangeAnim(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 mode, f32 transitionRate); -void SkelAnime_ChangeAnimDefaultStop(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void SkelAnime_ChangeAnimTransitionStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void SkelAnime_ChangeAnimPlaybackStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); -void SkelAnime_ChangeAnimDefaultRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void SkelAnime_ChangeAnimTransitionRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void SkelAnime_ChangeAnimPlaybackRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); -void SkelAnime_AnimSetStop(SkelAnime* skelAnime); -void SkelAnime_AnimReverse(SkelAnime* skelAnime); -void func_80137674(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index); -void func_801376DC(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3); -void func_80137748(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -s32 func_801378B8(SkelAnime* skelAnime, f32 arg1); +void SkelAnime_SetUpdate(SkelAnime* skelAnime); +s32 SkelAnime_Update(SkelAnime* skelAnime); +s32 SkelAnime_Morph(SkelAnime* skelAnime); +s32 SkelAnime_MorphTaper(SkelAnime* skelAnime); +void SkelAnime_AnimateFrame(SkelAnime* skelAnime); +s32 SkelAnime_LoopFull(SkelAnime* skelAnime); +s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); +s32 SkelAnime_Once(SkelAnime* skelAnime); +void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2); +void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 mode, f32 transitionRate); +void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); +void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); +void Animation_EndLoop(SkelAnime* skelAnime); +void Animation_Reverse(SkelAnime* skelAnime); +void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index); +void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); +s32 Animation_OnFrame(SkelAnime* skelAnime, f32 arg1); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); -void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); +void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); // void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80137B34(void); // void func_80137EBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -2683,7 +2700,7 @@ s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); // void func_8013A7C0(void); // void func_8013A860(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, void* func1, void* func2, void* func3, Actor* actor, Gfx* gfx); +Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, void* func1, void* func2, void* func3, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); // void func_8013AD9C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); void func_8013AED4(u16* param_1, u16 param_2, u16 param_3); @@ -2765,7 +2782,7 @@ s32 View_SetQuakeSpeed(View* view, f32 speed); s32 View_InitCameraQuake(View* view); s32 View_ClearQuake(View* view); s32 View_SetQuake(View* view, Vec3f rot, Vec3f scale, f32 speed); -s32 View_StepQuake(View* view, RSPMatrix* matrix); +s32 View_StepQuake(View* view, Mtx* matrix); void View_RenderView(View* view, s32 uParm2); s32 View_RenderToPerspectiveMatrix(View* view); s32 View_RenderToOrthographicMatrix(View* view); @@ -2803,11 +2820,12 @@ void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); -s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); -void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); -void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType); +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, + s32 arg8); +void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); +void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); // void func_801435A0(void); // void func_80143624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7); // void func_80143668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -2826,13 +2844,13 @@ void Sram_InitDebugSave(void); // void func_80144E78(void); // void func_8014546C(void); // void func_80145698(void); -void func_801457CC(GameState* gamestate, SramContext* param_2); +void func_801457CC(GameState* gameState, SramContext* param_2); void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); // void func_80146628(void); // void func_80146AA0(void); // void func_80146DF8(void); void func_80146E40(GameState* gameState, SramContext* sramCtx); -void Sram_Alloc(GameState* gamestate, SramContext* sramCtx); +void Sram_Alloc(GameState* gameState, SramContext* sramCtx); // void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); // void func_80146EE8(void); // void func_80146F5C(void); @@ -3101,8 +3119,9 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this); void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this); void func_801720C4(PreRender* this); void func_801720FC(PreRenderParams* params, Gfx** gfxp); -void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags); -void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size); +void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, + f32 y, f32 xScale, f32 yScale, u32 flags); +void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size); void THGA_Dt(TwoHeadGfxArena* thga); u32 THGA_IsCrash(TwoHeadGfxArena* thga); void THGA_Init(TwoHeadGfxArena* thga); @@ -3113,7 +3132,7 @@ Gfx* THGA_GetTail(TwoHeadGfxArena* thga); Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count); Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga); Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga); -Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size); +Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, size_t size); Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count); Gfx* THGA_AllocEnd64(TwoHeadGfxArena* thga); Gfx* THGA_AllocEndArray16(TwoHeadGfxArena* thga, u32 count); @@ -3121,15 +3140,15 @@ Gfx* THGA_AllocEnd16(TwoHeadGfxArena* thga); void* THA_GetHead(TwoHeadArena* tha); void THA_SetHead(TwoHeadArena* tha, void* start); void* THA_GetTail(TwoHeadArena* tha); -void* THA_AllocStart(TwoHeadArena* tha, u32 size); +void* THA_AllocStart(TwoHeadArena* tha, size_t size); void* THA_AllocStart1(TwoHeadArena* tha); -void* THA_AllocEnd(TwoHeadArena* tha, u32 size); -void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size); -void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask); +void* THA_AllocEnd(TwoHeadArena* tha, size_t size); +void* THA_AllocEndAlign16(TwoHeadArena* tha, size_t size); +void* THA_AllocEndAlign(TwoHeadArena* tha, size_t size, u32 mask); s32 THA_GetSize(TwoHeadArena* tha); u32 THA_IsCrash(TwoHeadArena* tha); void THA_Init(TwoHeadArena* tha); -void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size); +void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size); void THA_Dt(TwoHeadArena* tha); void func_80172BC0(void); void func_80172C30(AudioMgr* audioMgr); @@ -3145,46 +3164,46 @@ void TitleSetup_Init(GameState* gameState); void Game_UpdateFramerateVariables(s32 divisor); void Game_SetFramerateDivisor(GameState* gameState, s32 divisor); void GameState_SetFBFilter(Gfx** gfx, u32 arg1); -void Game_Nop80173534(GameState* gamestate); -void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx); -void Game_ResetSegments(GraphicsContext* gfxCtx); -void func_801736DC(GraphicsContext* gfxCtx); -void Game_UpdateInput(GameState* gamestate); -void Game_Update(GameState* gamestate); -void Game_IncrementFrameCount(GameState* gamestate); -void Game_InitHeap(GameState* gamestate, u32 size); -void Game_ResizeHeap(GameState* gamestate, u32 size); -void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); -void Game_StateFini(GameState* gamestate); -GameStateFunc Game_GetNextStateInit(GameState* gamestate); -u32 Game_GetNextStateSize(GameState* gamestate); -u32 Game_GetShouldContinue(GameState* gamestate); -s32 Game_GetHeapFreeSize(GameState* gamestate); -s32 func_80173B48(GameState* gamestate); -GameAlloc* func_80173BF0(GameAlloc* heap); -void* Gamealloc_Alloc(GameAlloc* heap, u32 size); -void Gamealloc_Free(GameAlloc* heap, void* ptr); -void Gamealloc_FreeAll(GameAlloc* heap); -void Gamealloc_Init(GameAlloc* iParm1); +void Game_Nop80173534(GameState* gameState); +void GameState_Draw(GameState* gameState, GraphicsContext* gCtxt); +void GameState_SetFrameBuffer(GraphicsContext* gCtxt); +void func_801736DC(GraphicsContext* gCtxt); +void Game_UpdateInput(GameState* gameState); +void Game_Update(GameState* gameState); +void Game_IncrementFrameCount(GameState* gameState); +void GameState_InitArena(GameState* gameState, size_t size); +void GameState_Realloc(GameState* gameState, size_t size); +void GameState_Init(GameState* gameState, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); +void GameState_Destroy(GameState* gameState); +GameStateFunc GameState_GetNextStateInit(GameState* gameState); +size_t Game_GetNextStateSize(GameState* gameState); +u32 GameState_IsRunning(GameState* gameState); +s32 GameState_GetArenaSize(GameState* gameState); +s32 func_80173B48(GameState* gameState); +void GameAlloc_Log(GameAlloc* heap); +void* GameAlloc_Malloc(GameAlloc* heap, size_t size); +void GameAlloc_Free(GameAlloc* heap, void* ptr); +void GameAlloc_Cleanup(GameAlloc* heap); +void GameAlloc_Init(GameAlloc* iParm1); // void Graph_FaultClient(void); -void Graph_DlAlloc(TwoHeadGfxArena* dl, void* memoryBlock, u32 size); +void Graph_DlAlloc(TwoHeadGfxArena* dl, void* memoryBlock, size_t size); void Graph_InitTHGA(GraphicsContext* gfxCtx); -GameStateOverlay* Graph_GetNextGameState(GameState* gamestate); +GameStateOverlay* Graph_GetNextGameState(GameState* gameState); void* Graph_FaultAddrConvFunc(void* addr); void Graph_Init(GraphicsContext* gfxCtx); // void Graph_Destroy(void); -void Graph_Render(GraphicsContext* gfxCtx, GameState* gamestate); -void Graph_FrameSetup(GameState* gamestate); -void Graph_RenderFrame(GraphicsContext* gfxCtx, GameState* gamestate); -void Graph_DoFrame(GraphicsContext* gfxCtx, GameState* gamestate); +void Graph_Render(GraphicsContext* gfxCtx, GameState* gameState); +void Graph_FrameSetup(GameState* gameState); +void Graph_RenderFrame(GraphicsContext* gfxCtx, GameState* gameState); +void Graph_DoFrame(GraphicsContext* gfxCtx, GameState* gameState); void Graph_ThreadEntry(void* arg); Gfx* Graph_GfxPlusOne(Gfx* gfx); Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); -void* Graph_DlistAlloc(Gfx** gfx, u32 size); -void func_80174AA0(ListAlloc* alloc); -// void func_80174AB4(void); -// void func_80174B20(void); -void func_80174BA0(ListAlloc* alloc); +void* Graph_DlistAlloc(Gfx** gfx, size_t size); +ListAlloc* ListAlloc_Init(ListAlloc* this); +// void ListAlloc_Alloc(void); +// void ListAlloc_Free(void); +void ListAlloc_FreeAll(ListAlloc* this); void Main(void* arg); u32 Padmgr_GetControllerBitmask(void); // void func_80174F24(void); @@ -3213,7 +3232,7 @@ void func_80175E68(Input* input, s32 param_2); void Padmgr_GetInput(Input* input, s32 param_2); void Padmgr_GetInput2(Input* input, s32 param_2); void Padmgr_ThreadEntry(PadMgr* padmgr); -void Padmgr_Start(OSMesgQueue* siEventCallbackQueue, IrqMgr* irqmgr, OSId threadId, OSPri threadPri, void* stack); +void PadMgr_Init(OSMesgQueue* siEventCallbackQueue, IrqMgr* irqmgr, OSId threadId, OSPri threadPri, void* stack); void Sched_SwapFramebuffer(CfbInfo* cfbInfo); void Sched_RetraceUpdateFramebuffer(SchedContext* sched, CfbInfo* cfbInfo); void Sched_HandleReset(SchedContext* sched); @@ -3239,9 +3258,9 @@ void Sched_Init(SchedContext* sched, void* stack, OSPri pri, UNK_TYPE arg3, UNK_ // void func_80177390(void); void func_801773A0(void* arg0); void func_801773C4(void* arg0); -void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gCtx); -// void func_80177A84(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); -// void func_80177AC8(void); +void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gfxCtx); +// void func_80177A84(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); +//void func_80177AC8(void); void SpeedMeter_DrawAllocEntries(void* displayList, GraphicsContext* gfxCtx, GameState* gameState); void func_801780F0(Mtx* param_1, f32 param_2, f32 param_3, f32 param_4, f32 param_5, f32 param_6, f32 param_7); // void func_801781EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -3375,46 +3394,48 @@ s16 Math_Atan2S(f32 opposite, f32 adjacent); f32 Math_Atan2F(f32 opposite, f32 adjacent); s16 Math_FAtan2F(f32 adjacent, f32 opposite); f32 Math_Acot2F(f32 adjacent, f32 opposite); -void SysMatrix_StateAlloc(GameState* gamestate); -void SysMatrix_StatePush(void); -void SysMatrix_StatePop(void); -void SysMatrix_CopyCurrentState(MtxF* matrix); -void SysMatrix_SetCurrentState(MtxF* matrix); -MtxF* SysMatrix_GetCurrentState(void); -void SysMatrix_InsertMatrix(MtxF* matrix, s32 appendToState); -void SysMatrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); +void Matrix_StateAlloc(GameState* gameState); +void Matrix_StatePush(void); +void Matrix_StatePop(void); +void Matrix_CopyCurrentState(MtxF* matrix); +void Matrix_SetCurrentState(MtxF* matrix); +MtxF* Matrix_GetCurrentState(void); +void Matrix_InsertMatrix(MtxF* matrix, s32 appendToState); +void Matrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, s32 appendToState); -void SysMatrix_InsertXRotation_s(s16 rotation, s32 appendToState); -void SysMatrix_InsertXRotation_f(f32 rotation, s32 appendToState); -void SysMatrix_RotateStateAroundXAxis(f32 rotation); -void SysMatrix_SetStateXRotation(f32 rotation); +void Matrix_InsertXRotation_s(s16 rotation, s32 appendToState); +void Matrix_InsertXRotation_f(f32 rotation, s32 appendToState); +void Matrix_RotateStateAroundXAxis(f32 rotation); +void Matrix_SetStateXRotation(f32 rotation); void Matrix_RotateY(s16 rotation, s32 appendToState); -void SysMatrix_InsertYRotation_f(f32 rotation, s32 appendToState); -void SysMatrix_InsertZRotation_s(s16 rotation, s32 appendToState); -void SysMatrix_InsertZRotation_f(f32 rotation, s32 appendToState); -void SysMatrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); -void SysMatrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); -void SysMatrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); -RSPMatrix* SysMatrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); -RSPMatrix* SysMatrix_GetStateAsRSPMatrix(RSPMatrix* matrix); +void Matrix_InsertYRotation_f(f32 rotation, s32 appendToState); +void Matrix_InsertZRotation_s(s16 rotation, s32 appendToState); +void Matrix_InsertZRotation_f(f32 rotation, s32 appendToState); +void Matrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); +void Matrix_JointPosition(Vec3f* position, Vec3s* rotation); +void Matrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); +void Matrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); +RSPMatrix* Matrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); +Mtx* Matrix_ToMtx(Mtx* dest); +RSPMatrix* Matrix_GetStateAsRSPMatrix(RSPMatrix* matrix); Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -RSPMatrix* SysMatrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx); -void SysMatrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx); -void SysMatrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); -void SysMatrix_GetStateTranslation(Vec3f* dst); -void SysMatrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); -void SysMatrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); -void SysMatrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); -void SysMatrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); +RSPMatrix* Matrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx); +void Matrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx); +void Matrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); +void Matrix_GetStateTranslation(Vec3f* dst); +void Matrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); +void Matrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); +void Matrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); +void Matrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); void Matrix_MtxFCopy(MtxF* dst, MtxF* src); -void SysMatrix_FromRSPMatrix(RSPMatrix* src, MtxF* dst); -void SysMatrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); -void SysMatrix_TransposeXYZ(MtxF* matrix); -void SysMatrix_NormalizeXYZ(MtxF* matrix); +void Matrix_FromRSPMatrix(Mtx* src, MtxF* dst); +void Matrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); +void Matrix_TransposeXYZ(MtxF* matrix); +void Matrix_NormalizeXYZ(MtxF* matrix); void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); // void func_801822C4(void); -void SysMatrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); -void SysMatrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); +void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); +void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); // void func_80182C90(void); // void func_80182CA0(void); // void func_80182CBC(void); diff --git a/include/io/controller.h b/include/io/controller.h index e976402ec..50add3561 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -139,7 +139,8 @@ typedef struct { /* 0x01 */ u8 txsize; /* 0x02 */ u8 rxsize; /* 0x03 */ u8 cmd; - /* 0x04 */ u16 address; + /* 0x04 */ u8 hi; + /* 0x05 */ u8 lo; /* 0x06 */ u8 data[32]; /* 0x26 */ u8 datacrc; } __OSContRamReadFormat; diff --git a/include/os.h b/include/os.h index 50f3b10c4..b182d4e47 100644 --- a/include/os.h +++ b/include/os.h @@ -1,6 +1,7 @@ #ifndef _OS_H_ #define _OS_H_ +#include "stdlib.h" #include "ultra64/thread.h" #include "ultra64/message.h" @@ -65,7 +66,7 @@ typedef struct { /* 0x00 */ OSIoMesgHdr hdr; /* 0x08 */ void* dramAddr; /* 0x0C */ u32 devAddr; - /* 0x10 */ u32 size; + /* 0x10 */ size_t size; /* 0x14 */ OSPiHandle* piHandle; } OSIoMesg; // size = 0x88 @@ -76,8 +77,8 @@ typedef struct { /* 0x08 */ OSMesgQueue* cmdQueue; /* 0x0C */ OSMesgQueue* evtQueue; /* 0x10 */ OSMesgQueue* acsQueue; - /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, u32); - /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, u32); + /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); } OSDevMgr; // size = 0x1C diff --git a/include/os_internal.h b/include/os_internal.h index b00548092..3c6d4eee4 100644 --- a/include/os_internal.h +++ b/include/os_internal.h @@ -6,4 +6,14 @@ typedef struct { /* 0x04 */ OSMesg msg; } __osHwInt; // size = 0x08 +typedef struct { + /* 0x00 */ u32 initialized; + /* 0x04 */ OSThread* mgrThread; + /* 0x08 */ OSMesgQueue* cmdQueue; + /* 0x0C */ OSMesgQueue* eventQueue; + /* 0x10 */ OSMesgQueue* accessQueue; + /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); +} OSMgrArgs; // size = 0x1C + #endif diff --git a/include/stdlib.h b/include/stdlib.h index f10cfef4b..a7b44961a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -18,7 +18,7 @@ typedef struct { /* 0x8 */ long long rem; } lldiv_t; -typedef unsigned int size_t; +typedef unsigned long size_t; typedef int ssize_t; diff --git a/include/string.h b/include/string.h deleted file mode 100644 index c519b1406..000000000 --- a/include/string.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _STRING_H_ -#define _STRING_H_ - -#define NULL 0 -typedef unsigned int size_t; - -#endif diff --git a/include/variables.h b/include/variables.h index 7d6969543..0897d2bc9 100644 --- a/include/variables.h +++ b/include/variables.h @@ -30,8 +30,8 @@ extern vs32 gIrqMgrResetStatus; extern volatile OSTime sIrqMgrResetTime; extern volatile OSTime sIrqMgrRetraceTime; extern s32 sIrqMgrRetraceCount; -extern char* D_80096B80[18]; -extern char* sExceptionNames[6]; +extern const char* sCpuExceptions[18]; +extern const char* sFpuExceptions[6]; extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; // extern UNK_TYPE4 D_80096C20; @@ -67,8 +67,8 @@ extern OSPiHandle* __osPiTable; extern OSPiHandle* __osCurrentHandle[]; extern UNK_TYPE4 __osPiAccessQueueEnabled; extern OSViMode osViModeNtscHpn1; -// extern UNK_TYPE4 D_80097F00; -// extern UNK_TYPE1 D_80097F04; +extern s32 __osPfsInodeCacheChannel; +extern u8 __osPfsInodeCacheBank; extern UNK_TYPE4 D_80097F10; extern char spaces[]; extern char zeroes[]; @@ -207,8 +207,8 @@ extern char D_80098A00[]; extern char D_80098A0C[]; extern char D_80098A1C[]; extern char D_80098A20[34]; -extern char D_80098A44[]; -extern char D_80098A68[]; +extern const char D_80098A44[]; +extern const char D_80098A68[]; extern char D_80098A88[53]; extern char D_80098AC0[49]; extern char D_80098AF4[51]; @@ -218,7 +218,7 @@ extern char D_80098B68[]; extern char D_80098B84[]; extern char D_80098BA0[]; extern char D_80098BBC[]; -extern char faultThreadName[]; +extern const char faultThreadName[]; extern char D_80098BE0[]; extern char D_80098BF8[]; extern char D_80098BFC[]; @@ -230,15 +230,14 @@ extern char D_80098C2C[]; extern char D_80098C34[]; extern char D_80098C38[]; extern char D_80098C40[]; -extern u8 sFaultDrawerFont[8][128]; extern char D_80099050[]; extern char D_80099054[]; extern char D_8009905C[]; extern char D_80099064[]; extern char D_80099070[]; -extern char D_80099078[]; -extern char D_8009907C[]; -extern char D_80099080[]; +extern const char D_80099078[]; +extern const char D_8009907C[]; +extern const char D_80099080[]; extern char D_800990B0[]; extern f32 D_800990C0[9]; extern f32 D_800990E4; @@ -325,10 +324,10 @@ extern FaultDrawer sFaultDrawerStruct; // extern Arena gSystemArena; extern u32 sRandFloat; // extern UNK_TYPE4 sArenaLockMsg; -// extern OSTask tmp_task; -// extern UNK_TYPE1 D_8009CDB0; -// extern OSMesg siAccessBuf[1]; -// extern OSMesgQueue __osSiAccessQueue; +extern OSTask tmp_task; +extern OSPifRam osPifBuffers[4]; +extern OSMesg siAccessBuf[1]; +extern OSMesgQueue __osSiAccessQueue; extern OSPifRam __osContPifRam; // extern UNK_TYPE1 D_8009CF0C; extern u8 __osContLastCmd; @@ -1673,7 +1672,7 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f D_801D15B0; extern Vec3s D_801D15BC; -extern RSPMatrix D_801D1DE0; +extern Mtx D_801D1DE0; extern MtxF D_801D1E20; extern UNK_PTR D_801D1E60; extern UNK_PTR D_801D1E64; @@ -3263,7 +3262,6 @@ extern TriNorm D_801EF590; extern TriNorm D_801EF5C8; extern TriNorm D_801EF600; extern TriNorm D_801EF638; -// extern UNK_TYPE1 D_801EF66D; extern SaveContext gSaveContext; // extern UNK_TYPE2 D_801F3F38; // extern UNK_TYPE1 D_801F3F3A; @@ -3344,7 +3342,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; extern LightsBuffer sLightsBuffer; -extern Arena mainHeap; +extern Arena sZeldaArena; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -3368,13 +3366,6 @@ extern Arena mainHeap; // extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern QuakeRequest sQuakeRequest[4]; -// extern Quake2Context sQuake2Context; -// extern s32 sMatAnimStep; -// extern u32 sMatAnimFlags; -// extern f32 sMatAnimAlphaRatio; -extern s32 D_801F5AB0; -extern s32 D_801F5AB4; // extern UNK_TYPE1 D_801F5AC0; // extern UNK_TYPE1 D_801F69D0; // extern UNK_TYPE1 D_801F6A10; @@ -3437,19 +3428,19 @@ extern FaultClient graphFaultClient; extern Gfx* graphDlEntry; // extern UNK_TYPE1 D_801F80F8; extern u64 lastRenderFrameTimestamp; -extern OSMesgQueue siEventCallbackQueue; -extern OSMesg siEventCallbackBuffer[1]; +extern OSMesgQueue sSiIntMsgQ; +extern OSMesg sSiIntMsgBuf[1]; extern u32 gSegments[NUM_SEGMENTS]; extern SchedContext gSchedContext; -extern IrqMgrClient mainIrqmgrCallbackNode; -extern OSMesgQueue mainIrqmgrCallbackQueue; -extern OSMesg mainIrqCallbackBuffer[60]; -extern OSThread graphOSThread; -extern u8 graphStack[0x1800]; -extern u8 schedStack[0x600]; -extern u8 audioStack[0x800]; -extern u8 padmgrStack[0x500]; -extern StackEntry graphStackEntry; +extern IrqMgrClient irqClient; +extern OSMesgQueue irqMgrMsgQ; +extern OSMesg irqMgrMsgBuf[60]; +extern OSThread sGraphThread; +extern u8 sGraphStack[6144]; +extern u8 schedStack[1536]; +extern u8 audioStack[2048]; +extern u8 padmgrStack[1280]; +extern StackEntry sGraphStackInfo; extern StackEntry schedStackEntry; extern StackEntry audioStackEntry; extern StackEntry padmgrStackEntry; diff --git a/include/z64.h b/include/z64.h index e38d926a6..96ebb233b 100644 --- a/include/z64.h +++ b/include/z64.h @@ -308,7 +308,7 @@ typedef struct GraphicsContext { /* 0x1B4 */ Gfx* unk1B4; /* 0x1B8 */ TwoHeadGfxArena unk1B8; /* 0x1C8 */ UNK_TYPE1 pad1C8[0xAC]; - /* 0x274 */ OSViMode* unk274; + /* 0x274 */ OSViMode* viMode; /* 0x278 */ void* zbuffer; /* 0x27C */ UNK_TYPE1 pad27C[0x1C]; /* 0x298 */ TwoHeadGfxArena overlay; @@ -410,13 +410,13 @@ typedef struct { /* 0xC */ s32 rightX; } Viewport; // size = 0x10 -typedef void*(*fault_address_converter_func)(void* addr, void* arg); +typedef void*(*FaultAddrConvFunc)(void* addr, void* arg); typedef void(*fault_client_func)(void* arg1, void* arg2); typedef void(*osCreateThread_func)(void*); -typedef void* (*PrintCallback)(void*, const char*, u32); +typedef void* (*PrintCallback)(void*, const char*, size_t); typedef enum { SLOWLY_CALLBACK_NO_ARGS, @@ -991,7 +991,7 @@ typedef struct { typedef struct ArenaNode_t { /* 0x0 */ s16 magic; // Should always be 0x7373 /* 0x2 */ s16 isFree; - /* 0x4 */ u32 size; + /* 0x4 */ size_t size; /* 0x8 */ struct ArenaNode_t* next; /* 0xC */ struct ArenaNode_t* prev; } ArenaNode; // size = 0x10 @@ -1009,7 +1009,7 @@ typedef struct FaultAddrConvClient FaultAddrConvClient; struct FaultAddrConvClient { /* 0x0 */ FaultAddrConvClient* next; - /* 0x4 */ fault_address_converter_func callback; + /* 0x4 */ FaultAddrConvFunc callback; /* 0x8 */ void* param; }; // size = 0xC @@ -1044,46 +1044,47 @@ typedef struct FireObj FireObj; typedef struct FireObjLight FireObjLight; -typedef struct GameAlloc GameAlloc; +typedef struct GameAllocNode { + /* 0x0 */ struct GameAllocNode* next; + /* 0x4 */ struct GameAllocNode* prev; + /* 0x8 */ size_t size; + /* 0xC */ u32 unk_0C; +} GameAllocEntry; // size = 0x10 -typedef struct PreNMIContext PreNMIContext; - -typedef struct GameAllocNode GameAllocNode; - -struct GameAllocNode { - /* 0x0 */ GameAllocNode* next; - /* 0x4 */ GameAllocNode* prev; - /* 0x8 */ u32 size; - /* 0xC */ UNK_TYPE1 padC[0x4]; -}; // size = 0x10 - -struct GameAlloc { - /* 0x00 */ GameAllocNode base; - /* 0x10 */ GameAllocNode* head; -}; // size = 0x14 +typedef struct GameAlloc { + /* 0x00 */ GameAllocEntry base; + /* 0x10 */ GameAllocEntry* head; +} GameAlloc; // size = 0x14 struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; /* 0x08 */ GameStateFunc destroy; /* 0x0C */ GameStateFunc nextGameStateInit; - /* 0x10 */ u32 nextGameStateSize; + /* 0x10 */ size_t nextGameStateSize; /* 0x14 */ Input input[4]; /* 0x74 */ TwoHeadArena heap; /* 0x84 */ GameAlloc alloc; /* 0x98 */ UNK_TYPE1 pad98[0x3]; /* 0x9B */ u8 running; // If 0, switch to next game state /* 0x9C */ u32 frames; - /* 0xA0 */ UNK_TYPE1 padA0[0x2]; + /* 0xA0 */ u8 padA0[0x2]; /* 0xA2 */ u8 framerateDivisor; // game speed? /* 0xA3 */ UNK_TYPE1 unkA3; }; // size = 0xA4 -struct PreNMIContext { +typedef struct PreNMIContext { /* 0x00 */ GameState state; /* 0xA4 */ u32 timer; /* 0xA8 */ UNK_TYPE4 unkA8; -}; // size = 0xAC +} PreNMIContext; // size = 0xAC + +typedef struct { + /* 0x00 */ u32 resetting; + /* 0x04 */ u32 resetCount; + /* 0x08 */ OSTime duration; + /* 0x10 */ OSTime resetTime; +} PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) typedef struct GlobalContext GlobalContext; @@ -1266,7 +1267,7 @@ typedef struct { /* 0x024 */ UNK_TYPE4 unk24; /* 0x028 */ OSMesg lockMesg[1]; /* 0x02C */ OSMesg interrupts[8]; - /* 0x04C */ OSMesgQueue siEventCallbackQueue; + /* 0x04C */ OSMesgQueue sSiIntMsgQ; /* 0x064 */ OSMesgQueue lock; /* 0x07C */ OSMesgQueue irqmgrCallbackQueue; /* 0x094 */ IrqMgrClient irqmgrCallbackQueueNode; diff --git a/include/z64actor.h b/include/z64actor.h index 48c53e8a2..5876251fb 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -141,7 +141,7 @@ typedef struct { /* 0x10 */ f32 shadowScale; // Changes the size of the shadow /* 0x14 */ u8 shadowAlpha; // Default is 255 /* 0x15 */ u8 feetFloorFlags; // Set if the actor's foot is clipped under the floor. & 1 is right foot, & 2 is left - /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDraw + /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDrawOpa } ActorShape; // size = 0x30 typedef struct Actor { @@ -289,12 +289,16 @@ typedef struct EnItem00 { /* 0x1A4 */ s8 unk1A4; } EnItem00; // size = 0x1A8 -typedef struct { - /* 0x000 */ Actor base; - /* 0x144 */ ActorFunc update; +struct EnAObj; + +typedef void (*EnAObjActionFunc)(struct EnAObj*, struct GlobalContext*); + +typedef struct EnAObj { + /* 0x000 */ Actor actor; + /* 0x144 */ EnAObjActionFunc actionFunc; /* 0x148 */ ColliderCylinder collision; /* 0x194 */ UNK_TYPE1 pad194[0x14]; -} ActorEnAObj; // size = 0x1A8 +} EnAObj; // size = 0x1A8 typedef enum { /* 0x00 */ ACTORCAT_SWITCH, diff --git a/include/z64animation.h b/include/z64animation.h index aa5148e3b..2eed33ffd 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -6,196 +6,216 @@ #include "z64dma.h" #include "z64math.h" +struct GlobalContext; +struct Actor; +struct SkelAnime; + #define LINK_ANIMETION_OFFSET(addr, offset) \ (SEGMENT_ROM_START(link_animetion) + ((u32)addr & 0xFFFFFF) + ((u32)offset)) #define LIMB_DONE 0xFF #define ANIMATION_ENTRY_MAX 50 -#define ANIM_FLAG_UPDATEXZ 0x02 -#define ANIM_FLAG_UPDATEY 0x10 +#define ANIM_FLAG_UPDATEY (1 << 1) +#define ANIM_FLAG_NOMOVE (1 << 4) -struct GlobalContext; -struct Actor; -typedef struct SkelAnime SkelAnime; +typedef enum { + /* 0 */ ANIMMODE_LOOP, + /* 1 */ ANIMMODE_LOOP_INTERP, + /* 2 */ ANIMMODE_ONCE, + /* 3 */ ANIMMODE_ONCE_INTERP, + /* 4 */ ANIMMODE_LOOP_PARTIAL, + /* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP +} AnimationModes; + +typedef enum { + /* -1 */ ANIMTAPER_DECEL = -1, + /* 0 */ ANIMTAPER_NONE, + /* 1 */ ANIMTAPER_ACCEL +} AnimationTapers; typedef struct { - /* 0x000 */ Vec3s translation; // Translation relative to parent limb. root limb is a tranlation for entire model. - /* 0x006 */ u8 firstChildIndex; // The first child's index into the limb table. - /* 0x007 */ u8 nextLimbIndex; // The parent limb's next limb index into the limb table. - /* 0x008 */ Gfx* displayLists[1]; // Display lists for the limb. Index 0 is the normal display list, index 1 is the - // far model display list. -} StandardLimb; // Size = 0xC + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; // The first child's index into the limb table. + /* 0x07 */ u8 sibling; // The parent limb's next limb index into the limb table. + /* 0x08 */ Gfx* dList; // Display lists for the limb. Index 0 is the normal display list, index 1 is the + // far model display list. +} StandardLimb; // size = 0xC // Model has limbs with only rigid meshes typedef struct { - /* 0x000 */ void** skeletonSeg; // Segment address of SkelLimbIndex. - /* 0x004 */ u8 limbCount; // Number of limbs in the model. + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; + /* 0x07 */ u8 sibling; + /* 0x08 */ Gfx* dLists[2]; // Near and far +} LodLimb; // size = 0x10 + +// Model has limbs with only rigid meshes +typedef struct { + /* 0x00 */ void** segment; + /* 0x04 */ u8 limbCount; } SkeletonHeader; // size = 0x8 // Model has limbs with flexible meshes typedef struct { - /* 0x000 */ SkeletonHeader sh; - /* 0x008 */ u8 dListCount; // Number of display lists in the model. + /* 0x00 */ SkeletonHeader sh; + /* 0x08 */ u8 dListCount; } FlexSkeletonHeader; // size = 0xC -typedef s16 AnimationRotationValue; - +// Index into the frame data table. typedef struct { - /* 0x000 */ u16 x; - /* 0x002 */ u16 y; - /* 0x004 */ u16 z; + /* 0x00 */ u16 x; + /* 0x02 */ u16 y; + /* 0x04 */ u16 z; } JointIndex; // size = 0x06 typedef struct { - /* 0x000 */ s16 frameCount; - /* 0x002 */ s16 unk02; -} AnimationHeaderCommon; // size = 0x4 + /* 0x00 */ s16 frameCount; +} AnimationHeaderCommon; typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ s16* frameData; // referenced as tbl - /* 0x08 */ JointIndex* jointIndices; // referenced as ref_tbl - /* 0x0C */ u16 staticIndexMax; + /* 0x000 */ AnimationHeaderCommon common; + /* 0x004 */ s16* frameData; // referenced as tbl + /* 0x008 */ JointIndex* jointIndices; // referenced as ref_tbl + /* 0x00C */ u16 staticIndexMax; } AnimationHeader; // size = 0x10 +typedef struct { + /* 0x00 */ s16 xMax; + /* 0x02 */ s16 x; + /* 0x04 */ s16 yMax; + /* 0x06 */ s16 y; + /* 0x08 */ s16 zMax; + /* 0x10 */ s16 z; +} JointKey; // size = 0x12 + +typedef struct { + /* 0x00 */ s16 frameCount; + /* 0x02 */ s16 limbCount; + /* 0x04 */ s16* frameData; + /* 0x08 */ JointKey* jointKey; +} LegacyAnimationHeader; // size = 0xC + typedef enum { ANIMATION_LINKANIMETION, - ANIMATION_TYPE1, - ANIMATION_TYPE2, - ANIMATION_TYPE3, - ANIMATION_TYPE4, - ANIMATION_TYPE5 + ANIMENTRY_COPYALL, + ANIMENTRY_INTERP, + ANIMENTRY_COPYTRUE, + ANIMENTRY_COPYFALSE, + ANIMENTRY_MOVEACTOR } AnimationType; typedef struct { /* 0x000 */ DmaRequest req; /* 0x020 */ OSMesgQueue msgQueue; /* 0x038 */ OSMesg msg; -} AnimationEntryType0; // size = 0x3C +} AnimEntryLoadFrame; // size = 0x3C typedef struct { - /* 0x000 */ u8 unk00; + /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; -} AnimationEntryType1; // size = 0xC +} AnimEntryCopyAll; // size = 0xC typedef struct { - /* 0x000 */ u8 unk00; - /* 0x001 */ u8 limbCount; - /* 0x004 */ Vec3s* unk04; - /* 0x008 */ Vec3s* unk08; - /* 0x00C */ f32 unk0C; -} AnimationEntryType2; // size = 0x10 + /* 0x000 */ u8 queueFlag; + /* 0x001 */ u8 vecCount; + /* 0x004 */ Vec3s* base; + /* 0x008 */ Vec3s* mod; + /* 0x00C */ f32 weight; +} AnimEntryInterp; // size = 0x10 typedef struct { - /* 0x000 */ u8 unk00; + /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; - /* 0x00C */ u8* index; -} AnimationEntryType3; // size = 0x10 + /* 0x00C */ u8* copyFlag; +} AnimEntryCopyTrue; // size = 0x10 typedef struct { - /* 0x000 */ u8 unk00; + /* 0x000 */ u8 queueFlag; /* 0x001 */ u8 vecCount; - /* 0x002 */ char unk02[0x2]; /* 0x004 */ Vec3s* dst; /* 0x008 */ Vec3s* src; - /* 0x00C */ u8* index; -} AnimationEntryType4; // size = 0x10 + /* 0x00C */ u8* copyFlag; +} AnimEntryCopyFalse; // size = 0x10 typedef struct { /* 0x000 */ struct Actor* actor; - /* 0x004 */ SkelAnime* skelAnime; + /* 0x004 */ struct SkelAnime* skelAnime; /* 0x008 */ f32 unk08; -} AnimationEntryType5; // size = 0xC - -typedef struct { - /* 0x000 */ u8 raw[0x3C]; -} AnimationEntryRaw; // size = 0x3C +} AnimEntryMoveActor; // size = 0xC typedef union { - AnimationEntryRaw raw; - AnimationEntryType0 type0; - AnimationEntryType1 type1; - AnimationEntryType2 type2; - AnimationEntryType3 type3; - AnimationEntryType4 type4; - AnimationEntryType5 type5; -} AnimationEntryType; // size = 0x3C + AnimEntryLoadFrame load; + AnimEntryCopyAll copy; + AnimEntryInterp interp; + AnimEntryCopyTrue copy1; + AnimEntryCopyFalse copy0; + AnimEntryMoveActor move; +} AnimationEntryData; // size = 0x3C typedef struct { /* 0x000 */ u8 type; - /* 0x001 */ u8 unk01; - /* 0x004 */ AnimationEntryType types; + /* 0x004 */ AnimationEntryData data; } AnimationEntry; // size = 0x40 typedef struct AnimationContext { /* 0x000 */ s16 animationCount; - /* 0x002 */ char unk02[2]; /* 0x004 */ AnimationEntry entries[ANIMATION_ENTRY_MAX]; } AnimationContext; // size = 0xC84 typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ u32 segment; + /* 0x000 */ AnimationHeaderCommon common; + /* 0x004 */ u32 segment; } LinkAnimationHeader; // size = 0x8 -struct SkelAnime { - /* 0x00 */ u8 limbCount; // joint_Num - /* modes 0 and 1 repeat the animation indefinitely - * modes 2 and 3 play the animaton once then stop - * modes >= 4 play the animation once, and always start at frame 0. - */ - /* 0x01 */ u8 mode; - /* 0x02 */ u8 dListCount; - /* 0x03 */ s8 unk03; +typedef struct SkelAnime { + /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton + /* 0x01 */ u8 mode; // 0: loop, 2: play once, 4: partial loop. +1 to interpolate between frames. + /* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton + /* 0x03 */ s8 taper; // Tapering to use when morphing between animations. Only used by Door_Warp1. /* 0x04 */ void** skeleton; // An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb. - /* 0x08 */ - union { - AnimationHeader* animCurrentSeg; - LinkAnimationHeader* linkAnimetionSeg; - AnimationHeaderCommon* genericSeg; - }; - /* 0x0C */ f32 initialFrame; - /* 0x10 */ f32 animFrameCount; - /* 0x14 */ f32 totalFrames; - /* 0x18 */ f32 animCurrentFrame; - /* 0x1C */ f32 animPlaybackSpeed; - /* 0x20 */ Vec3s* limbDrawTbl; // now_joint - /* 0x24 */ Vec3s* transitionDrawTbl; // morf_joint - /* 0x28 */ f32 transCurrentFrame; - /* 0x2C */ f32 transitionStep; - /* 0x30 */ s32 (*animUpdate)(); - /* 0x34 */ s8 initFlags; - /* 0x35 */ u8 flags; - /* 0x36 */ s16 prevFrameRot; - /* 0x38 */ Vec3s prevFramePos; - /* 0x3E */ Vec3s unk3E; -}; // size = 0x44 + /* 0x08 */ void* animation; // Can be an AnimationHeader or LinkAnimationHeader. + /* 0x0C */ f32 startFrame; // In mode 4, start of partial loop. + /* 0x10 */ f32 endFrame; // In mode 2, Update returns true when curFrame is equal to this. In mode 4, end of partial loop. + /* 0x14 */ f32 animLength; // Total number of frames in the current animation's file. + /* 0x18 */ f32 curFrame; // Current frame in the animation + /* 0x1C */ f32 playSpeed; // Multiplied by R_UPDATE_RATE / 3 to get the animation's frame rate. + /* 0x20 */ Vec3s* jointTable; // Current translation of model and rotations of all limbs + /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations + /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] + /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph + /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton + /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. + /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. + /* 0x38 */ Vec3s prevTransl; // Previous modelspace translation. + /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. +} SkelAnime; // size = 0x44 -typedef s32 (*OverrideLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + struct Actor* actor); + +typedef void (*PostLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* actor); +typedef s32 (*OverrideLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + struct Actor* actor, Gfx** gfx); + typedef void (*PostLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - struct Actor* actor); + struct Actor* actor, Gfx** gfx); -typedef s32 (*OverrideLimbDraw2)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - struct Actor* actor, Gfx** gfx); +typedef s32 (*OverrideLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + struct Actor* actor); -typedef void (*PostLimbDraw2)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - struct Actor* actor, Gfx** gfx); - -typedef s32 (*OverrideLimbDrawSV)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - struct Actor* actor); - -typedef void (*PostLimbDrawSV)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, - struct Actor* actor); +typedef void (*PostLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, + struct Actor* actor); typedef void (*UnkActorDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor); -typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryType*); +typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData*); extern u32 link_animetion_segment; diff --git a/include/z64effect.h b/include/z64effect.h index f84ae9c9a..adb690732 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -274,16 +274,37 @@ typedef struct { /* 0x8 */ s32 size; } EffectSsInfo; // size = 0xC +typedef struct { + /* 0x0 */ EffectSs* data_table; // Name from debug assert + /* 0x4 */ s32 searchIndex; + /* 0x8 */ s32 size; +} EffectTableInfo; // size = 0xC + +typedef struct { + /* 0x0 */ UNK_TYPE4 unk0; + /* 0x4 */ EffectSsInitFunc init; +} ParticleOverlayInfo; // size = 0x8 + +typedef struct { + /* 0x00 */ u32 vromStart; + /* 0x04 */ u32 vromEnd; + /* 0x08 */ void* vramStart; + /* 0x0C */ void* vramEnd; + /* 0x10 */ void* loadedRamAddr; + /* 0x14 */ ParticleOverlayInfo* overlayInfo; + /* 0x18 */ u32 unk18; // Always 0x01000000? +} ParticleOverlay; // size = 0x1C + typedef enum { /* 0x00 */ EFFECT_SS_DUST, /* 0x01 */ EFFECT_SS_KIRAKIRA, - /* 0x02 */ EFFECT_SS_UNSET_02, + /* 0x02 */ EFFECT_SS_UNSET_02, // Deleted /* 0x03 */ EFFECT_SS_BOMB2, /* 0x04 */ EFFECT_SS_BLAST, /* 0x05 */ EFFECT_SS_G_SPK, /* 0x06 */ EFFECT_SS_D_FIRE, /* 0x07 */ EFFECT_SS_BUBBLE, - /* 0x08 */ EFFECT_SS_UNSET_08, + /* 0x08 */ EFFECT_SS_UNSET_08, // Deleted /* 0x09 */ EFFECT_SS_G_RIPPLE, /* 0x0A */ EFFECT_SS_G_SPLASH, /* 0x0B */ EFFECT_SS_UNSET_0B, @@ -293,8 +314,8 @@ typedef enum { /* 0x0F */ EFFECT_SS_HAHEN, /* 0x10 */ EFFECT_SS_STICK, /* 0x11 */ EFFECT_SS_SIBUKI, - /* 0x12 */ EFFECT_SS_UNSET_12, - /* 0x13 */ EFFECT_SS_UNSET_13, + /* 0x12 */ EFFECT_SS_UNSET_12, // Deleted + /* 0x13 */ EFFECT_SS_UNSET_13, // Deleted /* 0x14 */ EFFECT_SS_STONE1, /* 0x15 */ EFFECT_SS_HITMARK, /* 0x16 */ EFFECT_SS_FHG_FLASH, @@ -306,11 +327,11 @@ typedef enum { /* 0x1C */ EFFECT_SS_FIRE_TAIL, /* 0x1D */ EFFECT_SS_EN_FIRE, /* 0x1E */ EFFECT_SS_EXTRA, - /* 0x1F */ EFFECT_SS_UNSET_1F, + /* 0x1F */ EFFECT_SS_UNSET_1F, // Deleted /* 0x20 */ EFFECT_SS_DEAD_DB, /* 0x21 */ EFFECT_SS_DEAD_DD, /* 0x22 */ EFFECT_SS_DEAD_DS, - /* 0x23 */ EFFECT_SS_UNSET_23, + /* 0x23 */ EFFECT_SS_UNSET_23, // Deleted /* 0x24 */ EFFECT_SS_ICE_SMOKE, /* 0x25 */ EFFECT_EN_ICE_BLOCK, /* 0x26 */ EFFECT_SS_SBN, diff --git a/include/z64scene.h b/include/z64scene.h index 5427d473b..333569974 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -215,8 +215,8 @@ typedef struct { } SCmdMinimapChests; typedef struct { - /* 0x0 */ u32 opaqueDl; - /* 0x4 */ u32 translucentDl; + /* 0x0 */ Gfx* opaqueDl; + /* 0x4 */ Gfx* translucentDl; } RoomMeshType0Params; // size = 0x8 // Fields TODO diff --git a/spec b/spec index b121ad83c..fc4845af4 100644 --- a/spec +++ b/spec @@ -25,7 +25,6 @@ beginseg include "build/src/boot_O2_g3/CIC6105.o" include "build/src/boot_O2_g3/syncprintf.o" include "build/src/boot_O2_g3/fault.o" - include "build/data/boot/fault.data.o" include "build/data/boot/fault.bss.o" include "build/src/boot_O2_g3/fault_drawer.o" include "build/data/boot/fault_drawer.bss.o" @@ -491,7 +490,7 @@ beginseg include "build/src/code/code_800F12D0.o" include "build/src/code/z_eventmgr.o" include "build/data/code/z_eventmgr.bss.o" - include "build/src/code/code_800F23E0.o" + include "build/src/code/z_fcurve_data.o" include "build/src/code/z_fcurve_data_skelanime.o" include "build/data/code/code_801BD830.data.o" include "build/src/code/z_fireobj.o" @@ -528,7 +527,7 @@ beginseg include "build/data/code/z_parameter.data.o" include "build/data/code/z_parameter.bss.o" include "build/src/code/z_path.o" - include "build/src/code/code_80122660.o" + include "build/src/code/z_pause.o" include "build/src/code/z_player_lib.o" include "build/data/code/z_player_lib.data.o" include "build/data/code/z_player_lib.bss.o" diff --git a/src/boot_O1/viextendvstart.c b/src/boot_O1/viextendvstart.c new file mode 100644 index 000000000..ce9f718d0 --- /dev/null +++ b/src/boot_O1/viextendvstart.c @@ -0,0 +1,5 @@ +#include "global.h" + +void osViExtendVStart(u32 a0) { + __additional_scanline = a0; +} diff --git a/src/boot_O2/__osMalloc.c b/src/boot_O2/__osMalloc.c index 40572a59f..503c7c25a 100644 --- a/src/boot_O2/__osMalloc.c +++ b/src/boot_O2/__osMalloc.c @@ -45,7 +45,7 @@ ArenaNode* ArenaImpl_GetLastBlock(Arena* arena) { return last; } -void __osMallocInit(Arena* arena, void* start, u32 size) { +void __osMallocInit(Arena* arena, void* start, size_t size) { bzero(arena, sizeof(*arena)); ArenaImpl_LockInit(arena); __osMallocAddBlock(arena, start, size); @@ -91,7 +91,7 @@ u8 __osMallocIsInitalized(Arena* arena) { return arena->isInit; } -void* __osMalloc(Arena* arena, u32 size) { +void* __osMalloc(Arena* arena, size_t size) { ArenaNode* iter; ArenaNode* newNode; void* alloc; @@ -134,7 +134,7 @@ void* __osMalloc(Arena* arena, u32 size) { return alloc; } -void* __osMallocR(Arena* arena, u32 size) { +void* __osMallocR(Arena* arena, size_t size) { ArenaNode* iter; ArenaNode* newNode; u32 blockSize; @@ -219,7 +219,7 @@ end: #pragma GLOBAL_ASM("asm/non_matchings/boot/__osMalloc/__osRealloc.s") -void __osAnalyzeArena(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAlloc) { +void __osAnalyzeArena(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc) { ArenaNode* iter; ArenaImpl_Lock(arena); diff --git a/src/boot_O2/__osMemset.c b/src/boot_O2/__osMemset.c index 3a5469855..0c4172e9f 100644 --- a/src/boot_O2/__osMemset.c +++ b/src/boot_O2/__osMemset.c @@ -1,6 +1,6 @@ #include "global.h" -void* __osMemset(void* ptr, s32 val, u32 size) { +void* __osMemset(void* ptr, s32 val, size_t size) { u8* dst = ptr; register s32 rem; diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c index b9ea4533d..5c884be96 100644 --- a/src/boot_O2/loadfragment2.c +++ b/src/boot_O2/loadfragment2.c @@ -71,7 +71,7 @@ void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr) { int nbytes; u32 pad; - u32 size; + size_t size; void* end; OverlayRelocationSection* overlayInfo; @@ -106,9 +106,9 @@ s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u3 #pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_LoadOverlay.s") #endif -void* Load2_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd) { +void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd) { void* allocatedVRamAddr; - u32 size; + size_t size; size = vRamEnd - vRamStart; allocatedVRamAddr = SystemArena_MallocR(size); diff --git a/src/boot_O2/system_malloc.c b/src/boot_O2/system_malloc.c index 61906ce42..ad2bb6345 100644 --- a/src/boot_O2/system_malloc.c +++ b/src/boot_O2/system_malloc.c @@ -2,15 +2,15 @@ Arena gSystemArena; -void* SystemArena_Malloc(u32 size) { +void* SystemArena_Malloc(size_t size) { return __osMalloc(&gSystemArena, size); } -void* SystemArena_MallocR(u32 size) { +void* SystemArena_MallocR(size_t size) { return __osMallocR(&gSystemArena, size); } -void* SystemArena_Realloc(void* oldPtr, u32 newSize) { +void* SystemArena_Realloc(void* oldPtr, size_t newSize) { return __osRealloc(&gSystemArena, oldPtr, newSize); } @@ -18,9 +18,9 @@ void SystemArena_Free(void* ptr) { __osFree(&gSystemArena, ptr); } -void* SystemArena_Calloc(u32 elements, u32 size) { +void* SystemArena_Calloc(u32 elements, size_t size) { void* ptr; - u32 totalSize = elements * size; + size_t totalSize = elements * size; ptr = __osMalloc(&gSystemArena, totalSize); if (ptr != NULL) { @@ -29,7 +29,7 @@ void* SystemArena_Calloc(u32 elements, u32 size) { return ptr; } -void SystemArena_AnalyzeArena(u32* maxFreeBlock, u32* bytesFree, u32* bytesAllocated) { +void SystemArena_AnalyzeArena(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated) { __osAnalyzeArena(&gSystemArena, maxFreeBlock, bytesFree, bytesAllocated); } @@ -37,7 +37,7 @@ u32 SystemArena_CheckArena(void) { return __osCheckArena(&gSystemArena); } -void SystemArena_InitArena(void* start, u32 size) { +void SystemArena_InitArena(void* start, size_t size) { __osMallocInit(&gSystemArena, start, size); } diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index 3cc3deb35..1851d21cb 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -1,7 +1,32 @@ +#include "ultra64.h" #include "global.h" #include "vt.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/fault/D_800982B0.s") +// data +const char* sCpuExceptions[] = { + "Interrupt", + "TLB modification", + "TLB exception on load", + "TLB exception on store", + "Address error on load", + "Address error on store", + "Bus error on inst.", + "Bus error on data", + "System call exception", + "Breakpoint exception", + "Reserved instruction", + "Coprocessor unusable", + "Arithmetic overflow", + "Trap exception", + "Virtual coherency on inst.", + "Floating point exception", + "Watchpoint exception", + "Virtual coherency on data", +}; + +const char* sFpuExceptions[] = { + "Unimplemented operation", "Invalid operation", "Division by zero", "Overflow", "Underflow", "Inexact operation", +}; void Fault_SleepImpl(u32 duration) { u64 value = (duration * OS_CPU_COUNTER) / 1000ull; @@ -79,7 +104,7 @@ void Fault_RemoveClient(FaultClient* client) { } } -void Fault_AddAddrConvClient(FaultAddrConvClient* client, fault_address_converter_func callback, void* param) { +void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvFunc callback, void* param) { OSIntMask mask; u32 alreadyExists = 0; @@ -269,9 +294,9 @@ void Fault_PrintFPCR(u32 value) { u32 flag = 0x20000; FaultDrawer_Printf("FPCSR:%08xH ", value); - for (i = 0; i < ARRAY_COUNT(sExceptionNames); i++) { + for (i = 0; i < ARRAY_COUNT(sFpuExceptions); i++) { if (value & flag) { - FaultDrawer_Printf("(%s)", sExceptionNames[i]); + FaultDrawer_Printf("(%s)", sFpuExceptions[i]); break; } flag >>= 1; @@ -284,9 +309,9 @@ void osSyncPrintfFPCR(u32 value) { u32 flag = 0x20000; osSyncPrintf("FPCSR:%08xH ", value); - for (i = 0; i < ARRAY_COUNT(sExceptionNames); i++) { + for (i = 0; i < ARRAY_COUNT(sFpuExceptions); i++) { if (value & flag) { - osSyncPrintf("(%s)\n", sExceptionNames[i]); + osSyncPrintf("(%s)\n", sFpuExceptions[i]); break; } flag >>= 1; @@ -308,7 +333,7 @@ void Fault_PrintThreadContext(OSThread* t) { FaultDrawer_SetCursor(0x16, 0x14); ctx = &t->context; - FaultDrawer_Printf("THREAD:%d (%d:%s)\n", t->id, causeStrIdx, D_80096B80[causeStrIdx]); + FaultDrawer_Printf("THREAD:%d (%d:%s)\n", t->id, causeStrIdx, sCpuExceptions[causeStrIdx]); FaultDrawer_SetCharPad(-1, 0); FaultDrawer_Printf("PC:%08xH SR:%08xH VA:%08xH\n", (u32)ctx->pc, (u32)ctx->sr, (u32)ctx->badvaddr); @@ -368,7 +393,7 @@ void osSyncPrintfThreadContext(OSThread* t) { ctx = &t->context; osSyncPrintf("\n"); - osSyncPrintf("THREAD ID:%d (%d:%s)\n", t->id, causeStrIdx, D_80096B80[causeStrIdx]); + osSyncPrintf("THREAD ID:%d (%d:%s)\n", t->id, causeStrIdx, sCpuExceptions[causeStrIdx]); osSyncPrintf("PC:%08xH SR:%08xH VA:%08xH\n", (u32)ctx->pc, (u32)ctx->sr, (u32)ctx->badvaddr); osSyncPrintf("AT:%08xH V0:%08xH V1:%08xH\n", (u32)ctx->at, (u32)ctx->v0, (u32)ctx->v1); @@ -444,7 +469,7 @@ void Fault_WaitForButtonCombo(void) { } while (!CHECK_BTN_ALL(input->cur.button, BTN_DLEFT | BTN_L | BTN_R | BTN_CRIGHT)); } -void Fault_DrawMemDumpPage(char* title, u32* addr, u32 param_3) { +void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) { u32* alignedAddr; u32* writeAddr; s32 y; @@ -741,9 +766,9 @@ void Fault_SetOptionsFromController3(void) { } if (faultCustomOptions) { - graphPC = graphOSThread.context.pc; - graphRA = graphOSThread.context.ra; - graphSP = graphOSThread.context.sp; + graphPC = sGraphThread.context.pc; + graphRA = sGraphThread.context.ra; + graphSP = sGraphThread.context.sp; if (CHECK_BTN_ALL(input3->press.button, BTN_R)) { faultCopyToLog = !faultCopyToLog; FaultDrawer_SetOsSyncPrintfEnabled(faultCopyToLog); diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index 4e6518d14..949faadf1 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -1,6 +1,8 @@ #include "global.h" #include "vt.h" +extern const u32 sFaultDrawerFont[]; + FaultDrawer* sFaultDrawContext = &sFaultDrawerStruct; FaultDrawer sFaultDrawerDefault = { (u16*)0x803DA800, // fb - TODO map out buffers in this region and avoid hard-coded pointer @@ -14,7 +16,7 @@ FaultDrawer sFaultDrawerDefault = { GPACK_RGBA5551(0, 0, 0, 0), // backColor 22, // cursorX 16, // cursorY - (u32*)&sFaultDrawerFont, // font + (u32*)sFaultDrawerFont, // font 8, // charW 8, // charH 0, // charWPad @@ -142,7 +144,7 @@ void FaultDrawer_FillScreen() { #pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/FaultDrawer_FormatStringFunc.s") -#pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/D_80099080.s") +const char D_80099080[] = "(null)"; void FaultDrawer_VPrintf(const char* str, char* args) { // va_list _Printf((PrintCallback)FaultDrawer_FormatStringFunc, sFaultDrawContext, str, args); diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index bf42adf3f..094c0bb38 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -122,7 +122,7 @@ s32 Yaz0_DecompressImpl(u8* src, u8* dst) { return 0; } -void Yaz0_Decompress(u32 romStart, void* dst, u32 size) { +void Yaz0_Decompress(u32 romStart, void* dst, size_t size) { s32 status; u32 pad; char sp80[0x50]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 3a447b0e8..2903b488f 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -9,7 +9,7 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(u32 rom, void* ram, u32 size) { +s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -111,7 +111,7 @@ const char* func_800809F4(u32 a0) { void DmaMgr_ProcessMsg(DmaRequest* req) { u32 vrom; void* ram; - u32 size; + size_t size; u32 romStart; u32 romSize; DmaEntry* dmaEntry; @@ -172,7 +172,7 @@ void DmaMgr_ThreadEntry(void* a0) { } } -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, u32 size, UNK_TYPE4 unused, +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, OSMesg msg) { if (gIrqMgrResetStatus >= 2) { return -2; @@ -190,7 +190,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, u32 vromStart, return 0; } -s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, u32 size) { +s32 DmaMgr_SendRequest0(void* vramStart, u32 vromStart, size_t size) { DmaRequest req; OSMesgQueue queue; OSMesg msg[1]; diff --git a/src/code/PreRender.c b/src/code/PreRender.c index bdf4d326c..0afb1df68 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -17,7 +17,7 @@ void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void PreRender_Init(PreRender* this) { bzero(this, sizeof(PreRender)); - func_80174AA0(&this->alloc); + ListAlloc_Init(&this->alloc); } /** @@ -35,7 +35,7 @@ void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, voi } void PreRender_Destroy(PreRender* this) { - func_80174BA0(&this->alloc); + ListAlloc_FreeAll(&this->alloc); } void func_8016FDB8(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 arg4) { diff --git a/src/code/TwoHeadArena.c b/src/code/TwoHeadArena.c index b4262e3c6..83d5be3d1 100644 --- a/src/code/TwoHeadArena.c +++ b/src/code/TwoHeadArena.c @@ -12,7 +12,7 @@ void* THA_GetTail(TwoHeadArena* tha) { return tha->tail; } -void* THA_AllocStart(TwoHeadArena* tha, u32 size) { +void* THA_AllocStart(TwoHeadArena* tha, size_t size) { void* start = tha->head; tha->head = (u32)tha->head + size; @@ -23,7 +23,7 @@ void* THA_AllocStart1(TwoHeadArena* tha) { return THA_AllocStart(tha, 1); } -void* THA_AllocEnd(TwoHeadArena* tha, u32 size) { +void* THA_AllocEnd(TwoHeadArena* tha, size_t size) { u32 mask; if (size >= 0x10) { @@ -42,14 +42,14 @@ void* THA_AllocEnd(TwoHeadArena* tha, u32 size) { return tha->tail; } -void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size) { +void* THA_AllocEndAlign16(TwoHeadArena* tha, size_t size) { u32 mask = ~0xF; tha->tail = (((u32)tha->tail & mask) - size) & mask; return tha->tail; } -void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask) { +void* THA_AllocEndAlign(TwoHeadArena* tha, size_t size, u32 mask) { tha->tail = (((u32)tha->tail & mask) - size) & mask; return tha->tail; } @@ -67,7 +67,7 @@ void THA_Init(TwoHeadArena* tha) { tha->tail = (u32)tha->bufp + tha->size; } -void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) { +void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size) { bzero(tha, sizeof(TwoHeadArena)); tha->bufp = ptr; tha->size = size; diff --git a/src/code/TwoHeadGfxArena.c b/src/code/TwoHeadGfxArena.c index 81a3a383b..2f1629765 100644 --- a/src/code/TwoHeadGfxArena.c +++ b/src/code/TwoHeadGfxArena.c @@ -1,6 +1,6 @@ #include "global.h" -void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size) { +void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size) { THA_Ct((TwoHeadArena*)thga, start, size); } @@ -44,7 +44,7 @@ Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) { return THGA_AllocStart8(thga); } -Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) { +Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, size_t size) { return THA_AllocEnd((TwoHeadArena*)thga, size); } diff --git a/src/code/code_800F23E0.c b/src/code/code_800F23E0.c deleted file mode 100644 index 008a95db3..000000000 --- a/src/code/code_800F23E0.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F23E0/func_800F23E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F23E0/func_800F2478.s") diff --git a/src/code/code_80122660.c b/src/code/code_80122660.c deleted file mode 100644 index 7c0da2932..000000000 --- a/src/code/code_80122660.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80122660/func_80122660.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80122660/func_80122670.s") diff --git a/src/code/game.c b/src/code/game.c index eb26dee8a..a90fc7ac2 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -22,7 +22,7 @@ void Game_SetFramerateDivisor(GameState* gameState, s32 divisor) { } void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { - Gfx* _gfx = *gfx; + Gfx* dlist = *gfx; if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) { D_801F8010.type = R_FB_FILTER_TYPE; @@ -30,7 +30,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1); D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2); D_801F8010.color.a = R_FB_FILTER_A; - func_80140D10(&D_801F8010, &_gfx, arg1); + func_80140D10(&D_801F8010, &dlist, arg1); } else { if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { D_801F8020.useRgba = (R_FB_FILTER_TYPE == 6); @@ -42,7 +42,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { D_801F8020.envColor.g = R_FB_FILTER_ENV_COLOR(1); D_801F8020.envColor.b = R_FB_FILTER_ENV_COLOR(2); D_801F8020.envColor.a = R_FB_FILTER_A; - func_80142100(&D_801F8020, &_gfx, arg1); + func_80142100(&D_801F8020, &dlist, arg1); } else { if (R_FB_FILTER_TYPE == 7) { sMonoColors.unk_00 = 0; @@ -54,27 +54,24 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &_gfx, arg1); + VisMono_Draw(&sMonoColors, &dlist, arg1); } } } - *gfx = _gfx; + *gfx = dlist; } -void Game_Nop80173534(GameState* gamestate) { - ; +void Game_Nop80173534(GameState* gameState) { } -void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) { +void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { Gfx* nextDisplayList; Gfx* polyOpa; OPEN_DISPS(gfxCtx); - polyOpa = POLY_OPA_DISP; - nextDisplayList = Graph_GfxPlusOne(POLY_OPA_DISP); - + nextDisplayList = Graph_GfxPlusOne(polyOpa = POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, nextDisplayList); if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) { @@ -98,119 +95,123 @@ void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) { if (R_ENABLE_ARENA_DBG != 0) { SpeedMeter_DrawTimeEntries(&D_801F7FF0, gfxCtx); - SpeedMeter_DrawAllocEntries(&D_801F7FF0, gfxCtx, gamestate); + SpeedMeter_DrawAllocEntries(&D_801F7FF0, gfxCtx, gameState); } CLOSE_DISPS(gfxCtx); } -void Game_ResetSegments(GraphicsContext* gfxCtx) { - gSPSegment(gfxCtx->polyOpa.p++, 0, 0); - gSPSegment(gfxCtx->polyOpa.p++, 0xF, gfxCtx->framebuffer); - gSPSegment(gfxCtx->polyXlu.p++, 0, 0); - gSPSegment(gfxCtx->polyXlu.p++, 0xF, gfxCtx->framebuffer); - gSPSegment(gfxCtx->overlay.p++, 0, 0); - gSPSegment(gfxCtx->overlay.p++, 0xF, gfxCtx->framebuffer); +void GameState_SetFrameBuffer(GraphicsContext* gfxCtx) { + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0, NULL); + gSPSegment(POLY_OPA_DISP++, 0xF, gfxCtx->framebuffer); + gSPSegment(POLY_XLU_DISP++, 0, NULL); + gSPSegment(POLY_XLU_DISP++, 0xF, gfxCtx->framebuffer); + gSPSegment(OVERLAY_DISP++, 0, NULL); + gSPSegment(OVERLAY_DISP++, 0xF, gfxCtx->framebuffer); + + CLOSE_DISPS(gfxCtx); } void func_801736DC(GraphicsContext* gfxCtx) { Gfx* nextDisplayList; - Gfx* _polyOpa; + Gfx* polyOpa; - nextDisplayList = Graph_GfxPlusOne(_polyOpa = gfxCtx->polyOpa.p); - gSPDisplayList(gfxCtx->overlay.p++, nextDisplayList); + OPEN_DISPS(gfxCtx); + + nextDisplayList = Graph_GfxPlusOne(polyOpa = gfxCtx->polyOpa.p); + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); gSPEndDisplayList(nextDisplayList++); - Graph_BranchDlist(_polyOpa, nextDisplayList); + Graph_BranchDlist(polyOpa, nextDisplayList); - gfxCtx->polyOpa.p = nextDisplayList; + POLY_OPA_DISP = nextDisplayList; + + CLOSE_DISPS(gfxCtx); } -void Game_UpdateInput(GameState* gamestate) { - Padmgr_GetInput(gamestate->input, 1); +void Game_UpdateInput(GameState* gameState) { + Padmgr_GetInput(gameState->input, 1); } -void Game_Update(GameState* gamestate) { - GraphicsContext* _gCtx; - _gCtx = gamestate->gfxCtx; +void Game_Update(GameState* gameState) { + GraphicsContext* gfxCtx = gameState->gfxCtx; - Game_ResetSegments(gamestate->gfxCtx); + GameState_SetFrameBuffer(gameState->gfxCtx); - gamestate->main(gamestate); + gameState->main(gameState); if (R_PAUSE_MENU_MODE != 2) { - GameState_Draw(gamestate, _gCtx); - func_801736DC(_gCtx); + GameState_Draw(gameState, gfxCtx); + func_801736DC(gfxCtx); } } -void Game_IncrementFrameCount(GameState* gamestate) { - Game_Nop80173534(gamestate); - gamestate->frames++; +void Game_IncrementFrameCount(GameState* gameState) { + Game_Nop80173534(gameState); + gameState->frames++; } -void Game_InitHeap(GameState* gamestate, u32 size) { - GameState* _ctx; - void* buf; - - _ctx = gamestate; - buf = Gamealloc_Alloc(&_ctx->alloc, size); +void GameState_InitArena(GameState* gameState, size_t size) { + GameAlloc* alloc = &gameState->alloc; + void* buf = GameAlloc_Malloc(alloc, size); if (buf) { - THA_Ct(&gamestate->heap, buf, size); + THA_Ct(&gameState->heap, buf, size); return; } - THA_Ct(&gamestate->heap, NULL, 0); - __assert("../game.c", 0x40B); + THA_Ct(&gameState->heap, NULL, 0); + __assert("../game.c", 1035); } -void Game_ResizeHeap(GameState* gamestate, u32 size) { +void GameState_Realloc(GameState* gameState, size_t size) { GameAlloc* alloc; - void* buf; - u32 systemMaxFree; - u32 bytesFree; - u32 bytesAllocated; + void* gameArena; + size_t systemMaxFree; + size_t bytesFree; + size_t bytesAllocated; void* heapStart; - heapStart = gamestate->heap.bufp; - alloc = &gamestate->alloc; - THA_Dt(&gamestate->heap); - Gamealloc_Free(alloc, heapStart); + heapStart = gameState->heap.bufp; + alloc = &gameState->alloc; + THA_Dt(&gameState->heap); + GameAlloc_Free(alloc, heapStart); SystemArena_AnalyzeArena(&systemMaxFree, &bytesFree, &bytesAllocated); size = ((systemMaxFree - (sizeof(ArenaNode))) < size) ? (0) : (size); - if (!size) { + if (size == 0) { size = systemMaxFree - (sizeof(ArenaNode)); } - if ((buf = Gamealloc_Alloc(alloc, size)) != NULL) { - THA_Ct(&gamestate->heap, buf, size); + if ((gameArena = GameAlloc_Malloc(alloc, size)) != NULL) { + THA_Ct(&gameState->heap, gameArena, size); } else { - THA_Ct(&gamestate->heap, 0, 0); - __assert("../game.c", 0x432); + THA_Ct(&gameState->heap, 0, 0); + __assert("../game.c", 1074); } } -void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsContext* gfxCtx) { - gamestate->gfxCtx = gfxCtx; - gamestate->frames = 0U; - gamestate->main = NULL; - gamestate->destroy = NULL; - gamestate->running = 1; - gfxCtx->unk274 = D_801FBB88; +void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) { + gameState->gfxCtx = gfxCtx; + gameState->frames = 0U; + gameState->main = NULL; + gameState->destroy = NULL; + gameState->running = 1; + gfxCtx->viMode = D_801FBB88; gfxCtx->viConfigFeatures = gViConfigFeatures; gfxCtx->viConfigXScale = gViConfigXScale; gfxCtx->viConfigYScale = gViConfigYScale; - gamestate->nextGameStateInit = NULL; - gamestate->nextGameStateSize = 0U; + gameState->nextGameStateInit = NULL; + gameState->nextGameStateSize = 0U; { s32 requiredScopeTemp; - Gamealloc_Init(&gamestate->alloc); - Game_InitHeap(gamestate, 0x100000); - Game_SetFramerateDivisor(gamestate, 3); + GameAlloc_Init(&gameState->alloc); + GameState_InitArena(gameState, 0x100000); + Game_SetFramerateDivisor(gameState, 3); - gameStateInit(gamestate); + init(gameState); func_80140CE0(&D_801F8010); func_801420C0(&D_801F8020); @@ -219,17 +220,17 @@ void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsC func_801773A0(&D_801F7FF0); func_8013ED9C(); - osSendMesg(&gamestate->gfxCtx->unk5C, NULL, 1); + osSendMesg(&gameState->gfxCtx->unk5C, NULL, 1); } } -void Game_StateFini(GameState* gamestate) { +void GameState_Destroy(GameState* gameState) { func_80172BC0(); func_8019E014(); - osRecvMesg(&gamestate->gfxCtx->unk5C, 0, 1); + osRecvMesg(&gameState->gfxCtx->unk5C, NULL, OS_MESG_BLOCK); - if (gamestate->destroy != 0) { - gamestate->destroy(gamestate); + if (gameState->destroy != NULL) { + gameState->destroy(gameState); } func_8013EDD0(); @@ -238,28 +239,28 @@ void Game_StateFini(GameState* gamestate) { func_801420F4(&D_801F8020); func_80141900(&sMonoColors); func_80140900(&D_801F8048); - THA_Dt(&gamestate->heap); - Gamealloc_FreeAll(&gamestate->alloc); + THA_Dt(&gameState->heap); + GameAlloc_Cleanup(&gameState->alloc); } -GameStateFunc Game_GetNextStateInit(GameState* gamestate) { - return gamestate->nextGameStateInit; +GameStateFunc GameState_GetNextStateInit(GameState* gameState) { + return gameState->nextGameStateInit; } -u32 Game_GetNextStateSize(GameState* gamestate) { - return gamestate->nextGameStateSize; +size_t Game_GetNextStateSize(GameState* gameState) { + return gameState->nextGameStateSize; } -u32 Game_GetShouldContinue(GameState* gamestate) { - return gamestate->running; +u32 GameState_IsRunning(GameState* gameState) { + return gameState->running; } -s32 Game_GetHeapFreeSize(GameState* gamestate) { - return THA_GetSize(&gamestate->heap); +s32 GameState_GetArenaSize(GameState* gameState) { + return THA_GetSize(&gameState->heap); } -s32 func_80173B48(GameState* gamestate) { - s32 result; - result = OS_CYCLES_TO_NSEC(gamestate->framerateDivisor * sIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(D_801FBAF0); +s32 func_80173B48(GameState* gameState) { + s32 result = OS_CYCLES_TO_NSEC(gameState->framerateDivisor * sIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(D_801FBAF0); + return result; } diff --git a/src/code/gamealloc.c b/src/code/gamealloc.c index 34d595f79..541f9125b 100644 --- a/src/code/gamealloc.c +++ b/src/code/gamealloc.c @@ -1,11 +1,59 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/func_80173BF0.s") +void GameAlloc_Log(GameAlloc* this) { + GameAllocEntry* iter; -#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Alloc.s") + iter = this->base.next; + while (iter != &this->base) { + iter = iter->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Free.s") +void* GameAlloc_Malloc(GameAlloc* this, size_t size) { + GameAllocEntry* ptr = SystemArena_Malloc(size + sizeof(GameAllocEntry)); -#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_FreeAll.s") + if (ptr != NULL) { + ptr->size = size; + ptr->prev = this->head; + this->head->next = ptr; + this->head = ptr; + ptr->next = &this->base; + this->base.prev = this->head; + return ptr + 1; + } else { + return NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Init.s") +void GameAlloc_Free(GameAlloc* this, void* data) { + GameAllocEntry* ptr; + + if (data != NULL) { + ptr = &((GameAllocEntry*)data)[-1]; + ptr->prev->next = ptr->next; + ptr->next->prev = ptr->prev; + this->head = this->base.prev; + SystemArena_Free(ptr); + } +} + +void GameAlloc_Cleanup(GameAlloc* this) { + GameAllocEntry* next = this->base.next; + GameAllocEntry* cur; + + while (&this->base != next) { + cur = next; + next = next->next; + SystemArena_Free(cur); + } + + this->head = &this->base; + this->base.next = &this->base; + this->base.prev = &this->base; +} + +void GameAlloc_Init(GameAlloc* this) { + this->head = &this->base; + this->base.next = &this->base; + this->base.prev = &this->base; +} diff --git a/src/code/listalloc.c b/src/code/listalloc.c index 3880806a1..da294a109 100644 --- a/src/code/listalloc.c +++ b/src/code/listalloc.c @@ -1,9 +1,62 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174AA0.s") +ListAlloc* ListAlloc_Init(ListAlloc* this) { + this->prev = NULL; + this->next = NULL; + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174AB4.s") +void* ListAlloc_Alloc(ListAlloc* this, size_t size) { + ListAlloc* ptr = SystemArena_Malloc(size + sizeof(ListAlloc)); + ListAlloc* next; -#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174B20.s") + if (ptr == NULL) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174BA0.s") + next = this->next; + if (next != NULL) { + next->next = ptr; + } + + ptr->prev = next; + ptr->next = NULL; + this->next = ptr; + + if (this->prev == NULL) { + this->prev = ptr; + } + + return (u8*)ptr + sizeof(ListAlloc); +} + +void ListAlloc_Free(ListAlloc* this, void* data) { + ListAlloc* ptr = &((ListAlloc*)data)[-1]; + + if (ptr->prev != NULL) { + ptr->prev->next = ptr->next; + } + + if (ptr->next != NULL) { + ptr->next->prev = ptr->prev; + } + + if (this->prev == ptr) { + this->prev = ptr->next; + } + + if (this->next == ptr) { + this->next = ptr->prev; + } + + SystemArena_Free(ptr); +} + +void ListAlloc_FreeAll(ListAlloc* this) { + ListAlloc* iter = this->prev; + + while (iter != NULL) { + ListAlloc_Free(this, (u8*)iter + sizeof(ListAlloc)); + iter = this->prev; + } +} diff --git a/src/code/main.c b/src/code/main.c index a2b859991..59ffb6a32 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -28,36 +28,36 @@ void Main(void* arg) { R_ENABLE_ARENA_DBG = 0; - osCreateMesgQueue(&siEventCallbackQueue, siEventCallbackBuffer, ARRAY_COUNT(siEventCallbackBuffer)); - osSetEventMesg(OS_EVENT_SI, &siEventCallbackQueue, NULL); + osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, ARRAY_COUNT(sSiIntMsgBuf)); + osSetEventMesg(OS_EVENT_SI, &sSiIntMsgQ, NULL); - osCreateMesgQueue(&mainIrqmgrCallbackQueue, mainIrqCallbackBuffer, ARRAY_COUNT(mainIrqCallbackBuffer)); + osCreateMesgQueue(&irqMgrMsgQ, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf)); StackCheck_Init(&schedStackEntry, schedStack, schedStack + sizeof(schedStack), 0, 0x100, "sched"); Sched_Init(&gSchedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); CIC6105_AddRomInfoFaultPage(); - IrqMgr_AddClient(&gIrqMgr, &mainIrqmgrCallbackNode, &mainIrqmgrCallbackQueue); + IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQ); StackCheck_Init(&audioStackEntry, audioStack, audioStack + sizeof(audioStack), 0, 0x100, "audio"); AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr); StackCheck_Init(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr"); - Padmgr_Start(&siEventCallbackQueue, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack)); + PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack)); AudioMgr_Unlock(&audioContext); - StackCheck_Init(&graphStackEntry, graphStack, graphStack + sizeof(graphStack), 0, 0x100, "graph"); - osCreateThread(&graphOSThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, graphStack + sizeof(graphStack), + StackCheck_Init(&sGraphStackInfo, sGraphStack, sGraphStack + sizeof(sGraphStack), 0, 0x100, "graph"); + osCreateThread(&sGraphThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, sGraphStack + sizeof(sGraphStack), Z_PRIORITY_GRAPH); - osStartThread(&graphOSThread); + osStartThread(&sGraphThread); exit = false; while (!exit) { msg = NULL; - osRecvMesg(&mainIrqmgrCallbackQueue, (OSMesg)&msg, OS_MESG_BLOCK); + osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK); if (msg == NULL) { break; } @@ -72,6 +72,6 @@ void Main(void* arg) { } } - IrqMgr_RemoveClient(&gIrqMgr, &mainIrqmgrCallbackNode); - osDestroyThread(&graphOSThread); + IrqMgr_RemoveClient(&gIrqMgr, &irqClient); + osDestroyThread(&sGraphThread); } diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 65b9d0ff4..a8ef1db15 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -54,4 +54,4 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_ThreadEntry.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Start.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_Init.s") diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index cab2e563a..a4d5b9379 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -1,92 +1,92 @@ #include "global.h" -void SysMatrix_StateAlloc(GameState* gamestate) { - sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gamestate->heap, 0x500); +void Matrix_StateAlloc(GameState* gameState) { + sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gameState->heap, 0x500); sCurrentMatrix = sMatrixStack; } -void SysMatrix_StatePush(void) { +void Matrix_StatePush(void) { MtxF* prev = sCurrentMatrix; sCurrentMatrix++; Matrix_MtxFCopy(sCurrentMatrix, prev); } -void SysMatrix_StatePop(void) { +void Matrix_StatePop(void) { sCurrentMatrix--; } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_CopyCurrentState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetCurrentState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetCurrentState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertMatrix.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertTranslation.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Scale.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_s.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_f.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_RotateStateAroundXAxis.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetStateXRotation.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateY.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertYRotation_f.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_s.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_f.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotation.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_RotateAndTranslateState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_JointPosition.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetStateRotationAndTranslation.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_ToRSPMatrix.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateAsRSPMatrix.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_AppendToPolyOpaDisp.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslation.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledX.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledY.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledZ.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fXZByCurrentState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_FromRSPMatrix.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByMatrix.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_TransposeXYZ.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_NormalizeXYZ.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_8018219C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_801822C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_f.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_s.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182C90.s") diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 1ae43c91d..688a5af15 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,5 +1,5 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/DLF_LoadGameState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/DLF_FreeGameState.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 2f1277057..8d87e539b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -53,7 +53,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); - SysMatrix_SetCurrentState(&mtx); + Matrix_SetCurrentState(&mtx); if (dlist != D_04076BC0) { Matrix_RotateY((f32)actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY); @@ -117,7 +117,7 @@ void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, sp58 = Math_FAtan2F(light->l.dir[0], light->l.dir[2]); arg6 *= (4.5f - (light->l.dir[1] * 0.035f)); arg6 = (arg6 < 1.0f) ? 1.0f : arg6; - SysMatrix_SetCurrentState(arg2); + Matrix_SetCurrentState(arg2); Matrix_RotateY(sp58, MTXMODE_APPLY); Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY); @@ -744,7 +744,7 @@ void Actor_FreeOverlay(ActorOverlay* entry) { if ((entry->allocType & 1) != 0) { entry->loadedRamAddr = NULL; } else { - zelda_free(ramAddr); + ZeldaArena_Free(ramAddr); entry->loadedRamAddr = NULL; } } diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 4165e4c9b..f33fcd538 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -736,7 +736,7 @@ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { s32 i; u8* ramStart; u8* ramEnd; - u32 size; + size_t size; u32 offset; for (i = 0; i < gMaxActorId; i++, overlayEntry++) { diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 6ea0b2fcf..059fbce09 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -327,7 +327,7 @@ s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { collider->count = 0; if (collider->elements != NULL) { - zelda_free(collider->elements); + ZeldaArena_Free(collider->elements); } collider->elements = NULL; return 1; @@ -359,7 +359,7 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider Collider_SetBaseToActor(globalCtx, &collider->base, &src->base); collider->count = src->count; - collider->elements = zelda_malloc(src->count * sizeof(ColliderJntSphElement)); + collider->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement)); if (collider->elements == NULL) { collider->count = 0; @@ -385,7 +385,7 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher Collider_SetBaseType1(globalCtx, &sphereGroup->base, actor, &src->base); sphereGroup->count = src->count; - sphereGroup->elements = zelda_malloc(src->count * sizeof(ColliderJntSphElement)); + sphereGroup->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement)); if (sphereGroup->elements == NULL) { sphereGroup->count = 0; @@ -681,7 +681,7 @@ s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) { tris->count = 0; if (tris->elements != NULL) { - zelda_free(tris->elements); + ZeldaArena_Free(tris->elements); } tris->elements = NULL; @@ -714,7 +714,7 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act Collider_SetBaseType1(globalCtx, &tris->base, actor, &src->base); tris->count = src->count; - tris->elements = zelda_malloc(tris->count * sizeof(ColliderTrisElement)); + tris->elements = ZeldaArena_Malloc(tris->count * sizeof(ColliderTrisElement)); if (tris->elements == NULL) { tris->count = 0; @@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) { D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x; D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y; D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z; - SysMatrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0); + Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0); collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x; collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y; collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z; @@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { D_801EE1E0.x = collider->dim.modelSphere.center.x; D_801EE1E0.y = collider->dim.modelSphere.center.y; D_801EE1E0.z = collider->dim.modelSphere.center.z; - SysMatrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0); + Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0); collider->dim.worldSphere.center.x = D_801EE1F0.x; collider->dim.worldSphere.center.y = D_801EE1F0.y; collider->dim.worldSphere.center.z = D_801EE1F0.z; diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index ba2c79f71..d246aaffa 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -106,8 +106,8 @@ void EffFootmark_Draw(GlobalContext* globalCtx) { for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { - SysMatrix_SetCurrentState(&footmark->displayMatrix); - Matrix_Scale(footmark->size * 0.00390625f * 0.7f, 1, footmark->size * 0.00390625f, 1); + Matrix_SetCurrentState(&footmark->displayMatrix); + Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 0ed19c050..47c2202f1 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -41,7 +41,7 @@ void EffectSS_Clear(GlobalContext* globalCtx) { for (i = 0; i < EFFECT_SS_MAX; i++) { addr = overlay->loadedRamAddr; if (addr != NULL) { - zelda_free(addr); + ZeldaArena_Free(addr); } overlay->loadedRamAddr = 0; @@ -175,7 +175,7 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init initInfo = entry->initInfo; } else { if (entry->loadedRamAddr == NULL) { - entry->loadedRamAddr = zelda_mallocR(overlaySize); + entry->loadedRamAddr = ZeldaArena_MallocR(overlaySize); if (entry->loadedRamAddr == NULL) { return; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index aa461153c..cf27d2251 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -403,7 +403,7 @@ void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, // EffectSsDFire Spawn Functions void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 alpha, s16 fadeDelay, s16 life, s32 arg9) { + s16 alpha, s16 fadeDelay, s16 arg8, s32 life) { EffectSsDFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -413,8 +413,8 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scaleStep = scaleStep; initParams.alpha = alpha; initParams.fadeDelay = fadeDelay; + initParams.unk_2C = arg8; initParams.life = life; - initParams.unk_30 = arg9; EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams); } @@ -535,8 +535,8 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec /** * Spawn a single fragment * - * Notes: - * - if a display list is not provided, D_0400C0D0 (wilted deku fragment) will be used as default + * * Notes: + * - if a display list is not provided, an unknown default will be used as default * - the unused arg does not do anything, any value can be passed here * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames @@ -960,6 +960,7 @@ void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, } // EffectSsDeadDb Spawn Functions + void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) { EffectSsDeadDbInitParams initParams; diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index fbd323885..d5125d249 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -1,48 +1,57 @@ #include "global.h" -void EnAObj_Init(ActorEnAObj* this, GlobalContext* globalCtx) { - ActorEnAObj* s0 = (ActorEnAObj*)this; - s0->base.textId = ((s0->base.params >> 8) & 0xFF) | 0x300; - s0->base.params = (s0->base.params & 0xFF) - 9; - Actor_ProcessInitChain((Actor*)s0, &enAObjInitVar); - ActorShape_Init(&s0->base.shape, 0, (ActorShadowFunc)func_800B3FC0, 12); - Collider_InitAndSetCylinder(globalCtx, &s0->collision, (Actor*)s0, &enAObjCylinderInit); - Collider_UpdateCylinder((Actor*)s0, &s0->collision); - s0->base.colChkInfo.mass = 255; - s0->update = (ActorFunc)EnAObj_Update1; +#define THIS ((EnAObj*)thisx) + +void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx); +void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx); + +void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAObj* this = THIS; + + this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300; + this->actor.params = (this->actor.params & 0xFF) - 9; + Actor_ProcessInitChain(&this->actor, &enAObjInitVar); + ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 12); + Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collision); + this->actor.colChkInfo.mass = 255; + this->actionFunc = EnAObj_Update1; } -void EnAObj_Destroy(ActorEnAObj* this, GlobalContext* globalCtx) { - ColliderCylinder* a2 = &this->collision; - Collider_DestroyCylinder(globalCtx, a2); +void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAObj* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collision); } -void EnAObj_Update1(ActorEnAObj* this, GlobalContext* globalCtx) { - s16 v0; - s32 v1; - if (func_800B84D0((Actor*)this, globalCtx) != 0) { - this->update = (ActorFunc)EnAObj_Update2; +void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { + s32 yawDiff; + + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = EnAObj_Update2; } else { - v0 = this->base.yawTowardsPlayer - this->base.shape.rot.y; - v1 = (v0 < 0) ? -v0 : v0; - if ((v1 < 10240) || ((this->base.params == 1) && (v1 > 22528))) { - func_800B863C((Actor*)this, globalCtx); + yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); + + if ((yawDiff < 0x2800) || ((this->actor.params == 1) && (yawDiff > 0x5800))) { + func_800B863C(&this->actor, globalCtx); } } } -void EnAObj_Update2(ActorEnAObj* this, GlobalContext* globalCtx) { - if (func_800B867C((Actor*)this, globalCtx) != 0) { - this->update = (ActorFunc)EnAObj_Update1; +void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) { + if (func_800B867C(&this->actor, globalCtx)) { + this->actionFunc = EnAObj_Update1; } } -void EnAObj_Update(ActorEnAObj* this, GlobalContext* globalCtx) { - (this->update)((Actor*)this, (GlobalContext*)globalCtx); - Actor_SetHeight((Actor*)this, 45.0f); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, (Collider*)&this->collision); +void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAObj* this = THIS; + + this->actionFunc(this, globalCtx); + Actor_SetHeight(&this->actor, 45.0f); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base); } -void EnAObj_Draw(ActorEnAObj* this, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, enAObjDisplayLists[this->base.params]); +void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { + func_800BDFC0(globalCtx, enAObjDisplayLists[thisx->params]); } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 0a412c2da..acae2e0ce 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -660,7 +660,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->unk152 = -2; } } else { - Matrix_Scale(16.0f, 16.0f, 16.0f, 1); + Matrix_Scale(16.0f, 16.0f, 16.0f, MTXMODE_APPLY); GetItem_Draw(globalCtx, 8); } break; @@ -785,7 +785,7 @@ void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Scale(20.0f, 20.0f, 20.0f, 1); + Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); diff --git a/src/code/z_fcurve_data.c b/src/code/z_fcurve_data.c new file mode 100644 index 000000000..a0bf887e1 --- /dev/null +++ b/src/code/z_fcurve_data.c @@ -0,0 +1,5 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F23E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F2478.s") diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index 79439550d..c6ee50d87 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,15 +1,181 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2620.s") +void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { + skelCurve->limbCount = 0; + skelCurve->limbList = NULL; + skelCurve->transUpdIdx = NULL; + skelCurve->animCurFrame = 0.0f; + skelCurve->animSpeed = 0.0f; + skelCurve->animFinalFrame = 0.0f; + skelCurve->unk0C = 0.0f; + skelCurve->transforms = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2650.s") +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, + TransformUpdateIndex* transUpdIdx) { + SkelCurveLimb** limbs; + SkelCurveLimbList* limbList = (SkelCurveLimbList*)Lib_SegmentedToVirtual(limbListSeg); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F26C0.s") + skelCurve->limbCount = limbList->limbCount; + skelCurve->limbList = (SkelCurveLimb**)Lib_SegmentedToVirtual(limbList->limbs); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F26F0.s") + skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2728.s") + do { + skelCurve->animCurFrame = 0.0f; + } while (0); + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F29A0.s") +void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { + if (skelCurve->transforms != NULL) { + ZeldaArena_Free(skelCurve->transforms); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2CD8.s") +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, + f32 animCurFrame, f32 animSpeed) { + skelCurve->unk0C = arg2 - skelCurve->animSpeed; + skelCurve->animFinalFrame = animFinalFrame; + skelCurve->animCurFrame = animCurFrame; + skelCurve->animSpeed = animSpeed; + skelCurve->transUpdIdx = transUpdIdx; +} + +#ifdef NON_MATCHING +/* Should be functionally equivalent, also migrating rodata makes it a lot cleaner */ +s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { + s16* transforms; + u8* transformRefIdx; + TransformUpdateIndex* transformIndex; + u16* transformCopyValues; + s32 i; + s32 ret = 0; + s32 k; + TransformData* transData; + f32 transformValue; + s32 j; + + transformIndex = Lib_SegmentedToVirtual(skelCurve->transUpdIdx); + transformRefIdx = Lib_SegmentedToVirtual(transformIndex->refIndex); + transData = Lib_SegmentedToVirtual(transformIndex->transformData); + transformCopyValues = Lib_SegmentedToVirtual(transformIndex->copyValues); + transforms = (s16*)skelCurve->transforms; + + skelCurve->animCurFrame += skelCurve->animSpeed * (globalCtx->state.framerateDivisor * 0.5f); + + if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) || + (skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) { + skelCurve->animCurFrame = skelCurve->animFinalFrame; + ret = 1; + } + + for (i = 0; i < skelCurve->limbCount; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++, transformRefIdx++, transforms++) { + if (*transformRefIdx == 0) { + transformValue = *transformCopyValues; + *transforms = transformValue; + transformCopyValues++; + } else { + transformValue = func_800F2478(skelCurve->animCurFrame, transData, *transformRefIdx); + transData += *transformRefIdx; + if (j == 0) { + *transforms = transformValue * 1024.0f; + } else if (j == 1) { + *transforms = transformValue * (32768.0f / 180.0f); + } else { + *transforms = transformValue * 100.0f; + } + } + } + } + } + + return ret; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/SkelCurve_Update.s") +#endif + +void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { + SkelCurveLimb* limb = (SkelCurveLimb*)Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + if (overrideLimbDraw == NULL || + (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { + Vec3f scale; + Vec3s rot; + Vec3f pos; + Gfx* dList; + Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex]; + + scale.x = transform->x / 1024.0f; + scale.y = transform->y / 1024.0f; + scale.z = transform->z / 1024.0f; + transform++; + rot.x = transform->x; + rot.y = transform->y; + rot.z = transform->z; + transform++; + pos.x = transform->x; + pos.y = transform->y; + pos.z = transform->z; + + Matrix_JointPosition(&pos, &rot); + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + + if (lod == 0) { + s32 pad1; + + dList = limb->dList[0]; + if (dList != NULL) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, dList); + } + } else if (lod == 1) { + s32 pad2; + + dList = limb->dList[0]; + if (dList != NULL) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, dList); + } + dList = limb->dList[1]; + if (dList != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, dList); + } + } + } + + if (postLimbDraw != NULL) { + postLimbDraw(globalCtx, skelCurve, limbIndex, thisx); + } + + if (limb->firstChildIdx != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + } + + Matrix_StatePop(); + + if (limb->nextLimbIdx != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, + OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { + if (skelCurve->transforms != NULL) { + SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + } +} diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 3e2e041b3..80d3f7131 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -432,7 +432,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - SysMatrix_InsertTranslation(params->x, params->y, params->z, 0); + Matrix_InsertTranslation(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/code/z_malloc.c b/src/code/z_malloc.c index f99519e9b..8d0bba44a 100644 --- a/src/code/z_malloc.c +++ b/src/code/z_malloc.c @@ -1,21 +1,54 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_malloc.s") +void* ZeldaArena_Malloc(size_t size) { + void* ptr = __osMalloc(&sZeldaArena, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_mallocR.s") + return ptr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_realloc.s") +void* ZeldaArena_MallocR(size_t size) { + void* ptr = __osMallocR(&sZeldaArena, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_free.s") + return ptr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_calloc.s") +void* ZeldaArena_Realloc(void* ptr, size_t newSize) { + ptr = __osRealloc(&sZeldaArena, ptr, newSize); + return ptr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_AnalyzeArena.s") +void ZeldaArena_Free(void* ptr) { + __osFree(&sZeldaArena, ptr); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Check.s") +void* ZeldaArena_Calloc(u32 num, size_t size) { + void* ret; + u32 n = num * size; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Init.s") + ret = __osMalloc(&sZeldaArena, n); + if (ret != NULL) { + bzero(ret, n); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Cleanup.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_IsInitialized.s") +void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc) { + __osAnalyzeArena(&sZeldaArena, outMaxFree, outFree, outAlloc); +} + +void ZeldaArena_Check() { + __osCheckArena(&sZeldaArena); +} + +void ZeldaArena_Init(void* start, size_t size) { + __osMallocInit(&sZeldaArena, start, size); +} + +void ZeldaArena_Cleanup() { + __osMallocCleanup(&sZeldaArena); +} + +u8 ZeldaArena_IsInitialized() { + return __osMallocIsInitalized(&sZeldaArena); +} diff --git a/src/code/z_pause.c b/src/code/z_pause.c new file mode 100644 index 000000000..44be6238a --- /dev/null +++ b/src/code/z_pause.c @@ -0,0 +1,5 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122660.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122670.s") diff --git a/src/code/z_room.c b/src/code/z_room.c index 5f900ea87..5163f1f29 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -77,7 +77,7 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { #ifdef NON_MATCHING s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) { - u32 size; + size_t size; // XXX: this should use a branch-likely if (roomCtx->unk31 == 0) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index e77144528..b744af5d0 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -1,7 +1,7 @@ #include "global.h" s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { - u32 size; + size_t size; objectCtx->status[objectCtx->num].id = id; size = objectFileTable[id].vromEnd - objectFileTable[id].vromStart; @@ -23,8 +23,8 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { return objectCtx->num - 1; } -void Object_InitBank(GameState* gamestate, ObjectContext* objectCtx) { - GlobalContext* globalCtx = (GlobalContext*)gamestate; +void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { + GlobalContext* globalCtx = (GlobalContext*)gameState; s32 pad; u32 spaceSize; s32 i; @@ -49,7 +49,7 @@ void Object_InitBank(GameState* gamestate, ObjectContext* objectCtx) { for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = 0; } // clang-format on - objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&gamestate->heap, spaceSize); + objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&gameState->heap, spaceSize); objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP); @@ -60,7 +60,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { s32 i; ObjectStatus* status = &objectCtx->status[0]; RomFile* objectFile; - u32 size; + size_t size; for (i = 0; i < objectCtx->num; i++) { if (status->id < 0) { @@ -354,7 +354,7 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { { SEGMENT_ROM_START(scene_texture_08), SEGMENT_ROM_END(scene_texture_08) }, }; u32 vromStart = sceneTextureFiles[fileIndex].vromStart; - u32 size = sceneTextureFiles[fileIndex].vromEnd - vromStart; + size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart; if (size != 0) { globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 16428023a..4cd9734f6 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,63 +1,57 @@ #include "global.h" -s32 func_80136288(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 func_8013631C(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 func_8013702C(SkelAnime* skelAnime); -s32 func_801370B0(SkelAnime* skelAnime); -s32 func_8013713C(SkelAnime* skelAnime); -void SkelAnime_ChangeAnimDefaultRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void func_80137748(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -void SkelAnime_ChangeLinkAnim(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed, f32 frame, f32 frameCount, - u8 animationMode, f32 transitionRate); -void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry); -void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry); -void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry); -void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry); -void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry); -void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry); +#define ANIM_INTERP 1 + +s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 SkelAnime_LoopFull(SkelAnime* skelAnime); +s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); +s32 SkelAnime_Once(SkelAnime* skelAnime); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, + f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); +void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { - (AnimationEntryCallback)SkelAnime_LinkAnimetionLoaded, (AnimationEntryCallback)SkelAnime_AnimationType1Loaded, - (AnimationEntryCallback)SkelAnime_AnimationType2Loaded, (AnimationEntryCallback)SkelAnime_AnimationType3Loaded, - (AnimationEntryCallback)SkelAnime_AnimationType4Loaded, (AnimationEntryCallback)SkelAnime_AnimationType5Loaded, + AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, + AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, }; -s32 D_801F5AB0; -s32 D_801F5AB4; +s32 sAnimQueueFlags; +s32 sDisableAnimQueueFlags; /* * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex` */ -void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s32 dListIndex) { - StandardLimb* limbEntry; +void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) { + LodLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - SysMatrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + limb = (LodLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; + rot = jointTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - dList = limbEntry->displayLists[dListIndex]; + dList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPDisplayList(&polyTemp[1], dList); + POLY_OPA_DISP = &polyTemp[2]; } } @@ -65,58 +59,58 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skele postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex); + if (limb->child != LIMB_DONE) { + SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex); + if (limb->sibling != LIMB_DONE) { + SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + lod); } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex` +/** + * Draw all limbs of type `LodLimb` in a given skeleton + * Near or far display list is specified via `lod` */ -void SkelAnime_LodDraw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s32 dListIndex) { - StandardLimb* limbEntry; +void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) { + LodLimb* rootLimb; s32 pad; Gfx* dList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx; - s32 pad2; if (skeleton == NULL) { return; } - gfxCtx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; + rootLimb = (LodLimb*)Lib_SegmentedToVirtual(skeleton[0]); + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; - rot = limbDrawTable[1]; - dList = limbEntry->displayLists[dListIndex]; + rot = jointTable[1]; + dList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList); + gSPDisplayList(&polyTemp[1], dList); - gfxCtx->polyOpa.p = polyTemp + 2; + POLY_OPA_DISP = &polyTemp[2]; } } @@ -124,167 +118,169 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDra postLimbDraw(globalCtx, 1, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex); + if (rootLimb->child != LIMB_DONE) { + SkelAnime_DrawLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + lod); } - SysMatrix_StatePop(); + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex`, Limb matrices come - * from a dynamic allocation from the graph arena. +/** + * Draw a limb of type `LodLimb` contained within a flexible skeleton + * Near or far display list is specified via `lod` */ -void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDrawSV overrideLimbDraw, PostLimbDrawSV postLimbDraw, Actor* actor, - s32 dListIndex, RSPMatrix** mtx) { - StandardLimb* limbEntry; - Gfx* dList[2]; +void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, + s32 lod, Mtx** mtx) { + LodLimb* limb; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - SysMatrix_StatePush(); + OPEN_DISPS(globalCtx->state.gfxCtx); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + Matrix_StatePush(); + + limb = (LodLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; + rot = jointTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; - // Double assignment here would not work. - dList[0] = limbEntry->displayLists[dListIndex]; - dList[1] = dList[0]; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList[1] != NULL) { - SysMatrix_GetStateAsRSPMatrix(*mtx); - gSPMatrix(gfxCtx->polyOpa.p++, *mtx, G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); + newDList = limbDList = limb->dLists[lod]; + + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + Matrix_ToMtx(*mtx); + gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, newDList); (*mtx)++; - } else if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(*mtx); + } else if (limbDList != NULL) { + Matrix_ToMtx(*mtx); (*mtx)++; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList[1], &dList[0], &rot, actor); + postLimbDraw(globalCtx, limbIndex, &newDList, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex, mtx); + if (limb->child != LIMB_DONE) { + SkelAnime_DrawFlexLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + lod, mtx); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex, mtx); + if (limb->sibling != LIMB_DONE) { + SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + lod, mtx); } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex` - * Matricies for the limbs are dynamically allocted from the graph arena. The dynamic allocation occurs - * because the Skeleton is too large to be supported by the normal matrix stack. +/** + * Draws all limbs of type `LodLimb` in a given flexible skeleton + * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. + * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -void SkelAnime_LodDrawSV(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, - OverrideLimbDrawSV overrideLimbDraw, PostLimbDrawSV postLimbDraw, Actor* actor, - s32 dListIndex) { - StandardLimb* limbEntry; +void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, + s32 lod) { + LodLimb* rootLimb; s32 pad; - Gfx* dList[2]; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - RSPMatrix* mtx; - GraphicsContext* gfxCtx; - s32 pad2; - - mtx = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(RSPMatrix) * dListCount)); + Mtx* mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); if (skeleton == NULL) { return; } - gfxCtx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); - SysMatrix_StatePush(); + gSPSegment(POLY_OPA_DISP++, 0xD, mtx); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; + rootLimb = (LodLimb*)Lib_SegmentedToVirtual(skeleton[0]); + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; - rot = limbDrawTable[1]; + rot = jointTable[1]; - dList[0] = limbEntry->displayLists[dListIndex]; - dList[1] = dList[0]; + newDList = limbDList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList[1] != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, SysMatrix_GetStateAsRSPMatrix(mtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList[1]); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPMatrix(&polyTemp[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], newDList); + POLY_OPA_DISP = &polyTemp[2]; mtx++; - } else if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(mtx); + } else if (limbDList != NULL) { + Matrix_ToMtx(mtx); mtx++; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList[1], &dList[0], &rot, actor); + postLimbDraw(globalCtx, 1, &newDList, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, dListIndex, &mtx); + if (rootLimb->child != LIMB_DONE) { + SkelAnime_DrawFlexLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, lod, &mtx); } - SysMatrix_StatePop(); + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } /* * Draws the limb of the Skeleton `skeleton` at `limbIndex` */ -void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor) { - StandardLimb* limbEntry; +void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { + StandardLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - SysMatrix_StatePush(); + OPEN_DISPS(globalCtx->state.gfxCtx); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + Matrix_StatePush(); + + limb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; - dList = limbEntry->displayLists[0]; + rot = jointTable[limbIndex]; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; + dList = limb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], dList); + POLY_OPA_DISP = &polyTemp[2]; } } @@ -292,53 +288,54 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor); + if (limb->child != LIMB_DONE) { + SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, - actor); + if (limb->sibling != LIMB_DONE) { + SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, OverrideLimbDraw overrideLimbDraw, - PostLimbDraw postLimbDraw, Actor* actor) { +/** + * Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer + */ +void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { StandardLimb* rootLimb; s32 pad; Gfx* dList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx; - s32 pad2; if (skeleton == NULL) { return; } - gfxCtx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_StatePush(); - rootLimb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); + Matrix_StatePush(); + rootLimb = Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; - rot = limbDrawTable[1]; - dList = rootLimb->displayLists[0]; + rot = jointTable[1]; + dList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], dList); + POLY_OPA_DISP = &polyTemp[2]; } } @@ -346,318 +343,333 @@ void SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTa postLimbDraw(globalCtx, 1, &dList, &rot, actor); } - if (rootLimb->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor); + if (rootLimb->child != LIMB_DONE) { + SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - SysMatrix_StatePop(); + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, - RSPMatrix** limbMatricies) { - StandardLimb* limbEntry; - Gfx* dList[2]; +void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, + Mtx** limbMatricies) { + StandardLimb* limb; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad; - SysMatrix_StatePush(); + OPEN_DISPS(globalCtx->state.gfxCtx); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + Matrix_StatePush(); + + limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; + rot = jointTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - dList[0] = limbEntry->displayLists[0]; - dList[1] = dList[0]; + newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList[1] != NULL) { - SysMatrix_GetStateAsRSPMatrix(*limbMatricies); - gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + Matrix_ToMtx(*limbMatricies); + gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, newDList); (*limbMatricies)++; - } else if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(*limbMatricies); + } else if (limbDList != NULL) { + Matrix_ToMtx(*limbMatricies); (*limbMatricies)++; } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList[0], &rot, actor); + postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, limbMatricies); + if (limb->child != LIMB_DONE) { + SkelAnime_DrawFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + limbMatricies); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, limbMatricies); + if (limb->sibling != LIMB_DONE) { + SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + limbMatricies); } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelAnime_DrawSV(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor) { - StandardLimb* limbEntry; +/** + * Draw all limbs of type `StandardLimb` in a given flexible skeleton to the polyOpa buffer + * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. + * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. + */ +void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) { + StandardLimb* rootLimb; s32 pad; - Gfx* dList[2]; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - RSPMatrix* mtx; - GraphicsContext* gfxCtx; - s32 pad2; - - mtx = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(RSPMatrix) * dListCount)); + Mtx* mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); if (skeleton == NULL) { return; } - gfxCtx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); + gSPSegment(POLY_OPA_DISP++, 0xD, mtx); - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); + rootLimb = Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; - rot = limbDrawTable[1]; + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; + rot = jointTable[1]; - dList[0] = limbEntry->displayLists[0]; - dList[1] = dList[0]; + newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList[1] != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, SysMatrix_GetStateAsRSPMatrix(mtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList[1]); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPMatrix(&polyTemp[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], newDList); + POLY_OPA_DISP = &polyTemp[2]; mtx++; } else { - if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(mtx); + if (limbDList != NULL) { + Matrix_ToMtx(mtx); mtx++; } } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList[0], &rot, actor); + postLimbDraw(globalCtx, 1, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, &mtx); + if (rootLimb->child != LIMB_DONE) { + SkelAnime_DrawFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, &mtx); } - SysMatrix_StatePop(); + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkDraw, Actor* actor, - RSPMatrix** mtx) { - StandardLimb* limbEntry; - Gfx* dList[2]; +void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + Actor* actor, Mtx** mtx) { + StandardLimb* limb; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - s32 pad2; - SysMatrix_StatePush(); + OPEN_DISPS(globalCtx->state.gfxCtx); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + Matrix_StatePush(); + + limb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + rot = jointTable[limbIndex]; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - dList[0] = limbEntry->displayLists[0]; - dList[1] = dList[0]; + newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - SysMatrix_StatePush(); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + Matrix_StatePush(); + + //! @bug Does not check unkDraw is not NULL before calling it. unkDraw(globalCtx, limbIndex, actor); - if (dList[1] != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; + if (newDList != NULL) { + Gfx* polyTemp = POLY_OPA_DISP; - gSPMatrix(polyTemp, SysMatrix_GetStateAsRSPMatrix(*mtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList[1]); - gfxCtx->polyOpa.p = polyTemp + 2; + gSPMatrix(&polyTemp[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], newDList); + POLY_OPA_DISP = &polyTemp[2]; (*mtx)++; } else { - if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(*mtx); + if (limbDList != NULL) { + Matrix_ToMtx(*mtx); (*mtx)++; } } - SysMatrix_StatePop(); + Matrix_StatePop(); } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList[0], &rot, actor); + postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - func_80134148(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, - unkDraw, actor, mtx); + if (limb->child != LIMB_DONE) { + func_80134148(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, unkDraw, actor, + mtx); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - func_80134148(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, - unkDraw, actor, mtx); + if (limb->sibling != LIMB_DONE) { + func_80134148(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, unkDraw, actor, + mtx); } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkDraw, Actor* actor) { - StandardLimb* limbEntry; +void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + Actor* actor) { + StandardLimb* rootLimb; s32 pad; - Gfx* dList[2]; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - RSPMatrix* mtx; - GraphicsContext* gfxCtx; - s32 pad2; + Mtx* mtx; if (skeleton == NULL) { return; } - gfxCtx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - mtx = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(RSPMatrix) * dListCount)); + mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); - gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); + gSPSegment(POLY_OPA_DISP++, 0xD, mtx); - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); + rootLimb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; - rot = limbDrawTable[1]; + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; + rot = jointTable[1]; - dList[0] = limbEntry->displayLists[0]; - dList[1] = dList[0]; + newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - SysMatrix_StatePush(); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { + Matrix_JointPosition(&pos, &rot); + Matrix_StatePush(); + + //! @bug Does not check unkDraw is not NULL before calling it. unkDraw(globalCtx, 1, actor); - if (dList[1] != NULL) { - Gfx* polyTemp = gfxCtx->polyOpa.p; - gSPMatrix(polyTemp, SysMatrix_GetStateAsRSPMatrix(mtx), G_MTX_LOAD); - gSPDisplayList(polyTemp + 1, dList[1]); - gfxCtx->polyOpa.p = polyTemp + 2; + if (newDList != NULL) { + Gfx* polyTemp = POLY_OPA_DISP; + + gSPMatrix(&polyTemp[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPDisplayList(&polyTemp[1], newDList); + POLY_OPA_DISP = &polyTemp[2]; mtx++; } else { - if (dList[0] != NULL) { - SysMatrix_GetStateAsRSPMatrix(mtx++); + if (limbDList != NULL) { + Matrix_ToMtx(mtx++); } } - SysMatrix_StatePop(); + Matrix_StatePop(); } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList[0], &rot, actor); + postLimbDraw(globalCtx, 1, &limbDList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - func_80134148(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, postLimbDraw, - unkDraw, actor, &mtx); + if (rootLimb->child != LIMB_DONE) { + func_80134148(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, unkDraw, actor, + &mtx); } - SysMatrix_StatePop(); + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * Copies the rotation values from the rotation value table, indexed by the rotation index table - * When a rotation index is >= the animation limit, the output rotation value is copied from the frame's - * rotation value list, otherwise it is copied from the initial rotation value list +/** + * Copies frame data from the frame data table, indexed by the joint index table. + * Indices below staticIndexMax are copied from that entry in the static frame data table. + * Indices above staticIndexMax are offsets to a frame data array indexed by the frame. */ -void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst) { - AnimationHeader* animationHeader = Lib_SegmentedToVirtual(animationSeg); - JointIndex* index = Lib_SegmentedToVirtual(animationHeader->jointIndices); - AnimationRotationValue* rotationValueTable = Lib_SegmentedToVirtual(animationHeader->frameData); - AnimationRotationValue* frameRotationValueTable = &rotationValueTable[currentFrame]; +void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable) { + AnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); + JointIndex* jointIndices = Lib_SegmentedToVirtual(animHeader->jointIndices); + s16* frameData = Lib_SegmentedToVirtual(animHeader->frameData); + s16* dynamicData = &frameData[frame]; s32 i; - u16 limit = animationHeader->staticIndexMax; + u16 staticIndexMax = animHeader->staticIndexMax; for (i = 0; i < limbCount; i++) { // Debug prints here, this is needed to prevent loop unrolling if (0) { if (0) {}; } - dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x]; - dst->y = index->y >= limit ? frameRotationValueTable[index->y] : rotationValueTable[index->y]; - dst->z = index->z >= limit ? frameRotationValueTable[index->z] : rotationValueTable[index->z]; - index++, dst++; + frameTable->x = jointIndices->x >= staticIndexMax ? dynamicData[jointIndices->x] : frameData[jointIndices->x]; + frameTable->y = jointIndices->y >= staticIndexMax ? dynamicData[jointIndices->y] : frameData[jointIndices->y]; + frameTable->z = jointIndices->z >= staticIndexMax ? dynamicData[jointIndices->z] : frameData[jointIndices->z]; + jointIndices++, frameTable++; } } -s16 SkelAnime_GetTotalFrames(AnimationHeaderCommon* animationSeg) { - AnimationHeaderCommon* animation = Lib_SegmentedToVirtual(animationSeg); - return animation->frameCount; +s16 Animation_GetLength(void* animation) { + AnimationHeaderCommon* common = Lib_SegmentedToVirtual(animation); + + return common->frameCount; } -s16 SkelAnime_GetFrameCount(AnimationHeaderCommon* animationSeg) { - AnimationHeaderCommon* animation = Lib_SegmentedToVirtual(animationSeg); +s16 Animation_GetLastFrame(void* animation) { + AnimationHeaderCommon* common = Lib_SegmentedToVirtual(animation); - return (u16)animation->frameCount - 1; + return (u16)common->frameCount - 1; } /* * Draws the Skeleton `skeleton`'s limb at index `limbIndex`. Appends all generated graphics commands to * `gfx`. Returns a pointer to the next gfx to be appended to. */ -Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx) { - StandardLimb* limbEntry; +Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { + StandardLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + limb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + rot = jointTable[limbIndex]; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - dList = limbEntry->displayLists[0]; + dList = limb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx)) { + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfx, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(gfx + 1, dList); - gfx = gfx + 2; + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&gfx[1], dList); + gfx = &gfx[2]; } } @@ -665,16 +677,16 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, void** skeleto postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, gfx); + if (limb->child != LIMB_DONE) { + gfx = SkelAnime_DrawLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + gfx); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, gfx); + if (limb->sibling != LIMB_DONE) { + gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, + gfx); } return gfx; @@ -684,9 +696,9 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, void** skeleto * Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the * next gfx to be appended to. */ -Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx) { - StandardLimb* limbEntry; +Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, + PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { + StandardLimb* rootLimb; s32 pad; Gfx* dList; Vec3f pos; @@ -696,23 +708,24 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawT return NULL; } - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); + rootLimb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; - rot = limbDrawTable[1]; + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; - dList = limbEntry->displayLists[0]; + rot = jointTable[1]; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); + dList = rootLimb->dList; + + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) { + Matrix_JointPosition(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfx, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); - gSPDisplayList(gfx + 1, dList); - gfx = gfx + 2; + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&gfx[1], dList); + gfx = &gfx[2]; } } @@ -720,202 +733,285 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawT postLimbDraw(globalCtx, 1, &dList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, gfx); + if (rootLimb->child != LIMB_DONE) { + gfx = SkelAnime_DrawLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, gfx); } - SysMatrix_StatePop(); + Matrix_StatePop(); return gfx; } -/* - * Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the - * next gfx to be appended to. Allocates matricies for display lists on the graph heap. +/** + * Draw a limb of type `StandardLimb` contained within a flexible skeleton to the specified display buffer */ -Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* limbDrawTable, - OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, - RSPMatrix** mtx, Gfx* gfx) { - StandardLimb* limbEntry; - Gfx* dList1; - Gfx* dList2; +Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, + Gfx* gfx) { + StandardLimb* limb; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + limb = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; - rot = limbDrawTable[limbIndex]; + rot = jointTable[limbIndex]; - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + pos.x = limb->jointPos.x; + pos.y = limb->jointPos.y; + pos.z = limb->jointPos.z; - dList1 = dList2 = limbEntry->displayLists[0]; + newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList1, &pos, &rot, actor, &gfx) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList1 != NULL) { - gSPMatrix(gfx, SysMatrix_GetStateAsRSPMatrix(*mtx), G_MTX_LOAD); - gSPDisplayList(gfx + 1, dList1); - gfx = gfx + 2; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); + gSPDisplayList(&gfx[1], newDList); + gfx = &gfx[2]; (*mtx)++; } else { - if (dList2 != NULL) { - SysMatrix_GetStateAsRSPMatrix(*mtx); + if (limbDList != NULL) { + Matrix_ToMtx(*mtx); (*mtx)++; } } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList2, &rot, actor, &gfx); + postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, mtx, gfx); + if (limb->child != LIMB_DONE) { + gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, mtx, gfx); } - SysMatrix_StatePop(); + Matrix_StatePop(); - if (limbEntry->nextLimbIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, mtx, gfx); + if (limb->sibling != LIMB_DONE) { + gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, mtx, gfx); } return gfx; } -Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, void** skeleton, Vec3s* limbDrawTable, s32 dListCount, - OverrideLimbDraw2 overrideLimbDraw, PostLimbDraw2 postLimbDraw, Actor* actor, Gfx* gfx) { - StandardLimb* limbEntry; +/** + * Draw all limbs of type `StandardLimb` in a given flexible skeleton to the specified display buffer + * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. + * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. + */ +Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, + OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) { + StandardLimb* rootLimb; s32 pad; - Gfx* dList1; - Gfx* dList2; + Gfx* newDList; + Gfx* limbDList; Vec3f pos; Vec3s rot; - RSPMatrix* mtx; + Mtx* mtx; if (skeleton == NULL) { return NULL; } - mtx = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(RSPMatrix) * dListCount)); + mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); gSPSegment(gfx++, 0xD, mtx); - SysMatrix_StatePush(); + Matrix_StatePush(); - limbEntry = (StandardLimb*)Lib_SegmentedToVirtual(skeleton[0]); + rootLimb = Lib_SegmentedToVirtual(skeleton[0]); - pos.x = limbDrawTable[0].x; - pos.y = limbDrawTable[0].y; - pos.z = limbDrawTable[0].z; + pos.x = jointTable[0].x; + pos.y = jointTable[0].y; + pos.z = jointTable[0].z; - rot = limbDrawTable[1]; + rot = jointTable[1]; - dList1 = dList2 = limbEntry->displayLists[0]; + newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) { - SysMatrix_RotateAndTranslateState(&pos, &rot); - if (dList1 != NULL) { - gSPMatrix(gfx, SysMatrix_GetStateAsRSPMatrix(mtx), G_MTX_LOAD); - gSPDisplayList(gfx + 1, dList1); - gfx = gfx + 2; + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) { + Matrix_JointPosition(&pos, &rot); + if (newDList != NULL) { + gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPDisplayList(&gfx[1], newDList); + gfx = &gfx[2]; mtx++; } else { - if (dList2 != NULL) { - SysMatrix_GetStateAsRSPMatrix(mtx); + if (limbDList != NULL) { + Matrix_ToMtx(mtx); mtx++; } } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList2, &rot, actor, &gfx); + postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, limbDrawTable, overrideLimbDraw, - postLimbDraw, actor, &mtx, gfx); + if (rootLimb->child != LIMB_DONE) { + gfx = SkelAnime_DrawFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + actor, &mtx, gfx); } - SysMatrix_StatePop(); + Matrix_StatePop(); return gfx; } -// Function is unused. -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_80134FFC.s") - -s16 func_801353D4(AnimationHeaderCommon* animationSeg) { - AnimationHeaderCommon* animation = Lib_SegmentedToVirtual(animationSeg); - - return animation->unk02; -} - -/* - * Appears to be unused anywhere in the game. Appears to be a clone of - * SkelAnime_GetTotalFrames +/** + * Unpacks frame data for the animation at the given frame into frameTable + * Used by the legacy animation format */ -s16 SkelAnime_GetTotalFrames2(AnimationHeaderCommon* animationSeg) { - AnimationHeaderCommon* animation = Lib_SegmentedToVirtual(animationSeg); - - return animation->frameCount; -} - -/* - * Appears to be unused anywhere in the game. Appears to be a clone of - * SkelAnime_GetFrameCount - */ -s16 SkelAnime_GetFrameCount2(AnimationHeaderCommon* animationSeg) { - AnimationHeaderCommon* animation = Lib_SegmentedToVirtual(animationSeg); - - return animation->frameCount - 1; -} - -void SkelAnime_InterpolateVec3s(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf) { +#ifdef NON_MATCHING +// equivalent, minor reordering +s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable) { + LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); + s16 limbCount = animHeader->limbCount; + JointKey* key = Lib_SegmentedToVirtual(animHeader->jointKey); + s16* frameData = Lib_SegmentedToVirtual(animHeader->frameData); + s16* staticData = &frameData[0]; + s16* dynamicData = &frameData[frame]; s32 i; - s16 dist; - s16 temp2; - if (unkf < 1.0f) { - for (i = 0; i < limbCount; i++, dst++, vec2++, vec3++) { - temp2 = vec2->x; - dist = vec3->x - temp2; - dst->x = (s16)(dist * unkf) + temp2; - temp2 = vec2->y; - dist = vec3->y - temp2; - dst->y = (s16)(dist * unkf) + temp2; - temp2 = vec2->z; - dist = vec3->z - temp2; - dst->z = (s16)(dist * unkf) + temp2; + /** + *Equivalent to the following, but the compiler optimizes the loop in a way I can't replicate + */ + /* + for(i = 0, frameTable++, key++; i < limbCount + 1; i++, key++, frameTable++) { + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; + } + */ + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; + + i = 1; + frameTable++; + key++; + + if (limbCount & 1) {} + + if (limbCount > 0) { + if (limbCount & 1) { + i++; + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; + key++; + frameTable++; + if (limbCount + 1 == i) { + goto ret; + } + } + do { + i += 2; + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; + key++; + frameTable++; + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; + key++; + frameTable++; + } while (i != limbCount + 1); + } + +ret: + return limbCount; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameData2.s") +#endif + +/** + * Used by legacy animation format + */ +s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation) { + LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); + + return animHeader->limbCount; +} + +/** + * Used by legacy animation format + */ +s16 Animation_GetLength2(LegacyAnimationHeader* animation) { + LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); + + return animHeader->frameCount; +} + +/** + * Used by legacy animation format + */ +s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation) { + AnimationHeaderCommon* animHeader = Lib_SegmentedToVirtual(animation); + + return animHeader->frameCount - 1; +} + +/** + * Linearly interpolates the start and tactoret frame tables with the given weight, putting the result in dst + */ +void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* tactoret, f32 weight) { + s32 i; + s16 diff; + s16 base; + + if (weight < 1.0f) { + for (i = 0; i < limbCount; i++, dst++, start++, tactoret++) { + base = start->x; + diff = tactoret->x - base; + dst->x = (s16)(diff * weight) + base; + base = start->y; + diff = tactoret->y - base; + dst->y = (s16)(diff * weight) + base; + base = start->z; + diff = tactoret->z - base; + dst->z = (s16)(diff * weight) + base; } } else { - for (i = 0; i < limbCount; i++, dst++, vec3++) { - dst->x = vec3->x; - dst->y = vec3->y; - dst->z = vec3->z; + for (i = 0; i < limbCount; i++, dst++, tactoret++) { + dst->x = tactoret->x; + dst->y = tactoret->y; + dst->z = tactoret->z; } } } -void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx) { +/** + * Zeroes out the current request count + */ +void AnimationContext_Reset(AnimationContext* animationCtx) { animationCtx->animationCount = 0; } -void func_801358D4(GlobalContext* globalCtx) { - D_801F5AB0 *= 2; +/** + * Shifts the queue flag to the next queue + */ +void AnimationContext_SetNextQueue(GlobalContext* globalCtx) { + sAnimQueueFlags <<= 1; } -void func_801358F4(GlobalContext* globalCtx) { - D_801F5AB4 |= D_801F5AB0; +/** + * Disables the current animation queue. Only load and move actor requests will be processed for that queue. + */ +void AnimationContext_DisableQueue(GlobalContext* globalCtx) { + sDisableAnimQueueFlags |= sAnimQueueFlags; } -AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type) { +AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type) { AnimationEntry* entry; s16 index = animationCtx->animationCount; @@ -929,807 +1025,991 @@ AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationTyp return entry; } -/* - * The next 6 functions are coordinate with the AnimationType enum +/** + * Requests loading frame data from the Link animation into frameTable */ - -void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimationHeader* linkAnimetionSeg, s32 frame, - s32 limbCount, void* ram) { - AnimationEntry* entry; - LinkAnimationHeader* LinkAnimationHeader; - s32 pad; - - entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_LINKANIMETION); +void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, + Vec3s* frameTable) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMATION_LINKANIMETION); if (entry != NULL) { - LinkAnimationHeader = Lib_SegmentedToVirtual(linkAnimetionSeg); - osCreateMesgQueue(&entry->types.type0.msgQueue, &entry->types.type0.msg, 1); - DmaMgr_SendRequestImpl( - &entry->types.type0.req, ram, - LINK_ANIMETION_OFFSET(LinkAnimationHeader->segment, (sizeof(Vec3s) * limbCount + 2) * frame), - sizeof(Vec3s) * limbCount + 2, 0, &entry->types.type0.msgQueue, NULL); + LinkAnimationHeader* linkAnimHeader = (LinkAnimationHeader*)Lib_SegmentedToVirtual(animation); + u32 ram = frameTable; + + osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); + DmaMgr_SendRequestImpl(&entry->data.load.req, ram, + LINK_ANIMETION_OFFSET(linkAnimHeader->segment, (sizeof(Vec3s) * limbCount + 2) * frame), + sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL); } } -void SkelAnime_LoadAnimationType1(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE1); +/** + * Requests copying all vectors from src frame table into dst frame table + */ +void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYALL); if (entry != NULL) { - entry->types.type1.unk00 = D_801F5AB0; - entry->types.type1.vecCount = vecCount; - entry->types.type1.dst = dst; - entry->types.type1.src = src; + entry->data.copy.queueFlag = sAnimQueueFlags; + entry->data.copy.vecCount = vecCount; + entry->data.copy.dst = dst; + entry->data.copy.src = src; } } -void SkelAnime_LoadAnimationType2(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4) { - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE2); +/** + * Requests interpolating between base and mod frame tables with the given weight, placing the result in base + */ +void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_INTERP); if (entry != NULL) { - entry->types.type2.unk00 = D_801F5AB0; - entry->types.type2.limbCount = limbCount; - entry->types.type2.unk04 = arg2; - entry->types.type2.unk08 = arg3; - entry->types.type2.unk0C = arg4; + entry->data.interp.queueFlag = sAnimQueueFlags; + entry->data.interp.vecCount = vecCount; + entry->data.interp.base = base; + entry->data.interp.mod = mod; + entry->data.interp.weight = weight; } } -void SkelAnime_LoadAnimationType3(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) { - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE3); +/** + * Requests copying vectors from src frame table to dst frame table whose load flag is true + */ +void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYTRUE); if (entry != NULL) { - entry->types.type3.unk00 = D_801F5AB0; - entry->types.type3.vecCount = vecCount; - entry->types.type3.dst = dst; - entry->types.type3.src = src; - entry->types.type3.index = index; + entry->data.copy1.queueFlag = sAnimQueueFlags; + entry->data.copy1.vecCount = vecCount; + entry->data.copy1.dst = dst; + entry->data.copy1.src = src; + entry->data.copy1.copyFlag = copyFlag; } } -void SkelAnime_LoadAnimationType4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) { - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE4); +/** + * Requests copying vectors from src frame table to dst frame table whose load flag is false + */ +void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYFALSE); if (entry != NULL) { - entry->types.type4.unk00 = D_801F5AB0; - entry->types.type4.vecCount = vecCount; - entry->types.type4.dst = dst; - entry->types.type4.src = src; - entry->types.type4.index = index; + entry->data.copy0.queueFlag = sAnimQueueFlags; + entry->data.copy0.vecCount = vecCount; + entry->data.copy0.dst = dst; + entry->data.copy0.src = src; + entry->data.copy0.copyFlag = copyFlag; } } -void SkelAnime_LoadAnimationType5(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5); +/** + * Requests moving an actor according to the translation of its root limb + */ +void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 actor3) { + AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { - entry->types.type5.actor = actor; - entry->types.type5.skelAnime = skelAnime; - entry->types.type5.unk08 = arg3; + entry->data.move.actor = actor; + entry->data.move.skelAnime = skelAnime; + entry->data.move.unk08 = actor3; } } -/* The next functions are callbacks to loading animations */ +/** + * Receives the request for Link's animation frame data + */ +void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryLoadFrame* entry = &data->load; -void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry) { osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); } -void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry) { - s32 i; - Vec3s* dst; - Vec3s* src; - AnimationEntryRaw* genericEntry = (AnimationEntryRaw*)entry; +/** + * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table + */ +void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryCopyAll* entry = &data->copy; - if ((genericEntry->raw[0] & D_801F5AB4) != 0) { - return; - } + if (!(entry->queueFlag & sDisableAnimQueueFlags)) { + Vec3s* dst = entry->dst; + Vec3s* src = entry->src; + s32 i; - for (dst = entry->dst, src = entry->src, i = 0; i < genericEntry->raw[1]; i++) { - *dst++ = *src++; + for (i = 0; i < entry->vecCount; i++) { + *dst++ = *src++; + } } } -void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry) { - if ((entry->unk00 & D_801F5AB4) == 0) { - SkelAnime_InterpolateVec3s(entry->limbCount, entry->unk04, entry->unk04, entry->unk08, entry->unk0C); +/** + * If the entry's queue is enabled, interpolates between the base and mod frame tables, placing the result in base + */ +void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryInterp* entry = &data->interp; + + if (!(entry->queueFlag & sDisableAnimQueueFlags)) { + SkelAnime_InterpFrameTable(entry->vecCount, entry->base, entry->base, entry->mod, entry->weight); } } -void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry) { - s32 i; - Vec3s* dst; - Vec3s* src; - u8* index; - AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; +/** + * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is true + */ +void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryCopyTrue* entry = &data->copy1; - if ((rawEntry->raw[0] & D_801F5AB4) == 0) { - for (dst = entry->dst, src = entry->src, index = entry->index, i = 0; i < rawEntry->raw[1]; i++, dst++, src++) { - if (*index++) { + if (!(entry->queueFlag & sDisableAnimQueueFlags)) { + Vec3s* dst = entry->dst; + Vec3s* src = entry->src; + u8* copyFlag = entry->copyFlag; + s32 i; + + for (i = 0; i < entry->vecCount; i++, dst++, src++) { + if (*copyFlag++) { *dst = *src; } } } } -void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry) { - s32 i; - Vec3s* dst; - Vec3s* src; - u8* index; - AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; +/** + * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is false + */ +void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryCopyFalse* entry = &data->copy0; - if ((rawEntry->raw[0] & D_801F5AB4) == 0) { - for (dst = entry->dst, src = entry->src, index = entry->index, i = 0; i < rawEntry->raw[1]; i++, dst++, src++) { - if (*index++ < 1U) { + if (!(entry->queueFlag & sDisableAnimQueueFlags)) { + Vec3s* dst = entry->dst; + Vec3s* src = entry->src; + u8* copyFlag = entry->copyFlag; + s32 i; + + for (i = 0; i < entry->vecCount; i++, dst++, src++) { + if (!(*copyFlag++)) { *dst = *src; } } } } -void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry) { - s32 pad; +/** + * Moves an actor according to the translation of its root limb + */ +void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data) { + AnimEntryMoveActor* entry = &data->move; Actor* actor = entry->actor; - Vec3f pos; + Vec3f diff; - func_80137748(entry->skelAnime, &pos, actor->shape.rot.y); - actor->world.pos.x += (pos.x * actor->scale.x) * entry->unk08; - actor->world.pos.y += (pos.y * actor->scale.y) * entry->unk08; - actor->world.pos.z += (pos.z * actor->scale.z) * entry->unk08; + SkelAnime_UpdateTranslation(entry->skelAnime, &diff, actor->shape.rot.y); + actor->world.pos.x += diff.x * actor->scale.x * entry->unk08; + actor->world.pos.y += diff.y * actor->scale.y * entry->unk08; + actor->world.pos.z += diff.z * actor->scale.z * entry->unk08; } -void func_80135EE8(GlobalContext* globalCtx, AnimationContext* animationCtx) { +/** + * Performs all requests in the animation queue, then resets the queue flags. + */ +void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx) { AnimationEntry* entry = animationCtx->entries; for (; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - sAnimationLoadDone[entry->type](globalCtx, &entry->types); + sAnimationLoadDone[entry->type](globalCtx, &entry->data); } - D_801F5AB0 = 1; - D_801F5AB4 = 0; + sAnimQueueFlags = 1; + sDisableAnimQueueFlags = 0; } -void SkelAnime_InitLinkAnimetion(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - LinkAnimationHeader* linkAnimationHeaderSeg, s32 flags, Vec3s* limbDrawTbl, - Vec3s* transitionDrawTbl, s32 limbBufCount) { +/** + * Initializes a skeleton to be used with Link animations to a looping animation, dynamically allocating the frame + * tables if not given. + */ +void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, + s32 limbBufCount) { FlexSkeletonHeader* skeletonHeader; - s32 headerCount; + s32 headerJointCount; s32 limbCount; - u32 allocSize; + size_t allocSize; skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); - headerCount = skeletonHeader->sh.limbCount; + headerJointCount = skeletonHeader->sh.limbCount; skelAnime->initFlags = flags; - limbCount = (flags & 2) ? headerCount : 1; + limbCount = (flags & 2) ? headerJointCount : 1; if (flags & 1) { - limbCount += headerCount; + limbCount += headerJointCount; } if (flags & 4) { - limbCount += headerCount; + limbCount += headerJointCount; } skelAnime->limbCount = limbCount; skelAnime->dListCount = skeletonHeader->dListCount; - skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->sh.skeletonSeg); + skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->sh.segment); allocSize = sizeof(Vec3s) * limbCount; if (flags & 8) { allocSize += 2; } - if (limbDrawTbl == NULL) { - skelAnime->limbDrawTbl = zelda_malloc(allocSize); - skelAnime->transitionDrawTbl = zelda_malloc(allocSize); + if (jointTable == NULL) { + skelAnime->jointTable = ZeldaArena_Malloc(allocSize); + skelAnime->morphTable = ZeldaArena_Malloc(allocSize); } else { - skelAnime->limbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl); - skelAnime->transitionDrawTbl = (Vec3s*)ALIGN16((u32)transitionDrawTbl); + skelAnime->jointTable = (Vec3s*)ALIGN16((u32)jointTable); + skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable); } - SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimationHeaderSeg, 1.0f, 0.0f, 0.0f, 0, 0.0f); + LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); } -void func_801360A8(SkelAnime* skelAnime) { - if (skelAnime->mode < 2) { - skelAnime->animUpdate = func_80136288; +/** + * Sets the update function of a SkelAnime that uses Link animations based on its mode + */ +void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { + if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { + skelAnime->update = LinkAnimation_Loop; } else { - skelAnime->animUpdate = func_8013631C; + skelAnime->update = LinkAnimation_Once; } - skelAnime->transCurrentFrame = 0.0f; + skelAnime->morphWeight = 0.0f; } -s32 func_801360E0(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->animUpdate(globalCtx, skelAnime); +/** + * Advances the current Link animation and updates all frame tables. If the animation plays once, returns true when it + * finishes. + */ +s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { + return skelAnime->update(globalCtx, skelAnime); } -s32 func_80136104(GlobalContext* globalCtx, SkelAnime* skelAnime) { - f32 prevUnk28 = skelAnime->transCurrentFrame; +/** + * Requests an interpolation between the pose in jointTable to the one in morphTable, advancing the morph but not the + * animation frame + */ +s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { + f32 prevMorphWeight = skelAnime->morphWeight; f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; - skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate; - if (skelAnime->transCurrentFrame <= 0.0f) { - func_801360A8(skelAnime); + skelAnime->morphWeight -= skelAnime->morphRate * updateRate; + if (skelAnime->morphWeight <= 0.0f) { + LinkAnimation_SetUpdateFunction(skelAnime); } - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl, - 1.0f - (skelAnime->transCurrentFrame / prevUnk28)); + AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + 1.0f - (skelAnime->morphWeight / prevMorphWeight)); return 0; } -void func_801361BC(GlobalContext* globalCtx, SkelAnime* skelAnime) { - SkelAnime_LoadLinkAnimetion(globalCtx, skelAnime->linkAnimetionSeg, skelAnime->animCurrentFrame, - skelAnime->limbCount, skelAnime->limbDrawTbl); - if (skelAnime->transCurrentFrame != 0) { +/** + * Requests a load of the next frame of a Link animation, advances the morph, and requests an interpolation between + * jointTable and morphTable + */ +void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) { + AnimationContext_SetLoadFrame(globalCtx, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, + skelAnime->jointTable); + if (skelAnime->morphWeight != 0) { f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; - skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate; - if (skelAnime->transCurrentFrame <= 0.0f) { - skelAnime->transCurrentFrame = 0.0f; + skelAnime->morphWeight -= skelAnime->morphRate * updateRate; + if (skelAnime->morphWeight <= 0.0f) { + skelAnime->morphWeight = 0.0f; } else { - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, - skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame); + AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + skelAnime->morphWeight); } } } -s32 func_80136288(GlobalContext* globalCtx, SkelAnime* skelAnime) { +/** + * Advances a Link animation that loops over its full length + */ +s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->totalFrames; - } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->totalFrames; + skelAnime->curFrame += skelAnime->playSpeed * updateRate; + if (skelAnime->curFrame < 0.0f) { + skelAnime->curFrame += skelAnime->animLength; + } else if (skelAnime->animLength <= skelAnime->curFrame) { + skelAnime->curFrame -= skelAnime->animLength; } - func_801361BC(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(globalCtx, skelAnime); return 0; } -s32 func_8013631C(GlobalContext* globalCtx, SkelAnime* skelAnime) { +/** + * Advances a Link animation that stops at endFrame and returns true when it is reached. + */ +s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f; - if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { - func_801361BC(globalCtx, skelAnime); + if (skelAnime->curFrame == skelAnime->endFrame) { + LinkAnimation_AnimateFrame(globalCtx, skelAnime); return 1; } - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; + skelAnime->curFrame += skelAnime->playSpeed * updateRate; - if (((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed) > 0.0f) { - skelAnime->animCurrentFrame = skelAnime->animFrameCount; + if (((skelAnime->curFrame - skelAnime->endFrame) * skelAnime->playSpeed) > 0.0f) { + skelAnime->curFrame = skelAnime->endFrame; } else { - if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->totalFrames; - } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->totalFrames; + if (skelAnime->curFrame < 0.0f) { + skelAnime->curFrame += skelAnime->animLength; + } else if (skelAnime->animLength <= skelAnime->curFrame) { + skelAnime->curFrame -= skelAnime->animLength; } } - func_801361BC(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(globalCtx, skelAnime); return 0; } -void SkelAnime_SetTransition(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate) { - skelAnime->transCurrentFrame = 1.0f; - skelAnime->transitionStep = 1.0f / transitionRate; +/** + * Sets a new morph and resets the morph weight for the current animation. + */ +void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames) { + skelAnime->morphWeight = 1.0f; + skelAnime->morphRate = 1.0f / morphFrames; } -void SkelAnime_ChangeLinkAnim(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed, f32 frame, f32 frameCount, - u8 animationMode, f32 transitionRate) { - skelAnime->mode = animationMode; - if ((transitionRate != 0.0f) && - ((linkAnimationHeaderSeg != skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { - if (transitionRate < 0) { - func_801360A8(skelAnime); - SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl); - transitionRate = -transitionRate; +/** + * General way to set a new Link animation, allowing choice of playback speed, start frame, end frame, play mode, and + * number of transition frames. Positive morph frames morph from the current pose to the start pose of the new + * animation, then start the new animation. Negative morph frames start the new animation immediately, modified by the + * pose immediately before the animation change. + */ +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, + f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames) { + skelAnime->mode = mode; + if ((morphFrames != 0.0f) && ((animation != skelAnime->animation) || (startFrame != skelAnime->curFrame))) { + if (morphFrames < 0) { + LinkAnimation_SetUpdateFunction(skelAnime); + SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); + morphFrames = -morphFrames; } else { - skelAnime->animUpdate = func_80136104; - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)frame, skelAnime->limbCount, - skelAnime->transitionDrawTbl); + skelAnime->update = LinkAnimation_Morph; + AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + skelAnime->morphTable); } - skelAnime->transCurrentFrame = 1.0f; - skelAnime->transitionStep = 1.0f / transitionRate; + skelAnime->morphWeight = 1.0f; + skelAnime->morphRate = 1.0f / morphFrames; } else { - func_801360A8(skelAnime); - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)frame, skelAnime->limbCount, - skelAnime->limbDrawTbl); - skelAnime->transCurrentFrame = 0.0f; + LinkAnimation_SetUpdateFunction(skelAnime); + AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + skelAnime->jointTable); + skelAnime->morphWeight = 0.0f; } - skelAnime->linkAnimetionSeg = linkAnimationHeaderSeg; - skelAnime->animCurrentFrame = 0.0f; - skelAnime->initialFrame = frame; - skelAnime->animCurrentFrame = frame; - skelAnime->animFrameCount = frameCount; - skelAnime->totalFrames = SkelAnime_GetTotalFrames(&linkAnimationHeaderSeg->common); - skelAnime->animPlaybackSpeed = playbackSpeed; + skelAnime->animation = animation; + skelAnime->curFrame = 0.0f; + skelAnime->startFrame = startFrame; + skelAnime->curFrame = startFrame; + skelAnime->endFrame = endFrame; + skelAnime->animLength = Animation_GetLength(animation); + skelAnime->playSpeed = playSpeed; } -void SkelAnime_ChangeLinkAnimDefaultStop(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg) { - SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimationHeaderSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&linkAnimationHeaderSeg->common), 2, 0.0f); +/** + * Immediately changes to a Link animation that plays once at the default speed. + */ +void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_ONCE, 0.0f); } -void SkelAnime_ChangeLinkAnimPlaybackStop(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed) { - SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimationHeaderSeg, playbackSpeed, 0.0f, - SkelAnime_GetFrameCount(&linkAnimationHeaderSeg->common), 2, 0.0f); +/** + * Immediately changes to a Link animation that plays once at the specified speed. + */ +void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, + f32 playSpeed) { + LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_ONCE, 0.0f); } -void SkelAnime_ChangeLinkAnimDefaultRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg) { - SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimationHeaderSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&linkAnimationHeaderSeg->common), 0, 0.0f); +/** + * Immediately changes to a Link animation that loops at the default speed. + */ +void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_LOOP, 0.0f); } -void SkelAnime_ChangeLinkAnimPlaybackRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime, - LinkAnimationHeader* linkAnimationHeaderSeg, f32 playbackSpeed) { - SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimationHeaderSeg, playbackSpeed, 0.0f, - SkelAnime_GetFrameCount(&linkAnimationHeaderSeg->common), 0, 0.0f); +/** + * Immediately changes to a Link animation that loops at the specified speed. + */ +void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, + f32 playSpeed) { + LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_LOOP, 0.0f); } -void func_8013670C(GlobalContext* globalCtx, SkelAnime* skelAnime) { - SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl); +/** + * Requests copying jointTable to morphTable + */ +void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); } -void func_8013673C(GlobalContext* globalCtx, SkelAnime* skelAnime) { - SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl); +/** + * Requests copying morphTable to jointTable + */ +void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); } -void func_8013676C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, - f32 frame) { - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)frame, skelAnime->limbCount, - skelAnime->transitionDrawTbl); +/** + * Requests loading frame data from the Link animation into morphTable + */ +void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, + f32 frame) { + AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); } -void func_801367B0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, - f32 frame) { - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)frame, skelAnime->limbCount, - skelAnime->limbDrawTbl); +/** + * Requests loading frame data from the Link animation into jointTable + */ +void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, + f32 frame) { + AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); } -void func_801367F4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame) { - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->transitionDrawTbl, - frame); +/** + * Requests interpolating between jointTable and morphTable, placing the result in jointTable + */ +void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 weight) { + AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); } -void func_8013682C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, - f32 transitionFrame, LinkAnimationHeader* LinkAnimationHeaderSeg2, f32 frame, f32 transitionRate, - Vec3s* limbDrawTbl) { - Vec3s* alignedLimbDrawTbl; - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)transitionFrame, skelAnime->limbCount, - skelAnime->limbDrawTbl); +/** + * Requests loading frame data from the Link animations and blending them, placing the result in jointTable + */ +void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, + f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, + Vec3s* blendTable) { + Vec3s* alignedBlendTable; - alignedLimbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl); + AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); - SkelAnime_LoadLinkAnimetion(globalCtx, LinkAnimationHeaderSeg2, (s32)frame, skelAnime->limbCount, - alignedLimbDrawTbl); - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->limbDrawTbl, alignedLimbDrawTbl, - transitionRate); + alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); + + AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); } -void func_801368CC(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimationHeaderSeg, - f32 transitionFrame, LinkAnimationHeader* LinkAnimationHeaderSeg2, f32 frame, f32 transitionRate, - Vec3s* limbDrawTbl) { - Vec3s* alignedLimbDrawTbl; +/** + * Requests loading frame data from the Link animations and blending them, placing the result in morphTable + */ +void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, + f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, + Vec3s* blendTable) { + Vec3s* alignedBlendTable; - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimationHeaderSeg, (s32)transitionFrame, skelAnime->limbCount, - skelAnime->transitionDrawTbl); + AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); - alignedLimbDrawTbl = (Vec3s*)ALIGN16((u32)limbDrawTbl); + alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); - SkelAnime_LoadLinkAnimetion(globalCtx, LinkAnimationHeaderSeg2, (s32)frame, skelAnime->limbCount, - alignedLimbDrawTbl); - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl, alignedLimbDrawTbl, - transitionRate); + AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); } -void SkelAnime_SetModeStop(SkelAnime* skelAnime) { - skelAnime->mode = 2; - func_801360A8(skelAnime); +/** + * Changes a looping animation to one that stops at the end. + */ +void LinkAnimation_EndLoop(SkelAnime* skelAnime) { + skelAnime->mode = ANIMMODE_ONCE; + LinkAnimation_SetUpdateFunction(skelAnime); } -s32 func_80136990(SkelAnime* skelAnime, f32 arg1, f32 updateRate) { +/** + * Checks if the current frame is after frame and the previous frame was before it. + */ +s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate) { f32 updateSpeed; - f32 temp_f12; + f32 curFrameDiff; f32 nextFrame; - updateSpeed = skelAnime->animPlaybackSpeed * updateRate; - nextFrame = skelAnime->animCurrentFrame - updateSpeed; + updateSpeed = skelAnime->playSpeed * updateRate; + nextFrame = skelAnime->curFrame - updateSpeed; if (nextFrame < 0.0f) { - nextFrame += skelAnime->totalFrames; - } else if (skelAnime->totalFrames <= nextFrame) { - nextFrame -= skelAnime->totalFrames; + nextFrame += skelAnime->animLength; + } else if (skelAnime->animLength <= nextFrame) { + nextFrame -= skelAnime->animLength; } - if ((arg1 == 0.0f) && (updateSpeed > 0.0f)) { - arg1 = skelAnime->totalFrames; + if ((frame == 0.0f) && (updateSpeed > 0.0f)) { + frame = skelAnime->animLength; } - temp_f12 = (nextFrame + updateSpeed) - arg1; - if ((0.0f <= (temp_f12 * updateSpeed)) && (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f)) { - return 1; + curFrameDiff = (nextFrame + updateSpeed) - frame; + if ((0.0f <= (curFrameDiff * updateSpeed)) && (((curFrameDiff - updateSpeed) * updateSpeed) < 0.0f)) { + return true; } - return 0; + return false; } -s32 func_80136A48(SkelAnime* skelAnime, f32 arg1) { +/** + * Checks if the current Link animation has reached the specified frame + */ +s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { f32 updateRate = gFramerateDivisorHalf; - return func_80136990(skelAnime, arg1, updateRate); + return Animation_OnFrameImpl(skelAnime, frame, updateRate); } +/** + * Initializes a normal skeleton to a looping animation, dynamically allocating the frame tables if not provided. + */ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount) { + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { SkeletonHeader* skeletonHeader; skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->limbCount + 1; - skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->skeletonSeg); - if (limbDrawTbl == NULL) { - skelAnime->limbDrawTbl = zelda_malloc(sizeof(*skelAnime->limbDrawTbl) * skelAnime->limbCount); - skelAnime->transitionDrawTbl = zelda_malloc(sizeof(*skelAnime->transitionDrawTbl) * skelAnime->limbCount); + skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->segment); + if (jointTable == NULL) { + skelAnime->jointTable = ZeldaArena_Malloc(sizeof(*skelAnime->jointTable) * skelAnime->limbCount); + skelAnime->morphTable = ZeldaArena_Malloc(sizeof(*skelAnime->morphTable) * skelAnime->limbCount); } else { - skelAnime->limbDrawTbl = limbDrawTbl; - skelAnime->transitionDrawTbl = transitionDrawTable; + skelAnime->jointTable = jointTable; + skelAnime->morphTable = morphTable; } - if (animationSeg != NULL) { - SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg); + if (animation != NULL) { + Animation_PlayLoop(skelAnime, animation); } } -void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg, Vec3s* limbDrawTbl, Vec3s* transitionDrawTable, s32 limbCount) { +/** + * Initializes a flex skeleton to a looping animation, dynamically allocating the frame tables if not given. + */ +void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { FlexSkeletonHeader* skeletonHeader; skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->sh.limbCount + 1; skelAnime->dListCount = skeletonHeader->dListCount; - skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->sh.skeletonSeg); + skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->sh.segment); - if (limbDrawTbl == NULL) { - skelAnime->limbDrawTbl = zelda_malloc(sizeof(*skelAnime->limbDrawTbl) * skelAnime->limbCount); + if (jointTable == NULL) { + skelAnime->jointTable = ZeldaArena_Malloc(sizeof(*skelAnime->jointTable) * skelAnime->limbCount); - skelAnime->transitionDrawTbl = zelda_malloc(sizeof(*skelAnime->transitionDrawTbl) * skelAnime->limbCount); + skelAnime->morphTable = ZeldaArena_Malloc(sizeof(*skelAnime->morphTable) * skelAnime->limbCount); } else { - skelAnime->limbDrawTbl = limbDrawTbl; - skelAnime->transitionDrawTbl = transitionDrawTable; + skelAnime->jointTable = jointTable; + skelAnime->morphTable = morphTable; } - if (animationSeg != NULL) { - SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg); + if (animation != NULL) { + Animation_PlayLoop(skelAnime, animation); } } +/** + * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. + */ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg) { + AnimationHeader* animation) { SkeletonHeader* skeletonHeader; skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->limbCount + 1; - skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->skeletonSeg); - skelAnime->limbDrawTbl = zelda_malloc(sizeof(*skelAnime->limbDrawTbl) * skelAnime->limbCount); - skelAnime->transitionDrawTbl = zelda_malloc(sizeof(*skelAnime->transitionDrawTbl) * skelAnime->limbCount); + skelAnime->skeleton = Lib_SegmentedToVirtual(skeletonHeader->segment); + skelAnime->jointTable = ZeldaArena_Malloc(sizeof(*skelAnime->jointTable) * skelAnime->limbCount); + skelAnime->morphTable = ZeldaArena_Malloc(sizeof(*skelAnime->morphTable) * skelAnime->limbCount); // Debug prints here, required to match. if (1) {}; - if (animationSeg != NULL) { - SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg); + if (animation != NULL) { + Animation_PlayLoop(skelAnime, animation); } } -void func_80136C84(SkelAnime* skelAnime) { - if (skelAnime->mode < 2) { - skelAnime->animUpdate = func_8013702C; - } else if (skelAnime->mode < 4) { - skelAnime->animUpdate = func_8013713C; +/** + * Sets the SkelAnime's update function based on its current mode. + */ +void SkelAnime_SetUpdate(SkelAnime* skelAnime) { + if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { + skelAnime->update = SkelAnime_LoopFull; + } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { + skelAnime->update = SkelAnime_Once; } else { - skelAnime->animUpdate = func_801370B0; + skelAnime->update = SkelAnime_LoopPartial; } } -s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime) { - return skelAnime->animUpdate(skelAnime); +/** + * Advances the current animation and updates all frame tables. If the animation plays once, returns true when it + * finishes. + */ +s32 SkelAnime_Update(SkelAnime* skelAnime) { + return skelAnime->update(skelAnime); } -s32 func_80136CF4(SkelAnime* skelAnime) { - f32 prevUnk28 = skelAnime->transCurrentFrame; +/** + * Morphs from the pose in jointTable to the one in morphTable, advancing the morph but not the animation frame + */ +s32 SkelAnime_Morph(SkelAnime* skelAnime) { + f32 prevMorphWeight = skelAnime->morphWeight; f32 updateRate = gFramerateDivisorThird; - skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate; - if (skelAnime->transCurrentFrame <= 0.0f) { - func_80136C84(skelAnime); - skelAnime->transCurrentFrame = 0.0f; + skelAnime->morphWeight -= skelAnime->morphRate * updateRate; + if (skelAnime->morphWeight <= 0.0f) { + SkelAnime_SetUpdate(skelAnime); + skelAnime->morphWeight = 0.0f; } - SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl, - skelAnime->transitionDrawTbl, 1.0f - (skelAnime->transCurrentFrame / prevUnk28)); + SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, + skelAnime->morphTable, 1.0f - (skelAnime->morphWeight / prevMorphWeight)); return 0; } -s32 func_80136D98(SkelAnime* skelAnime) { - s16 temp_a2 = (s16)(skelAnime->transCurrentFrame * 16384.0f); - s16 temp_a1; - f32 sp28; - f32 phi_f2; +/** + * Performs a tapered morph from the pose in jointTable to the one in morphTable, advancing the morph but not the + * animation frame + */ +s32 SkelAnime_MorphTaper(SkelAnime* skelAnime) { + s16 prevPhase = skelAnime->morphWeight * 0x4000; + s16 curPhase; + f32 prevWeight; + f32 curWeight; f32 updateRate = gFramerateDivisorThird; - skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate; - if (skelAnime->transCurrentFrame <= 0.0f) { - func_80136C84(skelAnime); - skelAnime->transCurrentFrame = 0.0f; + skelAnime->morphWeight -= skelAnime->morphRate * updateRate; + if (skelAnime->morphWeight <= 0.0f) { + SkelAnime_SetUpdate(skelAnime); + skelAnime->morphWeight = 0.0f; } - temp_a1 = (s16)(skelAnime->transCurrentFrame * 16384.0f); - if (skelAnime->unk03 < 0) { - sp28 = 1.0f - Math_CosS(temp_a2); - phi_f2 = 1.0f - Math_CosS(temp_a1); + curPhase = skelAnime->morphWeight * 0x4000; + if (skelAnime->taper < 0) { + prevWeight = 1.0f - Math_CosS(prevPhase); + curWeight = 1.0f - Math_CosS(curPhase); } else { - sp28 = Math_SinS(temp_a2); - phi_f2 = Math_SinS(temp_a1); + prevWeight = Math_SinS(prevPhase); + curWeight = Math_SinS(curPhase); } - if (phi_f2 != 0.0f) { - phi_f2 /= sp28; + if (curWeight != 0.0f) { + curWeight /= prevWeight; } else { - phi_f2 = 0.0f; + curWeight = 0.0f; } - SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl, - skelAnime->transitionDrawTbl, 1.0f - phi_f2); + SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, + skelAnime->morphTable, 1.0f - curWeight); return 0; } -void func_80136F04(SkelAnime* skelAnime) { - s32 t; - s32 pad[2]; - Vec3s sp38[98]; - f32 temp_f10; - f32 temp_f2; +/** + * Gets frame data for the current frame as modified by morphTable and advances the morph + */ +void SkelAnime_AnimateFrame(SkelAnime* skelAnime) { + Vec3s nextjointTable[100]; - SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, skelAnime->animCurrentFrame, skelAnime->limbCount, - skelAnime->limbDrawTbl); - if (skelAnime->mode & 0x1) { - t = (s32)skelAnime->animCurrentFrame; - temp_f10 = t; - temp_f2 = skelAnime->animCurrentFrame - temp_f10; - t++; - if (t >= (s32)skelAnime->totalFrames) { - t = 0; + SkelAnime_GetFrameData(skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); + if (skelAnime->mode & ANIM_INTERP) { + s32 frame = skelAnime->curFrame; + f32 partialFrame = skelAnime->curFrame - frame; + + if (++frame >= (s32)skelAnime->animLength) { + frame = 0; } - SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, t, skelAnime->limbCount, sp38); - SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl, sp38, temp_f2); + SkelAnime_GetFrameData(skelAnime->animation, frame, skelAnime->limbCount, nextjointTable); + SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, nextjointTable, + partialFrame); } - if (skelAnime->transCurrentFrame != 0) { + if (skelAnime->morphWeight != 0) { f32 updateRate = gFramerateDivisorThird; - skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate; - if (skelAnime->transCurrentFrame <= 0.0f) { - skelAnime->transCurrentFrame = 0.0f; - return; + + skelAnime->morphWeight -= skelAnime->morphRate * updateRate; + if (skelAnime->morphWeight <= 0.0f) { + skelAnime->morphWeight = 0.0f; + } else { + SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, + skelAnime->morphTable, skelAnime->morphWeight); } - SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->limbDrawTbl, skelAnime->limbDrawTbl, - skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame); } } - -s32 func_8013702C(SkelAnime* skelAnime) { +/** + * Advances an animation that loops over its full length and updates the frame tables + */ +s32 SkelAnime_LoopFull(SkelAnime* skelAnime) { f32 updateRate = gFramerateDivisorThird; - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->totalFrames; - } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->totalFrames; + skelAnime->curFrame += skelAnime->playSpeed * updateRate; + if (skelAnime->curFrame < 0.0f) { + skelAnime->curFrame += skelAnime->animLength; + } else if (skelAnime->animLength <= skelAnime->curFrame) { + skelAnime->curFrame -= skelAnime->animLength; } - func_80136F04(skelAnime); + SkelAnime_AnimateFrame(skelAnime); return 0; } -s32 func_801370B0(SkelAnime* skelAnime) { +/** + * Advances an animation that loops over part of its length and updates the frame tables + */ +s32 SkelAnime_LoopPartial(SkelAnime* skelAnime) { f32 updateRate = gFramerateDivisorThird; - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (skelAnime->animCurrentFrame < skelAnime->initialFrame) { - skelAnime->animCurrentFrame = - (skelAnime->animCurrentFrame - skelAnime->initialFrame) + skelAnime->animFrameCount; - } else if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame = - (skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->initialFrame; + skelAnime->curFrame += skelAnime->playSpeed * updateRate; + if (skelAnime->curFrame < skelAnime->startFrame) { + skelAnime->curFrame = (skelAnime->curFrame - skelAnime->startFrame) + skelAnime->endFrame; + } else if (skelAnime->endFrame <= skelAnime->curFrame) { + skelAnime->curFrame = (skelAnime->curFrame - skelAnime->endFrame) + skelAnime->startFrame; } - func_80136F04(skelAnime); + SkelAnime_AnimateFrame(skelAnime); return 0; } -s32 func_8013713C(SkelAnime* skelAnime) { +/** + * Advances an animation that stops at endFrame and returns true when it is reached. + */ +s32 SkelAnime_Once(SkelAnime* skelAnime) { f32 updateRate = gFramerateDivisorThird; - if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { - SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, - skelAnime->limbDrawTbl); - func_80136F04(skelAnime); + if (skelAnime->curFrame == skelAnime->endFrame) { + SkelAnime_GetFrameData(skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); + SkelAnime_AnimateFrame(skelAnime); return 1; } - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed) > 0.0f) { - skelAnime->animCurrentFrame = skelAnime->animFrameCount; + skelAnime->curFrame += skelAnime->playSpeed * updateRate; + if (((skelAnime->curFrame - skelAnime->endFrame) * skelAnime->playSpeed) > 0.0f) { + skelAnime->curFrame = skelAnime->endFrame; } else { - if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->totalFrames; + if (skelAnime->curFrame < 0.0f) { + skelAnime->curFrame += skelAnime->animLength; } else { - if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->totalFrames; + if (skelAnime->animLength <= skelAnime->curFrame) { + skelAnime->curFrame -= skelAnime->animLength; } } } - func_80136F04(skelAnime); + SkelAnime_AnimateFrame(skelAnime); return 0; } -void SkelAnime_ChangeAnimImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, - f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2) { - skelAnime->mode = animationType; - if ((transitionRate != 0.0f) && - ((animationSeg != skelAnime->animCurrentSeg) || (frame != skelAnime->animCurrentFrame))) { - if (transitionRate < 0) { - func_80136C84(skelAnime); - SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->limbDrawTbl); - transitionRate = -transitionRate; - } else { - if (unk2 != 0) { - skelAnime->animUpdate = func_80136D98; - skelAnime->unk03 = unk2; - } else { - skelAnime->animUpdate = func_80136CF4; - } - SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->transitionDrawTbl); - } - skelAnime->transCurrentFrame = 1.0f; - skelAnime->transitionStep = 1.0f / transitionRate; - } else { - func_80136C84(skelAnime); - SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->limbDrawTbl); - skelAnime->transCurrentFrame = 0.0f; - } - - skelAnime->animCurrentSeg = animationSeg; - skelAnime->initialFrame = frame; - skelAnime->animFrameCount = frameCount; - skelAnime->totalFrames = SkelAnime_GetTotalFrames(&animationSeg->common); - if (skelAnime->mode >= 4) { - skelAnime->animCurrentFrame = 0.0f; - } else { - skelAnime->animCurrentFrame = frame; - if (skelAnime->mode < 2) { - skelAnime->animFrameCount = skelAnime->totalFrames - 1.0f; - } - } - skelAnime->animPlaybackSpeed = playbackSpeed; -} - -void SkelAnime_ChangeAnim(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, - f32 frameCount, u8 mode, f32 transitionRate) { - SkelAnime_ChangeAnimImpl(skelAnime, animationSeg, playbackSpeed, frame, frameCount, mode, transitionRate, 0); -} - -void SkelAnime_ChangeAnimDefaultStop(SkelAnime* skelAnime, AnimationHeader* animationSeg) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), 2, 0.0f); -} - -void SkelAnime_ChangeAnimTransitionStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(&animationSeg->common), 2, - transitionRate); -} - -void SkelAnime_ChangeAnimPlaybackStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), - 2, 0.0f); -} - -void SkelAnime_ChangeAnimDefaultRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), 0, 0.0f); -} - -void SkelAnime_ChangeAnimTransitionRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, 0.0f, 0, transitionRate); -} - -void SkelAnime_ChangeAnimPlaybackRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { - SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), - 0, 0.0f); -} - -void SkelAnime_AnimSetStop(SkelAnime* skelAnime) { - skelAnime->mode = 2; - skelAnime->animFrameCount = skelAnime->totalFrames; - func_80136C84(skelAnime); -} - -void SkelAnime_AnimReverse(SkelAnime* skelAnime) { - f32 initialFrame = skelAnime->initialFrame; - - skelAnime->initialFrame = skelAnime->animFrameCount; - skelAnime->animPlaybackSpeed = -skelAnime->animPlaybackSpeed; - skelAnime->animFrameCount = initialFrame; -} - -void func_80137674(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) { - s32 i; - - for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { - if (*index++) { - *dst = *src; - } - } -} - -void func_801376DC(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) { - s32 i; - - for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { - if (*arg3++ < 1U) { - *dst = *src; - } - } -} - -/* - * Moves `pos` backwards on the xz plane from `angle` +/** + * Fully general way to set a new animation, allowing choice of playback speed, start frame, end frame, play mode, + * number of transition frames, and tapering of the transition. Positive morph frames morph from the current pose to the + * start pose of the new animation, then start the new animation. Negative morph frames start the new animation + * immediately, modified by the pose immediately before the animation change. */ -void func_80137748(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { +void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, + u8 mode, f32 morphFrames, s8 taper) { + skelAnime->mode = mode; + if ((morphFrames != 0.0f) && ((animation != skelAnime->animation) || (startFrame != skelAnime->curFrame))) { + if (morphFrames < 0) { + SkelAnime_SetUpdate(skelAnime); + SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); + morphFrames = -morphFrames; + } else { + if (taper != ANIMTAPER_NONE) { + skelAnime->update = SkelAnime_MorphTaper; + skelAnime->taper = taper; + } else { + skelAnime->update = SkelAnime_Morph; + } + SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); + } + skelAnime->morphWeight = 1.0f; + skelAnime->morphRate = 1.0f / morphFrames; + } else { + SkelAnime_SetUpdate(skelAnime); + SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->jointTable); + skelAnime->morphWeight = 0.0f; + } + + skelAnime->animation = animation; + skelAnime->startFrame = startFrame; + skelAnime->endFrame = endFrame; + skelAnime->animLength = Animation_GetLength(&animation->common); + if (skelAnime->mode >= ANIMMODE_LOOP_PARTIAL) { + skelAnime->curFrame = 0.0f; + } else { + skelAnime->curFrame = startFrame; + if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { + skelAnime->endFrame = skelAnime->animLength - 1.0f; + } + } + skelAnime->playSpeed = playSpeed; +} + +/** + * General way to set a new animation, allowing choice of playback speed, start frame, end frame, play mode, and number + * of transition frames. Positive morph frames morph from the current pose to the start pose of the new animation, then + * start the new animation. Negative morph frames start the new animation immediately, modified by the pose immediately + * before the animation change. + */ +void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, + u8 mode, f32 morphFrames) { + Animation_ChangeImpl(skelAnime, animation, playSpeed, startFrame, endFrame, mode, morphFrames, ANIMTAPER_NONE); +} + +/** + * Immediately changes to an animation that plays once at the default speed. + */ +void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation) { + Animation_Change(skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, 0.0f); +} + +/** + * Smoothly transitions to an animation that plays once at the default speed. + * Positive morph frames morph from the current pose to the start pose of the new animation, then start the new + * animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the + * animation change. + */ +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 morphFrames) { + Animation_Change(skelAnime, animationSeg, 1.0f, 0, Animation_GetLastFrame(&animationSeg->common), ANIMMODE_ONCE, + morphFrames); +} + +/** + * Immediately changes to an animation that plays once at the specified speed. + */ +void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed) { + Animation_Change(skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, + 0.0f); +} + +/** + * Immediately changes to an animation that loops at the default. + */ +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation) { + Animation_Change(skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, 0.0f); +} + +/** + * Smoothly transitions to a looping animation, specifying the number of frames for the transition. + * Positive morph frames morph from the current pose to the start pose of the new animation, then start the new + * animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the + * animation change. + */ +void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { + Animation_Change(skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, morphFrames); +} + +/** + * Immediately changes to an animation that loops at the specified speed. + */ +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playbackSpeed) { + Animation_Change(skelAnime, animation, playbackSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_LOOP, 0.0f); +} + +/** + * Changes a looping animation to one that stops at the end. Unused + */ +void Animation_EndLoop(SkelAnime* skelAnime) { + skelAnime->mode = ANIMMODE_ONCE; + skelAnime->endFrame = skelAnime->animLength; + SkelAnime_SetUpdate(skelAnime); +} + +/** + * Reverses the current animation. + */ +void Animation_Reverse(SkelAnime* skelAnime) { + f32 startFrame = skelAnime->startFrame; + + skelAnime->startFrame = skelAnime->endFrame; + skelAnime->playSpeed = -skelAnime->playSpeed; + skelAnime->endFrame = startFrame; +} + +/** + * Copies the src frame table to the dst frame table if copyFlag for that limb is true. + */ +void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag) { + s32 i; + + for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { + if (*copyFlag++) { + *dst = *src; + } + } +} + +/** + * Copies the src frame table to the dst frame table if copyFlag for that limb is false. + */ +void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag) { + s32 i; + + for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { + if (!*copyFlag++) { + *dst = *src; + } + } +} + +/** + * Updates translation of the root limb and calculates `pos`, the difference between + * the old and new positions of the root limb as rotated by `angle`. Used to allow + * animations to change an actor's position. + */ +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) { f32 x; f32 z; f32 sin; f32 cos; - if (skelAnime->flags & 0x10) { - pos->z = 0.0f; - pos->x = 0.0f; + if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) { + diff->z = 0.0f; + diff->x = 0.0f; } else { // `angle` rotation around y axis. - x = skelAnime->limbDrawTbl->x - skelAnime->prevFramePos.x; - z = skelAnime->limbDrawTbl->z - skelAnime->prevFramePos.z; + x = skelAnime->jointTable->x - skelAnime->prevTransl.x; + z = skelAnime->jointTable->z - skelAnime->prevTransl.z; sin = Math_SinS(angle); cos = Math_CosS(angle); - pos->x = x * cos + z * sin; - pos->z = z * cos - x * sin; + diff->x = x * cos + z * sin; + diff->z = z * cos - x * sin; } - skelAnime->prevFramePos.x = skelAnime->limbDrawTbl->x; - skelAnime->limbDrawTbl->x = skelAnime->unk3E.x; - skelAnime->prevFramePos.z = skelAnime->limbDrawTbl->z; - skelAnime->limbDrawTbl->z = skelAnime->unk3E.z; - if (skelAnime->flags & ANIM_FLAG_UPDATEXZ) { - if (skelAnime->flags & ANIM_FLAG_UPDATEY) { - pos->y = 0.0f; + skelAnime->prevTransl.x = skelAnime->jointTable->x; + skelAnime->jointTable->x = skelAnime->baseTransl.x; + skelAnime->prevTransl.z = skelAnime->jointTable->z; + skelAnime->jointTable->z = skelAnime->baseTransl.z; + if (skelAnime->moveFlags & ANIM_FLAG_UPDATEY) { + if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) { + diff->y = 0.0f; } else { - pos->y = skelAnime->limbDrawTbl->y - skelAnime->prevFramePos.y; + diff->y = skelAnime->jointTable->y - skelAnime->prevTransl.y; } - skelAnime->prevFramePos.y = skelAnime->limbDrawTbl->y; - skelAnime->limbDrawTbl->y = skelAnime->unk3E.y; + skelAnime->prevTransl.y = skelAnime->jointTable->y; + skelAnime->jointTable->y = skelAnime->baseTransl.y; } else { - pos->y = 0.0f; - skelAnime->prevFramePos.y = skelAnime->limbDrawTbl->y; + diff->y = 0.0f; + skelAnime->prevTransl.y = skelAnime->jointTable->y; } - skelAnime->flags &= ~ANIM_FLAG_UPDATEY; + skelAnime->moveFlags &= ~ANIM_FLAG_NOMOVE; } -s32 func_801378B8(SkelAnime* skelAnime, f32 arg1) { - return func_80136990(skelAnime, arg1, 1.0f); +/** + * Checks if the current animation is at the specified frame + */ +s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame) { + return Animation_OnFrameImpl(skelAnime, frame, 1.0f); } +/** + * Frees the frame tables for a skelAnime with dynamically allocated tables. + */ void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) { - if (skelAnime->limbDrawTbl != NULL) { - zelda_free(skelAnime->limbDrawTbl); + if (skelAnime->jointTable != NULL) { + ZeldaArena_Free(skelAnime->jointTable); } - if (skelAnime->transitionDrawTbl != NULL) { - zelda_free(skelAnime->transitionDrawTbl); + if (skelAnime->morphTable != NULL) { + ZeldaArena_Free(skelAnime->morphTable); } } -void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { +/** + * Copies the src frame table to the dst frame table. + */ +void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { bcopy(src, dst, sizeof(Vec3s) * skelAnime->limbCount); } diff --git a/src/code/z_view.c b/src/code/z_view.c index 034f045b1..c325fd563 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -237,7 +237,7 @@ s32 View_SetQuake(View* view, Vec3f rot, Vec3f scale, f32 speed) { return 1; } -s32 View_StepQuake(View* view, RSPMatrix* matrix) { +s32 View_StepQuake(View* view, Mtx* matrix) { MtxF mf; if (view->quakeSpeed == 0.0f) { @@ -256,16 +256,16 @@ s32 View_StepQuake(View* view, RSPMatrix* matrix) { view->currQuakeScale.z += ((view->quakeScale.z - view->currQuakeScale.z) * view->quakeSpeed); } - SysMatrix_FromRSPMatrix(matrix, &mf); - SysMatrix_SetCurrentState(&mf); - SysMatrix_RotateStateAroundXAxis(view->currQuakeRot.x); - SysMatrix_InsertYRotation_f(view->currQuakeRot.y, 1); - SysMatrix_InsertZRotation_f(view->currQuakeRot.z, 1); - Matrix_Scale(view->currQuakeScale.x, view->currQuakeScale.y, view->currQuakeScale.z, 1); - SysMatrix_InsertZRotation_f(-view->currQuakeRot.z, 1); - SysMatrix_InsertYRotation_f(-view->currQuakeRot.y, 1); - SysMatrix_RotateStateAroundXAxis(-view->currQuakeRot.x); - SysMatrix_GetStateAsRSPMatrix(matrix); + Matrix_FromRSPMatrix(matrix, &mf); + Matrix_SetCurrentState(&mf); + Matrix_RotateStateAroundXAxis(view->currQuakeRot.x); + Matrix_InsertYRotation_f(view->currQuakeRot.y, 1); + Matrix_InsertZRotation_f(view->currQuakeRot.z, 1); + Matrix_Scale(view->currQuakeScale.x, view->currQuakeScale.y, view->currQuakeScale.z, MTXMODE_APPLY); + Matrix_InsertZRotation_f(-view->currQuakeRot.z, 1); + Matrix_InsertYRotation_f(-view->currQuakeRot.y, 1); + Matrix_RotateStateAroundXAxis(-view->currQuakeRot.x); + Matrix_ToMtx(matrix); return 1; } @@ -310,7 +310,7 @@ s32 View_RenderToPerspectiveMatrix(View* view) { guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); view->projection = *projection; //! @bug: This cast of `projection` is invalid - View_StepQuake(view, (RSPMatrix*)projection); + View_StepQuake(view, (Mtx*)projection); gSPPerspNormalize(POLY_OPA_DISP++, view->normal); gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 1fca4801d..9e949beac 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -35,9 +35,9 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) { } } -void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) { - GlobalContext* globalCtx = (GlobalContext*)gamestate; - u32 size; +void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + size_t size; void* offset; s32 pad; @@ -82,7 +82,7 @@ void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) } void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) { - u32 size; + size_t size; if (1) {} @@ -133,22 +133,22 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy } } -void func_801434E4(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) { +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) { skyboxCtx->skyboxShouldDraw = 0; skyboxCtx->rotX = skyboxCtx->rotY = skyboxCtx->rotZ = 0.0f; - func_801431E8(gamestate, skyboxCtx, skyType); + func_801431E8(gameState, skyboxCtx, skyType); if (skyType != 0) { - skyboxCtx->unk17C = THA_AllocEndAlign16(&gamestate->heap, 0x3840); + skyboxCtx->unk17C = THA_AllocEndAlign16(&gameState->heap, 0x3840); if (skyType == 5) { // Allocate enough space for the vertices for a 6 sided skybox (cube) - skyboxCtx->roomVtx = THA_AllocEndAlign16(&gamestate->heap, sizeof(Vtx) * 32 * 6); + skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6); func_80143148(skyboxCtx, 6); } else { // Allocate enough space for the vertices for a 5 sided skybox (bottom is missing) - skyboxCtx->roomVtx = THA_AllocEndAlign16(&gamestate->heap, sizeof(Vtx) * 32 * 5); + skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 5); func_80143148(skyboxCtx, 5); } } diff --git a/src/libultra/io/contpfs.c b/src/libultra/io/contpfs.c index b5e6e0288..42009674f 100644 --- a/src/libultra/io/contpfs.c +++ b/src/libultra/io/contpfs.c @@ -1,15 +1,308 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osSumcalc.s") +u16 __osSumcalc(u8* ptr, s32 length) { + s32 i; + u32 sum = 0; + u8* temp = ptr; -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osIdCheckSum.s") + for (i = 0; i < length; i++) { + sum += *temp++; + } + return sum & 0xFFFF; +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osRepairPackId.s") +s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum) { + u16 data = 0; + u32 i; -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osCheckPackId.s") + *checkSum = *idSum = 0; + for (i = 0; i < ((sizeof(__OSPackId) - sizeof(u32)) / sizeof(u8)); i += 2) { + data = *((u16*)((u32)ptr + i)); + *checkSum += data; + *idSum += ~data; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osGetId.s") +s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) { + s32 ret = 0; + u8 temp[BLOCKSIZE]; + u8 comp[BLOCKSIZE]; + u8 mask = 0; + s32 i, j = 0; + u16 index[4]; -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osCheckId.s") + newid->repaired = 0xFFFFFFFF; + newid->random = osGetCount(); + newid->serialMid = badid->serialMid; + newid->serialLow = badid->serialLow; -#pragma GLOBAL_ASM("asm/non_matchings/boot/contpfs/__osPfsRWInode.s") + if ((pfs->activebank != 0) && ((ret = __osPfsSelectBank(pfs, 0)) != 0)) { + return ret; + } + + do { + if ((ret = __osPfsSelectBank(pfs, j)) != 0) { + return ret; + } + + if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, temp)) != 0) { + return ret; + } + temp[0] = j | 0x80; + for (i = 1; i < BLOCKSIZE; i++) { + temp[i] = ~temp[i]; + } + + if ((ret = __osContRamWrite(pfs->queue, pfs->channel, 0, temp, 0)) != 0) { + return ret; + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, comp)) != 0) { + return (ret); + } + for (i = 0; i < BLOCKSIZE; i++) { + if (comp[i] != temp[i]) { + break; + } + } + if (i != BLOCKSIZE) { + break; + } + + if (j > 0) { + if ((ret = __osPfsSelectBank(pfs, 0)) != 0) { + return ret; + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, temp)) != 0) { + return ret; + } + if (temp[0] != 0x80) { + break; + } + } + + j++; + } while (j < PFS_MAX_BANKS); + + if ((pfs->activebank != 0) && (ret = __osPfsSelectBank(pfs, 0)) != 0) { + return ret; + } + + mask = (j > 0) ? 1 : 0; + newid->deviceid = (badid->deviceid & 0xFFFE) | mask; + newid->banks = j; + newid->version = badid->version; + __osIdCheckSum((u16*)newid, &newid->checksum, &newid->invertedChecksum); + + index[0] = PFS_ID_0AREA; + index[1] = PFS_ID_1AREA; + index[2] = PFS_ID_2AREA; + index[3] = PFS_ID_3AREA; + for (i = 0; i < 4; i++) { + if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, PFS_FORCE)) != 0) { + return ret; + } + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) { + return ret; + } + for (i = 0; i < BLOCKSIZE; i++) { + if (temp[i] != *(u8*)((s32)newid + i)) { + return PFS_ERR_DEVICE; + } + } + return 0; +} + +s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check) { + u16 index[4]; + s32 ret = 0; + u16 sum; + u16 idSum; + s32 i; + s32 j; + + if ((pfs->activebank != 0) && (ret = __osPfsSelectBank(pfs, 0)) != 0) { + return ret; + } + + index[0] = PFS_ID_0AREA; + index[1] = PFS_ID_1AREA; + index[2] = PFS_ID_2AREA; + index[3] = PFS_ID_3AREA; + for (i = 1; i < 4; i++) { + if ((ret = __osContRamRead(pfs->queue, pfs->channel, index[i], (u8*)check)) != 0) { + return ret; + } + __osIdCheckSum((u16*)check, &sum, &idSum); + if ((check->checksum == sum) && (check->invertedChecksum == idSum)) { + break; + } + } + if (i == 4) { + return PFS_ERR_ID_FATAL; + } + + for (j = 0; j < 4; j++) { + if (j != i) { + if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)check, PFS_FORCE)) != 0) { + return ret; + } + } + } + return 0; +} + +s32 __osGetId(OSPfs* pfs) { + u16 sum; + u16 isum; + u8 temp[BLOCKSIZE]; + __OSPackId* id; + __OSPackId newid; + s32 ret; + + if (pfs->activebank != 0) { + if ((ret = __osPfsSelectBank(pfs, 0)) != 0) { + return ret; + } + } + + if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) { + return ret; + } + + __osIdCheckSum((u16*)temp, &sum, &isum); + id = (__OSPackId*)temp; + if ((id->checksum != sum) || (id->invertedChecksum != isum)) { + if ((ret = __osCheckPackId(pfs, id)) == PFS_ERR_ID_FATAL) { + ret = __osRepairPackId(pfs, id, &newid); + if (ret) { + return ret; + } + id = &newid; + } else if (ret != 0) { + return ret; + } + } + + if ((id->deviceid & 0x01) == 0) { + ret = __osRepairPackId(pfs, id, &newid); + if (ret) { + return ret; + } + id = &newid; + if ((id->deviceid & 0x01) == 0) { + return PFS_ERR_DEVICE; + } + } + + bcopy(id, pfs->id, BLOCKSIZE); + + if (0) {} + + pfs->version = id->version; + + pfs->banks = id->banks; + pfs->inodeStartPage = 1 + DEF_DIR_PAGES + (2 * pfs->banks); + pfs->dir_size = DEF_DIR_PAGES * PFS_ONE_PAGE; + pfs->inode_table = 1 * PFS_ONE_PAGE; + pfs->minode_table = (1 + pfs->banks) * PFS_ONE_PAGE; + pfs->dir_table = pfs->minode_table + (pfs->banks * PFS_ONE_PAGE); + + if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_LABEL_AREA, pfs->label)) != 0) { + return ret; + } + + return 0; +} + +s32 __osCheckId(OSPfs* pfs) { + u8 temp[BLOCKSIZE]; + s32 ret; + + if (pfs->activebank != 0) { + ret = __osPfsSelectBank(pfs, 0); + if (ret == PFS_ERR_NEW_PACK) { + ret = __osPfsSelectBank(pfs, 0); + } + if (ret != 0) { + return ret; + } + } + + if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) { + if (ret != PFS_ERR_NEW_PACK) { + return ret; + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) { + return ret; + } + } + + if (bcmp(pfs->id, temp, BLOCKSIZE) != 0) { + return PFS_ERR_NEW_PACK; + } + + return 0; +} + +s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) { + u8 sum; + s32 j; + s32 ret; + s32 offset; + u8* addr; + + if (flag == PFS_READ && bank == __osPfsInodeCacheBank && (pfs->channel == __osPfsInodeCacheChannel)) { + bcopy(&__osPfsInodeCache, inode, sizeof(__OSInode)); + return 0; + } + + if ((pfs->activebank != 0) && (ret = __osPfsSelectBank(pfs, 0)) != 0) { + return ret; + } + + offset = ((bank > 0) ? 1 : pfs->inodeStartPage); + + if (flag == PFS_WRITE) { + inode->inodePage[0].inode_t.page = + __osSumcalc((u8*)(inode->inodePage + offset), (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + } + + for (j = 0; j < PFS_ONE_PAGE; j++) { + addr = (u8*)(((u8*)inode) + (j * BLOCKSIZE)); + if (flag == PFS_WRITE) { + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + (bank * PFS_ONE_PAGE) + j, addr, 0); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + (bank * PFS_ONE_PAGE) + j, addr, 0); + } else { + ret = __osContRamRead(pfs->queue, pfs->channel, pfs->inode_table + (bank * PFS_ONE_PAGE) + j, addr); + } + if (ret) { + return ret; + } + } + + if (flag == PFS_READ) { + sum = __osSumcalc((u8*)(inode->inodePage + offset), (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + if (sum != inode->inodePage[0].inode_t.page) { + for (j = 0; j < PFS_ONE_PAGE; j++) { + addr = (u8*)(((u8*)inode) + (j * BLOCKSIZE)); + ret = __osContRamRead(pfs->queue, pfs->channel, pfs->minode_table + (bank * PFS_ONE_PAGE) + j, addr); + } + sum = __osSumcalc((u8*)(inode->inodePage + offset), (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + if (sum != inode->inodePage[0].inode_t.page) { + return PFS_ERR_INCONSISTENT; + } + for (j = 0; j < PFS_ONE_PAGE; j++) { + addr = (u8*)(((u8*)inode) + (j * BLOCKSIZE)); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + (bank * PFS_ONE_PAGE) + j, addr, 0); + } + } + } + __osPfsInodeCacheBank = bank; + bcopy(inode, &__osPfsInodeCache, sizeof(__OSInode)); + __osPfsInodeCacheChannel = pfs->channel; + + return 0; +} diff --git a/src/libultra/io/devmgr.c b/src/libultra/io/devmgr.c index 0a5d7e0bb..c0f69c456 100644 --- a/src/libultra/io/devmgr.c +++ b/src/libultra/io/devmgr.c @@ -1,3 +1,104 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/devmgr/__osDevMgrMain.s") +void __osDevMgrMain(void* arg) { + OSIoMesg* ioMesg; + OSMesg sp70; + OSMesg sp6C; // "dummy" + s32 ret; + OSDevMgr* devMgr; + s32 msgVar = 0; + + devMgr = (OSDevMgr*)arg; + ioMesg = NULL; + ret = 0; + + while (true) { + osRecvMesg(devMgr->cmdQueue, (OSMesg)&ioMesg, OS_MESG_BLOCK); + if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == 2) && + ((ioMesg->piHandle->transferInfo.cmdType == OS_READ) || + (ioMesg->piHandle->transferInfo.cmdType == OS_WRITE))) { + __OSBlockInfo* block; + __OSTranxInfo* transfer; + + transfer = &ioMesg->piHandle->transferInfo; + block = &transfer->block[transfer->blockNum]; + transfer->sectorNum = -1; + if (transfer->transferMode != 3) { + block->dramAddr = (void*)((u32)block->dramAddr - block->sectorSize); + } + + if ((transfer->transferMode == 2) && (ioMesg->piHandle->transferInfo.cmdType == OS_READ)) { + msgVar = 1; + } else { + msgVar = 0; + } + + osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK); + __osResetGlobalIntMask(0x00100401); + __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x80000000); + + label: + osRecvMesg(devMgr->evtQueue, &sp70, OS_MESG_BLOCK); + transfer = &ioMesg->piHandle->transferInfo; + block = &transfer->block[transfer->blockNum]; + if (block->errStatus == 0x1D) { + u32 status; + + __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x10000000); + __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow); + __osEPiRawReadIo(ioMesg->piHandle, 0x05000508, &status); + if (status & 0x02000000) { + __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x1000000); + } + block->errStatus = 4; + HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; + __osSetGlobalIntMask(0x00100C01); + } + osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK); + + if ((msgVar == 1) && (ioMesg->piHandle->transferInfo.block[0].errStatus == 0)) { + msgVar = 0; + goto label; + } + + osSendMesg(devMgr->acsQueue, NULL, OS_MESG_NOBLOCK); + if (ioMesg->piHandle->transferInfo.blockNum == 1) { + osYieldThread(); + } + } else { + switch (ioMesg->hdr.type) { + case 11: + osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK); + ret = devMgr->piDmaCallback(OS_READ, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size); + break; + case 12: + osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK); + ret = devMgr->piDmaCallback(OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size); + break; + case 15: + osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK); + ret = devMgr->epiDmaCallback(ioMesg->piHandle, OS_READ, ioMesg->devAddr, ioMesg->dramAddr, + ioMesg->size); + break; + case 16: + osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK); + ret = devMgr->epiDmaCallback(ioMesg->piHandle, OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, + ioMesg->size); + break; + case 10: + osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); + ret = -1; + break; + default: + ret = -1; + break; + } + + if (ret == 0) { + osRecvMesg(devMgr->evtQueue, &sp70, OS_MESG_BLOCK); + osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); + osSendMesg(devMgr->acsQueue, NULL, OS_MESG_NOBLOCK); + } + } + } +} diff --git a/src/libultra/io/epilinkhandle.c b/src/libultra/io/epilinkhandle.c index 59efbc66e..bedd6d71c 100644 --- a/src/libultra/io/epilinkhandle.c +++ b/src/libultra/io/epilinkhandle.c @@ -1,3 +1,12 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epilinkhandle/osEPiLinkHandle.s") +s32 osEPiLinkHandle(OSPiHandle* handle) { + u32 saveMask = __osDisableInt(); + + handle->next = __osPiTable; + __osPiTable = handle; + + __osRestoreInt(saveMask); + + return 0; +} diff --git a/src/libultra/io/epirawdma.c b/src/libultra/io/epirawdma.c index e6ee17d5f..f9e2e0f97 100644 --- a/src/libultra/io/epirawdma.c +++ b/src/libultra/io/epirawdma.c @@ -1,3 +1,3 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawdma/osEPiRawStartDma.s") +#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawdma/__osEPiRawStartDma.s") diff --git a/src/libultra/io/epirawread.c b/src/libultra/io/epirawread.c index 0a175189e..e910cee4d 100644 --- a/src/libultra/io/epirawread.c +++ b/src/libultra/io/epirawread.c @@ -1,3 +1,3 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawread/osEPiRawReadIo.s") +#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawread/__osEPiRawReadIo.s") diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c new file mode 100644 index 000000000..25254c61b --- /dev/null +++ b/src/libultra/io/motor.c @@ -0,0 +1,120 @@ +#include "ultra64.h" +#include "global.h" + +#define BANK_ADDR 0x400 +#define MOTOR_ID 0x80 + +s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); + +s32 osSetRumble(OSPfs* pfs, u32 vibrate) { + s32 i; + s32 ret; + u8* buf = (u8*)&osPifBuffers[pfs->channel]; + + if (!(pfs->status & 8)) { + return 5; + } + + __osSiGetAccess(); + osPifBuffers[pfs->channel].pifstatus = 1; + buf += pfs->channel; + for (i = 0; i < BLOCKSIZE; i++) { + ((__OSContRamReadFormat*)buf)->data[i] = vibrate; + } + + __osContLastCmd = CONT_CMD_END; + __osSiRawStartDma(OS_WRITE, &osPifBuffers[pfs->channel]); + osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &osPifBuffers[pfs->channel]); + osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); + + ret = ((__OSContRamReadFormat*)buf)->rxsize & 0xC0; + if (!ret) { + if (!vibrate) { + if (((__OSContRamReadFormat*)buf)->datacrc != 0) { + ret = PFS_ERR_CONTRFAIL; + } + } else { + if (((__OSContRamReadFormat*)buf)->datacrc != 0xEB) { + ret = PFS_ERR_CONTRFAIL; + } + } + } + + __osSiRelAccess(); + + return ret; +} +void osSetUpMempakWrite(u32 channel, OSPifRam* buf) { + u8* bufptr = (u8*)buf; + __OSContRamReadFormat mempakwr; + u32 i; + + mempakwr.dummy = 0xFF; + mempakwr.txsize = 0x23; + mempakwr.rxsize = 1; + mempakwr.cmd = 3; // write mempak + mempakwr.hi = 0x600 >> 3; + mempakwr.lo = (u8)(__osContAddressCrc(0x600) | (0x600 << 5)); + + if (channel != 0) { + for (i = 0; i < channel; i++) { + *bufptr++ = 0; + } + } + + *(__OSContRamReadFormat*)bufptr = mempakwr; + bufptr += sizeof(mempakwr); + *bufptr = 0xFE; +} + +s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { + s32 ret; + u8 sp24[BLOCKSIZE]; + + pfs->queue = ctrlrqueue; + pfs->channel = channel; + pfs->activebank = 0xFF; + pfs->status = 0; + + ret = __osPfsSelectBank(pfs, 0xFE); + if (ret == 2) { + ret = __osPfsSelectBank(pfs, MOTOR_ID); + } + if (ret != 0) { + return ret; + } + ret = __osContRamRead(ctrlrqueue, channel, 0x400, sp24); + if (ret == 2) { + ret = 4; // "Controller pack communication error" + } + if (ret != 0) { + return ret; + } + if (sp24[BLOCKSIZE - 1] == 0xFE) { + return 0xB; + } + ret = __osPfsSelectBank(pfs, MOTOR_ID); + if (ret == 2) { + ret = 4; // "Controller pack communication error" + } + if (ret != 0) { + return ret; + } + ret = __osContRamRead(ctrlrqueue, channel, BANK_ADDR, sp24); + if (ret == 2) { + ret = 4; // "Controller pack communication error" + } + if (ret != 0) { + return ret; + } + if (sp24[BLOCKSIZE - 1] != MOTOR_ID) { + return 0xB; + } + if ((pfs->status & PFS_MOTOR_INITIALIZED) == 0) { + osSetUpMempakWrite(channel, &osPifBuffers[channel]); + } + pfs->status = PFS_MOTOR_INITIALIZED; + + return 0; // "Recognized rumble pak" +} diff --git a/src/libultra/io/pimgr.c b/src/libultra/io/pimgr.c index f5081c050..74b1075a1 100644 --- a/src/libultra/io/pimgr.c +++ b/src/libultra/io/pimgr.c @@ -31,9 +31,9 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC __osPiDevMgr.cmdQueue = cmdQ; __osPiDevMgr.evtQueue = &D_8009E3D0; __osPiDevMgr.acsQueue = &__osPiAccessQueue; - __osPiDevMgr.piDmaCallback = osPiRawStartDma; - __osPiDevMgr.epiDmaCallback = osEPiRawStartDma; - osCreateThread(&D_8009D220, 0, __osDevMgrMain, &__osPiDevMgr, &piManagerStack[0x1000], pri); + __osPiDevMgr.piDmaCallback = __osPiRawStartDma; + __osPiDevMgr.epiDmaCallback = __osEPiRawStartDma; + osCreateThread(&D_8009D220, 0, __osDevMgrMain, (void*)&__osPiDevMgr, &piManagerStack[4096], pri); osStartThread(&D_8009D220); __osRestoreInt(savedMask); if (oldPri != -1) { diff --git a/src/libultra/io/pirawdma.c b/src/libultra/io/pirawdma.c index b133fadf5..242a91c24 100644 --- a/src/libultra/io/pirawdma.c +++ b/src/libultra/io/pirawdma.c @@ -1,6 +1,6 @@ #include "global.h" -s32 osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) { +s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size) { register int stat; stat = *(vu32*)0xA4600010; diff --git a/src/libultra/io/sprawdma.c b/src/libultra/io/sprawdma.c index 01e944c5f..95395a29d 100644 --- a/src/libultra/io/sprawdma.c +++ b/src/libultra/io/sprawdma.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, u32 size) { +s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) { if (__osSpDeviceBusy() != 0) { return -1; } diff --git a/src/libultra/libc/string.c b/src/libultra/libc/string.c index 5f085f677..b23bf564d 100644 --- a/src/libultra/libc/string.c +++ b/src/libultra/libc/string.c @@ -1,4 +1,4 @@ -#include "string.h" +#include "global.h" const char* strchr(const char* s, int c) { const unsigned char ch = c; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 4f9b88118..62bac2109 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -300,14 +300,14 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - SysMatrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); - SysMatrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); - SysMatrix_MultiplyVector3fByState(&D_808C1C34, &sp50); + Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); + Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); + Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); this->unk1C4 = 0; } else { - SysMatrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); - SysMatrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); - SysMatrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); + Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); + Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); + Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); } func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); @@ -315,13 +315,13 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_0601D960); - SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); sp48 = SQXZ(sp68); sp4C = sqrtf(SQXZ(sp68)); Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); + Matrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); f0 = sqrtf(SQ(sp68.y) + sp48); Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 9d61ca292..ed513eef3 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -200,11 +200,10 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, - MTXMODE_NEW); + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits @@ -222,14 +221,14 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); - SysMatrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - SysMatrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - SysMatrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, sIceArrowDL); gSPDisplayList(POLY_XLU_DISP++, diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index c2554ec61..18b8a343c 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -90,14 +90,14 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { rotZ = this->dyna.actor.shape.rot.z & 0x1FFF; if ((flags != 0) && (rotZ < 0x1B58) && (rotZ >= 0x1388)) { Matrix_RotateY(this->dyna.actor.home.rot.y, 0); - SysMatrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1); - SysMatrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1); + Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1); + Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1); for (i = 0; i < 4; i++) { if ((u32)Rand_Next() >= 0x40000000) { splashOffset.x = D_80AD3270[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = D_80AD3270[i].y; splashOffset.z = D_80AD3270[i].z; - SysMatrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); @@ -108,14 +108,14 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { if ((rotZ < 0x1F4) && (rotZ >= 0)) { if (flags != 0) { Matrix_RotateY(this->dyna.actor.home.rot.y, 0); - SysMatrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1); - SysMatrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1); + Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1); + Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1); for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { splashOffset.x = D_80AD32A0[i].x + (Rand_ZeroOne() * 10.0f); splashOffset.y = D_80AD32A0[i].y; splashOffset.z = D_80AD32A0[i].z; - SysMatrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 9a6d2348b..34ad8fb1f 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -116,9 +116,9 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_NEW); - SysMatrix_InsertXRotation_s(this->dyna.actor.world.rot.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->dyna.actor.world.rot.z, MTXMODE_APPLY); - SysMatrix_MultiplyVector3fByState(&D_80BD68A4, &vec); + Matrix_InsertXRotation_s(this->dyna.actor.world.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.world.rot.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80BD68A4, &vec); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &vec, &this->dyna.actor.focus.pos); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 691cf9992..453bd919c 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -234,7 +234,7 @@ BgHakuginPostUnkStruct1* func_80A9B32C(BgHakuginPostUnkStruct* unkStruct, BgHaku } void func_80A9B384(Vec3f* arg0) { - MtxF* matrix = SysMatrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrentState(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -1013,8 +1013,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); for (i = 0; i < D_80A9E028.count; i++) { @@ -1035,8 +1035,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80A9E028.unk_02A4); i++) { unkStruct2 = &D_80A9E028.unk_02A4[i]; if (unkStruct2->unk_2C > 0) { - SysMatrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, - unkStruct2->unk_04.z, &unkStruct2->unk_20); + Matrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, + &unkStruct2->unk_20); Matrix_Scale(unkStruct2->unk_00, unkStruct2->unk_00, unkStruct2->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index a9ce12ce9..2d1fb8ca2 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -138,11 +138,11 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s Vec3f sp58; s32 pad[2]; - SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); for (i = 0; i < 2; i++) { - SysMatrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); + Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &D_801D15B0, &D_801D15B0, &primColor, &envColor, 6000, -10); } } @@ -156,9 +156,9 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000908); Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); - SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, 1); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { Collider_UpdateSpheres(i, &this->collider); diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 2b7492754..1e36f9e29 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -72,7 +72,7 @@ void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { DmNb* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06008C40, NULL, this->limbDrawTable, this->transitionDrawTable, 8); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008C40, NULL, this->jointTable, this->morphTable, 8); this->unk1F0 = -1; func_80C1DED0(this, 0); this->actor.flags &= ~1; @@ -87,17 +87,17 @@ void DmNb_Update(Actor* thisx, GlobalContext* globalCtx) { DmNb* this = THIS; this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 0x4); + SkelAnime_Update(&this->skelAnime); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } -void DmNb_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* actor) { +void DmNb_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { } void DmNb_Draw(Actor* thisx, GlobalContext* globalCtx) { DmNb* this = THIS; func_8012C5B0(globalCtx->state.gfxCtx); - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, DmNb_UnkActorDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h index f31d0c3de..a417ea070 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h @@ -11,8 +11,8 @@ typedef struct DmNb { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ DmNbActionFunc actionFunc; - /* 0x18C */ Vec3s limbDrawTable[8]; - /* 0x1BC */ Vec3s transitionDrawTable[8]; + /* 0x18C */ Vec3s jointTable[8]; + /* 0x1BC */ Vec3s morphTable[8]; /* 0x1EC */ u8 unk1EC; /* 0x1F0 */ s32 unk1F0; /* 0x1F4 */ s32 unk1F4; diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index b5ddf40a0..02101b113 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -33,12 +33,12 @@ void func_80A2E960(SkelAnime* arg0, ActorAnimationEntry* animations, u16 index) animations += index; if (animations->frameCount < 0.0f) { - frameCount = SkelAnime_GetFrameCount(&animations->animation->common); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - SkelAnime_ChangeAnim(arg0, animations->animation, animations->playSpeed, animations->startFrame, frameCount, - animations->mode, animations->morphFrames); + Animation_Change(arg0, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -48,7 +48,7 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013328, NULL, 0, 0, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, 0, 0, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; @@ -63,7 +63,7 @@ void DmSa_DoNothing(DmSa* this, GlobalContext* globalCtx) { void DmSa_Update(Actor* thisx, GlobalContext* globalCtx) { DmSa* this = THIS; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->alpha += 0; this->actionFunc(this, globalCtx); } @@ -114,7 +114,7 @@ void DmSa_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, func_80A2EBB0(globalCtx->state.gfxCtx, this->alpha)); } - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80A2EB10, func_80A2EB2C, func_80A2EB44, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index bfb2cc728..3ca55d7b8 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -281,14 +281,14 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->distanceTraveled); i++) { if (*distanceTraveled < 1.0f) { aux = 1.0f - SQ(*distanceTraveled); - SysMatrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_RotateY(sp92, MTXMODE_APPLY); - SysMatrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), - initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); - Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, 1); + Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), + initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); + Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -337,15 +337,15 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (*distanceTraveled * 255.0f)); aux = 1.0f - SQ(*distanceTraveled); - SysMatrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); - SysMatrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, - (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); + Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, + (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index b054b20e8..d9bb0f9fc 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -69,7 +69,7 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->paramCopy = this->actor.params; if (this->actor.params == 0) { @@ -103,9 +103,9 @@ void EnBaisen_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnBaisen_ChangeAnimation(EnBaisen* this, s32 animIndex) { this->animIndex = animIndex; - this->frameCount = SkelAnime_GetFrameCount(&D_80BE8E4C[animIndex]->common); - SkelAnime_ChangeAnim(&this->skelAnime, D_80BE8E4C[this->animIndex], 1.0f, 0.0f, this->frameCount, - animModes[this->animIndex], -10.0f); + this->frameCount = Animation_GetLastFrame(D_80BE8E4C[animIndex]); + Animation_Change(&this->skelAnime, D_80BE8E4C[this->animIndex], 1.0f, 0.0f, this->frameCount, + animModes[this->animIndex], -10.0f); } void func_80BE871C(EnBaisen* this) { @@ -201,7 +201,7 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { } if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) || (globalCtx->msgCtx.unk11F04 == 0x2AC8)) { - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } if (this->unk2AC == 2) { // Note: This variable is only ever set to 1. @@ -244,7 +244,7 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnBaisen* this = THIS; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unusedCounter != 0) { this->unusedCounter--; } @@ -284,6 +284,6 @@ void EnBaisen_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnBaisen_OverrideLimbDraw, NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBaisen_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index a639a10b8..2cb90b98d 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -74,8 +74,6 @@ void EnBigpo_WaitingForDampe(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_RevealedFireGrowing(EnBigpo* this, GlobalContext* globalCtx); // draw funcs -void EnBigpo_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* actor, - Gfx** gfx); void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx); void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx); void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx); @@ -404,7 +402,7 @@ void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx) { * big poe starts to visibly appear */ void EnBigpo_SpawnCutsceneStage5(EnBigpo* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06001360); + Animation_PlayLoop(&this->skelAnime, &D_06001360); this->actor.draw = EnBigpo_DrawMainBigpo; Actor_SetScale(&this->actor, 0.014f); Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); @@ -419,7 +417,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { s32 i; s32 alphaPlus; // color alpha + 10 - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y += this->rotVelocity; alphaPlus = this->mainColor.a + 10; // decrease transparency func_80B61914(this); @@ -466,7 +464,7 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { Actor* dampe; Camera* subCam; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->idleTimer--; if (this->idleTimer == 0) { subCam = Play_GetCamera(globalCtx, this->cutsceneSubCamId); @@ -518,7 +516,7 @@ void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06001360); + Animation_PlayLoop(&this->skelAnime, &D_06001360); this->rotVelocity = 0x2000; this->actor.world.pos.x = (Math_SinS(randomYaw) * distance) + player->actor.world.pos.x; this->actor.world.pos.z = (Math_CosS(randomYaw) * distance) + player->actor.world.pos.z; @@ -545,7 +543,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupIdleFlying(EnBigpo* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000924, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000924, -5.0f); // if poe missed attack, idle 4 seconds, otherwise its reappearing: attack immediately this->idleTimer = (this->actionFunc == EnBigpo_SpinningDown) ? 80 : 0; this->hoverHeightCycleTimer = 40; @@ -561,7 +559,7 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); DECR(this->idleTimer); // flight position calculations @@ -596,7 +594,7 @@ void EnBigpo_SetupSpinUp(EnBigpo* this) { } void EnBigpo_SpinningUp(EnBigpo* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->rotVelocity += 0x200; EnBigpo_UpdateSpin(this); if (this->rotVelocity >= 0x3C00) { @@ -614,7 +612,7 @@ void EnBigpo_SpinAttack(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 yawDiff; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_StepToF(&this->actor.speedXZ, 10.0f, 1.0f); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 0.3f, 7.5f, 1.0f); EnBigpo_UpdateSpin(this); @@ -638,7 +636,7 @@ void EnBigpo_SetupSpinDown(EnBigpo* this) { void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 100.0f, 0.3f, 5.0f, 1.0f); Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (Math_ScaledStepToS(&this->rotVelocity, 0, 0x200)) { @@ -656,7 +654,7 @@ void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { * called by EnBigpo_ApplyDamage */ void EnBigpo_HitStun(EnBigpo* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06000454, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000454, -6.0f); func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 0x10); this->collider.base.acFlags &= ~AC_ON; func_800BE504(&this->actor, &this->collider); @@ -669,7 +667,7 @@ void EnBigpo_HitStun(EnBigpo* this) { */ void EnBigpo_CheckHealth(EnBigpo* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { EnBigpo_SetupDeath(this); } else { @@ -1231,8 +1229,8 @@ void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } -s32 EnBigpo_OverrideLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - struct Actor* actor, Gfx** gfx) { +s32 EnBigpo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor, + Gfx** gfx) { EnBigpo* this = (EnBigpo*)actor; // not fully invisible if (!(this->mainColor.a != 0 && limbIndex != 7) || @@ -1259,36 +1257,37 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 7) { // we scale the vec3f... then do nothing with it? - SysMatrix_GetStateTranslationAndScaledY(1400.0f, &unusedVec); + Matrix_GetStateTranslationAndScaledY(1400.0f, &unusedVec); if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer > 18)) { - if (actor->scale.x != 0.0f) { - Matrix_Scale(0.014f / actor->scale.x, 0.014f / actor->scale.x, 0.014f / actor->scale.x, 1); + if (this->actor.scale.x != 0.0f) { + Matrix_Scale(0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, + 1); } } - SysMatrix_CopyCurrentState(&this->drawMtxF); + Matrix_CopyCurrentState(&this->drawMtxF); } limbByte = D_80B65078[limbIndex]; if (limbByte != -1) { if (limbByte < 3) { - SysMatrix_GetStateTranslation(&this->limbPos[limbByte]); + Matrix_GetStateTranslation(&this->limbPos[limbByte]); return; } if (limbByte == 3) { - SysMatrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); + Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); return; } if (limbByte == 4) { - SysMatrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); + Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); return; } v2ptr = &this->limbPos[limbByte + 1]; v1ptr = D_80B65084; - SysMatrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); + Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - SysMatrix_MultiplyVector3fByState(v1ptr, v2ptr); + Matrix_MultiplyVector3fByState(v1ptr, v2ptr); v2ptr++; v1ptr++; } @@ -1310,8 +1309,8 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&dispHead[2], 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); - POLY_OPA_DISP = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); } else { dispHead = POLY_XLU_DISP; @@ -1320,15 +1319,15 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&dispHead[2], 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); - POLY_XLU_DISP = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnBigpo_OverrideLimbDraw, EnBigpo_PostLimbDraw, &this->actor, &dispHead[3]); } // 71.428566f might be 500/7 context unknown func_800BE680(globalCtx, &this->actor, this->limbPos, 9, this->actor.scale.x * 71.428566f * this->unk220, 0, this->unk21C, 0x14); - SysMatrix_SetCurrentState(&this->drawMtxF); + Matrix_SetCurrentState(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { EnBigpo_DrawCircleFlames(&this->actor, globalCtx); @@ -1404,7 +1403,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - SysMatrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); @@ -1433,7 +1432,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { MtxF* mtfxPtr; s32 i; - mtfxPtr = SysMatrix_GetCurrentState(); + mtfxPtr = Matrix_GetCurrentState(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 5cce23a9c..45370609b 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -26,9 +26,8 @@ void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx); void func_809CD70C(EnBji01* this, GlobalContext* globalCtx); void func_809CD77C(EnBji01* this, GlobalContext* globalCtx); -s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* actor); -void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); +s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg); +void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg); extern AnimationHeader D_06000FDC; extern AnimationHeader D_06005B58; @@ -297,7 +296,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { func_809CCE98(this, globalCtx); break; } - if ((this->animationIndex == 3) && (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount)) { + if ((this->animationIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); } } @@ -339,8 +338,8 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { EnBji01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600578C, &D_06000FDC, this->jointTable, this->morphTable, - BJI_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600578C, &D_06000FDC, this->jointTable, this->morphTable, + BJI_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -386,7 +385,7 @@ void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, (Actor*)this, 0.0f, 0.0f, 0.0f, 4U); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->blinkTimer-- <= 0) { if (--this->blinkSeqIndex < 0) { @@ -438,7 +437,7 @@ void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, sp20.x += temp_f4 * 0.1f; sp20.y += temp_f4 * 0.1f; sp20.z += temp_f4 * 0.1f; - SysMatrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); } } @@ -449,7 +448,7 @@ void EnBji01_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnBji01_OverrideLimbDraw, EnBji01_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBji01_OverrideLimbDraw, EnBji01_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index ad001d6e0..8a7d39086 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -47,11 +47,11 @@ void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0); - SysMatrix_InsertZRotation_s(this->actor.shape.rot.z, 1); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); Matrix_RotateY(this->actor.shape.rot.y, 1); - SysMatrix_InsertXRotation_s(this->actor.shape.rot.x, 1); - Matrix_Scale(0.01f, 0.01f, 0.01f, 1); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 1df7f22e1..9a1280c29 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -118,7 +118,7 @@ void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; func_800BDFC0(globalCtx, D_06000710); - SysMatrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, 1); - SysMatrix_InsertXRotation_s(this->actor.home.rot.x, 1); + Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.home.rot.x, 1); func_800BDFC0(globalCtx, D_06000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index e0c520f9f..b7ad8e6f3 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -416,9 +416,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 54; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - SysMatrix_InsertYRotation_f(Rand_ZeroFloat(M_PI * 2), 0); - SysMatrix_RotateStateAroundXAxis(Rand_ZeroFloat(M_PI * 2)); - SysMatrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_InsertYRotation_f(Rand_ZeroFloat(M_PI * 2), 0); + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(M_PI * 2)); + Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -489,9 +489,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { pos = this->actor.world.pos; for (i = 0; i < 44; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - SysMatrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), 0); - SysMatrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - SysMatrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), 0); + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); + Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -798,10 +798,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - SysMatrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - SysMatrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - SysMatrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(effect->rotationX); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL); } @@ -817,7 +817,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); - SysMatrix_SetCurrentState(&mtxF); + Matrix_SetCurrentState(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_04030100); @@ -842,7 +842,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, &mtxF); - SysMatrix_SetCurrentState(&mtxF); + Matrix_SetCurrentState(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL); @@ -870,10 +870,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - SysMatrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); } @@ -896,8 +896,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - SysMatrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); @@ -918,8 +918,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - SysMatrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL); @@ -943,12 +943,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - SysMatrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - SysMatrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - SysMatrix_RotateStateAroundXAxis(effect->rotationX); - SysMatrix_InsertZRotation_f(effect->rotationZ, MTXMODE_APPLY); + Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_InsertZRotation_f(effect->rotationZ, MTXMODE_APPLY); Matrix_Scale(effect->scale * 0.5f, effect->scale * 0.5f, effect->maxScale * effect->scale, MTXMODE_APPLY); - SysMatrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_RotateStateAroundXAxis(M_PI / 2); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL); } @@ -968,8 +968,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Apply material 16 times along a circle to give the appearance of a splash for (j = 0; j < 16; j++) { - SysMatrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); - SysMatrix_GetStateTranslationAndScaledZ(effect->maxScale, &vec); + Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(effect->maxScale, &vec); /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * returns true if point is within the xz boundaries of an active water box, else false @@ -980,10 +980,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { &ySurface, &waterBox)) { if ((effect->position.y - ySurface) < 200.0f) { // Draw the splash effect. - SysMatrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, - MTXMODE_NEW); - SysMatrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); - SysMatrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, + MTXMODE_NEW); + Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_0403A0F0); diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 2bb487064..fb917742c 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -91,7 +91,7 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { isDisplayListSet = true; } - SysMatrix_StatePush(); + Matrix_StatePush(); alpha = (particle->unk_02 / (f32)particle->unk_01); alpha *= 255.0f; @@ -102,15 +102,15 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - SysMatrix_InsertTranslation(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_060002E8); - SysMatrix_StatePop(); + Matrix_StatePop(); } } @@ -280,8 +280,7 @@ s16 func_80B3E8BC(EnDai* this, s32 arg1) { } while (i < end) { - if ((D_80B3FCB4[i] <= this->skelAnime.animCurrentFrame) && - (D_80B3FCE4[i] >= this->skelAnime.animCurrentFrame)) { + if ((D_80B3FCB4[i] <= this->skelAnime.curFrame) && (D_80B3FCE4[i] >= this->skelAnime.curFrame)) { return D_80B3FD14[i]; } i++; @@ -297,7 +296,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { Vec3f sp50; if ((DECR(this->unk_1DA) == 0) && - ((this->unk_1DC == 0) || func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount))) { + ((this->unk_1DC == 0) || Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame))) { switch (this->unk_1DC) { case 0: func_80B3E5DC(this, 2); @@ -373,10 +372,10 @@ s32 func_80B3EC84(EnDai* this) { s32 ret = false; for (i = 0; i < ARRAY_COUNT(D_80B3FD6C); i++) { - if ((this->unk_1DC == D_80B3FD6C[i]) && (D_80B3FD2C[i] < this->skelAnime.animCurrentFrame) && - (D_80B3FD4C[i] >= this->skelAnime.animCurrentFrame)) { - func_80B3EC10(D_80B3FD2C[i], D_80B3FD7C[i], D_80B3FD4C[i], D_80B3FD7C[i + 1], - this->skelAnime.animCurrentFrame, &this->unk_1F0); + if ((this->unk_1DC == D_80B3FD6C[i]) && (D_80B3FD2C[i] < this->skelAnime.curFrame) && + (D_80B3FD4C[i] >= this->skelAnime.curFrame)) { + func_80B3EC10(D_80B3FD2C[i], D_80B3FD7C[i], D_80B3FD4C[i], D_80B3FD7C[i + 1], this->skelAnime.curFrame, + &this->unk_1F0); ret = true; break; } @@ -400,10 +399,10 @@ s32 func_80B3ED88(EnDai* this) { s32 ret = false; for (i = 0; i < ARRAY_COUNT(D_80B3FE00); i++) { - if ((this->unk_1DC == D_80B3FE00[i]) && (D_80B3FDE8[i] < this->skelAnime.animCurrentFrame) && - (D_80B3FDF4[i] >= this->skelAnime.animCurrentFrame)) { - func_80B3EC10(D_80B3FDE8[i], D_80B3FE08[i], D_80B3FDF4[i], D_80B3FE08[i + 1], - this->skelAnime.animCurrentFrame, &this->unk_1FC); + if ((this->unk_1DC == D_80B3FE00[i]) && (D_80B3FDE8[i] < this->skelAnime.curFrame) && + (D_80B3FDF4[i] >= this->skelAnime.curFrame)) { + func_80B3EC10(D_80B3FDE8[i], D_80B3FE08[i], D_80B3FDF4[i], D_80B3FE08[i + 1], this->skelAnime.curFrame, + &this->unk_1FC); ret = true; break; } @@ -496,24 +495,24 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 360) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); } - if (func_801378B8(&this->skelAnime, 43.0f)) { + if (Animation_OnFrame(&this->skelAnime, 43.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 3: - if (func_801378B8(&this->skelAnime, 6.0f)) { + if (Animation_OnFrame(&this->skelAnime, 6.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 4: - if (func_801378B8(&this->skelAnime, 30.0f)) { + if (Animation_OnFrame(&this->skelAnime, 30.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); } - if (func_801378B8(&this->skelAnime, 35.0f)) { + if (Animation_OnFrame(&this->skelAnime, 35.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_0); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); @@ -527,7 +526,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { EnDai* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060130D0, NULL, this->jointTable, this->morphTable, 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060130D0, NULL, this->jointTable, this->morphTable, 19); this->unk_A70 = -1; func_80B3E5DC(this, 0); Actor_SetScale(&this->actor, 0.2f); @@ -567,13 +566,13 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { if (!func_80B3E7C8(this, globalCtx) && func_80B3E69C(this, globalCtx)) { func_80B3F044(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B3E834(this); func_80B3E460(this); } else { this->actionFunc(this, globalCtx); if (!(player->stateFlags2 & 0x8000000)) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, 0, this->unk_1CE & 7); @@ -592,7 +591,7 @@ s32 func_80B3F598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } if (limbIndex == 11) { - SysMatrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_1E4); + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_1E4); } if (limbIndex == 10) { @@ -614,15 +613,15 @@ void func_80B3F614(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* D_80B3FE4C.x = sREG(0); D_80B3FE4C.y = sREG(1); D_80B3FE4C.z = sREG(2); - SysMatrix_MultiplyVector3fByState(&D_80B3FE4C, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_80B3FE4C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - SysMatrix_CopyCurrentState(&sp24); + Matrix_CopyCurrentState(&sp24); func_8018219C(&sp24, &sp64, 0); this->unk_1D4 = BINANG_SUB(sp64.y, 0x4000); break; case 10: - SysMatrix_CopyCurrentState(&this->unk_18C); + Matrix_CopyCurrentState(&this->unk_18C); break; } } @@ -671,10 +670,10 @@ void func_80B3F78C(EnDai* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE58[this->unk_1D6])); POLY_XLU_DISP = - func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B3F598, func_80B3F614, func_80B3F6EC, &this->actor, POLY_XLU_DISP); if (this->unk_1CE & 0x40) { - SysMatrix_SetCurrentState(&this->unk_18C); + Matrix_SetCurrentState(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_0600C538); @@ -703,9 +702,9 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE70[this->unk_1D6])); POLY_OPA_DISP = - func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B3F598, func_80B3F614, func_80B3F6EC, &this->actor, POLY_OPA_DISP); - SysMatrix_SetCurrentState(&this->unk_18C); + Matrix_SetCurrentState(&this->unk_18C); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_0600C538); @@ -722,9 +721,9 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3FE70[this->unk_1D6])); POLY_XLU_DISP = - func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_8013AB00(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B3F598, func_80B3F614, func_80B3F6EC, &this->actor, POLY_XLU_DISP); - SysMatrix_SetCurrentState(&this->unk_18C); + Matrix_SetCurrentState(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_0600C538); diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index c07c78398..40eac8099 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -108,18 +108,18 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_27E = this->unk_278 * 4 + 4; case ENDAIKU_PARAMS_FF_1: - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, - 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, + this->morphTable, 17); break; case ENDAIKU_PARAMS_FF_2: - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_0600B690, this->jointTable, this->morphTable, - 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_0600B690, this->jointTable, + this->morphTable, 17); break; case ENDAIKU_PARAMS_FF_3: - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06001114, this->jointTable, this->morphTable, - 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06001114, this->jointTable, + this->morphTable, 17); break; } @@ -141,8 +141,8 @@ void func_8094373C(EnDaiku* this, s32 arg1) { 0, 0, 0, 0, 2, 0, 0, 2, 2, }; - this->unk_284 = SkelAnime_GetFrameCount(&D_809440A4[arg1]->common); - SkelAnime_ChangeAnim(&this->skelAnime, D_809440A4[arg1], 1.0f, 0.0f, this->unk_284, D_809440C8[arg1], -4.0f); + this->unk_284 = Animation_GetLastFrame(D_809440A4[arg1]); + Animation_Change(&this->skelAnime, D_809440A4[arg1], 1.0f, 0.0f, this->unk_284, D_809440C8[arg1], -4.0f); } void func_809437C8(EnDaiku* this) { @@ -179,7 +179,7 @@ void func_80943820(EnDaiku* this) { } void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.animCurrentFrame; + f32 currentFrame = this->skelAnime.curFrame; s32 pad; s32 day = gSaveContext.day - 1; s32 pad2; @@ -245,7 +245,7 @@ void func_80943BC0(EnDaiku* this) { } void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.animCurrentFrame; + f32 currentFrame = this->skelAnime.curFrame; if ((this->unk_278 == ENDAIKU_PARAMS_FF_2) && (this->unk_284 <= currentFrame)) { if (Rand_ZeroOne() < 0.5f) { @@ -266,7 +266,7 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; if (this->unk_27E == 0) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.day == 3) && (gSaveContext.isNight)) { @@ -353,8 +353,8 @@ void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_80943E18, func_80943E60, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80943E18, func_80943E60, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 9e34154a2..daa159788 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -96,7 +96,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); this->actor.targetMode = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); @@ -144,12 +144,12 @@ void func_80BE6408(EnDaiku2* this, s32 arg1) { f32 sp34 = 1.0f; this->unk_276 = arg1; - this->unk_284 = SkelAnime_GetFrameCount(&sAnimations[this->unk_276]->common); + this->unk_284 = Animation_GetLastFrame(sAnimations[this->unk_276]); if (this->unk_276 == 3) { sp34 = 2.0f; } - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[this->unk_276], sp34, 0.0f, this->unk_284, - D_80BE7958[this->unk_276], -4.0f); + Animation_Change(&this->skelAnime, sAnimations[this->unk_276], sp34, 0.0f, this->unk_284, D_80BE7958[this->unk_276], + -4.0f); } s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { @@ -212,7 +212,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { - f32 sp9C = this->skelAnime.animCurrentFrame; + f32 sp9C = this->skelAnime.curFrame; s32 sp98 = gSaveContext.day - 1; s32 i; Vec3f sp88; @@ -244,7 +244,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { } func_800B8614(&this->actor, globalCtx, 80.0f); - if ((this->unk_276 == 8) && func_801378B8(&this->skelAnime, 6.0f)) { + if ((this->unk_276 == 8) && Animation_OnFrame(&this->skelAnime, 6.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); for (i = 0; i < 10; i++) { @@ -274,8 +274,8 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { if ((this->unk_276 == 5) || (this->unk_276 == 9)) { func_80BE6408(this, 10); } else if ((this->unk_276 == 10) && (this->unk_284 <= sp9C)) { - this->unk_284 = SkelAnime_GetFrameCount(&D_06002134.common); - SkelAnime_ChangeAnim(&this->skelAnime, &D_06002134, -1.0f, this->unk_284, 0.0f, 2, -4.0f); + this->unk_284 = Animation_GetLastFrame(&D_06002134); + Animation_Change(&this->skelAnime, &D_06002134, -1.0f, this->unk_284, 0.0f, 2, -4.0f); this->unk_276 = 11; } else if ((this->unk_276 == 11) && (sp9C <= 0.0f)) { func_80BE6408(this, 8); @@ -371,7 +371,7 @@ void func_80BE6EB0(EnDaiku2* this) { } void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { - f32 sp5C = this->skelAnime.animCurrentFrame; + f32 sp5C = this->skelAnime.curFrame; s32 pad[4]; Vec3f sp40; s16 var; @@ -440,7 +440,7 @@ void func_80BE71A0(EnDaiku2* this) { } void func_80BE71D8(EnDaiku2* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.animCurrentFrame; + f32 currentFrame = this->skelAnime.curFrame; if (func_80BE64C0(this, globalCtx)) { func_80BE6CFC(this); @@ -457,7 +457,7 @@ void EnDaiku2_Update(Actor* thisx, GlobalContext* globalCtx) { EnDaiku2* this = THIS; s32 pad; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actionFunc(this, globalCtx); this->actor.shape.rot.y = this->actor.world.rot.y; Actor_SetHeight(&this->actor, 65.0f); @@ -496,8 +496,8 @@ void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 245, 155, 0, 255); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - EnDaiku2_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnDaiku2_PostLimbDraw, &this->actor); func_80BE7718(this, globalCtx); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -561,17 +561,17 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isEnabled) { - SysMatrix_StatePush(); - SysMatrix_InsertTranslation(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - SysMatrix_InsertXRotation_s(particle->unk_28.x, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(particle->unk_28.x, MTXMODE_APPLY); Matrix_RotateY(particle->unk_28.y, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(particle->unk_28.z, MTXMODE_APPLY); + Matrix_InsertZRotation_s(particle->unk_28.z, MTXMODE_APPLY); Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_060009E0); - SysMatrix_StatePop(); + Matrix_StatePop(); } } } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 69042a822..39acd872d 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -178,7 +178,7 @@ void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD428(EnDekunuts* this) { - SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, &D_06003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &D_06003180, 0.0f); this->unk_190 = Rand_S16Offset(100, 50); this->collider.dim.height = 5; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -189,7 +189,7 @@ void func_808BD428(EnDekunuts* this) { void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { s32 phi_v1 = false; - if (this->skelAnime.animPlaybackSpeed < 0.5f) { + if (this->skelAnime.playSpeed < 0.5f) { phi_v1 = true; } @@ -197,18 +197,18 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { this->unk_190--; } - if (func_801378B8(&this->skelAnime, 9.0f)) { + if (Animation_OnFrame(&this->skelAnime, 9.0f)) { this->collider.base.acFlags |= AC_ON; - } else if (func_801378B8(&this->skelAnime, 8.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); } - this->collider.dim.height = (s32)((CLAMP(this->skelAnime.animCurrentFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; + this->collider.dim.height = (s32)((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; if (!phi_v1 && (this->actor.params == ENDEKUNUTS_GET_FF00_0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.xzDistToPlayer < 120.0f)) { func_808BDC9C(this); - } else if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + } else if (SkelAnime_Update(&this->skelAnime)) { if (((this->unk_190 == 0) && (this->actor.xzDistToPlayer > 320.0f)) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK)) { func_808BD78C(this); @@ -228,19 +228,19 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { ((this->actor.params == ENDEKUNUTS_GET_FF00_2) && (this->actor.yDistToPlayer > -60.0f)) || (this->actor.params == ENDEKUNUTS_GET_FF00_1)) && ((this->unk_190 == 0) || (this->actor.xzDistToPlayer < 480.0f))) { - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } } void func_808BD78C(EnDekunuts* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06002FA4); + Animation_PlayLoop(&this->skelAnime, &D_06002FA4); this->unk_190 = 2; this->actionFunc = func_808BD7D4; } void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { this->unk_190--; } @@ -253,7 +253,7 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD870(EnDekunuts* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600326C, -3.0f); if (this->actionFunc == func_808BDA4C) { this->unk_190 = 4098; } else { @@ -263,8 +263,8 @@ void func_808BD870(EnDekunuts* this) { } void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { this->unk_190--; } @@ -292,7 +292,7 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDA08(EnDekunuts* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000168); + Animation_PlayOnce(&this->skelAnime, &D_06000168); this->unk_190 = this->unk_194; this->actionFunc = func_808BDA4C; } @@ -314,17 +314,17 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { sp58.y = player->actor.world.pos.y + 40.0f; pitch = Actor_PitchToPoint(&this->actor, &sp58); pitch = CLAMP(pitch, -0x3800, -0x2000); - if (this->skelAnime.animCurrentFrame < 7.0f) { + if (this->skelAnime.curFrame < 7.0f) { Math_ScaledStepToS(&this->actor.world.rot.x, pitch, 0x800); } else { Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0x800); } } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.x = 0; func_808BD870(this); - } else if (func_801378B8(&this->skelAnime, 7.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 7.0f)) { val = Math_CosS(this->actor.world.rot.x) * 15.0f; pos.x = (Math_SinS(this->actor.shape.rot.y) * val) + this->actor.world.pos.x; pos.y = (this->actor.world.pos.y + 12.0f) - (Math_SinS(this->actor.world.rot.x) * 15.0f); @@ -335,8 +335,8 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); } - } else if ((this->unk_190 >= 2) && func_801378B8(&this->skelAnime, 12.0f)) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06000168, -3.0f); + } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000168, -3.0f); if (this->unk_190 != 0) { this->unk_190--; } @@ -344,14 +344,14 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDC9C(EnDekunuts* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->unk_190 = 0; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } void func_808BDCF0(EnDekunuts* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); @@ -359,7 +359,7 @@ void func_808BDCF0(EnDekunuts* this) { } void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_190 != 0) { this->unk_190--; } @@ -368,10 +368,10 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { func_808BD428(this); } } else { - this->collider.dim.height = (s32)((3.0f - CLAMP(this->skelAnime.animCurrentFrame, 1.0f, 3.0f)) * 12.0f) + 5; + this->collider.dim.height = (s32)((3.0f - CLAMP(this->skelAnime.curFrame, 1.0f, 3.0f)) * 12.0f) + 5; } - if (func_801378B8(&this->skelAnime, 4.0f)) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->collider.base.acFlags &= ~AC_ON; } Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.5f, 3.0f); @@ -379,7 +379,7 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDE7C(EnDekunuts* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002DD4, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06002DD4, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); @@ -390,7 +390,7 @@ void func_808BDE7C(EnDekunuts* this) { } void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); this->unk_18D = 3; func_808BDF60(this); @@ -399,7 +399,7 @@ void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDF60(EnDekunuts* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06003780); + Animation_PlayLoop(&this->skelAnime, &D_06003780); this->unk_190 = 2; this->unk_18C = 0; this->collider.base.acFlags |= AC_ON; @@ -410,8 +410,8 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { s16 yaw; s16 yaw2; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { this->unk_190--; } @@ -456,7 +456,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE1CC(EnDekunuts* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060033E4); + Animation_PlayLoop(&this->skelAnime, &D_060033E4); this->unk_190 = 3; this->actor.speedXZ = 0.0f; if (this->unk_18D != 0) { @@ -466,8 +466,8 @@ void func_808BE1CC(EnDekunuts* this) { } void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { if (this->unk_190 != 0) { this->unk_190--; } @@ -479,7 +479,7 @@ void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE294(EnDekunuts* this, s32 arg1) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_0600259C, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600259C, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { this->actor.speedXZ = 10.0f; if (arg1 != 0) { @@ -492,12 +492,12 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actionFunc = func_808BE358; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_CUTBODY); - func_800BCB70(&this->actor, 0x4000, 255, 0, SkelAnime_GetFrameCount(&D_0600259C.common)); + func_800BCB70(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&D_0600259C)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_808BE484(this); } } @@ -531,7 +531,7 @@ void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE484(EnDekunuts* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06002BD4); + Animation_PlayOnce(&this->skelAnime, &D_06002BD4); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DEAD); @@ -543,7 +543,7 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp40; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { sp40.x = this->actor.world.pos.x; sp40.y = this->actor.world.pos.y + 18.0f; sp40.z = this->actor.world.pos.z; @@ -560,12 +560,12 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE680(EnDekunuts* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600326C, -3.0f); this->actionFunc = func_808BE6C4; } void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); } @@ -678,7 +678,7 @@ s32 func_808BEBD0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p if (this->actionFunc == func_808BDA4C) { if (limbIndex == 5) { - currentFrame = this->skelAnime.animCurrentFrame; + currentFrame = this->skelAnime.curFrame; if (currentFrame <= 6.0f) { arg2 = 1.0f - (currentFrame * 0.0833f); arg1 = (currentFrame * 0.1167f) + 1.0f; @@ -719,30 +719,30 @@ void func_808BED30(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (value != -1) { if (value < 3) { - SysMatrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); } else { - SysMatrix_GetStateTranslation(&this->unk_21C[value]); + Matrix_GetStateTranslation(&this->unk_21C[value]); ptr1 = &D_808BEFA4[0]; ptr2 = &this->unk_21C[value + 1]; for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { - SysMatrix_MultiplyVector3fByState(ptr1, ptr2); + Matrix_MultiplyVector3fByState(ptr1, ptr2); ptr1++, ptr2++; } } } if (limbIndex == 2) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } } void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { EnDekunuts* this = THIS; - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, func_808BEBD0, func_808BED30, - &this->actor); - SysMatrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_808BEBD0, func_808BED30, + &this->actor); + Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index cf3337c0a..c0c17367d 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -157,13 +157,13 @@ void func_80989140(SkelAnime* skelAnime, ActorAnimationEntryS arg1[], s32 arg2) arg1 += arg2; if (arg1->frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&arg1->animationSeg->common); + frameCount = Animation_GetLastFrame(arg1->animationSeg); } else { frameCount = arg1->frameCount; } - SkelAnime_ChangeAnim(skelAnime, arg1->animationSeg, arg1->playbackSpeed + (BREG(88) * 0.1f), arg1->frame, - frameCount, arg1->mode, arg1->transitionRate); + Animation_Change(skelAnime, arg1->animationSeg, arg1->playbackSpeed + (BREG(88) * 0.1f), arg1->frame, frameCount, + arg1->mode, arg1->transitionRate); } void func_80989204(EnDg* this, GlobalContext* globalCtx) { @@ -294,7 +294,7 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { } void func_80989864(EnDg* this, GlobalContext* globalCtx) { - s16 frame = this->skelAnime.animCurrentFrame; + s16 frame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; Vec3f sp38; @@ -307,31 +307,31 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { } void func_80989974(EnDg* this) { - if (func_801378B8(&this->skelAnime, 1.0f) || func_801378B8(&this->skelAnime, 7.0f)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); } } void func_809899C8(EnDg* this, f32 arg1) { - if (func_801378B8(&this->skelAnime, arg1)) { + if (Animation_OnFrame(&this->skelAnime, arg1)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } void func_80989A08(EnDg* this, f32 arg1) { - if (func_801378B8(&this->skelAnime, arg1)) { + if (Animation_OnFrame(&this->skelAnime, arg1)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } void func_80989A48(EnDg* this) { - if (func_801378B8(&this->skelAnime, 23.0f) || func_801378B8(&this->skelAnime, 28.0f)) { + if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } void func_80989A9C(EnDg* this, f32 arg1) { - if (func_801378B8(&this->skelAnime, arg1)) { + if (Animation_OnFrame(&this->skelAnime, arg1)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } @@ -657,9 +657,9 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_80989974(this); - if (func_801378B8(&this->skelAnime, 3.0f)) { + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_CRY); - } else if (func_801378B8(&this->skelAnime, 6.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -689,7 +689,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 70.0f) { Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 1.0f); - if (func_801378B8(&this->skelAnime, 7.0f)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { s16 y = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); this->unk_28E = 20; @@ -751,7 +751,7 @@ void func_8098AB48(EnDg* this, GlobalContext* globalCtx) { } void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { - s16 sp26 = this->skelAnime.animCurrentFrame; + s16 sp26 = this->skelAnime.curFrame; if ((this->actor.xyzDistToPlayerSq < 800.0f) && (this->collider.base.atFlags & AT_BOUNCED)) { this->unk_28E = 60; @@ -772,13 +772,13 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { } if (sp26 < 9) { - if (func_801378B8(&this->skelAnime, 0.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { sAnimations[14].playbackSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } func_80989864(this, globalCtx); } else { this->unk_280 |= 2; - if (func_801378B8(&this->skelAnime, 9.0f)) { + if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); sAnimations[14].playbackSpeed = 1.2f; @@ -1116,7 +1116,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060080F0, NULL, this->jointTable, this->morphTable, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, NULL, this->jointTable, this->morphTable, 13); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -1170,7 +1170,7 @@ void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { func_8098933C(this, &sp28); Math_ApproachF(&this->unk_294.x, sp28.x, 0.2f, 0.1f); Math_ApproachF(&this->unk_294.z, sp28.z, 0.2f, 0.1f); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } } @@ -1185,9 +1185,9 @@ void func_8098BFD4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (limbIndex == 5) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; - SysMatrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); } else if (this->actionFunc != func_8098BC54) { - SysMatrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); } } } @@ -1225,13 +1225,13 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - SysMatrix_RotateStateAroundXAxis(this->unk_294.x); - SysMatrix_InsertZRotation_f(this->unk_294.z, MTXMODE_APPLY); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(this->unk_294.x); + Matrix_InsertZRotation_f(this->unk_294.z, MTXMODE_APPLY); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_8098BFB8, func_8098BFD4, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_8098BFB8, func_8098BFD4, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index cf6a959b4..8670600fe 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -293,7 +293,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { this->colliderJntSphElement); Collider_InitAndSetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06009570, &D_06002E40, this->jointTable, this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06009570, &D_06002E40, this->jointTable, this->morphTable, 21); if (D_8089E364 == 0) { for (i = 0; i < ARRAY_COUNT(D_8089E33C); i++) { @@ -483,8 +483,8 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f sp3C; - SkelAnime_ChangeAnim(&this->skelAnime, &D_06001CCC, 1.0f, SkelAnime_GetFrameCount(&D_06001CCC.common), - SkelAnime_GetFrameCount(&D_06001CCC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &D_06001CCC, 1.0f, Animation_GetLastFrame(&D_06001CCC), + Animation_GetLastFrame(&D_06001CCC), 2, 0.0f); func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, 1); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); @@ -549,7 +549,7 @@ void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { func_801A2E54(0x38); } - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_0600C974); + Animation_PlayOnce(&this->skelAnime, &D_0600C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; this->unk_2BC.y = this->actor.floorHeight + 11.0f; this->unk_2BC.z = (Math_CosS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.z; @@ -567,38 +567,38 @@ void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); } - if (this->skelAnime.animCurrentFrame > 35.0f) { - if ((globalCtx->sceneNum == SCENE_MITURIN) && func_801378B8(&this->skelAnime, 38.0f)) { + if (this->skelAnime.curFrame > 35.0f) { + if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { globalCtx->envCtx.unk_C3 = 11; } Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); - if (this->skelAnime.animCurrentFrame <= 55.0f) { + if (this->skelAnime.curFrame <= 55.0f) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); } } - if ((globalCtx->sceneNum == SCENE_MITURIN) && func_801378B8(&this->skelAnime, 55.0f)) { + if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { globalCtx->envCtx.unk_C3 = 0xFF; } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_8089B6E8(this); } } void func_8089B6E8(EnDinofos* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009B70, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009B70, -3.0f); this->actionFunc = func_8089B72C; } void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, 2.0f)) { + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_8089ABF4(this, globalCtx); this->actor.flags &= ~0x00100000; this->actor.cutscene = -1; @@ -607,7 +607,7 @@ void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089B7B0(EnDinofos* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06002E40, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06002E40, -4.0f); this->unk_290 = (s32)Rand_ZeroFloat(20.0f) + 40; this->unk_292 = 30; this->actor.speedXZ = 0.0f; @@ -617,7 +617,7 @@ void func_8089B7B0(EnDinofos* this) { } void func_8089B834(EnDinofos* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk_292 != 0) { this->unk_292--; } else if (func_8089A968(this)) { @@ -635,7 +635,7 @@ void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { f32 phi_f0; if (this->actionFunc != func_8089B98C) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000580, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000580, -4.0f); if (func_800BC5EC(globalCtx, &this->actor)) { phi_f0 = 170.0f; } else { @@ -656,7 +656,7 @@ void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { f32 phi_f0; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (!func_8089AE00(this, globalCtx)) { if (func_800BC5EC(globalCtx, &this->actor)) { phi_f0 = 170.0f; @@ -682,7 +682,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { func_8089A9B0(this, globalCtx); } - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 6.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -690,7 +690,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { void func_8089BAC0(EnDinofos* this) { if (this->actionFunc != func_8089BB60) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000580, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000580, -4.0f); this->actor.speedXZ = 0.0f; } if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) > 0) { @@ -704,7 +704,7 @@ void func_8089BAC0(EnDinofos* this) { } void func_8089BB60(EnDinofos* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_28C, 0x400)) { func_8089A9B0(this, globalCtx); } @@ -729,10 +729,10 @@ void func_8089BBB4(EnDinofos* this, GlobalContext* globalCtx) { } if (this->actionFunc == func_8089D1E0) { - this->skelAnime.animPlaybackSpeed = this->actor.speedXZ * 0.166666671634f; + this->skelAnime.playSpeed = this->actor.speedXZ * 0.166666671634f; } else { - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600D62C, this->actor.speedXZ * 0.166666671634f, 0.0f, 0.0f, 0, - -4.0f); + Animation_Change(&this->skelAnime, &D_0600D62C, this->actor.speedXZ * 0.166666671634f, 0.0f, 0.0f, 0, + -4.0f); } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -776,9 +776,9 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } if (this->actor.speedXZ > 0.0f) { - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } else { - this->skelAnime.animPlaybackSpeed = -1.0f; + this->skelAnime.playSpeed = -1.0f; } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -796,14 +796,14 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { this->actor.world.pos.x += Math_SinS(this->actor.shape.rot.y) * this->unk_2A4; this->actor.world.pos.z += Math_CosS(this->actor.shape.rot.y) * this->unk_2A4; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk_292 != 0) { this->unk_292--; } else { func_8089A9B0(this, globalCtx); } - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 5.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -811,10 +811,10 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { void func_8089C024(EnDinofos* this, s32 arg1) { if (arg1 == 0) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001CCC, 2.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001CCC, 2.0f); func_8089AD70(this); } else { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001CCC, -1.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001CCC, -1.0f); if ((arg1 == 2) || (arg1 == 3)) { this->colliderJntSph.base.acFlags &= ~AC_ON; func_8089AD70(this); @@ -830,8 +830,8 @@ void func_8089C024(EnDinofos* this, s32 arg1) { void func_8089C0DC(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x1000); this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 1.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { if (this->unk_290 == 3) { func_8089C244(this); } else { @@ -858,7 +858,7 @@ void func_8089C164(EnDinofos* this) { } void func_8089C1F8(EnDinofos* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 1) { func_8089C398(this); } @@ -875,13 +875,13 @@ void func_8089C244(EnDinofos* this) { } void func_8089C2A8(EnDinofos* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->unk_290++; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x1800); - if ((this->actor.velocity.y < 0.0f) && (this->skelAnime.animCurrentSeg == &D_06001CCC)) { + if ((this->actor.velocity.y < 0.0f) && (this->skelAnime.animation == &D_06001CCC)) { this->colliderQuad.base.atFlags |= AT_ON; this->colliderJntSph.base.acFlags |= AC_ON; - SkelAnime_ChangeAnim(&this->skelAnime, &D_060025B4, 1.0f, 7.0f, 13.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &D_060025B4, 1.0f, 7.0f, 13.0f, 2, -2.0f); } if (this->actor.bgCheckFlags & 1) { @@ -892,9 +892,9 @@ void func_8089C2A8(EnDinofos* this, GlobalContext* globalCtx) { void func_8089C398(EnDinofos* this) { if (this->actionFunc != func_8089C2A8) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000AF0); + Animation_PlayOnce(&this->skelAnime, &D_06000AF0); } else { - this->skelAnime.animFrameCount = SkelAnime_GetFrameCount(&D_060025B4.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&D_060025B4); } if (this->actor.speedXZ < 0.0f) { @@ -910,7 +910,7 @@ void func_8089C398(EnDinofos* this) { } void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if ((this->unk_290 == 1) && (this->actor.xzDistToPlayer < 280.0f) && func_8089A968(this) && (Rand_ZeroOne() < 0.6f)) { func_8089CA14(this); @@ -921,7 +921,7 @@ void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089C4F8(EnDinofos* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060025B4); + Animation_PlayOnce(&this->skelAnime, &D_060025B4); this->colliderQuad.base.atFlags &= ~AT_BOUNCED; Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_290 = 0; @@ -935,24 +935,24 @@ void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { this->unk_290++; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); this->actor.world.rot.y = this->actor.shape.rot.y; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_800A8514(Effect_GetParams(this->unk_2A0)); this->colliderQuad.base.atFlags &= ~AT_ON; func_8089A9B0(this, globalCtx); - } else if (func_801378B8(&this->skelAnime, 7.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 7.0f)) { this->colliderQuad.base.atFlags |= AT_ON; func_8089AD70(this); - } else if (func_801378B8(&this->skelAnime, 13.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 13.0f)) { this->colliderQuad.base.atFlags &= ~AT_ON; - } else if (func_801378B8(&this->skelAnime, 11.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); - } else if (this->skelAnime.animCurrentFrame < 7.0f) { + } else if (this->skelAnime.curFrame < 7.0f) { func_8089AE00(this, globalCtx); } } void func_8089C690(EnDinofos* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060025B4, -1.0f, this->skelAnime.animCurrentFrame, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &D_060025B4, -1.0f, this->skelAnime.curFrame, 0.0f, 2, 0.0f); this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); if (this->actionFunc != func_8089C2A8) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -967,7 +967,7 @@ void func_8089C724(EnDinofos* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_8089A9B0(this, globalCtx); } } @@ -1002,7 +1002,7 @@ void func_8089C7B8(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089C87C(EnDinofos* this, s32 arg1) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_0600D21C); + Animation_PlayOnce(&this->skelAnime, &D_0600D21C); func_800BE5CC(&this->actor, &this->colliderJntSph, arg1); this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->actor.speedXZ = 10.0f; @@ -1018,7 +1018,7 @@ void func_8089C87C(EnDinofos* this, s32 arg1) { void func_8089C938(EnDinofos* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { + if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { if (this->actor.colChkInfo.health == 0) { if (this->actor.cutscene == -1) { func_8089CFAC(this); @@ -1035,7 +1035,7 @@ void func_8089C938(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089CA14(EnDinofos* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001040, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001040, -5.0f); this->colliderJntSph.base.acFlags |= AC_ON; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1045,9 +1045,9 @@ void func_8089CA14(EnDinofos* this) { void func_8089CA74(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_8089CB10(this, globalCtx); - } else if (!func_8089AE00(this, globalCtx) && func_801378B8(&this->skelAnime, 12.0f)) { + } else if (!func_8089AE00(this, globalCtx) && Animation_OnFrame(&this->skelAnime, 12.0f)) { this->actor.speedXZ = 8.0f; } } @@ -1056,7 +1056,7 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { s32 i; Sphere16* worldSphere; - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060013C0); + Animation_PlayLoop(&this->skelAnime, &D_060013C0); this->unk_290 = 20; this->actor.speedXZ = 0.0f; this->colliderJntSph.base.atFlags |= AT_ON; @@ -1087,7 +1087,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { f32 temp_f22; s32 temp_s0; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); temp_f20 = Math_SinS(temp_s3); temp_f22 = Math_CosS(temp_s3); @@ -1128,7 +1128,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060017B8); + Animation_PlayOnce(&this->skelAnime, &D_060017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; if (globalCtx->sceneNum == SCENE_MITURIN) { globalCtx->envCtx.unk_C3 = 255; @@ -1137,13 +1137,13 @@ void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_8089A9B0(this, globalCtx); } } void func_8089CFAC(EnDinofos* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_0600ABD0); + Animation_PlayOnce(&this->skelAnime, &D_0600ABD0); this->actor.flags &= ~1; Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; @@ -1152,7 +1152,7 @@ void func_8089CFAC(EnDinofos* this) { } void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { s32 temp_v0 = this->unk_288 - 10; if (this->actor.category == ACTORCAT_ENEMY) { @@ -1172,7 +1172,7 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { } this->actor.shape.shadowAlpha = this->unk_288; - } else if (func_801378B8(&this->skelAnime, 26.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 26.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -1183,7 +1183,7 @@ void func_8089D11C(EnDinofos* this, s16 arg1) { } else { this->actor.speedXZ = 15.0f; } - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, 0, -4.0f); + Animation_Change(&this->skelAnime, &D_0600D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, 0, -4.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); this->unk_292 = 10; this->unk_2A4 = 0.0f; @@ -1195,17 +1195,17 @@ void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xBB8); Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); - this->skelAnime.animPlaybackSpeed = + this->skelAnime.playSpeed = (1.0f + fabsf(this->actor.speedXZ * (1.0f / 15.0f))) * ((this->actor.speedXZ >= 0.0f) ? 1.0f : -1.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk_292 != 0) { this->unk_292--; } else { func_8089A9B0(this, globalCtx); } - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 5.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -1443,15 +1443,15 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - SysMatrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); + Matrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && ((this->actionFunc == func_8089C56C) || (this->actionFunc == func_8089C2A8))) { Math_Vec3f_Copy(&sp74, &this->colliderQuad.dim.quad[0]); Math_Vec3f_Copy(&sp80, &this->colliderQuad.dim.quad[1]); - SysMatrix_MultiplyVector3fByState(&D_8089E38C, &sp68); - SysMatrix_MultiplyVector3fByState(&D_8089E398, &sp5C); + Matrix_MultiplyVector3fByState(&D_8089E38C, &sp68); + Matrix_MultiplyVector3fByState(&D_8089E398, &sp5C); Collider_SetQuadVertices(&this->colliderQuad, &sp5C, &sp68, &sp74, &sp80); if (this->colliderQuad.base.atFlags & AT_ON) { func_800A81F0(Effect_GetParams(this->unk_2A0), &sp68, &sp5C); @@ -1460,18 +1460,18 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } if (limbIndex == 4) { - SysMatrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[0]); + Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[0]); } else if (limbIndex == 7) { - SysMatrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[1]); + Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[1]); } if ((limbIndex == 16) && (this->actionFunc == func_8089B580)) { - if ((this->skelAnime.animCurrentFrame > 38.0f) && (this->skelAnime.animCurrentFrame <= 55.0f) && + if ((this->skelAnime.curFrame > 38.0f) && (this->skelAnime.curFrame <= 55.0f) && (this->unk_292 != this->unk_290)) { - sp48 = SysMatrix_GetCurrentState(); - sp58 = 48 - (s32)this->skelAnime.animCurrentFrame; + sp48 = Matrix_GetCurrentState(); + sp58 = 48 - (s32)this->skelAnime.curFrame; sp58 = CLAMP_MIN(sp58, 0); - SysMatrix_MultiplyVector3fByState(&D_8089E3A4, &sp4C); + Matrix_MultiplyVector3fByState(&D_8089E3A4, &sp4C); sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; @@ -1495,8 +1495,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { Scene_SetRenderModeXlu(globalCtx, 0, 1); POLY_OPA_DISP = - SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_OPA_DISP); + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_OPA_DISP); } else { func_8012C2DC(globalCtx->state.gfxCtx); func_800B8118(&this->actor, globalCtx, 0); @@ -1506,8 +1506,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { Scene_SetRenderModeXlu(globalCtx, 1, 2); POLY_XLU_DISP = - SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } func_800BE680(globalCtx, &this->actor, this->unk_2D4, 12, this->unk_2B4, this->unk_2B8, this->unk_2B0, diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 6aab7a2cd..780ce1cda 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -163,17 +163,17 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - SysMatrix_StatePush(); - SysMatrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, - this->particles[i].unk_0C.z, MTXMODE_NEW); - SysMatrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); - SysMatrix_StatePop(); + Matrix_StatePop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -188,17 +188,17 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - SysMatrix_StatePush(); - SysMatrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, - this->particles[i].unk_0C.z, MTXMODE_NEW); - SysMatrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); - SysMatrix_StatePop(); + Matrix_StatePop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -279,16 +279,16 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); isGfxSetup = true; } - SysMatrix_StatePush(); + Matrix_StatePush(); if (1) {}; arg0->unk_24 = (arg0->unk_01 / (f32)arg0->unk_02) * 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)arg0->unk_24); - SysMatrix_InsertTranslation(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); + Matrix_InsertTranslation(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -296,7 +296,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A50CBC[idx])); gSPDisplayList(POLY_XLU_DISP++, D_06000020); - SysMatrix_StatePop(); + Matrix_StatePop(); sp5C += 1; } } diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 067f16642..59a39f65a 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -148,14 +148,14 @@ s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { sp30 = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&(sAnimations[animIndex].animationSeg)->common); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); } frame = sAnimations[animIndex].frame; if (frame < 0) { frame = frameCount; } - SkelAnime_ChangeAnim(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - frame, frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, + frame, frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].transitionRate); } } return sp30; @@ -263,7 +263,7 @@ void EnDnk_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80A515C4(this); Actor_SetHeight(&this->actor, 34.0f); Collider_UpdateCylinder(&this->actor, &this->collider); @@ -288,10 +288,10 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - SysMatrix_MultiplyVector3fByState(&sp50, &sp44); - SysMatrix_CopyCurrentState(&sp5C); + Matrix_MultiplyVector3fByState(&sp50, &sp44); + Matrix_CopyCurrentState(&sp5C); func_8018219C(&sp5C, &sp3C, 0); - SysMatrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { if (this->unk_28C & 0x20) { @@ -315,8 +315,8 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -342,8 +342,8 @@ void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A5245C[this->unk_2A0])); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, func_80A51A78, func_80A51AA4, - &this->actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51A78, func_80A51AA4, + &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -364,10 +364,10 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - SysMatrix_MultiplyVector3fByState(&sp50, &sp44); - SysMatrix_CopyCurrentState(&sp5C); + Matrix_MultiplyVector3fByState(&sp50, &sp44); + Matrix_CopyCurrentState(&sp5C); func_8018219C(&sp5C, &sp3C, 0); - SysMatrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { @@ -392,8 +392,8 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -406,8 +406,8 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80A51FC0(EnDnk* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, func_80A51D78, func_80A51DA4, - &this->actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, func_80A51D78, func_80A51DA4, + &this->actor); } void func_80A52018(Actor* thisx, GlobalContext* globalCtx) { 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 b39ac6640..ff7e3de3b 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -172,7 +172,7 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); Matrix_RotateY(-crace->actor.home.rot.y, 0); - SysMatrix_MultiplyVector3fByState(&sp7C, &sp70); + Matrix_MultiplyVector3fByState(&sp7C, &sp70); if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { crace->unk_170 |= 1; } @@ -213,19 +213,19 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 21.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600E1F8, &D_06007CA4, this->jointTable, this->morphTable, - 28); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600E1F8, &D_06007CA4, this->jointTable, + this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&(sAnimations[14].animationSeg)->common), sAnimations[14].mode, - sAnimations[14].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[14].animationSeg), sAnimations[14].mode, + sAnimations[14].transitionRate); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; this->unk_468 = 99; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; switch (ENDNO_GET_C000(thisx)) { case ENDNO_GET_C000_0: @@ -309,7 +309,7 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { case 3: case 10: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); } break; @@ -319,7 +319,7 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { break; case 15: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); } @@ -390,8 +390,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0x80F: if (this->unk_32C == 13) { func_8013E1C8(&this->skelAnime, sAnimations, 4, &this->unk_32C); - } else if ((this->unk_32C == 4) && - (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount)) { + } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { func_8013E1C8(&this->skelAnime, sAnimations, 11, &this->unk_32C); func_801518B0(globalCtx, this->unk_464, &this->actor); } @@ -404,7 +403,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.unk11F04 == 0x80B) { switch (this->unk_32C) { case 16: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); } Math_ScaledStepToS(&this->actor.shape.rot.y, @@ -412,7 +411,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 10: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); func_8013E1C8(&this->skelAnime, sAnimations, 0xD, &this->unk_32C); func_80A71B68(this, globalCtx); @@ -429,7 +428,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0x80B: switch (this->unk_32C) { case 16: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); } break; @@ -442,7 +441,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 10: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); @@ -467,7 +466,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { if (this->unk_32C == 11) { func_8013E1C8(&this->skelAnime, sAnimations, 3, &this->unk_32C); } else if (this->unk_32C == 3) { - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); } } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { @@ -496,7 +495,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 15: - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); } break; @@ -564,8 +563,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); } - } else if ((this->unk_32C == 5) && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { func_801518B0(globalCtx, 0x801, &this->actor); } else if (Player_GetMask(globalCtx) == PLAYER_MASK_MASK_OF_SCENTS) { @@ -596,18 +594,18 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); - if (this->skelAnime.animCurrentFrame <= 23.0f) { + if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; - if (func_801378B8(&this->skelAnime, 23.0f)) { + if (Animation_OnFrame(&this->skelAnime, 23.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_OPEN_AMBRELLA); } - } else if (this->skelAnime.animCurrentFrame <= 24.0f) { + } else if (this->skelAnime.curFrame <= 24.0f) { this->unk_452 = 4; - } else if (this->skelAnime.animCurrentFrame >= 25.0f) { + } else if (this->skelAnime.curFrame >= 25.0f) { this->unk_452 = 2; } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_8013E1C8(&this->skelAnime, sAnimations, 12, &this->unk_32C); func_801518B0(globalCtx, 0x803, &this->actor); } @@ -656,8 +654,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { this->unk_3B0 |= 0x40; } } - } else if ((this->unk_32C == 5) && - (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount)) { + } else if ((this->unk_32C == 5) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { func_801477B4(globalCtx); func_80A72438(this, globalCtx); } @@ -684,7 +681,7 @@ void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { } void func_80A72B3C(EnDno* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_44E = 0; func_80A72C04(this, globalCtx); } @@ -785,7 +782,7 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { f32 temp_f10; s32 phi_a2; - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { phi_a2 = -1; switch (this->unk_32C) { case 0: @@ -850,18 +847,18 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, sAnimations, 7, &this->unk_32C); } } else if (this->unk_44E == 3) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); func_80A72438(this, globalCtx); } else { - if (this->skelAnime.animCurrentFrame >= 20.0f) { + if (this->skelAnime.curFrame >= 20.0f) { Math_SmoothStepToF(&this->unk_454, 0.0f, 1.0f, 0.125f, 0.01f); } - if (func_801378B8(&this->skelAnime, 4.0f)) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); this->unk_452 = 4; - } else if (func_801378B8(&this->skelAnime, 5.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { this->unk_452 = 3; } } @@ -899,7 +896,7 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { func_800EDF24(&this->actor, globalCtx, temp_v0); } - if ((func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) && (this->unk_32C == 17)) { + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { if (0) {}; func_8013E1C8(&this->skelAnime, sAnimations, 18, &this->unk_32C); } @@ -909,7 +906,7 @@ void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { EnDno* this = THIS; s32 pad; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80A73408(this, globalCtx); this->actionFunc(this, globalCtx); if (this->unk_3B0 & 4) { @@ -923,8 +920,8 @@ void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx) { EnDno* this = THIS; - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnDno_OverrideLimbDraw, EnDno_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDno_OverrideLimbDraw, EnDno_PostLimbDraw, &this->actor); } s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -987,8 +984,8 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve func_8012C28C(globalCtx->state.gfxCtx); if (limbIndex == 13) { - Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, 1); - SysMatrix_InsertXRotation_s(this->unk_45C, 1); + Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_45C, 1); } gfxOpa = POLY_OPA_DISP; @@ -1004,13 +1001,13 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_StatePush(); + Matrix_StatePush(); frames = globalCtx->gameplayFrames; - SysMatrix_MultiplyVector3fByState(&D_80A73B40, &sp84); + Matrix_MultiplyVector3fByState(&D_80A73B40, &sp84); func_80A711D0(this, globalCtx, &sp84); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); - Matrix_Scale(0.15f, 0.15f, 1.0f, 1); - SysMatrix_InsertTranslation(0.0f, -3200.0f, 0.0f, 1); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(0.15f, 0.15f, 1.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); gfxXlu = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(gfxXlu, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1022,7 +1019,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve POLY_XLU_DISP = gfxXlu + 5; - SysMatrix_StatePop(); + Matrix_StatePop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 5c354d5d0..7477bbcc5 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -102,38 +102,38 @@ static s32 D_80B3DE58[] = { s32 func_80B3CA20(EnDnp* this) { if ((this->unk_340 == 2) || (this->unk_340 == 9)) { - if (func_801378B8(&this->skelAnime, 1.0f) || func_801378B8(&this->skelAnime, 5.0f) || - func_801378B8(&this->skelAnime, 9.0f) || func_801378B8(&this->skelAnime, 13.0f)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if ((this->unk_340 == 24) || (this->unk_340 == 7)) { - if (func_801378B8(&this->skelAnime, 1.0f)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if (this->unk_340 == 14) { - if (func_801378B8(&this->skelAnime, 7.0f)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); } - if (func_801378B8(&this->skelAnime, 22.0f)) { + if (Animation_OnFrame(&this->skelAnime, 22.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if (this->unk_340 == 8) { - if (func_801378B8(&this->skelAnime, 9.0f)) { + if (Animation_OnFrame(&this->skelAnime, 9.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); } - if (func_801378B8(&this->skelAnime, 18.0f)) { + if (Animation_OnFrame(&this->skelAnime, 18.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if ((this->unk_340 == 17) && (this->unk_340 == 18)) { - if (func_801378B8(&this->skelAnime, 7.0f) || func_801378B8(&this->skelAnime, 15.0f)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 21) { - if (func_801378B8(&this->skelAnime, 17.0f)) { + if (Animation_OnFrame(&this->skelAnime, 17.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 23) { - if (func_801378B8(&this->skelAnime, 3.0f)) { + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } @@ -289,7 +289,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { this->unk_324 = val; if (((this->unk_340 == 10) || (this->unk_340 == 12) || (this->unk_340 == 5) || (this->unk_340 == 19) || (this->unk_340 == 22) || (this->unk_340 == 24)) && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80B3CC38(this, this->unk_340 + 1); } func_800EDF24(&this->actor, globalCtx, temp_v0); @@ -358,7 +358,7 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { EnDnp* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 16.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06010D60, NULL, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010D60, NULL, this->jointTable, this->morphTable, 26); this->unk_340 = -1; func_80B3CC38(this, 15); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -405,12 +405,12 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { if (!func_80B3CF60(this, globalCtx) && func_80B3D044(this, globalCtx)) { func_80B3D11C(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); func_80B3CEC0(this, globalCtx); } else { this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); func_80B3CEC0(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); @@ -435,8 +435,8 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - SysMatrix_MultiplyVector3fByState(&D_801D15B0, &sp74); - SysMatrix_CopyCurrentState(&sp2C); + Matrix_MultiplyVector3fByState(&D_801D15B0, &sp74); + Matrix_CopyCurrentState(&sp2C); func_8018219C(&sp2C, &sp6C, 0); *arg2 = sp74; if (arg4 == 0) { @@ -478,13 +478,13 @@ void func_80B3DAA0(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { if (limbIndex == 12) { func_80B3D974(this->unk_330 + 0x4000, this->unk_332 + this->actor.shape.rot.y + 0x4000, &this->unk_1D8, &this->unk_1E4, phi_v1, phi_v0); - SysMatrix_StatePop(); - SysMatrix_InsertTranslation(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateY(this->unk_1E4.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_1E4.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_1E4.z, MTXMODE_APPLY); - SysMatrix_StatePush(); + Matrix_InsertXRotation_s(this->unk_1E4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1E4.z, MTXMODE_APPLY); + Matrix_StatePush(); } } @@ -504,8 +504,8 @@ void EnDnp_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3DEAC[this->unk_336])); - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - NULL, func_80B3DA88, func_80B3DAA0, &this->actor); + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + func_80B3DA88, func_80B3DAA0, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 861095e14..e392e6d60 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -148,7 +148,7 @@ s32 func_80A526F8(EnDnq* this) { this->unk_38C = ((s32)(Rand_ZeroOne() * 100.0f) % 4) + 3; this->unk_388 = 0; this->unk_386 = 1; - } else if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->unk_398) { case 8: if (DECR(this->unk_38C) == 0) { @@ -186,7 +186,7 @@ s32 func_80A526F8(EnDnq* this) { } if (this->unk_386 != 0) { - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } } @@ -204,7 +204,7 @@ s32 func_80A52944(EnDnq* this) { this->unk_386 = 1; phi_v1 = this->unk_38C * 0x2000; this->actor.shape.rot.y += phi_v1; - } else if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_386++; if (this->unk_386 >= 6) { func_80A5257C(this, 12); @@ -212,11 +212,11 @@ s32 func_80A52944(EnDnq* this) { phi_v1 = this->unk_38C * 0x2000; } else if (this->unk_386 <= 3) { this->unk_38C = -this->unk_38C; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; phi_v1 = this->unk_38C * 0x2000; } else { func_80A5257C(this, 13); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.y += phi_v1; @@ -242,14 +242,14 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { this->unk_38C--; } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_38C == 0) { this->unk_38C = Rand_S16Offset(20, 20); this->unk_388 += 3; this->unk_388 %= 5; } func_80A5257C(this, D_80A535DC[this->unk_388]); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } this->unk_386 = 0; @@ -403,12 +403,12 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { this->unk_1DC = temp_v1; } - if ((this->unk_398 == 4) && func_801378B8(&this->skelAnime, 2.0f)) { + if ((this->unk_398 == 4) && Animation_OnFrame(&this->skelAnime, 2.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); } if (((this->unk_398 == 3) || (this->unk_398 == 6)) && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80A5257C(this, this->unk_398 + 1); } @@ -420,7 +420,7 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { EnDnq* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 14.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600EB48, NULL, this->jointTable, this->morphTable, 33); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600EB48, NULL, this->jointTable, this->morphTable, 33); this->unk_398 = -1; func_80A5257C(this, 0); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -450,11 +450,11 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { if (!func_80A52D44(this, globalCtx) && func_80A52648(this, globalCtx)) { func_80A53038(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } else { this->actionFunc(this, globalCtx); func_80A52B68(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); @@ -470,6 +470,6 @@ void EnDnq_Draw(Actor* thisx, GlobalContext* globalCtx) { EnDnq* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 7d33a75ad..373e69880 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -84,7 +84,7 @@ void func_8092C5C0(EnDns* this) { s32 pad; if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 3.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); } } @@ -226,7 +226,7 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { if (ENDNS_GET_4000(&this->actor)) { this->unk_2F0 = 0.0f; if (this->unk_2D2 != 0) { - this->unk_2F0 = this->skelAnime.animCurrentFrame; + this->unk_2F0 = this->skelAnime.curFrame; func_8092C63C(this, 2); } this->unk_2DA = this->actor.world.rot.y; @@ -303,10 +303,10 @@ s32 func_8092CE38(EnDns* this) { Vec3f sp2C; s32 ret = false; - if ((this->unk_2C6 & 0x200) || func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if ((this->unk_2C6 & 0x200) || Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_8092C63C(this, D_8092DE00[this->unk_2D2]); this->unk_2C6 &= ~0x200; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; if (this->unk_2D2 == 2) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); } @@ -317,25 +317,25 @@ s32 func_8092CE38(EnDns* this) { ret = true; } else { if (this->unk_2D2 == 0) { - if (func_801378B8(&this->skelAnime, 13.0f)) { + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->unk_2E4 = 0.0f; this->actor.shape.rot.y = this->actor.world.rot.y; Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); - } else if (this->skelAnime.animCurrentFrame < 13.0f) { - frame = this->skelAnime.animCurrentFrame; + } else if (this->skelAnime.curFrame < 13.0f) { + frame = this->skelAnime.curFrame; this->actor.shape.rot.y = this->actor.world.rot.y; frame *= 2520; this->actor.shape.rot.y += frame; this->unk_2E4 -= -(40.0f / 13.0f); } } else { - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 6.0f) || - func_801378B8(&this->skelAnime, 13.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 13.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); } - if (this->skelAnime.animCurrentFrame > 7.0f) { + if (this->skelAnime.curFrame > 7.0f) { this->unk_2E4 += -(20.0f / 13.0f); } } @@ -371,8 +371,8 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - SysMatrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -450,7 +450,7 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { this->unk_2F4 = NULL; if (ENDNS_GET_4000(&this->actor)) { if (!(gSaveContext.eventInf[1] & 0x20)) { - this->skelAnime.animCurrentFrame = this->unk_2F0; + this->skelAnime.curFrame = this->unk_2F0; this->actor.world.rot.y = this->unk_2DA; func_8092C63C(this, 8); } @@ -478,7 +478,7 @@ void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { } if (((this->unk_2F8 == 4) || (this->unk_2F8 == 6)) && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_8092C63C(this, this->unk_2F8 + 1); } @@ -529,11 +529,11 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { if (!func_8092CAD0(this, globalCtx) && func_8092CB98(this, globalCtx)) { func_8092D5E8(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_8092C5C0(this); } else { this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_8092C934(this); func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); @@ -549,8 +549,8 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - SysMatrix_MultiplyVector3fByState(&D_801D15B0, &sp74); - SysMatrix_CopyCurrentState(&sp2C); + Matrix_MultiplyVector3fByState(&D_801D15B0, &sp74); + Matrix_CopyCurrentState(&sp2C); func_8018219C(&sp2C, &sp6C, 0); *arg2 = sp74; @@ -600,11 +600,11 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if (limbIndex == 2) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); - SysMatrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); + Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateY(this->unk_224.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -626,8 +626,8 @@ void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_8092DE1C[this->unk_2E0])); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnDns_OverrideLimbDraw, - EnDns_PostLimbDraw, &this->actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDns_OverrideLimbDraw, + EnDns_PostLimbDraw, &this->actor); func_8092D108(this, globalCtx); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index e913b669b..62cfddd0f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -513,8 +513,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { } s32 func_8087721C(EnDodongo* this) { - if ((this->actionFunc == func_8087784C) && (this->skelAnime.animCurrentFrame >= 29.0f) && - (this->skelAnime.animCurrentFrame <= 43.0f)) { + if ((this->actionFunc == func_8087784C) && (this->skelAnime.curFrame >= 29.0f) && + (this->skelAnime.curFrame <= 43.0f)) { return true; } return false; @@ -544,27 +544,27 @@ s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { } void func_808773C4(EnDodongo* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06004C20, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06004C20, -4.0f); this->actor.speedXZ = 0.0f; this->timer = Rand_S16Offset(30, 50); this->actionFunc = func_80877424; } void func_80877424(EnDodongo* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; } if (this->timer == 0) { - if (func_801378B8(&this->skelAnime, 0.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { func_80877494(this); } } } void func_80877494(EnDodongo* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06008B1C, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06008B1C, -4.0f); this->actor.speedXZ = this->unk_334 * 1.5f; this->timer = Rand_S16Offset(50, 70); this->actionFunc = func_80877500; @@ -575,14 +575,14 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { Vec3f sp30; s16 temp_v1; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 19.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 19.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[2].dim.worldSphere.center.x; sp30.y = this->collider1Elements[2].dim.worldSphere.center.y; sp30.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp30); - } else if (func_801378B8(&this->skelAnime, 39.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 39.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[1].dim.worldSphere.center.x; sp30.y = this->collider1Elements[1].dim.worldSphere.center.y; @@ -623,7 +623,7 @@ void func_808777A8(EnDodongo* this) { s32 i; Sphere16* sph; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060028F0, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_060028F0, -4.0f); this->actor.speedXZ = 0.0f; for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { @@ -648,13 +648,13 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f2; f32 temp_f12; - if (func_801378B8(&this->skelAnime, 24.0f)) { + if (Animation_OnFrame(&this->skelAnime, 24.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_CRY); } if (func_8087721C(this)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - frame = this->skelAnime.animCurrentFrame - 29.0f; + frame = this->skelAnime.curFrame - 29.0f; end = frame >> 1; if (end > 3) { end = 3; @@ -678,29 +678,29 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { D_80879348.z = 2.5f * temp_f12; EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); - } else if ((this->skelAnime.animCurrentFrame >= 2.0f) && (this->skelAnime.animCurrentFrame <= 20.0f)) { + } else if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 20.0f)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_80877D50(this); } } void func_80877D50(EnDodongo* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06003088); + Animation_PlayOnce(&this->skelAnime, &D_06003088); this->actionFunc = func_80877D90; } void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_808773C4(this); this->timer = Rand_S16Offset(10, 20); } } void func_80877DE0(EnDodongo* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); + Animation_Change(&this->skelAnime, &D_060028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); this->actor.flags |= 0x10; this->timer = 25; this->actionFunc = func_80877E60; @@ -735,14 +735,14 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { this->actor.child->freezeTimer = 30000; // 25 minutes } - if (func_801378B8(&this->skelAnime, 28.0f)) { + if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_EAT); if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; } this->actor.flags &= ~0x10; - } else if (this->skelAnime.animPlaybackSpeed > -0.5f) { + } else if (this->skelAnime.playSpeed > -0.5f) { this->timer--; if (this->timer == 10) { for (i = 10; i >= 0; i--) { @@ -768,13 +768,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } func_800BCB70(&this->actor, 0x4000, 0x78, 0, 8); } - } else if (func_801378B8(&this->skelAnime, 24.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { this->timer--; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; } - if (this->skelAnime.animCurrentFrame <= 27.0f) { - if ((this->skelAnime.animCurrentFrame <= 25.0f) && (this->timer < 11)) { + if (this->skelAnime.curFrame <= 27.0f) { + if ((this->skelAnime.curFrame <= 25.0f) && (this->timer < 11)) { func_80876DC4(this, globalCtx); } else { sp5E = this->unk_334 * 50.0f; @@ -793,7 +793,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { this->unk_314.z = Math_SinS((this->actor.colorFilterTimer * 0x1000) >> 1) + 1.0f; this->unk_314.x = Math_SinS(this->actor.colorFilterTimer * 0x1000) + 1.0f; this->unk_314.y = this->unk_314.z; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer == 0) { if (this->actor.colChkInfo.health == 0) { func_80878724(this); @@ -819,7 +819,7 @@ void func_80878354(EnDodongo* this) { } Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_TAIL); - SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, sp18, 2.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, sp18, 2.0f); this->timer = 0; this->collider1.base.atFlags |= AT_ON; this->unk_304 = -1; @@ -831,7 +831,7 @@ void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { Vec3f sp20; this->timer++; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { this->collider1.base.atFlags &= ~AT_ON; func_808777A8(this); @@ -878,7 +878,7 @@ void func_808785B0(EnDodongo* this, GlobalContext* globalCtx) { } void func_8087864C(EnDodongo* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001A44, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001A44, -4.0f); Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DAMAGE); this->timer = 0; this->unk_304 = 0; @@ -892,13 +892,13 @@ void func_808786C8(EnDodongo* this, GlobalContext* globalCtx) { func_80876DC4(this, globalCtx); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_80876B08(this, globalCtx); } } void func_80878724(EnDodongo* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060013C4, -8.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_060013C4, -8.0f); this->timer = 0; this->unk_304 = 0; Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DEAD); @@ -911,7 +911,7 @@ void func_80878724(EnDodongo* this) { void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { s32 pad; - if (this->skelAnime.animCurrentFrame < 35.0f) { + if (this->skelAnime.curFrame < 35.0f) { if (this->unk_304 != 0) { func_80876DC4(this, globalCtx); } @@ -919,7 +919,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { func_800BCB70(&this->actor, 0x4000, 0x78, 0, 4); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->timer == 0) { EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); @@ -928,7 +928,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { } this->timer = 8; } - } else if (func_801378B8(&this->skelAnime, 52.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 52.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } @@ -1086,16 +1086,16 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - SysMatrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + Matrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); } if (limbIndex == 7) { - SysMatrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - SysMatrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); - SysMatrix_GetStateTranslation(&this->actor.focus.pos); - SysMatrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); + Matrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); + Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); } else if (limbIndex == 13) { - SysMatrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); + Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { @@ -1108,8 +1108,8 @@ void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnDodongo* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnDodongo_OverrideLimbDraw, - EnDodongo_PostLimbDraw, &this->actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, + EnDodongo_PostLimbDraw, &this->actor); func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 7d492ac1d..e8145f806 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -153,12 +153,12 @@ void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - SysMatrix_InsertTranslation(0.0f, 0.0f, 1.0f, 1); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(0.0f, 0.0f, 1.0f, 1); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, 1); - SysMatrix_InsertZRotation_s(this->zRot, 1); + Matrix_InsertZRotation_s(this->zRot, 1); Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, 1); - SysMatrix_InsertZRotation_s(this->zRot * -1, 1); + Matrix_InsertZRotation_s(this->zRot * -1, 1); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06001000); diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index b61b73c58..ba444eb6c 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -270,7 +270,7 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { if (sPtr->enabled) { - SysMatrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(&D_04079B10)); @@ -278,8 +278,8 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); - SysMatrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); - SysMatrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + Matrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_0407AB58); diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index f32c5cc5a..089ee3788 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -42,8 +42,7 @@ void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600B0CC, &D_06000BE0, this->limbDrawTable, - this->transitionDrawTable, 15); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B0CC, &D_06000BE0, this->jointTable, this->morphTable, 15); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); func_80C1E748(this); } @@ -57,7 +56,7 @@ void func_80C1E748(EnEndingHero* this) { } void func_80C1E764(EnEndingHero* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -93,8 +92,8 @@ void EnEndingHero_Draw(Actor* thisx, GlobalContext* globalCtx) { } gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1E984[index])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, 0, 0, - &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + 0, 0, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h index bd81f7e06..95991fee8 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.h @@ -10,8 +10,8 @@ typedef void (*EnEndingHeroActionFunc)(struct EnEndingHero*, GlobalContext*); typedef struct EnEndingHero { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[15]; - /* 0x1E2 */ Vec3s transitionDrawTable[15]; + /* 0x188 */ Vec3s jointTable[15]; + /* 0x1E2 */ Vec3s morphTable[15]; /* 0x23C */ EnEndingHeroActionFunc actionFunc; /* 0x240 */ s16 unk240; /* 0x242 */ s16 unk242; diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index 8b201a7ae..0ff95496d 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -34,8 +34,7 @@ void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->limbDrawTable, - this->transitionDrawTable, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); func_80C232E8(this); } @@ -49,7 +48,7 @@ void func_80C232E8(EnEndingHero2* this) { } void func_80C23304(EnEndingHero2* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -65,6 +64,6 @@ void EnEndingHero2_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, 0, 0, - &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + 0, 0, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h index 99f57ab6a..fe7e6bf2e 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.h @@ -10,8 +10,8 @@ typedef void (*EnEndingHero2ActionFunc)(struct EnEndingHero2*, GlobalContext*); typedef struct EnEndingHero2 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[20]; - /* 0x200 */ Vec3s transitionDrawTable[20]; + /* 0x188 */ Vec3s jointTable[20]; + /* 0x200 */ Vec3s morphTable[20]; /* 0x278 */ EnEndingHero2ActionFunc actionFunc; /* 0x27C */ u16 unk27C; } EnEndingHero2; // size = 0x280 diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 73d28cd18..91a42c409 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -34,8 +34,7 @@ void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->limbDrawTable, - this->transitionDrawTable, 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); func_80C23518(this); } @@ -49,7 +48,7 @@ void func_80C23518(EnEndingHero3* this) { } void func_80C23534(EnEndingHero3* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -65,6 +64,6 @@ void EnEndingHero3_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, 0, 0, - &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + 0, 0, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h index fc5bb9c0f..b61452d77 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.h @@ -10,8 +10,8 @@ typedef void (*EnEndingHero3ActionFunc)(struct EnEndingHero3*, GlobalContext*); typedef struct EnEndingHero3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[17]; - /* 0x1EE */ Vec3s transitionDrawTable[17]; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; /* 0x254 */ EnEndingHero3ActionFunc actionFunc; /* 0x258 */ u16 unk258; } EnEndingHero3; // size = 0x25C diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 38729764a..949999b57 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -34,8 +34,7 @@ void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600D640, &D_06002A84, this->limbDrawTable, - this->transitionDrawTable, 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D640, &D_06002A84, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); func_80C23748(this); } @@ -49,7 +48,7 @@ void func_80C23748(EnEndingHero4* this) { } void func_80C23764(EnEndingHero4* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -65,6 +64,6 @@ void EnEndingHero4_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, 0, 0, - &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + 0, 0, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h index 048757932..09e3a72ee 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.h @@ -10,8 +10,8 @@ typedef void (*EnEndingHero4ActionFunc)(struct EnEndingHero4*, GlobalContext*); typedef struct EnEndingHero4 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[17]; - /* 0x1EE */ Vec3s transitionDrawTable[17]; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; /* 0x254 */ EnEndingHero4ActionFunc actionFunc; /* 0x258 */ u16 unk258; } EnEndingHero4; // size = 0x25C diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index ec48db441..1e392ef12 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -40,8 +40,7 @@ void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->limbDrawTable, - this->transitionDrawTable, 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); this->unk25C = this->actor.params; func_80C23980(this); @@ -56,7 +55,7 @@ void func_80C23980(EnEndingHero5* this) { } void func_80C2399C(EnEndingHero5* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -106,8 +105,8 @@ void EnEndingHero5_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - func_80C23A30, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80C23A30, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h index a630b56f4..e9f3ecf18 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.h @@ -10,8 +10,8 @@ typedef void (*EnEndingHero5ActionFunc)(struct EnEndingHero5*, GlobalContext*); typedef struct EnEndingHero5 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[17]; - /* 0x1EE */ Vec3s transitionDrawTable[17]; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; /* 0x254 */ EnEndingHero5ActionFunc actionFunc; /* 0x258 */ u16 unk258; /* 0x25C */ s32 unk25C; diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index 334856872..d692d4f11 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -76,8 +76,8 @@ void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitSV(globalCtx, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], - this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], + this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); EnEndingHero6_SetupIdle(this); } @@ -87,8 +87,8 @@ void EnEndingHero6_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex) { this->animIndex = npcIndex; - this->frameCount = SkelAnime_GetFrameCount(&sAnimations[npcIndex]->common); - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, 0, 0.0f); + this->frameCount = Animation_GetLastFrame(sAnimations[npcIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, 0, 0.0f); } void EnEndingHero6_SetupIdle(EnEndingHero6* this) { @@ -98,7 +98,7 @@ void EnEndingHero6_SetupIdle(EnEndingHero6* this) { } void EnEndingHero6_Idle(EnEndingHero6* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -182,8 +182,8 @@ void EnEndingHero6_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C24294[index])); } - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnEndingHero6_PostLimbDraw, &this->actor); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index 3b94a5732..197f07606 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -117,11 +117,11 @@ s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&sAnimations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); } - SkelAnime_ChangeAnim(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, + sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].transitionRate); } return ret; } @@ -137,7 +137,7 @@ void func_80A2D348(EnFg* this, GlobalContext* globalCtx) { } void func_80A2D3D4(EnFg* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } u8 EnFg_UpdateHealth(EnFg* this) { @@ -185,7 +185,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_DEKUSTICK: this->actor.flags &= ~1; Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_1); - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; this->actor.scale.x *= 1.5f; this->actor.scale.z *= 1.5f; @@ -197,7 +197,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { break; case FG_DMGEFFECT_ARROW: this->actor.flags &= ~1; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; rotY = this->collider.base.ac->world.rot.y; rotX = this->collider.base.ac->world.rot.x; this->actor.scale.x = fabsf(0.01f * Math_CosS(rotY)); @@ -213,7 +213,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; this->actor.world.rot.y = Math_Vec3f_Yaw(&ac->world.pos, &this->actor.world.pos); this->actor.shape.rot = this->actor.world.rot; @@ -245,7 +245,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_ARROW: this->actor.flags &= ~1; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; rotY = ac->world.rot.y; rotX = ac->world.rot.x; @@ -264,7 +264,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; - this->skelAnime.animPlaybackSpeed = 0.0f; + this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; this->actor.world.rot.y = Math_Vec3f_Yaw(&ac->world.pos, &this->actor.world.pos); this->actor.shape.rot = this->actor.world.rot; @@ -276,9 +276,9 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_Knockback; break; default: - if (func_801378B8(&this->skelAnime, 8.0f)) { - this->skelAnime.animCurrentFrame = 8.0f; - this->skelAnime.animPlaybackSpeed = 0.0f; + if (Animation_OnFrame(&this->skelAnime, 8.0f)) { + this->skelAnime.curFrame = 8.0f; + this->skelAnime.playSpeed = 0.0f; } if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & 1)) { @@ -321,7 +321,7 @@ void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { EnFg* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 10.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600B538, NULL, this->limbDrawTbl, this->transitionDrawTbl, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, NULL, this->jointTable, this->morphTable, 24); EnFg_UpdateAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -360,8 +360,8 @@ void EnFg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A2D348(this, globalCtx); } -s32 EnFg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - EnFg* this = THIS; +s32 EnFg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg) { + EnFg* this = (EnFg*)arg; if ((limbIndex == 7) || (limbIndex == 8)) { *dList = NULL; @@ -375,23 +375,23 @@ s32 EnFg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return 0; } -void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnFg* this = THIS; +void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnFg* this = (EnFg*)arg; s16 pad; Vec3f vec1 = { 0.0f, 0.0f, 0.0f }; if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_StatePush(); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_StatePush(); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - SysMatrix_StatePop(); + Matrix_StatePop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - SysMatrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); } } @@ -403,9 +403,9 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, { 0, 0, 0, 255 }, }; - SysMatrix_StatePush(); + Matrix_StatePush(); EnFg_DrawDust(globalCtx, &this->dustEffect[0]); - SysMatrix_StatePop(); + Matrix_StatePop(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -414,8 +414,8 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { envColor[this->actor.params].b, envColor[this->actor.params].a); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_060059A0)); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(&D_060059A0)); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnFg_OverrideLimbDraw, EnFg_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFg_OverrideLimbDraw, EnFg_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -476,8 +476,8 @@ void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { alpha = (255.0f / 16.0f) * dustEffect->timer; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPPipeSync(POLY_XLU_DISP++); - SysMatrix_InsertTranslation(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(dustEffect->xyScale, dustEffect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.h b/src/overlays/actors/ovl_En_Fg/z_en_fg.h index 5f12fca6e..45f643a1c 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.h +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.h @@ -42,8 +42,8 @@ typedef struct EnFg { /* 0x144 */ EnFgActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Vec3s limbDrawTbl[24]; - /* 0x268 */ Vec3s transitionDrawTbl[24]; + /* 0x1D8 */ Vec3s jointTable[24]; + /* 0x268 */ Vec3s morphTable[24]; /* 0x2F8 */ s16 timer; /* 0x2FA */ s16 bounceCounter; /* 0x2FC */ EnFgEffectDust dustEffect[10]; diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 6590796ae..716c460a8 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -268,7 +268,7 @@ void EnFirefly_SetupFlyIdle(EnFirefly* this) { this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); this->targetPitch = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; this->actionFunc = EnFirefly_FlyIdle; } @@ -276,12 +276,12 @@ void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { s32 isSkelAnimeUpdated; f32 rand; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; } - isSkelAnimeUpdated = func_801378B8(&this->skelAnime, 0.0f); + isSkelAnimeUpdated = Animation_OnFrame(&this->skelAnime, 0.0f); this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; if (!EnFirefly_ReturnToPerch(this, globalCtx) && !EnFirefly_SeekTorch(this, globalCtx)) { @@ -331,7 +331,7 @@ void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->timer = 40; this->actor.velocity.y = 0.0f; - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &D_0600017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= 0x10; @@ -411,7 +411,7 @@ void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupDiveAttack(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; this->targetPitch = ((this->actor.yDistToPlayer > 0.0f) ? -0xC00 : 0xC00) + 0x1554; this->actionFunc = EnFirefly_DiveAttack; } @@ -420,7 +420,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f preyPos; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; @@ -432,9 +432,9 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); } else if (Actor_IsActorFacingLink(&this->actor, 0x2800)) { - if (func_801378B8(&this->skelAnime, 4.0f)) { - this->skelAnime.animPlaybackSpeed = 0.0f; - this->skelAnime.animCurrentFrame = 4.0f; + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + this->skelAnime.playSpeed = 0.0f; + this->skelAnime.curFrame = 4.0f; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300); @@ -444,7 +444,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &preyPos) + 0x1554, 2, 0x400, 0x100); } else { - this->skelAnime.animPlaybackSpeed = 1.5f; + this->skelAnime.playSpeed = 1.5f; if (this->actor.xzDistToPlayer > 80.0f) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300); } @@ -471,14 +471,14 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupRebound(EnFirefly* this) { this->actor.world.rot.x = 0x7000; this->timer = 18; - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; this->actor.speedXZ = 2.5f; this->actionFunc = EnFirefly_Rebound; } // Knockback after hitting player void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); Math_StepToF(&this->actor.velocity.y, 0.0f, 0.4f); if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.15f)) { @@ -496,11 +496,11 @@ void EnFirefly_SetupFlyAway(EnFirefly* this) { this->timer = 150; this->targetPitch = 0x954; this->actionFunc = EnFirefly_FlyAway; - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; @@ -584,8 +584,8 @@ void EnFirefly_SetupPerch(EnFirefly* this) { void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); if (this->timer != 0) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 6.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->timer--; } } else if (Rand_ZeroOne() < 0.02f) { @@ -598,7 +598,7 @@ void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx) { } void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) { - this->skelAnime.animPlaybackSpeed = 3.0f; + this->skelAnime.playSpeed = 3.0f; this->actor.shape.rot.x = 0x1554; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->timer = 50; @@ -610,7 +610,7 @@ void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f preyPos; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { this->timer--; @@ -705,7 +705,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_801378B8(&this->skelAnime, 5.0f)) { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_FLY); } } @@ -762,7 +762,7 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { - SysMatrix_GetStateTranslation(&auraPos); + Matrix_GetStateTranslation(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); auraPos.y += Rand_ZeroFloat(5.0f); auraPos.z += Rand_ZeroFloat(5.0f); @@ -795,11 +795,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - SysMatrix_GetStateTranslation(&this->unk_2F8); + Matrix_GetStateTranslation(&this->unk_2F8); } else if (limbIndex == 21) { - SysMatrix_GetStateTranslation(&this->unk_304); + Matrix_GetStateTranslation(&this->unk_304); } else if (limbIndex == 10) { - SysMatrix_GetStateTranslation(&this->unk_310); + Matrix_GetStateTranslation(&this->unk_310); } } @@ -824,8 +824,8 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], 0, 0, 0, 255); } - gfx = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnFirefly_OverrideLimbDraw, - EnFirefly_PostLimbDraw, &this->actor, &gfx[2]); + gfx = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFirefly_OverrideLimbDraw, + EnFirefly_PostLimbDraw, &this->actor, &gfx[2]); if (this->isInvisible) { POLY_XLU_DISP = gfx; } else { 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 291495635..606e5f955 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -711,8 +711,8 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->animationIdx == 4) { - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animationSeg->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); if (curFrame == frameCount) { this->animationIdx = 5; func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); @@ -745,15 +745,15 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animationSeg->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; this->animationIdx = 11; func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { - if (this->animationIdx == 11 && func_801378B8(&this->skelAnime, 18.0f)) { + if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { @@ -770,7 +770,7 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { this->animationIdx = 5; func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { - if (func_801378B8(&this->skelAnime, 28.0f)) { + if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); } return; @@ -1398,8 +1398,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->limbDrawTable, - this->transitionDrawTable, 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->jointTable, this->morphTable, 19); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->actor.flags &= ~1; @@ -1442,7 +1441,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { EnFsn_UpdateStickDirectionPromptAnim(this); EnFsn_UpdateCursorAnim(this); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (ENFSN_IS_BACKROOM(&this->actor)) { EnFsn_UpdateCollider(this, globalCtx); } @@ -1559,7 +1558,7 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 limbRotTableIdx; if (limbIndex == 16) { - SysMatrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { @@ -1614,8 +1613,8 @@ void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C5B0(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnFsn_OverrideLimbDraw, EnFsn_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFsn_OverrideLimbDraw, EnFsn_PostLimbDraw, &this->actor); for (i = 0; i < this->totalSellingItems; i++) { this->items[i]->actor.scale.x = 0.2f; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 945bb0d76..139e145da 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -27,8 +27,8 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s limbDrawTable[19]; - /* 0x2F2 */ Vec3s transitionDrawTable[19]; + /* 0x280 */ Vec3s jointTable[19]; + /* 0x2F2 */ Vec3s morphTable[19]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; 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 04ddc07a4..550a54f62 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -200,7 +200,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { if (fuKaiten != NULL) { ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600B2B0, &D_06001F74, this->jointTable, this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B2B0, &D_06001F74, this->jointTable, this->morphTable, + 21); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -366,10 +367,10 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { sp34 = D_80964B24; } - SysMatrix_StatePush(); + Matrix_StatePush(); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - SysMatrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); - SysMatrix_StatePop(); + Matrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); + Matrix_StatePop(); this->actor.focus.pos.x += this->actor.world.pos.x; this->actor.focus.pos.y += this->actor.world.pos.y; this->actor.focus.pos.z += this->actor.world.pos.z; @@ -1341,7 +1342,7 @@ void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_8096209C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80961D7C(globalCtx); func_809640D8(this, globalCtx); func_80964034(this, globalCtx); @@ -1351,17 +1352,17 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFu* this = THIS; if (limbIndex == 9) { - SysMatrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); + Matrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); Matrix_RotateY(this->unk_524[2], MTXMODE_APPLY); - SysMatrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 20) { - SysMatrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); + Matrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); Matrix_RotateY(this->unk_52A[2], MTXMODE_APPLY); - SysMatrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); } return false; } @@ -1372,9 +1373,9 @@ void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnFu* this = THIS; if (limbIndex == 9) { - SysMatrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); + Matrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); } else if (limbIndex == 20) { - SysMatrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); + Matrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); } } @@ -1382,9 +1383,9 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - SysMatrix_StatePush(); + Matrix_StatePush(); func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); - SysMatrix_StatePop(); + Matrix_StatePop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1393,8 +1394,8 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 0, 50, 160, 0)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFu_OverrideLimbDraw, EnFu_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1435,11 +1436,11 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.y += ptr->unk_20.y; ptr->unk_08.x += 2.0f * Math_SinS(ptr->unk_2C); ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); - SysMatrix_StatePush(); - SysMatrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_StatePush(); + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); Matrix_RotateY(activeCam, MTXMODE_APPLY); - SysMatrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); - SysMatrix_StatePop(); + Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); + Matrix_StatePop(); ptr->unk_2C += 6000; } } @@ -1460,8 +1461,8 @@ void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { gSPDisplayList(POLY_OPA_DISP++, D_0600B0A0); flag = true; } - SysMatrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_0405E6F0)); diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 25f89e6f7..9997acd54 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -63,8 +63,7 @@ void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->isStampChecked = false; this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; this->serviceFee = 0; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600C240, &D_060043F0, this->limbDrawTbl, this->transitionDrawTbl, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600C240, &D_060043F0, this->jointTable, this->morphTable, 16); EnGinkoMan_SetupIdle(this); } @@ -496,8 +495,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; } - if ((this->skelAnime.animCurrentSeg == &D_060008C0) && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if ((this->skelAnime.animation == &D_060008C0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); } } @@ -566,11 +564,11 @@ void EnGinkoMan_SetupStamp(EnGinkoMan* this) { void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if ((this->curTextId == 0x464) // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - && (func_801378B8(&this->skelAnime, 10.0f))) { + && (Animation_OnFrame(&this->skelAnime, 10.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); // "stamp" } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); @@ -597,12 +595,12 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer > 160.0f) { if (this->animTimer == 0) { - if (this->skelAnime.animCurrentSeg != &D_06004A7C) { + if (this->skelAnime.animation != &D_06004A7C) { this->animTimer = 40; func_800BDC5C(&this->skelAnime, animations, GINKO_ADVERTISING); } } - } else if ((this->animTimer == 0) && (this->skelAnime.animCurrentSeg != &D_06000AC4)) { + } else if ((this->animTimer == 0) && (this->skelAnime.animation != &D_06000AC4)) { this->animTimer = 40; func_800BDC5C(&this->skelAnime, animations, GINKO_AMAZED); } @@ -611,8 +609,8 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { } void EnGinkoMan_FacePlayer(EnGinkoMan* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (this->skelAnime.animCurrentSeg != &D_06004A7C) { + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.animation != &D_06004A7C) { func_800E9250(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); } else { func_800E8F08(&this->limb15Rot, &this->limb8Rot); @@ -629,27 +627,27 @@ void EnGinkoMan_Update(Actor* thisx, GlobalContext* globalCtx) { } s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { - EnGinkoMan* this = THIS; + Actor* arg) { + EnGinkoMan* this = (EnGinkoMan*)arg; if (limbIndex == 15) { *dList = D_0600B1D8; } if (limbIndex == 15) { - SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, 1); - SysMatrix_InsertXRotation_s(this->limb15Rot.y, 1); - SysMatrix_InsertZRotation_s(this->limb15Rot.x, 1); - SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, 1); + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->limb15Rot.y, 1); + Matrix_InsertZRotation_s(this->limb15Rot.x, 1); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 8) { - SysMatrix_InsertXRotation_s(-this->limb8Rot.y, 1); - SysMatrix_InsertZRotation_s(-this->limb8Rot.x, 1); + Matrix_InsertXRotation_s(-this->limb8Rot.y, 1); + Matrix_InsertZRotation_s(-this->limb8Rot.x, 1); } return 0; } -void EnGinkoMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnGinkoMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { } void EnGinkoMan_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -663,8 +661,8 @@ void EnGinkoMan_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - &EnGinkoMan_OverrideLimbDraw, &EnGinkoMan_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGinkoMan_OverrideLimbDraw, EnGinkoMan_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h index ce992c0b3..e605be1d6 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h @@ -11,8 +11,8 @@ typedef struct EnGinkoMan { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnGinkoManActionFunc actionFunc; - /* 0x18C */ Vec3s limbDrawTbl[0x10]; - /* 0x1EC */ Vec3s transitionDrawTbl[0x10]; + /* 0x18C */ Vec3s jointTable[0x10]; + /* 0x1EC */ Vec3s morphTable[0x10]; /* 0x24C */ Vec3s limb15Rot; /* 0x252 */ Vec3s limb8Rot; /* 0x258 */ s16 curTextId; diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index b87748b8a..71e0c8cd0 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -80,7 +80,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 19.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable, 16); this->actor.targetMode = 0; if (this->actor.params != 2) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -112,9 +112,9 @@ void EnGuruguru_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnGuruguru_ChangeAnimation(EnGuruguru* this, s32 arg1) { - this->frameCount = SkelAnime_GetFrameCount(&D_80BC79CC[arg1]->common); - SkelAnime_ChangeAnim(&this->skelAnime, D_80BC79CC[arg1], D_80BC79D8[arg1], 0.0f, this->frameCount, D_80BC79D4[arg1], - -4.0f); + this->frameCount = Animation_GetLastFrame(D_80BC79CC[arg1]); + Animation_Change(&this->skelAnime, D_80BC79CC[arg1], D_80BC79D8[arg1], 0.0f, this->frameCount, D_80BC79D4[arg1], + -4.0f); } void EnGuruguru_DoNothing(EnGuruguru* this, GlobalContext* globalCtx) { @@ -152,7 +152,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { s16 yaw; s16 yawTemp; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk270 != 0) { Player* player = GET_PLAYER(globalCtx); @@ -194,7 +194,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->unk268 != 0) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } else if (this->unusedTimer == 0) { this->unusedTimer = 6; if (func_80152498(&globalCtx->msgCtx) != 5) { @@ -262,11 +262,11 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { this->texIndex = 1; } if ((this->unk268 != 0) && (this->textIdIndex >= 7)) { - this->skelAnime.animPlaybackSpeed = 2.0f; + this->skelAnime.playSpeed = 2.0f; func_801A29D4(3, 1.18921f, 2); func_801A3B48(0); } else { - if (this->skelAnime.animPlaybackSpeed == 2.0f) { + if (this->skelAnime.playSpeed == 2.0f) { func_801A29D4(3, 1.0f, 2); } if (this->unk268 == 0) { @@ -274,7 +274,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } else { func_801A3B48(0); } - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } this->unk266 = 1; func_80151938(globalCtx, textIDs[this->textIdIndex]); @@ -295,7 +295,7 @@ void func_80BC73F4(EnGuruguru* this) { } void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->textIdIndex++; @@ -311,7 +311,7 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { } void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_80BC7068; } else { @@ -394,7 +394,7 @@ void EnGuruguru_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->texIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->texIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnGuruguru_OverrideLimbDraw, NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGuruguru_OverrideLimbDraw, NULL, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 54c62e52d..7de50c75d 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -27,8 +27,8 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx); void func_80BCF8A0(EnHg* this, GlobalContext* globalCtx); void func_80BCF93C(EnHg* this); void func_80BCF95C(EnHg* this, GlobalContext* globalCtx); -s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); -void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg); +void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg); extern AnimationHeader D_06000370; extern AnimationHeader D_06001138; @@ -127,8 +127,8 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 36.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06008580, &D_0600260C, this->limbDrawTbl, this->transitionDrawTbl, - HG_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008580, &D_0600260C, this->jointTable, this->morphTable, + HG_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); @@ -183,8 +183,8 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { this->actor.speedXZ = 1.6f; if (!(player->stateFlags2 & 0x08000000) && !func_80152498(&globalCtx->msgCtx)) { - if (((this->skelAnime.animCurrentFrame > 9.0f) && (this->skelAnime.animCurrentFrame < 16.0f)) || - ((this->skelAnime.animCurrentFrame > 44.0f) && (this->skelAnime.animCurrentFrame < 51.0f))) { + if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || + ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3E8, 0x14); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -215,7 +215,7 @@ void func_80BCF68C(EnHg* this) { } void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80BCF5F0(this); } } @@ -283,7 +283,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { this->cutscenes[3] = globalCtx->csCtx.npcActions[actionIndex]->unk0; switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: - this->currentAnimation = NULL; + this->currentAnimation = 0; func_800BDC5C(&this->skelAnime, sAnimations, 0); break; case 2: @@ -314,7 +314,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { break; } } else { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; @@ -393,7 +393,7 @@ void EnHg_Update(Actor* thisx, GlobalContext* globalCtx) { EnHg* this = THIS; this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80BCF7D8(this, globalCtx); func_80BCFC0C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 0.0f, 5); @@ -407,9 +407,9 @@ s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; if (limbIndex == HG_LIMB_HEAD) { - SysMatrix_CopyCurrentState(&this->unk1D8); + Matrix_CopyCurrentState(&this->unk1D8); } else if (limbIndex == HG_LIMB_PELVIS) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -418,9 +418,9 @@ void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - SysMatrix_SetCurrentState(&this->unk1D8); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); + Matrix_SetCurrentState(&this->unk1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06005E28); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.h b/src/overlays/actors/ovl_En_Hg/z_en_hg.h index e6825ea45..489db0afb 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.h +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.h @@ -38,8 +38,8 @@ typedef struct EnHg { /* 0x1D8 */ MtxF unk1D8; /* 0x218 */ s32 unk218; /* 0x21C */ s32 currentAnimation; - /* 0x220 */ Vec3s limbDrawTbl[HG_LIMB_MAX]; - /* 0x292 */ Vec3s transitionDrawTbl[HG_LIMB_MAX]; + /* 0x220 */ Vec3s jointTable[HG_LIMB_MAX]; + /* 0x292 */ Vec3s morphTable[HG_LIMB_MAX]; /* 0x304 */ UNK_TYPE1 pad304[0xC]; /* 0x310 */ u16 cutscenes[4]; } EnHg; // size = 0x318 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 ad9e4e873..b2e0a09d9 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -330,7 +330,7 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl = Gfx_CallSetupDL(dl, dlIndex); if (this->playerSide == EN_HOLL_BEHIND) { - SysMatrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(dl++, 0, 0, 0, 0, 0, this->alpha); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index e3b34d19f..fe421558f 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -199,11 +199,11 @@ s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&sAnimations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); } - SkelAnime_ChangeAnim(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, + sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].transitionRate); } return ret; } @@ -279,7 +279,7 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { Vec3f sp30; if (this->unk23D == 0) { - this->unk494 = SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->unk494 = SkelAnime_Update(&this->skelAnime); } if (func_8013D5E8(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; @@ -346,8 +346,8 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { AnimationHeader* animations[] = { &D_06015E38, &D_06016A60, &D_060177AC, &D_06016484, &D_060170DC, &D_06018240, &D_060187C8, &D_060198A8 }; - if (this->skelAnime.animCurrentSeg == &D_06016484 || this->skelAnime.animCurrentSeg == &D_060170DC) { - if (func_801378B8(&this->skelAnime, 8.0f)) { + if (this->skelAnime.animation == &D_06016484 || this->skelAnime.animation == &D_060170DC) { + if (Animation_OnFrame(&this->skelAnime, 8.0f)) { func_8019F88C(&this->actor.projectedPos, NA_SE_VO_IN_LASH_0, 2); if (Rand_ZeroOne() < 0.3f) { func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_INGO_HORSE_NEIGH); @@ -355,13 +355,13 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_LASH); } } - if (this->skelAnime.animCurrentSeg == &D_060198A8 && func_801378B8(&this->skelAnime, 20.0f)) { + if (this->skelAnime.animation == &D_060198A8 && Animation_OnFrame(&this->skelAnime, 20.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_CRY_0); } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->unk486 = this->unk488 %= 8; - SkelAnime_ChangeAnim(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - SkelAnime_GetFrameCount(&animations[this->unk488]->common), 2, -10.0f); + Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, + Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); } } @@ -1399,7 +1399,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06014EA8, NULL, this->limbDrawTbl, this->transitionDrawTbl, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06014EA8, NULL, this->jointTable, this->morphTable, 20); func_808F30B0(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->colliderCylinder); Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); @@ -1415,8 +1415,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); this->unk488 = 1; - SkelAnime_ChangeAnim(&this->skelAnime, &D_06016A60, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06016A60.common), 2, - 0.0f); + Animation_Change(&this->skelAnime, &D_06016A60, 1.0f, 0.0f, Animation_GetLastFrame(&D_06016A60), 2, 0.0f); Actor_SetScale(&this->actor, 0.01f); this->unk23C = 0; this->unk23D = 1; @@ -1443,8 +1442,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { func_808F30B0(&this->skelAnime, 4); } if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { - this->skelAnime.animCurrentFrame = - ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.animFrameCount; + this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { this->actionFunc = func_808F39DC; @@ -1523,7 +1521,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); - SysMatrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (this == (EnIn*)player->targetActor && !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { @@ -1536,8 +1534,8 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { this->unk4C8 = newUnk4C8; } -s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - EnIn* this = THIS; +s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg) { + EnIn* this = (EnIn*)arg; s32 pad; Gfx* sp50[] = { NULL, NULL, D_060149A8, D_06014AE0, D_06014C30, D_060145D8, D_06014710, @@ -1565,15 +1563,15 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 16) { - SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk35A, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(-this->unk358, MTXMODE_APPLY); - SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk35A, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk358, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { Matrix_RotateY(this->unk360, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk35E, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk35E, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); @@ -1597,22 +1595,22 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return 0; } -void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnIn* this = THIS; +void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnIn* this = (EnIn*)arg; Vec3f sp50 = { 1600.0f, 0.0f, 0.0f }; Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 16) { - SysMatrix_MultiplyVector3fByState(&sp50, &this->unk4B4); + Matrix_MultiplyVector3fByState(&sp50, &this->unk4B4); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk4B4); } if (this->unk23D == 0) { Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (limbIndex == 4) { - SysMatrix_MultiplyVector3fByState(&sp44, &this->unk248); + Matrix_MultiplyVector3fByState(&sp44, &this->unk248); } if (limbIndex == 7) { - SysMatrix_MultiplyVector3fByState(&sp44, &this->unk254); + Matrix_MultiplyVector3fByState(&sp44, &this->unk254); } if (this->unk23C == 0) { if (!(this->unk4AC & 8)) { @@ -1642,7 +1640,7 @@ void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnIn_OverrideLimbDraw, EnIn_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnIn_OverrideLimbDraw, EnIn_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index e874ced5d..ca67df431 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -34,8 +34,8 @@ typedef struct EnIn { /* 0x254 */ Vec3f unk254; /* 0x260 */ u8 unk260; /* 0x261 */ u8 unk261; - /* 0x262 */ Vec3s limbDrawTbl[20]; - /* 0x2DA */ Vec3s transitionDrawTbl[20]; + /* 0x262 */ Vec3s jointTable[20]; + /* 0x2DA */ Vec3s morphTable[20]; /* 0x352 */ s16 unk352; /* 0x354 */ s16 unk354; /* 0x356 */ char unk356[0x2]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index a6aaa90c4..42b9a6c91 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -325,7 +325,7 @@ static Gfx* D_80B4E984[] = { static s8 D_80B4E994 = 0; -static s8 D_80B4E998 = NULL; +static s8 D_80B4E998 = 0; static s8 D_80B4E99C[] = { 0 }; @@ -1369,7 +1369,7 @@ void func_80B454BC(EnInvadepoh* this, GlobalContext* globalCtx) { } void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = SysMatrix_GetCurrentState(); + MtxF* sysMatrix = Matrix_GetCurrentState(); sysMatrix->wx = vec->x; sysMatrix->wy = vec->y; @@ -2160,7 +2160,7 @@ void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47568(EnInvadepoh* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06001D80, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06001D80, -6.0f); this->collider.base.atFlags &= ~0x1; this->collider.base.acFlags &= ~0x1; this->collider.base.ocFlags1 &= ~0x1; @@ -2202,8 +2202,8 @@ void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4770C(EnInvadepoh* this) { - if (this->skelAnime.animCurrentSeg != &D_06001D80) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06001D80, -6.0f); + if (this->skelAnime.animation != &D_06001D80) { + Animation_MorphToLoop(&this->skelAnime, &D_06001D80, -6.0f); } this->collider.base.atFlags |= 1; this->collider.base.acFlags |= 1; @@ -2231,7 +2231,7 @@ void func_80B47830(EnInvadepoh* this) { this->collider.base.atFlags &= ~1; this->collider.base.acFlags &= ~1; this->collider.base.ocFlags1 |= 1; - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060006C8); + Animation_PlayLoop(&this->skelAnime, &D_060006C8); func_800BCB70(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; this->actor.draw = func_80B4DB14; @@ -2256,7 +2256,7 @@ void func_80B47938(EnInvadepoh* this) { this->collider.base.atFlags &= ~1; this->collider.base.acFlags &= ~1; this->collider.base.ocFlags1 &= ~1; - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06000608); + Animation_PlayLoop(&this->skelAnime, &D_06000608); this->actor.flags &= ~1; this->actionTimer = 10; this->alienAlpha = 255; @@ -2327,9 +2327,9 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B47D30; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06004E50, &D_06001D80, this->limbDrawTable, - this->transitionDrawTable, 14); - this->skelAnime.animCurrentFrame = (this->actor.params & 7) * this->skelAnime.animFrameCount * 0.125f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001D80, this->jointTable, this->morphTable, + 14); + this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.125f; func_80B444BC(this, globalCtx); func_80B442E4(this); func_80B447C0(this, globalCtx); @@ -2378,7 +2378,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (thisx->draw != NULL) { - this->animPlayFlag = SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->animPlayFlag = SkelAnime_Update(&this->skelAnime); } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -2410,9 +2410,8 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06004010, NULL, this->limbDrawTable, this->transitionDrawTable, - 6); - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06004264); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004010, NULL, this->jointTable, this->morphTable, 6); + Animation_PlayLoop(&this->skelAnime, &D_06004264); } } @@ -2429,19 +2428,19 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { } temp = this->actor.params & 7; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, D_80B4EDC0[temp], 0x32); if (this->actor.child != NULL) { - SysMatrix_StatePush(); - SysMatrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, &this->actor.shape.rot); - SysMatrix_InsertTranslation(0, 57.0f, -36.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); - SysMatrix_GetStateTranslation(&this->actor.child->world.pos); - SysMatrix_CopyCurrentState(&unkMtx); + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_InsertTranslation(0, 57.0f, -36.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->actor.child->world.pos); + Matrix_CopyCurrentState(&unkMtx); func_8018219C(&unkMtx, &this->actor.child->shape.rot, 0); - SysMatrix_StatePop(); + Matrix_StatePop(); } } @@ -2454,9 +2453,8 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06004C30, NULL, this->limbDrawTable, this->transitionDrawTable, - 6); - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06004E98); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004C30, NULL, this->jointTable, this->morphTable, 6); + Animation_PlayLoop(&this->skelAnime, &D_06004E98); } } @@ -2468,12 +2466,12 @@ void func_80B4827C(Actor* thisx, GlobalContext* globalCtx) { return; } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } void func_80B482D4(EnInvadepoh* this) { this->actionTimer = 40; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06002A8C, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06002A8C, -10.0f); this->actor.draw = NULL; this->actionFunc = func_80B48324; } @@ -2489,7 +2487,7 @@ void func_80B48324(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B48374(EnInvadepoh* this) { this->actionTimer = 60; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06002A8C, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06002A8C, -10.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B483CC; } @@ -2521,7 +2519,7 @@ void func_80B4843C(EnInvadepoh* this) { this->behaviorInfo.unk44 = 0.1f; this->behaviorInfo.unk48 = 2000; this->actionTimer = 50; - SkelAnime_ChangeAnim(&this->skelAnime, &D_06007328, 2.0f, 0.0f, 0.0f, 0, -5.0f); + Animation_Change(&this->skelAnime, &D_06007328, 2.0f, 0.0f, 0.0f, 0, -5.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B484EC; } @@ -2551,7 +2549,7 @@ void func_80B48588(EnInvadepoh* this) { this->behaviorInfo.unk42 = 0; this->behaviorInfo.unk44 = 0.28f; this->behaviorInfo.unk48 = 7000; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009E58, -10.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B48610; } @@ -2568,10 +2566,10 @@ void func_80B48620(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4873C; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->limbDrawTable, - this->transitionDrawTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->jointTable, this->morphTable, + 23); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &D_801D15BC, 5000, 0.05f, 0.3f, 0.12f); - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06009E58); + Animation_PlayLoop(&this->skelAnime, &D_06009E58); func_80B482D4(this); } } @@ -2586,7 +2584,7 @@ void func_80B4873C(Actor* thisx, GlobalContext* globalCtx) { return; } this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B45CE0(substruct); if (substruct->unk40 != 0) { this->actor.shape.rot.x = -substruct->unk40; @@ -2604,7 +2602,7 @@ void func_80B487B4(EnInvadepoh* this) { substruct->unk26.z = 0; substruct->unk30 = 0.1f; substruct->unk2C = 800; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06014088, -10.0f); this->actionFunc = func_80B48848; } @@ -2621,7 +2619,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { } func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); if (((this->actor.flags & 0x40) == 0x40) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 7.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->actionTimer > 0) { @@ -2664,7 +2662,7 @@ void func_80B48948(EnInvadepoh* this) { substruct->unk2C = 1000; } - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); this->actionFunc = func_80B48AD4; } @@ -2735,7 +2733,7 @@ void func_80B48DE4(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; this->actor.speedXZ = 0.0f; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); this->behaviorInfo.unk4C = 0; substruct->unk30 = 0.05f; substruct->unk2C = 1200; @@ -2772,8 +2770,8 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { this->actor.update = func_80B490F0; this->actor.draw = func_80B4E324; this->actor.textId = 0x3330; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->limbDrawTable, - this->transitionDrawTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->jointTable, this->morphTable, + 23); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &D_801D15BC, 100, 0.03, 0.3, 0.03); func_80B444F4(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -2795,7 +2793,7 @@ void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); if (sp2C) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B48E4C) && !isTalking && this->actor.isTargeted) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -3042,7 +3040,7 @@ void func_80B49B1C(Actor* thisx, GlobalContext* globalCtx) { void func_80B49BD0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06014088, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3074,7 +3072,7 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { } if (((this->actor.flags & 0x40) == 0x40) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 7.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { @@ -3086,7 +3084,7 @@ void func_80B49DA0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; this->behaviorInfo.unk4C = 0; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); this->actionFunc = func_80B49DFC; } @@ -3124,8 +3122,8 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44F58(); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->limbDrawTable, - this->transitionDrawTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, + 23); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &D_801D15BC, 100, 0.03, 0.3, 0.03); func_80B44540(this, globalCtx); func_80B44570(this); @@ -3178,7 +3176,7 @@ void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); if (sp2C && this->actor.update != NULL) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B49DFC) && !isTalking && this->actor.isTargeted) { func_800B8614(&this->actor, globalCtx, 350.0f); @@ -3191,7 +3189,7 @@ void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A2C0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3250,7 +3248,7 @@ void func_80B4A350(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4A570(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06002A8C, -10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A8C, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3269,7 +3267,7 @@ void func_80B4A5E4(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4A614(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06014088, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06014088, 0.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3300,7 +3298,7 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.flags |= (0x8 | 0x1); } if (((this->actor.flags & 0x40) == 0x40) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 7.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->pathIndex == this->endPoint) { @@ -3312,7 +3310,7 @@ void func_80B4A7C0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; this->behaviorInfo.unk4C = 0; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, 0.0f); this->actionFunc = func_80B4A81C; } @@ -3355,8 +3353,8 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44F58(); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->limbDrawTable, - this->transitionDrawTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, + 23); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); func_80B44620(this, globalCtx); if ((sp38 < CLOCK_TIME(2, 15)) || (sp38 >= CLOCK_TIME(6, 0))) { @@ -3407,7 +3405,7 @@ void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); if (sp2C) { - this->animPlayFlag = SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->animPlayFlag = SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4A81C) && !isTalking && this->actor.isTargeted) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -3530,9 +3528,9 @@ void func_80B4B0C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4B218; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->limbDrawTable, - this->transitionDrawTable, 23); - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, + 23); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, 0.0f); substruct = &this->behaviorInfo; func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &D_801D15BC, 2000, 0.08f, 0.3f, 0.03f); substruct->unk30 = 0.08f; @@ -3553,7 +3551,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (sp38 && this->actor.update != NULL) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); player = GET_PLAYER(globalCtx); Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); @@ -3573,13 +3571,13 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { void func_80B4B3DC(EnInvadepoh* this) { s32 pad; - if (func_801378B8(&this->skelAnime, 1.0f) || func_801378B8(&this->skelAnime, 7.0f)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); } } void func_80B4B430(EnInvadepoh* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060021C8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_060021C8, -6.0f); this->actionTimer = Rand_S16Offset(50, 80); this->actionFunc = func_80B4B484; } @@ -3602,7 +3600,7 @@ void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B510(EnInvadepoh* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06001BD8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06001BD8, -6.0f); this->actionTimer = Rand_S16Offset(50, 200); this->actionFunc = func_80B4B564; } @@ -3646,7 +3644,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B724(EnInvadepoh* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06000998, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000998, -6.0f); this->actionFunc = func_80B4B768; } @@ -3657,7 +3655,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, Actor_YawBetweenActors(&this->actor, &D_80B5040C->actor), 5, 0x1388, 0x64); func_80B44E90(this, globalCtx); - if (func_801378B8(&this->skelAnime, 13.0f) || func_801378B8(&this->skelAnime, 19.0f)) { + if (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 19.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } if (this->animPlayFlag) { @@ -3666,7 +3664,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B820(EnInvadepoh* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001560, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001560, -6.0f); this->actionFunc = func_80B4B864; } @@ -3685,8 +3683,8 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectSegment(globalCtx, &this->actor); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060080F0, &D_060021C8, this->limbDrawTable, - this->transitionDrawTable, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, &D_060021C8, this->jointTable, this->morphTable, + 13); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &D_801D15BC, 3000, 0.1f, 0.0f, 0.0f); func_80B44664(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -3755,7 +3753,7 @@ void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); - this->animPlayFlag = SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->animPlayFlag = SkelAnime_Update(&this->skelAnime); if (sp34 && (this->actor.update != NULL)) { func_80B45CE0(&this->behaviorInfo); Collider_UpdateCylinder(&this->actor, &this->collider); @@ -3766,7 +3764,7 @@ void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { void func_80B4BBE0(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06016720, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06016720, -6.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -3834,7 +3832,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { } if (((this->actor.flags & 0x40) == 0x40) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 12.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } if (gSaveContext.time > CLOCK_TIME(20, 15)) { @@ -3847,7 +3845,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4BFFC(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600A174, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600A174, -6.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4C058; } @@ -3879,7 +3877,7 @@ void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4C1BC(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600A174, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600A174, -6.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4C218; } @@ -3919,8 +3917,8 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44FEC(); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06015C28, &D_06016720, this->limbDrawTable, - this->transitionDrawTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, &D_06016720, this->jointTable, this->morphTable, + 22); func_80B45C04(&this->behaviorInfo, D_80B4EBDC, 1, D_80B4EC08, 0, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); this->actor.textId = 0x33CD; if (currentTime < 0xD5A0) { @@ -3969,7 +3967,7 @@ void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); if (sp2C && (this->actor.update != NULL)) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4C058) && !isTalking && this->actor.isTargeted) { func_800B8614(&this->actor, globalCtx, 350.0f); @@ -3982,7 +3980,7 @@ void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C6C8(EnInvadepoh* this) { AlienBehaviorInfo* substruct = &this->behaviorInfo; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06014088, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06014088, -10.0f); substruct->unk26.x = 0; substruct->unk26.y = 0; substruct->unk26.z = 0; @@ -4055,7 +4053,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { } if (((this->actor.flags & 0x40) == 0x40) && - (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 7.0f))) { + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -4072,7 +4070,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4CAB0(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 4000; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4CB0C; } @@ -4101,7 +4099,7 @@ void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B4CC70(EnInvadepoh* this) { this->behaviorInfo.unk30 = 0.08f; this->behaviorInfo.unk2C = 2000; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06009E58, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06009E58, -10.0f); this->behaviorInfo.unk4C = 0; this->actionFunc = func_80B4CCCC; } @@ -4140,8 +4138,8 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectSegment(globalCtx, &this->actor); func_80B44F58(); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->limbDrawTable, - this->transitionDrawTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, + 23); func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); func_80B446D0(this, globalCtx); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -4185,7 +4183,7 @@ void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); if (sp2C && this->actor.update != NULL) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80B45CE0(&this->behaviorInfo); if ((this->actionFunc != func_80B4CB0C) && !isTalking && this->actor.isTargeted) { func_800B8614(thisx, globalCtx, 350.0f); @@ -4200,8 +4198,8 @@ void func_80B4D15C(EnInvadepoh* this) { s32 temp_v1 = this->actor.params & 7; unkstruct80B4EE0C* temp_v0; - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06001674); - this->skelAnime.animCurrentFrame = ((this->actor.params & 7) * this->skelAnime.animFrameCount) * 0.25f; + Animation_PlayLoop(&this->skelAnime, &D_06001674); + this->skelAnime.curFrame = ((this->actor.params & 7) * this->skelAnime.endFrame) * 0.25f; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; @@ -4252,8 +4250,8 @@ void func_80B4D290(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4D3E4(EnInvadepoh* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06001674); - this->skelAnime.animCurrentFrame = (this->actor.params & 7) * this->skelAnime.animFrameCount * 0.25f; + Animation_PlayLoop(&this->skelAnime, &D_06001674); + this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.25f; this->alienAlpha = 255; this->actor.draw = NULL; this->drawAlien = true; @@ -4329,8 +4327,8 @@ void func_80B4D670(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectSegment(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B4D760; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06004E50, &D_06001674, this->limbDrawTable, - this->transitionDrawTable, 14); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001674, this->jointTable, this->morphTable, + 14); if (invadepohType < 3) { func_80B453F4(this, globalCtx, invadepohType); func_80B4D15C(this); @@ -4346,7 +4344,7 @@ void func_80B4D760(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actor.update != NULL) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); } } @@ -4365,7 +4363,7 @@ void func_80B4D7B8(GlobalContext* globalCtx) { temp_v0 = globalCtx->gameplayFrames; temp_s5 = (temp_v0 + ((0x10 * i) & 0xFFU)) & 0x7F; temp_s6 = (u8)(temp_v0 * -0xF); - SysMatrix_InsertTranslation(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); + Matrix_InsertTranslation(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); @@ -4394,22 +4392,22 @@ void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - SysMatrix_StatePush(); - SysMatrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); Matrix_RotateY(-0x3830, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - SysMatrix_CopyCurrentState(&D_80B502A0); - SysMatrix_StatePop(); + Matrix_CopyCurrentState(&D_80B502A0); + Matrix_StatePop(); } else if ((limbIndex == 13) && (this->alienBeamAlpha != 0)) { - SysMatrix_StatePush(); - SysMatrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); Matrix_RotateY(-0x47D0, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - SysMatrix_CopyCurrentState(&D_80B502E0); - SysMatrix_StatePop(); + Matrix_CopyCurrentState(&D_80B502E0); + Matrix_StatePop(); } if (limbIndex == 11) { - SysMatrix_MultiplyVector3fByState(&D_80B4EE24, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_80B4EE24, &this->actor.focus.pos); } } @@ -4420,7 +4418,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(spCC); func_8012C2DC(spCC); - SysMatrix_StatePush(); + Matrix_StatePush(); if (this->drawAlien) { Gfx* new_var6; Gfx* spBC; @@ -4431,16 +4429,16 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, D_80B50400); Scene_SetRenderModeXlu(globalCtx, 0, 1); gDPSetEnvColor(spCC->polyOpa.p++, 0, 0, 0, 255); - spCC->polyOpa.p = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, - spCC->polyOpa.p); + spCC->polyOpa.p = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, + spCC->polyOpa.p); } else { AnimatedMat_Draw(globalCtx, D_80B50400); Scene_SetRenderModeXlu(globalCtx, 1, 2); gDPSetEnvColor(spCC->polyXlu.p++, 0, 0, 0, this->alienAlpha); - spCC->polyXlu.p = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, - spCC->polyXlu.p); + spCC->polyXlu.p = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, + spCC->polyXlu.p); } if (this->alienBeamAlpha != 0) { @@ -4450,10 +4448,10 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(spBC++); gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - SysMatrix_InsertMatrix(&D_80B502A0, MTXMODE_NEW); + Matrix_InsertMatrix(&D_80B502A0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, D_06000080); - SysMatrix_InsertMatrix(&D_80B502E0, MTXMODE_NEW); + Matrix_InsertMatrix(&D_80B502E0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, D_06000080); spB8->polyXlu.p = spBC; @@ -4461,8 +4459,8 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } if (this->drawAlienDeathEffect) { - SysMatrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, MTXMODE_APPLY); gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4482,12 +4480,12 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - SysMatrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_NEW); - SysMatrix_GetStateTranslationAndScaledZ(60.0f, &sp80); + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(60.0f, &sp80); sp74.x = thisx->world.pos.x + sp80.x; sp74.y = thisx->world.pos.y + sp80.y + 68.0f; sp74.z = thisx->world.pos.z + sp80.z; - SysMatrix_InsertTranslation(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); + Matrix_InsertTranslation(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); Matrix_Scale(0.25f, 0.25f, 0.25f, MTXMODE_APPLY); alpha2 = this->alienAlpha * (100.0f / 255.0f); gSPDisplayList(gfx++, D_04029CB0); @@ -4501,7 +4499,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } } - SysMatrix_StatePop(); + Matrix_StatePop(); CLOSE_DISPS(spCC); } @@ -4517,26 +4515,28 @@ void func_80B4E158(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_80B4E120, NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B4E120, NULL, &this->actor); } void func_80B4E1B0(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); } s32 func_80B4E200(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if (limbIndex == 14) { EnInvadepoh* this = THIS; // both of these needed to match + rot->x += this->behaviorInfo.unk20.y; rot->y += this->behaviorInfo.unk20.z; rot->z += this->behaviorInfo.unk20.x; } else if (limbIndex == 13) { EnInvadepoh* this = THIS; // both of these needed to match + rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); rot->z += this->behaviorInfo.unk40; } @@ -4551,7 +4551,7 @@ void func_80B4E2AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* gSPDisplayList(POLY_OPA_DISP++, D_060003B0); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { - SysMatrix_MultiplyVector3fByState(&D_80B4EE30, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_80B4EE30, &this->actor.focus.pos); } } @@ -4562,8 +4562,8 @@ void func_80B4E324(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, D_80B4E958[this->behaviorInfo.unk10.unkF]); gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4E944[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_80B4E200, func_80B4E2AC, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B4E200, func_80B4E2AC, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -4571,16 +4571,16 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; Vec3f sp5C; - SysMatrix_StatePush(); - SysMatrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_NEW); - SysMatrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); - SysMatrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); + Matrix_StatePop(); sp5C.x += thisx->world.pos.x; sp5C.y += thisx->world.pos.y; sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); - SysMatrix_InsertZRotation_s(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertZRotation_s(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4598,6 +4598,7 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7)) { EnInvadepoh* this = THIS; + rot->x += this->behaviorInfo.unk20.x; rot->y += this->behaviorInfo.unk20.y; rot->z += this->behaviorInfo.unk20.z; @@ -4607,8 +4608,10 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnInvadepoh* this = THIS; + if (limbIndex == 5) { - SysMatrix_GetStateTranslationAndScaledY(20.0f, &thisx->focus.pos); + Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); } } @@ -4618,27 +4621,31 @@ void func_80B4E660(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_80B4E5B0, func_80B4E61C, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B4E5B0, func_80B4E61C, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } s32 func_80B4E6E4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { if (limbIndex == 9) { EnInvadepoh* this = THIS; // both of these needed to match + rot->x += this->behaviorInfo.unk20.y; rot->y += this->behaviorInfo.unk20.z; rot->z += this->behaviorInfo.unk20.x; } else if (limbIndex == 2) { EnInvadepoh* this = THIS; // both of these needed to match + rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); } return 0; } void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnInvadepoh* this = THIS; + if (limbIndex == 9) { - SysMatrix_GetStateTranslation(&thisx->focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -4649,7 +4656,7 @@ void func_80B4E7BC(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, D_80B4E984[this->behaviorInfo.unk10.unkF]); gSPSegment(POLY_OPA_DISP++, 0x08, D_80B4E96C[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - func_80B4E6E4, func_80B4E784, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B4E6E4, func_80B4E784, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h index 8b766189f..3a242eace 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h @@ -109,8 +109,8 @@ typedef struct AlienBehaviorInfo { typedef struct EnInvadepoh { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[23]; - /* 0x212 */ Vec3s transitionDrawTable[23]; + /* 0x188 */ Vec3s jointTable[23]; + /* 0x212 */ Vec3s morphTable[23]; /* 0x29C */ s8 animPlayFlag; /* 0x2A0 */ ColliderCylinder collider; /* 0x2EC */ EnInvadepohActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 3fee5e073..7390d9f7c 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -163,6 +163,6 @@ void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000390); - SysMatrix_MultiplyVector3fByState(&movement, &this->pos); + Matrix_MultiplyVector3fByState(&movement, &this->pos); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 457178720..26bf172bc 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -67,7 +67,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600F910, &D_06004B98, this->jointTable, this->morphTable, 23); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600F910, &D_06004B98, this->jointTable, this->morphTable, 23); this->unk_2D2 = -1; this->unk_29C = 0; this->unk_2E4 = 0; @@ -131,8 +131,8 @@ void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 transitionRate) { &D_06001764, &D_06003334, &D_06010B84, &D_06001EA4, &D_06003D88, }; - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, - SkelAnime_GetFrameCount(&sAnimations[animIndex]->common), mode, transitionRate); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[animIndex]), mode, transitionRate); this->unk_2D2 = animIndex; } @@ -432,7 +432,7 @@ void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { this->actor.focus.pos = this->unk_2A8; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 6) { if (this->unk_2EA > 0) { EnKgy_ChangeAnim(this, 6, 2, 0.0f); @@ -444,10 +444,10 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { } else { EnKgy_ChangeAnim(this, 6, 2, -5.0f); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } - switch ((s32)this->skelAnime.animCurrentFrame) { + switch ((s32)this->skelAnime.curFrame) { case 1: case 7: case 13: @@ -523,7 +523,7 @@ void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { } void func_80B41A48(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk_2E4 > 0) { this->unk_2E4--; } else { @@ -536,7 +536,7 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { s32 temp_v0; Player* player = GET_PLAYER(globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (func_80152498(&globalCtx->msgCtx) == 0x10) { temp_v0 = func_80123810(globalCtx); if (temp_v0 != 0) { @@ -585,7 +585,7 @@ void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { } void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (func_800B867C(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; this->actor.flags &= ~0x100; @@ -594,7 +594,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { } void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (func_800B84D0(&this->actor, globalCtx)) { this->actor.flags &= ~0x10000; func_80B40E18(this, this->actor.textId); @@ -606,7 +606,7 @@ void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { } void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; this->actor.flags |= 0x10000; @@ -622,7 +622,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 3)) { + if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 3)) { func_80B40BC0(this, 4); } @@ -844,7 +844,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { this->actionFunc = func_80B41E18; @@ -854,7 +854,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { } void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_80B41E18; @@ -867,7 +867,7 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { } void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); @@ -883,7 +883,7 @@ void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { func_80B411DC(this, globalCtx, 4); @@ -900,7 +900,7 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { s32 pad; u16 temp_a2; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 5) { func_80B40BC0(this, 7); } @@ -946,7 +946,7 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 8)) { + if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { func_80B40BC0(this, 2); } @@ -971,7 +971,7 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { u16 temp_a2; s32 pad; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 5) { func_80B40BC0(this, 1); } @@ -1058,7 +1058,7 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 8)) { + if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { func_80B40BC0(this, 2); } @@ -1134,11 +1134,11 @@ void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKgy* this = THIS; if (limbIndex == 11) { - SysMatrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); + Matrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); } if (limbIndex == 16) { - SysMatrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); + Matrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); } } @@ -1150,9 +1150,9 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); - SysMatrix_StatePush(); - SysMatrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); if (func_80B40D8C(globalCtx)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(D_0600F6A0)); @@ -1174,7 +1174,7 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - SysMatrix_StatePop(); + Matrix_StatePop(); } void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -1184,6 +1184,6 @@ void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_29C & 1) { func_80B43074(this, globalCtx); } - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnKgy_OverrideLimbDraw, EnKgy_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKgy_OverrideLimbDraw, EnKgy_PostLimbDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index b83fba1b4..e2ff014c9 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -154,9 +154,9 @@ static struct_80B8E1A8 sAnimationInfo[] = { }; void EnMa4_ChangeAnim(EnMa4* this, s32 index) { - SkelAnime_ChangeAnim(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&sAnimationInfo[index].animationSeg->common), - sAnimationInfo[index].mode, sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, + sAnimationInfo[index].transitionRate); } void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { @@ -164,8 +164,8 @@ void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { s16 flag; if (this->unk_1D8.unk_00 == 0 && - ((this->skelAnime.animCurrentSeg == &D_06007328) || (this->skelAnime.animCurrentSeg == &D_06002A8C) || - (this->skelAnime.animCurrentSeg == &D_06015B7C))) { + ((this->skelAnime.animation == &D_06007328) || (this->skelAnime.animation == &D_06002A8C) || + (this->skelAnime.animation == &D_06015B7C))) { flag = 1; } else { flag = (this->type == MA4_TYPE_ALIENS_WON && this->actionFunc != EnMa4_DialogueHandler) ? 1 : 0; @@ -201,8 +201,8 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, NULL, this->limbDrawTable, this->transitionDrawTable, - MA1_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, + MA1_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -270,7 +270,7 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { s32 pad; s16 sp2E; - if (sCurrentAnim != 9 && func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (sCurrentAnim != 9 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (sCurrentAnim == 3) { if (D_80AC0250 < 3) { D_80AC0250++; @@ -286,7 +286,7 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } } - if (sCurrentAnim == 13 && func_801378B8(&this->skelAnime, 37.0f)) { + if (sCurrentAnim == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); } @@ -318,8 +318,8 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - if (this->skelAnime.animCurrentSeg == &D_06007328) { // Walking animation - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 4.0f)) { + if (this->skelAnime.animation == &D_06007328) { // Walking animation + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); } } @@ -353,7 +353,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; } else if (this->type != MA4_TYPE_ALIENS_WON) { EnMa4_RunInCircles(this, globalCtx); - } else if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->animTimer++; if (this->animTimer == 5) { EnMa4_ChangeAnim(this, 17); // Traumatized anim @@ -843,8 +843,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { } func_800EDF24(&this->actor, globalCtx, actionIndex); - if (D_80AC0260 == 2 && this->animTimer == 0 && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } } else { @@ -1042,7 +1041,7 @@ void EnMa4_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnMa4_UpdateEyes(this); this->actionFunc(this, globalCtx); func_80ABDD9C(this, globalCtx); @@ -1071,7 +1070,7 @@ void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; if (limbIndex == MA1_LIMB_HEAD) { - SysMatrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1095,8 +1094,8 @@ void EnMa4_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnMa4_OverrideLimbDraw, EnMa4_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMa4_OverrideLimbDraw, EnMa4_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h index 1ecc67ed5..b1e25569b 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h @@ -15,9 +15,9 @@ typedef struct EnMa4 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ Vec3s* pathPoints; - /* 0x204 */ Vec3s limbDrawTable[MA1_LIMB_MAX]; + /* 0x204 */ Vec3s jointTable[MA1_LIMB_MAX]; /* 0x28E */ UNK_TYPE1 unk28E[0x6]; - /* 0x294 */ Vec3s transitionDrawTable[MA1_LIMB_MAX]; + /* 0x294 */ Vec3s morphTable[MA1_LIMB_MAX]; /* 0x31E */ UNK_TYPE1 unk31E[0x6]; /* 0x324 */ s16 pathIndex; /* 0x326 */ s16 pathPointsCount; diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index b8f7f969b..9d9969e68 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -189,8 +189,8 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06015C28, NULL, this->limbDrawTbl, this->transitionDrawTbl, - MA2_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, NULL, this->jointTable, this->morphTable, + MA2_LIMB_MAX); EnMaYto_InitAnimation(this, globalCtx); Collider_InitCylinder(globalCtx, &this->collider); @@ -464,8 +464,8 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3000, 0x100); - if (this->textId == 0x3395 && this->skelAnime.animCurrentSeg == &D_0600AF7C && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (this->textId == 0x3395 && this->skelAnime.animation == &D_0600AF7C && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 4); } } @@ -1081,8 +1081,8 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { } func_800EDF24(&this->actor, globalCtx, csActionIndex); - if (D_80B915F0 == 2 && this->skelAnime.animCurrentSeg == &D_06001FD0 && - func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (D_80B915F0 == 2 && this->skelAnime.animation == &D_06001FD0 && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); } } else { @@ -1293,16 +1293,16 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { - SkelAnime_ChangeAnim(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&sAnimationInfo[index].animationSeg->common), - sAnimationInfo[index].mode, sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, + sAnimationInfo[index].transitionRate); } void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 flag; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); flag = this->unk31E == 2 ? true : false; if (this->unk31E == 0) { @@ -1464,12 +1464,12 @@ s32 EnMaYto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis rot->x += sp4.y; rot->z += sp4.x; } else if (limbIndex == MA2_LIMB_TORSO) { - if (this->skelAnime.animCurrentSeg != &D_06007E28 && this->skelAnime.animCurrentSeg != &D_06003D54) { + if (this->skelAnime.animation != &D_06007E28 && this->skelAnime.animation != &D_06003D54) { sp4 = this->unk_1D8.unk_0E; rot->x += sp4.y; - if (this->skelAnime.animCurrentSeg == &D_0600A174 || this->skelAnime.animCurrentSeg == &D_060070EC || - this->skelAnime.animCurrentSeg == &D_06003D54) { + if (this->skelAnime.animation == &D_0600A174 || this->skelAnime.animation == &D_060070EC || + this->skelAnime.animation == &D_06003D54) { rot->z += sp4.x; } } @@ -1481,7 +1481,7 @@ void EnMaYto_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYto* this = THIS; if (limbIndex == MA2_LIMB_HEAD) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -1499,8 +1499,8 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyesTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnMaYto_OverrideLimbDraw, EnMaYto_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMaYto_OverrideLimbDraw, EnMaYto_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h index 0fe7e009f..0feaea48a 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h @@ -42,8 +42,8 @@ typedef struct EnMaYto { /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ s32 unk200; // unused /* 0x204 */ s32 type; - /* 0x208 */ Vec3s limbDrawTbl[MA2_LIMB_MAX]; - /* 0x28C */ Vec3s transitionDrawTbl[MA2_LIMB_MAX]; + /* 0x208 */ Vec3s jointTable[MA2_LIMB_MAX]; + /* 0x28C */ Vec3s morphTable[MA2_LIMB_MAX]; /* 0x310 */ s16 unk310; // state? /* 0x312 */ UNK_TYPE1 unk_312[0x2]; /* 0x314 */ s16 currentAnim; // Used only in DefaultWait diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 786dee4ba..266ba90e9 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -125,12 +125,6 @@ static struct_80B8E1A8 sAnimationInfo[] = { { &D_060180DC, 1.0f, 2, 0.0f }, { &D_060180DC, 1.0f, 2, -6.0f }, // Turns around anim }; -void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - SkelAnime_ChangeAnim(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&sAnimationInfo[index].animationSeg->common), - sAnimationInfo[index].mode, sAnimationInfo[index].transitionRate); -} - static void* sMouthTextures[] = { D_060127C8, D_06012BC8, @@ -142,6 +136,12 @@ static void* sEyeTextures[] = { D_0600FFC8, D_060107C8, D_06010FC8, D_060117C8, D_06011FC8, }; +void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { + Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, + sAnimationInfo[index].transitionRate); +} + void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 flag = this->unk_32C == 2 ? true : false; @@ -246,8 +246,8 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, NULL, this->limbDrawTbl, this->transitionDrawTbl, - MA1_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, + MA1_LIMB_MAX); EnMaYts_InitAnimation(this, globalCtx); Collider_InitCylinder(globalCtx, &this->collider); @@ -435,7 +435,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { func_800EDF24(&this->actor, globalCtx, actionIndex); if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && - (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) != 0)) { + (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) != 0)) { this->endCreditsFlag++; EnMaYts_ChangeAnim(this, 5); } @@ -517,20 +517,19 @@ void EnMaYts_Update(Actor* thisx, GlobalContext* globalCtx) { collider = &this->collider; Collider_UpdateCylinder(&this->actor, collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnMaYts_UpdateEyes(this); func_80B8D12C(this, globalCtx); } -s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { - EnMaYts* this = THIS; +s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg) { + EnMaYts* this = (EnMaYts*)arg; Vec3s sp4; if (limbIndex == MA1_LIMB_HEAD) { sp4 = this->unk_1D8.unk_08; rot->x += sp4.y; - if ((this->skelAnime.animCurrentSeg == &D_06009E58) || (this->skelAnime.animCurrentSeg == &D_06007D98)) { + if ((this->skelAnime.animation == &D_06009E58) || (this->skelAnime.animation == &D_06007D98)) { rot->z += sp4.x; } } else if (limbIndex == MA1_LIMB_TORSO) { @@ -542,11 +541,11 @@ s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return 0; } -void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnMaYts* this = THIS; +void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnMaYts* this = (EnMaYts*)arg; if (limbIndex == MA1_LIMB_HEAD) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -565,8 +564,8 @@ void EnMaYts_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[this->mouthTexIndex])); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnMaYts_OverrideLimbDraw, EnMaYts_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMaYts_OverrideLimbDraw, EnMaYts_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h index 75f0ee0b6..2fcc20509 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h @@ -41,9 +41,9 @@ typedef struct EnMaYts { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ s32 unk_200; // Set, but not used - /* 0x204 */ Vec3s limbDrawTbl[MA1_LIMB_MAX]; + /* 0x204 */ Vec3s jointTable[MA1_LIMB_MAX]; /* 0x28E */ char unk_28E[0x6]; - /* 0x294 */ Vec3s transitionDrawTbl[MA1_LIMB_MAX]; + /* 0x294 */ Vec3s morphTable[MA1_LIMB_MAX]; /* 0x31E */ char unk_31E[0x8]; /* 0x326 */ s16 blinkTimer; /* 0x328 */ s16 overrideEyeTexIndex; // If non-zero, then this index will be used instead of eyeTexIndex diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index d1f4a0d90..9de59a963 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -92,8 +92,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600B538, &D_06001534, this->limbDrawTable, - this->transitionDrawTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, &D_06001534, this->jointTable, this->morphTable, 24); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -181,7 +180,7 @@ EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx) { void EnMinifrog_SetJumpState(EnMinifrog* this) { if (this->jumpState == MINIFROG_STATE_GROUND) { this->jumpState = MINIFROG_STATE_JUMP; - SkelAnime_ChangeAnim(&this->skelAnime, &D_060007BC, 1.0f, 0.0f, 7.0f, 2, -5.0f); + Animation_Change(&this->skelAnime, &D_060007BC, 1.0f, 0.0f, 7.0f, 2, -5.0f); } } @@ -195,10 +194,10 @@ void EnMinifrog_JumpTimer(EnMinifrog* this) { } void EnMinifrog_Jump(EnMinifrog* this) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); switch (this->jumpState) { case MINIFROG_STATE_JUMP: - if (func_801378B8(&this->skelAnime, 4.0f)) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->actor.bgCheckFlags &= ~1; this->actor.velocity.y = 6.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_JUMP); @@ -208,8 +207,8 @@ void EnMinifrog_Jump(EnMinifrog* this) { case MINIFROG_STATE_AIR: if (this->actor.bgCheckFlags & 1) { this->jumpState = MINIFROG_STATE_GROUND; - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06001534, -2.5f); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + Animation_MorphToLoop(&this->skelAnime, &D_06001534, -2.5f); + SkelAnime_Update(&this->skelAnime); } break; } @@ -606,7 +605,7 @@ void EnMinifrog_UpdateMissingFrog(Actor* thisx, GlobalContext* globalCtx) { } s32 EnMinifrog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { + Actor* arg) { if (limbIndex == 1) { pos->z -= 500.0f; } @@ -618,19 +617,19 @@ s32 EnMinifrog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return 0; } -void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnMinifrog* this = THIS; +void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnMinifrog* this = (EnMinifrog*)arg; if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -648,7 +647,7 @@ void EnMinifrog_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, D_808A4D74[0]); gSPSegment(POLY_OPA_DISP++, 0x09, D_808A4D74[0]); gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, envColor->a); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnMinifrog_OverrideLimbDraw, EnMinifrog_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMinifrog_OverrideLimbDraw, EnMinifrog_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h index 1dc4a53de..201ef5c47 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h @@ -27,8 +27,8 @@ typedef enum { typedef struct EnMinifrog { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[24]; - /* 0x218 */ Vec3s transitionDrawTable[24]; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; /* 0x2A8 */ EnMinifrogActionFunc actionFunc; /* 0x2AC */ struct EnMinifrog* frog; /* 0x2B0 */ s16 frogIndex; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index f3af54caf..4bad3b031 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -8,6 +8,8 @@ #define FLAGS 0x00800010 +#define THIS ((EnNiw*)thisx) + void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx); void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx); @@ -28,7 +30,6 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx); void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx); void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx); void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2); -s32 EnNiw_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* actor); void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); extern FlexSkeletonHeader D_06002530; @@ -125,8 +126,8 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 25.0f); - SkelAnime_InitSV(globalCtx, &this->skelanime, &D_06002530, &D_060000E8, this->limbDrawTbl, - this->transitionDrawtable, ENNIW_LIMBCOUNT); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &D_06002530, &D_060000E8, this->jointTable, this->morphTable, + ENNIW_LIMBCOUNT); Math_Vec3f_Copy(&this->unk2A4, &this->actor.world.pos); Math_Vec3f_Copy(&this->unk2B0, &this->actor.world.pos); @@ -326,8 +327,7 @@ void func_808917F8(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { } void EnNiw_SetupIdle(EnNiw* this) { - SkelAnime_ChangeAnim(&this->skelanime, &D_060000E8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_060000E8.common), 0, - -10.0f); + Animation_Change(&this->skelanime, &D_060000E8, 1.0f, 0.0f, Animation_GetLastFrame(&D_060000E8), 0, -10.0f); this->unknownState28E = 0; this->actionFunc = EnNiw_Idle; } @@ -629,8 +629,7 @@ void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { } void EnNiw_SetupRunAway(EnNiw* this) { - SkelAnime_ChangeAnim(&this->skelanime, &D_060000E8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_060000E8.common), 0, - -10.0f); + Animation_Change(&this->skelanime, &D_060000E8, 1.0f, 0.0f, Animation_GetLastFrame(&D_060000E8), 0, -10.0f); this->unk29A = Rand_ZeroFloat(1.99f); this->unknownState28E = 7; this->actionFunc = EnNiw_RunAway; @@ -907,8 +906,8 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnNiw_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor) { - EnNiw* this = (EnNiw*)actor; +s32 EnNiw_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnNiw* this = THIS; if (limbIndex == 13) { rot->y += (s16)this->limbDRot; @@ -933,8 +932,8 @@ void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = (EnNiw*)thisx; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelanime.skeleton, this->skelanime.limbDrawTbl, this->skelanime.dListCount, - EnNiw_LimbDraw, NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, + EnNiw_LimbDraw, NULL, &this->actor); EnNiw_DrawFeathers(this, globalCtx); } @@ -1007,11 +1006,11 @@ void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { isMaterialApplied++; } - SysMatrix_InsertTranslation(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - SysMatrix_InsertZRotation_f(feather->zRot, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(feather->zRot, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index 07d958893..5a03215bc 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -25,8 +25,8 @@ typedef struct { typedef struct EnNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelanime; - /* 0x188 */ Vec3s limbDrawTbl[ENNIW_LIMBCOUNT]; - /* 0x1E8 */ Vec3s transitionDrawtable[ENNIW_LIMBCOUNT]; + /* 0x188 */ Vec3s jointTable[ENNIW_LIMBCOUNT]; + /* 0x1E8 */ Vec3s morphTable[ENNIW_LIMBCOUNT]; /* 0x248 */ EnNiwActionFunc actionFunc; /* 0x24C */ s16 unkTimer24C; /* 0x24E */ s16 unkTimer24E; diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index bae091c19..b9aa32a0c 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -165,8 +165,8 @@ void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - SysMatrix_InsertMatrix(&globalCtx->mf_187FC, 1); - SysMatrix_InsertZRotation_s(this->actor.home.rot.z, 1); + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_04058BA0); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 046f3bb80..be2c4b570 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -355,8 +355,8 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&animations[this->animationIdx].animationSeg->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animationSeg); if (this->animationIdx == 3) { frameCount = 0; @@ -550,7 +550,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { this->animationIdx = 9; func_8013BC6C(&this->skelAnime, animations, 9); } - if (this->animationIdx == 11 && func_801378B8(&this->skelAnime, 18.0f)) { + if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); } } @@ -1329,14 +1329,12 @@ void EnOssan_Blink(EnOssan* this) { } void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->limbDrawTbl, this->transitionDrawTbl, - 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->jointTable, this->morphTable, 19); this->actor.draw = EnOssan_DrawCuriosityShopMan; } void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060028A0, &D_06009D34, this->limbDrawTbl, this->transitionDrawTbl, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060028A0, &D_06009D34, this->jointTable, this->morphTable, 16); this->actor.draw = EnOssan_DrawPartTimeWorker; } @@ -1521,7 +1519,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); Actor_SetHeight(&this->actor, 90.0f); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } else { this->actionFunc(this, globalCtx); } @@ -1642,7 +1640,7 @@ s32 EnOssan_OverrideLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbI EnOssan* this = THIS; if (limbIndex == 16) { - SysMatrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } return false; } @@ -1652,8 +1650,8 @@ s32 EnOssan_OverrideLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbInd EnOssan* this = THIS; if (limbIndex == 15) { - SysMatrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } @@ -1674,7 +1672,7 @@ void EnOssan_PostLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, EnOssan* this = THIS; if (limbIndex == 15) { - SysMatrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } @@ -1686,8 +1684,8 @@ void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1701,8 +1699,8 @@ void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 689d352cf..53f8b8f39 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -50,8 +50,8 @@ typedef struct EnOssan { /* 0x2CC */ Vec3s unk2CC; // Set but never used /* 0x2D2 */ s16 limbRotTableY[19]; /* 0x2F8 */ s16 limbRotTableZ[19]; - /* 0x31E */ Vec3s limbDrawTbl[19]; - /* 0x390 */ Vec3s transitionDrawTbl[19]; + /* 0x31E */ Vec3s jointTable[19]; + /* 0x390 */ Vec3s morphTable[19]; /* 0x402 */ s16 animationIdx; /* 0x404 */ Vec3s headRotPartTimeWorker; /* 0x40A */ u16 flags; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 381f4e90a..f0a2327fd 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -139,8 +139,10 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime1, &D_0600C5F8, &D_06001ADC, this->jointTable1, this->morphTable1, 21); - SkelAnime_InitSV(globalCtx, &this->skelAnime2, &D_060105C0, &D_0600CDB0, this->jointTable2, this->morphTable2, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &D_0600C5F8, &D_06001ADC, this->jointTable1, this->morphTable1, + 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &D_060105C0, &D_0600CDB0, this->jointTable2, this->morphTable2, + 16); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.minVelocityY = -10.0f; @@ -425,9 +427,9 @@ void func_8095B0C8(EnOwl* this) { } void func_8095B158(EnOwl* this) { - if (func_801378B8(&this->skelAnime1, 2.0f) || func_801378B8(&this->skelAnime1, 9.0f) || - func_801378B8(&this->skelAnime1, 23.0f) || func_801378B8(&this->skelAnime1, 40.0f) || - func_801378B8(&this->skelAnime1, 58.0f)) { + if (Animation_OnFrame(&this->skelAnime1, 2.0f) || Animation_OnFrame(&this->skelAnime1, 9.0f) || + Animation_OnFrame(&this->skelAnime1, 23.0f) || Animation_OnFrame(&this->skelAnime1, 40.0f) || + Animation_OnFrame(&this->skelAnime1, 58.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); } } @@ -458,15 +460,15 @@ void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx) { func_8095B06C(this); - if (this->skelAnime1.animCurrentFrame >= 18.0f) { + if (this->skelAnime1.curFrame >= 18.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; } if ((this->actor.shape.rot.y == this->unk_3EC) && (this->actionFlags & 1)) { this->actionFunc = func_8095B254; - SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 19.0f, - SkelAnime_GetFrameCount(&D_06001168.common), 2, 0.0f); + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 19.0f, + Animation_GetLastFrame(&D_06001168), 2, 0.0f); this->unk_414 = func_8095C484; } @@ -476,7 +478,7 @@ void func_8095B2F8(EnOwl* this, GlobalContext* globalCtx) { void func_8095B3DC(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { this->actionFunc = func_8095B2F8; - SkelAnime_ChangeAnim(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); this->unk_414 = func_8095C408; this->unk_3EC = 0x5500; this->actor.world.pos.y += 100.0f; @@ -532,8 +534,7 @@ void func_8095B650(EnOwl* this, GlobalContext* globalCtx) { void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { - SkelAnime_ChangeAnim(this->skelAnime3, &D_0600CB94, -1.0f, SkelAnime_GetFrameCount(&D_0600CB94.common), 0.0f, 2, - 0.0f); + Animation_Change(this->skelAnime3, &D_0600CB94, -1.0f, Animation_GetLastFrame(&D_0600CB94), 0.0f, 2, 0.0f); this->unk_414 = func_8095C484; this->actionFunc = func_8095B650; } @@ -588,7 +589,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { } void func_8095B960(EnOwl* this, GlobalContext* globalCtx) { - if (this->skelAnime1.animCurrentFrame >= 18.0f) { + if (this->skelAnime1.curFrame >= 18.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x200, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -605,7 +606,7 @@ void func_8095B960(EnOwl* this, GlobalContext* globalCtx) { void func_8095B9FC(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { this->actionFunc = func_8095B960; - SkelAnime_ChangeAnim(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &D_06001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); this->unk_414 = func_8095C408; func_8095B0C8(this); } @@ -766,16 +767,16 @@ void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { } void func_8095C09C(EnOwl* this, GlobalContext* globalCtx) { - if (this->skelAnime1.animCurrentFrame > 10.0f) { + if (this->skelAnime1.curFrame > 10.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x400, 0x40); this->actor.shape.rot.y = this->actor.world.rot.y; } - if (this->skelAnime1.animCurrentFrame > 45.0f) { + if (this->skelAnime1.curFrame > 45.0f) { this->actor.velocity.y = 2.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 8.0f; - } else if (this->skelAnime1.animCurrentFrame > 17.0f) { + } else if (this->skelAnime1.curFrame > 17.0f) { this->actor.velocity.y = 6.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 4.0f; @@ -802,36 +803,34 @@ void func_8095C1C8(EnOwl* this, GlobalContext* globalCtx) { } void func_8095C258(EnOwl* this) { - SkelAnime_FrameUpdateMatrix(this->skelAnime3); + SkelAnime_Update(this->skelAnime3); if (this->unk_3EA > 0) { this->unk_3EA--; this->actor.shape.rot.z = Math_SinS(this->unk_3EA * 0x333) * 1000.0f; } else { this->unk_414 = func_8095C328; this->unk_3EA = 6; - SkelAnime_ChangeAnim(this->skelAnime3, &D_06001ADC, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06001ADC.common), 2, - 5.0f); + Animation_Change(this->skelAnime3, &D_06001ADC, 1.0f, 0.0f, Animation_GetLastFrame(&D_06001ADC), 2, 5.0f); } } void func_8095C328(EnOwl* this) { - if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { + if (SkelAnime_Update(this->skelAnime3)) { if (this->unk_3EA > 0) { this->unk_3EA--; - SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(this->skelAnime3->genericSeg), 2, 0.0f); + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, + Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); } else { this->unk_3EA = 160; this->unk_414 = func_8095C258; - SkelAnime_ChangeAnim(this->skelAnime3, &D_0600C6D4, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_0600C6D4.common), - 0, 5.0f); + Animation_Change(this->skelAnime3, &D_0600C6D4, 1.0f, 0.0f, Animation_GetLastFrame(&D_0600C6D4), 0, 5.0f); } } } void func_8095C408(EnOwl* this) { - if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { - SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 18.0f, 35.0f, 2, 0.0f); + if (SkelAnime_Update(this->skelAnime3)) { + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 18.0f, 35.0f, 2, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -839,9 +838,9 @@ void func_8095C408(EnOwl* this) { } void func_8095C484(EnOwl* this) { - if (SkelAnime_FrameUpdateMatrix(this->skelAnime3)) { - SkelAnime_ChangeAnim(this->skelAnime3, this->skelAnime3->animCurrentSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(this->skelAnime3->genericSeg), 2, 0.0f); + if (SkelAnime_Update(this->skelAnime3)) { + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, + Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -905,7 +904,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.update != NULL) { - if ((this->skelAnime1.animCurrentSeg == &D_06001ADC) && func_801378B8(&this->skelAnime1, 4.0f)) { + if ((this->skelAnime1.animation == &D_06001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); } @@ -1143,7 +1142,7 @@ void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 3) { - SysMatrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); } } @@ -1162,8 +1161,8 @@ void EnOwl_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime3->skeleton, this->skelAnime3->limbDrawTbl, this->skelAnime3->dListCount, - EnOwl_OverrideLimbDraw, EnOwl_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime3->skeleton, this->skelAnime3->jointTable, + this->skelAnime3->dListCount, EnOwl_OverrideLimbDraw, EnOwl_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1173,9 +1172,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - SysMatrix_InsertTranslation(0.0f, 500.0f, 0.0f, 1); - SysMatrix_InsertXRotation_s(this->unk_3D8 - 0x4000, 1); - SysMatrix_InsertTranslation(0.0f, 0.0f, -500.0f, 1); + Matrix_InsertTranslation(0.0f, 500.0f, 0.0f, 1); + Matrix_InsertXRotation_s(this->unk_3D8 - 0x4000, 1); + Matrix_InsertTranslation(0.0f, 0.0f, -500.0f, 1); if (this->unk_3DC >= 0x20) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1200,8 +1199,8 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { this->skelAnime3 = skelAnime; - SkelAnime_ChangeAnim(this->skelAnime3, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->common), 2, - transitionRate); + Animation_Change(this->skelAnime3, animationSeg, 1.0f, 0.0f, Animation_GetLastFrame(animationSeg), 2, + transitionRate); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 94f8605af..bb7a5ffbd 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -152,8 +152,8 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp44; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06008448, &D_060005BC, this->limbDrawTbl, this->transitionDrawTbl, - PAMERA_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008448, &D_060005BC, this->jointTable, this->morphTable, + PAMERA_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit2); @@ -406,7 +406,7 @@ void EnPamera_LookDownWell(EnPamera* this) { void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_800BDC5C(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); @@ -510,12 +510,12 @@ void func_80BD93CC(EnPamera* this, s16 arg1, s16 arg2) { void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80BD8B70) || (this->actionFunc == func_80BD8DB0) || (this->actionFunc == func_80BD8964) || (this->actionFunc == func_80BD8A7C)) { - if (this->skelAnime.animCurrentSeg == &D_06008AE0) { - if (func_801378B8(&this->skelAnime, 9.0f) || func_801378B8(&this->skelAnime, 18.0f)) { + if (this->skelAnime.animation == &D_06008AE0) { + if (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if ((this->skelAnime.animCurrentSeg == &D_06008E38) && - (func_801378B8(&this->skelAnime, 2.0f) || func_801378B8(&this->skelAnime, 6.0f))) { + } else if ((this->skelAnime.animation == &D_06008E38) && + (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } } @@ -536,7 +536,7 @@ void EnPamera_Update(Actor* thisx, GlobalContext* globalCtx) { EnPamera* this = THIS; this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80BD90AC(this, globalCtx); func_80BD9384(this, globalCtx); func_80BD94E0(this, globalCtx); @@ -557,8 +557,10 @@ s32 EnPamera_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } void EnPamera_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnPamera* this = THIS; + if (limbIndex == PAMERA_LIMB_HAIR) { - SysMatrix_MultiplyVector3fByState(&D_80BDA5F0, &thisx->focus.pos); + Matrix_MultiplyVector3fByState(&D_80BDA5F0, &this->actor.focus.pos); } } @@ -570,8 +572,8 @@ void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80BDA604[this->unk_312])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(D_80BDA610[this->unk_314])); gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(D_80BDA5FC[this->unk_310])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnPamera_OverrideLimbDraw, EnPamera_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPamera_OverrideLimbDraw, EnPamera_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -775,13 +777,13 @@ void func_80BD9EE0(EnPamera* this) { void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { - if (func_801378B8(&this->skelAnime, 2.0f) || func_801378B8(&this->skelAnime, 6.0f) || - func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 14.0f) || - func_801378B8(&this->skelAnime, 18.0f) || func_801378B8(&this->skelAnime, 22.0f) || - func_801378B8(&this->skelAnime, 25.0f)) { + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f) || + Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 22.0f) || + Animation_OnFrame(&this->skelAnime, 25.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); func_800BDC5C(&this->skelAnime, sAnimations, 6); @@ -808,7 +810,7 @@ void func_80BDA0A0(EnPamera* this) { void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); func_800BDC5C(&this->skelAnime, sAnimations, 6); @@ -825,11 +827,11 @@ void func_80BDA170(EnPamera* this) { void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { - if (func_801378B8(&this->skelAnime, 2.0f) || func_801378B8(&this->skelAnime, 6.0f) || - func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 14.0f)) { + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); func_800BDC5C(&this->skelAnime, sAnimations, 10); @@ -846,7 +848,7 @@ void func_80BDA288(EnPamera* this) { void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_800BDC5C(&this->skelAnime, sAnimations, 12); } @@ -858,7 +860,7 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { EnPamera* this = THIS; this->actionFunc(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_80BD9384(this, globalCtx); if (func_80BD9CB8(this, globalCtx)) { // Pamela is outside diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h index 4ad65de5e..d19030aae 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h @@ -46,8 +46,8 @@ typedef struct EnPamera { /* 0x1E4 */ s32 pathPointsCount; /* 0x1E8 */ s32 pathId; /* 0x1EC */ s32 unk_1EC; - /* 0x1F0 */ Vec3s limbDrawTbl[PAMERA_LIMB_MAX]; - /* 0x27A */ Vec3s transitionDrawTbl[PAMERA_LIMB_MAX]; + /* 0x1F0 */ Vec3s jointTable[PAMERA_LIMB_MAX]; + /* 0x27A */ Vec3s morphTable[PAMERA_LIMB_MAX]; /* 0x304 */ Vec3s limb9Rot; /* 0x30A */ Vec3s limb8Rot; /* 0x310 */ s16 unk_310; 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 ca90a1fd4..2b8246f34 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -207,8 +207,7 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 55.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600DF98, &D_0600F990, this->limbDrawTable, - this->transitionDrawTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600DF98, &D_0600F990, this->jointTable, this->morphTable, 24); Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colElement); this->params = CLAMP(this->actor.params, 1, 4); if (Actor_GetRoomCleared(globalCtx, globalCtx->roomCtx.currRoom.num)) { @@ -336,8 +335,8 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { Math3D_CrossProduct(&this->unk_2DC, &floorNorm, &vec2); EnPametfrog_Vec3fNormalize(&vec2); - SysMatrix_InsertRotationAroundUnitVector_f(rotation, &vec2, 0); - SysMatrix_MultiplyVector3fByState(&this->unk_2E8, &vec2); + Matrix_InsertRotationAroundUnitVector_f(rotation, &vec2, 0); + Matrix_MultiplyVector3fByState(&this->unk_2E8, &vec2); Math_Vec3f_Copy(&this->unk_2E8, &vec2); Math3D_CrossProduct(&this->unk_2E8, &floorNorm, &this->unk_2D0); EnPametfrog_Vec3fNormalize(&this->unk_2D0); @@ -398,9 +397,9 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, 1.0f)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_JUMP); - } else if (func_801378B8(&this->skelAnime, 11.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { EnPametfrog_JumpWaterEffects(this, globalCtx); Audio_PlayActorSound2(&this->actor, NA_SE_EV_WALK_WATER); } @@ -440,11 +439,11 @@ void EnPametfrog_ApplyStun(EnPametfrog* this) { void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { if (this->actionFunc == EnPametfrog_RearOnSnapperRise) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06005694); + Animation_PlayOnce(&this->skelAnime, &D_06005694); } else if (this->actionFunc == EnPametfrog_RearOnSnapperWave) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060052EC); + Animation_PlayOnce(&this->skelAnime, &D_060052EC); } else { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06004680); + Animation_PlayOnce(&this->skelAnime, &D_06004680); } this->actor.flags &= ~1; @@ -457,11 +456,11 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f rearingPoint; s32 pad; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (Rand_ZeroOne() < 0.5f) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06004D50); + Animation_PlayOnce(&this->skelAnime, &D_06004D50); } else { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06004680); + Animation_PlayOnce(&this->skelAnime, &D_06004680); } } @@ -479,13 +478,13 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupRearOnSnapperWave(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06004894); + Animation_PlayOnce(&this->skelAnime, &D_06004894); this->timer = 15; this->actionFunc = EnPametfrog_RearOnSnapperWave; } void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && this->timer > 0) { + if (SkelAnime_Update(&this->skelAnime) && this->timer > 0) { this->timer--; if (this->timer == 0) { EnPametfrog_SetupRearOnSnapper(this); @@ -494,7 +493,7 @@ void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_SetupRearOnSnapperRise(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060050B8); + Animation_PlayOnce(&this->skelAnime, &D_060050B8); this->timer = 10; this->actor.params = GEKKO_REAR_ON_SNAPPER; this->actor.shape.rot.x = 0; @@ -504,7 +503,7 @@ void EnPametfrog_SetupRearOnSnapperRise(EnPametfrog* this) { } void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->timer--; if (this->timer == 0) { EnPametfrog_SetupRearOnSnapper(this); @@ -518,7 +517,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx Vec3f eye; s16 yaw; - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06001F20); + Animation_PlayOnce(&this->skelAnime, &D_06001F20); this->actor.params = GEKKO_FALL_OFF_SNAPPER; this->actor.speedXZ = 7.0f; this->actor.velocity.y = 15.0f; @@ -539,7 +538,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { f32 sin; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.x += 0x800; this->actor.shape.rot.z += 0x1000; if (this->timer != 0) { @@ -555,7 +554,7 @@ void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.bgCheckFlags &= ~8; @@ -564,13 +563,13 @@ void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { } void EnPametfrog_JumpToWall(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, globalCtx); if ((this->actor.bgCheckFlags & 1) && (this->actor.bgCheckFlags & 8) && (this->actor.wallBgId == BGCHECK_SCENE) && (COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y) < 0.5f)) { EnPametfrog_SetupWallCrawl(this); } else if (!(this->actor.bgCheckFlags & 1) || - ((this->skelAnime.animCurrentFrame > 1.0f) && (this->skelAnime.animCurrentFrame < 12.0f))) { + ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { this->actor.speedXZ = 12.0f; } else { this->actor.speedXZ = 0.0f; @@ -579,7 +578,7 @@ void EnPametfrog_JumpToWall(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { if (this->actionFunc == EnPametfrog_JumpToWall) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06001E14); + Animation_PlayLoop(&this->skelAnime, &D_06001E14); this->collider.base.acFlags |= AC_ON; this->unk_2D0.x = 0.0f; this->unk_2D0.z = 0.0f; @@ -599,7 +598,7 @@ void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { this->actor.floorPoly = this->actor.wallPoly; this->wallPauseTimer = 10; } else { - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_RUNAWAY); @@ -623,7 +622,7 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { if (this->freezeTimer > 0) { this->freezeTimer--; } else { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->timer--; this->actor.speedXZ = 8.0f; doubleSpeedXZ = this->actor.speedXZ * 2.0f; @@ -657,7 +656,7 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { func_8086A238(this); } - if (func_801378B8(&this->skelAnime, 15.0f)) { + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); } @@ -682,7 +681,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { f32 randFloat; this->actor.speedXZ = 0.0f; - this->skelAnime.animPlaybackSpeed = 1.5f; + this->skelAnime.playSpeed = 1.5f; if (this->timer != 0) { this->wallRotation = this->unk_2E8.y > 0.0f ? (M_PI / 30) : (-M_PI / 30); } else { @@ -700,10 +699,10 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { if (this->freezeTimer > 0) { this->freezeTimer--; } else { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->timer--; - SysMatrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, 0); - SysMatrix_MultiplyVector3fByState(&this->unk_2D0, &vec); + Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, 0); + Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); @@ -720,8 +719,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { s16 yaw; - SkelAnime_ChangeAnim(&this->skelAnime, &D_060039C4, 0.0f, 0.0f, SkelAnime_GetFrameCount(&D_060039C4.common), 2, - 0.0f); + Animation_Change(&this->skelAnime, &D_060039C4, 0.0f, 0.0f, Animation_GetLastFrame(&D_060039C4), 2, 0.0f); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.rot.x = 0; @@ -755,31 +753,30 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupRunToSnapper(EnPametfrog* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); this->actor.params = GEKKO_RETURN_TO_SNAPPER; this->actionFunc = EnPametfrog_RunToSnapper; } void EnPametfrog_RunToSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, globalCtx); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; - if (!(this->actor.bgCheckFlags & 1) || - ((this->skelAnime.animCurrentFrame > 1.0f) && (this->skelAnime.animCurrentFrame < 12.0f))) { + if (!(this->actor.bgCheckFlags & 1) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { this->actor.speedXZ = 12.0f; } else { this->actor.speedXZ = 0.0f; } if ((this->actor.child->params == 1) && (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) < 120.0f) && - func_801378B8(&this->skelAnime, 0.0f)) { + Animation_OnFrame(&this->skelAnime, 0.0f)) { EnPametfrog_SetupJumpOnSnapper(this); } } void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06004680, 6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06004680, 6.0f); this->timer = 6; this->collider.base.ocFlags1 &= ~OC1_ON; this->collider.base.acFlags &= ~AC_ON; @@ -796,7 +793,7 @@ void EnPametfrog_JumpOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { f32 temp_f0; EnBigpamet* bigpamet; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->timer--; if (this->timer == 0) { EnPametfrog_SetupLandOnSnapper(this); @@ -811,14 +808,14 @@ void EnPametfrog_JumpOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupLandOnSnapper(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000994); + Animation_PlayOnce(&this->skelAnime, &D_06000994); this->actor.shape.rot.y = this->actor.child->shape.rot.y; this->actor.params = GEKKO_ON_SNAPPER; this->actionFunc = EnPametfrog_LandOnSnapper; } void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { EnPametfrog_StopCutscene(this, globalCtx); EnPametfrog_SetupRearOnSnapper(this); } @@ -829,7 +826,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f eye; f32 xzDist; - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06001F20); + Animation_PlayOnce(&this->skelAnime, &D_06001F20); if (this->actor.colChkInfo.health > 0) { this->actor.params = GEKKO_RETURN_TO_SNAPPER; } @@ -868,7 +865,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->actor.colorFilterTimer = 0x10; if (this->timer > 0) { this->timer--; @@ -890,7 +887,7 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06004298); + Animation_PlayOnce(&this->skelAnime, &D_06004298); this->actor.shape.rot.x = 0; this->actor.shape.rot.y += this->spinYaw; this->actor.shape.rot.z = 0; @@ -903,15 +900,15 @@ void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { - if (this->skelAnime.animCurrentSeg == &D_06004298) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &D_06004298) { if (this->actor.colChkInfo.health == 0) { this->timer--; if (this->timer == 0) { EnPametfrog_SetupDefeatGekko(this, globalCtx); } } else { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060030E4); + Animation_PlayOnce(&this->skelAnime, &D_060030E4); } } else { EnPametfrog_SetupRunToSnapper(this); @@ -1044,7 +1041,7 @@ void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupLookAround(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_060066B4); + Animation_PlayOnce(&this->skelAnime, &D_060066B4); this->collider.base.atFlags &= ~AT_ON; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1055,7 +1052,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x400, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { + if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { if (!this->unk_2AE) { func_801A2E54(0x38); this->unk_2AE = true; @@ -1065,7 +1062,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupJumpToLink(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060039C4); + Animation_PlayLoop(&this->skelAnime, &D_060039C4); this->collider.base.acFlags |= AC_ON; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnPametfrog_JumpToLink; @@ -1074,10 +1071,9 @@ void EnPametfrog_SetupJumpToLink(EnPametfrog* this) { void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, globalCtx); - if (!(this->actor.bgCheckFlags & 1) || - (this->skelAnime.animCurrentFrame > 1.0f && this->skelAnime.animCurrentFrame < 12.0f)) { + if (!(this->actor.bgCheckFlags & 1) || (this->skelAnime.curFrame > 1.0f && this->skelAnime.curFrame < 12.0f)) { this->actor.speedXZ = 8.0f; } else { this->actor.speedXZ = 0.0f; @@ -1085,13 +1081,13 @@ void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx) { if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) && Actor_IsActorFacingLink(&this->actor, 0x3000) && - (this->skelAnime.animCurrentFrame <= 2.0f || this->skelAnime.animCurrentFrame >= 11.0f)) { + (this->skelAnime.curFrame <= 2.0f || this->skelAnime.curFrame >= 11.0f)) { EnPametfrog_SetupMeleeAttack(this); } } void EnPametfrog_SetupMeleeAttack(EnPametfrog* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_0600F990); + Animation_PlayOnce(&this->skelAnime, &D_0600F990); this->timer = 7; this->actor.speedXZ = 0.0f; this->actionFunc = EnPametfrog_MeleeAttack; @@ -1106,23 +1102,23 @@ static AnimationHeader* sAttackAnimations[] = { void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->timer--; if (this->timer == 0) { EnPametfrog_SetupLookAround(this); } else if (this->timer == 6) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_0600F990); + Animation_PlayOnce(&this->skelAnime, &D_0600F990); } else { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, sAttackAnimations[(s32)Rand_ZeroFloat(4.0f) % 4]); + Animation_PlayOnce(&this->skelAnime, sAttackAnimations[(s32)Rand_ZeroFloat(4.0f) % 4]); } } - if ((this->skelAnime.animCurrentSeg == &D_0600347C && func_801378B8(&this->skelAnime, 2.0f)) || - (this->skelAnime.animCurrentSeg == &D_060070C4 && func_801378B8(&this->skelAnime, 9.0f)) || - (this->skelAnime.animCurrentSeg == &D_06003F28 && func_801378B8(&this->skelAnime, 2.0f)) || - ((this->skelAnime.animCurrentSeg == &D_0600F048) && func_801378B8(&this->skelAnime, 27.0f))) { + if ((this->skelAnime.animation == &D_0600347C && Animation_OnFrame(&this->skelAnime, 2.0f)) || + (this->skelAnime.animation == &D_060070C4 && Animation_OnFrame(&this->skelAnime, 9.0f)) || + (this->skelAnime.animation == &D_06003F28 && Animation_OnFrame(&this->skelAnime, 2.0f)) || + ((this->skelAnime.animation == &D_0600F048) && Animation_OnFrame(&this->skelAnime, 27.0f))) { this->collider.base.atFlags |= AT_ON; - if (this->skelAnime.animCurrentSeg == &D_06003F28) { + if (this->skelAnime.animation == &D_06003F28) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_KICK); } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_PUNCH1); @@ -1133,7 +1129,7 @@ void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDamage(EnPametfrog* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06005D54, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06005D54, -3.0f); this->timer = 20; this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; @@ -1146,7 +1142,7 @@ void EnPametfrog_SetupDamage(EnPametfrog* this) { } void EnPametfrog_Damage(EnPametfrog* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->timer--; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (this->timer == 0) { @@ -1159,9 +1155,9 @@ void EnPametfrog_Damage(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupStun(EnPametfrog* this) { - if (this->skelAnime.animCurrentSeg == &D_060039C4) { - this->skelAnime.animCurrentFrame = 0.0f; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->skelAnime.animation == &D_060039C4) { + this->skelAnime.curFrame = 0.0f; + SkelAnime_Update(&this->skelAnime); } this->collider.base.atFlags &= ~AT_ON; @@ -1191,7 +1187,7 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f at; s16 yawDiff; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001B08, 3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001B08, 3.0f); Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_GREET); this->actor.flags &= ~1; this->actor.colChkInfo.health = 6; @@ -1219,7 +1215,7 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { EnPametfrog_SetupSnapperSpawn(this, globalCtx); } } @@ -1408,16 +1404,16 @@ static s8 limbPosIndex[] = { -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, 6, -1, 7, 8, 9, -1, 10, -1, 11, -1, -1, }; -void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnPametfrog* this = THIS; +void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnPametfrog* this = (EnPametfrog*)arg; Vec3f vec; Vec3s* center; s8 index; if (limbIndex == GEKKO_LIMB_HEAD) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); this->actor.focus.rot.y = this->actor.shape.rot.y; - SysMatrix_GetStateTranslationAndScaledY(2500.0f, &vec); + Matrix_GetStateTranslationAndScaledY(2500.0f, &vec); center = &this->collider.elements[0].dim.worldSphere.center; center->x = vec.x; center->y = vec.y; @@ -1430,7 +1426,7 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi index = limbPosIndex[limbIndex]; if (index != -1) { - SysMatrix_GetStateTranslation(&this->limbPos[index]); + Matrix_GetStateTranslation(&this->limbPos[index]); } } @@ -1439,8 +1435,8 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - EnPametfrog_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnPametfrog_PostLimbDraw, &this->actor); func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->unk_2C8, this->unk_2CC, this->unk_2C4, this->drawEffect); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 58b8dcf4b..f00acecb5 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -58,8 +58,8 @@ typedef enum { typedef struct EnPametfrog { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[GEKKO_LIMB_MAX]; - /* 0x218 */ Vec3s transitionDrawTable[GEKKO_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[GEKKO_LIMB_MAX]; + /* 0x218 */ Vec3s morphTable[GEKKO_LIMB_MAX]; /* 0x2A8 */ EnPametfrogActionFunc actionFunc; /* 0x2AC */ u8 drawEffect; /* 0x2AD */ u8 wallPauseTimer; // Gekko stops 10 times along wall/ceiling after being blown off of Snapper diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index b4d540fe7..c578e3d37 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -26,7 +26,7 @@ void EnPoFusen_Pop(EnPoFusen* this, GlobalContext* globalCtx); void EnPoFusen_Idle(EnPoFusen* this, GlobalContext* globalCtx); void EnPoFusen_IdleFuse(EnPoFusen* this, GlobalContext* globalCtx); s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - struct Actor* actor); + Actor* arg); extern AnimationHeader D_06000040; extern FlexSkeletonHeader D_060024F0; @@ -111,7 +111,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { if (0) {} this->collider.dim.worldSphere.radius = 40; - SkelAnime_InitSV(globalCtx, &this->anime, &D_060024F0, &D_06000040, this->limbDrawTbl, this->transitionDrawTbl, 10); + SkelAnime_InitFlex(globalCtx, &this->anime, &D_060024F0, &D_06000040, this->jointTable, this->morphTable, 10); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); @@ -271,8 +271,8 @@ void EnPoFusen_Update(Actor* thisx, GlobalContext* globalCtx) { } s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - struct Actor* actor) { - EnPoFusen* this = (EnPoFusen*)actor; + Actor* arg) { + EnPoFusen* this = (EnPoFusen*)arg; f32 zScale; f32 yScale; f32 xScale; @@ -289,10 +289,10 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL yScale = yScale * yScale; xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); - SysMatrix_InsertRotation(xRot, 0, zRot, 1); - Matrix_Scale(xScale, yScale, zScale, 1); - SysMatrix_InsertZRotation_s(-zRot, 1); - SysMatrix_InsertXRotation_s(-xRot, 1); + Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_Scale(xScale, yScale, zScale, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-zRot, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-xRot, MTXMODE_APPLY); } else if (limbIndex == 3) { rot->y += this->limb3Rot; } else if (limbIndex == 6) { @@ -310,15 +310,15 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL return 0; } -void EnPoFusen_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor) { +void EnPoFusen_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { } -void EnPoFusen_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* actor) { +void EnPoFusen_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { } void EnPoFusen_Draw(Actor* thisx, GlobalContext* globalCtx) { EnPoFusen* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - func_801343C0(globalCtx, this->anime.skeleton, this->anime.limbDrawTbl, this->anime.dListCount, + func_801343C0(globalCtx, this->anime.skeleton, this->anime.jointTable, this->anime.dListCount, EnPoFusen_OverrideLimbDraw, EnPoFusen_PostLimbDraw, EnPoFusen_UnkActorDraw, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h index b19cc01f9..5a879ddb1 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h @@ -12,8 +12,8 @@ typedef struct EnPoFusen { /* 0x144 */ SkelAnime anime; /* 0x188 */ EnPoFusenActionFunc actionFunc; /* 0x18C */ ColliderSphere collider; - /* 0x1E4 */ Vec3s limbDrawTbl[0xA]; - /* 0x220 */ Vec3s transitionDrawTbl[0xA]; + /* 0x1E4 */ Vec3s jointTable[0xA]; + /* 0x220 */ Vec3s morphTable[0xA]; /* 0x25C */ s16 randScaleChange; /* 0x25E */ s16 randXZRotChange; /* 0x260 */ s16 randYRotChange; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index ace41a2ba..bddd970b9 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -222,15 +222,15 @@ void func_80B2C9B8(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2CA4C(EnPoh* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060015B0); + Animation_PlayLoop(&this->skelAnime, &D_060015B0); this->unk_18E = Rand_S16Offset(2, 3); this->actionFunc = func_80B2CAA4; this->actor.speedXZ = 0.0f; } void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { this->unk_18E--; } @@ -248,16 +248,16 @@ void func_80B2CAA4(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2CB60(EnPoh* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06000A60); + Animation_PlayLoop(&this->skelAnime, &D_06000A60); this->unk_18E = Rand_S16Offset(15, 3); this->colliderCylinder.base.acFlags |= AC_ON; this->actionFunc = func_80B2CBBC; } void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); - if (func_801378B8(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { this->unk_18E--; } @@ -283,7 +283,7 @@ void func_80B2CBBC(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2CD14(EnPoh* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06000A60); + Animation_PlayLoop(&this->skelAnime, &D_06000A60); this->actionFunc = func_80B2CD64; this->unk_18E = 0; this->actor.speedXZ = 2.0f; @@ -293,7 +293,7 @@ void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 yawDiff; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->unk_18E != 0) { this->unk_18E--; } @@ -322,7 +322,7 @@ void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2CEC8(EnPoh* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060001A8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_060001A8, -6.0f); this->unk_18E = 12; this->actor.speedXZ = 0.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); @@ -330,8 +330,8 @@ void func_80B2CEC8(EnPoh* this) { } void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 0.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_KANTERA); if (this->unk_18E != 0) { this->unk_18E--; @@ -343,7 +343,7 @@ void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xAAA); } else if (this->unk_18E == 9) { this->actor.speedXZ = 5.0f; - this->skelAnime.animPlaybackSpeed = 2.0f; + this->skelAnime.playSpeed = 2.0f; } else if (this->unk_18E == 0) { func_80B2CB60(this); this->unk_18E = 0x17; @@ -351,7 +351,7 @@ void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2CFF8(EnPoh* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060004EC, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_060004EC, -6.0f); func_800BE504(&this->actor, &this->colliderCylinder); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actor.speedXZ = 5.0f; @@ -361,7 +361,7 @@ void func_80B2CFF8(EnPoh* this) { void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health != 0) { func_80B2DAD0(this); } else { @@ -373,23 +373,23 @@ void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { void func_80B2D0E8(EnPoh* this) { this->unk_197 = 0; this->actor.flags &= ~1; - SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, &D_060011C4, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &D_060011C4, 0.0f); this->actionFunc = func_80B2D140; } void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->unk_197 = 255; this->unk_190 = Rand_S16Offset(700, 300); this->actor.flags |= 1; func_80B2CB60(this); - } else if (this->skelAnime.animCurrentFrame > 10.0f) { - this->unk_197 = (this->skelAnime.animCurrentFrame - 10.0f) * 0.05f * 255.0f; + } else if (this->skelAnime.curFrame > 10.0f) { + this->unk_197 = (this->skelAnime.curFrame - 10.0f) * 0.05f * 255.0f; } - if ((this->skelAnime.animPlaybackSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { + if ((this->skelAnime.playSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - this->skelAnime.animPlaybackSpeed = 1.0f; + this->skelAnime.playSpeed = 1.0f; } } @@ -452,13 +452,13 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2D5DC(EnPoh* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000A60); + Animation_PlayOnce(&this->skelAnime, &D_06000A60); this->actionFunc = func_80B2D628; this->actor.speedXZ = -5.0f; } void func_80B2D628(EnPoh* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80B2CB60(this); this->unk_18E = 23; @@ -469,14 +469,14 @@ void func_80B2D628(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2D694(EnPoh* this) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060015B0); + Animation_PlayLoop(&this->skelAnime, &D_060015B0); this->unk_192 = BINANG_ROT180(this->actor.world.rot.y); this->actionFunc = func_80B2D6EC; this->actor.speedXZ = 0.0f; } void func_80B2D6EC(EnPoh* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C)) { func_80B2CB60(this); } @@ -547,7 +547,7 @@ void func_80B2D980(EnPoh* this, GlobalContext* globalCtx) { } void func_80B2DAD0(EnPoh* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060006E0, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &D_060006E0, -5.0f); this->actor.speedXZ = 5.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->colliderCylinder.base.acFlags |= AC_ON; @@ -558,7 +558,7 @@ void func_80B2DAD0(EnPoh* this) { void func_80B2DB44(EnPoh* this, GlobalContext* globalCtx) { f32 sp24; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); sp24 = Math_SinS(this->unk_18D * 0x800) * 3.0f; this->actor.world.pos.x -= sp24 * Math_CosS(this->actor.shape.rot.y); this->actor.world.pos.z += sp24 * Math_SinS(this->actor.shape.rot.y); @@ -791,9 +791,9 @@ void func_80B2E6C0(EnPoh* this) { } void func_80B2E8E0(EnPoh* this) { - if ((this->actionFunc == func_80B2D140) && (this->skelAnime.animCurrentFrame < 12.0f)) { - this->unk_198 = this->unk_199 = this->unk_19A = (this->skelAnime.animCurrentFrame * 16.66f) + 55.0f; - this->unk_19B = this->skelAnime.animCurrentFrame * 16.666666f; + if ((this->actionFunc == func_80B2D140) && (this->skelAnime.curFrame < 12.0f)) { + this->unk_198 = this->unk_199 = this->unk_19A = (this->skelAnime.curFrame * 16.66f) + 55.0f; + this->unk_19B = this->skelAnime.curFrame * 16.666666f; } else { f32 rand = Rand_ZeroOne(); @@ -895,7 +895,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if ((this->actionFunc == func_80B2D300) && (this->unk_18E >= 19) && (this->actor.scale.x != 0.0f)) { Matrix_Scale(0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 1); } - SysMatrix_CopyCurrentState(&this->unk_3D8); + Matrix_CopyCurrentState(&this->unk_3D8); func_80B2C910(&sp60, globalCtx); Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x + (s32)sp60.x, this->colliderSph.elements[0].dim.worldSphere.center.y + (s32)sp60.y, @@ -906,19 +906,19 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - SysMatrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + Matrix_GetStateTranslation(&this->unk_2A0[temp_s3]); } else if (temp_s3 == 4) { - SysMatrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); } else { s32 i; Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - SysMatrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); - SysMatrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); + Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { - SysMatrix_MultiplyVector3fByState(vec2, vec); + Matrix_MultiplyVector3fByState(vec2, vec); } } } @@ -938,8 +938,8 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], this->unk_194, this->unk_195, this->unk_196, this->unk_197); gSPSegment(&gfx[2], 0x08, D_801AEFA0); - gfx = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnPoh_OverrideLimbDraw, - EnPoh_PostLimbDraw, &this->actor, &gfx[3]); + gfx = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoh_OverrideLimbDraw, + EnPoh_PostLimbDraw, &this->actor, &gfx[3]); POLY_OPA_DISP = gfx; } else { @@ -949,8 +949,8 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(&gfx[1], 255, 255, 255, this->unk_197); gSPSegment(&gfx[2], 0x08, D_801AEF88); - POLY_XLU_DISP = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, &gfx[3]); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnPoh_OverrideLimbDraw, EnPoh_PostLimbDraw, &this->actor, &gfx[3]); gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 25]); @@ -959,7 +959,7 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(&gfx[0]); gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); - SysMatrix_SetCurrentState(&this->unk_3D8); + Matrix_SetCurrentState(&this->unk_3D8); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], D_06002D28); @@ -1013,8 +1013,7 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - SysMatrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), - MTXMODE_APPLY); + Matrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06003850); diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 8105dfb66..5f9fe203a 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -220,7 +220,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -354,7 +354,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3F4--; } - if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 95) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); @@ -378,7 +378,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { switch (this->unk_3F0) { case 0: sp34 = func_80BA7088(this, globalCtx); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) && (sp34 == 1)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { this->unk_3F0 = 1; func_800BDC5C(&this->skelAnime, sAnimations, 0); } else if (!(player->stateFlags2 & 0x80)) { @@ -402,7 +402,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3F2++; } - if (func_801378B8(&this->skelAnime, 0.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); } @@ -419,7 +419,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { break; case 2: - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F4 = 40; this->actor.shape.yOffset = 0.0f; func_80BA5AF0(this); @@ -445,7 +445,7 @@ void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x12C, 0); Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x12C, 0); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80BA6158(this); } @@ -516,12 +516,12 @@ void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.speedXZ += 0.15f; } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { this->actor.hintId = 0x2A; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06010B88, NULL, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010B88, NULL, this->jointTable, this->morphTable, 26); this->unk_3F8 = 1; } func_80BA6284(this); @@ -584,7 +584,7 @@ void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { } if ((this->unk_3F2 == 20) && (this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06010B88, NULL, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010B88, NULL, this->jointTable, this->morphTable, 26); this->unk_3F8 = 1; } } @@ -912,7 +912,7 @@ void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BA6DF8(this, globalCtx); this->actionFunc(this, globalCtx); if (this->actionFunc != func_80BA6604) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } func_80BA71E4(this, globalCtx); func_80BA76C4(this, globalCtx); @@ -949,7 +949,7 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - SysMatrix_GetStateTranslation(&this->unk_1D8[this->unk_28C]); + Matrix_GetStateTranslation(&this->unk_1D8[this->unk_28C]); this->unk_28C++; } } @@ -966,18 +966,18 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); - POLY_OPA_DISP = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, - EnRailgibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, + EnRailgibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); - POLY_XLU_DISP = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, - EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnRailgibud_OverrideLimbDraw, + EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } if (this->unk_3F6 > 0) { @@ -996,7 +996,7 @@ void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.flags |= 0x100000; this->actor.flags |= 0x10; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -1091,7 +1091,7 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { func_800BDC5C(&this->skelAnime, sAnimations, 10); break; } - } else if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_3F0 == 15) { this->unk_3F0 = 16; func_800BDC5C(&this->skelAnime, sAnimations, 16); @@ -1113,7 +1113,7 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { break; case 5: - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (globalCtx->csCtx.frames < 280) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); } else { @@ -1136,5 +1136,5 @@ void func_80BA8050(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); func_80BA7DC8(this, globalCtx); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index ff35322f1..c6359ba89 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -163,9 +163,11 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params >= ENRD_GET_MINUS_1) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06010B88, &D_0600ABE0, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010B88, &D_0600ABE0, this->jointTable, this->morphTable, + 26); } else { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, + 26); } Collider_InitCylinder(globalCtx, &this->collider); @@ -217,7 +219,7 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { func_808D4DC4(this); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->actor.params == ENRD_GET_3) { this->actor.flags |= 0x80; @@ -279,9 +281,9 @@ void func_808D4260(EnRd* this, GlobalContext* globalCtx) { void func_808D4308(EnRd* this) { if (this->actor.params != ENRD_GET_2) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600ABE0, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600ABE0, -6.0f); } else { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060081A8); + Animation_PlayLoop(&this->skelAnime, &D_060081A8); } this->unk_3EF = 0; @@ -292,20 +294,20 @@ void func_808D4308(EnRd* this) { } void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if ((this->actor.params == ENRD_GET_2) && func_801378B8(&this->skelAnime, 0.0f)) { + if ((this->actor.params == ENRD_GET_2) && Animation_OnFrame(&this->skelAnime, 0.0f)) { if (Rand_ZeroOne() >= 0.5f) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_060081A8); + Animation_PlayLoop(&this->skelAnime, &D_060081A8); } else { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06007BBC); + Animation_PlayLoop(&this->skelAnime, &D_06007BBC); } } else { this->unk_3D6--; if (this->unk_3D6 == 0) { this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 10.0f; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } } @@ -342,7 +344,7 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } void func_808D45D4(EnRd* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0601216C, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0601216C, -6.0f); this->unk_3EF = 14; this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; this->unk_3E4 = 0; @@ -352,7 +354,7 @@ void func_808D45D4(EnRd* this) { } void func_808D4660(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); if (this->unk_3EC != 0) { @@ -366,7 +368,7 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } else { this->actor.hintId = 0x2A; } - SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); this->actionFunc = func_808D49E4; } @@ -385,7 +387,7 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } void func_808D47DC(EnRd* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06011DB8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06011DB8, -6.0f); this->unk_3EF = 15; this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; this->unk_3E4 = 0; @@ -395,7 +397,7 @@ void func_808D47DC(EnRd* this) { } void func_808D4868(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); if (this->unk_3EC != 0) { @@ -409,7 +411,7 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } else { this->actor.hintId = 0x2A; } - SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); this->actionFunc = func_808D49E4; } @@ -428,7 +430,7 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); } @@ -445,7 +447,7 @@ void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { } void func_808D4A90(EnRd* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060118D8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &D_060118D8, -6.0f); this->unk_3EF = 16; this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; this->unk_3E4 = 4370; @@ -455,7 +457,7 @@ void func_808D4A90(EnRd* this) { } void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); if (this->unk_3EC != 0) { @@ -485,9 +487,9 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3E4 = 4370; - } else if (func_801378B8(&this->skelAnime, 15.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 15.0f)) { this->unk_3E4 = 6554; } @@ -496,7 +498,7 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); } @@ -506,7 +508,7 @@ void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { this->unk_3E4 -= 100; if ((this->unk_3E4 < 2100) && (this->unk_3E4 >= 2000)) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); } else if (this->unk_3E4 < 1000) { if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { func_808D5C54(this); @@ -517,8 +519,7 @@ void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { } void func_808D4DC4(EnRd* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600ABE0, 0.0f, 0.0f, SkelAnime_GetFrameCount(&D_0600ABE0.common), 0, - -6.0f); + Animation_Change(&this->skelAnime, &D_0600ABE0, 0.0f, 0.0f, Animation_GetLastFrame(&D_0600ABE0), 0, -6.0f); this->unk_3EF = 13; this->unk_3D6 = 6; this->actor.shape.rot.x = -0x4000; @@ -552,9 +553,9 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { - f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); + f32 frameCount = Animation_GetLastFrame(&D_060113EC); - SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &D_060113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); this->actor.speedXZ = 0.4f; this->unk_3EF = 4; this->actionFunc = func_808D506C; @@ -565,12 +566,12 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { s32 pad; s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; - this->skelAnime.animPlaybackSpeed = this->actor.speedXZ; + this->skelAnime.playSpeed = this->actor.speedXZ; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { func_808D53C0(this, globalCtx); @@ -619,7 +620,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } } - if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); @@ -627,8 +628,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, SkelAnime_GetFrameCount(&D_060113EC.common), 1, - -4.0f); + Animation_Change(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, Animation_GetLastFrame(&D_060113EC), 1, -4.0f); this->unk_3EF = 2; this->actionFunc = func_808D5440; } @@ -654,7 +654,7 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && !(player->stateFlags2 & 0x4080) && (player->transformation != PLAYER_FORM_GORON) && @@ -670,7 +670,7 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } } - if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); @@ -678,9 +678,9 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } void func_808D5660(EnRd* this) { - f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); + f32 frameCount = Animation_GetLastFrame(&D_060113EC); - SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); this->unk_3EF = 3; this->unk_3EC = 1; this->actionFunc = func_808D56E4; @@ -713,9 +713,9 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.shape.rot.y; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 10.0f) || func_801378B8(&this->skelAnime, 22.0f)) { + if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); @@ -723,7 +723,7 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { } void func_808D586C(EnRd* this) { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06006EEC); + Animation_PlayOnce(&this->skelAnime, &D_06006EEC); this->unk_3D6 = 0; this->unk_3EB = 0; this->unk_3EA = 200; @@ -736,13 +736,13 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->unk_3EB++; } switch (this->unk_3EB) { case 1: - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_06006678); + Animation_PlayLoop(&this->skelAnime, &D_06006678); this->unk_3EB++; globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 255, 1, 12); @@ -758,8 +758,8 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - SkelAnime_ChangeAnim(&this->skelAnime, &D_06006B08, 0.5f, 0.0f, - SkelAnime_GetFrameCount(&D_06006B08.common), 3, 0.0f); + Animation_Change(&this->skelAnime, &D_06006B08, 0.5f, 0.0f, Animation_GetLastFrame(&D_06006B08), 3, + 0.0f); this->unk_3EB++; this->unk_3EF = 4; break; @@ -786,7 +786,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { 0.0f); Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 6000, 0); - if (func_801378B8(&this->skelAnime, 0.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); } @@ -819,8 +819,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { } void func_808D5C54(EnRd* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, SkelAnime_GetFrameCount(&D_060073A4.common), 2, - 0.0f); + Animation_Change(&this->skelAnime, &D_060073A4, 0.0f, 0.0f, Animation_GetLastFrame(&D_060073A4), 2, 0.0f); this->unk_3EF = 7; this->actionFunc = func_808D5CCC; } @@ -842,7 +841,7 @@ void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { void func_808D5D88(EnRd* this) { this->unk_3EF = 8; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009900, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009900, -6.0f); this->actor.speedXZ = -2.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3EF = 8; @@ -857,16 +856,16 @@ void func_808D5DF4(EnRd* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_808D5E98(this); } } void func_808D5E98(EnRd* this) { - f32 frameCount = SkelAnime_GetFrameCount(&D_060113EC.common); + f32 frameCount = Animation_GetLastFrame(&D_060113EC); - SkelAnime_ChangeAnim(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &D_060113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); this->unk_3EF = 9; this->unk_3D4 = 0; this->actionFunc = func_808D5F18; @@ -880,19 +879,19 @@ void func_808D5F18(EnRd* this, GlobalContext* globalCtx) { this->unk_3D4 = 0; } else { this->unk_3D8 = Math_SinS(this->unk_3D4 * 4000) * (9583.0f * ((60 - this->unk_3D4) / 60.0f)); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); this->unk_3D4++; } } void func_808D6008(EnRd* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_0600A450, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A450, -4.0f); this->unk_3EF = 5; this->actionFunc = func_808D6054; } void func_808D6054(EnRd* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.parent != NULL) { func_808D5660(this); } else { @@ -902,21 +901,20 @@ void func_808D6054(EnRd* this, GlobalContext* globalCtx) { } void func_808D60B0(EnRd* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600A450, -1.0f, SkelAnime_GetFrameCount(&D_0600A450.common), 0.0f, 2, - -4.0f); + Animation_Change(&this->skelAnime, &D_0600A450, -1.0f, Animation_GetLastFrame(&D_0600A450), 0.0f, 2, -4.0f); this->unk_3EF = 6; this->actionFunc = func_808D6130; } void func_808D6130(EnRd* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { func_808D4308(this); } } void func_808D616C(EnRd* this) { this->actor.shape.yOffset = 0.0f; - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009900, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009900, -6.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -2.0f; } @@ -938,7 +936,7 @@ void func_808D6200(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.parent != NULL) { func_808D5660(this); @@ -952,7 +950,7 @@ void func_808D6200(EnRd* this, GlobalContext* globalCtx) { } void func_808D6310(EnRd* this) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06009298, -1.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009298, -1.0f); this->unk_3EF = 12; this->unk_3D6 = 300; this->actor.flags &= ~1; @@ -969,7 +967,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_3D8, 0, 1, 2000, 0); Math_SmoothStepToS(&this->unk_3DA, 0, 1, 2000, 0); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_3D6 == 0) { if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { Actor_SetSwitchFlag(globalCtx, this->unk_3DC & 0x7F); @@ -987,7 +985,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { } else { this->unk_3D6--; } - } else if (func_801378B8(&this->skelAnime, 33.0f) || func_801378B8(&this->skelAnime, 40.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -1224,7 +1222,7 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - SysMatrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); + Matrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); this->unk_290++; } } @@ -1245,9 +1243,9 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_3DE); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); - POLY_OPA_DISP = SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, - &this->actor, POLY_OPA_DISP); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, + &this->actor, POLY_OPA_DISP); func_800BC620(&sp54, &D_808D7138, 255, globalCtx); } else { @@ -1257,8 +1255,8 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); POLY_XLU_DISP = - SkelAnime_DrawSV2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, - this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); func_800BC620(&sp54, &D_808D7138, this->unk_3DE, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 94db2b4bc..a5e91243b 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -42,7 +42,7 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, NULL, NULL, 0); this->actor.flags &= ~1; func_80C25D40(this); } @@ -58,36 +58,37 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } -s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - EnRsn* this = THIS; +s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* arg) { + EnRsn* this = (EnRsn*)arg; if (limbIndex == 14) { - SysMatrix_InsertXRotation_s(this->unk1D8.y, 1); + Matrix_InsertXRotation_s(this->unk1D8.y, 1); } return 0; } static Vec3f D_80C26028 = { 0.0f, 0.0f, 0.0f }; -void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnRsn* this = THIS; +void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* arg) { + EnRsn* this = (EnRsn*)arg; Vec3f sp18 = D_80C26028; if (limbIndex == 14) { - SysMatrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); } } void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; + OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_06005458)); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index 691efcdf7..a860e49fb 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -117,8 +117,7 @@ void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.mass = 0xA; this->actor.colChkInfo.health = 2; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06002BF0, &D_06000194, this->limbDrawTable, - this->transitionDrawTable, 9); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06002BF0, &D_06000194, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->isDead = false; @@ -150,45 +149,45 @@ void EnSb_SpawnBubbles(GlobalContext* globalCtx, EnSb* this) { } void EnSb_SetupWaitClosed(EnSb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600004C, 1.0f, 0, SkelAnime_GetFrameCount(&D_0600004C.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &D_0600004C, 1.0f, 0, Animation_GetLastFrame(&D_0600004C), 2, 0.0f); this->state = SHELLBLADE_WAIT_CLOSED; this->actionFunc = EnSb_Idle; } void EnSb_SetupOpen(EnSb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_06000194, 1.0f, 0, SkelAnime_GetFrameCount(&D_06000194.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &D_06000194, 1.0f, 0, Animation_GetLastFrame(&D_06000194), 2, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupWaitOpen(EnSb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_06002C8C, 1.0f, 0, SkelAnime_GetFrameCount(&D_06002C8C.common), 0, 0.0f); + Animation_Change(&this->skelAnime, &D_06002C8C, 1.0f, 0, Animation_GetLastFrame(&D_06002C8C), 0, 0.0f); this->state = SHELLBLADE_WAIT_OPEN; this->actionFunc = EnSb_WaitOpen; } void EnSb_SetupLunge(EnSb* this) { - f32 frameCount = SkelAnime_GetFrameCount(&D_06000124.common); + f32 frameCount = Animation_GetLastFrame(&D_06000124); f32 playbackSpeed = this->actor.yDistToWater > 0.0f ? 1.0f : 0.0f; - SkelAnime_ChangeAnim(&this->skelAnime, &D_06000124, playbackSpeed, 0.0f, frameCount, 2, 0); + Animation_Change(&this->skelAnime, &D_06000124, playbackSpeed, 0.0f, frameCount, 2, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupBounce(EnSb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_060000B4, 1.0f, 0, SkelAnime_GetFrameCount(&D_060000B4.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &D_060000B4, 1.0f, 0, Animation_GetLastFrame(&D_060000B4), 2, 0.0f); this->state = SHELLBLADE_BOUNCE; this->actionFunc = EnSb_Bounce; } void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { - f32 frameCount = SkelAnime_GetFrameCount(&D_0600004C.common); + f32 frameCount = Animation_GetLastFrame(&D_0600004C); if (this->state != SHELLBLADE_WAIT_CLOSED) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600004C, 1.0f, 0, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &D_0600004C, 1.0f, 0, frameCount, 2, 0.0f); } this->state = SHELLBLADE_WAIT_CLOSED; if (changeSpeed) { @@ -216,9 +215,9 @@ void EnSb_Idle(EnSb* this, GlobalContext* globalCtx) { } void EnSb_Open(EnSb* this, GlobalContext* globalCtx) { - f32 currentFrame = this->skelAnime.animCurrentFrame; + f32 currentFrame = this->skelAnime.curFrame; - if (SkelAnime_GetFrameCount(&D_06000194.common) <= currentFrame) { + if (Animation_GetLastFrame(&D_06000194) <= currentFrame) { this->vulnerableTimer = 20; EnSb_SetupWaitOpen(this); } else { @@ -281,8 +280,8 @@ void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { s32 pad; - f32 currentFrame = currentFrame = this->skelAnime.animCurrentFrame; - f32 frameCount = frameCount = SkelAnime_GetFrameCount(&D_060000B4.common); + f32 currentFrame = currentFrame = this->skelAnime.curFrame; + f32 frameCount = frameCount = Animation_GetLastFrame(&D_060000B4); Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (currentFrame == frameCount) { @@ -384,7 +383,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } } @@ -411,8 +410,8 @@ void EnSb_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 fireDecr; func_800B8050(&this->actor, globalCtx, 1); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - EnSb_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnSb_PostLimbDraw, &this->actor); if (this->fireCount != 0) { this->actor.colorFilterTimer++; fireDecr = this->fireCount - 1; diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.h b/src/overlays/actors/ovl_En_Sb/z_en_sb.h index 935a697ca..167a0c5c8 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.h +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.h @@ -18,8 +18,8 @@ typedef enum { typedef struct EnSb { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTable[9]; - /* 0x1BE */ Vec3s transitionDrawTable[9]; + /* 0x188 */ Vec3s jointTable[9]; + /* 0x1BE */ Vec3s morphTable[9]; /* 0x1F4 */ EnSbActionFunc actionFunc; /* 0x1F8 */ ColliderCylinder collider; /* 0x244 */ s16 fireCount; diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 3901c8b24..badcc5501 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -133,7 +133,7 @@ void func_80ADADD0(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADAE64(EnSellnuts* this) { - s16 currentFrame = this->skelAnime.animCurrentFrame; + s16 currentFrame = this->skelAnime.curFrame; switch (currentFrame) { case 10: @@ -194,7 +194,7 @@ void func_80ADAE64(EnSellnuts* this) { } void func_80ADAFC0(EnSellnuts* this) { - s16 currentFrame = this->skelAnime.animCurrentFrame; + s16 currentFrame = this->skelAnime.curFrame; switch (currentFrame) { case 10: @@ -244,8 +244,8 @@ f32 func_80ADB08C(GlobalContext* globalCtx) { } void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if (currentFrame == frameCount) { switch (this->unk_340) { @@ -298,8 +298,8 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (((this->actor.yDistToPlayer < 50.0f) && (this->actor.yDistToPlayer > -50.0f) ? true : false) && @@ -339,7 +339,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { - if (this->skelAnime.animCurrentFrame == this->skelAnime.animFrameCount) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80ADB544; func_8013BC6C(&this->skelAnime, D_80ADD990, 0); } @@ -463,8 +463,8 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = func_80152498(&globalCtx->msgCtx); - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if (this->unk_368 == 0x28) { this->unk_34C = 5; @@ -516,8 +516,8 @@ void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = func_80152498(&globalCtx->msgCtx); - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if ((currentFrame == frameCount) && (this->unk_34C == 7)) { this->unk_34C = 0; @@ -536,8 +536,8 @@ void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); func_80ADAE64(this); if (this->unk_366 == 0) { @@ -598,8 +598,8 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { Vec3f sp34; - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if (currentFrame == frameCount) { Math_SmoothStepToS(&this->unk_364, 0x1C71, 3, 0x100, 0); @@ -817,8 +817,8 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if (this->unk_34C == 22) { Math_SmoothStepToS(&this->unk_364, 0, 3, 0x100, 0); @@ -852,8 +852,8 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { - s16 currentFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&D_80ADD990[this->unk_34C].animationSeg->common); + s16 currentFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); if (this->unk_34C == 3) { if (currentFrame == frameCount) { @@ -962,7 +962,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600AC70, &D_06005488, this->jointTable, this->morphTable, 28); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600AC70, &D_06005488, this->jointTable, this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); @@ -1055,7 +1055,7 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetHeight(&this->actor, 60.0f); Actor_SetScale(&this->actor, 0.01f); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); this->actionFunc(this, globalCtx); if (this->unk_338 & 8) { @@ -1110,7 +1110,7 @@ s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 24) { - SysMatrix_InsertXRotation_s(this->unk_342, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_342, MTXMODE_APPLY); } if (limbIndex == 26) { @@ -1148,6 +1148,6 @@ void EnSellnuts_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSellnuts* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSellnuts_OverrideLimbDraw, EnSellnuts_PostLimbDraw, func_80ADD7CC, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 91efc860c..3fd19ef91 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -297,7 +297,7 @@ void func_80994E2C(EnSkb* this) { } void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { - if (this->skelAnime.animCurrentFrame < 4.0f) { + if (this->skelAnime.curFrame < 4.0f) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; } else { @@ -310,7 +310,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { func_809947B0(globalCtx, this, &this->actor.world.pos); } - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) && (this->actor.shape.yOffset == 0.0f)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.shape.yOffset == 0.0f)) { func_80995A30(this); } this->unk_3D0++; @@ -471,13 +471,13 @@ void func_809954F8(EnSkb* this) { void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { s16 sp26; - if (this->skelAnime.animCurrentFrame < 15.0f) { - sp26 = this->skelAnime.animCurrentFrame - 7.5f; + if (this->skelAnime.curFrame < 15.0f) { + sp26 = this->skelAnime.curFrame - 7.5f; } else { - sp26 = 22.5f - this->skelAnime.animCurrentFrame; + sp26 = 22.5f - this->skelAnime.curFrame; } - if (func_801378B8(&this->skelAnime, 22.5f)) { + if (Animation_OnFrame(&this->skelAnime, 22.5f)) { this->unk_3D4 = (u32)Rand_Next() % 0x7D0; } @@ -487,7 +487,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && - (this->skelAnime.animCurrentFrame > 24.0f) && (this->skelAnime.animCurrentFrame < 28.0f)) { + (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.targetArrowOffset = 2000.0f; @@ -521,7 +521,7 @@ void func_80995818(EnSkb* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.shadowScale, 25.0f, 1.0f, 2.5f); Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 0x10, 0x7D0, 0x64); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.rot.x = 0; this->actor.gravity = -2.0f; func_80995A30(this); @@ -536,8 +536,7 @@ void func_80995818(EnSkb* this, GlobalContext* globalCtx) { } void func_809958F4(EnSkb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_06003584, -1.0f, SkelAnime_GetFrameCount(&D_06003584.common), 0.0f, 2, - -4.0f); + Animation_Change(&this->skelAnime, &D_06003584, -1.0f, Animation_GetLastFrame(&D_06003584), 0.0f, 2, -4.0f); this->unk_3E4 = 0; this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; @@ -555,7 +554,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 2.5f); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_MarkForDeath(&this->actor); } } @@ -585,7 +584,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_801378B8(&this->skelAnime, 8.0f) || func_801378B8(&this->skelAnime, 15.0f)) { + if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { Audio_PlayActorSound2(&this->actor, 0x3830); } @@ -605,23 +604,23 @@ void func_80995C24(EnSkb* this) { } void func_80995C84(EnSkb* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { + if (Animation_OnFrame(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3E4 = 1; - } else if (func_801378B8(&this->skelAnime, 6.0f)) { + } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->unk_3E4 = 0; } if (this->collider.base.atFlags & AT_BOUNCED) { this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); func_80995D3C(this); - } else if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80994DA8(this, globalCtx); } } void func_80995D3C(EnSkb* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_06002190, -0.4f, this->skelAnime.animCurrentFrame - 1.0f, 0.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &D_06002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, 3, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->unk_3DE = 4; this->unk_3E4 = 0; @@ -629,7 +628,7 @@ void func_80995D3C(EnSkb* this) { } void func_80995DC4(EnSkb* this, GlobalContext* globalCtx) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80994DA8(this, globalCtx); } } @@ -720,7 +719,7 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 0x10, 0x7D0, 0x64); - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) && (this->actor.bgCheckFlags & 1)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.bgCheckFlags & 1)) { this->actor.shape.rot.x = 0; this->actor.world.rot = this->actor.shape.rot; func_80994DA8(this, globalCtx); @@ -1049,7 +1048,7 @@ void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->actionFunc != func_80995E64) && (this->actionFunc != func_80996284) && (this->actionFunc != func_8099630C) && (this->actionFunc != func_809963D8)) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } func_8099672C(this, globalCtx); @@ -1087,7 +1086,7 @@ s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 10) { - SysMatrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslation(&this->actor.focus.pos); } return false; @@ -1112,10 +1111,10 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - SysMatrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); + Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); this->unk_2DC++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - SysMatrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); + Matrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); this->unk_2DC++; } } @@ -1126,8 +1125,8 @@ void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { this->unk_2DC = 0; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnSkb_OverrideLimbDraw, - EnSkb_PostLimbDraw, &this->actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, + EnSkb_PostLimbDraw, &this->actor); if (this->unk_3D2 > 0) { func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_230, 0.5f, this->unk_22C, this->unk_3E6); 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 8d501627a..8f79570b6 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -171,12 +171,12 @@ void EnSob1_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s animations += idx; if (animations->frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&animations->animationSeg->common); + frameCount = Animation_GetLastFrame(animations->animationSeg); } else { frameCount = animations->frameCount; } - SkelAnime_ChangeAnim(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, + animations->mode, animations->transitionRate); } void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { @@ -721,8 +721,8 @@ void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s32 pad; f32 distSq; - s16 animCurrentFrame = this->skelAnime.animCurrentFrame / this->skelAnime.animPlaybackSpeed; - s16 animLastFrame = SkelAnime_GetFrameCount(&D_06009120.common) / (s16)this->skelAnime.animPlaybackSpeed; + s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&D_06009120) / (s16)this->skelAnime.playSpeed; Math_SmoothStepToS( &this->actor.world.rot.y, @@ -732,7 +732,7 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { this->actor.speedXZ = 0.0f; - if (animLastFrame == animCurrentFrame) { + if (animLastFrame == curFrame) { EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 1); EnSob1_SetupAction(this, EnSob1_SetupIdle); } @@ -741,9 +741,9 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { - s16 animCurrentFrame = this->skelAnime.animCurrentFrame; + s16 curFrame = this->skelAnime.curFrame; - if (SkelAnime_GetFrameCount(&D_06008268.common) == animCurrentFrame) { + if (Animation_GetLastFrame(&D_06008268) == curFrame) { EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 2); EnSob1_SetupAction(this, EnSob1_Idle); } @@ -1334,31 +1334,26 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600D208, NULL, this->limbDrawTable, this->transitionDrawTable, - 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D208, NULL, this->jointTable, this->morphTable, 20); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - SkelAnime_ChangeAnim(&this->skelAnime, &D_0600078C, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_0600078C.common), 0, - 0.0f); + Animation_Change(&this->skelAnime, &D_0600078C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0600078C), 0, 0.0f); this->actor.draw = EnSob1_DrawZoraShopkeeper; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06011AC8, NULL, this->limbDrawTable, this->transitionDrawTable, - 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011AC8, NULL, this->jointTable, this->morphTable, 18); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - SkelAnime_ChangeAnim(&this->skelAnime, &D_060000FC, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_060000FC.common), 0, - 0.0f); + Animation_Change(&this->skelAnime, &D_060000FC, 1.0f, 0.0f, Animation_GetLastFrame(&D_060000FC), 0, 0.0f); this->actor.draw = EnSob1_DrawGoronShopkeeper; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, this->limbDrawTable, - this->transitionDrawTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, this->jointTable, this->morphTable, 16); this->actor.draw = EnSob1_DrawBombShopkeeper; this->changeObjectFunc = NULL; - this->skelAnime.animPlaybackSpeed = 2.0f; + this->skelAnime.playSpeed = 2.0f; } void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { @@ -1483,7 +1478,7 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { if (changeObjectFunc != NULL) { changeObjectFunc(this, globalCtx); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } else { this->actionFunc(this, globalCtx); } @@ -1613,7 +1608,7 @@ s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbInde EnSob1* this = THIS; if (limbIndex == 15) { - SysMatrix_InsertXRotation_s(this->headRot, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot, MTXMODE_APPLY); } return false; } @@ -1647,8 +1642,8 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1668,8 +1663,8 @@ void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sGoronShopkeeperEyeTextures[this->eyeTexIndex])); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1689,8 +1684,8 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_06005458)); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1700,7 +1695,7 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { EnSob1_DrawStickDirectionPrompt(globalCtx, this); frames = globalCtx->gameplayFrames; func_8012C2DC(globalCtx->state.gfxCtx); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h index a7f8262fe..c1dfd3849 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -32,8 +32,8 @@ typedef struct EnSob1 { /* 0x1EA */ s8 objIndices[3]; /* 0x1EE */ s16 headRot; /* 0x1F0 */ s16 headRotTarget; - /* 0x1F2 */ Vec3s limbDrawTable[20]; - /* 0x26A */ Vec3s transitionDrawTable[20]; + /* 0x1F2 */ Vec3s jointTable[20]; + /* 0x26A */ Vec3s morphTable[20]; /* 0x2E2 */ s16 eyeTexIndex; /* 0x2E4 */ s16 blinkTimer; /* 0x2E8 */ EnSob1BlinkFunc blinkFunc; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index ec18b9bd2..7449b0f5d 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -215,8 +215,8 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAA9B4(EnSuttari* this) { - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); switch (this->textId) { case 0x1454: @@ -382,8 +382,8 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAAF1C(EnSuttari* this) { - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->animationIdx == 5) { this->animationIdx = 3; @@ -405,11 +405,11 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 10.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 10.0f; - SysMatrix_StatePush(); + Matrix_StatePush(); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - SysMatrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - SysMatrix_StatePop(); + Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); + Matrix_StatePop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, 50, &this->unk3F0, 1); } @@ -437,11 +437,11 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 350.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 350.0f; - SysMatrix_StatePush(); + Matrix_StatePush(); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - SysMatrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - SysMatrix_StatePop(); + Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); + Matrix_StatePop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, 50, &this->unk3F0, 1); } @@ -462,7 +462,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAB374(EnSuttari* this, GlobalContext* globalCtx) { - s16 curFrame = this->skelAnime.animCurrentFrame; + s16 curFrame = this->skelAnime.curFrame; Vec3f sp38; if ((curFrame % 3) == 0) { @@ -490,7 +490,7 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { if (this->flags1 & 0x80) { EnSuttari_UpdateCollider(this, globalCtx); } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) != 0) { sp30.x = player->actor.world.pos.x; @@ -816,8 +816,8 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); switch (this->unk428) { case 12: @@ -913,7 +913,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600C240, &D_0600071C, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600C240, &D_0600071C, this->jointTable, this->morphTable, 16); this->actor.draw = EnSuttari_Draw; this->actor.flags |= 1; if (globalCtx->sceneNum == SCENE_IKANA) { @@ -1220,8 +1220,8 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.unk_14; struct_80133038_arg2 unkStruct; - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { this->animationIdx = 2; @@ -1256,8 +1256,8 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.unk_14; struct_80133038_arg2 unkStruct; - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->enFsn == NULL) { this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); @@ -1305,8 +1305,8 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { u8 talkstate = func_80152498(&globalCtx->msgCtx); - s16 curFrame = this->skelAnime.animCurrentFrame; - s16 frameCount = SkelAnime_GetFrameCount(&sAnimations[this->animationIdx].animation->common); + s16 curFrame = this->skelAnime.curFrame; + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->flags1 & 1) { this->unk3F2 = this->unk2DE; @@ -1460,11 +1460,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk428 != 0) { if (this->animationIdx == 2 || this->animationIdx == 6) { - if (func_801378B8(&this->skelAnime, 8.0f) || func_801378B8(&this->skelAnime, 16.0f)) { + if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if (this->animationIdx == 0 || this->animationIdx == 5) { - if (func_801378B8(&this->skelAnime, 8.0f) || func_801378B8(&this->skelAnime, 17.0f)) { + if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); } } @@ -1478,15 +1478,15 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (limbIndex == 15) { *dList = D_0600AF90; if (!(this->flags1 & 4)) { - SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(-this->unk2DC, MTXMODE_APPLY); - SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2DC, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - SysMatrix_InsertXRotation_s(-this->unk2E4, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(-this->unk2E2, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->unk2E4, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2E2, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); @@ -1506,8 +1506,8 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (((this->flags1 & 8) && (this->flags1 & 0x10)) || ((this->flags1 & 2) && !(this->flags1 & 0x20)) || ((this->flags1 & 4) && !(this->flags1 & 0x20))) { if (limbIndex == 8) { - curState = SysMatrix_GetCurrentState(); - SysMatrix_MultiplyVector3fByState(&D_80BAE95C, &this->unk3F8); + curState = Matrix_GetCurrentState(); + Matrix_MultiplyVector3fByState(&D_80BAE95C, &this->unk3F8); if (this->actor.child == NULL) { if (this->flags1 & 0x100) { bombBag = @@ -1526,7 +1526,7 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } if (limbIndex == 15) { - SysMatrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); } } @@ -1545,7 +1545,7 @@ void EnSuttari_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 55, 55, 255, 0)); gDPPipeSync(POLY_OPA_DISP++); - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSuttari_OverrideLimbDraw, EnSuttari_PostLimbDraw, EnSuttari_UnkDraw, &this->actor); if (this->flags1 & 0x80) { func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index d0a58410c..5bcd70b77 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -289,8 +289,8 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - SysMatrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); - SysMatrix_MultiplyVector3fByState(&this->unk_350, &sp2C); + Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); + Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); } @@ -328,8 +328,8 @@ s32 func_808D91C4(EnSw* this, CollisionPoly* arg1) { } Math_Vec3f_Scale(&sp2C, 1.0f / temp_f0); - SysMatrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); - SysMatrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); + Matrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); Math_Vec3f_Copy(&this->unk_35C, &sp2C); Math3D_CrossProduct(&this->unk_35C, &sp38, &this->unk_350); @@ -488,11 +488,11 @@ void func_808D9894(EnSw* this, Vec3f* vec) { sp1C.zw = 0.0f; sp1C.ww = 0.0f; - SysMatrix_SetCurrentState(&sp1C); + Matrix_SetCurrentState(&sp1C); sp5C.x = vec->x - this->actor.world.pos.x; sp5C.y = vec->y - this->actor.world.pos.y; sp5C.z = vec->z - this->actor.world.pos.z; - SysMatrix_MultiplyVector3fByState(&sp5C, vec); + Matrix_MultiplyVector3fByState(&sp5C, vec); } s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { @@ -529,8 +529,8 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { f32 frame; if (DECR(this->unk_454) == 0) { - if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { - frame = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + frame = this->skelAnime.endFrame - this->skelAnime.curFrame; sp2E = (80.0f * frame) * this->unk_450; } else { if (this->unk_456 != 0) { @@ -540,7 +540,7 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } else { this->unk_454 = Rand_S16Offset(20, 20); this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; @@ -767,15 +767,15 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { Vec3f sp38; f32 temp_f16; - if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { - temp_f16 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + temp_f16 = this->skelAnime.endFrame - this->skelAnime.curFrame; temp_s1 = (s16)(80.0f * temp_f16); Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); temp_v0 = Math_FAtan2F(sp38.z, sp38.x); if (ABS_ALT(temp_v0) < temp_s1) { - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); this->unk_414 = 0.0f; if (this->unk_410 & 0x20) { @@ -788,7 +788,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { temp_s1 *= (temp_v0 < 0) ? -1 : 1; } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } func_808D94D0(this, globalCtx, 0, 0, temp_s1); } @@ -800,8 +800,8 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { s32 test2; Vec3f sp30; - if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { - temp_f0 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.3f * temp_f0; func_808D94D0(this, globalCtx, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { @@ -814,7 +814,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->actionFunc = func_808DA3F4; } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } temp_f0 = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); @@ -839,8 +839,8 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { Vec3f sp38; f32 temp_f0; - if (!func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { - temp_f0 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.14f * temp_f0; func_808D94D0(this, globalCtx, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { @@ -850,7 +850,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { } } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); @@ -861,7 +861,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { this->unk_454 = Rand_S16Offset(20, 20); this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; this->actionFunc = func_808DA350; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } this->unk_414 = sp4C; } @@ -939,15 +939,15 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { sp40 = 0; if (DECR(this->unk_454) == 0) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) == 0) { - temp_f16 = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 0) { + temp_f16 = this->skelAnime.endFrame - this->skelAnime.curFrame; sp40 = 80.0f * temp_f16; if (this->unk_45E == 0) { Math_Vec3s_ToVec3f(&sp34, &sp44[this->unk_4A0]); func_808D9894(this, &sp34); temp_v0 = Math_FAtan2F(sp34.z, sp34.x); if (ABS_ALT(temp_v0) < sp40) { - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); Math_Vec3s_ToVec3f(&this->unk_374, &sp44[this->unk_4A0]); this->actionFunc = func_808DACF4; @@ -960,7 +960,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { if (this->unk_456 != 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); this->unk_456--; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } else { this->unk_454 = Rand_S16Offset(20, 20); this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; @@ -987,11 +987,11 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { f32 temp_f0; s32 temp_f6; - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount) == 0) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 0) { Vec3f sp38; f32 temp; - temp = this->skelAnime.animFrameCount - this->skelAnime.animCurrentFrame; + temp = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.1f * temp; func_808D94D0(this, globalCtx, 1, 0, 0); if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { @@ -1002,7 +1002,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { } } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } sp4C = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_374); @@ -1092,7 +1092,7 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { this->unk_498 = this->actor.parent->id; this->unk_456 = 0; this->unk_454 = 0; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 4); this->actionFunc = func_808DB25C; return; @@ -1103,7 +1103,7 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { return; } - if ((DECR(this->unk_454) == 0) && func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if ((DECR(this->unk_454) == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); @@ -1111,7 +1111,7 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; - this->skelAnime.animCurrentFrame = 0.0f; + this->skelAnime.curFrame = 0.0f; } else { this->unk_454 = Rand_S16Offset(20, 20); this->unk_456 = (Rand_ZeroOne() * 10.0f) + 3.0f; @@ -1171,7 +1171,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06005298, NULL, this->jointTable, this->morphTable, 30); func_8013BC6C(&this->skelAnime, sAnimations, 0); - this->skelAnime.animPlaybackSpeed = 4.0f; + this->skelAnime.playSpeed = 4.0f; Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); if (!ENSW_GET_3(&this->actor)) { @@ -1261,7 +1261,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_412 != 10) || (this->unk_45A != 0)) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); } Actor_SetHeight(&this->actor, 0.0f); @@ -1327,9 +1327,9 @@ void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); } func_8012C28C(globalCtx->state.gfxCtx); - SysMatrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnSw_OverrideLimbDraw, NULL, - &this->actor); + Matrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, + &this->actor); } for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { 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 e44872127..7e641a4ed 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 @@ -141,9 +141,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600E7D0, &D_0600DFEC, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(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); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600E7D0, &D_0600D9D0, this->jointTable, this->morphTable, + 16); } this->actor.colChkInfo.cylRadius = 100; @@ -415,8 +417,8 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; } - if (this->skelAnime.animCurrentSeg == &D_0600D2F8) { - if (func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (this->skelAnime.animation == &D_0600D2F8) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_800BDC5C(&this->skelAnime, sAnimations, 0); } } @@ -1239,7 +1241,7 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos.y = 70.0f; Actor_SetHeight(&this->actor, 70.0f); if (this->unk_26A != 1) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); } } @@ -1253,12 +1255,12 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } 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); + Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); + Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 8) { - SysMatrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); } return false; @@ -1269,7 +1271,7 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; if (limbIndex == 15) { - SysMatrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); } } @@ -1299,7 +1301,7 @@ void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { 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, + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index d98657a29..b303ed877 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -37,17 +37,14 @@ extern AnimationHeader D_06000278; extern AnimationHeader D_06000604; extern Gfx D_06003060[]; extern Gfx D_060030D8[]; -extern UNK_PTR D_060033B0; -extern UNK_PTR D_06003D58; -extern UNK_TYPE D_06004348; -extern UNK_TYPE D_06004B88; -extern UNK_TYPE D_060055E0; +extern Gfx D_060033B0[]; +extern Gfx D_06003D58[]; +extern Gfx D_06004348[]; +extern Gfx D_06004B88[]; +extern Gfx D_060055E0[]; extern FlexSkeletonHeader D_060061A0; extern AnimationHeader D_060063C4; -static Vec3f D_80C13920; -static s32 D_80C1392C; - const ActorInit En_Thiefbird_InitVars = { ACTOR_EN_THIEFBIRD, ACTORCAT_ENEMY, @@ -156,13 +153,16 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; +static Vec3f D_80C13920; +static s32 D_80C1392C; + void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { EnThiefbird* this = THIS; s32 i; ColliderJntSphElementDim* dim; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_060061A0, &D_06000604, this->jointTable, this->morphTable, 17); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060061A0, &D_06000604, this->jointTable, this->morphTable, 17); Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { @@ -217,7 +217,7 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { } s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { - static UNK_TYPE D_80C13680[] = { &D_06004348, &D_06004B88, &D_060055E0 }; + static Gfx* D_80C13680[] = { D_06004348, D_06004B88, D_060055E0 }; s32 isItemFound = false; s32 phi_a3 = 0; s32 i = 18; @@ -249,7 +249,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { func_801149A0(sp1E, i); - this->unk_3E8 = &D_060033B0; + this->unk_3E8 = D_060033B0; if (!func_80152498(&globalCtx->msgCtx)) { func_801518B0(globalCtx, 0xF4, NULL); } @@ -266,7 +266,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { phi_t0_3 = phi_a3 + 0x4C; if (phi_a3 == 4) { func_801149A0(16, 16); - this->unk_3E8 = &D_06003D58; + this->unk_3E8 = D_06003D58; phi_t0_3 = 0x10; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; @@ -471,7 +471,7 @@ void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11538(EnThiefbird* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000604, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000604, -4.0f); this->unk_18E = 60; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C11590; @@ -481,8 +481,8 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp38; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - sp38 = func_801378B8(&this->skelAnime, 0.0f); + SkelAnime_Update(&this->skelAnime); + sp38 = Animation_OnFrame(&this->skelAnime, 0.0f); this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; if (this->actor.bgCheckFlags & 8) { @@ -535,7 +535,7 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C118E4(EnThiefbird* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_060063C4, -10.0f); + Animation_MorphToLoop(&this->skelAnime, &D_060063C4, -10.0f); this->unk_18E = 300; this->actionFunc = func_80C1193C; this->actor.speedXZ = 5.0f; @@ -545,8 +545,8 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 pitch; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); - if (func_801378B8(&this->skelAnime, 1.0f)) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } @@ -602,7 +602,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { void func_80C11C60(EnThiefbird* this) { this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06000088); + Animation_PlayOnce(&this->skelAnime, &D_06000088); this->actor.bgCheckFlags &= ~1; this->actor.shape.rot.x = 0; this->unk_18E = 40; @@ -674,7 +674,7 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000278, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000278, -4.0f); func_80C10984(this, 15); if (this->actor.colChkInfo.damageEffect != 3) { this->actor.speedXZ = 4.0f; @@ -732,7 +732,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { } } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 8) { this->unk_192 = this->actor.wallYaw; } else if (this->unk_3E8 == 0) { @@ -758,7 +758,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C12308(EnThiefbird* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000278, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000278, -4.0f); func_80C10984(this, 15); this->unk_190 = -0x1000; this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); @@ -771,7 +771,7 @@ void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 8) { this->unk_192 = this->actor.wallYaw; } else { @@ -787,7 +787,7 @@ void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C1242C(EnThiefbird* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_06000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); + Animation_Change(&this->skelAnime, &D_06000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); this->actor.flags |= 0x10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; @@ -798,7 +798,7 @@ void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { Actor* temp_v0; s16 temp_v1; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 8) { this->unk_192 = this->actor.wallYaw; } else { @@ -839,7 +839,7 @@ void func_80C126A8(EnThiefbird* this) { } void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); Math_ApproachS(&this->actor.shape.rot.x, 0x3000, 6, 0x1000); if (this->actor.yDistToPlayer > 100.0f) { Actor_MarkForDeath(&this->actor); @@ -847,14 +847,14 @@ void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C12744(EnThiefbird* this) { - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06000604, -4.0f); - SkelAnime_ChangeAnim(&this->skelAnime, &D_06000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_06000604, -4.0f); + Animation_Change(&this->skelAnime, &D_06000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; this->actor.flags |= 0x10; this->actionFunc = func_80C127F4; this->actor.speedXZ = 4.0f; - this->skelAnime.animPlaybackSpeed = 3.0f; + this->skelAnime.playSpeed = 3.0f; } void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { @@ -862,7 +862,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { s16 temp_v0; f32 temp_f0; - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if ((this->unk_3EC != NULL) && ((this->unk_3EC->actor.update == NULL) || (this->unk_3EC->unk152 == 0) || (Actor_XZDistanceBetweenActors(&player->actor, &this->unk_3EC->actor) <= 10.0f))) { this->unk_3EC = NULL; @@ -1041,8 +1041,8 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } func_80C12D00(this); - if (((this->skelAnime.animCurrentSeg == &D_06000604) && func_801378B8(&this->skelAnime, 13.0f)) || - ((this->skelAnime.animCurrentSeg == &D_06000278) && func_801378B8(&this->skelAnime, 1.0f))) { + if (((this->skelAnime.animation == &D_06000604) && Animation_OnFrame(&this->skelAnime, 13.0f)) || + ((this->skelAnime.animation == &D_06000278) && Animation_OnFrame(&this->skelAnime, 1.0f))) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } } @@ -1077,17 +1077,17 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E4); POLY_OPA_DISP = &gfx[2]; CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 16) { - if (this->unk_3E8 != 0) { + if (this->unk_3E8 != NULL) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->unk_3E8 == &D_060033B0) { + if (this->unk_3E8 == D_060033B0) { gfx = POLY_XLU_DISP; } else { gfx = POLY_OPA_DISP; @@ -1096,7 +1096,7 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E8); - if (this->unk_3E8 == &D_060033B0) { + if (this->unk_3E8 == D_060033B0) { POLY_XLU_DISP = &gfx[2]; } else { POLY_OPA_DISP = &gfx[2]; @@ -1109,11 +1109,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - SysMatrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); } else { - SysMatrix_GetStateTranslation(&this->unk_350[idx]); + Matrix_GetStateTranslation(&this->unk_350[idx]); if ((idx == 3) || (idx == 5)) { - SysMatrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); } } } @@ -1134,11 +1134,11 @@ void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { if (ptr->unk_22 != 0) { - SysMatrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); Matrix_RotateY(ptr->unk_1E, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(ptr->unk_18, ptr->unk_18, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1155,8 +1155,8 @@ void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { EnThiefbird* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnThiefbird_OverrideLimbDraw, EnThiefbird_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnThiefbird_OverrideLimbDraw, EnThiefbird_PostLimbDraw, &this->actor); if (this->actor.colorFilterTimer > 0) { func_800AE5A0(globalCtx); } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 7e3e3c32a..5581f1155 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -37,7 +37,7 @@ typedef struct EnThiefbird { /* 0x03DC */ f32 unk_3DC; /* 0x03E0 */ f32 unk_3E0; /* 0x03E4 */ Gfx* unk_3E4; - /* 0x03E8 */ UNK_PTR unk_3E8; + /* 0x03E8 */ Gfx* unk_3E8; /* 0x03EC */ EnItem00* unk_3EC; /* 0x03F0 */ EnThiefbirdUnkStruct unk_3F0[40]; } EnThiefbird; // size = 0x990 diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index d15af5517..0fd8d2564 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -205,8 +205,9 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); this->actor.bgCheckFlags |= 0x400; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A978, globalCtx->sceneNum == 0x12 ? &D_06003AA8 : &D_0600C880, - this->limbDrawTbl, this->transitionDrawTbl, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A978, + ((globalCtx->sceneNum == 0x12) ? &D_06003AA8 : &D_0600C880), this->jointTable, this->morphTable, + 18); func_80BA36C0(this, globalCtx, 0); this->actor.shape.rot.x = 0; } @@ -218,14 +219,13 @@ void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && this->actionFuncIndex == 1 && - this->skelAnime.animCurrentSeg != &D_06000C80) { + if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &D_06000C80) { if (globalCtx->msgCtx.unk11F04 != 0x2A98 && globalCtx->msgCtx.unk11F04 != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } } - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, D_80BA5078[this->unk2B4]); + Animation_PlayOnce(&this->skelAnime, D_80BA5078[this->unk2B4]); } func_800BBB74(&this->unk260, 0x14, 0x50, 3); } @@ -236,7 +236,7 @@ void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == 0x12) { animationHeader = &D_06003AA8; } - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, animationHeader, -4.0f); + Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); } s32 func_80BA397C(EnToto* this, s16 arg1) { @@ -298,13 +298,13 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == 0x12) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06000C80, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000C80, -4.0f); this->unk2B4 = 0; } else { if (this->text->unk0 == 4) { func_80151BB4(globalCtx, 9); } - SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_0600B3E0, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &D_0600B3E0, -4.0f); } } @@ -652,7 +652,7 @@ s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { if (func_80BA40D4(this, globalCtx)) { player = GET_PLAYER(globalCtx); - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060028B8, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_060028B8, -4.0f); if (player->transformation == PLAYER_FORM_ZORA) { if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { Actor_SetSwitchFlag(globalCtx, this->actor.params & 0x7F); @@ -695,9 +695,9 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { this->unk2B5 = action->unk0; if (this->unk2B5 != 4) { if (this->unk2B5 == 3) { - SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001DF0, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &D_06001DF0, -4.0f); } else { - SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, this->unk2B5 == 1 ? &D_060016A4 : &D_060022C8); + Animation_PlayOnce(&this->skelAnime, this->unk2B5 == 1 ? &D_060016A4 : &D_060022C8); if (this->unk2B5 == 2 && this->unk2B3 != 0xF) { func_80151BB4(globalCtx, 9); func_80151BB4(globalCtx, 10); @@ -706,9 +706,9 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { } } Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x320); - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { if (this->unk2B5 != 3) { - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, this->unk2B5 == 1 ? &D_0600C880 : &D_06001324); + Animation_PlayLoop(&this->skelAnime, this->unk2B5 == 1 ? &D_0600C880 : &D_06001324); } } if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, globalCtx)) { @@ -743,8 +743,8 @@ void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260])); Scene_SetRenderModeXlu(globalCtx, 0, 1); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, - NULL, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index 01f036880..aa9628426 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -24,8 +24,8 @@ typedef struct EnTotoUnkStruct2 { typedef struct EnToto { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s limbDrawTbl[18]; - /* 0x1F4 */ Vec3s transitionDrawTbl[18]; + /* 0x188 */ Vec3s jointTable[18]; + /* 0x1F4 */ Vec3s morphTable[18]; /* 0x260 */ s16 unk260; /* 0x264 */ ColliderCylinder collider; /* 0x2B0 */ u8 actionFuncIndex; 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 06fe1bfd4..0291851a1 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -112,12 +112,12 @@ void EnTrt_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s3 animations += idx; if (animations->frameCount < 0) { - frameCount = SkelAnime_GetFrameCount(&animations->animationSeg->common); + frameCount = Animation_GetLastFrame(animations->animationSeg); } else { frameCount = animations->frameCount; } - SkelAnime_ChangeAnim(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, + animations->mode, animations->transitionRate); } s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { @@ -851,8 +851,8 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { - s16 animCurrentFrame = this->skelAnime.animCurrentFrame / this->skelAnime.animPlaybackSpeed; - s16 animLastFrame = SkelAnime_GetFrameCount(&D_060030EC.common) / (s16)this->skelAnime.animPlaybackSpeed; + s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&D_060030EC) / (s16)this->skelAnime.playSpeed; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -863,7 +863,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (this->animationIdx != 5) { - if (animCurrentFrame == animLastFrame) { + if (curFrame == animLastFrame) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); this->animationIdx = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; @@ -1341,11 +1341,11 @@ void EnTrt_NodOff(EnTrt* this) { } void EnTrt_OpenThenCloseEyes(EnTrt* this) { - if (this->skelAnime.animCurrentFrame >= 40.0f) { + if (this->skelAnime.curFrame >= 40.0f) { EnTrt_CloseEyes(this); - } else if (this->skelAnime.animCurrentFrame >= 35.0f) { + } else if (this->skelAnime.curFrame >= 35.0f) { this->eyeTextureIdx = 1; - } else if (this->skelAnime.animCurrentFrame >= 10.0f) { + } else if (this->skelAnime.curFrame >= 10.0f) { EnTrt_OpenEyes(this); } } @@ -1359,7 +1359,7 @@ void EnTrt_OpenEyes2(EnTrt* this) { } void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { - if (this->skelAnime.animCurrentFrame >= 7.0f) { + if (this->skelAnime.curFrame >= 7.0f) { EnTrt_OpenEyes(this); if (this->eyeTextureIdx == 0) { this->blinkFunc = EnTrt_Blink; @@ -1452,7 +1452,7 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600FEF0, &D_0600FD34, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600FEF0, &D_0600FD34, NULL, NULL, 0); if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && gSaveContext.day >= 2) { this->actor.draw = NULL; } else { @@ -1691,7 +1691,7 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx) { EnTrt_UpdateHeadYawAndPitch(this, globalCtx); this->actionFunc(this, globalCtx); Actor_SetHeight(&this->actor, 90.0f); - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); EnTrt_UpdateCollider(this, globalCtx); } @@ -1716,8 +1716,8 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Vec3s newRot; MtxF currentState; - SysMatrix_MultiplyVector3fByState(&D_801D15B0tmp, &newPos); - SysMatrix_CopyCurrentState(¤tState); + Matrix_MultiplyVector3fByState(&D_801D15B0tmp, &newPos); + Matrix_CopyCurrentState(¤tState); func_8018219C(¤tState, &newRot, MTXMODE_NEW); *pos = newPos; if (isFullyAwake) { @@ -1759,11 +1759,11 @@ void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 21) { EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); - SysMatrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); } } @@ -1771,11 +1771,11 @@ void EnTrt_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTrt* this = THIS; if (limbIndex == 21) { - SysMatrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); } } @@ -1789,7 +1789,7 @@ void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIdx])); - func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt_OverrideLimbDraw, EnTrt_PostLimbDraw, EnTrt_UnkActorDraw, &this->actor); EnTrt_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnTrt_DrawStickDirectionPrompt(globalCtx, this); diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index dc8ea9ad1..8dd30eec2 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -82,7 +82,7 @@ void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { this->actor.textId = 0; Matrix_RotateY(this->actor.shape.rot.y, 0); - SysMatrix_MultiplyVector3fByState(&D_80A664FC, &sp24); + Matrix_MultiplyVector3fByState(&D_80A664FC, &sp24); Math_Vec3f_Sum(&this->actor.world.pos, &sp24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.shape.rot); this->actionFunc = func_80A66278; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 24ca09489..c1f0b3351 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -100,8 +100,8 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; - SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); - SkelAnime_ChangeAnimDefaultRepeat(&this->skelAnime, &D_0600DE20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); + Animation_PlayLoop(&this->skelAnime, &D_0600DE20); this->unk_2F0 = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -255,10 +255,10 @@ void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 10)) { if (arg1 >= 8) { - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 0.0f, arg1 - 8, arg1 - 8, arg2, 0.0f); + Animation_Change(&this->skelAnime, sAnimations[arg1], 0.0f, arg1 - 8, arg1 - 8, arg2, 0.0f); } else { - SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, - SkelAnime_GetFrameCount(&sAnimations[arg1]->common), arg2, -5.0f); + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + arg2, -5.0f); } this->unk_2F0 = arg1; } @@ -754,7 +754,7 @@ void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { this->actor.speedXZ = 8.0f; } - if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 5.0f)) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_ZORA_WALK); } } @@ -1329,7 +1329,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); this->unk_2F2 &= ~0x40; - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2F0 != 0)) { + if (SkelAnime_Update(&this->skelAnime) && (this->unk_2F0 != 0)) { this->unk_2F2 |= 0x40; } @@ -1368,15 +1368,15 @@ s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 pad; if (limbIndex == 15) { - SysMatrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); - SysMatrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - SysMatrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); } if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && @@ -1392,7 +1392,7 @@ void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZot* this = THIS; if (limbIndex == 15) { - SysMatrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); } } @@ -1412,8 +1412,8 @@ void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk_2EC])); gSPSegment(POLY_OPA_DISP++, 0x0C, func_80B99580(globalCtx->state.gfxCtx)); - SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, - EnZot_OverrideLimbDraw, EnZot_PostLimbDraw, &this->actor); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZot_OverrideLimbDraw, EnZot_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 5c0aa5cb1..2111f1d0f 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -285,9 +285,9 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { if (actionFuncTemp) { s16 rotation = Math_SinS(this->unk_198) * 8000.0f; - SysMatrix_InsertZRotation_s(rotation, 1); + Matrix_InsertZRotation_s(rotation, 1); Matrix_Scale(1.3f, 1.0f, 1.0f, 1); - SysMatrix_InsertZRotation_s(rotation * -1, 1); + Matrix_InsertZRotation_s(rotation * -1, 1); Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, 1); } Matrix_RotateY(yaw, 1); diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index a0d90123f..de7f30fbd 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -223,13 +223,13 @@ void func_80A358FC(ObjBell* this, GlobalContext* globalCtx) { } void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { - SysMatrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateY(thisx->world.rot.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(thisx->world.rot.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(thisx->world.rot.x, MTXMODE_APPLY); Matrix_RotateY(-thisx->world.rot.y, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -241,7 +241,7 @@ void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { - SysMatrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -252,7 +252,7 @@ void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35BD4(Actor* thisx, GlobalContext* globalCtx) { - SysMatrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); @@ -300,9 +300,9 @@ void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80A35BD4(thisx, globalCtx); func_80A359B4(thisx, globalCtx); Math_Vec3s_ToVec3f(&sp30, &this->collider1.dim.modelSphere.center); - SysMatrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultiplyVector3fByState(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider1.dim.worldSphere.center, &sp24); Math_Vec3s_ToVec3f(&sp30, &this->collider2.dim.modelSphere.center); - SysMatrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultiplyVector3fByState(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp24); } diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index 4a74a3c80..f252efbd5 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -120,8 +120,7 @@ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx } void ObjEtcetera_StartSmallFlutterAnimation(ObjEtcetera* this) { - SkelAnime_ChangeAnim(&this->skelAnime, &D_040117A8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_040117A8.common), 2, - 0.0f); + Animation_Change(&this->skelAnime, &D_040117A8, 1.0f, 0.0f, Animation_GetLastFrame(&D_040117A8), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_PlaySmallFlutterAnimation; } @@ -132,8 +131,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower - SkelAnime_ChangeAnim(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_0400EB7C.common), 2, - 0.0f); + Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoIntenseOscillation; Actor_SetScale(&this->dyna.actor, 0.01f); @@ -182,7 +180,7 @@ void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* glo } else { this->burrowFlag &= ~1; } - if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (SkelAnime_Update(&this->skelAnime)) { this->dyna.actor.draw = ObjEtcetera_DrawIdle; this->actionFunc = ObjEtcetera_Idle; } @@ -201,7 +199,7 @@ void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCt } else { this->burrowFlag &= ~1; } - SkelAnime_FrameUpdateMatrix(&this->skelAnime); + SkelAnime_Update(&this->skelAnime); if (this->oscillationTimer > 0) { this->oscillationTimer--; } else { @@ -272,8 +270,8 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { break; case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: - SkelAnime_ChangeAnim(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&D_0400EB7C.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, + 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoIntenseOscillation; Actor_SetScale(&this->dyna.actor, 0.0f); @@ -317,5 +315,5 @@ void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; func_8012C5B0(globalCtx->state.gfxCtx); - SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, NULL, NULL, &this->dyna.actor); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index c6b2daf66..4237e0992 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -89,10 +89,10 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->elements); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - SysMatrix_SetStateRotationAndTranslation( - this->actor.world.pos.x, this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -384,13 +384,13 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - SysMatrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - SysMatrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000408); @@ -420,13 +420,13 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - SysMatrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - SysMatrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06000408); diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 3a803bc61..13379e5f0 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -156,7 +156,7 @@ void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06001C60)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000D78); - SysMatrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_06000C80); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 597d47033..fb7074693 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -310,7 +310,7 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->flameTexScroll * -OBJ_SYOKUDAI_SNUFF_DEFAULT) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - SysMatrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index f6b0da869..22bcddc57 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -56,7 +56,7 @@ extern CollisionHeader D_06000968; void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { MtxF* sysMatrix; - sysMatrix = SysMatrix_GetCurrentState(); + sysMatrix = Matrix_GetCurrentState(); sysMatrix->wx = panel->pos.x; sysMatrix->wy = panel->pos.y; sysMatrix->wz = panel->pos.z; @@ -85,7 +85,7 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global dustSpawnOffset.z = -10.0f; for (i = 0; i < 7; i++) { dustSpawnOffset.x = dustSpawnXOffsets[i]; - SysMatrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); + Matrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); dustSpawnPos.x += panel->pos.x; dustSpawnPos.y += panel->pos.y; dustSpawnPos.z += panel->pos.z; @@ -100,15 +100,15 @@ void ObjTokeiStep_InitSteps(ObjTokeiStep* this) { Vec3f panelOffset; s32 pad; - SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; panelOffset.y = 0.0f; for (i = 0; i < 7; i++) { panel = &this->panels[i]; panelOffset.z = i * -20.0f; - SysMatrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); panel->posChangeY = 0.0f; panel->numBounces = 0; } @@ -119,15 +119,15 @@ void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this) { ObjTokeiStepPanel* panel; Vec3f panelOffset; - SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; for (i = 0; i < 7; i++) { panel = &this->panels[i]; panelOffset.y = panelXOffsets[i]; panelOffset.z = i * -20.0f; - SysMatrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); } } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 8d9511df8..496259853 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -170,21 +170,21 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - SysMatrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - SysMatrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); - SysMatrix_InsertTranslation(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, MTXMODE_APPLY); - SysMatrix_StatePush(); + Matrix_StatePush(); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, this->dyna.actor.home.rot.x); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - SysMatrix_InsertZRotation_f((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_InsertZRotation_f((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_04023210); - SysMatrix_StatePop(); - SysMatrix_InsertZRotation_f((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_StatePop(); + Matrix_InsertZRotation_f((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, D_04023210); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h index 1d199eee6..09298249d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h @@ -11,8 +11,8 @@ typedef struct { /* 0x26 */ s16 scaleStep; /* 0x28 */ s16 alpha; /* 0x2A */ s16 fadeDelay; - /* 0x2C */ s16 life; - /* 0x30 */ s32 unk_30; + /* 0x2C */ s16 unk_2C; + /* 0x30 */ s32 life; } EffectSsDFireInitParams; // size = 0x34 extern const EffectSsInit Effect_Ss_D_Fire_InitVars; diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index d4c729d56..9069a6aca 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -226,7 +226,7 @@ void Daytelop_Init(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; Game_SetFramerateDivisor(thisx, 1); - SysMatrix_StateAlloc(thisx); + Matrix_StateAlloc(thisx); ShrinkWindow_Destroy(); View_Init(&this->view, thisx->gfxCtx); thisx->main = Daytelop_Main; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index f3279db4e..96fe615fc 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -50,7 +50,7 @@ void Opening_Init(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; Game_SetFramerateDivisor(&this->gameState, 1); - SysMatrix_StateAlloc(&this->gameState); + Matrix_StateAlloc(&this->gameState); ShrinkWindow_Init(); View_Init(&this->view, this->gameState.gfxCtx); this->gameState.main = Opening_Main; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index c8027fcbe..ed732fc3d 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -80,9 +80,9 @@ void Title_Draw(GameState* thisx) { Title_RenderView(this, 0.0f, 150.0f, 300.0f); func_8012C28C(this->gameState.gfxCtx); - SysMatrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); + Matrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - SysMatrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); @@ -158,7 +158,7 @@ void Title_Init(GameState* thisx) { DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); Game_SetFramerateDivisor(thisx, 1); - SysMatrix_StateAlloc(thisx); + Matrix_StateAlloc(thisx); ShrinkWindow_Init(); View_Init(&this->view, thisx->gfxCtx); diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 238c7f9c0..4086528ef 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -7,10 +7,41 @@ animdict ={ "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", - "Matrix_Pop": "SysMatrix_StatePop", - "Matrix_Push": "SysMatrix_StatePush", - "Matrix_Init": "SysMatrix_StateAlloc", - "Matrix_Put": "SysMatrix_SetCurrentState", + "SysMatrix_StateAlloc": "Matrix_StateAlloc", + "SysMatrix_StatePush": "Matrix_StatePush", + "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", + "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", + "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", + "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", + "SysMatrix_Scale": "Matrix_Scale", + "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", + "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", + "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", + "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", + "SysMatrix_RotateY": "Matrix_RotateY", + "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", + "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", + "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", + "SysMatrix_InsertRotation": "Matrix_InsertRotation", + "SysMatrix_JointPosition": "Matrix_JointPosition", + "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", + "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", + "SysMatrix_ToMtx": "Matrix_ToMtx", + "SysMatrix_NewMtx": "Matrix_NewMtx", + "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", + "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", + "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", + "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", + "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", + "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", + "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", + "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", + "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", + "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", + "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", + "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", + "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", + "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", @@ -23,6 +54,90 @@ animdict ={ "ShrinkWindow_Step": "ShrinkWindow_Update", "ShrinkWindow_Fini": "ShrinkWindow_Destroy", "func_801A89A8": "Audio_QueueSeqCmd", + "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", + "SkelAnime_LodDraw": "SkelAnime_DrawLod", + "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", + "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", + "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", + "SkelAnime_Draw": "SkelAnime_DrawOpa", + "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", + "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", + "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", + "SkelAnime_GetTotalFrames": "Animation_GetLength", + "SkelAnime_GetFrameCount": "Animation_GetLastFrame", + "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", + "SkelAnime_Draw2": "SkelAnime_Draw", + "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", + "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", + "func_80134FFC": "SkelAnime_GetFrameData2", + "func_801353D4": "Animation_GetLimbCount2", + "SkelAnime_GetTotalFrames2": "Animation_GetLength2", + "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", + "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", + "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", + "func_801358D4": "AnimationContext_SetNextQueue", + "func_801358F4": "AnimationContext_DisableQueue", + "SkelAnime_NextEntry": "AnimationContext_AddEntry", + "SkelAnime_LoadLinkAnimetion": "AnimationContext_SetLoadFrame", + "SkelAnime_LoadAnimationType1": "AnimationContext_SetCopyAll", + "SkelAnime_LoadAnimationType2": "AnimationContext_SetInterp", + "SkelAnime_LoadAnimationType3": "AnimationContext_SetCopyTrue", + "SkelAnime_LoadAnimationType4": "AnimationContext_SetCopyFalse", + "SkelAnime_LoadAnimationType5": "AnimationContext_SetMoveActor", + "SkelAnime_LinkAnimetionLoaded": "AnimationContext_LoadFrame", + "SkelAnime_AnimationType1Loaded": "AnimationContext_CopyAll", + "SkelAnime_AnimationType2Loaded": "AnimationContext_CopyInterp", + "SkelAnime_AnimationType3Loaded": "AnimationContext_CopyTrue", + "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", + "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", + "func_80135EE8": "AnimationContext_Update", + "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", + "func_801360A8": "LinkAnimation_SetUpdateFunction", + "func_801360E0": "LinkAnimation_Update", + "func_80136104": "LinkAnimation_Morph", + "func_801361BC": "LinkAnimation_AnimateFrame", + "func_80136288": "LinkAnimation_Loop", + "func_8013631C": "LinkAnimation_Once", + "SkelAnime_SetTransition": "Animation_SetMorph", + "SkelAnime_ChangeLinkAnim": "LinkAnimation_Change", + "SkelAnime_ChangeLinkAnimDefaultStop": "LinkAnimation_PlayOnce", + "SkelAnime_ChangeLinkAnimPlaybackStop": "LinkAnimation_PlayOnceSetSpeed", + "SkelAnime_ChangeLinkAnimDefaultRepeat": "LinkAnimation_PlayLoop", + "SkelAnime_ChangeLinkAnimPlaybackRepeat": "LinkAnimation_PlayLoopSetSpeed", + "func_8013670C": "LinkAnimation_CopyJointToMorph", + "func_8013673C": "LinkAnimation_CopyMorphToJoint", + "func_8013676C": "LinkAnimation_LoadToMorph", + "func_801367B0": "LinkAnimation_LoadToJoint", + "func_801367F4": "LinkAnimation_InterpJointMorph", + "func_8013682C": "LinkAnimation_BlendToJoint", + "func_801368CC": "LinkAnimation_BlendToMorph", + "SkelAnime_SetModeStop": "LinkAnimation_EndLoop", + "func_80136990": "Animation_OnFrameImpl", + "func_80136A48": "LinkAnimation_OnFrame", + "SkelAnime_InitSV": "SkelAnime_InitFlex", + "func_80136C84": "SkelAnime_SetUpdate", + "SkelAnime_FrameUpdateMatrix": "SkelAnime_Update", + "func_80136CF4": "SkelAnime_Morph", + "func_80136D98": "SkelAnime_MorphTaper", + "func_80136F04": "SkelAnime_AnimateFrame", + "func_8013702C": "SkelAnime_LoopFull", + "func_801370B0": "SkelAnime_LoopPartial", + "func_8013713C": "SkelAnime_Once", + "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", + "SkelAnime_ChangeAnim": "Animation_Change", + "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", + "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", + "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", + "SkelAnime_ChangeAnimDefaultRepeat": "Animation_PlayLoop", + "SkelAnime_ChangeAnimTransitionRepeat": "Animation_MorphToLoop", + "SkelAnime_ChangeAnimPlaybackRepeat": "Animation_PlayLoopSetSpeed", + "SkelAnime_AnimSetStop": "Animation_EndLoop", + "SkelAnime_AnimReverse": "Animation_Reverse", + "func_80137674": "SkelAnime_CopyFrameTableTrue", + "func_801376DC": "SkelAnime_CopyFrameTableFalse", + "func_80137748": "SkelAnime_UpdateTranslation", + "func_801378B8": "Animation_OnFrame", + "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", } def replace_anim(file): diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index a71ca3f09..ed8637398 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -381,7 +381,7 @@ 0x800F1250 : "z_face_reaction", 0x800F12D0 : "code_800F12D0", 0x800F1460 : "z_eventmgr", - 0x800F23E0 : "code_800F23E0", + 0x800F23E0 : "z_fcurve_data", 0x800F2620 : "z_fcurve_data_skelanime", 0x800F2D30 : "z_fireobj", 0x800F3940 : "z_horse", @@ -403,7 +403,7 @@ 0x8010CB70 : "[PADDING]", 0x8010CB80 : "z_parameter", 0x801224E0 : "z_path", - 0x80122660 : "code_80122660", + 0x80122660 : "z_pause", 0x801226E0 : "z_player_lib", 0x80129EF0 : "z_prenmi", 0x8012A080 : "z_quake", @@ -594,7 +594,7 @@ 0x801DD770 : "z_draw", 0x801DD780 : "z_eff_footmark", 0x801DD790 : "z_eventmgr", - 0x801DD7B0 : "code_800F23E0", + 0x801DD7B0 : "z_fcurve_data", 0x801DD7C0 : "z_fcurve_data_skelanime", 0x801DD7D0 : "z_fireobj", 0x801DD7E0 : "z_horse", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8cf4a77b5..0bfa78b1d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -114,7 +114,7 @@ 0x80084CD0:("Load_AllocateAndLoad",), 0x80084DB0:("Load2_Relocate",), 0x8008501C:("Load2_LoadOverlay",), - 0x800850C8:("Load2_AllocateAndLoad",), + 0x800850C8:("Overlay_AllocateAndLoad",), 0x80085130:("PadUtils_Init",), 0x80085150:("func_80085150",), 0x80085158:("PadUtils_ResetPressRel",), @@ -331,7 +331,7 @@ 0x8008C1E0:("__osPiGetAccess",), 0x8008C224:("__osPiRelAccess",), 0x8008C260:("__osDevMgrMain",), - 0x8008C670:("osPiRawStartDma",), + 0x8008C670:("__osPiRawStartDma",), 0x8008C740:("__osSumcalc",), 0x8008C7B4:("__osIdCheckSum",), 0x8008C8B0:("__osRepairPackId",), @@ -374,11 +374,11 @@ 0x8008FAB0:("osJamMesg",), 0x8008FC00:("osSetThreadPri",), 0x8008FCE0:("osGetThreadPri",), - 0x8008FD00:("osEPiRawReadIo",), + 0x8008FD00:("__osEPiRawReadIo",), 0x8008FE60:("osViSwapBuffer",), 0x8008FEB0:("guPositionF",), 0x80090058:("guPosition",), - 0x800900C0:("osEPiRawStartDma",), + 0x800900C0:("__osEPiRawStartDma",), 0x800902A0:("osSpTaskYielded",), 0x80090300:("bcmp",), 0x80090420:("osGetTime",), @@ -654,8 +654,8 @@ 0x800B326C:("EffectSsIceBlock_Spawn",), 0x800B32D0:("FlagSet_Update",), 0x800B3644:("FlagSet_Draw",), - 0x800B3880:("DLF_LoadGameState",), - 0x800B39A4:("DLF_FreeGameState",), + 0x800B3880:("Overlay_LoadGameState",), + 0x800B39A4:("Overlay_FreeGameState",), 0x800B3AD0:("Actor_PrintLists",), 0x800B3BA4:("ActorShape_Init",), 0x800B3BC8:("ActorShadow_Draw",), @@ -1663,13 +1663,13 @@ 0x800F23C4:("ActorCutscene_SetReturnCamera",), 0x800F23E0:("func_800F23E0",), 0x800F2478:("func_800F2478",), - 0x800F2620:("func_800F2620",), - 0x800F2650:("func_800F2650",), - 0x800F26C0:("func_800F26C0",), - 0x800F26F0:("func_800F26F0",), - 0x800F2728:("func_800F2728",), - 0x800F29A0:("func_800F29A0",), - 0x800F2CD8:("func_800F2CD8",), + 0x800F2620:("SkelCurve_Clear",), + 0x800F2650:("SkelCurve_Init",), + 0x800F26C0:("SkelCurve_Destroy",), + 0x800F26F0:("SkelCurve_SetAnim",), + 0x800F2728:("SkelCurve_Update",), + 0x800F29A0:("SkelCurve_DrawLimb",), + 0x800F2CD8:("SkelCurve_Draw",), 0x800F2D30:("FireObj_InitWithParams",), 0x800F2E48:("FireObj_SetState",), 0x800F2EAC:("FireObj_SetPosition",), @@ -1891,16 +1891,16 @@ 0x80102834:("Lights_New",), 0x80102880:("Lights_GlowCheck",), 0x80102A64:("Lights_DrawGlow",), - 0x80102C60:("zelda_malloc",), - 0x80102C88:("zelda_mallocR",), - 0x80102CB0:("zelda_realloc",), - 0x80102CE0:("zelda_free",), - 0x80102D08:("zelda_calloc",), - 0x80102D60:("MainHeap_AnalyzeArena",), - 0x80102D98:("MainHeap_Check",), - 0x80102DBC:("MainHeap_Init",), - 0x80102DEC:("MainHeap_Cleanup",), - 0x80102E10:("MainHeap_IsInitialized",), + 0x80102C60:("ZeldaArena_Malloc",), + 0x80102C88:("ZeldaArena_MallocR",), + 0x80102CB0:("ZeldaArena_Realloc",), + 0x80102CE0:("ZeldaArena_Free",), + 0x80102D08:("ZeldaArena_Calloc",), + 0x80102D60:("ZeldaArena_GetSizes",), + 0x80102D98:("ZeldaArena_Check",), + 0x80102DBC:("ZeldaArena_Init",), + 0x80102DEC:("ZeldaArena_Cleanup",), + 0x80102E10:("ZeldaArena_IsInitialized",), 0x80102E40:("func_80102E40",), 0x80102E90:("func_80102E90",), 0x80102EA4:("func_80102EA4",), @@ -2519,95 +2519,95 @@ 0x80132FDC:("func_80132FDC",), 0x80133000:("func_80133000",), 0x80133038:("func_80133038",), - 0x801330E0:("SkelAnime_LodDrawLimb",), - 0x801332F0:("SkelAnime_LodDraw",), - 0x801334A0:("SkelAnime_LodDrawLimbSV",), - 0x80133710:("SkelAnime_LodDrawSV",), - 0x80133948:("SkelAnime_DrawLimb",), - 0x80133B3C:("SkelAnime_Draw",), - 0x80133CDC:("SkelAnime_DrawLimbSV",), - 0x80133F28:("SkelAnime_DrawSV",), + 0x801330E0:("SkelAnime_DrawLimbLod",), + 0x801332F0:("SkelAnime_DrawLod",), + 0x801334A0:("SkelAnime_DrawFlexLimbLod",), + 0x80133710:("SkelAnime_DrawFlexLod",), + 0x80133948:("SkelAnime_DrawLimbOpa",), + 0x80133B3C:("SkelAnime_DrawOpa",), + 0x80133CDC:("SkelAnime_DrawFlexLimbOpa",), + 0x80133F28:("SkelAnime_DrawFlexOpa",), 0x80134148:("func_80134148",), 0x801343C0:("func_801343C0",), - 0x80134600:("SkelAnime_AnimateFrame",), - 0x80134724:("SkelAnime_GetTotalFrames",), - 0x80134748:("SkelAnime_GetFrameCount",), - 0x80134774:("SkelAnime_Draw2Limb",), - 0x80134990:("SkelAnime_Draw2",), - 0x80134B54:("SkelAnime_DrawLimbSV2",), - 0x80134DBC:("SkelAnime_DrawSV2",), - 0x80134FFC:("func_80134FFC",), - 0x801353D4:("func_801353D4",), - 0x801353F8:("SkelAnime_GetTotalFrames2",), - 0x8013541C:("SkelAnime_GetFrameCount2",), - 0x80135448:("SkelAnime_InterpolateVec3s",), - 0x801358C8:("SkelAnime_AnimationCtxReset",), - 0x801358D4:("func_801358D4",), - 0x801358F4:("func_801358F4",), - 0x8013591C:("SkelAnime_NextEntry",), - 0x80135954:("SkelAnime_LoadLinkAnimetion",), - 0x80135A28:("SkelAnime_LoadAnimationType1",), - 0x80135A90:("SkelAnime_LoadAnimationType2",), - 0x80135B00:("SkelAnime_LoadAnimationType3",), - 0x80135B70:("SkelAnime_LoadAnimationType4",), - 0x80135BE0:("SkelAnime_LoadAnimationType5",), - 0x80135C3C:("SkelAnime_LinkAnimetionLoaded",), - 0x80135C6C:("SkelAnime_AnimationType1Loaded",), - 0x80135CDC:("SkelAnime_AnimationType2Loaded",), - 0x80135D38:("SkelAnime_AnimationType3Loaded",), - 0x80135DB8:("SkelAnime_AnimationType4Loaded",), - 0x80135E3C:("SkelAnime_AnimationType5Loaded",), - 0x80135EE8:("func_80135EE8",), - 0x80135F88:("SkelAnime_InitLinkAnimetion",), - 0x801360A8:("func_801360A8",), - 0x801360E0:("func_801360E0",), - 0x80136104:("func_80136104",), - 0x801361BC:("func_801361BC",), - 0x80136288:("func_80136288",), - 0x8013631C:("func_8013631C",), - 0x801363F0:("SkelAnime_SetTransition",), - 0x80136414:("SkelAnime_ChangeLinkAnim",), - 0x8013658C:("SkelAnime_ChangeLinkAnimDefaultStop",), - 0x801365EC:("SkelAnime_ChangeLinkAnimPlaybackStop",), - 0x80136650:("SkelAnime_ChangeLinkAnimDefaultRepeat",), - 0x801366AC:("SkelAnime_ChangeLinkAnimPlaybackRepeat",), - 0x8013670C:("func_8013670C",), - 0x8013673C:("func_8013673C",), - 0x8013676C:("func_8013676C",), - 0x801367B0:("func_801367B0",), - 0x801367F4:("func_801367F4",), - 0x8013682C:("func_8013682C",), - 0x801368CC:("func_801368CC",), - 0x8013696C:("SkelAnime_SetModeStop",), - 0x80136990:("func_80136990",), - 0x80136A48:("func_80136A48",), + 0x80134600:("SkelAnime_GetFrameData",), + 0x80134724:("Animation_GetLength",), + 0x80134748:("Animation_GetLastFrame",), + 0x80134774:("SkelAnime_DrawLimb",), + 0x80134990:("SkelAnime_Draw",), + 0x80134B54:("SkelAnime_DrawFlexLimb",), + 0x80134DBC:("SkelAnime_DrawFlex",), + 0x80134FFC:("SkelAnime_GetFrameData2",), + 0x801353D4:("Animation_GetLimbCount2",), + 0x801353F8:("Animation_GetLength2",), + 0x8013541C:("Animation_GetLastFrame2",), + 0x80135448:("SkelAnime_InterpFrameTable",), + 0x801358C8:("AnimationContext_Reset",), + 0x801358D4:("AnimationContext_SetNextQueue",), + 0x801358F4:("AnimationContext_DisableQueue",), + 0x8013591C:("AnimationContext_AddEntry",), + 0x80135954:("AnimationContext_SetLoadFrame",), + 0x80135A28:("AnimationContext_SetCopyAll",), + 0x80135A90:("AnimationContext_SetInterp",), + 0x80135B00:("AnimationContext_SetCopyTrue",), + 0x80135B70:("AnimationContext_SetCopyFalse",), + 0x80135BE0:("AnimationContext_SetMoveActor",), + 0x80135C3C:("AnimationContext_LoadFrame",), + 0x80135C6C:("AnimationContext_CopyAll",), + 0x80135CDC:("AnimationContext_Interp",), + 0x80135D38:("AnimationContext_CopyTrue",), + 0x80135DB8:("AnimationContext_CopyFalse",), + 0x80135E3C:("AnimationContext_MoveActor",), + 0x80135EE8:("AnimationContext_Update",), + 0x80135F88:("SkelAnime_InitLink",), + 0x801360A8:("LinkAnimation_SetUpdateFunction",), + 0x801360E0:("LinkAnimation_Update",), + 0x80136104:("LinkAnimation_Morph",), + 0x801361BC:("LinkAnimation_AnimateFrame",), + 0x80136288:("LinkAnimation_Loop",), + 0x8013631C:("LinkAnimation_Once",), + 0x801363F0:("Animation_SetMorph",), + 0x80136414:("LinkAnimation_Change",), + 0x8013658C:("LinkAnimation_PlayOnce",), + 0x801365EC:("LinkAnimation_PlayOnceSetSpeed",), + 0x80136650:("LinkAnimation_PlayLoop",), + 0x801366AC:("LinkAnimation_PlayLoopSetSpeed",), + 0x8013670C:("LinkAnimation_CopyJointToMorph",), + 0x8013673C:("LinkAnimation_CopyMorphToJoint",), + 0x8013676C:("LinkAnimation_LoadToMorph",), + 0x801367B0:("LinkAnimation_LoadToJoint",), + 0x801367F4:("LinkAnimation_InterpJointMorph",), + 0x8013682C:("LinkAnimation_BlendToJoint",), + 0x801368CC:("LinkAnimation_BlendToMorph",), + 0x8013696C:("LinkAnimation_EndLoop",), + 0x80136990:("Animation_OnFrameImpl",), + 0x80136A48:("LinkAnimation_OnFrame",), 0x80136A7C:("SkelAnime_Init",), - 0x80136B30:("SkelAnime_InitSV",), + 0x80136B30:("SkelAnime_InitFlex",), 0x80136BEC:("SkelAnime_InitSkin",), - 0x80136C84:("func_80136C84",), - 0x80136CD0:("SkelAnime_FrameUpdateMatrix",), - 0x80136CF4:("func_80136CF4",), - 0x80136D98:("func_80136D98",), - 0x80136F04:("func_80136F04",), - 0x8013702C:("func_8013702C",), - 0x801370B0:("func_801370B0",), - 0x8013713C:("func_8013713C",), - 0x8013722C:("SkelAnime_ChangeAnimImpl",), - 0x801373E8:("SkelAnime_ChangeAnim",), - 0x80137430:("SkelAnime_ChangeAnimDefaultStop",), - 0x80137488:("SkelAnime_ChangeAnimTransitionStop",), - 0x801374E4:("SkelAnime_ChangeAnimPlaybackStop",), - 0x80137540:("SkelAnime_ChangeAnimDefaultRepeat",), - 0x80137594:("SkelAnime_ChangeAnimTransitionRepeat",), - 0x801375CC:("SkelAnime_ChangeAnimPlaybackRepeat",), - 0x80137624:("SkelAnime_AnimSetStop",), - 0x80137650:("SkelAnime_AnimReverse",), - 0x80137674:("func_80137674",), - 0x801376DC:("func_801376DC",), - 0x80137748:("func_80137748",), - 0x801378B8:("func_801378B8",), + 0x80136C84:("SkelAnime_SetUpdate",), + 0x80136CD0:("SkelAnime_Update",), + 0x80136CF4:("SkelAnime_Morph",), + 0x80136D98:("SkelAnime_MorphTaper",), + 0x80136F04:("SkelAnime_AnimateFrame",), + 0x8013702C:("SkelAnime_LoopFull",), + 0x801370B0:("SkelAnime_LoopPartial",), + 0x8013713C:("SkelAnime_Once",), + 0x8013722C:("Animation_ChangeImpl",), + 0x801373E8:("Animation_Change",), + 0x80137430:("Animation_PlayOnce",), + 0x80137488:("Animation_MorphToPlayOnce",), + 0x801374E4:("Animation_PlayOnceSetSpeed",), + 0x80137540:("Animation_PlayLoop",), + 0x80137594:("Animation_MorphToLoop",), + 0x801375CC:("Animation_PlayLoopSetSpeed",), + 0x80137624:("Animation_EndLoop",), + 0x80137650:("Animation_Reverse",), + 0x80137674:("SkelAnime_CopyFrameTableTrue",), + 0x801376DC:("SkelAnime_CopyFrameTableFalse",), + 0x80137748:("SkelAnime_UpdateTranslation",), + 0x801378B8:("Animation_OnFrame",), 0x801378E0:("SkelAnime_Free",), - 0x8013792C:("SkelAnime_CopyVec3s",), + 0x8013792C:("SkelAnime_CopyFrameTable",), 0x80137970:("func_80137970",), 0x80137B34:("func_80137B34",), 0x80137EBC:("func_80137EBC",), @@ -3125,25 +3125,25 @@ 0x801733DC:("GameState_SetFBFilter",), 0x80173534:("Game_Nop80173534",), 0x80173540:("GameState_Draw",), - 0x80173644:("Game_ResetSegments",), + 0x80173644:("GameState_SetFrameBuffer",), 0x801736DC:("func_801736DC",), 0x80173754:("Game_UpdateInput",), 0x8017377C:("Game_Update",), 0x801737E4:("Game_IncrementFrameCount",), - 0x80173810:("Game_InitHeap",), - 0x80173880:("Game_ResizeHeap",), - 0x80173950:("Game_StateInit",), - 0x80173A50:("Game_StateFini",), - 0x80173B00:("Game_GetNextStateInit",), + 0x80173810:("GameState_InitArena",), + 0x80173880:("GameState_Realloc",), + 0x80173950:("GameState_Init",), + 0x80173A50:("GameState_Destroy",), + 0x80173B00:("GameState_GetNextStateInit",), 0x80173B0C:("Game_GetNextStateSize",), - 0x80173B18:("Game_GetShouldContinue",), - 0x80173B24:("Game_GetHeapFreeSize",), + 0x80173B18:("GameState_IsRunning",), + 0x80173B24:("GameState_GetArenaSize",), 0x80173B48:("func_80173B48",), - 0x80173BF0:("func_80173BF0",), - 0x80173C10:("Gamealloc_Alloc",), - 0x80173C7C:("Gamealloc_Free",), - 0x80173CC8:("Gamealloc_FreeAll",), - 0x80173D18:("Gamealloc_Init",), + 0x80173BF0:("GameAlloc_Log",), + 0x80173C10:("GameAlloc_Malloc",), + 0x80173C7C:("GameAlloc_Free",), + 0x80173CC8:("GameAlloc_Cleanup",), + 0x80173D18:("GameAlloc_Init",), 0x80173D30:("Graph_FaultClient",), 0x80173DAC:("Graph_DlAlloc",), 0x80173DCC:("Graph_InitTHGA",), @@ -3159,10 +3159,10 @@ 0x80174A40:("Graph_GfxPlusOne",), 0x80174A4C:("Graph_BranchDlist",), 0x80174A64:("Graph_DlistAlloc",), - 0x80174AA0:("func_80174AA0",), - 0x80174AB4:("func_80174AB4",), - 0x80174B20:("func_80174B20",), - 0x80174BA0:("func_80174BA0",), + 0x80174AA0:("ListAlloc_Init",), + 0x80174AB4:("ListAlloc_Alloc",), + 0x80174B20:("ListAlloc_Free",), + 0x80174BA0:("ListAlloc_FreeAll",), 0x80174BF0:("Main",), 0x80174F10:("Padmgr_GetControllerBitmask",), 0x80174F24:("func_80174F24",), @@ -3191,7 +3191,7 @@ 0x80175F98:("Padmgr_GetInput",), 0x80175FD4:("Padmgr_GetInput2",), 0x80176010:("Padmgr_ThreadEntry",), - 0x80176194:("Padmgr_Start",), + 0x80176194:("PadMgr_Init",), 0x80176280:("Sched_SwapFramebuffer",), 0x80176314:("Sched_RetraceUpdateFramebuffer",), 0x80176364:("Sched_HandleReset",), @@ -3354,45 +3354,45 @@ 0x801800CC:("Math_Atan2F",), 0x80180100:("Math_FAtan2F",), 0x8018012C:("Math_Acot2F",), - 0x80180160:("SysMatrix_StateAlloc",), - 0x8018019C:("SysMatrix_StatePush",), - 0x801801CC:("SysMatrix_StatePop",), - 0x801801E8:("SysMatrix_CopyCurrentState",), - 0x8018020C:("SysMatrix_SetCurrentState",), - 0x80180234:("SysMatrix_GetCurrentState",), - 0x80180244:("SysMatrix_InsertMatrix",), - 0x8018029C:("SysMatrix_InsertTranslation",), + 0x80180160:("Matrix_StateAlloc",), + 0x8018019C:("Matrix_StatePush",), + 0x801801CC:("Matrix_StatePop",), + 0x801801E8:("Matrix_CopyCurrentState",), + 0x8018020C:("Matrix_SetCurrentState",), + 0x80180234:("Matrix_GetCurrentState",), + 0x80180244:("Matrix_InsertMatrix",), + 0x8018029C:("Matrix_InsertTranslation",), 0x8018039C:("Matrix_Scale",), - 0x80180478:("SysMatrix_InsertXRotation_s",), - 0x80180610:("SysMatrix_InsertXRotation_f",), - 0x801807B8:("SysMatrix_RotateStateAroundXAxis",), - 0x80180900:("SysMatrix_SetStateXRotation",), + 0x80180478:("Matrix_InsertXRotation_s",), + 0x80180610:("Matrix_InsertXRotation_f",), + 0x801807B8:("Matrix_RotateStateAroundXAxis",), + 0x80180900:("Matrix_SetStateXRotation",), 0x801809AC:("Matrix_RotateY",), - 0x80180B48:("SysMatrix_InsertYRotation_f",), - 0x80180CF8:("SysMatrix_InsertZRotation_s",), - 0x80180E90:("SysMatrix_InsertZRotation_f",), - 0x8018103C:("SysMatrix_InsertRotation",), - 0x801812FC:("SysMatrix_RotateAndTranslateState",), - 0x80181650:("SysMatrix_SetStateRotationAndTranslation",), - 0x801817FC:("SysMatrix_ToRSPMatrix",), - 0x80181A18:("SysMatrix_GetStateAsRSPMatrix",), + 0x80180B48:("Matrix_InsertYRotation_f",), + 0x80180CF8:("Matrix_InsertZRotation_s",), + 0x80180E90:("Matrix_InsertZRotation_f",), + 0x8018103C:("Matrix_InsertRotation",), + 0x801812FC:("Matrix_JointPosition",), + 0x80181650:("Matrix_SetStateRotationAndTranslation",), + 0x801817FC:("Matrix_ToRSPMatrix",), + 0x80181A18:("Matrix_ToMtx",), 0x80181A40:("Matrix_NewMtx",), - 0x80181A6C:("SysMatrix_AppendToPolyOpaDisp",), - 0x80181A98:("SysMatrix_MultiplyVector3fByState",), - 0x80181B50:("SysMatrix_GetStateTranslation",), - 0x80181B78:("SysMatrix_GetStateTranslationAndScaledX",), - 0x80181BC4:("SysMatrix_GetStateTranslationAndScaledY",), - 0x80181C10:("SysMatrix_GetStateTranslationAndScaledZ",), - 0x80181C5C:("SysMatrix_MultiplyVector3fXZByCurrentState",), + 0x80181A6C:("Matrix_AppendToPolyOpaDisp",), + 0x80181A98:("Matrix_MultiplyVector3fByState",), + 0x80181B50:("Matrix_GetStateTranslation",), + 0x80181B78:("Matrix_GetStateTranslationAndScaledX",), + 0x80181BC4:("Matrix_GetStateTranslationAndScaledY",), + 0x80181C10:("Matrix_GetStateTranslationAndScaledZ",), + 0x80181C5C:("Matrix_MultiplyVector3fXZByCurrentState",), 0x80181CDC:("Matrix_MtxFCopy",), - 0x80181D64:("SysMatrix_FromRSPMatrix",), - 0x80181FB8:("SysMatrix_MultiplyVector3fByMatrix",), - 0x80182068:("SysMatrix_TransposeXYZ",), - 0x801820A0:("SysMatrix_NormalizeXYZ",), + 0x80181D64:("Matrix_FromRSPMatrix",), + 0x80181FB8:("Matrix_MultiplyVector3fByMatrix",), + 0x80182068:("Matrix_TransposeXYZ",), + 0x801820A0:("Matrix_NormalizeXYZ",), 0x8018219C:("func_8018219C",), 0x801822C4:("func_801822C4",), - 0x801823EC:("SysMatrix_InsertRotationAroundUnitVector_f",), - 0x8018284C:("SysMatrix_InsertRotationAroundUnitVector_s",), + 0x801823EC:("Matrix_InsertRotationAroundUnitVector_f",), + 0x8018284C:("Matrix_InsertRotationAroundUnitVector_s",), 0x80182C90:("func_80182C90",), 0x80182CA0:("func_80182CA0",), 0x80182CBC:("func_80182CBC",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d6ae0cfab..6cbe303ee 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -23,8 +23,8 @@ 0x80096B68:("sIrqMgrResetTime","volatile OSTime","",0x8), 0x80096B70:("sIrqMgrRetraceTime","volatile OSTime","",0x8), 0x80096B78:("sIrqMgrRetraceCount","s32","",0x4), - 0x80096B80:("D_80096B80","char*","[18]",0x48), - 0x80096BC8:("sExceptionNames","char*","[6]",0x18), + 0x80096B80:("sCpuExceptions","char*","[18]",0x48), + 0x80096BC8:("sFpuExceptions","char*","[6]",0x18), 0x80096BE0:("sFaultDrawContext","FaultDrawer*","",0x4), 0x80096BE4:("sFaultDrawerDefault","FaultDrawer","",0x3c), 0x80096C20:("D_80096C20","UNK_TYPE4","",0x4), @@ -61,8 +61,8 @@ 0x80097E90:("__osCurrentHandle","OSPiHandle*","[2]",0x8), 0x80097EA0:("__osPiAccessQueueEnabled","UNK_TYPE4","",0x4), 0x80097EB0:("osViModeNtscHpn1","OSViMode","",0x50), - 0x80097F00:("D_80097F00","UNK_TYPE4","",0x4), - 0x80097F04:("D_80097F04","UNK_TYPE1","",0x1), + 0x80097F00:("__osPfsInodeCacheChannel","s32","",0x4), + 0x80097F04:("__osPfsInodeCacheBank","u8","",0x1), 0x80097F10:("D_80097F10","UNK_TYPE4","",0x4), 0x80097F20:("spaces","char","[]",0x21), 0x80097F44:("zeroes","char","[]",0x24), @@ -326,7 +326,7 @@ 0x8009CD50:("sRandFloat","f32","",0x4), 0x8009CD60:("sArenaLockMsg","OSMesg","[1]",0x4), 0x8009CD70:("tmp_task","OSTask","",0x40), - 0x8009CDB0:("D_8009CDB0","UNK_TYPE1","",0x1), + 0x8009CDB0:("osPifBuffers","OSPifRam","[4]",0x100), 0x8009CEB0:("siAccessBuf","OSMesg","[1]",0x4), 0x8009CEB8:("__osSiAccessQueue","OSMesgQueue","",0x18), 0x8009CED0:("__osContPifRam","OSPifRam","",0x40), @@ -347,7 +347,7 @@ 0x8009E3E8:("D_8009E3E8","OSMesg","[1]",0x4), 0x8009E3F0:("D_8009E3F0","OSMesg","[1]",0x4), 0x8009E3F8:("__osPiAccessQueue","OSMesgQueue","",0x18), - 0x8009E410:("__osPfsInodeCache","_OSInode","",0x100), + 0x8009E410:("__osPfsInodeCache","__OSInode","",0x100), 0x8009E510:("__osEventStateTab","__OSEventState","[16]",0x80), 0x8009E590:("D_8009E590","OSTimer","",0x20), 0x8009E5B0:("__osCurrentTime","OSTime","",0x8), @@ -2256,8 +2256,8 @@ 0x801D1570:("D_801D1570","f32","[13]",0x34), 0x801D15B0:("D_801D15B0","Vec3f","",0xC), 0x801D15BC:("D_801D15BC","UNK_TYPE4","",0x4), - 0x801D15D0:("sATan2Tbl","u16","[1025]",0x802), - 0x801D1DE0:("D_801D1DE0","RSPMatrix","",0x40), + 0x801D15D0:("sATan2Tbl","s16","[1025]",0x802), + 0x801D1DE0:("D_801D1DE0","Mtx","",0x40), 0x801D1E20:("D_801D1E20","MtxF","",0x40), 0x801D1E60:("D_801D1E60","UNK_PTR","",0x4), 0x801D1E64:("D_801D1E64","UNK_PTR","",0x4), @@ -4011,16 +4011,15 @@ 0x801EE1E0:("D_801EE1E0","Vec3f","",0xc), 0x801EE1F0:("D_801EE1F0","Vec3f","",0xc), 0x801EE200:("D_801EE200","EffSparkParams","",0x4c4), - 0x801EE6C8:("D_801EE6C8","ColTriParams","",0x34), - 0x801EE700:("D_801EE700","ColTriParams","",0x34), + 0x801EE6C8:("D_801EE6C8","TriNorm","",0x34), + 0x801EE700:("D_801EE700","TriNorm","",0x34), 0x801EE738:("D_801EE738","EffSparkParams","",0x4c4), 0x801EEC00:("D_801EEC00","EffSparkParams","",0x4c4), 0x801EF0C8:("D_801EF0C8","EffSparkParams","",0x4c4), 0x801EF590:("D_801EF590","UNK_TYPE1","",0x1), 0x801EF5C8:("D_801EF5C8","UNK_TYPE1","",0x1), - 0x801EF600:("D_801EF600","ColTriParams","",0x34), - 0x801EF638:("D_801EF638","ColTriParams","",0x34), - 0x801EF66D:("D_801EF66D","UNK_TYPE1","",0x1), + 0x801EF600:("D_801EF600","TriNorm","",0x34), + 0x801EF638:("D_801EF638","TriNorm","",0x34), 0x801EF670:("gSaveContext","SaveContext","",0x48e8), 0x801F3F58:("D_801F3F58","UNK_TYPE1","",0x1), 0x801F3F5A:("D_801F3F5A","UNK_TYPE1","",0x1), @@ -4093,7 +4092,7 @@ 0x801F4F68:("D_801F4F68","UNK_TYPE1","",0x1), 0x801F4F6A:("D_801F4F6A","UNK_TYPE1","",0x1), 0x801F4F70:("sLightsBuffer","LightsBuffer","",0x188), - 0x801F5100:("mainHeap","Arena","",0x24), + 0x801F5100:("sZeldaArena","Arena","",0x24), 0x801F5130:("D_801F5130","UNK_TYPE1","",0x1), 0x801F5270:("D_801F5270","UNK_TYPE1","",0x1), 0x801F528E:("D_801F528E","UNK_TYPE1","",0x1), @@ -4122,8 +4121,8 @@ 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), - 0x801F5AB0:("D_801F5AB0","UNK_TYPE1","",0x1), - 0x801F5AB4:("D_801F5AB4","UNK_TYPE1","",0x1), + 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), + 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), 0x801F5AC0:("D_801F5AC0","UNK_TYPE1","",0x1), 0x801F69D0:("D_801F69D0","UNK_TYPE1","",0x1), 0x801F6A10:("D_801F6A10","UNK_TYPE1","",0x1), @@ -4186,19 +4185,19 @@ 0x801F80F0:("graphDlEntry","Gfx*","",0x4), 0x801F80F8:("D_801F80F8","UNK_TYPE1","",0x1), 0x801F8150:("lastRenderFrameTimestamp","u64","",0x8), - 0x801F8160:("siEventCallbackQueue","OSMesgQueue","",0x18), - 0x801F8178:("siEventCallbackBuffer","OSMesg","[1]",0x4), + 0x801F8160:("sSiIntMsgQ","OSMesgQueue","",0x18), + 0x801F8178:("sSiIntMsgBuf","OSMesg","[1]",0x4), 0x801F8180:("gSegments","u32","[16]",0x40), 0x801F81C0:("gSchedContext","SchedContext","",0x338), - 0x801F84F8:("mainIrqmgrCallbackNode","IrqMgrClient","",0x8), - 0x801F8500:("mainIrqmgrCallbackQueue","OSMesgQueue","",0x18), - 0x801F8518:("mainIrqCallbackBuffer","OSMesg","[60]",0xf0), - 0x801F8608:("graphOSThread","OSThread","",0x1b0), - 0x801F87B8:("graphStack","u8","[6144]",0x1800), + 0x801F84F8:("irqClient","IrqMgrClient","",0x8), + 0x801F8500:("irqMgrMsgQ","OSMesgQueue","",0x18), + 0x801F8518:("irqMgrMsgBuf","OSMesg","[60]",0xf0), + 0x801F8608:("sGraphThread","OSThread","",0x1b0), + 0x801F87B8:("sGraphStack","u8","[6144]",0x1800), 0x801F9FB8:("schedStack","u8","[1536]",0x600), 0x801FA5B8:("audioStack","u8","[2048]",0x800), 0x801FADB8:("padmgrStack","u8","[1280]",0x500), - 0x801FB2B8:("graphStackEntry","StackEntry","",0x1c), + 0x801FB2B8:("sGraphStackInfo","StackEntry","",0x1c), 0x801FB2D8:("schedStackEntry","StackEntry","",0x1c), 0x801FB2F8:("audioStackEntry","StackEntry","",0x1c), 0x801FB318:("padmgrStackEntry","StackEntry","",0x1c), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index d39d4c1ba..9d9b2d8b0 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -328,7 +328,7 @@ asm/non_matchings/boot/piacs/__osPiCreateAccessQueue.s,__osPiCreateAccessQueue,0 asm/non_matchings/boot/piacs/__osPiGetAccess.s,__osPiGetAccess,0x8008C1E0,0x11 asm/non_matchings/boot/piacs/__osPiRelAccess.s,__osPiRelAccess,0x8008C224,0xB asm/non_matchings/boot/devmgr/__osDevMgrMain.s,__osDevMgrMain,0x8008C260,0x104 -asm/non_matchings/boot/pirawdma/osPiRawStartDma.s,osPiRawStartDma,0x8008C670,0x34 +asm/non_matchings/boot/pirawdma/__osPiRawStartDma.s,__osPiRawStartDma,0x8008C670,0x34 asm/non_matchings/boot/contpfs/__osSumcalc.s,__osSumcalc,0x8008C740,0x1D asm/non_matchings/boot/contpfs/__osIdCheckSum.s,__osIdCheckSum,0x8008C7B4,0x3F asm/non_matchings/boot/contpfs/__osRepairPackId.s,__osRepairPackId,0x8008C8B0,0xD4 @@ -371,11 +371,11 @@ asm/non_matchings/boot/guMtxIdent/guMtxIdent.s,guMtxIdent,0x8008FA60,0x14 asm/non_matchings/boot/jammesg/osJamMesg.s,osJamMesg,0x8008FAB0,0x54 asm/non_matchings/boot/setthreadpri/osSetThreadPri.s,osSetThreadPri,0x8008FC00,0x38 asm/non_matchings/boot/getthreadpri/osGetThreadPri.s,osGetThreadPri,0x8008FCE0,0x8 -asm/non_matchings/boot/epirawread/osEPiRawReadIo.s,osEPiRawReadIo,0x8008FD00,0x58 +asm/non_matchings/boot/epirawread/__osEPiRawReadIo.s,__osEPiRawReadIo,0x8008FD00,0x58 asm/non_matchings/boot/viswapbuf/osViSwapBuffer.s,osViSwapBuffer,0x8008FE60,0x14 asm/non_matchings/boot/position/guPositionF.s,guPositionF,0x8008FEB0,0x6A asm/non_matchings/boot/position/guPosition.s,guPosition,0x80090058,0x1A -asm/non_matchings/boot/epirawdma/osEPiRawStartDma.s,osEPiRawStartDma,0x800900C0,0x78 +asm/non_matchings/boot/epirawdma/__osEPiRawStartDma.s,__osEPiRawStartDma,0x800900C0,0x78 asm/non_matchings/boot/sptaskyielded/osSpTaskYielded.s,osSpTaskYielded,0x800902A0,0x18 asm/non_matchings/boot/bcmp/bcmp.s,bcmp,0x80090300,0x48 asm/non_matchings/boot/gettime/osGetTime.s,osGetTime,0x80090420,0x24 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index d8ca54506..da6bc4acb 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1175,8 +1175,8 @@ asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentCamera.s,ActorCutscene asm/non_matchings/code/z_eventmgr/func_800F21CC.s,func_800F21CC,0x800F21CC,0x3E asm/non_matchings/code/z_eventmgr/func_800F22C4.s,func_800F22C4,0x800F22C4,0x40 asm/non_matchings/code/z_eventmgr/ActorCutscene_SetReturnCamera.s,ActorCutscene_SetReturnCamera,0x800F23C4,0x7 -asm/non_matchings/code/code_800F23E0/func_800F23E0.s,func_800F23E0,0x800F23E0,0x26 -asm/non_matchings/code/code_800F23E0/func_800F2478.s,func_800F2478,0x800F2478,0x6A +asm/non_matchings/code/z_fcurve_data/func_800F23E0.s,func_800F23E0,0x800F23E0,0x26 +asm/non_matchings/code/z_fcurve_data/func_800F2478.s,func_800F2478,0x800F2478,0x6A asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2620.s,func_800F2620,0x800F2620,0xC asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2650.s,func_800F2650,0x800F2650,0x1C asm/non_matchings/code/z_fcurve_data_skelanime/func_800F26C0.s,func_800F26C0,0x800F26C0,0xC @@ -1684,8 +1684,8 @@ asm/non_matchings/code/z_parameter/func_80121FC4.s,func_80121FC4,0x80121FC4,0x14 asm/non_matchings/code/z_path/func_801224E0.s,func_801224E0,0x801224E0,0x11 asm/non_matchings/code/z_path/func_80122524.s,func_80122524,0x80122524,0x2A asm/non_matchings/code/z_path/func_801225CC.s,func_801225CC,0x801225CC,0x25 -asm/non_matchings/code/code_80122660/func_80122660.s,func_80122660,0x80122660,0x4 -asm/non_matchings/code/code_80122660/func_80122670.s,func_80122670,0x80122670,0x1C +asm/non_matchings/code/z_pause/func_80122660.s,func_80122660,0x80122660,0x4 +asm/non_matchings/code/z_pause/func_80122670.s,func_80122670,0x80122670,0x1C asm/non_matchings/code/z_player_lib/func_801226E0.s,func_801226E0,0x801226E0,0x19 asm/non_matchings/code/z_player_lib/func_80122744.s,func_80122744,0x80122744,0x7 asm/non_matchings/code/z_player_lib/func_80122760.s,func_80122760,0x80122760,0x42 @@ -2040,16 +2040,16 @@ asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawSV.s,SkelAnime_LodDrawSV,0x8 asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimb.s,SkelAnime_DrawLimb,0x80133948,0x7D asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s,SkelAnime_Draw,0x80133B3C,0x68 asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV.s,SkelAnime_DrawLimbSV,0x80133CDC,0x93 -asm/non_matchings/code/z_skelanime/SkelAnime_DrawSV.s,SkelAnime_DrawSV,0x80133F28,0x88 +asm/non_matchings/code/z_skelanime/SkelAnime_DrawFlexOpa.s,SkelAnime_DrawFlexOpa,0x80133F28,0x88 asm/non_matchings/code/z_skelanime/func_80134148.s,func_80134148,0x80134148,0x9E asm/non_matchings/code/z_skelanime/func_801343C0.s,func_801343C0,0x801343C0,0x90 asm/non_matchings/code/z_skelanime/SkelAnime_AnimateFrame.s,SkelAnime_AnimateFrame,0x80134600,0x49 asm/non_matchings/code/z_skelanime/SkelAnime_GetTotalFrames.s,SkelAnime_GetTotalFrames,0x80134724,0x9 -asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameCount.s,SkelAnime_GetFrameCount,0x80134748,0xB +asm/non_matchings/code/z_skelanime/Animation_GetLastFrame.s,Animation_GetLastFrame,0x80134748,0xB asm/non_matchings/code/z_skelanime/SkelAnime_Draw2Limb.s,SkelAnime_Draw2Limb,0x80134774,0x87 -asm/non_matchings/code/z_skelanime/SkelAnime_Draw2.s,SkelAnime_Draw2,0x80134990,0x71 +asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s,SkelAnime_Draw,0x80134990,0x71 asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV2.s,SkelAnime_DrawLimbSV2,0x80134B54,0x9A -asm/non_matchings/code/z_skelanime/SkelAnime_DrawSV2.s,SkelAnime_DrawSV2,0x80134DBC,0x90 +asm/non_matchings/code/z_skelanime/SkelAnime_DrawFlex.s,SkelAnime_DrawFlex,0x80134DBC,0x90 asm/non_matchings/code/z_skelanime/func_80134FFC.s,func_80134FFC,0x80134FFC,0xF6 asm/non_matchings/code/z_skelanime/func_801353D4.s,func_801353D4,0x801353D4,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetTotalFrames2.s,SkelAnime_GetTotalFrames2,0x801353F8,0x9 @@ -2096,30 +2096,30 @@ asm/non_matchings/code/z_skelanime/SkelAnime_SetModeStop.s,SkelAnime_SetModeStop asm/non_matchings/code/z_skelanime/func_80136990.s,func_80136990,0x80136990,0x2E asm/non_matchings/code/z_skelanime/func_80136A48.s,func_80136A48,0x80136A48,0xD asm/non_matchings/code/z_skelanime/SkelAnime_Init.s,SkelAnime_Init,0x80136A7C,0x2D -asm/non_matchings/code/z_skelanime/SkelAnime_InitSV.s,SkelAnime_InitSV,0x80136B30,0x2F +asm/non_matchings/code/z_skelanime/SkelAnime_InitFlex.s,SkelAnime_InitFlex,0x80136B30,0x2F asm/non_matchings/code/z_skelanime/SkelAnime_InitSkin.s,SkelAnime_InitSkin,0x80136BEC,0x26 asm/non_matchings/code/z_skelanime/func_80136C84.s,func_80136C84,0x80136C84,0x13 -asm/non_matchings/code/z_skelanime/SkelAnime_FrameUpdateMatrix.s,SkelAnime_FrameUpdateMatrix,0x80136CD0,0x9 +asm/non_matchings/code/z_skelanime/SkelAnime_Update.s,SkelAnime_Update,0x80136CD0,0x9 asm/non_matchings/code/z_skelanime/func_80136CF4.s,func_80136CF4,0x80136CF4,0x29 asm/non_matchings/code/z_skelanime/func_80136D98.s,func_80136D98,0x80136D98,0x5B asm/non_matchings/code/z_skelanime/func_80136F04.s,func_80136F04,0x80136F04,0x4A asm/non_matchings/code/z_skelanime/func_8013702C.s,func_8013702C,0x8013702C,0x21 asm/non_matchings/code/z_skelanime/func_801370B0.s,func_801370B0,0x801370B0,0x23 asm/non_matchings/code/z_skelanime/func_8013713C.s,func_8013713C,0x8013713C,0x3C -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimImpl.s,SkelAnime_ChangeAnimImpl,0x8013722C,0x6F -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnim.s,SkelAnime_ChangeAnim,0x801373E8,0x12 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimDefaultStop.s,SkelAnime_ChangeAnimDefaultStop,0x80137430,0x16 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimTransitionStop.s,SkelAnime_ChangeAnimTransitionStop,0x80137488,0x17 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimPlaybackStop.s,SkelAnime_ChangeAnimPlaybackStop,0x801374E4,0x17 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimDefaultRepeat.s,SkelAnime_ChangeAnimDefaultRepeat,0x80137540,0x15 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimTransitionRepeat.s,SkelAnime_ChangeAnimTransitionRepeat,0x80137594,0xE -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimPlaybackRepeat.s,SkelAnime_ChangeAnimPlaybackRepeat,0x801375CC,0x16 +asm/non_matchings/code/z_skelanime/Animation_ChangeImpl.s,Animation_ChangeImpl,0x8013722C,0x6F +asm/non_matchings/code/z_skelanime/Animation_Change.s,Animation_Change,0x801373E8,0x12 +asm/non_matchings/code/z_skelanime/Animation_PlayOnce.s,Animation_PlayOnce,0x80137430,0x16 +asm/non_matchings/code/z_skelanime/Animation_MorphToPlayOnce.s,Animation_MorphToPlayOnce,0x80137488,0x17 +asm/non_matchings/code/z_skelanime/Animation_PlayOnceSetSpeed.s,Animation_PlayOnceSetSpeed,0x801374E4,0x17 +asm/non_matchings/code/z_skelanime/Animation_PlayLoop.s,Animation_PlayLoop,0x80137540,0x15 +asm/non_matchings/code/z_skelanime/Animation_MorphToLoop.s,Animation_MorphToLoop,0x80137594,0xE +asm/non_matchings/code/z_skelanime/Animation_ChangePlaybackRepeat.s,Animation_ChangePlaybackRepeat,0x801375CC,0x16 asm/non_matchings/code/z_skelanime/SkelAnime_AnimSetStop.s,SkelAnime_AnimSetStop,0x80137624,0xB asm/non_matchings/code/z_skelanime/SkelAnime_AnimReverse.s,SkelAnime_AnimReverse,0x80137650,0x9 asm/non_matchings/code/z_skelanime/func_80137674.s,func_80137674,0x80137674,0x1A asm/non_matchings/code/z_skelanime/func_801376DC.s,func_801376DC,0x801376DC,0x1B asm/non_matchings/code/z_skelanime/func_80137748.s,func_80137748,0x80137748,0x5C -asm/non_matchings/code/z_skelanime/func_801378B8.s,func_801378B8,0x801378B8,0xA +asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_CopyVec3s.s,SkelAnime_CopyVec3s,0x8013792C,0x11 asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 @@ -2705,7 +2705,7 @@ asm/non_matchings/code/padmgr/func_80175E68.s,func_80175E68,0x80175E68,0x4C asm/non_matchings/code/padmgr/Padmgr_GetInput.s,Padmgr_GetInput,0x80175F98,0xF asm/non_matchings/code/padmgr/Padmgr_GetInput2.s,Padmgr_GetInput2,0x80175FD4,0xF asm/non_matchings/code/padmgr/Padmgr_ThreadEntry.s,Padmgr_ThreadEntry,0x80176010,0x61 -asm/non_matchings/code/padmgr/Padmgr_Start.s,Padmgr_Start,0x80176194,0x3B +asm/non_matchings/code/padmgr/PadMgr_Init.s,PadMgr_Init,0x80176194,0x3B asm/non_matchings/code/sched/Sched_SwapFramebuffer.s,Sched_SwapFramebuffer,0x80176280,0x25 asm/non_matchings/code/sched/Sched_RetraceUpdateFramebuffer.s,Sched_RetraceUpdateFramebuffer,0x80176314,0x14 asm/non_matchings/code/sched/Sched_HandleReset.s,Sched_HandleReset,0x80176364,0x3 @@ -2868,45 +2868,45 @@ asm/non_matchings/code/sys_math_atan/Math_Atan2S.s,Math_Atan2S,0x8017FEE4,0x7A asm/non_matchings/code/sys_math_atan/Math_Atan2F.s,Math_Atan2F,0x801800CC,0xD asm/non_matchings/code/sys_math_atan/Math_FAtan2F.s,Math_FAtan2F,0x80180100,0xB asm/non_matchings/code/sys_math_atan/Math_Acot2F.s,Math_Acot2F,0x8018012C,0xD -asm/non_matchings/code/sys_matrix/SysMatrix_StateAlloc.s,SysMatrix_StateAlloc,0x80180160,0xF -asm/non_matchings/code/sys_matrix/SysMatrix_StatePush.s,SysMatrix_StatePush,0x8018019C,0xC -asm/non_matchings/code/sys_matrix/SysMatrix_StatePop.s,SysMatrix_StatePop,0x801801CC,0x7 -asm/non_matchings/code/sys_matrix/SysMatrix_CopyCurrentState.s,SysMatrix_CopyCurrentState,0x801801E8,0x9 -asm/non_matchings/code/sys_matrix/SysMatrix_SetCurrentState.s,SysMatrix_SetCurrentState,0x8018020C,0xA -asm/non_matchings/code/sys_matrix/SysMatrix_GetCurrentState.s,SysMatrix_GetCurrentState,0x80180234,0x4 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertMatrix.s,SysMatrix_InsertMatrix,0x80180244,0x16 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertTranslation.s,SysMatrix_InsertTranslation,0x8018029C,0x40 +asm/non_matchings/code/sys_matrix/Matrix_StateAlloc.s,Matrix_StateAlloc,0x80180160,0xF +asm/non_matchings/code/sys_matrix/Matrix_StatePush.s,Matrix_StatePush,0x8018019C,0xC +asm/non_matchings/code/sys_matrix/Matrix_StatePop.s,Matrix_StatePop,0x801801CC,0x7 +asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s,Matrix_CopyCurrentState,0x801801E8,0x9 +asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s,Matrix_SetCurrentState,0x8018020C,0xA +asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s,Matrix_GetCurrentState,0x80180234,0x4 +asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s,Matrix_InsertMatrix,0x80180244,0x16 +asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s,Matrix_InsertTranslation,0x8018029C,0x40 asm/non_matchings/code/sys_matrix/Matrix_Scale.s,Matrix_Scale,0x8018039C,0x37 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_s.s,SysMatrix_InsertXRotation_s,0x80180478,0x66 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_f.s,SysMatrix_InsertXRotation_f,0x80180610,0x6A -asm/non_matchings/code/sys_matrix/SysMatrix_RotateStateAroundXAxis.s,SysMatrix_RotateStateAroundXAxis,0x801807B8,0x52 -asm/non_matchings/code/sys_matrix/SysMatrix_SetStateXRotation.s,SysMatrix_SetStateXRotation,0x80180900,0x2B +asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s,Matrix_InsertXRotation_s,0x80180478,0x66 +asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s,Matrix_InsertXRotation_f,0x80180610,0x6A +asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s,Matrix_RotateStateAroundXAxis,0x801807B8,0x52 +asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s,Matrix_SetStateXRotation,0x80180900,0x2B asm/non_matchings/code/sys_matrix/Matrix_RotateY.s,Matrix_RotateY,0x801809AC,0x67 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertYRotation_f.s,SysMatrix_InsertYRotation_f,0x80180B48,0x6C -asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_s.s,SysMatrix_InsertZRotation_s,0x80180CF8,0x66 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_f.s,SysMatrix_InsertZRotation_f,0x80180E90,0x6B -asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotation.s,SysMatrix_InsertRotation,0x8018103C,0xB0 -asm/non_matchings/code/sys_matrix/SysMatrix_RotateAndTranslateState.s,SysMatrix_RotateAndTranslateState,0x801812FC,0xD5 -asm/non_matchings/code/sys_matrix/SysMatrix_SetStateRotationAndTranslation.s,SysMatrix_SetStateRotationAndTranslation,0x80181650,0x6B -asm/non_matchings/code/sys_matrix/SysMatrix_ToRSPMatrix.s,SysMatrix_ToRSPMatrix,0x801817FC,0x87 -asm/non_matchings/code/sys_matrix/SysMatrix_GetStateAsRSPMatrix.s,SysMatrix_GetStateAsRSPMatrix,0x80181A18,0xA +asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s,Matrix_InsertYRotation_f,0x80180B48,0x6C +asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s,Matrix_InsertZRotation_s,0x80180CF8,0x66 +asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s,Matrix_InsertZRotation_f,0x80180E90,0x6B +asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s,Matrix_InsertRotation,0x8018103C,0xB0 +asm/non_matchings/code/sys_matrix/Matrix_RotateAndTranslateState.s,Matrix_RotateAndTranslateState,0x801812FC,0xD5 +asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s,Matrix_SetStateRotationAndTranslation,0x80181650,0x6B +asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s,Matrix_ToRSPMatrix,0x801817FC,0x87 +asm/non_matchings/code/sys_matrix/Matrix_GetStateAsRSPMatrix.s,Matrix_GetStateAsRSPMatrix,0x80181A18,0xA asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s,Matrix_NewMtx,0x80181A40,0xB -asm/non_matchings/code/sys_matrix/SysMatrix_AppendToPolyOpaDisp.s,SysMatrix_AppendToPolyOpaDisp,0x80181A6C,0xB -asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByState.s,SysMatrix_MultiplyVector3fByState,0x80181A98,0x2E -asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslation.s,SysMatrix_GetStateTranslation,0x80181B50,0xA -asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledX.s,SysMatrix_GetStateTranslationAndScaledX,0x80181B78,0x13 -asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledY.s,SysMatrix_GetStateTranslationAndScaledY,0x80181BC4,0x13 -asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledZ.s,SysMatrix_GetStateTranslationAndScaledZ,0x80181C10,0x13 -asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fXZByCurrentState.s,SysMatrix_MultiplyVector3fXZByCurrentState,0x80181C5C,0x20 +asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s,Matrix_AppendToPolyOpaDisp,0x80181A6C,0xB +asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s,Matrix_MultiplyVector3fByState,0x80181A98,0x2E +asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s,Matrix_GetStateTranslation,0x80181B50,0xA +asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s,Matrix_GetStateTranslationAndScaledX,0x80181B78,0x13 +asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s,Matrix_GetStateTranslationAndScaledY,0x80181BC4,0x13 +asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s,Matrix_GetStateTranslationAndScaledZ,0x80181C10,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s,Matrix_MultiplyVector3fXZByCurrentState,0x80181C5C,0x20 asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s,Matrix_MtxFCopy,0x80181CDC,0x22 -asm/non_matchings/code/sys_matrix/SysMatrix_FromRSPMatrix.s,SysMatrix_FromRSPMatrix,0x80181D64,0x95 -asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByMatrix.s,SysMatrix_MultiplyVector3fByMatrix,0x80181FB8,0x2C -asm/non_matchings/code/sys_matrix/SysMatrix_TransposeXYZ.s,SysMatrix_TransposeXYZ,0x80182068,0xE -asm/non_matchings/code/sys_matrix/SysMatrix_NormalizeXYZ.s,SysMatrix_NormalizeXYZ,0x801820A0,0x3F +asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s,Matrix_FromRSPMatrix,0x80181D64,0x95 +asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s,Matrix_MultiplyVector3fByMatrix,0x80181FB8,0x2C +asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s,Matrix_TransposeXYZ,0x80182068,0xE +asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s,Matrix_NormalizeXYZ,0x801820A0,0x3F asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A -asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_f.s,SysMatrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 -asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_s.s,SysMatrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 +asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 +asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 asm/non_matchings/code/sys_matrix/func_80182C90.s,func_80182C90,0x80182C90,0x4 asm/non_matchings/code/sys_matrix/func_80182CA0.s,func_80182CA0,0x80182CA0,0x7 asm/non_matchings/code/sys_matrix/func_80182CBC.s,func_80182CBC,0x80182CBC,0x4 From b2747aa8b4186034d6621e8e3eccc44d14ec27a7 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 24 Oct 2021 13:04:36 -0300 Subject: [PATCH 41/86] Subrepos updates (#360) * git subrepo pull tools/asm-differ --force subrepo: subdir: "tools/asm-differ" merged: "d218cdf0" upstream: origin: "https://github.com/simonlindholm/asm-differ.git" branch: "main" commit: "d218cdf0" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/graphovl --force subrepo: subdir: "tools/graphovl" merged: "f5fe93d7" upstream: origin: "https://github.com/AngheloAlf/graphovl.git" branch: "master" commit: "f5fe93d7" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/ZAPD --force subrepo: subdir: "tools/ZAPD" merged: "e7a8a48c" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e7a8a48c" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/graphovl --force subrepo: subdir: "tools/graphovl" merged: "d14ea084" upstream: origin: "https://github.com/AngheloAlf/graphovl.git" branch: "master" commit: "d14ea084" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/ZAPD --force subrepo: subdir: "tools/ZAPD" merged: "e243634e" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "e243634e" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/decomp-permuter --force subrepo: subdir: "tools/decomp-permuter" merged: "d1294dfa0" upstream: origin: "https://github.com/simonlindholm/decomp-permuter.git" branch: "main" commit: "d1294dfa0" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/graphovl --force subrepo: subdir: "tools/graphovl" merged: "f5fe93d75" upstream: origin: "https://github.com/AngheloAlf/graphovl.git" branch: "master" commit: "f5fe93d75" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/ZAPD --force subrepo: subdir: "tools/ZAPD" merged: "d0cd6b397" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "d0cd6b397" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * add ExternalXMLFolder config * git subrepo pull --force tools/decomp-permuter subrepo: subdir: "tools/decomp-permuter" merged: "a20bac942" upstream: origin: "https://github.com/simonlindholm/decomp-permuter.git" branch: "main" commit: "a20bac942" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "4f7b8393e" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "4f7b8393e" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/asm-differ subrepo: subdir: "tools/asm-differ" merged: "f30d43ace" upstream: origin: "https://github.com/simonlindholm/asm-differ.git" branch: "main" commit: "f30d43ace" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Remove Segment="128" --- assets/xml/overlays/ovl_Arrow_Ice.xml | 4 +- assets/xml/overlays/ovl_En_Clear_Tag.xml | 2 +- assets/xml/overlays/ovl_En_Holl.xml | 2 +- format.sh | 1 + tools/ZAPD/.gitignore | 1 + tools/ZAPD/.gitrepo | 4 +- tools/ZAPD/ExporterTest/CollisionExporter.cpp | 10 +- tools/ZAPD/ExporterTest/CollisionExporter.h | 2 +- tools/ZAPD/ExporterTest/Main.cpp | 18 +- tools/ZAPD/ExporterTest/RoomExporter.cpp | 249 ++-- tools/ZAPD/ExporterTest/TextureExporter.cpp | 8 +- tools/ZAPD/ExporterTest/TextureExporter.h | 2 +- tools/ZAPD/Makefile | 20 +- tools/ZAPD/README.md | 6 +- tools/ZAPD/ZAPD/Declaration.cpp | 227 ++- tools/ZAPD/ZAPD/Declaration.h | 88 +- tools/ZAPD/ZAPD/GameConfig.cpp | 184 +++ tools/ZAPD/ZAPD/GameConfig.h | 58 + tools/ZAPD/ZAPD/Globals.cpp | 308 ++--- tools/ZAPD/ZAPD/Globals.h | 56 +- tools/ZAPD/ZAPD/ImageBackend.cpp | 13 +- tools/ZAPD/ZAPD/Main.cpp | 171 ++- .../ZAPD/OtherStructs/SkinLimbStructs.cpp | 341 +++++ .../ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h | 113 ++ tools/ZAPD/ZAPD/OutputFormatter.cpp | 6 +- tools/ZAPD/ZAPD/OutputFormatter.h | 4 +- tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp | 6 +- tools/ZAPD/ZAPD/Overlays/ZOverlay.h | 4 +- tools/ZAPD/ZAPD/ZAnimation.cpp | 302 ++-- tools/ZAPD/ZAPD/ZAnimation.h | 31 +- tools/ZAPD/ZAPD/ZArray.cpp | 72 +- tools/ZAPD/ZAPD/ZArray.h | 8 +- tools/ZAPD/ZAPD/ZBackground.cpp | 67 +- tools/ZAPD/ZAPD/ZBackground.h | 25 +- tools/ZAPD/ZAPD/ZBlob.cpp | 47 +- tools/ZAPD/ZAPD/ZBlob.h | 7 +- tools/ZAPD/ZAPD/ZCollision.cpp | 163 ++- tools/ZAPD/ZAPD/ZCollision.h | 27 +- tools/ZAPD/ZAPD/ZCutscene.cpp | 84 +- tools/ZAPD/ZAPD/ZCutscene.h | 14 +- tools/ZAPD/ZAPD/ZCutsceneMM.cpp | 37 +- tools/ZAPD/ZAPD/ZCutsceneMM.h | 8 +- tools/ZAPD/ZAPD/ZDisplayList.cpp | 502 +++---- tools/ZAPD/ZAPD/ZDisplayList.h | 41 +- tools/ZAPD/ZAPD/ZFile.cpp | 1225 +++++++++-------- tools/ZAPD/ZAPD/ZFile.h | 98 +- tools/ZAPD/ZAPD/ZLimb.cpp | 641 ++------- tools/ZAPD/ZAPD/ZLimb.h | 129 +- tools/ZAPD/ZAPD/ZMtx.cpp | 49 +- tools/ZAPD/ZAPD/ZMtx.h | 11 +- tools/ZAPD/ZAPD/ZPath.cpp | 72 +- tools/ZAPD/ZAPD/ZPath.h | 4 +- tools/ZAPD/ZAPD/ZPlayerAnimationData.cpp | 97 ++ tools/ZAPD/ZAPD/ZPlayerAnimationData.h | 28 + tools/ZAPD/ZAPD/ZResource.cpp | 107 +- tools/ZAPD/ZAPD/ZResource.h | 121 +- .../ZRoom/Commands/SetActorCutsceneList.cpp | 9 +- .../ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp | 13 +- .../ZRoom/Commands/SetAlternateHeaders.cpp | 28 +- .../Commands/SetAnimatedMaterialList.cpp | 6 +- .../ZRoom/Commands/SetAnimatedMaterialList.h | 1 - .../ZRoom/Commands/SetCollisionHeader.cpp | 13 +- .../ZAPD/ZRoom/Commands/SetCollisionHeader.h | 2 +- .../ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp | 28 +- .../ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp | 14 +- .../ZAPD/ZRoom/Commands/SetEntranceList.cpp | 26 +- .../ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp | 20 +- .../ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp | 11 +- .../ZRoom/Commands/SetLightingSettings.cpp | 12 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp | 339 ++--- tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h | 99 +- .../ZAPD/ZRoom/Commands/SetMinimapChests.cpp | 7 +- .../ZAPD/ZRoom/Commands/SetMinimapList.cpp | 8 +- .../ZAPD/ZRoom/Commands/SetObjectList.cpp | 10 +- .../ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp | 16 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h | 2 - .../ZAPD/ZRoom/Commands/SetRoomBehavior.cpp | 1 + .../ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp | 18 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h | 3 +- .../ZRoom/Commands/SetStartPositionList.cpp | 9 +- .../ZRoom/Commands/SetTransitionActorList.cpp | 11 +- tools/ZAPD/ZAPD/ZRoom/ZNames.h | 2 +- tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp | 47 +- tools/ZAPD/ZAPD/ZRoom/ZRoom.h | 15 +- tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.cpp | 10 +- tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.h | 2 +- tools/ZAPD/ZAPD/ZScalar.cpp | 34 +- tools/ZAPD/ZAPD/ZScalar.h | 12 +- tools/ZAPD/ZAPD/ZSkeleton.cpp | 128 +- tools/ZAPD/ZAPD/ZSkeleton.h | 17 +- tools/ZAPD/ZAPD/ZString.cpp | 22 +- tools/ZAPD/ZAPD/ZString.h | 3 +- tools/ZAPD/ZAPD/ZSymbol.cpp | 23 +- tools/ZAPD/ZAPD/ZSymbol.h | 4 +- tools/ZAPD/ZAPD/ZTexture.cpp | 73 +- tools/ZAPD/ZAPD/ZTexture.h | 11 +- tools/ZAPD/ZAPD/ZTextureAnimation.cpp | 129 +- tools/ZAPD/ZAPD/ZTextureAnimation.h | 16 +- tools/ZAPD/ZAPD/ZVector.cpp | 56 +- tools/ZAPD/ZAPD/ZVector.h | 16 +- tools/ZAPD/ZAPD/ZVtx.cpp | 28 +- tools/ZAPD/ZAPD/ZVtx.h | 8 +- tools/ZAPD/ZAPDUtils/Color3b.h | 14 +- tools/ZAPD/ZAPDUtils/StrHash.h | 6 +- tools/ZAPD/ZAPDUtils/Utils/BinaryReader.cpp | 9 +- tools/ZAPD/ZAPDUtils/Utils/BinaryReader.h | 16 +- tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.cpp | 2 +- tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.h | 2 +- tools/ZAPD/ZAPDUtils/Utils/Directory.h | 2 +- tools/ZAPD/ZAPDUtils/Utils/Path.h | 23 +- tools/ZAPD/ZAPDUtils/Utils/StringHelper.h | 2 +- tools/ZAPD/ZAPDUtils/Vec2f.h | 12 +- tools/ZAPD/ZAPDUtils/Vec3f.h | 14 +- tools/ZAPD/copycheck.py | 2 + .../docs/zapd_extraction_xml_reference.md | 59 +- tools/ZAPD/docs/zapd_xml_spec.md | 55 + tools/ZAPDConfigs/MM/Config.xml | 8 + tools/asm-differ/.gitrepo | 4 +- tools/asm-differ/__init__.py | 0 tools/asm-differ/diff.py | 23 +- tools/decomp-permuter/.gitrepo | 2 +- tools/graphovl/.gitrepo | 4 +- tools/graphovl/graphovl.py | 70 +- tools/graphovl/graphovl_styles/classic.ini | 1 + tools/graphovl/graphovl_styles/soft.ini | 1 + .../graphovl_styles/solarized_dark.ini | 1 + .../graphovl_styles/solarized_light.ini | 1 + 127 files changed, 4132 insertions(+), 3488 deletions(-) create mode 100644 tools/ZAPD/ZAPD/GameConfig.cpp create mode 100644 tools/ZAPD/ZAPD/GameConfig.h create mode 100644 tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h create mode 100644 tools/ZAPD/ZAPD/ZPlayerAnimationData.cpp create mode 100644 tools/ZAPD/ZAPD/ZPlayerAnimationData.h create mode 100644 tools/ZAPD/docs/zapd_xml_spec.md delete mode 100644 tools/asm-differ/__init__.py diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index e130bdd05..96c0f2522 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,5 +1,5 @@ - + @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/assets/xml/overlays/ovl_En_Clear_Tag.xml b/assets/xml/overlays/ovl_En_Clear_Tag.xml index 82a1e2fe8..0cbfcf80a 100644 --- a/assets/xml/overlays/ovl_En_Clear_Tag.xml +++ b/assets/xml/overlays/ovl_En_Clear_Tag.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/overlays/ovl_En_Holl.xml b/assets/xml/overlays/ovl_En_Holl.xml index 5679e1605..2baa5737c 100644 --- a/assets/xml/overlays/ovl_En_Holl.xml +++ b/assets/xml/overlays/ovl_En_Holl.xml @@ -1,5 +1,5 @@ - + diff --git a/format.sh b/format.sh index c705e9aff..ed830a502 100755 --- a/format.sh +++ b/format.sh @@ -25,4 +25,5 @@ echo "Running clang-tidy..." clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null echo "Adding missing final new lines..." find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \; +find assets/xml/ -type f -name "*.xml" -exec sed -i -e '$a\' {} \; echo "Done formatting all files." diff --git a/tools/ZAPD/.gitignore b/tools/ZAPD/.gitignore index 00ec03b0f..68c502e36 100644 --- a/tools/ZAPD/.gitignore +++ b/tools/ZAPD/.gitignore @@ -338,3 +338,4 @@ ZAPDUtils/ZAPDUtils.a .vscode/ build/ ZAPDUtils/build/ +ZAPD/BuildInfo.h diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 7201aacd3..94da913d0 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 623d779f8ea111cb8cbb78a218c8454e819c4c13 - parent = 9f2368dd710e740ced0f8086de91228b87f41512 + commit = 4f7b8393ec8a3abd59649c2ba669e951fb61f3d2 + parent = 346df1bbc8ca21673fe63d884b6734c23a4d9f4b method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index 81a9b5464..e00f5c1b0 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -1,6 +1,7 @@ #include "CollisionExporter.h" -void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]]fs::path outPath, BinaryWriter* writer) +void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path outPath, + BinaryWriter* writer) { ZCollisionHeader* col = (ZCollisionHeader*)res; @@ -35,9 +36,10 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]]fs::path ou for (uint16_t i = 0; i < col->vertices.size(); i++) { - writer->Write(col->vertices[i].x); - writer->Write(col->vertices[i].y); - writer->Write(col->vertices[i].z); + for (uint32_t j = 0; j < col->vertices[i].dimensions; j++) + { + writer->Write(col->vertices[i].scalars[j].scalarData.s16); + } } writer->Seek(col->polySegmentOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.h b/tools/ZAPD/ExporterTest/CollisionExporter.h index 2828995d0..5f48e6557 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.h +++ b/tools/ZAPD/ExporterTest/CollisionExporter.h @@ -1,7 +1,7 @@ #pragma once -#include "ZResource.h" #include "ZCollision.h" +#include "ZResource.h" class ExporterExample_Collision : public ZResourceExporter { diff --git a/tools/ZAPD/ExporterTest/Main.cpp b/tools/ZAPD/ExporterTest/Main.cpp index 1fb6bea77..4f683a1ba 100644 --- a/tools/ZAPD/ExporterTest/Main.cpp +++ b/tools/ZAPD/ExporterTest/Main.cpp @@ -1,7 +1,7 @@ -#include -#include #include #include +#include +#include enum class ExporterFileMode { @@ -10,7 +10,7 @@ enum class ExporterFileMode ModeExample3 = (int)ZFileMode::Custom + 3, }; -static void ExporterParseFileMode(std::string buildMode, ZFileMode& fileMode) +static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileMode) { if (buildMode == "me1") fileMode = (ZFileMode)ExporterFileMode::ModeExample1; @@ -20,17 +20,15 @@ static void ExporterParseFileMode(std::string buildMode, ZFileMode& fileMode) fileMode = (ZFileMode)ExporterFileMode::ModeExample3; } -static void ExporterParseArgs([[maybe_unused]]int argc, char* argv[], int& i) +static void ExporterParseArgs([[maybe_unused]] int argc, char* argv[], int& i) { std::string arg = argv[i]; if (arg == "--do-x") { - } else if (arg == "--do-y") { - } } @@ -61,7 +59,8 @@ static void ExporterFileEnd(ZFile* file) static void ImportExporters() { // In this example we set up a new exporter called "EXAMPLE". - // By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter for our resources. + // By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter + // for our resources. ExporterSet* exporterSet = new ExporterSet(); exporterSet->processFileModeFunc = ExporterProcessFileMode; exporterSet->parseFileModeFunc = ExporterParseFileMode; @@ -75,5 +74,6 @@ static void ImportExporters() Globals::AddExporter("EXAMPLE", exporterSet); } -// When ZAPD starts up, it will automatically call the below function, which in turn sets up our exporters. -REGISTER_EXPORTER(ImportExporters) \ No newline at end of file +// When ZAPD starts up, it will automatically call the below function, which in turn sets up our +// exporters. +REGISTER_EXPORTER(ImportExporters); diff --git a/tools/ZAPD/ExporterTest/RoomExporter.cpp b/tools/ZAPD/ExporterTest/RoomExporter.cpp index dc8c82302..c4a6844fb 100644 --- a/tools/ZAPD/ExporterTest/RoomExporter.cpp +++ b/tools/ZAPD/ExporterTest/RoomExporter.cpp @@ -1,41 +1,41 @@ #include "RoomExporter.h" +#include #include -#include #include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include #include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* writer) { - ZRoom* room = (ZRoom*)res; + ZRoom* room = dynamic_cast(res); - //MemoryStream* memStream = new MemoryStream(); - //BinaryWriter* writer = new BinaryWriter(memStream); + // MemoryStream* memStream = new MemoryStream(); + // BinaryWriter* writer = new BinaryWriter(memStream); - for (uint i = 0; i < room->commands.size() * 8; i++) + for (size_t i = 0; i < room->commands.size() * 8; i++) writer->Write((uint8_t)0); - for (uint i = 0; i < room->commands.size(); i++) + for (size_t i = 0; i < room->commands.size(); i++) { ZRoomCommand* cmd = room->commands[i]; - + writer->Seek(i * 8, SeekOffsetType::Start); - + writer->Write((uint8_t)cmd->cmdID); switch (cmd->cmdID) @@ -44,115 +44,115 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* { SetWind* cmdSetWind = (SetWind*)cmd; - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdSetWind->windWest); // 0x04 - writer->Write(cmdSetWind->windVertical); // 0x05 - writer->Write(cmdSetWind->windSouth); // 0x06 - writer->Write(cmdSetWind->clothFlappingStrength); // 0x07 + writer->Write(cmdSetWind->windWest); // 0x04 + writer->Write(cmdSetWind->windVertical); // 0x05 + writer->Write(cmdSetWind->windSouth); // 0x06 + writer->Write(cmdSetWind->clothFlappingStrength); // 0x07 } - break; + break; case RoomCommand::SetTimeSettings: { SetTimeSettings* cmdTime = (SetTimeSettings*)cmd; - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdTime->hour); // 0x04 - writer->Write(cmdTime->min); // 0x05 - writer->Write(cmdTime->unk); // 0x06 - writer->Write((uint8_t)0); // 0x07 + writer->Write(cmdTime->hour); // 0x04 + writer->Write(cmdTime->min); // 0x05 + writer->Write(cmdTime->unk); // 0x06 + writer->Write((uint8_t)0); // 0x07 } break; case RoomCommand::SetSkyboxModifier: { SetSkyboxModifier* cmdSkybox = (SetSkyboxModifier*)cmd; - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdSkybox->disableSky); // 0x04 - writer->Write(cmdSkybox->disableSunMoon); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 + writer->Write(cmdSkybox->disableSky); // 0x04 + writer->Write(cmdSkybox->disableSunMoon); // 0x05 + writer->Write((uint8_t)0); // 0x06 + writer->Write((uint8_t)0); // 0x07 } break; case RoomCommand::SetEchoSettings: { SetEchoSettings* cmdEcho = (SetEchoSettings*)cmd; - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)cmdEcho->echo); // 0x07 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x04 + writer->Write((uint8_t)0); // 0x05 + writer->Write((uint8_t)0); // 0x06 + writer->Write((uint8_t)cmdEcho->echo); // 0x07 } break; case RoomCommand::SetSoundSettings: { SetSoundSettings* cmdSound = (SetSoundSettings*)cmd; - writer->Write((uint8_t)cmdSound->reverb); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 + writer->Write((uint8_t)cmdSound->reverb); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x04 + writer->Write((uint8_t)0); // 0x05 - writer->Write(cmdSound->nightTimeSFX); // 0x06 - writer->Write(cmdSound->musicSequence); // 0x07 + writer->Write(cmdSound->nightTimeSFX); // 0x06 + writer->Write(cmdSound->musicSequence); // 0x07 } break; case RoomCommand::SetSkyboxSettings: { SetSkyboxSettings* cmdSkybox = (SetSkyboxSettings*)cmd; - writer->Write((uint8_t)cmdSkybox->unk1); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04 - writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05 - writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06 + writer->Write((uint8_t)cmdSkybox->unk1); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04 + writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05 + writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06 } break; case RoomCommand::SetRoomBehavior: { SetRoomBehavior* cmdRoom = (SetRoomBehavior*)cmd; - writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdRoom->gameplayFlags2); // 0x04 + writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(cmdRoom->gameplayFlags2); // 0x04 } break; case RoomCommand::SetCsCamera: { SetCsCamera* cmdCsCam = (SetCsCamera*)cmd; - writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdCsCam->segmentOffset); // 0x04 + writer->Write(cmdCsCam->segmentOffset); // 0x04 } break; case RoomCommand::SetMesh: { SetMesh* cmdMesh = (SetMesh*)cmd; - + int baseStreamEnd = writer->GetStream().get()->GetLength(); - writer->Write((uint8_t)cmdMesh->data); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)cmdMesh->data); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - writer->Write(baseStreamEnd); // 0x04 + writer->Write(baseStreamEnd); // 0x04 uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(baseStreamEnd, SeekOffsetType::Start); @@ -163,15 +163,13 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* if (cmdMesh->meshHeaderType == 0) { - //writer->Write(cmdMesh->) + // writer->Write(cmdMesh->) } else if (cmdMesh->meshHeaderType == 1) { - } else if (cmdMesh->meshHeaderType == 2) { - } writer->Seek(oldOffset, SeekOffsetType::Start); @@ -181,20 +179,20 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* { SetCameraSettings* cmdCam = (SetCameraSettings*)cmd; - writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdCam->mapHighlight); // 0x04 + writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(cmdCam->mapHighlight); // 0x04 } break; case RoomCommand::SetLightingSettings: { SetLightingSettings* cmdLight = (SetLightingSettings*)cmd; - writer->Write((uint8_t)cmdLight->settings.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(cmdLight->segmentOffset); // 0x04 + writer->Write((uint8_t)cmdLight->settings.size()); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(cmdLight->segmentOffset); // 0x04 uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(cmdLight->segmentOffset, SeekOffsetType::Start); @@ -236,17 +234,17 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* { SetRoomList* cmdRoom = (SetRoomList*)cmd; - writer->Write((uint8_t)cmdRoom->rooms.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)cmdRoom->romfile->rooms.size()); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 - int baseStreamEnd = writer->GetLength(); - writer->Write(baseStreamEnd); // 0x04 + auto baseStreamEnd = writer->GetLength(); + writer->Write(baseStreamEnd); // 0x04 uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(baseStreamEnd, SeekOffsetType::Start); - for (RoomEntry entry : cmdRoom->rooms) + for (const auto& entry : cmdRoom->romfile->rooms) { writer->Write(entry.virtualAddressStart); writer->Write(entry.virtualAddressEnd); @@ -261,10 +259,10 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* int streamEnd = writer->GetStream().get()->GetLength(); - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(streamEnd); // 0x04 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(streamEnd); // 0x04 // TODO: NOT DONE @@ -284,10 +282,10 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(baseStreamEnd); // 0x04 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(baseStreamEnd); // 0x04 uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(baseStreamEnd, SeekOffsetType::Start); @@ -305,12 +303,12 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* { SetSpecialObjects* cmdSpecObj = (SetSpecialObjects*)cmd; - writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06 + writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x04 + writer->Write((uint8_t)0); // 0x05 + writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06 } break; case RoomCommand::SetStartPositionList: @@ -319,10 +317,10 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); - writer->Write((uint8_t)cmdStartPos->actors.size()); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write(baseStreamEnd); // 0x04 + writer->Write((uint8_t)cmdStartPos->actors.size()); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write(baseStreamEnd); // 0x04 uint32_t oldOffset = writer->GetBaseAddress(); writer->Seek(baseStreamEnd, SeekOffsetType::Start); @@ -344,30 +342,31 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* break; case RoomCommand::EndMarker: { - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x04 + writer->Write((uint8_t)0); // 0x05 + writer->Write((uint8_t)0); // 0x06 + writer->Write((uint8_t)0); // 0x07 } break; default: printf("UNIMPLEMENTED COMMAND: %i\n", (int)cmd->cmdID); - writer->Write((uint8_t)0); // 0x01 - writer->Write((uint8_t)0); // 0x02 - writer->Write((uint8_t)0); // 0x03 - writer->Write((uint8_t)0); // 0x04 - writer->Write((uint8_t)0); // 0x05 - writer->Write((uint8_t)0); // 0x06 - writer->Write((uint8_t)0); // 0x07 + writer->Write((uint8_t)0); // 0x01 + writer->Write((uint8_t)0); // 0x02 + writer->Write((uint8_t)0); // 0x03 + writer->Write((uint8_t)0); // 0x04 + writer->Write((uint8_t)0); // 0x05 + writer->Write((uint8_t)0); // 0x06 + writer->Write((uint8_t)0); // 0x07 break; } } - //writer->Close(); - //File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), memStream->ToVector()); + // writer->Close(); + // File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), + // memStream->ToVector()); } diff --git a/tools/ZAPD/ExporterTest/TextureExporter.cpp b/tools/ZAPD/ExporterTest/TextureExporter.cpp index 95d84b8f7..6488bed3a 100644 --- a/tools/ZAPD/ExporterTest/TextureExporter.cpp +++ b/tools/ZAPD/ExporterTest/TextureExporter.cpp @@ -1,12 +1,14 @@ #include "TextureExporter.h" #include "../ZAPD/ZFile.h" -void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]]fs::path outPath, BinaryWriter* writer) +void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]] fs::path outPath, + BinaryWriter* writer) { ZTexture* tex = (ZTexture*)res; auto data = tex->parent->GetRawData(); - for (uint i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); i++) + for (offset_t i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize(); + i++) writer->Write(data[i]); -} \ No newline at end of file +} diff --git a/tools/ZAPD/ExporterTest/TextureExporter.h b/tools/ZAPD/ExporterTest/TextureExporter.h index fcee8be5a..ffe6001dc 100644 --- a/tools/ZAPD/ExporterTest/TextureExporter.h +++ b/tools/ZAPD/ExporterTest/TextureExporter.h @@ -1,8 +1,8 @@ #pragma once +#include #include "ZResource.h" #include "ZTexture.h" -#include class ExporterExample_Texture : public ZResourceExporter { diff --git a/tools/ZAPD/Makefile b/tools/ZAPD/Makefile index e8f6c92a3..737b85ecf 100644 --- a/tools/ZAPD/Makefile +++ b/tools/ZAPD/Makefile @@ -5,17 +5,22 @@ ASAN ?= 0 DEPRECATION_ON ?= 1 DEBUG ?= 0 COPYCHECK_ARGS ?= -# Set LLD=1 to use ld.lld as the linker LLD ?= 0 -CXX := g++ +# Use clang++ if available, else use g++ +ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0) + CXX := clang++ +else + CXX := g++ +endif + INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer OPTFLAGS := ifneq ($(DEBUG),0) OPTIMIZATION_ON = 0 - DEPRECATION_OFF = 1 + CXXFLAGS += -g3 -DDEVELOPMENT -D_DEBUG COPYCHECK_ARGS += --devel DEPRECATION_ON = 0 else @@ -29,7 +34,7 @@ else endif ifneq ($(ASAN),0) - CXXFLAGS += -fsanitize=address + CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined endif ifneq ($(DEPRECATION_ON),0) CXXFLAGS += -DDEPRECATION_ON @@ -38,6 +43,11 @@ endif LDFLAGS := -lm -ldl -lpng +# Use LLD if available. Set LLD=0 to not use it +ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) + LLD := 1 +endif + ifneq ($(LLD),0) LDFLAGS += -fuse-ld=lld endif @@ -105,4 +115,4 @@ ZAPDUtils: # Linking ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils - $(CXX) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive $(LDFLAGS) $(OUTPUT_OPTION) + $(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive $(LDFLAGS) $(OUTPUT_OPTION) diff --git a/tools/ZAPD/README.md b/tools/ZAPD/README.md index 4d7ade27e..e2764b627 100644 --- a/tools/ZAPD/README.md +++ b/tools/ZAPD/README.md @@ -30,7 +30,7 @@ You can configure a bit your ZAPD build with the following options: - `DEBUG`: If non-zero, ZAPD will be compiled in _development mode_. This implies the following: - Debugging symbols enabled (`-g3`). They are disabled by default. - `OPTIMIZATION_ON=0`: Disables optimizations (`-O0`). - - `DEPRECATION_OFF=1`: Disables deprecation warnings. + - `DEPRECATION_ON=0`: Disables deprecation warnings. - `LLD=1`: builds with the LLVM linker `ld.lld` instead of the system default. As an example, if you want to build ZAPD with optimizations disabled and use the address sanitizer, you could use the following command: @@ -110,8 +110,10 @@ ZAPD also accepts the following list of extra parameters: - Can be used only in `e` or `bsf` modes. - `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`. - `-wno` / `--warn-no-offsets` : Enable warnings for nodes that dont have offsets specified. Takes priority over `-eno`/ `--error-no-offsets`. -- `-eno`/ `--error-no-offsets` : Enable errors for nodes that dont have offsets specified. +- `-eno` / `--error-no-offsets` : Enable errors for nodes that dont have offsets specified. - `-se` / `--set-exporter` : Sets which exporter to use. - `--gcc-compat` : Enables GCC compatible mode. Slower. +- `-s` / `--static` : Mark every asset as `static`. + - This behaviour can be overridden per asset using `Static=` in the respective XML node. Additionally, you can pass the flag `--version` to see the current ZAPD version. If that flag is passed, ZAPD will ignore any other parameter passed. diff --git a/tools/ZAPD/ZAPD/Declaration.cpp b/tools/ZAPD/ZAPD/Declaration.cpp index 63a391805..d2a86ffcc 100644 --- a/tools/ZAPD/ZAPD/Declaration.cpp +++ b/tools/ZAPD/ZAPD/Declaration.cpp @@ -1,37 +1,31 @@ #include "Declaration.h" -Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nText) +#include "Globals.h" +#include "Utils/StringHelper.h" + +Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nText) { + address = nAddress; alignment = nAlignment; - padding = nPadding; size = nSize; text = nText; } -Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, std::string nText) - : Declaration(nAlignment, DeclarationPadding::None, nSize, nText) +Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + const std::string& nText) + : Declaration(nAddress, nAlignment, nSize, nText) { varType = nVarType; varName = nVarName; isArray = nIsArray; } -Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nVarType, std::string nVarName, bool nIsArray, - std::string nText) - : Declaration(nAlignment, nPadding, nSize, nText) -{ - varType = nVarType; - varName = nVarName; - isArray = nIsArray; -} - -Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, size_t nArrayItemCnt, - std::string nText) - : Declaration(nAlignment, DeclarationPadding::None, nSize, nText) +Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + size_t nArrayItemCnt, const std::string& nText) + : Declaration(nAddress, nAlignment, nSize, nText) { varType = nVarType; varName = nVarName; @@ -39,10 +33,10 @@ Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::str arrayItemCnt = nArrayItemCnt; } -Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, std::string nArrayItemCntStr, - std::string nText) - : Declaration(nAlignment, DeclarationPadding::None, nSize, nText) +Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + const std::string& nArrayItemCntStr, const std::string& nText) + : Declaration(nAddress, nAlignment, nSize, nText) { varType = nVarType; varName = nVarName; @@ -50,30 +44,179 @@ Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::str arrayItemCntStr = nArrayItemCntStr; } -Declaration::Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, size_t nArrayItemCnt, - std::string nText, bool nIsExternal) - : Declaration(nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText) +Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + size_t nArrayItemCnt, const std::string& nText, bool nIsExternal) + : Declaration(nAddress, nAlignment, nSize, nVarType, nVarName, nIsArray, nArrayItemCnt, nText) { isExternal = nIsExternal; } -Declaration::Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nVarType, std::string nVarName, bool nIsArray, - size_t nArrayItemCnt, std::string nText) - : Declaration(nAlignment, nPadding, nSize, nText) -{ - varType = nVarType; - varName = nVarName; - isArray = nIsArray; - arrayItemCnt = nArrayItemCnt; -} - -Declaration::Declaration(std::string nIncludePath, size_t nSize, std::string nVarType, - std::string nVarName) - : Declaration(DeclarationAlignment::None, DeclarationPadding::None, nSize, "") +Declaration::Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize, + const std::string& nVarType, const std::string& nVarName) + : Declaration(nAddress, DeclarationAlignment::Align4, nSize, "") { includePath = nIncludePath; varType = nVarType; varName = nVarName; } + +bool Declaration::IsStatic() const +{ + switch (staticConf) + { + case StaticConfig::Off: + return false; + + case StaticConfig::Global: + return Globals::Instance->forceStatic; + + case StaticConfig::On: + return true; + } + + return false; +} + +std::string Declaration::GetNormalDeclarationStr() const +{ + std::string output; + + if (preText != "") + output += preText + "\n"; + + if (IsStatic()) + { + output += "static "; + } + + if (isArray) + { + if (arrayItemCntStr != "") + { + output += StringHelper::Sprintf("%s %s[%s];\n", varType.c_str(), varName.c_str(), + arrayItemCntStr.c_str()); + } + else if (arrayItemCnt == 0) + { + output += StringHelper::Sprintf("%s %s[] = {\n", varType.c_str(), varName.c_str()); + } + else + { + output += StringHelper::Sprintf("%s %s[%i] = {\n", varType.c_str(), varName.c_str(), + arrayItemCnt); + } + + output += text + "\n"; + } + else + { + output += StringHelper::Sprintf("%s %s = { ", varType.c_str(), varName.c_str()); + output += text; + } + + if (output.back() == '\n') + output += "};"; + else + output += " };"; + + if (rightText != "") + output += " " + rightText + ""; + + output += "\n"; + + if (postText != "") + output += postText + "\n"; + + output += "\n"; + + return output; +} + +std::string Declaration::GetExternalDeclarationStr() const +{ + std::string output; + + if (preText != "") + output += preText + "\n"; + + if (IsStatic()) + { + output += "static "; + } + + if (arrayItemCntStr != "") + output += + StringHelper::Sprintf("%s %s[%s] = {\n#include \"%s\"\n};", varType.c_str(), + varName.c_str(), arrayItemCntStr.c_str(), includePath.c_str()); + else if (arrayItemCnt != 0) + output += StringHelper::Sprintf("%s %s[%i] = {\n#include \"%s\"\n};", varType.c_str(), + varName.c_str(), arrayItemCnt, includePath.c_str()); + else + output += StringHelper::Sprintf("%s %s[] = {\n#include \"%s\"\n};", varType.c_str(), + varName.c_str(), includePath.c_str()); + + if (rightText != "") + output += " " + rightText + ""; + + output += "\n"; + + if (postText != "") + output += postText + "\n"; + + output += "\n"; + + return output; +} + +std::string Declaration::GetExternStr() const +{ + if (IsStatic() || varType == "") + { + return ""; + } + + if (isArray) + { + if (arrayItemCntStr != "") + { + return StringHelper::Sprintf("extern %s %s[%s];\n", varType.c_str(), varName.c_str(), + arrayItemCntStr.c_str()); + } + else if (arrayItemCnt != 0) + return StringHelper::Sprintf("extern %s %s[%i];\n", varType.c_str(), varName.c_str(), + arrayItemCnt); + else + return StringHelper::Sprintf("extern %s %s[];\n", varType.c_str(), varName.c_str()); + } + + return StringHelper::Sprintf("extern %s %s;\n", varType.c_str(), varName.c_str()); +} + +std::string Declaration::GetStaticForwardDeclarationStr() const +{ + if (!IsStatic() || isUnaccounted) + return ""; + + if (isArray) + { + if (arrayItemCntStr == "" && arrayItemCnt == 0) + { + // Forward declaring static arrays without specifying the size is not allowed. + return ""; + } + + if (arrayItemCntStr != "") + { + return StringHelper::Sprintf("static %s %s[%s];\n", varType.c_str(), varName.c_str(), + arrayItemCntStr.c_str()); + } + else + { + return StringHelper::Sprintf("static %s %s[%i];\n", varType.c_str(), varName.c_str(), + arrayItemCnt); + } + } + + return StringHelper::Sprintf("static %s %s;\n", varType.c_str(), varName.c_str()); +} diff --git a/tools/ZAPD/ZAPD/Declaration.h b/tools/ZAPD/ZAPD/Declaration.h index f955110e7..138524a4c 100644 --- a/tools/ZAPD/ZAPD/Declaration.h +++ b/tools/ZAPD/ZAPD/Declaration.h @@ -3,63 +3,77 @@ #include #include +// TODO: should we drop the `_t` suffix because of UNIX compliance? +typedef uint32_t segptr_t; +typedef uint32_t offset_t; + +#define SEGMENTED_NULL ((segptr_t)0) + enum class DeclarationAlignment { - None, Align4, Align8, Align16 }; -enum class DeclarationPadding +enum class StaticConfig { - None, - Pad4, - Pad8, - Pad16 + Off, + Global, + On }; class Declaration { public: + offset_t address; DeclarationAlignment alignment; - DeclarationPadding padding; size_t size; - std::string preText = ""; - std::string text = ""; - std::string rightText = ""; - std::string postText = ""; - std::string preComment = ""; - std::string postComment = ""; - std::string varType = ""; - std::string varName = ""; - std::string includePath = ""; + std::string preText; + std::string text; + std::string rightText; + std::string postText; + std::string preComment; + std::string postComment; + std::string varType; + std::string varName; + std::string includePath; bool isExternal = false; bool isArray = false; size_t arrayItemCnt = 0; - std::string arrayItemCntStr = ""; - std::vector references; + std::string arrayItemCntStr; + std::vector references; bool isUnaccounted = false; bool isPlaceholder = false; + bool declaredInXml = false; + StaticConfig staticConf = StaticConfig::Global; - Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, std::string nText); - Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nVarType, std::string nVarName, bool nIsArray, std::string nText); - Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText); - Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, std::string nArrayItemCntStr, - std::string nText); - Declaration(DeclarationAlignment nAlignment, size_t nSize, std::string nVarType, - std::string nVarName, bool nIsArray, size_t nArrayItemCnt, std::string nText, - bool nIsExternal); - Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nVarType, std::string nVarName, bool nIsArray, size_t nArrayItemCnt, - std::string nText); - Declaration(std::string nIncludePath, size_t nSize, std::string nVarType, std::string nVarName); + Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + const std::string& nText); + Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + size_t nArrayItemCnt, const std::string& nText); + Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + const std::string& nArrayItemCntStr, const std::string& nText); + Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nVarType, const std::string& nVarName, bool nIsArray, + size_t nArrayItemCnt, const std::string& nText, bool nIsExternal); + + Declaration(offset_t nAddress, const std::string& nIncludePath, size_t nSize, + const std::string& nVarType, const std::string& nVarName); + + bool IsStatic() const; + + std::string GetNormalDeclarationStr() const; + std::string GetExternalDeclarationStr() const; + + std::string GetExternStr() const; + + std::string GetStaticForwardDeclarationStr() const; protected: - Declaration(DeclarationAlignment nAlignment, DeclarationPadding nPadding, size_t nSize, - std::string nText); -}; \ No newline at end of file + Declaration(offset_t nAddress, DeclarationAlignment nAlignment, size_t nSize, + const std::string& nText); +}; diff --git a/tools/ZAPD/ZAPD/GameConfig.cpp b/tools/ZAPD/ZAPD/GameConfig.cpp new file mode 100644 index 000000000..f197493a4 --- /dev/null +++ b/tools/ZAPD/ZAPD/GameConfig.cpp @@ -0,0 +1,184 @@ +#include "GameConfig.h" + +#include +#include + +#include "Utils/Directory.h" +#include "Utils/File.h" +#include "Utils/Path.h" +#include "ZFile.h" +#include "tinyxml2.h" + +using ConfigFunc = void (GameConfig::*)(const tinyxml2::XMLElement&); + +GameConfig::~GameConfig() +{ + for (auto& declPair : segmentRefFiles) + { + for (auto& file : declPair.second) + { + delete file; + } + } +} + +void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath) +{ + tinyxml2::XMLDocument doc; + tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str()); + + if (eResult != tinyxml2::XML_SUCCESS) + { + fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult); + return; + } + + tinyxml2::XMLNode* root = doc.FirstChild(); + + if (root == nullptr) + return; + + for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr; + child = child->NextSiblingElement()) + { + if (std::string_view(child->Name()) == "Texture") + { + std::string crcStr = child->Attribute("CRC"); + fs::path texPath = child->Attribute("Path"); + std::string texName; + + uint32_t crc = strtoul(crcStr.c_str(), nullptr, 16); + + texturePool[crc].path = texPath; + } + } +} + +void GameConfig::GenSymbolMap(const fs::path& symbolMapPath) +{ + auto symbolLines = File::ReadAllLines(symbolMapPath); + + for (std::string& symbolLine : symbolLines) + { + auto split = StringHelper::Split(symbolLine, " "); + uint32_t addr = strtoul(split[0].c_str(), nullptr, 16); + std::string symbolName = split[1]; + + symbolMap[addr] = std::move(symbolName); + } +} + +void GameConfig::ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + GenSymbolMap(Path::GetDirectoryName(configFilePath) / fileName); +} + +void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + actorList.emplace_back(std::move(line)); +} + +void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + objectList.emplace_back(std::move(line)); +} + +void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + ReadTexturePool(Path::GetDirectoryName(configFilePath) / fileName); +} + +void GameConfig::ConfigFunc_BGConfig(const tinyxml2::XMLElement& element) +{ + bgScreenWidth = element.IntAttribute("ScreenWidth", 320); + bgScreenHeight = element.IntAttribute("ScreenHeight", 240); +} + +void GameConfig::ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element) +{ + const char* pathValue = element.Attribute("Path"); + if (pathValue == nullptr) + { + throw std::runtime_error( + StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" + "\t Missing 'Path' attribute in `ExternalXMLFolder` element.\n")); + } + if (externalXmlFolder != "") + { + throw std::runtime_error(StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" + "\t `ExternalXMLFolder` is duplicated.\n")); + } + externalXmlFolder = pathValue; +} + +void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element) +{ + const char* xmlPathValue = element.Attribute("XmlPath"); + if (xmlPathValue == nullptr) + { + throw std::runtime_error( + StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" + "\t Missing 'XmlPath' attribute in `ExternalFile` element.\n")); + } + const char* outPathValue = element.Attribute("OutPath"); + if (outPathValue == nullptr) + { + throw std::runtime_error( + StringHelper::Sprintf("Parse: Fatal error in configuration file.\n" + "\t Missing 'OutPath' attribute in `ExternalFile` element.\n")); + } + + externalFiles.push_back(ExternalFile(fs::path(xmlPathValue), fs::path(outPathValue))); +} + +void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) +{ + static const std::map ConfigFuncDictionary = { + {"SymbolMap", &GameConfig::ConfigFunc_SymbolMap}, + {"ActorList", &GameConfig::ConfigFunc_ActorList}, + {"ObjectList", &GameConfig::ConfigFunc_ObjectList}, + {"TexturePool", &GameConfig::ConfigFunc_TexturePool}, + {"BGConfig", &GameConfig::ConfigFunc_BGConfig}, + {"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder}, + {"ExternalFile", &GameConfig::ConfigFunc_ExternalFile}, + }; + + configFilePath = argConfigFilePath; + tinyxml2::XMLDocument doc; + tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str()); + + if (eResult != tinyxml2::XML_SUCCESS) + { + throw std::runtime_error("Error: Unable to read config file."); + } + + tinyxml2::XMLNode* root = doc.FirstChild(); + + if (root == nullptr) + return; + + for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr; + child = child->NextSiblingElement()) + { + auto it = ConfigFuncDictionary.find(child->Name()); + if (it == ConfigFuncDictionary.end()) + { + fprintf(stderr, "Unsupported configuration variable: %s\n", child->Name()); + continue; + } + + std::invoke(it->second, *this, *child); + } +} diff --git a/tools/ZAPD/ZAPD/GameConfig.h b/tools/ZAPD/ZAPD/GameConfig.h new file mode 100644 index 000000000..c478d16ce --- /dev/null +++ b/tools/ZAPD/ZAPD/GameConfig.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include +#include + +#include "Utils/Directory.h" +#include "tinyxml2.h" + +struct TexturePoolEntry +{ + fs::path path = ""; // Path to Shared Texture +}; + +class ExternalFile +{ +public: + fs::path xmlPath, outPath; + + ExternalFile(fs::path nXmlPath, fs::path nOutPath); +}; + +class ZFile; + +class GameConfig +{ +public: + std::string configFilePath; + std::map> segmentRefFiles; + std::map symbolMap; + std::vector actorList; + std::vector objectList; + std::map texturePool; // Key = CRC + + // ZBackground + uint32_t bgScreenWidth = 320, bgScreenHeight = 240; + + // ExternalFile + fs::path externalXmlFolder; + std::vector externalFiles; + + GameConfig() = default; + ~GameConfig(); + + void ReadTexturePool(const fs::path& texturePoolXmlPath); + void GenSymbolMap(const fs::path& symbolMapPath); + + void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element); + void ConfigFunc_ActorList(const tinyxml2::XMLElement& element); + void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element); + void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element); + void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element); + void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element); + void ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element); + + void ReadConfigFile(const fs::path& configFilePath); +}; diff --git a/tools/ZAPD/ZAPD/Globals.cpp b/tools/ZAPD/ZAPD/Globals.cpp index b3bc067bf..036e4a5cb 100644 --- a/tools/ZAPD/ZAPD/Globals.cpp +++ b/tools/ZAPD/ZAPD/Globals.cpp @@ -1,175 +1,35 @@ #include "Globals.h" + +#include +#include + #include #include -#include #include "tinyxml2.h" -using namespace tinyxml2; - Globals* Globals::Instance; Globals::Globals() { Instance = this; - files = std::vector(); - segments = std::vector(); - symbolMap = std::map(); - segmentRefs = std::map(); - segmentRefFiles = std::map(); game = ZGame::OOT_RETAIL; genSourceFile = true; testMode = false; profile = false; useLegacyZDList = false; useExternalResources = true; - lastScene = nullptr; verbosity = VerbosityLevel::VERBOSITY_SILENT; - currentExporter = ""; outputPath = Directory::GetCurrentDirectory(); } -std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress) +Globals::~Globals() { - if (segmentRefs.find(segNumber) != segmentRefs.end()) + auto& exporters = GetExporterMap(); + + for (auto& it : exporters) { - if (segmentRefFiles.find(segNumber) == segmentRefFiles.end()) - { - XMLDocument doc; - std::string filePath = segmentRefs[segNumber]; - XMLError eResult = doc.LoadFile(filePath.c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - return "ERROR"; - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - return "ERROR"; - - for (XMLElement* child = root->FirstChildElement(); child != NULL; - child = child->NextSiblingElement()) - { - if (std::string(child->Name()) == "File") - { - ZFile* file = new ZFile(fileMode, child, "", "", filePath, true); - file->GeneratePlaceholderDeclarations(); - segmentRefFiles[segNumber] = file; - break; - } - } - } - - return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR"); - } - - return "ERROR"; -} - -void Globals::ReadConfigFile(const std::string& configFilePath) -{ - tinyxml2::XMLDocument doc; - tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - { - throw std::runtime_error("Error: Unable to read config file."); - return; - } - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - return; - - for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL; - child = child->NextSiblingElement()) - { - if (std::string(child->Name()) == "SymbolMap") - { - std::string fileName = std::string(child->Attribute("File")); - GenSymbolMap(Path::GetDirectoryName(configFilePath) + "/" + fileName); - } - else if (std::string(child->Name()) == "Segment") - { - std::string fileName = std::string(child->Attribute("File")); - int32_t segNumber = child->IntAttribute("Number"); - segmentRefs[segNumber] = fileName; - } - else if (std::string(child->Name()) == "ActorList") - { - std::string fileName = std::string(child->Attribute("File")); - std::vector lines = - File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName); - - for (std::string line : lines) - cfg.actorList.push_back(StringHelper::Strip(line, "\r")); - } - else if (std::string(child->Name()) == "ObjectList") - { - std::string fileName = std::string(child->Attribute("File")); - std::vector lines = - File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName); - - for (std::string line : lines) - cfg.objectList.push_back(StringHelper::Strip(line, "\r")); - } - else if (std::string(child->Name()) == "TexturePool") - { - std::string fileName = std::string(child->Attribute("File")); - ReadTexturePool(Path::GetDirectoryName(configFilePath) + "/" + fileName); - } - else if (std::string(child->Name()) == "BGConfig") - { - cfg.bgScreenWidth = child->IntAttribute("ScreenWidth", 320); - cfg.bgScreenHeight = child->IntAttribute("ScreenHeight", 240); - } - } -} - -void Globals::ReadTexturePool(const std::string& texturePoolXmlPath) -{ - tinyxml2::XMLDocument doc; - tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str()); - - if (eResult != tinyxml2::XML_SUCCESS) - { - fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult); - return; - } - - tinyxml2::XMLNode* root = doc.FirstChild(); - - if (root == nullptr) - return; - - for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL; - child = child->NextSiblingElement()) - { - if (std::string(child->Name()) == "Texture") - { - std::string crcStr = std::string(child->Attribute("CRC")); - fs::path texPath = std::string(child->Attribute("Path")); - std::string texName = ""; - - uint32_t crc = strtoul(crcStr.c_str(), NULL, 16); - - cfg.texturePool[crc].path = texPath; - } - } -} - -void Globals::GenSymbolMap(const std::string& symbolMapPath) -{ - auto symbolLines = File::ReadAllLines(symbolMapPath); - - for (std::string symbolLine : symbolLines) - { - auto split = StringHelper::Split(symbolLine, " "); - uint32_t addr = strtoul(split[0].c_str(), NULL, 16); - std::string symbolName = split[1]; - - symbolMap[addr] = symbolName; + delete it.second; } } @@ -177,9 +37,10 @@ void Globals::AddSegment(int32_t segment, ZFile* file) { if (std::find(segments.begin(), segments.end(), segment) == segments.end()) segments.push_back(segment); + if (cfg.segmentRefFiles.find(segment) == cfg.segmentRefFiles.end()) + cfg.segmentRefFiles[segment] = std::vector(); - segmentRefs[segment] = file->GetXmlFilePath().string(); - segmentRefFiles[segment] = file; + cfg.segmentRefFiles[segment].push_back(file); } bool Globals::HasSegment(int32_t segment) @@ -187,21 +48,21 @@ bool Globals::HasSegment(int32_t segment) return std::find(segments.begin(), segments.end(), segment) != segments.end(); } -std::map* Globals::GetExporterMap() +std::map& Globals::GetExporterMap() { static std::map exporters; - return &exporters; + return exporters; } void Globals::AddExporter(std::string exporterName, ExporterSet* exporterSet) { - auto exporters = GetExporterMap(); - (*exporters)[exporterName] = exporterSet; + auto& exporters = GetExporterMap(); + exporters[exporterName] = exporterSet; } ZResourceExporter* Globals::GetExporter(ZResourceType resType) { - auto exporters = *GetExporterMap(); + auto& exporters = GetExporterMap(); if (currentExporter != "" && exporters[currentExporter]->exporters.find(resType) != exporters[currentExporter]->exporters.end()) @@ -212,10 +73,141 @@ ZResourceExporter* Globals::GetExporter(ZResourceType resType) ExporterSet* Globals::GetExporterSet() { - auto exporters = *GetExporterMap(); + auto& exporters = GetExporterMap(); if (currentExporter != "") return exporters[currentExporter]; else return nullptr; -} \ No newline at end of file +} + +bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, + const std::string& expectedType, std::string& declName) +{ + if (segAddress == 0) + { + declName = "NULL"; + return true; + } + + uint8_t segment = GETSEGNUM(segAddress); + uint32_t offset = Seg2Filespace(segAddress, currentFile->baseAddress); + ZSymbol* sym; + + sym = currentFile->GetSymbolResource(offset); + if (sym != nullptr) + { + if (expectedType == "" || expectedType == sym->GetSourceTypeName()) + { + declName = sym->GetName(); + return true; + } + } + sym = currentFile->GetSymbolResource(segAddress); + if (sym != nullptr) + { + if (expectedType == "" || expectedType == sym->GetSourceTypeName()) + { + declName = sym->GetName(); + return true; + } + } + + if (currentFile->IsSegmentedInFilespaceRange(segAddress)) + { + if (currentFile->GetDeclarationPtrName(segAddress, expectedType, declName)) + return true; + } + else if (HasSegment(segment)) + { + for (auto file : cfg.segmentRefFiles[segment]) + { + offset = Seg2Filespace(segAddress, file->baseAddress); + + sym = file->GetSymbolResource(offset); + if (sym != nullptr) + { + if (expectedType == "" || expectedType == sym->GetSourceTypeName()) + { + declName = sym->GetName(); + return true; + } + } + sym = file->GetSymbolResource(segAddress); + if (sym != nullptr) + { + if (expectedType == "" || expectedType == sym->GetSourceTypeName()) + { + declName = sym->GetName(); + return true; + } + } + + if (file->IsSegmentedInFilespaceRange(segAddress)) + { + if (file->GetDeclarationPtrName(segAddress, expectedType, declName)) + return true; + } + } + } + + const auto& symbolFromMap = Globals::Instance->symbolMap.find(segAddress); + if (symbolFromMap != Globals::Instance->symbolMap.end()) + { + declName = "&" + symbolFromMap->second; + return true; + } + + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; +} + +bool Globals::GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize, + ZFile* currentFile, const std::string& expectedType, + std::string& declName) +{ + if (segAddress == 0) + { + declName = "NULL"; + return true; + } + + uint8_t segment = GETSEGNUM(segAddress); + + if (currentFile->IsSegmentedInFilespaceRange(segAddress)) + { + bool addressFound = currentFile->GetDeclarationArrayIndexedName(segAddress, elementSize, + expectedType, declName); + if (addressFound) + return true; + } + else if (HasSegment(segment)) + { + for (auto file : cfg.segmentRefFiles[segment]) + { + if (file->IsSegmentedInFilespaceRange(segAddress)) + { + bool addressFound = file->GetDeclarationArrayIndexedName(segAddress, elementSize, + expectedType, declName); + if (addressFound) + return true; + } + } + } + + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; +} + +ExternalFile::ExternalFile(fs::path nXmlPath, fs::path nOutPath) + : xmlPath{nXmlPath}, outPath{nOutPath} +{ +} + +ExporterSet::~ExporterSet() +{ + for (auto& it : exporters) + { + delete it.second; + } +} diff --git a/tools/ZAPD/ZAPD/Globals.h b/tools/ZAPD/ZAPD/Globals.h index 60c79db12..265f1af24 100644 --- a/tools/ZAPD/ZAPD/Globals.h +++ b/tools/ZAPD/ZAPD/Globals.h @@ -3,6 +3,7 @@ #include #include #include +#include "GameConfig.h" #include "ZFile.h" class ZRoom; @@ -14,36 +15,17 @@ enum class VerbosityLevel VERBOSITY_DEBUG }; -struct TexturePoolEntry -{ - fs::path path = ""; // Path to Shared Texture -}; - -class GameConfig -{ -public: - std::map segmentRefs; - std::map segmentRefFiles; - std::map symbolMap; - std::vector actorList; - std::vector objectList; - std::map texturePool; // Key = CRC - - // ZBackground - uint32_t bgScreenWidth = 320, bgScreenHeight = 240; - - GameConfig() = default; -}; - typedef void (*ExporterSetFunc)(ZFile*); typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode); typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i); -typedef void (*ExporterSetFuncVoid2)(std::string buildMode, ZFileMode& fileMode); +typedef void (*ExporterSetFuncVoid2)(const std::string& buildMode, ZFileMode& fileMode); typedef void (*ExporterSetFuncVoid3)(); class ExporterSet { public: + ~ExporterSet(); + std::map exporters; ExporterSetFuncVoid parseArgsFunc = nullptr; ExporterSetFuncVoid2 parseFileModeFunc = nullptr; @@ -76,25 +58,37 @@ public: bool errorNoOffset = false; bool verboseUnaccounted = false; bool gccCompat = false; + bool forceStatic = false; std::vector files; + std::vector externalFiles; std::vector segments; - std::map segmentRefs; - std::map segmentRefFiles; - ZRoom* lastScene; std::map symbolMap; std::string currentExporter; - static std::map* GetExporterMap(); + static std::map& GetExporterMap(); static void AddExporter(std::string exporterName, ExporterSet* exporterSet); Globals(); - std::string FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress); - void ReadConfigFile(const std::string& configFilePath); - void ReadTexturePool(const std::string& texturePoolXmlPath); - void GenSymbolMap(const std::string& symbolMapPath); + ~Globals(); + void AddSegment(int32_t segment, ZFile* file); bool HasSegment(int32_t segment); + ZResourceExporter* GetExporter(ZResourceType resType); ExporterSet* GetExporterSet(); -}; \ No newline at end of file + + /** + * Search in every file (and the symbol map) for the `segAddress` passed as parameter. + * If the segment of `currentFile` is the same segment of `segAddress`, then that file will be + * used only, otherwise, the search will be performed in every other file. + * The name of that variable will be stored in the `declName` parameter. + * Returns `true` if the address is found. `false` otherwise, + * in which case `declName` will be set to the address formatted as a pointer. + */ + bool GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, + const std::string& expectedType, std::string& declName); + + bool GetSegmentedArrayIndexedName(segptr_t segAddress, size_t elementSize, ZFile* currentFile, + const std::string& expectedType, std::string& declName); +}; diff --git a/tools/ZAPD/ZAPD/ImageBackend.cpp b/tools/ZAPD/ZAPD/ImageBackend.cpp index a8fb900f6..137e326c3 100644 --- a/tools/ZAPD/ZAPD/ImageBackend.cpp +++ b/tools/ZAPD/ZAPD/ImageBackend.cpp @@ -387,11 +387,22 @@ void ImageBackend::SetPalette(const ImageBackend& pal) { for (size_t x = 0; x < pal.width; x++) { + size_t index = y * pal.width + x; + if (index >= paletteSize) + { + /* + * Some TLUTs are bigger than 256 colors. + * For those cases, we will only take the first 256 + * to colorize this CI texture. + */ + return; + } + uint8_t r = pal.pixelMatrix[y][x * bytePerPixel + 0]; uint8_t g = pal.pixelMatrix[y][x * bytePerPixel + 1]; uint8_t b = pal.pixelMatrix[y][x * bytePerPixel + 2]; uint8_t a = pal.pixelMatrix[y][x * bytePerPixel + 3]; - SetPaletteIndex(y * pal.width + x, r, g, b, a); + SetPaletteIndex(index, r, g, b, a); } } } diff --git a/tools/ZAPD/ZAPD/Main.cpp b/tools/ZAPD/ZAPD/Main.cpp index e7fc6fcc7..298ca0262 100644 --- a/tools/ZAPD/ZAPD/Main.cpp +++ b/tools/ZAPD/ZAPD/Main.cpp @@ -20,13 +20,13 @@ #endif #include +#include #include "tinyxml2.h" -using namespace tinyxml2; - extern const char gBuildHash[]; -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode); +bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, + ZFileMode fileMode); void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const fs::path& outPath); void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath); @@ -113,7 +113,7 @@ int main(int argc, char* argv[]) } } - Globals* g = new Globals(); + Globals* g = new Globals; // Parse other "commands" for (int32_t i = 2; i < argc; i++) @@ -141,30 +141,30 @@ int main(int argc, char* argv[]) } else if (arg == "-gsf") // Generate source file during extraction { - Globals::Instance->genSourceFile = std::string(argv[++i]) == "1"; + Globals::Instance->genSourceFile = std::string_view(argv[++i]) == "1"; } else if (arg == "-tm") // Test Mode (enables certain experimental features) { - Globals::Instance->testMode = std::string(argv[++i]) == "1"; + Globals::Instance->testMode = std::string_view(argv[++i]) == "1"; } else if (arg == "-crc" || arg == "--output-crc") // Outputs a CRC file for each extracted texture. { - Globals::Instance->testMode = std::string(argv[++i]) == "1"; + Globals::Instance->testMode = std::string_view(argv[++i]) == "1"; } else if (arg == "-ulzdl") // Use Legacy ZDisplay List { - Globals::Instance->useLegacyZDList = std::string(argv[++i]) == "1"; + Globals::Instance->useLegacyZDList = std::string_view(argv[++i]) == "1"; } else if (arg == "-profile") // Enable profiling { - Globals::Instance->profile = std::string(argv[++i]) == "1"; + Globals::Instance->profile = std::string_view(argv[++i]) == "1"; } else if (arg == "-uer") // Split resources into their individual components (enabled by default) // TODO: We may wish to make this a part of the config file... { - Globals::Instance->useExternalResources = std::string(argv[++i]) == "1"; + Globals::Instance->useExternalResources = std::string_view(argv[++i]) == "1"; } else if (arg == "-tt") // Set texture type { @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) } else if (arg == "-rconf") // Read Config File { - Globals::Instance->ReadConfigFile(argv[++i]); + Globals::Instance->cfg.ReadConfigFile(argv[++i]); } else if (arg == "-eh") // Enable Error Handler { @@ -218,6 +218,10 @@ int main(int argc, char* argv[]) { Globals::Instance->gccCompat = true; } + else if (arg == "-s" || arg == "--static") + { + Globals::Instance->forceStatic = true; + } } // Parse File Mode @@ -258,6 +262,7 @@ int main(int argc, char* argv[]) if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash); + // TODO: switch if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile) { bool procFileModeSuccess = false; @@ -267,39 +272,30 @@ int main(int argc, char* argv[]) if (!procFileModeSuccess) { - if (fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile) + bool parseSuccessful; + + for (auto& extFile : Globals::Instance->cfg.externalFiles) { - bool parseSuccessful = - Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, fileMode); + fs::path externalXmlFilePath = + Globals::Instance->cfg.externalXmlFolder / extFile.xmlPath; + + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + { + printf("Parsing external file from config: '%s'\n", + externalXmlFilePath.c_str()); + } + + parseSuccessful = Parse(externalXmlFilePath, Globals::Instance->baseRomPath, + extFile.outPath, ZFileMode::ExternalFile); if (!parseSuccessful) return 1; } - else if (fileMode == ZFileMode::BuildTexture) - { - TextureType texType = Globals::Instance->texType; - BuildAssetTexture(Globals::Instance->inputPath, texType, - Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildBackground) - { - BuildAssetBackground(Globals::Instance->inputPath, Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildBlob) - { - BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath); - } - else if (fileMode == ZFileMode::BuildOverlay) - { - ZOverlay* overlay = ZOverlay::FromBuild( - Path::GetDirectoryName(Globals::Instance->inputPath.string()), - Path::GetDirectoryName(Globals::Instance->cfgPath.string())); - - if (overlay) - File::WriteAllText(Globals::Instance->outputPath.string(), - overlay->GetSourceOutputCode("")); - } + parseSuccessful = Parse(Globals::Instance->inputPath, Globals::Instance->baseRomPath, + Globals::Instance->outputPath, fileMode); + if (!parseSuccessful) + return 1; } } else if (fileMode == ZFileMode::BuildTexture) @@ -321,18 +317,20 @@ int main(int argc, char* argv[]) ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath), Path::GetDirectoryName(Globals::Instance->cfgPath)); - if (overlay) + if (overlay != nullptr) File::WriteAllText(Globals::Instance->outputPath.string(), overlay->GetSourceOutputCode("")); } + delete g; return 0; } -bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode fileMode) +bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, + ZFileMode fileMode) { - XMLDocument doc; - XMLError eResult = doc.LoadFile(xmlFilePath.string().c_str()); + tinyxml2::XMLDocument doc; + tinyxml2::XMLError eResult = doc.LoadFile(xmlFilePath.string().c_str()); if (eResult != tinyxml2::XML_SUCCESS) { @@ -340,7 +338,7 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode file return false; } - XMLNode* root = doc.FirstChild(); + tinyxml2::XMLNode* root = doc.FirstChild(); if (root == nullptr) { @@ -348,45 +346,78 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode file return false; } - for (XMLElement* child = root->FirstChildElement(); child != NULL; + for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) { - if (std::string(child->Name()) == "File") + if (std::string_view(child->Name()) == "File") { - ZFile* file = new ZFile(fileMode, child, basePath, "", xmlFilePath, false); + ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", xmlFilePath); Globals::Instance->files.push_back(file); + if (fileMode == ZFileMode::ExternalFile) + { + Globals::Instance->externalFiles.push_back(file); + file->isExternalFile = true; + } + } + else if (std::string(child->Name()) == "ExternalFile") + { + const char* xmlPathValue = child->Attribute("XmlPath"); + if (xmlPathValue == nullptr) + { + throw std::runtime_error(StringHelper::Sprintf( + "Parse: Fatal error in '%s'.\n" + "\t Missing 'XmlPath' attribute in `ExternalFile` element.\n", + xmlFilePath.c_str())); + } + const char* outPathValue = child->Attribute("OutPath"); + if (outPathValue == nullptr) + { + throw std::runtime_error(StringHelper::Sprintf( + "Parse: Fatal error in '%s'.\n" + "\t Missing 'OutPath' attribute in `ExternalFile` element.\n", + xmlFilePath.c_str())); + } + + fs::path externalXmlFilePath = + Globals::Instance->cfg.externalXmlFolder / fs::path(xmlPathValue); + fs::path externalOutFilePath = fs::path(outPathValue); + + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + { + printf("Parsing external file: '%s'\n", externalXmlFilePath.c_str()); + } + + // Recursion. What can go wrong? + Parse(externalXmlFilePath, basePath, externalOutFilePath, ZFileMode::ExternalFile); } else { - throw std::runtime_error( - StringHelper::Sprintf("Parse: Fatal error in '%s'.\n\t Found a resource outside of " - "a File element: '%s'\n", - xmlFilePath.c_str(), child->Name())); + throw std::runtime_error(StringHelper::Sprintf( + "Parse: Fatal error in '%s'.\n\t A resource was found outside of " + "a File element: '%s'\n", + xmlFilePath.c_str(), child->Name())); } } - ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); - - if (exporterSet != nullptr && exporterSet->beginXMLFunc != nullptr) - exporterSet->beginXMLFunc(); - - for (ZFile* file : Globals::Instance->files) + if (fileMode != ZFileMode::ExternalFile) { - if (fileMode == ZFileMode::BuildSourceFile) - file->BuildSourceFile(); - else - file->ExtractResources(); + ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); + + if (exporterSet != nullptr && exporterSet->beginXMLFunc != nullptr) + exporterSet->beginXMLFunc(); + + for (ZFile* file : Globals::Instance->files) + { + if (fileMode == ZFileMode::BuildSourceFile) + file->BuildSourceFile(); + else + file->ExtractResources(); + } + + if (exporterSet != nullptr && exporterSet->endXMLFunc != nullptr) + exporterSet->endXMLFunc(); } - if (exporterSet != nullptr && exporterSet->endXMLFunc != nullptr) - exporterSet->endXMLFunc(); - - // All done, free files - for (ZFile* file : Globals::Instance->files) - delete file; - - Globals::Instance->files.clear(); - return true; } @@ -419,7 +450,7 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath) ZBlob* blob = ZBlob::FromFile(blobFilePath.string()); std::string name = outPath.stem().string(); // filename without extension - std::string src = blob->GetSourceOutputCode(name); + std::string src = blob->GetBodySourceCode(); File::WriteAllText(outPath.string(), src); diff --git a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp new file mode 100644 index 000000000..9d16de438 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp @@ -0,0 +1,341 @@ +#include "SkinLimbStructs.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" +#include "ZDisplayList.h" +#include "ZFile.h" + +/* Struct_800A57C0 */ + +Struct_800A57C0::Struct_800A57C0(ZFile* nParent) : ZResource(nParent) +{ +} + +void Struct_800A57C0::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + unk_2 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); + unk_4 = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); + unk_6 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x06); + unk_7 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x07); + unk_8 = BitConverter::ToInt8BE(rawData, rawDataIndex + 0x08); + unk_9 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); +} + +std::string Struct_800A57C0::GetBodySourceCode() const +{ + return StringHelper::Sprintf("0x%02X, %i, %i, %i, %i, %i, 0x%02X", unk_0, unk_2, unk_4, unk_6, + unk_7, unk_8, unk_9); +} + +std::string Struct_800A57C0::GetSourceTypeName() const +{ + return "Struct_800A57C0"; +} + +ZResourceType Struct_800A57C0::GetResourceType() const +{ + // TODO + return ZResourceType::Error; +} + +size_t Struct_800A57C0::GetRawDataSize() const +{ + return 0x0A; +} + +/* Struct_800A598C_2 */ + +Struct_800A598C_2::Struct_800A598C_2(ZFile* nParent) : ZResource(nParent) +{ +} + +void Struct_800A598C_2::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + unk_0 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x00); + x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x02); + y = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x04); + z = BitConverter::ToInt16BE(rawData, rawDataIndex + 0x06); + unk_8 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); +} + +std::string Struct_800A598C_2::GetBodySourceCode() const +{ + return StringHelper::Sprintf("0x%02X, %i, %i, %i, 0x%02X", unk_0, x, y, z, unk_8); +} + +std::string Struct_800A598C_2::GetSourceTypeName() const +{ + return "Struct_800A598C_2"; +} + +ZResourceType Struct_800A598C_2::GetResourceType() const +{ + // TODO + return ZResourceType::Error; +} + +size_t Struct_800A598C_2::GetRawDataSize() const +{ + return 0x0A; +} + +/* Struct_800A598C */ + +Struct_800A598C::Struct_800A598C(ZFile* nParent) : ZResource(nParent) +{ +} + +void Struct_800A598C::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); + unk_4 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x04); + unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); + unk_C = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0C); + + if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + { + uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + for (size_t i = 0; i < unk_0; i++) + { + Struct_800A57C0 unk8_data(parent); + unk8_data.ExtractFromFile(unk_8_Offset); + unk_8_arr.push_back(unk8_data); + + unk_8_Offset += unk8_data.GetRawDataSize(); + } + } + + if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment) + { + uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + for (size_t i = 0; i < unk_2; i++) + { + Struct_800A598C_2 unkC_data(parent); + unkC_data.ExtractFromFile(unk_C_Offset); + unk_C_arr.push_back(unkC_data); + + unk_C_Offset += unkC_data.GetRawDataSize(); + } + } +} + +void Struct_800A598C::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = prefix; + if (name != "") + varPrefix = name; + + if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + { + const auto& res = unk_8_arr.at(0); + std::string unk_8_Str = res.GetDefaultName(varPrefix); + + size_t arrayItemCnt = unk_8_arr.size(); + std::string entryStr = ""; + + for (size_t i = 0; i < arrayItemCnt; i++) + { + auto& child = unk_8_arr[i]; + child.DeclareReferences(varPrefix); + entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); + + if (i < arrayItemCnt - 1) + entryStr += "\n"; + } + + uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(unk_8_Offset); + if (decl == nullptr) + { + parent->AddDeclarationArray(unk_8_Offset, res.GetDeclarationAlignment(), + arrayItemCnt * res.GetRawDataSize(), + res.GetSourceTypeName(), unk_8_Str, arrayItemCnt, entryStr); + } + else + decl->text = entryStr; + } + + if (unk_C != 0 && GETSEGNUM(unk_C) == parent->segment) + { + const auto& res = unk_C_arr.at(0); + std::string unk_C_Str = res.GetDefaultName(varPrefix); + + size_t arrayItemCnt = unk_C_arr.size(); + std::string entryStr = ""; + + for (size_t i = 0; i < arrayItemCnt; i++) + { + auto& child = unk_C_arr[i]; + child.DeclareReferences(varPrefix); + entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); + + if (i < arrayItemCnt - 1) + entryStr += "\n"; + } + + uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(unk_C_Offset); + if (decl == nullptr) + { + parent->AddDeclarationArray(unk_C_Offset, res.GetDeclarationAlignment(), + arrayItemCnt * res.GetRawDataSize(), + res.GetSourceTypeName(), unk_C_Str, arrayItemCnt, entryStr); + } + else + decl->text = entryStr; + } +} + +std::string Struct_800A598C::GetBodySourceCode() const +{ + std::string unk_8_Str; + std::string unk_C_Str; + Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Struct_800A57C0", unk_8_Str); + Globals::Instance->GetSegmentedPtrName(unk_C, parent, "Struct_800A598C_2", unk_C_Str); + + std::string entryStr = StringHelper::Sprintf("\n\t\tARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n", + unk_8_Str.c_str(), unk_C_Str.c_str()); + entryStr += + StringHelper::Sprintf("\t\t%i, %s, %s\n\t", unk_4, unk_8_Str.c_str(), unk_C_Str.c_str()); + + return entryStr; +} + +std::string Struct_800A598C::GetSourceTypeName() const +{ + return "Struct_800A598C"; +} + +ZResourceType Struct_800A598C::GetResourceType() const +{ + // TODO + return ZResourceType::Error; +} + +size_t Struct_800A598C::GetRawDataSize() const +{ + return 0x10; +} + +/* Struct_800A5E28 */ + +Struct_800A5E28::Struct_800A5E28(ZFile* nParent) : ZResource(nParent) +{ +} + +void Struct_800A5E28::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + unk_0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x00); + unk_2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x02); + unk_4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x04); + unk_8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); + + if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) + { + uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); + for (size_t i = 0; i < unk_2; i++) + { + Struct_800A598C unk_4_data(parent); + unk_4_data.ExtractFromFile(unk_4_Offset); + unk_4_arr.push_back(unk_4_data); + + unk_4_Offset += unk_4_data.GetRawDataSize(); + } + } +} + +void Struct_800A5E28::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = prefix; + if (name != "") + varPrefix = name; + + ZResource::DeclareReferences(varPrefix); + + if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) + { + const auto& res = unk_4_arr.at(0); + std::string unk_4_Str = res.GetDefaultName(varPrefix); + + size_t arrayItemCnt = unk_4_arr.size(); + std::string entryStr = ""; + + for (size_t i = 0; i < arrayItemCnt; i++) + { + auto& child = unk_4_arr[i]; + child.DeclareReferences(varPrefix); + entryStr += StringHelper::Sprintf("\t{ %s },", child.GetBodySourceCode().c_str()); + + if (i < arrayItemCnt - 1) + entryStr += "\n"; + } + + uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(unk_4_Offset); + if (decl == nullptr) + { + parent->AddDeclarationArray(unk_4_Offset, res.GetDeclarationAlignment(), + arrayItemCnt * res.GetRawDataSize(), + res.GetSourceTypeName(), unk_4_Str, arrayItemCnt, entryStr); + } + else + decl->text = entryStr; + } + + if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + { + uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + + int32_t dlistLength = ZDisplayList::GetDListLength( + parent->GetRawData(), unk_8_Offset, + Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); + ZDisplayList* unk_8_dlist = new ZDisplayList(parent); + unk_8_dlist->ExtractFromBinary(unk_8_Offset, dlistLength); + + std::string dListStr = + StringHelper::Sprintf("%sSkinLimbDL_%06X", varPrefix.c_str(), unk_8_Offset); + unk_8_dlist->SetName(dListStr); + parent->AddResource(unk_8_dlist); + } +} + +std::string Struct_800A5E28::GetBodySourceCode() const +{ + std::string unk_4_Str; + std::string unk_8_Str; + Globals::Instance->GetSegmentedPtrName(unk_4, parent, "Struct_800A598C", unk_4_Str); + Globals::Instance->GetSegmentedPtrName(unk_8, parent, "Gfx", unk_8_Str); + + std::string entryStr = "\n"; + entryStr += StringHelper::Sprintf("\t%i, ARRAY_COUNTU(%s),\n", unk_0, unk_4_Str.c_str()); + entryStr += StringHelper::Sprintf("\t%s, %s\n", unk_4_Str.c_str(), unk_8_Str.c_str()); + + return entryStr; +} + +std::string Struct_800A5E28::GetSourceTypeName() const +{ + return "Struct_800A5E28"; +} + +ZResourceType Struct_800A5E28::GetResourceType() const +{ + // TODO + return ZResourceType::Error; +} + +size_t Struct_800A5E28::GetRawDataSize() const +{ + return 0x0C; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h new file mode 100644 index 000000000..33edd07ca --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.h @@ -0,0 +1,113 @@ +#pragma once + +#include +#include +#include + +#include "ZResource.h" + +// TODO: check if more types exists +enum class ZLimbSkinType +{ + SkinType_0, // Segment = 0 + SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 + SkinType_5 = 5, // Segment = 0 + SkinType_DList = 11, // Segment = DList address +}; + +class Struct_800A57C0 : public ZResource +{ +public: + Struct_800A57C0(ZFile* nParent); + + void ParseRawData() override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + uint16_t unk_0; + int16_t unk_2; + int16_t unk_4; + int8_t unk_6; + int8_t unk_7; + int8_t unk_8; + uint8_t unk_9; +}; + +class Struct_800A598C_2 : public ZResource +{ +public: + Struct_800A598C_2(ZFile* nParent); + + void ParseRawData() override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + uint8_t unk_0; + int16_t x; + int16_t y; + int16_t z; + uint8_t unk_8; +}; + +class Struct_800A598C : public ZResource +{ +public: + Struct_800A598C(ZFile* nParent); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + uint16_t unk_0; // Length of unk_8 + uint16_t unk_2; // Length of unk_C + uint16_t unk_4; // 0 or 1 // Used as an index for unk_C + segptr_t unk_8; // Struct_800A57C0* + segptr_t unk_C; // Struct_800A598C_2* + + std::vector unk_8_arr; + std::vector unk_C_arr; +}; + +class Struct_800A5E28 : public ZResource +{ +public: + Struct_800A5E28(ZFile* nParent); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + uint16_t unk_0; // Vtx count + uint16_t unk_2; // Length of unk_4 + segptr_t unk_4; // Struct_800A598C* + segptr_t unk_8; // Gfx* + + std::vector unk_4_arr; + // ZDisplayList* unk_8_dlist = nullptr; +}; diff --git a/tools/ZAPD/ZAPD/OutputFormatter.cpp b/tools/ZAPD/ZAPD/OutputFormatter.cpp index 4c92b621e..393ec1936 100644 --- a/tools/ZAPD/ZAPD/OutputFormatter.cpp +++ b/tools/ZAPD/ZAPD/OutputFormatter.cpp @@ -101,9 +101,9 @@ int (*OutputFormatter::StaticWriter())(const char* buf, int count) return &WriteStatic; } -OutputFormatter::OutputFormatter(uint32_t tabSize, uint32_t defaultIndent, uint32_t lineLimit) - : tabSize{tabSize}, lineLimit{lineLimit}, col{0}, nest{0}, nestIndent{defaultIndent}, - currentIndent{defaultIndent}, wordNests(0), wordP{word}, spaceP{space} +OutputFormatter::OutputFormatter(uint32_t tabSize, uint32_t indentation, uint32_t lineLimit) + : tabSize{tabSize}, lineLimit{lineLimit}, col{0}, nest{0}, nestIndent{indentation}, + currentIndent{indentation}, wordNests(0), wordP{word}, spaceP{space} { } diff --git a/tools/ZAPD/ZAPD/OutputFormatter.h b/tools/ZAPD/ZAPD/OutputFormatter.h index b024d958e..28955b1cd 100644 --- a/tools/ZAPD/ZAPD/OutputFormatter.h +++ b/tools/ZAPD/ZAPD/OutputFormatter.h @@ -29,7 +29,7 @@ private: static int WriteStatic(const char* buf, int count); public: - OutputFormatter(uint32_t tabSize = 4, uint32_t defaultIndent = 4, uint32_t lineLimit = 120); + OutputFormatter(uint32_t tabSize = 4, uint32_t indentation = 4, uint32_t lineLimit = 120); int (*StaticWriter())(const char* buf, int count); // Must be `int` due to libgfxd @@ -37,4 +37,4 @@ public: int Write(const std::string& buf); std::string GetOutput(); -}; \ No newline at end of file +}; diff --git a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp b/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp index 0f68c849c..a842a7e7d 100644 --- a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp +++ b/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp @@ -51,7 +51,7 @@ ZOverlay::ZOverlay() entries = std::vector(); } -ZOverlay::ZOverlay(std::string nName) : ZOverlay() +ZOverlay::ZOverlay(const std::string& nName) : ZOverlay() { name = nName; } @@ -251,7 +251,7 @@ ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) std::string ZOverlay::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) { - std::string output = ""; + std::string output; output += ".section .ovl\n"; @@ -286,7 +286,7 @@ std::string ZOverlay::GetSourceOutputCode([[maybe_unused]] const std::string& pr return output; } -SectionType ZOverlay::GetSectionTypeFromStr(std::string sectionName) +SectionType ZOverlay::GetSectionTypeFromStr(const std::string& sectionName) { if (sectionName == ".rel.text" || sectionName == ".text") return SectionType::Text; diff --git a/tools/ZAPD/ZAPD/Overlays/ZOverlay.h b/tools/ZAPD/ZAPD/Overlays/ZOverlay.h index 971a66e84..98ead9013 100644 --- a/tools/ZAPD/ZAPD/Overlays/ZOverlay.h +++ b/tools/ZAPD/ZAPD/Overlays/ZOverlay.h @@ -56,7 +56,7 @@ class ZOverlay public: std::string name; - ZOverlay(std::string nName); + ZOverlay(const std::string& nName); ~ZOverlay(); static ZOverlay* FromBuild(fs::path buildPath, fs::path cfgFolderPath); std::string GetSourceOutputCode(const std::string& prefix); @@ -67,7 +67,7 @@ private: ZOverlay(); - static SectionType GetSectionTypeFromStr(std::string sectionName); + static SectionType GetSectionTypeFromStr(const std::string& sectionName); // static std::string GetOverlayNameFromElf(ELFIO::elfio& reader); ELFIO::Elf_Half FindSymbolInSection(const std::string& curSymName, ELFIO::section* sectionData, diff --git a/tools/ZAPD/ZAPD/ZAnimation.cpp b/tools/ZAPD/ZAPD/ZAnimation.cpp index e0ee26366..9242f657a 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZAnimation.cpp @@ -1,5 +1,7 @@ #include "ZAnimation.h" + #include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" @@ -23,73 +25,15 @@ void ZAnimation::ParseRawData() frameCount = BitConverter::ToInt16BE(parent->GetRawData(), rawDataIndex + 0); } -std::string ZAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - return ""; -} - ZResourceType ZAnimation::GetResourceType() const { return ZResourceType::Animation; } +/* ZNormalAnimation */ + ZNormalAnimation::ZNormalAnimation(ZFile* nParent) : ZAnimation(nParent) { - rotationValues = std::vector(); - rotationIndices = std::vector(); - limit = 0; -} - -std::string ZNormalAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - if (parent != nullptr) - { - std::string defaultPrefix = name.c_str(); - defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables - - std::string headerStr = StringHelper::Sprintf("\n\t{ %i },\n", frameCount); - headerStr += StringHelper::Sprintf("\t%sFrameData,\n", defaultPrefix.c_str()); - headerStr += StringHelper::Sprintf("\t%sJointIndices,\n", defaultPrefix.c_str()); - headerStr += StringHelper::Sprintf("\t%i\n", limit); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()), - headerStr); - - std::string indicesStr = ""; - std::string valuesStr = " "; - const uint8_t lineLength = 14; - const uint8_t offset = 0; - - for (size_t i = 0; i < rotationValues.size(); i++) - { - valuesStr += StringHelper::Sprintf("0x%04X, ", rotationValues[i]); - - if ((i - offset + 1) % lineLength == 0) - valuesStr += "\n "; - } - - for (size_t i = 0; i < rotationIndices.size(); i++) - { - indicesStr += - StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X },", rotationIndices[i].x, - rotationIndices[i].y, rotationIndices[i].z); - - if (i != (rotationIndices.size() - 1)) - indicesStr += "\n"; - } - - parent->AddDeclarationArray(rotationValuesSeg, DeclarationAlignment::Align16, - rotationValues.size() * 2, "static s16", - StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), - rotationValues.size(), valuesStr); - - parent->AddDeclarationArray(rotationIndicesSeg, DeclarationAlignment::Align16, - rotationIndices.size() * 6, "static JointIndex", - StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), - rotationIndices.size(), indicesStr); - } - - return ""; } size_t ZNormalAnimation::GetRawDataSize() const @@ -108,23 +52,26 @@ void ZNormalAnimation::ParseRawData() const uint8_t* data = parent->GetRawData().data(); - rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4) & 0x00FFFFFF; - rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8) & 0x00FFFFFF; + rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4); + rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8); limit = BitConverter::ToInt16BE(data, rawDataIndex + 12); - uint32_t currentPtr = rotationValuesSeg; + rotationValuesOffset = Seg2Filespace(rotationValuesSeg, parent->baseAddress); + rotationIndicesOffset = Seg2Filespace(rotationIndicesSeg, parent->baseAddress); + + uint32_t currentPtr = rotationValuesOffset; // Read the Rotation Values - for (uint32_t i = 0; i < ((rotationIndicesSeg - rotationValuesSeg) / 2); i++) + for (uint32_t i = 0; i < ((rotationIndicesOffset - rotationValuesOffset) / 2); i++) { rotationValues.push_back(BitConverter::ToInt16BE(data, currentPtr)); currentPtr += 2; } - currentPtr = rotationIndicesSeg; + currentPtr = rotationIndicesOffset; // Read the Rotation Indices - for (uint32_t i = 0; i < ((rawDataIndex - rotationIndicesSeg) / 6); i++) + for (uint32_t i = 0; i < ((rawDataIndex - rotationIndicesOffset) / 6); i++) { rotationIndices.push_back(RotationIndex(BitConverter::ToInt16BE(data, currentPtr), BitConverter::ToInt16BE(data, currentPtr + 2), @@ -133,31 +80,71 @@ void ZNormalAnimation::ParseRawData() } } +void ZNormalAnimation::DeclareReferences(const std::string& prefix) +{ + std::string defaultPrefix = prefix.c_str(); + if (name != "") + defaultPrefix = name; + + // replace g prefix with s for local variables + if (defaultPrefix.at(0) == 'g') + defaultPrefix.replace(0, 1, "s"); + + std::string indicesStr = ""; + std::string valuesStr = " "; + const uint8_t lineLength = 14; + const uint8_t offset = 0; + + for (size_t i = 0; i < rotationValues.size(); i++) + { + valuesStr += StringHelper::Sprintf("0x%04X, ", rotationValues[i]); + + if ((i - offset + 1) % lineLength == 0) + valuesStr += "\n "; + } + + parent->AddDeclarationArray(rotationValuesOffset, DeclarationAlignment::Align16, + rotationValues.size() * 2, "s16", + StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), + rotationValues.size(), valuesStr); + + for (size_t i = 0; i < rotationIndices.size(); i++) + { + indicesStr += StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X },", rotationIndices[i].x, + rotationIndices[i].y, rotationIndices[i].z); + + if (i != (rotationIndices.size() - 1)) + indicesStr += "\n"; + } + + parent->AddDeclarationArray(rotationIndicesOffset, DeclarationAlignment::Align16, + rotationIndices.size() * 6, "JointIndex", + StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), + rotationIndices.size(), indicesStr); +} + +std::string ZNormalAnimation::GetBodySourceCode() const +{ + std::string frameDataName; + Globals::Instance->GetSegmentedPtrName(rotationValuesSeg, parent, "s16", frameDataName); + std::string jointIndicesName; + Globals::Instance->GetSegmentedPtrName(rotationIndicesSeg, parent, "JointIndex", + jointIndicesName); + + std::string headerStr = + StringHelper::Sprintf("\n\t{ %i }, %s,\n", frameCount, frameDataName.c_str()); + headerStr += StringHelper::Sprintf("\t%s, %i\n", jointIndicesName.c_str(), limit); + + return headerStr; +} + +/* ZLinkAnimation */ + ZLinkAnimation::ZLinkAnimation(ZFile* nParent) : ZAnimation(nParent) { segmentAddress = 0; } -std::string ZLinkAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - if (parent != nullptr) - { - std::string segSymbol = - segmentAddress == 0 ? - "NULL" : - parent->GetDeclarationName( - segmentAddress, - StringHelper::Sprintf("%sSeg%06X", name.c_str(), segmentAddress)); - std::string headerStr = - StringHelper::Sprintf("\n\t{ %i },\n\t0x%08X\n", frameCount, segmentAddress); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), StringHelper::Sprintf("%s", name.c_str()), - headerStr); - } - - return ""; -} - size_t ZLinkAnimation::GetRawDataSize() const { return 8; @@ -172,8 +159,16 @@ void ZLinkAnimation::ParseRawData() { ZAnimation::ParseRawData(); - const uint8_t* data = parent->GetRawData().data(); - segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4)); + const auto& rawData = parent->GetRawData(); + segmentAddress = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); +} + +std::string ZLinkAnimation::GetBodySourceCode() const +{ + std::string segSymbol; + Globals::Instance->GetSegmentedPtrName(segmentAddress, parent, "", segSymbol); + + return StringHelper::Sprintf("\n\t{ %i }, %s\n", frameCount, segSymbol.c_str()); } /* ZCurveAnimation */ @@ -280,14 +275,6 @@ void ZCurveAnimation::ParseRawData() } } -void ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), - GetSourceTypeName(), name, ""); -} - void ZCurveAnimation::DeclareReferences(const std::string& prefix) { if (refIndex != 0) @@ -308,7 +295,7 @@ void ZCurveAnimation::DeclareReferences(const std::string& prefix) Declaration* decl = parent->GetDeclaration(refIndexOffset); if (decl == nullptr) { - parent->AddDeclarationArray(refIndexOffset, DeclarationAlignment::None, + parent->AddDeclarationArray(refIndexOffset, DeclarationAlignment::Align4, arrayItemCnt * 1, "u8", refIndexStr, arrayItemCnt, entryStr); } @@ -325,7 +312,7 @@ void ZCurveAnimation::DeclareReferences(const std::string& prefix) "%sCurveAnime_%s_%06X", prefix.c_str(), transformDataArr.at(0).GetSourceTypeName().c_str(), transformDataOffset); - std::string entryStr = ""; + std::string entryStr; uint16_t arrayItemCnt = transformDataArr.size(); size_t i = 0; @@ -338,7 +325,7 @@ void ZCurveAnimation::DeclareReferences(const std::string& prefix) Declaration* decl = parent->GetDeclaration(transformDataOffset); if (decl == nullptr) { - parent->AddDeclarationArray(transformDataOffset, DeclarationAlignment::None, + parent->AddDeclarationArray(transformDataOffset, DeclarationAlignment::Align4, arrayItemCnt * transformDataArr.at(0).GetRawDataSize(), transformDataArr.at(0).GetSourceTypeName(), transformDataStr, arrayItemCnt, entryStr); @@ -367,7 +354,7 @@ void ZCurveAnimation::DeclareReferences(const std::string& prefix) Declaration* decl = parent->GetDeclaration(copyValuesOffset); if (decl == nullptr) { - parent->AddDeclarationArray(copyValuesOffset, DeclarationAlignment::None, + parent->AddDeclarationArray(copyValuesOffset, DeclarationAlignment::Align4, arrayItemCnt * 2, "s16", copyValuesStr, arrayItemCnt, entryStr); } @@ -378,81 +365,28 @@ void ZCurveAnimation::DeclareReferences(const std::string& prefix) } } +std::string ZCurveAnimation::GetBodySourceCode() const +{ + std::string refIndexStr; + Globals::Instance->GetSegmentedPtrName(refIndex, parent, "u8", refIndexStr); + std::string transformDataStr; + Globals::Instance->GetSegmentedPtrName(transformData, parent, "TransformData", + transformDataStr); + std::string copyValuesStr; + Globals::Instance->GetSegmentedPtrName(copyValues, parent, "s16", copyValuesStr); + + return StringHelper::Sprintf("\n\t%s,\n\t%s,\n\t%s,\n\t%i, %i\n", refIndexStr.c_str(), + transformDataStr.c_str(), copyValuesStr.c_str(), unk_0C, unk_10); +} + size_t ZCurveAnimation::GetRawDataSize() const { return 0x10; } -std::string ZCurveAnimation::GetSourceOutputCode(const std::string& prefix) +DeclarationAlignment ZCurveAnimation::GetDeclarationAlignment() const { - std::string bodyStr = ""; - uint32_t address = Seg2Filespace(rawDataIndex, parent->baseAddress); - - std::string refIndexStr = "NULL"; - if (refIndex != 0) - { - uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(refIndexOffset); - if (decl == nullptr) - { - refIndexStr = StringHelper::Sprintf("%sCurveAnime_%s_%06X", prefix.c_str(), "Ref", - refIndexOffset); - } - else - { - refIndexStr = decl->varName; - } - } - - std::string transformDataStr = "NULL"; - if (transformData != 0) - { - uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(transformDataOffset); - if (decl == nullptr) - { - transformDataStr = StringHelper::Sprintf( - "%sCurveAnime_%s_%06X", prefix.c_str(), - transformDataArr.at(0).GetSourceTypeName().c_str(), transformDataOffset); - } - else - { - transformDataStr = decl->varName; - } - } - - std::string copyValuesStr = "NULL"; - if (copyValues != 0) - { - uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(copyValuesOffset); - if (decl == nullptr) - { - copyValuesStr = StringHelper::Sprintf("%sCurveAnime_%s_%06X", prefix.c_str(), "Copy", - copyValuesOffset); - } - else - { - copyValuesStr = decl->varName; - } - } - - bodyStr = - StringHelper::Sprintf("\n %s,\n %s,\n %s,\n %i, %i\n", refIndexStr.c_str(), - transformDataStr.c_str(), copyValuesStr.c_str(), unk_0C, unk_10); - - Declaration* decl = parent->GetDeclaration(address); - if (decl == nullptr) - { - parent->AddDeclaration(address, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), name, bodyStr); - } - else - { - decl->text = bodyStr; - } - - return ""; + return DeclarationAlignment::Align16; } std::string ZCurveAnimation::GetSourceTypeName() const @@ -466,14 +400,6 @@ ZLegacyAnimation::ZLegacyAnimation(ZFile* nParent) : ZAnimation(nParent) { } -void ZLegacyAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZAnimation::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name, ""); -} - void ZLegacyAnimation::ParseRawData() { ZAnimation::ParseRawData(); @@ -543,7 +469,7 @@ void ZLegacyAnimation::DeclareReferences(const std::string& prefix) if (GETSEGNUM(jointKey) == parent->segment && !parent->HasDeclaration(jointKeyOffset)) { const auto res = jointKeyArray.at(0); - std::string jointKeyBody = ""; + std::string jointKeyBody; for (size_t i = 0; i < jointKeyArray.size(); i++) { @@ -567,8 +493,10 @@ std::string ZLegacyAnimation::GetBodySourceCode() const { std::string body = "\n"; - std::string frameDataName = parent->GetDeclarationPtrName(frameData); - std::string jointKeyName = parent->GetDeclarationPtrName(jointKey); + std::string frameDataName; + std::string jointKeyName; + Globals::Instance->GetSegmentedPtrName(frameData, parent, "s16", frameDataName); + Globals::Instance->GetSegmentedPtrName(jointKey, parent, "JointKey", jointKeyName); body += StringHelper::Sprintf("\t%i, %i,\n", frameCount, limbCount); body += StringHelper::Sprintf("\t%s,\n", frameDataName.c_str()); @@ -577,20 +505,6 @@ std::string ZLegacyAnimation::GetBodySourceCode() const return body; } -std::string ZLegacyAnimation::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string body = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - if (decl == nullptr || decl->isPlaceholder) - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name, body); - else - decl->text = body; - - return ""; -} - std::string ZLegacyAnimation::GetSourceTypeName() const { return "LegacyAnimationHeader"; diff --git a/tools/ZAPD/ZAPD/ZAnimation.h b/tools/ZAPD/ZAPD/ZAnimation.h index 61662099a..e5b69d3ef 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.h +++ b/tools/ZAPD/ZAPD/ZAnimation.h @@ -23,7 +23,6 @@ public: ZAnimation(ZFile* nParent); - std::string GetSourceOutputCode(const std::string& prefix) override; ZResourceType GetResourceType() const override; protected: @@ -35,17 +34,21 @@ class ZNormalAnimation : public ZAnimation public: std::vector rotationValues; std::vector rotationIndices; - uint32_t rotationValuesSeg; - uint32_t rotationIndicesSeg; - int16_t limit; + segptr_t rotationValuesSeg = 0; + segptr_t rotationIndicesSeg = 0; + offset_t rotationValuesOffset = 0; + offset_t rotationIndicesOffset = 0; + int16_t limit = 0; ZNormalAnimation(ZFile* nParent); - std::string GetSourceOutputCode(const std::string& prefix) override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + size_t GetRawDataSize() const override; std::string GetSourceTypeName() const override; -protected: void ParseRawData() override; }; @@ -56,11 +59,11 @@ public: ZLinkAnimation(ZFile* nParent); - std::string GetSourceOutputCode(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + size_t GetRawDataSize() const override; std::string GetSourceTypeName() const override; -protected: void ParseRawData() override; }; @@ -115,16 +118,17 @@ protected: std::vector copyValuesArr; public: - ZCurveAnimation(); ZCurveAnimation(ZFile* nParent); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + size_t GetRawDataSize() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; + DeclarationAlignment GetDeclarationAlignment() const override; std::string GetSourceTypeName() const override; }; @@ -156,13 +160,10 @@ class ZLegacyAnimation : public ZAnimation public: ZLegacyAnimation(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; - std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; + std::string GetBodySourceCode() const override; std::string GetSourceTypeName() const override; diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index b30c217bb..b1ba3a669 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -1,5 +1,7 @@ #include "ZArray.h" + #include + #include "Globals.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -53,28 +55,56 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader) } } -std::string ZArray::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) +Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bodyStr) { - std::string output = ""; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + ZResource* res = resList.at(0); + Declaration* decl; + if (res->IsExternalResource()) + { + auto filepath = Globals::Instance->outputPath / name; + std::string includePath = StringHelper::Sprintf("%s.%s.inc", filepath.c_str(), + res->GetExternalExtension().c_str()); + decl = parent->AddDeclarationIncludeArray(rawDataIndex, includePath, GetRawDataSize(), + GetSourceTypeName(), name, arrayCnt); + decl->text = bodyStr; + decl->isExternal = true; + } + else + { + decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, arrayCnt, bodyStr); + } + + decl->staticConf = staticConf; + return decl; +} + +std::string ZArray::GetBodySourceCode() const +{ + std::string output; for (size_t i = 0; i < arrayCnt; i++) { - output += resList.at(i)->GetBodySourceCode(); + const auto& res = resList[i]; + output += "\t"; - if (i < arrayCnt - 1) + if (res->GetResourceType() == ZResourceType::Scalar || + res->GetResourceType() == ZResourceType::Vertex) + output += resList.at(i)->GetBodySourceCode(); + else + output += StringHelper::Sprintf("{ %s }", resList.at(i)->GetBodySourceCode().c_str()); + + if (i < arrayCnt - 1 || res->IsExternalResource()) output += ",\n"; } - if (parent != nullptr) - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - resList.at(0)->GetSourceTypeName(), name, arrayCnt, output); - - return ""; -} - -std::string ZArray::GetSourceTypeName() const -{ - return resList.at(0)->GetSourceTypeName(); + return output; } size_t ZArray::GetRawDataSize() const @@ -85,7 +115,21 @@ size_t ZArray::GetRawDataSize() const return size; } +std::string ZArray::GetSourceTypeName() const +{ + return resList.at(0)->GetSourceTypeName(); +} + ZResourceType ZArray::GetResourceType() const { return ZResourceType::Array; } + +DeclarationAlignment ZArray::GetDeclarationAlignment() const +{ + if (resList.size() == 0) + { + return DeclarationAlignment::Align4; + } + return resList.at(0)->GetDeclarationAlignment(); +} diff --git a/tools/ZAPD/ZAPD/ZArray.h b/tools/ZAPD/ZAPD/ZArray.h index 257a9dc58..46a04d732 100644 --- a/tools/ZAPD/ZAPD/ZArray.h +++ b/tools/ZAPD/ZAPD/ZArray.h @@ -14,14 +14,16 @@ public: void ParseXML(tinyxml2::XMLElement* reader) override; - std::string GetSourceOutputCode(const std::string& prefix) override; - - std::string GetSourceTypeName() const override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; + DeclarationAlignment GetDeclarationAlignment() const override; + protected: size_t arrayCnt; std::string childName; diff --git a/tools/ZAPD/ZAPD/ZBackground.cpp b/tools/ZAPD/ZAPD/ZBackground.cpp index ed2968c72..4125f239f 100644 --- a/tools/ZAPD/ZAPD/ZBackground.cpp +++ b/tools/ZAPD/ZAPD/ZBackground.cpp @@ -1,4 +1,5 @@ #include "ZBackground.h" + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" @@ -10,21 +11,12 @@ REGISTER_ZFILENODE(Background, ZBackground); #define JPEG_MARKER 0xFFD8FFE0 #define MARKER_DQT 0xFFDB +#define MARKER_EOI 0xFFD9 ZBackground::ZBackground(ZFile* nParent) : ZResource(nParent) { } -ZBackground::ZBackground(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) - : ZResource(nParent) -{ - rawDataIndex = nRawDataIndex; - name = GetDefaultName(prefix.c_str(), rawDataIndex); - outName = name; - - ParseRawData(); -} - void ZBackground::ParseRawData() { ZResource::ParseRawData(); @@ -36,7 +28,7 @@ void ZBackground::ParseRawData() uint8_t val = rawData.at(rawDataIndex + i); data.push_back(val); - if (BitConverter::ToUInt16BE(rawData, rawDataIndex + i) == 0xFFD9) + if (BitConverter::ToUInt16BE(rawData, rawDataIndex + i) == MARKER_EOI) { data.push_back(rawData.at(rawDataIndex + i + 1)); break; @@ -60,12 +52,6 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam CheckValidJpeg(filepath.generic_string()); } -void ZBackground::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar("", ""); -} - void ZBackground::CheckValidJpeg(const std::string& filepath) { std::string filename = outName; @@ -132,16 +118,28 @@ size_t ZBackground::GetRawDataSize() const return Globals::Instance->cfg.bgScreenHeight * Globals::Instance->cfg.bgScreenWidth * 2; } -void ZBackground::DeclareVar(const std::string& prefix, const std::string& bodyStr) const +Declaration* ZBackground::DeclareVar(const std::string& prefix, + [[maybe_unused]] const std::string& bodyStr) { std::string auxName = name; + std::string auxOutName = outName; - if (name == "") - auxName = GetDefaultName(prefix, rawDataIndex); + if (auxName == "") + auxName = GetDefaultName(prefix); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(), - GetSourceTypeName(), auxName, "SCREEN_WIDTH * SCREEN_HEIGHT / 4", - bodyStr); + if (auxOutName == "") + auxOutName = GetDefaultName(prefix); + + auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem(); + + std::string incStr = + StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str()); + + Declaration* decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), + GetSourceTypeName(), auxName, 0); + decl->arrayItemCntStr = "SCREEN_WIDTH * SCREEN_HEIGHT / 4"; + decl->staticConf = staticConf; + return decl; } bool ZBackground::IsExternalResource() const @@ -177,23 +175,9 @@ std::string ZBackground::GetBodySourceCode() const return bodyStr; } -std::string ZBackground::GetSourceOutputCode(const std::string& prefix) +std::string ZBackground::GetDefaultName(const std::string& prefix) const { - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - -std::string ZBackground::GetDefaultName(const std::string& prefix, uint32_t address) -{ - return StringHelper::Sprintf("%sBackground_%06X", prefix.c_str(), address); + return StringHelper::Sprintf("%sBackground_%06X", prefix.c_str(), rawDataIndex); } std::string ZBackground::GetSourceTypeName() const @@ -205,3 +189,8 @@ ZResourceType ZBackground::GetResourceType() const { return ZResourceType::Background; } + +DeclarationAlignment ZBackground::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align8; +} diff --git a/tools/ZAPD/ZAPD/ZBackground.h b/tools/ZAPD/ZAPD/ZBackground.h index 8071f84cc..e3728bd98 100644 --- a/tools/ZAPD/ZAPD/ZBackground.h +++ b/tools/ZAPD/ZAPD/ZBackground.h @@ -11,25 +11,24 @@ protected: public: ZBackground(ZFile* nParent); - ZBackground(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); + + void ParseBinaryFile(const std::string& inFolder, bool appendOutName); void ParseRawData() override; - void ParseBinaryFile(const std::string& inFolder, bool appendOutName); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void CheckValidJpeg(const std::string& filepath); + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; - size_t GetRawDataSize() const override; - - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const; + void Save(const fs::path& outFolder) override; bool IsExternalResource() const override; - std::string GetExternalExtension() const override; - void Save(const fs::path& outFolder) override; - std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; - static std::string GetDefaultName(const std::string& prefix, uint32_t address); - std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; + std::string GetExternalExtension() const override; + + size_t GetRawDataSize() const override; + DeclarationAlignment GetDeclarationAlignment() const override; + + void CheckValidJpeg(const std::string& filepath); }; diff --git a/tools/ZAPD/ZAPD/ZBlob.cpp b/tools/ZAPD/ZAPD/ZBlob.cpp index 3c187336d..c1f078820 100644 --- a/tools/ZAPD/ZAPD/ZBlob.cpp +++ b/tools/ZAPD/ZAPD/ZBlob.cpp @@ -1,12 +1,12 @@ #include "ZBlob.h" + +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "ZFile.h" -using namespace tinyxml2; - REGISTER_ZFILENODE(Blob, ZBlob); ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent) @@ -14,19 +14,6 @@ ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent) RegisterRequiredAttribute("Size"); } -// Build Source File Mode -ZBlob* ZBlob::BuildFromXML(XMLElement* reader, const std::string& inFolder, bool readFile) -{ - ZBlob* blob = new ZBlob(nullptr); - - blob->ParseXML(reader); - - if (readFile) - blob->blobData = File::ReadAllBytes(inFolder + "/" + blob->name + ".bin"); - - return blob; -} - ZBlob* ZBlob::FromFile(const std::string& filePath) { ZBlob* blob = new ZBlob(nullptr); @@ -49,14 +36,38 @@ void ZBlob::ParseRawData() parent->GetRawData().begin() + rawDataIndex + blobSize); } -std::string ZBlob::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) +Declaration* ZBlob::DeclareVar(const std::string& prefix, + [[maybe_unused]] const std::string& bodyStr) { - std::string sourceOutput = ""; + std::string auxName = name; + std::string auxOutName = outName; + + if (auxName == "") + auxName = GetDefaultName(prefix); + + if (auxOutName == "") + auxOutName = GetDefaultName(prefix); + + std::string path = Path::GetFileNameWithoutExtension(auxOutName); + + std::string assetOutDir = + (Globals::Instance->outputPath / Path::GetFileNameWithoutExtension(GetOutName())).string(); + + std::string incStr = + StringHelper::Sprintf("%s.%s.inc.c", assetOutDir.c_str(), GetExternalExtension().c_str()); + + return parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), + GetSourceTypeName(), auxName, blobData.size()); +} + +std::string ZBlob::GetBodySourceCode() const +{ + std::string sourceOutput; for (size_t i = 0; i < blobData.size(); i += 1) { if (i % 16 == 0) - sourceOutput += " "; + sourceOutput += "\t"; sourceOutput += StringHelper::Sprintf("0x%02X, ", blobData[i]); diff --git a/tools/ZAPD/ZAPD/ZBlob.h b/tools/ZAPD/ZAPD/ZBlob.h index 2f8d31572..86623b511 100644 --- a/tools/ZAPD/ZAPD/ZBlob.h +++ b/tools/ZAPD/ZAPD/ZBlob.h @@ -8,13 +8,14 @@ class ZBlob : public ZResource public: ZBlob(ZFile* nParent); - static ZBlob* BuildFromXML(tinyxml2::XMLElement* reader, const std::string& inFolder, - bool readFile); static ZBlob* FromFile(const std::string& filePath); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; - std::string GetSourceOutputCode(const std::string& prefix) override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; + std::string GetSourceOutputHeader(const std::string& prefix) override; void Save(const fs::path& outFolder) override; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index eb37d71e3..f9c0bf7d6 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -1,6 +1,8 @@ #include "ZCollision.h" -#include + +#include #include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -13,9 +15,6 @@ ZCollisionHeader::ZCollisionHeader(ZFile* nParent) : ZResource(nParent) ZCollisionHeader::~ZCollisionHeader() { - for (WaterBoxHeader* waterBox : waterBoxes) - delete waterBox; - delete camData; } @@ -51,8 +50,16 @@ void ZCollisionHeader::ParseRawData() vertices.reserve(numVerts); polygons.reserve(numPolygons); + uint32_t currentPtr = vtxSegmentOffset; + for (uint16_t i = 0; i < numVerts; i++) - vertices.push_back(VertexEntry(rawData, vtxSegmentOffset + (i * 6))); + { + ZVector vec(parent); + vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); + + currentPtr += vec.GetRawDataSize(); + vertices.push_back(vec); + } for (uint16_t i = 0; i < numPolygons; i++) polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); @@ -74,34 +81,38 @@ void ZCollisionHeader::ParseRawData() polyTypeDefSegmentOffset, polygonTypes.size()); for (uint16_t i = 0; i < numWaterBoxes; i++) - waterBoxes.push_back(new WaterBoxHeader( + waterBoxes.push_back(WaterBoxHeader( rawData, waterBoxSegmentOffset + (i * (Globals::Instance->game == ZGame::OOT_SW97 ? 12 : 16)))); +} - std::string declaration = ""; +void ZCollisionHeader::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); if (waterBoxes.size() > 0) { for (size_t i = 0; i < waterBoxes.size(); i++) { - declaration += StringHelper::Sprintf("\t{ %i, %i, %i, %i, %i, 0x%08X },", - waterBoxes[i]->xMin, waterBoxes[i]->ySurface, - waterBoxes[i]->zMin, waterBoxes[i]->xLength, - waterBoxes[i]->zLength, waterBoxes[i]->properties); + declaration += + StringHelper::Sprintf("\t{ %s },", waterBoxes[i].GetBodySourceCode().c_str()); if (i + 1 < waterBoxes.size()) declaration += "\n"; } - } - if (waterBoxAddress != 0) parent->AddDeclarationArray( - waterBoxSegmentOffset, DeclarationAlignment::None, 16 * waterBoxes.size(), "WaterBox", - StringHelper::Sprintf("%s_waterBoxes_%06X", name.c_str(), waterBoxSegmentOffset), 0, - declaration); + waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox", + StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset), + waterBoxes.size(), declaration); + } if (polygons.size() > 0) { - declaration = ""; + declaration.clear(); for (size_t i = 0; i < polygons.size(); i++) { @@ -113,17 +124,13 @@ void ZCollisionHeader::ParseRawData() declaration += "\n"; } - if (polyAddress != 0) - { - parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::None, polygons.size() * 16, - "CollisionPoly", - StringHelper::Sprintf("%s_polygons_%08X", name.c_str(), polySegmentOffset), 0, - declaration); - } + parent->AddDeclarationArray( + polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", + StringHelper::Sprintf("%s_polygons_%08X", auxName.c_str(), polySegmentOffset), + polygons.size(), declaration); } - declaration = ""; + declaration.clear(); for (size_t i = 0; i < polygonTypes.size(); i++) { declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32, @@ -135,57 +142,71 @@ void ZCollisionHeader::ParseRawData() if (polyTypeDefAddress != 0) parent->AddDeclarationArray( - polyTypeDefSegmentOffset, DeclarationAlignment::None, polygonTypes.size() * 8, + polyTypeDefSegmentOffset, DeclarationAlignment::Align4, polygonTypes.size() * 8, "SurfaceType", - StringHelper::Sprintf("%s_surfaceType_%08X", name.c_str(), polyTypeDefSegmentOffset), 0, - declaration); + StringHelper::Sprintf("%s_surfaceType_%08X", auxName.c_str(), polyTypeDefSegmentOffset), + polygonTypes.size(), declaration); - declaration = ""; + declaration.clear(); if (vertices.size() > 0) { - declaration = ""; + declaration.clear(); for (size_t i = 0; i < vertices.size(); i++) { - declaration += StringHelper::Sprintf("\t{ %6i, %6i, %6i },", vertices[i].x, - vertices[i].y, vertices[i].z); + declaration += + StringHelper::Sprintf("\t{ %s },", vertices[i].GetBodySourceCode().c_str()); if (i < vertices.size() - 1) declaration += "\n"; } + const auto& first = vertices.front(); if (vtxAddress != 0) parent->AddDeclarationArray( - vtxSegmentOffset, DeclarationAlignment::None, vertices.size() * 6, "Vec3s", - StringHelper::Sprintf("%s_vtx_%08X", name.c_str(), vtxSegmentOffset), 0, - declaration); - - declaration = ""; + vtxSegmentOffset, first.GetDeclarationAlignment(), + vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(), + StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset), + vertices.size(), declaration); } +} - declaration = ""; - char waterBoxStr[2048]; - - if (waterBoxAddress != 0) - sprintf(waterBoxStr, "%s_waterBoxes_%06X", name.c_str(), waterBoxSegmentOffset); - else - sprintf(waterBoxStr, "NULL"); +std::string ZCollisionHeader::GetBodySourceCode() const +{ + std::string declaration; declaration += "\n"; - declaration += StringHelper::Sprintf(" { %i, %i, %i },\n { %i, %i, %i },\n", absMinX, - absMinY, absMinZ, absMaxX, absMaxY, absMaxZ); + declaration += StringHelper::Sprintf("\t{ %i, %i, %i },\n", absMinX, absMinY, absMinZ); + declaration += StringHelper::Sprintf("\t{ %i, %i, %i },\n", absMaxX, absMaxY, absMaxZ); - declaration += StringHelper::Sprintf( - " %i,\n %s_vtx_%08X,\n %i,\n %s_polygons_%08X,\n %s_surfaceType_%08X,\n " - "%s_camDataList_%08X,\n %i,\n %s\n", - numVerts, name.c_str(), vtxSegmentOffset, numPolygons, name.c_str(), polySegmentOffset, - name.c_str(), polyTypeDefSegmentOffset, name.c_str(), camDataSegmentOffset, numWaterBoxes, - waterBoxStr); + std::string vtxName; + Globals::Instance->GetSegmentedPtrName(vtxAddress, parent, "Vec3s", vtxName); + declaration += StringHelper::Sprintf("\t%i,\n\t%s,\n", numVerts, vtxName.c_str()); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, DeclarationPadding::Pad16, 44, - GetSourceTypeName(), name, declaration); + std::string polyName; + Globals::Instance->GetSegmentedPtrName(polyAddress, parent, "CollisionPoly", polyName); + declaration += StringHelper::Sprintf("\t%i,\n\t%s,\n", numPolygons, polyName.c_str()); + + std::string surfaceName; + Globals::Instance->GetSegmentedPtrName(polyTypeDefAddress, parent, "SurfaceType", surfaceName); + declaration += StringHelper::Sprintf("\t%s,\n", surfaceName.c_str()); + + std::string camName; + Globals::Instance->GetSegmentedPtrName(camDataAddress, parent, "CamData", camName); + declaration += StringHelper::Sprintf("\t%s,\n", camName.c_str()); + + std::string waterBoxName; + Globals::Instance->GetSegmentedPtrName(waterBoxAddress, parent, "WaterBox", waterBoxName); + declaration += StringHelper::Sprintf("\t%i,\n\t%s\n", numWaterBoxes, waterBoxName.c_str()); + + return declaration; +} + +std::string ZCollisionHeader::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCol_%06X", prefix.c_str(), rawDataIndex); } std::string ZCollisionHeader::GetSourceTypeName() const @@ -217,15 +238,6 @@ PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawData d = BitConverter::ToUInt16BE(data, rawDataIndex + 14); } -VertexEntry::VertexEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - x = BitConverter::ToInt16BE(data, rawDataIndex + 0); - y = BitConverter::ToInt16BE(data, rawDataIndex + 2); - z = BitConverter::ToInt16BE(data, rawDataIndex + 4); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { const uint8_t* data = rawData.data(); @@ -242,12 +254,18 @@ WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t raw properties = BitConverter::ToInt32BE(data, rawDataIndex + 12); } +std::string WaterBoxHeader::GetBodySourceCode() const +{ + return StringHelper::Sprintf("%i, %i, %i, %i, %i, 0x%08X", xMin, ySurface, zMin, xLength, + zLength, properties); +} + CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, const std::vector& rawData, uint32_t rawDataIndex, uint32_t polyTypeDefSegmentOffset, [[maybe_unused]] uint32_t polygonTypesCnt) { - std::string declaration = ""; + std::string declaration; // Parse CameraDataEntries int32_t numElements = (polyTypeDefSegmentOffset - rawDataIndex) / 8; @@ -299,7 +317,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, } parent->AddDeclarationArray( - rawDataIndex, DeclarationAlignment::None, entries.size() * 8, "CamData", + rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData", StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(), declaration); @@ -307,7 +325,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, if (numDataTotal > 0) { - declaration = ""; + declaration.clear(); for (uint32_t i = 0; i < numDataTotal; i++) { CameraPositionData* data = @@ -322,12 +340,21 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg); uint32_t entrySize = numDataTotal * 0x6; parent->AddDeclarationArray( - cameraPosDataIndex, DeclarationAlignment::None, entrySize, "Vec3s", + cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, "Vec3s", StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex), numDataTotal, declaration); } } +CameraDataList::~CameraDataList() +{ + for (auto entry : entries) + delete entry; + + for (auto camPosData : cameraPositionData) + delete camPosData; +} + CameraPositionData::CameraPositionData(const std::vector& rawData, uint32_t rawDataIndex) { x = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 29420646a..d0325bfb9 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -3,6 +3,7 @@ #include "ZFile.h" #include "ZResource.h" #include "ZRoom/ZRoom.h" +#include "ZVector.h" class PolygonEntry { @@ -14,17 +15,14 @@ public: PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); }; -class VertexEntry -{ -public: - int16_t x, y, z; - - VertexEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - class WaterBoxHeader { public: + WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex); + + std::string GetBodySourceCode() const; + +protected: int16_t xMin; int16_t ySurface; int16_t zMin; @@ -32,8 +30,6 @@ public: int16_t zLength; int16_t pad; int32_t properties; - - WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex); }; class CameraPositionData @@ -61,6 +57,7 @@ public: CameraDataList(ZFile* parent, const std::string& prefix, const std::vector& rawData, uint32_t rawDataIndex, uint32_t polyTypeDefSegmentOffset, uint32_t polygonTypesCnt); + ~CameraDataList(); }; class ZCollisionHeader : public ZResource @@ -81,16 +78,20 @@ public: uint32_t vtxSegmentOffset, polySegmentOffset, polyTypeDefSegmentOffset, camDataSegmentOffset, waterBoxSegmentOffset; - std::vector vertices; + std::vector vertices; std::vector polygons; std::vector polygonTypes; - std::vector waterBoxes; - CameraDataList* camData; + std::vector waterBoxes; + CameraDataList* camData = nullptr; ZCollisionHeader(ZFile* nParent); ~ZCollisionHeader(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 5db169077..237481079 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -87,8 +87,7 @@ CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() std::string ZCutscene::GetBodySourceCode() const { - std::string output = ""; - size_t size = 0; + std::string output; uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); @@ -98,7 +97,6 @@ std::string ZCutscene::GetBodySourceCode() const CutsceneCommand* cmd = commands[i]; output += " " + cmd->GenerateSourceCode(curPtr); curPtr += cmd->GetCommandSize(); - size += cmd->GetCommandSize(); } output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); @@ -106,32 +104,6 @@ std::string ZCutscene::GetBodySourceCode() const return output; } -std::string ZCutscene::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - -void ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) const -{ - std::string auxName = name; - - if (auxName == "") - auxName = StringHelper::Sprintf("%sCutsceneData0x%06X", prefix.c_str(), rawDataIndex); - - parent->AddDeclarationArray(getSegmentOffset(), DeclarationAlignment::Align4, - DeclarationPadding::Pad16, GetRawDataSize(), GetSourceTypeName(), - auxName, 0, bodyStr); -} - size_t ZCutscene::GetRawDataSize() const { size_t size = 0; @@ -152,12 +124,6 @@ size_t ZCutscene::GetRawDataSize() const return size; } -void ZCutscene::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar(parent->GetName(), ""); -} - void ZCutscene::ParseRawData() { ZResource::ParseRawData(); @@ -526,10 +492,10 @@ std::string CutsceneCommandSetCameraPos::GetCName() std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; - std::string listStr = ""; - std::string posStr = ""; + std::string listStr; + std::string posStr; if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) { @@ -617,7 +583,7 @@ std::string CutsceneCommandFadeBGM::GetCName() std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); @@ -670,7 +636,7 @@ CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawDa std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); @@ -713,7 +679,7 @@ CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawDa std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); @@ -771,7 +737,7 @@ CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& raw std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); @@ -885,7 +851,7 @@ CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawDa std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); @@ -943,7 +909,7 @@ std::string CutsceneCommandDayTime::GetCName() std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); @@ -994,7 +960,7 @@ std::string CutsceneCommandTextbox::GetCName() std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); @@ -1060,8 +1026,8 @@ CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vectoraction, entries[i]->startFrame, entries[i]->endFrame, entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, @@ -1117,7 +1083,7 @@ std::string CutsceneCommandTerminator::GetCName() std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); @@ -1139,7 +1105,7 @@ CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) { - std::string result = ""; + std::string result; result += StringHelper::Sprintf("CS_END(),\n"); @@ -1193,7 +1159,7 @@ CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vectorAddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, 0, bodyStr); + decl->staticConf = staticConf; + return decl; +} + std::string ZCutsceneBase::GetSourceTypeName() const { return "CutsceneData"; diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 19389a90d..cbb6a78b0 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -413,13 +413,9 @@ class ZCutsceneBase : public ZResource public: ZCutsceneBase(ZFile* nParent); - std::string GetBodySourceCode() const override = 0; - - virtual void DeclareVar(const std::string& prefix, const std::string& bodyStr) const = 0; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetSourceTypeName() const override; - - virtual uint32_t getSegmentOffset() const = 0; }; class ZCutscene : public ZCutsceneBase @@ -431,17 +427,13 @@ public: void ParseRawData() override; std::string GetBodySourceCode() const override; - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const override; - std::string GetSourceOutputCode(const std::string& prefix) override; + size_t GetRawDataSize() const override; - CutsceneCommands GetCommandFromID(int32_t id); - uint32_t getSegmentOffset() const override { return rawDataIndex; } ZResourceType GetResourceType() const override; - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + CutsceneCommands GetCommandFromID(int32_t id); -protected: int32_t numCommands; int32_t endFrame; std::vector commands; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp index 4d3c2af51..d0208bc07 100644 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp @@ -1,4 +1,5 @@ #include "ZCutsceneMM.h" + #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -14,7 +15,7 @@ ZCutsceneMM::~ZCutsceneMM() std::string ZCutsceneMM::GetBodySourceCode() const { - std::string output = ""; + std::string output; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); @@ -22,51 +23,19 @@ std::string ZCutsceneMM::GetBodySourceCode() const { if ((i % 4) == 0) output += "\n "; - output += StringHelper::Sprintf("0x%08X,", data[i]); + output += StringHelper::Sprintf("0x%08X, ", data[i]); } return output; } -std::string ZCutsceneMM::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - -void ZCutsceneMM::DeclareVar(const std::string& prefix, const std::string& bodyStr) const -{ - std::string auxName = name; - - if (auxName == "") - auxName = StringHelper::Sprintf("%sCutsceneData0x%06X", prefix.c_str(), rawDataIndex); - - parent->AddDeclarationArray(getSegmentOffset(), DeclarationAlignment::Align4, GetRawDataSize(), - "s32", auxName, 0, bodyStr); -} - size_t ZCutsceneMM::GetRawDataSize() const { return 8 + data.size() * 4; } -void ZCutsceneMM::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar(parent->GetName(), ""); -} - void ZCutsceneMM::ParseRawData() { - segmentOffset = rawDataIndex; const auto& rawData = parent->GetRawData(); numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h index 91a40e843..41b7de37f 100644 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ b/tools/ZAPD/ZAPD/ZCutsceneMM.h @@ -10,22 +10,16 @@ class ZCutsceneMM : public ZCutsceneBase { public: - uint32_t segmentOffset; - ZCutsceneMM(ZFile* nParent); virtual ~ZCutsceneMM(); std::string GetBodySourceCode() const override; - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const override; - std::string GetSourceOutputCode(const std::string& prefix) override; + size_t GetRawDataSize() const override; - uint32_t getSegmentOffset() const override { return segmentOffset; } void ParseRawData() override; ZResourceType GetResourceType() const override; - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - protected: int32_t numCommands; int32_t endFrame; diff --git a/tools/ZAPD/ZAPD/ZDisplayList.cpp b/tools/ZAPD/ZAPD/ZDisplayList.cpp index 24353d437..63c568422 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.cpp +++ b/tools/ZAPD/ZAPD/ZDisplayList.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "Globals.h" #include "OutputFormatter.h" @@ -17,8 +17,6 @@ REGISTER_ZFILENODE(DList, ZDisplayList); ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent) { - defines = ""; - sceneSegName = ""; lastTexWidth = 0; lastTexHeight = 0; lastTexAddr = 0; @@ -45,21 +43,30 @@ void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDat rawDataIndex = nRawDataIndex; ParseXML(reader); - int32_t rawDataSize = ZDisplayList::GetDListLength( - parent->GetRawData(), rawDataIndex, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - numInstructions = rawDataSize / 8; - ParseRawData(); + // Don't parse raw data of external files + if (parent->GetMode() != ZFileMode::ExternalFile) + { + int32_t rawDataSize = ZDisplayList::GetDListLength( + parent->GetRawData(), rawDataIndex, + Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); + numInstructions = rawDataSize / 8; + ParseRawData(); + } - DeclareVar("", ""); + Declaration* decl = DeclareVar("", ""); + decl->declaredInXml = true; } -ZDisplayList::ZDisplayList(uint32_t nRawDataIndex, int32_t rawDataSize, ZFile* nParent) - : ZDisplayList(nParent) +void ZDisplayList::ExtractFromBinary(uint32_t nRawDataIndex, int32_t rawDataSize) { rawDataIndex = nRawDataIndex; - name = StringHelper::Sprintf("DL_%06X", rawDataIndex); + name = GetDefaultName(parent->GetName()); numInstructions = rawDataSize / 8; + + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + ParseRawData(); } @@ -80,14 +87,20 @@ Declaration* ZDisplayList::DeclareVar([[maybe_unused]] const std::string& prefix const std::string& bodyStr) { Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(), - GetSourceTypeName(), name, 0, bodyStr); + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, numInstructions, bodyStr); decl->isExternal = true; + decl->staticConf = staticConf; return decl; } -void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, std::string prefix, - char* line) +std::string ZDisplayList::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sDL_%06X", prefix.c_str(), rawDataIndex); +} + +void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, + const std::string& prefix, char* line) { switch (opcode) { @@ -259,9 +272,10 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, st sprintf(line, "gsSPBranchLessZraw(%sDlist0x%06X, 0x%02X, 0x%02X),", prefix.c_str(), h & 0x00FFFFFF, (a / 5) | (b / 2), z); - ZDisplayList* nList = new ZDisplayList( - h & 0x00FFFFFF, GetDListLength(parent->GetRawData(), h & 0x00FFFFFF, dListType), - parent); + ZDisplayList* nList = new ZDisplayList(parent); + nList->ExtractFromBinary( + h & 0x00FFFFFF, GetDListLength(parent->GetRawData(), h & 0x00FFFFFF, dListType)); + nList->SetName(nList->GetDefaultName(prefix)); otherDLists.push_back(nList); i++; @@ -277,7 +291,8 @@ void ZDisplayList::ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, st } } -void ZDisplayList::ParseF3DEX(F3DEXOpcode opcode, uint64_t data, std::string prefix, char* line) +void ZDisplayList::ParseF3DEX(F3DEXOpcode opcode, uint64_t data, const std::string& prefix, + char* line) { switch (opcode) { @@ -428,7 +443,7 @@ int32_t ZDisplayList::GetDListLength(const std::vector& rawData, uint32 size_t rawDataSize = rawData.size(); while (true) { - if (ptr > rawDataSize) + if (ptr >= rawDataSize) { throw std::runtime_error(StringHelper::Sprintf( "%s: Fatal error.\n" @@ -470,7 +485,7 @@ bool ZDisplayList::SequenceCheck(std::vector sequence, int32_t sta } int32_t ZDisplayList::OptimizationChecks(int32_t startIndex, std::string& output, - std::string prefix) + const std::string& prefix) { int32_t result = -1; @@ -483,13 +498,8 @@ int32_t ZDisplayList::OptimizationChecks(int32_t startIndex, std::string& output } int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output, - std::string prefix) + [[maybe_unused]] const std::string& prefix) { - if (Globals::Instance->lastScene == nullptr) - { - return -1; - } - std::vector sequence = {F3DZEXOpcode::G_SETTIMG, F3DZEXOpcode::G_SETTILE, F3DZEXOpcode::G_RDPLOADSYNC, F3DZEXOpcode::G_LOADBLOCK, F3DZEXOpcode::G_RDPPIPESYNC, F3DZEXOpcode::G_SETTILE, @@ -507,7 +517,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std uint32_t texAddr, tmem, rtile, fmt, siz, sizB, width, height, width2, height2, pal, cms, cmt, masks, maskt, shifts, shiftt; - std::string texStr = ""; + std::string texStr; // gsDPSetTextureImage { @@ -523,17 +533,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std lastTexSeg = segmentNumber; - ZFile* auxParent = parent; - if (parent->segment != segmentNumber && Globals::Instance->HasSegment(segmentNumber)) - auxParent = Globals::Instance->segmentRefFiles.at(segmentNumber); - - Declaration* decl = auxParent->GetDeclaration(texAddr); - if (Globals::Instance->HasSegment(segmentNumber) && decl != nullptr) - texStr = decl->varName; - else if (lastTexture != nullptr) - texStr = lastTexture->GetName(); - else - texStr = auxParent->GetDeclarationPtrName(data & 0xFFFFFFFF); + Globals::Instance->GetSegmentedPtrName(data & 0xFFFFFFFF, parent, "", texStr); } // gsDPSetTile @@ -602,12 +602,12 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std height2 = (vvv >> 2) + 1; } - std::string fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", + const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", "G_IM_FMT_I"}; - std::string sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; + const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; // output += StringHelper::Sprintf("gsDPLoadTextureBlock(%s, %s, %s, %i, %i, %i, %i, %i, %i, - // %i, %i, %i),", texStr.c_str(), fmtTbl[fmt].c_str(), sizTbl[siz].c_str(), width, height, + // %i, %i, %i),", texStr.c_str(), fmtTbl[fmt], sizTbl[siz].c_str(), width, height, // pal, cms, cmt, masks, maskt, shifts, shiftt); if (siz == 2 && sizB == 0) @@ -615,26 +615,26 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std if (tmem != 0) output += StringHelper::Sprintf( "gsDPLoadMultiBlock_4b(%s, %i, %i, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt].c_str(), width2, height2, pal, cms, - cmt, masks, maskt, shifts, shiftt); + texStr.c_str(), tmem, rtile, fmtTbl[fmt], width2, height2, pal, cms, cmt, masks, + maskt, shifts, shiftt); else output += StringHelper::Sprintf( "gsDPLoadTextureBlock_4b(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), fmtTbl[fmt].c_str(), width2, height2, pal, cms, cmt, masks, - maskt, shifts, shiftt); + texStr.c_str(), fmtTbl[fmt], width2, height2, pal, cms, cmt, masks, maskt, + shifts, shiftt); } else if (siz == 2 && sizB != 0) { if (tmem != 0) output += StringHelper::Sprintf( "gsDPLoadMultiBlock(%s, %i, %i, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt].c_str(), sizTbl[sizB].c_str(), width2, - height2, pal, cms, cmt, masks, maskt, shifts, shiftt); + texStr.c_str(), tmem, rtile, fmtTbl[fmt], sizTbl[sizB], width2, height2, pal, + cms, cmt, masks, maskt, shifts, shiftt); else output += StringHelper::Sprintf( "gsDPLoadTextureBlock(%s, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), fmtTbl[fmt].c_str(), sizTbl[sizB].c_str(), width2, height2, pal, - cms, cmt, masks, maskt, shifts, shiftt); + texStr.c_str(), fmtTbl[fmt], sizTbl[sizB], width2, height2, pal, cms, cmt, + masks, maskt, shifts, shiftt); } else { @@ -647,15 +647,15 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std lastTexSiz = (F3DZEXTexSizes)siz; lastTexLoaded = true; - TextureGenCheck(prefix); + TextureGenCheck(); return -1; } output += StringHelper::Sprintf( "gsDPLoadMultiBlock(%s, %i, %i, %s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - texStr.c_str(), tmem, rtile, fmtTbl[fmt].c_str(), sizTbl[siz].c_str(), width, - height, pal, cms, cmt, masks, maskt, shifts, shiftt); + texStr.c_str(), tmem, rtile, fmtTbl[fmt], sizTbl[siz], width, height, pal, cms, cmt, + masks, maskt, shifts, shiftt); } lastTexAddr = texAddr; @@ -665,7 +665,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std lastTexSiz = (F3DZEXTexSizes)siz; lastTexLoaded = true; - TextureGenCheck(prefix); + TextureGenCheck(); return (int32_t)sequence.size(); } @@ -673,7 +673,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std return -1; } -void ZDisplayList::Opcode_G_DL(uint64_t data, std::string prefix, char* line) +void ZDisplayList::Opcode_G_DL(uint64_t data, const std::string& prefix, char* line) { int32_t pp = (data & 0x00FF000000000000) >> 56; int32_t segNum = GETSEGNUM(data); @@ -713,9 +713,10 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, std::string prefix, char* line) } else { - ZDisplayList* nList = new ZDisplayList( - GETSEGOFFSET(data), GetDListLength(parent->GetRawData(), GETSEGOFFSET(data), dListType), - parent); + ZDisplayList* nList = new ZDisplayList(parent); + nList->ExtractFromBinary(GETSEGOFFSET(data), GetDListLength(parent->GetRawData(), + GETSEGOFFSET(data), dListType)); + nList->SetName(nList->GetDefaultName(prefix)); otherDLists.push_back(nList); } @@ -780,10 +781,10 @@ void ZDisplayList::Opcode_G_MTX(uint64_t data, char* line) else pp = (data & 0x000000FF00000000) >> 32; - std::string matrixRef = ""; + std::string matrixRef; - if (Globals::Instance->symbolMap.find(mm) != Globals::Instance->symbolMap.end()) - matrixRef = StringHelper::Sprintf("&%s", Globals::Instance->symbolMap[mm].c_str()); + if (Globals::Instance->cfg.symbolMap.find(mm) != Globals::Instance->cfg.symbolMap.end()) + matrixRef = StringHelper::Sprintf("&%s", Globals::Instance->cfg.symbolMap[mm].c_str()); else matrixRef = StringHelper::Sprintf("0x%08X", mm); @@ -832,29 +833,28 @@ void ZDisplayList::Opcode_G_VTX(uint64_t data, char* line) StringHelper::Sprintf("0x%08X", segmented), ""); return; } - references.push_back(vtxAddr); + references.push_back(data); { uint32_t currentPtr = Seg2Filespace(data, parent->baseAddress); + Declaration* decl; // Check for vertex intersections from other display lists // TODO: These two could probably be condenced to one... - if (parent->GetDeclarationRanged(vtxAddr + (nn * 16)) != nullptr) + decl = parent->GetDeclarationRanged(vtxAddr + (nn * 16)); + if (decl != nullptr) { - // Declaration* decl = parent->GetDeclarationRanged(vtxAddr + (nn * 16)); - uint32_t addr = parent->GetDeclarationRangedAddress(vtxAddr + (nn * 16)); - int32_t diff = addr - vtxAddr; + int32_t diff = decl->address - vtxAddr; if (diff > 0) nn = diff / 16; else nn = 0; } - if (parent->GetDeclarationRanged(vtxAddr) != nullptr) + decl = parent->GetDeclarationRanged(vtxAddr); + if (decl != nullptr) { - // Declaration* decl = parent->GetDeclarationRanged(vtxAddr); - uint32_t addr = parent->GetDeclarationRangedAddress(vtxAddr); - int32_t diff = addr - vtxAddr; + int32_t diff = decl->address - vtxAddr; if (diff > 0) nn = diff / 16; else @@ -869,8 +869,7 @@ void ZDisplayList::Opcode_G_VTX(uint64_t data, char* line) for (int32_t i = 0; i < nn; i++) { ZVtx vtx(parent); - vtx.SetRawDataIndex(currentPtr); - vtx.ParseRawData(); + vtx.ExtractFromFile(currentPtr); vtxList.push_back(vtx); currentPtr += 16; @@ -899,13 +898,13 @@ void ZDisplayList::Opcode_G_TEXTURE(uint64_t data, char* line) nnnnnnn == 1 ? "G_ON" : "G_OFF"); } -void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* line) +void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, const std::string& prefix, char* line) { int32_t __ = (data & 0x00FF000000000000) >> 48; int32_t www = (data & 0x00000FFF00000000) >> 32; - std::string fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", + const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", "G_IM_FMT_I"}; - std::string sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; + const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; uint32_t fmt = (__ & 0xE0) >> 5; uint32_t siz = (__ & 0x18) >> 3; @@ -913,7 +912,7 @@ void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* lin if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) printf("TextureGenCheck G_SETTIMG\n"); - TextureGenCheck(prefix); // HOTSPOT + TextureGenCheck(); // HOTSPOT lastTexFmt = (F3DZEXTexFormats)fmt; lastTexSiz = (F3DZEXTexSizes)siz; @@ -945,14 +944,15 @@ void ZDisplayList::Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* lin sprintf(texStr, "0x%08lX", data & 0xFFFFFFFF); } - sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt].c_str(), - sizTbl[siz].c_str(), www + 1, texStr); + sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt], sizTbl[siz], www + 1, + texStr); } else { - sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %sTex_%06lX),", fmtTbl[fmt].c_str(), - sizTbl[siz].c_str(), www + 1, Globals::Instance->lastScene->GetName().c_str(), - GETSEGOFFSET(data)); + std::string texName; + Globals::Instance->GetSegmentedPtrName(data, parent, "", texName); + sprintf(line, "gsDPSetTextureImage(%s, %s, %i, %s),", fmtTbl[fmt], sizTbl[siz], www + 1, + texName.c_str()); } } @@ -976,21 +976,21 @@ void ZDisplayList::Opcode_G_SETTILE(uint64_t data, char* line) int32_t bbbb = (data & 0b0000000000000000000000000000000000000000000000000000000011110000) >> 4; int32_t uuuu = (data & 0b0000000000000000000000000000000000000000000000000000000000001111); - std::string fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", + const char* fmtTbl[] = {"G_IM_FMT_RGBA", "G_IM_FMT_YUV", "G_IM_FMT_CI", "G_IM_FMT_IA", "G_IM_FMT_I"}; - std::string sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; + const char* sizTbl[] = {"G_IM_SIZ_4b", "G_IM_SIZ_8b", "G_IM_SIZ_16b", "G_IM_SIZ_32b"}; if (fff == (int32_t)F3DZEXTexFormats::G_IM_FMT_CI) lastCISiz = (F3DZEXTexSizes)ii; lastTexSizTest = (F3DZEXTexSizes)ii; - sprintf(line, "gsDPSetTile(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),", - fmtTbl[fff].c_str(), sizTbl[ii].c_str(), nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, - ssss, dd, bbbb, uuuu); + sprintf(line, "gsDPSetTile(%s, %s, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),", fmtTbl[fff], + sizTbl[ii], nnnnnnnnn, mmmmmmmmm, ttt, pppp, cc, aaaa, ssss, dd, bbbb, uuuu); } -void ZDisplayList::Opcode_G_SETTILESIZE(uint64_t data, std::string prefix, char* line) +void ZDisplayList::Opcode_G_SETTILESIZE(uint64_t data, [[maybe_unused]] const std::string& prefix, + char* line) { int32_t sss = (data & 0x00FFF00000000000) >> 44; int32_t ttt = (data & 0x00000FFF00000000) >> 32; @@ -1024,7 +1024,7 @@ void ZDisplayList::Opcode_G_SETTILESIZE(uint64_t data, std::string prefix, char* if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) printf("TextureGenCheck G_SETTILESIZE\n"); - TextureGenCheck(prefix); + TextureGenCheck(); sprintf(line, "gsDPSetTileSize(%i, %i, %i, %i, %i),", i, sss, ttt, uuu, vvv); } @@ -1061,13 +1061,13 @@ void ZDisplayList::Opcode_G_SETCOMBINE(uint64_t data, char* line) int32_t ab1 = (data & 0b00000000000000000000000000000000000000000000000000000000111000) >> 3; int32_t ad1 = (data & 0b00000000000000000000000000000000000000000000000000000000000111) >> 0; - std::string modesA[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", + const char* modesA[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", "1", "NOISE", "0", "9", "10", "11", "12", "13", "14", "0"}; - std::string modesB[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", + const char* modesB[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", "CENTER", "K4", "8", "9", "10", "11", "12", "13", "14", "0"}; - std::string modesC[] = {"COMBINED", + const char* modesC[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", @@ -1099,21 +1099,20 @@ void ZDisplayList::Opcode_G_SETCOMBINE(uint64_t data, char* line) "29", "30", "0"}; - std::string modesD[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", + const char* modesD[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", "1", "0"}; - std::string modes2[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", + const char* modes2[] = {"COMBINED", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", "1", "0"}; - std::string modes2C[] = {"LOD_FRACTION", "TEXEL0", "TEXEL1", "PRIMITIVE", + const char* modes2C[] = {"LOD_FRACTION", "TEXEL0", "TEXEL1", "PRIMITIVE", "SHADE", "ENVIRONMENT", "PRIM_LOD_FRAC", "0"}; sprintf(line, "gsDPSetCombineLERP(%s, %s, %s, %s, %s, %s, %s, %s,\n %s, %s, " "%s, %s, %s, %s, %s, %s),", - modesA[a0].c_str(), modesB[b0].c_str(), modesC[c0].c_str(), modesD[d0].c_str(), - modes2[aa0].c_str(), modes2[ab0].c_str(), modes2C[ac0].c_str(), modes2[ad0].c_str(), - modesA[a1].c_str(), modesB[b1].c_str(), modesC[c1].c_str(), modesD[d1].c_str(), - modes2[aa1].c_str(), modes2[ab1].c_str(), modes2C[ac1].c_str(), modes2[ad1].c_str()); + modesA[a0], modesB[b0], modesC[c0], modesD[d0], modes2[aa0], modes2[ab0], modes2C[ac0], + modes2[ad0], modesA[a1], modesB[b1], modesC[c1], modesD[d1], modes2[aa1], modes2[ab1], + modes2C[ac1], modes2[ad1]); } void ZDisplayList::Opcode_G_SETPRIMCOLOR(uint64_t data, char* line) @@ -1258,7 +1257,7 @@ void ZDisplayList::Opcode_G_SETOTHERMODE_L(uint64_t data, char* line) G_RM_VISCVG2, G_RM_OPA_CI2}; - std::map str = { + std::map str = { {G_RM_FOG_SHADE_A, "G_RM_FOG_SHADE_A"}, {G_RM_FOG_PRIM_A, "G_RM_FOG_PRIM_A"}, {G_RM_PASS, "G_RM_PASS"}, @@ -1384,60 +1383,49 @@ void ZDisplayList::Opcode_G_SETOTHERMODE_L(uint64_t data, char* line) if (mode2Str == "") { - int32_t remainingFlags = mode2; - if (mode2 & AA_EN) { mode2Str += "AA_EN | "; - remainingFlags ^= AA_EN; } if (mode2 & Z_CMP) { mode2Str += "Z_CMP | "; - remainingFlags ^= Z_CMP; } if (mode2 & Z_UPD) { mode2Str += "Z_UPD | "; - remainingFlags ^= Z_UPD; } if (mode2 & IM_RD) { mode2Str += "IM_RD | "; - remainingFlags ^= IM_RD; } if (mode2 & CLR_ON_CVG) { mode2Str += "CLR_ON_CVG | "; - remainingFlags ^= CLR_ON_CVG; } if (mode2 & CVG_DST_CLAMP) { mode2Str += "CVG_DST_CLAMP | "; - remainingFlags ^= CVG_DST_CLAMP; } if (mode2 & CVG_DST_WRAP) { mode2Str += "CVG_DST_WRAP | "; - remainingFlags ^= CVG_DST_WRAP; } if (mode2 & CVG_DST_FULL) { mode2Str += "CVG_DST_FULL | "; - remainingFlags ^= CVG_DST_FULL; } if (mode2 & CVG_DST_SAVE) { mode2Str += "CVG_DST_SAVE | "; - remainingFlags ^= CVG_DST_SAVE; } int32_t zMode = mode2 & 0xC00; @@ -1445,35 +1433,29 @@ void ZDisplayList::Opcode_G_SETOTHERMODE_L(uint64_t data, char* line) if (zMode == ZMODE_INTER) { mode2Str += "ZMODE_INTER | "; - remainingFlags ^= ZMODE_INTER; } else if (zMode == ZMODE_XLU) { mode2Str += "ZMODE_XLU | "; - remainingFlags ^= ZMODE_XLU; } else if (zMode == ZMODE_DEC) { mode2Str += "ZMODE_DEC | "; - remainingFlags ^= ZMODE_DEC; } if (mode2 & CVG_X_ALPHA) { mode2Str += "CVG_X_ALPHA | "; - remainingFlags ^= CVG_X_ALPHA; } if (mode2 & ALPHA_CVG_SEL) { mode2Str += "ALPHA_CVG_SEL | "; - remainingFlags ^= ALPHA_CVG_SEL; } if (mode2 & FORCE_BL) { mode2Str += "FORCE_BL | "; - remainingFlags ^= FORCE_BL; } int32_t bp = (mode2 >> 28) & 0b11; @@ -1503,14 +1485,15 @@ void ZDisplayList::Opcode_G_SETOTHERMODE_H(uint64_t data, char* line) if (sft == 14) // G_MDSFT_TEXTLUT { - std::string types[] = {"G_TT_NONE", "G_TT_NONE", "G_TT_RGBA16", "G_TT_IA16"}; - sprintf(line, "gsDPSetTextureLUT(%s),", types[dd >> 14].c_str()); + const char* types[] = {"G_TT_NONE", "G_TT_NONE", "G_TT_RGBA16", "G_TT_IA16"}; + sprintf(line, "gsDPSetTextureLUT(%s),", types[dd >> 14]); } else sprintf(line, "gsSPSetOtherMode(0xE3, %i, %i, 0x%08X),", sft, nn + 1, dd); } -void ZDisplayList::Opcode_G_LOADTLUT(uint64_t data, std::string prefix, char* line) +void ZDisplayList::Opcode_G_LOADTLUT(uint64_t data, [[maybe_unused]] const std::string& prefix, + char* line) { int32_t t = (data & 0x0000000007000000) >> 24; int32_t ccc = (data & 0x00000000003FF000) >> 14; @@ -1524,19 +1507,19 @@ void ZDisplayList::Opcode_G_LOADTLUT(uint64_t data, std::string prefix, char* li if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) printf("TextureGenCheck G_LOADTLUT (lastCISiz: %i)\n", (uint32_t)lastCISiz); - TextureGenCheck(prefix); + TextureGenCheck(); sprintf(line, "gsDPLoadTLUTCmd(%i, %i),", t, ccc); } -void ZDisplayList::Opcode_G_ENDDL(std::string prefix, char* line) +void ZDisplayList::Opcode_G_ENDDL([[maybe_unused]] const std::string& prefix, char* line) { sprintf(line, "gsSPEndDisplayList(),"); if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) printf("TextureGenCheck G_ENDDL\n"); - TextureGenCheck(prefix); + TextureGenCheck(); } std::string ZDisplayList::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) @@ -1599,24 +1582,17 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t vtxOffset = Seg2Filespace(seg, self->parent->baseAddress); - std::string vtxName = ""; - // Probably an external asset we are unable to track - if (!Globals::Instance->HasSegment(GETSEGNUM(seg))) + if (GETSEGNUM(seg) == self->parent->segment) { - vtxName = StringHelper::Sprintf("0x%08X", seg); - } - else - { - self->references.push_back(vtxOffset); + Declaration* decl; // Check for vertex intersections from other display lists // TODO: These two could probably be condenced to one... - if (self->parent->GetDeclarationRanged(vtxOffset + (count * 16)) != nullptr) + decl = self->parent->GetDeclarationRanged(vtxOffset + (count * 16)); + if (decl != nullptr) { - // Declaration* decl = self->parent->GetDeclarationRanged(vtxOffset + (count * 16)); - uint32_t addr = self->parent->GetDeclarationRangedAddress(vtxOffset + (count * 16)); - int32_t diff = addr - vtxOffset; + int32_t diff = decl->address - vtxOffset; if (diff > 0) count = diff / 16; @@ -1624,11 +1600,10 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) count = 0; } - if (self->parent->GetDeclarationRanged(vtxOffset) != nullptr) + decl = self->parent->GetDeclarationRanged(vtxOffset); + if (decl != nullptr) { - // Declaration* decl = self->parent->GetDeclarationRanged(vtxOffset); - uint32_t addr = self->parent->GetDeclarationRangedAddress(vtxOffset); - int32_t diff = addr - vtxOffset; + int32_t diff = decl->address - vtxOffset; if (diff > 0) count = diff / 16; @@ -1645,19 +1620,17 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) for (int32_t i = 0; i < count; i++) { ZVtx vtx(self->parent); - vtx.SetRawDataIndex(currentPtr); - vtx.ParseRawData(); + vtx.ExtractFromFile(currentPtr); vtxList.push_back(vtx); currentPtr += 16; } self->vertices[vtxOffset] = vtxList; } - - vtxName = "@r"; } - gfxd_puts(vtxName.c_str()); + self->references.push_back(seg); + gfxd_puts("@r"); return 1; } @@ -1667,7 +1640,6 @@ static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int3 { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t texOffset = Seg2Filespace(seg, self->parent->baseAddress); - uint32_t texSegNum = GETSEGNUM(seg); self->lastTexWidth = width; self->lastTexHeight = height; @@ -1678,21 +1650,10 @@ static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int3 self->lastTexLoaded = true; self->lastTexIsPalette = false; - self->TextureGenCheck(self->curPrefix); + self->TextureGenCheck(); - std::string texName = ""; - - ZFile* auxParent = self->parent; - if (self->parent->segment != texSegNum && Globals::Instance->HasSegment(texSegNum)) - auxParent = Globals::Instance->segmentRefFiles.at(texSegNum); - - Declaration* decl = auxParent->GetDeclaration(texOffset); - if (Globals::Instance->HasSegment(texSegNum) && decl != nullptr) - texName = decl->varName; - else if (self->lastTexture != nullptr) - texName = self->lastTexture->GetName(); - else - texName = auxParent->GetDeclarationPtrName(seg); + std::string texName; + Globals::Instance->GetSegmentedPtrName(seg, self->parent, "", texName); gfxd_puts(texName.c_str()); @@ -1703,7 +1664,6 @@ static int32_t GfxdCallback_Palette(uint32_t seg, [[maybe_unused]] int32_t idx, { ZDisplayList* self = static_cast(gfxd_udata_get()); uint32_t palOffset = Seg2Filespace(seg, self->parent->baseAddress); - uint32_t palSegNum = GETSEGNUM(seg); self->lastTexWidth = sqrt(count); self->lastTexHeight = sqrt(count); @@ -1714,21 +1674,10 @@ static int32_t GfxdCallback_Palette(uint32_t seg, [[maybe_unused]] int32_t idx, self->lastTexLoaded = true; self->lastTexIsPalette = true; - self->TextureGenCheck(self->curPrefix); + self->TextureGenCheck(); - std::string palName = ""; - - ZFile* auxParent = self->parent; - if (self->parent->segment != palSegNum && Globals::Instance->HasSegment(palSegNum)) - auxParent = Globals::Instance->segmentRefFiles.at(palSegNum); - - Declaration* decl = auxParent->GetDeclaration(palOffset); - if (Globals::Instance->HasSegment(palSegNum) && decl != nullptr) - palName = decl->varName; - else if (self->lastTlut != nullptr) - palName = self->lastTlut->GetName(); - else - palName = auxParent->GetDeclarationPtrName(seg); + std::string palName; + Globals::Instance->GetSegmentedPtrName(seg, self->parent, "", palName); gfxd_puts(palName.c_str()); @@ -1741,22 +1690,20 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg) uint32_t dListOffset = GETSEGOFFSET(seg); uint32_t dListSegNum = GETSEGNUM(seg); - if ((dListSegNum <= 6) && Globals::Instance->HasSegment(dListSegNum)) + std::string dListName = ""; + bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Gfx", dListName); + + if (!addressFound && self->parent->segment == dListSegNum) { - ZDisplayList* newDList = new ZDisplayList( + ZDisplayList* newDList = new ZDisplayList(self->parent); + newDList->ExtractFromBinary( dListOffset, - self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType), - self->parent); - newDList->parent = self->parent; + self->GetDListLength(self->parent->GetRawData(), dListOffset, self->dListType)); + newDList->SetName(newDList->GetDefaultName(self->parent->GetName())); self->otherDLists.push_back(newDList); + dListName = newDList->GetName(); } - ZFile* auxParent = self->parent; - if (self->parent->segment != dListSegNum && Globals::Instance->HasSegment(dListSegNum)) - auxParent = Globals::Instance->segmentRefFiles.at(dListSegNum); - - std::string dListName = auxParent->GetDeclarationPtrName(seg); - gfxd_puts(dListName.c_str()); return 1; @@ -1764,30 +1711,26 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg) static int32_t GfxdCallback_Matrix(uint32_t seg) { - std::string mtxName = ""; + std::string mtxName; ZDisplayList* self = static_cast(gfxd_udata_get()); - if (Globals::Instance->symbolMap.find(seg) != Globals::Instance->symbolMap.end()) - mtxName = StringHelper::Sprintf("&%s", Globals::Instance->symbolMap[seg].c_str()); - else if (Globals::Instance->HasSegment(GETSEGNUM(seg))) + bool addressFound = Globals::Instance->GetSegmentedPtrName(seg, self->parent, "Mtx", mtxName); + if (!addressFound && GETSEGNUM(seg) == self->parent->segment) { Declaration* decl = self->parent->GetDeclaration(Seg2Filespace(seg, self->parent->baseAddress)); if (decl == nullptr) { - ZMtx mtx(self->GetName(), Seg2Filespace(seg, self->parent->baseAddress), self->parent); + ZMtx mtx(self->parent); + mtx.SetName(mtx.GetDefaultName(self->GetName())); + mtx.ExtractFromFile(Seg2Filespace(seg, self->parent->baseAddress)); + mtx.DeclareVar(self->GetName(), ""); mtx.GetSourceOutputCode(self->GetName()); self->mtxList.push_back(mtx); mtxName = "&" + mtx.GetName(); } - else - { - mtxName = "&" + decl->varName; - } } - else - mtxName = StringHelper::Sprintf("0x%08X", seg); gfxd_puts(mtxName.c_str()); @@ -1796,7 +1739,7 @@ static int32_t GfxdCallback_Matrix(uint32_t seg) std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) { - std::string sourceOutput = ""; + std::string sourceOutput; if (Globals::Instance->useLegacyZDList) sourceOutput += ProcessLegacy(prefix); @@ -1829,46 +1772,29 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) } } - if (Globals::Instance->lastScene == nullptr) // TODO: Bit of a hack but it works for now... - parent->defines += defines; - // Generate Vertex Declarations for (auto& item : vertices) { - std::string declaration = ""; + std::string declaration; - uint32_t curAddr = item.first; + offset_t curAddr = item.first; + auto& firstVtx = item.second.at(0); for (auto vtx : item.second) { declaration += StringHelper::Sprintf("\t%s,\n", vtx.GetBodySourceCode().c_str()); - - curAddr += vtx.GetRawDataSize(); } - vtxDeclarations[item.first] = declaration; - - if (parent != nullptr) - { - parent->AddDeclarationArray(item.first, DeclarationAlignment::None, - item.second.size() * 16, "static Vtx", - StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), - item.first, item.second.size()), - item.second.size(), declaration); - } + Declaration* decl = parent->AddDeclarationArray( + curAddr, firstVtx.GetDeclarationAlignment(), + item.second.size() * firstVtx.GetRawDataSize(), firstVtx.GetSourceTypeName(), + firstVtx.GetDefaultName(name), item.second.size(), declaration); + decl->isExternal = true; } } - if (Globals::Instance->lastScene != nullptr) - defines += Globals::Instance->lastScene->extDefines; - - if (parent != nullptr) - { - Declaration* decl = DeclareVar("", sourceOutput); - decl->references = references; - // return ""; - // return sourceOutput; - } + Declaration* decl = DeclareVar("", sourceOutput); + decl->references = references; // Iterate through our vertex lists, connect intersecting lists. if (vertices.size() > 0) @@ -1897,9 +1823,6 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) } } - if (Globals::Instance->lastScene == nullptr) // TODO: Bit of a hack but it works for now... - parent->defines += defines; - // Generate Vertex Declarations std::vector vtxKeys; @@ -1911,27 +1834,16 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) { auto& item = vertices[vtxKeys[i]]; - std::string declaration = ""; - - int32_t curAddr = vtxKeys[i]; + std::string declaration; for (auto& vtx : item) - { - if (curAddr != vtxKeys[i]) - declaration += "\n"; - - declaration += StringHelper::Sprintf("\t%s,", vtx.GetBodySourceCode().c_str()); - - curAddr += 16; - } + declaration += StringHelper::Sprintf("\t%s,\n", vtx.GetBodySourceCode().c_str()); // Ensure there's always a trailing line feed to prevent dumb warnings. // Please don't remove this line, unless you somehow made a way to prevent // that warning when building the OoT repo. declaration += "\n"; - vtxDeclarations[vtxKeys[i]] = declaration; - if (parent != nullptr) { std::string vtxName; @@ -1945,12 +1857,8 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) auto filepath = Globals::Instance->outputPath / vtxName; std::string incStr = StringHelper::Sprintf("%s.%s.inc", filepath.c_str(), "vtx"); - parent->AddDeclarationArray(vtxKeys[i], DeclarationAlignment::None, - item.size() * 16, "static Vtx", vtxName, item.size(), - declaration); - Declaration* vtxDecl = parent->AddDeclarationIncludeArray( - vtxKeys[i], incStr, item.size() * 16, "static Vtx", vtxName, item.size()); + vtxKeys[i], incStr, item.size() * 16, "Vtx", vtxName, item.size()); vtxDecl->isExternal = true; } } @@ -1965,7 +1873,7 @@ std::string ZDisplayList::GetSourceOutputCode(const std::string& prefix) std::string ZDisplayList::ProcessLegacy(const std::string& prefix) { char line[4096]; - std::string sourceOutput = ""; + std::string sourceOutput; for (size_t i = 0; i < instructions.size(); i++) { @@ -2005,9 +1913,9 @@ std::string ZDisplayList::ProcessLegacy(const std::string& prefix) return sourceOutput; } -std::string ZDisplayList::ProcessGfxDis(const std::string& prefix) +std::string ZDisplayList::ProcessGfxDis([[maybe_unused]] const std::string& prefix) { - std::string sourceOutput = ""; + std::string sourceOutput; OutputFormatter outputformatter; int32_t dListSize = instructions.size() * sizeof(instructions[0]); @@ -2032,7 +1940,6 @@ std::string ZDisplayList::ProcessGfxDis(const std::string& prefix) else gfxd_target(gfxd_f3dex); - this->curPrefix = prefix; gfxd_udata_set(this); gfxd_execute(); // generate display list sourceOutput += outputformatter.GetOutput(); // write formatted display list @@ -2040,10 +1947,10 @@ std::string ZDisplayList::ProcessGfxDis(const std::string& prefix) return sourceOutput; } -void ZDisplayList::TextureGenCheck(std::string prefix) +void ZDisplayList::TextureGenCheck() { - if (TextureGenCheck(parent, prefix, lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg, - lastTexFmt, lastTexSiz, lastTexLoaded, lastTexIsPalette, this)) + if (TextureGenCheck(lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg, lastTexFmt, + lastTexSiz, lastTexLoaded, lastTexIsPalette, this)) { lastTexAddr = 0; lastTexLoaded = false; @@ -2051,12 +1958,11 @@ void ZDisplayList::TextureGenCheck(std::string prefix) } } -bool ZDisplayList::TextureGenCheck(ZFile* parent, [[maybe_unused]] std::string prefix, - int32_t texWidth, int32_t texHeight, uint32_t texAddr, +bool ZDisplayList::TextureGenCheck(int32_t texWidth, int32_t texHeight, uint32_t texAddr, uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, bool texLoaded, bool texIsPalette, ZDisplayList* self) { - int32_t segmentNumber = GETSEGNUM(texSeg); + uint32_t segmentNumber = GETSEGNUM(texSeg); if (!texIsPalette) self->lastTexture = nullptr; @@ -2070,58 +1976,53 @@ bool ZDisplayList::TextureGenCheck(ZFile* parent, [[maybe_unused]] std::string p if ((texSeg != 0 || texAddr != 0) && texWidth > 0 && texHeight > 0 && texLoaded && Globals::Instance->HasSegment(segmentNumber)) { - if (segmentNumber != SEGMENT_SCENE) + ZFile* auxParent = nullptr; + if (segmentNumber == self->parent->segment) { - if (texAddr < parent->GetRawData().size()) + auxParent = self->parent; + } + else + { + // Try to find a non-external file (ie, one we are actually extracting) + // which has the same segment number we are looking for. + for (auto& otherFile : Globals::Instance->cfg.segmentRefFiles[segmentNumber]) { - ZTexture* tex = parent->GetTextureResource(texAddr); - if (tex != nullptr) - tex->isPalette = texIsPalette; - else + if (!otherFile->isExternalFile) { - tex = new ZTexture(parent); - tex->FromBinary(texAddr, texWidth, texHeight, - TexFormatToTexType(texFmt, texSiz), texIsPalette); - parent->AddTextureResource(texAddr, tex); + auxParent = otherFile; } - - if (!texIsPalette) - self->lastTexture = tex; - else - self->lastTlut = tex; - - return true; } } - else if (Globals::Instance->lastScene != nullptr) + + if (auxParent == nullptr) { - if (Globals::Instance->lastScene->parent->GetDeclaration(texAddr) == nullptr) + // We can't declare the texture in any of the files we are extracting. + return false; + } + + if (auxParent->IsOffsetInFileRange(texAddr)) + { + ZTexture* tex = auxParent->GetTextureResource(texAddr); + if (tex != nullptr) + tex->isPalette = texIsPalette; + else { - ZTexture* tex = Globals::Instance->lastScene->parent->GetTextureResource(texAddr); - if (tex != nullptr) - tex->isPalette = texIsPalette; - else - { - tex = new ZTexture(Globals::Instance->lastScene->parent); - tex->FromBinary(texAddr, texWidth, texHeight, - TexFormatToTexType(texFmt, texSiz), texIsPalette); - - Globals::Instance->lastScene->parent->AddTextureResource(texAddr, tex); - } - - if (!texIsPalette) - self->lastTexture = tex; - else - self->lastTlut = tex; - - auto filepath = Globals::Instance->outputPath / - Path::GetFileNameWithoutExtension(tex->GetName()); - auto filename = StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), - tex->GetExternalExtension().c_str()); - Globals::Instance->lastScene->parent->AddDeclarationIncludeArray( - texAddr, filename, tex->GetRawDataSize(), tex->GetSourceTypeName(), - tex->GetName(), 0); + tex = new ZTexture(auxParent); + tex->ExtractFromBinary(texAddr, texWidth, texHeight, + TexFormatToTexType(texFmt, texSiz), texIsPalette); + auxParent->AddTextureResource(texAddr, tex); } + + if (!texIsPalette) + self->lastTexture = tex; + else + self->lastTlut = tex; + + if (auxParent->GetDeclaration(texAddr) == nullptr) + { + tex->DeclareVar(self->GetName(), ""); + } + return true; } } @@ -2196,3 +2097,8 @@ size_t ZDisplayList::GetRawDataSize() const { return instructions.size() * 8; } + +DeclarationAlignment ZDisplayList::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align8; +} diff --git a/tools/ZAPD/ZAPD/ZDisplayList.h b/tools/ZAPD/ZAPD/ZDisplayList.h index 4098b9712..d53866675 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.h +++ b/tools/ZAPD/ZAPD/ZDisplayList.h @@ -288,14 +288,15 @@ class ZDisplayList : public ZResource protected: static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz); - void ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, std::string prefix, char* line); - void ParseF3DEX(F3DEXOpcode opcode, uint64_t data, std::string prefix, char* line); + void ParseF3DZEX(F3DZEXOpcode opcode, uint64_t data, int32_t i, const std::string& prefix, + char* line); + void ParseF3DEX(F3DEXOpcode opcode, uint64_t data, const std::string& prefix, char* line); // Various Instruction Optimizations bool SequenceCheck(std::vector sequence, int32_t startIndex); - int32_t OptimizationChecks(int32_t startIndex, std::string& output, std::string prefix); + int32_t OptimizationChecks(int32_t startIndex, std::string& output, const std::string& prefix); int32_t OptimizationCheck_LoadTextureBlock(int32_t startIndex, std::string& output, - std::string prefix); + const std::string& prefix); // int32_t OptimizationCheck_LoadMultiBlock(int32_t startIndex, std::string& output, std::string // prefix); @@ -303,7 +304,7 @@ protected: void Opcode_F3DEX_G_SETOTHERMODE_L(uint64_t data, char* line); // Shared Opcodes between F3DZEX and F3DEX - void Opcode_G_DL(uint64_t data, std::string prefix, char* line); + void Opcode_G_DL(uint64_t data, const std::string& prefix, char* line); void Opcode_G_MODIFYVTX(uint64_t data, char* line); void Opcode_G_CULLDL(uint64_t data, char* line); void Opcode_G_TRI1(uint64_t data, char* line); @@ -311,21 +312,19 @@ protected: void Opcode_G_MTX(uint64_t data, char* line); void Opcode_G_VTX(uint64_t data, char* line); void Opcode_G_TEXTURE(uint64_t data, char* line); - void Opcode_G_SETTIMG(uint64_t data, std::string prefix, char* line); + void Opcode_G_SETTIMG(uint64_t data, const std::string& prefix, char* line); void Opcode_G_SETTILE(uint64_t data, char* line); - void Opcode_G_SETTILESIZE(uint64_t data, std::string prefix, char* line); + void Opcode_G_SETTILESIZE(uint64_t data, const std::string& prefix, char* line); void Opcode_G_LOADBLOCK(uint64_t data, char* line); void Opcode_G_SETCOMBINE(uint64_t data, char* line); void Opcode_G_SETPRIMCOLOR(uint64_t data, char* line); void Opcode_G_SETOTHERMODE_L(uint64_t data, char* line); void Opcode_G_SETOTHERMODE_H(uint64_t data, char* line); - void Opcode_G_LOADTLUT(uint64_t data, std::string prefix, char* line); - void Opcode_G_ENDDL(std::string prefix, char* line); + void Opcode_G_LOADTLUT(uint64_t data, const std::string& prefix, char* line); + void Opcode_G_ENDDL(const std::string& prefix, char* line); public: - std::string sceneSegName; std::vector instructions; - std::string curPrefix; int32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg; F3DZEXTexFormats lastTexFmt; @@ -336,36 +335,34 @@ public: DListType dListType; std::map> vertices; - std::map vtxDeclarations; std::vector otherDLists; ZTexture* lastTexture = nullptr; ZTexture* lastTlut = nullptr; - std::vector references; - - std::string defines; // Hack for special cases where vertex arrays intersect... + std::vector references; std::vector mtxList; ZDisplayList(ZFile* nParent); - ZDisplayList(uint32_t rawDataIndex, int32_t rawDataSize, ZFile* nParent); ~ZDisplayList(); void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + void ExtractFromBinary(uint32_t nRawDataIndex, int32_t rawDataSize); void ParseRawData() override; - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr); + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetDefaultName(const std::string& prefix) const override; - void TextureGenCheck(std::string prefix); - static bool TextureGenCheck(ZFile* parent, std::string prefix, int32_t texWidth, - int32_t texHeight, uint32_t texAddr, uint32_t texSeg, - F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, bool texLoaded, - bool texIsPalette, ZDisplayList* self); + void TextureGenCheck(); + static bool TextureGenCheck(int32_t texWidth, int32_t texHeight, uint32_t texAddr, + uint32_t texSeg, F3DZEXTexFormats texFmt, F3DZEXTexSizes texSiz, + bool texLoaded, bool texIsPalette, ZDisplayList* self); static int32_t GetDListLength(const std::vector& rawData, uint32_t rawDataIndex, DListType dListType); size_t GetRawDataSize() const override; + DeclarationAlignment GetDeclarationAlignment() const override; std::string GetSourceOutputHeader(const std::string& prefix) override; std::string GetSourceOutputCode(const std::string& prefix) override; std::string ProcessLegacy(const std::string& prefix); diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index 3709771b8..7cbfeba88 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -1,14 +1,18 @@ #include "ZFile.h" -#include -#include + #include #include +#include #include + #include "Globals.h" #include "OutputFormatter.h" +#include "Utils/BinaryWriter.h" #include "Utils/Directory.h" #include "Utils/File.h" +#include "Utils/MemoryStream.h" #include "Utils/Path.h" +#include "Utils/StringHelper.h" #include "ZAnimation.h" #include "ZArray.h" #include "ZBackground.h" @@ -26,8 +30,6 @@ #include "ZVector.h" #include "ZVtx.h" -using namespace tinyxml2; - ZFile::ZFile() { resources = std::vector(); @@ -39,13 +41,15 @@ ZFile::ZFile() rangeEnd = 0xFFFFFFFF; } -ZFile::ZFile(std::string nName) : ZFile() +ZFile::ZFile(const fs::path& nOutPath, const std::string& nName) : ZFile() { name = nName; + outName = nName; + outputPath = nOutPath; } -ZFile::ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - std::string filename, const fs::path& nXmlFilePath, bool placeholderMode) +ZFile::ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, + const fs::path& nOutPath, const std::string& filename, const fs::path& nXmlFilePath) : ZFile() { xmlFilePath = nXmlFilePath; @@ -54,8 +58,16 @@ ZFile::ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBase else basePath = nBasePath; - ParseXML(mode, reader, filename, placeholderMode); - DeclareResourceSubReferences(); + if (nOutPath == "") + outputPath = Directory::GetCurrentDirectory(); + else + outputPath = nOutPath; + + mode = nMode; + + ParseXML(reader, filename); + if (mode != ZFileMode::ExternalFile) + DeclareResourceSubReferences(); } ZFile::~ZFile() @@ -69,11 +81,17 @@ ZFile::~ZFile() { delete d.second; } + + for (auto sym : symbolResources) + { + delete sym.second; + } } -void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, - [[maybe_unused]] bool placeholderMode) +void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) { + assert(mode != ZFileMode::Invalid); + if (filename == "") name = reader->Attribute("Name"); else @@ -89,11 +107,11 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, const char* gameStr = reader->Attribute("Game"); if (reader->Attribute("Game") != nullptr) { - if (std::string(gameStr) == "MM") + if (std::string_view(gameStr) == "MM") Globals::Instance->game = ZGame::MM_RETAIL; - else if (std::string(gameStr) == "SW97" || std::string(gameStr) == "OOTSW97") + else if (std::string_view(gameStr) == "SW97" || std::string_view(gameStr) == "OOTSW97") Globals::Instance->game = ZGame::OOT_SW97; - else if (std::string(gameStr) == "OOT") + else if (std::string_view(gameStr) == "OOT") Globals::Instance->game = ZGame::OOT_RETAIL; else throw std::runtime_error( @@ -109,28 +127,67 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, if (reader->Attribute("RangeEnd") != nullptr) rangeEnd = StringHelper::StrToL(reader->Attribute("RangeEnd"), 16); - // Commented until ZArray doesn't use a ZFile to parse it's contents anymore. - /* - if (reader->Attribute("Segment") == nullptr) - throw std::runtime_error(StringHelper::Sprintf( - "ZFile::ParseXML: Error in '%s'.\n" - "\t Missing 'Segment' attribute in File node. \n", - name.c_str())); - */ + if (rangeStart > rangeEnd) + throw std::runtime_error("Error: RangeStart must be before than RangeEnd."); - if (reader->Attribute("Segment") != nullptr) + const char* segmentXml = reader->Attribute("Segment"); + if (segmentXml != nullptr) { - segment = StringHelper::StrToL(reader->Attribute("Segment"), 10); - Globals::Instance->AddSegment(segment, this); + if (!StringHelper::HasOnlyDigits(segmentXml)) + { + throw std::runtime_error(StringHelper::Sprintf( + "error: Invalid segment value '%s': must be a decimal between 0 and 15 inclusive", + segmentXml)); + } + + segment = StringHelper::StrToL(segmentXml, 10); + if (segment > 15) + { + if (segment == 128) + { +#ifdef DEPRECATION_ON + fprintf(stderr, "warning: segment 128 is deprecated.\n\tRemove " + "'Segment=\"128\"' from the xml to use virtual addresses\n"); +#endif + } + else + { + throw std::runtime_error( + StringHelper::Sprintf("error: invalid segment value '%s': must be a decimal " + "number between 0 and 15 inclusive", + segmentXml)); + } + } + } + Globals::Instance->AddSegment(segment, this); + + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + { + if (segment == 0x80) + { + printf("File '%s' using virtual addresses.\n", GetName().c_str()); + } + else + { + printf("File '%s' using segment %X.\n", GetName().c_str(), segment); + } } - if (mode == ZFileMode::Extract) + if (mode == ZFileMode::Extract || mode == ZFileMode::ExternalFile) { if (!File::Exists((basePath / name).string())) throw std::runtime_error( StringHelper::Sprintf("Error! File %s does not exist.", (basePath / name).c_str())); rawData = File::ReadAllBytes((basePath / name).string()); + + /* + * TODO: In OoT repo ovl_Boss_Sst has a wrong RangeEnd (0xAD40 instead of 0xAD70), + * so uncommenting the following produces wrong behavior. + * If somebody fixes that in OoT repo, uncomment this. I'm too tired of fixing XMLs. + */ + // if (reader->Attribute("RangeEnd") == nullptr) + // rangeEnd = rawData.size(); } std::unordered_set nameSet; @@ -140,16 +197,13 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, auto nodeMap = *GetNodeMap(); uint32_t rawDataIndex = 0; - for (XMLElement* child = reader->FirstChildElement(); child != nullptr; + for (tinyxml2::XMLElement* child = reader->FirstChildElement(); child != nullptr; child = child->NextSiblingElement()) { const char* nameXml = child->Attribute("Name"); const char* outNameXml = child->Attribute("OutName"); const char* offsetXml = child->Attribute("Offset"); - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) - printf("%s: 0x%06X\n", nameXml, rawDataIndex); - // Check for repeated attributes. if (offsetXml != nullptr) { @@ -172,6 +226,10 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, throw std::runtime_error( StringHelper::Sprintf("Error no offset specified for %s", nameXml)); } + + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) + printf("%s: 0x%06X\n", nameXml, rawDataIndex); + if (outNameXml != nullptr) { if (outNameSet.find(outNameXml) != outNameSet.end()) @@ -199,18 +257,27 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, { ZResource* nRes = nodeMap[nodeName](this); - if (mode == ZFileMode::Extract) + if (mode == ZFileMode::Extract || mode == ZFileMode::ExternalFile) nRes->ExtractFromXML(child, rawDataIndex); - auto resType = nRes->GetResourceType(); - if (resType == ZResourceType::Texture) + switch (nRes->GetResourceType()) + { + case ZResourceType::Texture: AddTextureResource(rawDataIndex, static_cast(nRes)); - else - resources.push_back(nRes); + break; + + case ZResourceType::Symbol: + AddSymbolResource(rawDataIndex, static_cast(nRes)); + break; + + default: + AddResource(nRes); + break; + } rawDataIndex += nRes->GetRawDataSize(); } - else if (std::string(child->Name()) == "File") + else if (std::string_view(child->Name()) == "File") { throw std::runtime_error(StringHelper::Sprintf( "ZFile::ParseXML: Error in '%s'.\n\t Can't declare a File inside a File.\n", @@ -236,21 +303,13 @@ void ZFile::DeclareResourceSubReferences() void ZFile::BuildSourceFile() { - if (!Directory::Exists(Globals::Instance->outputPath)) - Directory::CreateDirectory(Globals::Instance->outputPath.string()); + if (mode == ZFileMode::ExternalFile) + return; - GenerateSourceFiles(Globals::Instance->outputPath); -} + if (!Directory::Exists(outputPath)) + Directory::CreateDirectory(outputPath); -std::string ZFile::GetVarName(uint32_t address) -{ - for (std::pair pair : declarations) - { - if (pair.first == address) - return pair.second->varName; - } - - return ""; + GenerateSourceFiles(); } std::string ZFile::GetName() const @@ -258,6 +317,11 @@ std::string ZFile::GetName() const return name; } +ZFileMode ZFile::GetMode() const +{ + return mode; +} + const fs::path& ZFile::GetXmlFilePath() const { return xmlFilePath; @@ -270,11 +334,14 @@ const std::vector& ZFile::GetRawData() const void ZFile::ExtractResources() { - if (!Directory::Exists(Globals::Instance->outputPath)) - Directory::CreateDirectory(Globals::Instance->outputPath.string()); + if (mode == ZFileMode::ExternalFile) + return; - if (!Directory::Exists(GetSourceOutputFolderPath().string())) - Directory::CreateDirectory(GetSourceOutputFolderPath().string()); + if (!Directory::Exists(outputPath)) + Directory::CreateDirectory(outputPath); + + if (!Directory::Exists(GetSourceOutputFolderPath())) + Directory::CreateDirectory(GetSourceOutputFolderPath()); for (size_t i = 0; i < resources.size(); i++) resources[i]->ParseRawDataLate(); @@ -282,7 +349,7 @@ void ZFile::ExtractResources() resources[i]->DeclareReferencesLate(name); if (Globals::Instance->genSourceFile) - GenerateSourceFiles(Globals::Instance->outputPath); + GenerateSourceFiles(); MemoryStream* memStream = new MemoryStream(); BinaryWriter writer = BinaryWriter(memStream); @@ -297,12 +364,10 @@ void ZFile::ExtractResources() if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) printf("Saving resource %s\n", res->GetName().c_str()); - res->CalcHash(); - res->Save(Globals::Instance->outputPath.string()); + res->Save(outputPath); // Check if we have an exporter "registered" for this resource type ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType()); - if (exporter != nullptr) exporter->Save(res, Globals::Instance->outputPath.string(), &writer); } @@ -350,62 +415,45 @@ std::vector ZFile::GetResourcesOfType(ZResourceType resType) return resList; } -Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, size_t size, - std::string varType, std::string varName, std::string body) +Declaration* ZFile::AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size, + const std::string& varType, const std::string& varName, + const std::string& body) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; - Declaration* decl = new Declaration(alignment, size, varType, varName, false, body); - declarations[address] = decl; + Declaration* decl = GetDeclaration(address); + if (decl == nullptr) + { + decl = new Declaration(address, alignment, size, varType, varName, false, body); + declarations[address] = decl; + } + else + { + decl->alignment = alignment; + decl->size = size; + decl->varType = varType; + decl->varName = varName; + decl->text = body; + } return decl; } -Declaration* ZFile::AddDeclaration(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, size_t size, std::string varType, - std::string varName, std::string body) +Declaration* ZFile::AddDeclarationArray(offset_t address, DeclarationAlignment alignment, + size_t size, const std::string& varType, + const std::string& varName, size_t arrayItemCnt, + const std::string& body) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - - declarations[address] = - new Declaration(alignment, padding, size, varType, varName, false, body); - return declarations[address]; -} - -Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - size_t size, std::string varType, std::string varName, - size_t arrayItemCnt, std::string body) -{ - return AddDeclarationArray(address, alignment, DeclarationPadding::None, size, varType, varName, - arrayItemCnt, body); -} - -Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - size_t size, std::string varType, std::string varName, - std::string arrayItemCntStr, std::string body) -{ - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - - declarations[address] = - new Declaration(alignment, size, varType, varName, true, arrayItemCntStr, body); - return declarations[address]; -} - -Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, size_t size, - std::string varType, std::string varName, - size_t arrayItemCnt, std::string body) -{ - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; Declaration* decl = GetDeclaration(address); if (decl == nullptr) { decl = - new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body); + new Declaration(address, alignment, size, varType, varName, true, arrayItemCnt, body); declarations[address] = decl; } else @@ -413,27 +461,55 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a if (decl->isPlaceholder) decl->varName = varName; decl->alignment = alignment; - decl->padding = padding; decl->size = size; decl->varType = varType; decl->isArray = true; decl->arrayItemCnt = arrayItemCnt; - if (body != "" && decl->text == "") - decl->text = body; + decl->text = body; } return decl; } -Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address) +Declaration* ZFile::AddDeclarationArray(offset_t address, DeclarationAlignment alignment, + size_t size, const std::string& varType, + const std::string& varName, + const std::string& arrayItemCntStr, const std::string& body) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - Declaration* decl; + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; + Declaration* decl = GetDeclaration(address); + if (decl == nullptr) + { + decl = new Declaration(address, alignment, size, varType, varName, true, arrayItemCntStr, + body); + declarations[address] = decl; + } + else + { + decl->alignment = alignment; + decl->size = size; + decl->varType = varType; + decl->varName = varName; + decl->isArray = true; + decl->arrayItemCntStr = arrayItemCntStr; + decl->text = body; + } + return decl; +} + +Declaration* ZFile::AddDeclarationPlaceholder(offset_t address, const std::string& varName) +{ + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; + + Declaration* decl; if (declarations.find(address) == declarations.end()) { - decl = new Declaration(DeclarationAlignment::None, 0, "", "", false, ""); + decl = new Declaration(address, DeclarationAlignment::Align4, 0, "", varName, false, ""); decl->isPlaceholder = true; declarations[address] = decl; } @@ -443,114 +519,165 @@ Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address) return decl; } -Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address, std::string varName) +Declaration* ZFile::AddDeclarationInclude(offset_t address, const std::string& includePath, + size_t size, const std::string& varType, + const std::string& varName) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - Declaration* decl; + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; - if (declarations.find(address) == declarations.end()) + Declaration* decl = GetDeclaration(address); + if (decl == nullptr) { - decl = new Declaration(DeclarationAlignment::None, 0, "", varName, false, ""); - decl->isPlaceholder = true; + decl = new Declaration(address, includePath, size, varType, varName); declarations[address] = decl; } else - decl = declarations[address]; - + { + decl->includePath = includePath; + decl->size = size; + decl->varType = varType; + decl->varName = varName; + } return decl; } -Declaration* ZFile::AddDeclarationInclude(uint32_t address, std::string includePath, size_t size, - std::string varType, std::string varName) +Declaration* ZFile::AddDeclarationIncludeArray(offset_t address, std::string& includePath, + size_t size, const std::string& varType, + const std::string& varName, size_t arrayItemCnt) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - - if (declarations.find(address) == declarations.end()) - declarations[address] = new Declaration(includePath, size, varType, varName); - - return declarations[address]; -} - -Declaration* ZFile::AddDeclarationIncludeArray(uint32_t address, std::string includePath, - size_t size, std::string varType, - std::string varName, size_t arrayItemCnt) -{ - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); + bool validOffset = AddDeclarationChecks(address, varName); + if (!validOffset) + return nullptr; if (StringHelper::StartsWith(includePath, "assets/extracted/")) includePath = "assets/" + StringHelper::Split(includePath, "assets/extracted/")[1]; if (StringHelper::StartsWith(includePath, "assets/custom/")) includePath = "assets/" + StringHelper::Split(includePath, "assets/custom/")[1]; - auto declCheck = declarations.find(address); - - if (declCheck != declarations.end()) + Declaration* decl = GetDeclaration(address); + if (decl == nullptr) { - declCheck->second->includePath = includePath; - declCheck->second->varType = varType; - declCheck->second->varName = varName; - declCheck->second->size = size; - declCheck->second->isArray = true; - declCheck->second->arrayItemCnt = arrayItemCnt; - - return declCheck->second; - } - else - { - Declaration* decl = new Declaration(includePath, size, varType, varName); + decl = new Declaration(address, includePath, size, varType, varName); decl->isArray = true; decl->arrayItemCnt = arrayItemCnt; declarations[address] = decl; - return declarations[address]; } + else + { + decl->includePath = includePath; + decl->varType = varType; + decl->varName = varName; + decl->size = size; + decl->isArray = true; + decl->arrayItemCnt = arrayItemCnt; + } + return decl; } -void ZFile::AddDeclarationDebugChecks(uint32_t address) +bool ZFile::AddDeclarationChecks(uint32_t address, const std::string& varName) { assert(GETSEGNUM(address) == 0); -#ifdef _DEBUG + assert(varName != ""); +#ifdef DEVELOPMENT if (address == 0x0000) { - int32_t bp = 0; + [[maybe_unused]] int32_t bp = 0; } #endif + + if (!IsOffsetInFileRange(address)) + { + fprintf(stderr, + "%s: Warning in %s\n" + "\t Tried to declare a variable outside of this file's range. Ignoring...\n" + "\t\t Variable's name: %s\n" + "\t\t Variable's offset: 0x%06X\n", + __PRETTY_FUNCTION__, name.c_str(), varName.c_str(), address); + return false; + } + + return true; } -std::string ZFile::GetDeclarationName(uint32_t address) const -{ - return GetDeclarationName(address, - "ERROR_COULD_NOT_FIND_DECLARATION"); // Note: For now that default - // message is just for testing -} - -std::string ZFile::GetDeclarationName(uint32_t address, std::string defaultResult) const -{ - Declaration* decl = GetDeclaration(address); - if (decl != nullptr) - return decl->varName; - - return defaultResult; -} - -std::string ZFile::GetDeclarationPtrName(segptr_t segAddress) const +bool ZFile::GetDeclarationPtrName(segptr_t segAddress, const std::string& expectedType, + std::string& declName) const { if (segAddress == 0) - return "NULL"; + { + declName = "NULL"; + return true; + } - Declaration* decl = GetDeclaration(Seg2Filespace(segAddress, baseAddress)); + uint32_t offset = Seg2Filespace(segAddress, baseAddress); + Declaration* decl = GetDeclaration(offset); + if (GETSEGNUM(segAddress) != segment || decl == nullptr) + { + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; + } - if (!Globals::Instance->HasSegment(GETSEGNUM(segAddress)) || decl == nullptr) - return StringHelper::Sprintf("0x%08X", segAddress); + if (expectedType != "" && expectedType != "void*") + { + if (expectedType != decl->varType && "static " + expectedType != decl->varType) + { + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; + } + } if (!decl->isArray) - return "&" + decl->varName; + declName = "&" + decl->varName; + else + declName = decl->varName; + return true; +} - return decl->varName; +bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSize, + const std::string& expectedType, + std::string& declName) const +{ + if (segAddress == 0) + { + declName = "NULL"; + return true; + } + + uint32_t address = Seg2Filespace(segAddress, baseAddress); + Declaration* decl = GetDeclarationRanged(address); + if (GETSEGNUM(segAddress) != segment || decl == nullptr || !decl->isArray) + { + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; + } + + if (expectedType != "" && expectedType != "void*") + { + if (expectedType != decl->varType && "static " + expectedType != decl->varType) + { + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; + } + } + + if (decl->address == address) + { + declName = decl->varName; + return true; + } + + if ((address - decl->address) % elementSize != 0 || !(address < decl->address + decl->size)) + { + declName = StringHelper::Sprintf("0x%08X", segAddress); + return false; + } + + uint32_t index = (address - decl->address) / elementSize; + declName = StringHelper::Sprintf("&%s[%u]", decl->varName.c_str(), index); + return true; } Declaration* ZFile::GetDeclaration(uint32_t address) const @@ -572,86 +699,47 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -uint32_t ZFile::GetDeclarationRangedAddress(uint32_t address) const -{ - for (const auto decl : declarations) - { - if (address >= decl.first && address < decl.first + decl.second->size) - return decl.first; - } - - return 0xFFFFFFFF; -} - bool ZFile::HasDeclaration(uint32_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); } -void ZFile::GenerateSourceFiles(fs::path outputDir) +void ZFile::GenerateSourceFiles() { - std::string sourceOutput = ""; + std::string sourceOutput; sourceOutput += "#include \"ultra64.h\"\n"; sourceOutput += "#include \"z64.h\"\n"; sourceOutput += "#include \"macros.h\"\n"; sourceOutput += GetHeaderInclude(); + bool hasZRoom = false; + for (const auto& res : resources) + { + ZResourceType resType = res->GetResourceType(); + if (resType == ZResourceType::Room || resType == ZResourceType::Scene || + resType == ZResourceType::AltHeader) + { + hasZRoom = true; + break; + } + } + + if (hasZRoom) + { + sourceOutput += GetZRoomHeaderInclude(); + } + + sourceOutput += GetExternalFileHeaderInclude(); + GeneratePlaceholderDeclarations(); // Generate Code for (size_t i = 0; i < resources.size(); i++) { ZResource* res = resources.at(i); - std::string resSrc = res->GetSourceOutputCode(name); - - if (res->IsExternalResource()) - { - std::string path = Path::GetFileNameWithoutExtension(res->GetName()).c_str(); - - std::string assetOutDir = - (outputDir / Path::GetFileNameWithoutExtension(res->GetOutName())).string(); - std::string declType = res->GetSourceTypeName(); - - std::string incStr = StringHelper::Sprintf("%s.%s.inc", assetOutDir.c_str(), - res->GetExternalExtension().c_str()); - - if (res->GetResourceType() == ZResourceType::Texture) - { - ZTexture* tex = static_cast(res); - - if (!Globals::Instance->cfg.texturePool.empty()) - { - tex->CalcHash(); - - // TEXTURE POOL CHECK - if (Globals::Instance->cfg.texturePool.find(tex->hash) != - Globals::Instance->cfg.texturePool.end()) - { - incStr = Globals::Instance->cfg.texturePool[tex->hash].path.string() + "." + - res->GetExternalExtension() + ".inc"; - } - } - - incStr += ".c"; - } - else if (res->GetResourceType() == ZResourceType::Blob || - res->GetResourceType() == ZResourceType::Background) - { - incStr += ".c"; - } - - AddDeclarationIncludeArray(res->GetRawDataIndex(), incStr, res->GetRawDataSize(), - declType, res->GetName(), 0); - } - else - { - sourceOutput += resSrc; - } - - if (resSrc != "" && !res->IsExternalResource()) - sourceOutput += "\n"; + res->GetSourceOutputCode(name); } sourceOutput += ProcessDeclarations(); @@ -682,6 +770,11 @@ void ZFile::GenerateSourceHeaderFiles() formatter.Write("\n"); } + for (auto& sym : symbolResources) + { + formatter.Write(sym.second->GetSourceOutputHeader("")); + } + formatter.Write(ProcessExterns()); fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h"); @@ -692,10 +785,48 @@ void ZFile::GenerateSourceHeaderFiles() File::WriteAllText(headerFilename, formatter.GetOutput()); } -std::string ZFile::GetHeaderInclude() +std::string ZFile::GetHeaderInclude() const { - return StringHelper::Sprintf("#include \"%s\"\n\n", - (outName.parent_path() / outName.stem().concat(".h")).c_str()); + std::string headers = StringHelper::Sprintf("#include \"%s.h\"\n", + (outName.parent_path() / outName.stem()).c_str()); + + return headers; +} + +std::string ZFile::GetZRoomHeaderInclude() const +{ + std::string headers; + headers += "#include \"segment_symbols.h\"\n"; + headers += "#include \"command_macros_base.h\"\n"; + headers += "#include \"z64cutscene_commands.h\"\n"; + headers += "#include \"variables.h\"\n"; + return headers; +} + +std::string ZFile::GetExternalFileHeaderInclude() const +{ + std::string externalFilesIncludes = ""; + + for (ZFile* externalFile : Globals::Instance->files) + { + if (externalFile != this) + { + fs::path outputFolderPath = externalFile->GetSourceOutputFolderPath(); + if (outputFolderPath == this->GetSourceOutputFolderPath()) + { + outputFolderPath = externalFile->outName.stem(); + } + else + { + outputFolderPath /= externalFile->outName.stem(); + } + + externalFilesIncludes += + StringHelper::Sprintf("#include \"%s.h\"\n", outputFolderPath.c_str()); + } + } + + return externalFilesIncludes; } void ZFile::GeneratePlaceholderDeclarations() @@ -703,8 +834,17 @@ void ZFile::GeneratePlaceholderDeclarations() // Generate placeholder declarations for (ZResource* res : resources) { - if (GetDeclaration(res->GetRawDataIndex()) == nullptr) - AddDeclarationPlaceholder(res->GetRawDataIndex(), res->GetName()); + if (GetDeclaration(res->GetRawDataIndex()) != nullptr) + { + continue; + } + + Declaration* decl = res->DeclareVar(GetName(), ""); + decl->staticConf = res->GetStaticConf(); + if (res->GetResourceType() == ZResourceType::Symbol) + { + decl->staticConf = StaticConfig::Off; + } } } @@ -726,9 +866,52 @@ ZTexture* ZFile::GetTextureResource(uint32_t offset) const return nullptr; } +void ZFile::AddSymbolResource(uint32_t offset, ZSymbol* sym) +{ + symbolResources[offset] = sym; +} + +ZSymbol* ZFile::GetSymbolResource(uint32_t offset) const +{ + auto sym = symbolResources.find(offset); + if (sym != symbolResources.end()) + return sym->second; + + return nullptr; +} + +ZSymbol* ZFile::GetSymbolResourceRanged(uint32_t offset) const +{ + for (const auto decl : symbolResources) + { + if (offset >= decl.first && offset < decl.first + decl.second->GetRawDataSize()) + return decl.second; + } + + return nullptr; +} + fs::path ZFile::GetSourceOutputFolderPath() const { - return Globals::Instance->sourceOutputPath / outName.parent_path(); + return outputPath / outName.parent_path(); +} + +bool ZFile::IsOffsetInFileRange(uint32_t offset) const +{ + if (!(offset < rawData.size())) + return false; + + return rangeStart <= offset && offset < rangeEnd; +} +bool ZFile::IsSegmentedInFilespaceRange(segptr_t segAddress) const +{ + uint8_t segnum = GETSEGNUM(segAddress); + uint32_t offset = Seg2Filespace(segAddress, baseAddress); + + if (segment != segnum) + return false; + + return IsOffsetInFileRange(offset); } std::map* ZFile::GetNodeMap() @@ -745,7 +928,7 @@ void ZFile::RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc) std::string ZFile::ProcessDeclarations() { - std::string output = ""; + std::string output; if (declarations.size() == 0) return output; @@ -754,7 +937,6 @@ std::string ZFile::ProcessDeclarations() // Account for padding/alignment uint32_t lastAddr = 0; - uint32_t lastSize = 0; // printf("RANGE START: 0x%06X - RANGE END: 0x%06X\n", rangeStart, rangeEnd); @@ -772,21 +954,25 @@ std::string ZFile::ProcessDeclarations() { if (curItem.second->varType == lastItem.second->varType) { - // TEST: For now just do Vtx declarations... - if (lastItem.second->varType == "static Vtx") + if (!curItem.second->declaredInXml && !lastItem.second->declaredInXml) { - int32_t sizeDiff = curItem.first - (lastItem.first + lastItem.second->size); - - // Make sure there isn't an unaccounted inbetween these two - if (sizeDiff == 0) + // TEST: For now just do Vtx declarations... + if (lastItem.second->varType == "Vtx") { - lastItem.second->size += curItem.second->size; - lastItem.second->arrayItemCnt += curItem.second->arrayItemCnt; - lastItem.second->text += "\n" + curItem.second->text; - declarations.erase(curItem.first); - declarationKeys.erase(declarationKeys.begin() + i); - i--; - continue; + int32_t sizeDiff = curItem.first - (lastItem.first + lastItem.second->size); + + // Make sure there isn't an unaccounted inbetween these two + if (sizeDiff == 0) + { + lastItem.second->size += curItem.second->size; + lastItem.second->arrayItemCnt += curItem.second->arrayItemCnt; + lastItem.second->text += "\n" + curItem.second->text; + declarations.erase(curItem.first); + declarationKeys.erase(declarationKeys.begin() + i); + delete curItem.second; + i--; + continue; + } } } } @@ -807,35 +993,21 @@ std::string ZFile::ProcessDeclarations() { if (item.second->alignment == DeclarationAlignment::Align16) { - // int32_t lastAddrSizeTest = declarations[lastAddr]->size; int32_t curPtr = lastAddr + declarations[lastAddr]->size; while (curPtr % 4 != 0) { declarations[lastAddr]->size++; - // item.second->size++; curPtr++; } - - /*while (curPtr % 16 != 0) - { - char buffer[2048]; - - sprintf(buffer, "static u32 align%02X = 0;\n", curPtr); - item.second->text = buffer + item.second->text; - - declarations[lastAddr]->size += 4; - curPtr += 4; - }*/ } else if (item.second->alignment == DeclarationAlignment::Align8) { - int32_t curPtr = lastAddr + declarations[lastAddr]->size; + size_t curPtr = lastAddr + declarations[lastAddr]->size; while (curPtr % 4 != 0) { declarations[lastAddr]->size++; - // item.second->size++; curPtr++; } @@ -843,208 +1015,33 @@ std::string ZFile::ProcessDeclarations() { char buffer[2048]; - sprintf(buffer, "static u32 align%02X = 0;\n", curPtr); + sprintf(buffer, "u32 %s_align%02zX = 0;\n", name.c_str(), curPtr); item.second->preText = buffer + item.second->preText; declarations[lastAddr]->size += 4; - // item.second->size += 4; curPtr += 4; } } } - if (item.second->padding == DeclarationPadding::Pad16) - { - int32_t curPtr = item.first + item.second->size; - - while (curPtr % 4 != 0) - { - item.second->size++; - curPtr++; - } - - while (curPtr % 16 != 0) - { - item.second->postText += StringHelper::Sprintf("static u32 pad%02X = 0;\n", curPtr); - - item.second->size += 4; - curPtr += 4; - } - } - lastAddr = item.first; } - // Handle unaccounted data - lastAddr = 0; - lastSize = 0; - std::vector declsAddresses; - for (const auto& item : declarations) - { - declsAddresses.push_back(item.first); - } - declsAddresses.push_back(rawData.size()); - - for (uint32_t currentAddress : declsAddresses) - { - if (currentAddress >= rangeEnd) - { - break; - } - - if (currentAddress < rangeStart) - { - lastAddr = currentAddress; - continue; - } - - if (currentAddress != lastAddr && declarations.find(lastAddr) != declarations.end()) - { - Declaration* lastDecl = declarations.at(lastAddr); - lastSize = lastDecl->size; - - if (lastAddr + lastSize > currentAddress) - { - Declaration* currentDecl = declarations.at(currentAddress); - - fprintf(stderr, - "WARNING: Intersection detected from 0x%06X:0x%06X (%s), conflicts with " - "0x%06X (%s)\n", - lastAddr, lastAddr + lastSize, lastDecl->varName.c_str(), currentAddress, - currentDecl->varName.c_str()); - } - } - - uint32_t unaccountedAddress = lastAddr + lastSize; - - if (unaccountedAddress != currentAddress && lastAddr >= rangeStart && - unaccountedAddress < rangeEnd) - { - int diff = currentAddress - unaccountedAddress; - bool nonZeroUnaccounted = false; - - std::string src = " "; - - for (int i = 0; i < diff; i++) - { - uint8_t val = rawData.at(unaccountedAddress + i); - src += StringHelper::Sprintf("0x%02X, ", val); - if (val != 0x00) - { - nonZeroUnaccounted = true; - } - - if (Globals::Instance->verboseUnaccounted) - { - if ((i % 4 == 3)) - { - src += StringHelper::Sprintf(" // 0x%06X", unaccountedAddress + i - 3); - if (i != (diff - 1)) - { - src += "\n\t"; - } - } - } - else - { - if ((i % 16 == 15) && (i != (diff - 1))) - src += "\n "; - } - } - - if (declarations.find(unaccountedAddress) == declarations.end()) - { - if (diff > 0) - { - std::string unaccountedPrefix = "unaccounted"; - - if (diff < 16 && !nonZeroUnaccounted) - { - unaccountedPrefix = "possiblePadding"; - - // Strip unnecessary padding at the end of the file. - if (unaccountedAddress + diff >= rawData.size()) - break; - } - - Declaration* decl = AddDeclarationArray( - unaccountedAddress, DeclarationAlignment::None, diff, "static u8", - StringHelper::Sprintf("%s_%06X", unaccountedPrefix.c_str(), - unaccountedAddress), - diff, src); - decl->isUnaccounted = true; - - if (Globals::Instance->warnUnaccounted) - { - if (nonZeroUnaccounted) - { - fprintf( - stderr, - "Warning in file: %s (%s)\n" - "\t A non-zero unaccounted block was found at address '0x%06X'.\n" - "\t Block size: '0x%X'.\n", - xmlFilePath.c_str(), name.c_str(), unaccountedAddress, diff); - } - else if (diff >= 16) - { - fprintf(stderr, - "Warning in file: %s (%s)\n" - "\t A big (size>=0x10) zero-only unaccounted block was found " - "at address '0x%06X'.\n" - "\t Block size: '0x%X'.\n", - xmlFilePath.c_str(), name.c_str(), unaccountedAddress, diff); - } - } - } - } - } - - lastAddr = currentAddress; - } + HandleUnaccountedData(); // Go through include declarations // First, handle the prototypes (static only for now) - int32_t protoCnt = 0; for (std::pair item : declarations) { - if (StringHelper::StartsWith(item.second->varType, "static ") && - !item.second->isUnaccounted) - { - if (item.second->isArray) - { - if (item.second->arrayItemCntStr != "") - { - output += StringHelper::Sprintf("%s %s[%s];\n", item.second->varType.c_str(), - item.second->varName.c_str(), - item.second->arrayItemCntStr.c_str()); - } - else if (item.second->arrayItemCnt == 0) - { - output += StringHelper::Sprintf("%s %s[];\n", item.second->varType.c_str(), - item.second->varName.c_str()); - } - else - { - output += StringHelper::Sprintf("%s %s[%i];\n", item.second->varType.c_str(), - item.second->varName.c_str(), - item.second->arrayItemCnt); - } - } - else - output += StringHelper::Sprintf("%s %s;\n", item.second->varType.c_str(), - item.second->varName.c_str()); - - protoCnt++; - } + output += item.second->GetStaticForwardDeclarationStr(); } - if (protoCnt > 0) - output += "\n"; + output += "\n"; // Next, output the actual declarations - for (std::pair item : declarations) + for (const auto& item : declarations) { - if (item.first < rangeStart || item.first >= rangeEnd) + if (!IsOffsetInFileRange(item.first)) continue; if (item.second->includePath != "") @@ -1052,88 +1049,24 @@ std::string ZFile::ProcessDeclarations() if (item.second->isExternal) { // HACK - std::string extType = ""; + std::string extType; if (item.second->varType == "Gfx") extType = "dlist"; - else if (item.second->varType == "Vtx" || item.second->varType == "static Vtx") + else if (item.second->varType == "Vtx") extType = "vtx"; - auto filepath = Globals::Instance->outputPath / item.second->varName; + auto filepath = outputPath / item.second->varName; File::WriteAllText( StringHelper::Sprintf("%s.%s.inc", filepath.c_str(), extType.c_str()), item.second->text); } - // Do not asm_process vertex arrays. They have no practical use being overridden. - // if (item.second->varType == "Vtx" || item.second->varType == "static Vtx") - if (item.second->varType != "u64" && item.second->varType != "static u64" && - item.second->varType != "u8" && item.second->varType != "static u8") - { - output += StringHelper::Sprintf( - "%s %s[] = {\n #include \"%s\"\n};\n\n", item.second->varType.c_str(), - item.second->varName.c_str(), - StringHelper::Replace(item.second->includePath, "assets/", "../assets/") - .c_str()); - } - else - { - if (item.second->arrayItemCntStr != "") - output += StringHelper::Sprintf( - "%s %s[%s] = {\n #include \"%s\"\n};\n\n", item.second->varType.c_str(), - item.second->varName.c_str(), item.second->arrayItemCntStr.c_str(), - item.second->includePath.c_str()); - else - output += StringHelper::Sprintf( - "%s %s[] = {\n #include \"%s\"\n};\n\n", item.second->varType.c_str(), - item.second->varName.c_str(), item.second->includePath.c_str()); - } + output += item.second->GetExternalDeclarationStr(); } else if (item.second->varType != "") { - if (item.second->preText != "") - output += item.second->preText + "\n"; - - { - if (item.second->isArray) - { - if (item.second->arrayItemCntStr != "") - { - output += StringHelper::Sprintf( - "%s %s[%s];\n", item.second->varType.c_str(), - item.second->varName.c_str(), item.second->arrayItemCntStr.c_str()); - } - else - { - if (item.second->arrayItemCnt == 0) - output += - StringHelper::Sprintf("%s %s[] = {\n", item.second->varType.c_str(), - item.second->varName.c_str()); - else - output += StringHelper::Sprintf( - "%s %s[%i] = {\n", item.second->varType.c_str(), - item.second->varName.c_str(), item.second->arrayItemCnt); - } - - output += item.second->text + "\n"; - } - else - { - output += StringHelper::Sprintf("%s %s = { ", item.second->varType.c_str(), - item.second->varName.c_str()); - output += item.second->text; - } - - if (output.back() == '\n') - output += "};"; - else - output += " };"; - } - - output += " " + item.second->rightText + "\n\n"; - - if (item.second->postText != "") - output += item.second->postText + "\n"; + output += item.second->GetNormalDeclarationStr(); } } @@ -1146,84 +1079,41 @@ void ZFile::ProcessDeclarationText(Declaration* decl) { size_t refIndex = 0; - if (decl->references.size() > 0) + if (!(decl->references.size() > 0)) + return; + + for (size_t i = 0; i < decl->text.size() - 1; i++) { - for (size_t i = 0; i < decl->text.size() - 1; i++) + char c = decl->text[i]; + char c2 = decl->text[i + 1]; + + if (c == '@' && c2 == 'r') { - char c = decl->text[i]; - char c2 = decl->text[i + 1]; + std::string vtxName; + Globals::Instance->GetSegmentedArrayIndexedName(decl->references[refIndex], 0x10, this, + "Vtx", vtxName); + decl->text.replace(i, 2, vtxName); - if (c == '@' && c2 == 'r') - { - if (refIndex >= decl->references.size()) - break; + refIndex++; - Declaration* refDecl = GetDeclarationRanged(decl->references[refIndex]); - uint32_t refDeclAddr = GetDeclarationRangedAddress(decl->references[refIndex]); - - if (refDecl != nullptr) - { - if (refDecl->isArray) - { - if (refDecl->arrayItemCnt != 0) - { - int32_t itemSize = refDecl->size / refDecl->arrayItemCnt; - int32_t itemIndex = - (decl->references[refIndex] - refDeclAddr) / itemSize; - - decl->text.replace(i, 2, - StringHelper::Sprintf( - "&%s[%i]", refDecl->varName.c_str(), itemIndex)); - } - else - { - decl->text.replace(i, 2, - StringHelper::Sprintf("ERROR ARRAYITEMCNT = 0")); - } - } - else - { - decl->text.replace(i, 2, refDecl->varName); - } - } - else - decl->text.replace(i, 2, "ERROR"); - - refIndex++; - } + if (refIndex >= decl->references.size()) + break; } } } std::string ZFile::ProcessExterns() { - std::string output = ""; + std::string output; - for (std::pair item : declarations) + for (const auto& item : declarations) { - if (item.first < rangeStart || item.first >= rangeEnd) + if (!IsOffsetInFileRange(item.first)) { continue; } - if (!StringHelper::StartsWith(item.second->varType, "static ") && - item.second->varType != "") // && item.second->includePath == "") - { - if (item.second->isArray) - { - if (item.second->arrayItemCnt == 0) - output += - StringHelper::Sprintf("extern %s %s[];\n", item.second->varType.c_str(), - item.second->varName.c_str()); - else - output += StringHelper::Sprintf( - "extern %s %s[%i];\n", item.second->varType.c_str(), - item.second->varName.c_str(), item.second->arrayItemCnt); - } - else - output += StringHelper::Sprintf("extern %s %s;\n", item.second->varType.c_str(), - item.second->varName.c_str()); - } + output += item.second->GetExternStr(); } output += "\n"; @@ -1233,12 +1123,12 @@ std::string ZFile::ProcessExterns() return output; } -std::string ZFile::ProcessTextureIntersections([[maybe_unused]] std::string prefix) +std::string ZFile::ProcessTextureIntersections([[maybe_unused]] const std::string& prefix) { if (texturesResources.empty()) return ""; - std::string defines = ""; + std::string defines; std::vector> texturesSorted(texturesResources.begin(), texturesResources.end()); @@ -1263,11 +1153,13 @@ std::string ZFile::ProcessTextureIntersections([[maybe_unused]] std::string pref // Shrink palette so it doesn't overlap currentTex->SetDimensions(offsetDiff / currentTex->GetPixelMultiplyer(), 1); declarations.at(currentOffset)->size = currentTex->GetRawDataSize(); + currentTex->DeclareVar(GetName(), ""); } else { - std::string texName = GetDeclarationPtrName(currentOffset); + std::string texName; std::string texNextName; + GetDeclarationPtrName(currentOffset, "", texName); Declaration* nextDecl = GetDeclaration(nextOffset); if (nextDecl == nullptr) @@ -1278,6 +1170,7 @@ std::string ZFile::ProcessTextureIntersections([[maybe_unused]] std::string pref defines += StringHelper::Sprintf("#define %s ((u32)%s + 0x%06X)\n", texNextName.c_str(), texName.c_str(), offsetDiff); + delete declarations[nextOffset]; declarations.erase(nextOffset); texturesResources.erase(nextOffset); texturesSorted.erase(texturesSorted.begin() + i + 1); @@ -1289,3 +1182,155 @@ std::string ZFile::ProcessTextureIntersections([[maybe_unused]] std::string pref return defines; } + +void ZFile::HandleUnaccountedData() +{ + uint32_t lastAddr = 0; + uint32_t lastSize = 0; + std::vector declsAddresses; + for (const auto& item : declarations) + { + declsAddresses.push_back(item.first); + } + + bool breakLoop = false; + for (uint32_t currentAddress : declsAddresses) + { + if (currentAddress >= rangeEnd) + { + breakLoop = true; + break; + } + + if (currentAddress < rangeStart) + { + lastAddr = currentAddress; + continue; + } + + breakLoop = HandleUnaccountedAddress(currentAddress, lastAddr, lastSize); + if (breakLoop) + break; + + lastAddr = currentAddress; + } + + if (!breakLoop) + { + // TODO: change rawData.size() to rangeEnd + // HandleUnaccountedAddress(rangeEnd, lastAddr, lastSize); + HandleUnaccountedAddress(rawData.size(), lastAddr, lastSize); + } +} + +bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, uint32_t& lastSize) +{ + if (currentAddress != lastAddr && declarations.find(lastAddr) != declarations.end()) + { + Declaration* lastDecl = declarations.at(lastAddr); + lastSize = lastDecl->size; + + if (lastAddr + lastSize > currentAddress) + { + Declaration* currentDecl = declarations.at(currentAddress); + + fprintf(stderr, + "WARNING: Intersection detected from 0x%06X:0x%06X (%s), conflicts with " + "0x%06X (%s)\n", + lastAddr, lastAddr + lastSize, lastDecl->varName.c_str(), currentAddress, + currentDecl->varName.c_str()); + } + } + + uint32_t unaccountedAddress = lastAddr + lastSize; + + if (unaccountedAddress != currentAddress && lastAddr >= rangeStart && + unaccountedAddress < rangeEnd) + { + int diff = currentAddress - unaccountedAddress; + bool nonZeroUnaccounted = false; + + std::string src = " "; + + if (currentAddress > rawData.size()) + { + throw std::runtime_error(StringHelper::Sprintf( + "ZFile::ProcessDeclarations(): Fatal error while processing XML '%s'.\n" + "\t Offset '0x%X' is outside of the limits of file '%s', which has a size of " + "'0x%X'.\n" + "\t Aborting...", + xmlFilePath.c_str(), currentAddress, name.c_str(), rawData.size())); + } + + for (int i = 0; i < diff; i++) + { + uint8_t val = rawData.at(unaccountedAddress + i); + src += StringHelper::Sprintf("0x%02X, ", val); + if (val != 0x00) + { + nonZeroUnaccounted = true; + } + + if (Globals::Instance->verboseUnaccounted) + { + if ((i % 4 == 3)) + { + src += StringHelper::Sprintf(" // 0x%06X", unaccountedAddress + i - 3); + if (i != (diff - 1)) + { + src += "\n\t"; + } + } + } + else + { + if ((i % 16 == 15) && (i != (diff - 1))) + src += "\n "; + } + } + + if (declarations.find(unaccountedAddress) == declarations.end() && diff > 0) + { + std::string unaccountedPrefix = "unaccounted"; + + if (diff < 16 && !nonZeroUnaccounted) + { + unaccountedPrefix = "possiblePadding"; + + // Strip unnecessary padding at the end of the file. + if (unaccountedAddress + diff >= rawData.size()) + return true; + } + + Declaration* decl = AddDeclarationArray( + unaccountedAddress, DeclarationAlignment::Align4, diff, "u8", + StringHelper::Sprintf("%s_%s_%06X", name.c_str(), unaccountedPrefix.c_str(), + unaccountedAddress), + diff, src); + decl->isUnaccounted = true; + + if (Globals::Instance->warnUnaccounted) + { + if (nonZeroUnaccounted) + { + fprintf(stderr, + "Warning in file: %s (%s)\n" + "\t A non-zero unaccounted block was found at offset '0x%06X'.\n" + "\t Block size: '0x%X'.\n", + xmlFilePath.c_str(), name.c_str(), unaccountedAddress, diff); + } + else if (diff >= 16) + { + fprintf(stderr, + "Warning in file: %s (%s)\n" + "\t A big (size>=0x10) zero-only unaccounted block was found " + "at offset '0x%06X'.\n" + "\t Block size: '0x%X'.\n", + xmlFilePath.c_str(), name.c_str(), unaccountedAddress, diff); + } + } + } + } + + return false; +} diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 0ca0de837..9de6950e4 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -3,6 +3,8 @@ #include #include #include + +#include "ZSymbol.h" #include "ZTexture.h" #include "tinyxml2.h" @@ -14,8 +16,9 @@ enum class ZFileMode BuildSourceFile, BuildBackground, Extract, + ExternalFile, Invalid, - Custom = 1000 // Used for exporter file modes + Custom = 1000, // Used for exporter file modes }; enum class ZGame @@ -28,19 +31,22 @@ enum class ZGame class ZFile { public: - std::map declarations; + std::map declarations; std::string defines; std::vector resources; - uint32_t segment; - uint32_t baseAddress, rangeStart, rangeEnd; - ZFile(std::string nName); - ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, - std::string filename, const fs::path& nXmlFilePath, bool placeholderMode); + // Default to using virtual addresses + uint32_t segment = 0x80; + uint32_t baseAddress, rangeStart, rangeEnd; + bool isExternalFile = false; + + ZFile(const fs::path& nOutPath, const std::string& nName); + ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath, + const fs::path& nOutPath, const std::string& filename, const fs::path& nXmlFilePath); ~ZFile(); - std::string GetVarName(uint32_t address); std::string GetName() const; + ZFileMode GetMode() const; const fs::path& GetXmlFilePath() const; const std::vector& GetRawData() const; void ExtractResources(); @@ -49,42 +55,54 @@ public: ZResource* FindResource(uint32_t rawDataIndex); std::vector GetResourcesOfType(ZResourceType resType); - Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, size_t size, - std::string varType, std::string varName, std::string body); - Declaration* AddDeclaration(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, size_t size, std::string varType, - std::string varName, std::string body); - Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size, - std::string varType, std::string varName, size_t arrayItemCnt, - std::string body); - Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, size_t size, - std::string varType, std::string varName, - std::string arrayItemCntStr, std::string body); - Declaration* AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - DeclarationPadding padding, size_t size, std::string varType, - std::string varName, size_t arrayItemCnt, std::string body); - Declaration* AddDeclarationPlaceholder(uint32_t address); - Declaration* AddDeclarationPlaceholder(uint32_t address, std::string varName); - Declaration* AddDeclarationInclude(uint32_t address, std::string includePath, size_t size, - std::string varType, std::string varName); - Declaration* AddDeclarationIncludeArray(uint32_t address, std::string includePath, size_t size, - std::string varType, std::string varName, + Declaration* AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size, + const std::string& varType, const std::string& varName, + const std::string& body); + + Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size, + const std::string& varType, const std::string& varName, + size_t arrayItemCnt, const std::string& body); + Declaration* AddDeclarationArray(offset_t address, DeclarationAlignment alignment, size_t size, + const std::string& varType, const std::string& varName, + const std::string& arrayItemCntStr, const std::string& body); + + Declaration* AddDeclarationPlaceholder(offset_t address, const std::string& varName); + + Declaration* AddDeclarationInclude(offset_t address, const std::string& includePath, + size_t size, const std::string& varType, + const std::string& varName); + Declaration* AddDeclarationIncludeArray(offset_t address, std::string& includePath, size_t size, + const std::string& varType, const std::string& varName, size_t arrayItemCnt); - std::string GetDeclarationName(uint32_t address) const; - std::string GetDeclarationName(uint32_t address, std::string defaultResult) const; - std::string GetDeclarationPtrName(segptr_t segAddress) const; + + bool GetDeclarationPtrName(segptr_t segAddress, const std::string& expectedType, + std::string& declName) const; + bool GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSize, + const std::string& expectedType, + std::string& declName) const; + Declaration* GetDeclaration(uint32_t address) const; Declaration* GetDeclarationRanged(uint32_t address) const; - uint32_t GetDeclarationRangedAddress(uint32_t address) const; bool HasDeclaration(uint32_t address); - std::string GetHeaderInclude(); + + std::string GetHeaderInclude() const; + std::string GetZRoomHeaderInclude() const; + std::string GetExternalFileHeaderInclude() const; + void GeneratePlaceholderDeclarations(); void AddTextureResource(uint32_t offset, ZTexture* tex); ZTexture* GetTextureResource(uint32_t offset) const; + void AddSymbolResource(uint32_t offset, ZSymbol* sym); + ZSymbol* GetSymbolResource(uint32_t offset) const; + ZSymbol* GetSymbolResourceRanged(uint32_t offset) const; + fs::path GetSourceOutputFolderPath() const; + bool IsOffsetInFileRange(uint32_t offset) const; + bool IsSegmentedInFilespaceRange(segptr_t segAddress) const; + static std::map* GetNodeMap(); static void RegisterNode(std::string nodeName, ZResourceFactoryFunc* nodeFunc); @@ -93,23 +111,27 @@ protected: std::string name; fs::path outName = ""; fs::path basePath; + fs::path outputPath; fs::path xmlFilePath; // Keep track of every texture of this ZFile. // The pointers declared here are "borrowed" (somebody else is the owner), // so ZFile shouldn't delete/free those textures. std::map texturesResources; + std::map symbolResources; + ZFileMode mode = ZFileMode::Invalid; ZFile(); - void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, std::string filename, - bool placeholderMode); + void ParseXML(tinyxml2::XMLElement* reader, const std::string& filename); void DeclareResourceSubReferences(); - void GenerateSourceFiles(fs::path outputDir); + void GenerateSourceFiles(); void GenerateSourceHeaderFiles(); - void AddDeclarationDebugChecks(uint32_t address); + bool AddDeclarationChecks(uint32_t address, const std::string& varName); std::string ProcessDeclarations(); void ProcessDeclarationText(Declaration* decl); std::string ProcessExterns(); - std::string ProcessTextureIntersections(std::string prefix); + std::string ProcessTextureIntersections(const std::string& prefix); + void HandleUnaccountedData(); + bool HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, uint32_t& lastSize); }; diff --git a/tools/ZAPD/ZAPD/ZLimb.cpp b/tools/ZAPD/ZAPD/ZLimb.cpp index 498329568..77c66871f 100644 --- a/tools/ZAPD/ZAPD/ZLimb.cpp +++ b/tools/ZAPD/ZAPD/ZLimb.cpp @@ -1,379 +1,31 @@ #include "ZLimb.h" + #include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" REGISTER_ZFILENODE(Limb, ZLimb); -Struct_800A57C0::Struct_800A57C0(const std::vector& rawData, uint32_t fileOffset) +ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent), segmentStruct(nParent) { - unk_0 = BitConverter::ToUInt16BE(rawData, fileOffset + 0x00); - unk_2 = BitConverter::ToInt16BE(rawData, fileOffset + 0x02); - unk_4 = BitConverter::ToInt16BE(rawData, fileOffset + 0x04); - unk_6 = BitConverter::ToInt8BE(rawData, fileOffset + 0x06); - unk_7 = BitConverter::ToInt8BE(rawData, fileOffset + 0x07); - unk_8 = BitConverter::ToInt8BE(rawData, fileOffset + 0x08); - unk_9 = BitConverter::ToUInt8BE(rawData, fileOffset + 0x09); -} -Struct_800A57C0::Struct_800A57C0(const std::vector& rawData, uint32_t fileOffset, - size_t index) - : Struct_800A57C0(rawData, fileOffset + index * GetRawDataSize()) -{ -} - -std::string Struct_800A57C0::GetSourceOutputCode() const -{ - return StringHelper::Sprintf("0x%02X, %i, %i, %i, %i, %i, 0x%02X", unk_0, unk_2, unk_4, unk_6, - unk_7, unk_8, unk_9); -} - -size_t Struct_800A57C0::GetRawDataSize() -{ - return 0x0A; -} - -std::string Struct_800A57C0::GetSourceTypeName() -{ - return "Struct_800A57C0"; -} - -Struct_800A598C_2::Struct_800A598C_2(const std::vector& rawData, uint32_t fileOffset) -{ - unk_0 = BitConverter::ToUInt8BE(rawData, fileOffset + 0x00); - x = BitConverter::ToInt16BE(rawData, fileOffset + 0x02); - y = BitConverter::ToInt16BE(rawData, fileOffset + 0x04); - z = BitConverter::ToInt16BE(rawData, fileOffset + 0x06); - unk_8 = BitConverter::ToUInt8BE(rawData, fileOffset + 0x08); -} -Struct_800A598C_2::Struct_800A598C_2(const std::vector& rawData, uint32_t fileOffset, - size_t index) - : Struct_800A598C_2(rawData, fileOffset + index * GetRawDataSize()) -{ -} - -std::string Struct_800A598C_2::GetSourceOutputCode() const -{ - return StringHelper::Sprintf("0x%02X, %i, %i, %i, 0x%02X", unk_0, x, y, z, unk_8); -} - -size_t Struct_800A598C_2::GetRawDataSize() -{ - return 0x0A; -} - -std::string Struct_800A598C_2::GetSourceTypeName() -{ - return "Struct_800A598C_2"; -} - -Struct_800A598C::Struct_800A598C(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset) - : parent(parent) -{ - unk_0 = BitConverter::ToUInt16BE(rawData, fileOffset + 0x00); - unk_2 = BitConverter::ToUInt16BE(rawData, fileOffset + 0x02); - unk_4 = BitConverter::ToUInt16BE(rawData, fileOffset + 0x04); - unk_8 = BitConverter::ToUInt32BE(rawData, fileOffset + 0x08); - unk_C = BitConverter::ToUInt32BE(rawData, fileOffset + 0x0C); - - if (unk_8 != 0) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - for (size_t i = 0; i < unk_0; i++) - { - unk_8_arr.emplace_back(rawData, unk_8_Offset, i); - } - } - - if (unk_C != 0) - { - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); - for (size_t i = 0; i < unk_2; i++) - { - unk_C_arr.emplace_back(rawData, unk_C_Offset, i); - } - } -} -Struct_800A598C::Struct_800A598C(ZFile* parent, const std::vector& rawData, - uint32_t fileOffset, size_t index) - : Struct_800A598C(parent, rawData, fileOffset + index * GetRawDataSize()) -{ -} - -void Struct_800A598C::DeclareReferences(const std::string& prefix) -{ - std::string entryStr; - - if (unk_8 != 0) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - std::string unk_8_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A57C0::GetSourceTypeName().c_str(), unk_8_Offset); - - size_t arrayItemCnt = unk_8_arr.size(); - entryStr = ""; - size_t i = 0; - - for (auto& child : unk_8_arr) - { - entryStr += StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode().c_str(), - (++i < arrayItemCnt) ? "\n" : ""); - } - - Declaration* decl = parent->GetDeclaration(unk_8_Offset); - - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_8_Offset, DeclarationAlignment::None, - arrayItemCnt * Struct_800A57C0::GetRawDataSize(), - Struct_800A57C0::GetSourceTypeName(), unk_8_Str, - arrayItemCnt, entryStr); - } - else - { - decl->text = entryStr; - } - } - - if (unk_C != 0) - { - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); - std::string unk_C_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A598C_2::GetSourceTypeName().c_str(), unk_C_Offset); - - size_t arrayItemCnt = unk_C_arr.size(); - entryStr = ""; - size_t i = 0; - - for (auto& child : unk_C_arr) - { - entryStr += StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode().c_str(), - (++i < arrayItemCnt) ? "\n" : ""); - } - - Declaration* decl = parent->GetDeclaration(unk_C_Offset); - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_C_Offset, DeclarationAlignment::None, - arrayItemCnt * Struct_800A598C_2::GetRawDataSize(), - Struct_800A598C_2::GetSourceTypeName(), unk_C_Str, - arrayItemCnt, entryStr); - } - else - { - decl->text = entryStr; - } - } -} - -std::string Struct_800A598C::GetSourceOutputCode(const std::string& prefix) const -{ - std::string entryStr; - - std::string unk_8_Str = "NULL"; - - if (unk_8 != 0) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - unk_8_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A57C0::GetSourceTypeName().c_str(), unk_8_Offset); - } - - std::string unk_C_Str = "NULL"; - - if (unk_C != 0) - { - uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); - unk_C_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A598C_2::GetSourceTypeName().c_str(), unk_C_Offset); - } - - entryStr = StringHelper::Sprintf("\n ARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n", - unk_8_Str.c_str(), unk_C_Str.c_str()); - entryStr += StringHelper::Sprintf(" %i, %s, %s\n ", unk_4, unk_8_Str.c_str(), - unk_C_Str.c_str()); - entryStr = StringHelper::Sprintf("\n ARRAY_COUNTU(%s), ARRAY_COUNTU(%s),\n", - unk_8_Str.c_str(), unk_C_Str.c_str()); - entryStr += StringHelper::Sprintf(" %i, %s, %s\n ", unk_4, unk_8_Str.c_str(), - unk_C_Str.c_str()); - - return entryStr; -} - -size_t Struct_800A598C::GetRawDataSize() -{ - return 0x10; -} - -std::string Struct_800A598C::GetSourceTypeName() -{ - return "Struct_800A598C"; -} - -Struct_800A5E28::Struct_800A5E28(ZFile* parent, const std::vector& nRawData, - uint32_t fileOffset) - : parent(parent) -{ - unk_0 = BitConverter::ToUInt16BE(nRawData, fileOffset + 0x00); - unk_2 = BitConverter::ToUInt16BE(nRawData, fileOffset + 0x02); - unk_4 = BitConverter::ToUInt32BE(nRawData, fileOffset + 0x04); - unk_8 = BitConverter::ToUInt32BE(nRawData, fileOffset + 0x08); - - if (unk_4 != 0) - { - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - - for (size_t i = 0; i < unk_2; i++) - { - unk_4_arr.emplace_back(parent, nRawData, unk_4_Offset, i); - } - } -} - -Struct_800A5E28::~Struct_800A5E28() -{ - delete unk_8_dlist; -} - -void Struct_800A5E28::DeclareReferences(const std::string& prefix) -{ - if (unk_4 != 0) - { - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - std::string unk_4_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A598C::GetSourceTypeName().c_str(), unk_4_Offset); - - std::string entryStr = ""; - uint16_t arrayItemCnt = unk_4_arr.size(); - - size_t i = 0; - - for (auto& child : unk_4_arr) - { - child.DeclareReferences(prefix); - entryStr += - StringHelper::Sprintf(" { %s },%s", child.GetSourceOutputCode(prefix).c_str(), - (++i < arrayItemCnt) ? "\n" : ""); - } - - Declaration* decl = parent->GetDeclaration(unk_4_Offset); - - if (decl == nullptr) - { - parent->AddDeclarationArray(unk_4_Offset, DeclarationAlignment::None, - arrayItemCnt * Struct_800A598C::GetRawDataSize(), - Struct_800A598C::GetSourceTypeName(), unk_4_Str, - arrayItemCnt, entryStr); - } - else - { - decl->text = entryStr; - } - } - - if (unk_8 != 0) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - - int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), unk_8_Offset, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - unk_8_dlist = new ZDisplayList(unk_8_Offset, dlistLength, parent); - - std::string dListStr = - StringHelper::Sprintf("%sSkinLimbDL_%06X", prefix.c_str(), unk_8_Offset); - unk_8_dlist->SetName(dListStr); - unk_8_dlist->GetSourceOutputCode(prefix); - } -} - -std::string Struct_800A5E28::GetSourceOutputCode(const std::string& prefix) const -{ - std::string entryStr = ""; - - std::string unk_4_Str = "NULL"; - - if (unk_4 != 0) - { - uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_4_Offset); - - if (decl == nullptr) - { - unk_4_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A598C::GetSourceTypeName().c_str(), unk_4_Offset); - } - else - { - unk_4_Str = decl->varName; - } - } - - std::string unk_8_Str = "NULL"; - if (unk_8 != 0) - { - uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); - Declaration* decl = parent->GetDeclaration(unk_8_Offset); - if (decl == nullptr) - { - // Something went wrong... - unk_8_Str = StringHelper::Sprintf("0x%08X", unk_8); - } - else - { - unk_8_Str = decl->varName; - } - } - - return StringHelper::Sprintf("\n %i, ARRAY_COUNTU(%s),\n %s, %s\n", unk_0, - unk_4_Str.c_str(), unk_4_Str.c_str(), unk_8_Str.c_str()); -} - -size_t Struct_800A5E28::GetRawDataSize() -{ - return 0x0C; -} - -std::string Struct_800A5E28::GetSourceTypeName() -{ - return "Struct_800A5E28"; -} - -ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent) -{ - dListPtr = 0; - dList2Ptr = 0; RegisterOptionalAttribute("LimbType"); RegisterOptionalAttribute("Type"); } -ZLimb::ZLimb(ZLimbType limbType, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) - : ZLimb(nParent) +void ZLimb::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType) { rawDataIndex = nRawDataIndex; - parent = nParent; - type = limbType; + type = nType; - name = StringHelper::Sprintf("%sLimb_%06X", prefix.c_str(), GetFileAddress()); + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; ParseRawData(); } -void ZLimb::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclaration(GetFileAddress(), DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), name, ""); -} - void ZLimb::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); @@ -385,37 +37,29 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader) if (limbType == "") { - fprintf(stderr, - "ZLimb::ParseXML: Warning in '%s'.\n" - "\t Missing 'LimbType' attribute in xml.\n" - "\t Defaulting to 'Standard'.\n", - name.c_str()); - type = ZLimbType::Standard; + throw std::runtime_error(StringHelper::Sprintf("ZLimb::ParseXML: Error in '%s'.\n" + "\t Missing 'LimbType' attribute in xml.\n", + name.c_str())); } - else + + type = GetTypeByAttributeName(limbType); + if (type == ZLimbType::Invalid) { - type = GetTypeByAttributeName(limbType); - if (type == ZLimbType::Invalid) - { - fprintf(stderr, - "ZLimb::ParseXML: Warning in '%s'.\n" - "\t Invalid LimbType found: '%s'.\n" - "\t Defaulting to 'Standard'.\n", - name.c_str(), limbType.c_str()); - type = ZLimbType::Standard; - } + throw std::runtime_error(StringHelper::Sprintf("ZLimb::ParseXML: Error in '%s'.\n" + "\t Invalid 'LimbType' found: '%s'.\n", + name.c_str(), limbType.c_str())); } } void ZLimb::ParseRawData() { ZResource::ParseRawData(); - const auto& rawData = parent->GetRawData(); + if (type == ZLimbType::Curve) { - childIndex = rawData.at(rawDataIndex + 0); - siblingIndex = rawData.at(rawDataIndex + 1); + childIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0); + siblingIndex = BitConverter::ToUInt8BE(rawData, rawDataIndex + 1); dListPtr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); dList2Ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); @@ -455,12 +99,16 @@ void ZLimb::ParseRawData() skinSegmentType = static_cast(BitConverter::ToInt32BE(rawData, rawDataIndex + 8)); skinSegment = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - if (skinSegmentType == ZLimbSkinType::SkinType_4 && skinSegment != 0) + if (skinSegmentType == ZLimbSkinType::SkinType_4) { - uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress); - segmentStruct = Struct_800A5E28(parent, rawData, skinSegmentOffset); + if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) + { + uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress); + segmentStruct.ExtractFromFile(skinSegmentOffset); + } } break; + default: throw std::runtime_error("Invalid ZLimb type"); break; @@ -469,8 +117,13 @@ void ZLimb::ParseRawData() void ZLimb::DeclareReferences(const std::string& prefix) { - ZResource::DeclareReferences(prefix); + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; + ZResource::DeclareReferences(varPrefix); + + std::string suffix; switch (type) { case ZLimbType::Legacy: @@ -479,8 +132,10 @@ void ZLimb::DeclareReferences(const std::string& prefix) uint32_t childOffset = Seg2Filespace(childPtr, parent->baseAddress); if (!parent->HasDeclaration(childOffset)) { - ZLimb* child = new ZLimb(ZLimbType::Legacy, prefix, childOffset, parent); - child->GetSourceOutputCode(prefix); + ZLimb* child = new ZLimb(parent); + child->ExtractFromBinary(childOffset, ZLimbType::Legacy); + child->DeclareVar(varPrefix, ""); + child->DeclareReferences(varPrefix); parent->AddResource(child); } } @@ -489,18 +144,47 @@ void ZLimb::DeclareReferences(const std::string& prefix) uint32_t siblingdOffset = Seg2Filespace(siblingPtr, parent->baseAddress); if (!parent->HasDeclaration(siblingdOffset)) { - ZLimb* sibling = new ZLimb(ZLimbType::Legacy, prefix, siblingdOffset, parent); - sibling->GetSourceOutputCode(prefix); + ZLimb* sibling = new ZLimb(parent); + sibling->ExtractFromBinary(siblingdOffset, ZLimbType::Legacy); + sibling->DeclareVar(varPrefix, ""); + sibling->DeclareReferences(varPrefix); parent->AddResource(sibling); } } break; - // TODO - case ZLimbType::Standard: - case ZLimbType::LOD: - case ZLimbType::Skin: case ZLimbType::Curve: + case ZLimbType::LOD: + suffix = "Far"; + if (type == ZLimbType::Curve) + suffix = "Curve2"; + DeclareDList(dList2Ptr, varPrefix, suffix); + [[fallthrough]]; + case ZLimbType::Standard: + suffix = ""; + if (type == ZLimbType::Curve) + suffix = "Curve"; + DeclareDList(dListPtr, varPrefix, suffix); + break; + + case ZLimbType::Skin: + switch (skinSegmentType) + { + case ZLimbSkinType::SkinType_4: + if (skinSegment != 0 && GETSEGNUM(skinSegment) == parent->segment) + { + segmentStruct.DeclareReferences(varPrefix); + segmentStruct.GetSourceOutputCode(varPrefix); + } + break; + + case ZLimbSkinType::SkinType_DList: + DeclareDList(skinSegment, varPrefix, ""); + break; + + default: + break; + } break; case ZLimbType::Invalid: @@ -530,18 +214,20 @@ size_t ZLimb::GetRawDataSize() const return 0x0C; } -std::string ZLimb::GetSourceOutputCode(const std::string& prefix) +std::string ZLimb::GetBodySourceCode() const { - std::string limbPrefix = type == ZLimbType::Curve ? "Curve" : ""; - std::string dListStr = GetLimbDListSourceOutputCode(prefix, limbPrefix, dListPtr); - limbPrefix = type == ZLimbType::Curve ? "Curve" : "Far"; - std::string dListStr2 = GetLimbDListSourceOutputCode(prefix, limbPrefix, dList2Ptr); + std::string dListStr; + std::string dListStr2; + Globals::Instance->GetSegmentedArrayIndexedName(dListPtr, 8, parent, "Gfx", dListStr); + Globals::Instance->GetSegmentedArrayIndexedName(dList2Ptr, 8, parent, "Gfx", dListStr2); std::string entryStr = "\n\t"; if (type == ZLimbType::Legacy) { - std::string childName = parent->GetDeclarationPtrName(childPtr); - std::string siblingName = parent->GetDeclarationPtrName(siblingPtr); + std::string childName; + std::string siblingName; + Globals::Instance->GetSegmentedPtrName(childPtr, parent, "Gfx", childName); + Globals::Instance->GetSegmentedPtrName(siblingPtr, parent, "Gfx", siblingName); entryStr += StringHelper::Sprintf("%s,\n", dListStr.c_str()); entryStr += @@ -556,24 +242,28 @@ std::string ZLimb::GetSourceOutputCode(const std::string& prefix) { entryStr += StringHelper::Sprintf("{ %i, %i, %i }, ", transX, transY, transZ); } - entryStr += StringHelper::Sprintf("0x%02X, 0x%02X,\n", childIndex, siblingIndex); switch (type) { case ZLimbType::Standard: - entryStr += StringHelper::Sprintf(" %s\n", dListStr.c_str()); + entryStr += StringHelper::Sprintf("\t%s\n", dListStr.c_str()); break; case ZLimbType::LOD: case ZLimbType::Curve: entryStr += - StringHelper::Sprintf(" { %s, %s }\n", dListStr.c_str(), dListStr2.c_str()); + StringHelper::Sprintf("\t{ %s, %s }\n", dListStr.c_str(), dListStr2.c_str()); break; case ZLimbType::Skin: - entryStr += GetSourceOutputCodeSkin(prefix); - break; + { + std::string skinSegmentStr; + Globals::Instance->GetSegmentedPtrName(skinSegment, parent, "", skinSegmentStr); + entryStr += + StringHelper::Sprintf("\t0x%02X, %s\n", skinSegmentType, skinSegmentStr.c_str()); + } + break; case ZLimbType::Legacy: break; @@ -583,15 +273,12 @@ std::string ZLimb::GetSourceOutputCode(const std::string& prefix) } } - Declaration* decl = parent->GetDeclaration(GetFileAddress()); + return entryStr; +} - if (decl == nullptr) - parent->AddDeclaration(GetFileAddress(), DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), name, entryStr); - else - decl->text = entryStr; - - return ""; +std::string ZLimb::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sLimb_%06X", prefix.c_str(), rawDataIndex); } std::string ZLimb::GetSourceTypeName() const @@ -663,126 +350,34 @@ ZLimbType ZLimb::GetTypeByAttributeName(const std::string& attrName) return ZLimbType::Invalid; } -uint32_t ZLimb::GetFileAddress() +void ZLimb::DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, + const std::string& limbSuffix) { - return Seg2Filespace(rawDataIndex, parent->baseAddress); -} + if (dListSegmentedPtr == 0 || GETSEGNUM(dListSegmentedPtr) != parent->segment) + return; -// Returns the ptrname of a dlist. Declares it if it has not been declared yet. -std::string ZLimb::GetLimbDListSourceOutputCode(const std::string& prefix, - const std::string& limbPrefix, segptr_t dListPtr) -{ - if (dListPtr == 0) - return "NULL"; + uint32_t dlistOffset = Seg2Filespace(dListSegmentedPtr, parent->baseAddress); + if (parent->HasDeclaration(dlistOffset)) + return; - uint32_t dListOffset = Seg2Filespace(dListPtr, parent->baseAddress); + if (!parent->IsOffsetInFileRange(dlistOffset) || dlistOffset >= parent->GetRawData().size()) + return; - // Check if pointing past the object's size - if (dListOffset > parent->GetRawData().size()) - return StringHelper::Sprintf("0x%08X", dListPtr); - - // Check if it is already declared - Declaration* decl = parent->GetDeclaration(dListOffset); - if (decl != nullptr) - return decl->varName; - - // Check if it points to the middle of a DList - decl = parent->GetDeclarationRanged(dListOffset); - if (decl != nullptr) - { - // TODO: Figure out a way to not hardcode the "Gfx" type. - if (decl->varType == "Gfx") - { - uint32_t declAddress = parent->GetDeclarationRangedAddress(dListOffset); - if (dListOffset < declAddress + decl->size) - { - uint32_t index = (dListOffset - declAddress) / 8; - return StringHelper::Sprintf("&%s[%u]", decl->varName.c_str(), index); - } - } - } - - // Create the DList - std::string dListStr = - StringHelper::Sprintf("%s%sLimbDL_%06X", prefix.c_str(), limbPrefix.c_str(), dListOffset); + std::string dlistName; + bool declFound = Globals::Instance->GetSegmentedArrayIndexedName(dListSegmentedPtr, 8, parent, + "Gfx", dlistName); + if (declFound) + return; int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), dListOffset, + parent->GetRawData(), dlistOffset, Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - auto dList = new ZDisplayList(dListOffset, dlistLength, parent); - dList->SetName(dListStr); - dList->GetSourceOutputCode(prefix); - return dListStr; -} - -std::string ZLimb::GetSourceOutputCodeSkin_Type_4(const std::string& prefix) -{ - assert(type == ZLimbType::Skin); - assert(skinSegmentType == ZLimbSkinType::SkinType_4); - - if (skinSegment == 0) - return "NULL"; - - uint32_t skinSegmentOffset = Seg2Filespace(skinSegment, parent->baseAddress); - - std::string struct_800A5E28_Str; - Declaration* decl = parent->GetDeclaration(skinSegmentOffset); - if (decl == nullptr) - { - struct_800A5E28_Str = - StringHelper::Sprintf("%sSkinLimb_%s_%06X", prefix.c_str(), - Struct_800A5E28::GetSourceTypeName().c_str(), skinSegmentOffset); - - segmentStruct.DeclareReferences(prefix); - std::string entryStr = segmentStruct.GetSourceOutputCode(prefix); - - parent->AddDeclaration(skinSegmentOffset, DeclarationAlignment::None, - Struct_800A5E28::GetRawDataSize(), - Struct_800A5E28::GetSourceTypeName(), struct_800A5E28_Str, entryStr); - } - else - { - struct_800A5E28_Str = decl->varName; - } - - return struct_800A5E28_Str; -} - -std::string ZLimb::GetSourceOutputCodeSkin(const std::string& prefix) -{ - assert(type == ZLimbType::Skin); - - std::string skinSegmentStr = "NULL"; - - if (skinSegment != 0) - { - switch (skinSegmentType) - { - case ZLimbSkinType::SkinType_4: - skinSegmentStr = "&" + GetSourceOutputCodeSkin_Type_4(prefix); - break; - case ZLimbSkinType::SkinType_DList: - skinSegmentStr = GetLimbDListSourceOutputCode(prefix, "Skin", skinSegment); - break; - default: - fprintf(stderr, - "ZLimb::GetSourceOutputCodeSkinType: Error in '%s'.\n\t Unknown segment type " - "for SkinLimb: '%i'. \n\tPlease report this.\n", - name.c_str(), static_cast(skinSegmentType)); - break; - case ZLimbSkinType::SkinType_0: - case ZLimbSkinType::SkinType_5: - fprintf(stderr, - "ZLimb::GetSourceOutputCodeSkinType: Error in '%s'.\n\t Segment type for " - "SkinLimb not implemented: '%i'.\n", - name.c_str(), static_cast(skinSegmentType)); - skinSegmentStr = StringHelper::Sprintf("0x%08X", skinSegment); - break; - } - } - - std::string entryStr = - StringHelper::Sprintf(" 0x%02X, %s\n", skinSegmentType, skinSegmentStr.c_str()); - - return entryStr; + ZDisplayList* dlist = new ZDisplayList(parent); + dlist->ExtractFromBinary(dlistOffset, dlistLength); + + std::string dListStr = + StringHelper::Sprintf("%s%sDL_%06X", prefix.c_str(), limbSuffix.c_str(), dlistOffset); + dlist->SetName(dListStr); + dlist->DeclareVar(prefix, ""); + parent->AddResource(dlist); } diff --git a/tools/ZAPD/ZAPD/ZLimb.h b/tools/ZAPD/ZAPD/ZLimb.h index affc7b49d..53a414329 100644 --- a/tools/ZAPD/ZAPD/ZLimb.h +++ b/tools/ZAPD/ZAPD/ZLimb.h @@ -3,6 +3,8 @@ #include #include #include + +#include "OtherStructs/SkinLimbStructs.h" #include "ZDisplayList.h" #include "ZFile.h" @@ -16,117 +18,14 @@ enum class ZLimbType Legacy, }; -// TODO: check if more types exists -enum class ZLimbSkinType -{ - SkinType_0, // Segment = 0 - SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 - SkinType_5 = 5, // Segment = 0 - SkinType_DList = 11, // Segment = DList address -}; - -class Struct_800A57C0 -{ -protected: - uint16_t unk_0; - int16_t unk_2; - int16_t unk_4; - int8_t unk_6; - int8_t unk_7; - int8_t unk_8; - uint8_t unk_9; - -public: - Struct_800A57C0(const std::vector& rawData, uint32_t fileOffset); - Struct_800A57C0(const std::vector& rawData, uint32_t fileOffset, size_t index); - - [[nodiscard]] std::string GetSourceOutputCode() const; - - static size_t GetRawDataSize(); - static std::string GetSourceTypeName(); -}; - -class Struct_800A598C_2 -{ -protected: - uint8_t unk_0; - int16_t x; - int16_t y; - int16_t z; - uint8_t unk_8; - -public: - Struct_800A598C_2(const std::vector& rawData, uint32_t fileOffset); - Struct_800A598C_2(const std::vector& rawData, uint32_t fileOffset, size_t index); - - [[nodiscard]] std::string GetSourceOutputCode() const; - - static size_t GetRawDataSize(); - static std::string GetSourceTypeName(); -}; - -class Struct_800A598C -{ -protected: - ZFile* parent; - - uint16_t unk_0; // Length of unk_8 - uint16_t unk_2; // Length of unk_C - uint16_t unk_4; // 0 or 1 // Used as an index for unk_C - segptr_t unk_8; // Struct_800A57C0* - segptr_t unk_C; // Struct_800A598C_2* - - std::vector unk_8_arr; - std::vector unk_C_arr; - -public: - Struct_800A598C(ZFile* parent, const std::vector& rawData, uint32_t fileOffset); - Struct_800A598C(ZFile* parent, const std::vector& rawData, uint32_t fileOffset, - size_t index); - - void DeclareReferences(const std::string& prefix); - [[nodiscard]] std::string GetSourceOutputCode(const std::string& prefix) const; - - static size_t GetRawDataSize(); - static std::string GetSourceTypeName(); -}; - -class Struct_800A5E28 -{ -protected: - ZFile* parent; - - uint16_t unk_0; // Vtx count - uint16_t unk_2; // Length of unk_4 - segptr_t unk_4; // Struct_800A598C* - segptr_t unk_8; // Gfx* - - std::vector unk_4_arr; - ZDisplayList* unk_8_dlist = nullptr; - -public: - Struct_800A5E28() = default; - Struct_800A5E28(ZFile* parent, const std::vector& rawData, uint32_t fileOffset); - Struct_800A5E28(ZFile* parent, const std::vector& rawData, uint32_t fileOffset, - size_t index); - ~Struct_800A5E28(); - - void DeclareReferences(const std::string& prefix); - [[nodiscard]] std::string GetSourceOutputCode(const std::string& prefix) const; - - static size_t GetRawDataSize(); - static std::string GetSourceTypeName(); -}; - class ZLimb : public ZResource { -protected: +public: ZLimbType type = ZLimbType::Standard; ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only segptr_t skinSegment = 0; // Skin only Struct_800A5E28 segmentStruct; // Skin only - segptr_t dList2Ptr; // LOD and Curve Only // Legacy only float legTransX, legTransY, legTransZ; // Vec3f @@ -134,29 +33,24 @@ protected: segptr_t childPtr; // LegacyLimb* segptr_t siblingPtr; // LegacyLimb* - std::string GetLimbDListSourceOutputCode(const std::string& prefix, - const std::string& limbPrefix, segptr_t dListPtr); - - std::string GetSourceOutputCodeSkin(const std::string& prefix); - std::string GetSourceOutputCodeSkin_Type_4(const std::string& prefix); - -public: segptr_t dListPtr = 0; - segptr_t farDListPtr = 0; // LOD only + segptr_t dList2Ptr = 0; // LOD and Curve Only + int16_t transX, transY, transZ; uint8_t childIndex, siblingIndex; ZLimb(ZFile* nParent); - ZLimb(ZLimbType limbType, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; + void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + size_t GetRawDataSize() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; @@ -165,6 +59,7 @@ public: static const char* GetSourceTypeName(ZLimbType limbType); static ZLimbType GetTypeByAttributeName(const std::string& attrName); - uint32_t GetFileAddress(); - void SetFileAddress(uint32_t nAddress); +protected: + void DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, + const std::string& limbSuffix); }; diff --git a/tools/ZAPD/ZAPD/ZMtx.cpp b/tools/ZAPD/ZAPD/ZMtx.cpp index 87918b8ce..b9ca3f22d 100644 --- a/tools/ZAPD/ZAPD/ZMtx.cpp +++ b/tools/ZAPD/ZAPD/ZMtx.cpp @@ -1,4 +1,5 @@ #include "ZMtx.h" + #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -9,13 +10,6 @@ ZMtx::ZMtx(ZFile* nParent) : ZResource(nParent) { } -ZMtx::ZMtx(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) : ZResource(nParent) -{ - name = GetDefaultName(prefix.c_str(), rawDataIndex); - ExtractFromFile(nRawDataIndex); - DeclareVar("", ""); -} - void ZMtx::ParseRawData() { ZResource::ParseRawData(); @@ -26,28 +20,11 @@ void ZMtx::ParseRawData() mtx[i][j] = BitConverter::ToInt32BE(rawData, rawDataIndex + (i * 4 + j) * 4); } -void ZMtx::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar("", ""); -} - size_t ZMtx::GetRawDataSize() const { return 64; } -void ZMtx::DeclareVar(const std::string& prefix, const std::string& bodyStr) const -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix, rawDataIndex); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align8, GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); -} - std::string ZMtx::GetBodySourceCode() const { std::string bodyStr = "\n"; @@ -65,25 +42,6 @@ std::string ZMtx::GetBodySourceCode() const return bodyStr; } -std::string ZMtx::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - -std::string ZMtx::GetDefaultName(const std::string& prefix, uint32_t address) -{ - return StringHelper::Sprintf("%sMtx_%06X", prefix.c_str(), address); -} - std::string ZMtx::GetSourceTypeName() const { return "Mtx"; @@ -93,3 +51,8 @@ ZResourceType ZMtx::GetResourceType() const { return ZResourceType::Mtx; } + +DeclarationAlignment ZMtx::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align8; +} diff --git a/tools/ZAPD/ZAPD/ZMtx.h b/tools/ZAPD/ZAPD/ZMtx.h index 5a4d1efe6..eed502374 100644 --- a/tools/ZAPD/ZAPD/ZMtx.h +++ b/tools/ZAPD/ZAPD/ZMtx.h @@ -8,22 +8,17 @@ class ZMtx : public ZResource { public: ZMtx(ZFile* nParent); - ZMtx(const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); void ParseRawData() override; - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - - size_t GetRawDataSize() const override; - - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; - static std::string GetDefaultName(const std::string& prefix, uint32_t address); std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; + size_t GetRawDataSize() const override; + DeclarationAlignment GetDeclarationAlignment() const override; + protected: std::array, 4> mtx; }; diff --git a/tools/ZAPD/ZAPD/ZPath.cpp b/tools/ZAPD/ZAPD/ZPath.cpp index c7be85268..4a95c5b91 100644 --- a/tools/ZAPD/ZAPD/ZPath.cpp +++ b/tools/ZAPD/ZAPD/ZPath.cpp @@ -13,14 +13,6 @@ ZPath::ZPath(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("NumPaths", "1"); } -void ZPath::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, pathways.size() * 8, - GetSourceTypeName(), name, pathways.size(), ""); -} - void ZPath::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); @@ -43,8 +35,7 @@ void ZPath::ParseRawData() for (size_t pathIndex = 0; pathIndex < numPaths; pathIndex++) { PathwayEntry path(parent); - path.SetRawDataIndex(currentPtr); - path.ParseRawData(); + path.ExtractFromFile(currentPtr); if (path.GetListAddress() == 0) break; @@ -62,9 +53,23 @@ void ZPath::DeclareReferences(const std::string& prefix) entry.DeclareReferences(prefix); } +Declaration* ZPath::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, pathways.size(), bodyStr); + decl->staticConf = staticConf; + return decl; +} + std::string ZPath::GetBodySourceCode() const { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& entry : pathways) @@ -80,20 +85,6 @@ std::string ZPath::GetBodySourceCode() const return declaration; } -std::string ZPath::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string declaration = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - if (decl == nullptr || decl->isPlaceholder) - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, pathways.size() * 8, - GetSourceTypeName(), name, pathways.size(), declaration); - else - decl->text = declaration; - - return ""; -} - std::string ZPath::GetSourceTypeName() const { return "Path"; @@ -134,10 +125,7 @@ void PathwayEntry::ParseRawData() for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); - vec.SetRawDataIndex(currentPtr); - vec.SetScalarType(ZScalarType::ZSCALAR_S16); - vec.SetDimensions(3); - vec.ParseRawData(); + vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); currentPtr += vec.GetRawDataSize(); points.push_back(vec); @@ -150,12 +138,18 @@ void PathwayEntry::DeclareReferences(const std::string& prefix) if (points.empty()) return; - std::string declaration = ""; + std::string pointsName; + bool addressFound = + Globals::Instance->GetSegmentedPtrName(listSegmentAddress, parent, "Vec3s", pointsName); + if (addressFound) + return; + + std::string declaration; size_t index = 0; for (const auto& point : points) { - declaration += StringHelper::Sprintf("\t%s,", point.GetBodySourceCode().c_str()); + declaration += StringHelper::Sprintf("\t{ %s },", point.GetBodySourceCode().c_str()); if (index < points.size() - 1) declaration += "\n"; @@ -163,14 +157,13 @@ void PathwayEntry::DeclareReferences(const std::string& prefix) index++; } - Declaration* decl = parent->GetDeclaration(GETSEGOFFSET(listSegmentAddress)); + uint32_t pointsOffset = Seg2Filespace(listSegmentAddress, parent->baseAddress); + Declaration* decl = parent->GetDeclaration(pointsOffset); if (decl == nullptr) { - parent->AddDeclarationArray(GETSEGOFFSET(listSegmentAddress), DeclarationAlignment::Align4, - DeclarationPadding::Pad4, points.size() * 6, - points.at(0).GetSourceTypeName(), - StringHelper::Sprintf("%sPathwayList0x%06X", prefix.c_str(), - GETSEGOFFSET(listSegmentAddress)), + pointsName = StringHelper::Sprintf("%sPathwayList_%06X", prefix.c_str(), pointsOffset); + parent->AddDeclarationArray(pointsOffset, points.at(0).GetDeclarationAlignment(), + points.size() * 6, points.at(0).GetSourceTypeName(), pointsName, points.size(), declaration); } else @@ -179,8 +172,9 @@ void PathwayEntry::DeclareReferences(const std::string& prefix) std::string PathwayEntry::GetBodySourceCode() const { - std::string declaration = ""; - std::string listName = parent->GetDeclarationPtrName(listSegmentAddress); + std::string declaration; + std::string listName; + Globals::Instance->GetSegmentedPtrName(listSegmentAddress, parent, "Vec3s", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) declaration += diff --git a/tools/ZAPD/ZAPD/ZPath.h b/tools/ZAPD/ZAPD/ZPath.h index 21394fa56..e519decff 100644 --- a/tools/ZAPD/ZAPD/ZPath.h +++ b/tools/ZAPD/ZAPD/ZPath.h @@ -32,14 +32,12 @@ class ZPath : public ZResource public: ZPath(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; diff --git a/tools/ZAPD/ZAPD/ZPlayerAnimationData.cpp b/tools/ZAPD/ZAPD/ZPlayerAnimationData.cpp new file mode 100644 index 000000000..a96604fda --- /dev/null +++ b/tools/ZAPD/ZAPD/ZPlayerAnimationData.cpp @@ -0,0 +1,97 @@ +#include "ZPlayerAnimationData.h" + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" +#include "ZFile.h" + +REGISTER_ZFILENODE(PlayerAnimationData, ZPlayerAnimationData); + +ZPlayerAnimationData::ZPlayerAnimationData(ZFile* nParent) : ZResource(nParent) +{ + RegisterRequiredAttribute("FrameCount"); +} + +void ZPlayerAnimationData::ParseXML(tinyxml2::XMLElement* reader) +{ + ZResource::ParseXML(reader); + + std::string& frameCountXml = registeredAttributes.at("FrameCount").value; + + frameCount = StringHelper::StrToL(frameCountXml); +} + +void ZPlayerAnimationData::ParseRawData() +{ + ZResource::ParseRawData(); + + const auto& rawData = parent->GetRawData(); + + size_t totalSize = GetRawDataSize(); + // Divided by 2 because each value is an s16 + limbRotData.reserve(totalSize * frameCount / 2); + + for (size_t i = 0; i < totalSize; i += 2) + { + limbRotData.push_back(BitConverter::ToUInt16BE(rawData, rawDataIndex + i)); + } +} + +Declaration* ZPlayerAnimationData::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (auxName == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, limbRotData.size(), bodyStr); + decl->staticConf = staticConf; + return decl; +} + +std::string ZPlayerAnimationData::GetBodySourceCode() const +{ + std::string declaration = ""; + + size_t index = 0; + for (const auto& entry : limbRotData) + { + if (index % 8 == 0) + { + declaration += "\t"; + } + + declaration += StringHelper::Sprintf("0x%04X, ", entry); + + if ((index + 1) % 8 == 0) + { + declaration += "\n"; + } + + index++; + } + + return declaration; +} + +std::string ZPlayerAnimationData::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sPlayerAnimationData_%06X", prefix.c_str(), rawDataIndex); +} + +std::string ZPlayerAnimationData::GetSourceTypeName() const +{ + return "s16"; +} + +ZResourceType ZPlayerAnimationData::GetResourceType() const +{ + return ZResourceType::PlayerAnimationData; +} + +size_t ZPlayerAnimationData::GetRawDataSize() const +{ + // (sizeof(Vec3s) * limbCount + 2) * frameCount + return (6 * 22 + 2) * frameCount; +} diff --git a/tools/ZAPD/ZAPD/ZPlayerAnimationData.h b/tools/ZAPD/ZAPD/ZPlayerAnimationData.h new file mode 100644 index 000000000..20835f236 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZPlayerAnimationData.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#include "ZResource.h" + +class ZPlayerAnimationData : public ZResource +{ +public: + int16_t frameCount = 0; + std::vector limbRotData; + + ZPlayerAnimationData(ZFile* nParent); + + void ParseXML(tinyxml2::XMLElement* reader) override; + void ParseRawData() override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index bff7037d4..cb811f4c3 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -2,6 +2,7 @@ #include #include + #include "Utils/StringHelper.h" #include "ZFile.h" @@ -19,23 +20,43 @@ ZResource::ZResource(ZFile* nParent) RegisterOptionalAttribute("OutName"); RegisterOptionalAttribute("Offset"); RegisterOptionalAttribute("Custom"); + RegisterOptionalAttribute("Static", "Global"); } -void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) +void ZResource::ExtractFromXML(tinyxml2::XMLElement* reader, offset_t nRawDataIndex) { rawDataIndex = nRawDataIndex; + declaredInXml = true; if (reader != nullptr) ParseXML(reader); - ParseRawData(); - CalcHash(); + // Don't parse raw data of external files + if (parent->GetMode() != ZFileMode::ExternalFile) + { + ParseRawData(); + CalcHash(); + } + + if (!isInner) + { + Declaration* decl = DeclareVar(parent->GetName(), ""); + if (decl != nullptr) + { + decl->declaredInXml = true; + decl->staticConf = staticConf; + } + } } -void ZResource::ExtractFromFile(uint32_t nRawDataIndex) +void ZResource::ExtractFromFile(offset_t nRawDataIndex) { rawDataIndex = nRawDataIndex; + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + ParseRawData(); CalcHash(); } @@ -110,6 +131,24 @@ void ZResource::ParseXML(tinyxml2::XMLElement* reader) isCustomAsset = registeredAttributes["Custom"].wasSet; + std::string& staticXml = registeredAttributes["Static"].value; + if (staticXml == "Global") + { + staticConf = StaticConfig::Global; + } + else if (staticXml == "On") + { + staticConf = StaticConfig::On; + } + else if (staticXml == "Off") + { + staticConf = StaticConfig::Off; + } + else + { + throw std::runtime_error("Invalid value for 'Static' attribute."); + } + declaredInXml = true; } } @@ -130,6 +169,20 @@ void ZResource::DeclareReferencesLate([[maybe_unused]] const std::string& prefix { } +Declaration* ZResource::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclaration(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, bodyStr); + decl->staticConf = staticConf; + return decl; +} + void ZResource::Save([[maybe_unused]] const fs::path& outFolder) { } @@ -169,19 +222,24 @@ std::string ZResource::GetExternalExtension() const return ""; } +DeclarationAlignment ZResource::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align4; +} + bool ZResource::WasDeclaredInXml() const { return declaredInXml; } -uint32_t ZResource::GetRawDataIndex() const +StaticConfig ZResource::GetStaticConf() const { - return rawDataIndex; + return staticConf; } -void ZResource::SetRawDataIndex(uint32_t value) +offset_t ZResource::GetRawDataIndex() const { - rawDataIndex = value; + return rawDataIndex; } std::string ZResource::GetBodySourceCode() const @@ -189,8 +247,23 @@ std::string ZResource::GetBodySourceCode() const return "ERROR"; } +std::string ZResource::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), GetSourceTypeName().c_str(), + rawDataIndex); +} + std::string ZResource::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) { + std::string bodyStr = GetBodySourceCode(); + + Declaration* decl = parent->GetDeclaration(rawDataIndex); + if (decl == nullptr || decl->isPlaceholder) + decl = DeclareVar(prefix, bodyStr); + else + decl->text = bodyStr; + decl->staticConf = staticConf; + return ""; } @@ -230,12 +303,24 @@ void ZResource::RegisterOptionalAttribute(const std::string& attr, const std::st registeredAttributes[attr] = resAtrr; } -uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress) +offset_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress) { - uint32_t currentPtr = GETSEGOFFSET(segmentedAddress); + offset_t currentPtr = GETSEGOFFSET(segmentedAddress); if (GETSEGNUM(segmentedAddress) == 0x80) // Is defined in code? - currentPtr -= GETSEGOFFSET(parentBaseAddress); + { + uint32_t parentBaseOffset = GETSEGOFFSET(parentBaseAddress); + if (parentBaseOffset > currentPtr) + { + throw std::runtime_error( + StringHelper::Sprintf("\nSeg2Filespace: Segmented address is smaller than " + "'BaseAddress'. Maybe your 'BaseAddress' is wrong?\n" + "\t SegmentedAddress: 0x%08X\n" + "\t BaseAddress: 0x%08X\n", + segmentedAddress, parentBaseAddress)); + } + currentPtr -= parentBaseOffset; + } return currentPtr; } diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index 71d91ee2b..ff35786fa 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -21,8 +21,6 @@ #define GETSEGOFFSET(x) (x & 0x00FFFFFF) #define GETSEGNUM(x) ((x >> 24) & 0xFF) -typedef uint32_t segptr_t; - class ZFile; enum class ZResourceType @@ -40,6 +38,7 @@ enum class ZResourceType LimbTable, Mtx, Path, + PlayerAnimationData, Room, RoomCommand, Scalar, @@ -57,8 +56,8 @@ enum class ZResourceType class ResourceAttribute { public: - std::string key = ""; - std::string value = ""; + std::string key; + std::string value; bool isRequired = false; bool wasSet = false; }; @@ -70,54 +69,127 @@ public: bool outputDeclaration = true; uint32_t hash = 0; + /** + * Constructor. + * Child classes should not declare any other constructor besides this one + */ ZResource(ZFile* nParent); virtual ~ZResource() = default; // Parsing from File - virtual void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex); - virtual void ExtractFromFile(uint32_t nRawDataIndex); + virtual void ExtractFromXML(tinyxml2::XMLElement* reader, offset_t nRawDataIndex); + virtual void ExtractFromFile(offset_t nRawDataIndex); // Misc + /** + * Parses additional attributes of the XML node. + * Extra attritbutes have to be registered using `RegisterRequiredAttribute` or + * `RegisterOptionalAttribute` in the constructor of the ZResource + */ virtual void ParseXML(tinyxml2::XMLElement* reader); + /** + * Extracts data from the binary file + */ virtual void ParseRawData(); + /** + * Declares any data pointed by this resource that has not been declared already. + * For example, a Vtx referenced by a Dlist should be declared here if it wasn't + * declared previously by something else + */ virtual void DeclareReferences(const std::string& prefix); virtual void ParseRawDataLate(); virtual void DeclareReferencesLate(const std::string& prefix); - virtual std::string GetBodySourceCode() const; + + /** + * Adds this resource as a Declaration of its parent ZFile + */ + virtual Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr); + /** + * Returns the body of the variable of the extracted resource, without any side-effect + */ + [[nodiscard]] virtual std::string GetBodySourceCode() const; + /** + * Creates an automatically generated variable name for the current resource + */ + [[nodiscard]] virtual std::string GetDefaultName(const std::string& prefix) const; virtual std::string GetSourceOutputCode(const std::string& prefix); virtual std::string GetSourceOutputHeader(const std::string& prefix); virtual void CalcHash(); + /** + * Exports the resource to binary format + */ virtual void Save(const fs::path& outFolder); // Properties + /** + * Returns true if the resource will be externalized, and included back to the C file using + * `#include`s + */ virtual bool IsExternalResource() const; - virtual bool DoesSupportArray() const; // Can this type be wrapped in an node? - virtual std::string GetSourceTypeName() const = 0; - virtual ZResourceType GetResourceType() const = 0; - virtual std::string GetExternalExtension() const; + /** + * Can this type be wrapped in an node? + */ + virtual bool DoesSupportArray() const; + /** + * The type of the resource as a C struct + */ + [[nodiscard]] virtual std::string GetSourceTypeName() const = 0; + /** + * The type in the ZResource enum + */ + [[nodiscard]] virtual ZResourceType GetResourceType() const = 0; + /** + * The filename extension for assets extracted as standalone files + */ + [[nodiscard]] virtual std::string GetExternalExtension() const; // Getters/Setters - const std::string& GetName() const; + [[nodiscard]] const std::string& GetName() const; void SetName(const std::string& nName); - const std::string& GetOutName() const; + [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); - virtual uint32_t GetRawDataIndex() const; - virtual void SetRawDataIndex(uint32_t value); - virtual size_t GetRawDataSize() const = 0; + [[nodiscard]] offset_t GetRawDataIndex() const; + /** + * The size of the current struct being extracted, not counting data referenced by it + */ + [[nodiscard]] virtual size_t GetRawDataSize() const = 0; + /** + * The alignment of the extracted struct + */ + [[nodiscard]] virtual DeclarationAlignment GetDeclarationAlignment() const; void SetInnerNode(bool inner); - bool WasDeclaredInXml() const; + /** + * Returns `true` if this ZResource was declared using an XML node, + * `false` otherwise (for example, a Vtx extracted indirectly by a DList) + */ + [[nodiscard]] bool WasDeclaredInXml() const; + [[nodiscard]] StaticConfig GetStaticConf() const; protected: std::string name; std::string outName; - uint32_t rawDataIndex; + offset_t rawDataIndex; std::string sourceOutput; - bool isInner = false; // Is this resource an inner node of another resource? inside of - bool canHaveInner = false; // Can this type have an inner node? - bool isCustomAsset; // If set to true, create a reference for the asset in the file, but don't - // actually try to extract it from the file + + // Inner is used mostly for nodes + /** + * Is this resource an inner node of another resource? + * (namely inside an ) + */ + bool isInner = false; + /** + * Can this type have an inner node? + */ + bool canHaveInner = false; + + /** + * If set to true, create a reference for the asset in the file, but don't + * actually try to extract it from the file + */ + bool isCustomAsset; bool declaredInXml = false; + StaticConfig staticConf = StaticConfig::Global; // Reading from this XMLs attributes should be performed in the overrided `ParseXML` method. std::map registeredAttributes; @@ -137,11 +209,12 @@ class ZResourceExporter { public: ZResourceExporter() = default; + virtual ~ZResourceExporter() = default; virtual void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) = 0; }; -uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress); +offset_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress); typedef ZResource*(ZResourceFactoryFunc)(ZFile* nParent); @@ -167,4 +240,4 @@ typedef ZResource*(ZResourceFactoryFunc)(ZFile* nParent); public: \ ZResExp_##expFunc() { expFunc(); } \ }; \ - static ZResExp_##expFunc inst_ZResExp_##expFunc; + static ZResExp_##expFunc inst_ZResExp_##expFunc diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp index 32c50747e..60391a9d1 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp @@ -29,7 +29,7 @@ void SetActorCutsceneList::DeclareReferences(const std::string& prefix) { if (cutscenes.size() > 0) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < cutscenes.size(); i++) { @@ -45,15 +45,16 @@ void SetActorCutsceneList::DeclareReferences(const std::string& prefix) std::string typeName = cutscenes.at(0).GetSourceTypeName(); parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, cutscenes.size() * 16, typeName, + segmentOffset, GetDeclarationAlignment(), cutscenes.size() * 16, typeName, StringHelper::Sprintf("%s%sList_%06X", prefix.c_str(), typeName.c_str(), segmentOffset), - 0, declaration); + cutscenes.size(), declaration); } } std::string SetActorCutsceneList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorCutscene", listName); return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_LIST(%i, %s)", cutscenes.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp index 64cea558d..919d86f57 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp @@ -48,7 +48,7 @@ void SetActorList::DeclareReferencesLate(const std::string& prefix) if (actors.empty()) return; - std::string declaration = ""; + std::string declaration; size_t largestlength = 0; for (const auto& entry : actors) @@ -72,19 +72,16 @@ void SetActorList::DeclareReferencesLate(const std::string& prefix) const auto& entry = actors.front(); - DeclarationPadding padding = DeclarationPadding::Pad16; - if (Globals::Instance->game == ZGame::MM_RETAIL) - padding = DeclarationPadding::None; - std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, padding, + parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(), varName, GetActorListArraySize(), declaration); } std::string SetActorList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName); if (numActors != actors.size()) { printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors, @@ -140,7 +137,7 @@ ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t r std::string ActorSpawnEntry::GetBodySourceCode() const { - std::string body = ""; + std::string body; std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); body = diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp index 4f5461f30..629d4a0b0 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp @@ -1,5 +1,6 @@ #include "SetAlternateHeaders.h" +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -10,8 +11,12 @@ SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent) void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& prefix) { - if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); + if (cmdArg2 != 0) + { + std::string varName = + StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationPlaceholder(segmentOffset, varName); + } } void SetAlternateHeaders::ParseRawDataLate() @@ -38,27 +43,30 @@ void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix) { if (!headers.empty()) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < headers.size(); i++) { - declaration += StringHelper::Sprintf( - "\t%s,", parent->GetDeclarationPtrName(headers.at(i)).c_str()); + std::string altHeaderName; + Globals::Instance->GetSegmentedPtrName(headers.at(i), parent, "", altHeaderName); + + declaration += StringHelper::Sprintf("\t%s,", altHeaderName.c_str()); if (i + 1 < headers.size()) declaration += "\n"; } - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, headers.size() * 4, "SceneCmd*", - StringHelper::Sprintf("%sAltHeader_%06X", prefix.c_str(), segmentOffset), 0, - declaration); + std::string varName = + StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationArray(segmentOffset, GetDeclarationAlignment(), headers.size() * 4, + "SceneCmd*", varName, headers.size(), declaration); } } std::string SetAlternateHeaders::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "SceneCmd*", listName); return StringHelper::Sprintf("SCENE_CMD_ALTERNATE_HEADER_LIST(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp index b1b3ed0ae..0b9a67e0e 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.cpp @@ -20,8 +20,7 @@ SetAnimatedMaterialList::SetAnimatedMaterialList(ZFile* nParent) void SetAnimatedMaterialList::ParseRawData() { ZRoomCommand::ParseRawData(); - textureAnimation.SetRawDataIndex(segmentOffset); - textureAnimation.ParseRawData(); + textureAnimation.ExtractFromFile(segmentOffset); } void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix) @@ -33,7 +32,8 @@ void SetAnimatedMaterialList::DeclareReferences(const std::string& prefix) std::string SetAnimatedMaterialList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "AnimatedMaterial", listName); return StringHelper::Sprintf("SCENE_CMD_ANIMATED_MATERIAL_LIST(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h index fecb9f2a0..3dbbf9684 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAnimatedMaterialList.h @@ -1,6 +1,5 @@ #pragma once -#include #include "ZRoom/ZRoomCommand.h" #include "ZTextureAnimation.h" diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp index 22273e031..03aaa4bbb 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.cpp @@ -1,5 +1,6 @@ #include "SetCollisionHeader.h" +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -12,21 +13,23 @@ SetCollisionHeader::SetCollisionHeader(ZFile* nParent) : ZRoomCommand(nParent) void SetCollisionHeader::ParseRawData() { ZRoomCommand::ParseRawData(); + collisionHeader = new ZCollisionHeader(parent); - collisionHeader->SetRawDataIndex(segmentOffset); collisionHeader->SetName( StringHelper::Sprintf("%sCollisionHeader_%06X", parent->GetName().c_str(), segmentOffset)); - collisionHeader->ParseRawData(); + collisionHeader->ExtractFromFile(segmentOffset); + parent->AddResource(collisionHeader); } -SetCollisionHeader::~SetCollisionHeader() +void SetCollisionHeader::DeclareReferences(const std::string& prefix) { - delete collisionHeader; + collisionHeader->DeclareVar(prefix, ""); } std::string SetCollisionHeader::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CollisionHeader", listName); return StringHelper::Sprintf("SCENE_CMD_COL_HEADER(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h index b0a599fd0..f7d5ecf35 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCollisionHeader.h @@ -9,9 +9,9 @@ public: ZCollisionHeader* collisionHeader; SetCollisionHeader(ZFile* nParent); - ~SetCollisionHeader(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp index ec41683ad..5cf0a3d03 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp @@ -1,5 +1,6 @@ #include "SetCsCamera.h" +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -33,31 +34,23 @@ void SetCsCamera::ParseRawData() for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); - vec.SetRawDataIndex(currentPtr); - vec.SetScalarType(ZScalarType::ZSCALAR_S16); - vec.SetDimensions(3); - vec.ParseRawData(); + vec.ExtractFromBinary(currentPtr, ZScalarType::ZSCALAR_S16, 3); currentPtr += vec.GetRawDataSize(); points.push_back(vec); } } - - if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); } void SetCsCamera::DeclareReferences(const std::string& prefix) { if (points.size() > 0) { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (auto& point : points) { - declaration += - StringHelper::Sprintf("\t%s, //0x%06X", point.GetBodySourceCode().c_str(), - cameras.at(0).segmentOffset + (index * 6)); + declaration += StringHelper::Sprintf("\t{ %s },", point.GetBodySourceCode().c_str()); if (index < points.size() - 1) declaration += "\n"; @@ -76,8 +69,10 @@ void SetCsCamera::DeclareReferences(const std::string& prefix) if (!cameras.empty()) { - std::string camPointsName = parent->GetDeclarationName(cameras.at(0).GetSegmentOffset()); - std::string declaration = ""; + std::string camPointsName; + Globals::Instance->GetSegmentedPtrName(cameras.at(0).GetCamAddress(), parent, "Vec3s", + camPointsName); + std::string declaration; size_t index = 0; size_t pointsIndex = 0; @@ -98,8 +93,8 @@ void SetCsCamera::DeclareReferences(const std::string& prefix) std::string camTypename = entry.GetSourceTypeName(); parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, DeclarationPadding::Pad16, - cameras.size() * entry.GetRawDataSize(), camTypename, + segmentOffset, DeclarationAlignment::Align4, cameras.size() * entry.GetRawDataSize(), + camTypename, StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), camTypename.c_str(), segmentOffset), cameras.size(), declaration); } @@ -107,7 +102,8 @@ void SetCsCamera::DeclareReferences(const std::string& prefix) std::string SetCsCamera::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CsCameraEntry", listName); return StringHelper::Sprintf("SCENE_CMD_ACTOR_CUTSCENE_CAM_LIST(%i, %s)", cameras.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index 34707a26f..e51e550b0 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -19,7 +19,7 @@ SetCutscenes::~SetCutscenes() void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output = ""; + std::string output; numCutscenes = cmdArg1; if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) @@ -38,7 +38,7 @@ void SetCutscenes::ParseRawData() else { int32_t currentPtr = segmentOffset; - std::string declaration = ""; + std::string declaration; for (uint8_t i = 0; i < numCutscenes; i++) { @@ -46,8 +46,9 @@ void SetCutscenes::ParseRawData() cutsceneEntries.push_back(entry); currentPtr += 8; + // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead declaration += StringHelper::Sprintf( - " { %sCutsceneData0x%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), + " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), entry.segmentOffset, entry.exit, entry.entrance, entry.flag); if (i < numCutscenes - 1) @@ -67,9 +68,9 @@ void SetCutscenes::ParseRawData() for (ZCutsceneBase* cutscene : cutscenes) { - if (cutscene->getSegmentOffset() != 0) + if (cutscene->GetRawDataIndex() != 0) { - Declaration* decl = parent->GetDeclaration(cutscene->getSegmentOffset()); + Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); if (decl == nullptr) { cutscene->GetSourceOutputCode(zRoom->GetName()); @@ -84,7 +85,8 @@ void SetCutscenes::ParseRawData() std::string SetCutscenes::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp index 9f8a0e0f4..8099bacf1 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp @@ -1,4 +1,6 @@ #include "SetEntranceList.h" + +#include "Globals.h" #include "SetStartPositionList.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -12,7 +14,11 @@ SetEntranceList::SetEntranceList(ZFile* nParent) : ZRoomCommand(nParent) void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& prefix) { if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); + { + std::string varName = + StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationPlaceholder(segmentOffset, varName); + } } void SetEntranceList::ParseRawDataLate() @@ -34,30 +40,30 @@ void SetEntranceList::DeclareReferencesLate([[maybe_unused]] const std::string& { if (!entrances.empty()) { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& entry : entrances) { - declaration += - StringHelper::Sprintf(" { %s }, //0x%06X", entry.GetBodySourceCode().c_str(), - segmentOffset + (index * 2)); + declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str()); if (index + 1 < entrances.size()) declaration += "\n"; index++; } - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, entrances.size() * 2, "EntranceEntry", - StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset), - entrances.size(), declaration); + std::string varName = + StringHelper::Sprintf("%sEntranceList0x%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, + entrances.size() * 2, "EntranceEntry", varName, + entrances.size(), declaration); } } std::string SetEntranceList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "EntranceEntry", listName); return StringHelper::Sprintf("SCENE_CMD_ENTRANCE_LIST(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp index a3cd64202..ddc4c5d43 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp @@ -1,5 +1,6 @@ #include "SetExitList.h" +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -12,7 +13,11 @@ SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent) void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix) { if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); + { + std::string varName = + StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationPlaceholder(segmentOffset, varName); + } } void SetExitList::ParseRawDataLate() @@ -34,7 +39,7 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref { if (!exits.empty()) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < exits.size(); i++) { @@ -43,16 +48,17 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref declaration += "\n"; } - parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::Align4, exits.size() * 2, "u16", - StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset), exits.size(), - declaration); + std::string varName = + StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, exits.size() * 2, + "u16", varName, exits.size(), declaration); } } std::string SetExitList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "u16", listName); return StringHelper::Sprintf("SCENE_CMD_EXIT_LIST(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp index 3bfc3a08a..2e023ff20 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp @@ -1,4 +1,6 @@ #include "SetLightList.h" + +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -9,7 +11,7 @@ SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent) void SetLightList::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string declarations = ""; + std::string declarations; numLights = cmdArg1; int32_t currentPtr = segmentOffset; @@ -26,7 +28,7 @@ void SetLightList::DeclareReferences(const std::string& prefix) { if (!lights.empty()) { - std::string declarations = ""; + std::string declarations; for (size_t i = 0; i < lights.size(); i++) { @@ -40,7 +42,7 @@ void SetLightList::DeclareReferences(const std::string& prefix) const auto& light = lights.front(); parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, lights.size() * light.GetRawDataSize(), + segmentOffset, DeclarationAlignment::Align4, lights.size() * light.GetRawDataSize(), light.GetSourceTypeName(), StringHelper::Sprintf("%sLightInfo0x%06X", prefix.c_str(), segmentOffset), lights.size(), declarations); @@ -49,7 +51,8 @@ void SetLightList::DeclareReferences(const std::string& prefix) std::string SetLightList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightInfo", listName); return StringHelper::Sprintf("SCENE_CMD_LIGHT_LIST(%i, %s)", numLights, listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp index cad21521e..08cd83d14 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp @@ -1,4 +1,6 @@ #include "SetLightingSettings.h" + +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -21,13 +23,12 @@ void SetLightingSettings::DeclareReferences(const std::string& prefix) { if (settings.size() > 0) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < settings.size(); i++) { - declaration += StringHelper::Sprintf("\t{ %s }, // 0x%06X", - settings.at(i).GetBodySourceCode().c_str(), - segmentOffset + (i * 22)); + declaration += + StringHelper::Sprintf("\t{ %s },", settings.at(i).GetBodySourceCode().c_str()); if (i + 1 < settings.size()) declaration += "\n"; } @@ -42,7 +43,8 @@ void SetLightingSettings::DeclareReferences(const std::string& prefix) std::string SetLightingSettings::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightSettings", listName); return StringHelper::Sprintf("SCENE_CMD_ENV_LIGHT_SETTINGS(%i, %s)", settings.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp index b2f9268ee..d1c8abd5c 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -22,15 +22,15 @@ void SetMesh::ParseRawData() switch (meshHeaderType) { case 0: - polyType = std::make_shared(parent, parentRawData, segmentOffset, zRoom); + polyType = std::make_shared(parent, segmentOffset, zRoom); break; case 1: - polyType = std::make_shared(parent, parentRawData, segmentOffset, zRoom); + polyType = std::make_shared(parent, segmentOffset, zRoom); break; case 2: - polyType = std::make_shared(parent, parentRawData, segmentOffset, zRoom); + polyType = std::make_shared(parent, segmentOffset, zRoom); break; default: @@ -49,36 +49,23 @@ void SetMesh::DeclareReferences(const std::string& prefix) polyType->DeclareAndGenerateOutputCode(prefix); } +// TODO: is this really needed? void GenDListDeclarations(ZRoom* zRoom, ZFile* parent, ZDisplayList* dList) { if (dList == nullptr) { return; } - std::string srcVarName = - StringHelper::Sprintf("%s%s", zRoom->GetName().c_str(), dList->GetName().c_str()); - dList->SetName(srcVarName); std::string sourceOutput = dList->GetSourceOutputCode(zRoom->GetName()); for (ZDisplayList* otherDList : dList->otherDLists) GenDListDeclarations(zRoom, parent, otherDList); - - for (const auto& vtxEntry : dList->vtxDeclarations) - { - DeclarationAlignment alignment = DeclarationAlignment::Align4; - if (Globals::Instance->game == ZGame::MM_RETAIL) - alignment = DeclarationAlignment::None; - parent->AddDeclarationArray( - vtxEntry.first, alignment, dList->vertices[vtxEntry.first].size() * 16, "static Vtx", - StringHelper::Sprintf("%sVtx_%06X", zRoom->GetName().c_str(), vtxEntry.first), - dList->vertices[vtxEntry.first].size(), vtxEntry.second); - } } std::string SetMesh::GenDListExterns(ZDisplayList* dList) { - std::string sourceOutput = ""; + std::string sourceOutput; sourceOutput += StringHelper::Sprintf("extern Gfx %sDL_%06X[];\n", zRoom->GetName().c_str(), dList->GetRawDataIndex()); @@ -86,14 +73,13 @@ std::string SetMesh::GenDListExterns(ZDisplayList* dList) for (ZDisplayList* otherDList : dList->otherDLists) sourceOutput += GenDListExterns(otherDList); - sourceOutput += dList->defines; - return sourceOutput; } std::string SetMesh::GetBodySourceCode() const { - std::string list = parent->GetDeclarationPtrName(cmdArg2); + std::string list; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "", list); return StringHelper::Sprintf("SCENE_CMD_MESH(%s)", list.c_str()); } @@ -107,15 +93,8 @@ RoomCommand SetMesh::GetRoomCommand() const return RoomCommand::SetMesh; } -PolygonDlist::PolygonDlist(const std::string& prefix, - [[maybe_unused]] const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom) +PolygonDlist::PolygonDlist(ZFile* nParent) : ZResource(nParent) { - rawDataIndex = nRawDataIndex; - parent = nParent; - zRoom = nRoom; - - name = GetDefaultName(prefix.c_str(), rawDataIndex); } void PolygonDlist::ParseRawData() @@ -146,22 +125,57 @@ void PolygonDlist::DeclareReferences(const std::string& prefix) xluDList = MakeDlist(xlu, prefix); } -ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix) +std::string PolygonDlist::GetBodySourceCode() const { - if (ptr == 0) + std::string bodyStr; + std::string opaStr; + std::string xluStr; + Globals::Instance->GetSegmentedPtrName(opa, parent, "Gfx", opaStr); + Globals::Instance->GetSegmentedPtrName(xlu, parent, "Gfx", xluStr); + + if (polyType == 2) { - return nullptr; + bodyStr += StringHelper::Sprintf("{ %6i, %6i, %6i }, %6i, ", x, y, z, unk_06); } - uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress); + bodyStr += StringHelper::Sprintf("%s, %s", opaStr.c_str(), xluStr.c_str()); - int32_t dlistLength = ZDisplayList::GetDListLength( - parent->GetRawData(), dlistAddress, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); - ZDisplayList* dlist = new ZDisplayList(dlistAddress, dlistLength, parent); - GenDListDeclarations(zRoom, parent, dlist); + return bodyStr; +} - return dlist; +std::string PolygonDlist::GetSourceOutputCode(const std::string& prefix) +{ + std::string bodyStr = StringHelper::Sprintf("\n\t%s\n", GetBodySourceCode().c_str()); + + Declaration* decl = parent->GetDeclaration(rawDataIndex); + if (decl == nullptr) + { + DeclareVar(prefix, bodyStr); + } + else + { + decl->text = bodyStr; + } + + return ""; +} + +std::string PolygonDlist::GetSourceTypeName() const +{ + switch (polyType) + { + case 2: + return "PolygonDlist2"; + + default: + return "PolygonDlist"; + } +} + +ZResourceType PolygonDlist::GetResourceType() const +{ + // TODO + return ZResourceType::Error; } size_t PolygonDlist::GetRawDataSize() const @@ -181,97 +195,42 @@ void PolygonDlist::SetPolyType(uint8_t nPolyType) polyType = nPolyType; } -void PolygonDlist::DeclareVar(const std::string& prefix, const std::string& bodyStr) +ZDisplayList* PolygonDlist::MakeDlist(segptr_t ptr, [[maybe_unused]] const std::string& prefix) { - std::string auxName = name; - if (name == "") + if (ptr == 0) { - auxName = GetDefaultName(prefix, rawDataIndex); + return nullptr; } - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); + + uint32_t dlistAddress = Seg2Filespace(ptr, parent->baseAddress); + + int32_t dlistLength = ZDisplayList::GetDListLength( + parent->GetRawData(), dlistAddress, + Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); + ZDisplayList* dlist = new ZDisplayList(parent); + parent->AddResource(dlist); + dlist->ExtractFromBinary(dlistAddress, dlistLength); + dlist->SetName(dlist->GetDefaultName(prefix)); + GenDListDeclarations(zRoom, parent, dlist); + + return dlist; } -std::string PolygonDlist::GetBodySourceCode(bool arrayElement) +/* BgImage */ + +BgImage::BgImage(ZFile* nParent) : ZResource(nParent) { - std::string bodyStr = ""; - std::string opaStr = parent->GetDeclarationPtrName(opa); - std::string xluStr = parent->GetDeclarationPtrName(xlu); - if (arrayElement) - { - bodyStr += " { "; - } - else - { - bodyStr += "\n "; - } - - if (polyType == 2) - { - bodyStr += StringHelper::Sprintf("{ %6i, %6i, %6i }, %6i, ", x, y, z, unk_06); - } - - bodyStr += StringHelper::Sprintf("%s, ", opaStr.c_str()); - bodyStr += StringHelper::Sprintf("%s", xluStr.c_str()); - - if (arrayElement) - { - bodyStr += " },"; - } - else - { - bodyStr += "\n"; - } - - return bodyStr; } -void PolygonDlist::DeclareAndGenerateOutputCode() -{ - std::string bodyStr = GetBodySourceCode(false); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - if (decl == nullptr) - { - DeclareVar("", bodyStr); - } - else - { - decl->text = bodyStr; - } -} - -std::string PolygonDlist::GetDefaultName(const std::string& prefix, uint32_t address) -{ - return StringHelper::Sprintf("%sPolyDlist_%06X", prefix.c_str(), address); -} - -std::string PolygonDlist::GetSourceTypeName() -{ - switch (polyType) - { - case 2: - return "PolygonDlist2"; - - default: - return "PolygonDlist"; - } -} - -std::string PolygonDlist::GetName() -{ - return name; -} - -BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, - [[maybe_unused]] const std::vector& nRawData, uint32_t nRawDataIndex, +BgImage::BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent) + : BgImage(nParent) { rawDataIndex = nRawDataIndex; parent = nParent; isSubStruct = nIsSubStruct; - name = GetDefaultName(prefix.c_str(), rawDataIndex); + name = GetDefaultName(prefix); ParseRawData(); sourceBackground = MakeBackground(source, prefix); @@ -306,22 +265,28 @@ ZBackground* BgImage::MakeBackground(segptr_t ptr, const std::string& prefix) uint32_t backAddress = Seg2Filespace(ptr, parent->baseAddress); - ZBackground* background = new ZBackground(prefix, backAddress, parent); + ZBackground* background = new ZBackground(parent); + background->ExtractFromFile(backAddress); + + std::string defaultName = background->GetDefaultName(prefix); + background->SetName(defaultName); + background->SetOutName(defaultName); + background->DeclareVar(prefix, ""); parent->resources.push_back(background); return background; } -size_t BgImage::GetRawDataSize() +size_t BgImage::GetRawDataSize() const { return 0x1C; } -std::string BgImage::GetBodySourceCode(bool arrayElement) const +std::string BgImage::GetBodySourceCode() const { std::string bodyStr = " "; - if (arrayElement) + if (!isSubStruct) { bodyStr += "{ \n "; } @@ -331,16 +296,14 @@ std::string BgImage::GetBodySourceCode(bool arrayElement) const bodyStr += StringHelper::Sprintf("0x%04X, ", unk_00); bodyStr += StringHelper::Sprintf("%i, ", id); bodyStr += "\n "; - if (arrayElement) - { - bodyStr += " "; - } + bodyStr += " "; } - std::string backgroundName = parent->GetDeclarationPtrName(source); + std::string backgroundName; + Globals::Instance->GetSegmentedPtrName(source, parent, "", backgroundName); bodyStr += StringHelper::Sprintf("%s, ", backgroundName.c_str()); bodyStr += "\n "; - if (arrayElement) + if (!isSubStruct) { bodyStr += " "; } @@ -348,7 +311,7 @@ std::string BgImage::GetBodySourceCode(bool arrayElement) const bodyStr += StringHelper::Sprintf("0x%08X, ", unk_0C); bodyStr += StringHelper::Sprintf("0x%08X, ", tlut); bodyStr += "\n "; - if (arrayElement) + if (!isSubStruct) { bodyStr += " "; } @@ -356,7 +319,7 @@ std::string BgImage::GetBodySourceCode(bool arrayElement) const bodyStr += StringHelper::Sprintf("%i, ", width); bodyStr += StringHelper::Sprintf("%i, ", height); bodyStr += "\n "; - if (arrayElement) + if (!isSubStruct) { bodyStr += " "; } @@ -364,14 +327,14 @@ std::string BgImage::GetBodySourceCode(bool arrayElement) const bodyStr += StringHelper::Sprintf("%i, ", fmt); bodyStr += StringHelper::Sprintf("%i, ", siz); bodyStr += "\n "; - if (arrayElement) + if (!isSubStruct) { bodyStr += " "; } bodyStr += StringHelper::Sprintf("0x%04X, ", mode0); bodyStr += StringHelper::Sprintf("0x%04X, ", tlutCount); - if (arrayElement) + if (!isSubStruct) { bodyStr += " \n }, "; } @@ -383,41 +346,26 @@ std::string BgImage::GetBodySourceCode(bool arrayElement) const return bodyStr; } -std::string BgImage::GetDefaultName(const std::string& prefix, uint32_t address) -{ - return StringHelper::Sprintf("%sBgImage_%06X", prefix.c_str(), address); -} - -std::string BgImage::GetSourceTypeName() +std::string BgImage::GetSourceTypeName() const { return "BgImage"; } -std::string BgImage::GetName() +ZResourceType BgImage::GetResourceType() const { - return name; + // TODO + return ZResourceType::Error; } /* PolygonType section */ -PolygonTypeBase::PolygonTypeBase(ZFile* nParent, - [[maybe_unused]] const std::vector& nRawData, - uint32_t nRawDataIndex, ZRoom* nRoom) - : rawDataIndex{nRawDataIndex}, parent{nParent}, zRoom{nRoom} +PolygonTypeBase::PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) + : ZResource(nParent), zRoom{nRoom} { + rawDataIndex = nRawDataIndex; type = BitConverter::ToUInt8BE(parent->GetRawData(), rawDataIndex); } -void PolygonTypeBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) -{ - std::string auxName = name; - if (name == "") - auxName = GetDefaultName(prefix); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); -} - void PolygonTypeBase::DeclareAndGenerateOutputCode(const std::string& prefix) { std::string bodyStr = GetBodySourceCode(); @@ -448,25 +396,14 @@ std::string PolygonTypeBase::GetSourceTypeName() const } } -std::string PolygonTypeBase::GetName() const +ZResourceType PolygonTypeBase::GetResourceType() const { - return name; + // TODO + return ZResourceType::Error; } -void PolygonTypeBase::SetName(const std::string& newName) -{ - name = newName; -} - -std::string PolygonTypeBase::GetDefaultName(const std::string& prefix) const -{ - return StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), GetSourceTypeName().c_str(), - rawDataIndex); -} - -PolygonType1::PolygonType1(ZFile* nParent, const std::vector& nRawData, - uint32_t nRawDataIndex, ZRoom* nRoom) - : PolygonTypeBase(nParent, nRawData, nRawDataIndex, nRoom) +PolygonType1::PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) + : PolygonTypeBase(nParent, nRawDataIndex, nRoom), single(nParent) { } @@ -485,10 +422,10 @@ void PolygonType1::ParseRawData() if (dlist != 0) { - PolygonDlist polyGfxList(zRoom->GetName(), rawData, - Seg2Filespace(dlist, parent->baseAddress), parent, zRoom); + PolygonDlist polyGfxList(parent); + polyGfxList.zRoom = zRoom; polyGfxList.SetPolyType(type); - polyGfxList.ParseRawData(); + polyGfxList.ExtractFromFile(Seg2Filespace(dlist, parent->baseAddress)); polyGfxList.DeclareReferences(zRoom->GetName()); polyDLists.push_back(polyGfxList); } @@ -496,26 +433,27 @@ void PolygonType1::ParseRawData() void PolygonType1::DeclareReferences(const std::string& prefix) { - polyDLists.at(0).DeclareAndGenerateOutputCode(); + polyDLists.at(0).GetSourceOutputCode(prefix); uint32_t listAddress; - std::string bgImageArrayBody = ""; + std::string bgImageArrayBody; switch (format) { case 1: - single = BgImage(true, prefix, parent->GetRawData(), rawDataIndex + 0x08, parent); + single = BgImage(true, prefix, rawDataIndex + 0x08, parent); break; case 2: if (list != 0) { listAddress = Seg2Filespace(list, parent->baseAddress); + uint32_t auxPtr = listAddress; for (size_t i = 0; i < count; ++i) { - BgImage bg(false, prefix, parent->GetRawData(), - listAddress + i * BgImage::GetRawDataSize(), parent); + BgImage bg(false, prefix, auxPtr, parent); multiList.push_back(bg); - bgImageArrayBody += bg.GetBodySourceCode(true); + auxPtr += bg.GetRawDataSize(); + bgImageArrayBody += bg.GetBodySourceCode(); if (i + 1 < count) { bgImageArrayBody += "\n"; @@ -526,9 +464,9 @@ void PolygonType1::DeclareReferences(const std::string& prefix) if (decl == nullptr) { parent->AddDeclarationArray( - listAddress, DeclarationAlignment::Align4, count * BgImage::GetRawDataSize(), - BgImage::GetSourceTypeName(), multiList.at(0).GetName().c_str(), count, - bgImageArrayBody); + listAddress, DeclarationAlignment::Align4, + count * multiList.at(0).GetRawDataSize(), multiList.at(0).GetSourceTypeName(), + multiList.at(0).GetName().c_str(), count, bgImageArrayBody); } } break; @@ -560,26 +498,26 @@ std::string PolygonType1::GetBodySourceCode() const bodyStr += "{ "; bodyStr += StringHelper::Sprintf("%i, %i, ", type, format); - std::string dlistStr = parent->GetDeclarationPtrName(dlist); + std::string dlistStr; + Globals::Instance->GetSegmentedPtrName(dlist, parent, "", dlistStr); + bodyStr += StringHelper::Sprintf("%s, ", dlistStr.c_str()); bodyStr += "}, \n"; std::string listStr = "NULL"; - // bodyStr += " { \n"; switch (format) { case 1: - bodyStr += single.GetBodySourceCode(false); + bodyStr += single.GetBodySourceCode(); break; case 2: - listStr = parent->GetDeclarationPtrName(list); + Globals::Instance->GetSegmentedPtrName(list, parent, "BgImage", listStr); bodyStr += StringHelper::Sprintf(" %i, %s, \n", count, listStr.c_str()); break; default: break; } - // bodyStr += " } \n"; return bodyStr; } @@ -598,9 +536,8 @@ std::string PolygonType1::GetSourceTypeName() const // return "PolygonType1"; } -PolygonType2::PolygonType2(ZFile* nParent, const std::vector& nRawData, - uint32_t nRawDataIndex, ZRoom* nRoom) - : PolygonTypeBase(nParent, nRawData, nRawDataIndex, nRoom) +PolygonType2::PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom) + : PolygonTypeBase(nParent, nRawDataIndex, nRoom) { } @@ -616,9 +553,10 @@ void PolygonType2::ParseRawData() uint32_t currentPtr = GETSEGOFFSET(start); for (size_t i = 0; i < num; i++) { - PolygonDlist entry(zRoom->GetName(), rawData, currentPtr, parent, zRoom); + PolygonDlist entry(parent); + entry.zRoom = zRoom; entry.SetPolyType(type); - entry.ParseRawData(); + entry.ExtractFromFile(currentPtr); entry.DeclareReferences(zRoom->GetName()); polyDLists.push_back(entry); currentPtr += entry.GetRawDataSize(); @@ -629,17 +567,18 @@ void PolygonType2::DeclareReferences(const std::string& prefix) { if (num > 0) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < polyDLists.size(); i++) { - declaration += polyDLists.at(i).GetBodySourceCode(true); + declaration += + StringHelper::Sprintf("\t{ %s },", polyDLists.at(i).GetBodySourceCode().c_str()); if (i + 1 < polyDLists.size()) declaration += "\n"; } std::string polyDlistType = polyDLists.at(0).GetSourceTypeName(); - std::string polyDListName = ""; + std::string polyDListName; polyDListName = StringHelper::Sprintf("%s%s_%06X", prefix.c_str(), polyDlistType.c_str(), GETSEGOFFSET(start)); @@ -648,13 +587,16 @@ void PolygonType2::DeclareReferences(const std::string& prefix) polyDlistType, polyDListName, polyDLists.size(), declaration); } - parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4, 4, "static s32", - "terminatorMaybe", "0x01000000"); + parent->AddDeclaration(GETSEGOFFSET(end), DeclarationAlignment::Align4, 4, "s32", + StringHelper::Sprintf("%s_terminatorMaybe_%06X", + parent->GetName().c_str(), GETSEGOFFSET(end)), + "0x01000000"); } std::string PolygonType2::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(start); + std::string listName; + Globals::Instance->GetSegmentedPtrName(start, parent, "", listName); std::string body = StringHelper::Sprintf("\n %i, %i,\n", type, polyDLists.size()); body += StringHelper::Sprintf(" %s,\n", listName.c_str()); @@ -667,3 +609,8 @@ size_t PolygonType2::GetRawDataSize() const { return 0x0C; } + +DeclarationAlignment PolygonType2::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align4; +} diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h index 65591966c..566711a9a 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.h @@ -5,9 +5,11 @@ #include "ZDisplayList.h" #include "ZRoom/ZRoomCommand.h" -class PolygonDlist +class PolygonDlist : public ZResource { public: + ZRoom* zRoom; + uint8_t polyType; int16_t x, y, z; // polyType == 2 @@ -19,35 +21,27 @@ public: ZDisplayList* opaDList = nullptr; // Gfx* ZDisplayList* xluDList = nullptr; // Gfx* - PolygonDlist() = default; - PolygonDlist(const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent, ZRoom* nRoom); + PolygonDlist(ZFile* nParent); - void ParseRawData(); - void DeclareReferences(const std::string& prefix); + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceOutputCode(const std::string& prefix) override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; - size_t GetRawDataSize() const; void SetPolyType(uint8_t nPolyType); - void DeclareVar(const std::string& prefix, const std::string& bodyStr); - - std::string GetBodySourceCode(bool arrayElement); - void DeclareAndGenerateOutputCode(); - - static std::string GetDefaultName(const std::string& prefix, uint32_t address); - std::string GetSourceTypeName(); - std::string GetName(); - protected: - uint32_t rawDataIndex; - ZFile* parent; - ZRoom* zRoom; - std::string name; - ZDisplayList* MakeDlist(segptr_t ptr, const std::string& prefix); }; -class BgImage +class BgImage : public ZResource { public: uint16_t unk_00; @@ -64,59 +58,39 @@ public: ZBackground* sourceBackground; - uint32_t rawDataIndex; - ZFile* parent; - std::string name; bool isSubStruct; + BgImage(ZFile* nParent); + BgImage(bool nIsSubStruct, const std::string& prefix, uint32_t nRawDataIndex, ZFile* nParent); + + void ParseRawData() override; + + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + protected: - void ParseRawData(); ZBackground* MakeBackground(segptr_t ptr, const std::string& prefix); - -public: - BgImage() = default; - BgImage(bool nIsSubStruct, const std::string& prefix, const std::vector& nRawData, - uint32_t nRawDataIndex, ZFile* nParent); - - static size_t GetRawDataSize(); - - std::string GetBodySourceCode(bool arrayElement) const; - - static std::string GetDefaultName(const std::string& prefix, uint32_t address); - static std::string GetSourceTypeName(); - std::string GetName(); }; -class PolygonTypeBase +class PolygonTypeBase : public ZResource { public: uint8_t type; std::vector polyDLists; - PolygonTypeBase(ZFile* nParent, const std::vector& nRawData, uint32_t nRawDataIndex, - ZRoom* nRoom); - virtual ~PolygonTypeBase() = default; + PolygonTypeBase(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); - virtual void ParseRawData() = 0; - virtual void DeclareReferences(const std::string& prefix) = 0; - - virtual std::string GetBodySourceCode() const = 0; - void DeclareVar(const std::string& prefix, const std::string& bodyStr); void DeclareAndGenerateOutputCode(const std::string& prefix); - virtual std::string GetSourceTypeName() const; - - std::string GetName() const; - void SetName(const std::string& newName); - virtual size_t GetRawDataSize() const = 0; - - std::string GetDefaultName(const std::string& prefix) const; + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; protected: - uint32_t rawDataIndex; - ZFile* parent; ZRoom* zRoom; - std::string name; }; class PolygonType1 : public PolygonTypeBase @@ -133,8 +107,7 @@ public: segptr_t list; // BgImage* std::vector multiList; - PolygonType1(ZFile* nParent, const std::vector& nRawData, uint32_t nRawDataIndex, - ZRoom* nRoom); + PolygonType1(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; @@ -153,8 +126,7 @@ public: segptr_t start; segptr_t end; - PolygonType2(ZFile* nParent, const std::vector& nRawData, uint32_t nRawDataIndex, - ZRoom* nRoom); + PolygonType2(ZFile* nParent, uint32_t nRawDataIndex, ZRoom* nRoom); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; @@ -162,8 +134,7 @@ public: std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; - -protected: + DeclarationAlignment GetDeclarationAlignment() const override; }; class SetMesh : public ZRoomCommand diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp index 75f032f8a..ec432b7d9 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp @@ -28,7 +28,7 @@ void SetMinimapChests::ParseRawData() void SetMinimapChests::DeclareReferences(const std::string& prefix) { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& chest : chests) @@ -42,14 +42,15 @@ void SetMinimapChests::DeclareReferences(const std::string& prefix) } parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, chests.size() * 10, "MinimapChest", + segmentOffset, DeclarationAlignment::Align4, chests.size() * 10, "MinimapChest", StringHelper::Sprintf("%sMinimapChests0x%06X", prefix.c_str(), segmentOffset), chests.size(), declaration); } std::string SetMinimapChests::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapChest", listName); return StringHelper::Sprintf("SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(0x%02X, %s)", chests.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp index c81fb200c..be5d8f15d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp @@ -31,7 +31,7 @@ void SetMinimapList::ParseRawData() void SetMinimapList::DeclareReferences(const std::string& prefix) { { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& entry : minimaps) @@ -51,7 +51,8 @@ void SetMinimapList::DeclareReferences(const std::string& prefix) } { - std::string listName = parent->GetDeclarationPtrName(listSegmentAddr); + std::string listName; + Globals::Instance->GetSegmentedPtrName(listSegmentAddr, parent, "MinimapEntry", listName); std::string declaration = StringHelper::Sprintf("\n\t%s, 0x%08X\n", listName.c_str(), unk4); parent->AddDeclaration( @@ -63,7 +64,8 @@ void SetMinimapList::DeclareReferences(const std::string& prefix) std::string SetMinimapList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "MinimapList", listName); return StringHelper::Sprintf("SCENE_CMD_MINIMAP_INFO(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp index 9e3e9bb7f..fdd41e6cb 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp @@ -23,16 +23,13 @@ void SetObjectList::ParseRawData() objects.push_back(objectIndex); currentPtr += 2; } - - if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); } void SetObjectList::DeclareReferences(const std::string& prefix) { if (!objects.empty()) { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < objects.size(); i++) { @@ -45,7 +42,7 @@ void SetObjectList::DeclareReferences(const std::string& prefix) } parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, objects.size() * 2, "s16", + segmentOffset, DeclarationAlignment::Align4, objects.size() * 2, "s16", StringHelper::Sprintf("%sObjectList_%06X", prefix.c_str(), segmentOffset), objects.size(), declaration); } @@ -53,7 +50,8 @@ void SetObjectList::DeclareReferences(const std::string& prefix) std::string SetObjectList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "s16", listName); return StringHelper::Sprintf("SCENE_CMD_OBJECT_LIST(%i, %s)", objects.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp index 0f7b4beda..52d400a84 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.cpp @@ -1,4 +1,5 @@ #include "SetPathways.h" + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -12,7 +13,11 @@ SetPathways::SetPathways(ZFile* nParent) : ZRoomCommand(nParent), pathwayList(nP void SetPathways::DeclareReferences([[maybe_unused]] const std::string& prefix) { if (segmentOffset != 0) - parent->AddDeclarationPlaceholder(segmentOffset); + { + std::string varName = + StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset); + parent->AddDeclarationPlaceholder(segmentOffset, varName); + } } void SetPathways::ParseRawDataLate() @@ -23,20 +28,21 @@ void SetPathways::ParseRawDataLate() pathwayList.SetNumPaths(numPaths); } - pathwayList.SetRawDataIndex(segmentOffset); - pathwayList.ParseRawData(); + pathwayList.ExtractFromFile(segmentOffset); } void SetPathways::DeclareReferencesLate(const std::string& prefix) { - pathwayList.SetName(StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset)); + std::string varName = StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset); + pathwayList.SetName(varName); pathwayList.DeclareReferences(prefix); pathwayList.GetSourceOutputCode(prefix); } std::string SetPathways::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "Path", listName); return StringHelper::Sprintf("SCENE_CMD_PATH_LIST(%s)", listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h index cc754f752..9abc93d32 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetPathways.h @@ -17,8 +17,6 @@ public: void ParseRawDataLate() override; void DeclareReferencesLate(const std::string& prefix) override; - void DeclareVar(const std::string& prefix, const std::string& bodyStr); - std::string GetBodySourceCode() const override; RoomCommand GetRoomCommand() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp index 426804b57..8c6f4bf51 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomBehavior.cpp @@ -1,4 +1,5 @@ #include "SetRoomBehavior.h" + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 6d697fa37..43c396822 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -16,9 +16,8 @@ void SetRoomList::ParseRawData() int numRooms = cmdArg1; romfile = new RomFile(parent); - romfile->SetRawDataIndex(segmentOffset); romfile->numRooms = numRooms; - romfile->ParseRawData(); + romfile->ExtractFromFile(segmentOffset); parent->resources.push_back(romfile); @@ -34,8 +33,9 @@ void SetRoomList::DeclareReferences(const std::string& prefix) std::string SetRoomList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); - return StringHelper::Sprintf("SCENE_CMD_ROOM_LIST(%i, %s)", romfile->numRooms, + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "RomFile", listName); + return StringHelper::Sprintf("SCENE_CMD_ROOM_LIST(%i, %s)", romfile->rooms.size(), listName.c_str()); } @@ -78,20 +78,20 @@ void RomFile::ParseRawData() } } -void RomFile::DeclareVar(const std::string& prefix, const std::string body) +Declaration* RomFile::DeclareVar(const std::string& prefix, const std::string& body) { std::string auxName = name; if (name == "") auxName = StringHelper::Sprintf("%sRoomList0x%06X", prefix.c_str(), rawDataIndex); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, - rooms.size() * rooms.at(0).GetRawDataSize(), GetSourceTypeName(), - auxName, 0, body); + return parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, + rooms.size() * rooms.at(0).GetRawDataSize(), + GetSourceTypeName(), auxName, rooms.size(), body); } std::string RomFile::GetBodySourceCode() const { - std::string declaration = ""; + std::string declaration; bool isFirst = true; for (ZFile* file : Globals::Instance->files) diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h index ae2035115..4fb2ced17 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.h @@ -22,7 +22,7 @@ public: void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; - void DeclareVar(const std::string& prefix, const std::string body); + Declaration* DeclareVar(const std::string& prefix, const std::string& body) override; std::string GetBodySourceCode() const override; std::string GetSourceOutputCode(const std::string& prefix) override; @@ -38,7 +38,6 @@ public: class SetRoomList : public ZRoomCommand { public: - std::vector rooms; // Borrowed reference. Don't delete. RomFile* romfile = nullptr; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp index 5e160121b..f75b5e0d5 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp @@ -29,7 +29,7 @@ void SetStartPositionList::DeclareReferences(const std::string& prefix) { if (!actors.empty()) { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& entry : actors) @@ -43,14 +43,15 @@ void SetStartPositionList::DeclareReferences(const std::string& prefix) parent->AddDeclarationArray( segmentOffset, DeclarationAlignment::Align4, actors.size() * 16, "ActorEntry", - StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset), 0, - declaration); + StringHelper::Sprintf("%sStartPositionList0x%06X", prefix.c_str(), segmentOffset), + actors.size(), declaration); } } std::string SetStartPositionList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName); return StringHelper::Sprintf("SCENE_CMD_SPAWN_LIST(%i, %s)", actors.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp index 9065bf153..a33d1c6e1 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp @@ -28,7 +28,7 @@ void SetTransitionActorList::ParseRawData() void SetTransitionActorList::DeclareReferences(const std::string& prefix) { - std::string declaration = ""; + std::string declaration; size_t index = 0; for (const auto& entry : transitionActors) @@ -43,15 +43,16 @@ void SetTransitionActorList::DeclareReferences(const std::string& prefix) } parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, transitionActors.size() * 16, + segmentOffset, DeclarationAlignment::Align4, transitionActors.size() * 16, "TransitionActorEntry", - StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset), 0, - declaration); + StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset), + transitionActors.size(), declaration); } std::string SetTransitionActorList::GetBodySourceCode() const { - std::string listName = parent->GetDeclarationPtrName(cmdArg2); + std::string listName; + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "TransitionActorEntry", listName); return StringHelper::Sprintf("SCENE_CMD_TRANSITION_ACTOR_LIST(%i, %s)", transitionActors.size(), listName.c_str()); } diff --git a/tools/ZAPD/ZAPD/ZRoom/ZNames.h b/tools/ZAPD/ZAPD/ZRoom/ZNames.h index d8488a6f1..94e08de0d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZNames.h +++ b/tools/ZAPD/ZAPD/ZRoom/ZNames.h @@ -29,7 +29,7 @@ public: { int32_t flags = id & 0xF000; id &= 0xFFF; - std::string name = ""; + std::string name; if (id < ZNames::GetNumActors()) name = Globals::Instance->cfg.actorList.at(id); else diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp index 0ef3724d1..edc0cad02 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp @@ -1,9 +1,8 @@ #include "ZRoom.h" - #include #include #include - +#include #include "Commands/EndMarker.h" #include "Commands/SetActorCutsceneList.h" #include "Commands/SetActorList.h" @@ -113,7 +112,6 @@ void ZRoom::ParseXML(tinyxml2::XMLElement* reader) std::string nodeName = std::string(reader->Name()); if (nodeName == "Scene") { - Globals::Instance->lastScene = this; zroomType = ZResourceType::Scene; } else if (nodeName == "Room") @@ -293,7 +291,7 @@ void ZRoom::DeclareReferencesLate(const std::string& prefix) cmd->DeclareReferencesLate(prefix); } -void ZRoom::DeclareVar(const std::string& prefix, const std::string body) +Declaration* ZRoom::DeclareVar(const std::string& prefix, const std::string& body) { std::string auxName = name; if (auxName == "") @@ -301,13 +299,16 @@ void ZRoom::DeclareVar(const std::string& prefix, const std::string body) if (zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room) auxName = StringHelper::Sprintf("%sCommands", name.c_str()); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, 0, body); + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, commands.size(), body); + decl->staticConf = staticConf; + return decl; } std::string ZRoom::GetBodySourceCode() const { - std::string declaration = ""; + std::string declaration; for (size_t i = 0; i < commands.size(); i++) { @@ -327,17 +328,17 @@ std::string ZRoom::GetDefaultName(const std::string& prefix) const } /* - * There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates back to very - * early in the game's development. Since this room is a special case, declare automatically the - * data its contains whitout the need of a header. + * There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates + * back to very early in the game's development. Since this room is a special case, + * declare automatically the data its contains whitout the need of a header. */ void ZRoom::SyotesRoomHack() { - PolygonType2 poly(parent, parent->GetRawData(), 0, this); + PolygonType2 poly(parent, 0, this); poly.ParseRawData(); poly.DeclareReferences(GetName()); - parent->AddDeclaration(0, DeclarationAlignment::Align4, poly.GetRawDataSize(), + parent->AddDeclaration(0, poly.GetDeclarationAlignment(), poly.GetRawDataSize(), poly.GetSourceTypeName(), poly.GetDefaultName(GetName()), poly.GetBodySourceCode()); } @@ -391,32 +392,14 @@ size_t ZRoom::GetCommandSizeFromNeighbor(ZRoomCommand* cmd) return 0; } -std::string ZRoom::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) -{ - return "\n" + extDefines + "\n\n"; -} - std::string ZRoom::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) { - std::string sourceOutput = ""; - - if (zroomType == ZResourceType::Scene || zroomType == ZResourceType::Room) - { - sourceOutput += "#include \"segment_symbols.h\"\n"; - sourceOutput += "#include \"command_macros_base.h\"\n"; - sourceOutput += "#include \"z64cutscene_commands.h\"\n"; - sourceOutput += "#include \"variables.h\"\n"; - - if (Globals::Instance->lastScene != nullptr) - sourceOutput += Globals::Instance->lastScene->parent->GetHeaderInclude(); - } - if (hackMode == "syotes_room") - return sourceOutput; + return ""; DeclareVar(prefix, GetBodySourceCode()); - return sourceOutput; + return ""; } size_t ZRoom::GetRawDataSize() const diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.h b/tools/ZAPD/ZAPD/ZRoom/ZRoom.h index 993baafe7..0993a9d30 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.h +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.h @@ -14,9 +14,7 @@ public: std::vector commands; int32_t roomCount; // Only valid for scenes - std::string extDefines; - - std::string hackMode = ""; + std::string hackMode; ZResourceType zroomType = ZResourceType::Error; ZResourceType parentZroomType = ZResourceType::Error; @@ -33,21 +31,20 @@ public: void ParseRawDataLate() override; void DeclareReferencesLate(const std::string& prefix) override; - void DeclareVar(const std::string& prefix, const std::string body); + Declaration* DeclareVar(const std::string& prefix, const std::string& body) override; std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const; + std::string GetSourceOutputCode(const std::string& prefix) override; + + std::string GetDefaultName(const std::string& prefix) const override; size_t GetDeclarationSizeFromNeighbor(uint32_t declarationAddress); size_t GetCommandSizeFromNeighbor(ZRoomCommand* cmd); ZRoomCommand* FindCommandOfType(RoomCommand cmdType); - std::string GetSourceTypeName() const override; - size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; protected: - std::string GetSourceOutputHeader(const std::string& prefix) override; - std::string GetSourceOutputCode(const std::string& prefix) override; void SyotesRoomHack(); }; diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.cpp b/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.cpp index 3f5876eaf..711c86a40 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.cpp @@ -27,11 +27,6 @@ void ZRoomCommand::ParseRawData() segmentOffset = Seg2Filespace(cmdArg2, parent->baseAddress); } -std::string ZRoomCommand::GetSourceTypeName() const -{ - return "SCmdBase"; -} - RoomCommand ZRoomCommand::GetRoomCommand() const { return RoomCommand::Error; @@ -42,6 +37,11 @@ size_t ZRoomCommand::GetRawDataSize() const return 0x08; } +std::string ZRoomCommand::GetSourceTypeName() const +{ + return GetCommandCName(); +} + ZResourceType ZRoomCommand::GetResourceType() const { return ZResourceType::RoomCommand; diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.h b/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.h index b79dc3e16..e4029984c 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.h +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoomCommand.h @@ -57,7 +57,7 @@ public: uint32_t cmdIndex; uint32_t commandSet; RoomCommand cmdID; - uint32_t segmentOffset; + offset_t segmentOffset; ZRoomCommand(ZFile* nParent); virtual ~ZRoomCommand() = default; diff --git a/tools/ZAPD/ZAPD/ZScalar.cpp b/tools/ZAPD/ZAPD/ZScalar.cpp index 007c1cd03..062fb0e07 100644 --- a/tools/ZAPD/ZAPD/ZScalar.cpp +++ b/tools/ZAPD/ZAPD/ZScalar.cpp @@ -1,4 +1,5 @@ #include "ZScalar.h" + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" @@ -14,9 +15,16 @@ ZScalar::ZScalar(ZFile* nParent) : ZResource(nParent) RegisterRequiredAttribute("Type"); } -ZScalar::ZScalar(const ZScalarType scalarType, ZFile* nParent) : ZScalar(nParent) +void ZScalar::ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType) { - this->scalarType = scalarType; + rawDataIndex = nRawDataIndex; + scalarType = nScalarType; + + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + + ParseRawData(); } void ZScalar::ParseXML(tinyxml2::XMLElement* reader) @@ -247,15 +255,6 @@ std::string ZScalar::GetBodySourceCode() const } } -std::string ZScalar::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - if (parent != nullptr) - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), GetName(), GetBodySourceCode()); - - return ""; -} - ZResourceType ZScalar::GetResourceType() const { return ZResourceType::Scalar; @@ -265,3 +264,16 @@ bool ZScalar::DoesSupportArray() const { return true; } + +DeclarationAlignment ZScalar::GetDeclarationAlignment() const +{ + switch (scalarType) + { + case ZScalarType::ZSCALAR_S64: + case ZScalarType::ZSCALAR_U64: + case ZScalarType::ZSCALAR_F64: + return DeclarationAlignment::Align8; + default: + return DeclarationAlignment::Align4; + } +} diff --git a/tools/ZAPD/ZAPD/ZScalar.h b/tools/ZAPD/ZAPD/ZScalar.h index ca2082756..d269995cc 100644 --- a/tools/ZAPD/ZAPD/ZScalar.h +++ b/tools/ZAPD/ZAPD/ZScalar.h @@ -44,25 +44,25 @@ class ZScalar : public ZResource friend class ZVector; public: + ZScalarData scalarData; + ZScalarType scalarType; + ZScalar(ZFile* nParent); - ZScalar(const ZScalarType scalarType, ZFile* nParent); + + void ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType); void ParseRawData() override; void ParseXML(tinyxml2::XMLElement* reader) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; bool DoesSupportArray() const override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; size_t GetRawDataSize() const override; + DeclarationAlignment GetDeclarationAlignment() const override; static size_t MapTypeToSize(const ZScalarType scalarType); static ZScalarType MapOutputTypeToScalarType(const std::string& type); static std::string MapScalarTypeToOutputType(const ZScalarType scalarType); - -protected: - ZScalarData scalarData; - ZScalarType scalarType; }; diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index 6912f2ea4..84f00c818 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -1,6 +1,8 @@ #include "ZSkeleton.h" #include + +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" @@ -13,14 +15,6 @@ ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent), limbsTable(nParent) RegisterRequiredAttribute("LimbType"); } -void ZSkeleton::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name, ""); -} - void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); @@ -33,24 +27,18 @@ void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) type = ZSkeletonType::Curve; else if (skelTypeXml != "Normal") { - fprintf(stderr, - "ZSkeleton::ParseXML: Warning in '%s'.\n" - "\t Invalid Type found: '%s'.\n" - "\t Defaulting to 'Normal'.\n", - name.c_str(), skelTypeXml.c_str()); - type = ZSkeletonType::Normal; + throw std::runtime_error(StringHelper::Sprintf("ZSkeleton::ParseXML: Error in '%s'.\n" + "\t Invalid Type found: '%s'.\n", + name.c_str(), skelTypeXml.c_str())); } std::string limbTypeXml = registeredAttributes.at("LimbType").value; limbType = ZLimb::GetTypeByAttributeName(limbTypeXml); if (limbType == ZLimbType::Invalid) { - fprintf(stderr, - "ZSkeleton::ParseXML: Warning in '%s'.\n" - "\t Invalid LimbType found: '%s'.\n" - "\t Defaulting to 'Standard'.\n", - name.c_str(), limbTypeXml.c_str()); - limbType = ZLimbType::Standard; + throw std::runtime_error(StringHelper::Sprintf("ZSkeleton::ParseXML: Error in '%s'.\n" + "\t Invalid LimbType found: '%s'.\n", + name.c_str(), limbTypeXml.c_str())); } } @@ -61,7 +49,11 @@ void ZSkeleton::ParseRawData() const auto& rawData = parent->GetRawData(); limbsArrayAddress = BitConverter::ToUInt32BE(rawData, rawDataIndex); limbCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 4); - dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); + + if (type == ZSkeletonType::Flex) + { + dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); + } if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) { @@ -76,6 +68,8 @@ void ZSkeleton::DeclareReferences(const std::string& prefix) if (defaultPrefix == "") defaultPrefix = prefix; + ZResource::DeclareReferences(defaultPrefix); + if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) { uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); @@ -90,22 +84,22 @@ void ZSkeleton::DeclareReferences(const std::string& prefix) std::string ZSkeleton::GetBodySourceCode() const { - std::string limbTableName = parent->GetDeclarationPtrName(limbsArrayAddress); + std::string limbArrayName; + Globals::Instance->GetSegmentedPtrName(limbsArrayAddress, parent, "", limbArrayName); - std::string headerStr; switch (type) { case ZSkeletonType::Normal: case ZSkeletonType::Curve: - headerStr = StringHelper::Sprintf("\n\t%s, %i\n", limbTableName.c_str(), limbCount); - break; + return StringHelper::Sprintf("\n\t%s, %i\n", limbArrayName.c_str(), limbCount); + case ZSkeletonType::Flex: - headerStr = StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbTableName.c_str(), limbCount, - dListCount); - break; + return StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbArrayName.c_str(), limbCount, + dListCount); } - return headerStr; + // TODO: Throw exception? + return "ERROR"; } size_t ZSkeleton::GetRawDataSize() const @@ -121,25 +115,6 @@ size_t ZSkeleton::GetRawDataSize() const } } -std::string ZSkeleton::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string headerStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(GetAddress()); - - if (decl == nullptr) - { - parent->AddDeclaration(GetAddress(), DeclarationAlignment::Align16, GetRawDataSize(), - GetSourceTypeName(), name, headerStr); - } - else - { - decl->text = headerStr; - } - - return ""; -} - std::string ZSkeleton::GetSourceTypeName() const { switch (type) @@ -160,9 +135,9 @@ ZResourceType ZSkeleton::GetResourceType() const return ZResourceType::Skeleton; } -segptr_t ZSkeleton::GetAddress() +DeclarationAlignment ZSkeleton::GetDeclarationAlignment() const { - return rawDataIndex; + return DeclarationAlignment::Align16; } uint8_t ZSkeleton::GetLimbCount() @@ -178,14 +153,6 @@ ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent) RegisterRequiredAttribute("Count"); } -void ZLimbTable::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name, limbsAddresses.size(), ""); -} - void ZLimbTable::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount) { rawDataIndex = nRawDataIndex; @@ -229,9 +196,9 @@ void ZLimbTable::ParseRawData() void ZLimbTable::DeclareReferences(const std::string& prefix) { - std::string varPrefix = prefix; - if (name != "") - varPrefix = name; + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; ZResource::DeclareReferences(varPrefix); @@ -244,22 +211,39 @@ void ZLimbTable::DeclareReferences(const std::string& prefix) uint32_t limbOffset = Seg2Filespace(limbAddress, parent->baseAddress); if (!parent->HasDeclaration(limbOffset)) { - ZLimb* limb = new ZLimb(limbType, varPrefix, limbOffset, parent); + ZLimb* limb = new ZLimb(parent); + limb->ExtractFromBinary(limbOffset, limbType); + limb->SetName(limb->GetDefaultName(varPrefix)); + limb->DeclareVar(varPrefix, ""); limb->DeclareReferences(varPrefix); - limb->GetSourceOutputCode(varPrefix); parent->AddResource(limb); } } } } +Declaration* ZLimbTable::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, limbsAddresses.size(), bodyStr); + decl->staticConf = staticConf; + return decl; +} + std::string ZLimbTable::GetBodySourceCode() const { - std::string body = ""; + std::string body; for (size_t i = 0; i < count; i++) { - std::string limbName = parent->GetDeclarationPtrName(limbsAddresses[i]); + std::string limbName; + Globals::Instance->GetSegmentedPtrName(limbsAddresses[i], parent, "", limbName); body += StringHelper::Sprintf("\t%s,", limbName.c_str()); if (i + 1 < count) @@ -269,20 +253,6 @@ std::string ZLimbTable::GetBodySourceCode() const return body; } -std::string ZLimbTable::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string body = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - if (decl == nullptr || decl->isPlaceholder) - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), name, limbsAddresses.size(), body); - else - decl->text = body; - - return ""; -} - std::string ZLimbTable::GetSourceTypeName() const { switch (limbType) diff --git a/tools/ZAPD/ZAPD/ZSkeleton.h b/tools/ZAPD/ZAPD/ZSkeleton.h index fb658503e..ed003ceaf 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.h +++ b/tools/ZAPD/ZAPD/ZSkeleton.h @@ -20,15 +20,15 @@ class ZLimbTable : public ZResource public: ZLimbTable(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; - std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + + std::string GetBodySourceCode() const override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; @@ -53,21 +53,18 @@ public: ZSkeleton(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; - - size_t GetRawDataSize() const override; - std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - segptr_t GetAddress(); + size_t GetRawDataSize() const override; + DeclarationAlignment GetDeclarationAlignment() const override; + uint8_t GetLimbCount(); protected: diff --git a/tools/ZAPD/ZAPD/ZString.cpp b/tools/ZAPD/ZAPD/ZString.cpp index b54560460..965d4d636 100644 --- a/tools/ZAPD/ZAPD/ZString.cpp +++ b/tools/ZAPD/ZAPD/ZString.cpp @@ -29,19 +29,25 @@ void ZString::ParseRawData() strData.assign(dataStart, dataStart + size); } +Declaration* ZString::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, 0, bodyStr); + decl->staticConf = staticConf; + return decl; +} + std::string ZString::GetBodySourceCode() const { return StringHelper::Sprintf("\t\"%s\"", strData.data()); } -std::string ZString::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), name, 0, GetBodySourceCode()); - - return ""; -} - std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) { return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data()); diff --git a/tools/ZAPD/ZAPD/ZString.h b/tools/ZAPD/ZAPD/ZString.h index 19b4abb1d..6c58ebdcb 100644 --- a/tools/ZAPD/ZAPD/ZString.h +++ b/tools/ZAPD/ZAPD/ZString.h @@ -9,8 +9,9 @@ public: ZString(ZFile* nParent); void ParseRawData() override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; std::string GetSourceOutputHeader(const std::string& prefix) override; std::string GetSourceTypeName() const override; diff --git a/tools/ZAPD/ZAPD/ZSymbol.cpp b/tools/ZAPD/ZAPD/ZSymbol.cpp index 278c80d6c..b24c3de4b 100644 --- a/tools/ZAPD/ZAPD/ZSymbol.cpp +++ b/tools/ZAPD/ZAPD/ZSymbol.cpp @@ -1,4 +1,5 @@ #include "ZSymbol.h" + #include "Utils/StringHelper.h" #include "ZFile.h" @@ -54,6 +55,18 @@ void ZSymbol::ParseXML(tinyxml2::XMLElement* reader) if (countXml != "") count = StringHelper::StrToL(countXml, 0); } + + if (registeredAttributes.at("Static").value == "On") + { + fprintf(stderr, "A can't be marked as static.\n\t Disabling static\n"); + } + staticConf = StaticConfig::Off; +} + +Declaration* ZSymbol::DeclareVar([[maybe_unused]] const std::string& prefix, + [[maybe_unused]] const std::string& bodyStr) +{ + return nullptr; } size_t ZSymbol::GetRawDataSize() const @@ -64,19 +77,17 @@ size_t ZSymbol::GetRawDataSize() const return typeSize; } -std::string ZSymbol::GetSourceOutputHeader(const std::string& prefix) +std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) { if (isArray) { if (count == 0) - return StringHelper::Sprintf("extern %s %s%s[];\n", type.c_str(), prefix.c_str(), - name.c_str()); + return StringHelper::Sprintf("extern %s %s[];\n", type.c_str(), name.c_str()); else - return StringHelper::Sprintf("extern %s %s%s[%i];\n", type.c_str(), prefix.c_str(), - name.c_str(), count); + return StringHelper::Sprintf("extern %s %s[%i];\n", type.c_str(), name.c_str(), count); } - return StringHelper::Sprintf("extern %s %s%s;\n", type.c_str(), prefix.c_str(), name.c_str()); + return StringHelper::Sprintf("extern %s %s;\n", type.c_str(), name.c_str()); } std::string ZSymbol::GetSourceTypeName() const diff --git a/tools/ZAPD/ZAPD/ZSymbol.h b/tools/ZAPD/ZAPD/ZSymbol.h index 1094a0222..7cb14aa9b 100644 --- a/tools/ZAPD/ZAPD/ZSymbol.h +++ b/tools/ZAPD/ZAPD/ZSymbol.h @@ -16,10 +16,12 @@ public: void ParseXML(tinyxml2::XMLElement* reader) override; - size_t GetRawDataSize() const override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetSourceOutputHeader(const std::string& prefix) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; }; diff --git a/tools/ZAPD/ZAPD/ZTexture.cpp b/tools/ZAPD/ZAPD/ZTexture.cpp index 45a6a7cce..33ee54d1b 100644 --- a/tools/ZAPD/ZAPD/ZTexture.cpp +++ b/tools/ZAPD/ZAPD/ZTexture.cpp @@ -1,6 +1,7 @@ #include "ZTexture.h" #include + #include "CRC32.h" #include "Globals.h" #include "Utils/BitConverter.h" @@ -21,21 +22,8 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent) RegisterOptionalAttribute("TlutOffset"); } -void ZTexture::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - - auto filepath = Globals::Instance->outputPath / fs::path(name).stem(); - - std::string incStr = - StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str()); - - parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(), - name, 0); -} - -void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, - TextureType nType, bool nIsPalette) +void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, + TextureType nType, bool nIsPalette) { width = nWidth; height = nHeight; @@ -45,6 +33,10 @@ void ZTexture::FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeigh name = GetDefaultName(parent->GetName()); outName = name; + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + ParseRawData(); CalcHash(); } @@ -339,15 +331,10 @@ void ZTexture::DeclareReferences([[maybe_unused]] const std::string& prefix) if (format == TextureType::Palette4bpp) tlutDim = 4; - auto filepath = Globals::Instance->outputPath / fs::path(name).stem(); - std::string incStr = StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), - GetExternalExtension().c_str()); - tlut = new ZTexture(parent); - tlut->FromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true); + tlut->ExtractFromBinary(tlutOffset, tlutDim, tlutDim, TextureType::RGBA16bpp, true); parent->AddTextureResource(tlutOffset, tlut); - parent->AddDeclarationIncludeArray(tlutOffset, incStr, tlut->GetRawDataSize(), - tlut->GetSourceTypeName(), tlut->GetName(), 0); + tlut->DeclareVar(prefix, ""); } else { @@ -685,7 +672,7 @@ std::string ZTexture::GetIMSizFromType() } } -std::string ZTexture::GetDefaultName(const std::string& prefix) +std::string ZTexture::GetDefaultName(const std::string& prefix) const { const char* suffix = "Tex"; if (isPalette) @@ -746,9 +733,45 @@ void ZTexture::Save(const fs::path& outFolder) #endif } +Declaration* ZTexture::DeclareVar(const std::string& prefix, + [[maybe_unused]] const std::string& bodyStr) +{ + std::string auxName = name; + std::string auxOutName = outName; + + if (auxName == "") + auxName = GetDefaultName(prefix); + + if (auxOutName == "") + auxOutName = GetDefaultName(prefix); + + auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem(); + + std::string incStr = + StringHelper::Sprintf("%s.%s.inc.c", filepath.c_str(), GetExternalExtension().c_str()); + + if (!Globals::Instance->cfg.texturePool.empty()) + { + CalcHash(); + + // TEXTURE POOL CHECK + const auto& poolEntry = Globals::Instance->cfg.texturePool.find(hash); + if (poolEntry != Globals::Instance->cfg.texturePool.end()) + { + incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.c_str(), + GetExternalExtension().c_str()); + } + } + + Declaration* decl = parent->AddDeclarationIncludeArray( + rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(), auxName, GetRawDataSize() / 8); + decl->staticConf = staticConf; + return decl; +} + std::string ZTexture::GetBodySourceCode() const { - std::string sourceOutput = ""; + std::string sourceOutput; for (size_t i = 0; i < textureDataRaw.size(); i += 8) { @@ -826,7 +849,7 @@ fs::path ZTexture::GetPoolOutPath(const fs::path& defaultValue) return defaultValue; } -TextureType ZTexture::GetTextureTypeFromString(std::string str) +TextureType ZTexture::GetTextureTypeFromString(const std::string& str) { TextureType texType = TextureType::Error; diff --git a/tools/ZAPD/ZAPD/ZTexture.h b/tools/ZAPD/ZAPD/ZTexture.h index 2ec4a4c89..ef67c3f6e 100644 --- a/tools/ZAPD/ZAPD/ZTexture.h +++ b/tools/ZAPD/ZAPD/ZTexture.h @@ -55,15 +55,16 @@ public: bool isPalette = false; - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; - void FromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, TextureType nType, - bool nIsPalette); + void ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, + TextureType nType, bool nIsPalette); void FromPNG(const fs::path& pngFilePath, TextureType texType); - static TextureType GetTextureTypeFromString(std::string str); + static TextureType GetTextureTypeFromString(const std::string& str); void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; void CalcHash() override; void Save(const fs::path& outFolder) override; @@ -76,7 +77,7 @@ public: size_t GetRawDataSize() const override; std::string GetIMFmtFromType(); std::string GetIMSizFromType(); - std::string GetDefaultName(const std::string& prefix); + std::string GetDefaultName(const std::string& prefix) const override; uint32_t GetWidth() const; uint32_t GetHeight() const; void SetDimensions(uint32_t nWidth, uint32_t nHeight); diff --git a/tools/ZAPD/ZAPD/ZTextureAnimation.cpp b/tools/ZAPD/ZAPD/ZTextureAnimation.cpp index e8236f186..4332fcf1e 100644 --- a/tools/ZAPD/ZAPD/ZTextureAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZTextureAnimation.cpp @@ -75,9 +75,11 @@ * Each of these will declare all its subsidiary arrays, using POD structs. */ #include "ZTextureAnimation.h" + #include #include #include + #include "Globals.h" #include "Utils/BitConverter.h" #include "ZFile.h" @@ -125,32 +127,6 @@ ZTextureAnimationParams::GetDefaultName([[maybe_unused]] const std::string& pref return "ShouldNotBeVIsible"; } -void ZTextureAnimationParams::DeclareVar(const std::string& prefix, - const std::string& bodyStr) const -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); -} - -std::string ZTextureAnimationParams::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - ZResourceType ZTextureAnimationParams::GetResourceType() const { return ZResourceType::TextureAnimationParams; @@ -197,24 +173,25 @@ size_t TextureScrollingParams::GetRawDataSize() const /** * Overrides the parent version to declare an array of the params rather than just one entry. */ -void TextureScrollingParams::DeclareVar(const std::string& prefix, const std::string& bodyStr) const +Declaration* TextureScrollingParams::DeclareVar(const std::string& prefix, + const std::string& bodyStr) { std::string auxName = name; if (name == "") auxName = GetDefaultName(prefix); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, count, bodyStr); + return parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, count, bodyStr); } std::string TextureScrollingParams::GetBodySourceCode() const { - std::string bodyStr = ""; + std::string bodyStr; for (int i = 0; i < count; i++) { - bodyStr += StringHelper::Sprintf(" { %d, %d, 0x%02X, 0x%02X },\n", rows[i].xStep, + bodyStr += StringHelper::Sprintf("\t{ %d, %d, 0x%02X, 0x%02X },\n", rows[i].xStep, rows[i].yStep, rows[i].width, rows[i].height); } @@ -318,11 +295,11 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s { if (primColorListAddress != 0) // NULL { - std::string primColorBodyStr = ""; + std::string primColorBodyStr; for (const auto& color : primColorList) { - primColorBodyStr += StringHelper::Sprintf(" { %d, %d, %d, %d, %d },\n", color.r, + primColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d, %d },\n", color.r, color.g, color.b, color.a, color.lodFrac); } @@ -338,11 +315,11 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s if (envColorListAddress != 0) // NULL { - std::string envColorBodyStr = ""; + std::string envColorBodyStr; for (const auto& color : envColorList) { - envColorBodyStr += StringHelper::Sprintf(" { %d, %d, %d, %d },\n", color.r, color.g, + envColorBodyStr += StringHelper::Sprintf("\t{ %d, %d, %d, %d },\n", color.r, color.g, color.b, color.a); } @@ -358,7 +335,7 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s if (frameDataListAddress != 0) // NULL { - std::string frameDataBodyStr = " "; + std::string frameDataBodyStr = "\t"; for (const auto& frame : frameDataList) { @@ -378,11 +355,17 @@ void TextureColorChangingParams::DeclareReferences([[maybe_unused]] const std::s std::string TextureColorChangingParams::GetBodySourceCode() const { - std::string bodyStr = - StringHelper::Sprintf("\n %d, %d, %s, %s, %s,\n", animLength, colorListCount, - parent->GetDeclarationPtrName(primColorListAddress).c_str(), - parent->GetDeclarationPtrName(envColorListAddress).c_str(), - parent->GetDeclarationPtrName(frameDataListAddress).c_str()); + std::string primColorListName; + std::string envColorListName; + std::string frameDataListName; + + Globals::Instance->GetSegmentedPtrName(primColorListAddress, parent, "", primColorListName); + Globals::Instance->GetSegmentedPtrName(envColorListAddress, parent, "", envColorListName); + Globals::Instance->GetSegmentedPtrName(frameDataListAddress, parent, "", frameDataListName); + + std::string bodyStr = StringHelper::Sprintf( + "\n %d, %d, %s, %s, %s,\n", animLength, colorListCount, primColorListName.c_str(), + envColorListName.c_str(), frameDataListName.c_str()); return bodyStr; } @@ -456,18 +439,18 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string& { if (textureListAddress != 0) // NULL { - std::string texturesBodyStr = ""; + std::string texturesBodyStr; std::string texName; - std::string comment = ""; + std::string comment; for (const auto& tex : textureList) { - texName = parent->GetDeclarationPtrName(tex); + bool texFound = Globals::Instance->GetSegmentedPtrName(tex, parent, "", texName); // texName is a raw segmented pointer. This occurs if the texture is not declared // separately since we cannot read the format. In theory we could scan DLists for the // format on the appropriate segments. - if (texName.length() == 10 && texName.substr(0, 2) == "0x") + if (!texFound) { comment = " // Raw pointer, declare texture in XML to use proper symbol"; @@ -487,8 +470,7 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string& Globals::Instance->inputPath.c_str(), parent->GetName().c_str(), Seg2Filespace(textureListAddress, parent->baseAddress), texName.c_str()); } - texturesBodyStr += - StringHelper::Sprintf(" %s,%s\n", texName.c_str(), comment.c_str()); + texturesBodyStr += StringHelper::Sprintf("\t%s,%s\n", texName.c_str(), comment.c_str()); } texturesBodyStr.pop_back(); @@ -503,7 +485,7 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string& if (textureIndexListAddress != 0) // NULL { - std::string indicesBodyStr = " "; + std::string indicesBodyStr = "\t"; for (uint8_t index : textureIndexList) { @@ -523,10 +505,15 @@ void TextureCyclingParams::DeclareReferences([[maybe_unused]] const std::string& std::string TextureCyclingParams::GetBodySourceCode() const { - std::string bodyStr = - StringHelper::Sprintf("\n %d, %s, %s,\n", cycleLength, - parent->GetDeclarationPtrName(textureListAddress).c_str(), - parent->GetDeclarationPtrName(textureIndexListAddress).c_str()); + std::string textureListName; + std::string textureIndexListName; + + Globals::Instance->GetSegmentedPtrName(textureListAddress, parent, "", textureListName); + Globals::Instance->GetSegmentedPtrName(textureIndexListAddress, parent, "", + textureIndexListName); + + std::string bodyStr = StringHelper::Sprintf( + "\n %d, %s, %s,\n", cycleLength, textureListName.c_str(), textureIndexListName.c_str()); return bodyStr; } @@ -537,12 +524,6 @@ ZTextureAnimation::ZTextureAnimation(ZFile* nParent) : ZResource(nParent) { } -void ZTextureAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar("", ""); -} - /** * Builds the array of params */ @@ -688,42 +669,34 @@ std::string ZTextureAnimation::GetDefaultName(const std::string& prefix) const return StringHelper::Sprintf("%sTexAnim_%06X", prefix.c_str(), rawDataIndex); } -void ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& bodyStr) const +Declaration* ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; if (name == "") auxName = GetDefaultName(prefix); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, entries.size(), bodyStr); + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, entries.size(), bodyStr); + decl->staticConf = staticConf; + return decl; } std::string ZTextureAnimation::GetBodySourceCode() const { - std::string bodyStr = ""; + std::string bodyStr; for (const auto& entry : entries) { - bodyStr += StringHelper::Sprintf(" { %d, %d, %s },\n", entry.segment, entry.type, - parent->GetDeclarationPtrName(entry.paramsPtr).c_str()); + std::string paramName; + Globals::Instance->GetSegmentedPtrName(entry.paramsPtr, parent, "", paramName); + + bodyStr += StringHelper::Sprintf("\t{ %d, %d, %s },\n", entry.segment, entry.type, + paramName.c_str()); } bodyStr.pop_back(); return bodyStr; } - -std::string ZTextureAnimation::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} diff --git a/tools/ZAPD/ZAPD/ZTextureAnimation.h b/tools/ZAPD/ZAPD/ZTextureAnimation.h index d23307191..6b03eb7cf 100644 --- a/tools/ZAPD/ZAPD/ZTextureAnimation.h +++ b/tools/ZAPD/ZAPD/ZTextureAnimation.h @@ -4,8 +4,8 @@ #include #include #include + #include "ZResource.h" -#include "tinyxml2.h" enum class TextureAnimationParamsType { @@ -26,10 +26,7 @@ public: void ExtractFromBinary(uint32_t nRawDataIndex); virtual void ExtractFromBinary(uint32_t nRawDataIndex, int count); - std::string GetSourceOutputCode(const std::string& prefix); - virtual std::string GetDefaultName(const std::string& prefix) const; - virtual void DeclareVar(const std::string& prefix, const std::string& bodyStr) const; ZResourceType GetResourceType() const; TextureAnimationParamsType type; @@ -55,7 +52,7 @@ public: std::string GetDefaultName(const std::string& prefix) const override; size_t GetRawDataSize() const override; - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; int count; // 1 for Single, 2 for Dual @@ -138,20 +135,17 @@ class ZTextureAnimation : public ZResource public: ZTextureAnimation(ZFile* nParent); - void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override; void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; size_t GetRawDataSize() const override; - std::string GetDefaultName(const std::string& prefix) const; + std::string GetDefaultName(const std::string& prefix) const override; - void DeclareVar(const std::string& prefix, const std::string& bodyStr) const; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; private: std::vector entries; -}; \ No newline at end of file +}; diff --git a/tools/ZAPD/ZAPD/ZVector.cpp b/tools/ZAPD/ZAPD/ZVector.cpp index 0b7b9f3df..c940b0b0d 100644 --- a/tools/ZAPD/ZAPD/ZVector.cpp +++ b/tools/ZAPD/ZAPD/ZVector.cpp @@ -1,5 +1,7 @@ #include "ZVector.h" -#include + +#include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" @@ -17,6 +19,20 @@ ZVector::ZVector(ZFile* nParent) : ZResource(nParent) RegisterRequiredAttribute("Dimensions"); } +void ZVector::ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType, + uint32_t nDimensions) +{ + rawDataIndex = nRawDataIndex; + scalarType = nScalarType; + dimensions = nDimensions; + + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + + ParseRawData(); +} + void ZVector::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); @@ -34,9 +50,8 @@ void ZVector::ParseRawData() for (uint32_t i = 0; i < dimensions; i++) { - ZScalar scalar(scalarType, parent); - scalar.rawDataIndex = currentRawDataIndex; - scalar.ParseRawData(); + ZScalar scalar(parent); + scalar.ExtractFromBinary(currentRawDataIndex, scalarType); currentRawDataIndex += scalar.GetRawDataSize(); scalars.push_back(scalar); @@ -84,21 +99,17 @@ std::string ZVector::GetSourceTypeName() const std::string ZVector::GetBodySourceCode() const { - std::string body = ""; + std::string body; - for (size_t i = 0; i < this->scalars.size(); i++) - body += StringHelper::Sprintf("%6s, ", scalars[i].GetBodySourceCode().c_str()); + for (size_t i = 0; i < scalars.size(); i++) + { + body += StringHelper::Sprintf("%6s", scalars[i].GetBodySourceCode().c_str()); - return "{ " + body + "}"; -} + if (i + 1 < scalars.size()) + body += ", "; + } -std::string ZVector::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - if (parent != nullptr) - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), - GetSourceTypeName(), GetName(), GetBodySourceCode()); - - return ""; + return body; } ZResourceType ZVector::GetResourceType() const @@ -106,12 +117,11 @@ ZResourceType ZVector::GetResourceType() const return ZResourceType::Vector; } -void ZVector::SetScalarType(ZScalarType type) +DeclarationAlignment ZVector::GetDeclarationAlignment() const { - scalarType = type; -} - -void ZVector::SetDimensions(uint32_t dim) -{ - dimensions = dim; + if (scalars.size() == 0) + { + return DeclarationAlignment::Align4; + } + return scalars.at(0).GetDeclarationAlignment(); } diff --git a/tools/ZAPD/ZAPD/ZVector.h b/tools/ZAPD/ZAPD/ZVector.h index d700d4396..d1a738968 100644 --- a/tools/ZAPD/ZAPD/ZVector.h +++ b/tools/ZAPD/ZAPD/ZVector.h @@ -10,24 +10,22 @@ class ZVector : public ZResource { public: + std::vector scalars; + ZScalarType scalarType; + uint32_t dimensions; + ZVector(ZFile* nParent); + void ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType, uint32_t nDimensions); + void ParseXML(tinyxml2::XMLElement* reader) override; void ParseRawData() override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; bool DoesSupportArray() const override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; size_t GetRawDataSize() const override; - - void SetScalarType(ZScalarType type); - void SetDimensions(uint32_t dim); - -protected: - std::vector scalars; - ZScalarType scalarType; - uint32_t dimensions; + DeclarationAlignment GetDeclarationAlignment() const override; }; diff --git a/tools/ZAPD/ZAPD/ZVtx.cpp b/tools/ZAPD/ZAPD/ZVtx.cpp index 8b825b1db..d5214e840 100644 --- a/tools/ZAPD/ZAPD/ZVtx.cpp +++ b/tools/ZAPD/ZAPD/ZVtx.cpp @@ -1,4 +1,5 @@ #include "ZVtx.h" + #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -36,27 +37,19 @@ void ZVtx::ParseRawData() a = rawData[rawDataIndex + 15]; } +Declaration* ZVtx::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + Declaration* decl = ZResource::DeclareVar(prefix, bodyStr); + decl->isExternal = true; + return decl; +} + std::string ZVtx::GetBodySourceCode() const { return StringHelper::Sprintf("VTX(%i, %i, %i, %i, %i, %i, %i, %i, %i)", x, y, z, s, t, r, g, b, a); } -std::string ZVtx::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string output = GetBodySourceCode(); - - if (parent != nullptr) - { - Declaration* decl = - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), - GetSourceTypeName(), name, output); - decl->isExternal = true; - } - - return ""; -} - size_t ZVtx::GetRawDataSize() const { return 16; @@ -86,3 +79,8 @@ std::string ZVtx::GetExternalExtension() const { return "vtx"; } + +DeclarationAlignment ZVtx::GetDeclarationAlignment() const +{ + return DeclarationAlignment::Align16; +} diff --git a/tools/ZAPD/ZAPD/ZVtx.h b/tools/ZAPD/ZAPD/ZVtx.h index feed30766..018a1d4a9 100644 --- a/tools/ZAPD/ZAPD/ZVtx.h +++ b/tools/ZAPD/ZAPD/ZVtx.h @@ -18,8 +18,9 @@ public: ZVtx(ZFile* nParent); void ParseRawData() override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputCode(const std::string& prefix) override; bool IsExternalResource() const override; bool DoesSupportArray() const override; @@ -28,6 +29,5 @@ public: std::string GetExternalExtension() const override; size_t GetRawDataSize() const override; - -protected: -}; \ No newline at end of file + DeclarationAlignment GetDeclarationAlignment() const override; +}; diff --git a/tools/ZAPD/ZAPDUtils/Color3b.h b/tools/ZAPD/ZAPDUtils/Color3b.h index d2412972c..7e59f6b7f 100644 --- a/tools/ZAPD/ZAPDUtils/Color3b.h +++ b/tools/ZAPD/ZAPDUtils/Color3b.h @@ -6,6 +6,16 @@ struct Color3b { uint8_t r, g, b; - Color3b() { r = 0; g = 0; b = 0; }; - Color3b(uint8_t nR, uint8_t nG, uint8_t nB) { r = nR; g = nG; b = nB; }; + Color3b() + { + r = 0; + g = 0; + b = 0; + }; + Color3b(uint8_t nR, uint8_t nG, uint8_t nB) + { + r = nR; + g = nG; + b = nB; + }; }; \ No newline at end of file diff --git a/tools/ZAPD/ZAPDUtils/StrHash.h b/tools/ZAPD/ZAPDUtils/StrHash.h index 858c51761..68d22b9cd 100644 --- a/tools/ZAPD/ZAPDUtils/StrHash.h +++ b/tools/ZAPD/ZAPDUtils/StrHash.h @@ -6,8 +6,7 @@ typedef uint32_t strhash; -[[maybe_unused]] -static strhash CRC32B(unsigned char* message, int32_t size) +[[maybe_unused]] static strhash CRC32B(unsigned char* message, int32_t size) { int32_t byte = 0, crc = 0; int32_t mask = 0; @@ -29,8 +28,7 @@ static strhash CRC32B(unsigned char* message, int32_t size) return ~(uint32_t)(crc); } -[[maybe_unused]] -constexpr static strhash CRC32BCT(const char* message, int32_t size) +[[maybe_unused]] constexpr static strhash CRC32BCT(const char* message, int32_t size) { int32_t byte = 0, crc = 0; int32_t mask = 0; diff --git a/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.cpp b/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.cpp index b05188883..a4cf78229 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.cpp +++ b/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.cpp @@ -1,7 +1,7 @@ #include "BinaryReader.h" -#include "Stream.h" #include #include +#include "Stream.h" BinaryReader::BinaryReader(Stream* nStream) { @@ -23,7 +23,7 @@ uint32_t BinaryReader::GetBaseAddress() return stream->GetBaseAddress(); } -void BinaryReader::Read([[maybe_unused]]char* buffer, int32_t length) +void BinaryReader::Read([[maybe_unused]] char* buffer, int32_t length) { stream->Read(length); } @@ -133,9 +133,9 @@ Color3b BinaryReader::ReadColor3b() std::string BinaryReader::ReadString() { - std::string res = ""; + std::string res; char c; - + do { c = ReadChar(); @@ -144,6 +144,5 @@ std::string BinaryReader::ReadString() res += c; } while (c != 0); - return res; } \ No newline at end of file diff --git a/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.h b/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.h index 9e2871812..cf0eeb42c 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BinaryReader.h @@ -1,14 +1,14 @@ #pragma once -#include "Stream.h" +#include +#include +#include +#include +#include "../Color3b.h" #include "../Vec2f.h" #include "../Vec3f.h" #include "../Vec3s.h" -#include "../Color3b.h" -#include -#include -#include -#include +#include "Stream.h" class BinaryReader { @@ -16,7 +16,7 @@ public: BinaryReader(Stream* nStream); void Close(); - + void Seek(uint32_t offset, SeekOffsetType seekType); uint32_t GetBaseAddress(); @@ -37,7 +37,7 @@ public: Vec2f ReadVec2f(); Color3b ReadColor3b(); std::string ReadString(); - + protected: std::shared_ptr stream; }; \ No newline at end of file diff --git a/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.cpp b/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.cpp index a48d40d7f..87bc0ac68 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.cpp +++ b/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.cpp @@ -85,7 +85,7 @@ void BinaryWriter::Write(double value) stream->Write((char*)&value, sizeof(double)); } -void BinaryWriter::Write(std::string str) +void BinaryWriter::Write(const std::string& str) { int strLen = str.size(); stream->Write((char*)&strLen, sizeof(int)); diff --git a/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.h b/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.h index e187b8c3e..e224d182e 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BinaryWriter.h @@ -28,7 +28,7 @@ public: void Write(uint64_t value); void Write(float value); void Write(double value); - void Write(std::string str); + void Write(const std::string& str); protected: std::shared_ptr stream; diff --git a/tools/ZAPD/ZAPDUtils/Utils/Directory.h b/tools/ZAPD/ZAPDUtils/Utils/Directory.h index adb2e17d2..eaa6a26ab 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/Directory.h +++ b/tools/ZAPD/ZAPDUtils/Utils/Directory.h @@ -23,7 +23,7 @@ public: static void CreateDirectory(const std::string& path) { - std::string curPath = ""; + std::string curPath; std::vector split = StringHelper::Split(path, "/"); for (std::string s : split) diff --git a/tools/ZAPD/ZAPDUtils/Utils/Path.h b/tools/ZAPD/ZAPDUtils/Utils/Path.h index fd3c658cc..496a0ae13 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/Path.h +++ b/tools/ZAPD/ZAPDUtils/Utils/Path.h @@ -15,16 +15,16 @@ namespace fs = std::experimental::filesystem; class Path { public: - static std::string GetFileName(const std::string& input) + static std::string GetFileName(const fs::path& input) { - std::vector split = StringHelper::Split(input, "/"); - return split[split.size() - 1]; + // https://en.cppreference.com/w/cpp/filesystem/path/filename + return input.filename(); }; - static std::string GetFileNameWithoutExtension(const std::string& input) + static std::string GetFileNameWithoutExtension(const fs::path& input) { - std::vector split = StringHelper::Split(input, "/"); - return split[split.size() - 1].substr(0, split[split.size() - 1].find_last_of(".")); + // https://en.cppreference.com/w/cpp/filesystem/path/stem + return input.stem(); }; static std::string GetFileNameExtension(const std::string& input) @@ -32,22 +32,19 @@ public: return input.substr(input.find_last_of("."), input.length()); }; - static std::string GetPath(const std::string& input) + static fs::path GetPath(const std::string& input) { std::vector split = StringHelper::Split(input, "/"); - std::string output = ""; + fs::path output; for (std::string str : split) { if (str.find_last_of(".") == std::string::npos) - output += str + "/"; + output /= str; } return output; }; - static std::string GetDirectoryName(const fs::path& path) - { - return path.parent_path().u8string(); - }; + static fs::path GetDirectoryName(const fs::path& path) { return path.parent_path(); }; }; diff --git a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h index ed8921cac..74607ce3a 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h +++ b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h @@ -81,7 +81,7 @@ public: { char buffer[32768]; // char buffer[2048]; - std::string output = ""; + std::string output; va_list va; va_start(va, format); diff --git a/tools/ZAPD/ZAPDUtils/Vec2f.h b/tools/ZAPD/ZAPDUtils/Vec2f.h index e9c505955..9d4beeb46 100644 --- a/tools/ZAPD/ZAPDUtils/Vec2f.h +++ b/tools/ZAPD/ZAPDUtils/Vec2f.h @@ -6,6 +6,14 @@ struct Vec2f { float x, y; - Vec2f() { x = 0; y = 0; }; - Vec2f(float nX, float nY) { x = nX; y = nY; }; + Vec2f() + { + x = 0; + y = 0; + }; + Vec2f(float nX, float nY) + { + x = nX; + y = nY; + }; }; \ No newline at end of file diff --git a/tools/ZAPD/ZAPDUtils/Vec3f.h b/tools/ZAPD/ZAPDUtils/Vec3f.h index cde5202d1..4bfbb3c25 100644 --- a/tools/ZAPD/ZAPDUtils/Vec3f.h +++ b/tools/ZAPD/ZAPDUtils/Vec3f.h @@ -6,6 +6,16 @@ struct Vec3f { float x, y, z; - Vec3f() { x = 0; y = 0; z = 0; }; - Vec3f(float nX, float nY, float nZ) { x = nX; y = nY; z = nZ; }; + Vec3f() + { + x = 0; + y = 0; + z = 0; + }; + Vec3f(float nX, float nY, float nZ) + { + x = nX; + y = nY; + z = nZ; + }; }; \ No newline at end of file diff --git a/tools/ZAPD/copycheck.py b/tools/ZAPD/copycheck.py index d13f9843d..36288f685 100755 --- a/tools/ZAPD/copycheck.py +++ b/tools/ZAPD/copycheck.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import os from shutil import copyfile diff --git a/tools/ZAPD/docs/zapd_extraction_xml_reference.md b/tools/ZAPD/docs/zapd_extraction_xml_reference.md index d07ef9811..06b95bb57 100644 --- a/tools/ZAPD/docs/zapd_extraction_xml_reference.md +++ b/tools/ZAPD/docs/zapd_extraction_xml_reference.md @@ -32,6 +32,7 @@ This document aims to be a small reference of how to create a compatible xml fil - [Cutscene](#cutscene) - [Array](#array) - [Path](#path) + - [PlayerAnimationData](#playeranimationdata) ## Basic XML @@ -69,6 +70,20 @@ For most resources inside a `` tag **you should also set an `Offset` attri It's worth noting that every tag expects a `Name="gNameOfTheAsset"`. This is will be the name of the extracted variable in the output C code. Every asset must be prefixed with `g` and the suffix should represent the type of the variable. +Every tag can accept a `Static` attribute to specify if the asset should be marked as `static` or not. +There are 3 valid values (defaults to `Global`): + +- `Global`: Mark static if the flag `--static` was used. +- `On`: Override the global config and **always mark** as `static`. +- `Off`: Override the global config and **don't mark** as `static`. + +This table summarizes if the asset will be marked `static` (✅) or not (❌) +| `Static=""` attribute in XML | Without `--static` flag | With `--static` flag | +| ---------------------------- | ----------------------- | -------------------- | +| `On` | ✅ | ✅ | +| `Global` (default) | ❌ | ✅ | +| `Off` | ❌ | ❌ | + ------------------------- ### File @@ -83,7 +98,7 @@ It's worth noting that every tag expects a `Name="gNameOfTheAsset"`. This is wil - `Name`: Required. The name of the file in `baserom/` which will be extracted. - `OutName`: Optional. The output name of the generated C source file. Defaults to the value passed to `Name`. - - `Segment`: Required. This is the segment number of the current file. Expects a decimal number, usually 6 if it is an object, or 128 for overlays (It's kinda a whacky hack to get around of the `0x80` addresses). + - `Segment`: Optional. This is the segment number of the current file. Expects a decimal number between 0 and 15 inclusive, usually 6 if it is an object. If not specified, the file will use VRAM instead of segmented addresses. - `BaseAddress`: Optional. RAM address of the file. Expects a hex number (with `0x` prefix). Default value: `0`. - `RangeStart`: Optional. File offset where the extraction will begin. Hex. Default value: `0x000000000`. - `RangeEnd`: Optional. File offset where the extraction will end. Hex. Default value: `0xFFFFFFFF`. @@ -91,6 +106,27 @@ It's worth noting that every tag expects a `Name="gNameOfTheAsset"`. This is wil ------------------------- +### ExternalFile + +Allows ZAPD to map segmented addresses to variables declared in other files by using its XML. + +It is useful for objects that use variables from `gameplay_keep`, `gameplay_dangeon_keep`, `gameplay_field_keep`, etc. + +This tag can be used in the global `config.xml` file. + +- Example of this tag: + +```xml + +``` + +- Attributes: + + - `XmlPath`: Required. The path of the XML, relative to the value set by `ExternalXMLFolder` in the configuration file. + - `OutPath`: Required. The path were the header for the corresponding external file is. It is used to `#include` it in the generated `.c` file. + +------------------------- + ### Texture Textures are extracted as `.png` files. @@ -202,7 +238,6 @@ A.k.a. Display list, or Gfx. A data type exclusive to Majora's Mask, that has scrolling, color changing, and texture changing capabilities. Declaring the main array will generate everything else; textures for the TextureCycle type must be declared manually in the XML to use symbols. (If it does reference any undeclared textures, ZAPD will warn and give the their offsets.) - ```xml ``` @@ -402,6 +437,7 @@ extern u8 gJsjutanShadowTex[2048]; - `Type`: The type of the declared variable. If missing, it will default to `void*`. - `TypeSize`: The size in bytes of the type. If missing, it will default to `4` (the size of a word and a pointer). Integer or hex value. - `Count`: Optional. If it is present, the variable will be declared as an array instead of a plain variable. The value of this attribute specifies the length of the array. If `Count` is present but it has no value (`Count=""`), then the length of the array will not be specified either in the declared variable. Integer or hex value. + - `Static`: This attribute can't be enabled on a Symbol node. A warning will be showed in this case. ------------------------- @@ -570,8 +606,6 @@ Currently, only [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) suppo ------------------------- -------------------------- - ### Path - Example: @@ -586,3 +620,20 @@ Currently, only [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) suppo - `NumPaths`: Optional. The amount of paths contained in the array. It must be a positive integer. ------------------------- + +### PlayerAnimationData + +Allows the extraction of the specific data of the player animations which are found in the `link_animetion` file. + +- Example: + +```xml + +``` + +- Attributes: + + - `Name`: Required. Suxffixed by `AnimData`. + - `FrameCount`: Required. The length of the animation in frames. It must be a positive integer. + +------------------------- diff --git a/tools/ZAPD/docs/zapd_xml_spec.md b/tools/ZAPD/docs/zapd_xml_spec.md new file mode 100644 index 000000000..9fcc0d4aa --- /dev/null +++ b/tools/ZAPD/docs/zapd_xml_spec.md @@ -0,0 +1,55 @@ +# ZAPD XML specification + +ZAPD XMLs use a restrictive subset of the XML standard: any ZAPD XML must be a valid XML (All elements starting with `` ending appropriately with ``, single "empty-element" tags with `/` at the end, etc.). + +Reminder that in + +```xml + + + + + + + + + +``` + +``, ``, `` are *children* of ``, but `` is not. `` is a *descendent* of `` and a child of ``. + +- Every XML's outermost element start/end tag is a single ``. +- The children of a `` must be ``s. +- A `` has *resources* as children. A resource is almost always single empty-element tag, and has one of the types + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + - `` + +- A `` cannot descend from a ``. +- All resources must be children of a ``. +- `` is the only paired resource tag enclosing an element; the element must be a single resource tag, one of + - `` + - `` + - `` diff --git a/tools/ZAPDConfigs/MM/Config.xml b/tools/ZAPDConfigs/MM/Config.xml index 2817cf591..657040010 100644 --- a/tools/ZAPDConfigs/MM/Config.xml +++ b/tools/ZAPDConfigs/MM/Config.xml @@ -2,4 +2,12 @@ + + + + diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 12bcbb869..d3e4418c9 100644 --- a/tools/asm-differ/.gitrepo +++ b/tools/asm-differ/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/simonlindholm/asm-differ.git branch = main - commit = 55bba23ad53dea059db783bb5598bc0c299863e6 - parent = d3fd19b21c07664e488216b515b0e9a4ecbfa578 + commit = f30d43aceba6291aa3c08b7317b0458b6d734321 + parent = e977dfeb374c6de4076ca9a0f44ba5a6a701d849 method = merge cmdver = 0.4.3 diff --git a/tools/asm-differ/__init__.py b/tools/asm-differ/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 3a2f844a2..d7ac3f344 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -488,7 +488,12 @@ def get_objdump_executable(objdump_executable: Optional[str]) -> str: if objdump_executable is not None: return objdump_executable - for objdump_cand in ["mips-linux-gnu-objdump", "mips64-elf-objdump"]: + objdump_candidates = [ + "mips-linux-gnu-objdump", + "mips64-elf-objdump", + "mips-elf-objdump", + ] + for objdump_cand in objdump_candidates: try: subprocess.check_call( [objdump_cand, "--version"], @@ -502,7 +507,7 @@ def get_objdump_executable(objdump_executable: Optional[str]) -> str: pass return fail( - "Missing binutils; please ensure mips-linux-gnu-objdump or mips64-elf-objdump exist, or configure objdump_executable." + f"Missing binutils; please ensure {' or '.join(objdump_candidates)} exists, or configure objdump_executable." ) @@ -1480,7 +1485,6 @@ ARM32_BRANCH_INSTRUCTIONS = { } AARCH64_BRANCH_INSTRUCTIONS = { - "bl", "b", "b.eq", "b.ne", @@ -1534,7 +1538,7 @@ MIPS_SETTINGS = ArchSettings( re_int=re.compile(r"[0-9]+"), re_comment=re.compile(r"<.*?>"), re_reg=re.compile( - r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|k[01]|fp|ra|zero)\b" + r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" ), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), @@ -1578,7 +1582,7 @@ AARCH64_SETTINGS = ArchSettings( re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(? Tuple[str, str, str]: def process_mips_reloc(row: str, prev: str, arch: ArchSettings) -> str: + if "R_MIPS_NONE" in row: + # GNU as emits no-op relocations immediately after real ones when + # assembling with -mabi=64. Return without trying to parse 'imm' as an + # integer. + return prev before, imm, after = parse_relocated_line(prev) repl = row.split()[-1] if imm != "0": @@ -2375,6 +2384,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) + output = output[config.skip_lines :] return Diff(lines=output, score=score) @@ -2608,10 +2618,9 @@ class Display: self.last_diff_output = diff_output meta, diff_lines = align_diffs(last_diff_output, diff_output, self.config) - diff_lines = diff_lines[self.config.skip_lines :] output = self.config.formatter.table(meta, diff_lines) refresh_key = ( - [[col.key2 for col in x[1:]] for x in diff_lines], + [line.key2 for line in diff_output.lines], diff_output.score, ) return (output, refresh_key) diff --git a/tools/decomp-permuter/.gitrepo b/tools/decomp-permuter/.gitrepo index 905668e4d..270e3df56 100644 --- a/tools/decomp-permuter/.gitrepo +++ b/tools/decomp-permuter/.gitrepo @@ -7,6 +7,6 @@ remote = https://github.com/simonlindholm/decomp-permuter.git branch = main commit = a20bac9422b6d8adbf7c06473c2ae3c3fee16be5 - parent = 96e44d31f814b690ccc0a462513792c8daf6c9fd + parent = 2668eec556c01fa2f4c16a203c93c208dc03e639 method = merge cmdver = 0.4.3 diff --git a/tools/graphovl/.gitrepo b/tools/graphovl/.gitrepo index b55933807..064b8ee58 100644 --- a/tools/graphovl/.gitrepo +++ b/tools/graphovl/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AngheloAlf/graphovl.git branch = master - commit = eb25be944156ec859853f0aa28aea66c98b1ca99 - parent = ad3db144b2cdd212f61fac695e05dc06b9569699 + commit = f5fe93d75bb75ea4bea65f62c43f41f6a1e70679 + parent = 6c5a50ef95f351acc7c4c0455a347a94443adbe1 method = merge cmdver = 0.4.3 diff --git a/tools/graphovl/graphovl.py b/tools/graphovl/graphovl.py index b65657b57..28f0a361c 100755 --- a/tools/graphovl/graphovl.py +++ b/tools/graphovl/graphovl.py @@ -3,10 +3,18 @@ # Generates graphs for actor overlay files # -from graphviz import Digraph -import argparse, os, re +import argparse, os, re, sys from configparser import ConfigParser +try: + from graphviz import Digraph +except ModuleNotFoundError: + print("Module 'graphviz' is not installed", file=sys.stderr) + print("You can install it using: pip3 install graphviz", file=sys.stderr) + print("You may also need to install it on your system", file=sys.stderr) + print("On Debian/Ubuntu derivates you can use: apt install graphviz", file=sys.stderr) + sys.exit(1) + script_dir = os.path.dirname(os.path.realpath(__file__)) config = ConfigParser() @@ -57,7 +65,12 @@ def capture_setupaction_calls(content): # Captures the function name of a setupaction call def capture_setupaction_call_arg(content): - return [x.group().split(",")[1].strip().split(");")[0].strip() for x in re.finditer(setupaction_regexpr, content)] + transitionList = [] + for x in re.finditer(setupaction_regexpr, content): + func = x.group().split(",")[1].strip().split(");")[0].strip() + if func not in transitionList: + transitionList.append(func) + return transitionList # Search for the function definition by supplied function name def definition_by_name(content, name): @@ -171,7 +184,8 @@ def action_var_values_in_func(code_body, action_var, macros, enums): elif index in enums: index = str(enums[index]) - transition.append(index) + if index not in transition: + transition.append(index) return transition def setup_line_numbers(content, func_names): @@ -201,7 +215,7 @@ def addFunctionTransitionToGraph(dot, index: int, func_name: str, action_transit edgeColor = config.get("colors", "actionFuncInit") dot.edge(indexStr, funcIndex, color=edgeColor) -def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, setupAction=False, rawActorFunc=False): +def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, removeList: list, setupAction=False, rawActorFunc=False): edgeColor = config.get("colors", "funcCall") fontColor = config.get("colors", "fontcolor") bubbleColor = config.get("colors", "bubbleColor") @@ -213,6 +227,8 @@ def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, setup continue if call in seen: continue + if call in removeList: + continue if setupAction and "_SetupAction" in call: continue @@ -226,6 +242,27 @@ def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, setup dot.node(calledFuncIndex, call, fontcolor=fontColor, color=bubbleColor) dot.edge(indexStr, calledFuncIndex, color=edgeColor) +def addCallbacksToGraph(dot, func_names: list, index: int, code_body: str, transitionList: list): + edgeColor = config.get("colors", "callback") + fontColor = config.get("colors", "fontcolor") + bubbleColor = config.get("colors", "bubbleColor") + + indexStr = str(index) + seen = set() + for call_with_arguments in capture_calls(code_body): + call_with_arguments = call_with_arguments.replace("\n", "").replace(" ", "") + name, arguments = call_with_arguments.split("(", 1) + argumentList = [x.strip() for x in arguments.split(",")] + for callback in [x for x in func_names if x in argumentList]: + if callback in transitionList: + # already catched in another edge + continue + seen.add(callback) + + calledFuncIndex = str(index_of_func(callback)) + + dot.node(calledFuncIndex, callback, fontcolor=fontColor, color=bubbleColor) + dot.edge(indexStr, calledFuncIndex, color=edgeColor) def loadConfigFile(selectedStyle): # For a list of colors, see https://www.graphviz.org/doc/info/colors.html @@ -241,6 +278,7 @@ def loadConfigFile(selectedStyle): config.set('colors', 'actionFunc', 'Black') config.set('colors', 'fontColor', 'Black') config.set('colors', 'bubbleColor', 'Black') + config.set('colors', 'callback', 'blue') if os.path.exists(configFilename): config.read(configFilename) @@ -264,14 +302,20 @@ def main(): parser.add_argument("filename", help="Filename without the z_ or ovl_ prefix, e.x. Door_Ana") parser.add_argument("--loners", help="Include functions that are not called or call any other overlay function", action="store_true") parser.add_argument("-s", "--style", help="Use a color style defined in graphovl_styles folder. i.e. solarized") + parser.add_argument("--format", help="Select output file format. Defaults to 'png'", default="png") + parser.add_argument("-r", "--remove", help="A space-separated list of nodes to remove from the graph", nargs='+') args = parser.parse_args() + removeList = [] + if args.remove is not None: + removeList = args.remove + loadConfigFile(args.style) fontColor = config.get("colors", "fontcolor") bubbleColor = config.get("colors", "bubbleColor") fname = args.filename - dot = Digraph(comment = fname, format = 'png') + dot = Digraph(comment = fname, format = args.format) dot.attr(bgcolor=config.get("colors", "background")) contents = "" @@ -325,6 +369,9 @@ def main(): action_var = actionVarMatch.group(1).strip() for index, func_name in enumerate(func_names): + if func_name in removeList: + continue + indexStr = str(index) if args.loners: dot.node(indexStr, func_name, fontcolor=fontColor, color=bubbleColor) @@ -348,13 +395,20 @@ def main(): """ transitionList = action_var_values_in_func(code_body, actionIdentifier, macros, enums) + # Remove functions calls + transitionList = [x for x in transitionList if x not in removeList] + for action_transition in transitionList: addFunctionTransitionToGraph(dot, index, func_name, action_transition) - addCallNamesToGraph(dot, func_names, index, code_body, setupAction, rawActorFunc) + addCallNamesToGraph(dot, func_names, index, code_body, removeList, setupAction, rawActorFunc) + + addCallbacksToGraph(dot, func_names, index, code_body, transitionList) # print(dot.source) - dot.render("graphs/" + fname + ".gv") + outname = f"graphs/{fname}.gv" + dot.render(outname) + print(f"Written to {outname}.{args.format}") if __name__ == "__main__": main() diff --git a/tools/graphovl/graphovl_styles/classic.ini b/tools/graphovl/graphovl_styles/classic.ini index 3264ad34a..9a90dbbc8 100644 --- a/tools/graphovl/graphovl_styles/classic.ini +++ b/tools/graphovl/graphovl_styles/classic.ini @@ -5,3 +5,4 @@ actionFuncInit = green actionFunc = Black fontColor = Black bubbleColor = Black +callback = blue diff --git a/tools/graphovl/graphovl_styles/soft.ini b/tools/graphovl/graphovl_styles/soft.ini index 61cb50a8a..2e936e97f 100644 --- a/tools/graphovl/graphovl_styles/soft.ini +++ b/tools/graphovl/graphovl_styles/soft.ini @@ -5,3 +5,4 @@ actionfuncinit = seagreen1 actionfunc = Black fontColor = Black bubbleColor = Black +callback = deepskyblue diff --git a/tools/graphovl/graphovl_styles/solarized_dark.ini b/tools/graphovl/graphovl_styles/solarized_dark.ini index 5e4f28e2b..b78489311 100644 --- a/tools/graphovl/graphovl_styles/solarized_dark.ini +++ b/tools/graphovl/graphovl_styles/solarized_dark.ini @@ -5,3 +5,4 @@ actionFuncInit = #dc322f actionFunc = #b58900 fontColor = #839496 bubbleColor = #839496 +callback = #268bd2 diff --git a/tools/graphovl/graphovl_styles/solarized_light.ini b/tools/graphovl/graphovl_styles/solarized_light.ini index 6eb37973a..b6b4b116a 100644 --- a/tools/graphovl/graphovl_styles/solarized_light.ini +++ b/tools/graphovl/graphovl_styles/solarized_light.ini @@ -5,3 +5,4 @@ actionFuncInit = #dc322f actionFunc = #b58900 fontColor = #657b83 bubbleColor = #657b83 +callback = #268bd2 From ef53ba82614ae64043101360931af2ee2dd11fea Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:41:50 +0100 Subject: [PATCH 42/86] z_game_over.c (#263) * game over * Fixes * Revert save field rename * Fix comment indent Co-authored-by: Anghelo Carvajal * Add bss reordering stuff, fix bss reordering in z_scene_proc * Enum uggestions, fix item id * link -> player in enum comments Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Anghelo Carvajal Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- include/functions.h | 16 +-- include/macros.h | 4 +- include/variables.h | 1 - include/z64.h | 13 +++ include/z64item.h | 4 +- spec | 2 +- src/boot_O2_g3/boot_main.c | 1 + src/code/z_game_over.c | 116 +++++++++++++++++++- src/code/z_kankyo.c | 6 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 10 +- tools/disasm/functions.txt | 12 +- tools/disasm/variables.txt | 2 +- tools/sizes/code_functions.csv | 12 +- 13 files changed, 163 insertions(+), 36 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6801b986b..6bb0c03cc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1769,9 +1769,9 @@ void func_800FB320(GlobalContext* globalCtx, u8 param_2); void func_800FB758(GlobalContext* globalCtx); // void func_800FB9B4(void); // void func_800FBCBC(void); -// void func_800FBDEC(void); -void func_800FBF3C(GlobalContext* globalCtx); -// void func_800FC158(void); +void Kankyo_InitGameOverLights(GlobalContext* globalCtx); +void Kankyo_FadeInGameOverLights(GlobalContext* globalCtx); +void Kankyo_FadeOutGameOverLights(GlobalContext* globalCtx); // void func_800FC3DC(void); void func_800FC444(GraphicsContext* gfxCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4, UNK_TYPE arg5); // void func_800FC64C(void); @@ -2758,7 +2758,7 @@ void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); void func_8013EDD0(void); // void func_8013EE04(void); -// void func_8013EE24(void); +void func_8013EE24(void); // void func_8013EE38(void); // void func_8013EE48(void); void View_ViewportToVp(Vp* dest, Viewport* src); @@ -3070,7 +3070,7 @@ void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 a void func_80169E6C(GlobalContext* globalCtx, s32 param_1, s32 param_2); // void func_80169ECC(void); void func_80169EFC(GlobalContext* globalCtx); -// void func_80169F78(void); +void func_80169F78(GlobalContext* globalCtx); // void func_80169FDC(void); // void func_80169FFC(void); s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx); @@ -4058,9 +4058,9 @@ s32 func_801A8A50(s32 param1); // void func_801AA248(void); // void func_801AA3E4(void); // void func_801AA520(void); -void func_801AA610(GlobalContext* globalCtx); -void func_801AA624(GlobalContext* globalCtx); -// void func_801AA68C(UNK_TYPE4 ctxt); +void GameOver_Init(GlobalContext* globalCtx); +void GameOver_FadeLights(GlobalContext* globalCtx); +void GameOver_Update(GlobalContext* globalCtx); void func_801AAAA0(GlobalContext* globalCtx); #endif diff --git a/include/macros.h b/include/macros.h index 915a3fff3..607e5e9bc 100644 --- a/include/macros.h +++ b/include/macros.h @@ -61,11 +61,13 @@ #define CUR_UPG_VALUE_VOID(upg) \ ((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm) + #define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) #define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip]))) -#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[gSaveContext.playerForm == PLAYER_FORM_HUMAN ? 0 : gSaveContext.playerForm][button]) +#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button]) #define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) #define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) diff --git a/include/variables.h b/include/variables.h index 0897d2bc9..ddc77f90f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3134,7 +3134,6 @@ extern UNK_PTR D_801E10B0; // extern UNK_TYPE4 D_801E1104; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; -// extern UNK_TYPE2 D_801E1110; // extern UNK_TYPE2 D_801E1180; // extern UNK_TYPE1 D_801E1420; // extern UNK_TYPE2 D_801E1630; diff --git a/include/z64.h b/include/z64.h index 96ebb233b..cd00fb86f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1509,6 +1509,19 @@ typedef struct { /* 0x04 */ s32 timer; } FrameAdvanceContext; // size = 0x8 +typedef enum { + /* 00 */ GAMEOVER_INACTIVE, + /* 01 */ GAMEOVER_DEATH_START, + /* 02 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for player to fall and hit the ground + /* 03 */ GAMEOVER_DEATH_FADE_OUT, // wait before fading out + + /* 20 */ GAMEOVER_REVIVE_START = 20, + /* 21 */ GAMEOVER_REVIVE_RUMBLE, + /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for player to fall and hit the ground + /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of player's body + /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as player is revived and gets back up +} GameOverState; + typedef struct { /* 0x00 */ u16 state; } GameOverContext; // size = 0x02 diff --git a/include/z64item.h b/include/z64item.h index 11c0201d6..434b565fb 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -34,6 +34,7 @@ typedef enum { /* 0x16 */ ITEM_FAIRY, /* 0x17 */ ITEM_DEKU_PRINCESS, /* 0x1E */ ITEM_MUSHROOM = 0x1E, + /* 0x32 */ ITEM_MASK_DEKU = 0x32, /* 0x38 */ ITEM_MASK_ALL_NIGHT = 0x38, /* 0x3A */ ITEM_MASK_KEATON = 0x3A, /* 0x3B */ ITEM_MASK_GARO, @@ -43,7 +44,8 @@ typedef enum { /* 0x4D */ ITEM_SWORD_KOKIRI = 0x4D, /* 0x4E */ ITEM_SWORD_RAZOR, /* 0x4F */ ITEM_SWORD_GILDED, - /* 0x51 */ ITEM_SHIELD_HERO = 0x51, + /* 0x50 */ ITEM_SWORD_DEITY, + /* 0x51 */ ITEM_SHIELD_HERO, /* 0x52 */ ITEM_SHIELD_MIRROR, /* 0x56 */ ITEM_BOMB_BAG_20 = 0x56, /* 0x57 */ ITEM_BOMB_BAG_30, diff --git a/spec b/spec index fc4845af4..40a76a93f 100644 --- a/spec +++ b/spec @@ -675,7 +675,7 @@ beginseg include "build/data/code/code_801A7B10.bss.o" include "build/src/code/code_801AA020.o" include "build/data/code/code_801AA020.bss.o" - include "build/src/code/z_game_over.o" + include_readonly "build/src/code/z_game_over.o" include "build/src/code/z_construct.o" include "build/data/code/code_801D9090.data.o" include "build/data/code/code_801E1180.rodata.o" diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 04bb9a33a..ec6b446e7 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,4 +1,5 @@ #include "global.h" +#include "prevent_bss_reordering.h" StackEntry sBootThreadInfo; OSThread sIdleThread; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 412cb7080..c510c1974 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,7 +1,117 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA610.s") +void GameOver_Init(GlobalContext* globalCtx) { + globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA624.s") +void GameOver_FadeLights(GlobalContext* globalCtx) { + GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA68C.s") + if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) || + (gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) { + Kankyo_FadeInGameOverLights(globalCtx); + } +} + +static s16 sGameOverTimer = 0; + +void GameOver_Update(GlobalContext* globalCtx) { + GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; + s16 i; + + switch (gameOverCtx->state) { + case GAMEOVER_DEATH_START: + func_801477B4(globalCtx); + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + } + + gSaveContext.eventInf[1] &= ~1; + + if (CUR_FORM == 0) { + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI && + CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR && + CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED && + CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_DEITY) { + + if (gSaveContext.buttonStatus[0] != BTN_ENABLED) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[0]; + } else { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; + } + } + } + + gSaveContext.unk_3DC0 = 2000; + gSaveContext.naviTimer = 0; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.eventInf[0] = 0; + gSaveContext.eventInf[1] = 0; + gSaveContext.eventInf[2] = 0; + gSaveContext.eventInf[3] = 0; + gSaveContext.buttonStatus[0] = BTN_ENABLED; + gSaveContext.buttonStatus[1] = BTN_ENABLED; + gSaveContext.buttonStatus[2] = BTN_ENABLED; + gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.unk_3F1E = 0; + gSaveContext.unk_3F20 = 0; + gSaveContext.unk_3F22 = 0; + gSaveContext.unk_3F24 = 0; + Kankyo_InitGameOverLights(globalCtx); + sGameOverTimer = 20; + func_8013ECE0(0.0f, 126, 124, 63); + gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; + break; + case GAMEOVER_DEATH_FADE_OUT: + if (func_801A8A50(1) != 32) { + func_80169F78(globalCtx); + if (gSaveContext.respawnFlag != -7) { + gSaveContext.respawnFlag = -6; + } + gSaveContext.nextTransition = 2; + gSaveContext.health = 48; + gameOverCtx->state++; + if (gSaveContext.inventory.items[SLOT(ITEM_MASK_DEKU)] == ITEM_MASK_DEKU) { + gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.equippedMask = PLAYER_MASK_NONE; + } + func_8013EE24(); + } + break; + case GAMEOVER_REVIVE_START: + gameOverCtx->state++; + sGameOverTimer = 0; + Kankyo_InitGameOverLights(globalCtx); + ShrinkWindow_SetLetterboxTarget(32); + break; + case GAMEOVER_REVIVE_RUMBLE: + sGameOverTimer = 50; + gameOverCtx->state++; + func_8013ECE0(0.0f, 126, 124, 63); + break; + case GAMEOVER_REVIVE_WAIT_GROUND: + sGameOverTimer--; + if (sGameOverTimer == 0) { + sGameOverTimer = 64; + gameOverCtx->state++; + } + break; + case GAMEOVER_REVIVE_WAIT_FAIRY: + sGameOverTimer--; + if (sGameOverTimer == 0) { + sGameOverTimer = 50; + gameOverCtx->state++; + } + break; + case GAMEOVER_REVIVE_FADE_OUT: + Kankyo_FadeOutGameOverLights(globalCtx); + sGameOverTimer--; + if (sGameOverTimer == 0) { + gameOverCtx->state = GAMEOVER_INACTIVE; + } + break; + } +} diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 22c96883e..6221e0910 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -74,11 +74,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBCBC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBDEC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBF3C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC158.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC3DC.s") diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 0fd8d2564..4716439cb 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -556,22 +556,22 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_80152434(globalCtx, D_80BA5120[gSaveContext.playerForm == 4 ? 0 : gSaveContext.playerForm]); + func_80152434(globalCtx, D_80BA5120[CUR_FORM]); return 0; } s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.unk1202A == 4) { - if (gSaveContext.playerForm == 4) { + if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { gSaveContext.weekEventReg[56] |= 0x10; } - if (gSaveContext.playerForm == 3) { + if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { gSaveContext.weekEventReg[56] |= 0x20; } - if (gSaveContext.playerForm == 2) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { gSaveContext.weekEventReg[56] |= 0x40; } - if (gSaveContext.playerForm == 1) { + if (gSaveContext.playerForm == PLAYER_FORM_GORON) { gSaveContext.weekEventReg[56] |= 0x80; } return 1; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0bfa78b1d..cf6076b7f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1743,9 +1743,9 @@ 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), 0x800FBCBC:("func_800FBCBC",), - 0x800FBDEC:("func_800FBDEC",), - 0x800FBF3C:("func_800FBF3C",), - 0x800FC158:("func_800FC158",), + 0x800FBDEC:("Kankyo_InitGameOverLights",), + 0x800FBF3C:("Kankyo_FadeInGameOverLights",), + 0x800FC158:("Kankyo_FadeOutGameOverLights",), 0x800FC3DC:("func_800FC3DC",), 0x800FC444:("func_800FC444",), 0x800FC64C:("func_800FC64C",), @@ -4083,9 +4083,9 @@ 0x801AA248:("func_801AA248",), 0x801AA3E4:("func_801AA3E4",), 0x801AA520:("func_801AA520",), - 0x801AA610:("func_801AA610",), - 0x801AA624:("func_801AA624",), - 0x801AA68C:("func_801AA68C",), + 0x801AA610:("GameOver_Init",), + 0x801AA624:("GameOver_FadeLights",), + 0x801AA68C:("GameOver_Update",), 0x801AAAA0:("func_801AAAA0",), 0x80800000:("Title_UpdateCounters",), 0x8080009C:("Title_RenderView",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 6cbe303ee..b71f05517 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -3890,7 +3890,7 @@ 0x801E1104:("D_801E1104","UNK_TYPE4","",0x4), 0x801E1108:("D_801E1108","UNK_TYPE4","",0x4), 0x801E110C:("D_801E110C","UNK_TYPE4","",0x4), - 0x801E1110:("D_801E1110","UNK_TYPE2","",0x2), + 0x801E1110:("sGameOverTimer","UNK_TYPE2","",0x2), 0x801E1120:("jtbl_801E1120","UNK_PTR","",0x4), 0x801E1180:("D_801E1180","UNK_TYPE2","",0x2), 0x801E1420:("D_801E1420","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index da6bc4acb..14919f754 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1257,9 +1257,9 @@ asm/non_matchings/code/z_kankyo/func_800FB388.s,func_800FB388,0x800FB388,0xF4 asm/non_matchings/code/z_kankyo/func_800FB758.s,func_800FB758,0x800FB758,0x97 asm/non_matchings/code/z_kankyo/func_800FB9B4.s,func_800FB9B4,0x800FB9B4,0xC2 asm/non_matchings/code/z_kankyo/func_800FBCBC.s,func_800FBCBC,0x800FBCBC,0x4C -asm/non_matchings/code/z_kankyo/func_800FBDEC.s,func_800FBDEC,0x800FBDEC,0x54 -asm/non_matchings/code/z_kankyo/func_800FBF3C.s,func_800FBF3C,0x800FBF3C,0x87 -asm/non_matchings/code/z_kankyo/func_800FC158.s,func_800FC158,0x800FC158,0xA1 +asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s,Kankyo_InitGameOverLights,0x800FBDEC,0x54 +asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s,Kankyo_FadeInGameOverLights,0x800FBF3C,0x87 +asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s,Kankyo_FadeOutGameOverLights,0x800FC158,0xA1 asm/non_matchings/code/z_kankyo/func_800FC3DC.s,func_800FC3DC,0x800FC3DC,0x1A asm/non_matchings/code/z_kankyo/func_800FC444.s,func_800FC444,0x800FC444,0x82 asm/non_matchings/code/z_kankyo/func_800FC64C.s,func_800FC64C,0x800FC64C,0x31A @@ -3597,7 +3597,7 @@ asm/non_matchings/code/code_801AA020/func_801AA020.s,func_801AA020,0x801AA020,0x asm/non_matchings/code/code_801AA020/func_801AA248.s,func_801AA248,0x801AA248,0x67 asm/non_matchings/code/code_801AA020/func_801AA3E4.s,func_801AA3E4,0x801AA3E4,0x4F asm/non_matchings/code/code_801AA020/func_801AA520.s,func_801AA520,0x801AA520,0x3C -asm/non_matchings/code/z_game_over/func_801AA610.s,func_801AA610,0x801AA610,0x5 -asm/non_matchings/code/z_game_over/func_801AA624.s,func_801AA624,0x801AA624,0x1A -asm/non_matchings/code/z_game_over/func_801AA68C.s,func_801AA68C,0x801AA68C,0x105 +asm/non_matchings/code/z_game_over/GameOver_Init.s,GameOver_Init,0x801AA610,0x5 +asm/non_matchings/code/z_game_over/GameOver_FadeLights.s,GameOver_FadeLights,0x801AA624,0x1A +asm/non_matchings/code/z_game_over/GameOver_Update.s,GameOver_Update,0x801AA68C,0x105 asm/non_matchings/code/z_construct/func_801AAAA0.s,func_801AAAA0,0x801AAAA0,0x4 From 57a9fb7b34acc1d248a07398cf1e7ce3864ad0fc Mon Sep 17 00:00:00 2001 From: rylieb <31797144+rylieb@users.noreply.github.com> Date: Sun, 24 Oct 2021 11:06:46 -0600 Subject: [PATCH 43/86] Hopefully prevent misformatted files from ever entering master again. (#356) * Added tools/check_format.sh. * Exit nonzero from format.sh if clang-format-11 not installed. * Replace which with command -v. * Fail check_format.sh if format.sh fails. * Improve Jenkinsfile. * Take exit 0 out of else in check_format.sh. * Format flg_set.c to test new Jenkins environment. * Fix formatter failed logic in check_format.sh. * Format all misformatted files in master. * Remove Summarize Problems stage from Jenkins. I didn't realize Jenkins would not a run a subsequent stage if a previous stage errored. This defeats the purpose of summarizing all problems at the end, since this will only happen if there *are* no problems. * Use Post->Failure block to print all logs instead. * Remove spurious semicolon in arms_hook. --- Jenkinsfile | 9 +++++++++ format.sh | 11 +++++++++-- tools/check_format.sh | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100755 tools/check_format.sh diff --git a/Jenkinsfile b/Jenkinsfile index 555504de4..df06c6a09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,12 @@ pipeline { } stages { + stage('Check formatting') { + steps { + echo 'Checking formatting...' + sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' @@ -68,6 +74,9 @@ pipeline { } } post { + failure { + sh 'cat tools/check_format.txt tools/warnings_count/warnings_setup_new.txt tools/warnings_count/warnings_disasm_new.txt tools/warnings_count/warnings_build_new.txt' + } always { cleanWs() } diff --git a/format.sh b/format.sh index ed830a502..89a0906ad 100755 --- a/format.sh +++ b/format.sh @@ -1,15 +1,22 @@ #!/usr/bin/env bash +FORMAT_VER="11" FORMAT_OPTS="-i -style=file" TIDY_OPTS="-p . --fix --fix-errors" COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING" shopt -s globstar +if [ -z `command -v clang-format-${FORMAT_VER}` ] +then + echo "clang-format-${FORMAT_VER} not found. Exiting." + exit 1 +fi + if (( $# > 0 )); then echo "Formatting file(s) $*" echo "Running clang-format..." - clang-format-11 ${FORMAT_OPTS} "$@" + clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@" echo "Running clang-tidy..." clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null echo "Adding missing final new lines..." @@ -20,7 +27,7 @@ fi echo "Formatting C files. This will take a bit" echo "Running clang-format..." -clang-format-11 ${FORMAT_OPTS} src/**/*.c +clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c echo "Running clang-tidy..." clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null echo "Adding missing final new lines..." diff --git a/tools/check_format.sh b/tools/check_format.sh new file mode 100755 index 000000000..d8119e743 --- /dev/null +++ b/tools/check_format.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +STATUSOLD=`git status --porcelain` +./format.sh +if [ $? -ne 0 ] +then + echo "Formatter failed. Exiting." + exit -1 +fi +STATUSNEW=`git status --porcelain` + +if [ "${STATUSOLD}" != "${STATUSNEW}" ]; +then + echo "" + echo "Misformatted files found. Run ./format.sh and verify codegen is not impacted." + echo "" + diff --unified=0 --label "Old git status" <(echo "${STATUSOLD}") --label "New git status" <(echo "${STATUSNEW}") + echo "" + echo "Exiting." + exit 1 +fi + +exit 0 From 6b8baad7bd21ac3d5016535ec59b0a451ddb4190 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 24 Oct 2021 15:56:48 -0300 Subject: [PATCH 44/86] Prevent building unused asm (#369) * Grep spec to know which asm should be built * Remove cut --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2a00a7694..349c50b67 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,8 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \ C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) -S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s)) +S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ + $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \ $(foreach f,$(wildcard baserom/*),build/$f.o) \ $(foreach f,$(C_FILES:.c=.o),build/$f) \ From 4129e868820aaf98264d8add4bd1b3e0d74a4a70 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 25 Oct 2021 11:35:03 +1100 Subject: [PATCH 45/86] Match 2 of the 6 remaining functions in En_Sw (#368) * Match 2 functions * clean-up * clean-up part2 * one more touch-up * -> 2.0f * format --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 5bcd70b77..9cc79183e 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -381,7 +381,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 Vec3f sp6C; u32 sp68; u32 sp64; - s32 pad2; + Actor* thisx = &this->actor; f32 temp_f20; s32 i; @@ -391,8 +391,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 sp64 = 50; func_808D90F0(this, arg3, arg4); this->actor.speedXZ = this->unk_44C; - if (1) {} - temp_f20 = this->actor.speedXZ + this->actor.speedXZ; + temp_f20 = thisx->speedXZ * 2.0f; sp90.x = this->actor.world.pos.x + (this->unk_368.x * 2.0f); sp90.y = this->actor.world.pos.y + (this->unk_368.y * 2.0f); @@ -419,12 +418,13 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 this->actor.floorBgId = sp68; } } else { - temp_f20 *= 3.0f; this->actor.speedXZ = 0.0f; + temp_f20 *= 3.0f; Math_Vec3f_Copy(&sp90, &sp84); for (i = 0; i < 3; i++) { if (i == 0) { + if (this && this && this) {} sp84.x = sp90.x - (this->unk_350.x * temp_f20); sp84.y = sp90.y - (this->unk_350.y * temp_f20); sp84.z = sp90.z - (this->unk_350.z * temp_f20); @@ -560,10 +560,10 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { return false; } -#ifdef NON_MATCHING s32 func_808D9C18(EnSw* this) { Vec3f sp3C; Vec3f sp30; + f32 new_var; if ((this->unk_498 == 0xF9) || (this->unk_498 == 0x82) || (this->unk_498 == 0xE4) || (this->unk_498 == 0xE5)) { this->actor.velocity.x = this->actor.speedXZ; @@ -571,9 +571,11 @@ s32 func_808D9C18(EnSw* this) { this->actor.velocity.x *= Math_SinS(this->actor.world.rot.y); this->actor.velocity.z *= Math_CosS(this->actor.world.rot.y); } else { - this->actor.velocity.x = (this->actor.speedXZ * this->unk_350.x) + (this->actor.speedXZ * this->unk_368.x); + new_var = this->actor.speedXZ * this->unk_350.x; + this->actor.velocity.x = new_var + (this->actor.speedXZ * this->unk_368.x); + new_var = this->actor.speedXZ * this->unk_350.z; + this->actor.velocity.z = new_var + this->actor.speedXZ * this->unk_368.z; this->actor.velocity.y = 14.0f; - this->actor.velocity.z = (this->actor.speedXZ * this->unk_350.z) + (this->actor.speedXZ * this->unk_368.z); Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); Math_Vec3f_Copy(&sp30, &this->actor.world.pos); sp30.x += this->actor.velocity.x; @@ -598,9 +600,6 @@ s32 func_808D9C18(EnSw* this) { this->actor.parent = NULL; return false; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D9C18.s") -#endif void func_808D9DA0(EnSw* this) { static Vec3f D_808DBAAC = { 0.0f, 1.0f, 0.0f }; @@ -1028,7 +1027,6 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") #endif -#ifdef NON_MATCHING void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { Vec3f sp5C; s32 i; @@ -1037,8 +1035,11 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { if (this->unk_410 & 2) { if (!ENSW_GET_3(&this->actor)) { - if ((this->unk_410 & 4) && (DECR(this->unk_45C) == 0)) { - this->unk_410 &= ~4; + if (this->unk_410 & 4) { + phi_a0 = DECR(this->unk_45C); + if (phi_a0 == 0) { + this->unk_410 &= ~4; + } } for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_464); i++) { @@ -1073,19 +1074,19 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { } func_808D94D0(this, globalCtx, 0, 0, 0x1554); } - } else if (DECR(this->unk_45C) == 0) { - this->unk_410 |= 2; - if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { - func_808D8B58(this); - this->unk_45C = 10; - } else { - this->unk_45C = 20; + } else { + phi_a0 = DECR(this->unk_45C); + if (phi_a0 == 0) { + this->unk_410 |= 2; + if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + func_808D8B58(this); + this->unk_45C = 10; + } else { + this->unk_45C = 20; + } } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DAEB4.s") -#endif void func_808DB100(EnSw* this, GlobalContext* globalCtx) { if (this->actor.parent != NULL) { From bfd1ab28a6e56f876742fb3a4b84c767a5553f33 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Mon, 25 Oct 2021 05:22:17 -0700 Subject: [PATCH 46/86] En_Giant OK and mostly documented (#346) * Migrate data to C * EnGiant_Destroy OK * EnGiant_Init OK * func_80B01A74 OK * Comment what each of the quest items are * Put a little comment for myself on func_80B01A74 because it was confusing me lol * Very early names (they're all bad) * func_80B01990 OK * EnGiant_Update OK * func_80B024AC OK * func_80B023D0 OK * func_80B024D8 OK * func_80B02354 OK (this function is bad!) * func_80B020A0 OK * func_80B01EE8 OK * func_80B01E84 OK * func_80B0211C OK * func_80B02234 OK * unk_250 -> sfxId and label SFX * func_80B02688 OK * func_80B026C4 OK * EnGiant_Draw OK * Update spec * Fix up the static data * unk_24E -> alpha * Document some of the animation stuff * Name EnGiant_IsNotFreed * Document the giant types better * Minor cleanup * Add explanatory comment * Rename the functions in functions.txt too, whoops * Document sFaceTextures and blink routine * Document all the various animations * Name EnGiant_PlaySound * Document some functions and change an unknown to action * Add an SFX id I missed * Name all the action funcs * Name last two functions * Mark one case as unused * Change func_800F5A8C to use arg0, arg1, arg2, etc. * Move sFaceTextures to EnGiant_Draw and comment what they are * EnGiant_IsNotFreed -> EnGiant_IsImprisoned * Use booleans in EnGiant_IsImprisoned * **/ -> */ * action -> csAction * Make macros for all type conditional checks * Add warning about inconsistency * Document the cs actions * Add some documentation to animation-changing functions * Update the function name in functions.txt too * Improve GIANT_TYPE macros * Remove an unncessary early return * Incorporate animation changes --- include/functions.h | 2 +- include/z64cutscene.h | 6 +- spec | 3 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 473 +++++++++++++++++- src/overlays/actors/ovl_En_Giant/z_en_giant.h | 99 +++- tools/disasm/functions.txt | 26 +- undefined_syms.txt | 15 + 7 files changed, 579 insertions(+), 45 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6bb0c03cc..80e48e256 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1736,7 +1736,7 @@ void Font_LoadOrderedFont(Font* font); // void func_800F50D4(void); void Kankyo_Init(GlobalContext* globalCtx, EnvironmentContext* envCtx); u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5); -// void func_800F5A8C(void); +f32 func_800F5A8C(u16 arg0, u16 arg1, u16 arg2, GlobalContext* globalContext); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); // void func_800F6834(void); diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 3629aba74..51e60799e 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -29,7 +29,11 @@ typedef struct { /* 0x00 */ u16 unk0; // action; // "dousa" /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; - /* 0x06 */ UNK_TYPE1 pad6[0x2A]; + /* 0x06 */ UNK_TYPE1 pad6[0xA]; + /* 0x10 */ s32 unk10; + /* 0x14 */ UNK_TYPE1 pad14[0x8]; + /* 0x1C */ s32 unk1C; + /* 0x20 */ UNK_TYPE1 pad20[0x10]; } CsCmdActorAction; // size = 0x30 typedef struct { diff --git a/spec b/spec index 40a76a93f..697971ff1 100644 --- a/spec +++ b/spec @@ -3889,8 +3889,7 @@ beginseg name "ovl_En_Giant" compress include "build/src/overlays/actors/ovl_En_Giant/z_en_giant.o" - include "build/data/ovl_En_Giant/ovl_En_Giant.data.o" - include "build/data/ovl_En_Giant/ovl_En_Giant.reloc.o" + include "build/src/overlays/actors/ovl_En_Giant/ovl_En_Giant_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 2bf3bbd53..62da9b9f6 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -1,3 +1,9 @@ +/* + * File: z_en_giant.c + * Overlay: ovl_En_Giant + * Description: Giant + */ + #include "z_en_giant.h" #define FLAGS 0x00000030 @@ -9,11 +15,10 @@ void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx); void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B023D0(EnGiant* this, GlobalContext* globalCtx); -void func_80B024AC(EnGiant* this, GlobalContext* globalCtx); -void func_80B024D8(EnGiant* this, GlobalContext* globalCtx); +void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx); +void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx); +void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, ACTORCAT_NPC, @@ -26,42 +31,460 @@ const ActorInit En_Giant_InitVars = { (ActorFunc)EnGiant_Draw, }; -#endif +extern AnimationHeader D_06002168; +extern Gfx D_06005A80[]; +extern Gfx D_06006280[]; +extern Gfx D_06007610[]; +extern Gfx D_06006A80[]; +extern FlexSkeletonHeader D_060079B0; +extern AnimationHeader D_06008394; +extern AnimationHeader D_060096E4; +extern AnimationHeader D_0600A1C4; +extern AnimationHeader D_0600ACA4; +extern AnimationHeader D_0600B784; +extern AnimationHeader D_0600C5D4; +extern AnimationHeader D_0600D040; +extern AnimationHeader D_0600DE84; +extern AnimationHeader D_060102A4; +extern AnimationHeader D_060116E4; +extern AnimationHeader D_06012A38; +extern AnimationHeader D_06013004; +extern AnimationHeader D_06013FE8; +extern AnimationHeader D_06015334; +extern AnimationHeader D_06017944; -extern UNK_TYPE D_06002168; -extern UNK_TYPE D_06007610; -extern UNK_TYPE D_060116E4; +static AnimationHeader* sAnimationTable[] = { + &D_06008394, &D_060096E4, &D_060102A4, &D_060116E4, &D_06012A38, &D_06013004, &D_06013FE8, &D_06015334, + &D_06017944, &D_0600A1C4, &D_0600D040, &D_0600DE84, &D_0600ACA4, &D_0600B784, &D_0600C5D4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B01990.s") +void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { + if (newAnimationId >= GIANT_ANIMATION_LOOK_UP_START && newAnimationId < GIANT_ANIMATION_MAX) { + if ((this->animationId == GIANT_ANIMATION_WALKING_LOOP && newAnimationId != GIANT_ANIMATION_WALKING_LOOP) || + (newAnimationId == GIANT_ANIMATION_WALKING_LOOP && this->animationId != GIANT_ANIMATION_WALKING_LOOP)) { + Animation_Change(&this->skelAnime, sAnimationTable[newAnimationId], 1.0f, 0.0f, + Animation_GetLastFrame(&sAnimationTable[newAnimationId]->common), 2, 10.0f); + } else { + Animation_PlayOnce(&this->skelAnime, sAnimationTable[newAnimationId]); + } + this->animationId = newAnimationId; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B01A74.s") +s32 EnGiant_IsImprisoned(EnGiant* this) { + switch (GIANT_TYPE(&this->actor)) { + case GIANT_TYPE_SWAMP_TERMINA_FIELD: + case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: + case GIANT_TYPE_SWAMP_CLOCK_TOWER_FAILURE: + if (!CHECK_QUEST_ITEM(0)) { + return true; + } + break; + case GIANT_TYPE_MOUNTAIN_TERMINA_FIELD: + case GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING: + case GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE: + if (!CHECK_QUEST_ITEM(1)) { + return true; + } + break; + case GIANT_TYPE_OCEAN_TERMINA_FIELD: + case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: + case GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE: + if (!CHECK_QUEST_ITEM(2)) { + return true; + } + break; + case GIANT_TYPE_CANYON_TERMINA_FIELD: + case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: + case GIANT_TYPE_CANYON_CLOCK_TOWER_FAILURE: + if (!CHECK_QUEST_ITEM(3)) { + return true; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/EnGiant_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/EnGiant_Destroy.s") +void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGiant* this = THIS; + s32 type = GIANT_TYPE(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B01E84.s") + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + Actor_SetScale(&this->actor, 0.32f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060079B0, &D_06002168, this->jointTable, this->morphTable, 16); + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + this->csAction = GIANT_CS_ACTION_NONE; + this->actionFunc = EnGiant_PerformCutsceneActions; + this->actor.draw = NULL; + this->alpha = 0; + this->actor.velocity.y = -10.0f; + this->actor.minVelocityY = -10.0f; + this->actor.gravity = -5.0f; + switch (type) { + case GIANT_TYPE_CANYON_TERMINA_FIELD: + case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: + this->unk_24A = 0x1C6; + break; + case GIANT_TYPE_SWAMP_TERMINA_FIELD: + case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: + this->unk_24A = 0x1C7; + break; + case GIANT_TYPE_OCEAN_TERMINA_FIELD: + case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: + case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: + this->unk_24A = 0x1C8; + break; + default: + this->unk_24A = 0x1C5; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B01EE8.s") + if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { + if (!(gSaveContext.weekEventReg[0x19] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_24A = 0x1C5; + Actor_SetScale(&this->actor, 0.32f); + this->actionFunc = EnGiant_PerformClockTowerSuccessActions; + Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, + Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + this->actor.draw = EnGiant_Draw; + this->actor.velocity.y = 0.0f; + this->actor.minVelocityY = 0.0f; + this->actor.gravity = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B020A0.s") + if (GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type)) { + Actor_SetScale(&this->actor, 0.32f); + this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; + Animation_Change(&this->skelAnime, &D_06013FE8, 1.0f, 0.0f, Animation_GetLastFrame(&D_06013004), 0, 0.0f); + this->actor.draw = EnGiant_Draw; + this->actor.velocity.y = 0.0f; + this->actor.minVelocityY = 0.0f; + this->actor.gravity = 0.0f; + if (EnGiant_IsImprisoned(this)) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B0211C.s") + if (GIANT_TYPE_IS_NOT_TERMINA_FIELD(type)) { + this->alpha = 255; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B02234.s") + this->sfxId = 0xFFFF; + if (GIANT_TYPE_IS_CHAMBER_OR_ENDING(type)) { + switch (gSaveContext.sceneSetupIndex) { + case 0: + case 10: + this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE2 - SFX_FLAG; + break; + case 1: + case 2: + case 3: + this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE1 - SFX_FLAG; + break; + default: + this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE0 - SFX_FLAG; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B02354.s") +void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B023D0.s") +/** + * The animations in sAnimationTable are organized such that looping animations + * appear immediately after their respective starting animations. The point of + * this function is to play the requested start animation if it has not been + * played yet and play the respetive looping animation otherwise. + */ +void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimationId) { + s16 nextAnimationId = requestedAnimationId + 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B024AC.s") + if (this->animationId != nextAnimationId) { + if (this->animationId != requestedAnimationId) { + EnGiant_ChangeAnimation(this, requestedAnimationId); + } else { + EnGiant_ChangeAnimation(this, nextAnimationId); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B024D8.s") +/** + * Immediately switches to the specified animation for this cutscene action. + */ +void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { + switch (this->csAction) { + case GIANT_CS_ACTION_IDLE: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + break; + case GIANT_CS_ACTION_WALKING: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + break; + case GIANT_CS_ACTION_STRUGGLING: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_STRUGGLE_START); + break; + case GIANT_CS_ACTION_FALLING_OVER: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_FALLING_OVER); + break; + case GIANT_CS_ACTION_IDLE_FADE_IN: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + this->alpha = 0; + break; + case GIANT_CS_ACTION_TALKING: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_START); + break; + case GIANT_CS_ACTION_DONE_TALKING: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_END); + break; + case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_START); + break; + case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_END); + break; + case GIANT_CS_ACTION_UNKNOWN_12: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + break; + case GIANT_CS_ACTION_UNKNOWN_13: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + break; + case GIANT_CS_ACTION_UNKNOWN_14: + if (this->animationId != GIANT_ANIMATION_WALKING_LOOP) { + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_WALKING_LOOP); + } + break; + case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: + Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, + Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/EnGiant_Update.s") +void EnGiant_UpdateAlpha(EnGiant* this) { + switch (this->csAction) { + case GIANT_CS_ACTION_FALLING_OVER: + if (this->skelAnime.curFrame >= 90.0f && this->alpha > 0) { + this->alpha -= 12; + } + break; + case GIANT_CS_ACTION_UNKNOWN_14: + this->alpha -= 12; + break; + default: + if (this->alpha < 255) { + this->alpha += 8; + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B02688.s") +/** + * Plays the currently specified animation and, if the animation is done playing, + * switches to the animation appropriate for the current cutscene action. This + * function can be used to play the appropriate starting or looping animation for + * a given cutscene action, depending on what animation has already been played. + */ +void EnGiant_PlayAndUpdateAnimation(EnGiant* this) { + if (SkelAnime_Update(&this->skelAnime) && + (this->animationId != GIANT_ANIMATION_FALLING_OVER || this->csAction != GIANT_CS_ACTION_FALLING_OVER)) { + EnGiant_ChangeAnimation(this, this->animationId); + switch (this->csAction) { + case GIANT_CS_ACTION_LOOKING_UP: + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_LOOK_UP_START); + break; + case GIANT_CS_ACTION_RAISING_ARMS: + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_RAISED_ARMS_START); + break; + case GIANT_CS_ACTION_STRUGGLING: + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_STRUGGLE_START); + break; + case GIANT_CS_ACTION_FALLING_OVER: + // Unused + EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIMATION_FALLING_OVER); + break; + case GIANT_CS_ACTION_TALKING: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_BIG_CALL_LOOP); + break; + case GIANT_CS_ACTION_DONE_TALKING: + case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); + break; + case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: + EnGiant_ChangeAnimation(this, GIANT_ANIMATION_SMALL_CALL_LOOP); + break; + } + SkelAnime_Update(&this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/func_80B026C4.s") +void EnGiant_PlaySound(EnGiant* this) { + if (this->actor.draw != NULL && this->alpha > 0) { + if (this->animationId == GIANT_ANIMATION_WALKING_LOOP && + (Animation_OnFrame(&this->skelAnime, 40.0f) || Animation_OnFrame(&this->skelAnime, 100.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_WALK); + } + if (this->animationId == GIANT_ANIMATION_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); + } + if (this->sfxId != 0xFFFF && + ((this->animationId == GIANT_ANIMATION_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || + this->animationId == GIANT_ANIMATION_BIG_CALL_LOOP)) { + func_800B9010(&this->actor, this->sfxId); + } + if ((this->animationId == GIANT_ANIMATION_SMALL_CALL_START && this->skelAnime.curFrame >= 18.0f) || + this->animationId == GIANT_ANIMATION_SMALL_CALL_LOOP) { + func_800B9010(&this->actor, NA_SE_EV_KYOJIN_SIGN - SFX_FLAG); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Giant/EnGiant_Draw.s") +void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { + CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; + f32 floatUnk10 = actorAction->unk10; + s32 pad[2]; + f32 floatUnk1C = actorAction->unk1C; + f32 functionTemp; + + functionTemp = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); + this->actor.world.pos.y = ((floatUnk1C - floatUnk10) * functionTemp) + floatUnk10; +} + +void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, this->unk_24A)) { + EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->unk_24A)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + EnGiant_ChangeAnimationBasedOnCsAction(this); + } + EnGiant_UpdateAlpha(this); + } + + EnGiant_PlaySound(this); + if (this->csAction == GIANT_CS_ACTION_STRUGGLING) { + func_800B9010(&this->actor, NA_SE_IT_KYOJIN_BEARING - SFX_FLAG); + } + EnGiant_PlayAndUpdateAnimation(this); +} + +void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} + +void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { + this->actor.draw = EnGiant_Draw; + + if (func_800EE29C(globalCtx, this->unk_24A)) { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_24A)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + EnGiant_ChangeAnimationBasedOnCsAction(this); + } + EnGiant_UpdateAlpha(this); + } + + if (GIANT_TYPE_IS_TERMINA_FIELD(GIANT_TYPE(&this->actor)) && EnGiant_IsImprisoned(this)) { + this->actor.draw = NULL; + } + + EnGiant_PlaySound(this); + EnGiant_PlayAndUpdateAnimation(this); +} + +void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGiant* this = THIS; + s32 blinkTimerTemp; + + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->blinkTimer == 0) { + blinkTimerTemp = 0; + } else { + this->blinkTimer--; + blinkTimerTemp = this->blinkTimer; + } + + if (!blinkTimerTemp) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + this->faceIndex = this->blinkTimer; + if (this->faceIndex >= 3) { + this->faceIndex = 0; + } +} + +void EnGiant_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, D_06007610); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGiant* this = THIS; + + if (limbIndex == 1) { + Matrix_CopyCurrentState(&this->unk_254); + } +} + +void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGiant* this = THIS; + + /** + * 0 = eyes fully open face + * 1 = eyes half-closed face + * 2 = eyes fully closed face + */ + static TexturePtr sFaceTextures[] = { D_06005A80, D_06006280, D_06006A80 }; + + if (this->alpha > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->alpha >= 255) { + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sFaceTextures[this->faceIndex])); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawOpa, thisx); + } else if (this->alpha > 0) { + if (this->alpha >= 129) { + func_8012C2B4(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 2, 2); + } else { + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + } + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sFaceTextures[this->faceIndex])); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); + Matrix_InsertMatrix(&this->unk_254, MTXMODE_NEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_06007610); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index 9c75272fa..6f50370f7 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -3,14 +3,107 @@ #include "global.h" +#define GIANT_TYPE(thisx) ((thisx)->params & 0xF) +#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) +#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) +#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) + +/** + * The giants are divided into types based on where in the game they appear. + * - TERMINA_FIELD: These appear in all non-ending cutscenes that take place in Termina Field. + * - CLOCK_TOWER_SUCCESS: These appear in the Clock Tower when the Oath to Order is played and all giants are freed. + * - GIANTS_CHAMBER_AND_ENDING: These giants appear in the Giant's Chamber or in all cutscenes that play after defeating Majora. + * - CLOCK_TOWER_FAILURE: These appear in the Clock Tower when the Oath to Order is played and all giants are NOT freed. + * + * The SWAMP, MOUNTAIN, OCEAN, and CANYON signifiers are used to identify which of the four giants it is, + * but the devs were not always consistent about this. For example, the giants in the Giant's Chamber are + * always GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING, regardless of which boss was just defeated. These + * are named such that EnGiant_IsImprisoned has the expected behavior; the devs were only inconsistent in + * the cases where they weren't calling this function. + */ +typedef enum { + /* 0 */ GIANT_TYPE_MOUNTAIN_TERMINA_FIELD, + /* 1 */ GIANT_TYPE_CANYON_TERMINA_FIELD, + /* 2 */ GIANT_TYPE_SWAMP_TERMINA_FIELD, + /* 3 */ GIANT_TYPE_OCEAN_TERMINA_FIELD, + /* 4 */ GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS, + /* 5 */ GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS, + /* 6 */ GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS, + /* 7 */ GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS, + /* 8 */ GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING, + /* 9 */ GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING, + /* 10 */ GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING, + /* 11 */ GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING, + /* 12 */ GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE, + /* 13 */ GIANT_TYPE_CANYON_CLOCK_TOWER_FAILURE, + /* 14 */ GIANT_TYPE_SWAMP_CLOCK_TOWER_FAILURE, + /* 15 */ GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE, +} GiantType; + +/** + * These values are used to index into sAnimationTable to pick the appropriate animation. + */ +typedef enum { + /* 0 */ GIANT_ANIMATION_LOOK_UP_START, + /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, + /* 2 */ GIANT_ANIMATION_FALLING_OVER, + /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, + /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, + /* 5 */ GIANT_ANIMATION_STRUGGLE_START, + /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, + /* 7 */ GIANT_ANIMATION_IDLE_LOOP, + /* 8 */ GIANT_ANIMATION_WALKING_LOOP, + /* 9 */ GIANT_ANIMATION_BIG_CALL_START, + /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, + /* 11 */ GIANT_ANIMATION_BIG_CALL_END, + /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, + /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, + /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, + /* 15 */ GIANT_ANIMATION_MAX +} GiantAnimationIndex; + +/** + * Used as values for csAction. The UNKNOWN ones are never used in-game. + */ +typedef enum { + /* 0 */ GIANT_CS_ACTION_NONE, + /* 1 */ GIANT_CS_ACTION_IDLE, + /* 2 */ GIANT_CS_ACTION_WALKING, + /* 3 */ GIANT_CS_ACTION_LOOKING_UP, + /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, + /* 5 */ GIANT_CS_ACTION_STRUGGLING, + /* 6 */ GIANT_CS_ACTION_FALLING_OVER, + /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, + /* 8 */ GIANT_CS_ACTION_TALKING, + /* 9 */ GIANT_CS_ACTION_DONE_TALKING, + /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, + /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, + /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, + /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, + /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, + /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER +} GiantCsActionIndex; + struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); typedef struct EnGiant { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; - /* 0x0298 */ EnGiantActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[16]; + /* 0x1E8 */ Vec3s morphTable[16]; + /* 0x248 */ s16 animationId; + /* 0x24A */ u16 unk_24A; + /* 0x24C */ u16 csAction; + /* 0x24E */ s16 alpha; + /* 0x250 */ u16 sfxId; + /* 0x254 */ MtxF unk_254; + /* 0x294 */ s16 faceIndex; + /* 0x296 */ s16 blinkTimer; + /* 0x298 */ EnGiantActionFunc actionFunc; } EnGiant; // size = 0x29C extern const ActorInit En_Giant_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index cf6076b7f..e77e59ad0 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12869,22 +12869,22 @@ 0x80B00F08:("func_80B00F08",), 0x80B00F64:("func_80B00F64",), 0x80B01040:("EnTalkGibud_Draw",), - 0x80B01990:("func_80B01990",), - 0x80B01A74:("func_80B01A74",), + 0x80B01990:("EnGiant_ChangeAnimation",), + 0x80B01A74:("EnGiant_IsImprisoned",), 0x80B01B30:("EnGiant_Init",), 0x80B01E74:("EnGiant_Destroy",), - 0x80B01E84:("func_80B01E84",), - 0x80B01EE8:("func_80B01EE8",), - 0x80B020A0:("func_80B020A0",), - 0x80B0211C:("func_80B0211C",), - 0x80B02234:("func_80B02234",), - 0x80B02354:("func_80B02354",), - 0x80B023D0:("func_80B023D0",), - 0x80B024AC:("func_80B024AC",), - 0x80B024D8:("func_80B024D8",), + 0x80B01E84:("EnGiant_ChangeToStartOrLoopAnimation",), + 0x80B01EE8:("EnGiant_ChangeAnimationBasedOnCsAction",), + 0x80B020A0:("EnGiant_UpdateAlpha",), + 0x80B0211C:("EnGiant_PlayAndUpdateAnimation",), + 0x80B02234:("EnGiant_PlaySound",), + 0x80B02354:("EnGiant_UpdatePosition",), + 0x80B023D0:("EnGiant_PerformClockTowerSuccessActions",), + 0x80B024AC:("EnGiant_PlayClockTowerFailureAnimation",), + 0x80B024D8:("EnGiant_PerformCutsceneActions",), 0x80B025CC:("EnGiant_Update",), - 0x80B02688:("func_80B02688",), - 0x80B026C4:("func_80B026C4",), + 0x80B02688:("EnGiant_PostLimbDrawOpa",), + 0x80B026C4:("EnGiant_PostLimbDrawXlu",), 0x80B026FC:("EnGiant_Draw",), 0x80B02CD0:("func_80B02CD0",), 0x80B02D58:("func_80B02D58",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d6a0e05ee..2b5e23257 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2321,11 +2321,26 @@ D_0600F6C0 = 0x0600F6C0; // ovl_En_Giant D_06002168 = 0x06002168; +D_06005A80 = 0x06005A80; +D_06006280 = 0x06006280; +D_06006A80 = 0x06006A80; D_06007610 = 0x06007610; D_060079B0 = 0x060079B0; +D_06008394 = 0x06008394; +D_060096E4 = 0x060096E4; +D_0600A1C4 = 0x0600A1C4; +D_0600ACA4 = 0x0600ACA4; +D_0600B784 = 0x0600B784; +D_0600C5D4 = 0x0600C5D4; +D_0600D040 = 0x0600D040; +D_0600DE84 = 0x0600DE84; +D_060102A4 = 0x060102A4; D_060116E4 = 0x060116E4; +D_06012A38 = 0x06012A38; D_06013004 = 0x06013004; D_06013FE8 = 0x06013FE8; +D_06015334 = 0x06015334; +D_06017944 = 0x06017944; // ovl_En_Ginko_Man From 820d8b6270454898cc753be1c3349a60da3d6d4a Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 25 Oct 2021 13:00:07 +0000 Subject: [PATCH 47/86] ovl_En_Muto OK (#358) * ovl_En_Muto OK * Address initial PR comments * Add heading to file * Address additional PR comments * Update ovl_En_Muto to new animation system --- spec | 3 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 284 ++++++++++++++++++-- src/overlays/actors/ovl_En_Muto/z_en_muto.h | 20 +- 3 files changed, 282 insertions(+), 25 deletions(-) diff --git a/spec b/spec index 697971ff1..7cbd8da08 100644 --- a/spec +++ b/spec @@ -5004,8 +5004,7 @@ beginseg name "ovl_En_Muto" compress include "build/src/overlays/actors/ovl_En_Muto/z_en_muto.o" - include "build/data/ovl_En_Muto/ovl_En_Muto.data.o" - include "build/data/ovl_En_Muto/ovl_En_Muto.reloc.o" + include "build/src/overlays/actors/ovl_En_Muto/ovl_En_Muto_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index e8e88b6df..041fad748 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -1,3 +1,9 @@ +/* + * File: z_en_muto.c + * Overlay: ovl_En_Muto + * Description: Mutoh, leader of the carpenters + */ + #include "z_en_muto.h" #define FLAGS 0x00000009 @@ -9,10 +15,17 @@ void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx); void EnMuto_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE7DEC(EnMuto* this, GlobalContext* globalCtx); -void func_80BE7FEC(EnMuto* this, GlobalContext* globalCtx); +void EnMuto_ChangeAnim(EnMuto* this, s32 arg1); +void EnMuto_SetHeadRotation(EnMuto* this); +void EnMuto_SetupIdle(EnMuto* this); +void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx); +void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx); +void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx); +s32 EnMuto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); + +extern AnimationHeader D_06000E50; +extern FlexSkeletonHeader D_06007150; -#if 0 const ActorInit En_Muto_InitVars = { ACTOR_EN_MUTO, ACTORCAT_NPC, @@ -25,37 +38,266 @@ const ActorInit En_Muto_InitVars = { (ActorFunc)EnMuto_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE841C = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x0624, 0x0623, 0x2AC6 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMuto* this = THIS; -extern ColliderCylinderInit D_80BE841C; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); -extern UNK_TYPE D_06000E50; + this->isInMayorsRoom = this->actor.params; + if (!this->isInMayorsRoom) { + this->shouldSetHeadRotation = true; + this->textIdIndex = 2; + if (gSaveContext.weekEventReg[60] & 0x80) { + this->textIdIndex = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/EnMuto_Init.s") + if (gSaveContext.day != 3 || !gSaveContext.isNight) { + Actor_MarkForDeath(&this->actor); + } + } else { + this->collider.dim.radius = 30; + this->collider.dim.height = 60; + this->collider.dim.yShift = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/EnMuto_Destroy.s") + if (gSaveContext.weekEventReg[63] & 0x80 || (gSaveContext.day == 3 && gSaveContext.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7C94.s") + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + EnMuto_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7D20.s") +void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMuto* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7DB4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7DEC.s") +void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { &D_06000E50, &D_06000E50 }; + static u8 sAnimationModes[] = { 0, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7F88.s") + this->animIndex = animIndex; + this->frameIndex = Animation_GetLastFrame(&sAnimations[animIndex]->common); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameIndex, + sAnimationModes[this->animIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE7FEC.s") +void EnMuto_SetHeadRotation(EnMuto* this) { + s32 yawRotToTarget = ABS_ALT(BINANG_SUB(this->yawTowardsTarget, this->actor.world.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/EnMuto_Update.s") + this->headRotTarget.y = 0; + if (this->actor.xzDistToPlayer < 200.0f && yawRotToTarget < 0x4E20) { + this->headRotTarget.y = BINANG_SUB(this->yawTowardsTarget, this->actor.world.rot.y); + if (this->headRotTarget.y > 0x2710) { + this->headRotTarget.y = 0x2710; + } else if (this->headRotTarget.y < -0x2710) { + this->headRotTarget.y = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/func_80BE8328.s") +void EnMuto_SetupIdle(EnMuto* this) { + EnMuto_ChangeAnim(this, 0); + this->isInDialogue = false; + this->actionFunc = EnMuto_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Muto/EnMuto_Draw.s") +void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { + Player* player; + this->actor.textId = sTextIds[this->textIdIndex]; + + if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.weekEventReg[0x58] & 8)) { + this->actor.textId = 0x62C; + } else { + this->actor.textId = 0x62B; + } + } + + if (1) {} // Needed to match + + if (!this->isInMayorsRoom && Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + this->actor.textId = 0x2363; + } + + if (func_800B84D0(&this->actor, globalCtx)) { + EnMuto_SetupDialogue(this, globalCtx); + return; + } + + if (!this->isInMayorsRoom) { + s16 yawRotToPlayer = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); + + this->yawTowardsTarget = this->actor.yawTowardsPlayer; + if (yawRotToPlayer > 0x2890) { + return; + } + } else { + this->textIdIndex = 0; + if (gSaveContext.weekEventReg[0x3C] & 8) { + this->textIdIndex = 1; + } + if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLES_MASK) { + this->textIdIndex = 4; + } + + if (this->cutsceneState == 1) { + EnMuto_SetupDialogue(this, globalCtx); + return; + } + } + + func_800B8614(&this->actor, globalCtx, 80.0f); +} + +void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { + if (!this->isInMayorsRoom) { + this->yawTowardsTarget = 0; + } + + if (this->targetActor != NULL) { + this->shouldSetHeadRotation = true; + this->cutsceneState = 1; + func_800B86C8(this->targetActor, globalCtx, this->targetActor); + } + + this->isInDialogue = true; + this->actionFunc = EnMuto_InDialogue; +} + +void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { + if (!this->isInMayorsRoom) { + this->yawTowardsTarget = this->actor.yawTowardsPlayer; + if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + if (this->actor.textId == 0x62C) { + gSaveContext.weekEventReg[88] |= 8; + } + if (this->actor.textId == 0x624) { + gSaveContext.weekEventReg[60] |= 0x80; + } + + this->textIdIndex = 3; + + EnMuto_SetupIdle(this); + } + return; + } + + if (this->targetActor == &this->actor) { + this->yawTowardsTarget = this->actor.world.rot.y; + if (this->skelAnime.playSpeed == 0.0f) { + this->skelAnime.playSpeed = 1.0f; + } + } else { + f32 frameIndex = this->skelAnime.curFrame; + + this->yawTowardsTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &this->targetActor->world.pos); + if (this->frameIndex <= frameIndex) { + this->skelAnime.playSpeed = 0.0f; + } + } + + if (globalCtx->msgCtx.unk11F04 == 0x2AC6 || globalCtx->msgCtx.unk11F04 == 0x2AC7 || + globalCtx->msgCtx.unk11F04 == 0x2AC8) { + this->skelAnime.playSpeed = 0.0f; + this->yawTowardsTarget = this->actor.yawTowardsPlayer; + this->skelAnime.curFrame = 30.0f; + } + if (globalCtx->msgCtx.unk11F04 == 0x2ACF) { + this->skelAnime.playSpeed = 0.0f; + } + + if (this->cutsceneState == 2) { + EnMuto_SetupIdle(this); + } +} + +void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnMuto* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + if (this->shouldSetHeadRotation) { + EnMuto_SetHeadRotation(this); + } + + if (this->isInMayorsRoom && gSaveContext.day == 3 && gSaveContext.isNight) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actionFunc(this, globalCtx); + + DECR(this->unusedCounter); + + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_SetHeight(&this->actor, 60.0f); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + + Math_SmoothStepToS(&this->headRot.y, this->headRotTarget.y, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); + Math_SmoothStepToS(&this->waistRot.y, this->waistRotTarget.y, 1, 0xBB8, 0); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1DU); + + this->actor.uncullZoneForward = 500.0f; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnMuto_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnMuto* this = THIS; + + if (limbIndex == 1) { + rot->x += this->waistRot.y; + } + + if (limbIndex == 15) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + + return false; +} + +void EnMuto_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMuto* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMuto_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.h b/src/overlays/actors/ovl_En_Muto/z_en_muto.h index 817c4ea8a..29af0d624 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.h +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.h @@ -9,9 +9,25 @@ typedef void (*EnMutoActionFunc)(struct EnMuto*, GlobalContext*); typedef struct EnMuto { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[17]; + /* 0x01EE */ Vec3s morphTable[17]; /* 0x0254 */ EnMutoActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x88]; + /* 0x0258 */ Vec3s headRot; + /* 0x025E */ Vec3s headRotTarget; + /* 0x0262 */ Vec3s waistRot; + /* 0x026A */ Vec3s waistRotTarget; + /* 0x0270 */ s16 unusedCounter; + /* 0x0274 */ f32 frameIndex; + /* 0x0278 */ s16 isInDialogue; + /* 0x027A */ s16 textIdIndex; + /* 0x027C */ s16 yawTowardsTarget; + /* 0x0280 */ s32 isInMayorsRoom; + /* 0x0284 */ s32 shouldSetHeadRotation; + /* 0x0288 */ Actor* targetActor; + /* 0x028C */ s32 cutsceneState; + /* 0x0290 */ s32 animIndex; + /* 0x0294 */ ColliderCylinder collider; } EnMuto; // size = 0x2E0 extern const ActorInit En_Muto_InitVars; From a60c47a970f45363868a868f6ba8ad32b4fd404a Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Wed, 27 Oct 2021 14:28:52 +0100 Subject: [PATCH 48/86] En_Fish2 (#292) * En_Fish2 * Fix --- include/functions.h | 2 +- include/variables.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 1156 ++++++++++++++++- src/overlays/actors/ovl_En_Fish2/z_en_fish2.h | 51 +- .../actors/ovl_En_Mushi2/z_en_mushi2.h | 7 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 4 + 8 files changed, 1172 insertions(+), 57 deletions(-) diff --git a/include/functions.h b/include/functions.h index 80e48e256..0ccda1bc5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1013,7 +1013,7 @@ s32 func_800C576C(CollisionContext* colCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg // void func_800C58C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_800C5954(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8); s32 func_800C5A20(CollisionContext* colCtx, Vec3f* arg1, f32 arg2); -// void func_800C5A64(void); +s32 func_800C5A64(CollisionContext* colCtx, Vec3f* arg1, f32 arg2, Actor* actor); void BgCheck_ScenePolygonListsInit(SSNodeList* arg0); void BgCheck_ScenePolygonListsAlloc(GlobalContext* globalCtx, SSNodeList* lists, s32 numNodes, u32 numPolygons); s32 func_800C5B80(u16* arg0); diff --git a/include/variables.h b/include/variables.h index ddc77f90f..7bfd0de86 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3985,7 +3985,7 @@ extern Gfx D_0402E510[]; extern UNK_TYPE D_0402E65C; extern UNK_TYPE D_0402F0EC; extern Gfx D_04030100[]; // Floor shockwave ring -extern UNK_TYPE D_040301B0; +extern Gfx D_040301B0[]; extern UNK_TYPE D_04032270; extern UNK_TYPE D_04035710; extern UNK_TYPE D_040367B0; diff --git a/spec b/spec index 7cbd8da08..c282c24e0 100644 --- a/spec +++ b/spec @@ -4054,8 +4054,7 @@ beginseg name "ovl_En_Fish2" compress include "build/src/overlays/actors/ovl_En_Fish2/z_en_fish2.o" - include "build/data/ovl_En_Fish2/ovl_En_Fish2.data.o" - include "build/data/ovl_En_Fish2/ovl_En_Fish2.reloc.o" + include "build/src/overlays/actors/ovl_En_Fish2/ovl_En_Fish2_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 47e9c2efe..aba81fc31 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -1,3 +1,10 @@ +/* + * File: z_en_fish2.c + * Overlay: ovl_En_Fish2 + * Description: Marine Research Lab Fish + */ + +#include "overlays/actors/ovl_En_Mushi2/z_en_mushi2.h" #include "z_en_fish2.h" #define FLAGS 0x00000019 @@ -9,7 +16,43 @@ void EnFish2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx); void EnFish2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B28B5C(EnFish2* this); +void func_80B28C14(EnFish2* this, GlobalContext* globalCtx); +void func_80B29128(EnFish2* this); +void func_80B2913C(EnFish2* this, GlobalContext* globalCtx); +void func_80B29194(EnFish2* this); +void func_80B29250(EnFish2* this, GlobalContext* globalCtx); +void func_80B2938C(EnFish2* this); +void func_80B293C4(EnFish2* this, GlobalContext* globalCtx); +void func_80B2951C(EnFish2* this); +void func_80B295A4(EnFish2* this, GlobalContext* globalCtx); +void func_80B29778(EnFish2* this); +void func_80B297FC(EnFish2* this, GlobalContext* globalCtx); +void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx); +void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx); +void func_80B2A01C(EnFish2* this, GlobalContext* globalCtx); +void func_80B2A094(EnFish2* this, GlobalContext* globalCtx); +void func_80B2A23C(EnFish2* this, GlobalContext* globalCtx); +void func_80B2A448(EnFish2* this); +void func_80B2A498(EnFish2* this, GlobalContext* globalCtx); +void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2); +void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx); +void func_80B2B180(EnFish2* this, GlobalContext* globalCtx); + +extern AnimationHeader D_060006D8; +extern AnimationHeader D_060007D4; +extern AnimationHeader D_06000ACC; +extern AnimationHeader D_06001174; +extern AnimationHeader D_060013AC; +extern FlexSkeletonHeader D_06006190; + +static s32 D_80B2B2E0 = 0; +static s32 D_80B2B2E4 = 0; +static s32 D_80B2B2E8 = 0; +static s32 D_80B2B2EC = 0; +static s32 D_80B2B2F0 = 0; +static Actor* D_80B2B2F4 = NULL; + const ActorInit En_Fish2_InitVars = { ACTOR_EN_FISH2, ACTORCAT_PROP, @@ -22,95 +65,1114 @@ const ActorInit En_Fish2_InitVars = { (ActorFunc)EnFish2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80B2B318[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 17, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B2B360 = { - { COLTYPE_HARD, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_80B2B318, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -#endif +static f32 D_80B2B370[] = { 0.01f, 0.012f, 0.014f, 0.017f }; +static f32 D_80B2B380[] = { 0.019f, 0.033f }; -extern ColliderJntSphElementInit D_80B2B318[2]; -extern ColliderJntSphInit D_80B2B360; +void func_80B28370(EnFish2* this, s32 arg0) { + static AnimationHeader* D_80B2B388[] = { + &D_060013AC, &D_060007D4, &D_060006D8, &D_060006D8, &D_06001174, &D_06000ACC, + }; + static u8 D_80B2B3A0[] = { 0, 0, 2, 2, 2, 2 }; + f32 sp34; -extern UNK_TYPE D_060013AC; + this->unk_2AC = arg0; + this->unk_2CC = Animation_GetLastFrame(&D_80B2B388[arg0]->common); + sp34 = 0.0f; + if (this->unk_2AC == 3) { + sp34 = Animation_GetLastFrame(&D_80B2B388[this->unk_2AC]->common) - 21.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B28370.s") + if (this->unk_2AC == 2) { + this->unk_2CC = Animation_GetLastFrame(&D_80B2B388[this->unk_2AC]->common) - 21.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B28478.s") + Animation_Change(&this->skelAnime, D_80B2B388[this->unk_2AC], 1.0f, sp34, this->unk_2CC, D_80B2B3A0[this->unk_2AC], + -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/EnFish2_Init.s") +s32 func_80B28478(EnFish2* this) { + if (this->unk_2C8 == 0) { + if ((D_80B2B2E4 != 0) && ((D_80B2B2E0 != 1) || (this->unk_350 == NULL) || (this->unk_350->update == NULL)) && + (this->unk_2B0 == 0)) { + this->unk_2B4 = 0; + this->unk_2C4 = 0; + this->unk_2B6 = this->unk_2B4; + func_80B28B5C(this); + return true; + } + } else if ((this->unk_350 == NULL) || (this->unk_350->update == NULL)) { + this->unk_2B4 = 0; + this->unk_2C4 = 0; + this->unk_2B6 = this->unk_2B4; + func_80B28B5C(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/EnFish2_Destroy.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B287F4.s") +void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFish2* this = THIS; + s32 i; + s32 cs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B288E8.s") + Math_Vec3f_Copy(&this->unk_324, &this->actor.home.pos); + this->unk_344 = D_80B2B2F0; + D_80B2B2F0++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2899C.s") + if (this->actor.params == 0) { + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006190, &D_060013AC, this->jointTable, this->morphTable, + 24); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if (this->unk_344 == 0) { + if (gSaveContext.weekEventReg[81] & 0x10) { + this->unk_2C0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B289DC.s") + if (gSaveContext.weekEventReg[81] & 0x20) { + this->unk_2C0 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B28B5C.s") + if (gSaveContext.weekEventReg[81] & 0x40) { + this->unk_2C0 = 3; + } + } else { + if (gSaveContext.weekEventReg[81] & 0x80) { + this->unk_2C0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B28C14.s") + if (gSaveContext.weekEventReg[82] & 1) { + this->unk_2C0 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29128.s") + if (gSaveContext.weekEventReg[82] & 2) { + this->unk_2C0 = 3; + } + } + cs = this->actor.cutscene; + this->unk_330 = D_80B2B370[this->unk_2C0]; + i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2913C.s") + // clang-format off + while (cs != -1) { this->unk_2BA[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29194.s") + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].dim.modelSphere.radius = 5; + this->collider.elements[0].dim.scale = 1.0f; + this->collider.elements[0].dim.modelSphere.center.x = 1300; + this->collider.elements[0].dim.modelSphere.center.y = 0; + this->collider.elements[0].dim.modelSphere.center.z = 0; + this->collider.elements[1].dim.modelSphere.radius = 5; + this->collider.elements[1].dim.scale = 1.0f; + this->collider.elements[1].dim.modelSphere.center.x = 500; + this->collider.elements[1].dim.modelSphere.center.y = 0; + this->collider.elements[1].dim.modelSphere.center.z = 0; + this->actor.textId = 0x24C; + func_80B28B5C(this); + } else if (this->actor.params != 0) { + this->unk_2B4 = 10; + this->actor.draw = NULL; + this->actor.flags |= 0x8000000; + this->actionFunc = func_80B2A01C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29250.s") +void EnFish2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFish2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2938C.s") + if (this->actor.params != 1) { + Collider_DestroyJntSph(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B293C4.s") +void func_80B287F4(EnFish2* this, s32 arg1) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2951C.s") + if ((this->unk_354 != 0) && (this->unk_2C8 == 0)) { + if (this->unk_2C4 < 400) { + this->unk_2C4++; + } + this->unk_338 = 440.0f - this->unk_2C4; + if (arg1 == 0) { + this->unk_338 = 410.0f - this->unk_2C4; + } + Math_ApproachF(&this->unk_350->speedXZ, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); + } + Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); + this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->unk_348 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B295A4.s") +s32 func_80B288E8(EnFish2* this, Vec3f vec, s32 arg2) { + f32 temp_f2 = this->unk_350->world.pos.x - vec.x; + f32 temp_f12 = this->unk_350->world.pos.y - vec.y; + f32 temp_f14 = this->unk_350->world.pos.z - vec.z; + f32 dist = sqrtf(SQ(temp_f2) + SQ(temp_f12) + SQ(temp_f14)); + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29778.s") + if (arg2 == 0) { + phi_f2 = 40.0f; + } else { + phi_f2 = this->unk_330 * 2000.0f; + if (phi_f2 > 20.0f) { + phi_f2 = 20.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B297FC.s") + if (dist < phi_f2) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29E5C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B29EE4.s") +s32 func_80B2899C(EnFish2* this, GlobalContext* globalCtx) { + if (func_800C5A64(&globalCtx->colCtx, &this->unk_2F4, this->unk_33C, &this->actor)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2A01C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2A094.s") +void func_80B289DC(EnFish2* this, GlobalContext* globalCtx) { + WaterBox* sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2A23C.s") + if (this->unk_2B4 != 0) { + this->unk_348 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2A448.s") + if (this->unk_348 != 0) { + if (this->unk_348 > 0) { + if (this->unk_2D4 < this->actor.world.pos.y) { + this->actor.velocity.y = this->actor.world.rot.x * 0.001f * -0.1f; + if (this->actionFunc == func_80B297FC) { + this->actor.velocity.y *= 2.0f; + } + } else { + this->unk_348 = 0; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } + } else if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp2C)) { + if ((this->unk_334 != BGCHECK_Y_MIN) && (this->actor.world.pos.y < (this->unk_334 - this->unk_2D8))) { + this->actor.velocity.y = this->actor.world.rot.x * 0.001f * -0.1f; + if (this->actionFunc == func_80B297FC) { + this->actor.velocity.y *= 2.0f; + } + } + } else { + this->unk_348 = 0; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2A498.s") +void func_80B28B5C(EnFish2* this) { + func_80B28370(this, 0); + this->unk_2B4 = 0; + this->unk_348 = 0; + this->unk_2C4 = 0; + this->unk_2C8 = 0; + this->unk_334 = BGCHECK_Y_MIN; + this->unk_2B6 = this->unk_2B4; + this->unk_34C = this->unk_348; + this->unk_34A = this->actor.world.rot.y; + this->collider.elements[1].dim.modelSphere.radius = (s32)((this->unk_330 - 0.01f) * 1000.0f) + 5; + if (this->collider.elements[1].dim.modelSphere.radius > 15) { + this->collider.elements[1].dim.modelSphere.radius = 15; + } + this->actionFunc = func_80B28C14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/EnFish2_Update.s") +void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + WaterBox* waterbox; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2ABF4.s") + if (func_800B84D0(&this->actor, globalCtx)) { + func_80B29128(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2AC20.s") + if ((this->unk_2B8 == 0) && (fabsf(this->actor.world.rot.y - this->unk_34A) < 100.0f)) { + if (func_80B2899C(this, globalCtx)) { + if (this->unk_340 == 0) { + this->unk_34A += 0x4000; + } else { + this->unk_34A -= 0x4000; + } + this->unk_2B8 = (s32)(this->unk_330 * 1000.0f) - 10; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/EnFish2_Draw.s") + func_80B289DC(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2ADB0.s") + if (this->unk_2B6 == 0) { + if (this->unk_2B4 == 0) { + this->unk_2B4 = (s32)Rand_ZeroFloat(20.0f) + 10; + } else if (this->unk_2B4 == 1) { + if ((this->unk_348 == 0) || (Rand_ZeroOne() < 0.6f)) { + this->unk_348 = randPlusMinusPoint5Scaled(0x2000); + } else { + this->unk_348 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_324); + if (this->unk_348 < -0x1000) { + this->unk_348 = -0x1000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2AF80.s") + if (this->unk_348 > 0x1000) { + this->unk_348 = 0x1000; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish2/func_80B2B180.s") + this->unk_2B6 = (s32)Rand_ZeroFloat(70.0f) + 30; + if (this->unk_2C0 >= 3) { + this->unk_2B6 -= (s32)Rand_ZeroFloat(20.0f); + } + } + } + + if ((this->unk_334 == BGCHECK_Y_MIN) && !func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, + this->actor.world.pos.z, &this->unk_334, &waterbox)) { + this->unk_334 = this->actor.world.pos.y; + } + + if (this->unk_2B4 == 0) { + Math_ApproachF(&this->actor.speedXZ, (D_80B2B380[0] - this->unk_330) * 400.0f, 0.3f, 0.3f); + if (this->actor.speedXZ > 3.0f) { + this->actor.speedXZ = 3.0f; + } else if (this->actor.speedXZ < 1.5f) { + this->actor.speedXZ = 1.5f; + } + } else { + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 0.3f); + } + + if ((D_80B2B2E8 == 0) && (D_80B2B2E0 != 2)) { + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_FISH) && (itemAction->id != ACTOR_EN_MUSHI2)) { + itemAction = itemAction->next; + continue; + } + + if (itemAction->id == ACTOR_EN_MUSHI2) { + if ((itemAction->update != NULL) && (((EnMushi2*)itemAction)->unk_30C & 0x200)) { + this->unk_350 = itemAction; + this->unk_2C8 = 1; + func_80B29194(this); + break; + } + } else if ((itemAction->update != NULL) && (itemAction->params == 0) && + (fabsf(itemAction->world.pos.x - this->actor.world.pos.x) < 100.0f) && + (fabsf(itemAction->world.pos.z - this->actor.world.pos.z) < 100.0f) && + (itemAction->bgCheckFlags & 0x20)) { + this->unk_350 = itemAction; + if (D_80B2B2E0 == 0) { + EnFish2* fish; + + this->unk_354 = NULL; + fish = (EnFish2*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_FISH2, + this->unk_324.x, this->unk_324.y, this->unk_324.z, 0, 0, 0, 1); + this->unk_354 = fish; + if (this->unk_354 != NULL) { + D_80B2B2E4 = 0; + D_80B2B2E0 = 1; + fish->unk_2BA[0] = this->unk_2BA[0]; + fish->unk_350 = this->unk_350; + } + } + func_80B29194(this); + break; + } + itemAction = itemAction->next; + } + + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void func_80B29128(EnFish2* this) { + this->actionFunc = func_80B2913C; +} + +void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80B28B5C(this); + } +} + +void func_80B29194(EnFish2* this) { + if ((this->unk_354 != NULL) && (this->unk_2C8 == 0)) { + EnMushi2* mushi = (EnMushi2*)this->unk_350; + mushi->unk_277 = 1; + } + + this->unk_2C4 = 0; + this->actor.speedXZ = 0.0f; + if (this->unk_2C8 == 0) { + this->unk_34C = 400; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_324); + this->actor.world.pos.y = this->actor.floorHeight + (this->unk_330 * 1200.0f); + } + + this->unk_34A = 0; + this->unk_340 = (s32)Rand_ZeroOne() & 1; + func_80B28370(this, 1); + this->actionFunc = func_80B29250; +} + +void func_80B29250(EnFish2* this, GlobalContext* globalCtx) { + if (!func_80B28478(this)) { + Math_ApproachF(&this->actor.speedXZ, (D_80B2B380[0] - this->unk_330) * 1000.0f, 0.3f, 0.3f); + + if (this->actor.speedXZ > 4.0f) { + this->actor.speedXZ = 4.0f; + } else if (this->actor.speedXZ < 2.0f) { + this->actor.speedXZ = 2.0f; + } + + func_80B287F4(this, 0); + func_80B289DC(this, globalCtx); + if (func_80B288E8(this, this->unk_300, 0) && + (((this->unk_2C8 == 0) && (D_80B2B2E4 == 1)) || (this->unk_2C8 != 0))) { + Math_Vec3f_Copy(&this->unk_30C, &this->unk_350->world.pos); + func_80B2938C(this); + } + } +} + +void func_80B2938C(EnFish2* this) { + func_80B28370(this, 5); + this->unk_348 = 0; + this->actionFunc = func_80B293C4; +} + +void func_80B293C4(EnFish2* this, GlobalContext* globalCtx) { + f32 currentFrame = this->skelAnime.curFrame; + + if (func_80B28478(this) == 0) { + func_80B287F4(this, 1); + Math_ApproachF(&this->actor.speedXZ, (*D_80B2B380 - this->unk_330) * 1000.0f, 0.3f, 0.3f); + + if (this->actor.speedXZ > 3.0f) { + this->actor.speedXZ = 3.0f; + } else if (this->actor.speedXZ < 1.0f) { + this->actor.speedXZ = 1.0f; + } + + if (this->unk_2CC <= currentFrame) { + func_80B28370(this, 1); + if (this->unk_2B0 == 0) { + this->actionFunc = func_80B29250; + } else { + this->actionFunc = func_80B29EE4; + } + } else { + func_80B289DC(this, globalCtx); + if (func_80B288E8(this, this->unk_318, 1)) { + func_80B2951C(this); + } + } + } +} + +void func_80B2951C(EnFish2* this) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->unk_348 = 0; + + if (this->unk_2C8 == 0) { + D_80B2B2E0 = 2; + } + + this->unk_2B4 = 10; + this->actor.speedXZ = 3.0f; + Actor_MarkForDeath(this->unk_350); + this->unk_350 = NULL; + D_80B2B2F4 = &this->actor; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_EAT); + this->actionFunc = func_80B295A4; +} + +void func_80B295A4(EnFish2* this, GlobalContext* globalCtx) { + s32 i; + f32 currentFrame = this->skelAnime.curFrame; + s32 pad; + Vec3f sp60; + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &globalCtx->view.eye), 1, + 0x1388, 0); + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 0.3f); + if (this->unk_2B4 != 0) { + Math_Vec3f_Copy(&sp60, &this->unk_318); + sp60.x += randPlusMinusPoint5Scaled(100.0f); + sp60.z += randPlusMinusPoint5Scaled(100.0f); + + for (i = 0; i < 2; i++) { + EffectSsBubble_Spawn(globalCtx, &sp60, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); + } + } else if (this->unk_2CC <= currentFrame) { + if (this->unk_2AC != 5) { + func_80B28370(this, 5); + } else if (this->unk_2C8 == 0) { + func_80B29778(this); + } else { + this->unk_2B4 = 0; + this->unk_2C4 = 0; + this->unk_2B6 = this->unk_2B4; + func_80B28B5C(this); + } + } +} + +void func_80B29778(EnFish2* this) { + func_80B28370(this, 0); + this->unk_2B4 = 0; + this->unk_2C4 = 0; + this->unk_2B6 = this->unk_2B4; + if (this->unk_2B0 != 0) { + this->unk_324.x = this->actor.home.pos.x - 14.0f; + this->unk_324.z = this->actor.home.pos.z - 18.0f; + } + this->actionFunc = func_80B297FC; + this->unk_324.y = this->unk_2D4; + this->actor.speedXZ = 0.0f; +} + +void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { + f32 phi_f0 = 0.0f; + Vec3f sp48; + + switch (this->unk_2C4) { + case 0: + Math_Vec3f_Copy(&sp48, &this->unk_324); + sp48.y = this->unk_2D4; + this->unk_348 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp48); + + if (this->unk_348 < -0x2000) { + this->unk_348 = -0x2000; + } + + if (this->unk_348 > 0x2000) { + this->unk_348 = 0x2000; + } + + this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_324); + func_80B289DC(this, globalCtx); + Math_ApproachF(&this->actor.world.pos.x, this->unk_324.x, 0.3f, 3.0f); + Math_ApproachF(&this->actor.world.pos.y, this->unk_2D4, 0.3f, 3.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_324.z, 0.3f, 3.0f); + if ((fabsf(this->actor.world.pos.x - this->unk_324.x) < 2.0f) && + (this->actor.world.pos.y < (this->unk_2D4 + 3.0f)) && + (fabsf(this->actor.world.pos.z - this->unk_324.z) < 2.0f)) { + this->actor.speedXZ = 0.0f; + this->unk_34A = BINANG_ROT180(this->actor.home.rot.y); + this->unk_2C4++; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } + break; + + case 1: + Math_SmoothStepToS(&this->unk_348, 0, 1, 0x7D0, 0); + if ((fabsf(this->actor.world.rot.y - this->unk_34A) < 100.0f) && (fabsf(this->actor.world.rot.x) < 30.0f)) { + this->unk_2C0++; + if (this->unk_344 == 0) { + if (this->unk_2C0 == 1) { + gSaveContext.weekEventReg[81] |= 0x10; + } else if (this->unk_2C0 == 2) { + gSaveContext.weekEventReg[81] |= 0x20; + } else if (this->unk_2C0 == 3) { + gSaveContext.weekEventReg[81] |= 0x40; + } + } else if (this->unk_2C0 == 1) { + gSaveContext.weekEventReg[81] |= 0x80; + } else if (this->unk_2C0 == 2) { + gSaveContext.weekEventReg[82] |= 1; + } else if (this->unk_2C0 == 3) { + gSaveContext.weekEventReg[82] |= 2; + } + + if (this->unk_2B0 != 0) { + this->unk_2C0 = 5; + } + + this->unk_2B6 = 4; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_GROW_UP); + this->unk_2C4++; + } + break; + + case 2: + phi_f0 = 0.1f; + + case 4: + if (phi_f0 == 0) { + phi_f0 = 0.3f; + } + + case 6: + if (phi_f0 == 0) { + phi_f0 = 0.5f; + } + + Math_ApproachF(&this->unk_330, D_80B2B370[this->unk_2C0] * phi_f0, 0.3f, 0.004f); + + if (this->unk_2B6 == 0) { + Vec3f sp3C; + s32 i; + s32 pad2; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.y += -10.0f; + + for (i = 0; i < 30; i++) { + func_80B2ADB0(this, &sp3C, 0x46); + } + this->unk_2C4++; + this->unk_2B6 = 2; + } + break; + + case 3: + phi_f0 = 1.3f; + + case 5: + if (phi_f0 == 0) { + phi_f0 = 1.5f; + } + + case 7: + if (phi_f0 == 0) { + phi_f0 = 1.7f; + } + + Math_ApproachF(&this->unk_330, D_80B2B370[this->unk_2C0] * phi_f0, 0.3f, 0.004f); + + if (this->unk_2B6 == 0) { + this->unk_2B6 = 2; + this->unk_2C4++; + } + break; + + case 8: + Math_ApproachF(&this->unk_330, D_80B2B370[this->unk_2C0], 0.3f, 0.004f); + if (this->unk_2B6 == 0) { + this->unk_2B6 = 30; + this->unk_2C4++; + } + break; + + case 9: + if (this->unk_2B6 == 0) { + if (this->unk_2C0 > 3) { + this->unk_2C0 = 3; + this->unk_2C4 = 0; + if (this->unk_2B0 == 0) { + this->actionFunc = func_80B29E5C; + } else { + func_80B2A448(this); + } + } else { + this->unk_2B6 = 0; + this->unk_2B4 = 0; + this->unk_2C4 = 0; + if (D_80B2B2EC > 200) { + D_80B2B2E4 = 0; + D_80B2B2E0 = D_80B2B2EC = 0; + } else { + D_80B2B2E4 = 3; + } + + this->collider.elements[0].dim.modelSphere.radius = (s32)((this->unk_330 - 0.01f) * 1000.0f) + 5; + if (this->collider.elements[0].dim.modelSphere.radius > 15) { + this->collider.elements[0].dim.modelSphere.radius = 15; + } + + this->collider.elements[1].dim.modelSphere.radius = (s32)((this->unk_330 - 0.01f) * 1000.0f) + 5; + if (this->collider.elements[1].dim.modelSphere.radius > 15) { + this->collider.elements[1].dim.modelSphere.radius = 15; + } + func_80B28B5C(this); + } + } + break; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_34A, 1, 0xFA0, 0); +} + +void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + + while (prop != NULL) { + if (prop->id != ACTOR_EN_FISH2) { + prop = prop->next; + continue; + } + + if (&this->actor != prop) { + this->unk_350 = prop; + this->unk_2B0 = D_80B2B2E8 = 1; + func_80B28370(this, 0); + this->actionFunc = func_80B29EE4; + break; + } + + prop = prop->next; + } +} + +void func_80B29EE4(EnFish2* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this->unk_2C4 < 400) { + this->unk_2C4++; + } + this->unk_338 = 410.0f - this->unk_2C4; + Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.3f); + Math_ApproachF(&this->unk_350->speedXZ, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); + func_80B289DC(this, globalCtx); + Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); + this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->unk_348 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); + if (func_80B288E8(this, this->unk_300, 0)) { + Math_Vec3f_Copy(&this->unk_30C, &this->unk_350->world.pos); + func_80B2938C(this); + } +} + +void func_80B2A01C(EnFish2* this, GlobalContext* globalCtx) { + if (this->unk_2B4 == 0) { + if (!ActorCutscene_GetCanPlayNext(this->unk_2BA[0])) { + ActorCutscene_SetIntentToPlay(this->unk_2BA[0]); + } else { + this->unk_2B4 = 15; + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2BA[0], &this->actor); + this->actionFunc = func_80B2A094; + } + } +} + +void func_80B2A094(EnFish2* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this->unk_2B4 == 0) { + D_80B2B2E4 = 1; + } + + this->unk_2CA = ActorCutscene_GetCurrentCamera(this->unk_2BA[0]); + + if (D_80B2B2EC != 0) { + D_80B2B2EC++; + if (D_80B2B2EC > 200) { + Actor_MarkForDeath(&this->actor); + ActorCutscene_Stop(this->unk_2BA[0]); + return; + } + } + + if ((this->unk_350 != NULL) && (this->unk_350->update != NULL)) { + Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); + sp2C.x += Math_SinS(-0x3A98) * 110.0f; + sp2C.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->unk_2DC, &sp2C); + Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); + sp2C.x += Math_SinS(-0x3A98) * 10.0f; + sp2C.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + } + + Play_CameraSetAtEye(globalCtx, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + if ((this->unk_350 == NULL) || (this->unk_350->update == NULL)) { + this->unk_350 = NULL; + this->unk_2B0++; + if (this->unk_2B0 > 10) { + this->unk_2B4 = 20; + this->actionFunc = func_80B2A23C; + } + } +} + +void func_80B2A23C(EnFish2* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + if (D_80B2B2E4 == 2) { + sp2C.x += (Math_SinS(-0x3A98) * 180.0f); + sp2C.y += 90.0f; + sp2C.z += Math_CosS(-0x3A98) * 180.0f; + Math_Vec3f_Copy(&this->unk_2DC, &sp2C); + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + sp2C.y += 70.0f; + Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + } else if (D_80B2B2F4 != NULL) { + Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); + sp2C.x += Math_SinS(-0x3A98) * 110.0f; + sp2C.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->unk_2DC, &sp2C); + Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); + sp2C.x += Math_SinS(-0x3A98) * 10.0f; + sp2C.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + } + + Play_CameraSetAtEye(globalCtx, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + + if ((this->unk_2B4 == 0) && (D_80B2B2E4 == 3)) { + D_80B2B2E0 = D_80B2B2EC = D_80B2B2E4 = 0; + D_80B2B2F4 = NULL; + ActorCutscene_Stop(this->unk_2BA[0]); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B2A448(EnFish2* this) { + func_80B28370(this, 4); + this->unk_2B4 = 0; + this->unk_2C4 = 0; + this->unk_2B6 = this->unk_2B4; + D_80B2B2E4 = 2; + this->actionFunc = func_80B2A498; +} + +void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { + f32 currentFrame = this->skelAnime.curFrame; + Vec3f sp80; + + if ((this->unk_2AC == 4) && Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor* temp_v0; + + Math_Vec3f_Copy(&sp80, &this->unk_318); + temp_v0 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_COL_MAN, sp80.x, sp80.y, sp80.z, 0, + this->actor.world.rot.y, 0, 0); + if (temp_v0 != NULL) { + temp_v0->speedXZ = 4.0f; + temp_v0->velocity.y = 15.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_SY_PIECE_OF_HEART); + gSaveContext.weekEventReg[81] &= (u8)~0x10; + gSaveContext.weekEventReg[81] &= (u8)~0x20; + gSaveContext.weekEventReg[81] &= (u8)~0x40; + gSaveContext.weekEventReg[81] &= (u8)~0x80; + gSaveContext.weekEventReg[82] &= (u8)~0x1; + gSaveContext.weekEventReg[82] &= (u8)~0x2; + } + } + + if ((this->unk_2AC == 4) && + (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 31.0f))) { + WaterBox* sp78; + + if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp78)) { + Vec3f sp6C; + s32 i; + + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); + sp6C.x += randPlusMinusPoint5Scaled(70.0f); + sp6C.y = this->unk_334 + 10.0f; + sp6C.z += randPlusMinusPoint5Scaled(70.0f); + EffectSsGSplash_Spawn(globalCtx, &sp6C, NULL, NULL, 0, (s32)randPlusMinusPoint5Scaled(50.0f) + 350); + } + } + } + + if ((this->unk_2CC <= currentFrame) && (this->unk_2AC == 4)) { + D_80B2B2E0 = 0; + D_80B2B2E4 = 3; + this->actor.world.pos.x = this->unk_324.x; + this->actor.world.pos.z = this->unk_324.z; + func_80B28370(this, 0); + } +} + +void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { + static f32 D_80B2B3A8[] = { + 0.0f, 40.0f, -40.0f, 0.0f, 0.0f, 0.0f, + }; + EnFish2* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + if ((this->actionFunc != func_80B295A4) && (this->actor.params != 1)) { + SkelAnime_Update(&this->skelAnime); + } + + if (this->unk_2B8 != 0) { + this->unk_2B8--; + } + + if (this->unk_2B6 != 0) { + this->unk_2B6--; + } + + if (this->unk_2B4 == 0) { + } else { + this->unk_2B4--; + } + + this->actionFunc(this, globalCtx); + Actor_SetHeight(&this->actor, 0); + + if (this->actor.params != 1) { + WaterBox* sp6C; + s32 i; + Vec3f sp5C; + + if (this->actor.params == 0) { + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_348, 1, this->unk_34C + 200, 0); + if (this->actionFunc != func_80B297FC) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_34A, 1, 0xBB8, 0); + } + } + + if ((globalCtx->gameplayFrames % 8) == 0) { + Math_Vec3f_Copy(&sp5C, &this->unk_324); + sp5C.x += randPlusMinusPoint5Scaled(100.0f); + sp5C.y = this->actor.floorHeight; + sp5C.z += randPlusMinusPoint5Scaled(100.0f); + + for (i = 0; i < (s32)randPlusMinusPoint5Scaled(5.0f) + 10; i++) { + EffectSsBubble_Spawn(globalCtx, &sp5C, 0, 5.0f, 5.0f, Rand_ZeroFloat(this->unk_330 * 4.0f) + 0.1f); + } + } + + func_80B2AF80(this, globalCtx); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + Math_Vec3f_Copy(&this->unk_2F4, &this->actor.world.pos); + this->unk_2F4.x += (Math_SinS(this->actor.world.rot.y) * 25.0f) - this->unk_330; + this->unk_2F4.z += (Math_CosS(this->actor.world.rot.y) * 25.0f) - this->unk_330; + this->unk_33C = 25.0f - ((this->unk_330 - 0.01f) * 1000.0f); + Actor_SetScale(&this->actor, this->unk_330); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 15.0f, 10.0f, 7); + + if (this->actor.params != 2) { + this->unk_2D4 = this->actor.floorHeight + (this->unk_330 * 1000.0f); + this->unk_2D8 = this->unk_330 * 600.0f; + if (this->actor.world.pos.y < this->unk_2D4) { + this->actor.world.pos.y = this->unk_2D4 + 0.1f; + } + + if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp6C)) { + if ((this->unk_334 != BGCHECK_Y_MIN) && (this->unk_334 - this->unk_2D8 < this->actor.world.pos.y)) { + this->actor.world.pos.y = this->unk_334 - this->unk_2D8; + } + } + + if ((D_80B2B2E8 == 0) && (this->actionFunc == func_80B28C14)) { + s32 temp_s0_2 = this->unk_344 * 2; + f32 phi_f2 = 0.0f; + f32 phi_f20 = 0; + WaterBox* sp4C; + + if (func_800CA1AC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_334, &sp4C)) { + phi_f20 = D_80B2B3A8[temp_s0_2] + (this->unk_334 - this->unk_2D8); + phi_f2 = D_80B2B3A8[temp_s0_2 + 1] + this->unk_2D4; + } + + if ((phi_f20 < this->actor.world.pos.y) && (this->unk_348 < 0)) { + this->unk_348 = 0; + this->actor.velocity.y = 0; + this->actor.gravity = 0; + } + + if ((this->actor.world.pos.y < phi_f2) && (this->unk_348 > 0)) { + this->unk_348 = 0; + this->actor.velocity.y = 0; + this->actor.gravity = 0; + } + } + + if (D_80B2B2E8 == 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + } +} + +s32 EnFish2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFish2* this = THIS; + + if ((limbIndex == 20) || (limbIndex == 21)) { + *dList = NULL; + } + + return false; +} + +void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFish2* this = THIS; + s32 pad; + + if ((limbIndex == 20) || (limbIndex == 21)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == 14) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_318); + } + + if (limbIndex == 17) { + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_300); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnFish2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFish2* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFish2_OverrideLimbDraw, EnFish2_PostLimbDraw, &this->actor); + func_80B2B180(this, globalCtx); +} + +void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { + s16 i; + EnFish2UnkStruct* ptr = &this->unk_3F8[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { + if (!ptr->unk_00) { + u32 phi_v0; + + if (Rand_ZeroOne() < 0.5f) { + phi_v0 = &D_04091CE0; + } else { + phi_v0 = &D_04091BE0; + } + + ptr->unk_20 = gSegments[(phi_v0 * 0x10) >> 0x1C] + (phi_v0 & 0xFFFFFF); + ptr->unk_00 = true; + ptr->unk_04 = *vec; + ptr->unk_04.x += randPlusMinusPoint5Scaled(ptr->unk_00 + (this->unk_330 * 4000.0f)); + ptr->unk_04.y += randPlusMinusPoint5Scaled(20.0f); + ptr->unk_04.z += randPlusMinusPoint5Scaled(ptr->unk_00 + (this->unk_330 * 4000.0f)); + ptr->unk_18 = (this->unk_330 * 20.0f) - (Rand_ZeroFloat(5.0f) * 0.01f); + ptr->unk_1C = 0x42; + ptr->unk_10 = arg2; + break; + } + } +} + +void func_80B2AF80(EnFish2* this, GlobalContext* globalCtx) { + EnFish2UnkStruct* ptr = &this->unk_3F8[0]; + WaterBox* sp90; + f32 sp8C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { + if (ptr->unk_00) { + if ((ptr->unk_10 != 0) && (ptr->unk_1C != 0)) { + Math_ApproachF(&ptr->unk_14, ptr->unk_18, 0.4f, 0.5f); + ptr->unk_10--; + } else { + ptr->unk_00 = 0; + } + + if (ptr->unk_00) { + ptr->unk_04.x += (0.3f + (Rand_ZeroOne() * 0.5f)) - 0.55f; + ptr->unk_04.y += 1.0f + ((Rand_ZeroOne() - 0.3f) * 1.2f); + ptr->unk_04.z += (0.3f + (Rand_ZeroOne() * 0.5f)) - 0.55f; + sp8C = ptr->unk_04.y; + if (!func_800CA1AC(globalCtx, &globalCtx->colCtx, ptr->unk_04.x, ptr->unk_04.z, &sp8C, &sp90)) { + ptr->unk_00 = 0; + } else if (sp8C < ptr->unk_04.y) { + Vec3f sp7C; + + sp7C.x = ptr->unk_04.x; + sp7C.y = sp8C; + sp7C.z = ptr->unk_04.z; + EffectSsGRipple_Spawn(globalCtx, &sp7C, 0, 80, 0); + ptr->unk_00 = 0; + } + } + } + } +} + +void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { + s16 i; + EnFish2UnkStruct* ptr; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + ptr = &this->unk_3F8[0]; + func_8012C28C(gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { + if (ptr->unk_00) { + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_14, ptr->unk_14, ptr->unk_14, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, ptr->unk_20); + gSPDisplayList(POLY_OPA_DISP++, D_040301B0); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h index f2714191f..ba6e2f4f0 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h @@ -7,11 +7,58 @@ struct EnFish2; typedef void (*EnFish2ActionFunc)(struct EnFish2*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ s16 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 unk_1C; + /* 0x20 */ s32 unk_20; +} EnFish2UnkStruct; // size = 0x24 + typedef struct EnFish2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[24]; + /* 0x0218 */ Vec3s morphTable[24]; /* 0x02A8 */ EnFish2ActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x1D6C]; + /* 0x02AC */ s32 unk_2AC; + /* 0x02B0 */ s32 unk_2B0; + /* 0x02B4 */ s16 unk_2B4; + /* 0x02B6 */ s16 unk_2B6; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA[3]; + /* 0x02C0 */ s32 unk_2C0; + /* 0x02C4 */ s32 unk_2C4; + /* 0x02C8 */ u8 unk_2C8; + /* 0x02CA */ s16 unk_2CA; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ char unk_2D0[0x4]; + /* 0x02D4 */ f32 unk_2D4; + /* 0x02D8 */ f32 unk_2D8; + /* 0x02DC */ Vec3f unk_2DC; + /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02F4 */ Vec3f unk_2F4; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ Vec3f unk_30C; + /* 0x0318 */ Vec3f unk_318; + /* 0x0324 */ Vec3f unk_324; + /* 0x0330 */ f32 unk_330; + /* 0x0334 */ f32 unk_334; + /* 0x0338 */ f32 unk_338; + /* 0x033C */ f32 unk_33C; + /* 0x0340 */ s32 unk_340; + /* 0x0344 */ s32 unk_344; + /* 0x0348 */ s16 unk_348; + /* 0x034A */ s16 unk_34A; + /* 0x034C */ s16 unk_34C; + /* 0x034E */ char unk_34E[0x02]; + /* 0x0350 */ Actor* unk_350; + /* 0x0354 */ struct EnFish2* unk_354; + /* 0x0358 */ ColliderJntSph collider; + /* 0x0378 */ ColliderJntSphElement colliderElements[2]; + /* 0x03F8 */ EnFish2UnkStruct unk_3F8[200]; } EnFish2; // size = 0x2018 extern const ActorInit En_Fish2_InitVars; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h index eb22a4973..7804db715 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -9,9 +9,12 @@ typedef void (*EnMushi2ActionFunc)(struct EnMushi2*, GlobalContext*); typedef struct EnMushi2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; + /* 0x0144 */ char unk_144[0x133]; + /* 0x0277 */ s8 unk_277; + /* 0x0278 */ char unk_278[0x90]; /* 0x0308 */ EnMushi2ActionFunc actionFunc; - /* 0x030C */ char unk_30C[0x68]; + /* 0x030C */ s32 unk_30C; + /* 0x0310 */ char unk_310[0x64]; } EnMushi2; // size = 0x374 extern const ActorInit En_Mushi2_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e77e59ad0..ec3e89a90 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13370,8 +13370,8 @@ 0x80B2A448:("func_80B2A448",), 0x80B2A498:("func_80B2A498",), 0x80B2A738:("EnFish2_Update",), - 0x80B2ABF4:("func_80B2ABF4",), - 0x80B2AC20:("func_80B2AC20",), + 0x80B2ABF4:("EnFish2_OverrideLimbDraw",), + 0x80B2AC20:("EnFish2_PostLimbDraw",), 0x80B2AD34:("EnFish2_Draw",), 0x80B2ADB0:("func_80B2ADB0",), 0x80B2AF80:("func_80B2AF80",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 2b5e23257..d83bf24ed 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2165,6 +2165,10 @@ D_060018B8 = 0x060018B8; // ovl_En_Fish2 +D_060006D8 = 0x060006D8; +D_060007D4 = 0x060007D4; +D_06000ACC = 0x06000ACC; +D_06001174 = 0x06001174; D_060013AC = 0x060013AC; D_06006190 = 0x06006190; From c97a8e5225c926ca8babcb11f5cb4fbc1ac961a1 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Wed, 27 Oct 2021 15:02:26 +0100 Subject: [PATCH 49/86] En_Tite (#318) * En_Tite * Fix --- include/functions.h | 4 +- spec | 3 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 1144 +++++++++++++++++-- src/overlays/actors/ovl_En_Tite/z_en_tite.h | 27 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 6 + 6 files changed, 1107 insertions(+), 81 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0ccda1bc5..eac92c320 100644 --- a/include/functions.h +++ b/include/functions.h @@ -912,9 +912,9 @@ u8 Actor_ApplyDamage(Actor* actor); // returns current health void func_800BE258(Actor* actor, UNK_PTR arg1); void func_800BE2B8(Actor* actor, ColliderJntSph* jntSphere); void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); -// void func_800BE3D0(void); +void func_800BE3D0(Actor* actor, s16 arg1, s16* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); -// void func_800BE568(void); +void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 arg2); // void func_800BE63C(void); void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 arg4, f32 arg5, f32 arg6, u8 mode); diff --git a/spec b/spec index c282c24e0..c92c79741 100644 --- a/spec +++ b/spec @@ -880,8 +880,7 @@ beginseg name "ovl_En_Tite" compress include "build/src/overlays/actors/ovl_En_Tite/z_en_tite.o" - include "build/data/ovl_En_Tite/ovl_En_Tite.data.o" - include "build/data/ovl_En_Tite/ovl_En_Tite.reloc.o" + include "build/src/overlays/actors/ovl_En_Tite/ovl_En_Tite_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 2108a5a8f..ee88a7a31 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tite.c + * Overlay: ovl_En_Tite + * Description: Tektites + */ + #include "z_en_tite.h" #define FLAGS 0x00000205 @@ -9,7 +15,50 @@ void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTite_Update(Actor* thisx, GlobalContext* globalCtx); void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80893ED4(EnTite* this); +void func_80893F30(EnTite* this, GlobalContext* globalCtx); +void func_80893FD0(EnTite* this); +void func_80894024(EnTite* this, GlobalContext* globalCtx); +void func_8089408C(EnTite* this, GlobalContext* globalCtx); +void func_808942B4(EnTite* this, GlobalContext* globalCtx); +void func_80894414(EnTite* this); +void func_80894454(EnTite* this, GlobalContext* globalCtx); +void func_8089452C(EnTite* this, GlobalContext* globalCtx); +void func_808945B4(EnTite* this, GlobalContext* globalCtx); +void func_808945EC(EnTite* this); +void func_80894638(EnTite* this, GlobalContext* globalCtx); +void func_8089484C(EnTite* this); +void func_80894910(EnTite* this, GlobalContext* globalCtx); +void func_80894B2C(EnTite* this); +void func_80894BC8(EnTite* this, GlobalContext* globalCtx); +void func_80894E0C(EnTite* this, GlobalContext* globalCtx); +void func_80895020(EnTite* this, GlobalContext* globalCtx); +void func_808951B8(EnTite* this, GlobalContext* globalCtx); +void func_80895424(EnTite* this, GlobalContext* globalCtx); +void func_808955E4(EnTite* this); +void func_80895640(EnTite* this, GlobalContext* globalCtx); +void func_808956B8(EnTite* this); +void func_80895738(EnTite* this, GlobalContext* globalCtx); +void func_80895A10(EnTite* this); +void func_80895AC0(EnTite* this, GlobalContext* globalCtx); +void func_80895CB0(EnTite* this); +void func_80895D08(EnTite* this, GlobalContext* globalCtx); +void func_80895E28(EnTite* this, GlobalContext* globalCtx); + +extern AnimationHeader D_060004F8; +extern AnimationHeader D_0600069C; +extern AnimationHeader D_0600083C; +extern AnimationHeader D_06000A14; +extern AnimationHeader D_06000C70; +extern AnimationHeader D_060012E4; +extern SkeletonHeader D_06003A20; +extern UNK_PTR D_06001300; +extern UNK_PTR D_06001700; +extern UNK_PTR D_06001900; +extern UNK_PTR D_06001B00; +extern UNK_PTR D_06001F00; +extern UNK_PTR D_06002100; + const ActorInit En_Tite_InitVars = { ACTOR_EN_TITE, ACTORCAT_ENEMY, @@ -22,15 +71,27 @@ const ActorInit En_Tite_InitVars = { (ActorFunc)EnTite_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80896AD0 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 1500, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80896AFC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -65,129 +126,1066 @@ static DamageTable D_80896AFC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80896B1C = { 2, 40, 40, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 40, 40, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80896B50[] = { +static UNK_PTR D_80896B24[2][3] = { + { &D_06001300, &D_06001700, &D_06001900 }, + { &D_06001B00, &D_06001F00, &D_06002100 }, +}; + +static Color_RGBA8 D_80896B3C = { 250, 250, 250, 255 }; +static Color_RGBA8 D_80896B40 = { 180, 180, 180, 255 }; +static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +static s32 D_80896B60 = 0; +static Vec3f D_80896B64 = { 0.0f, 0.3f, 0.0f }; -extern ColliderSphereInit D_80896AD0; -extern DamageTable D_80896AFC; -extern CollisionCheckInfoInit D_80896B1C; -extern InitChainEntry D_80896B50[]; +void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + s32 i; + s32 j; -extern UNK_TYPE D_060004F8; -extern UNK_TYPE D_0600069C; -extern UNK_TYPE D_0600083C; -extern UNK_TYPE D_06000A14; -extern UNK_TYPE D_06000C70; -extern UNK_TYPE D_060012E4; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06003A20, &D_060012E4, this->jointTable, this->morphTable, 25); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); + Actor_SetHeight(&this->actor, 20.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; + this->unk_2C0 = 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Init.s") + if (!D_80896B60) { + for (i = 0; i < ARRAY_COUNT(D_80896B24); i++) { + for (j = 0; j < ARRAY_COUNT(D_80896B24[0]); j++) { + D_80896B24[i][j] = Lib_SegmentedToVirtual(D_80896B24[i][j]); + } + } + D_80896B60 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Destroy.s") + if (this->actor.params == ENTITE_MINUS_3) { + this->actor.params = ENTITE_MINUS_2; + this->unk_2BE = 240; + this->actor.flags &= ~1; + this->actor.shape.yOffset = -3000.0f; + this->actor.shape.shadowDraw = NULL; + func_80895A10(this); + } else { + if (this->actor.params == ENTITE_MINUS_4) { + this->actor.params = ENTITE_MINUS_2; + this->unk_2BE = 240; + } else if (this->actor.params == ENTITE_MINUS_2) { + this->unk_2BE = 128; + } else { + this->unk_2BE = 64; + } + func_80893ED4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A18.s") + if (this->actor.params == ENTITE_MINUS_2) { + this->unk_2C0 |= 0x40; + this->actor.colChkInfo.health = 3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A34.s") +void EnTite_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893A9C.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893ADC.s") +void func_80893A18(EnTite* this) { + this->collider.base.colType = COLTYPE_HIT6; + this->collider.base.acFlags &= ~AC_HARD; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893B10.s") +s32 func_80893A34(EnTite* this, GlobalContext* globalCtx) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 1) && + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 5)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893B70.s") +void func_80893A9C(EnTite* this, GlobalContext* globalCtx) { + if (func_80893A34(this, globalCtx)) { + func_808956B8(this); + } else { + func_80893FD0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893BCC.s") +s32 func_80893ADC(EnTite* this) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 0x20)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893DD4.s") +s32 func_80893B10(EnTite* this) { + Math_StepToF(&this->actor.velocity.y, 0.0f, 2.0f); + return Math_StepToF(&this->actor.world.pos.y, (this->actor.world.pos.y + this->actor.yDistToWater) - 1.0f, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893E54.s") +void func_80893B70(EnTite* this) { + if (this->actor.params == ENTITE_MINUS_2) { + if (this->actor.bgCheckFlags & 0x20) { + this->actor.gravity = 0.0f; + func_80893B10(this); + } else { + this->actor.gravity = -1.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893ED4.s") +void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp7C; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893F30.s") + if (this->actor.bgCheckFlags & 2) { + u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80893FD0.s") + if ((temp_v0 == 0) || (temp_v0 == 1)) { + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + } + } else if (temp_v0 == 14) { + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894024.s") + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (j = 0; j < 2; j++) { + ptr = &this->unk_2D0[i]; + sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); + sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); + sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); + func_800B0DE0(globalCtx, &sp7C, &D_801D15B0, &D_80896B64, &D_80896B3C, &D_80896B40, + (s32)Rand_ZeroFloat(16.0f) + 80, 15); + } + } + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089408C.s") +void func_80893DD4(EnTite* this) { + this->unk_2BB = 10; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_2BC = 80; + this->unk_2C8 = 0.5f; + this->unk_2CC = 0.75f; + this->unk_2C4 = 1.0f; + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + this->actor.flags &= ~0x200; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808942B4.s") +void func_80893E54(EnTite* this, GlobalContext* globalCtx) { + if (this->unk_2BB == 10) { + this->unk_2BB = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_2C4 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + this->actor.flags |= 0x200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894414.s") +void func_80893ED4(EnTite* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060012E4, 4.0f); + this->unk_2BC = Rand_S16Offset(15, 30); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80893F30; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894454.s") +void func_80893F30(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + func_80893B70(this); + if (this->unk_2BC > 0) { + this->unk_2BC--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.xzDistToPlayer < 300.0f) && + (this->actor.yDistToPlayer < 80.0f)) { + func_808945EC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089452C.s") +void func_80893FD0(EnTite* this) { + Animation_PlayOnce(&this->skelAnime, &D_0600083C); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80894024; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808945B4.s") +void func_80894024(EnTite* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + func_8089408C(this, globalCtx); + } else { + func_80893B70(this); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808945EC.s") +void func_8089408C(EnTite* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &D_060004F8); + if (!func_80893ADC(this)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + } else { + this->actor.world.pos.y += this->actor.yDistToWater; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894638.s") + if (this->actor.shape.yOffset < 0.0f) { + s32 i; + Vec3f sp70; + Vec3f sp64; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089484C.s") + sp64.y = 3.0f; + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894910.s") + for (i = 0; i < 4; i++) { + sp64.x = 2.0f * Math_SinS(this->actor.shape.rot.y); + sp64.z = 2.0f * Math_CosS(this->actor.shape.rot.y); + sp70.x = this->actor.world.pos.x + (12.5f * sp64.x); + sp70.y = this->actor.world.pos.y + 15.0f; + sp70.z = this->actor.world.pos.z + (12.5f * sp64.z); + func_800B0DE0(globalCtx, &sp70, &sp64, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + this->actor.shape.rot.y += 0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894B2C.s") + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.flags |= 1; + this->actor.velocity.y = 10.0f; + } else { + this->actor.velocity.y = 8.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894BC8.s") + this->actor.bgCheckFlags &= ~(0x40 | 0x20 | 0x2 | 0x1); + this->actor.gravity = -1.0f; + this->actor.speedXZ = 4.0f; + this->actionFunc = func_808942B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894DD0.s") +void func_808942B4(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + (this->actor.velocity.y <= 0.0f)) { + this->actor.speedXZ = 0.0f; + this->collider.base.atFlags &= ~AT_HIT; + if (!func_80893ADC(this)) { + func_80893BCC(this, globalCtx); + func_80894414(this); + } else { + this->actor.gravity = 0.0f; + if (this->actor.velocity.y < -8.0f) { + func_8089452C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + func_80894414(this); + } + } + } else if (!(this->collider.base.atFlags & AT_HIT)) { + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.atFlags &= ~AT_HIT; + func_80894B2C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80894E0C.s") +void func_80894414(EnTite* this) { + Animation_PlayOnce(&this->skelAnime, &D_0600069C); + this->actionFunc = func_80894454; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895020.s") +void func_80894454(EnTite* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + func_808945EC(this); + } else { + func_80893A9C(this, globalCtx); + } + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1500); + func_80893B70(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808951B8.s") +void func_8089452C(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808952EC.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + sp2C.y += this->actor.yDistToWater; + this->actor.velocity.y *= 0.75f; + EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + this->actionFunc = func_808945B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895424.s") +void func_808945B4(EnTite* this, GlobalContext* globalCtx) { + if (func_80893B10(this)) { + func_80894414(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808955E4.s") +void func_808945EC(EnTite* this) { + Animation_PlayLoop(&this->skelAnime, &D_06000A14); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80894638; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895640.s") +void func_80894638(EnTite* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808956B8.s") + func_80893B70(this); + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (temp_v0 > 0) { + temp_v1 = (s32)(temp_v0 * (1.0f / 42.0f)) + 10; + } else { + temp_v1 = (s32)(temp_v0 * (1.0f / 42.0f)) - 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808956FC.s") + this->actor.shape.rot.y = this->actor.shape.rot.y + (temp_v1 * 2); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->skelAnime.playSpeed = temp_v1 * 0.01f; + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895738.s") + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (func_80893ADC(this)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK_WATER); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_8089595C.s") + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater < 10.0f))) && + Actor_IsActorFacingLink(&this->actor, 0xE38)) { + if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895A10.s") +void func_8089484C(EnTite* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000C70, -3.0f); + if (this->actionFunc != func_80894910) { + this->unk_2B8 = Rand_S16Offset(1, 3); + } + this->actor.velocity.y = 9.5f; + this->actor.gravity = -1.0f; + this->actor.speedXZ = 4.0f; + if (func_80893ADC(this)) { + this->actor.world.pos.y += this->actor.yDistToWater; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + } + this->actionFunc = func_80894910; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895AC0.s") +void func_80894910(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895CB0.s") + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + SkelAnime_Update(&this->skelAnime); + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895D08.s") + if (func_80893ADC(this)) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y += this->actor.yDistToWater; + this->actor.velocity.y *= 0.75f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 0, 500, 0); + } + } else { + func_80893BCC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895DE8.s") + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + (this->actor.velocity.y <= 0.0f)) { + this->actor.speedXZ = 0.0f; + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4000); + this->actor.world.rot.y = this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895E28.s") + if (func_80893ADC(this)) { + this->actor.gravity = 0.0f; + if (!func_80893B10(this)) { + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80895FF8.s") + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + func_808945EC(this); + } else { + func_8089484C(this); + } + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1000); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_808963B4.s") +void func_80894B2C(EnTite* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060012E4, 4.0f); + this->actor.speedXZ = -6.0f; + this->actor.gravity = -1.0f; + if (this->collider.base.ac != NULL) { + func_800BE568(&this->actor, &this->collider); + } else { + this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + } + this->actor.world.rot.y += 0x8000; + this->actionFunc = func_80894BC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Update.s") +void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + SkelAnime_Update(&this->skelAnime); + if (func_80893ADC(this) && (this->actor.velocity.y <= 0.0f)) { + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.yDistToWater - 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80896750.s") + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + } else { + func_80893BCC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/func_80896788.s") + if ((this->actor.speedXZ == 0.0f) && ((this->actor.bgCheckFlags & 1) || func_80893ADC(this))) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->collider.base.acFlags |= AC_ON; + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + Actor_IsActorFacingLink(&this->actor, 0x1770)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tite/EnTite_Draw.s") +void func_80894DD0(EnTite* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80894E0C; +} + +void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { + if (this->unk_2BC != 0) { + this->unk_2BC--; + } + + if ((func_80893ADC(this) != 0) && (this->actor.velocity.y <= 0.0f)) { + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.yDistToWater; + } + + if (this->actor.bgCheckFlags & 0x40) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + } else { + func_80893BCC(this, globalCtx); + } + + if (this->unk_2BC == 0) { + func_80893E54(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80895020(this, globalCtx); + } else if (this->unk_2B9 != 0) { + func_808955E4(this); + } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { + func_80893ED4(this); + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + Actor_IsActorFacingLink(&this->actor, 0x1770)) { + func_80893A9C(this, globalCtx); + } else { + func_8089484C(this); + } + } +} + +void func_80895020(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp74; + s32 i; + f32 temp_f0; + Vec3f* ptr; + + this->actor.speedXZ = 0.0f; + this->collider.base.acFlags &= ~AC_ON; + this->actor.colorFilterTimer = 0; + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); + this->actor.flags &= ~1; + this->actor.flags |= 0x10; + this->unk_2BA = 1; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, this->unk_2BE); + this->unk_2BC = 25; + this->actor.gravity = -0.58f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + + ptr = &this->unk_33C[0]; + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + temp_f0 = Math3D_Vec3fMagnitude(&sp74); + if (temp_f0 > 1.0f) { + temp_f0 = 1.2f / temp_f0; + } + + ptr->x = sp74.x * temp_f0; + ptr->z = sp74.z * temp_f0; + ptr->y = Rand_ZeroFloat(3.5f) + 5.5f; + } + this->actionFunc = func_808951B8; +} + +void func_808951B8(EnTite* this, GlobalContext* globalCtx) { + s32 i; + + this->unk_2BC--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->unk_2BC == 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + func_800B3030(globalCtx, &this->unk_2D0[i], &D_801D15B0, &D_801D15B0, 40, 7, 1); + Audio_PlaySoundAtPosition(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + } + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { + Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + this->unk_33C[i].y += this->actor.gravity; + } + } +} + +void func_808952EC(EnTite* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &D_06000A14, 1.5f); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + this->collider.base.acFlags &= ~AC_ON; + func_80893A18(this); + this->unk_2B9 = 1; + this->unk_2BC = 400; + this->actor.speedXZ = 0.0f; + this->actor.gravity = -1.0f; + this->unk_2B8 = Rand_ZeroOne() * 50.0f; + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 11.0f; + this->actionFunc = func_80895424; +} + +void func_80895424(EnTite* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 4000); + if (this->unk_2B8 != 0) { + this->unk_2B8--; + } else { + this->unk_2B8 = Rand_ZeroOne() * 30.0f; + this->skelAnime.curFrame = Rand_ZeroOne() * 5.0f; + } + + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 1) { + this->collider.base.acFlags |= AC_ON; + if (this->actor.bgCheckFlags & 2) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + if (this->unk_2BC == 0) { + func_808955E4(this); + } else { + this->unk_2BC--; + } + } else if (this->actor.shape.yOffset < 2800.0f) { + this->actor.shape.yOffset += 400.0f; + } +} + +void func_808955E4(EnTite* this) { + this->unk_2B9 = 0; + this->actor.velocity.y = 13.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + this->actor.bgCheckFlags &= ~1; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80895640; +} + +void func_80895640(EnTite* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 4000); + SkelAnime_Update(&this->skelAnime); + if (this->actor.bgCheckFlags & 1) { + this->collider.base.acFlags |= AC_ON; + this->actor.shape.yOffset = 0.0f; + func_80893BCC(this, globalCtx); + func_80893ED4(this); + } +} + +void func_808956B8(EnTite* this) { + this->unk_2BC = 400; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.colType = COLTYPE_HARD; + this->collider.base.acFlags |= AC_HARD; + this->actor.gravity = -1.0f; + this->actionFunc = func_80895738; +} + +void func_808956FC(EnTite* this) { + this->unk_2BC = -1; + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 7.5f; + func_80893A18(this); +} + +void func_80895738(EnTite* this, GlobalContext* globalCtx) { + func_80893BCC(this, globalCtx); + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + if (this->collider.base.atFlags & AT_BOUNCED) { + func_808956FC(this); + } + } else if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = BINANG_SUB((this->actor.wallYaw * 2) - this->actor.world.rot.y, 0x8000); + } + + if (this->unk_2BC == -1) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f); + if (this->actor.bgCheckFlags & 1) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80893ED4(this); + this->unk_2BC = 100; + } + } else if (this->unk_2BC > 0) { + this->unk_2BC--; + Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (!func_80893A34(this, globalCtx)) { + this->unk_2BC = 0; + } + } else if ((this->unk_2BC == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80893A18(this); + if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || + (this->actor.yDistToPlayer > 80.0f)) { + func_80893ED4(this); + } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + func_808945EC(this); + } else { + func_80893A9C(this, globalCtx); + } + } + this->actor.shape.rot.y += (s16)(this->actor.speedXZ * 768.0f); +} + +void func_8089595C(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + sp2C.x = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.x; + sp2C.y = this->actor.world.pos.y + 15.0f; + sp2C.z = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &sp2C, &D_801D15B0, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); +} + +void func_80895A10(EnTite* this) { + s32 pad; + s16 rand; + + Animation_Change(&this->skelAnime, &D_06000A14, 2.0f, 0.0f, 0.0f, 0, 4.0f); + this->actor.speedXZ = 0.0f; + rand = Rand_S16Offset(20, 20); + this->unk_2BC = ((Rand_ZeroOne() < 0.5f) ? -1 : 1) * rand; + this->actionFunc = func_80895AC0; +} + +void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { + s16 temp_v1; + s32 temp_v0; + + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (Rand_ZeroOne() < 0.25f) { + func_8089595C(this, globalCtx); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + + if ((this->unk_2BC == 1) || (this->unk_2BC == -1)) { + if (this->actor.bgCheckFlags & 8) { + temp_v1 = this->actor.shape.rot.y - this->actor.wallYaw; + temp_v0 = ABS_ALT(temp_v1); + if (temp_v0 > 0x3000) { + this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; + } + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { + temp_v1 = this->actor.shape.rot.y - Actor_YawToPoint(&this->actor, &this->actor.home.pos); + temp_v0 = ABS_ALT(temp_v1); + if (temp_v0 > 0x2000) { + this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; + } + } + } + + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_8089408C(this, globalCtx); + } else if (this->unk_2BC > 0) { + this->unk_2BC--; + this->actor.shape.rot.y += 0x100; + } else if (this->unk_2BC < 0) { + this->unk_2BC++; + this->actor.shape.rot.y -= 0x100; + } else { + func_80895CB0(this); + } +} + +void func_80895CB0(EnTite* this) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_2BC = Rand_S16Offset(20, 20); + this->actionFunc = func_80895D08; +} + +void func_80895D08(EnTite* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + if (Rand_ZeroOne() < 0.5f) { + func_8089595C(this, globalCtx); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + } + if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_8089408C(this, globalCtx); + } else { + this->unk_2BC--; + if (this->unk_2BC == 0) { + func_80895A10(this); + } + } +} + +void func_80895DE8(EnTite* this) { + this->collider.base.acFlags &= ~AC_ON; + this->actor.shape.shadowDraw = func_800B3FC0; + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80895E28; +} + +void func_80895E28(EnTite* this, GlobalContext* globalCtx) { + Vec3f sp44; + Vec3f sp38; + s16 sp36; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1E00; + + sp44.x = (Math_SinS(this->actor.shape.rot.y) * 25.0f) + this->actor.world.pos.x; + sp44.y = this->actor.world.pos.y + 15.0f; + sp44.z = (Math_CosS(this->actor.shape.rot.y) * 25.0f) + this->actor.world.pos.z; + + sp36 = BINANG_SUB(this->actor.shape.rot.y, 0x4000); + + sp38.x = 2.0f * Math_SinS(sp36); + sp38.y = 3.0f; + sp38.z = 2.0f * Math_CosS(sp36); + + func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + + sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; + sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; + sp38.x *= -1.0f; + sp38.z *= -1.0f; + + func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + + if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { + this->actor.flags |= 1; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->collider.base.acFlags |= AC_ON; + func_808945EC(this); + } +} + +void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~AT_HIT; + if (this->collider.base.colType == COLTYPE_HARD) { + func_808956FC(this); + func_800BE568(&this->actor, &this->collider); + return; + } + + func_800BE258(&this->actor, &this->collider.info); + + if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + func_80893E54(this, globalCtx); + if (this->actor.shape.yOffset < 0.0f) { + func_80895DE8(this); + return; + } + + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect != 0xF) { + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2BC = 40; + func_800BCB70(&this->actor, 0, 200, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2BB = 32; + this->unk_2C8 = 0.5f; + this->unk_2C4 = 2.0f; + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2BC = 40; + func_800BCB70(&this->actor, 0, 200, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 3) { + func_80893DD4(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_2BC = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_80894DD0(this); + return; + } + + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2BB = 0; + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2BB = 0x14; + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + + if (this->actor.colChkInfo.health == 0) { + func_80895020(this, globalCtx); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_DAMAGE); + + if (this->unk_2B9 == 0) { + func_80894B2C(this); + this->collider.base.acFlags &= ~AC_ON; + } else { + func_808955E4(this); + } + } + } + } + } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && + (this->actor.colChkInfo.health != 0) && (globalCtx->actorCtx.unk2 != 0) && + (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + this->actor.flags |= 1; + if (this->actor.shape.yOffset < 0.0f) { + this->actor.shape.yOffset = 0.0f; + this->actor.shape.shadowDraw = func_800B3FC0; + } + if (this->unk_2B9 != 0) { + func_808955E4(this); + } else { + func_808952EC(this); + } + } +} + +void func_808963B4(EnTite* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp48; + + if (this->actor.bgCheckFlags & 0x40) { + for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); + } + } else if (this->actor.bgCheckFlags & 0x20) { + s32 temp = globalCtx->gameplayFrames & 7; + + if (!(temp & 1) && (this->actor.yDistToWater < 10.0f)) { + Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); + } + } +} + +void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + + func_80895FF8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_808951B8) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); + func_808963B4(this, globalCtx); + if (this->actor.bgCheckFlags & 1) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot.x); + if (this->unk_2B9 != 0) { + this->actor.shape.rot.z = BINANG_ROT180(this->actor.shape.rot.z); + } + } else { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 1000); + if (this->unk_2B9 == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 1000); + if (this->actor.shape.yOffset > 0.0f) { + this->actor.shape.yOffset -= 400.0f; + } + } + } + + Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 15; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_2C4 > 0.0f) { + if (this->unk_2BB != 10) { + Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); + this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; + this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); + } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnTite_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTite* this = THIS; + + if (this->unk_2BA == -1) { + this->unk_3A8 = *dList; + *dList = NULL; + } + return false; +} + +void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static s8 D_80896B70[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, -1, -1, -1, 3, -1, -1, -1, -1, 4, -1, + }; + static s8 D_80896B8C[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, -1, -1, -1, 2, 6, -1, -1, -1, 3, 7, -1, -1, -1, 4, 8, + }; + EnTite* this = THIS; + MtxF* matrix; + s8 idx; + + if (this->unk_2BA == 0) { + idx = D_80896B70[limbIndex]; + if (idx != -1) { + Matrix_GetStateTranslation(&this->unk_2D0[idx]); + if (idx >= 1) { + Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + } + } + } else if (this->unk_2BA > 0) { + if (D_80896B8C[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + } + + if (limbIndex == 24) { + this->unk_2BA = -1; + } + } else if (D_80896B8C[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + matrix = Matrix_GetCurrentState(); + matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; + matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; + matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; + Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTite* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + if (this->actor.params == ENTITE_MINUS_2) { + gSPSegment(&gfx[1], 0x08, D_80896B24[0][0]); + gSPSegment(&gfx[2], 0x09, D_80896B24[0][1]); + gSPSegment(&gfx[3], 0x0A, D_80896B24[0][2]); + } else { + gSPSegment(&gfx[1], 0x08, D_80896B24[1][0]); + gSPSegment(&gfx[2], 0x09, D_80896B24[1][1]); + gSPSegment(&gfx[3], 0x0A, D_80896B24[1][2]); + } + + POLY_OPA_DISP = &gfx[4]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, + EnTite_PostLimbDraw, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, + this->unk_2C4, this->unk_2BB); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index cf6939425..91bbfc7c2 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -7,11 +7,34 @@ struct EnTite; typedef void (*EnTiteActionFunc)(struct EnTite*, GlobalContext*); +enum { + /* -4 */ ENTITE_MINUS_4 = -4, + /* -3 */ ENTITE_MINUS_3, + /* -2 */ ENTITE_MINUS_2, + /* -1 */ ENTITE_MINUS_1, + /* 0 */ ENTITE_MINUS_0, +}; + typedef struct EnTite { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x170]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[25]; + /* 0x021E */ Vec3s morphTable[25]; /* 0x02B4 */ EnTiteActionFunc actionFunc; - /* 0x02B8 */ char unk_2B8[0x14C]; + /* 0x02B8 */ u8 unk_2B8; + /* 0x02B9 */ u8 unk_2B9; + /* 0x02BA */ s8 unk_2BA; + /* 0x02BB */ u8 unk_2BB; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s32 unk_2C0; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x033C */ Vec3f unk_33C[9]; + /* 0x03A8 */ Gfx* unk_3A8; + /* 0x03AC */ ColliderSphere collider; } EnTite; // size = 0x404 extern const ActorInit En_Tite_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ec3e89a90..b1fb037ee 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5498,8 +5498,8 @@ 0x80895FF8:("func_80895FF8",), 0x808963B4:("func_808963B4",), 0x808964E8:("EnTite_Update",), - 0x80896750:("func_80896750",), - 0x80896788:("func_80896788",), + 0x80896750:("EnTite_OverrideLimbDraw",), + 0x80896788:("EnTite_PostLimbDraw",), 0x8089695C:("EnTite_Draw",), 0x80896F30:("EnPeehat_Init",), 0x808970F4:("EnPeehat_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d83bf24ed..6f792044a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3618,6 +3618,12 @@ D_06000A14 = 0x06000A14; D_06000C70 = 0x06000C70; D_060012E4 = 0x060012E4; D_06003A20 = 0x06003A20; +D_06001300 = 0x06001300; +D_06001700 = 0x06001700; +D_06001900 = 0x06001900; +D_06001B00 = 0x06001B00; +D_06001F00 = 0x06001F00; +D_06002100 = 0x06002100; // ovl_En_Tk From de3fc29d517a9e807d39d6020b82ca57ca9b6e80 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Wed, 27 Oct 2021 15:59:21 +0100 Subject: [PATCH 50/86] En_Ot ~~(1 non-matching)~~ (#302) * En_Ot * Fix --- include/functions.h | 6 +- include/z64actor.h | 3 +- spec | 4 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 1133 +++++++++++++++++++++-- src/overlays/actors/ovl_En_Ot/z_en_ot.h | 53 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 2 + 7 files changed, 1129 insertions(+), 74 deletions(-) diff --git a/include/functions.h b/include/functions.h index eac92c320..d43098265 100644 --- a/include/functions.h +++ b/include/functions.h @@ -981,7 +981,7 @@ f32 func_800C3D50(s32 arg0, CollisionContext* colCtx, s32 arg2, CollisionPoly** // void func_800C3FA0(void); f32 func_800C4000(GlobalContext* globalCtx, CollisionContext* colCtx, s32* arg2, Vec3f* arg3); // void func_800C4058(void); -// void func_800C40B4(void); +f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Vec3f* pos); f32 func_800C411C(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Actor* actor, Vec3f* pos); // void func_800C4188(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800C41E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -2255,7 +2255,7 @@ s32 func_801240C8(Player* player); // void func_8012422C(void); // void func_80124258(void); // void func_80124278(void); -// void func_801242B4(void); +s32 func_801242B4(Player* player); // void func_801242DC(void); // void func_80124420(void); // void func_80124618(void); @@ -3304,7 +3304,7 @@ void func_80179B34(float fParm1, f32 fParm2, f32 fParm5, f32 fParm6, f32 param_5 // void func_80179D74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); void Math3D_ScaleAndAdd(Vec3f* a, Vec3f* b, f32 scale, Vec3f* dst); void Math3D_Lerp(Vec3f* a, Vec3f* b, f32 t, Vec3f* dst); -s32 Math3D_Parallel(Vec3f* a, Vec3f* b); +f32 Math3D_Parallel(Vec3f* a, Vec3f* b); s32 Math3D_AngleBetweenVectors(Vec3f* a, Vec3f* b, f32* angle); void func_80179F64(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); s32 Math3D_XZBoundCheck(f32 xMin, f32 xMax, f32 zMin, f32 zMax, f32 x, f32 z); diff --git a/include/z64actor.h b/include/z64actor.h index 5876251fb..ec6de9d72 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -88,7 +88,8 @@ typedef struct EnDno_ActorUnkStruct { /* 0x1D */ u8 unk_1D; /* 0x20 */ Vec3f unk_20; /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ UNK_TYPE1 unk_38[0x10]; + /* 0x38 */ Vec3f unk_38; + /* 0x44 */ UNK_TYPE1 unk_44[0x4]; /* 0x48 */ struct Actor* unk_48; /* 0x4C */ f32 unk_4C; /* 0x50 */ f32 unk_50; diff --git a/spec b/spec index c92c79741..1f77335c3 100644 --- a/spec +++ b/spec @@ -4198,9 +4198,7 @@ beginseg name "ovl_En_Ot" compress include "build/src/overlays/actors/ovl_En_Ot/z_en_ot.o" - include "build/data/ovl_En_Ot/ovl_En_Ot.data.o" - include "build/data/ovl_En_Ot/ovl_En_Ot.bss.o" - include "build/data/ovl_En_Ot/ovl_En_Ot.reloc.o" + include "build/src/overlays/actors/ovl_En_Ot/ovl_En_Ot_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 1744e5ddf..0f987a390 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -1,4 +1,11 @@ +/* + * File: z_en_ot.c + * Overlay: ovl_En_Ot + * Description: Seahorse + */ + #include "z_en_ot.h" +#include "prevent_bss_reordering.h" #define FLAGS 0x00000019 @@ -9,26 +16,60 @@ void EnOt_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOt_Update(Actor* thisx, GlobalContext* globalCtx); void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx); void func_80B5BE04(EnOt* this, GlobalContext* globalCtx); +void func_80B5BE88(EnOt* this, GlobalContext* globalCtx); void func_80B5BED4(EnOt* this, GlobalContext* globalCtx); +void func_80B5BF60(EnOt* this, GlobalContext* globalCtx); void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx); void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx); +void func_80B5C244(EnOt* this, GlobalContext* globalCtx); void func_80B5C25C(EnOt* this, GlobalContext* globalCtx); +void func_80B5C3B8(EnOt* this, GlobalContext* globalCtx); void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx); +void func_80B5C634(EnOt* this, GlobalContext* globalCtx); void func_80B5C64C(EnOt* this, GlobalContext* globalCtx); +void func_80B5C684(EnOt* this, GlobalContext* globalCtx); void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx); +void func_80B5C910(EnOt* this, GlobalContext* globalCtx); void func_80B5C950(EnOt* this, GlobalContext* globalCtx); +void func_80B5C9A8(EnOt* this, GlobalContext* globalCtx); void func_80B5C9C0(EnOt* this, GlobalContext* globalCtx); +void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx); void func_80B5CA30(EnOt* this, GlobalContext* globalCtx); +void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx); void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx); void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx); +void func_80B5CC88(EnOt* this, GlobalContext* globalCtx); void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx); +void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx); void func_80B5CD40(EnOt* this, GlobalContext* globalCtx); +void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx); void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx); +void func_80B5D114(EnOt* this, GlobalContext* globalCtx); void func_80B5D160(EnOt* this, GlobalContext* globalCtx); +void func_80B5D648(EnOt* this, GlobalContext* globalCtx); void func_80B5D750(EnOt* this, GlobalContext* globalCtx); +void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx); +void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx); +void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4); +void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2); +void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2); + +extern Gfx D_06000040[]; +extern Gfx D_06000078[]; +extern AnimationHeader D_06000420; +extern Gfx D_060004A0[]; +extern AnimatedMaterial D_060005F8; +extern AnimationHeader D_060008D8; +extern FlexSkeletonHeader D_06004800; +extern AnimationHeader D_06004B30; + +static EnOt* D_80B5E880; +static EnOt* D_80B5E884; +static EnOt* D_80B5E888; -#if 0 const ActorInit En_Ot_InitVars = { ACTOR_EN_OT, ACTORCAT_NPC, @@ -41,128 +82,1090 @@ const ActorInit En_Ot_InitVars = { (ActorFunc)EnOt_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B5E3A0 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 5, 33, -20, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B5E3FC[] = { +static struct_80B8E1A8 sAnimations[] = { + { &D_06004B30, 1.0f, 0, -5.0f }, + { &D_060008D8, 1.0f, 0, -5.0f }, + { &D_06000420, 1.0f, 0, 0.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 80, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 80, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +void func_80B5B2E0(GlobalContext* globalCtx, Vec3f* pos, s16 params, Vec3f* vec, s32* index) { + s32 i; + Path* path = &globalCtx->setupPathList[params]; + f32 dist; + Vec3f sp58; + Vec3f sp4C; + f32 minDist = FLT_MAX; -extern ColliderCylinderInit D_80B5E3A0; -extern InitChainEntry D_80B5E3FC[]; + for (i = 0; i < path->count; i++) { + Math_Vec3s_ToVec3f(&sp58, &((Vec3s*)Lib_SegmentedToVirtual(path->points))[i]); + dist = Math_Vec3f_DistXYZ(pos, &sp58); + if (dist < minDist) { + minDist = dist; + Math_Vec3f_Copy(&sp4C, &sp58); + *index = i; + } + } -extern UNK_TYPE D_06000078; -extern UNK_TYPE D_060004A0; -extern UNK_TYPE D_060005F8; -extern UNK_TYPE D_060008D8; + Math_Vec3f_Copy(vec, &sp4C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5B2E0.s") +void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOt* this = THIS; + s32 sp74; + s32 pad2; + Vec3f sp64; + Vec3f sp58; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/EnOt_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_388 = 0; + this->unk_33C = ENOT_GET_C000(&this->actor); + if (this->unk_33C == 0) { + D_80B5E880 = this; + this->actor.flags |= 0x8000000; + this->actor.flags &= ~(0x8 | 0x1); + this->actor.update = func_80B5DB6C; + this->actor.draw = NULL; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/EnOt_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004800, &D_060008D8, this->jointTable, this->morphTable, 19); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, + Animation_GetLastFrame(&sAnimations[0].animationSeg->common) * Rand_ZeroOne(), + Animation_GetLastFrame(&sAnimations[0].animationSeg->common), sAnimations[0].mode, + sAnimations[0].transitionRate); + this->unk_346 = ENOT_GET_7F(&this->actor); + this->unk_344 = this->actor.world.rot.z; + this->actor.world.rot.z = 0; + this->actor.shape.rot.z = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.gravity = 0.0f; + func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->unk_744.r = 255; + this->unk_744.g = 200; + this->unk_744.b = 80; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BAAC.s") + switch (ENOT_GET_C000(&this->actor)) { + case 1: + D_80B5E884 = this; + Actor_SetScale(&this->actor, 0.012999999f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BB38.s") + switch (this->unk_344) { + case 0: + this->actor.world.pos.y = + func_800C40B4(&globalCtx->colCtx, &this->actor.floorPoly, &sp74, &this->actor.world.pos) + + 50.0f; + if (gSaveContext.weekEventReg[84] & 0x10) { + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); + Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); + this->unk_360 = (EnOt*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp64.x, sp64.y, + sp64.z, 0, BINANG_ROT180(this->actor.shape.rot.y), 1, + ENOT_GET_3FFF(&this->actor) | 0x8000); + if (this->unk_360 != NULL) { + this->unk_360->unk_360 = this; + this->unk_3A0 = 0; + this->unk_360->unk_3A0 = BINANG_ROT180(this->unk_3A0); + this->unk_394.x = (this->actor.world.pos.x + this->unk_360->actor.world.pos.x) * 0.5f; + this->unk_394.y = this->actor.world.pos.y; + this->unk_394.z = (this->actor.world.pos.z + this->unk_360->actor.world.pos.z) * 0.5f; + Math_Vec3f_Copy(&this->unk_360->unk_394, &this->unk_394); + if (gSaveContext.weekEventReg[32] & 1) { + func_80B5C244(this, globalCtx); + } else { + func_80B5C684(this, globalCtx); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { + this->unk_360 = D_80B5E888; + this->unk_360->unk_360 = this; + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(800.0f, &sp58); + Math_Vec3f_Sum(&this->actor.world.pos, &sp58, &sp58); + Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &sp58); + Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &sp58); + func_80B5BDA8(this, globalCtx); + func_80B5BE88(this->unk_360, globalCtx); + } else { + func_80B5CE6C(this, globalCtx); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BDA8.s") + case 1: + Actor_MarkForDeath(&this->actor); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BE04.s") + case 2: + D_80B5E888 = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BE88.s") + switch (this->unk_344) { + case 0: + Actor_SetScale(&this->actor, 0.0f); + if (!(gSaveContext.weekEventReg[13] & 1)) { + Actor_SetScale(&this->actor, 0.0f); + func_80B5C910(this, globalCtx); + } else { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BED4.s") + if (func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + Actor_SetScale(&this->actor, 0.0f); + func_80B5C910(this, globalCtx); + } else { + this->unk_360 = D_80B5E884; + this->unk_360->unk_360 = this; + func_80B5C9D0(this, globalCtx); + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BF60.s") + case 1: + Actor_SetScale(&this->actor, 0.012999999f); + if (gSaveContext.weekEventReg[84] & 0x10) { + if (gSaveContext.weekEventReg[32] & 1) { + func_80B5C244(this, globalCtx); + } else { + func_80B5C684(this, globalCtx); + } + } else { + func_80B5CE6C(this, globalCtx); + } + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5BFB8.s") + case 3: + if (!(gSaveContext.weekEventReg[26] & 8)) { + this->actor.flags |= 0x8000000; + this->actor.flags &= ~(0x8 | 0x1); + Actor_SetScale(&this->actor, 0.0064999997f); + this->collider.dim.radius *= 0.5f; + this->collider.dim.height *= 0.5f; + this->collider.dim.yShift *= 0.5f; + this->actor.update = func_80B5DAEC; + func_80B5C634(this, globalCtx); + } else { + Actor_MarkForDeath(&this->actor); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C154.s") +void EnOt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C1CC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C244.s") +void func_80B5BAAC(LightInfo* lightInfo, Vec3f* arg1, Color_RGB8* arg2, s16 radius) { + Lights_PointNoGlowSetInfo(lightInfo, arg1->x, arg1->y, arg1->z, arg2->r, arg2->g, arg2->b, radius); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C25C.s") +void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { + f32 rand = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C3B8.s") + arg0->r = (arg1->r * arg2) + (arg1->r * (1.0f - arg2) * rand); + arg0->g = (arg1->g * arg2) + (arg1->g * (1.0f - arg2) * rand); + arg0->b = (arg1->b * arg2) + (arg1->b * (1.0f - arg2) * rand); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C3D8.s") +void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + this->actionFunc = func_80B5BE04; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C634.s") +void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { + switch (this->unk_388) { + case 0: + if (func_8013E2D4(&this->actor, this->cutscenes[2], -1, 0)) { + func_80B5BF60(this, globalCtx); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C64C.s") + case 1: + if (func_8013E2D4(&this->actor, this->cutscenes[3], -1, 0)) { + func_80B5BF60(this, globalCtx); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C684.s") +void func_80B5BE88(EnOt* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + this->actionFunc = func_80B5BED4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C6DC.s") +void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { + func_800BE33C(&this->actor.world.pos, &this->unk_360->actor.world.pos, &this->actor.world.rot, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_360->actor), 3, 0xE38, + 0x38E); + this->actor.speedXZ = 3.5f; + this->actor.world.pos.y = this->unk_360->actor.world.pos.y; + Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C910.s") +void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { + this->unk_32C |= 0x40; + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->actionFunc = func_80B5BFB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C950.s") +void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 temp_f0 = this->actor.floorHeight + 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C9A8.s") + if (temp_f0 <= this->actor.world.pos.y) { + Math_StepToF(&this->actor.world.pos.y, temp_f0, 2.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C9C0.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_360->actor), 3, 0xE38, + 0x38E); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5C9D0.s") + if (Actor_DistanceBetweenActors(&this->actor, &this->unk_360->actor) <= 52.519997f) { + this->unk_73C = 50; + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp34); + this->unk_360->actor.world.pos.x = this->actor.world.pos.x + sp34.x; + this->unk_360->actor.world.pos.y = this->actor.world.pos.y + sp34.y; + this->unk_360->actor.world.pos.z = this->actor.world.pos.z + sp34.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CA30.s") + this->unk_394.x = (this->unk_360->actor.world.pos.x + this->actor.world.pos.x) * 0.5f; + this->unk_394.y = (this->unk_360->actor.world.pos.y + this->actor.world.pos.y) * 0.5f; + this->unk_394.z = (this->unk_360->actor.world.pos.z + this->actor.world.pos.z) * 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CAD0.s") + this->unk_360->unk_394.x = this->unk_394.x; + this->unk_360->unk_394.y = this->unk_394.y; + this->unk_360->unk_394.z = this->unk_394.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CB0C.s") + func_80B5C684(this->unk_360, globalCtx); + func_80B5C684(this, globalCtx); + } else { + Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CBA0.s") +void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { + if (gSaveContext.weekEventReg[32] & 1) { + this->unk_38C = 4; + } else { + this->unk_38C = 12; + gSaveContext.weekEventReg[32] |= 1; + } + func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.yDistToPlayer); + this->actionFunc = func_80B5C1CC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CBEC.s") +void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_80B5C244(this, globalCtx); + func_80B5C244(this->unk_360, globalCtx); + } else { + func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.yDistToPlayer); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CC88.s") +void func_80B5C244(EnOt* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B5C25C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CCA0.s") +void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { + this->unk_390 = Actor_YawBetweenActors(&this->actor, &this->unk_360->actor); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_390, 3, 0xE38, 0x38E); + if (BINANG_SUB(BINANG_ROT180(this->unk_360->actor.shape.rot.y), this->actor.shape.rot.y) < 0x38E) { + this->unk_32C |= 0x80; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CCF4.s") + if ((this->unk_33C == 2) && (this->unk_32C & 0x80) && (this->unk_360->unk_32C & 0x80)) { + this->unk_32C |= 0x100; + this->unk_360->unk_32C |= 0x100; + func_8013E1C8(&this->skelAnime, sAnimations, 2, &this->animIdx); + func_8013E1C8(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); + this->actor.flags |= 0x8000000; + this->actor.flags &= ~(0x8 | 0x1); + this->unk_360->actor.flags |= 0x8000000; + this->unk_360->actor.flags &= ~(0x8 | 0x1); + func_80B5C9A8(this->unk_360, globalCtx); + func_80B5C3B8(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CD40.s") +void func_80B5C3B8(EnOt* this, GlobalContext* globalCtx) { + this->unk_740 = 0.0f; + this->actionFunc = func_80B5C3D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CE6C.s") +void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { + static Color_RGB8 D_80B5E408 = { 255, 200, 80 }; + static Color_RGB8 D_80B5E40C = { 255, 60, 200 }; + s16 temp; + s32 pad; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + Vec3f sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5CEC8.s") + this->unk_3A0 += 0x2D8; + Matrix_RotateY(this->unk_3A0, 0); + Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); + Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); + this->unk_348.x = this->unk_394.x + sp5C.x; + this->unk_348.y = this->unk_394.y; + this->unk_348.z = this->unk_394.z + sp5C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D114.s") + this->unk_360->unk_348.x = this->unk_394.x + sp50.x; + this->unk_360->unk_348.y = this->unk_394.y; + this->unk_360->unk_348.z = this->unk_394.z + sp50.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D160.s") + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_348); + Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &this->unk_360->unk_348); + temp = Actor_YawBetweenActors(&this->actor, &this->unk_360->actor); + this->actor.shape.rot.y = temp; + this->unk_360->actor.shape.rot.y = BINANG_ROT180(temp); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D37C.s") + if (this->unk_740 < 1.0f) { + Lib_LerpRGB(&D_80B5E408, &D_80B5E40C, this->unk_740, &this->unk_744); + Lib_LerpRGB(&D_80B5E408, &D_80B5E40C, this->unk_740, &this->unk_360->unk_744); + Math_StepToF(&this->unk_740, 1.0f, 0.05f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D470.s") + if (Animation_OnFrame(&this->skelAnime, 12.0f)) { + Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), 0); + sp38.x = 1.0f; + sp38.y = 8.1f; + sp38.z = 0.0f; + Matrix_MultiplyVector3fByState(&sp38, &sp44); + Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); + func_80B5DF58(this->unk_3A4, 1, &sp44, &this->actor.shape.rot, 10); + sp38.x = -1.0f; + sp38.y = 8.1f; + sp38.z = 0.0f; + Matrix_MultiplyVector3fByState(&sp38, &sp44); + Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); + func_80B5DF58(this->unk_3A4, 2, &sp44, &this->actor.shape.rot, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D648.s") +void func_80B5C634(EnOt* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B5C64C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5D750.s") +void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { + if (gSaveContext.weekEventReg[26] & 8) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/EnOt_Update.s") +void func_80B5C684(EnOt* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->actionFunc = func_80B5C6DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5DAEC.s") +void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s16 sp3E; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5DB6C.s") + sp3E = Actor_YawToPoint(&player->actor, &this->unk_394); + Matrix_RotateY(BINANG_ADD(sp3E, 0x4000), 0); + if (this->unk_33C == 2) { + Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); + } else { + if (this->unk_73C == 0) { + gSaveContext.weekEventReg[84] |= 0x10; + switch (this->unk_388) { + case 0: + ActorCutscene_Stop(this->cutscenes[2]); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/EnOt_Draw.s") + case 1: + ActorCutscene_Stop(this->cutscenes[3]); + break; + } + this->unk_73C = -1; + } else { + this->unk_73C--; + } + Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp30); + } + this->unk_348.x = this->unk_394.x + sp30.x; + this->unk_348.y = this->unk_394.y; + this->unk_348.z = this->unk_394.z + sp30.z; + Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_348.x, 1.0f, 2.0f, 0.01f); + Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_348.z, 1.0f, 2.0f, 0.01f); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); + if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { + this->actor.textId = 0; + this->unk_384 = 1; + if (func_800B84D0(&this->actor, globalCtx)) { + this->unk_3A0 = BINANG_ADD(sp3E, 0x4000); + this->unk_360->unk_3A0 = this->unk_3A0; + func_80B5C9A8(this, globalCtx); + func_80B5D114(this, globalCtx); + } else if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && + (this->actor.xzDistToPlayer < 130.0f)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5DECC.s") +void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + // This is weird + this->actor.world.rot.x = this->actor.world.rot.x; + this->actor.world.rot.y = this->actor.world.rot.y; + this->actor.world.rot.z = this->actor.world.rot.z; + this->actionFunc = func_80B5C950; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5DF58.s") +void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { + if (this->unk_32C & 8) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + gSaveContext.weekEventReg[25] |= 4; + func_80B5CAD0(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5E078.s") +void func_80B5C9A8(EnOt* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B5C9C0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ot/func_80B5E1D8.s") +void func_80B5C9C0(EnOt* this, GlobalContext* globalCtx) { +} + +void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + // This is weird + this->actor.world.rot.x = this->actor.world.rot.x; + this->actor.world.rot.y = this->actor.world.rot.y; + this->actor.world.rot.z = this->actor.world.rot.z; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + this->actionFunc = func_80B5CA30; +} + +void func_80B5CA30(EnOt* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.scale.x, 0.012999999f, 0.7f, 0.0001f, 0.01f); + Actor_SetScale(&this->actor, this->actor.scale.x); + if (this->actor.scale.x == 0.012999999f) { + this->unk_360->unk_32C |= 0x1000; + this->unk_360->unk_360 = this; + func_80B5C9A8(this, globalCtx); + } +} + +void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx) { + func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); + this->actionFunc = func_80B5CB0C; +} + +void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.scale.x, 0.012999999f, 0.7f, 0.0001f, 0.01f); + Actor_SetScale(&this->actor, this->actor.scale.x); + if (this->actor.scale.x == 0.012999999f) { + this->unk_32C |= 0x800; + func_80B5CE6C(this, globalCtx); + } +} + +void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + this->actionFunc = func_80B5CBEC; +} + +void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + func_80B5CC88(this, globalCtx); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); + this->actor.world.rot.y = this->actor.shape.rot.y; + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + } +} + +void func_80B5CC88(EnOt* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B5CCA0; +} + +void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { + if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 1)) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 |= 0x20000000; + func_80B5CCF4(this, globalCtx); + } +} + +void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->actionFunc = func_80B5CD40; +} + +void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 temp; + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), + 3, 0xE38, 0x38E); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (1) {} + if (!temp) { + gSaveContext.weekEventReg[23] |= 0x10; + func_801518B0(globalCtx, 0x1069, NULL); + } + break; + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1069)) { + this->unk_32C |= 4; + ActorCutscene_Stop(this->cutscenes[0]); + player->stateFlags2 &= ~0x20000000; + func_80B5CE6C(this, globalCtx); + } + break; + } +} + +void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx) { + this->unk_384 = 0; + this->unk_32C |= 0x20; + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->actionFunc = func_80B5CEC8; +} + +void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + this->actor.textId = 0; + if (func_800B84D0(&this->actor, globalCtx)) { + func_80B5D114(this, globalCtx); + return; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); + if (this->unk_32C & 0x800) { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + } else { + this->actor.flags &= ~0x10000; + if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + } + + if (!(gSaveContext.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { + if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.yDistToPlayer) <= 130.0f)) { + player->unk_B2B = 29; + } + + if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { + Vec3f sp2C; + + this->unk_360 = D_80B5E888; + this->unk_360->unk_360 = this; + Matrix_RotateY(this->actor.home.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(800.0f, &sp2C); + Math_Vec3f_Sum(&this->actor.world.pos, &sp2C, &this->unk_360->actor.world.pos); + Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &this->unk_360->actor.world.pos); + this->unk_32C &= ~0x800; + this->unk_360->unk_32C &= ~0x800; + func_80B5BDA8(this, globalCtx); + func_80B5BE88(this->unk_360, globalCtx); + return; + } + } + + if (this->unk_32C & 0x1000) { + this->unk_388 = 1; + func_80B5BDA8(this, globalCtx); + func_80B5BE88(this->unk_360, globalCtx); + } +} + +void func_80B5D114(EnOt* this, GlobalContext* globalCtx) { + func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + this->actionFunc = func_80B5D160; +} + +void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { + u16 phi_a1; + s32 temp; + + switch (func_80152498(&globalCtx->msgCtx)) { + case 0: + temp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!temp) { + switch (this->unk_384) { + case 0: + if ((this->unk_33C != 1) && (this->unk_33C == 2)) { + if (this->unk_32C & 1) { + if (this->unk_32C & 4) { + phi_a1 = 0x106A; + } else { + phi_a1 = 0x1069; + } + } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { + if (gSaveContext.weekEventReg[23] & 0x10) { + phi_a1 = 0x106C; + } else { + phi_a1 = 0x106B; + } + } else { + phi_a1 = 0x1068; + } + } else { + phi_a1 = 0x10A5; + } + func_801518B0(globalCtx, phi_a1, &this->actor); + func_80B5D114(this, globalCtx); + break; + + case 1: + func_801518B0(globalCtx, 0x106D, &this->actor); + func_80B5D114(this, globalCtx); + break; + } + break; + } + break; + + case 1: + case 2: + case 3: + break; + + case 4: + case 5: + case 6: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + default: + case 0x1068: + case 0x106B: + case 0x106C: + func_80B5D648(this, globalCtx); + break; + + case 0x1069: + this->unk_32C |= 4; + + case 0x106A: + func_80B5CE6C(this, globalCtx); + break; + + case 0x10A5: + func_801477B4(globalCtx); + func_80B5CE6C(this, globalCtx); + break; + + case 0x106D: + func_801477B4(globalCtx); + func_80B5C154(this, globalCtx); + break; + } + } + break; + } +} + +s32 func_80B5D37C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { + s32 pad; + EnOt* temp_s0 = (EnOt*)arg1->unk_48; + f32 sp24; + f32 sp20; + + sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; + sp20 = gFramerateDivisorHalf; + + temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; + temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; + do { + temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; + temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; + temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; + } while (0); + temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + + return false; +} + +s32 func_80B5D470(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { + s32 pad; + s32 ret; + Actor* temp_s1 = arg1->unk_48; + Vec3f sp50; + Vec3f sp44; + f32 temp; + s32 sp2C; + s32 sp30; + s32 sp34; + + ret = false; + temp_s1->gravity = 0.0f; + Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + + sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; + sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; + sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + + sp44.x = arg1->unk_20.x - arg1->unk_38.x; + sp44.y = arg1->unk_20.y - arg1->unk_38.y; + sp44.z = arg1->unk_20.z - arg1->unk_38.z; + + temp = Math3D_Parallel(&sp50, &sp44); + if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + ret = true; + } else { + temp = SQ(temp_s1->speedXZ) / arg1->unk_50; + sp34 = ABS(arg1->unk_54 - temp_s1->world.rot.x); + sp2C = (s32)(sp34 * temp) + 0xAAA; + + sp34 = ABS(arg1->unk_56 - temp_s1->world.rot.y); + + Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54, 1, sp2C, 0); + sp2C = (s32)(sp34 * temp) + 0xAAA; + Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_56, 1, sp2C, 0); + Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); + } + + return ret; +} + +void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { + func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); + Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); + func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, + 0, this->unk_340, 0); + this->unk_32C = 0; + this->unk_2C0.unk_2C.x = 0.0f; + this->unk_2C0.unk_2C.y = 0.0f; + this->unk_2C0.unk_2C.z = 0.0f; + this->actor.gravity = 0.0f; + this->actor.speedXZ = 0.0f; + func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + this->actor.flags |= 0x8000000; + this->actor.flags &= ~(0x8 | 0x1); + Actor_SetSwitchFlag(globalCtx, ENOT_GET_3F80(&this->actor)); + this->actionFunc = func_80B5D750; +} + +void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { + if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { + func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + } + + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); + + if (this->unk_2C0.unk_1C & 0x40) { + this->unk_32C |= 2; + } + + if (this->unk_2C0.unk_1C & 0x80) { + this->unk_32C |= 1; + } + + if ((this->unk_32C & 2) && (this->actor.xyzDistToPlayerSq <= SQ(120.0f))) { + this->unk_32C &= ~2; + } + + if ((this->unk_32C & 1) && (this->actor.xzDistToPlayer <= 180.0f)) { + this->actor.flags &= ~0x8000000; + this->actor.flags |= (0x8 | 0x1); + if (D_80B5E884 != 0) { + func_80B5C9A8(this, globalCtx); + } else { + func_80B5CBA0(this, globalCtx); + } + } +} + +void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOt* this = THIS; + + if ((this->animIdx == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_SWIM); + } + + this->actionFunc(this, globalCtx); + if (this->actor.bgCheckFlags & 0x20) { + if (DECR(this->unk_354) == 0) { + if (this->actor.flags & 0x40) { + s32 i; + + for (i = 0; i < 2; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 20.0f, 5.0f, 0.1f); + } + this->unk_354 = (Rand_ZeroOne() * 10.0f) + 10.0f; + } + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 0.0f, 4); + + if (this->actor.world.pos.y <= this->actor.floorHeight + 50.0f) { + this->actor.world.pos.y = this->actor.floorHeight + 50.0f; + this->actor.prevPos.y = this->actor.floorHeight + 50.0f; + } + + Actor_SetHeight(&this->actor, 12.0f); + SkelAnime_Update(&this->skelAnime); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); + + if (this->unk_32C & 0x400) { + func_80B5BAAC(&this->lightInfo, &this->unk_378, &this->unk_747, 0xD2); + } + + func_80B5E078(globalCtx, this->unk_3A4, 10); +} + +void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOt* this = THIS; + + this->actionFunc(this, globalCtx); + Actor_SetHeight(&this->actor, 12.0f); + SkelAnime_Update(&this->skelAnime); + func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); + if (this->unk_32C & 0x400) { + func_80B5BAAC(&this->lightInfo, &this->unk_378, &this->unk_747, 210); + } +} + +void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOt* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + if (!(gSaveContext.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { + if (gSaveContext.weekEventReg[25] & 4) { + Vec3f sp50; + + func_80B5B2E0(globalCtx, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp50.x, sp50.y, sp50.z, 0, + this->actor.shape.rot.y, 1, ENOT_GET_3FFF(&this->actor) | 0x8000, + this->actor.cutscene, this->actor.unk20, NULL) != NULL) { + this->unk_32C |= 8; + } + } else if (D_80B5E888 != NULL) { + s32 sp4C = false; + + if (gSaveContext.weekEventReg[13] & 1) { + if (!func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + sp4C = true; + } + } + + if (!sp4C) { + EnOt* temp = D_80B5E888; + + temp->unk_32C |= 8; + temp->unk_346 = ENOT_GET_7F(&this->actor); + temp->actor.params = this->actor.params; + temp->actor.cutscene = this->actor.cutscene; + this->unk_32C |= 8; + } + } else if (func_800C9B90(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + player->unk_B2B = 29; + } + } +} + +void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + EnOt* this = THIS; + Gfx* gfx; + + Matrix_StatePush(); + func_80B5E1D8(globalCtx, this->unk_3A4, 10); + Matrix_StatePop(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 25); + POLY_XLU_DISP = func_8012C2B4(POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + AnimatedMat_Draw(globalCtx, (AnimatedMaterial*)Lib_SegmentedToVirtual(&D_060005F8)); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnOt_PostLimbDraw, &this->actor); + Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); + Matrix_Scale(0.0882f, 0.0882f, 0.0882f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = func_8012C7FC(POLY_XLU_DISP); + + gSPSetOtherMode(&gfx[0], G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetCombineLERP(&gfx[1], 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, + 0); + gSPDisplayList(&gfx[2], D_04029CB0); + gDPSetPrimColor(&gfx[3], 0, 0, this->unk_747.r, this->unk_747.g, this->unk_747.b, 50); + gSPMatrix(&gfx[4], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[5], D_04029CF0); + + POLY_XLU_DISP = &gfx[6]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B5E410 = { 400.0f, 600.0f, 0.0f }; + EnOt* this = THIS; + + if (limbIndex == 4) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Gfx* gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], D_060004A0); + POLY_OPA_DISP = &gfx[1]; + Matrix_MultiplyVector3fByState(&D_80B5E410, &this->unk_74C); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 1) { + Matrix_GetStateTranslation(&this->unk_378); + this->unk_32C |= 0x400; + } +} + +EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { + s32 i = 0; + + while (i < arg4 && arg0->unk_00) { + i++; + arg0++; + } + + if ((i < arg4) && ((arg1 == 1) || (arg1 == 2))) { + arg0->unk_00 = arg1; + Math_Vec3f_Copy(&arg0->unk_0C, arg2); + Math_Vec3f_Copy(&arg0->unk_50, arg2); + arg0->unk_04 = 0.009f; + arg0->unk_30 = 0.0f; + arg0->unk_34 = 0.0f; + arg0->unk_38 = 0.3f; + arg0->unk_3C = 1.4f; + arg0->unk_40 = -0.05f; + arg0->unk_4C = 40; + + if (arg0->unk_00 == 2) { + arg0->unk_30 = -arg0->unk_30; + arg0->unk_38 = -arg0->unk_38; + } + } + + return arg0; +} + +void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { + Vec3f sp54; + s32 i; + s16 temp = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + + for (i = 0; i < arg2; i++, arg1++) { + if ((arg1->unk_00 == 1) || (arg1->unk_00 == 2)) { + if (DECR(arg1->unk_4C) == 0) { + arg1->unk_00 = 0; + } + + arg1->unk_30 += arg1->unk_38; + arg1->unk_34 += arg1->unk_3C; + arg1->unk_3C += arg1->unk_40; + sp54.x = arg1->unk_30; + sp54.y = arg1->unk_34; + sp54.z = 0.0f; + Matrix_RotateY(temp, 0); + Matrix_MultiplyVector3fByState(&sp54, &arg1->unk_0C); + Math_Vec3f_Sum(&arg1->unk_0C, &arg1->unk_50, &arg1->unk_0C); + arg1->unk_4C--; + } + } +} + +void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { + s32 i; + s32 flag = 0; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + for (i = 0; i < arg2; i++, arg1++) { + if (arg1->unk_00) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, D_06000040); + flag = true; + if (globalCtx) {} + } + + Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_0405E6F0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_06000078); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index c9ab16c42..f0adb73e4 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -7,10 +7,61 @@ struct EnOt; typedef void (*EnOtActionFunc)(struct EnOt*, GlobalContext*); +#define ENOT_GET_7F(thisx) ((thisx)->params & 0x7F) +#define ENOT_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define ENOT_GET_3FFF(thisx) ((thisx)->params & 0x3FFF) +#define ENOT_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ UNK_TYPE1 unk_08[0x4]; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ UNK_TYPE1 unk_18[0x18]; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; + /* 0x40 */ f32 unk_40; + /* 0x44 */ UNK_TYPE1 unk_44[0x8]; + /* 0x4C */ u8 unk_4C; + /* 0x50 */ Vec3f unk_50; +} EnOtUnkStruct; // size = 0x5C + typedef struct EnOt { /* 0x0000 */ Actor actor; /* 0x0144 */ EnOtActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x610]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ Vec3s jointTable[19]; + /* 0x024A */ Vec3s morphTable[19]; + /* 0x02BC */ s32 animIdx; + /* 0x02C0 */ EnDno_ActorUnkStruct unk_2C0; + /* 0x032C */ u16 unk_32C; + /* 0x0330 */ Vec3f unk_330; + /* 0x033C */ s32 unk_33C; + /* 0x0340 */ s32 unk_340; + /* 0x0344 */ s16 unk_344; + /* 0x0346 */ s16 unk_346; + /* 0x0348 */ Vec3f unk_348; + /* 0x0354 */ s16 unk_354; + /* 0x0356 */ s16 cutscenes[4]; + /* 0x0360 */ struct EnOt* unk_360; + /* 0x0364 */ LightNode* lightNode; + /* 0x0368 */ LightInfo lightInfo; + /* 0x0378 */ Vec3f unk_378; + /* 0x0384 */ u8 unk_384; + /* 0x0388 */ s32 unk_388; + /* 0x038C */ s32 unk_38C; + /* 0x0390 */ s16 unk_390; + /* 0x0394 */ Vec3f unk_394; + /* 0x03A0 */ s16 unk_3A0; + /* 0x03A4 */ EnOtUnkStruct unk_3A4[10]; + /* 0x073C */ s16 unk_73C; + /* 0x0740 */ f32 unk_740; + /* 0x0744 */ Color_RGB8 unk_744; + /* 0x0747 */ Color_RGB8 unk_747; + /* 0x074C */ Vec3f unk_74C; } EnOt; // size = 0x758 extern const ActorInit En_Ot_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b1fb037ee..f55e2c808 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14128,7 +14128,7 @@ 0x80B5DAEC:("func_80B5DAEC",), 0x80B5DB6C:("func_80B5DB6C",), 0x80B5DD20:("EnOt_Draw",), - 0x80B5DECC:("func_80B5DECC",), + 0x80B5DECC:("EnOt_PostLimbDraw",), 0x80B5DF58:("func_80B5DF58",), 0x80B5E078:("func_80B5E078",), 0x80B5E1D8:("func_80B5E1D8",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 6f792044a..088ce83a6 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3066,6 +3066,8 @@ D_060004A0 = 0x060004A0; D_060005F8 = 0x060005F8; D_060008D8 = 0x060008D8; D_06004800 = 0x06004800; +D_06000420 = 0x06000420; +D_06004B30 = 0x06004B30; // ovl_En_Owl From 8beaa7841ed5a10ad9e7b4e7097a02cf65899e12 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Wed, 27 Oct 2021 19:36:06 +0100 Subject: [PATCH 51/86] En_Mushi2 (#304) * En_Mushi2 * Warnings * Fix * YOLO * Format --- include/variables.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Fish/z_en_fish.h | 4 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 5 +- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 1205 ++++++++++++++++- .../actors/ovl_En_Mushi2/z_en_mushi2.h | 36 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h | 13 +- 7 files changed, 1191 insertions(+), 77 deletions(-) diff --git a/include/variables.h b/include/variables.h index 7bfd0de86..a9345eee5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4007,7 +4007,7 @@ extern Gfx D_04048DF0[]; extern UNK_TYPE D_04050D10; extern UNK_TYPE D_04051180; extern UNK_TYPE D_04051238; -extern UNK_TYPE D_0405140C; +extern AnimationHeader D_0405140C; extern UNK_TYPE D_040527F0; extern UNK_TYPE D_040528B0; extern Gfx D_04054A90[]; diff --git a/spec b/spec index 1f77335c3..f3f7b422d 100644 --- a/spec +++ b/spec @@ -3135,8 +3135,7 @@ beginseg name "ovl_En_Mushi2" compress include "build/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.o" - include "build/data/ovl_En_Mushi2/ovl_En_Mushi2.data.o" - include "build/data/ovl_En_Mushi2/ovl_En_Mushi2.reloc.o" + include "build/src/overlays/actors/ovl_En_Mushi2/ovl_En_Mushi2_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.h b/src/overlays/actors/ovl_En_Fish/z_en_fish.h index a80fe52ce..7d4a9f0cf 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.h +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.h @@ -7,7 +7,9 @@ struct EnFish; typedef struct EnFish { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x138]; + /* 0x144 */ char unk144[0x133]; + /* 0x277 */ s8 unk_277; + /* 0x278 */ char unk278[0x4]; } EnFish; // size = 0x27C extern const ActorInit En_Fish_InitVars; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index aba81fc31..c7f593179 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -4,6 +4,7 @@ * Description: Marine Research Lab Fish */ +#include "overlays/actors/ovl_En_Fish/z_en_fish.h" #include "overlays/actors/ovl_En_Mushi2/z_en_mushi2.h" #include "z_en_fish2.h" @@ -444,8 +445,8 @@ void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { void func_80B29194(EnFish2* this) { if ((this->unk_354 != NULL) && (this->unk_2C8 == 0)) { - EnMushi2* mushi = (EnMushi2*)this->unk_350; - mushi->unk_277 = 1; + EnFish* fish = (EnFish*)this->unk_350; + fish->unk_277 = 1; } this->unk_2C4 = 0; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 6c774240c..03c808602 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -1,3 +1,10 @@ +/* + * File: z_en_mushi2.c + * Overlay: ovl_En_Mushi2 + * Description: Burrowing Bugs + */ + +#include "overlays/actors/ovl_Obj_Bean/z_obj_bean.h" #include "z_en_mushi2.h" #define FLAGS 0x00000010 @@ -9,15 +16,23 @@ void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx); void EnMushi2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A6A300(EnMushi2* this); void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A508(Actor* thisx); void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A794(EnMushi2* this); void func_80A6A824(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6A984(EnMushi2* this); void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6AAA4(EnMushi2* this); void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6AE14(EnMushi2* this); void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx); +void func_80A6B078(EnMushi2* this); void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx); -#if 0 +extern SkeletonHeader D_040527A0; + const ActorInit En_Mushi2_InitVars = { ACTOR_EN_MUSHI2, ACTORCAT_ITEMACTION, @@ -30,134 +45,1192 @@ const ActorInit En_Mushi2_InitVars = { (ActorFunc)EnMushi2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A6B950[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A6B974 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A6B950, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A6BA04[] = { +static Color_RGBA8 D_80A6B984[] = { + { 170, 130, 90, 255 }, + { 250, 250, 250, 255 }, +}; + +static Color_RGBA8 D_80A6B98C[] = { + { 100, 60, 20, 255 }, + { 180, 180, 180, 255 }, +}; + +static s32 D_80A6B994 = 0; + +static EnMushi2Struct D_80A6B998[] = { + { 1, 0x1F40 }, + { 2, 0xE0C0 }, +}; + +static Vec3f D_80A6B9A0 = { 1.0f, 0.0f, 0.0f }; +static Vec3f D_80A6B9AC = { 0.0f, 1.0f, 0.0f }; +static Vec3f D_80A6B9B8 = { 0.0f, 0.0f, 1.0f }; + +static MtxF D_80A6B9C4 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 20, ICHAIN_STOP), }; -#endif +static f32 D_80A6BA14[] = { 0.06f, 0.1f, 0.13f }; -extern ColliderJntSphElementInit D_80A6B950[1]; -extern ColliderJntSphInit D_80A6B974; -extern InitChainEntry D_80A6BA04[]; +void func_80A687A0(EnMushi2* this) { + MtxF* matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A687A0.s") + matrix->mf[3][0] += this->unk_348 * this->unk_31C.x; + matrix->mf[3][1] += this->unk_348 * this->unk_31C.y; + matrix->mf[3][2] += this->unk_348 * this->unk_31C.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68808.s") +void func_80A68808(EnMushi2* this) { + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68860.s") +s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp40; + CollisionPoly* sp3C; + f32 temp_f0 = func_800C411C(&globalCtx->colCtx, &sp3C, &sp40, &this->actor, &this->actor.world.pos); + WaterBox* sp34; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68910.s") + if ((temp_f0 > (BGCHECK_Y_MIN + 1)) && ((this->actor.world.pos.y - 150.0f) < temp_f0)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68A78.s") + return func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, &sp34); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68B3C.s") +s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { + Actor* bean = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + f32 minDistSq = SQ(100.0f); + s32 ret = false; + f32 temp_f0; + f32 temp_f2; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68B6C.s") + this->unk_34C = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68BA0.s") + while (bean != NULL) { + if (bean->id == ACTOR_OBJ_BEAN) { + params = OBJBEAN_GET_C000(bean); + if (((params == ENOBJBEAN_GET_C000_1) || (params == ENOBJBEAN_GET_C000_2)) && + (bean->room == this->actor.room)) { + temp_f0 = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, bean->world.pos.x, + bean->world.pos.z); + temp_f2 = bean->world.pos.y - this->actor.world.pos.y; + if ((temp_f0 < minDistSq) && (temp_f2 < 100.0f) && (temp_f2 > -50.0f)) { + ret = true; + minDistSq = temp_f0; + this->unk_34C = (ObjBean*)bean; + if (params == ENOBJBEAN_GET_C000_1) { + this->unk_350 = SQ(30.0f); + } else { + this->unk_350 = SQ(39.0f); + } + } + } + } + bean = bean->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68BC8.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68C5C.s") +void func_80A68A78(EnMushi2* this, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68CE4.s") + for (i = 0; i < ARRAY_COUNT(D_80A6B998); i++) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MUSHI2, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y + (D_80A6B998 + i)->unk_02, this->actor.shape.rot.z, + (D_80A6B998 + i)->unk_00, this->actor.cutscene, this->actor.unk20, NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68DD4.s") +void func_80A68B3C(EnMushi2* this) { + if (!(this->unk_30C & 0x100)) { + this->unk_30C |= 0x100; + D_80A6B994++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68ED8.s") +void func_80A68B6C(EnMushi2* this) { + if (this->unk_30C & 0x100) { + this->unk_30C &= ~0x100; + D_80A6B994--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68F24.s") +s32 func_80A68BA0(EnMushi2* this) { + return (D_80A6B994 > 3) && this->unk_34C == 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A68F9C.s") +void func_80A68BC8(EnMushi2* this) { + if (this->unk_36C > 0) { + this->unk_36C--; + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_WALK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A690C4.s") + this->unk_36C = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.12f); + if (this->unk_36C < 2) { + this->unk_36C = 2; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A691EC.s") +s32 func_80A68C5C(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69388.s") + if (temp_f0 < 0.005f) { + Math_Vec3f_Copy(arg0, &D_801D15B0); + return false; + } else { + arg1->x = arg0->x * (1.0f / temp_f0); + arg1->y = arg0->y * (1.0f / temp_f0); + arg1->z = arg0->z * (1.0f / temp_f0); + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69424.s") +s32 func_80A68CE4(Vec3f* arg0, Vec3f* arg1, f32 arg2) { + Vec3f sp34; + f32 temp_f0; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69468.s") + Math_Vec3f_Diff(arg1, arg0, &sp34); + temp_f0 = Math3D_LengthSquared(&sp34); + temp_f2 = arg2 + 0.01f; + if (temp_f0 <= SQ(temp_f2)) { + Math_Vec3f_Copy(arg0, arg1); + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6958C.s") + Math_Vec3f_Scale(&sp34, arg2 / sqrtf(temp_f0)); + sp34.x += arg0->x; + sp34.y += arg0->y; + sp34.z += arg0->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6969C.s") + if (func_80A68C5C(&sp34, arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A697C4.s") + Math_Vec3f_Copy(arg0, arg1); + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A699E4.s") +s32 func_80A68DD4(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + Player* player; + s16 sp2E; + s32 pad2; + f32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69AA8.s") + if ((this->actor.xzDistToPlayer < 32.0f) && (this->actor.yDistToPlayer > -10.0f) && + (this->actor.yDistToPlayer < 31.0f)) { + player = GET_PLAYER(globalCtx); + sp2E = BINANG_ROT180(this->actor.yawTowardsPlayer); + sp24 = Math_SinS(sp2E); + if (Math3D_XZDistanceSquared((sp24 * 16.0f) + player->actor.world.pos.x, + (Math_CosS(sp2E) * 16.0f) + player->actor.world.pos.z, this->actor.world.pos.x, + this->actor.world.pos.z) < SQ(20.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69ADC.s") +void func_80A68ED8(EnMushi2* this) { + this->actor.velocity.x = this->actor.speedXZ * this->unk_328.x; + this->actor.velocity.y = this->actor.speedXZ * this->unk_328.y; + this->actor.velocity.z = this->actor.speedXZ * this->unk_328.z; + Actor_ApplyMovement(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69CE0.s") +void func_80A68F24(EnMushi2* this) { + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80A6B9A0, &this->unk_310); + Matrix_MultiplyVector3fByState(&D_80A6B9AC, &this->unk_31C); + Matrix_MultiplyVector3fByState(&D_80A6B9B8, &this->unk_328); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69D3C.s") +s32 func_80A68F9C(EnMushi2* this, s16 arg1) { + MtxF* matrix; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69EE4.s") + if (arg1 == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A69F5C.s") + matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A024.s") + matrix->mf[0][0] = this->unk_310.x; + matrix->mf[0][1] = this->unk_310.y; + matrix->mf[0][2] = this->unk_310.z; + matrix->mf[0][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A058.s") + matrix->mf[1][0] = this->unk_31C.x; + matrix->mf[1][1] = this->unk_31C.y; + matrix->mf[1][2] = this->unk_31C.z; + matrix->mf[1][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A094.s") + matrix->mf[2][0] = this->unk_328.x; + matrix->mf[2][1] = this->unk_328.y; + matrix->mf[2][2] = this->unk_328.z; + matrix->mf[2][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A0D8.s") + matrix->mf[3][0] = 0.0f; + matrix->mf[3][1] = 0.0f; + matrix->mf[3][2] = 0.0f; + matrix->mf[3][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/EnMushi2_Init.s") + Matrix_RotateY(arg1, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/EnMushi2_Destroy.s") + this->unk_310.x = matrix->mf[0][0]; + this->unk_310.y = matrix->mf[0][1]; + this->unk_310.z = matrix->mf[0][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A300.s") + this->unk_31C.x = matrix->mf[1][0]; + this->unk_31C.y = matrix->mf[1][1]; + this->unk_31C.z = matrix->mf[1][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A36C.s") + this->unk_328.x = matrix->mf[2][0]; + this->unk_328.y = matrix->mf[2][1]; + this->unk_328.z = matrix->mf[2][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A508.s") + this->unk_30C |= 0x40; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A5C0.s") +s32 func_80A690C4(EnMushi2* this, s16 arg1) { + MtxF* matrix; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A794.s") + if (arg1 == 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A824.s") + matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A984.s") + matrix->mf[0][0] = this->unk_310.x; + matrix->mf[0][1] = this->unk_310.y; + matrix->mf[0][2] = this->unk_310.z; + matrix->mf[0][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6A9E4.s") + matrix->mf[1][0] = this->unk_31C.x; + matrix->mf[1][1] = this->unk_31C.y; + matrix->mf[1][2] = this->unk_31C.z; + matrix->mf[1][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6AAA4.s") + matrix->mf[2][0] = this->unk_328.x; + matrix->mf[2][1] = this->unk_328.y; + matrix->mf[2][2] = this->unk_328.z; + matrix->mf[2][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6AB08.s") + matrix->mf[3][0] = 0.0f; + matrix->mf[3][1] = 0.0f; + matrix->mf[3][2] = 0.0f; + matrix->mf[3][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6AE14.s") + Matrix_InsertXRotation_s(arg1, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6AE7C.s") + this->unk_310.x = matrix->mf[0][0]; + this->unk_310.y = matrix->mf[0][1]; + this->unk_310.z = matrix->mf[0][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6B078.s") + this->unk_31C.x = matrix->mf[1][0]; + this->unk_31C.y = matrix->mf[1][1]; + this->unk_31C.z = matrix->mf[1][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/func_80A6B0D8.s") + this->unk_328.x = matrix->mf[2][0]; + this->unk_328.y = matrix->mf[2][1]; + this->unk_328.z = matrix->mf[2][2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/EnMushi2_Update.s") + this->unk_30C |= 0x40; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mushi2/EnMushi2_Draw.s") +s32 func_80A691EC(EnMushi2* this, CollisionPoly* floorPoly, f32 arg2) { + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + Vec3f sp34; + s32 sp30; + + if (arg2 > 0.0f) { + Vec3f sp24; + + sp24.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + sp24.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + sp24.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + Math_Vec3f_Copy(&sp4C, &this->unk_31C); + sp30 = func_80A68CE4(&sp4C, &sp24, arg2); + } else { + sp4C.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + sp4C.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + sp4C.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + sp30 = 1; + } + + Math3D_CrossProduct(&this->unk_310, &sp4C, &sp40); + Math3D_CrossProduct(&sp4C, &sp40, &sp64); + + if (func_80A68C5C(&sp64, &sp58) && func_80A68C5C(&sp40, &sp34)) { + Math_Vec3f_Copy(&this->unk_31C, &sp4C); + Math_Vec3f_Copy(&this->unk_310, &sp58); + Math_Vec3f_Copy(&this->unk_328, &sp34); + this->unk_30C |= 0x40; + return sp30; + } + + return -1; +} + +void func_80A69388(EnMushi2* this) { + D_80A6B9C4.mf[0][0] = this->unk_310.x; + D_80A6B9C4.mf[0][1] = this->unk_310.y; + D_80A6B9C4.mf[0][2] = this->unk_310.z; + + D_80A6B9C4.mf[1][0] = this->unk_31C.x; + D_80A6B9C4.mf[1][1] = this->unk_31C.y; + D_80A6B9C4.mf[1][2] = this->unk_31C.z; + + D_80A6B9C4.mf[2][0] = this->unk_328.x; + D_80A6B9C4.mf[2][1] = this->unk_328.y; + D_80A6B9C4.mf[2][2] = this->unk_328.z; + + func_8018219C(&D_80A6B9C4, &this->actor.world.rot, 0); + this->actor.shape.rot = this->actor.world.rot; +} + +void func_80A69424(EnMushi2* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 9.0f, 0.0f, 0x45); +} + +s32 func_80A69468(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + f32 x; + f32 y; + f32 z; + + sp50.x = 2.0f * this->unk_31C.x; + sp50.y = 2.0f * this->unk_31C.y; + sp50.z = 2.0f * this->unk_31C.z; + + Math_Vec3f_Sum(&sp50, &this->actor.prevPos, &sp68); + + x = (this->unk_328.x * 4.0f); + y = (this->unk_328.y * 4.0f); + z = (this->unk_328.z * 4.0f); + + sp5C.x = (x + sp50.x) + this->actor.world.pos.x; + sp5C.y = (y + sp50.y) + this->actor.world.pos.y; + sp5C.z = (z + sp50.z) + this->actor.world.pos.z; + + if (func_800C55C4(&globalCtx->colCtx, &this->actor.prevPos, &sp5C, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, + &this->unk_338)) { + this->unk_30C |= 6; + return true; + } + return false; +} + +s32 func_80A6958C(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp48; + Vec3f sp3C; + + sp48.x = (2.0f * this->unk_31C.x) + this->actor.world.pos.x; + sp48.y = (2.0f * this->unk_31C.y) + this->actor.world.pos.y; + sp48.z = (2.0f * this->unk_31C.z) + this->actor.world.pos.z; + + sp3C.x = (this->unk_31C.x * -4.0f) + this->actor.world.pos.x; + sp3C.y = (this->unk_31C.y * -4.0f) + this->actor.world.pos.y; + sp3C.z = (this->unk_31C.z * -4.0f) + this->actor.world.pos.z; + + if (func_800C55C4(&globalCtx->colCtx, &sp48, &sp3C, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, &this->unk_338)) { + this->unk_30C |= 0xA; + return true; + } + return false; +} + +s32 func_80A6969C(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp50; + Vec3f sp44; + Vec3f sp38; + + sp38.x = this->unk_31C.x * -4.0f; + sp38.y = this->unk_31C.y * -4.0f; + sp38.z = this->unk_31C.z * -4.0f; + + Math_Vec3f_Sum(&sp38, &this->actor.world.pos, &sp50); + + sp44.x = this->actor.prevPos.x + sp38.x + (this->unk_328.x * -4.0f); + sp44.y = this->actor.prevPos.y + sp38.y + (this->unk_328.y * -4.0f); + sp44.z = this->actor.prevPos.z + sp38.z + (this->unk_328.z * -4.0f); + + if (func_800C55C4(&globalCtx->colCtx, &sp50, &sp44, &this->unk_33C, &this->unk_334, 1, 1, 1, 1, &this->unk_338)) { + this->unk_30C |= (0x10 | 0x2); + return true; + } + return false; +} + +void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = this->unk_334; + s32 sp34 = this->unk_338; + + if (!(this->unk_30C & (0x10 | 0x4))) { + WaterBox* sp30; + f32 sp2C; + + this->unk_30C &= ~(0x40 | 0x8 | 0x2); + if (!func_80A69468(this, globalCtx) && !func_80A6958C(this, globalCtx)) { + func_80A6969C(this, globalCtx); + } + + if (func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30)) { + this->actor.yDistToWater = sp2C - this->actor.world.pos.y; + if (this->actor.yDistToWater >= 1.0f) { + this->unk_30C |= 0x20; + } else { + this->unk_30C &= ~0x20; + } + } else { + this->actor.yDistToWater = BGCHECK_Y_MIN; + this->unk_30C &= ~0x20; + } + } + + if (this->unk_30C & 4) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); + if (func_80A691EC(this, this->unk_334, 0.4f) == 1) { + this->unk_30C &= ~0x4; + } + } else if (this->unk_30C & 0x10) { + if (func_80A691EC(this, this->unk_334, 0.4f) == 1) { + this->unk_30C &= ~0x10; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); + } else { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + } + } else if (this->unk_30C & 8) { + if (!(this->unk_30C & 0x20)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_33C); + func_80A691EC(this, this->unk_334, -1.0f); + } + } else if (!(this->unk_30C & 2)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + Math_Vec3f_Copy(&this->unk_33C, &this->actor.prevPos); + this->unk_334 = sp38; + this->unk_338 = sp34; + } +} + +s32 func_80A699E4(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp40; + f32 sp3C; + + if (this->unk_328.y < 0.0f) { + f32 x = (2.0f * this->unk_328.x) + this->actor.world.pos.x; + f32 y = (2.0f * this->unk_328.y) + this->actor.world.pos.y; + f32 z = (2.0f * this->unk_328.z) + this->actor.world.pos.z; + + if (func_800CA1E8(globalCtx, &globalCtx->colCtx, x, z, &sp3C, &sp40) && (y <= sp3C)) { + return true; + } + } + return false; +} + +f32 func_80A69AA8(f32 x, f32 y, f32 z, Vec3f* pos) { + return -((pos->x * x) + (y * pos->y) + (z * pos->z)); +} + +void func_80A69ADC(Actor* thisx) { + EnMushi2* this = THIS; + ObjBean* bean = this->unk_34C; + f32 sp44; + f32 sp40; + f32 sp3C; + s32 pad2; + + if (this->unk_358 < 1.0f) { + sp44 = Math3D_SignedDistanceFromPlane( + this->unk_310.x, this->unk_310.y, this->unk_310.z, + func_80A69AA8(this->unk_310.x, this->unk_310.y, this->unk_310.z, &this->actor.world.pos), + &bean->actor.world.pos); + sp40 = Math3D_SignedDistanceFromPlane( + this->unk_328.x, this->unk_328.y, this->unk_328.z, + func_80A69AA8(this->unk_328.x, this->unk_328.y, this->unk_328.z, &this->actor.world.pos), + &bean->actor.world.pos); + sp3C = Math3D_XZLength(sp44, sp40); + + if (fabsf(sp3C) > 0.1f) { + this->unk_360 = (Rand_ZeroOne() * 3000.0f * (this->unk_358 - 1.0f)) + (((sp40 / sp3C) - 1.0f) * -1500.0f); + this->unk_364 = 0; + if (Rand_ZeroOne() < this->unk_358) { + this->unk_366 = (sp44 >= 0.0f) ? 2000 : -2000; + } else { + this->unk_366 = (Rand_Next() > 0) ? 2000 : -2000; + } + this->unk_366 += (s16)(((Rand_ZeroOne() * (1.0f - this->unk_358)) - 0.5f) * 0x400); + } else { + this->unk_360 = 0.0f; + this->unk_364 = -0x8000; + this->unk_366 = 0; + } + } +} + +void func_80A69CE0(Actor* thisx) { + EnMushi2* this = THIS; + + this->unk_360 = Rand_ZeroOne() * 1500.0f; + this->unk_364 = 0; + if (Rand_Next() > 0) { + this->unk_366 = 2000; + } else { + this->unk_366 = -2000; + } +} + +void func_80A69D3C(EnMushi2* this) { + s32 pad; + f32 sp40; + f32 sp3C; + f32 sp38; + + if ((this->unk_34C != NULL) && (this->unk_358 > 0.999f)) { + sp40 = Math3D_SignedDistanceFromPlane( + this->unk_310.x, this->unk_310.y, this->unk_310.z, + func_80A69AA8(this->unk_310.x, this->unk_310.y, this->unk_310.z, &this->actor.world.pos), + &this->unk_34C->actor.world.pos); + sp3C = Math3D_SignedDistanceFromPlane( + this->unk_328.x, this->unk_328.y, this->unk_328.z, + func_80A69AA8(this->unk_328.x, this->unk_328.y, this->unk_328.z, &this->actor.world.pos), + &this->unk_34C->actor.world.pos); + sp38 = Math3D_XZLengthSquared(sp40, sp3C); + + if (fabsf(sp38) > 0.010000001f) { + s16 temp_v0 = Math_FAtan2F(sp3C, sp40); + temp_v0 = CLAMP(temp_v0, -3000, 3000); + func_80A68F9C(this, temp_v0); + } + } else { + this->unk_364 += this->unk_366; + if (this->unk_366 >= 0) { + if (this->unk_364 < 0) { + this->unk_364 = -0x8000; + } + } else if (this->unk_364 > 0) { + this->unk_364 = -0x8000; + } + func_80A68F9C(this, Math_SinS(this->unk_364) * this->unk_360); + } +} + +s32 func_80A69EE4(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; + + if (func_800C9EBC(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, &sp30, + &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} + +void func_80A69F5C(Actor* thisx, GlobalContext* globalCtx) { + EnMushi2* this = THIS; + s32 i; + + for (i = 0; i < 7; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -10.0f, 10.0f, 10.0f, (Rand_ZeroOne() * 0.09f) + 0.05f); + } +} + +s32 func_80A6A024(EnMushi2* this) { + ObjBean* bean = this->unk_34C; + + if ((this->unk_34C != NULL) && (bean->unk_1E4 == 0)) { + bean->unk_1E4 = 1; + return true; + } + return false; +} + +s32 func_80A6A058(EnMushi2* this) { + ObjBean* bean = this->unk_34C; + + if ((this->unk_34C != NULL) && (bean->unk_1E4 == 2)) { + bean->unk_1E0++; + return true; + } + return false; +} + +s32 func_80A6A094(EnMushi2* this) { + if (this->unk_34C != NULL) { + ObjBean* bean = this->unk_34C; + + if ((bean->unk_1E4 == 2) || (bean->unk_1E4 == 1)) { + bean->unk_1E4 = 4; + return true; + } + } + return false; +} + +void func_80A6A0D8(EnMushi2* this) { + if (this->unk_34C != NULL) { + this->unk_34C = NULL; + } +} + +void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMushi2* this = THIS; + s32 pad; + s32 sp3C; + + Actor_ProcessInitChain(&this->actor, sInitChain); + if (!ENMUSHI2_GET_3(&this->actor)) { + func_80A68A78(this, globalCtx); + } + this->actor.shape.rot.y += Rand_S16Offset(-2000, 4000); + this->actor.home.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80A68F24(this); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_040527A0, &D_0405140C, this->jointTable, this->morphTable, 24); + Animation_Change(&this->skelAnime, &D_0405140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + func_80A68808(this); + this->actor.colChkInfo.mass = 30; + sp3C = func_80A69EE4(this, globalCtx); + + if ((sp3C == 0) && func_80A68860(this, globalCtx) && func_80A68910(this, globalCtx) && + !ENMUSHI2_GET_3(&this->actor)) { + func_80A6A024(this); + } + + this->unk_358 = 0.0f; + this->unk_36A = Rand_S16Offset(240, 40); + this->unk_30C = 1; + + if (sp3C != 0) { + func_80A69F5C(&this->actor, globalCtx); + this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + func_80A6AE14(this); + } else { + func_80A6A300(this); + } + + func_80A68B3C(this); +} + +void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMushi2* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); + func_80A68B6C(this); +} + +void func_80A6A300(EnMushi2* this) { + this->unk_368 = 100; + this->actor.gravity = -0.25f; + this->actor.minVelocityY = -3.5f; + this->unk_370 = Rand_S16Offset(-1000, 2000); + this->skelAnime.playSpeed = 1.5f; + this->actionFunc = func_80A6A36C; +} + +void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = false; + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + this->actor.velocity.y -= this->actor.velocity.y * D_80A6BA14[ENMUSHI2_GET_3(&this->actor)]; + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + func_80A69424(this, globalCtx); + this->actor.shape.rot.y += this->unk_370; + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->actor.floorHeight < this->actor.world.pos.y) && + (this->actor.world.pos.y < (this->actor.floorHeight + 4.0f))) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x1770); + this->actor.shape.rot.z += Rand_S16Offset(-2000, 4000); + } + + if (this->actor.floorHeight <= (BGCHECK_Y_MIN + 1)) { + sp20 = true; + func_80A6A094(this); + func_80A6A0D8(this); + } + + if (sp20 && (this->unk_36A <= 0)) { + Actor_MarkForDeath(&this->actor); + } else if (this->actor.bgCheckFlags & 0x20) { + func_80A6AAA4(this); + } else if (this->actor.bgCheckFlags & 1) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_WALK); + func_80A68F24(this); + func_80A691EC(this, this->actor.floorPoly, -1.0f); + func_80A69388(this); + func_80A6A508(&this->actor); + } +} + +void func_80A6A508(Actor* thisx) { + EnMushi2* this = THIS; + + if (this->unk_36A > 100) { + this->unk_35C = Rand_ZeroOne() + 1.0f; + } else { + this->unk_35C = (Rand_ZeroOne() * 0.8f) + 1.5f; + } + + this->unk_368 = Rand_S16Offset(10, 30); + if (this->unk_34C == 0) { + func_80A69CE0(thisx); + } else { + func_80A69ADC(thisx); + } + this->actionFunc = func_80A6A5C0; +} + +void func_80A6A5C0(EnMushi2* this, GlobalContext* globalCtx) { + EnMushi2* this2 = this; + + func_80A69D3C(this); + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_35C, 0.1f, 0.5f, 0.0f); + if (this->unk_354 < SQ(40.0f)) { + f32 temp = 1.0f - ((SQ(40.0f) - this->unk_354) * (1.0f / (10.0f * SQ(40.0f)))); + + this->actor.speedXZ *= temp; + } + + func_80A68ED8(this); + func_80A697C4(this, globalCtx); + if (this->unk_30C & 0x40) { + func_80A69388(this); + } + + this->skelAnime.playSpeed = this->actor.speedXZ * 1.6f; + this2->skelAnime.playSpeed = CLAMP(this2->skelAnime.playSpeed, 0.1f, 1.9f); + + if ((this->unk_36A <= 0) || func_80A68BA0(this)) { + func_80A6B078(this); + } else if (!(this->unk_30C & 2)) { + func_80A6A984(this); + } else if (this->unk_30C & 0x20) { + func_80A6AAA4(this); + } else if (this->unk_368 <= 0) { + func_80A6A794(this); + } else if (((globalCtx->gameplayFrames % 2) != 0) && func_80A699E4(this, globalCtx)) { + func_80A6A984(this); + } +} + +void func_80A6A794(EnMushi2* this) { + if (this->unk_354 < SQ(40.0f)) { + this->unk_368 = Rand_S16Offset(2, 4); + } else { + this->unk_368 = Rand_S16Offset(5, 10); + } + + this->unk_35C = Rand_ZeroOne() * 0.4f; + this->actionFunc = func_80A6A824; +} + +void func_80A6A824(EnMushi2* this, GlobalContext* globalCtx) { + EnMushi2* this2 = this; + + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_35C, 0.1f, 0.5f, 0.0f); + func_80A68ED8(this); + func_80A697C4(this, globalCtx); + + if (this->unk_30C & 0x40) { + func_80A69388(this); + } + + this->skelAnime.playSpeed = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + this2->skelAnime.playSpeed = CLAMP(this2->skelAnime.playSpeed, 0.0f, 1.9f); + + if ((this->unk_36A <= 0) || func_80A68BA0(this)) { + func_80A6B078(this); + } else if (!(this->unk_30C & 2)) { + func_80A6A984(this); + } else if (this->unk_30C & 0x20) { + func_80A6AAA4(this); + } else if (this->unk_368 <= 0) { + func_80A6A508(&this->actor); + } +} + +void func_80A6A984(EnMushi2* this) { + if (Rand_Next() & 1) { + this->unk_370 = 0x800; + } else { + this->unk_370 = -0x800; + } + this->skelAnime.playSpeed = 1.2f; + this->unk_368 = 17; + this->actionFunc = func_80A6A9E4; +} + +void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx) { + func_80A68F9C(this, this->unk_370); + func_80A69388(this); + if ((this->unk_36A <= 0) || func_80A68BA0(this)) { + func_80A6B078(this); + } else if (this->unk_368 <= 0) { + func_80A697C4(this, globalCtx); + if (this->unk_30C & 0x40) { + func_80A69388(this); + } + + if (this->unk_30C & 2) { + func_80A6A508(&this->actor); + } else { + func_80A6B078(this); + } + } +} + +void func_80A6AAA4(EnMushi2* this) { + this->actor.velocity.y = -1.2f; + this->actor.minVelocityY = -1.2f; + this->actor.gravity = -0.5f; + this->unk_368 = Rand_S16Offset(120, 50); + this->unk_36E = 0; + this->unk_370 = 0; + this->actionFunc = func_80A6AB08; +} + +void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad; + s16 temp; + + if (this->unk_368 > 80) { + Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + func_80A69424(this, globalCtx); + Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToWater, 2.8f); + this->skelAnime.playSpeed = this->unk_368 * 0.018f; + this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, 0.1f, 1.9f); + + if (this->unk_368 > 80) { + this->unk_36E += Rand_S16Offset(-50, 100); + this->unk_370 += Rand_S16Offset(-300, 600); + } + + temp = this->skelAnime.playSpeed * 200.0f; + this->unk_36E = CLAMP(this->unk_36E, -temp, temp); + + temp = this->skelAnime.playSpeed * 1000.0f; + this->unk_370 = CLAMP(this->unk_370, -temp, temp); + + this->actor.world.rot.y += this->unk_36E; + this->actor.shape.rot.y += this->unk_370; + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0xBB8); + this->actor.shape.rot.x = this->actor.world.rot.x; + Math_ScaledStepToS(&this->actor.world.rot.z, 0, 0xBB8); + this->actor.shape.rot.z = this->actor.world.rot.z; + + if ((this->actor.flags & 0x40) && (Rand_ZeroOne() < 0.03f)) { + Vec3f sp3C; + + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp3C.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp3C, 40, 200, 4); + } + + if ((this->unk_368 <= 0) || (this->unk_36A <= 0) || func_80A68BA0(this)) { + func_80A6A094(this); + func_80A6A0D8(this); + func_80A6AE14(this); + } else if (!(this->actor.bgCheckFlags & 0x20)) { + func_80A6A794(this); + } +} + +void func_80A6AE14(EnMushi2* this) { + this->unk_30C &= ~1; + this->unk_368 = 100; + this->actor.velocity.y = 0.0f; + this->actor.minVelocityY = -0.8f; + this->actor.gravity = -0.04f; + func_80A68B6C(this); + this->actionFunc = func_80A6AE7C; +} + +void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { + f32 temp_f2; + + this->actor.shape.rot.x -= 0x1F4; + this->actor.shape.rot.y += 0xC8; + this->actor.speedXZ += (Rand_ZeroOne() - 0.5f) * 0.16f; + this->actor.speedXZ *= 0.9f; + this->actor.world.rot.y += (s16)((Rand_ZeroOne() - 0.5f) * 2000.0f); + this->actor.gravity = -0.04f - (Rand_ZeroOne() * 0.02f); + this->actor.velocity.y *= 0.95f; + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + func_80A69424(this, globalCtx); + temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); + Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); + if ((this->actor.flags & 0x40) && (this->actor.yDistToWater > 5.0f) && (this->actor.yDistToWater < 30.0f) && + ((Rand_Next() & 0x1FF) < this->unk_368)) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, + ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); + } + + if (this->unk_368 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A6B078(EnMushi2* this) { + this->unk_30C &= ~1; + this->unk_368 = 50; + this->skelAnime.playSpeed = 1.9f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + func_80A68B6C(this); + this->actionFunc = func_80A6B0D8; +} + +void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { + s32 pad[2]; + f32 temp_f2; + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.4f, 1.2f, 0.0f); + temp_f2 = this->actor.scale.x - 0.0002f; + Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); + + if (this->unk_368 > 20) { + func_80A690C4(this, 0x160); + } + + if (this->unk_30C & 0x40) { + func_80A69388(this); + } + + if ((globalCtx->gameplayFrames % 2) != 0) { + temp_f2 = 0.6f; + } else { + temp_f2 = -0.6f; + } + + this->actor.velocity.x = + (this->actor.speedXZ * this->unk_328.x) + (-0.01f * this->unk_31C.x) + (this->unk_310.x * temp_f2); + this->actor.velocity.y = + (this->actor.speedXZ * this->unk_328.y) + (-0.01f * this->unk_31C.y) + (this->unk_310.y * temp_f2); + this->actor.velocity.z = + (this->actor.speedXZ * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); + + if ((this->actor.flags & 0x40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { + Vec3f sp48; + s32 sp44 = 0; + + if (this->unk_334 != 0) { + u32 temp_v0 = func_800C99D4(&globalCtx->colCtx, this->unk_334, this->unk_338); + if ((temp_v0 == 5) || (temp_v0 == 14) || (temp_v0 == 15)) { + sp44 = 1; + } + } + sp48.x = (this->unk_328.x * -0.6f) + (this->unk_31C.x * 0.1f); + sp48.y = (this->unk_328.y * -0.6f) + (this->unk_31C.y * 0.1f); + sp48.z = (this->unk_328.z * -0.6f) + (this->unk_31C.z * 0.1f); + func_800B0E48(globalCtx, &this->actor.world.pos, &sp48, &D_801D15B0, &D_80A6B984[sp44], &D_80A6B98C[sp44], + (Rand_ZeroOne() * 5.0f) + 8.0f, (Rand_ZeroOne() * 5.0f) + 8.0f); + } + + if (this->unk_368 <= 0) { + if (this->unk_30C & 0x80) { + func_80A6A058(this); + func_80A6A0D8(this); + } else { + func_80A6A094(this); + func_80A6A0D8(this); + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMushi2* this = THIS; + s32 pad; + f32 sp4C; + f32 phi_f0; + s32 temp; + + if ((this->unk_34C != NULL) && (this->unk_34C->actor.update == NULL)) { + this->unk_34C = NULL; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80A6A094(this); + func_80A6A0D8(this); + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_368 > 0) { + this->unk_368--; + } + + if (this->unk_36A > 0) { + this->unk_36A--; + } + + if ((this->unk_34C != 0) && ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824)) && + (this->unk_354 < SQ(3.0f))) { + this->unk_30C |= 0x80; + func_80A6B078(this); + } + + if (this->unk_354 < SQ(70.0f)) { + phi_f0 = 0.017f; + } else { + phi_f0 = 0.025f; + } + this->unk_358 += phi_f0; + + if (this->unk_358 > 1.0f) { + this->unk_358 = 1.0f; + } + + temp = this->unk_338; + if ((temp != 50) && + ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824) || + (this->actionFunc == func_80A6A9E4) || (this->actionFunc == func_80A6B0D8)) && + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, temp, &this->actor)) { + func_80A68F24(this); + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + if ((this->actionFunc == func_80A6AB08) || (this->actionFunc == func_80A6AE7C)) { + this->unk_30C |= 0x200; + } else { + this->unk_30C &= ~0x200; + } + + if ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824) || + (this->actionFunc == func_80A6A9E4)) { + func_80A68BC8(this); + } + + if (this->unk_34C != 0) { + sp4C = 0.0f; + + this->unk_354 = Math3D_DistanceSquared(&this->actor.world.pos, &this->unk_34C->actor.world.pos); + if (this->unk_354 < this->unk_350) { + f32 dist = Math3D_NormalizedSignedDistanceFromPlane( + COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->unk_34C->actor.floorPoly->normal.z), this->unk_34C->actor.floorPoly->dist, + &this->actor.world.pos); + + if (fabsf(dist) < 3.0f) { + sp4C = 1.9f; + } + } + Math_StepToF(&this->unk_348, sp4C, 0.7f); + } + + SkelAnime_Update(&this->skelAnime); + + if (this->actor.flags & 0x40) { + if ((this->actionFunc != func_80A6AE7C) && (this->actionFunc != func_80A6B0D8) && + ((this->actionFunc != func_80A6A36C) || (this->unk_36A < 0xDD)) && + (((this->actionFunc != func_80A6A5C0) && (this->actionFunc != func_80A6A824) && + (this->actionFunc != func_80A6A9E4)) || + !(this->unk_358 > 0.999f) || !(this->unk_354 < SQ(20.0f)))) { + s32 phi_v0 = true; + + if (this->unk_34C == 0) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } else { + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + if ((this->unk_358 > 0.999f) && (this->unk_354 < SQ(20.0f))) { + phi_v0 = false; + } + } + + if (phi_v0) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + } + + if ((this->unk_30C & 1) && func_80A68DD4(this, globalCtx)) { + func_800B8A1C(&this->actor, globalCtx, 0xBA, 60.0f, 30.0f); + } + } +} + +void EnMushi2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMushi2* this = THIS; + + func_80A687A0(this); + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); +} diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h index 7804db715..5a95ee49a 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -7,14 +7,42 @@ struct EnMushi2; typedef void (*EnMushi2ActionFunc)(struct EnMushi2*, GlobalContext*); +#define ENMUSHI2_GET_3(thisx) ((thisx)->params & 3) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; +} EnMushi2Struct; + typedef struct EnMushi2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x133]; - /* 0x0277 */ s8 unk_277; - /* 0x0278 */ char unk_278[0x90]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[24]; + /* 0x0218 */ Vec3s morphTable[24]; + /* 0x02A8 */ ColliderJntSph collider; + /* 0x02C8 */ ColliderJntSphElement colliderElements[1]; /* 0x0308 */ EnMushi2ActionFunc actionFunc; /* 0x030C */ s32 unk_30C; - /* 0x0310 */ char unk_310[0x64]; + /* 0x0310 */ Vec3f unk_310; + /* 0x031C */ Vec3f unk_31C; + /* 0x0328 */ Vec3f unk_328; + /* 0x0334 */ CollisionPoly* unk_334; + /* 0x0338 */ u32 unk_338; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ struct ObjBean* unk_34C; + /* 0x0350 */ f32 unk_350; + /* 0x0354 */ f32 unk_354; + /* 0x0358 */ f32 unk_358; + /* 0x035C */ f32 unk_35C; + /* 0x0360 */ f32 unk_360; + /* 0x0364 */ s16 unk_364; + /* 0x0366 */ s16 unk_366; + /* 0x0368 */ s16 unk_368; + /* 0x036A */ s16 unk_36A; + /* 0x036C */ s16 unk_36C; + /* 0x036E */ s16 unk_36E; + /* 0x0370 */ s16 unk_370; } EnMushi2; // size = 0x374 extern const ActorInit En_Mushi2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h index 876f2537a..5156011ff 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h @@ -7,11 +7,22 @@ struct ObjBean; typedef void (*ObjBeanActionFunc)(struct ObjBean*, GlobalContext*); +#define OBJBEAN_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +enum { + /* 0x00 */ ENOBJBEAN_GET_C000_0, + /* 0x01 */ ENOBJBEAN_GET_C000_1, + /* 0x02 */ ENOBJBEAN_GET_C000_2, +}; + typedef struct ObjBean { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; /* 0x015C */ ObjBeanActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xA4]; + /* 0x0160 */ char unk_160[0x80]; + /* 0x01E0 */ s8 unk_1E0; + /* 0x01E4 */ s32 unk_1E4; + /* 0x01E8 */ char unk_1E8[0x1C]; } ObjBean; // size = 0x204 extern const ActorInit Obj_Bean_InitVars; From dc47432ce086947e0add95f538e9b4a5867e1227 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 28 Oct 2021 06:02:44 +1100 Subject: [PATCH 52/86] En_Test4 OK (#366) --- spec | 4 ---- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 10 +++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/spec b/spec index f3f7b422d..a01dcffdd 100644 --- a/spec +++ b/spec @@ -2907,11 +2907,7 @@ beginseg name "ovl_En_Test4" compress include "build/src/overlays/actors/ovl_En_Test4/z_en_test4.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Test4/ovl_En_Test4_reloc.o" -#else - include "build/data/ovl_En_Test4/ovl_En_Test4.reloc.o" -#endif endseg beginseg 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 f5f460141..047a96155 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -287,8 +287,6 @@ void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// 1 instruction in the wrong place void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { s32 dayTemp; EnTest4* this = THIS; @@ -317,11 +315,12 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.time < CLOCK_TIME(6, 1)) { gSaveContext.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; - do { + { GameState* state = &globalCtx->state; state->running = false; - } while (0); + } SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + if (this && this && this) {} this->unk_144 = 1; gSaveContext.time = CLOCK_TIME(6, 0); Actor_MarkForDeath(&this->actor); @@ -363,9 +362,6 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.unk_3F64 = 1000.0f; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test4/EnTest4_Init.s") -#endif void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { } From 38fc110f9987d967f6a25e75220dbf995ff03600 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Thu, 28 Oct 2021 23:38:46 -0300 Subject: [PATCH 53/86] `actorfixer.py` hotfix (#374) * actorfixer.py hotfix * add missing stuff * add zeldaarena * add skelAnime fields * add comment --- .gitignore | 1 + tools/actorfixer.py | 98 ++++++++++++++++------ tools/sizes/code_functions.csv | 146 ++++++++++++++++----------------- 3 files changed, 148 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index e2078e841..9ecdc1e83 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ tools/qemu-mips tools/ido_recomp/* binary ctx.c graphs/ +*.c.m2c # Assets *.png diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 4086528ef..20b260d33 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -2,8 +2,11 @@ import argparse, os +# There are a few commented out entries that would produce unexpected renames. +# They are left as a comment so people can just grab them. + # "old": "new" -animdict ={ +animdict = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", @@ -54,25 +57,25 @@ animdict ={ "ShrinkWindow_Step": "ShrinkWindow_Update", "ShrinkWindow_Fini": "ShrinkWindow_Destroy", "func_801A89A8": "Audio_QueueSeqCmd", - "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", - "SkelAnime_LodDraw": "SkelAnime_DrawLod", - "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", - "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", - "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", - "SkelAnime_Draw": "SkelAnime_DrawOpa", - "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", - "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", - "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", - "SkelAnime_GetTotalFrames": "Animation_GetLength", - "SkelAnime_GetFrameCount": "Animation_GetLastFrame", - "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", - "SkelAnime_Draw2": "SkelAnime_Draw", - "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", - "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", + "SkelAnime_LodDrawLimb(": "SkelAnime_DrawLimbLod(", + "SkelAnime_LodDraw(": "SkelAnime_DrawLod(", + "SkelAnime_LodDrawLimbSV(": "SkelAnime_DrawFlexLimbLod(", + "SkelAnime_LodDrawSV(": "SkelAnime_DrawFlexLod(", + #"SkelAnime_DrawLimb(": "SkelAnime_DrawLimbOpa(", + #"SkelAnime_Draw(": "SkelAnime_DrawOpa(", + "SkelAnime_DrawLimbSV(": "SkelAnime_DrawFlexLimbOpa(", + "SkelAnime_DrawSV(": "SkelAnime_DrawFlexOpa(", + #"SkelAnime_AnimateFrame(": "SkelAnime_GetFrameData(", + "SkelAnime_GetTotalFrames(": "Animation_GetLength(", + "SkelAnime_GetFrameCount(": "Animation_GetLastFrame(", + "SkelAnime_Draw2Limb(": "SkelAnime_DrawLimb(", + "SkelAnime_Draw2(": "SkelAnime_Draw(", + "SkelAnime_DrawLimbSV2(": "SkelAnime_DrawFlexLimb(", + "SkelAnime_DrawSV2(": "SkelAnime_DrawFlex(", "func_80134FFC": "SkelAnime_GetFrameData2", "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2": "Animation_GetLength2", - "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", + "SkelAnime_GetTotalFrames2(": "Animation_GetLength2(", + "SkelAnime_GetFrameCount2(": "Animation_GetLastFrame2(", "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", @@ -91,7 +94,7 @@ animdict ={ "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", + "SkelAnime_InitLinkAnimetion(": "SkelAnime_InitLink(", "func_801360A8": "LinkAnimation_SetUpdateFunction", "func_801360E0": "LinkAnimation_Update", "func_80136104": "LinkAnimation_Morph", @@ -124,7 +127,7 @@ animdict ={ "func_801370B0": "SkelAnime_LoopPartial", "func_8013713C": "SkelAnime_Once", "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", - "SkelAnime_ChangeAnim": "Animation_Change", + "SkelAnime_ChangeAnim(": "Animation_Change(", "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", @@ -138,10 +141,39 @@ animdict ={ "func_80137748": "SkelAnime_UpdateTranslation", "func_801378B8": "Animation_OnFrame", "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", + "SysMatrix_StatePop": "Matrix_StatePop", + "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + "zelda_malloc(": "ZeldaArena_Malloc(", + "zelda_mallocR(": "ZeldaArena_MallocR(", + "zelda_realloc": "ZeldaArena_Realloc", + "zelda_free": "ZeldaArena_Free", + "zelda_calloc": "ZeldaArena_Calloc", + "MainHeap_AnalyzeArena": "ZeldaArena_GetSizes", + "MainHeap_Check": "ZeldaArena_Check", + "MainHeap_Init": "ZeldaArena_Init", + "MainHeap_Cleanup": "ZeldaArena_Cleanup", + "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", + + "skelanime.unk03": "skelanime.taper", + "skelanime.animCurrentSeg": "skelanime.animation", + "skelanime.initialFrame": "skelanime.startFrame", + "skelanime.animFrameCount": "skelanime.endFrame", + "skelanime.totalFrames": "skelanime.animLength", + "skelanime.animCurrentFrame": "skelanime.curFrame", + "skelanime.animPlaybackSpeed": "skelanime.playSpeed", + "skelanime.limbDrawTbl": "skelanime.jointTable", + "skelanime.transitionDrawTbl": "skelanime.morphTable", + "skelanime.transCurrentFrame": "skelanime.morphWeight", + "skelanime.transitionStep": "skelanime.morphRate", + "skelanime.animUpdate": "skelanime.update", + "skelanime.flags": "skelanime.moveFlags", + "skelanime.prevFrameRot": "skelanime.prevRot", + "skelanime.prevFramePos": "skelanime.prevTransl", + "skelanime.unk3E": "skelanime.baseTransl", } def replace_anim(file): - with open(file,'r',encoding = 'utf-8') as infile: + with open(file, 'r', encoding='utf-8') as infile: srcdata = infile.read() funcs = list(animdict.keys()) @@ -168,18 +200,36 @@ def replace_anim_all(repo): if(filename.endswith('.c')): file = subdir + os.sep + filename replace_anim(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'asm' + os.sep + 'non_matchings'): + for subdir, dirs, files in os.walk(repo + os.sep + 'asm'): for filename in files: if(filename.endswith('.s')): file = subdir + os.sep + filename replace_anim(file) + for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): + for filename in files: + if(filename.endswith('.csv')): + file = subdir + os.sep + filename + replace_anim(file) return 1 -parser = argparse.ArgumentParser(description='Update to the new animation names') -parser.add_argument('file', help="source file to be processed. use . to process the whole repo", default = None) +def dictSanityCheck(): + keys = animdict.keys() + values = animdict.values() + for k in keys: + if k in values: + print(f"Key '{k}' found in values") + print(f"This would produce unintended renames") + print(f"Fix this by removing said key from the dictionary") + exit(-1) if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Update to the new animation names') + parser.add_argument('file', help="source file to be processed. use . to process the whole repo", default = None) + args = parser.parse_args() + + dictSanityCheck() + if(args.file == '.'): replace_anim_all(os.curdir) else: diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 14919f754..7243d340d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -349,15 +349,15 @@ asm/non_matchings/code/z_actor/Actor_RemoveFromTypeList.s,Actor_RemoveFromTypeLi asm/non_matchings/code/z_actor/Actor_FreeOverlay.s,Actor_FreeOverlay,0x800BABFC,0x19 asm/non_matchings/code/z_actor/Actor_Spawn.s,Actor_Spawn,0x800BAC60,0x1D asm/non_matchings/code/z_actor/Actor_LoadOverlay.s,Actor_LoadOverlay,0x800BACD4,0x50 -asm/non_matchings/code/z_actor/Actor_SpawnWithParentAndCutscene.s,Actor_SpawnWithParentAndCutscene,0x800BAE14,0xAB -asm/non_matchings/code/z_actor/Actor_SpawnWithParent.s,Actor_SpawnWithParent,0x800BB0C0,0x20 +asm/non_matchings/code/z_actor/Actor_SpawnAsChildAndCutscene.s,Actor_SpawnAsChildAndCutscene,0x800BAE14,0xAB +asm/non_matchings/code/z_actor/Actor_SpawnAsChild.s,Actor_SpawnAsChild,0x800BB0C0,0x20 asm/non_matchings/code/z_actor/Actor_SpawnTransitionActors.s,Actor_SpawnTransitionActors,0x800BB140,0x64 asm/non_matchings/code/z_actor/func_800BB2D0.s,func_800BB2D0,0x800BB2D0,0x72 asm/non_matchings/code/z_actor/func_800BB498.s,func_800BB498,0x800BB498,0x41 asm/non_matchings/code/z_actor/func_800BB59C.s,func_800BB59C,0x800BB59C,0x1A asm/non_matchings/code/z_actor/func_800BB604.s,func_800BB604,0x800BB604,0xBA asm/non_matchings/code/z_actor/func_800BB8EC.s,func_800BB8EC,0x800BB8EC,0x67 -asm/non_matchings/code/z_actor/func_800BBA88.s,func_800BBA88,0x800BBA88,0xE +asm/non_matchings/code/z_actor/Enemy_StartFinishingBlow.s,Enemy_StartFinishingBlow,0x800BBA88,0xE asm/non_matchings/code/z_actor/func_800BBAC0.s,func_800BBAC0,0x800BBAC0,0x2D asm/non_matchings/code/z_actor/func_800BBB74.s,func_800BBB74,0x800BBB74,0x2B asm/non_matchings/code/z_actor/func_800BBC20.s,func_800BBC20,0x800BBC20,0x33 @@ -398,7 +398,7 @@ asm/non_matchings/code/z_actor/func_800BDFC0.s,func_800BDFC0,0x800BDFC0,0x1F asm/non_matchings/code/z_actor/func_800BE03C.s,func_800BE03C,0x800BE03C,0x1F asm/non_matchings/code/z_actor/func_800BE0B8.s,func_800BE0B8,0x800BE0B8,0x33 asm/non_matchings/code/z_actor/func_800BE184.s,func_800BE184,0x800BE184,0x2A -asm/non_matchings/code/z_actor/func_800BE22C.s,func_800BE22C,0x800BE22C,0xB +asm/non_matchings/code/z_actor/Actor_ApplyDamage.s,Actor_ApplyDamage,0x800BE22C,0xB asm/non_matchings/code/z_actor/func_800BE258.s,func_800BE258,0x800BE258,0x18 asm/non_matchings/code/z_actor/func_800BE2B8.s,func_800BE2B8,0x800BE2B8,0x21 asm/non_matchings/code/z_actor/func_800BE33C.s,func_800BE33C,0x800BE33C,0x25 @@ -1127,7 +1127,7 @@ asm/non_matchings/code/z_eff_footmark/EffFootmark_Draw.s,EffFootmark_Draw,0x800F asm/non_matchings/code/code_800F0390/func_800F0390.s,func_800F0390,0x800F0390,0xC asm/non_matchings/code/code_800F0390/func_800F03C0.s,func_800F03C0,0x800F03C0,0x33 asm/non_matchings/code/code_800F0390/func_800F048C.s,func_800F048C,0x800F048C,0x37 -asm/non_matchings/code/code_800F0390/func_800F0568.s,func_800F0568,0x800F0568,0xA +asm/non_matchings/code/code_800F0390/Audio_PlaySoundAtPosition.s,Audio_PlaySoundAtPosition,0x800F0568,0xA asm/non_matchings/code/code_800F0390/func_800F0590.s,func_800F0590,0x800F0590,0xC asm/non_matchings/code/z_elf_message/func_800F05C0.s,func_800F05C0,0x800F05C0,0x80 asm/non_matchings/code/code_800F07C0/func_800F07C0.s,func_800F07C0,0x800F07C0,0x32 @@ -1405,16 +1405,16 @@ asm/non_matchings/code/z_lights/Lights_NewAndDraw.s,Lights_NewAndDraw,0x801026E8 asm/non_matchings/code/z_lights/Lights_New.s,Lights_New,0x80102834,0x13 asm/non_matchings/code/z_lights/Lights_GlowCheck.s,Lights_GlowCheck,0x80102880,0x79 asm/non_matchings/code/z_lights/Lights_DrawGlow.s,Lights_DrawGlow,0x80102A64,0x7F -asm/non_matchings/code/z_malloc/zelda_malloc.s,zelda_malloc,0x80102C60,0xA -asm/non_matchings/code/z_malloc/zelda_mallocR.s,zelda_mallocR,0x80102C88,0xA -asm/non_matchings/code/z_malloc/zelda_realloc.s,zelda_realloc,0x80102CB0,0xC -asm/non_matchings/code/z_malloc/zelda_free.s,zelda_free,0x80102CE0,0xA -asm/non_matchings/code/z_malloc/zelda_calloc.s,zelda_calloc,0x80102D08,0x16 -asm/non_matchings/code/z_malloc/MainHeap_AnalyzeArena.s,MainHeap_AnalyzeArena,0x80102D60,0xE -asm/non_matchings/code/z_malloc/MainHeap_Check.s,MainHeap_Check,0x80102D98,0x9 -asm/non_matchings/code/z_malloc/MainHeap_Init.s,MainHeap_Init,0x80102DBC,0xC -asm/non_matchings/code/z_malloc/MainHeap_Cleanup.s,MainHeap_Cleanup,0x80102DEC,0x9 -asm/non_matchings/code/z_malloc/MainHeap_IsInitialized.s,MainHeap_IsInitialized,0x80102E10,0xC +asm/non_matchings/code/z_malloc/ZeldaArena_Malloc.s,ZeldaArena_Malloc,0x80102C60,0xA +asm/non_matchings/code/z_malloc/ZeldaArena_MallocR.s,ZeldaArena_MallocR,0x80102C88,0xA +asm/non_matchings/code/z_malloc/ZeldaArena_Realloc.s,ZeldaArena_Realloc,0x80102CB0,0xC +asm/non_matchings/code/z_malloc/ZeldaArena_Free.s,ZeldaArena_Free,0x80102CE0,0xA +asm/non_matchings/code/z_malloc/ZeldaArena_Calloc.s,ZeldaArena_Calloc,0x80102D08,0x16 +asm/non_matchings/code/z_malloc/ZeldaArena_GetSizes.s,ZeldaArena_GetSizes,0x80102D60,0xE +asm/non_matchings/code/z_malloc/ZeldaArena_Check.s,ZeldaArena_Check,0x80102D98,0x9 +asm/non_matchings/code/z_malloc/ZeldaArena_Init.s,ZeldaArena_Init,0x80102DBC,0xC +asm/non_matchings/code/z_malloc/ZeldaArena_Cleanup.s,ZeldaArena_Cleanup,0x80102DEC,0x9 +asm/non_matchings/code/z_malloc/ZeldaArena_IsInitialized.s,ZeldaArena_IsInitialized,0x80102E10,0xC asm/non_matchings/code/z_map_disp/func_80102E40.s,func_80102E40,0x80102E40,0x14 asm/non_matchings/code/z_map_disp/func_80102E90.s,func_80102E90,0x80102E90,0x5 asm/non_matchings/code/z_map_disp/func_80102EA4.s,func_80102EA4,0x80102EA4,0x4 @@ -2050,62 +2050,62 @@ asm/non_matchings/code/z_skelanime/SkelAnime_Draw2Limb.s,SkelAnime_Draw2Limb,0x8 asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s,SkelAnime_Draw,0x80134990,0x71 asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV2.s,SkelAnime_DrawLimbSV2,0x80134B54,0x9A asm/non_matchings/code/z_skelanime/SkelAnime_DrawFlex.s,SkelAnime_DrawFlex,0x80134DBC,0x90 -asm/non_matchings/code/z_skelanime/func_80134FFC.s,func_80134FFC,0x80134FFC,0xF6 -asm/non_matchings/code/z_skelanime/func_801353D4.s,func_801353D4,0x801353D4,0x9 +asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameData2.s,SkelAnime_GetFrameData2,0x80134FFC,0xF6 +asm/non_matchings/code/z_skelanime/Animation_GetLimbCount2.s,Animation_GetLimbCount2,0x801353D4,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetTotalFrames2.s,SkelAnime_GetTotalFrames2,0x801353F8,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameCount2.s,SkelAnime_GetFrameCount2,0x8013541C,0xB -asm/non_matchings/code/z_skelanime/SkelAnime_InterpolateVec3s.s,SkelAnime_InterpolateVec3s,0x80135448,0x120 -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationCtxReset.s,SkelAnime_AnimationCtxReset,0x801358C8,0x3 -asm/non_matchings/code/z_skelanime/func_801358D4.s,func_801358D4,0x801358D4,0x8 -asm/non_matchings/code/z_skelanime/func_801358F4.s,func_801358F4,0x801358F4,0xA -asm/non_matchings/code/z_skelanime/SkelAnime_NextEntry.s,SkelAnime_NextEntry,0x8013591C,0xE -asm/non_matchings/code/z_skelanime/SkelAnime_LoadLinkAnimetion.s,SkelAnime_LoadLinkAnimetion,0x80135954,0x35 -asm/non_matchings/code/z_skelanime/SkelAnime_LoadAnimationType1.s,SkelAnime_LoadAnimationType1,0x80135A28,0x1A -asm/non_matchings/code/z_skelanime/SkelAnime_LoadAnimationType2.s,SkelAnime_LoadAnimationType2,0x80135A90,0x1C -asm/non_matchings/code/z_skelanime/SkelAnime_LoadAnimationType3.s,SkelAnime_LoadAnimationType3,0x80135B00,0x1C -asm/non_matchings/code/z_skelanime/SkelAnime_LoadAnimationType4.s,SkelAnime_LoadAnimationType4,0x80135B70,0x1C -asm/non_matchings/code/z_skelanime/SkelAnime_LoadAnimationType5.s,SkelAnime_LoadAnimationType5,0x80135BE0,0x17 -asm/non_matchings/code/z_skelanime/SkelAnime_LinkAnimetionLoaded.s,SkelAnime_LinkAnimetionLoaded,0x80135C3C,0xC -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationType1Loaded.s,SkelAnime_AnimationType1Loaded,0x80135C6C,0x1C -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationType2Loaded.s,SkelAnime_AnimationType2Loaded,0x80135CDC,0x17 -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationType3Loaded.s,SkelAnime_AnimationType3Loaded,0x80135D38,0x20 -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationType4Loaded.s,SkelAnime_AnimationType4Loaded,0x80135DB8,0x21 -asm/non_matchings/code/z_skelanime/SkelAnime_AnimationType5Loaded.s,SkelAnime_AnimationType5Loaded,0x80135E3C,0x2B -asm/non_matchings/code/z_skelanime/func_80135EE8.s,func_80135EE8,0x80135EE8,0x28 +asm/non_matchings/code/z_skelanime/SkelAnime_InterpFrameTable.s,SkelAnime_InterpFrameTable,0x80135448,0x120 +asm/non_matchings/code/z_skelanime/AnimationContext_Reset.s,AnimationContext_Reset,0x801358C8,0x3 +asm/non_matchings/code/z_skelanime/AnimationContext_SetNextQueue.s,AnimationContext_SetNextQueue,0x801358D4,0x8 +asm/non_matchings/code/z_skelanime/AnimationContext_DisableQueue.s,AnimationContext_DisableQueue,0x801358F4,0xA +asm/non_matchings/code/z_skelanime/AnimationContext_AddEntry.s,AnimationContext_AddEntry,0x8013591C,0xE +asm/non_matchings/code/z_skelanime/AnimationContext_SetLoadFrame.s,AnimationContext_SetLoadFrame,0x80135954,0x35 +asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyAll.s,AnimationContext_SetCopyAll,0x80135A28,0x1A +asm/non_matchings/code/z_skelanime/AnimationContext_SetInterp.s,AnimationContext_SetInterp,0x80135A90,0x1C +asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyTrue.s,AnimationContext_SetCopyTrue,0x80135B00,0x1C +asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyFalse.s,AnimationContext_SetCopyFalse,0x80135B70,0x1C +asm/non_matchings/code/z_skelanime/AnimationContext_SetMoveActor.s,AnimationContext_SetMoveActor,0x80135BE0,0x17 +asm/non_matchings/code/z_skelanime/AnimationContext_LoadFrame.s,AnimationContext_LoadFrame,0x80135C3C,0xC +asm/non_matchings/code/z_skelanime/AnimationContext_CopyAll.s,AnimationContext_CopyAll,0x80135C6C,0x1C +asm/non_matchings/code/z_skelanime/AnimationContext_CopyInterp.s,AnimationContext_CopyInterp,0x80135CDC,0x17 +asm/non_matchings/code/z_skelanime/AnimationContext_CopyTrue.s,AnimationContext_CopyTrue,0x80135D38,0x20 +asm/non_matchings/code/z_skelanime/AnimationContext_CopyFalse.s,AnimationContext_CopyFalse,0x80135DB8,0x21 +asm/non_matchings/code/z_skelanime/AnimationContext_MoveActor.s,AnimationContext_MoveActor,0x80135E3C,0x2B +asm/non_matchings/code/z_skelanime/AnimationContext_Update.s,AnimationContext_Update,0x80135EE8,0x28 asm/non_matchings/code/z_skelanime/SkelAnime_InitLinkAnimetion.s,SkelAnime_InitLinkAnimetion,0x80135F88,0x48 -asm/non_matchings/code/z_skelanime/func_801360A8.s,func_801360A8,0x801360A8,0xE -asm/non_matchings/code/z_skelanime/func_801360E0.s,func_801360E0,0x801360E0,0x9 -asm/non_matchings/code/z_skelanime/func_80136104.s,func_80136104,0x80136104,0x2E -asm/non_matchings/code/z_skelanime/func_801361BC.s,func_801361BC,0x801361BC,0x33 -asm/non_matchings/code/z_skelanime/func_80136288.s,func_80136288,0x80136288,0x25 -asm/non_matchings/code/z_skelanime/func_8013631C.s,func_8013631C,0x8013631C,0x35 -asm/non_matchings/code/z_skelanime/SkelAnime_SetTransition.s,SkelAnime_SetTransition,0x801363F0,0x9 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeLinkAnim.s,SkelAnime_ChangeLinkAnim,0x80136414,0x5E -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeLinkAnimDefaultStop.s,SkelAnime_ChangeLinkAnimDefaultStop,0x8013658C,0x18 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeLinkAnimPlaybackStop.s,SkelAnime_ChangeLinkAnimPlaybackStop,0x801365EC,0x19 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeLinkAnimDefaultRepeat.s,SkelAnime_ChangeLinkAnimDefaultRepeat,0x80136650,0x17 -asm/non_matchings/code/z_skelanime/SkelAnime_ChangeLinkAnimPlaybackRepeat.s,SkelAnime_ChangeLinkAnimPlaybackRepeat,0x801366AC,0x18 -asm/non_matchings/code/z_skelanime/func_8013670C.s,func_8013670C,0x8013670C,0xC -asm/non_matchings/code/z_skelanime/func_8013673C.s,func_8013673C,0x8013673C,0xC -asm/non_matchings/code/z_skelanime/func_8013676C.s,func_8013676C,0x8013676C,0x11 -asm/non_matchings/code/z_skelanime/func_801367B0.s,func_801367B0,0x801367B0,0x11 -asm/non_matchings/code/z_skelanime/func_801367F4.s,func_801367F4,0x801367F4,0xE -asm/non_matchings/code/z_skelanime/func_8013682C.s,func_8013682C,0x8013682C,0x28 -asm/non_matchings/code/z_skelanime/func_801368CC.s,func_801368CC,0x801368CC,0x28 -asm/non_matchings/code/z_skelanime/SkelAnime_SetModeStop.s,SkelAnime_SetModeStop,0x8013696C,0x9 -asm/non_matchings/code/z_skelanime/func_80136990.s,func_80136990,0x80136990,0x2E -asm/non_matchings/code/z_skelanime/func_80136A48.s,func_80136A48,0x80136A48,0xD +asm/non_matchings/code/z_skelanime/LinkAnimation_SetUpdateFunction.s,LinkAnimation_SetUpdateFunction,0x801360A8,0xE +asm/non_matchings/code/z_skelanime/LinkAnimation_Update.s,LinkAnimation_Update,0x801360E0,0x9 +asm/non_matchings/code/z_skelanime/LinkAnimation_Morph.s,LinkAnimation_Morph,0x80136104,0x2E +asm/non_matchings/code/z_skelanime/LinkAnimation_AnimateFrame.s,LinkAnimation_AnimateFrame,0x801361BC,0x33 +asm/non_matchings/code/z_skelanime/LinkAnimation_Loop.s,LinkAnimation_Loop,0x80136288,0x25 +asm/non_matchings/code/z_skelanime/LinkAnimation_Once.s,LinkAnimation_Once,0x8013631C,0x35 +asm/non_matchings/code/z_skelanime/Animation_SetMorph.s,Animation_SetMorph,0x801363F0,0x9 +asm/non_matchings/code/z_skelanime/LinkAnimation_Change.s,LinkAnimation_Change,0x80136414,0x5E +asm/non_matchings/code/z_skelanime/LinkAnimation_ChangeDefaultStop.s,LinkAnimation_ChangeDefaultStop,0x8013658C,0x18 +asm/non_matchings/code/z_skelanime/LinkAnimation_ChangePlaybackStop.s,LinkAnimation_ChangePlaybackStop,0x801365EC,0x19 +asm/non_matchings/code/z_skelanime/LinkAnimation_ChangeDefaultRepeat.s,LinkAnimation_ChangeDefaultRepeat,0x80136650,0x17 +asm/non_matchings/code/z_skelanime/LinkAnimation_ChangePlaybackRepeat.s,LinkAnimation_ChangePlaybackRepeat,0x801366AC,0x18 +asm/non_matchings/code/z_skelanime/LinkAnimation_CopyJointToMorph.s,LinkAnimation_CopyJointToMorph,0x8013670C,0xC +asm/non_matchings/code/z_skelanime/LinkAnimation_CopyMorphToJoint.s,LinkAnimation_CopyMorphToJoint,0x8013673C,0xC +asm/non_matchings/code/z_skelanime/LinkAnimation_LoadToMorph.s,LinkAnimation_LoadToMorph,0x8013676C,0x11 +asm/non_matchings/code/z_skelanime/LinkAnimation_LoadToJoint.s,LinkAnimation_LoadToJoint,0x801367B0,0x11 +asm/non_matchings/code/z_skelanime/LinkAnimation_InterpJointMorph.s,LinkAnimation_InterpJointMorph,0x801367F4,0xE +asm/non_matchings/code/z_skelanime/LinkAnimation_BlendToJoint.s,LinkAnimation_BlendToJoint,0x8013682C,0x28 +asm/non_matchings/code/z_skelanime/LinkAnimation_BlendToMorph.s,LinkAnimation_BlendToMorph,0x801368CC,0x28 +asm/non_matchings/code/z_skelanime/LinkAnimation_EndLoop.s,LinkAnimation_EndLoop,0x8013696C,0x9 +asm/non_matchings/code/z_skelanime/Animation_OnFrameImpl.s,Animation_OnFrameImpl,0x80136990,0x2E +asm/non_matchings/code/z_skelanime/LinkAnimation_OnFrame.s,LinkAnimation_OnFrame,0x80136A48,0xD asm/non_matchings/code/z_skelanime/SkelAnime_Init.s,SkelAnime_Init,0x80136A7C,0x2D asm/non_matchings/code/z_skelanime/SkelAnime_InitFlex.s,SkelAnime_InitFlex,0x80136B30,0x2F asm/non_matchings/code/z_skelanime/SkelAnime_InitSkin.s,SkelAnime_InitSkin,0x80136BEC,0x26 -asm/non_matchings/code/z_skelanime/func_80136C84.s,func_80136C84,0x80136C84,0x13 +asm/non_matchings/code/z_skelanime/SkelAnime_SetUpdate.s,SkelAnime_SetUpdate,0x80136C84,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_Update.s,SkelAnime_Update,0x80136CD0,0x9 -asm/non_matchings/code/z_skelanime/func_80136CF4.s,func_80136CF4,0x80136CF4,0x29 -asm/non_matchings/code/z_skelanime/func_80136D98.s,func_80136D98,0x80136D98,0x5B -asm/non_matchings/code/z_skelanime/func_80136F04.s,func_80136F04,0x80136F04,0x4A -asm/non_matchings/code/z_skelanime/func_8013702C.s,func_8013702C,0x8013702C,0x21 -asm/non_matchings/code/z_skelanime/func_801370B0.s,func_801370B0,0x801370B0,0x23 -asm/non_matchings/code/z_skelanime/func_8013713C.s,func_8013713C,0x8013713C,0x3C +asm/non_matchings/code/z_skelanime/SkelAnime_Morph.s,SkelAnime_Morph,0x80136CF4,0x29 +asm/non_matchings/code/z_skelanime/SkelAnime_MorphTaper.s,SkelAnime_MorphTaper,0x80136D98,0x5B +asm/non_matchings/code/z_skelanime/SkelAnime_AnimateFrame.s,SkelAnime_AnimateFrame,0x80136F04,0x4A +asm/non_matchings/code/z_skelanime/SkelAnime_LoopFull.s,SkelAnime_LoopFull,0x8013702C,0x21 +asm/non_matchings/code/z_skelanime/SkelAnime_LoopPartial.s,SkelAnime_LoopPartial,0x801370B0,0x23 +asm/non_matchings/code/z_skelanime/SkelAnime_Once.s,SkelAnime_Once,0x8013713C,0x3C asm/non_matchings/code/z_skelanime/Animation_ChangeImpl.s,Animation_ChangeImpl,0x8013722C,0x6F asm/non_matchings/code/z_skelanime/Animation_Change.s,Animation_Change,0x801373E8,0x12 asm/non_matchings/code/z_skelanime/Animation_PlayOnce.s,Animation_PlayOnce,0x80137430,0x16 @@ -2114,14 +2114,14 @@ asm/non_matchings/code/z_skelanime/Animation_PlayOnceSetSpeed.s,Animation_PlayOn asm/non_matchings/code/z_skelanime/Animation_PlayLoop.s,Animation_PlayLoop,0x80137540,0x15 asm/non_matchings/code/z_skelanime/Animation_MorphToLoop.s,Animation_MorphToLoop,0x80137594,0xE asm/non_matchings/code/z_skelanime/Animation_ChangePlaybackRepeat.s,Animation_ChangePlaybackRepeat,0x801375CC,0x16 -asm/non_matchings/code/z_skelanime/SkelAnime_AnimSetStop.s,SkelAnime_AnimSetStop,0x80137624,0xB -asm/non_matchings/code/z_skelanime/SkelAnime_AnimReverse.s,SkelAnime_AnimReverse,0x80137650,0x9 -asm/non_matchings/code/z_skelanime/func_80137674.s,func_80137674,0x80137674,0x1A -asm/non_matchings/code/z_skelanime/func_801376DC.s,func_801376DC,0x801376DC,0x1B -asm/non_matchings/code/z_skelanime/func_80137748.s,func_80137748,0x80137748,0x5C +asm/non_matchings/code/z_skelanime/Animation_EndLoop.s,Animation_EndLoop,0x80137624,0xB +asm/non_matchings/code/z_skelanime/Animation_Reverse.s,Animation_Reverse,0x80137650,0x9 +asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTableTrue.s,SkelAnime_CopyFrameTableTrue,0x80137674,0x1A +asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTableFalse.s,SkelAnime_CopyFrameTableFalse,0x801376DC,0x1B +asm/non_matchings/code/z_skelanime/SkelAnime_UpdateTranslation.s,SkelAnime_UpdateTranslation,0x80137748,0x5C asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 -asm/non_matchings/code/z_skelanime/SkelAnime_CopyVec3s.s,SkelAnime_CopyVec3s,0x8013792C,0x11 +asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTable.s,SkelAnime_CopyFrameTable,0x8013792C,0x11 asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 asm/non_matchings/code/z_skin/func_80137B34.s,func_80137B34,0x80137B34,0xE2 asm/non_matchings/code/z_skin/func_80137EBC.s,func_80137EBC,0x80137EBC,0x27 @@ -2415,8 +2415,8 @@ asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxTarget.s,ShrinkW asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxMagnitude.s,ShrinkWindow_SetPillarboxMagnitude,0x80160C78,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxMagnitude.s,ShrinkWindow_GetPillarboxMagnitude,0x80160C8C,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s,ShrinkWindow_Init,0x80160CA0,0xD -asm/non_matchings/code/z_shrink_window/ShrinkWindow_Fini.s,ShrinkWindow_Fini,0x80160CD4,0x4 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_Step.s,ShrinkWindow_Step,0x80160CE4,0x2D +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Destroy.s,ShrinkWindow_Destroy,0x80160CD4,0x4 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Update.s,ShrinkWindow_Update,0x80160CE4,0x2D asm/non_matchings/code/z_shrink_window/ShrinkWindow_Draw.s,ShrinkWindow_Draw,0x80160D98,0xFA asm/non_matchings/code/db_camera/func_80161180.s,func_80161180,0x80161180,0x7 asm/non_matchings/code/db_camera/func_8016119C.s,func_8016119C,0x8016119C,0x24 @@ -2526,7 +2526,7 @@ asm/non_matchings/code/z_play/func_80169590.s,func_80169590,0x80169590,0x1C asm/non_matchings/code/z_play/func_80169600.s,func_80169600,0x80169600,0x1A asm/non_matchings/code/z_play/func_80169668.s,func_80169668,0x80169668,0x1B asm/non_matchings/code/z_play/Play_GetCamera.s,Play_GetCamera,0x801696D4,0xE -asm/non_matchings/code/z_play/func_8016970C.s,func_8016970C,0x8016970C,0x44 +asm/non_matchings/code/z_play/Play_CameraSetAtEye.s,Play_CameraSetAtEye,0x8016970C,0x44 asm/non_matchings/code/z_play/func_8016981C.s,func_8016981C,0x8016981C,0x49 asm/non_matchings/code/z_play/func_80169940.s,func_80169940,0x80169940,0x12 asm/non_matchings/code/z_play/func_80169988.s,func_80169988,0x80169988,0x13 From b1b114e142f05443524d91b4127d9bf97fe75a28 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Fri, 29 Oct 2021 19:30:48 +0100 Subject: [PATCH 54/86] Decompile graph.c (#274) * Decompiled, 1 non-matching, add some bss reordering helpers * Document stuff * Review suggestions * graphutil.c -> graphalloc.c * Try to fix fault callback warnings * Remove extra comments in GfxMasterList * char pad -> u32 pad Co-authored-by: Derek Hensley * Fix gameState Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Other suggestions Co-authored-by: Derek Hensley Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/functions.h | 50 +-- include/macros.h | 2 + include/os.h | 3 - include/ultra64/sptask.h | 26 +- include/ultra64/vi.h | 34 +- include/variables.h | 51 +-- include/z64.h | 324 ++++++++------- spec | 6 +- src/boot_O2_g3/CIC6105.c | 3 +- src/boot_O2_g3/fault.c | 8 +- src/code/code_80174A40.c | 7 - src/code/code_80182CE0.c | 7 + src/code/game.c | 25 +- src/code/graph.c | 385 +++++++++++++++++- src/code/graphalloc.c | 29 ++ src/code/sched.c | 8 +- src/code/sys_cmpdma.c | 4 +- src/code/sys_matrix.c | 8 - src/code/sys_ucode.c | 8 +- src/code/title_setup.c | 2 +- src/code/z_actor.c | 2 +- src/code/z_effect_soft_sprite_old_init.c | 2 +- src/code/z_prenmi.c | 4 +- src/code/z_rcp.c | 146 ++++--- src/code/z_room.c | 4 +- src/code/z_scene.c | 4 +- src/code/z_skelanime.c | 8 +- src/libultra/gu/visetevent.c | 2 +- src/libultra/io/sptask.c | 20 +- src/libultra/io/vi.c | 6 +- src/libultra/io/vigetnextframebuf.c | 6 +- src/libultra/io/visetmode.c | 2 +- src/libultra/io/visetspecial.c | 20 +- src/libultra/io/viswapbuf.c | 2 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 3 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 4 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 3 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 2 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 2 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.h | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 6 +- .../ovl_file_choose/z_file_choose_80807940.c | 4 +- .../ovl_file_choose/z_file_choose_NES.c | 4 +- .../ovl_file_choose/z_file_nameset_NES.c | 4 +- tools/disasm/files.txt | 8 +- tools/disasm/functions.txt | 26 +- tools/disasm/variables.txt | 28 +- tools/sizes/code_functions.csv | 44 +- undefined_syms.txt | 4 +- 49 files changed, 908 insertions(+), 454 deletions(-) delete mode 100644 src/code/code_80174A40.c create mode 100644 src/code/code_80182CE0.c create mode 100644 src/code/graphalloc.c diff --git a/include/functions.h b/include/functions.h index d43098265..6ba1d1a70 100644 --- a/include/functions.h +++ b/include/functions.h @@ -53,9 +53,9 @@ void __osSyncVPrintf(const char* fmt, ...); void osSyncPrintf(const char* fmt, ...); void rmonPrintf(const char* fmt, ...); void Fault_SleepImpl(u32 duration); -void Fault_AddClient(FaultClient* client, fault_client_func callback, void* param0, void* param1); +void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* param1); void Fault_RemoveClient(FaultClient* client); -void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvFunc callback, void* param); +void Fault_AddAddrConvClient(FaultAddrConvClient* client, void* callback, void* param); void Fault_RemoveAddrConvClient(FaultAddrConvClient* client); void* Fault_ConvertAddress(void* addr); void Fault_Sleep(u32 duration); @@ -2412,7 +2412,7 @@ Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 wi Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a); Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a); Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s32 a); -void func_8012CF0C(GraphicsContext* gfxCtx, s32 iParm2, s32 iParm3, u8 r, u8 g, u8 b); +void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b); void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void func_8012D40C(f32* param_1, f32* param_2, s16* param_3); void Room_nop8012D510(GlobalContext* globalCtx, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4); @@ -3176,26 +3176,26 @@ void GameState_Realloc(GameState* gameState, size_t size); void GameState_Init(GameState* gameState, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); void GameState_Destroy(GameState* gameState); GameStateFunc GameState_GetNextStateInit(GameState* gameState); -size_t Game_GetNextStateSize(GameState* gameState); +size_t GameState_GetNextStateSize(GameState* gameState); u32 GameState_IsRunning(GameState* gameState); s32 GameState_GetArenaSize(GameState* gameState); s32 func_80173B48(GameState* gameState); -void GameAlloc_Log(GameAlloc* heap); -void* GameAlloc_Malloc(GameAlloc* heap, size_t size); -void GameAlloc_Free(GameAlloc* heap, void* ptr); -void GameAlloc_Cleanup(GameAlloc* heap); -void GameAlloc_Init(GameAlloc* iParm1); -// void Graph_FaultClient(void); -void Graph_DlAlloc(TwoHeadGfxArena* dl, void* memoryBlock, size_t size); -void Graph_InitTHGA(GraphicsContext* gfxCtx); +void GameAlloc_Log(GameAlloc* this); +void* GameAlloc_Malloc(GameAlloc* this, size_t size); +void GameAlloc_Free(GameAlloc* this, void* data); +void GameAlloc_Cleanup(GameAlloc* this); +void GameAlloc_Init(GameAlloc* this); +void* Graph_FaultClient(void); +void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); +void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); -void* Graph_FaultAddrConvFunc(void* addr); +void* Graph_FaultAddrConvFunc(void* address, void* param); void Graph_Init(GraphicsContext* gfxCtx); -// void Graph_Destroy(void); -void Graph_Render(GraphicsContext* gfxCtx, GameState* gameState); -void Graph_FrameSetup(GameState* gameState); -void Graph_RenderFrame(GraphicsContext* gfxCtx, GameState* gameState); -void Graph_DoFrame(GraphicsContext* gfxCtx, GameState* gameState); +void Graph_Destroy(GraphicsContext* gfxCtx); +void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState); +void Graph_UpdateGame(GameState* gameState); +void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState); +void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState); void Graph_ThreadEntry(void* arg); Gfx* Graph_GfxPlusOne(Gfx* gfx); Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); @@ -3267,10 +3267,10 @@ void func_801780F0(Mtx* param_1, f32 param_2, f32 param_3, f32 param_4, f32 para // void func_8017842C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_80178750(void); // void func_80178818(void); -// void func_80178978(void); +void func_80178978(void); // void func_801789D4(void); -u32* get_framebuffer(s32 index); -// u16* get_zbuffer(void); +u32 SysCfb_GetFbPtr(s32 index); +u32 SysCfb_GetZBuffer(void); // UNK_TYPE4 func_80178A24(void); // void func_80178A34(void); s32 func_80178A94(s32 param_1, s32 param_2); @@ -3436,10 +3436,10 @@ void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); // void func_801822C4(void); void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); -// void func_80182C90(void); -// void func_80182CA0(void); -// void func_80182CBC(void); -// void func_80182CCC(void); +u64* SysUcode_GetUCodeBoot(void); +u32 SysUcode_GetUCodeBootSize(void); +u64* SysUcode_GetUCode(void); +u64* SysUcode_GetUCodeData(void); // void func_80182CE0(void); // void func_80183020(void); // void func_80183058(void); diff --git a/include/macros.h b/include/macros.h index 607e5e9bc..ebe4b636e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -88,6 +88,7 @@ extern GraphicsContext* __gfxCtx; #define POLY_OPA_DISP __gfxCtx->polyOpa.p #define POLY_XLU_DISP __gfxCtx->polyXlu.p #define OVERLAY_DISP __gfxCtx->overlay.p +#define DEBUG_DISP __gfxCtx->debug.p // __gfxCtx shouldn't be used directly. // Use the DISP macros defined above when writing to display buffers. @@ -121,6 +122,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN8(val) (((val) + 7) & ~7) #define ALIGN16(val) (((val) + 0xF) & ~0xF) +#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) diff --git a/include/os.h b/include/os.h index b182d4e47..f89239874 100644 --- a/include/os.h +++ b/include/os.h @@ -81,10 +81,8 @@ typedef struct { /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); } OSDevMgr; // size = 0x1C - typedef u64 OSTime; - typedef struct OSTimer_s { /* 0x00 */ struct OSTimer_s* next; /* 0x04 */ struct OSTimer_s* prev; @@ -94,7 +92,6 @@ typedef struct OSTimer_s { /* 0x1C */ OSMesg msg; } OSTimer; // size = 0x20 - typedef struct { /* 0x0 */ u16 type; /* 0x2 */ u8 status; diff --git a/include/ultra64/sptask.h b/include/ultra64/sptask.h index c6e314f82..e89557267 100644 --- a/include/ultra64/sptask.h +++ b/include/ultra64/sptask.h @@ -79,26 +79,26 @@ typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 flags; - /* 0x08 */ u64* ucode_boot; - /* 0x0C */ u32 ucode_boot_size; + /* 0x08 */ u64* ucodeBoot; + /* 0x0C */ u32 ucodeBootSize; /* 0x10 */ u64* ucode; - /* 0x14 */ u32 ucode_size; + /* 0x14 */ u32 ucodeSize; - /* 0x18 */ u64* ucode_data; - /* 0x1C */ u32 ucode_data_size; + /* 0x18 */ u64* ucodeData; + /* 0x1C */ u32 ucodeDataSize; - /* 0x20 */ u64* dram_stack; - /* 0x24 */ u32 dram_stack_size; + /* 0x20 */ u64* dramStack; + /* 0x24 */ u32 dramStackSize; - /* 0x28 */ u64* output_buff; - /* 0x2C */ u64* output_buff_size; + /* 0x28 */ u64* outputBuff; + /* 0x2C */ u64* outputBuffSize; - /* 0x30 */ u64* data_ptr; - /* 0x34 */ u32 data_size; + /* 0x30 */ u64* dataPtr; + /* 0x34 */ u32 dataSize; - /* 0x38 */ u64* yield_data_ptr; - /* 0x3C */ u32 yield_data_size; + /* 0x38 */ u64* yieldDataPtr; + /* 0x3C */ u32 yieldDataSize; } OSTask_t; // size = 0x40 typedef union diff --git a/include/ultra64/vi.h b/include/ultra64/vi.h index 783087361..67d7f681d 100644 --- a/include/ultra64/vi.h +++ b/include/ultra64/vi.h @@ -1,6 +1,8 @@ #ifndef _ULTRA64_VI_H_ #define _ULTRA64_VI_H_ +#include "ultra64/message.h" + /* Special Features */ #define OS_VI_GAMMA_ON 0x0001 #define OS_VI_GAMMA_OFF 0x0002 @@ -65,7 +67,7 @@ typedef struct { /* 0x14 */ OSMesg* msg; /* 0x18 */ __OSViScale x; /* 0x24 */ __OSViScale y; -} OSViContext; // size = 0x30 +} __OSViContext; // size = 0x30 #define OS_VI_NTSC_LPN1 0 /* NTSC */ #define OS_VI_NTSC_LPF1 1 @@ -97,6 +99,36 @@ typedef struct { #define OS_VI_PAL_HPN2 26 #define OS_VI_PAL_HPF2 27 +#define OS_VI_MPAL_LPN1 28 /* MPAL */ +#define OS_VI_MPAL_LPF1 29 +#define OS_VI_MPAL_LAN1 30 +#define OS_VI_MPAL_LAF1 31 +#define OS_VI_MPAL_LPN2 32 +#define OS_VI_MPAL_LPF2 33 +#define OS_VI_MPAL_LAN2 34 +#define OS_VI_MPAL_LAF2 35 +#define OS_VI_MPAL_HPN1 36 +#define OS_VI_MPAL_HPF1 37 +#define OS_VI_MPAL_HAN1 38 +#define OS_VI_MPAL_HAF1 39 +#define OS_VI_MPAL_HPN2 40 +#define OS_VI_MPAL_HPF2 41 + +#define OS_VI_FPAL_LPN1 42 /* FPAL */ +#define OS_VI_FPAL_LPF1 43 +#define OS_VI_FPAL_LAN1 44 +#define OS_VI_FPAL_LAF1 45 +#define OS_VI_FPAL_LPN2 46 +#define OS_VI_FPAL_LPF2 47 +#define OS_VI_FPAL_LAN2 48 +#define OS_VI_FPAL_LAF2 49 +#define OS_VI_FPAL_HPN1 50 +#define OS_VI_FPAL_HPF1 51 +#define OS_VI_FPAL_HAN1 52 +#define OS_VI_FPAL_HAF1 53 +#define OS_VI_FPAL_HPN2 54 +#define OS_VI_FPAL_HPF2 55 + #define OS_TV_PAL 0 #define OS_TV_NTSC 1 #define OS_TV_MPAL 2 diff --git a/include/variables.h b/include/variables.h index a9345eee5..ffaadaadf 100644 --- a/include/variables.h +++ b/include/variables.h @@ -937,13 +937,7 @@ extern s16 D_801BD8C6; extern ColliderCylinderInit fireObjCollisionInit; extern FireObjLightParams D_801BD8FC[2]; extern GameStateOverlay gGameStateOverlayTable[]; -// extern GameStateOverlay D_801BD940; -// extern GameStateOverlay titleGameStateInfo; -// extern GameStateOverlay mainGameStateInfo; -// extern GameStateOverlay openingGameStateInfo; -// extern GameStateOverlay fileChooseGameStateInfo; -// extern GameStateOverlay daytelopGameStateInfo; -// extern UNK_TYPE4 graphNumGameStates; +extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA70; // extern UNK_TYPE2 D_801BDA74; // extern UNK_TYPE2 D_801BDA78; @@ -1660,8 +1654,8 @@ extern s32 gFramerateDivisor; extern f32 gFramerateDivisorF; extern f32 gFramerateDivisorHalf; extern f32 gFramerateDivisorThird; -extern u32 D_801D1510; -extern u32 D_801D1514[3]; +extern u32 retryCount; +extern u32 cfbIdx[3]; extern s32 gScreenWidth; extern s32 gScreenHeight; extern u32 startHeapSize; @@ -3422,11 +3416,10 @@ extern struct_801F8010 D_801F8010; extern struct_801F8020 D_801F8020; extern VisMono sMonoColors; extern UNK_TYPE1 D_801F8048; -extern FaultAddrConvClient grapgFaultAddrConvClient; -extern FaultClient graphFaultClient; -extern Gfx* graphDlEntry; -// extern UNK_TYPE1 D_801F80F8; -extern u64 lastRenderFrameTimestamp; +extern FaultAddrConvClient sGraphFaultAddrConvClient; +extern FaultClient sGraphFaultClient; +extern GfxMasterList* gGfxMasterDL; +extern CfbInfo sGraphCfbInfos[3]; extern OSMesgQueue sSiIntMsgQ; extern OSMesg sSiIntMsgBuf[1]; extern u32 gSegments[NUM_SEGMENTS]; @@ -3452,8 +3445,8 @@ extern OSTime sRSPOtherStartTime; extern OSTime sRDPStartTime; extern u64* gAudioSPDataPtr; extern u32 gAudioSPDataSize; -// extern UNK_TYPE1 D_801FBAE0; -// extern UNK_TYPE1 D_801FBAE8; +extern volatile OSTime D_801FBAE0; +extern volatile OSTime D_801FBAE8; extern volatile OSTime D_801FBAF0; extern volatile OSTime lastRenderFrameDuration; extern volatile OSTime gRSPAudioTotalTime; @@ -3466,21 +3459,21 @@ extern OSViMode D_801FBB30; extern u32* gFramebuffers[2]; extern OSViMode* D_801FBB88; extern u16* gZBufferPtr; -// extern UNK_TYPE4 D_801FBB90; -// extern UNK_TYPE1 D_801FBB94; -// extern UNK_TYPE1 D_801FBB98; +extern void* D_801FBB90; +extern u64* gGfxSPTaskOutputBufferPtr; +extern u32 gGfxSPTaskOutputBufferSize; // extern UNK_TYPE1 D_801FBB9C; // extern UNK_TYPE1 D_801FBBA0; -extern u16* sys_cfb_zbufl; -extern u16** sys_cfb_wbufl; -extern u16** sys_cfb_fifol; -// extern UNK_TYPE1 D_801FBBB0; +extern u16 (*gZBuffer)[SCREEN_WIDTH * SCREEN_HEIGHT]; +extern u16 (*gWorkBuffer)[SCREEN_WIDTH * SCREEN_HEIGHT]; +extern u64 (*gGfxSPTaskOutputBuffer)[0x3000]; +extern void* gGfxSPTaskOutputBufferEnd; // extern UNK_TYPE1 D_801FBBB4; // extern UNK_TYPE1 D_801FBBB8; // extern UNK_TYPE1 D_801FBBBC; // extern UNK_TYPE1 D_801FBBC0; -// extern UNK_TYPE1 D_801FBBC4; -// extern UNK_TYPE1 D_801FBBC8; +extern u64 (*gGfxSPTaskOutputBuffer2)[0x3000]; +extern void* gGfxSPTaskOutputBufferEnd2; extern UNK_TYPE2 D_801FBBCC; extern UNK_TYPE2 D_801FBBCE; // extern UNK_TYPE1 D_801FBBD0; @@ -4093,10 +4086,8 @@ extern UNK_TYPE D_05023008; extern UNK_TYPE D_0502324C; // other segments -extern UNK_TYPE D_0E000048; -extern UNK_TYPE D_0E000088; -extern UNK_TYPE D_0E000140; -extern UNK_TYPE D_0E0001C8; -extern UNK_TYPE D_0E0002C8; +extern GfxMasterList D_0E000000; + +extern UNK_TYPE D_0F000000; #endif diff --git a/include/z64.h b/include/z64.h index cd00fb86f..643a75f0e 100644 --- a/include/z64.h +++ b/include/z64.h @@ -5,16 +5,13 @@ #include "stdbool.h" #include "stdint.h" -#include "PR/ultratypes.h" -#include "PR/gbi.h" +#include "ultra64.h" #include "io/controller.h" #include "osint.h" -#include "viint.h" #include "math.h" #include "os.h" #include "stdlib.h" #include "xstdio.h" -#include "unk.h" #include "bgm.h" #include "sfx.h" @@ -255,6 +252,30 @@ typedef struct { /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries } GameInfo; // size = 0x15D4 +typedef struct IrqMgrClient { + /* 0x0 */ struct IrqMgrClient* next; + /* 0x4 */ OSMesgQueue* queue; +} IrqMgrClient; // size = 0x8 + +typedef struct { + /* 0x0 */ s16 type; + /* 0x2 */ u8 misc[30]; +} OSScMsg; + +typedef struct { + /* 0x000 */ OSScMsg verticalRetraceMesg; + /* 0x020 */ OSScMsg prenmiMsg; + /* 0x040 */ OSScMsg nmiMsg; + /* 0x060 */ OSMesgQueue irqQueue; + /* 0x078 */ OSMesg irqBuffer[8]; + /* 0x098 */ OSThread thread; + /* 0x248 */ IrqMgrClient* callbacks; + /* 0x24C */ u8 prenmiStage; + /* 0x250 */ OSTime lastPrenmiTime; + /* 0x258 */ OSTimer prenmiTimer; + /* 0x278 */ OSTime lastFrameTime; +} IrqMgr; // size = 0x280 + typedef struct { /* 0x0000 */ u32 size; /* 0x0004 */ void* bufp; @@ -269,13 +290,31 @@ typedef struct { /* 0x000C */ Gfx* d; } TwoHeadGfxArena; // size = 0x10 +typedef struct { + /* 0x000 */ Gfx taskStart[9]; + /* 0x048 */ Gfx clearZBuffer[8]; // original name: clear_zb_dl + /* 0x088 */ Gfx clearFrameBuffer[5]; // original name: clear_fb_dl + /* 0x0B0 */ Gfx setupBuffers[6]; // setup framebuffer and zbuffer + /* 0x0E0 */ Gfx unk_E0[12]; // unused + /* 0x140 */ Gfx syncSegments[17]; + /* 0x1C8 */ Gfx setScissor[2]; + /* 0x1D8 */ Gfx unk_1D8[25]; // unused + /* 0x2A0 */ Gfx disps[5]; + /* 0x2C8 */ Gfx clearFillRect[3]; // fillrect for clearing buffers + /* 0x2E0 */ Gfx fillRect[3]; // fillrect for general purpose + /* 0x2F8 */ Gfx debugDisp[1]; +} GfxMasterList; // size = 0x300 + +#define GFXPOOL_HEAD_MAGIC 0x1234 +#define GFXPOOL_TAIL_MAGIC 0x5678 + typedef struct { /* 0x00000 */ u16 headMagic; // 1234 - /* 0x00008 */ Gfx unk8[96]; + /* 0x00008 */ GfxMasterList master; /* 0x00308 */ Gfx polyXluBuffer[2048]; /* 0x04308 */ Gfx overlayBuffer[1024]; - /* 0x06308 */ Gfx unk6308[64]; - /* 0x06508 */ Gfx unk6508[64]; + /* 0x06308 */ Gfx workBuffer[64]; + /* 0x06508 */ Gfx debugBuffer[64]; /* 0x06708 */ Gfx polyOpaBuffer[13184]; /* 0x20308 */ u16 tailMagic; // 5678 } GfxPool; // size = 0x20310 @@ -293,38 +332,90 @@ typedef struct { /* 0x18 */ f32 yScale; } CfbInfo; // size = 0x1C +#define OS_SC_NEEDS_RDP 0x0001 +#define OS_SC_NEEDS_RSP 0x0002 +#define OS_SC_DRAM_DLIST 0x0004 +#define OS_SC_PARALLEL_TASK 0x0010 +#define OS_SC_LAST_TASK 0x0020 +#define OS_SC_SWAPBUFFER 0x0040 + +#define OS_SC_RCP_MASK 0x0003 +#define OS_SC_TYPE_MASK 0x0007 + +#define OS_SC_DP 0x0001 +#define OS_SC_SP 0x0002 +#define OS_SC_YIELD 0x0010 +#define OS_SC_YIELDED 0x0020 + +typedef struct OSScTask { + /* 0x00 */ struct OSScTask* next; + /* 0x04 */ u32 state; + /* 0x08 */ u32 flags; + /* 0x0C */ CfbInfo* framebuffer; + /* 0x10 */ OSTask list; + /* 0x50 */ OSMesgQueue* msgQ; + /* 0x54 */ OSMesg msg; +} OSScTask; // size = 0x58 + typedef struct GraphicsContext { - /* 0x000 */ Gfx* polyOpaBuffer; - /* 0x004 */ Gfx* polyXluBuffer; - /* 0x008 */ UNK_TYPE1 pad8[0x8]; - /* 0x010 */ Gfx* overlayBuffer; - /* 0x014 */ UNK_TYPE1 pad14[0x24]; - /* 0x038 */ UNK_TYPE4 unk38[8]; - /* 0x058 */ OSMesgQueue* unk58; - /* 0x05C */ OSMesgQueue unk5C; - /* 0x074 */ UNK_TYPE1 pad74[0x12C]; - /* 0x1A0 */ Gfx* unk1A0; - /* 0x1A4 */ TwoHeadGfxArena unk1A4; - /* 0x1B4 */ Gfx* unk1B4; - /* 0x1B8 */ TwoHeadGfxArena unk1B8; - /* 0x1C8 */ UNK_TYPE1 pad1C8[0xAC]; - /* 0x274 */ OSViMode* viMode; - /* 0x278 */ void* zbuffer; - /* 0x27C */ UNK_TYPE1 pad27C[0x1C]; - /* 0x298 */ TwoHeadGfxArena overlay; - /* 0x2A8 */ TwoHeadGfxArena polyOpa; - /* 0x2B8 */ TwoHeadGfxArena polyXlu; - /* 0x2C8 */ s32 displaylistCounter; - /* 0x2CC */ void* framebuffer; - /* 0x2D0 */ int pad2D0; - /* 0x2D4 */ u32 viConfigFeatures; - /* 0x2D8 */ UNK_TYPE1 gap2D8[0x3]; - /* 0x2DB */ u8 framebufferCounter; - /* 0x2DC */ UNK_TYPE1 pad2DC[0x8]; - /* 0x2E4 */ f32 viConfigXScale; - /* 0x2E8 */ f32 viConfigYScale; - /* 0x2EC */ UNK_TYPE1 pad2EC[0x4]; -} GraphicsContext; // size = 0x2F0 + /* 0x000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" + /* 0x004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" + /* 0x008 */ char unk_8[0x8]; // Unused, could this be pointers to "Zelda 2" / "Zelda 3" + /* 0x010 */ Gfx* overlayBuffer; // Pointer to "Zelda 4" + /* 0x014 */ u32 unk_14; + /* 0x018 */ char unk_18[0x20]; + /* 0x038 */ OSMesg msgBuff[8]; + /* 0x058 */ OSMesgQueue* schedMsgQ; + /* 0x05C */ OSMesgQueue queue; + /* 0x074 */ char unk_74[0x04]; + /* 0x078 */ OSScTask task; + /* 0x0E0 */ char unk_E0[0xD0]; + /* 0x1B0 */ Gfx* workBuffer; + /* 0x1B4 */ TwoHeadGfxArena work; + /* 0x1C4 */ Gfx* debugBuffer; + /* 0x1C8 */ TwoHeadGfxArena debug; + /* 0x1D8 */ char unk_1D8[0xAC]; + /* 0x284 */ OSViMode* viMode; + /* 0x288 */ void* zbuffer; + /* 0x28C */ char unk_28C[0x1C]; + /* 0x2A8 */ TwoHeadGfxArena overlay; // "Zelda 4" + /* 0x2B8 */ TwoHeadGfxArena polyOpa; // "Zelda 0" + /* 0x2C8 */ TwoHeadGfxArena polyXlu; // "Zelda 1" + /* 0x2D8 */ u32 gfxPoolIdx; + /* 0x2DC */ u16* curFrameBuffer; + /* 0x2E0 */ char unk_2E0[0x4]; + /* 0x2E4 */ u32 viConfigFeatures; + /* 0x2E8 */ char unk_2E8[0x2]; + /* 0x2EA */ u8 updateViMode; + /* 0x2EB */ u8 framebufferIdx; + /* 0x2EC */ void (*callback)(struct GraphicsContext*, u32); + /* 0x2F0 */ u32 callbackParam; + /* 0x2F4 */ f32 xScale; + /* 0x2F8 */ f32 yScale; + /* 0x2FC */ GfxMasterList* masterList; +} GraphicsContext; // size = 0x300 + +typedef struct { + /* 0x000 */ OSMesgQueue interruptQ; + /* 0x018 */ OSMesg intBuf[64]; + /* 0x118 */ OSMesgQueue cmdQ; + /* 0x130 */ OSMesg cmdMsgBuf[8]; + /* 0x150 */ OSThread thread; + /* 0x300 */ OSScTask* audioListHead; + /* 0x304 */ OSScTask* gfxListHead; + /* 0x308 */ OSScTask* audioListTail; + /* 0x30C */ OSScTask* gfxListTail; + /* 0x310 */ OSScTask* curRSPTask; + /* 0x314 */ OSScTask* curRDPTask; + /* 0x318 */ s32 retraceCount; + /* 0x318 */ s32 doAudio; + /* 0x320 */ CfbInfo* curBuf; + /* 0x324 */ CfbInfo* pendingSwapBuf1; + /* 0x328 */ CfbInfo* pendingSwapBuf2; + /* 0x32C */ char unk_32C[0x3]; + /* 0x32F */ u8 shouldUpdateVi; + /* 0x330 */ IrqMgrClient irqClient; +} SchedContext; // size = 0x338 typedef enum IRQ_MSG_TYPE { IRQ_VERTICAL_RETRACE_MSG = 0x1, @@ -410,10 +501,6 @@ typedef struct { /* 0xC */ s32 rightX; } Viewport; // size = 0x10 -typedef void*(*FaultAddrConvFunc)(void* addr, void* arg); - -typedef void(*fault_client_func)(void* arg1, void* arg2); - typedef void(*osCreateThread_func)(void*); typedef void* (*PrintCallback)(void*, const char*, size_t); @@ -563,25 +650,6 @@ typedef enum { GFXPRINT_OPEN = 0x80 } GfxPrintFlag; -typedef struct GameState GameState; - -typedef void (*GameStateFunc)(GameState* gameState); - -typedef struct { - /* 0x00 */ void* loadedRamAddr; - /* 0x04 */ uintptr_t vromStart; // if applicable - /* 0x08 */ uintptr_t vromEnd; // if applicable - /* 0x0C */ void* vramStart; // if applicable - /* 0x10 */ void* vramEnd; // if applicable - /* 0x14 */ UNK_PTR unk_14; - /* 0x18 */ GameStateFunc init; // initializes and executes the given context - /* 0x1C */ GameStateFunc destroy; // deconstructs the context, and sets the next context to load - /* 0x20 */ UNK_PTR unk_20; - /* 0x24 */ UNK_PTR unk_24; - /* 0x28 */ UNK_TYPE unk_28; - /* 0x2C */ size_t instanceSize; -} GameStateOverlay; // size = 0x30 - typedef struct { /* 0x00 */ u16 countdown; /* 0x04 */ Vec3f originPos; @@ -988,12 +1056,12 @@ typedef struct { /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 -typedef struct ArenaNode_t { +typedef struct ArenaNode { /* 0x0 */ s16 magic; // Should always be 0x7373 /* 0x2 */ s16 isFree; /* 0x4 */ size_t size; - /* 0x8 */ struct ArenaNode_t* next; - /* 0xC */ struct ArenaNode_t* prev; + /* 0x8 */ struct ArenaNode* next; + /* 0xC */ struct ArenaNode* prev; } ArenaNode; // size = 0x10 typedef struct { @@ -1005,22 +1073,18 @@ typedef struct { /* 0x22 */ u8 flag; } Arena; // size = 0x24 -typedef struct FaultAddrConvClient FaultAddrConvClient; - -struct FaultAddrConvClient { - /* 0x0 */ FaultAddrConvClient* next; - /* 0x4 */ FaultAddrConvFunc callback; +typedef struct FaultAddrConvClient { + /* 0x0 */ struct FaultAddrConvClient* next; + /* 0x4 */ void* (*callback)(void*, void*); /* 0x8 */ void* param; -}; // size = 0xC +} FaultAddrConvClient; // size = 0xC -typedef struct FaultClient FaultClient; - -struct FaultClient { - /* 0x0 */ FaultClient* next; - /* 0x4 */ fault_client_func callback; +typedef struct FaultClient { + /* 0x0 */ struct FaultClient* next; + /* 0x4 */ void (*callback)(void*, void*); /* 0x8 */ void* param0; /* 0xC */ void* param1; -}; // size = 0x10 +} FaultClient; // size = 0x10 typedef struct { /* 0x000 */ OSThread thread; @@ -1044,9 +1108,28 @@ typedef struct FireObj FireObj; typedef struct FireObjLight FireObjLight; -typedef struct GameAllocNode { - /* 0x0 */ struct GameAllocNode* next; - /* 0x4 */ struct GameAllocNode* prev; +struct GameState; + +typedef void (*GameStateFunc)(struct GameState* gameState); + +typedef struct { + /* 0x00 */ void* loadedRamAddr; + /* 0x04 */ uintptr_t vromStart; // if applicable + /* 0x08 */ uintptr_t vromEnd; // if applicable + /* 0x0C */ void* vramStart; // if applicable + /* 0x10 */ void* vramEnd; // if applicable + /* 0x14 */ UNK_PTR unk_14; + /* 0x18 */ GameStateFunc init; // initializes and executes the given context + /* 0x1C */ GameStateFunc destroy; // deconstructs the context, and sets the next context to load + /* 0x20 */ UNK_PTR unk_20; + /* 0x24 */ UNK_PTR unk_24; + /* 0x28 */ UNK_TYPE unk_28; + /* 0x2C */ size_t instanceSize; +} GameStateOverlay; // size = 0x30 + +typedef struct GameAllocEntry { + /* 0x0 */ struct GameAllocEntry* next; + /* 0x4 */ struct GameAllocEntry* prev; /* 0x8 */ size_t size; /* 0xC */ u32 unk_0C; } GameAllocEntry; // size = 0x10 @@ -1056,7 +1139,7 @@ typedef struct GameAlloc { /* 0x10 */ GameAllocEntry* head; } GameAlloc; // size = 0x14 -struct GameState { +typedef struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; /* 0x08 */ GameStateFunc destroy; @@ -1070,8 +1153,8 @@ struct GameState { /* 0x9C */ u32 frames; /* 0xA0 */ u8 padA0[0x2]; /* 0xA2 */ u8 framerateDivisor; // game speed? - /* 0xA3 */ UNK_TYPE1 unkA3; -}; // size = 0xA4 + /* 0xA3 */ u8 unk_A3; +} GameState; // size = 0xA4 typedef struct PreNMIContext { /* 0x00 */ GameState state; @@ -1236,30 +1319,6 @@ typedef enum { QUAKE2_SETUP, } Quake2State; -typedef struct IrqMgrClient_t { - /* 0x0 */ struct IrqMgrClient_t* next; - /* 0x4 */ OSMesgQueue* queue; -} IrqMgrClient; // size = 0x8 - -typedef struct { - /* 0x0 */ s16 type; - /* 0x2 */ u8 misc[30]; -} OSScMsg; - -typedef struct { - /* 0x000 */ OSScMsg verticalRetraceMesg; - /* 0x020 */ OSScMsg prenmiMsg; - /* 0x040 */ OSScMsg nmiMsg; - /* 0x060 */ OSMesgQueue irqQueue; - /* 0x078 */ OSMesg irqBuffer[8]; - /* 0x098 */ OSThread thread; - /* 0x248 */ IrqMgrClient* callbacks; - /* 0x24C */ u8 prenmiStage; - /* 0x250 */ OSTime lastPrenmiTime; - /* 0x258 */ OSTimer prenmiTimer; - /* 0x278 */ OSTime lastFrameTime; -} IrqMgr; // size = 0x280 - typedef struct { /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. /* 0x001 */ UNK_TYPE1 pad1[0x13]; @@ -1283,56 +1342,9 @@ typedef struct { /* 0x47F */ UNK_TYPE1 pad47F[0x1]; } PadMgr; // size = 0x480 -#define OS_SC_NEEDS_RDP 0x0001 -#define OS_SC_NEEDS_RSP 0x0002 -#define OS_SC_DRAM_DLIST 0x0004 -#define OS_SC_PARALLEL_TASK 0x0010 -#define OS_SC_LAST_TASK 0x0020 -#define OS_SC_SWAPBUFFER 0x0040 - -#define OS_SC_RCP_MASK 0x0003 -#define OS_SC_TYPE_MASK 0x0007 - -#define OS_SC_DP 0x0001 -#define OS_SC_SP 0x0002 -#define OS_SC_YIELD 0x0010 -#define OS_SC_YIELDED 0x0020 - -typedef struct OSScTask { - /* 0x00 */ struct OSScTask* next; - /* 0x04 */ u32 state; - /* 0x08 */ u32 flags; - /* 0x0C */ CfbInfo* framebuffer; - /* 0x10 */ OSTask list; - /* 0x50 */ OSMesgQueue* msgQ; - /* 0x54 */ OSMesg msg; -} OSScTask; // size = 0x58 - -typedef struct { - /* 0x0000 */ OSMesgQueue interruptQ; - /* 0x0018 */ OSMesg intBuf[64]; - /* 0x0118 */ OSMesgQueue cmdQ; - /* 0x0130 */ OSMesg cmdMsgBuf[8]; - /* 0x0150 */ OSThread thread; - /* 0x0300 */ OSScTask* audioListHead; - /* 0x0304 */ OSScTask* gfxListHead; - /* 0x0308 */ OSScTask* audioListTail; - /* 0x030C */ OSScTask* gfxListTail; - /* 0x0310 */ OSScTask* curRSPTask; - /* 0x0314 */ OSScTask* curRDPTask; - /* 0x0318 */ s32 retraceCount; - /* 0x0318 */ s32 doAudio; - /* 0x0320 */ CfbInfo* curBuf; - /* 0x0324 */ CfbInfo* pendingSwapBuf1; - /* 0x0328 */ CfbInfo* pendingSwapBuf2; - /* 0x032C */ char unk_32C[0x3]; - /* 0x032F */ u8 shouldUpdateVi; - /* 0x0330 */ IrqMgrClient irqClient; -} SchedContext; // size = 0x338 - -typedef struct StackEntry_t { - /* 0x00 */ struct StackEntry_t* next; - /* 0x04 */ struct StackEntry_t* prev; +typedef struct StackEntry { + /* 0x00 */ struct StackEntry* next; + /* 0x04 */ struct StackEntry* prev; /* 0x08 */ u32 head; /* 0x0C */ u32 tail; /* 0x10 */ u32 initValue; diff --git a/spec b/spec index a01dcffdd..f8bdae92b 100644 --- a/spec +++ b/spec @@ -610,11 +610,10 @@ beginseg include "build/data/code/game.bss.o" include "build/src/code/gamealloc.o" include "build/src/code/graph.o" - include "build/data/code/graph.data.o" - include "build/data/code/graph.bss.o" - include "build/src/code/code_80174A40.o" + include "build/src/code/graphalloc.o" include "build/src/code/listalloc.o" include "build/src/code/main.o" + include "build/data/code/main.data.o" include "build/data/code/main.bss.o" include "build/src/code/padmgr.o" include "build/data/code/padmgr.data.o" @@ -635,6 +634,7 @@ beginseg include "build/data/code/sys_matrix.data.o" include "build/data/code/sys_matrix.bss.o" include "build/src/code/sys_ucode.o" + include "build/src/code/code_80182CE0.o" include "build/data/code/code_801D1E70.data.o" include "build/src/code/code_80183070.o" include "build/src/code/c_keyframe.o" diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 5a51b22c8..4ab4ca4e8 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,4 +1,5 @@ #include "global.h" +#include "prevent_bss_reordering.h" UNK_TYPE4 D_8009BE30; UNK_TYPE4 D_8009BE34; @@ -17,7 +18,7 @@ void CIC6105_PrintRomInfo(void) { } void CIC6105_AddRomInfoFaultPage(void) { - Fault_AddClient(&romInfoFaultClient, (fault_client_func)CIC6105_PrintRomInfo, 0, 0); + Fault_AddClient(&romInfoFaultClient, CIC6105_PrintRomInfo, 0, 0); } void CIC6105_RemoveRomInfoFaultPage(void) { diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index 1851d21cb..b32b5aa98 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -33,7 +33,7 @@ void Fault_SleepImpl(u32 duration) { Sleep_Cycles(value); } -void Fault_AddClient(FaultClient* client, fault_client_func callback, void* param0, void* param1) { +void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* param1) { OSIntMask mask; u32 alreadyExists = 0; @@ -104,7 +104,7 @@ void Fault_RemoveClient(FaultClient* client) { } } -void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvFunc callback, void* param) { +void Fault_AddAddrConvClient(FaultAddrConvClient* client, void* callback, void* param) { OSIntMask mask; u32 alreadyExists = 0; @@ -910,8 +910,8 @@ void Fault_HangupFaultClient(const char* arg0, char* arg1) { void Fault_AddHungupAndCrashImpl(const char* arg0, char* arg1) { FaultClient client; - char padd[4]; - Fault_AddClient(&client, (fault_client_func)Fault_HangupFaultClient, (void*)arg0, arg1); + u32 pad; + Fault_AddClient(&client, Fault_HangupFaultClient, (void*)arg0, arg1); *(u32*)0x11111111 = 0; // trigger an exception } diff --git a/src/code/code_80174A40.c b/src/code/code_80174A40.c deleted file mode 100644 index a4daff018..000000000 --- a/src/code/code_80174A40.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80174A40/Graph_GfxPlusOne.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80174A40/Graph_BranchDlist.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80174A40/Graph_DlistAlloc.s") diff --git a/src/code/code_80182CE0.c b/src/code/code_80182CE0.c new file mode 100644 index 000000000..6ff8736e5 --- /dev/null +++ b/src/code/code_80182CE0.c @@ -0,0 +1,7 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80182CE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183020.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183058.s") diff --git a/src/code/game.c b/src/code/game.c index a90fc7ac2..e431fafda 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -5,9 +5,6 @@ f32 gFramerateDivisorF = 1.0f; f32 gFramerateDivisorHalf = 1.0f / 2.0f; f32 gFramerateDivisorThird = 1.0f / 3.0f; -u32 D_801D1510 = 0x0000000A; -u32 D_801D1514[3] = { 0 }; - void Game_UpdateFramerateVariables(s32 divisor) { gFramerateDivisor = divisor; gFramerateDivisorF = (f32)divisor; @@ -104,12 +101,12 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { void GameState_SetFrameBuffer(GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0, NULL); - gSPSegment(POLY_OPA_DISP++, 0xF, gfxCtx->framebuffer); - gSPSegment(POLY_XLU_DISP++, 0, NULL); - gSPSegment(POLY_XLU_DISP++, 0xF, gfxCtx->framebuffer); - gSPSegment(OVERLAY_DISP++, 0, NULL); - gSPSegment(OVERLAY_DISP++, 0xF, gfxCtx->framebuffer); + gSPSegment(POLY_OPA_DISP++, 0x00, NULL); + gSPSegment(POLY_OPA_DISP++, 0x0F, gfxCtx->curFrameBuffer); + gSPSegment(POLY_XLU_DISP++, 0x00, NULL); + gSPSegment(POLY_XLU_DISP++, 0x0F, gfxCtx->curFrameBuffer); + gSPSegment(OVERLAY_DISP++, 0x00, NULL); + gSPSegment(OVERLAY_DISP++, 0x0F, gfxCtx->curFrameBuffer); CLOSE_DISPS(gfxCtx); } @@ -199,8 +196,8 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g gameState->running = 1; gfxCtx->viMode = D_801FBB88; gfxCtx->viConfigFeatures = gViConfigFeatures; - gfxCtx->viConfigXScale = gViConfigXScale; - gfxCtx->viConfigYScale = gViConfigYScale; + gfxCtx->xScale = gViConfigXScale; + gfxCtx->yScale = gViConfigYScale; gameState->nextGameStateInit = NULL; gameState->nextGameStateSize = 0U; @@ -220,14 +217,14 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g func_801773A0(&D_801F7FF0); func_8013ED9C(); - osSendMesg(&gameState->gfxCtx->unk5C, NULL, 1); + osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); } } void GameState_Destroy(GameState* gameState) { func_80172BC0(); func_8019E014(); - osRecvMesg(&gameState->gfxCtx->unk5C, NULL, OS_MESG_BLOCK); + osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); if (gameState->destroy != NULL) { gameState->destroy(gameState); @@ -247,7 +244,7 @@ GameStateFunc GameState_GetNextStateInit(GameState* gameState) { return gameState->nextGameStateInit; } -size_t Game_GetNextStateSize(GameState* gameState) { +size_t GameState_GetNextStateSize(GameState* gameState) { return gameState->nextGameStateSize; } diff --git a/src/code/graph.c b/src/code/graph.c index 428bd8621..7ef1715fd 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,25 +1,388 @@ +#include "prevent_bss_reordering.h" #include "global.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" +#include "overlays/gamestates/ovl_opening/z_opening.h" +#include "overlays/gamestates/ovl_select/z_select.h" +#include "overlays/gamestates/ovl_title/z_title.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FaultClient.s") +FaultAddrConvClient sGraphFaultAddrConvClient; +FaultClient sGraphFaultClient; +GfxMasterList* gGfxMasterDL; +CfbInfo sGraphCfbInfos[3]; +OSTime sGraphTaskStartTime; -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_DlAlloc.s") +void* Graph_FaultClient(void) { + FaultDrawer_DrawText(30, 100, "ShowFrameBuffer PAGE 0/1"); + osViSwapBuffer(SysCfb_GetFbPtr(0)); + osViSetMode(D_801FBB88); + osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF); + Fault_WaitForInput(); + osViSwapBuffer(SysCfb_GetFbPtr(1)); + osViSetMode(D_801FBB88); + osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_InitTHGA.s") +void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size) { + THGA_Ct(arena, buffer, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_GetNextGameState.s") +void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { + GfxPool* pool = &gGfxPools[gfxCtx->gfxPoolIdx % 2]; + gGfxMasterDL = &pool->master; + gSegments[0x0E] = gGfxMasterDL; + + pool->headMagic = GFXPOOL_HEAD_MAGIC; + pool->tailMagic = GFXPOOL_TAIL_MAGIC; + + Graph_InitTHGA(&gfxCtx->polyOpa, pool->polyOpaBuffer, sizeof(pool->polyOpaBuffer)); + Graph_InitTHGA(&gfxCtx->polyXlu, pool->polyXluBuffer, sizeof(pool->polyXluBuffer)); + Graph_InitTHGA(&gfxCtx->overlay, pool->overlayBuffer, sizeof(pool->overlayBuffer)); + Graph_InitTHGA(&gfxCtx->work, pool->workBuffer, sizeof(pool->workBuffer)); + Graph_InitTHGA(&gfxCtx->debug, pool->debugBuffer, sizeof(pool->debugBuffer)); + + gfxCtx->polyOpaBuffer = pool->polyOpaBuffer; + gfxCtx->polyXluBuffer = pool->polyXluBuffer; + gfxCtx->overlayBuffer = pool->overlayBuffer; + gfxCtx->workBuffer = pool->workBuffer; + gfxCtx->debugBuffer = pool->debugBuffer; + + gfxCtx->curFrameBuffer = (u16*)SysCfb_GetFbPtr(gfxCtx->framebufferIdx % 2); + gSegments[0x0F] = gfxCtx->curFrameBuffer; + + gfxCtx->zbuffer = SysCfb_GetZBuffer(); + + gSPBranchList(&gGfxMasterDL->disps[0], pool->polyOpaBuffer); + gSPBranchList(&gGfxMasterDL->disps[1], pool->polyXluBuffer); + gSPBranchList(&gGfxMasterDL->disps[2], pool->overlayBuffer); + gSPBranchList(&gGfxMasterDL->disps[3], pool->workBuffer); + gSPEndDisplayList(&gGfxMasterDL->disps[4]); + gSPBranchList(&gGfxMasterDL->debugDisp[0], pool->debugBuffer); +} + +GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { + GameStateFunc gameStateInit = GameState_GetNextStateInit(gameState); + + if (gameStateInit == (GameStateFunc)TitleSetup_Init) { + return &gGameStateOverlayTable[0]; + } + if (gameStateInit == (GameStateFunc)Select_Init) { + return &gGameStateOverlayTable[1]; + } + if (gameStateInit == (GameStateFunc)Title_Init) { + return &gGameStateOverlayTable[2]; + } + if (gameStateInit == (GameStateFunc)Play_Init) { + return &gGameStateOverlayTable[3]; + } + if (gameStateInit == (GameStateFunc)Opening_Init) { + return &gGameStateOverlayTable[4]; + } + if (gameStateInit == (GameStateFunc)FileChoose_Init) { + return &gGameStateOverlayTable[5]; + } + if (gameStateInit == (GameStateFunc)Daytelop_Init) { + return &gGameStateOverlayTable[6]; + } + return NULL; +} + +#ifdef NON_MATCHING +// Regalloc differences +void* Graph_FaultAddrConvFunc(void* address, void* param) { + u32 addr = address; + GameStateOverlay* gamestateOvl; + u32 ramConv; + u32 ramStart; + u32 diff; + s32 i; + + for (i = 0; i < graphNumGameStates; i++) { + gamestateOvl = &gGameStateOverlayTable[i]; + ramStart = gamestateOvl->loadedRamAddr; + diff = (u32)gamestateOvl->vramEnd - (u32)gamestateOvl->vramStart; + ramConv = (u32)gamestateOvl->vramStart - ramStart; + + if (gamestateOvl->loadedRamAddr != NULL) { + if (addr >= ramStart && addr < ramStart + diff) { + return addr + ramConv; + } + } + } + return NULL; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_Init.s") +void Graph_Init(GraphicsContext* gfxCtx) { + bzero(gfxCtx, sizeof(GraphicsContext)); + gfxCtx->gfxPoolIdx = 0; + gfxCtx->framebufferIdx = 0; + gfxCtx->viMode = NULL; + gfxCtx->viConfigFeatures = gViConfigFeatures; + gfxCtx->xScale = gViConfigXScale; + gfxCtx->yScale = gViConfigYScale; + osCreateMesgQueue(&gfxCtx->queue, gfxCtx->msgBuff, ARRAY_COUNT(gfxCtx->msgBuff)); + Fault_AddClient(&sGraphFaultClient, Graph_FaultClient, NULL, NULL); + Fault_AddAddrConvClient(&sGraphFaultAddrConvClient, Graph_FaultAddrConvFunc, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_Destroy.s") +void Graph_Destroy(GraphicsContext* gfxCtx) { + Fault_RemoveClient(&sGraphFaultClient); + Fault_RemoveAddrConvClient(&sGraphFaultAddrConvClient); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_Render.s") +/** + * Constructs the graphics OSTask and forwards it to the scheduler. + * Waits for up to 3 additional seconds for any current graphics task to complete. + * If it does not signal completion in that time, retry or trigger a crash. + */ +void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { + static s32 retryCount = 10; + static s32 cfbIdx = 0; + OSTask_t* task = &gfxCtx->task.list.t; + OSScTask* scTask = &gfxCtx->task; + OSTimer timer; + OSMesg msg; + CfbInfo* cfb; -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FrameSetup.s") +retry: + osSetTimer(&timer, OS_USEC_TO_CYCLES(3 * 1000 * 1000), 0, &gfxCtx->queue, (OSMesg)666); + osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK); + osStopTimer(&timer); -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_RenderFrame.s") + if (msg == (OSMesg)666) { + osSyncPrintf("GRAPH SP TIMEOUT\n"); + if (retryCount >= 0) { + retryCount--; + Sched_SendGfxCancelMsg(&gSchedContext); + goto retry; + } else { + // graph.c: No more! die! + osSyncPrintf("graph.c:もうダメ!死ぬ!\n"); + Fault_AddHungupAndCrashImpl("RCP is HUNG UP!!", "Oh! MY GOD!!"); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_DoFrame.s") + gfxCtx->masterList = gGfxMasterDL; + if (gfxCtx->callback != NULL) { + gfxCtx->callback(gfxCtx, gfxCtx->callbackParam); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_ThreadEntry.s") + task->type = M_GFXTASK; + task->flags = OS_SC_DRAM_DLIST; + task->ucodeBoot = SysUcode_GetUCodeBoot(); + task->ucodeBootSize = SysUcode_GetUCodeBootSize(); + task->ucode = SysUcode_GetUCode(); + task->ucodeData = SysUcode_GetUCodeData(); + task->ucodeSize = 0x1000; + task->ucodeDataSize = 0x800; + task->dramStack = (u64*)gGfxSPTaskStack; + task->dramStackSize = sizeof(gGfxSPTaskStack); + task->outputBuff = gGfxSPTaskOutputBufferPtr; + task->outputBuffSize = gGfxSPTaskOutputBufferSize; + task->dataPtr = (u64*)gGfxMasterDL; + task->dataSize = 0; + task->yieldDataPtr = (u64*)gGfxSPTaskYieldBuffer; + task->yieldDataSize = sizeof(gGfxSPTaskYieldBuffer); + + scTask->next = NULL; + scTask->flags = OS_SC_RCP_MASK | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK; + + if (SREG(33) & 1) { + SREG(33) &= ~1; + scTask->flags &= ~OS_SC_SWAPBUFFER; + gfxCtx->framebufferIdx--; + } + + scTask->msgQ = &gfxCtx->queue; + scTask->msg = NULL; + + { s32 pad; } + + cfb = &sGraphCfbInfos[cfbIdx]; + cfbIdx = (cfbIdx + 1) % ARRAY_COUNT(sGraphCfbInfos); + + cfb->fb1 = gfxCtx->curFrameBuffer; + cfb->swapBuffer = gfxCtx->curFrameBuffer; + + if (gfxCtx->updateViMode) { + gfxCtx->updateViMode = false; + cfb->viMode = gfxCtx->viMode; + cfb->features = gfxCtx->viConfigFeatures; + cfb->xScale = gfxCtx->xScale; + cfb->yScale = gfxCtx->yScale; + } else { + cfb->viMode = NULL; + } + cfb->unk_10 = 0; + cfb->updateRate = gameState->framerateDivisor; + + scTask->framebuffer = cfb; + + while (gfxCtx->queue.validCount != 0) { + osRecvMesg(&gfxCtx->queue, NULL, OS_MESG_NOBLOCK); + } + + gfxCtx->schedMsgQ = &gSchedContext.cmdQ; + osSendMesg(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK); + Sched_SendEntryMsg(&gSchedContext); +} + +void Graph_UpdateGame(GameState* gameState) { + Game_UpdateInput(gameState); + Game_IncrementFrameCount(gameState); + if (SREG(20) < 3) { + func_8019E014(); + } +} + +/** + * Run the gamestate logic, then finalize the gfx buffer + * and run the graphics task for this frame. + */ +void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { + u32 problem; + + gameState->unk_A3 = 0; + Graph_SetNextGfxPool(gfxCtx); + + Game_Update(gameState); + + OPEN_DISPS(gfxCtx); + + gSPEndDisplayList(WORK_DISP++); + gSPEndDisplayList(POLY_OPA_DISP++); + gSPEndDisplayList(POLY_XLU_DISP++); + gSPEndDisplayList(OVERLAY_DISP++); + gSPEndDisplayList(DEBUG_DISP++); + + CLOSE_DISPS(gfxCtx); + + { + Gfx* gfx = gGfxMasterDL->taskStart; + + gSPSegment(gfx++, 0x0E, gGfxMasterDL); + gSPDisplayList(gfx++, &D_0E000000.disps[3]); + gSPDisplayList(gfx++, &D_0E000000.disps[0]); + gSPDisplayList(gfx++, &D_0E000000.disps[1]); + gSPDisplayList(gfx++, &D_0E000000.disps[2]); + gSPDisplayList(gfx++, &D_0E000000.debugDisp[0]); + + gDPPipeSync(gfx++); + gDPFullSync(gfx++); + gSPEndDisplayList(gfx++); + } + + problem = false; + + { + GfxPool* pool = &gGfxPools[gfxCtx->gfxPoolIdx % 2]; + + if (pool->headMagic != GFXPOOL_HEAD_MAGIC) { + Fault_AddHungupAndCrash("../graph.c", 1054); + } + if (pool->tailMagic != GFXPOOL_TAIL_MAGIC) { + Fault_AddHungupAndCrash("../graph.c", 1066); + } + } + + if (THGA_IsCrash(&gfxCtx->polyOpa)) { + problem = true; + } + if (THGA_IsCrash(&gfxCtx->polyXlu)) { + problem = true; + } + if (THGA_IsCrash(&gfxCtx->overlay)) { + problem = true; + } + if (THGA_IsCrash(&gfxCtx->work)) { + problem = true; + } + if (THGA_IsCrash(&gfxCtx->debug)) { + problem = true; + } + + if (!problem) { + Graph_TaskSet00(gfxCtx, gameState); + gfxCtx->gfxPoolIdx++; + gfxCtx->framebufferIdx++; + } + + { + OSTime time = osGetTime(); + + D_801FBAE8 = sRSPGFXTotalTime; + D_801FBAE0 = gRSPAudioTotalTime; + D_801FBAF0 = gRDPTotalTime; + sRSPGFXTotalTime = 0; + gRSPAudioTotalTime = 0; + gRDPTotalTime = 0; + + if (sGraphTaskStartTime != 0) { + lastRenderFrameDuration = time - sGraphTaskStartTime; + } + sGraphTaskStartTime = time; + } +} + +void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { + gameState->unk_A3 = 0; + + Graph_UpdateGame(gameState); + Graph_ExecuteAndDraw(gfxCtx, gameState); +} + +void Graph_ThreadEntry(void* arg) { + GraphicsContext gfxCtx; + GameStateOverlay* nextOvl = &gGameStateOverlayTable[0]; + GameStateOverlay* ovl; + GameState* gameState; + u32 size; + s32 pad[2]; + + gZBuffer = SystemArena_Malloc(sizeof(*gZBuffer) + sizeof(*gWorkBuffer) + 64 - 1); + gZBuffer = (void*)ALIGN64((u32)gZBuffer); + + gWorkBuffer = (void*)((u8*)gZBuffer + sizeof(*gZBuffer)); + + gGfxSPTaskOutputBuffer2 = gGfxSPTaskOutputBuffer = SystemArena_Malloc(sizeof(*gGfxSPTaskOutputBuffer)); + + gGfxSPTaskOutputBufferEnd = (u8*)gGfxSPTaskOutputBuffer + sizeof(*gGfxSPTaskOutputBuffer); + gGfxSPTaskOutputBufferEnd2 = (u8*)gGfxSPTaskOutputBuffer2 + sizeof(*gGfxSPTaskOutputBuffer2); + + func_80178978(); + Fault_SetFB(D_801FBB90, SCREEN_WIDTH, SCREEN_HEIGHT); + Graph_Init(&gfxCtx); + + while (nextOvl) { + ovl = nextOvl; + + Overlay_LoadGameState(ovl); + + size = ovl->instanceSize; + + func_800809F4(ovl->vromStart); + + gameState = SystemArena_Malloc(size); + + bzero(gameState, size); + GameState_Init(gameState, ovl->init, &gfxCtx); + + while (GameState_IsRunning(gameState)) { + Graph_Update(&gfxCtx, gameState); + } + + nextOvl = Graph_GetNextGameState(gameState); + + if (size) {} + + GameState_Destroy(gameState); + SystemArena_Free(gameState); + + Overlay_FreeGameState(ovl); + } + Graph_Destroy(&gfxCtx); +} diff --git a/src/code/graphalloc.c b/src/code/graphalloc.c new file mode 100644 index 000000000..cbae8ebe4 --- /dev/null +++ b/src/code/graphalloc.c @@ -0,0 +1,29 @@ +#include "global.h" + +Gfx* Graph_GfxPlusOne(Gfx* gfx) { + return &gfx[1]; +} + +Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) { + gSPBranchList(gfx, dst); + return dst; +} + +/** + * Allocates a structure of `size` into the display list buffer`gfx`, + * returning a pointer to the start of the buffer. + * Since the alloc may not itself be display list commands, a BranchList + * command is used to step over this region. + */ +void* Graph_DlistAlloc(Gfx** gfx, size_t size) { + u8* start; + Gfx* end; + + size = ALIGN8(size); + start = (u8*)&(*gfx)[1]; + end = (Gfx*)(start + size); + gSPBranchList(*gfx, end); + + *gfx = end; + return start; +} diff --git a/src/code/sched.c b/src/code/sched.c index a5a3a8558..ecd984b05 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -179,7 +179,7 @@ halt_rdp: if (dpTask->type == M_GFXTASK) { // Try to stop DP osSyncPrintf("DP止めようとします\n"); - bzero(dpTask->output_buff, (u32)dpTask->output_buff_size - (u32)dpTask->output_buff); + bzero(dpTask->outputBuff, (u32)dpTask->outputBuffSize - (u32)dpTask->outputBuff); osSendMesg(&sched->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK); } } @@ -336,8 +336,8 @@ void Sched_RunTask(SchedContext* sched, OSScTask* spTask, OSScTask* dpTask) { if (spTask->list.t.type == M_AUDTASK) { // Set global pointers to audio task data for use in audio processing - gAudioSPDataPtr = spTask->list.t.data_ptr; - gAudioSPDataSize = spTask->list.t.data_size; + gAudioSPDataPtr = spTask->list.t.dataPtr; + gAudioSPDataSize = spTask->list.t.dataSize; } // Begin task execution @@ -527,7 +527,7 @@ void Sched_FaultClient(void* param1, void* param2) { spTask = sched->curRSPTask; if (spTask != NULL) { FaultDrawer_Printf("RSPTask %08x %08x %02x %02x\n%01x %08x %08x\n", spTask, spTask->next, spTask->state, - spTask->flags, spTask->list.t.type, spTask->list.t.data_ptr, spTask->list.t.data_size); + spTask->flags, spTask->list.t.type, spTask->list.t.dataPtr, spTask->list.t.dataSize); } dpTask = sched->curRDPTask; diff --git a/src/code/sys_cmpdma.c b/src/code/sys_cmpdma.c index c7317a7b7..c670645fc 100644 --- a/src/code/sys_cmpdma.c +++ b/src/code/sys_cmpdma.c @@ -8,9 +8,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_801789D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/get_framebuffer.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/SysCfb_GetFbPtr.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/get_zbuffer.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/SysCfb_GetZBuffer.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178A24.s") diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index a4d5b9379..a09d95200 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -87,11 +87,3 @@ void Matrix_StatePop(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182C90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182CA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182CBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182CCC.s") diff --git a/src/code/sys_ucode.c b/src/code/sys_ucode.c index 973606702..a832f9d38 100644 --- a/src/code/sys_ucode.c +++ b/src/code/sys_ucode.c @@ -1,7 +1,9 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/func_80182CE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/func_80183020.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/func_80183058.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeData.s") diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 324f8df3e..7df67a3b2 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -62,6 +62,6 @@ void TitleSetup_Destroy(GameState* gameState) { } void TitleSetup_Init(GameState* gameState) { - gameState->destroy = &TitleSetup_Destroy; + gameState->destroy = TitleSetup_Destroy; TitleSetup_InitImpl(gameState); } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 8d87e539b..03a362fc6 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -319,7 +319,7 @@ void Actor_SetScale(Actor* actor, f32 scale) { void Actor_SetObjectSegment(GlobalContext* globalCtx, Actor* actor) { // TODO: Segment number enum - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); } #if 0 diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index cf27d2251..f293c81c2 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -50,7 +50,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur SkinMatrix_SetScale(&mfScale, scale, scale, scale); SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->mf_187FC, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); - gSegments[6] = PHYSICAL_TO_VIRTUAL(object); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index df55d2488..0e9c435c6 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -19,7 +19,7 @@ void PreNMI_Update(PreNMIContext* prenmiCtx) { void PreNMI_Draw(PreNMIContext* prenmiCtx) { GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx; - func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(gfxCtx); @@ -35,7 +35,7 @@ void PreNMI_Main(PreNMIContext* prenmiCtx) { PreNMI_Update(prenmiCtx); PreNMI_Draw(prenmiCtx); - prenmiCtx->state.unkA3 = 1; + prenmiCtx->state.unk_A3 = 1; } void PreNMI_Destroy(PreNMIContext* prenmiCtx) { diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 0498885a0..09e026e8f 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -762,7 +762,7 @@ Gfx sFillSetupDL[] = { G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2), gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH), - gsSPDisplayList(&D_0E0001C8), + gsSPDisplayList(D_0E000000.setScissor), gsDPSetBlendColor(0x00, 0x00, 0x00, 0x08), gsSPClipRatio(FRUSTRATIO_2), gsSPEndDisplayList(), @@ -1223,82 +1223,110 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 } #ifdef NON_MATCHING -// regalloc, some reorderings -void func_8012CF0C(GraphicsContext* gfxCtx, s32 iParm2, s32 iParm3, u8 r, u8 g, u8 b) { +// Regalloc differences, minor reorderings +void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { + Gfx* masterGfx; + void* zbuffer; s32 i; - Gfx* gfx; - gSegments[0] = 0; - gSegments[14] = (u32)graphDlEntry; - gSegments[15] = (u32)gfxCtx->framebuffer; + gSegments[0x00] = 0; + gSegments[0x0F] = gfxCtx->curFrameBuffer; + gSegments[0x0E] = gGfxMasterDL; - gfx = graphDlEntry + 0x16; - gSPDisplayList(gfx + 0, &D_0E000140); - gSPDisplayList(gfx + 1, &sFillSetupDL); - gDPSetColorImage(gfx + 2, G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, 0x0F000000); - if (gfxCtx->zbuffer != NULL) { - gDPSetDepthImage(gfx + 3, gfxCtx->zbuffer); + zbuffer = gfxCtx->zbuffer; + + // Set up Framebuffer and Z-Buffer + + masterGfx = gGfxMasterDL->setupBuffers; + + gSPDisplayList(&masterGfx[0], D_0E000000.syncSegments); + gSPDisplayList(&masterGfx[1], sFillSetupDL); + gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + if (zbuffer != NULL) { + gDPSetDepthImage(&masterGfx[3], zbuffer); } else { - gDPSetDepthImage(gfx + 3, 0x0F000000); + gDPSetDepthImage(&masterGfx[3], &D_0F000000); } - gSPEndDisplayList(gfx + 4); + gSPEndDisplayList(&masterGfx[4]); - gfx = graphDlEntry + 0x39; - gDPSetScissor(gfx + 0, G_SC_NON_INTERLACE, 0, 0, D_801FBBCC, D_801FBBCE); - gSPEndDisplayList(gfx + 1); + // Set Scissor - gfx = graphDlEntry + 0x9; - if (gfxCtx->zbuffer == NULL) { - gSPEndDisplayList(gfx + 0); + masterGfx = gGfxMasterDL->setScissor; + + gDPSetScissor(&masterGfx[0], G_SC_NON_INTERLACE, 0, 0, D_801FBBCC, D_801FBBCE); + gSPEndDisplayList(&masterGfx[1]); + + // Clear Z-Buffer + + masterGfx = gGfxMasterDL->clearZBuffer; + + if (zbuffer == NULL) { + gSPEndDisplayList(&masterGfx[0]); } else { - gDPSetColorImage(gfx + 0, G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, gfxCtx->zbuffer); - gDPPipeSync(gfx + 1); - gDPSetCycleType(gfx + 2, G_CYC_FILL); - gDPSetRenderMode(gfx + 3, G_RM_NOOP, G_RM_NOOP2); - gDPSetFillColor(gfx + 4, (GPACK_RGBA5551(0xFF, 0xFF, 0xF0, 0) << 16) | GPACK_RGBA5551(0xFF, 0xFF, 0xF0, 0)); - gSPDisplayList(gfx + 5, &D_0E0002C8); - gDPSetColorImage(gfx + 6, G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, gfxCtx->zbuffer); - gSPEndDisplayList(gfx + 7); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gDPPipeSync(&masterGfx[1]); + gDPSetCycleType(&masterGfx[2], G_CYC_FILL); + gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); + gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gSPEndDisplayList(&masterGfx[7]); } - gfx = graphDlEntry + 0x11; - gDPSetColorImage(gfx + 0, G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, 0x0F000000); - gDPSetCycleType(gfx + 1, G_CYC_FILL); - gDPSetRenderMode(gfx + 2, G_RM_NOOP, G_RM_NOOP2); - gDPSetFillColor(gfx + 3, GPACK_RGBA5551(r, g, b, 0)); - gSPBranchList(gfx + 4, &D_0E0002C8); + // Clear Framebuffer - gfx = graphDlEntry + 0x59; - gDPFillRectangle(gfx + 0, 0, 0, D_801FBBCC - 1, D_801FBBCE - 1); - gDPPipeSync(gfx + 1); - gSPEndDisplayList(gfx + 2); + masterGfx = gGfxMasterDL->clearFrameBuffer; - gfx = graphDlEntry + 0x5C; - gDPFillRectangle(gfx + 0, 0, 0, D_801FBBCC, D_801FBBCE); - gDPPipeSync(gfx + 1); - gSPEndDisplayList(gfx + 2); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetCycleType(&masterGfx[1], G_CYC_FILL); + gDPSetRenderMode(&masterGfx[2], G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(&masterGfx[3], (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); + gSPBranchList(&masterGfx[4], D_0E000000.clearFillRect); - gfx = graphDlEntry + 0x28; - for (i = 0; i < 0x10; i++) { - if (i == 0xE) { - gSPNoOp(gfx + i); + // Fillrect used by the above buffer clearing routines + + masterGfx = gGfxMasterDL->clearFillRect; + + gDPFillRectangle(&masterGfx[0], 0, 0, D_801FBBCC - 1, D_801FBBCE - 1); + gDPPipeSync(&masterGfx[1]); + gSPEndDisplayList(&masterGfx[2]); + + // General Fillrect? + + masterGfx = gGfxMasterDL->fillRect; + + gDPFillRectangle(&masterGfx[0], 0, 0, D_801FBBCC, D_801FBBCE); + gDPPipeSync(&masterGfx[1]); + gSPEndDisplayList(&masterGfx[2]); + + // Sync SP Segments with current CPU Segments + + masterGfx = gGfxMasterDL->syncSegments; + + for (i = 0; i < ARRAY_COUNT(gSegments); i++) { + if (i == 0x0E) { + gSPNoOp(&masterGfx[i]); } else { - gSPSegment(gfx + i, i, gSegments[i]); + gSPSegment(&masterGfx[i], i, gSegments[i]); } } - gSPEndDisplayList(gfx + i); + gSPEndDisplayList(&masterGfx[i]); - gSPDisplayList(gfxCtx->polyOpa.p++, graphDlEntry + 0x16); - gSPDisplayList(gfxCtx->polyXlu.p++, graphDlEntry + 0x16); - gSPDisplayList(gfxCtx->overlay.p++, graphDlEntry + 0x16); - gSPDisplayList(gfxCtx->unk1B8.p++, graphDlEntry + 0x16); + OPEN_DISPS(gfxCtx); - if (iParm3) { - gSPDisplayList(gfxCtx->polyOpa.p++, &D_0E000048); + gSPDisplayList(POLY_OPA_DISP++, gGfxMasterDL->setupBuffers); + gSPDisplayList(POLY_XLU_DISP++, gGfxMasterDL->setupBuffers); + gSPDisplayList(OVERLAY_DISP++, gGfxMasterDL->setupBuffers); + gSPDisplayList(DEBUG_DISP++, gGfxMasterDL->setupBuffers); + + if (clearZb) { + gSPDisplayList(gfxCtx->polyOpa.p++, D_0E000000.clearZBuffer); } - if (iParm2) { - gSPDisplayList(gfxCtx->polyOpa.p++, &D_0E000088); + if (clearFb) { + gSPDisplayList(gfxCtx->polyOpa.p++, D_0E000000.clearFrameBuffer); } + + CLOSE_DISPS(gfxCtx); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_rcp/func_8012CF0C.s") @@ -1306,9 +1334,9 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 iParm2, s32 iParm3, u8 r, u8 g, void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { - func_8012CF0C(gfxCtx, 1, 1, r, g, b); + func_8012CF0C(gfxCtx, true, true, r, g, b); } else { - func_8012CF0C(gfxCtx, 0, 0, r, g, b); + func_8012CF0C(gfxCtx, false, false, r, g, b); } } diff --git a/src/code/z_room.c b/src/code/z_room.c index 5163f1f29..fe4b51d68 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -111,7 +111,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { roomCtx->unk31 = 0; roomCtx->currRoom.segment = roomCtx->activeRoomVram; // TODO: Segment number enum - gSegments[3] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); + gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); Scene_ProcessHeader(globalCtx, (SceneCmd*)roomCtx->currRoom.segment); func_80123140(globalCtx, GET_PLAYER(globalCtx)); @@ -137,7 +137,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) { if (room->segment != NULL) { // TODO: Segment number enum - gSegments[3] = PHYSICAL_TO_VIRTUAL(room->segment); + gSegments[0x03] = PHYSICAL_TO_VIRTUAL(room->segment); roomDrawFuncs[room->mesh->type0.type](globalCtx, room, flags); } return; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index b744af5d0..a0be4a75f 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -53,7 +53,7 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP); - gSegments[4] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment); + gSegments[0x04] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment); } void Object_UpdateBank(ObjectContext* objectCtx) { @@ -228,7 +228,7 @@ void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) { if (cmd->specialFiles.subKeepIndex != 0) { globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.subKeepIndex); // TODO: Segment number enum? - gSegments[5] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); + gSegments[0x05] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); } if (cmd->specialFiles.cUpElfMsgNum != 0) { diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 4cd9734f6..c8ab534de 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -210,7 +210,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi OPEN_DISPS(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0xD, mtx); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); Matrix_StatePush(); rootLimb = (LodLimb*)Lib_SegmentedToVirtual(skeleton[0]); @@ -428,7 +428,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi OPEN_DISPS(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0xD, mtx); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); Matrix_StatePush(); @@ -555,7 +555,7 @@ void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); - gSPSegment(POLY_OPA_DISP++, 0xD, mtx); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); Matrix_StatePush(); @@ -822,7 +822,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT mtx = (Mtx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); - gSPSegment(gfx++, 0xD, mtx); + gSPSegment(gfx++, 0x0D, mtx); Matrix_StatePush(); diff --git a/src/libultra/gu/visetevent.c b/src/libultra/gu/visetevent.c index 2d2e4bd3b..3a14ccbc1 100644 --- a/src/libultra/gu/visetevent.c +++ b/src/libultra/gu/visetevent.c @@ -3,7 +3,7 @@ void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount) { register u32 saveMask = __osDisableInt(); - __osViNext->msgq = mq; + __osViNext->mq = mq; __osViNext->msg = m; __osViNext->retraceCount = retraceCount; diff --git a/src/libultra/io/sptask.c b/src/libultra/io/sptask.c index 84a9624fb..0ec16a4c3 100644 --- a/src/libultra/io/sptask.c +++ b/src/libultra/io/sptask.c @@ -13,12 +13,12 @@ OSTask* _VirtualToPhysicalTask(OSTask* intp) { bcopy(intp, tp, sizeof(OSTask)); _osVirtualToPhysical(tp->t.ucode); - _osVirtualToPhysical(tp->t.ucode_data); - _osVirtualToPhysical(tp->t.dram_stack); - _osVirtualToPhysical(tp->t.output_buff); - _osVirtualToPhysical(tp->t.output_buff_size); - _osVirtualToPhysical(tp->t.data_ptr); - _osVirtualToPhysical(tp->t.yield_data_ptr); + _osVirtualToPhysical(tp->t.ucodeData); + _osVirtualToPhysical(tp->t.dramStack); + _osVirtualToPhysical(tp->t.outputBuff); + _osVirtualToPhysical(tp->t.outputBuffSize); + _osVirtualToPhysical(tp->t.dataPtr); + _osVirtualToPhysical(tp->t.yieldDataPtr); return tp; } @@ -27,12 +27,12 @@ void osSpTaskLoad(OSTask* intp) { OSTask* tp = _VirtualToPhysicalTask(intp); if (tp->t.flags & OS_TASK_YIELDED) { - tp->t.ucode_data = tp->t.yield_data_ptr; - tp->t.ucode_data_size = tp->t.yield_data_size; + tp->t.ucodeData = tp->t.yieldDataPtr; + tp->t.ucodeDataSize = tp->t.yieldDataSize; intp->t.flags &= ~OS_TASK_YIELDED; if (tp->t.flags & OS_TASK_LOADABLE) { - tp->t.ucode = HW_REG((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4, u32); + tp->t.ucode = HW_REG((u32)intp->t.yieldDataPtr + OS_YIELD_DATA_SIZE - 4, u32); } } osWritebackDCache(tp, sizeof(OSTask)); @@ -47,7 +47,7 @@ void osSpTaskLoad(OSTask* intp) { while (__osSpDeviceBusy()) { ; } - while (__osSpRawStartDma(1, (void*)SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) { + while (__osSpRawStartDma(1, (void*)SP_IMEM_START, tp->t.ucodeBoot, tp->t.ucodeBootSize) == -1) { ; } } diff --git a/src/libultra/io/vi.c b/src/libultra/io/vi.c index dca456462..4facf48e6 100644 --- a/src/libultra/io/vi.c +++ b/src/libultra/io/vi.c @@ -6,8 +6,8 @@ void __osViInit(void) { __osViNext = &D_80098060[1]; __osViNext->retraceCount = 1; __osViCurr->retraceCount = 1; - __osViNext->framep = (void*)0x80000000; - __osViCurr->framep = (void*)0x80000000; + __osViNext->buffer = (void*)0x80000000; + __osViCurr->buffer = (void*)0x80000000; if (osTvType == 0) { __osViNext->modep = &osViModePalLan1; @@ -18,7 +18,7 @@ void __osViInit(void) { } __osViNext->state = 0x20; - __osViNext->control = __osViNext->modep->comRegs.ctrl; + __osViNext->features = __osViNext->modep->comRegs.ctrl; while (*(vu32*)0xA4400010 > 10) { ; diff --git a/src/libultra/io/vigetnextframebuf.c b/src/libultra/io/vigetnextframebuf.c index dac52e5bd..21fd8ece7 100644 --- a/src/libultra/io/vigetnextframebuf.c +++ b/src/libultra/io/vigetnextframebuf.c @@ -2,13 +2,13 @@ void* osViGetNextFramebuffer(void) { register u32 saveMask; - void* framep; + void* buffer; saveMask = __osDisableInt(); - framep = __osViNext->framep; + buffer = __osViNext->buffer; __osRestoreInt(saveMask); - return framep; + return buffer; } diff --git a/src/libultra/io/visetmode.c b/src/libultra/io/visetmode.c index f839875b3..6953bf63b 100644 --- a/src/libultra/io/visetmode.c +++ b/src/libultra/io/visetmode.c @@ -7,7 +7,7 @@ void osViSetMode(OSViMode* modep) { __osViNext->modep = modep; __osViNext->state = 1; - __osViNext->control = __osViNext->modep->comRegs.ctrl; + __osViNext->features = __osViNext->modep->comRegs.ctrl; __osRestoreInt(saveMask); } diff --git a/src/libultra/io/visetspecial.c b/src/libultra/io/visetspecial.c index 37d510ed3..6e7a6ac43 100644 --- a/src/libultra/io/visetspecial.c +++ b/src/libultra/io/visetspecial.c @@ -4,33 +4,33 @@ void osViSetSpecialFeatures(u32 func) { register u32 saveMask = __osDisableInt(); if (func & 1) { - __osViNext->control |= 8; + __osViNext->features |= 8; } if (func & 2) { - __osViNext->control &= ~8; + __osViNext->features &= ~8; } if (func & 4) { - __osViNext->control |= 4; + __osViNext->features |= 4; } if (func & 8) { - __osViNext->control &= ~4; + __osViNext->features &= ~4; } if (func & 0x10) { - __osViNext->control |= 0x10; + __osViNext->features |= 0x10; } if (func & 0x20) { - __osViNext->control &= ~0x10; + __osViNext->features &= ~0x10; } if (func & 0x40) { - __osViNext->control |= 0x10000; - __osViNext->control &= ~0x300; + __osViNext->features |= 0x10000; + __osViNext->features &= ~0x300; } if (func & 0x80) { - __osViNext->control &= ~0x10000; - __osViNext->control |= __osViNext->modep->comRegs.ctrl & 0x300; + __osViNext->features &= ~0x10000; + __osViNext->features |= __osViNext->modep->comRegs.ctrl & 0x300; } __osViNext->state |= 8; diff --git a/src/libultra/io/viswapbuf.c b/src/libultra/io/viswapbuf.c index 4d5f27788..c60918092 100644 --- a/src/libultra/io/viswapbuf.c +++ b/src/libultra/io/viswapbuf.c @@ -4,7 +4,7 @@ void osViSwapBuffer(void* frameBufPtr) { u32 saveMask = __osDisableInt(); - __osViNext->framep = frameBufPtr; + __osViNext->buffer = frameBufPtr; __osViNext->state |= 0x10; __osRestoreInt(saveMask); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index eb941df6e..4cce3075e 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -39,7 +39,8 @@ const ActorInit Arrow_Fire_InitVars = { extern ColliderQuadInit D_80922230; -extern UNK_TYPE D_0E0002E0; +// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file +extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s") diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index ed513eef3..14bfdce02 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -40,8 +40,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -extern Gfx D_0E0002E0[]; - void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc) { this->actionFunc = actionFunc; } @@ -214,7 +212,7 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { (s32)(150.0f * this->blueingEffectMagnitude) & 0xFF); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); - gSPDisplayList(POLY_XLU_DISP++, D_0E0002E0); + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); } // Draw ice on the arrow diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index e39d08570..6a3b0ed18 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -37,7 +37,8 @@ static InitChainEntry D_809260A0[] = { extern InitChainEntry D_809260A0[]; -extern UNK_TYPE D_0E0002E0; +// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file +extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s") diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 59a39f65a..7fd5c84b8 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -177,7 +177,7 @@ s32 func_80A515C4(EnDnk* this) { void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { if (func_8013D8DC(this->unk_28E, globalCtx) == 1) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index c7f593179..6846bfb92 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -1102,7 +1102,7 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { phi_v0 = &D_04091BE0; } - ptr->unk_20 = gSegments[(phi_v0 * 0x10) >> 0x1C] + (phi_v0 & 0xFFFFFF); + ptr->unk_20 = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(phi_v0)); ptr->unk_00 = true; ptr->unk_04 = *vec; ptr->unk_04.x += randPlusMinusPoint5Scaled(ptr->unk_00 + (this->unk_330 * 4000.0f)); diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h index ba6e2f4f0..7216d00c8 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h @@ -14,7 +14,7 @@ typedef struct { /* 0x14 */ f32 unk_14; /* 0x18 */ f32 unk_18; /* 0x1C */ s16 unk_1C; - /* 0x20 */ s32 unk_20; + /* 0x20 */ void* unk_20; } EnFish2UnkStruct; // size = 0x24 typedef struct EnFish2 { 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 8f79570b6..939d59e22 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1317,7 +1317,7 @@ void EnSob1_Blink(EnSob1* this) { } void EnSob1_ChangeObject(EnSob1* this, GlobalContext* globalCtx) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); } s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { @@ -1335,7 +1335,7 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D208, NULL, this->jointTable, this->morphTable, 20); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &D_0600078C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0600078C), 0, 0.0f); this->actor.draw = EnSob1_DrawZoraShopkeeper; this->changeObjectFunc = EnSob1_ChangeObject; @@ -1343,7 +1343,7 @@ void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011AC8, NULL, this->jointTable, this->morphTable, 18); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &D_060000FC, 1.0f, 0.0f, Animation_GetLastFrame(&D_060000FC), 0, 0.0f); this->actor.draw = EnSob1_DrawGoronShopkeeper; this->changeObjectFunc = EnSob1_ChangeObject; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c index 91293528a..ea1ed9eed 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_80807940.c @@ -12,7 +12,9 @@ extern UNK_TYPE D_0102A6B0; extern UNK_TYPE D_0102B170; extern UNK_TYPE D_010310F0; extern UNK_TYPE D_010311F0; -extern UNK_TYPE D_0E0002E0; + +// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file +extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80807940.s") diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 2e116dd6b..ad9ca6ccf 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -12,7 +12,9 @@ extern UNK_TYPE D_0102A6B0; extern UNK_TYPE D_0102B170; extern UNK_TYPE D_010310F0; extern UNK_TYPE D_010311F0; -extern UNK_TYPE D_0E0002E0; + +// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file +extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BC20.s") diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c index 65d528464..6612d9728 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c @@ -12,7 +12,9 @@ extern UNK_TYPE D_0102A6B0; extern UNK_TYPE D_0102B170; extern UNK_TYPE D_010310F0; extern UNK_TYPE D_010311F0; -extern UNK_TYPE D_0E0002E0; + +// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file +extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80804010.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index ed8637398..f1938cf4c 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -455,7 +455,7 @@ 0x80173360 : "game", 0x80173BF0 : "gamealloc", 0x80173D30 : "graph", - 0x80174A40 : "code_80174A40", + 0x80174A40 : "graphalloc", 0x80174AA0 : "listalloc", 0x80174BF0 : "main", 0x80174F10 : "padmgr", @@ -467,7 +467,8 @@ 0x801795F0 : "sys_math3d", 0x8017FEB0 : "sys_math_atan", 0x80180160 : "sys_matrix", - 0x80182CE0 : "sys_ucode", + 0x80182C90 : "sys_ucode", + 0x80182CE0 : "", 0x80183070 : "code_80183070", 0x801830A0 : "c_keyframe", 0x80185660 : "sys_slowly", @@ -560,7 +561,8 @@ 0x801D0D80 : "z_play_hireso", 0x801D14F0 : "audioMgr", 0x801D1500 : "game", - 0x801D1520 : "graph", + 0x801D1510 : "graph", + 0x801D1520 : "main", 0x801D1530 : "padmgr", 0x801D1540 : "speed_meter", 0x801D1570 : "sys_math", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f55e2c808..910b8c995 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3135,7 +3135,7 @@ 0x80173950:("GameState_Init",), 0x80173A50:("GameState_Destroy",), 0x80173B00:("GameState_GetNextStateInit",), - 0x80173B0C:("Game_GetNextStateSize",), + 0x80173B0C:("GameState_GetNextStateSize",), 0x80173B18:("GameState_IsRunning",), 0x80173B24:("GameState_GetArenaSize",), 0x80173B48:("func_80173B48",), @@ -3145,16 +3145,16 @@ 0x80173CC8:("GameAlloc_Cleanup",), 0x80173D18:("GameAlloc_Init",), 0x80173D30:("Graph_FaultClient",), - 0x80173DAC:("Graph_DlAlloc",), - 0x80173DCC:("Graph_InitTHGA",), + 0x80173DAC:("Graph_InitTHGA",), + 0x80173DCC:("Graph_SetNextGfxPool",), 0x80173F98:("Graph_GetNextGameState",), 0x80174060:("Graph_FaultAddrConvFunc",), 0x801740D0:("Graph_Init",), 0x80174174:("Graph_Destroy",), - 0x801741A8:("Graph_Render",), - 0x801744AC:("Graph_FrameSetup",), - 0x801744F8:("Graph_RenderFrame",), - 0x80174868:("Graph_DoFrame",), + 0x801741A8:("Graph_TaskSet00",), + 0x801744AC:("Graph_UpdateGame",), + 0x801744F8:("Graph_ExecuteAndDraw",), + 0x80174868:("Graph_Update",), 0x801748A0:("Graph_ThreadEntry",), 0x80174A40:("Graph_GfxPlusOne",), 0x80174A4C:("Graph_BranchDlist",), @@ -3229,8 +3229,8 @@ 0x80178818:("func_80178818",), 0x80178978:("func_80178978",), 0x801789D4:("func_801789D4",), - 0x801789EC:("get_framebuffer",), - 0x80178A14:("get_zbuffer",), + 0x801789EC:("SysCfb_GetFbPtr",), + 0x80178A14:("SysCfb_GetZBuffer",), 0x80178A24:("func_80178A24",), 0x80178A34:("func_80178A34",), 0x80178A94:("func_80178A94",), @@ -3393,10 +3393,10 @@ 0x801822C4:("func_801822C4",), 0x801823EC:("Matrix_InsertRotationAroundUnitVector_f",), 0x8018284C:("Matrix_InsertRotationAroundUnitVector_s",), - 0x80182C90:("func_80182C90",), - 0x80182CA0:("func_80182CA0",), - 0x80182CBC:("func_80182CBC",), - 0x80182CCC:("func_80182CCC",), + 0x80182C90:("SysUcode_GetUCodeBoot",), + 0x80182CA0:("SysUcode_GetUCodeBootSize",), + 0x80182CBC:("SysUcode_GetUCode",), + 0x80182CCC:("SysUcode_GetUCodeData",), 0x80182CE0:("func_80182CE0",), 0x80183020:("func_80183020",), 0x80183058:("func_80183058",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b71f05517..15026d89f 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2244,8 +2244,6 @@ 0x801D1504:("gFramerateDivisorF","f32","",0x4), 0x801D1508:("gFramerateDivisorHalf","f32","",0x4), 0x801D150C:("gFramerateDivisorThird","f32","",0x4), - 0x801D1510:("D_801D1510","UNK_TYPE4","",0x4), - 0x801D1514:("D_801D1514","UNK_TYPE4","",0x4), 0x801D1520:("gScreenWidth","s32","",0x4), 0x801D1524:("gScreenHeight","s32","",0x4), 0x801D1528:("startHeapSize","UNK_TYPE4","",0x4), @@ -4180,11 +4178,11 @@ 0x801F8020:("D_801F8020","struct_801F8020","",0x10), 0x801F8030:("sMonoColors","VisMono","",0x18), 0x801F8048:("D_801F8048","UNK_TYPE1","",0x1), - 0x801F80D0:("grapgFaultAddrConvClient","FaultAddrConvClient","",0xc), - 0x801F80E0:("graphFaultClient","FaultClient","",0x10), - 0x801F80F0:("graphDlEntry","Gfx*","",0x4), - 0x801F80F8:("D_801F80F8","UNK_TYPE1","",0x1), - 0x801F8150:("lastRenderFrameTimestamp","u64","",0x8), + 0x801F80D0:("sGraphFaultAddrConvClient","FaultAddrConvClient","",0xc), + 0x801F80E0:("sGraphFaultClient","FaultClient","",0x10), + 0x801F80F0:("gGfxMasterDL","Gfx*","",0x4), + 0x801F80F8:("sGraphCfbInfos","UNK_TYPE1","",0x1), + 0x801F8150:("sGraphTaskStartTime","u64","",0x8), 0x801F8160:("sSiIntMsgQ","OSMesgQueue","",0x18), 0x801F8178:("sSiIntMsgBuf","OSMesg","[1]",0x4), 0x801F8180:("gSegments","u32","[16]",0x40), @@ -4227,20 +4225,20 @@ 0x801FBB88:("D_801FBB88","OSViMode*","",0x4), 0x801FBB8C:("gZBufferPtr","u16*","",0x4), 0x801FBB90:("D_801FBB90","UNK_TYPE4","",0x4), - 0x801FBB94:("D_801FBB94","UNK_TYPE1","",0x1), - 0x801FBB98:("D_801FBB98","UNK_TYPE1","",0x1), + 0x801FBB94:("gGfxSPTaskOutputBufferPtr","UNK_TYPE1","",0x1), + 0x801FBB98:("gGfxSPTaskOutputBufferSize","UNK_TYPE1","",0x1), 0x801FBB9C:("D_801FBB9C","UNK_TYPE1","",0x1), 0x801FBBA0:("D_801FBBA0","UNK_TYPE1","",0x1), - 0x801FBBA4:("sys_cfb_zbufl","u16*","",0x4), - 0x801FBBA8:("sys_cfb_wbufl","u16**","",0x4), - 0x801FBBAC:("sys_cfb_fifol","u16**","",0x4), - 0x801FBBB0:("D_801FBBB0","UNK_TYPE1","",0x1), + 0x801FBBA4:("gZBuffer","u16*","",0x4), + 0x801FBBA8:("gWorkBuffer","u16**","",0x4), + 0x801FBBAC:("gGfxSPTaskOutputBuffer","u16**","",0x4), + 0x801FBBB0:("gGfxSPTaskOutputBufferEnd","UNK_TYPE1","",0x1), 0x801FBBB4:("D_801FBBB4","UNK_TYPE1","",0x1), 0x801FBBB8:("D_801FBBB8","UNK_TYPE1","",0x1), 0x801FBBBC:("D_801FBBBC","UNK_TYPE1","",0x1), 0x801FBBC0:("D_801FBBC0","UNK_TYPE1","",0x1), - 0x801FBBC4:("D_801FBBC4","UNK_TYPE1","",0x1), - 0x801FBBC8:("D_801FBBC8","UNK_TYPE1","",0x1), + 0x801FBBC4:("gGfxSPTaskOutputBuffer2","UNK_TYPE1","",0x1), + 0x801FBBC8:("gGfxSPTaskOutputBufferEnd2","UNK_TYPE1","",0x1), 0x801FBBCC:("D_801FBBCC","UNK_TYPE2","",0x2), 0x801FBBCE:("D_801FBBCE","UNK_TYPE2","",0x2), 0x801FBBD0:("D_801FBBD0","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 7243d340d..9737ede4d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -168,8 +168,8 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIceSmoke_Spawn.s,Ef asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIceBlock_Spawn.s,EffectSsIceBlock_Spawn,0x800B326C,0x19 asm/non_matchings/code/flg_set/FlagSet_Update.s,FlagSet_Update,0x800B32D0,0xDD asm/non_matchings/code/flg_set/FlagSet_Draw.s,FlagSet_Draw,0x800B3644,0x8F -asm/non_matchings/code/z_DLF/DLF_LoadGameState.s,DLF_LoadGameState,0x800B3880,0x49 -asm/non_matchings/code/z_DLF/DLF_FreeGameState.s,DLF_FreeGameState,0x800B39A4,0x4B +asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s,Overlay_LoadGameState,0x800B3880,0x49 +asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s,Overlay_FreeGameState,0x800B39A4,0x4B asm/non_matchings/code/z_actor/Actor_PrintLists.s,Actor_PrintLists,0x800B3AD0,0x35 asm/non_matchings/code/z_actor/ActorShape_Init.s,ActorShape_Init,0x800B3BA4,0x9 asm/non_matchings/code/z_actor/ActorShadow_Draw.s,ActorShadow_Draw,0x800B3BC8,0xFE @@ -2646,11 +2646,11 @@ asm/non_matchings/code/game/Game_Update.s,Game_Update,0x8017377C,0x1A asm/non_matchings/code/game/Game_IncrementFrameCount.s,Game_IncrementFrameCount,0x801737E4,0xB asm/non_matchings/code/game/Game_InitHeap.s,Game_InitHeap,0x80173810,0x1C asm/non_matchings/code/game/Game_ResizeHeap.s,Game_ResizeHeap,0x80173880,0x34 -asm/non_matchings/code/game/Game_StateInit.s,Game_StateInit,0x80173950,0x40 -asm/non_matchings/code/game/Game_StateFini.s,Game_StateFini,0x80173A50,0x2C -asm/non_matchings/code/game/Game_GetNextStateInit.s,Game_GetNextStateInit,0x80173B00,0x3 -asm/non_matchings/code/game/Game_GetNextStateSize.s,Game_GetNextStateSize,0x80173B0C,0x3 -asm/non_matchings/code/game/Game_GetShouldContinue.s,Game_GetShouldContinue,0x80173B18,0x3 +asm/non_matchings/code/game/GameState_Init.s,GameState_Init,0x80173950,0x40 +asm/non_matchings/code/game/GameState_Destroy.s,GameState_Destroy,0x80173A50,0x2C +asm/non_matchings/code/game/GameState_GetNextStateInit.s,GameState_GetNextStateInit,0x80173B00,0x3 +asm/non_matchings/code/game/GameState_GetNextStateSize.s,GameState_GetNextStateSize,0x80173B0C,0x3 +asm/non_matchings/code/game/GameState_IsRunning.s,GameState_IsRunning,0x80173B18,0x3 asm/non_matchings/code/game/Game_GetHeapFreeSize.s,Game_GetHeapFreeSize,0x80173B24,0x9 asm/non_matchings/code/game/func_80173B48.s,func_80173B48,0x80173B48,0x2A asm/non_matchings/code/gamealloc/func_80173BF0.s,func_80173BF0,0x80173BF0,0x8 @@ -2659,20 +2659,20 @@ asm/non_matchings/code/gamealloc/Gamealloc_Free.s,Gamealloc_Free,0x80173C7C,0x13 asm/non_matchings/code/gamealloc/Gamealloc_FreeAll.s,Gamealloc_FreeAll,0x80173CC8,0x14 asm/non_matchings/code/gamealloc/Gamealloc_Init.s,Gamealloc_Init,0x80173D18,0x6 asm/non_matchings/code/graph/Graph_FaultClient.s,Graph_FaultClient,0x80173D30,0x1F -asm/non_matchings/code/graph/Graph_DlAlloc.s,Graph_DlAlloc,0x80173DAC,0x8 -asm/non_matchings/code/graph/Graph_InitTHGA.s,Graph_InitTHGA,0x80173DCC,0x73 +asm/non_matchings/code/graph/Graph_InitTHGA.s,Graph_InitTHGA,0x80173DAC,0x8 +asm/non_matchings/code/graph/Graph_SetNextGfxPool.s,Graph_SetNextGfxPool,0x80173DCC,0x73 asm/non_matchings/code/graph/Graph_GetNextGameState.s,Graph_GetNextGameState,0x80173F98,0x32 asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s,Graph_FaultAddrConvFunc,0x80174060,0x1C asm/non_matchings/code/graph/Graph_Init.s,Graph_Init,0x801740D0,0x29 asm/non_matchings/code/graph/Graph_Destroy.s,Graph_Destroy,0x80174174,0xD -asm/non_matchings/code/graph/Graph_Render.s,Graph_Render,0x801741A8,0xC1 -asm/non_matchings/code/graph/Graph_FrameSetup.s,Graph_FrameSetup,0x801744AC,0x13 -asm/non_matchings/code/graph/Graph_RenderFrame.s,Graph_RenderFrame,0x801744F8,0xDC -asm/non_matchings/code/graph/Graph_DoFrame.s,Graph_DoFrame,0x80174868,0xE +asm/non_matchings/code/graph/Graph_TaskSet00.s,Graph_TaskSet00,0x801741A8,0xC1 +asm/non_matchings/code/graph/Graph_UpdateGame.s,Graph_UpdateGame,0x801744AC,0x13 +asm/non_matchings/code/graph/Graph_ExecuteAndDraw.s,Graph_ExecuteAndDraw,0x801744F8,0xDC +asm/non_matchings/code/graph/Graph_Update.s,Graph_Update,0x80174868,0xE asm/non_matchings/code/graph/Graph_ThreadEntry.s,Graph_ThreadEntry,0x801748A0,0x68 -asm/non_matchings/code/code_80174A40/Graph_GfxPlusOne.s,Graph_GfxPlusOne,0x80174A40,0x3 -asm/non_matchings/code/code_80174A40/Graph_BranchDlist.s,Graph_BranchDlist,0x80174A4C,0x6 -asm/non_matchings/code/code_80174A40/Graph_DlistAlloc.s,Graph_DlistAlloc,0x80174A64,0xF +asm/non_matchings/code/graphalloc/Graph_GfxPlusOne.s,Graph_GfxPlusOne,0x80174A40,0x3 +asm/non_matchings/code/graphalloc/Graph_BranchDlist.s,Graph_BranchDlist,0x80174A4C,0x6 +asm/non_matchings/code/graphalloc/Graph_DlistAlloc.s,Graph_DlistAlloc,0x80174A64,0xF asm/non_matchings/code/listalloc/func_80174AA0.s,func_80174AA0,0x80174AA0,0x5 asm/non_matchings/code/listalloc/func_80174AB4.s,func_80174AB4,0x80174AB4,0x1B asm/non_matchings/code/listalloc/func_80174B20.s,func_80174B20,0x80174B20,0x20 @@ -2743,8 +2743,8 @@ asm/non_matchings/code/sys_cmpdma/func_80178750.s,func_80178750,0x80178750,0x32 asm/non_matchings/code/sys_cmpdma/func_80178818.s,func_80178818,0x80178818,0x58 asm/non_matchings/code/sys_cmpdma/func_80178978.s,func_80178978,0x80178978,0x17 asm/non_matchings/code/sys_cmpdma/func_801789D4.s,func_801789D4,0x801789D4,0x6 -asm/non_matchings/code/sys_cmpdma/get_framebuffer.s,get_framebuffer,0x801789EC,0xA -asm/non_matchings/code/sys_cmpdma/get_zbuffer.s,get_zbuffer,0x80178A14,0x4 +asm/non_matchings/code/sys_cmpdma/SysCfb_GetFbPtr.s,SysCfb_GetFbPtr,0x801789EC,0xA +asm/non_matchings/code/sys_cmpdma/SysCfb_GetZBuffer.s,SysCfb_GetZBuffer,0x80178A14,0x4 asm/non_matchings/code/sys_cmpdma/func_80178A24.s,func_80178A24,0x80178A24,0x4 asm/non_matchings/code/sys_cmpdma/func_80178A34.s,func_80178A34,0x80178A34,0x18 asm/non_matchings/code/sys_cmpdma/func_80178A94.s,func_80178A94,0x80178A94,0xB @@ -2907,10 +2907,10 @@ asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 -asm/non_matchings/code/sys_matrix/func_80182C90.s,func_80182C90,0x80182C90,0x4 -asm/non_matchings/code/sys_matrix/func_80182CA0.s,func_80182CA0,0x80182CA0,0x7 -asm/non_matchings/code/sys_matrix/func_80182CBC.s,func_80182CBC,0x80182CBC,0x4 -asm/non_matchings/code/sys_matrix/func_80182CCC.s,func_80182CCC,0x80182CCC,0x5 +asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 +asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 +asm/non_matchings/code/sys_matrix/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 +asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 asm/non_matchings/code/sys_ucode/func_80182CE0.s,func_80182CE0,0x80182CE0,0xD0 asm/non_matchings/code/sys_ucode/func_80183020.s,func_80183020,0x80183020,0xE asm/non_matchings/code/sys_ucode/func_80183058.s,func_80183058,0x80183058,0x6 diff --git a/undefined_syms.txt b/undefined_syms.txt index 088ce83a6..392a5a74e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -4375,6 +4375,9 @@ D_0D003700 = 0x0D003700; // segment 0x0E +D_0E000000 = 0x0E000000; + +// TODO the following are fake and are offsets into the structure at D_0E000000 D_0E000048 = 0x0E000048; D_0E000088 = 0x0E000088; D_0E000140 = 0x0E000140; @@ -4385,7 +4388,6 @@ D_0E0002B0 = 0x0E0002B0; D_0E0002B8 = 0x0E0002B8; D_0E0002C8 = 0x0E0002C8; D_0E0002E0 = 0x0E0002E0; -D_0E0002F8 = 0x0E0002F8; // segment 0x0F From d4effceefd6610b8bb782fec97387ed2340ec4f2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 31 Oct 2021 09:25:10 -0700 Subject: [PATCH 55/86] En_Elforg (Stray Fairy) OK and mostly documented (#359) * Migrate data to C * EnElforg_Init OK * func_80ACC470 OK * EnElforg_Destroy OK * EnElforg_Update OK * func_80ACCBD0 OK * func_80ACCBB8 OK * func_80ACD6EC OK * func_80ACD59C OK * func_80ACD6A8 OK * func_80ACD610 OK * func_80ACD878 OK * Declare animated materials for Elforg * EnElforg_Draw OK * func_80ACCC98 OK * func_80ACC7E4 OK * func_80ACC8D4 OK * func_80ACCEB0 OK * func_80ACC994 OK * PLAYER -> GET_PLAYER * func_80ACCE4C OK * func_80ACC934 OK * func_80ACCAC0 OK * func_80ACD2E4 OK * func_80ACD1F0 OK * func_80ACD164 OK * func_80ACD1B0 OK (maybe fakematch but oh well) * func_80ACD088 OK * Better match for func_80ACD1B0 * Use compiled reloc * Move static data to appropriate function * Name sCylinderInit appropriately * Add explanatory comment * Clean up forward declarations * Add macro for the flag * Macro and enum for type * Add STRAY_FAIRY_GET_PARAM_1C0 macro (no clue what this does) * Document the area stuff * Name some functions * Document timer and direction * Eliminate some early returns * Tons more documentation * Name remaining functions * Document flags * Name targetDistanceFromHome * fairyFountainTimer -> secondaryTimer, since it's used outside of Fairy Fountains * Name the unknown flag * Name the collider fairy type * Last bit of renaming/documenting * Remove zero check * Use hex constant for newAngle * Merge animation updates * Use 0x10000 instead of 65536.0f * Use decimal for alpha * Move yDifference initialization up to the same line as declaration * Use +=/-= * <= 30 instead of < 31 * += -1 -> -- * >= 81 -> > 80 * 0xDFFFFFFF -> ~0x20000000 * EnElforg_InitializeSpeedAndRotation -> EnElforg_InitializeParams --- include/functions.h | 4 +- include/variables.h | 9 +- spec | 3 +- src/boot_O2_g3/CIC6105.c | 1 + src/boot_O2_g3/boot_main.c | 1 + .../actors/ovl_En_Elfbub/z_en_elfbub.c | 3 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 597 +++++++++++++++++- .../actors/ovl_En_Elforg/z_en_elforg.h | 46 +- tools/disasm/functions.txt | 40 +- 9 files changed, 642 insertions(+), 62 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6ba1d1a70..40412e629 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2021,7 +2021,7 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80109EF8(void); // void func_80109F78(void); s32 func_8010A000(GlobalContext* globalCtx); -// void func_8010A074(void); +s32 func_8010A074(GlobalContext* globalCtx); // void func_8010A0A4(void); // void func_8010A0F0(void); // void func_8010A164(void); @@ -2155,7 +2155,7 @@ void func_8011552C(GlobalContext* globalCtx, s16 arg1); // void func_801155B4(void); // void func_80115764(void); void func_80115844(GlobalContext* globalCtx, s16 param_2); -void func_80115908(GlobalContext* globalCtx, u8 param_2); +s32 func_80115908(GlobalContext* globalCtx, u8 param_2); void func_801159c0(s16 param_1); void func_801159EC(s16 arg0); void func_80115A14(s32 arg0, s16 arg1); diff --git a/include/variables.h b/include/variables.h index ffaadaadf..d61be8307 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3972,8 +3972,13 @@ extern UNK_TYPE D_04029140; extern Gfx D_04029CB0[]; extern Gfx D_04029CF0[]; extern UNK_TYPE D_04029D20; -extern UNK_TYPE D_0402B494; -extern UNK_TYPE D_0402C908; +extern AnimationHeader D_0402B494; +extern AnimatedMaterial D_0402C818; +extern AnimatedMaterial D_0402C890; +extern AnimatedMaterial D_0402C908; +extern AnimatedMaterial D_0402C980; +extern AnimatedMaterial D_0402C9F8; +extern FlexSkeletonHeader D_0402CA98; extern Gfx D_0402E510[]; extern UNK_TYPE D_0402E65C; extern UNK_TYPE D_0402F0EC; diff --git a/spec b/spec index f8bdae92b..ce47434ad 100644 --- a/spec +++ b/spec @@ -3577,8 +3577,7 @@ beginseg name "ovl_En_Elforg" compress include "build/src/overlays/actors/ovl_En_Elforg/z_en_elforg.o" - include "build/data/ovl_En_Elforg/ovl_En_Elforg.data.o" - include "build/data/ovl_En_Elforg/ovl_En_Elforg.reloc.o" + include "build/src/overlays/actors/ovl_En_Elforg/ovl_En_Elforg_reloc.o" endseg beginseg diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 4ab4ca4e8..7e9d960bf 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "prevent_bss_reordering.h" diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index ec6b446e7..be281d248 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "prevent_bss_reordering.h" diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index e8145f806..1e87473cd 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -5,6 +5,7 @@ */ #include "z_en_elfbub.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS 0x00000001 @@ -76,7 +77,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { childActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELFORG, this->actor.world.pos.x, this->actor.world.pos.y + 12.0f, this->actor.world.pos.z, this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, - ((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | 2); + ((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_BUBBLE); if (childActor != NULL) { childActor->parent = &this->actor; } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 2302e1cca..3bbe3ba8e 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_elforg.c + * Overlay: ovl_En_Elforg + * Description: Stray Fairy + */ + #include "z_en_elforg.h" #define FLAGS 0x00000010 @@ -9,7 +15,13 @@ void EnElforg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElforg_Update(Actor* thisx, GlobalContext* globalCtx); void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnElforg_TrappedByBubble(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_SetupTrappedByEnemy(EnElforg* this, GlobalContext* globalCtx); +void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx); + const ActorInit En_Elforg_InitVars = { ACTOR_EN_ELFORG, ACTORCAT_ITEMACTION, @@ -22,63 +34,584 @@ const ActorInit En_Elforg_InitVars = { (ActorFunc)EnElforg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ACDA30 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 16, 32, 0, { 0, 0, 0 } }, }; -#endif +void EnElforg_InitializeParams(EnElforg* this) { + this->actor.speedXZ = 1.0f; + this->targetSpeedXZ = 1.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x10000); + this->timer = 0; + this->secondaryTimer = Rand_ZeroFloat(100.0f); + this->actor.shape.yOffset = 0.0f; + this->skelAnime.curFrame = (s32)Rand_ZeroFloat(5.0f); +} -extern ColliderCylinderInit D_80ACDA30; +void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElforg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACC470.s") + Actor_SetScale(&this->actor, 0.01f); + this->flags = 0; + this->direction = 0; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0402CA98, &D_0402B494, this->jointTable, this->jointTable, 10); + this->skelAnime.playSpeed = 1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actor.shape.shadowAlpha = 255; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/EnElforg_Init.s") + switch (STRAY_FAIRY_TYPE(&this->actor)) { + case STRAY_FAIRY_TYPE_CLOCK_TOWN: + if (gSaveContext.weekEventReg[8] & 0x80) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + case STRAY_FAIRY_TYPE_COLLECTIBLE: + if (Actor_GetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + default: + if (Flags_GetSwitch(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + case STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN: + case STRAY_FAIRY_TYPE_BUBBLE: + case STRAY_FAIRY_TYPE_CHEST: + case STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN: + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/EnElforg_Destroy.s") + if (func_8010A074(globalCtx)) { + this->area = gSaveContext.unk_48C8 + 1; + } else { + // Needs to be thisx in order to match + this->area = STRAY_FAIRY_GET_PARAM_1C0(thisx) >> 6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACC7E4.s") + switch (STRAY_FAIRY_TYPE(&this->actor)) { + case STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN: + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_FreeFloatingFairyFountain; + this->targetSpeedXZ = Rand_ZeroFloat(2.0f) + 1.0f; + this->targetDistanceFromHome = Rand_ZeroFloat(100.0f) + 50.0f; + break; + case STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN: + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_TurnInFairy; + this->secondaryTimer = 60; + break; + case STRAY_FAIRY_TYPE_BUBBLE: + this->timer = 0; + this->actionFunc = EnElforg_TrappedByBubble; + break; + case STRAY_FAIRY_TYPE_ENEMY: + this->actionFunc = EnElforg_SetupTrappedByEnemy; + EnElforg_SetupTrappedByEnemy(this, globalCtx); + this->actor.draw = NULL; + break; + case STRAY_FAIRY_TYPE_COLLIDER: + this->actionFunc = EnElforg_HiddenByCollider; + this->actor.draw = NULL; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + break; + default: + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_FreeFloating; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACC8D4.s") + this->actor.shape.rot.y = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACC934.s") +void EnElforg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnElforg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACC994.s") + if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_COLLIDER) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCAC0.s") +void EnElforg_SpawnSparkles(EnElforg* this, GlobalContext* globalCtx, s32 life) { + static Vec3f sVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f sAcceleration = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 sPrimColors[] = { + { 255, 235, 220, 255 }, { 255, 220, 220, 255 }, { 220, 255, 220, 255 }, + { 220, 220, 255, 255 }, { 255, 255, 200, 255 }, + }; + static Color_RGBA8 sEnvColors[] = { + { 255, 150, 0, 255 }, { 255, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 0, 255, 255 }, { 255, 255, 0, 255 }, + }; + Vec3f pos; + s32 pad; + s32 index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCBB8.s") + pos.x = randPlusMinusPoint5Scaled(6.0f) + this->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 6.0f) + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + pos.z = randPlusMinusPoint5Scaled(6.0f) + this->actor.world.pos.z; + index = (this->area < STRAY_FAIRY_AREA_CLOCK_TOWN || this->area >= STRAY_FAIRY_AREA_MAX) + ? STRAY_FAIRY_AREA_CLOCK_TOWN + : this->area; + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], + &sEnvColors[index], 1000, life); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCBD0.s") +void EnElforg_ApproachTargetYPosition(EnElforg* this, Vec3f* targetPos) { + f32 yDifference = targetPos->y - this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCC98.s") + if (fabsf(yDifference) < this->actor.speedXZ) { + this->actor.world.pos.y = targetPos->y; + } else if (yDifference > 0.0f) { + this->actor.world.pos.y += this->actor.speedXZ; + } else { + this->actor.world.pos.y -= this->actor.speedXZ; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCE4C.s") +void EnElforg_ApproachTargetSpeedXZ(EnElforg* this) { + if (this->actor.speedXZ > this->targetSpeedXZ) { + this->actor.speedXZ *= 0.9f; + } else if (this->actor.speedXZ < (this->targetSpeedXZ - 0.1f)) { + this->actor.speedXZ += 0.1f; + } else { + this->actor.speedXZ = this->targetSpeedXZ; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACCEB0.s") +void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { + s32 pad[2]; + f32 xzDistance; + f32 zDifference; + f32 xDifference; + s16 angleAdjustment; + s16 targetAngle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD088.s") + this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer << 9); + EnElforg_ApproachTargetYPosition(this, homePos); + xDifference = this->actor.world.pos.x - homePos->x; + zDifference = this->actor.world.pos.z - homePos->z; + targetAngle = Math_FAtan2F(-zDifference, -xDifference); + xzDistance = sqrtf(SQ(xDifference) + SQ(zDifference)); + if ((this->targetDistanceFromHome + 10.0f) < xzDistance) { + angleAdjustment = 0x1000; + } else if ((this->targetDistanceFromHome - 10.0f) > xzDistance) { + angleAdjustment = 0x6000; + } else { + angleAdjustment = 0x4000; + } + targetAngle += angleAdjustment; + Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 4000, 1000); + EnElforg_ApproachTargetSpeedXZ(this); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD164.s") +/** + * Adjust's the Stray Fairy's speed, rotation, and y-position to bring it + * closer to targetPos. Since it doesn't directly point the fairy towards + * its target, it can take strange paths or even "orbit" the target. + */ +void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { + s16 targetAngle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD1B0.s") + this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer << 9); + EnElforg_ApproachTargetYPosition(this, targetPos); + targetAngle = Math_FAtan2F(-(this->actor.world.pos.z - targetPos->z), -(this->actor.world.pos.x - targetPos->x)); + if (this->targetSpeedXZ > 2.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 0x400, 0x100); + } else { + // If the speed is below a threshold, deliberately mess up the target + // angle so the fairy "orbits" the target instead of reaching it. + targetAngle += 0x2000; + Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 10, 0x200, 0x80); + } + EnElforg_ApproachTargetSpeedXZ(this); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD1F0.s") +void func_80ACCBB8(EnElforg* this, GlobalContext* globalCtx) { + globalCtx->actorCtx.unk5 |= 8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD2E4.s") +void EnElforg_TrappedByBubble(EnElforg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if ((this->actor.parent == NULL) || (this->actor.parent->update == NULL)) { + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_FreeFloating; + } else { + this->actor.shape.yOffset += 10.0f * Math_SinS(this->timer << 9); + this->actor.world.pos = this->actor.parent->world.pos; + this->actor.world.pos.y += 12.0f; + } + func_80ACCBB8(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD59C.s") +void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xzDistToPlayer; + s16 rotationTemp; + s16 newAngle; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD610.s") + // This code makes the fairy briefly circle the player before + // flying towards the fountain's center. + SkelAnime_Update(&this->skelAnime); + this->actor.shape.yOffset *= 0.9f; + this->actor.speedXZ = 5.0f; + EnElforg_ApproachTargetYPosition(this, &player->bodyPartsPos[0]); + xzDistToPlayer = this->actor.xzDistToPlayer; + if (xzDistToPlayer < 0.0f) { + xzDistToPlayer = 10.0f; + } + newAngle = 0x28000 / xzDistToPlayer; + Math_SmoothStepToF(&xzDistToPlayer, 40.0f, 0.2f, 100.0f, 1.0f); + rotationTemp = this->actor.yawTowardsPlayer - newAngle; + this->actor.world.pos.x = player->actor.world.pos.x - (Math_SinS(rotationTemp) * xzDistToPlayer); + this->actor.world.pos.z = player->actor.world.pos.z - (Math_CosS(rotationTemp) * xzDistToPlayer); + EnElforg_SpawnSparkles(this, globalCtx, 16); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD6A8.s") + if (this->secondaryTimer > 0) { + this->secondaryTimer--; + } else { + this->actor.world.rot.y = rotationTemp + 0x4000; + this->timer = 0; + this->secondaryTimer = Rand_ZeroFloat(100.0f); + this->actor.shape.yOffset = 0.0f; + this->targetSpeedXZ = 3.0f; + this->targetDistanceFromHome = 50.0f; + this->actionFunc = EnElforg_FreeFloatingFairyFountain; + this->flags &= ~STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD6EC.s") +void EnElforg_QuicklyCircleFairyFountain(EnElforg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnElforg_MoveToTargetFairyFountain(this, &this->actor.home.pos); + if (this->secondaryTimer <= 30) { + this->actionFunc = EnElforg_TurnInFairy; + } + this->secondaryTimer--; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/EnElforg_Update.s") +void EnElforg_FreeFloatingFairyFountain(EnElforg* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/func_80ACD878.s") + if (this->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME) { + // This happens when "turning in" the last batch of Stray Fairies to + // a Fairy Fountain. The ones being "turned in" will fly very + // quickly to the center of the fountain. + if (this->targetSpeedXZ < 8.0f) { + this->targetSpeedXZ += 0.1f; + } + if (this->targetDistanceFromHome > 0.0f) { + this->targetDistanceFromHome -= 2.0f; + } + } else if ((this->timer & 127) == 127) { + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > 150.0f) { + this->targetSpeedXZ = 5.0f; + } else { + this->targetSpeedXZ = Rand_ZeroFloat(2.0f) + 1.0f; + } + this->targetDistanceFromHome = Rand_ZeroFloat(100.0f) + 50.0f; + } + SkelAnime_Update(&this->skelAnime); + EnElforg_MoveToTargetFairyFountain(this, &this->actor.home.pos); + if (this->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN) { + // A small number of fairies will do this when the player walks into + // the center of the fountain to be healed. + this->actionFunc = EnElforg_QuicklyCircleFairyFountain; + } + if (this->flags & STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS) { + // This happens right before the Great Fairy appears once all + // Stray Fairies are saved. + if (this->actor.home.rot.x > 0) { + EnElforg_SpawnSparkles(this, globalCtx, 10); + this->actor.home.rot.x--; + } + Actor_SetScale(&this->actor, this->actor.scale.x * 0.9f); + if (this->actor.scale.x < 0.001f) { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elforg/EnElforg_Draw.s") +void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { + s32 pad; + Actor* playerActor = &GET_PLAYER(globalCtx)->actor; + Player* player = GET_PLAYER(globalCtx); + f32 distanceFromPlayer; + + if (gSaveContext.playerForm == PLAYER_FORM_GORON) { + distanceFromPlayer = 40.0f; + } else { + distanceFromPlayer = 20.0f; + } + this->actor.world.pos.x = (Math_SinS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.x; + this->actor.world.pos.z = (Math_CosS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.z; + this->actor.world.pos.y = player->bodyPartsPos[0].y; + EnElforg_SpawnSparkles(this, globalCtx, 16); +} + +void EnElforg_FairyCollected(EnElforg* this, GlobalContext* globalCtx) { + EnElforg_CirclePlayer(this, globalCtx); + if (this->timer > 80) { + Actor_MarkForDeath(&this->actor); + return; + } + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); +} + +void EnElforg_SetupFairyCollected(EnElforg* this, GlobalContext* globalCtx) { + Actor* playerActor = &GET_PLAYER(globalCtx)->actor; + Player* player = GET_PLAYER(globalCtx); + + this->actor.world.pos.x = playerActor->world.pos.x; + this->actor.world.pos.y = player->bodyPartsPos[0].y; + this->actor.world.pos.z = playerActor->world.pos.z; + this->actionFunc = EnElforg_FairyCollected; + this->timer = 0; + this->secondaryTimer = 0; + this->actor.shape.yOffset = 0.0f; +} + +void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnElforg_CirclePlayer(this, globalCtx); + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + if (func_800B867C(&this->actor, globalCtx)) { + player->actor.freezeTimer = 0; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + gSaveContext.weekEventReg[8] |= 0x80; + ActorCutscene_Stop(0x7C); + } else { + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + if (ActorCutscene_GetCurrentIndex() != 0x7C) { + if (ActorCutscene_GetCanPlayNext(0x7C)) { + ActorCutscene_Start(0x7C, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(0x7C); + } + } + } +} + +void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { + Vec3f pos; + f32 scaledYDistance; + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (Player_GetMask(globalCtx) == PLAYER_MASK_GREAT_FAIRYS_MASK) { + pos = player->bodyPartsPos[0]; + this->targetSpeedXZ = 5.0f; + EnElforg_MoveToTarget(this, &pos); + } else { + this->targetSpeedXZ = 1.0f; + EnElforg_MoveToTarget(this, &this->actor.home.pos); + } + + scaledYDistance = this->actor.yDistToPlayer - (this->actor.shape.yOffset * this->actor.scale.y); + if (!func_801233E4(globalCtx)) { + if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { + EnElforg_SetupFairyCollected(this, globalCtx); + func_80115908(globalCtx, 48); + switch (STRAY_FAIRY_TYPE(&this->actor)) { + case STRAY_FAIRY_TYPE_COLLECTIBLE: + Actor_SetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + break; + case STRAY_FAIRY_TYPE_CHEST: + Actor_SetChestFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + break; + default: + Actor_SetSwitchFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + break; + } + + if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + func_801518B0(globalCtx, 0x579, NULL); + this->actionFunc = EnElforg_ClockTownFairyCollected; + ActorCutscene_SetIntentToPlay(0x7C); + return; + } + + if (func_8010A074(globalCtx)) { + gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; + func_801518B0(globalCtx, 0x11, NULL); + if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + func_801A3098(0x922); + } + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 7); + func_80ACCBB8(this, globalCtx); + if (Player_GetMask(globalCtx) == PLAYER_MASK_GREAT_FAIRYS_MASK) { + if (!(this->flags & STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED)) { + play_sound(NA_SE_SY_FAIRY_MASK_SUCCESS); + } + this->flags |= STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; + } else { + this->flags &= ~STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED; + } + } +} + +/** + * This finds the enemy that is "holding" the Stray Fairy hostage. When + * this enemy is killed, the Stray Fairy will spawn. This function only + * works if the enemy and the Stray Fairy have the exact same home + * coordinates when the Stray Fairy first spawns. + */ +Actor* EnElforg_GetHoldingEnemy(EnElforg* this, GlobalContext* globalCtx) { + Actor* enemy; + + for (enemy = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { + if ((enemy->home.pos.x == this->actor.home.pos.x) && (enemy->home.pos.y == this->actor.home.pos.y) && + (enemy->home.pos.z == this->actor.home.pos.z)) { + return enemy; + } + } + return NULL; +} + +void EnElforg_TrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { + f32 posTemp; + + if (this->enemy->update == NULL) { + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_FreeFloating; + this->actor.draw = EnElforg_Draw; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + } else { + // The enemy is still alive, so have the Stray Fairy + // track the enemy in case it's moving around. + posTemp = this->enemy->world.pos.x; + this->actor.world.pos.x = posTemp; + this->actor.home.pos.x = posTemp; + posTemp = this->enemy->world.pos.y + 30.0f; + this->actor.world.pos.y = posTemp; + this->actor.home.pos.y = posTemp; + posTemp = this->enemy->world.pos.z; + this->actor.world.pos.z = posTemp; + this->actor.home.pos.z = posTemp; + } + func_80ACCBB8(this, globalCtx); +} + +void EnElforg_SetupTrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { + Actor* enemy = EnElforg_GetHoldingEnemy(this, globalCtx); + + if (enemy != NULL && enemy->update != NULL) { + this->actionFunc = EnElforg_TrappedByEnemy; + this->enemy = enemy; + } +} + +void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + EnElforg_InitializeParams(this); + this->actionFunc = EnElforg_FreeFloating; + this->actor.draw = EnElforg_Draw; + this->actor.world.pos.y += 40.0f; + this->actor.home.pos.y += 40.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + func_80ACCBB8(this, globalCtx); +} + +void EnElforg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElforg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->timer == 0 && this->secondaryTimer > 0) { + this->secondaryTimer--; + } else { + this->timer++; + } + + if (this->direction < 0) { + this->direction++; + if (this->direction == 0) { + this->direction = Rand_ZeroFloat(20.0f) + 20.0f; + } + } else if (this->direction > 0) { + this->direction--; + } else { + this->direction = -Rand_ZeroFloat(20.0f) - 20.0f; + } +} + +s32 EnElforg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + EnElforg* this = THIS; + + if (this->direction < 0) { + if (limbIndex == 9) { + *dList = NULL; + } + } else if (limbIndex == 1) { + *dList = NULL; + } + return 0; +} + +void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElforg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + switch (this->area) { + case STRAY_FAIRY_AREA_WOODFALL: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C908)); + break; + case STRAY_FAIRY_AREA_SNOWHEAD: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C890)); + break; + case STRAY_FAIRY_AREA_GREAT_BAY: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C980)); + break; + case STRAY_FAIRY_AREA_STONE_TOWER: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C9F8)); + break; + default: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C818)); + break; + } + Matrix_InsertMatrix(&globalCtx->mf_187FC, 1); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnElforg_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h index cd3f037bf..5195235a3 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h @@ -3,14 +3,54 @@ #include "global.h" +#define STRAY_FAIRY_TYPE(thisx) ((thisx)->params & 0xF) +#define STRAY_FAIRY_GET_PARAM_1C0(thisx) ((thisx)->params & 0x1C0) +#define STRAY_FAIRY_FLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + +#define STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME (1 << 0) +#define STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS (1 << 1) +#define STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN (1 << 2) +#define STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED (1 << 3) + +typedef enum { + STRAY_FAIRY_TYPE_FREE_FLOATING, // The ones just floating around + STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN, // The ones already present when you enter a Fairy Fountain + STRAY_FAIRY_TYPE_BUBBLE, // The ones trapped in bubbles + STRAY_FAIRY_TYPE_CLOCK_TOWN, // The free-floating Stray Fairies in Clock Town + STRAY_FAIRY_TYPE_ENEMY, // The ones trapped inside enemies + STRAY_FAIRY_TYPE_COLLIDER, // Unused in retail. The fairy is hidden until the collider is hit + STRAY_FAIRY_TYPE_CHEST, // The ones in treasure chests + STRAY_FAIRY_TYPE_COLLECTIBLE, // The ones in boxes, pots, beehives, etc. + STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN // The ones you "turn in" by walking into a Fairy Fountain +} StrayFairyType; + +typedef enum { + STRAY_FAIRY_AREA_CLOCK_TOWN, + STRAY_FAIRY_AREA_WOODFALL, + STRAY_FAIRY_AREA_SNOWHEAD, + STRAY_FAIRY_AREA_GREAT_BAY, + STRAY_FAIRY_AREA_STONE_TOWER, + STRAY_FAIRY_AREA_MAX +} StrayFairyArea; + struct EnElforg; typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); typedef struct EnElforg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE8]; - /* 0x022C */ EnElforgActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[10]; + /* 0x1C4 */ ColliderCylinder collider; + /* 0x210 */ Actor* enemy; + /* 0x214 */ u16 flags; + /* 0x216 */ s16 direction; // negative when facing left, positive when facing right + /* 0x218 */ s16 area; + /* 0x21C */ s32 timer; + /* 0x220 */ s32 secondaryTimer; + /* 0x224 */ f32 targetSpeedXZ; + /* 0x228 */ f32 targetDistanceFromHome; + /* 0x22C */ EnElforgActionFunc actionFunc; } EnElforg; // size = 0x230 extern const ActorInit En_Elforg_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 910b8c995..be268d88a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12075,30 +12075,30 @@ 0x80ACBDFC:("func_80ACBDFC",), 0x80ACBEE0:("ObjAqua_Update",), 0x80ACC048:("ObjAqua_Draw",), - 0x80ACC470:("func_80ACC470",), + 0x80ACC470:("EnElforg_InitializeParams",), 0x80ACC50C:("EnElforg_Init",), 0x80ACC7A4:("EnElforg_Destroy",), - 0x80ACC7E4:("func_80ACC7E4",), - 0x80ACC8D4:("func_80ACC8D4",), - 0x80ACC934:("func_80ACC934",), - 0x80ACC994:("func_80ACC994",), - 0x80ACCAC0:("func_80ACCAC0",), + 0x80ACC7E4:("EnElforg_SpawnSparkles",), + 0x80ACC8D4:("EnElforg_ApproachTargetYPosition",), + 0x80ACC934:("EnElforg_ApproachTargetSpeedXZ",), + 0x80ACC994:("EnElforg_MoveToTargetFairyFountain",), + 0x80ACCAC0:("EnElforg_MoveToTarget",), 0x80ACCBB8:("func_80ACCBB8",), - 0x80ACCBD0:("func_80ACCBD0",), - 0x80ACCC98:("func_80ACCC98",), - 0x80ACCE4C:("func_80ACCE4C",), - 0x80ACCEB0:("func_80ACCEB0",), - 0x80ACD088:("func_80ACD088",), - 0x80ACD164:("func_80ACD164",), - 0x80ACD1B0:("func_80ACD1B0",), - 0x80ACD1F0:("func_80ACD1F0",), - 0x80ACD2E4:("func_80ACD2E4",), - 0x80ACD59C:("func_80ACD59C",), - 0x80ACD610:("func_80ACD610",), - 0x80ACD6A8:("func_80ACD6A8",), - 0x80ACD6EC:("func_80ACD6EC",), + 0x80ACCBD0:("EnElforg_TrappedByBubble",), + 0x80ACCC98:("EnElforg_TurnInFairy",), + 0x80ACCE4C:("EnElforg_QuicklyCircleFairyFountain",), + 0x80ACCEB0:("EnElforg_FreeFloatingFairyFountain",), + 0x80ACD088:("EnElforg_CirclePlayer",), + 0x80ACD164:("EnElforg_FairyCollected",), + 0x80ACD1B0:("EnElforg_SetupFairyCollected",), + 0x80ACD1F0:("EnElforg_ClockTownFairyCollected",), + 0x80ACD2E4:("EnElforg_FreeFloating",), + 0x80ACD59C:("EnElforg_GetHoldingEnemy",), + 0x80ACD610:("EnElforg_TrappedByEnemy",), + 0x80ACD6A8:("EnElforg_SetupTrappedByEnemy",), + 0x80ACD6EC:("EnElforg_HiddenByCollider",), 0x80ACD798:("EnElforg_Update",), - 0x80ACD878:("func_80ACD878",), + 0x80ACD878:("EnElforg_OverrideLimbDraw",), 0x80ACD8C0:("EnElforg_Draw",), 0x80ACDCD0:("EnElfbub_Init",), 0x80ACDE34:("EnElfbub_Destroy",), From 829d1d4c2a37a1e241d5473782a3319cb08f0625 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 31 Oct 2021 19:07:08 +0000 Subject: [PATCH 56/86] En_Po_Sisters (#345) * En_Po_Sisters * Tharo magic * Rebase * PR * Fix make and actorfixer * Format --- spec | 3 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 1138 ++++++++++++++++- .../ovl_En_Po_Sisters/z_en_po_sisters.h | 30 +- tools/actorfixer.py | 17 + tools/disasm/functions.txt | 4 +- undefined_syms.txt | 8 + 6 files changed, 1125 insertions(+), 75 deletions(-) diff --git a/spec b/spec index ce47434ad..5f3ff06b1 100644 --- a/spec +++ b/spec @@ -3975,8 +3975,7 @@ beginseg name "ovl_En_Po_Sisters" compress include "build/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.o" - include "build/data/ovl_En_Po_Sisters/ovl_En_Po_Sisters.data.o" - include "build/data/ovl_En_Po_Sisters/ovl_En_Po_Sisters.reloc.o" + include "build/src/overlays/actors/ovl_En_Po_Sisters/ovl_En_Po_Sisters_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 50aba0d7b..4ec78d033 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -1,3 +1,9 @@ +/* + * File: z_en_po_sisters.c + * Overlay: ovl_En_Po_Sisters + * Description: Poe Sisters + */ + #include "z_en_po_sisters.h" #define FLAGS 0x00005015 @@ -9,24 +15,69 @@ void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx); void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B1AA88(EnPoSisters* this); void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx); void func_80B1ABB8(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1AC40(EnPoSisters* this); void func_80B1ACB8(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1AE28(EnPoSisters* this); void func_80B1AE3C(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1AF8C(EnPoSisters* this); void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1B0E0(EnPoSisters* this); void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx); void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx); void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1B5B4(EnPoSisters* this); void func_80B1B628(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1B70C(EnPoSisters* this); void func_80B1B7BC(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx); void func_80B1B940(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1BA3C(EnPoSisters* this); void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1BC4C(EnPoSisters* this, GlobalContext* globalCtx); void func_80B1BCA0(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1BCF0(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1BE4C(EnPoSisters* this, s32 arg1); void func_80B1BF2C(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1C030(EnPoSisters* this); void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx); +void func_80B1C2E8(EnPoSisters* this); void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_06000114; +extern AnimationHeader D_060008C0; +extern AnimationHeader D_06000A54; +extern AnimationHeader D_06000D40; +extern AnimationHeader D_0600119C; +extern AnimationHeader D_060014CC; +extern Gfx D_06001CB0[]; +extern Gfx D_06001DE0[]; +extern Gfx D_060027B0[]; +extern Gfx D_06002EB8[]; +extern Gfx D_06002F88[]; +extern Gfx D_06003628[]; +extern Gfx D_06003880[]; +extern Gfx D_06003DC8[]; +extern Gfx D_06004020[]; +extern Gfx D_060046E0[]; +extern SkeletonHeader D_060065C8; + +static Color_RGBA8 D_80B1DA30[] = { + { 255, 170, 255, 255 }, + { 255, 200, 0, 255 }, + { 0, 170, 255, 255 }, + { 170, 255, 0, 255 }, +}; + +static Color_RGBA8 D_80B1DA40[] = { + { 100, 0, 255, 255 }, + { 255, 0, 0, 255 }, + { 0, 0, 255, 255 }, + { 0, 150, 0, 255 }, +}; + const ActorInit En_Po_Sisters_InitVars = { ACTOR_EN_PO_SISTERS, ACTORCAT_ENEMY, @@ -39,18 +90,29 @@ const ActorInit En_Po_Sisters_InitVars = { (ActorFunc)EnPoSisters_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B1DA70 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CBFFFE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CBFFFE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 60, 15, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B1DA9C = { 6, 25, 60, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 6, 25, 60, 50 }; -// static DamageTable sDamageTable = { -static DamageTable D_80B1DAA4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -85,114 +147,1052 @@ static DamageTable D_80B1DAA4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B1DAC4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_STOP), }; -#endif +void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPoSisters* this = THIS; -extern ColliderCylinderInit D_80B1DA70; -extern CollisionCheckInfoInit D_80B1DA9C; -extern DamageTable D_80B1DAA4; -extern InitChainEntry D_80B1DAC4[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_060065C8, &D_060014CC, this->jointTable, this->morphTable, 12); + this->unk_226 = 255; + this->unk_227 = 255; + this->unk_228 = 210; + this->unk_229 = 255; + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, + 0, 0, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_18C = ENPOSISTERS_GET_300(thisx); + this->actor.hintId = this->unk_18C + 80; + this->unk_18D = ENPOSISTERS_GET_C00(thisx); + this->unk_18E = 32; + this->unk_18F = 20; + this->unk_190 = 1; + this->unk_191 = 0x20; + this->unk_2EC = 110.0f; + thisx->flags &= ~1; -extern UNK_TYPE D_06000114; -extern UNK_TYPE D_060008C0; -extern UNK_TYPE D_06000A54; -extern UNK_TYPE D_06000D40; -extern UNK_TYPE D_0600119C; -extern UNK_TYPE D_060014CC; -extern UNK_TYPE D_060027B0; -extern UNK_TYPE D_060046E0; + if (ENPOSISTERS_GET_1000(&this->actor)) { + func_80B1AA88(this); + } else if (this->unk_18C == 0) { + if (this->unk_18D == 0) { + this->actor.colChkInfo.health = 8; + this->collider.info.toucher.damage = 16; + this->collider.base.ocFlags1 = (OC1_TYPE_PLAYER | OC1_ON); + func_80B1BCF0(this, globalCtx); + func_80B1C2E8(this); + } else { + this->actor.flags &= ~(0x4000 | 0x200); + this->collider.info.elemType = ELEMTYPE_UNK4; + this->collider.info.bumper.dmgFlags |= (0x40000 | 0x1); + this->collider.base.ocFlags1 = OC1_NONE; + func_80B1BE4C(this, false); + } + } else { + func_80B1C2E8(this); + } + this->actor.params &= 0xFF; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/EnPoSisters_Init.s") +void EnPoSisters_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPoSisters* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/EnPoSisters_Destroy.s") + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1A648.s") +void func_80B1A648(EnPoSisters* this, s32 arg1, Vec3f* pos) { + s32 i; + Vec3f* ptr; + f32 temp_f20 = arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1A768.s") + for (i = 0; i < this->unk_190; i++) { + ptr = &this->unk_22C[i]; + ptr->x = Math_SinS(this->actor.shape.rot.y + (this->unk_192 * 0x800) + (i * 0x2000)) * (SQ(temp_f20) * 0.1f) + + pos->x; + ptr->z = Math_CosS(this->actor.shape.rot.y + (this->unk_192 * 0x800) + (i * 0x2000)) * (SQ(temp_f20) * 0.1f) + + pos->z; + ptr->y = pos->y + temp_f20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1A894.s") +void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1A9B0.s") + if ((this->unk_18D == 0) || (this->actionFunc != func_80B1B444)) { + if (((player->swordState == 0) || (player->swordAnimation >= 30)) && + ((player->actor.world.pos.y - player->actor.floorHeight) < 1.0f)) { + Math_StepToF(&this->unk_2EC, 110.0f, 3.0f); + } else { + Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); + } + sp20 = this->unk_2EC; + } else if (this->unk_18D != 0) { + sp20 = this->actor.parent->xzDistToPlayer; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AA88.s") + this->actor.world.pos.x = (Math_SinS(BINANG_ROT180(this->actor.shape.rot.y)) * sp20) + player->actor.world.pos.x; + this->actor.world.pos.z = (Math_CosS(BINANG_ROT180(this->actor.shape.rot.y)) * sp20) + player->actor.world.pos.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AAE8.s") +void func_80B1A894(EnPoSisters* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AB5C.s") + Math_ApproachF(&this->actor.world.pos.y, player->actor.world.pos.y + 5.0f, 0.5f, 3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1ABB8.s") + if (this->unk_18E == 0) { + this->unk_18E = 32; + if (this->unk_18E) {} + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AC40.s") + if (this->unk_18E != 0) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1ACB8.s") + this->actor.world.pos.y += (2.0f + (0.5f * Rand_ZeroOne())) * Math_SinS(this->unk_18E * 0x800); + if ((this->unk_229 == 255) && (this->actionFunc != func_80B1B168) && (this->actionFunc != func_80B1B020)) { + if (this->actionFunc == func_80B1B628) { + func_800B9010(&this->actor, NA_SE_EN_PO_AWAY - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AE28.s") +void func_80B1A9B0(EnPoSisters* this, GlobalContext* globalCtx) { + if (this->actor.isTargeted && (this->unk_229 == 255)) { + if (this->unk_18F != 0) { + this->unk_18F--; + } + } else { + this->unk_18F = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AE3C.s") + if (this->unk_229 == 0) { + if (this->unk_194 != 0) { + this->unk_194--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1AF8C.s") + if ((this->actionFunc != func_80B1B020) && (this->actionFunc != func_80B1B168) && + (this->actionFunc != func_80B1B444)) { + if (this->unk_18F == 0) { + func_80B1B70C(this); + } else if ((this->unk_194 == 0) && (this->unk_229 == 0)) { + func_80B1B860(this, globalCtx); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B020.s") +void func_80B1AA88(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060014CC, -3.0f); + this->actor.speedXZ = 0.0f; + this->unk_192 = Rand_S16Offset(100, 50); + this->actionFunc = func_80B1AAE8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B0E0.s") +void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (DECR(this->unk_192) == 0) { + this->unk_192 = Rand_S16Offset(100, 50); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B168.s") +void func_80B1AB5C(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &D_060014CC, -3.0f); + this->unk_192 = Rand_S16Offset(2, 3); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B1ABB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B280.s") +void func_80B1ABB8(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + if (this->unk_192 != 0) { + this->unk_192--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B2F0.s") + if ((this->unk_192 == 0) || (this->actor.xzDistToPlayer < 600.0f)) { + func_80B1AC40(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B3A8.s") +void func_80B1AC40(EnPoSisters* this) { + if (this->actionFunc != func_80B1AE3C) { + Animation_MorphToLoop(&this->skelAnime, &D_06000D40, -3.0f); + } + this->unk_192 = Rand_S16Offset(15, 3); + this->unk_191 |= (0x6 | 0x1); + this->actionFunc = func_80B1ACB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B444.s") +void func_80B1ACB8(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + if (this->unk_192 != 0) { + this->unk_192--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B5B4.s") + if ((this->actor.xzDistToPlayer < 600.0f) && (fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f)) { + func_80B1AE28(this); + } else if ((this->unk_192 == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f)) { + func_80B1AB5C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B628.s") + if (this->actor.bgCheckFlags & 8) { + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 600.0f) { + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B70C.s") +void func_80B1AE28(EnPoSisters* this) { + this->actionFunc = func_80B1AE3C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B7BC.s") +void func_80B1AE3C(EnPoSisters* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B860.s") + SkelAnime_Update(&this->skelAnime); + sp22 = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; + Math_StepToF(&this->actor.speedXZ, 2.0f, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1B940.s") + if (sp22 > 0x3000) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); + } else if (sp22 < -0x3000) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x3000, 0x71C); + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BA3C.s") + if ((this->actor.xzDistToPlayer < 320.0f) && (fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f)) { + func_80B1AF8C(this); + } else if (this->actor.xzDistToPlayer > 720.0f) { + func_80B1AC40(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BA90.s") +void func_80B1AF8C(EnPoSisters* this) { + if (this->unk_229 != 0) { + this->collider.base.colType = COLTYPE_METAL; + this->collider.base.acFlags |= AC_HARD; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BC4C.s") + Animation_MorphToLoop(&this->skelAnime, &D_06000114, -5.0f); + this->actor.speedXZ = 0.0f; + this->unk_192 = Animation_GetLastFrame(&D_06000114.common) * 3 + 3; + this->unk_191 &= ~2; + this->actionFunc = func_80B1B020; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BCA0.s") +void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->unk_192 != 0) { + this->unk_192--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BCF0.s") + this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->unk_192) * 0x180; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BE4C.s") + if ((this->unk_192 == 18) || (this->unk_192 == 7)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + } else if (this->unk_192 == 0) { + func_80B1B0E0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1BF2C.s") +void func_80B1B0E0(EnPoSisters* this) { + this->actor.speedXZ = 5.0f; + if (this->unk_18C == 0) { + this->collider.base.colType = COLTYPE_METAL; + this->collider.base.acFlags |= AC_HARD; + Animation_MorphToLoop(&this->skelAnime, &D_06000114, -5.0f); + } + this->unk_192 = 5; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_191 |= 8; + this->actionFunc = func_80B1B168; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C030.s") +void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + if (this->unk_192 != 0) { + this->unk_192--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C0A4.s") + this->actor.shape.rot.y += (s32)(1152.0f * this->skelAnime.endFrame); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C2E8.s") + if (this->unk_192 == 0) { + s16 rotY = this->actor.shape.rot.y - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C340.s") + if (ABS_ALT(rotY) < 0x1000) { + if (this->unk_18C != 0) { + this->collider.base.colType = COLTYPE_HIT3; + this->collider.base.acFlags &= ~AC_HARD; + func_80B1AC40(this); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + func_80B1BE4C(this, globalCtx); + } + } + } + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C408.s") +void func_80B1B280(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06000D40, -3.0f); + this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + if (this->unk_18C != 0) { + this->collider.base.colType = COLTYPE_HIT3; + this->collider.base.acFlags &= ~AC_HARD; + } + this->actionFunc = func_80B1B2F0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/EnPoSisters_Update.s") +void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y -= (s16)(this->actor.speedXZ * 10.0f * 128.0f); + if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->unk_18C != 0) { + func_80B1AC40(this); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + func_80B1BE4C(this, globalCtx); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1C974.s") +void func_80B1B3A8(EnPoSisters* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_060008C0, -3.0f); + if (this->collider.base.ac != NULL) { + func_800BE504(&this->actor, &this->collider); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1CB44.s") + if (this->unk_18C != 0) { + this->actor.speedXZ = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/func_80B1CD34.s") + this->unk_191 &= ~(0x8 | 0x2 | 0x1); + func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + this->actionFunc = func_80B1B444; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Sisters/EnPoSisters_Draw.s") +void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx) { + s32 temp_f18; + + if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & 0x8000)) { + if (this->actor.colChkInfo.health != 0) { + if (this->unk_18C != 0) { + func_80B1B5B4(this); + } else if (this->unk_18D != 0) { + func_80B1BE4C(this, 0); + } else { + func_80B1BE4C(this, globalCtx); + } + } else { + func_80B1BA3C(this); + } + } + + if (this->unk_18D != 0) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.parent->shape.rot.y, + (this->unk_18D == 2) ? 0x800 : 0x400); + temp_f18 = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; + this->unk_229 = CLAMP(temp_f18, 0, 255); + this->actor.world.pos.y = this->actor.parent->world.pos.y; + func_80B1A768(this, globalCtx); + } else if (this->unk_18C != 0) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + } +} + +void func_80B1B5B4(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06000A54, -3.0f); + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + this->unk_192 = 5; + this->unk_191 |= (0x8 | 0x2 | 0x1); + this->actor.speedXZ = 5.0f; + this->actionFunc = func_80B1B628; +} + +void func_80B1B628(EnPoSisters* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_ScaledStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 0x71C); + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + if (this->unk_192 != 0) { + this->unk_192--; + } + } + + if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_191 |= 2; + func_80B1B70C(this); + } else if ((this->unk_192 == 0) && (this->actor.xzDistToPlayer > 480.0f)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80B1AC40(this); + } +} + +void func_80B1B70C(EnPoSisters* this) { + Animation_Change(&this->skelAnime, &D_0600119C, 1.5f, 0.0f, Animation_GetLastFrame(&D_0600119C.common), 2, -3.0f); + this->unk_194 = 100; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_191 &= ~(0x4 | 0x1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + this->actionFunc = func_80B1B7BC; +} + +void func_80B1B7BC(EnPoSisters* this, GlobalContext* globalCtx) { + s32 temp_f18; + + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_229 = 0; + this->collider.info.bumper.dmgFlags = (0x40000 | 0x1); + func_80B1AC40(this); + } else { + temp_f18 = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; + this->unk_229 = CLAMP(temp_f18, 0, 255); + } +} + +void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &D_0600119C, 1.5f, 0.0f, Animation_GetLastFrame(&D_0600119C.common), 2, -3.0f); + if (this->unk_18C == 0) { + this->unk_2EC = 110.0f; + func_80B1A768(this, globalCtx); + this->unk_229 = 0; + this->actor.draw = EnPoSisters_Draw; + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + this->unk_192 = 15; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + this->unk_191 &= ~0x1; + this->actionFunc = func_80B1B940; +} + +void func_80B1B940(EnPoSisters* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime) != 0) { + this->unk_229 = 255; + if (this->unk_18C != 0) { + this->unk_191 |= 1; + this->collider.info.bumper.dmgFlags = ~(0x8000000 | 0x200000 | 0x100000 | 0x40000 | 0x1); + if (this->unk_192 != 0) { + this->unk_192--; + } + + if (this->unk_192 == 0) { + this->unk_18F = 20; + func_80B1AC40(this); + } + } else { + func_80B1C030(this); + } + } else { + s32 temp_f18 = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; + + this->unk_229 = CLAMP(temp_f18, 0, 255); + if (this->unk_18C == 0) { + func_80B1A768(this, globalCtx); + } + } +} + +void func_80B1BA3C(EnPoSisters* this) { + this->unk_192 = 0; + this->actor.speedXZ = 0.0f; + this->actor.world.pos.y += 42.0f; + this->actor.shape.yOffset = -6000.0f; + this->actor.flags &= ~1; + this->unk_191 = 0; + this->actionFunc = func_80B1BA90; +} + +void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx) { + s32 i; + s32 end = this->unk_190; + + this->unk_192++; + end++; + if (end > ARRAY_COUNT(this->unk_22C)) { + this->unk_190 = 8; + } else { + this->unk_190 = end; + } + + for (end = this->unk_190 - 1; end > 0; end--) { + this->unk_22C[end] = this->unk_22C[end - 1]; + } + + this->unk_22C[0].x = + (Math_SinS((this->actor.shape.rot.y + (this->unk_192 * 0x3000)) - 0x4000) * (3000.0f * this->actor.scale.x)) + + this->actor.world.pos.x; + this->unk_22C[0].z = + (Math_CosS((this->actor.shape.rot.y + (this->unk_192 * 0x3000)) - 0x4000) * (3000.0f * this->actor.scale.x)) + + this->actor.world.pos.z; + if (this->unk_192 < 8) { + this->unk_22C[0].y = this->unk_22C[1].y - 9.0f; + } else { + this->unk_22C[0].y = this->unk_22C[1].y + 2.0f; + if (this->unk_192 >= 16) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { + func_80B1BC4C(this, globalCtx); + } + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; + } + } + + if (this->unk_192 == 16) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + } +} + +void func_80B1BC4C(EnPoSisters* this, GlobalContext* globalCtx) { + this->unk_192 = 0; + this->actor.world.pos.y = this->unk_22C[0].y; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + this->actionFunc = func_80B1BCA0; +} + +void func_80B1BCA0(EnPoSisters* this, GlobalContext* globalCtx) { + this->unk_192++; + if (this->unk_192 == 32) { + Actor_MarkForDeath(&this->actor); + } else { + func_80B1A648(this, this->unk_192, &this->actor.world.pos); + } +} + +void func_80B1BCF0(EnPoSisters* this, GlobalContext* globalCtx) { + Actor* sp4C = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x400); + Actor* sp48 = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x800); + Actor* sp44 = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0xC00); + + if ((sp4C == NULL) || (sp48 == NULL) || (sp44 == NULL)) { + if (sp4C != NULL) { + Actor_MarkForDeath(sp4C); + } + + if (sp48 != NULL) { + Actor_MarkForDeath(sp48); + } + + if (sp44 != NULL) { + Actor_MarkForDeath(sp44); + } + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B1BE4C(EnPoSisters* this, s32 arg1) { + Vec3f sp34; + + this->actor.draw = NULL; + this->actor.flags &= ~1; + this->unk_194 = 100; + this->unk_191 = 0x20; + this->collider.base.colType = COLTYPE_HIT3; + this->collider.base.acFlags &= ~AC_HARD; + if (arg1) { + sp34.x = this->actor.world.pos.x; + sp34.y = this->actor.world.pos.y + 45.0f; + sp34.z = this->actor.world.pos.z; + func_800B3030(arg1, &sp34, &D_801D15B0, &D_801D15B0, 150, 0, 3); + } + Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); + this->actionFunc = func_80B1BF2C; +} + +void func_80B1BF2C(EnPoSisters* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnPoSisters* parent = (EnPoSisters*)this->actor.parent; + + if (this->unk_18D == 0) { + if (this->unk_194 != 0) { + this->unk_194--; + } + + if (this->unk_194 == 0) { + s32 rand = Rand_ZeroFloat(4.0f); + + this->actor.shape.rot.y = (rand * 0x4000) + this->actor.yawTowardsPlayer; + this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; + func_80B1B860(this, globalCtx); + } + } else if (parent->actionFunc == func_80B1B940) { + this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->unk_18D * 0x4000); + this->actor.world.pos.y = player->actor.world.pos.y + 5.0f; + func_80B1B860(this, globalCtx); + } else if (parent->actionFunc == func_80B1BA90) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B1C030(EnPoSisters* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06000D40, -3.0f); + this->unk_229 = 255; + this->unk_192 = 300; + this->unk_194 = 3; + this->unk_191 |= (0x8 | 0x1); + this->actor.flags |= 1; + this->actionFunc = func_80B1C0A4; +} + +void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx) { + EnPoSisters* parent; + + if (this->unk_192 != 0) { + this->unk_192--; + } + + if (this->unk_194 > 0) { + if (this->unk_192 >= 16) { + SkelAnime_Update(&this->skelAnime); + if (this->unk_18D == 0) { + if (ABS_ALT(16 - this->unk_18E) < 14) { + this->actor.shape.rot.y += + (s16)((0x580 - (this->unk_194 * 0x180)) * fabsf(Math_SinS(this->unk_18E * 0x800))); + } + + if ((this->unk_192 >= 284) || (this->unk_192 < 31)) { + this->unk_191 |= 0x40; + } else { + this->unk_191 &= ~0x40; + } + } else { + this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->unk_18D * 0x4000); + } + } + } + + if (this->unk_18D == 0) { + if ((this->unk_192 >= 284) || ((this->unk_192 < 31) && (this->unk_192 >= 16))) { + this->unk_191 |= 0x40; + } else { + this->unk_191 &= ~0x40; + } + } + + if (this->unk_192 == 0) { + if (this->unk_18D == 0) { + func_80B1B0E0(this); + } else { + func_80B1BE4C(this, globalCtx); + } + } else if (this->unk_18D != 0) { + parent = (EnPoSisters*)this->actor.parent; + if (parent->actionFunc == func_80B1B444) { + func_80B1B3A8(this); + } + } else if (this->unk_194 == 0) { + this->unk_194 = -15; + } else if (this->unk_194 < 0) { + this->unk_194++; + if (this->unk_194 == 0) { + func_80B1B0E0(this); + } + } + func_80B1A768(this, globalCtx); +} + +void func_80B1C2E8(EnPoSisters* this) { + Animation_PlayOnce(&this->skelAnime, &D_0600119C); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + this->unk_229 = 0; + this->unk_191 = 0x20; + this->actionFunc = func_80B1C340; +} + +void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_229 = 255; + this->actor.flags |= 1; + this->unk_191 |= (0x10 | 0x8); + if (this->unk_18C == 0) { + func_80B1BE4C(this, globalCtx); + } else { + func_80B1AC40(this); + } + } else { + f32 temp = this->skelAnime.curFrame / this->skelAnime.endFrame; + s32 temp_f16 = 255.0f * temp; + + this->unk_229 = CLAMP(temp_f16, 0, 255); + } +} + +void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + func_800BE258(&this->actor, &this->collider.info); + + if (this->unk_18D != 0) { + ((EnPoSisters*)this->actor.parent)->unk_194--; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + func_80B1BE4C(this, globalCtx); + if (Rand_ZeroOne() < 0.2f) { + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y; + sp3C.z = this->actor.world.pos.z; + Item_DropCollectible(globalCtx, &sp3C, ITEM00_ARROWS_10); + } + } else if (this->collider.base.colType != 9) { + if (this->actor.colChkInfo.damageEffect == 0xF) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_191 |= 2; + func_80B1B860(this, globalCtx); + } else if ((this->unk_18C == 0) && (this->actor.colChkInfo.damageEffect == 0xE) && + (this->actionFunc == func_80B1C0A4)) { + if (this->unk_194 == 0) { + this->unk_194 = -45; + } + } else { + if (Actor_ApplyDamage(&this->actor)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_SISTER_DEAD); + } + + if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2F0 = 4.0f; + this->unk_2F4 = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + func_80B1B3A8(this); + } + } + } +} + +void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPoSisters* this = THIS; + f32 temp_f2; + Vec3f sp40; + s32 sp3C; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_80B1B280(this); + } + + func_80B1C408(this, globalCtx); + if (this->unk_191 & 0x4) { + func_80B1A9B0(this, globalCtx); + } + + this->actionFunc(this, globalCtx); + + if (this->unk_191 & 0x8) { + func_80B1A894(this, globalCtx); + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + + if (this->unk_191 & 0x10) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); + } else { + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 10.0f; + sp40.z = this->actor.world.pos.z; + this->actor.floorHeight = func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &sp40); + } + + this->actor.shape.shadowAlpha = this->unk_229; + Actor_SetHeight(&this->actor, 40.0f); + + if (this->unk_2F0 > 0.0f) { + Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); + if (this->unk_229 != 255) { + temp_f2 = this->unk_229 * (1.0f / 255); + if (temp_f2 < this->unk_229) { + this->unk_2F0 = temp_f2; + } + } + + this->unk_2F4 = (this->unk_2F0 + 1.0f) * 0.25f; + this->unk_2F4 = CLAMP_MAX(this->unk_2F4, 0.5f); + } + + if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + if ((this->actionFunc == func_80B1B168) || (this->actionFunc == func_80B1B020)) { + this->unk_190++; + this->unk_190 = CLAMP_MAX(this->unk_190, ARRAY_COUNT(this->unk_22C)); + } else if (this->actionFunc != func_80B1BA90) { + this->unk_190 = CLAMP_MIN(this->unk_190 - 1, 1); + } + + if (this->actionFunc == func_80B1B168) { + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->unk_191 & 0x1) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actionFunc != func_80B1BF2C) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actionFunc == func_80B1B628) { + this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); + } else if (this->unk_191 & 0x2) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } +} + +void func_80B1C974(EnPoSisters* this) { + if (this->skelAnime.animation == &D_06000114) { + this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 255); + this->unk_227 = CLAMP_MIN(this->unk_227 - 5, 50); + this->unk_228 = CLAMP_MIN(this->unk_228 - 5, 0); + } else if (this->skelAnime.animation == &D_06000A54) { + this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 80); + this->unk_227 = CLAMP_MAX(this->unk_227 + 5, 255); + this->unk_228 = CLAMP_MAX(this->unk_228 + 5, 225); + } else if (this->skelAnime.animation == &D_060008C0) { + if (this->actor.colorFilterTimer & 0x2) { + this->unk_226 = 0; + this->unk_227 = 0; + this->unk_228 = 0; + } else { + this->unk_226 = 80; + this->unk_227 = 255; + this->unk_228 = 225; + } + } else { + this->unk_226 = CLAMP_MAX(this->unk_226 + 5, 255); + this->unk_227 = CLAMP_MAX(this->unk_227 + 5, 255); + + if (this->unk_228 > 210) { + if (this->unk_228 && this->unk_228 && this->unk_228) {} + this->unk_228 = CLAMP_MIN(this->unk_228 - 5, 210); + } else { + this->unk_228 = CLAMP_MAX(this->unk_228 + 5, 210); + } + } +} + +s32 EnPoSisters_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + static Gfx* D_80B1DACC[] = { + D_06001DE0, + D_06002F88, + D_06003628, + D_06003DC8, + }; + static Gfx* D_80B1DADC[] = { + D_06001CB0, + D_06002EB8, + D_06003880, + D_06004020, + }; + static Color_RGBA8 D_80B1DAEC[] = { + { 80, 0, 100, 0 }, + { 80, 15, 0, 0 }, + { 0, 70, 50, 0 }, + { 70, 70, 0, 0 }, + }; + EnPoSisters* this = THIS; + + if ((limbIndex == 1) && (this->unk_191 & 0x40)) { + if (this->unk_192 >= 284) { + rot->x += (this->unk_192 - 284) * 0x1000; + } else { + rot->x += (this->unk_192 - 15) * 0x1000; + } + } + + if ((this->unk_229 == 0) || (limbIndex == 8) || ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8))) { + *dList = NULL; + } else if (limbIndex == 9) { + *dList = D_80B1DACC[this->unk_18C]; + } else if (limbIndex == 10) { + *dList = D_80B1DADC[this->unk_18C]; + + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, this->unk_226, this->unk_227, this->unk_228, this->unk_229); + } else if (limbIndex == 11) { + Color_RGBA8* colour = &D_80B1DAEC[this->unk_18C]; + + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, colour->r, colour->g, colour->b, this->unk_229); + } + + return false; +} + +void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + static Vec3f D_80B1DAFC = { 1000.0f, -1700.0f, 0.0f }; + static s8 D_80B1DB08[] = { + -1, -1, 0, 1, 2, -1, 3, -1, -1, -1, -1, -1, + }; + EnPoSisters* this = THIS; + s32 end; + f32 temp_f2; + + if (D_80B1DB08[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_28C[D_80B1DB08[limbIndex]]); + } else if (limbIndex == 9) { + Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->unk_28C[4]); + Matrix_GetStateTranslationAndScaledY(3000.0f, &this->unk_28C[5]); + } else if (limbIndex == 10) { + Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->unk_28C[6]); + } else if (limbIndex == 11) { + Matrix_GetStateTranslationAndScaledX(3000.0f, &this->unk_28C[7]); + } + + if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, D_060046E0); + } + + if (limbIndex == 8) { + if (this->unk_191 & 0x20) { + for (end = this->unk_190 - 1; end > 0; end--) { + this->unk_22C[end] = this->unk_22C[end - 1]; + } + + Matrix_MultiplyVector3fByState(&D_80B1DAFC, this->unk_22C); + } + + if (this->unk_190 > 0) { + Color_RGBA8* sp38 = &D_80B1DA30[this->unk_18C]; + + temp_f2 = Rand_ZeroFloat(0.3f) + 0.7f; + + if (this->actionFunc == func_80B1BCA0) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->unk_22C[0].x, this->unk_22C[0].y + 15.0f, + this->unk_22C[0].z, sp38->r * temp_f2, sp38->g * temp_f2, sp38->b * temp_f2, + 200); + } else { + Lights_PointGlowSetInfo(&this->lightInfo, this->unk_22C[0].x, this->unk_22C[0].y + 15.0f, + this->unk_22C[0].z, sp38->r * temp_f2, sp38->g * temp_f2, sp38->b * temp_f2, + 200); + } + } else { + Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); + } + + if (!(this->unk_191 & 0x80)) { + Matrix_CopyCurrentState(&this->unk_358); + } + } +} + +void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPoSisters* this = THIS; + Color_RGBA8* temp_s1 = &D_80B1DA40[this->unk_18C]; + Color_RGBA8* temp_s7 = &D_80B1DA30[this->unk_18C]; + s32 pad; + s32 i; + s32 phi_s5; + f32 phi_f20; + s32 pad2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_80B1C974(this); + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if ((this->unk_229 == 255) || (this->unk_229 == 0)) { + gDPSetEnvColor(POLY_OPA_DISP++, this->unk_226, this->unk_227, this->unk_228, this->unk_229); + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + POLY_OPA_DISP = + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_229); + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + POLY_XLU_DISP = + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); + } + + if (!(this->unk_191 & 0x80)) { + Matrix_SetCurrentState(&this->unk_358); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_060027B0); + } + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (globalCtx->gameplayFrames * -20) % 512, + 32, 128)); + gDPSetEnvColor(POLY_XLU_DISP++, temp_s1->r, temp_s1->g, temp_s1->b, temp_s1->a); + + if (this->actionFunc == func_80B1BCA0) { + phi_s5 = (((-this->unk_192 * 255) + 0x1FE0) / 32) & 0xFF; + phi_f20 = 0.0056000003f; + } else { + phi_s5 = 0; + phi_f20 = this->actor.scale.x * 0.5f; + } + + for (i = 0; i < this->unk_190; i++) { + if (this->actionFunc != func_80B1BCA0) { + phi_s5 = ((-i * 31) + 248) & 0xFF; + } + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); + + Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); + Matrix_InsertRotation(0, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + + if (this->actionFunc == func_80B1BA90) { + f32 phi_f0; + + phi_f20 = ((this->unk_192 - i) * 0.025f) + 0.5f; + phi_f0 = CLAMP(phi_f20, 0.5f, 0.8f); + phi_f20 = phi_f0 * 0.007f; + } + Matrix_Scale(phi_f20, phi_f20, phi_f20, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + } + + func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), + this->actor.scale.x * 142.857131958f * this->unk_2F4, 0.0f, this->unk_2F0, 20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 75ad55a00..741ebbcce 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -7,11 +7,37 @@ struct EnPoSisters; typedef void (*EnPoSistersActionFunc)(struct EnPoSisters*, GlobalContext*); +#define ENPOSISTERS_GET_300(thisx) (((thisx)->params >> 8) & 3) +#define ENPOSISTERS_GET_C00(thisx) (((thisx)->params >> 0xA) & 3) +#define ENPOSISTERS_GET_1000(thisx) ((thisx)->params & 0x1000) + typedef struct EnPoSisters { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnPoSistersActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x20C]; + /* 0x018C */ u8 unk_18C; + /* 0x018D */ u8 unk_18D; + /* 0x018E */ u8 unk_18E; + /* 0x018F */ u8 unk_18F; + /* 0x0190 */ u8 unk_190; + /* 0x0191 */ u8 unk_191; + /* 0x0192 */ s16 unk_192; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ Vec3s jointTable[12]; + /* 0x01DE */ Vec3s morphTable[12]; + /* 0x0226 */ u8 unk_226; + /* 0x0227 */ u8 unk_227; + /* 0x0228 */ u8 unk_228; + /* 0x0229 */ u8 unk_229; + /* 0x022C */ Vec3f unk_22C[8]; + /* 0x028C */ Vec3f unk_28C[8]; + /* 0x02EC */ f32 unk_2EC; + /* 0x02F0 */ f32 unk_2F0; + /* 0x02F4 */ f32 unk_2F4; + /* 0x02F8 */ LightNode* lightNode; + /* 0x02FC */ LightInfo lightInfo; + /* 0x030C */ ColliderCylinder collider; + /* 0x0358 */ MtxF unk_358; } EnPoSisters; // size = 0x398 extern const ActorInit En_Po_Sisters_InitVars; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 20b260d33..24e0d0ad5 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -170,6 +170,23 @@ animdict = { "skelanime.prevFrameRot": "skelanime.prevRot", "skelanime.prevFramePos": "skelanime.prevTransl", "skelanime.unk3E": "skelanime.baseTransl", + + "skelAnime.unk03": "skelAnime.taper", + "skelAnime.animCurrentSeg": "skelAnime.animation", + "skelAnime.initialFrame": "skelAnime.startFrame", + "skelAnime.animFrameCount": "skelAnime.endFrame", + "skelAnime.totalFrames": "skelAnime.animLength", + "skelAnime.animCurrentFrame": "skelAnime.curFrame", + "skelAnime.animPlaybackSpeed": "skelAnime.playSpeed", + "skelAnime.limbDrawTbl": "skelAnime.jointTable", + "skelAnime.transitionDrawTbl": "skelAnime.morphTable", + "skelAnime.transCurrentFrame": "skelAnime.morphWeight", + "skelAnime.transitionStep": "skelAnime.morphRate", + "skelAnime.animUpdate": "skelAnime.update", + "skelAnime.flags": "skelAnime.moveFlags", + "skelAnime.prevFrameRot": "skelAnime.prevRot", + "skelAnime.prevFramePos": "skelAnime.prevTransl", + "skelAnime.unk3E": "skelAnime.baseTransl", } def replace_anim(file): diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index be268d88a..c158bd87f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13201,8 +13201,8 @@ 0x80B1C408:("func_80B1C408",), 0x80B1C61C:("EnPoSisters_Update",), 0x80B1C974:("func_80B1C974",), - 0x80B1CB44:("func_80B1CB44",), - 0x80B1CD34:("func_80B1CD34",), + 0x80B1CB44:("EnPoSisters_OverrideLimbDraw",), + 0x80B1CD34:("EnPoSisters_PostLimbDraw",), 0x80B1D484:("EnPoSisters_Draw",), 0x80B1DEB0:("EnPp_Init",), 0x80B1E234:("EnPp_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 392a5a74e..9636e0534 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3186,7 +3186,15 @@ D_06000A54 = 0x06000A54; D_06000D40 = 0x06000D40; D_0600119C = 0x0600119C; D_060014CC = 0x060014CC; +D_06001CB0 = 0x06001CB0; +D_06001DE0 = 0x06001DE0; D_060027B0 = 0x060027B0; +D_06002EB8 = 0x06002EB8; +D_06002F88 = 0x06002F88; +D_06003628 = 0x06003628; +D_06003880 = 0x06003880; +D_06003DC8 = 0x06003DC8; +D_06004020 = 0x06004020; D_060046E0 = 0x060046E0; D_060065C8 = 0x060065C8; From 5a4bceea2c16381f7321bebf60f6199496c51c25 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 1 Nov 2021 14:47:04 +0000 Subject: [PATCH 57/86] En_Wf (#370) * En_Wf * PR * Fix make and actorfixer * Format * Warnings --- include/functions.h | 8 +- spec | 3 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 2 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 1520 +++++++++++++++-- src/overlays/actors/ovl_En_Wf/z_en_wf.h | 26 +- .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h | 3 +- undefined_syms.txt | 6 + 7 files changed, 1457 insertions(+), 111 deletions(-) diff --git a/include/functions.h b/include/functions.h index 40412e629..7f71bc4cb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -881,7 +881,7 @@ void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* acto Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, UNK_TYPE4 arg3); Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2); // void func_800BC4EC(void); -// void func_800BC5B8(void); +s32 func_800BC5B8(GlobalContext* globalCtx, Actor* actor); s32 func_800BC5EC(GlobalContext* globalCtx, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 arg2, GlobalContext* globalCtx); // void func_800BC770(void); @@ -907,12 +907,12 @@ void Actor_Noop(Actor* actor, GlobalContext* globalCtx); void func_800BDFC0(GlobalContext* globalCtx, Gfx* dl); void func_800BE03C(GlobalContext* globalCtx, Gfx* dl); Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3, f32 arg4); -// void func_800BE184(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); +s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3, s32 arg4, s32 arg5); u8 Actor_ApplyDamage(Actor* actor); // returns current health void func_800BE258(Actor* actor, UNK_PTR arg1); void func_800BE2B8(Actor* actor, ColliderJntSph* jntSphere); void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); -void func_800BE3D0(Actor* actor, s16 arg1, s16* arg2); +void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 arg2); @@ -1638,7 +1638,7 @@ void func_800F0390(GlobalContext* globalCtx); void func_800F03C0(GlobalContext* globalCtx); void func_800F048C(GlobalContext* globalCtx, Vec3f* param_2, u8 param_3, u16 param_4, u8 param_5); void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* position, s32 param_3, u16 sfxId); -// void func_800F0590(void); +void func_800F0590(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2, s32 arg3); // void func_800F05C0(void); // void func_800F07C0(void); // void func_800F0888(void); diff --git a/spec b/spec index 5f3ff06b1..bf75a91ed 100644 --- a/spec +++ b/spec @@ -2192,8 +2192,7 @@ beginseg name "ovl_En_Wf" compress include "build/src/overlays/actors/ovl_En_Wf/z_en_wf.o" - include "build/data/ovl_En_Wf/ovl_En_Wf.data.o" - include "build/data/ovl_En_Wf/ovl_En_Wf.reloc.o" + include "build/src/overlays/actors/ovl_En_Wf/ovl_En_Wf_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index ee88a7a31..7a17a27b4 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -1071,7 +1071,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); func_808963B4(this, globalCtx); if (this->actor.bgCheckFlags & 1) { - func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot.x); + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); if (this->unk_2B9 != 0) { this->actor.shape.rot.z = BINANG_ROT180(this->actor.shape.rot.z); } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index cf8edba5a..f46207777 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1,4 +1,12 @@ +/* + * File: z_en_wf.c + * Overlay: ovl_En_Wf + * Description: Wolfos + */ + #include "z_en_wf.h" +#include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #define FLAGS 0x00000415 @@ -9,28 +17,61 @@ void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWf_Update(Actor* thisx, GlobalContext* globalCtx); void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80990F0C(EnWf* this); void func_80990F50(EnWf* this, GlobalContext* globalCtx); +void func_80990FC8(EnWf* this); void func_80991040(EnWf* this, GlobalContext* globalCtx); void func_80991174(EnWf* this, GlobalContext* globalCtx); +void func_80991200(EnWf* this); void func_80991280(EnWf* this, GlobalContext* globalCtx); +void func_80991438(EnWf* this); void func_8099149C(EnWf* this, GlobalContext* globalCtx); +void func_80991738(EnWf* this); void func_8099177C(EnWf* this, GlobalContext* globalCtx); +void func_80991948(EnWf* this); void func_809919F4(EnWf* this, GlobalContext* globalCtx); +void func_80991C04(EnWf* this); void func_80991C80(EnWf* this, GlobalContext* globalCtx); void func_80992068(EnWf* this, GlobalContext* globalCtx); +void func_8099223C(EnWf* this); void func_809922B4(EnWf* this, GlobalContext* globalCtx); void func_809923E4(EnWf* this, GlobalContext* globalCtx); void func_809924EC(EnWf* this, GlobalContext* globalCtx); +void func_809926D0(EnWf* this); void func_80992784(EnWf* this, GlobalContext* globalCtx); +void func_8099282C(EnWf* this); void func_809928CC(EnWf* this, GlobalContext* globalCtx); +void func_80992A74(EnWf* this, GlobalContext* globalCtx); void func_80992B8C(EnWf* this, GlobalContext* globalCtx); +void func_80992D6C(EnWf* this); void func_80992E0C(EnWf* this, GlobalContext* globalCtx); +void func_80992FD4(EnWf* this); void func_80993018(EnWf* this, GlobalContext* globalCtx); +void func_80993148(EnWf* this); void func_80993194(EnWf* this, GlobalContext* globalCtx); +void func_80993350(EnWf* this); void func_809933A0(EnWf* this, GlobalContext* globalCtx); +void func_80993524(EnWf* this); void func_8099357C(EnWf* this, GlobalContext* globalCtx); +s32 func_8099408C(GlobalContext* globalCtx, EnWf* this); + +extern UNK_TYPE D_06000300; +extern UNK_TYPE D_060027D8; +extern UNK_TYPE D_060029D8; +extern FlexSkeletonHeader D_06003BC0; +extern AnimationHeader D_06004638; +extern AnimationHeader D_06004A90; +extern AnimationHeader D_06004C44; +extern AnimationHeader D_060053D0; +extern AnimationHeader D_06005700; +extern UNK_TYPE D_06007AA8; +extern UNK_TYPE D_060082A8; +extern UNK_TYPE D_060084A8; +extern FlexSkeletonHeader D_060095D0; +extern AnimationHeader D_06009808; +extern AnimationHeader D_06009A50; +extern AnimationHeader D_0600A3CC; -#if 0 const ActorInit En_Wf_InitVars = { ACTOR_EN_WF, ACTORCAT_PROP, @@ -43,48 +84,107 @@ const ActorInit En_Wf_InitVars = { (ActorFunc)EnWf_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[4] = { -static ColliderJntSphElementInit D_80994170[4] = { +static ColliderJntSphElementInit sJntSphElementsInit[4] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 15, { { 0, 0, 0 }, 15 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 21, { { 0, 0, 0 }, 15 }, 100 }, }, { - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 17, { { 800, 0, 0 }, 25 }, 100 }, }, { - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80994200 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 4, D_80994170, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 4, + sJntSphElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80994210 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8099423C = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 15, 20, -15, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80994268 = { +static DamageTable sDamageTable1 = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -119,8 +219,7 @@ static DamageTable D_80994268 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static DamageTable sDamageTable = { -static DamageTable D_80994288 = { +static DamageTable sDamageTable2 = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -155,145 +254,1364 @@ static DamageTable D_80994288 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809942A8 = { 8, 50, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 8, 50, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809942D0[] = { +static UNK_TYPE D_809942B0[] = { + &D_06007AA8, + &D_060082A8, + &D_060084A8, + &D_060082A8, +}; + +static UNK_TYPE D_809942C0[] = { + &D_06000300, + &D_060027D8, + &D_060029D8, + &D_060027D8, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -#endif +static s32 D_809942D8 = 0; -extern ColliderJntSphElementInit D_80994170[4]; -extern ColliderJntSphInit D_80994200; -extern ColliderCylinderInit D_80994210; -extern ColliderCylinderInit D_8099423C; -extern DamageTable D_80994268; -extern DamageTable D_80994288; -extern CollisionCheckInfoInit D_809942A8; -extern InitChainEntry D_809942D0[]; +void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWf* this = THIS; + s32 i; + s32 temp_s0; -extern UNK_TYPE D_06004638; -extern UNK_TYPE D_06004A90; -extern UNK_TYPE D_06004C44; -extern UNK_TYPE D_060053D0; -extern UNK_TYPE D_06005700; -extern UNK_TYPE D_06009808; -extern UNK_TYPE D_06009A50; -extern UNK_TYPE D_0600A3CC; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 70.0f); + this->actor.shape.shadowAlpha = 150; + Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider3, &this->actor, &sCylinderInit2); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/EnWf_Init.s") + if (this->actor.shape.rot.x <= 0) { + this->unk_2A8 = 10000.0f; + } else { + this->unk_2A8 = this->actor.shape.rot.x * 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/EnWf_Destroy.s") + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809907D4.s") + if (ENWF_GET_80(&this->actor)) { + this->unk_295 = true; + } else { + this->unk_295 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990854.s") + if (this->unk_295) { + temp_s0 = this->actor.shape.rot.z + 100; + temp_s0 = CLAMP(temp_s0, 1, 255); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + this->actor.child = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + temp_s0 | 0xFF00); + if (this->actor.child != NULL) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809908E0.s") + this->actor.child->xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->unk_2A4 = (temp_s0 * 0.5f) + 45.0f; + this->unk_29C = 0x32000 / this->unk_2A4; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); + this->actor.world.pos.x -= this->unk_2A4 * Math_SinS(this->actor.shape.rot.y); + this->actor.world.pos.z -= this->unk_2A4 * Math_CosS(this->actor.shape.rot.y); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990948.s") + if (Actor_GetRoomCleared(globalCtx, this->actor.room)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990C6C.s") + this->actor.params &= 0x3F; + Actor_SetScale(&this->actor, 0.0075f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990E4C.s") + if (this->actor.params == 0) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060095D0, &D_0600A3CC, this->jointTable, this->morphTable, + 22); + this->actor.hintId = 0x4C; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); + this->collider1.elements[0].info.toucher.damage = 8; + this->collider1.elements[1].info.toucher.damage = 8; + this->actor.colChkInfo.health = 6; + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003BC0, &D_0600A3CC, this->jointTable, this->morphTable, + 22); + this->actor.hintId = 0x57; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990EAC.s") + if (this->actor.child == NULL) { + func_80990F0C(this); + this->unk_2A0 = 0; + } else { + func_80992FD4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990ED4.s") + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990F0C.s") + if (D_809942D8 == 0) { + for (i = 0; i < ARRAY_COUNT(D_809942B0); i++) { + D_809942B0[i] = Lib_SegmentedToVirtual(D_809942B0[i]); + D_809942C0[i] = Lib_SegmentedToVirtual(D_809942C0[i]); + } + D_809942D8 = 1; + } + this->unk_2A2 = Rand_ZeroFloat(96.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990F50.s") +void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80990FC8.s") + Collider_DestroyJntSph(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider3); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991040.s") +void func_809907D4(EnWf* this) { + this->unk_2B0 = 0.75f; + this->unk_2B4 = 1.125f; + this->unk_2AC = 1.0f; + this->unk_296 = 10; + this->collider2.base.colType = COLTYPE_HIT3; + this->collider3.base.colType = COLTYPE_HIT3; + this->unk_2A0 = 80; + this->actor.flags &= ~0x400; + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809910F0.s") +void func_80990854(EnWf* this, GlobalContext* globalCtx) { + if (this->unk_296 == 10) { + this->unk_296 = 0; + this->collider2.base.colType = COLTYPE_HIT5; + this->collider3.base.colType = COLTYPE_HIT5; + this->unk_2AC = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991174.s") +void func_809908E0(EnWf* this) { + if (this->unk_294 != 0) { + this->unk_294++; + if (this->unk_294 == 4) { + this->unk_294 = 0; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->unk_294 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991200.s") +s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + s32 sp38; + s32 pad; + s32 pad2; + s16 sp2E; + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991280.s") + sp38 = ABS_ALT(BINANG_SUB(this->actor.wallYaw, this->actor.shape.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991438.s") + if (((this->unk_295 == 0) || + ((this->unk_295 == 1) && (this->actor.child != NULL) && (this->actor.child->update != NULL))) && + (this->actor.xzDistToPlayer > 160.0f) && + (this->unk_2A8 < Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos))) { + func_80993524(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099149C.s") + if (func_800BE184(globalCtx, &this->actor, 100.0f, 10000, 12000, this->actor.shape.rot.y) && + ((player->swordAnimation == 0x11) || ((globalCtx->gameplayFrames % 2) != 0))) { + func_8099282C(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991738.s") + if (func_800BE184(globalCtx, &this->actor, 100.0f, 24000, 0x2AA8, this->actor.shape.rot.y)) { + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if ((this->actor.bgCheckFlags & 8) && (sp38 < 12000)) { + func_809926D0(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099177C.s") + if ((player->swordAnimation == 0x11) || ((globalCtx->gameplayFrames % 2) != 0)) { + func_8099282C(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991948.s") + func_8099223C(this); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809919F4.s") + actor = func_800BC444(globalCtx, &this->actor, 80.0f); + if ((actor != NULL) && (actor->id == ACTOR_EN_BOM_CHU)) { + EnBomChu* bomchu = (EnBomChu*)actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991C04.s") + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (BINANG_ROT180(this->actor.shape.rot.y - bomchu->actor.world.rot.y) < 16000) { + func_809926D0(this); + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991C80.s") + if (arg2 != 0) { + if (!Actor_IsActorFacingLink(&this->actor, 7000)) { + func_80992A74(this, globalCtx); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80991FD8.s") + sp2E = player->actor.shape.rot.y - this->actor.shape.rot.y; + if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor)) { + if (((globalCtx->gameplayFrames % 8) != 0) || (ABS_ALT(sp2E) < 0x38E0)) { + func_80991C04(this); + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992068.s") + func_80991948(this); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099223C.s") +void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { + static Vec3f D_809942DC = { 0.0f, 0.1f, 0.0f }; + static Color_RGBA8 D_809942E8 = { 185, 140, 70, 255 }; + static Color_RGBA8 D_809942EC = { 255, 255, 255, 255 }; + s32 i; + Vec3f sp88; + u32 temp_v0; + Color_RGBA8* phi_s1; + s16 phi_s6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809922B4.s") + if (this->actor.floorPoly != NULL) { + temp_v0 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if (temp_v0 != 5) { + if ((temp_v0 == 15) || (temp_v0 == 14)) { + phi_s1 = &D_809942EC; + phi_s6 = Rand_ZeroFloat(150.0f) + 350.0f; + arg2 += 2; + } else { + phi_s1 = &D_809942E8; + phi_s6 = Rand_ZeroFloat(100.0f) + 250.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809923B0.s") + for (i = 0; i < arg2; i++) { + sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; + sp88.y = Rand_ZeroFloat(5.0f) + this->actor.world.pos.y; + sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; + func_800B0F18(globalCtx, &sp88, &D_801D15B0, &D_809942DC, phi_s1, phi_s1, phi_s6, 5, + Rand_ZeroFloat(5.0f) + 14.0f); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809923E4.s") +void func_80990E4C(EnWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & 1)) { + func_80990C6C(this, globalCtx, 2); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099245C.s") +s32 func_80990EAC(EnWf* this) { + ObjIcePoly* icePoly = (ObjIcePoly*)this->actor.child; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809924EC.s") + if (icePoly->unk_148 < 200) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809926D0.s") +void func_80990ED4(EnWf* this) { + this->actor.child = NULL; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + func_80991438(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992784.s") +void func_80990F0C(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + this->actor.shape.shadowScale = 0.0f; + this->actor.scale.y = 0.0f; + this->actor.flags &= ~1; + this->unk_2A0 = 60; + this->actionFunc = func_80990F50; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099282C.s") +void func_80990F50(EnWf* this, GlobalContext* globalCtx) { + f32 phi_f2 = 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809928CC.s") + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992A74.s") + if (this->unk_2A0 <= 0) { + if (this->unk_2A8 < 240.0f) { + phi_f2 = this->unk_2A8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992B8C.s") + if (this->actor.xzDistToPlayer < phi_f2) { + func_80990FC8(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992D6C.s") +void func_80990FC8(EnWf* this) { + Animation_Change(&this->skelAnime, &D_060053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); + this->unk_2A0 = 5; + this->actor.flags |= 1; + this->actionFunc = func_80991040; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992E0C.s") +void func_80991040(EnWf* this, GlobalContext* globalCtx) { + if (this->unk_2A0 != 0) { + this->actor.scale.y += this->actor.scale.x * 0.2f; + Math_StepToF(&this->actor.shape.shadowScale, 70.0f, 14.0f); + this->unk_2A0--; + if (this->unk_2A0 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + } + } else if (SkelAnime_Update(&this->skelAnime)) { + this->actor.scale.y = this->actor.scale.x; + func_80991200(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80992FD4.s") +void func_809910F0(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &D_060053D0, 0.5f, 0.0f, 7.0f, 3, -5.0f); + this->unk_2A0 = 5; + this->actionFunc = func_80991174; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993018.s") +void func_80991174(EnWf* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_2A0 > 0) { + this->actor.scale.y -= this->actor.scale.x * 0.2f; + Math_StepToF(&this->actor.shape.shadowScale, 0.0f, 14.0f); + this->unk_2A0--; + } else { + func_80990F0C(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993148.s") +void func_80991200(EnWf* this) { + this->collider2.base.acFlags |= AC_ON; + Animation_MorphToLoop(&this->skelAnime, &D_0600A3CC, -4.0f); + this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 2; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80991280; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993194.s") +void func_80991280(EnWf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v0; + s32 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993350.s") + SkelAnime_Update(&this->skelAnime); + if (this->unk_298 != 0) { + temp_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_29E; + if (ABS_ALT(temp_v0) > 0x2000) { + this->unk_298--; + return; + } + this->unk_298 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_809933A0.s") + if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + phi_v1 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); + if ((this->actor.xzDistToPlayer < 80.0f) && (player->swordState != 0) && (phi_v1 >= 0x1F40)) { + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80991948(this); + } else { + this->unk_2A0--; + if (this->unk_2A0 == 0) { + if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Rand_ZeroOne() > 0.3f) { + func_80991438(this); + } else { + func_80991948(this); + } + } else { + func_80991738(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993524.s") + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099357C.s") +void func_80991438(EnWf* this) { + this->collider2.base.acFlags |= AC_ON; + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.speedXZ = 8.0f; + this->actionFunc = func_8099149C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993738.s") +void func_8099149C(EnWf* this, GlobalContext* globalCtx) { + f32 sp2C; + s32 sp28; + s32 pad; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099386C.s") + if (!func_8099408C(globalCtx, this)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 500); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (func_800BC5EC(globalCtx, &this->actor)) { + sp2C = 150.0f; + } else { + sp2C = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/EnWf_Update.s") + sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993E50.s") + if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->swordState != 0) && (sp28 >= 0x1F40)) { + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + func_80991948(this); + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_80993E94.s") + SkelAnime_Update(&this->skelAnime); + if (!func_80990948(globalCtx, this, 0)) { + if (!Actor_IsActorFacingLink(&this->actor, 0x11C7)) { + if (Rand_ZeroOne() > 0.5f) { + func_80991948(this); + } else { + func_80991200(this); + } + } else if (this->actor.xzDistToPlayer < (90.0f + sp2C)) { + if (!func_800BC5EC(globalCtx, &this->actor) && + ((Rand_ZeroOne() > 0.03f) || ((this->actor.xzDistToPlayer <= 80.0f) && (sp28 < 0x38E0)))) { + func_80991C04(this); + } else if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + func_8099223C(this); + } else { + func_80991948(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/EnWf_Draw.s") + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wf/func_8099408C.s") + func_80990E4C(this, globalCtx); + } + } +} + +void func_80991738(EnWf* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06009808, -4.0f); + this->actionFunc = func_8099177C; +} + +void func_8099177C(EnWf* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 phi_v1; + f32 phi_f2; + f32 phi_f12; + + if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (temp_v0 > 0) { + phi_v1 = (temp_v0 * 0.25f) + 2000.0f; + } else { + phi_v1 = (temp_v0 * 0.25f) - 2000.0f; + } + + this->actor.shape.rot.y += phi_v1; + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (temp_v0 > 0) { + phi_f2 = phi_v1 * 0.5f; + phi_f12 = 1.0f; + if (phi_f2 > 1.0f) { + phi_f2 = phi_f12; + } + } else { + phi_f2 = phi_v1 * 0.5f; + phi_f12 = -1.0f; + if (phi_f2 < -1.0f) { + phi_f2 = phi_f12; + } + } + + this->skelAnime.playSpeed = -phi_f2; + SkelAnime_Update(&this->skelAnime); + if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Rand_ZeroOne() > 0.8f) { + func_80991948(this); + } else { + func_80991438(this); + } + } + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } + } +} + +void func_80991948(EnWf* this) { + this->collider2.base.acFlags |= AC_ON; + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + if (Rand_ZeroOne() > 0.5f) { + this->unk_29A = 16000; + } else { + this->unk_29A = -16000; + } + this->actor.speedXZ = 6.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_2A0 = (s32)Rand_ZeroFloat(30.0f) + 30; + this->actionFunc = func_809919F4; +} + +void func_809919F4(EnWf* this, GlobalContext* globalCtx) { + s16 sp26; + Player* player = GET_PLAYER(globalCtx); + s16 temp_v0; + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_29A, 2500); + if (!func_8099408C(globalCtx, this) && !func_80990948(globalCtx, this, 0)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + sp26 = BINANG_ROT180(player->actor.shape.rot.y + this->unk_29A); + if (this->actor.bgCheckFlags & 8) { + temp_v0 = (this->actor.wallYaw - this->actor.yawTowardsPlayer) - this->unk_29A; + if (ABS_ALT(temp_v0) > 0x2EE0) { + this->unk_29A = -this->unk_29A; + } + } + + SkelAnime_Update(&this->skelAnime); + func_80990E4C(this, globalCtx); + + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } + + if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !func_800BC5EC(globalCtx, &this->actor) && + (this->actor.xzDistToPlayer <= 80.0f)) { + func_80991C04(this); + } else { + this->unk_2A0--; + if (this->unk_2A0 == 0) { + if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + func_8099223C(this); + } else { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(3.0f) + 1; + } + } + } + } +} + +void func_80991C04(EnWf* this) { + this->collider2.base.acFlags |= AC_ON; + Animation_PlayOnce(&this->skelAnime, &D_06004638); + this->collider1.base.atFlags &= ~AT_BOUNCED; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_2A0 = 7; + this->skelAnime.endFrame = 20.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80991C80; +} + +void func_80991C80(EnWf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp30; + s32 sp2C; + s16 sp2A; + + sp2A = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + sp30 = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); + + this->actor.speedXZ = 0.0f; + if (((this->skelAnime.curFrame >= 9.0f) && (this->skelAnime.curFrame < 13.0f)) || + ((this->skelAnime.curFrame >= 17.0f) && (this->skelAnime.curFrame < 20.0f))) { + if (!(this->collider1.base.atFlags & AT_ON)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_ATTACK); + } + this->collider1.base.atFlags |= AT_ON; + } else { + this->collider1.base.atFlags &= ~AT_ON; + } + + sp2C = Animation_OnFrame(&this->skelAnime, 15.0f); + if (((sp2C != 0) && !func_800BC5B8(globalCtx, &this->actor) && + (!Actor_IsActorFacingLink(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || + SkelAnime_Update(&this->skelAnime)) { + if ((sp2C == 0) && (this->unk_2A0 != 0)) { + this->actor.shape.rot.y += (s16)(0xCCC * (1.5f + ((this->unk_2A0 - 4) * 0.4f))); + func_80990C6C(this, globalCtx, 1); + this->unk_2A0--; + } else if (!Actor_IsActorFacingLink(&this->actor, 0x1554) && (sp2C == 0)) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; + if (sp30 >= 0x32C9) { + this->unk_298 = 7; + } + } else if ((Rand_ZeroOne() > 0.7f) || (this->actor.xzDistToPlayer >= 120.0f)) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; + } else { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + func_80992A74(this, globalCtx); + } else if (ABS_ALT(sp2A) < 0x2711) { + if (sp30 >= 0x3E81) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80991948(this); + } else { + func_80990948(globalCtx, this, 1); + } + } else { + func_80991948(this); + } + } + } +} + +void func_80991FD8(EnWf* this) { + f32 phi_f0 = 1.0f; + + if (this->skelAnime.curFrame > 15.0f) { + phi_f0 = 15.0f; + } + Animation_Change(&this->skelAnime, &D_06004638, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); + this->collider1.base.atFlags &= ~AT_ON; + this->actionFunc = func_80992068; +} + +void func_80992068(EnWf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28; + s16 sp26; + + sp26 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + sp28 = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); + + if (SkelAnime_Update(&this->skelAnime)) { + if (!Actor_IsActorFacingLink(&this->actor, 0x1554)) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; + if (sp28 > 0x32C8) { + this->unk_298 = 30; + } + } else if ((Rand_ZeroOne() > 0.7f) || (this->actor.xzDistToPlayer >= 120.0f)) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; + } else { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + func_80992A74(this, globalCtx); + } else if (ABS_ALT(sp26) < 0x2711) { + if (sp28 > 0x3E80) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80991948(this); + } else { + func_80990948(globalCtx, this, 1); + } + } else { + func_80991948(this); + } + } + } +} + +void func_8099223C(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + Animation_MorphToPlayOnce(&this->skelAnime, &D_06004A90, -3.0f); + this->unk_2A0 = 0; + this->actor.speedXZ = -6.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + this->actionFunc = func_809922B4; +} + +void func_809922B4(EnWf* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (!func_800BC5EC(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && + (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { + func_80991438(this); + } else if ((globalCtx->gameplayFrames % 2) != 0) { + func_80992A74(this, globalCtx); + } else { + func_80991200(this); + } + } + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } +} + +void func_809923B0(EnWf* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + this->actionFunc = func_809923E4; +} + +void func_809923E4(EnWf* this, GlobalContext* globalCtx) { + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } + + if (this->unk_2A0 == 0) { + func_80990854(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80992D6C(this); + } else { + func_80990948(globalCtx, this, 1); + } + } +} + +void func_8099245C(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + Animation_MorphToPlayOnce(&this->skelAnime, &D_06009A50, -4.0f); + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ = -4.0f; + } + this->unk_298 = 0; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); + this->actionFunc = func_809924EC; +} + +void func_809924EC(EnWf* this, GlobalContext* globalCtx) { + s16 sp26; + + if (this->actor.bgCheckFlags & 2) { + this->actor.speedXZ = 0.0f; + } + + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.0f)) { + this->actor.speedXZ += 0.05f; + } + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3000); + if (SkelAnime_Update(&this->skelAnime)) { + sp26 = this->actor.wallYaw - this->actor.shape.rot.y; + + if (func_80990948(globalCtx, this, 0)) { + return; + } + + if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(sp26) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { + func_809926D0(this); + } else if (!func_8099408C(globalCtx, this)) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + ((globalCtx->gameplayFrames % 8) != 0)) { + func_80991C04(this); + } else if (Rand_ZeroOne() > 0.5f) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; + this->unk_298 = 30; + } else { + func_8099223C(this); + } + } + } +} + +void func_809926D0(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + Animation_Change(&this->skelAnime, &D_06004A90, -1.0f, Animation_GetLastFrame(&D_06004A90.common), 0.0f, 2, -3.0f); + this->unk_2A0 = 0; + this->actor.speedXZ = 6.5f; + this->actor.velocity.y = 15.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80992784; +} + +void func_80992784(EnWf* this, GlobalContext* globalCtx) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2500); + if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & (2 | 1))) { + this->actor.shape.rot.x = 0; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.pos.y = this->actor.floorHeight; + if (!func_800BC5EC(globalCtx, &this->actor)) { + func_80991C04(this); + } else { + func_80991200(this); + } + } +} + +void func_8099282C(EnWf* this) { + this->collider2.base.acFlags |= AC_ON; + this->collider1.base.atFlags &= ~AT_ON; + this->unk_2A0 = 10; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &D_06004C44, -1.0f, Animation_GetLastFrame(&D_06004C44.common), 0.0f, 2, -2.0f); + this->actionFunc = func_809928CC; +} + +void func_809928CC(EnWf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp2A; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } else if (func_800BE184(globalCtx, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { + if ((player->swordAnimation != 0x11) || ((globalCtx->gameplayFrames % 2) != 0)) { + this->unk_2A0 = 10; + } else { + func_8099223C(this); + } + } else if (Actor_IsActorFacingLink(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && + (fabsf(this->actor.yDistToPlayer) < 50.0f)) { + sp2A = player->actor.shape.rot.y - this->actor.shape.rot.y; + if (!func_800BC5EC(globalCtx, &this->actor) && + (((globalCtx->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { + func_80991C04(this); + } else { + func_80991948(this); + } + } else { + func_80991948(this); + } + } +} + +void func_80992A74(EnWf* this, GlobalContext* globalCtx) { + Player* player; + f32 temp_f0; + + this->collider2.base.acFlags |= AC_ON; + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + player = GET_PLAYER(globalCtx); + temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); + if (temp_f0 > 0.0f) { + this->unk_29A = 16000; + } else if (temp_f0 < 0.0f) { + this->unk_29A = -16000; + } else if (Rand_ZeroOne() > 0.5f) { + this->unk_29A = 16000; + } else { + this->unk_29A = -16000; + } + this->actor.speedXZ = 6.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 5; + this->actionFunc = func_80992B8C; +} + +void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { + s32 sp28; + s32 sp2C; + Player* player = GET_PLAYER(globalCtx); + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_29A, 2000); + if (this->actor.bgCheckFlags & 8) { + sp2C = BINANG_SUB((this->actor.wallYaw - this->actor.yawTowardsPlayer), this->unk_29A); + if (ABS_ALT(sp2C) > 0x2EE0) { + this->unk_29A = -this->unk_29A; + } + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + SkelAnime_Update(&this->skelAnime); + + if (!func_80990948(globalCtx, this, 0)) { + this->unk_2A0--; + if (this->unk_2A0 == 0) { + sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.yawTowardsPlayer)); + if (sp28 >= 0x3A98) { + func_80991200(this); + this->unk_2A0 = (s32)Rand_ZeroFloat(3.0f) + 1; + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + (((globalCtx->gameplayFrames % 4) == 0) || (sp28 < 0x38E0))) { + func_80991C04(this); + } else { + func_80991438(this); + } + } + } + + func_80990E4C(this, globalCtx); + + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } + } +} + +void func_80992D6C(EnWf* this) { + this->collider2.base.acFlags &= ~AC_ON; + Animation_MorphToPlayOnce(&this->skelAnime, &D_060053D0, -4.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ = -6.0f; + } + this->actor.flags &= ~1; + this->unk_2A0 = 25; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DEAD); + this->actionFunc = func_80992E0C; +} + +void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { + static Vec3f D_809942F0 = { 0.0f, 0.5f, 0.0f }; + + if (this->actor.bgCheckFlags & 2) { + this->actor.speedXZ = 0.0f; + } + + if (this->actor.bgCheckFlags & 1) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + } + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_295 != 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + } + Actor_MarkForDeath(&this->actor); + } else { + s32 i; + Vec3f sp60; + + if (this->unk_2A0 == 25) { + func_800F0590(globalCtx, &this->actor.world.pos, 36, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + + this->unk_2A0--; + + for (i = (25 - this->unk_2A0) >> 1; i >= 0; i--) { + sp60.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp60.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp60.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp60, &D_809942F0, &D_809942F0, 100, 0, 2); + } + + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } +} + +void func_80992FD4(EnWf* this) { + Animation_MorphToLoop(&this->skelAnime, &D_0600A3CC, -4.0f); + this->actionFunc = func_80993018; +} + +void func_80993018(EnWf* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + if (func_80990EAC(this)) { + func_80990ED4(this); + } else if (this->actor.child->xzDistToPlayer < (80.0f + this->unk_2A4)) { + func_80993350(this); + } else { + s16 temp_v0 = Actor_YawBetweenActors(this->actor.child, &this->actor); + s16 temp_v1 = BINANG_SUB(temp_v0 - this->actor.child->yawTowardsPlayer, 0x8000); + + if (ABS_ALT(temp_v1) > 0x800) { + func_80993148(this); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ROT180(temp_v0), 0x800); + } + } + } else { + func_80990ED4(this); + } +} + +void func_80993148(EnWf* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80993194; +} + +void func_80993194(EnWf* this, GlobalContext* globalCtx) { + s16 sp36; + s16 sp34; + s16 sp32; + + SkelAnime_Update(&this->skelAnime); + func_80990E4C(this, globalCtx); + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + if (func_80990EAC(this)) { + func_80990ED4(this); + } else { + if (this->actor.child->xzDistToPlayer < (80.0f + this->unk_2A4)) { + func_80993350(this); + } else { + sp36 = Actor_YawBetweenActors(this->actor.child, &this->actor); + sp34 = Math_SmoothStepToS(&sp36, BINANG_ROT180(this->actor.child->yawTowardsPlayer), 10, this->unk_29C, + 16); + this->actor.world.pos.x = (Math_SinS(sp36) * this->unk_2A4) + this->actor.child->world.pos.x; + this->actor.world.pos.z = (Math_CosS(sp36) * this->unk_2A4) + this->actor.child->world.pos.z; + if (sp34 < -0x800) { + sp32 = sp36 - 0x4000; + } else if (sp34 > 0x800) { + sp32 = sp36 + 0x4000; + } else { + sp32 = sp36 + 0x8000; + func_80992FD4(this); + } + Math_ScaledStepToS(&this->actor.shape.rot.y, sp32, 0x800); + } + } + } else { + func_80990ED4(this); + } + + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } +} + +void func_80993350(EnWf* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + this->actionFunc = func_809933A0; +} + +void func_809933A0(EnWf* this, GlobalContext* globalCtx) { + s16 sp2E; + s16 sp2C; + s16 phi_a1; + + SkelAnime_Update(&this->skelAnime); + func_80990E4C(this, globalCtx); + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + if (func_80990EAC(this)) { + func_80990ED4(this); + } else { + sp2E = Actor_YawBetweenActors(this->actor.child, &this->actor); + Math_ScaledStepToS(&sp2E, this->actor.child->yawTowardsPlayer, this->unk_29C >> 2); + sp2C = sp2E - this->actor.child->yawTowardsPlayer; + this->actor.world.pos.x = (Math_SinS(sp2E) * this->unk_2A4) + this->actor.child->world.pos.x; + this->actor.world.pos.z = (Math_CosS(sp2E) * this->unk_2A4) + this->actor.child->world.pos.z; + if (sp2C > 0) { + phi_a1 = sp2E - 0x4000; + } else { + phi_a1 = sp2E + 0x4000; + } + Math_ScaledStepToS(&this->actor.shape.rot.y, phi_a1, 0x800); + if (ABS_ALT(sp2C) < 0x3000) { + func_80991438(this); + } + } + } else { + func_80990ED4(this); + } + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } +} + +void func_80993524(EnWf* this) { + Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); + this->actor.speedXZ = 6.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_8099357C; +} + +void func_8099357C(EnWf* this, GlobalContext* globalCtx) { + s16 sp2E; + + SkelAnime_Update(&this->skelAnime); + func_80990E4C(this, globalCtx); + if (this->unk_295 != 0) { + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + sp2E = Actor_YawBetweenActors(&this->actor, this->actor.child); + if (func_80990EAC(this)) { + this->actor.child = NULL; + func_80991738(this); + return; + } + + if (this->actor.bgCheckFlags & 8) { + if (BINANG_SUB(sp2E, this->actor.wallYaw) > 0) { + sp2E = this->actor.wallYaw - 0x4000; + } else { + sp2E = this->actor.wallYaw + 0x4000; + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, sp2E, 10, 0x800, 16); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) < (this->unk_2A4 + 10.0f)) { + func_80993148(this); + } + } else { + this->actor.child = NULL; + func_80991738(this); + } + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 10, 0x800, + 16); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 40.0f) { + func_809910F0(this); + } + } + + if (this->unk_2A2 == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + } +} + +void func_80993738(EnWf* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80991280) && (this->unk_298 != 0)) { + this->unk_29E = Math_SinS(this->unk_298 * 4200) * 8920.0f; + } else if ((this->actionFunc == func_80991C80) || (this->actionFunc == func_8099357C) || + (this->actionFunc == func_80991040) || (this->actionFunc == func_80991174)) { + Math_ScaledStepToS(&this->unk_29E, 0, 1000); + } else if (this->actionFunc != func_809923E4) { + Math_ScaledStepToS(&this->unk_29E, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 1000); + this->unk_29E = CLAMP(this->unk_29E, -0x3127, 0x3127); + } +} + +void func_8099386C(EnWf* this, GlobalContext* globalCtx) { + s32 pad; + ColliderCylinder* collider; + + if (this->collider1.base.acFlags & AC_BOUNCED) { + this->collider1.base.acFlags &= ~(AC_BOUNCED | AC_HIT); + this->collider2.base.acFlags &= ~AC_HIT; + this->collider3.base.acFlags &= ~AC_HIT; + return; + } + + if ((this->collider2.base.acFlags & AC_HIT) || (this->collider3.base.acFlags & AC_HIT)) { + if ((!(this->collider2.base.acFlags & AC_HIT) && (this->collider3.base.acFlags & AC_HIT)) || + !Actor_IsActorFacingLink(&this->actor, 0x4A38)) { + this->actor.colChkInfo.damage *= 4; + } + + if (this->collider2.base.acFlags & AC_HIT) { + func_800BE258(&this->actor, &this->collider2.info); + collider = &this->collider2; + } else { + func_800BE258(&this->actor, &this->collider3.info); + collider = &this->collider3; + } + + this->collider2.base.acFlags &= ~AC_HIT; + this->collider3.base.acFlags &= ~AC_HIT; + this->collider1.base.atFlags &= ~AT_ON; + + if (((this->unk_296 != 10) || + !(collider->info.acHitInfo->toucher.dmgFlags & + (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && + (this->actor.colChkInfo.damageEffect != 0xF)) { + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + func_80990854(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2A0 = 40; + func_800BCB70(&this->actor, 0, 0x78, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_809923B0(this); + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2A0 = 40; + func_800BCB70(&this->actor, 0, 0xFF, 0, 40); + this->unk_296 = 30; + this->unk_2B0 = 0.75f; + this->unk_2AC = 2.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_809923B0(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_809907D4(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_2A0 = 3; + this->collider2.base.acFlags &= ~AC_ON; + } + func_809923B0(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_296 = 0; + this->unk_2B0 = 0.75f; + this->unk_2AC = 4.0f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_296 = 20; + this->unk_2B0 = 0.75f; + this->unk_2AC = 4.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, + collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + if (this->actor.colChkInfo.health == 0) { + func_80992D6C(this); + } else { + func_8099245C(this); + } + } + } + } +} + +void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWf* this = THIS; + + if (this->unk_2A2 == 0) { + this->unk_2A2 = 96; + } else { + this->unk_2A2--; + } + + func_8099386C(this, globalCtx); + if (this->actionFunc != func_809923E4) { + func_809908E0(this); + } + + this->actionFunc(this, globalCtx); + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); + func_80993738(this, globalCtx); + + if (this->actor.bgCheckFlags & (2 | 1)) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 600); + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 600); + } + + if (this->actionFunc != func_80990F50) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (this->collider2.base.acFlags & AC_ON) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + if (this->actionFunc == func_809928CC) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (this->collider1.base.atFlags & AT_ON) { + if (!(this->collider1.base.atFlags & AT_BOUNCED)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } else { + func_80991FD8(this); + } + } + + Actor_SetHeight(&this->actor, 25.0f); + + if (this->unk_2AC > 0.0f) { + if (this->unk_296 != 10) { + Math_StepToF(&this->unk_2AC, 0.0f, 0.05f); + this->unk_2B0 = (this->unk_2AC + 1.0f) * 0.375f; + if (this->unk_2B0 > 0.75f) { + this->unk_2B0 = 0.75f; + } else { + this->unk_2B0 = this->unk_2B0; + } + } else if (!Math_StepToF(&this->unk_2B4, 0.75f, 0.01875f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 func_80993E50(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnWf* this = THIS; + + if ((limbIndex == 17) || (limbIndex == 18)) { + rot->y -= this->unk_29E; + } + return false; +} + +void func_80993E94(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static s8 D_809942FC[] = { + -1, -1, -1, -1, -1, 0, 1, -1, -1, -1, -1, 2, -1, 3, 4, 5, 6, -1, -1, 7, 8, 9, + }; + EnWf* this = THIS; + Vec3f sp20; + + Collider_UpdateSpheres(limbIndex, &this->collider1); + + if (D_809942FC[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2B8[D_809942FC[limbIndex]]); + } + + if (limbIndex == 6) { + Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); + this->collider3.dim.pos.x = sp20.x; + this->collider3.dim.pos.y = sp20.y; + this->collider3.dim.pos.z = sp20.z; + } +} + +void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWf* this = THIS; + + if (this->actionFunc != func_80990F50) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actor.params == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, D_809942B0[this->unk_294]); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, D_809942C0[this->unk_294]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80993E50, func_80993E94, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2B8, 10, this->unk_2B0, this->unk_2B4, this->unk_2AC, + this->unk_296); + } +} + +s32 func_8099408C(GlobalContext* globalCtx, EnWf* this) { + Actor* temp_v0 = func_800BC270(globalCtx, &this->actor, 80.0f, 0x138B0); + s16 temp_v1; + + if (temp_v0 != NULL) { + temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_29E; + if (ABS_ALT(temp_v1) < 0x3000) { + if (Rand_ZeroOne() < 0.5f) { + func_8099223C(this); + } else { + func_8099282C(this); + } + return true; + } + } + return false; +} diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index 8e3d132ab..defd8fc79 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -7,11 +7,33 @@ struct EnWf; typedef void (*EnWfActionFunc)(struct EnWf*, GlobalContext*); +#define ENWF_GET_80(thisx) ((thisx)->params & 0x80) + typedef struct EnWf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[22]; + /* 0x020C */ Vec3s morphTable[22]; /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x254]; + /* 0x0294 */ u8 unk_294; + /* 0x0295 */ u8 unk_295; + /* 0x0296 */ u8 unk_296; + /* 0x0298 */ s16 unk_298; + /* 0x029A */ s16 unk_29A; + /* 0x029C */ s16 unk_29C; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ u16 unk_2A2; + /* 0x02A4 */ f32 unk_2A4; + /* 0x02A8 */ f32 unk_2A8; + /* 0x02AC */ f32 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ Vec3f unk_2B8[10]; + /* 0x0330 */ ColliderJntSph collider1; + /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; + /* 0x0450 */ ColliderCylinder collider2; + /* 0x049C */ ColliderCylinder collider3; } EnWf; // size = 0x4E8 extern const ActorInit En_Wf_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h index d23020f8a..6870eccc9 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h @@ -10,7 +10,8 @@ typedef void (*ObjIcePolyActionFunc)(struct ObjIcePoly*, GlobalContext*); typedef struct ObjIcePoly { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjIcePolyActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x134]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ char unk_149[0x133]; } ObjIcePoly; // size = 0x27C extern const ActorInit Obj_Ice_Poly_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 9636e0534..0c7b23172 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -3766,12 +3766,18 @@ D_06001E20 = 0x06001E20; // ovl_En_Wf +D_06000300 = 0x06000300; +D_060027D8 = 0x060027D8; +D_060029D8 = 0x060029D8; D_06003BC0 = 0x06003BC0; D_06004638 = 0x06004638; D_06004A90 = 0x06004A90; D_06004C44 = 0x06004C44; D_060053D0 = 0x060053D0; D_06005700 = 0x06005700; +D_06007AA8 = 0x06007AA8; +D_060082A8 = 0x060082A8; +D_060084A8 = 0x060084A8; D_060095D0 = 0x060095D0; D_06009808 = 0x06009808; D_06009A50 = 0x06009A50; From c7614777996e430d58211b8b21c9473cc4cbc044 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 2 Nov 2021 13:05:53 -0700 Subject: [PATCH 58/86] Update diff-init to be dependent on just the uncompressed rom (#372) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 349c50b67..cf23794bd 100644 --- a/Makefile +++ b/Makefile @@ -232,7 +232,7 @@ disasm: $(RM) -rf asm data python3 tools/disasm/disasm.py -diff-init: all +diff-init: uncompressed $(RM) -rf expected/ mkdir -p expected/ cp -r build expected/build From 4841a4a0bf7c2ab92493d64c22442c4e584a7b99 Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Tue, 2 Nov 2021 14:35:57 -0700 Subject: [PATCH 59/86] padsetup OK (#383) * padsetup OK * Made tharo's suggestions * Made arg name consistent --- include/functions.h | 2 +- src/boot_O2/padsetup.c | 33 ++++++++++++++++++++++++++++++++- tools/disasm/functions.txt | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7f71bc4cb..fedeaf0f5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -168,7 +168,7 @@ void func_800863AC(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); // void func_800864EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80086588(void); void SystemArena_Init(u32 base, u32 size); -s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3); +s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); // void func_80086760(void); // void func_80086794(void); // void func_800867B4(void); diff --git a/src/boot_O2/padsetup.c b/src/boot_O2/padsetup.c index 5f83bd524..9cef6f196 100644 --- a/src/boot_O2/padsetup.c +++ b/src/boot_O2/padsetup.c @@ -1,3 +1,34 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/padsetup/func_80086620.s") +s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status) { + s32 ret; + s32 i; + + *outMask = 0xFF; + ret = osContInit(mq, outMask, status); + if (ret != 0) { + return ret; + } + if (*outMask == 0xFF) { + if (osContStartQuery(mq) != 0) { + return 1; + } + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + osContGetQuery(status); + + *outMask = 0; + + for (i = 0; i < MAXCONTROLLERS; i++) { + switch (status[i].errno) { + case 0: + if (status[i].type == CONT_TYPE_NORMAL) { + *outMask |= 1 << i; + } + break; + default: + break; + } + } + } + return 0; +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c158bd87f..4348bf5b5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -165,7 +165,7 @@ 0x800864EC:("func_800864EC",), 0x80086588:("func_80086588",), 0x800865F8:("SystemArena_Init",), - 0x80086620:("func_80086620",), + 0x80086620:("PadSetup_Init",), 0x80086760:("func_80086760",), 0x80086794:("func_80086794",), 0x800867B4:("func_800867B4",), From 9bae8900f0d8cf097a2d9e4e58e2e507941c4fd6 Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Tue, 2 Nov 2021 14:56:47 -0700 Subject: [PATCH 60/86] sp.c OK (#389) * io/sp OK * Fixed function prototype * Made tharo's suggestions --- src/libultra/io/sp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libultra/io/sp.c b/src/libultra/io/sp.c index 6c829b062..db2e5b451 100644 --- a/src/libultra/io/sp.c +++ b/src/libultra/io/sp.c @@ -1,3 +1,10 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/sp/__osSpDeviceBusy.s") +s32 __osSpDeviceBusy(void) { + register u32 status = HW_REG(SP_STATUS_REG, u32); + + if (status & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) { + return true; + } + return false; +} From 7bda32153ca8376682f083318fdbb2e36220dbdd Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 2 Nov 2021 16:47:25 -0700 Subject: [PATCH 61/86] Add an explanatory comment header for every actor that doesn't have one (#377) * Add a header for every actor that doesn't have one * Run ./format.sh * Update comment for demo_kankyo --- src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c | 6 ++++++ src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c | 6 ++++++ src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c | 6 ++++++ .../actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c | 6 ++++++ src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c | 6 ++++++ .../actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c | 6 ++++++ .../actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 6 ++++++ .../actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c | 6 ++++++ src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 6 ++++++ .../actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c | 6 ++++++ src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 6 ++++++ src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c | 6 ++++++ src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c | 6 ++++++ src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c | 6 ++++++ src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c | 6 ++++++ src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c | 6 ++++++ src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c | 6 ++++++ src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c | 6 ++++++ .../actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c | 6 ++++++ src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 6 ++++++ .../actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c | 6 ++++++ .../actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c | 6 ++++++ .../actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c | 6 ++++++ src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 6 ++++++ .../actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c | 6 ++++++ .../actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c | 6 ++++++ .../actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 6 ++++++ .../actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c | 6 ++++++ src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c | 6 ++++++ src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 6 ++++++ src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c | 6 ++++++ src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c | 6 ++++++ src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c | 6 ++++++ .../actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 6 ++++++ src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c | 6 ++++++ src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 6 ++++++ src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c | 6 ++++++ src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c | 6 ++++++ src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c | 6 ++++++ src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c | 6 ++++++ src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 6 ++++++ src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c | 6 ++++++ src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c | 6 ++++++ src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c | 6 ++++++ src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c | 6 ++++++ src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c | 6 ++++++ src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 6 ++++++ src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c | 6 ++++++ src/overlays/actors/ovl_Boss_01/z_boss_01.c | 6 ++++++ src/overlays/actors/ovl_Boss_02/z_boss_02.c | 6 ++++++ src/overlays/actors/ovl_Boss_03/z_boss_03.c | 6 ++++++ src/overlays/actors/ovl_Boss_04/z_boss_04.c | 6 ++++++ src/overlays/actors/ovl_Boss_05/z_boss_05.c | 6 ++++++ src/overlays/actors/ovl_Boss_06/z_boss_06.c | 6 ++++++ src/overlays/actors/ovl_Boss_07/z_boss_07.c | 6 ++++++ src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c | 6 ++++++ src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c | 6 ++++++ src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c | 6 ++++++ src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 6 ++++++ src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c | 6 ++++++ src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c | 6 ++++++ src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c | 6 ++++++ src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 6 ++++++ src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c | 6 ++++++ src/overlays/actors/ovl_Dm_Al/z_dm_al.c | 6 ++++++ src/overlays/actors/ovl_Dm_An/z_dm_an.c | 6 ++++++ src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c | 6 ++++++ src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c | 6 ++++++ src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 6 ++++++ src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c | 6 ++++++ src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c | 6 ++++++ src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 6 ++++++ src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c | 6 ++++++ src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 6 ++++++ src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c | 6 ++++++ src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c | 6 ++++++ src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c | 6 ++++++ src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 6 ++++++ src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c | 6 ++++++ src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c | 6 ++++++ src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c | 6 ++++++ src/overlays/actors/ovl_Eff_Change/z_eff_change.c | 6 ++++++ .../actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c | 6 ++++++ src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c | 6 ++++++ src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c | 6 ++++++ src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c | 6 ++++++ src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 6 ++++++ src/overlays/actors/ovl_En_Ah/z_en_ah.c | 6 ++++++ src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c | 6 ++++++ src/overlays/actors/ovl_En_Al/z_en_al.c | 6 ++++++ src/overlays/actors/ovl_En_Am/z_en_am.c | 6 ++++++ src/overlays/actors/ovl_En_An/z_en_an.c | 6 ++++++ src/overlays/actors/ovl_En_And/z_en_and.c | 6 ++++++ src/overlays/actors/ovl_En_Ani/z_en_ani.c | 6 ++++++ src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c | 6 ++++++ src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 6 ++++++ src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c | 6 ++++++ src/overlays/actors/ovl_En_Az/z_en_az.c | 6 ++++++ src/overlays/actors/ovl_En_Baba/z_en_baba.c | 6 ++++++ src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 6 ++++++ src/overlays/actors/ovl_En_Bal/z_en_bal.c | 6 ++++++ src/overlays/actors/ovl_En_Bat/z_en_bat.c | 6 ++++++ src/overlays/actors/ovl_En_Bb/z_en_bb.c | 6 ++++++ src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c | 6 ++++++ src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c | 6 ++++++ src/overlays/actors/ovl_En_Bee/z_en_bee.c | 6 ++++++ src/overlays/actors/ovl_En_Bh/z_en_bh.c | 6 ++++++ src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c | 6 ++++++ src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c | 6 ++++++ src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c | 6 ++++++ src/overlays/actors/ovl_En_Bjt/z_en_bjt.c | 6 ++++++ src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c | 6 ++++++ src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c | 6 ++++++ src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c | 6 ++++++ src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c | 6 ++++++ src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c | 6 ++++++ src/overlays/actors/ovl_En_Bom/z_en_bom.c | 6 ++++++ src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 6 ++++++ src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 6 ++++++ src/overlays/actors/ovl_En_Bombal/z_en_bombal.c | 6 ++++++ src/overlays/actors/ovl_En_Bombers/z_en_bombers.c | 6 ++++++ src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c | 6 ++++++ src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 6 ++++++ src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c | 6 ++++++ src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c | 6 ++++++ src/overlays/actors/ovl_En_Boom/z_en_boom.c | 6 ++++++ src/overlays/actors/ovl_En_Box/z_en_box.c | 6 ++++++ src/overlays/actors/ovl_En_Bsb/z_en_bsb.c | 6 ++++++ src/overlays/actors/ovl_En_Bu/z_en_bu.c | 6 ++++++ src/overlays/actors/ovl_En_Bubble/z_en_bubble.c | 6 ++++++ src/overlays/actors/ovl_En_Butte/z_en_butte.c | 6 ++++++ src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c | 6 ++++++ src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c | 6 ++++++ src/overlays/actors/ovl_En_Cow/z_en_cow.c | 6 ++++++ src/overlays/actors/ovl_En_Crow/z_en_crow.c | 6 ++++++ src/overlays/actors/ovl_En_Death/z_en_death.c | 6 ++++++ src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c | 6 ++++++ src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c | 6 ++++++ src/overlays/actors/ovl_En_Dnh/z_en_dnh.c | 6 ++++++ src/overlays/actors/ovl_En_Door/z_en_door.c | 6 ++++++ src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c | 6 ++++++ src/overlays/actors/ovl_En_Dragon/z_en_dragon.c | 6 ++++++ src/overlays/actors/ovl_En_Drs/z_en_drs.c | 6 ++++++ src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c | 6 ++++++ src/overlays/actors/ovl_En_Dt/z_en_dt.c | 6 ++++++ src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c | 6 ++++++ src/overlays/actors/ovl_En_Egblock/z_en_egblock.c | 6 ++++++ src/overlays/actors/ovl_En_Egol/z_en_egol.c | 6 ++++++ src/overlays/actors/ovl_En_Elf/z_en_elf.c | 6 ++++++ src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c | 6 ++++++ src/overlays/actors/ovl_En_Encount1/z_en_encount1.c | 6 ++++++ src/overlays/actors/ovl_En_Encount2/z_en_encount2.c | 6 ++++++ src/overlays/actors/ovl_En_Encount3/z_en_encount3.c | 6 ++++++ src/overlays/actors/ovl_En_Encount4/z_en_encount4.c | 6 ++++++ src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c | 6 ++++++ src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c | 6 ++++++ src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c | 6 ++++++ src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c | 6 ++++++ src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c | 6 ++++++ src/overlays/actors/ovl_En_Estone/z_en_estone.c | 6 ++++++ src/overlays/actors/ovl_En_Fall/z_en_fall.c | 6 ++++++ src/overlays/actors/ovl_En_Fall2/z_en_fall2.c | 6 ++++++ src/overlays/actors/ovl_En_Famos/z_en_famos.c | 6 ++++++ src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c | 6 ++++++ src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c | 6 ++++++ src/overlays/actors/ovl_En_Fish/z_en_fish.c | 6 ++++++ src/overlays/actors/ovl_En_Floormas/z_en_floormas.c | 6 ++++++ src/overlays/actors/ovl_En_Fr/z_en_fr.c | 6 ++++++ src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 6 ++++++ src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 6 ++++++ src/overlays/actors/ovl_En_Fz/z_en_fz.c | 6 ++++++ src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c | 6 ++++++ src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c | 6 ++++++ src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 6 ++++++ src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 6 ++++++ src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 6 ++++++ src/overlays/actors/ovl_En_Ge3/z_en_ge3.c | 6 ++++++ src/overlays/actors/ovl_En_Geg/z_en_geg.c | 6 ++++++ src/overlays/actors/ovl_En_Gg/z_en_gg.c | 6 ++++++ src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 6 ++++++ src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 6 ++++++ src/overlays/actors/ovl_En_Gk/z_en_gk.c | 6 ++++++ src/overlays/actors/ovl_En_Gm/z_en_gm.c | 6 ++++++ src/overlays/actors/ovl_En_Go/z_en_go.c | 6 ++++++ src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c | 6 ++++++ src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c | 6 ++++++ src/overlays/actors/ovl_En_Gs/z_en_gs.c | 6 ++++++ src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c | 6 ++++++ src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c | 6 ++++++ src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c | 6 ++++++ src/overlays/actors/ovl_En_Hata/z_en_hata.c | 6 ++++++ src/overlays/actors/ovl_En_Heishi/z_en_heishi.c | 6 ++++++ src/overlays/actors/ovl_En_Hg/z_en_hg.c | 2 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 6 ++++++ src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 6 ++++++ src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 6 ++++++ src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c | 6 ++++++ src/overlays/actors/ovl_En_Horse/z_en_horse.c | 6 ++++++ .../actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c | 6 ++++++ .../actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c | 6 ++++++ src/overlays/actors/ovl_En_Hs/z_en_hs.c | 6 ++++++ src/overlays/actors/ovl_En_Hs2/z_en_hs2.c | 6 ++++++ src/overlays/actors/ovl_En_Ig/z_en_ig.c | 6 ++++++ src/overlays/actors/ovl_En_Ik/z_en_ik.c | 6 ++++++ src/overlays/actors/ovl_En_Insect/z_en_insect.c | 6 ++++++ .../actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c | 6 ++++++ .../actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c | 6 ++++++ src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 6 ++++++ src/overlays/actors/ovl_En_Ja/z_en_ja.c | 6 ++++++ src/overlays/actors/ovl_En_Jg/z_en_jg.c | 6 ++++++ src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 6 ++++++ src/overlays/actors/ovl_En_Js/z_en_js.c | 6 ++++++ src/overlays/actors/ovl_En_Jso/z_en_jso.c | 6 ++++++ src/overlays/actors/ovl_En_Jso2/z_en_jso2.c | 6 ++++++ src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c | 6 ++++++ src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c | 6 ++++++ src/overlays/actors/ovl_En_Kame/z_en_kame.c | 6 ++++++ src/overlays/actors/ovl_En_Kanban/z_en_kanban.c | 6 ++++++ src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c | 6 ++++++ src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 6 ++++++ src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 6 ++++++ src/overlays/actors/ovl_En_Kitan/z_en_kitan.c | 6 ++++++ src/overlays/actors/ovl_En_Knight/z_en_knight.c | 6 ++++++ src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c | 6 ++++++ src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 6 ++++++ src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 6 ++++++ src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c | 6 ++++++ src/overlays/actors/ovl_En_Light/z_en_light.c | 6 ++++++ src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 6 ++++++ src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c | 6 ++++++ src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c | 6 ++++++ src/overlays/actors/ovl_En_Mag/z_en_mag.c | 6 ++++++ src/overlays/actors/ovl_En_Maruta/z_en_maruta.c | 6 ++++++ src/overlays/actors/ovl_En_Minideath/z_en_minideath.c | 6 ++++++ src/overlays/actors/ovl_En_Mk/z_en_mk.c | 6 ++++++ src/overlays/actors/ovl_En_Mkk/z_en_mkk.c | 6 ++++++ src/overlays/actors/ovl_En_Mm/z_en_mm.c | 6 ++++++ src/overlays/actors/ovl_En_Mm2/z_en_mm2.c | 6 ++++++ src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 6 ++++++ src/overlays/actors/ovl_En_Mnk/z_en_mnk.c | 6 ++++++ src/overlays/actors/ovl_En_Ms/z_en_ms.c | 6 ++++++ src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c | 2 +- src/overlays/actors/ovl_En_Nb/z_en_nb.c | 6 ++++++ src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 6 ++++++ src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c | 6 ++++++ src/overlays/actors/ovl_En_Nnh/z_en_nnh.c | 6 ++++++ src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c | 6 ++++++ src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 6 ++++++ .../actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c | 6 ++++++ src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Okuta/z_en_okuta.c | 6 ++++++ src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c | 6 ++++++ src/overlays/actors/ovl_En_Osk/z_en_osk.c | 6 ++++++ src/overlays/actors/ovl_En_Osn/z_en_osn.c | 6 ++++++ src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 2 +- src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c | 2 +- src/overlays/actors/ovl_En_Paper/z_en_paper.c | 6 ++++++ src/overlays/actors/ovl_En_Part/z_en_part.c | 6 ++++++ src/overlays/actors/ovl_En_Peehat/z_en_peehat.c | 6 ++++++ src/overlays/actors/ovl_En_Pm/z_en_pm.c | 6 ++++++ src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c | 6 ++++++ src/overlays/actors/ovl_En_Pp/z_en_pp.c | 6 ++++++ src/overlays/actors/ovl_En_Pr/z_en_pr.c | 6 ++++++ src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 6 ++++++ src/overlays/actors/ovl_En_Prz/z_en_prz.c | 6 ++++++ src/overlays/actors/ovl_En_Pst/z_en_pst.c | 6 ++++++ src/overlays/actors/ovl_En_Racedog/z_en_racedog.c | 6 ++++++ src/overlays/actors/ovl_En_Raf/z_en_raf.c | 6 ++++++ src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 6 ++++++ src/overlays/actors/ovl_En_Rat/z_en_rat.c | 6 ++++++ src/overlays/actors/ovl_En_Rd/z_en_rd.c | 2 +- src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c | 6 ++++++ src/overlays/actors/ovl_En_Rg/z_en_rg.c | 6 ++++++ src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c | 6 ++++++ src/overlays/actors/ovl_En_Rr/z_en_rr.c | 6 ++++++ src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 6 ++++++ src/overlays/actors/ovl_En_Ru/z_en_ru.c | 6 ++++++ src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 6 ++++++ src/overlays/actors/ovl_En_Rz/z_en_rz.c | 6 ++++++ src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c | 6 ++++++ src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c | 6 ++++++ src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c | 6 ++++++ src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c | 6 ++++++ src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c | 6 ++++++ src/overlays/actors/ovl_En_Sda/z_en_sda.c | 6 ++++++ src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c | 6 ++++++ src/overlays/actors/ovl_En_Shn/z_en_shn.c | 6 ++++++ src/overlays/actors/ovl_En_Si/z_en_si.c | 6 ++++++ src/overlays/actors/ovl_En_Slime/z_en_slime.c | 6 ++++++ src/overlays/actors/ovl_En_Snowman/z_en_snowman.c | 6 ++++++ src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c | 6 ++++++ src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 6 ++++++ src/overlays/actors/ovl_En_St/z_en_st.c | 6 ++++++ src/overlays/actors/ovl_En_Sth/z_en_sth.c | 6 ++++++ src/overlays/actors/ovl_En_Sth2/z_en_sth2.c | 6 ++++++ src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c | 6 ++++++ src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c | 6 ++++++ src/overlays/actors/ovl_En_Stream/z_en_stream.c | 6 ++++++ src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c | 6 ++++++ .../actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c | 6 ++++++ .../actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 6 ++++++ src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c | 6 ++++++ src/overlays/actors/ovl_En_Tab/z_en_tab.c | 6 ++++++ src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c | 6 ++++++ src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c | 6 ++++++ src/overlays/actors/ovl_En_Talk/z_en_talk.c | 6 ++++++ src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c | 6 ++++++ src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c | 6 ++++++ src/overlays/actors/ovl_En_Test/z_en_test.c | 6 ++++++ src/overlays/actors/ovl_En_Test2/z_en_test2.c | 6 ++++++ src/overlays/actors/ovl_En_Test3/z_en_test3.c | 6 ++++++ src/overlays/actors/ovl_En_Test5/z_en_test5.c | 6 ++++++ src/overlays/actors/ovl_En_Test6/z_en_test6.c | 6 ++++++ src/overlays/actors/ovl_En_Test7/z_en_test7.c | 6 ++++++ src/overlays/actors/ovl_En_Tg/z_en_tg.c | 6 ++++++ src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Tk/z_en_tk.c | 6 ++++++ src/overlays/actors/ovl_En_Torch/z_en_torch.c | 6 ++++++ src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 6 ++++++ src/overlays/actors/ovl_En_Tru/z_en_tru.c | 6 ++++++ src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 6 ++++++ src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 6 ++++++ src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 6 ++++++ src/overlays/actors/ovl_En_Twig/z_en_twig.c | 6 ++++++ src/overlays/actors/ovl_En_Viewer/z_en_viewer.c | 6 ++++++ src/overlays/actors/ovl_En_Vm/z_en_vm.c | 6 ++++++ src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c | 6 ++++++ src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c | 6 ++++++ src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c | 6 ++++++ src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c | 6 ++++++ src/overlays/actors/ovl_En_Wiz/z_en_wiz.c | 6 ++++++ src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 6 ++++++ src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 6 ++++++ src/overlays/actors/ovl_En_Wood02/z_en_wood02.c | 6 ++++++ src/overlays/actors/ovl_En_Yb/z_en_yb.c | 6 ++++++ src/overlays/actors/ovl_En_Zl1/z_en_zl1.c | 6 ++++++ src/overlays/actors/ovl_En_Zl4/z_en_zl4.c | 6 ++++++ src/overlays/actors/ovl_En_Zo/z_en_zo.c | 6 ++++++ src/overlays/actors/ovl_En_Zob/z_en_zob.c | 6 ++++++ src/overlays/actors/ovl_En_Zod/z_en_zod.c | 6 ++++++ src/overlays/actors/ovl_En_Zog/z_en_zog.c | 6 ++++++ src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c | 6 ++++++ src/overlays/actors/ovl_En_Zos/z_en_zos.c | 6 ++++++ src/overlays/actors/ovl_En_Zot/z_en_zot.c | 2 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 6 ++++++ src/overlays/actors/ovl_En_Zow/z_en_zow.c | 6 ++++++ src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c | 6 ++++++ src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c | 6 ++++++ src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 6 ++++++ src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c | 6 ++++++ src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 6 ++++++ src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c | 6 ++++++ src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 6 ++++++ src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c | 6 ++++++ src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c | 6 ++++++ src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c | 6 ++++++ src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 6 ++++++ src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 6 ++++++ src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c | 6 ++++++ src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 6 ++++++ src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 6 ++++++ src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 6 ++++++ src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c | 6 ++++++ src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 6 ++++++ src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c | 6 ++++++ src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c | 6 ++++++ src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c | 6 ++++++ src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c | 6 ++++++ src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c | 6 ++++++ src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c | 6 ++++++ src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c | 6 ++++++ src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c | 6 ++++++ src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 6 ++++++ src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 6 ++++++ src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 6 ++++++ src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 6 ++++++ src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 6 ++++++ src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 6 ++++++ src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c | 6 ++++++ .../actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 6 ++++++ src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c | 6 ++++++ src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 6 ++++++ src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c | 6 ++++++ src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c | 6 ++++++ .../actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c | 6 ++++++ src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 6 ++++++ src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 6 ++++++ src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c | 6 ++++++ src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c | 6 ++++++ src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c | 6 ++++++ src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 6 ++++++ src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 6 ++++++ src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c | 6 ++++++ src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c | 6 ++++++ src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c | 6 ++++++ src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c | 6 ++++++ src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c | 6 ++++++ src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c | 6 ++++++ src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c | 6 ++++++ src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c | 6 ++++++ src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c | 6 ++++++ src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c | 6 ++++++ src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c | 6 ++++++ src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c | 6 ++++++ src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c | 6 ++++++ .../actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c | 6 ++++++ src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c | 6 ++++++ src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c | 6 ++++++ .../actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c | 6 ++++++ .../actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c | 6 ++++++ src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 6 ++++++ src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c | 6 ++++++ src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c | 6 ++++++ src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 6 ++++++ src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 6 ++++++ src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c | 6 ++++++ src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c | 6 ++++++ src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 6 ++++++ src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c | 6 ++++++ src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c | 6 ++++++ src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c | 6 ++++++ src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c | 6 ++++++ src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c | 6 ++++++ src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 6 ++++++ src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 6 ++++++ src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c | 6 ++++++ src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c | 6 ++++++ src/overlays/actors/ovl_TG_Sw/z_tg_sw.c | 6 ++++++ 479 files changed, 2844 insertions(+), 6 deletions(-) diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 62bac2109..a66535d79 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -1,3 +1,9 @@ +/* + * File: z_arms_hook.c + * Overlay: ovl_Arms_Hook + * Description: Hookshot tip + */ + #include "z_arms_hook.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 4cce3075e..a0f11082c 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -1,3 +1,9 @@ +/* + * File: z_arrow_fire.c + * Overlay: ovl_Arrow_Fire + * Description: Fire Arrow + */ + #include "z_arrow_fire.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 6a3b0ed18..b31185726 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -1,3 +1,9 @@ +/* + * File: z_arrow_light.c + * Overlay: ovl_Arrow_Light + * Description: Light Arrow + */ + #include "z_arrow_light.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index 2e48496c2..f2608b583 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_astr_bombwall.c + * Overlay: ovl_Bg_Astr_Bombwall + * Description: Astral Observatory - Bombable Wall + */ + #include "z_bg_astr_bombwall.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c index 086ca1c9d..7ca6678ff 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_botihasira.c + * Overlay: ovl_Bg_Botihasira + * Description: Captain Keeta Race - Gatepost + */ + #include "z_bg_botihasira.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index cb97f62a5..c67eece3d 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_breakwall.c + * Overlay: ovl_Bg_Breakwall + * Description: Great Bay Temple? (or the weather around it?) + */ + #include "z_bg_breakwall.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index dac778945..82e9c8a15 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_crace_movebg.c + * Overlay: ovl_Bg_Crace_Movebg + * Description: Huge sliding doors in Deku Shrine + */ + #include "z_bg_crace_movebg.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index 29fbd928d..00219105b 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_danpei_movebg.c + * Overlay: ovl_Bg_Danpei_Movebg + * Description: Moving platforms beneath Dampe's house + */ + #include "z_bg_danpei_movebg.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 03d9d60f6..9f2e18d9c 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dblue_balance.c + * Overlay: ovl_Bg_Dblue_Balance + * Description: Great Bay Temple - See-Saw + */ + #include "z_bg_dblue_balance.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index 708d13c6c..977c3ed8b 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dblue_elevator.c + * Overlay: ovl_Bg_Dblue_Elevator + * Description: Great Bay Temple - Elevator + */ + #include "z_bg_dblue_elevator.h" #define FLAGS 0x00000010 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 043b55d9f..aa4a32581 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dblue_movebg.c + * Overlay: ovl_Bg_Dblue_Movebg + * Description: Great Bay Temple - Waterwheels and push switches + */ + #include "z_bg_dblue_movebg.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index 97ddab138..fac369ac6 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dblue_waterfall.c + * Overlay: ovl_Bg_Dblue_Waterfall + * Description: Great Bay Temple - Freezable Geyser + */ + #include "z_bg_dblue_waterfall.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c index 5761c8585..9071dd520 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dkjail_ivy.c + * Overlay: ovl_Bg_Dkjail_Ivy + * Description: Ivy in Deku Jail + */ + #include "z_bg_dkjail_ivy.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 4e5993c5a..1423328a1 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_dy_yoseizo.c + * Overlay: ovl_Bg_Dy_Yoseizo + * Description: Great Fairy + */ + #include "z_bg_dy_yoseizo.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index 08c1a2fdd..e916d005c 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_f40_block.c + * Overlay: ovl_Bg_F40_Block + * Description: Stone Tower Block + */ + #include "z_bg_f40_block.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index e449bf6b4..fb8736181 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_f40_flift.c + * Overlay: ovl_Bg_F40_Flift + * Description: Stone Tower Temple - Grey Square Stone Elevator + */ + #include "z_bg_f40_flift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index ec1cf0553..45cfbf74c 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_f40_switch.c + * Overlay: ovl_Bg_F40_Switch + * Description: Stone Tower Switch + */ + #include "z_bg_f40_switch.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 48e3ef512..a4e20816b 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_f40_swlift.c + * Overlay: ovl_Bg_F40_Swlift + * Description: + */ + #include "z_bg_f40_swlift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c index ac802e3bf..1f959e827 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_fire_wall.c + * Overlay: ovl_Bg_Fire_Wall + * Description: Wall of fire spawned by ovl_Bg_Spout_Fire + */ + #include "z_bg_fire_wall.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index d85ace2f6..f9447ba03 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_fu_kaiten.c + * Overlay: ovl_Bg_Fu_Kaiten + * Description: Honey & Darling's Shop - Rotating Platform + */ + #include "z_bg_fu_kaiten.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index 27c04a7dd..dbfe2eaf4 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_fu_mizu.c + * Overlay: ovl_Bg_Fu_Mizu + * Description: + */ + #include "z_bg_fu_mizu.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index e38fc77cf..b0e79b3db 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_goron_oyu.c + * Overlay: ovl_Bg_Goron_Oyu + * Description: Goron Hot Spring Water + */ + #include "z_bg_goron_oyu.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c index 02d54c529..3c535326e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_haka_bombwall.c + * Overlay: ovl_Bg_Haka_Bombwall + * Description: Beneath the Grave - Bombable Wall + */ + #include "z_bg_haka_bombwall.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index 1274b0bdc..d6f3bdcdb 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_haka_curtain.c + * Overlay: ovl_Bg_Haka_Curtain + * Description: Curtain That Lifts to Reveal Flat's Tomb + */ + #include "z_bg_haka_curtain.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 34ad8fb1f..6a610470e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_haka_tomb.c + * Overlay: ovl_Bg_Haka_Tomb + * Description: Flat's Tomb + */ + #include "z_bg_haka_tomb.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index c211e16c2..4061745f7 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_hakugin_bombwall.c + * Overlay: ovl_Bg_Hakugin_Bombwall + * Description: Snowhead Temple - Bombable Wall + */ + #include "z_bg_hakugin_bombwall.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c index 5b5637090..52e1e5614 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_hakugin_elvpole.c + * Overlay: ovl_Bg_Hakugin_Elvpole + * Description: Raisable pillar in Snowhead Temple Map room + */ + #include "z_bg_hakugin_elvpole.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index 916b825d6..f4ca155bd 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_hakugin_switch.c + * Overlay: ovl_Bg_Hakugin_Switch + * Description: Goron Link Switch + */ + #include "z_bg_hakugin_switch.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index 8d77107c2..8ad7b2905 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_icefloe.c + * Overlay: ovl_Bg_Icefloe + * Description: Ice Platform Created by Ice Arrow + */ + #include "z_bg_icefloe.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index c9026f529..360e8b897 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_block.c + * Overlay: ovl_Bg_Ikana_Block + * Description: Stone Tower Temple - Rotating Room Pushblock + */ + #include "z_bg_ikana_block.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index acbdb6bc9..b1a0a19c1 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_bombwall.c + * Overlay: ovl_Bg_Ikana_Bombwall + * Description: Stone Tower Temple - Bombable Tan Floor Tile + */ + #include "z_bg_ikana_bombwall.h" #define FLAGS 0x10000000 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 350f45c20..8821fc5f4 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_dharma.c + * Overlay: ovl_Bg_Ikana_Dharma + * Description: Ikana Castle - Punchable Pillar Segments + */ + #include "z_bg_ikana_dharma.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index 1e723ce82..6b72aba38 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_mirror.c + * Overlay: ovl_Bg_Ikana_Mirror + * Description: Stone Tower Temple - Mirror + */ + #include "z_bg_ikana_mirror.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index 10be85765..bc3ee7880 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_ray.c + * Overlay: ovl_Bg_Ikana_Ray + * Description: Large light ray in Stone Tower Temple + */ + #include "z_bg_ikana_ray.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index ada046457..f4263f783 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_rotaryroom.c + * Overlay: ovl_Bg_Ikana_Rotaryroom + * Description: Stone Tower Temple - Rotating Room + */ + #include "z_bg_ikana_rotaryroom.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 986b8b8ae..9d5a36ba5 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikana_shutter.c + * Overlay: ovl_Bg_Ikana_Shutter + * Description: Metal shutter in switch room of Stone Tower Temple + */ + #include "z_bg_ikana_shutter.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 123a1248f..5b68e1363 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_iknin_susceil.c + * Overlay: ovl_Bg_Iknin_Susceil + * Description: Ikana Castle - Hot Checkered Ceiling + */ + #include "z_bg_iknin_susceil.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index f5c7ea607..3b3b21172 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ikninside.c + * Overlay: ovl_Bg_Ikninside + * Description: Ancient Castle of Ikana Objects + */ + #include "z_bg_ikninside.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c index 980d20f93..67d95a2e4 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_iknv_doukutu.c + * Overlay: ovl_Bg_Iknv_Doukutu + * Description: Sharp's Cave + */ + #include "z_bg_iknv_doukutu.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index caa4021f1..8c6380aaf 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_iknv_obj.c + * Overlay: ovl_Bg_Iknv_Obj + * Description: Ikana - waterwheel, stone tower door, sakon's hideout door + */ + #include "z_bg_iknv_obj.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index d374c5fa1..152240528 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_ingate.c + * Overlay: ovl_Bg_Ingate + * Description: Swamp Tour Boat + */ + #include "z_bg_ingate.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c index f31b9da3b..817cda67e 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_inibs_movebg.c + * Overlay: ovl_Bg_Inibs_Movebg + * Description: Twinmold Arena + */ + #include "z_bg_inibs_movebg.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c index b5ba51a05..0e7488a9a 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_keikoku_saku.c + * Overlay: ovl_Bg_Keikoku_Saku + * Description: Termina Field Spiked Fence + */ + #include "z_bg_keikoku_saku.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c index 116d6d5f7..5abeab5f0 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_kin2_bombwall.c + * Overlay: ovl_Bg_Kin2_Bombwall + * Description: Ocean Spider House - Bombable Wall + */ + #include "z_bg_kin2_bombwall.h" #define FLAGS 0x10000010 diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 2d1fb8ca2..39b22417c 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_kin2_fence.c + * Overlay: ovl_Bg_Kin2_Fence + * Description: Ocean Spider House - Fireplace Grate + */ + #include "z_bg_kin2_fence.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c index 01ec6fcda..c646c3e6c 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_kin2_picture.c + * Overlay: ovl_Bg_Kin2_Picture + * Description: Ocean Spider House - Skullkid Painting + */ + #include "z_bg_kin2_picture.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index a9c0a2dec..cf09d0896 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_kin2_shelf.c + * Overlay: ovl_Bg_Kin2_Shelf + * Description: Ocean Spider House - Drawers + */ + #include "z_bg_kin2_shelf.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index 3e1eb0d0c..0e3a88029 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_last_bwall.c + * Overlay: ovl_Bg_Last_Bwall + * Description: Link Moon Dungeon - Bombable, Climbable Wall + */ + #include "z_bg_last_bwall.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c index 673f41e20..2b77f73ac 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_lbfshot.c + * Overlay: ovl_Bg_Lbfshot + * Description: Rainbow Hookshot Pillar + */ + #include "z_bg_lbfshot.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index bf31ff8e7..b5b13cd7c 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_market_step.c + * Overlay: ovl_Bg_Market_Step + * Description: West Clocktown - Stairs + */ + #include "z_bg_market_step.h" #define FLAGS 0x10000020 diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c index bc3dc17dc..43022630a 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_mbar_chair.c + * Overlay: ovl_Bg_Mbar_Chair + * Description: Milk Bar - Chair + */ + #include "z_bg_mbar_chair.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index f4e95a2b1..62ae7ab8a 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_numa_hana.c + * Overlay: ovl_Bg_Numa_Hana + * Description: Big wooden flower in Woodfall Temple + */ + #include "z_bg_numa_hana.h" #define FLAGS 0x00000410 diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index 5b79969dd..94a148c17 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_open_shutter.c + * Overlay: ovl_Bg_Open_Shutter + * Description: + */ + #include "z_bg_open_shutter.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index fe5ce47b7..8657a40db 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_open_spot.c + * Overlay: ovl_Bg_Open_Spot + * Description: Star Light Rays in Intro Scene + */ + #include "z_bg_open_spot.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 0c8c72087..8e443f529 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_sinkai_kabe.c + * Overlay: ovl_Bg_Sinkai_Kabe + * Description: Large Rotating Green Rupee + */ + #include "z_bg_sinkai_kabe.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index ff0c8ad3e..6fccf89a0 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_spdweb.c + * Overlay: ovl_Bg_Spdweb + * Description: Spiderweb + */ + #include "z_bg_spdweb.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c index ab783a5ad..08a7087e3 100644 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c +++ b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_spout_fire.c + * Overlay: ovl_Bg_Spout_Fire + * Description: Proximity-Activated Fire Wall Spawner + */ + #include "z_bg_spout_fire.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 72b196ab0..506b508b2 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_tobira01.c + * Overlay: ovl_Bg_Tobira01 + * Description: Gate to Goron Shrine + */ + #include "z_bg_tobira01.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c index a501fd117..72aa44fb7 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_umajump.c + * Overlay: ovl_Bg_Umajump + * Description: Horse Jumping Fence + */ + #include "z_bg_umajump.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 54264e0dc..467911ca9 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_01.c + * Overlay: ovl_Boss_01 + * Description: Odolwa + */ + #include "z_boss_01.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index c2d70bb36..df36e8e2d 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_02.c + * Overlay: ovl_Boss_02 + * Description: Twinmold + */ + #include "z_boss_02.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 7e335424b..ce8551aa7 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_03.c + * Overlay: ovl_Boss_03 + * Description: Gyorg + */ + #include "z_boss_03.h" #define FLAGS 0x00000035 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 58fd9a26e..3e3ca12c1 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_04.c + * Overlay: ovl_Boss_04 + * Description: Wart + */ + #include "z_boss_04.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index 190b4693d..a8122fdaa 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_05.c + * Overlay: ovl_Boss_05 + * Description: Bio Deku Baba + */ + #include "z_boss_05.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index ed04e008d..9e38aaccb 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_06.c + * Overlay: ovl_Boss_06 + * Description: Igos du Ikana window - curtains and ray effects + */ + #include "z_boss_06.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index 6c549b217..d5e0e22ed 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_07.c + * Overlay: ovl_Boss_07 + * Description: Majora + */ + #include "z_boss_07.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 447c6c568..333d2a89f 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -1,3 +1,9 @@ +/* + * File: z_boss_hakugin.c + * Overlay: ovl_Boss_Hakugin + * Description: Goht + */ + #include "z_boss_hakugin.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 53bf05fd2..17435de3d 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_effect.c + * Overlay: ovl_Demo_Effect + * Description: Obtaining Masks (?) + */ + #include "z_demo_effect.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 0853cc8b6..1d39dc022 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_getitem.c + * Overlay: ovl_Demo_Getitem + * Description: + */ + #include "z_demo_getitem.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 61ff3f7a2..fcf3e0dec 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_kankyo.c + * Overlay: ovl_Demo_Kankyo + * Description: Background Lost Woods/Giant's Chamber/Moon Particles + */ + #include "z_demo_kankyo.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index 50b340953..ab3cf474f 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_moonend.c + * Overlay: ovl_Demo_Moonend + * Description: Moon Disappearing (cutscene) + */ + #include "z_demo_moonend.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c index d68e977e4..f7001b489 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_shd.c + * Overlay: ovl_Demo_Shd + * Description: + */ + #include "z_demo_shd.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index f4b42e580..2fb5a86da 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_syoten.c + * Overlay: ovl_Demo_Syoten + * Description: + */ + #include "z_demo_syoten.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 32e38897a..d4ce73419 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -1,3 +1,9 @@ +/* + * File: z_demo_tre_lgt.c + * Overlay: ovl_Demo_Tre_Lgt + * Description: Light Radiating From Treasure Chest + */ + #include "z_demo_tre_lgt.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c index ed3aae49d..3a84e6b39 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_ah.c + * Overlay: ovl_Dm_Ah + * Description: Anju's Mother (cutscene) + */ + #include "z_dm_ah.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index 549cf52ca..f61a8f74e 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_al.c + * Overlay: ovl_Dm_Al + * Description: Madame Aroma (cutscene) + */ + #include "z_dm_al.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index f780f8de3..865cbeef0 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_an.c + * Overlay: ovl_Dm_An + * Description: Anju (cutscene) + */ + #include "z_dm_an.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index 76b41dbc6..4394c6109 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_bal.c + * Overlay: ovl_Dm_Bal + * Description: Tingle (cutscene) + */ + #include "z_dm_bal.h" #define FLAGS 0x02000019 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 43e140a51..db345ab3a 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char00.c + * Overlay: ovl_Dm_Char00 + * Description: Tatl (cutscene) + */ + #include "z_dm_char00.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 22f51085b..b98ad4329 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char01.c + * Overlay: ovl_Dm_Char01 + * Description: Tatl and Tael (cutscene) + */ + #include "z_dm_char01.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 4f379784c..46ed5e619 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char02.c + * Overlay: ovl_Dm_Char02 + * Description: + */ + #include "z_dm_char02.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index 5baff6c4a..b5e6c8742 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char03.c + * Overlay: ovl_Dm_Char03 + * Description: + */ + #include "z_dm_char03.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index 698eba116..6a09de8b5 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char04.c + * Overlay: ovl_Dm_Char04 + * Description: + */ + #include "z_dm_char04.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 67d59b3cf..1f61d302f 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char05.c + * Overlay: ovl_Dm_Char05 + * Description: Cutscene mask objects + */ + #include "z_dm_char05.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index e23886630..6dd180e21 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char06.c + * Overlay: ovl_Dm_Char06 + * Description: Some unseen Mountain Village cutscene actor? + */ + #include "z_dm_char06.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c index ed83d46f3..aa0357ef2 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char08.c + * Overlay: ovl_Dm_Char08 + * Description: Large Great Bay Turtle + */ + #include "z_dm_char08.h" #define FLAGS 0x02000000 diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index ef98424c3..490800ea9 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char09.c + * Overlay: ovl_Dm_Char09 + * Description: Pirates' Fortress cutscene characters + */ + #include "z_dm_char09.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 4f1440dd5..c6499f0ee 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_gm.c + * Overlay: ovl_Dm_Gm + * Description: Anju (cutscene) (duplicate of Dm_An?) + */ + #include "z_dm_gm.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c index 0bec5d023..187e93514 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_hina.c + * Overlay: ovl_Dm_Hina + * Description: Boss mask cutscene objects + */ + #include "z_dm_hina.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index 531c293ce..6f22be2ff 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_opstage.c + * Overlay: ovl_Dm_Opstage + * Description: Lost Woods cutscene objects + */ + #include "z_dm_opstage.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 02101b113..9460d405a 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_sa.c + * Overlay: ovl_Dm_Sa + * Description: + */ + #include "z_dm_sa.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index 566c6f614..b3b3b3e28 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_statue.c + * Overlay: ovl_Dm_Statue + * Description: Elegy of Emptiness - Beam of Light When Creating Statue + */ + #include "z_dm_statue.h" #define FLAGS 0x04000030 diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index efeb8a82c..154b1dba0 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_stk.c + * Overlay: ovl_Dm_Stk + * Description: Skull Kid (cutscene) + */ + #include "z_dm_stk.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c index 59fe0236b..80eb930fd 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_tag.c + * Overlay: ovl_Dm_Tag + * Description: + */ + #include "z_dm_tag.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c index 5abb5d8f9..b3c11b83e 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_tsg.c + * Overlay: ovl_Dm_Tsg + * Description: Handles all the masks scrolling by as Link falls in the intro + */ + #include "z_dm_tsg.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index 7b724b9f4..993dbc320 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_zl.c + * Overlay: ovl_Dm_Zl + * Description: Child Zelda (Cutscenes) + */ + #include "z_dm_zl.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 4db7316e4..2b5a76a49 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -1,3 +1,9 @@ +/* + * File: z_door_ana.c + * Overlay: ovl_Door_Ana + * Description: Grotto Hole Entrance + */ + #include "z_door_ana.h" #define FLAGS 0x02000000 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 7b870e03d..44f699298 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -1,3 +1,9 @@ +/* + * File: z_door_shutter.c + * Overlay: ovl_Door_Shutter + * Description: Studded Lifting Door / Ikana Castle Rolling Door + */ + #include "z_door_shutter.h" #define FLAGS 0x00000010 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 1978756a2..1716721de 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -1,3 +1,9 @@ +/* + * File: z_door_spiral.c + * Overlay: ovl_Door_Spiral + * Description: Staircase + */ + #include "z_door_spiral.h" #define FLAGS 0x00000010 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 0759321af..22e249861 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1,3 +1,9 @@ +/* + * File: z_door_warp1.c + * Overlay: ovl_Door_Warp1 + * Description: Blue Warp + */ + #include "z_door_warp1.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index f9f6a77f8..339a08076 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -1,3 +1,9 @@ +/* + * File: z_eff_change.c + * Overlay: ovl_Eff_Change + * Description: + */ + #include "z_eff_change.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index d127a76a0..7b982d25c 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -1,3 +1,9 @@ +/* + * File z_eff_kamejima_wave.c + * Overlay: ovl_Eff_Kamejima_Wave + * Description: Wave Created by Turtle Awakening + */ + #include "z_eff_kamejima_wave.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 378fe8e3b..7812faa9b 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -1,3 +1,9 @@ +/* + * File z_eff_lastday.c + * Overlay: ovl_Eff_Lastday + * Description: Moon Crash Cutscene Fire Wall + */ + #include "z_eff_lastday.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index 7e114b311..dcc61493a 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -1,3 +1,9 @@ +/* + * File z_eff_stk.c + * Overlay: ovl_Eff_Stk + * Description: Skullkid Effects (calling down moon / cursing Link) + */ + #include "z_eff_stk.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index ff1ee7986..6ffafb311 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -1,3 +1,9 @@ +/* + * File z_eff_zoraband.c + * Overlay: ovl_Eff_Zoraband + * Description: + */ + #include "z_eff_zoraband.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index bf27f5e21..7c7a39a2c 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg.c + * Overlay: ovl_Elf_Msg + * Description: Tatl Hint (proximity-activated C-up hint?) + */ + #include "z_elf_msg.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index 4ebc208fe..014f61c43 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg2.c + * Overlay: ovl_Elf_Msg2 + * Description: Tatl Hint (Z-target-activated C-up hint?) + */ + #include "z_elf_msg2.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index fd457ac2a..6e84cccf2 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg3.c + * Overlay: ovl_Elf_Msg3 + * Description: Tatl Message (Proximity-activated dialogue?) + */ + #include "z_elf_msg3.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index 3c0d1cca4..eefe99063 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg4.c + * Overlay: ovl_Elf_Msg4 + * Description: Tatl Hint (another proximity-activated C-up hint?) + */ + #include "z_elf_msg4.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index abd811d28..371fa7f22 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg5.c + * Overlay: ovl_Elf_Msg5 + * Description: Tatl Message (Another proximity-activated dialogue?) + */ + #include "z_elf_msg5.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index ec07f5fef..ea9e79df6 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -1,3 +1,9 @@ +/* + * File z_elf_msg6.c + * Overlay: ovl_Elf_Msg6 + * Description: Tatl Hint (another proximity-activated C-up hint?) + */ + #include "z_elf_msg6.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 1f68470d9..da7721152 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -1,3 +1,9 @@ +/* + * File z_en_ah.c + * Overlay: ovl_En_Ah + * Description: Anju's Mother + */ + #include "z_en_ah.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index abbc3dfea..191b35ec9 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1,3 +1,9 @@ +/* + * File z_en_akindonuts.c + * Overlay: ovl_En_Akindonuts + * Description: Woodfall - Business Scrub + */ + #include "z_en_akindonuts.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 239997d36..66eb513b9 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -1,3 +1,9 @@ +/* + * File z_en_al.c + * Overlay: ovl_En_Al + * Description: Madame Aroma + */ + #include "z_en_al.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 411b25f2b..37a38a9e8 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -1,3 +1,9 @@ +/* + * File z_en_am.c + * Overlay: ovl_En_Am + * Description: Armos + */ + #include "z_en_am.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 285d33447..9611e2c76 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -1,3 +1,9 @@ +/* + * File z_en_an.c + * Overlay: ovl_En_An + * Description: Anju + */ + #include "z_en_an.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index 96de4702b..178674efd 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -1,3 +1,9 @@ +/* + * File z_en_and.c + * Overlay: ovl_En_And + * Description: Anju in Wedding Dress + */ + #include "z_en_and.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 9f8d2e22b..5571fe73c 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -1,3 +1,9 @@ +/* + * File z_en_ani.c + * Overlay: ovl_En_Ani + * Description: Part-Timer + */ + #include "z_en_ani.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 54af774ac..fe0312f3b 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -1,3 +1,9 @@ +/* + * File z_en_aob_01.c + * Overlay: ovl_En_Aob_01 + * Description: Mamamu Yan + */ + #include "z_en_aob_01.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index a4bacc799..bd2e07b57 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -1,3 +1,9 @@ +/* + * File z_en_arrow.c + * Overlay: ovl_En_Arrow + * Description: Arrows and other projectiles + */ + #include "z_en_arrow.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index c1342a0f3..9e7f4be9c 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -1,3 +1,9 @@ +/* + * File z_en_attack_niw.c + * Overlay: ovl_En_Attack_Niw + * Description: Attacking cucco + */ + #include "z_en_attack_niw.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index 6ce1660e9..5af1dac54 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -1,3 +1,9 @@ +/* + * File z_en_az.c + * Overlay: ovl_En_Az + * Description: Beaver Bros + */ + #include "z_en_az.h" #define FLAGS 0x80000010 diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 8c9021927..afe4f44ca 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -1,3 +1,9 @@ +/* + * File z_en_baba.c + * Overlay: ovl_En_Baba + * Description: Bomb Shop Lady + */ + #include "z_en_baba.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 52df1b78e..edfd63ede 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -1,3 +1,9 @@ +/* + * File z_en_baguo.c + * Overlay: ovl_En_Baguo + * Description: Nejiron + */ + #include "z_en_baguo.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index 8c284396d..aa48ac9c6 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -1,3 +1,9 @@ +/* + * File z_en_bal.c + * Overlay: ovl_En_Bal + * Description: Tingle With Balloon + */ + #include "z_en_bal.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index 4fb3df60a..de2330bb8 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -1,3 +1,9 @@ +/* + * File z_en_bat.c + * Overlay: ovl_En_Bat + * Description: Bad Bat + */ + #include "z_en_bat.h" #define FLAGS 0x00005005 diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 0d12dfc46..cfbb8240e 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -1,3 +1,9 @@ +/* + * File z_en_bb.c + * Overlay: ovl_En_Bb + * Description: Blue Bubble + */ + #include "z_en_bb.h" #define FLAGS 0x00000205 diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 9057a9672..5a393e7c2 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -1,3 +1,9 @@ +/* + * File z_en_bba_01.c + * Overlay: ovl_En_Bba_01 + * Description: + */ + #include "z_en_bba_01.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index df6ef4f5c..97c44ce5f 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -1,3 +1,9 @@ +/* + * File z_en_bbfall.c + * Overlay: ovl_En_Bbfall + * Description: Red Bubble + */ + #include "z_en_bbfall.h" #define FLAGS 0x00000215 diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index ca3c3decb..eeb8af33c 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -1,3 +1,9 @@ +/* + * File z_en_bee.c + * Overlay: ovl_En_Bee + * Description: Giant Bee + */ + #include "z_en_bee.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index 1bc0ea082..fdffeca26 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -1,3 +1,9 @@ +/* + * File z_en_bh.c + * Overlay: ovl_En_Bh + * Description: Brown Bird + */ + #include "z_en_bh.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 8f11c38c8..364e1205f 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -1,3 +1,9 @@ +/* + * File z_en_bigokuta.c + * Overlay: ovl_En_Bigokuta + * Description: Big Octo + */ + #include "z_en_bigokuta.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index ebfc25ddb..a1d663f61 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -1,3 +1,9 @@ +/* + * File z_en_bigpamet.c + * Overlay: ovl_En_Bigpamet + * Description: Gekko & Snapper Miniboss - Snapper + */ + #include "z_en_bigpamet.h" #define FLAGS 0x00000435 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 6aaa77956..2d2ad5a3f 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1,3 +1,9 @@ +/* + * File z_en_bigslime.c + * Overlay: ovl_En_Bigslime + * Description: Mad Jelly (miniboss) + */ + #include "z_en_bigslime.h" #define FLAGS 0x00000235 diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index b08295107..c09bb4cea 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -1,3 +1,9 @@ +/* + * File z_en_bjt.c + * Overlay: ovl_En_Bjt + * Description: Hand in Toilet + */ + #include "z_en_bjt.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index 5981567e7..9a3304b8a 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c @@ -1,3 +1,9 @@ +/* + * File z_en_boj_01.c + * Overlay: ovl_En_Boj_01 + * Description: [Empty] + */ + #include "z_en_boj_01.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c index 602a1016e..19b384d7f 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c @@ -1,3 +1,9 @@ +/* + * File z_en_boj_02.c + * Overlay: ovl_En_Boj_02 + * Description: [Empty] + */ + #include "z_en_boj_02.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c index 6c5736858..4391e59fb 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c @@ -1,3 +1,9 @@ +/* + * File z_en_boj_03.c + * Overlay: ovl_En_Boj_03 + * Description: [Empty] + */ + #include "z_en_boj_03.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c index 1cfd102ef..4fea47b30 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c @@ -1,3 +1,9 @@ +/* + * File z_en_boj_04.c + * Overlay: ovl_En_Boj_04 + * Description: [Empty] + */ + #include "z_en_boj_04.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c index 8513d0f95..b327b381c 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c @@ -1,3 +1,9 @@ +/* + * File z_en_boj_05.c + * Overlay: ovl_En_Boj_05 + * Description: [Empty] + */ + #include "z_en_boj_05.h" #define FLAGS 0x00000019 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 62e63c7e9..acb36d258 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -1,3 +1,9 @@ +/* + * File z_en_bom.c + * Overlay: ovl_En_Bom + * Description: Bomb / Powder Keg + */ + #include "z_en_bom.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index dec58fb36..919fd5798 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -1,3 +1,9 @@ +/* + * File z_en_bom_bowl_man.c + * Overlay: ovl_En_Bom_Bowl_Man + * Description: Line of Bombers? + */ + #include "z_en_bom_bowl_man.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index e6e584bb8..3dabe557b 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -1,3 +1,9 @@ +/* + * File z_en_bom_chu.c + * Overlay: ovl_En_Bom_Chu + * Description: Bombchus + */ + #include "z_en_bom_chu.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c index 75eb00e81..134dc1042 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -1,3 +1,9 @@ +/* + * File z_en_bombal.c + * Overlay: ovl_En_Bombal + * Description: Bombers - Majora Balloon + */ + #include "z_en_bombal.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 7786d5c03..4bd648dea 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -1,3 +1,9 @@ +/* + * File z_en_bombers.c + * Overlay: ovl_En_Bombers + * Description: Bombers - Blue-Hatted Bomber + */ + #include "z_en_bombers.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 6d7a8d43a..478b117d7 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -1,3 +1,9 @@ +/* + * File z_en_bombers2.c + * Overlay: ovl_En_Bombers2 + * Description: Bombers - Hideout Guard + */ + #include "z_en_bombers2.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 8456301cd..e40ff2efb 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -1,3 +1,9 @@ +/* + * File z_en_bombf.c + * Overlay: ovl_En_Bombf + * Description: Bomb flower + */ + #include "z_en_bombf.h" #define FLAGS 0x00000011 diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 64336e59d..0562e8dc4 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -1,3 +1,9 @@ +/* + * File z_en_bomjima.c + * Overlay: ovl_En_Bomjima + * Description: Bombers - Jim + */ + #include "z_en_bomjima.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 9833d0d77..f8c22c44f 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -1,3 +1,9 @@ +/* + * File z_en_bomjimb.c + * Overlay: ovl_En_Bomjimb + * Description: Bomber Jim B + */ + #include "z_en_bomjimb.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index ffc840165..99efd7f3d 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -1,3 +1,9 @@ +/* + * File z_en_boom.c + * Overlay: ovl_En_Boom + * Description: Zora boomerangs + */ + #include "z_en_boom.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 46fb32162..f3a2d835c 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -1,3 +1,9 @@ +/* + * File z_en_box.c + * Overlay: ovl_En_Box + * Description: Chest + */ + #include "z_en_box.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index bbf95860c..0bb1f7e29 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -1,3 +1,9 @@ +/* + * File z_en_bsb.c + * Overlay: ovl_En_Bsb + * Description: Captain Keeta + */ + #include "z_en_bsb.h" #define FLAGS 0x02000035 diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 8a7d39086..4bd1e310f 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -1,3 +1,9 @@ +/* + * File z_en_bu.c + * Overlay: ovl_En_Bu + * Description: Unused dummied-out enemy + */ + #include "z_en_bu.h" #define FLAGS 0x00000001 diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index 4a78ad3dc..4cddd0d54 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -1,3 +1,9 @@ +/* + * File z_en_bubble.c + * Overlay: ovl_En_Bubble + * Description: Bubble (flying skull enemy) + */ + #include "z_en_bubble.h" #define FLAGS 0x00000001 diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 50ecc46fd..e8b2dceb4 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -1,3 +1,9 @@ +/* + * File z_en_butte.c + * Overlay: ovl_En_Butte + * Description: Butterflies + */ + #include "z_en_butte.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index fa6a977f9..fcb693e71 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -1,3 +1,9 @@ +/* + * File z_en_cne_01.c + * Overlay: ovl_En_Cne_01 + * Description: + */ + #include "z_en_cne_01.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index a81f6a24a..d6d7f4100 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -1,3 +1,9 @@ +/* + * File z_en_col_man.c + * Overlay: ovl_En_Col_Man + * Description: Gives you a Piece of Heart when you touch it? + */ + #include "z_en_col_man.h" #define FLAGS 0x00100000 diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 6a76160bb..84f6928a7 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -1,3 +1,9 @@ +/* + * File z_en_cow.c + * Overlay: ovl_En_Cow + * Description: Cow + */ + #include "z_en_cow.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index dc32a698e..b4dead243 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -1,3 +1,9 @@ +/* + * File z_en_crow.c + * Overlay: ovl_En_Crow + * Description: Guay + */ + #include "z_en_crow.h" #define FLAGS 0x00005005 diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index f309102bc..e47822ed8 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -1,3 +1,9 @@ +/* + * File z_en_death.c + * Overlay: ovl_En_Death + * Description: Gomess + */ + #include "z_en_death.h" #define FLAGS 0x00001035 diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index ecfd20483..421495be7 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -1,3 +1,9 @@ +/* + * File z_en_dekubaba.c + * Overlay: ovl_En_Dekubaba + * Description: Deku Baba + */ + #include "z_en_dekubaba.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index 18cc974ed..a1cda6362 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -1,3 +1,9 @@ +/* + * File z_en_demo_heishi.c + * Overlay: ovl_En_Demo_heishi + * Description: Unused(?) version of Shiro + */ + #include "z_en_demo_heishi.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c index 21071691e..ecd6e8ffc 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -1,3 +1,9 @@ +/* + * File: z_en_dnh.c + * Overlay: ovl_En_Dnh + * Description: Koume in boat house + */ + #include "z_en_dnh.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 894f11b48..a410aabdd 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -1,3 +1,9 @@ +/* + * File: z_en_door.c + * Overlay: ovl_En_Door + * Description: Wooden Door + */ + #include "z_en_door.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 074739aa1..688aa7a42 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -1,3 +1,9 @@ +/* + * File: z_en_door_etc.c + * Overlay: ovl_En_Door_Etc + * Description: Wooden Door + */ + #include "z_en_door_etc.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 8c16469f8..2068ca8ff 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -1,3 +1,9 @@ +/* + * File: z_en_dragon.c + * Overlay: ovl_En_Dragon + * Description: Deep Python + */ + #include "z_en_dragon.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 3cc504594..81acb58cf 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -1,3 +1,9 @@ +/* + * File: z_en_drs.c + * Overlay: ovl_En_Drs + * Description: Wedding dress manequin + */ + #include "z_en_drs.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index bf8d4b1db..ab0c54888 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ds2n.c + * Overlay: ovl_En_Ds2n + * Description: + */ + #include "z_en_ds2n.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/src/overlays/actors/ovl_En_Dt/z_en_dt.c index 57e89b76b..d76c0c919 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -1,3 +1,9 @@ +/* + * File: z_en_dt.c + * Overlay: ovl_En_Dt + * Description: Mayor Dotour + */ + #include "z_en_dt.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index fbecb97a5..a67805e57 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -1,3 +1,9 @@ +/* + * File: z_en_dy_extra.c + * Overlay: ovl_En_Dy_Extra + * Description: Great Fairy beam + */ + #include "z_en_dy_extra.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c index 1dd7541b6..8d72af042 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -1,3 +1,9 @@ +/* + * File: z_en_egblock.c + * Overlay: ovl_En_Egblock + * Description: Eyegore Block + */ + #include "z_en_egblock.h" #define FLAGS 0x08000000 diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index a005e8b57..fe3e0e09e 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -1,3 +1,9 @@ +/* + * File: z_en_egol.c + * Overlay: ovl_En_Egol + * Description: Eyegore + */ + #include "z_en_egol.h" #define FLAGS 0x80000035 diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index be9f5de3a..1af159e0b 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1,3 +1,9 @@ +/* + * File: z_en_elf.c + * Overlay: ovl_En_Elf + * Description: Fairies + */ + #include "z_en_elf.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 0da225746..bb19fa61a 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -1,3 +1,9 @@ +/* + * File: z_en_elfgrp.c + * Overlay: ovl_En_Elfgrp + * Description: Group of Stray Fairies in Fairy Fountain + */ + #include "z_en_elfgrp.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 3d8c9161c..94641b569 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -1,3 +1,9 @@ +/* + * File: z_en_encount1.c + * Overlay: ovl_En_Encount1 + * Description: + */ + #include "z_en_encount1.h" #define FLAGS 0x08100010 diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index ba444eb6c..6071137ce 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_encount2.c + * Overlay: ovl_En_Encount2 + * Description: Astral Observatory - Majora's Mask Balloon + */ + #include "z_en_encount2.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c index 13ba1ea33..0a4a55c4b 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_encount3.c + * Overlay: ovl_En_Encount3 + * Description: + */ + #include "z_en_encount3.h" #define FLAGS 0x08000030 diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index 99c17f7c0..5a0bc632a 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -1,3 +1,9 @@ +/* + * File: z_en_encount4.c + * Overlay: ovl_En_Encount4 + * Description: + */ + #include "z_en_encount4.h" #define FLAGS 0x08000010 diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index 089ee3788..3206eef53 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero.c + * Overlay: ovl_En_Ending_Hero + * Description: + */ + #include "z_en_ending_hero.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index 0ff95496d..d6864d741 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero2.c + * Overlay: ovl_En_Ending_Hero2 + * Description: + */ + #include "z_en_ending_hero2.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 91a42c409..4a39d382a 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero3.c + * Overlay: ovl_En_Ending_Hero3 + * Description: + */ + #include "z_en_ending_hero3.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 949999b57..46fca27d6 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero4.c + * Overlay: ovl_En_Ending_Hero4 + * Description: + */ + #include "z_en_ending_hero4.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index 1e392ef12..b7b3d6b8e 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ending_hero5.c + * Overlay: ovl_En_Ending_Hero5 + * Description: + */ + #include "z_en_ending_hero5.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.c b/src/overlays/actors/ovl_En_Estone/z_en_estone.c index a3cd6bd21..7cc45bb5a 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -1,3 +1,9 @@ +/* + * File: z_en_estone.c + * Overlay: ovl_En_Estone + * Description: Eyegore Rubble + */ + #include "z_en_estone.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index f56948ded..43582bf26 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fall.c + * Overlay: ovl_En_Fall + * Description: The Moon and related effects + */ + #include "z_en_fall.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index 48514fd82..a9e27fec7 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fall2.c + * Overlay: ovl_En_Fall2 + * Description: "Warp Beam" from Moon's Mouth in Cutscene? + */ + #include "z_en_fall2.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 6636923a4..de24735c7 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -1,3 +1,9 @@ +/* + * File: z_en_famos.c + * Overlay: ovl_En_Famos + * Description: Death Armos + */ + #include "z_en_famos.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index f4fb5dff8..765e69488 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fire_rock.c + * Overlay: ovl_En_Fire_Rock + * Description: [Empty] + */ + #include "z_en_fire_rock.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c index 9806e5cea..62417b95e 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_firefly2.c + * Overlay: ovl_En_Firefly2 + * Description: [Empty] + */ + #include "z_en_firefly2.h" #define FLAGS 0x00005015 diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index ab615c304..61f08534b 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fish.c + * Overlay: ovl_En_Fish + * Description: Fish + */ + #include "z_en_fish.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 0cf1d6401..f804e398a 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -1,3 +1,9 @@ +/* + * File: z_en_floormas.c + * Overlay: ovl_En_Floormas + * Description: Floormaster + */ + #include "z_en_floormas.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index d8293b010..fb8749a11 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fr.c + * Overlay: ovl_En_Fr + * Description: + */ + #include "z_en_fr.h" #define FLAGS 0x40000000 diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ed55f1055..ec03de695 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fu_kago.c + * Overlay: ovl_En_Fu_Kago + * Description: Honey & Darling's Shop - Bomb Basket + */ + #include "z_en_fu_kago.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 3963a7eb9..400bd6d67 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fu_mato.c + * Overlay: ovl_En_Fu_Mato + * Description: Honey & Darling's Shop - Target + */ + #include "z_en_fu_mato.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index abf79af80..e48b3d169 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -1,3 +1,9 @@ +/* + * File: z_en_fz.c + * Overlay: ovl_En_Fz + * Description: Freezard + */ + #include "z_en_fz.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 4bea50eb4..c5f663108 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gakufu.c + * Overlay: ovl_En_Gakufu + * Description: Termina Field - 2D Song Buttons Appearing on Wall + */ + #include "z_en_gakufu.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index e80c311d1..590949028 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gamelupy.c + * Overlay: ovl_En_Gamelupy + * Description: Deku Scrub Playground - Large Green Rupee + */ + #include "z_en_gamelupy.h" #define FLAGS 0x00000010 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 c1f3b53bd..6d78480e7 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gb2.c + * Overlay: ovl_En_Gb2 + * Description: Spirit House - Owner + */ + #include "z_en_gb2.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index c7e133471..8125c9c33 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ge1.c + * Overlay: ovl_En_Ge1 + * Description: + */ + #include "z_en_ge1.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 3622ae5c9..6e3b7ac6b 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ge2.c + * Overlay: ovl_En_Ge2 + * Description: Patrolling Pirate + */ + #include "z_en_ge2.h" #define FLAGS 0x80000009 diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index b5c793db2..9e891f708 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ge3.c + * Overlay: ovl_En_Ge3 + * Description: + */ + #include "z_en_ge3.h" #define FLAGS 0x80000019 diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index de611989e..260f3d74e 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_geg.c + * Overlay: ovl_En_Geg + * Description: Goron With Don Gero's Mask + */ + #include "z_en_geg.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index 20fc87b43..4eb259e50 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gg.c + * Overlay: ovl_En_Gg + * Description: Darmani's Ghost + */ + #include "z_en_gg.h" #define FLAGS 0x00000089 diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 7fe7d43fb..e415165ac 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gg2.c + * Overlay: ovl_En_Gg2 + * Description: Darmani's Ghost (2) + */ + #include "z_en_gg2.h" #define FLAGS 0x00000089 diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 9997acd54..58768b2cd 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ginko_man.c + * Overlay: ovl_En_Ginko_Man + * Description: Bank Teller + */ + #include "z_en_ginko_man.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index fc77cba3e..acc972053 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gk.c + * Overlay: ovl_En_Gk + * Description: Goron Elder's Son + */ + #include "z_en_gk.h" #define FLAGS 0x00000009 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 2dfe45e80..bb81c00a0 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gm.c + * Overlay: ovl_En_Gm + * Description: Gorman + */ + #include "z_en_gm.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index fcdaf8eaa..a79aef7ea 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1,3 +1,9 @@ +/* + * File: z_en_go.c + * Overlay: ovl_En_Go + * Description: Goron + */ + #include "z_en_go.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 49cf58f3d..e2ab6909c 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -1,3 +1,9 @@ +/* + * File: z_en_goroiwa.c + * Overlay: ovl_En_Goroiwa + * Description: Rolling boulder + */ + #include "z_en_goroiwa.h" #define FLAGS 0x80000010 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 f04e9c2b8..1a877457f 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -1,3 +1,9 @@ +/* + * File: z_en_grasshopper.c + * Overlay: ovl_En_Grasshopper + * Description: Dragonfly + */ + #include "z_en_grasshopper.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index cb95479b4..4b96987f7 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -1,3 +1,9 @@ +/* + * File: z_en_gs.c + * Overlay: ovl_En_Gs + * Description: Gossip stone + */ + #include "z_en_gs.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 6bf970c34..8f7fa4f4a 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_guard_nuts.c + * Overlay: ovl_En_Guard_Nuts + * Description: Deku Palace - Entrance Guard + */ + #include "z_en_guard_nuts.h" #define FLAGS 0x80100009 diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 560a86dee..039397802 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hakurock.c + * Overlay: ovl_En_Hakurock + * Description: Rocks Kicked Up by Goht + */ + #include "z_en_hakurock.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index cda19b4fd..ce1f2a0f0 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hanabi.c + * Overlay: ovl_En_Hanabi + * Description: Fireworks + */ + #include "z_en_hanabi.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index c849e8673..10c8df4e7 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hata.c + * Overlay: ovl_En_Hata + * Description: Red Flag on Post + */ + #include "z_en_hata.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index df4211818..f25e8f790 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_heishi.c + * Overlay: ovl_En_Heishi + * Description: Soldier + */ + #include "z_en_heishi.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 7de50c75d..ca2891c54 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -1,6 +1,6 @@ /* * File: z_en_hg.c - * Overlay: En_Hg + * Overlay: ovl_En_Hg * Description: Pamela's Father (Human) */ diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index 3a206e0c4..a54b01861 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hgo.c + * Overlay: ovl_En_Hgo + * Description: Pamela's Father As a Gibdo + */ + #include "z_en_hgo.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 03fb8e965..2dc819719 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hidden_nuts.c + * Overlay: ovl_En_Hidden_Nuts + * Description: Swamp Spider House - Sleeping Deku Scrub + */ + #include "z_en_hidden_nuts.h" #define FLAGS 0x02000009 diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index c9436c9d9..0807f007d 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hint_skb.c + * Overlay: ovl_En_Hint_Skb + * Description: Stalchild that gives hints in Oceanside Spider House + */ + #include "z_en_hint_skb.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 98f2eca76..0e61a4937 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hit_tag.c + * Overlay: ovl_En_Hit_Tag + * Description: Invisible hitbox that can spawn rupees + */ + #include "z_en_hit_tag.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 19e79782c..3edd916d2 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -1,3 +1,9 @@ +/* + * File: z_en_honotrap.c + * Overlay: ovl_En_Honotrap + * Description: Eye switch that shoots fire + */ + #include "z_en_honotrap.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 4eddd6b42..e03114ea8 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1,3 +1,9 @@ +/* + * File: z_en_horse.c + * Overlay: ovl_En_Horse + * Description: Epona + */ + #include "z_en_horse.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 593f56e35..8eca23a7c 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -1,3 +1,9 @@ +/* + * File: z_en_horse_game_check.c + * Overlay: ovl_En_Horse_Game_Check + * Description: + */ + #include "z_en_horse_game_check.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index 8057ca491..fca05f277 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -1,3 +1,9 @@ +/* + * File: z_en_horse_link_child.c + * Overlay: ovl_En_Horse_Link_Child + * Description: Child Epona + */ + #include "z_en_horse_link_child.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index ca2f01e56..abf9966ff 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hs.c + * Overlay: ovl_En_Hs + * Description: Grog + */ + #include "z_en_hs.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 0cebfccd9..3bc939d74 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_hs2.c + * Overlay: ovl_En_Hs2 + * Description: Blue Target Spot + */ + #include "z_en_hs2.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index b8e6e91d6..c059d2e08 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ig.c + * Overlay: ovl_En_Ig + * Description: The Goron named the same as the player + */ + #include "z_en_ig.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 4b61b88ed..59cd63487 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ik.c + * Overlay: ovl_En_Ik + * Description: Iron Knuckle + */ + #include "z_en_ik.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index cc07e58dd..b3c1d2dd1 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -1,3 +1,9 @@ +/* + * File: z_en_insect.c + * Overlay: ovl_En_Insect + * Description: Single freestanding bug that doesn't burrow + */ + #include "z_en_insect.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index 5d0b78a23..603420f76 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -1,3 +1,9 @@ +/* + * File: z_en_invadepoh_demo.c + * Overlay: ovl_En_Invadepoh_Demo + * Description: + */ + #include "z_en_invadepoh_demo.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index 9935eb67a..24aa7d33b 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -1,3 +1,9 @@ +/* + * File: z_en_invisible_ruppe.c + * Overlay: ovl_En_Invisible_Ruppe + * Description: Invisible Rupee + */ + #include "z_en_invisible_ruppe.h" #define FLAGS 0x00000000 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 d74a917fb..0843cb87b 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ishi.c + * Overlay: ovl_En_Ishi + * Description: Rock + */ + #include "z_en_ishi.h" #define FLAGS 0x00800010 diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 8fd60081a..7d8099dbd 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ja.c + * Overlay: ovl_En_Ja + * Description: Juggler + */ + #include "z_en_ja.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 240c6cb40..ce8651d3c 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_jg.c + * Overlay: ovl_En_Jg + * Description: Goron Elder + */ + #include "z_en_jg.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 7148c01de..46f9ec21d 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -1,3 +1,9 @@ +/* + * File: z_en_jgame_tsn.c + * Overlay: ovl_En_Jgame_Tsn + * Description: Fisherman's Jumping Game - Fisherman + */ + #include "z_en_jgame_tsn.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index cab6ca7f2..ecd2fafa1 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -1,3 +1,9 @@ +/* + * File: z_en_js.c + * Overlay: ovl_En_Js + * Description: Moon Child + */ + #include "z_en_js.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.c b/src/overlays/actors/ovl_En_Jso/z_en_jso.c index 3248c716e..e20a4de3a 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.c +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.c @@ -1,3 +1,9 @@ +/* + * File: z_en_jso.c + * Overlay: ovl_En_Jso + * Description: Garo + */ + #include "z_en_jso.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index 4b978eb16..ad00e6d87 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_jso2.c + * Overlay: ovl_En_Jso2 + * Description: Garo Master + */ + #include "z_en_jso2.h" #define FLAGS 0x80100035 diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index 5cb041458..eef75acf9 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kaizoku.c + * Overlay: ovl_En_Kaizoku + * Description: Fighter pirate + */ + #include "z_en_kaizoku.h" #define FLAGS 0x00100015 diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 16d9f8271..0617bcdd3 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kakasi.c + * Overlay: ovl_En_Kakasi + * Description: Pierre + */ + #include "z_en_kakasi.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index c932fd054..c8cceba61 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kame.c + * Overlay: ovl_En_Kame + * Description: Snapper Turtle + */ + #include "z_en_kame.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index cccece638..63c5854ea 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kanban.c + * Overlay: ovl_En_Kanban + * Description: Square signpost + */ + #include "z_en_kanban.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 1d2d13da1..dd2233e4c 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -1,3 +1,9 @@ +/* + * File: z_en_karebaba.c + * Overlay: ovl_En_Karebaba + * Description: Wilted Deku Baba + */ + #include "z_en_karebaba.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index 159ce61f0..a937dbcd6 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kbt.c + * Overlay: ovl_En_Kbt + * Description: Zubora + */ + #include "z_en_kbt.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 142dfece7..2cd8dd5e9 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kendo_js.c + * Overlay: ovl_En_Kendo_Js + * Description: Swordsman + */ + #include "z_en_kendo_js.h" #define FLAGS 0x0A000019 diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c index fa391cafd..3ad020f92 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kitan.c + * Overlay: ovl_En_Kitan + * Description: + */ + #include "z_en_kitan.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 64f1d78df..3c71d5a40 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -1,3 +1,9 @@ +/* + * File: z_en_knight.c + * Overlay: ovl_En_Knight + * Description: Igos du Ikana and his lackeys + */ + #include "z_en_knight.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index dfc0a1173..b7abdebdf 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kujiya.c + * Overlay: ovl_En_Kujiya + * Description: Clock Town - Lottery Shop + */ + #include "z_en_kujiya.h" #define FLAGS 0x08000009 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 5684c89dd..3a2f74983 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kusa.c + * Overlay: ovl_En_Kusa + * Description: Grass / Bush + */ + #include "z_en_kusa.h" #define FLAGS 0x00800010 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 cb6fe757c..c46ed7728 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_kusa2.c + * Overlay: ovl_En_Kusa2 + * Description: Keaton grass? + */ + #include "z_en_kusa2.h" #define FLAGS 0x00800010 diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index b35b39df0..bfe535600 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_lift_nuts.c + * Overlay: ovl_En_Lift_Nuts + * Description: Deku Scrub Playground - Employee + */ + #include "z_en_lift_nuts.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index ba02662ae..fdb2cf123 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -1,3 +1,9 @@ +/* + * File: z_en_light.c + * Overlay: ovl_En_Light + * Description: Deku Shrine - Flames of Varying Colours + */ + #include "z_en_light.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 915164eed..22a1f73cc 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_look_nuts.c + * Overlay: ovl_En_Look_Nuts + * Description: Deku Palace - Patrolling Deku Guard + */ + #include "z_en_look_nuts.h" #define FLAGS 0x80000000 diff --git a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c index 117c19ee5..4da43c3cf 100644 --- a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c +++ b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.c @@ -1,3 +1,9 @@ +/* + * File: z_en_m_fire1.c + * Overlay: ovl_En_M_Fire1 + * Description: Deku Nut Effect + */ + #include "z_en_m_fire1.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 03140ab1f..395dcbeed 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -1,3 +1,9 @@ +/* + * File: z_en_m_thunder.c + * Overlay: ovl_En_M_Thunder + * Description: Spin attack effect + */ + #include "z_en_m_thunder.h" #define FLAGS 0x00000010 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 3fdf1766a..6b18d43fd 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mag.c + * Overlay: ovl_En_Mag + * Description: Title Logo + */ + #include "z_en_mag.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 01b47bf00..7d379c08d 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -1,3 +1,9 @@ +/* + * File: z_en_maruta.c + * Overlay: ovl_En_Maruta + * Description: Swordsman's School - Practice Log + */ + #include "z_en_maruta.h" #define FLAGS 0x00000011 diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index 955cf8fc7..eb3a02eb3 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -1,3 +1,9 @@ +/* + * File: z_en_minideath.c + * Overlay: ovl_En_Minideath + * Description: Bats Surrounding Gomess? + */ + #include "z_en_minideath.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 2122321d3..514816f10 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mk.c + * Overlay: ovl_En_Mk + * Description: Marine Researcher + */ + #include "z_en_mk.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 81ba9a6ec..73e2fc62d 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mkk.c + * Overlay: ovl_En_Mkk + * Description: Makkurokurosuke / Black and White Boe + */ + #include "z_en_mkk.h" #define FLAGS 0x00000005 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 fc6859542..60cd43246 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mm.c + * Overlay: ovl_En_Mm + * Description: Rock Sirloin + */ + #include "z_en_mm.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 4d008e947..69823ad0e 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mm2.c + * Overlay: ovl_En_Mm2 + * Description: Postman's Letter to Himself + */ + #include "z_en_mm2.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 8e2e633cf..3c9719008 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mm3.c + * Overlay: ovl_En_Mm3 + * Description: Counting Game Postman + */ + #include "z_en_mm3.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c index e0b247f54..cf9d23cb0 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mnk.c + * Overlay: ovl_En_Mnk + * Description: Monkey + */ + #include "z_en_mnk.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 3126b899b..e9a779376 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ms.c + * Overlay: ovl_En_Ms + * Description: Bean salesman + */ + #include "z_en_ms.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 0a1497130..934e7b427 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_mt_tag.c + * Overlay: ovl_En_Mt_tag + * Description: + */ + #include "z_en_mt_tag.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 03c808602..191939426 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -1,7 +1,7 @@ /* * File: z_en_mushi2.c * Overlay: ovl_En_Mushi2 - * Description: Burrowing Bugs + * Description: Group of three bugs that burrow underground */ #include "overlays/actors/ovl_Obj_Bean/z_obj_bean.h" diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 773945393..ffd002a40 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -1,3 +1,9 @@ +/* + * File: z_en_nb.c + * Overlay: ovl_En_Nb + * Description: Anju's Grandma + */ + #include "z_en_nb.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index c2548d548..86f477a0f 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -1,3 +1,9 @@ +/* + * File: z_en_neo_reeba.c + * Overlay: ovl_En_Neo_Reeba + * Description: Leevers + */ + #include "z_en_neo_reeba.h" #define FLAGS 0x00000205 diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c index 2206589bf..050d22dac 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -1,3 +1,9 @@ +/* + * File: z_en_nimotsu.c + * Overlay: ovl_En_Nimotsu + * Description: Bomb Shop Bag Stolen by Sakon + */ + #include "z_en_nimotsu.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index 5ff712d7e..dc93bf7cd 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -1,3 +1,9 @@ +/* + * File: z_en_nnh.c + * Overlay: ovl_En_Nnh + * Description: Twisted Corpse of Deku Butler's Son + */ + #include "z_en_nnh.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index b9aa32a0c..9d90c4ec6 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -1,3 +1,9 @@ +/* + * File: z_en_nutsball.c + * Overlay: ovl_En_Nutsball + * Description: Deku nut Projectile + */ + #include "z_en_nutsball.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 2d6e56e58..53c38ab6b 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -1,3 +1,9 @@ +/* + * File: z_en_nwc.c + * Overlay: ovl_En_Nwc + * Description: Cucco chick + */ + #include "z_en_nwc.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 4ae96bafb..96f12dab2 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -1,3 +1,9 @@ +/* + * File: z_en_okarina_effect.c + * Overlay: ovl_En_Okarina_Effect + * Description: + */ + #include "z_en_okarina_effect.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index 606f723e2..096fd9421 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_okarina_tag.c + * Overlay: ovl_En_Okarina_Tag + * Description: + */ + #include "z_en_okarina_tag.h" #define FLAGS 0x0A000010 diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 2ccb7c91b..251f23a30 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -1,3 +1,9 @@ +/* + * File: z_en_okuta.c + * Overlay: ovl_En_Okuta + * Description: Octorok + */ + #include "z_en_okuta.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index feddfb17a..0e4ebdd48 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -1,3 +1,9 @@ +/* + * File: z_en_onpuman.c + * Overlay: ovl_En_Onpuman + * Description: Monkey Instrument Prompt + */ + #include "z_en_onpuman.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 3c88c3b0a..c71650ef1 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_osk.c + * Overlay: ovl_En_Osk + * Description: Igos du Ikana's and his lackey's floating heads + */ + #include "z_en_osk.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 8f301ace1..758da16f4 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -1,3 +1,9 @@ +/* + * File: z_en_osn.c + * Overlay: ovl_En_Osn + * Description: Happy Mask Salesman + */ + #include "z_en_osn.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index bb7a5ffbd..87c707e78 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -1,6 +1,6 @@ /* * File: z_en_pamera.c - * Overlay: En_Pamera + * Overlay: ovl_En_Pamera * Description: Pamela */ 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 2b8246f34..fd87fdc59 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1,6 +1,6 @@ /* * File: z_en_pametfrog.c - * Overlay: En_Pametfrog + * Overlay: ovl_En_Pametfrog * Description: Gekko & Snapper Miniboss: Gekko */ diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.c b/src/overlays/actors/ovl_En_Paper/z_en_paper.c index 037541cf4..e629ebf9a 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -1,3 +1,9 @@ +/* + * File: z_en_paper.c + * Overlay: ovl_En_Paper + * Description: Tingle Confetti + */ + #include "z_en_paper.h" #define FLAGS 0x02100010 diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index e574ee53a..9e184b1d9 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -1,3 +1,9 @@ +/* + * File: z_en_part.c + * Overlay: ovl_En_Part + * Description: + */ + #include "z_en_part.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index f56e49f05..5f51217bb 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -1,3 +1,9 @@ +/* + * File: z_en_peehat.c + * Overlay: ovl_En_Peehat + * Description: Peahat + */ + #include "z_en_peehat.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 62620a035..be1efeaf7 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1,3 +1,9 @@ +/* + * File: z_en_pm.c + * Overlay: ovl_En_Pm + * Description: Postman delivering letters + */ + #include "z_en_pm.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 9c2741808..dce3a55fd 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -1,3 +1,9 @@ +/* + * File: z_en_po_composer.c + * Overlay: ovl_En_Po_Composer + * Description: Poe Composers + */ + #include "z_en_po_composer.h" #define FLAGS 0x02100019 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 2ae03a166..0fb1e08d0 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -1,3 +1,9 @@ +/* + * File: z_en_pp.c + * Overlay: ovl_En_Pp + * Description: Hiploop + */ + #include "z_en_pp.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 91c8407a3..696abb358 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -1,3 +1,9 @@ +/* + * File: z_en_pr.c + * Overlay: ovl_En_Pr + * Description: Desbreko + */ + #include "z_en_pr.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index b2d70518d..b1ef7eaca 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_pr2.c + * Overlay: ovl_En_Pr2 + * Description: Skullfish + */ + #include "z_en_pr2.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index d966b00d1..960340d7e 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -1,3 +1,9 @@ +/* + * File: z_en_prz.c + * Overlay: ovl_En_Prz + * Description: Skullfish - Defeated + */ + #include "z_en_prz.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.c b/src/overlays/actors/ovl_En_Pst/z_en_pst.c index 30ffa979b..df0355ce9 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -1,3 +1,9 @@ +/* + * File: z_en_pst.c + * Overlay: ovl_En_Pst + * Description: Postbox + */ + #include "z_en_pst.h" #define FLAGS 0x00000001 diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 1170827cc..489fe63df 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -1,3 +1,9 @@ +/* + * File: z_en_racedog.c + * Overlay: ovl_En_Racedog + * Description: Racetrack Dog + */ + #include "z_en_racedog.h" #define FLAGS 0x80000010 diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index ee2cbd79e..38fb9e965 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,3 +1,9 @@ +/* + * File: z_en_raf.c + * Overlay: ovl_En_Raf + * Description: Carnivorous Lilypad + */ + #include "z_en_raf.h" #define FLAGS 0x08000000 diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 38579f83a..a1a88ecbd 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rail_skb.c + * Overlay: ovl_En_Rail_Skb + * Description: Ikana Graveyard - Circle of Stalchildren + */ + #include "z_en_rail_skb.h" #define FLAGS 0x00000015 diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index ef302a688..5160203b2 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rat.c + * Overlay: ovl_En_Rat + * Description: Real Bombchu + */ + #include "z_en_rat.h" #define FLAGS 0x00000205 diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index c6359ba89..1393c2686 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,7 +1,7 @@ /* * File: z_en_rd.c * Overlay: ovl_En_Rd - * Description: Redead / Gibdo + * Description: Dancing Redead/Gibdo */ #include "z_en_rd.h" diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 516dae5cc..6c3afaa6f 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -1,3 +1,9 @@ +/* + * File: z_en_recepgirl.c + * Overlay: ovl_En_Recepgirl + * Description: Mayor's receptionist + */ + #include "z_en_recepgirl.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 67d08ed98..6a2b734bd 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rg.c + * Overlay: ovl_En_Rg + * Description: Racetrack Goron + */ + #include "z_en_rg.h" #define FLAGS 0x80000010 diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index ef39aafb1..f104ff1b2 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -1,3 +1,9 @@ +/* + * File: z_en_river_sound.c + * Overlay: ovl_En_River_Sound + * Description: + */ + #include "z_en_river_sound.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index f1094a154..1d44f721c 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rr.c + * Overlay: ovl_En_Rr + * Description: Like Like + */ + #include "z_en_rr.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index a5e91243b..f02130121 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rsn.c + * Overlay: ovl_En_Rsn + * Description: Bomb Shop Man in the credits? + */ + #include "z_en_rsn.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.c b/src/overlays/actors/ovl_En_Ru/z_en_ru.c index 90f4b3eb1..3a0acd4b6 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ru.c + * Overlay: ovl_En_Ru + * Description: Ruto + */ + #include "z_en_ru.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 2b19b33a7..ba851d64d 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ruppecrow.c + * Overlay: ovl_En_Ruppecrow + * Description: Guay Circling Clock Town + */ + #include "z_en_ruppecrow.h" #define FLAGS 0x00004030 diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index e812c284b..e87dfa556 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -1,3 +1,9 @@ +/* + * File: z_en_rz.c + * Overlay: ovl_En_Rz + * Description: Rosa Sister + */ + #include "z_en_rz.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index bc1b6c91d..07d0dc3f9 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c @@ -1,3 +1,9 @@ +/* + * File: z_en_s_goro.c + * Overlay: ovl_En_S_Goro + * Description: Goron Complaining About Crying / Bomb Shop Goron + */ + #include "z_en_s_goro.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index 752ade75e..c813759cb 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sc_ruppe.c + * Overlay: ovl_En_Sc_Ruppe + * Description: Giant Rupee + */ + #include "z_en_sc_ruppe.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index f14dabc20..0d38ff2b5 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -1,3 +1,9 @@ +/* + * File: z_en_scopecoin.c + * Overlay: ovl_En_Scopecoin + * Description: Telescope Coin + */ + #include "z_en_scopecoin.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index 8351aa961..76665f67a 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -1,3 +1,9 @@ +/* + * File: z_en_scopecrow.c + * Overlay: ovl_En_Scopecrow + * Description: Astral Observatory - Guay in Telescope + */ + #include "z_en_scopecrow.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index ee45a01db..400c18044 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_scopenuts.c + * Overlay: ovl_En_Scopenuts + * Description: Astral Observatory - Business Scrub in Telescope + */ + #include "z_en_scopenuts.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 62a36b618..2059de563 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sda.c + * Overlay: ovl_En_Sda + * Description: + */ + #include "z_en_sda.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c index 58152281d..29b673760 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sekihi.c + * Overlay: ovl_En_Sekihi + * Description: Mikau's Grave & Song Pedestals + */ + #include "z_en_sekihi.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 447f7cea4..c93402fbc 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -1,3 +1,9 @@ +/* + * File: z_en_shn.c + * Overlay: ovl_En_Shn + * Description: Swamp Tourist Center Guide + */ + #include "z_en_shn.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index e47fbb11b..35eddf10b 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -1,3 +1,9 @@ +/* + * File: z_en_si.c + * Overlay: ovl_En_Si + * Description: Golden Skulltula Token + */ + #include "z_en_si.h" #define FLAGS 0x00000201 diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index ba48df119..d313450f5 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -1,3 +1,9 @@ +/* + * File: z_en_slime.c + * Overlay: ovl_En_Slime + * Description: Chuchu + */ + #include "z_en_slime.h" #define FLAGS 0x00000215 diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 5fcfe3645..8f28748b7 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,3 +1,9 @@ +/* + * File: z_en_snowman.c + * Overlay: ovl_En_Snowman + * Description: Enos + */ + #include "z_en_snowman.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c index ef7899fd4..03038d058 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c @@ -1,3 +1,9 @@ +/* + * File: z_en_snowwd.c + * Overlay: ovl_En_Snowwd + * Description: Snow-Covered Tree + */ + #include "z_en_snowwd.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 1ac84901e..5d045ca75 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ssh.c + * Overlay: ovl_En_Ssh + * Description: Cursed Man + */ + #include "z_en_ssh.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index a0d2cacf9..6f92e8e76 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -1,3 +1,9 @@ +/* + * File: z_en_st.c + * Overlay: ovl_En_St + * Description: Skulltula + */ + #include "z_en_st.h" #define FLAGS 0x01004035 diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 9b7965946..9b6d621a0 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sth.c + * Overlay: ovl_En_Sth + * Description: Guy looking at moon in South Clock Town + */ + #include "z_en_sth.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index d0141f546..42bfe2363 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_sth2.c + * Overlay: ovl_En_Sth2 + * Description: + */ + #include "z_en_sth2.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c index 3ae886dc1..387afd7e9 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_stone_heishi.c + * Overlay: ovl_En_Stone_heishi + * Description: Shiro + */ + #include "z_en_stone_heishi.h" #define FLAGS 0x00000089 diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index 96e593392..c5746771c 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c @@ -1,3 +1,9 @@ +/* + * File: z_en_stop_heishi.c + * Overlay: ovl_En_Stop_heishi + * Description: Clock Town - Gate-Blocking Soldier + */ + #include "z_en_stop_heishi.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index ad7228b1b..8e72ac31c 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -1,3 +1,9 @@ +/* + * File: z_en_stream.c + * Overlay: ovl_En_Stream + * Description: + */ + #include "z_en_stream.h" #define FLAGS 0x00000010 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 f14c5b3c5..4b6d4a5d6 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 @@ -1,3 +1,9 @@ +/* + * File: z_en_syateki_crow.c + * Overlay: ovl_En_Syateki_Crow + * Description: Shooting Gallery Guay + */ + #include "z_en_syateki_crow.h" #define FLAGS 0x08000030 diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index ec86ce081..6d606f8b7 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -1,3 +1,9 @@ +/* + * File: z_en_syateki_dekunuts.c + * Overlay: ovl_En_Syateki_Dekunuts + * Description: Shooting Gallery Deku Scrub + */ + #include "z_en_syateki_dekunuts.h" #define FLAGS 0x08000030 diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 480c0badb..6360f0f39 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -1,3 +1,9 @@ +/* + * File: z_en_syateki_okuta.c + * Overlay: ovl_En_Syateki_Okuta + * Description: Shooting Gallery Octorok + */ + #include "z_en_syateki_okuta.h" #define FLAGS 0x08000030 diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 9323517fd..952861c83 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -1,3 +1,9 @@ +/* + * File: z_en_syateki_wf.c + * Overlay: ovl_En_Syateki_Wf + * Description: Shooting Gallery Wolfos + */ + #include "z_en_syateki_wf.h" #define FLAGS 0x08000030 diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 451c762d7..d39849ee6 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tab.c + * Overlay: ovl_En_Tab + * Description: Talon B - Mr. Barten + */ + #include "z_en_tab.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c index dec8347bc..2c4c50049 100644 --- a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c +++ b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tag_obj.c + * Overlay: ovl_En_Tag_Obj + * Description: + */ + #include "z_en_tag_obj.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c index b7715b6ab..f579719d2 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -1,3 +1,9 @@ +/* + * File: z_en_takaraya.c + * Overlay: ovl_En_Takaraya + * Description: Treasure Chest Shop Gal + */ + #include "z_en_takaraya.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index 960bdbb05..2d054f808 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_talk.c + * Overlay: ovl_En_Talk + * Description: Green Target Spot (e.g., Indigo-Go's Poster) + */ + #include "z_en_talk.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index ab563ab23..0c5dbfa71 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -1,3 +1,9 @@ +/* + * File: z_en_talk_gibud.c + * Overlay: ovl_En_Talk_Gibud + * Description: Gibdos requesting items Beneath the Well + */ + #include "z_en_talk_gibud.h" #define FLAGS 0x00000415 diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 1781ab829..1b2e04472 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron1.c + * Overlay: ovl_En_Tanron1 + * Description: Swarm of Moths in Woodfall Temple + */ + #include "z_en_tanron1.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 640d24f8c..be89681f1 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron2.c + * Overlay: ovl_En_Tanron2 + * Description: Wart's Bubbles + */ + #include "z_en_tanron2.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index 126dd987c..2de774191 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron3.c + * Overlay: ovl_En_Tanron3 + * Description: Small Fish summoned by Gyorg + */ + #include "z_en_tanron3.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index df10d0042..45330247d 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron4.c + * Overlay: ovl_En_Tanron4 + * Description: Flock of Seagulls + */ + #include "z_en_tanron4.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 9d3a8bbb2..f79aea937 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron5.c + * Overlay: ovl_En_Tanron5 + * Description: Destructible props in Twinmold's arena + */ + #include "z_en_tanron5.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index 7e184a710..2c855d36a 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tanron6.c + * Overlay: ovl_En_Tanron6 + * Description: Swarm of Giant Bees + */ + #include "z_en_tanron6.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 12086b398..516cf8258 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test.c + * Overlay: ovl_En_Test + * Description: + */ + #include "z_en_test.h" #define FLAGS 0x00000010 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 8a78ce1bd..9beb86263 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test2.c + * Overlay: ovl_En_Test2 + * Description: Objects affected by the Lens of Truth + */ + #include "z_en_test2.h" #define FLAGS 0x00000090 diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index c5f54d31a..63d0cf954 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test3.c + * Overlay: ovl_En_Test3 + * Description: Kafei + */ + #include "z_en_test3.h" #define FLAGS 0x04000030 diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 76097f09a..69d550c8a 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test5.c + * Overlay: ovl_En_Test5 + * Description: Spring Water + */ + #include "z_en_test5.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 6fa9bf8b9..918a503f4 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test6.c + * Overlay: ovl_En_Test6 + * Description: + */ + #include "z_en_test6.h" #define FLAGS 0x02200030 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 0e318e246..a5bca6c56 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -1,3 +1,9 @@ +/* + * File: z_en_test7.c + * Overlay: ovl_En_Test7 + * Description: + */ + #include "z_en_test7.h" #define FLAGS 0x02300030 diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.c index 95801e7b4..c53e096f0 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tg.c + * Overlay: ovl_En_Tg + * Description: Target Game (Honey & Darling) + */ + #include "z_en_tg.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index b9a48e7c3..db71ae58d 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_time_tag.c + * Overlay: ovl_En_Time_Tag + * Description: + */ + #include "z_en_time_tag.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index de2c1fe1e..6db72b074 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tk.c + * Overlay: ovl_En_Tk + * Description: Dampé + */ + #include "z_en_tk.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index 2658799b4..786942bcf 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -1,3 +1,9 @@ +/* + * File: z_en_torch.c + * Overlay: ovl_En_Torch + * Description: Treasure chest (grotto) + */ + #include "z_en_torch.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 3de9370ff..9306f4cc8 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -1,3 +1,9 @@ +/* + * File: z_en_trt2.c + * Overlay: ovl_En_Trt2 + * Description: + */ + #include "z_en_trt2.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index cd35652cc..240a4f236 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tru.c + * Overlay: ovl_En_Tru + * Description: Koume in Woods of Mystery + */ + #include "z_en_tru.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 53fe4b195..2d956d494 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tru_mt.c + * Overlay: ovl_En_Tru_Mt + * Description: Koume's Target Game - Koume on Broom + */ + #include "z_en_tru_mt.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index f8129b237..4205bf035 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tsn.c + * Overlay: ovl_En_Tsn + * Description: Great Bay - Fisherman + */ + #include "z_en_tsn.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 06ef6ef3f..d808de961 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -1,3 +1,9 @@ +/* + * File: z_en_tubo_trap.c + * Overlay: ovl_En_Tubo_Trap + * Description: Flying Pot Trap Enemy + */ + #include "z_en_tubo_trap.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index 383354eed..aa1b3e1d4 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -1,3 +1,9 @@ +/* + * File: z_en_twig.c + * Overlay: ovl_En_Twig + * Description: Beaver Race Ring + */ + #include "z_en_twig.h" #define FLAGS 0x00000010 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 e3ceb9721..84d9a8356 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -1,3 +1,9 @@ +/* + * File: z_en_viewer.c + * Overlay: ovl_En_Viewer + * Description: Cutscene Actors? + */ + #include "z_en_viewer.h" #define FLAGS 0x00200030 diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 2b7072ab6..b1fcfad5e 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -1,3 +1,9 @@ +/* + * File: z_en_vm.c + * Overlay: ovl_En_Vm + * Description: Beamos + */ + #include "z_en_vm.h" #define FLAGS 0x00000405 diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index c56a4a166..05078f541 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wallmas.c + * Overlay: ovl_En_Wallmas + * Description: Wallmaster + */ + #include "z_en_wallmas.h" #define FLAGS 0x00000415 diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 7ee643f03..1f376ace3 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_warp_tag.c + * Overlay: ovl_En_Warp_tag + * Description: Warp to Trial Entrance + */ + #include "z_en_warp_tag.h" #define FLAGS 0x0A000011 diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 4bcf2b765..236881f25 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -1,3 +1,9 @@ +/* + * File: z_en_water_effect.c + * Overlay: ovl_En_Water_Effect + * Description: Water splashing effect (used for Gyorg) + */ + #include "z_en_water_effect.h" #define FLAGS 0x00000035 diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index 385950209..b04de536b 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wdhand.c + * Overlay: ovl_En_Wdhand + * Description: Dexihand + */ + #include "z_en_wdhand.h" #define FLAGS 0x00000005 diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 401bf50b2..b230a767f 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -1,3 +1,9 @@ +/* + * File: z_en_weather_tag.c + * Overlay: ovl_En_Weather_Tag + * Description: Local weather changes + */ + #include "z_en_weather_tag.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 2190b28cd..9264f42fb 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wiz.c + * Overlay: ovl_En_Wiz + * Description: Wizzrobe + */ + #include "z_en_wiz.h" #define FLAGS 0x88101035 diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index 48ad84d58..1fa6bd35b 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wiz_brock.c + * Overlay: ovl_En_Wiz_Brock + * Description: Wizzrobe Warp Platform + */ + #include "z_en_wiz_brock.h" #define FLAGS 0x08000010 diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 8c45955ec..480bdaeaa 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wiz_fire.c + * Overlay: ovl_En_Wiz_Fire + * Description: Wizzrobe Fire/Ice Attack + */ + #include "z_en_wiz_fire.h" #define FLAGS 0x08000015 diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index d111e7bba..e24a5af95 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -1,3 +1,9 @@ +/* + * File: z_en_wood02.c + * Overlay: ovl_En_Wood02 + * Description: Trees, shrubs + */ + #include "z_en_wood02.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 8704d9ea5..bb3f81576 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -1,3 +1,9 @@ +/* + * File: z_en_yb.c + * Overlay: ovl_En_Yb + * Description: Kamaro the Dancing Ghost + */ + #include "z_en_yb.h" #define FLAGS 0x02000019 diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index b029e220a..0ef9f83af 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zl1.c + * Overlay: ovl_En_Zl1 + * Description: [Empty] + */ + #include "z_en_zl1.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index cef6afd3d..d961ffc1b 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zl4.c + * Overlay: ovl_En_Zl4 + * Description: + */ + #include "z_en_zl4.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 575bf65de..730bcf10b 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zo.c + * Overlay: ovl_En_Zo + * Description: Zoras + */ + #include "z_en_zo.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 272250134..51fcf53bc 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zob.c + * Overlay: ovl_En_Zob + * Description: Zora Bassist Japas + */ + #include "z_en_zob.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index 3a28b8616..f8a38bd52 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zod.c + * Overlay: ovl_En_Zod + * Description: Zora Drummer Tijo + */ + #include "z_en_zod.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index babf4a063..a4c63543c 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zog.c + * Overlay: ovl_En_Zog + * Description: Mikau + */ + #include "z_en_zog.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 05a99edff..d5dc7fda0 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zoraegg.c + * Overlay: ovl_En_Zoraegg + * Description: Zora Egg + */ + #include "z_en_zoraegg.h" #define FLAGS 0x00000010 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 d87428967..713547400 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zos.c + * Overlay: ovl_En_Zos + * Description: Zora Synthesizer - Evan + */ + #include "z_en_zos.h" #define FLAGS 0x02000009 diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index c1f0b3351..f3d977a7b 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1,7 +1,7 @@ /* * File: z_en_zot.c * Overlay: ovl_En_Zot - * Description: Great Bay - Zora With Directions to Zora Hall + * Description: Great Bay - Zora With Directions to Zora Hall / Pot Game Zora */ #include "z_en_zot.h" diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index e4d6a51ed..278ffa7fe 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zov.c + * Overlay: ovl_En_Zov + * Description: Zora Vocalist - Lulu + */ + #include "z_en_zov.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 9fd768879..2147bc5f4 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -1,3 +1,9 @@ +/* + * File: z_en_zow.c + * Overlay: ovl_En_Zow + * Description: Great Bay - Zora Complaining About Water + */ + #include "z_en_zow.h" #define FLAGS 0x00000019 diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 66a68363a..551a5d7a0 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -1,3 +1,9 @@ +/* + * File: z_item_etcetera.c + * Overlay: ovl_Item_Etcetera + * Description: + */ + #include "z_item_etcetera.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index 8bcb67a98..d30a74878 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -1,3 +1,9 @@ +/* + * File: z_item_inbox.c + * Overlay: ovl_Item_Inbox + * Description: + */ + #include "z_item_inbox.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index b9aee5f76..ccc7e487d 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -1,3 +1,9 @@ +/* + * File: z_mir_ray.c + * Overlay: ovl_Mir_Ray + * Description: Mirror Shield Face & Light Ray + */ + #include "z_mir_ray.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index 75517b3fd..19a1e299b 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -1,3 +1,9 @@ +/* + * File: z_mir_ray2.c + * Overlay: ovl_Mir_Ray2 + * Description: + */ + #include "z_mir_ray2.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 35978d4c2..0159996d8 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -1,3 +1,9 @@ +/* + * File: z_mir_ray3.c + * Overlay: ovl_Mir_Ray3 + * Description: + */ + #include "z_mir_ray3.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index e678d6f27..d4ae2b79f 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_armos.c + * Overlay: ovl_Obj_Armos + * Description: Non-hostile Armos statues + */ + #include "z_obj_armos.h" #define FLAGS 0x04000010 diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index b261af7ed..953f70e43 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_bean.c + * Overlay: ovl_Obj_Bean + * Description: Floating Bean Plant / Dirt Patch + */ + #include "z_obj_bean.h" #define FLAGS 0x00400000 diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index c7d0abb14..1995aacf9 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_bigicicle.c + * Overlay: ovl_Obj_Bigicicle + * Description: Large icicles + */ + #include "z_obj_bigicicle.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index f5995d718..88ae42945 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_blockstop.c + * Overlay: ovl_Obj_Blockstop + * Description: + */ + #include "z_obj_blockstop.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 70c672628..341dc5c56 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_boat.c + * Overlay: ovl_Obj_Boat + * Description: Pirate Boat + */ + #include "z_obj_boat.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index ad40c5a75..0b91f6f5f 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_bombiwa.c + * Overlay: ovl_Obj_Bombiwa + * Description: Bombable boulder + */ + #include "z_obj_bombiwa.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 45260a7b7..2ac00d73f 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_chan.c + * Overlay: ovl_Obj_Chan + * Description: Goron Shrine chandelier + */ + #include "z_obj_chan.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index 0208d59b7..7c6580aaf 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_chikuwa.c + * Overlay: ovl_Obj_Chikuwa + * Description: Falling Block Row + */ + #include "z_obj_chikuwa.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 386915dee..c8eff2da6 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_comb.c + * Overlay: ovl_Obj_Comb + * Description: Honeycomb + */ + #include "z_obj_comb.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index 15c7d2b7c..9fa0026fe 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_danpeilift.c + * Overlay: ovl_Obj_Danpeilift + * Description: Deku Shrine & Snowhead Temple Elevator + */ + #include "z_obj_danpeilift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 8c5b70ec3..a51a7e8d2 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_demo.c + * Overlay: ovl_Obj_Demo + * Description: + */ + #include "z_obj_demo.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index 42ef837c4..1177a6855 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_dhouse.c + * Overlay: ovl_Obj_Dhouse + * Description: Dinner plate Prop + */ + #include "z_obj_dhouse.h" #define FLAGS 0x00400010 diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index 604d1dbbe..fde316a81 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_dinner.c + * Overlay: ovl_Obj_Dinner + * Description: Cremia and Romani's dinner + */ + #include "z_obj_dinner.h" #define FLAGS 0x00000020 diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 680148896..77285cdfd 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_dora.c + * Overlay: ovl_Obj_Dora + * Description: Swordsman's School - Gong + */ + #include "z_obj_dora.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index 96d817a70..98f66c014 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_dowsing.c + * Overlay: ovl_Obj_Dowsing + * Description: + */ + #include "z_obj_dowsing.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index 1f6dc10fe..f193fbbc1 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_driftice.c + * Overlay: ovl_Obj_Driftice + * Description: Floating Ice Platforms in Mountain Village + */ + #include "z_obj_driftice.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index e34d5321c..4acf00181 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_entotu.c + * Overlay: ovl_Obj_Entotu + * Description: Clock tower chimney Expelling Smoke + */ + #include "z_obj_entotu.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index 04ff86bf9..eaa085f49 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_fireshield.c + * Overlay: ovl_Obj_Fireshield + * Description: Ring of fire + */ + #include "z_obj_fireshield.h" #define FLAGS 0x00000010 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 5e16c553e..8a6795094 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_flowerpot.c + * Overlay: ovl_Obj_Flowerpot + * Description: Breakable Pot With Grass + */ + #include "z_obj_flowerpot.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 04f4635a6..b2b624282 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_funen.c + * Overlay: ovl_Obj_Funen + * Description: + */ + #include "z_obj_funen.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 23a09d80f..88d20d49b 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_grass.c + * Overlay: ovl_Obj_Grass + * Description: + */ + #include "z_obj_grass.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 1a3cbfeb4..a603509fa 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_grass_carry.c + * Overlay: ovl_Obj_Grass_Carry + * Description: + */ + #include "z_obj_grass_carry.h" #define FLAGS 0x00800030 diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c index 77bd96c24..e3787849f 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_grass_unit.c + * Overlay: ovl_Obj_Grass_Unit + * Description: + */ + #include "z_obj_grass_unit.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index f053fc20a..978f2cd13 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hakaisi.c + * Overlay: ovl_Obj_Hakaisi + * Description: Gravestone + */ + #include "z_obj_hakaisi.h" #define FLAGS 0x00000029 diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 34fb4e0fc..069eb3a66 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hamishi.c + * Overlay: ovl_Obj_Hamishi + * Description: Hammer Stone + */ + #include "z_obj_hamishi.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 17ce38ce9..286080631 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hariko.c + * Overlay: ovl_Obj_Hariko + * Description: Little Cow Statue Head + */ + #include "z_obj_hariko.h" #define FLAGS 0x02000020 diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index d2878b2ad..c6870edf1 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hgdoor.c + * Overlay: ovl_Obj_Hgdoor + * Description: Music Box House - Closet Door + */ + #include "z_obj_hgdoor.h" #define FLAGS 0x00100000 diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index 89346ce0e..3a61c41e8 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hsstump.c + * Overlay: ovl_Obj_HsStump + * Description: Ikana Canyon - Hookshotable Tree + */ + #include "z_obj_hsstump.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index edb8df061..373815365 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hsblock.c + * Overlay: ovl_Obj_Hsblock + * Description: Hookshot Block + */ + #include "z_obj_hsblock.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 43975537b..31bde1d51 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hugebombiwa.c + * Overlay: ovl_Obj_Hugebombiwa + * Description: Boulder Blocking Goron Racetrack + */ + #include "z_obj_hugebombiwa.h" #define FLAGS 0x00000010 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 a30fb95d2..ff90f2e3e 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_hunsui.c + * Overlay: ovl_Obj_Hunsui + * Description: Switch-Activated Geyser + */ + #include "z_obj_hunsui.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index 3715be349..57092079a 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_ice_poly.c + * Overlay: ovl_Obj_Ice_Poly + * Description: Large Block of Meltable Ice + */ + #include "z_obj_ice_poly.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index d94173f1e..bbeb4da26 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_iceblock.c + * Overlay: ovl_Obj_Iceblock + * Description: Ice Block That Appears After Freezing Enemy + */ + #include "z_obj_iceblock.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index eed1be594..e85548758 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_jg_gakki.c + * Overlay: ovl_Obj_Jg_Gakki + * Description: Goron Elder's Drum + */ + #include "z_obj_jg_gakki.h" #define FLAGS 0x00000020 diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c index 56fd79ff7..6c8cb3722 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_jgame_light.c + * Overlay: ovl_Obj_Jgame_Light + * Description: Fisherman's Jumping Game - Torch + */ + #include "z_obj_jgame_light.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 6d3a16e56..82e4e4de2 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_kendo_kanban.c + * Overlay: ovl_Obj_Kendo_Kanban + * Description: Swordsman's School - Cuttable Board + */ + #include "z_obj_kendo_kanban.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c index 09f345323..9b3d19051 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_kepn_koya.c + * Overlay: ovl_Obj_Kepn_Koya + * Description: Gorman Bros. Buildings + */ + #include "z_obj_kepn_koya.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 3a5e17df3..8d4b2f582 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_kinoko.c + * Overlay: ovl_Obj_Kinoko + * Description: Mushroom + */ + #include "z_obj_kinoko.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c index 8153c8556..d00746c37 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_kzsaku.c + * Overlay: ovl_Obj_Kzsaku + * Description: Underwater grate + */ + #include "z_obj_kzsaku.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index c1d56bf8d..c6fd52f13 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_lift.c + * Overlay: ovl_Obj_Lift + * Description: Dampé's Grave - Brown Elevator + */ + #include "z_obj_lift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index 4237e0992..35c81daa9 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_lightswitch.c + * Overlay: ovl_Obj_Lightswitch + * Description: Sun Switch / STT Flip switch + */ + #include "z_obj_lightswitch.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index 81141154a..57db84b12 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_lupygamelift.c + * Overlay: ovl_Obj_Lupygamelift + * Description: Deku Scrub Playground - Rupee Elevator + */ + #include "z_obj_lupygamelift.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index b8a8e1b30..f0cc27a9c 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_makekinsuta.c + * Overlay: ovl_Obj_Makekinsuta + * Description: Dirt Patch with Skulltula hiding in it + */ + #include "z_obj_makekinsuta.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index a1f127eaa..5b5e80d39 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_mine.c + * Overlay: ovl_Obj_Mine + * Description: Spike metal Mine + */ + #include "z_obj_mine.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index c0bcd9bd5..41446b805 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_mu_pict.c + * Overlay: ovl_Obj_Mu_Pict + * Description: + */ + #include "z_obj_mu_pict.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index 22efe55d9..7191ca259 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_mure.c + * Overlay: ovl_Obj_Mure + * Description: Bugs, Insects, Butterfly spawner and behavior + */ + #include "z_obj_mure.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c index cb04a8170..49101b746 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_mure2.c + * Overlay: ovl_Obj_Mure2 + * Description: Circle of rocks spawner + */ + #include "z_obj_mure2.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c index 043c6b8e1..bdeb9c702 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_mure3.c + * Overlay: ovl_Obj_Mure3 + * Description: Group Rupee spawner + */ + #include "z_obj_mure3.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index 567cf43b4..d2cd9f7fa 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_nozoki.c + * Overlay: ovl_Obj_Nozoki + * Description: Sakon's Hideout Objects (Sun's Mask, doors, etc) + */ + #include "z_obj_nozoki.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 04cf0040f..fe7d90062 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_ocarinalift.c + * Overlay: ovl_Obj_Ocarinalift + * Description: Elevator With Triforce Texture + */ + #include "z_obj_ocarinalift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index ab6b573a6..523cd7fb9 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_oshihiki.c + * Overlay: ovl_Obj_Oshihiki + * Description: Pushable Block + */ + #include "z_obj_oshihiki.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index 5f61a8a3e..1c8f0a132 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_purify.c + * Overlay: ovl_Obj_Purify + * Description: Poisoned/Purified Water Elements + */ + #include "z_obj_purify.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index a9f582a37..b89a0b1c3 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_pzlblock.c + * Overlay: ovl_Obj_Pzlblock + * Description: Puzzle Block + */ + #include "z_obj_pzlblock.h" #define FLAGS 0x04000010 diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index 219e89321..e398d3336 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_roomtimer.c + * Overlay: ovl_Obj_Roomtimer + * Description: + */ + #include "z_obj_roomtimer.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 2f10d6a68..6163c753c 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_rotlift.c + * Overlay: ovl_Obj_Rotlift + * Description: Deku Moon Dungeon - Spiked Rotating Platforms + */ + #include "z_obj_rotlift.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index d067ff2b3..80cad625f 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_shutter.c + * Overlay: ovl_Obj_Shutter + * Description: + */ + #include "z_obj_shutter.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 83612cfa3..677ab56b9 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_skateblock.c + * Overlay: ovl_Obj_Skateblock + * Description: Pushable block that slides on ice + */ + #include "z_obj_skateblock.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index dae5c4711..f928acc0e 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_smork.c + * Overlay: ovl_Obj_Smork + * Description: Romani Ranch Chimney Smoke + */ + #include "z_obj_smork.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index a927cadfc..42cec6623 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_snowball.c + * Overlay: ovl_Obj_Snowball + * Description: Large Snowball + */ + #include "z_obj_snowball.h" #define FLAGS 0x00000000 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 fa6b60135..ea554c4cf 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_snowball2.c + * Overlay: ovl_Obj_Snowball2 + * Description: Small Snowball + */ + #include "z_obj_snowball2.h" #define FLAGS 0x00800000 diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c index d80f30fa0..6b59eeb16 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_sound.c + * Overlay: ovl_Obj_Sound + * Description: Plays certain sounds (e.g., swamp waterfall noise) + */ + #include "z_obj_sound.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 95c1e0402..90fa1f42f 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_spidertent.c + * Overlay: ovl_Obj_Spidertent + * Description: Tent-Shaped Spider Web + */ + #include "z_obj_spidertent.h" #define FLAGS 0x10000000 diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index c9a881180..e0e1c99a4 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_spinyroll.c + * Overlay: ovl_Obj_Spinyroll + * Description: Spike-Covered Log + */ + #include "z_obj_spinyroll.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 79077e7d2..b8e576e39 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_switch.c + * Overlay: ovl_Obj_Switch + * Description: Floor and Eye Switches + */ + #include "z_obj_switch.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index f8c1bcd35..bc56c60d2 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_swprize.c + * Overlay: ovl_Obj_Swprize + * Description: Spawner for dirt square prize? + */ + #include "z_obj_swprize.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c index 0b2c789f2..d1e168447 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_takaraya_wall.c + * Overlay: ovl_Obj_Takaraya_Wall + * Description: Treasure Chest Shop rising wall + */ + #include "z_obj_takaraya_wall.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c index 2fc319692..6d7fd7552 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_taru.c + * Overlay: ovl_Obj_Taru + * Description: Wooden Barrel + */ + #include "z_obj_taru.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index 3d4edd76e..7bb44cc94 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_toge.c + * Overlay: ovl_Obj_Toge + * Description: Blade Trap + */ + #include "z_obj_toge.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c index 2ac8a64a6..9ffa6d446 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_tokei_tobira.c + * Overlay: ovl_Obj_Tokei_Tobira + * Description: Clock Tower - Swinging Doors + */ + #include "z_obj_tokei_tobira.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c index f1247cfef..327183cfd 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_tokei_turret.c + * Overlay: ovl_Obj_Tokei_Turret + * Description: South Clock Town - Flags & Carnival Platform + */ + #include "z_obj_tokei_turret.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 484e0bf3a..76a38e117 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_tokeidai.c + * Overlay: ovl_Obj_Tokeidai + * Description: Clock Face + */ + #include "z_obj_tokeidai.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 1ae3bf122..5a84ec663 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_toudai.c + * Overlay: ovl_Obj_Toudai + * Description: Clock Tower Spotlight + */ + #include "z_obj_toudai.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index 8ffee7d20..6eedfd500 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_tree.c + * Overlay: ovl_Obj_Tree + * Description: Single tree (e.g. North Clock Town) + */ + #include "z_obj_tree.h" #define FLAGS 0x02000000 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 d9f944527..5eac816e2 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_tsubo.c + * Overlay: ovl_Obj_Tsubo + * Description: Pots + */ + #include "z_obj_tsubo.h" #define FLAGS 0x04800010 diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index fe474e428..ee5222543 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_um.c + * Overlay: ovl_Obj_Um + * Description: Cremia's cart and milk run quest + */ + #include "z_obj_um.h" #define FLAGS 0x00000039 diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c index 32b9d49dc..2a1f4bf30 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_usiyane.c + * Overlay: ovl_Obj_Usiyane + * Description: Roof of Cow Barn + */ + #include "z_obj_usiyane.h" #define FLAGS 0x00000020 diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 38ade90d7..23178e9c1 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_visiblock.c + * Overlay: ovl_Obj_Visiblock + * Description: Lens of Truth Platform + */ + #include "z_obj_visiblock.h" #define FLAGS 0x00000080 diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index ffbd6a511..df293030a 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_vspinyroll.c + * Overlay: ovl_Obj_Vspinyroll + * Description: Spiked rollers + */ + #include "z_obj_vspinyroll.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index 778b78162..02fc51e13 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_wind.c + * Overlay: ovl_Obj_Wind + * Description: Updraft Current (STT) and Water Current (PFInterior) + */ + #include "z_obj_wind.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index ab8df497c..94f73d2a2 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_wturn.c + * Overlay: ovl_Obj_Wturn + * Description: Stone Tower Temple Inverter + */ + #include "z_obj_wturn.h" #define FLAGS 0x02100010 diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 76100efc6..55e14fb15 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_y2lift.c + * Overlay: ovl_Obj_Y2lift + * Description: + */ + #include "z_obj_y2lift.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c index be1c5f9d5..6eb1cffa7 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_y2shutter.c + * Overlay: ovl_Obj_Y2shutter + * Description: + */ + #include "z_obj_y2shutter.h" #define FLAGS 0x00000010 diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 1f63b1389..73ebea007 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_yado.c + * Overlay: ovl_Obj_Yado + * Description: Stockpot Inn - 2nd Floor Window + */ + #include "z_obj_yado.h" #define FLAGS 0x00000030 diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index c0a4f0b6a..e79af5a3c 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_yasi.c + * Overlay: ovl_Obj_Yasi + * Description: Palm Tree + */ + #include "z_obj_yasi.h" #define FLAGS 0x00000000 diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 7cd8eab45..2787b2ef4 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -1,3 +1,9 @@ +/* + * File: z_object_kankyo.c + * Overlay: ovl_Object_Kankyo + * Description: + */ + #include "z_object_kankyo.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 18bdbf1e7..bd9b0c4e4 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_spot.c + * Overlay: ovl_Oceff_Spot + * Description: + */ + #include "z_oceff_spot.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index b287f82f3..14860ee61 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_storm.c + * Overlay: ovl_Oceff_Storm + * Description: + */ + #include "z_oceff_storm.h" #define FLAGS 0x02000030 diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 6b15732af..087dd5ecf 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe.c + * Overlay: ovl_Oceff_Wipe + * Description: + */ + #include "z_oceff_wipe.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index aa0adb3ca..1caac073e 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe2.c + * Overlay: ovl_Oceff_Wipe2 + * Description: + */ + #include "z_oceff_wipe2.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 318f19291..cf0fabe94 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe3.c + * Overlay: ovl_Oceff_Wipe3 + * Description: + */ + #include "z_oceff_wipe3.h" #define FLAGS 0x02000010 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 f7b1611f0..99e9e2048 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe4.c + * Overlay: ovl_Oceff_Wipe4 + * Description: + */ + #include "z_oceff_wipe4.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 74c7e17d3..637d91cc7 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe5.c + * Overlay: ovl_Oceff_Wipe5 + * Description: + */ + #include "z_oceff_wipe5.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index cefe27e50..365475ac2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe6.c + * Overlay: ovl_Oceff_Wipe6 + * Description: + */ + #include "z_oceff_wipe6.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index c1151dd94..1adf9d44c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -1,3 +1,9 @@ +/* + * File: z_oceff_wipe7.c + * Overlay: ovl_Oceff_Wipe7 + * Description: + */ + #include "z_oceff_wipe7.h" #define FLAGS 0x02000010 diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 73aa5ac9f..8072d9f44 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -1,3 +1,9 @@ +/* + * File: z_shot_sun.c + * Overlay: ovl_Shot_Sun + * Description: + */ + #include "z_shot_sun.h" #define FLAGS 0x00000009 diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 94ec87a4b..2756b1200 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -1,3 +1,9 @@ +/* + * File: z_tg_sw.c + * Overlay: ovl_TG_Sw + * Description: Skulltula spider bonk detector + */ + #include "z_tg_sw.h" #define FLAGS 0x00000010 From b37e3db802945d95f7a67a7b648fc151349bbe45 Mon Sep 17 00:00:00 2001 From: rylieb <31797144+rylieb@users.noreply.github.com> Date: Tue, 2 Nov 2021 18:29:20 -0600 Subject: [PATCH 62/86] Rename yDistTo variables (#286) * Change yDistTo to yDirDistTo. * Run format.sh. * Apply suggestions from code review Fix comments in header file. * Added "Surface" to yDirDistToWater. * Update names in sellnuts and skb. * Actually fix skb * Rename yDirDistToWaterSurface to depthInWater. * Rename yDirDistToPlayer to playerHeightRel. * Apply suggestions from code review Fix capitalization in header file comments. Co-authored-by: Anghelo Carvajal * Fix Jenkins (Obj_Aqua). * Fix Jenkins (Obj_Etcetera). * Fix Jenkins (En_Thiefbird). * Fix misformatted files in current master. * Fix Jenkins and run format.sh. * Fix misformatted file in current master (z_debug). * Update PR to include new actors. * Update PR to include elforg, po_sisters, wf. * update actorfixer.py with variable name changes. Co-authored-by: Anghelo Carvajal --- include/z64actor.h | 4 +- src/code/z_en_item00.c | 8 ++-- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 9 ++-- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 4 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 4 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 16 +++---- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 4 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 2 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 2 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 2 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 6 +-- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 8 ++-- .../actors/ovl_En_Minislime/z_en_minislime.c | 2 +- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 16 +++---- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 8 ++-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 12 ++--- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 8 ++-- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 4 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 16 +++---- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 8 ++-- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 10 ++-- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 8 ++-- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 48 +++++++++---------- .../actors/ovl_En_Torch2/z_en_torch2.c | 2 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 6 +-- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 2 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 2 +- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.c | 4 +- .../actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 2 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 4 +- src/overlays/actors/ovl_TG_Sw/z_tg_sw.c | 2 +- tools/actorfixer.py | 2 + 35 files changed, 122 insertions(+), 119 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index ec6de9d72..13f13026a 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -172,12 +172,12 @@ typedef struct Actor { /* 0x085 */ u8 floorBgId; // Bg ID of the floor polygon directly below the actor /* 0x086 */ s16 wallYaw; // Y rotation of the wall polygon the actor is touching /* 0x088 */ f32 floorHeight; // Y position of the floor polygon directly below the actor - /* 0x08C */ f32 yDistToWater; // Distance to the surface of active waterbox. Negative value means above water + /* 0x08C */ f32 depthInWater; // Directed distance to the surface of active waterbox. Negative value means water is below. /* 0x090 */ u16 bgCheckFlags; // See comments below actor struct for wip docs. TODO: macros for these flags /* 0x092 */ s16 yawTowardsPlayer; // Y rotation difference between the actor and the player /* 0x094 */ f32 xyzDistToPlayerSq; // Squared distance between the actor and the player in the x,y,z axis /* 0x098 */ f32 xzDistToPlayer; // Distance between the actor and the player in the XZ plane - /* 0x09C */ f32 yDistToPlayer; // Dist is negative if the actor is above the player + /* 0x09C */ f32 playerHeightRel; // Directed distance is negative if the player is below. /* 0x0A0 */ CollisionCheckInfo colChkInfo; // Variables related to the Collision Check system /* 0x0BC */ ActorShape shape; // Variables related to the physical shape of the actor /* 0x0EC */ Vec3f projectedPos; // Position of the actor in projected space diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index acae2e0ce..7d4c050d4 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -480,10 +480,10 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { return; } - if (!((sp38 != 0) && (this->actor.xzDistToPlayer <= 60.0f) && (this->actor.yDistToPlayer >= -100.0f) && - (this->actor.yDistToPlayer <= 100.0f)) && - !((sp38 == 0) && (this->actor.xzDistToPlayer <= 30.0f) && (this->actor.yDistToPlayer >= -50.0f) && - (this->actor.yDistToPlayer <= 50.0f))) { + if (!((sp38 != 0) && (this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel >= -100.0f) && + (this->actor.playerHeightRel <= 100.0f)) && + !((sp38 == 0) && (this->actor.xzDistToPlayer <= 30.0f) && (this->actor.playerHeightRel >= -50.0f) && + (this->actor.playerHeightRel <= 50.0f))) { if (!Actor_HasParent(&this->actor, globalCtx)) { return; } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 2b5a76a49..ed485a110 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -128,7 +128,7 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { s32 dooranaType = GET_DOORANA_TYPE(this); s8 pad[4]; s32 entranceIndex; - f32 yDist; + f32 playerHeightRel; if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f) != 0) { if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && @@ -166,8 +166,9 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { } else { if ((func_801690CC(globalCtx) == 0) && ((player->stateFlags1 & 0x08800000) == 0) && - (this->actor.xzDistToPlayer <= 20.0f) && (yDist = this->actor.yDistToPlayer, (yDist >= -50.0f)) && - (yDist <= 15.0f)) { + (this->actor.xzDistToPlayer <= 20.0f) && + (playerHeightRel = this->actor.playerHeightRel, (playerHeightRel >= -50.0f)) && + (playerHeightRel <= 15.0f)) { player->stateFlags1 |= 0x80000000; this->actor.targetMode = 1; @@ -192,7 +193,7 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } } - if ((this->actor.yDistToPlayer <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { + if ((this->actor.playerHeightRel <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { player = GET_PLAYER(globalCtx); player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 45370609b..ee51c7444 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -99,7 +99,7 @@ void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x444); if (this->actor.params == ENBJI01_PARAMS_DEFAULT) { - if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.yDistToPlayer <= 10.0f)) { + if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel <= 10.0f)) { this->actor.flags |= 0x10000; } else { this->actor.flags &= ~0x10000; @@ -172,7 +172,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } else { this->textId = 0x5F1; } - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); break; case PLAYER_FORM_HUMAN: this->textId = 0x5F7; diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 39acd872d..dcf32235c 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -224,8 +224,8 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { } if (phi_v1 && ((this->actor.xzDistToPlayer > 160.0f) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) && - (((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (fabsf(this->actor.yDistToPlayer) < 120.0f)) || - ((this->actor.params == ENDEKUNUTS_GET_FF00_2) && (this->actor.yDistToPlayer > -60.0f)) || + (((this->actor.params == ENDEKUNUTS_GET_FF00_0) && (fabsf(this->actor.playerHeightRel) < 120.0f)) || + ((this->actor.params == ENDEKUNUTS_GET_FF00_2) && (this->actor.playerHeightRel > -60.0f)) || (this->actor.params == ENDEKUNUTS_GET_FF00_1)) && ((this->unk_190 == 0) || (this->actor.xzDistToPlayer < 480.0f))) { this->skelAnime.playSpeed = 1.0f; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index c0c17367d..7e0127bcf 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -928,11 +928,11 @@ void func_8098B464(EnDg* this, GlobalContext* globalCtx) { Vec3f sp2C; sp2C.x = this->actor.world.pos.x; - sp2C.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp2C.y = this->actor.world.pos.y + this->actor.depthInWater; sp2C.z = this->actor.world.pos.z + 20.0f; EffectSsGSplash_Spawn(globalCtx, &sp2C, NULL, NULL, 0, 800); EffectSsGRipple_Spawn(globalCtx, &sp2C, 100, 500, 30); - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; this->unk_284 = 10; @@ -954,7 +954,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { f32 sp34; sp54.x = this->actor.world.pos.x; - sp54.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp54.y = this->actor.world.pos.y + this->actor.depthInWater; sp54.z = this->actor.world.pos.z + 20.0f; sp48.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; sp48.y = this->actor.home.pos.y + 100.0f; @@ -969,9 +969,9 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &sp54, 100, 500, 30); } - if (this->actor.yDistToWater > 15.0f) { + if (this->actor.depthInWater > 15.0f) { this->actor.velocity.y = 0.5f; - } else if (this->actor.yDistToWater < 10.0f) { + } else if (this->actor.depthInWater < 10.0f) { this->actor.velocity.y = -0.5f; } @@ -1015,7 +1015,7 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { Vec3f sp34; sp34.x = this->actor.world.pos.x; - sp34.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp34.y = this->actor.world.pos.y + this->actor.depthInWater; sp34.z = this->actor.world.pos.z + 20.0f; if (DECR(this->unk_284) == 0) { @@ -1023,9 +1023,9 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 30); } - if (this->actor.yDistToWater > 15.0f) { + if (this->actor.depthInWater > 15.0f) { this->actor.velocity.y = 1.0f; - } else if (this->actor.yDistToWater < 10.0f) { + } else if (this->actor.depthInWater < 10.0f) { this->actor.velocity.y = -1.0f; } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 8670600fe..a73f5423f 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -1372,10 +1372,10 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); if (this->actionFunc != func_8089C7B8) { - if ((this->actor.yDistToWater > 0.0f) && (this->actor.yDistToWater < 10.0f)) { + if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((globalCtx->gameplayFrames % 4) & 1)) { Math_Vec3f_Copy(&sp30, &this->unk_2D4[1 + (globalCtx->gameplayFrames % 4)]); - sp30.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp30.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); } } 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 ff7e3de3b..33706267b 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -536,7 +536,7 @@ void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { } void func_80A7256C(EnDno* this, GlobalContext* globalCtx) { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, -1); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); } void func_80A72598(EnDno* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index e392e6d60..a52d7fa11 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -458,7 +458,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); - func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.yDistToPlayer) + 1.0f, 0, + func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; Actor_SetHeight(&this->actor, 46.0f); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 62cfddd0f..97a2e389d 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -595,7 +595,7 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x1F4); if (this->actor.xzDistToPlayer < (100.0f * this->unk_334)) { - if ((ABS_ALT(temp_v1) < 0x1388) && (this->actor.yDistToPlayer < 60.0f) && + if ((ABS_ALT(temp_v1) < 0x1388) && (this->actor.playerHeightRel < 60.0f) && !(player->stateFlags1 & 0x800000)) { func_808777A8(this); } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 3bbe3ba8e..a2df9772b 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -434,7 +434,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { EnElforg_MoveToTarget(this, &this->actor.home.pos); } - scaledYDistance = this->actor.yDistToPlayer - (this->actor.shape.yOffset * this->actor.scale.y); + scaledYDistance = this->actor.playerHeightRel - (this->actor.shape.yOffset * this->actor.scale.y); if (!func_801233E4(globalCtx)) { if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { EnElforg_SetupFairyCollected(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 716c460a8..120aa4d29 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -412,7 +412,7 @@ void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupDiveAttack(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); this->skelAnime.playSpeed = 1.0f; - this->targetPitch = ((this->actor.yDistToPlayer > 0.0f) ? -0xC00 : 0xC00) + 0x1554; + this->targetPitch = ((this->actor.playerHeightRel > 0.0f) ? -0xC00 : 0xC00) + 0x1554; this->actionFunc = EnFirefly_DiveAttack; } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index ca2891c54..e5a4448d0 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -161,7 +161,7 @@ void func_80BCF354(EnHg* this) { void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { - if ((this->actor.xzDistToPlayer < 200.0f && this->actor.yDistToPlayer < 40.0f) && + if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && !func_800EE29C(globalCtx, 0x1E3)) { func_80BCF468(this); } @@ -353,7 +353,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->actor.colChkInfo.health == 1 && !(fabsf(this->actor.yDistToPlayer) >= 80.0f)) { + if (this->actor.colChkInfo.health == 1 && !(fabsf(this->actor.playerHeightRel) >= 80.0f)) { if (player->stateFlags2 & 0x08000000) { if (!D_80BD00C8) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); @@ -372,7 +372,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { func_80BCF88C(this); } } else { - if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.yDistToPlayer) < 40.0f) { + if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { if (!(gSaveContext.weekEventReg[0x3D] & 2)) { gSaveContext.weekEventReg[0x3D] |= 2; 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 b2e0a09d9..65f5e4d55 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -251,7 +251,7 @@ void EnHoll_VerticalBgCoverIdle(EnHoll* this, GlobalContext* globalCtx) { f32 playerDistFromCentralPlane; if ((this->actor.xzDistToPlayer < EN_HOLL_RADIUS) && - (playerDistFromCentralPlane = fabsf(this->actor.yDistToPlayer), + (playerDistFromCentralPlane = fabsf(this->actor.playerHeightRel), playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL)) { if (playerDistFromCentralPlane < EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { globalCtx->bgCoverAlpha = 255; @@ -260,7 +260,7 @@ void EnHoll_VerticalBgCoverIdle(EnHoll* this, GlobalContext* globalCtx) { } if (playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { s32 enHollId = EN_HOLL_GET_ID_CAST(this); - s32 playerSide = (this->actor.yDistToPlayer > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; + s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[playerSide].room; @@ -279,12 +279,12 @@ void EnHoll_VerticalBgCoverIdle(EnHoll* this, GlobalContext* globalCtx) { void EnHoll_VerticalIdle(EnHoll* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < EN_HOLL_RADIUS) { - f32 playerDistFromCentralPlane = fabsf(this->actor.yDistToPlayer); + f32 playerDistFromCentralPlane = fabsf(this->actor.playerHeightRel); if (playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL && playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { s32 enHollId = EN_HOLL_GET_ID_CAST(this); - s32 playerSide = (this->actor.yDistToPlayer > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; + s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; this->actor.room = globalCtx->doorCtx.transitionActorList[enHollId].sides[playerSide].room; if ((this->actor.room != globalCtx->roomCtx.currRoom.num) && diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 18be1dc95..831e6a4b9 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -765,7 +765,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { player = GET_PLAYER(globalCtx); vec1.x = this->actor.world.pos.x; vec1.z = this->actor.world.pos.z; - vec1.y = player->actor.world.pos.y + player->actor.yDistToWater; + vec1.y = player->actor.world.pos.y + player->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &vec1, 500, 720, 0); } } diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 191939426..d3e7f1cd0 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -261,8 +261,8 @@ s32 func_80A68DD4(EnMushi2* this, GlobalContext* globalCtx) { s32 pad2; f32 sp24; - if ((this->actor.xzDistToPlayer < 32.0f) && (this->actor.yDistToPlayer > -10.0f) && - (this->actor.yDistToPlayer < 31.0f)) { + if ((this->actor.xzDistToPlayer < 32.0f) && (this->actor.playerHeightRel > -10.0f) && + (this->actor.playerHeightRel < 31.0f)) { player = GET_PLAYER(globalCtx); sp2E = BINANG_ROT180(this->actor.yawTowardsPlayer); sp24 = Math_SinS(sp2E); @@ -533,14 +533,14 @@ void func_80A697C4(EnMushi2* this, GlobalContext* globalCtx) { if (func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, &sp30)) { - this->actor.yDistToWater = sp2C - this->actor.world.pos.y; - if (this->actor.yDistToWater >= 1.0f) { + this->actor.depthInWater = sp2C - this->actor.world.pos.y; + if (this->actor.depthInWater >= 1.0f) { this->unk_30C |= 0x20; } else { this->unk_30C &= ~0x20; } } else { - this->actor.yDistToWater = BGCHECK_Y_MIN; + this->actor.depthInWater = BGCHECK_Y_MIN; this->unk_30C &= ~0x20; } } @@ -966,7 +966,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_80A69424(this, globalCtx); - Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.yDistToWater, 2.8f); + Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 2.8f); this->skelAnime.playSpeed = this->unk_368 * 0.018f; this->skelAnime.playSpeed = CLAMP(this->skelAnime.playSpeed, 0.1f, 1.9f); @@ -992,7 +992,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Vec3f sp3C; sp3C.x = this->actor.world.pos.x; - sp3C.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp3C.y = this->actor.world.pos.y + this->actor.depthInWater; sp3C.z = this->actor.world.pos.z; EffectSsGRipple_Spawn(globalCtx, &sp3C, 40, 200, 4); } @@ -1030,7 +1030,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); - if ((this->actor.flags & 0x40) && (this->actor.yDistToWater > 5.0f) && (this->actor.yDistToWater < 30.0f) && + if ((this->actor.flags & 0x40) && (this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 4bad3b031..f72add584 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -523,13 +523,13 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x20) { // still touching water this->actor.gravity = 0.0f; - if (this->actor.yDistToWater > 15.0f) { + if (this->actor.depthInWater > 15.0f) { this->actor.world.pos.y += 2.0f; } if (this->unkTimer250 == 0) { this->unkTimer250 = 30; Math_Vec3f_Copy(&ripplePos, &this->actor.world.pos); - ripplePos.y += this->actor.yDistToWater; + ripplePos.y += this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 30); } @@ -858,12 +858,12 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnNiw_LandBeforeIdle; return; - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f) && + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f) && (this->unknownState28E != 6)) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; Math_Vec3f_Copy(&pos, &this->actor.world.pos); - pos.y += this->actor.yDistToWater; + pos.y += this->actor.depthInWater; this->unkTimer250 = 30; EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); this->unkTimer252 = 0; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 0f987a390..1bbdae1f9 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -387,7 +387,7 @@ void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { this->unk_38C = 12; gSaveContext.weekEventReg[32] |= 1; } - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.yDistToPlayer); + func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; } @@ -397,7 +397,7 @@ void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx) { func_80B5C244(this, globalCtx); func_80B5C244(this->unk_360, globalCtx); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.yDistToPlayer); + func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -611,7 +611,7 @@ void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80B5CBEC; } @@ -622,7 +622,7 @@ void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); } } @@ -698,7 +698,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); if (this->unk_32C & 0x800) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.yDistToPlayer, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); } else { this->actor.flags &= ~0x10000; if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { @@ -707,7 +707,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } if (!(gSaveContext.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { - if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.yDistToPlayer) <= 130.0f)) { + if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.playerHeightRel) <= 130.0f)) { player->unk_B2B = 29; } 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 fd87fdc59..12e234991 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -273,10 +273,10 @@ void EnPametfrog_ChangeColliderThaw(EnPametfrog* this, GlobalContext* globalCtx) void EnPametfrog_JumpWaterEffects(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f pos; - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { pos.x = this->actor.world.pos.x; pos.z = this->actor.world.pos.z; - pos.y = this->actor.world.pos.y + this->actor.yDistToWater; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &pos, 150, 550, 0); pos.y += 8.0f; EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 550); @@ -286,10 +286,10 @@ void EnPametfrog_JumpWaterEffects(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_IdleWaterEffects(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f pos; - if ((this->actor.yDistToWater > 0.0f) && ((globalCtx->gameplayFrames % 14) == 0)) { + if ((this->actor.depthInWater > 0.0f) && ((globalCtx->gameplayFrames % 14) == 0)) { pos.x = this->actor.world.pos.x; pos.z = this->actor.world.pos.z; - pos.y = this->actor.world.pos.y + this->actor.yDistToWater; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &pos, 150, 550, 0); } } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 4ec78d033..57fca7fd7 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -344,7 +344,7 @@ void func_80B1ACB8(EnPoSisters* this, GlobalContext* globalCtx) { } } - if ((this->actor.xzDistToPlayer < 600.0f) && (fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f)) { + if ((this->actor.xzDistToPlayer < 600.0f) && (fabsf(this->actor.playerHeightRel + 5.0f) < 30.0f)) { func_80B1AE28(this); } else if ((this->unk_192 == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f)) { func_80B1AB5C(this); @@ -377,7 +377,7 @@ void func_80B1AE3C(EnPoSisters* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C); } - if ((this->actor.xzDistToPlayer < 320.0f) && (fabsf(this->actor.yDistToPlayer + 5.0f) < 30.0f)) { + if ((this->actor.xzDistToPlayer < 320.0f) && (fabsf(this->actor.playerHeightRel + 5.0f) < 30.0f)) { func_80B1AF8C(this); } else if (this->actor.xzDistToPlayer > 720.0f) { func_80B1AC40(this); diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index a860e49fb..c355f9934 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -141,7 +141,7 @@ void EnSb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSb_SpawnBubbles(GlobalContext* globalCtx, EnSb* this) { s32 bubbleCount; - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { for (bubbleCount = 0; bubbleCount < 10; bubbleCount++) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 10.0f, 10.0f, 30.0f, 0.25f); } @@ -169,7 +169,7 @@ void EnSb_SetupWaitOpen(EnSb* this) { void EnSb_SetupLunge(EnSb* this) { f32 frameCount = Animation_GetLastFrame(&D_06000124); - f32 playbackSpeed = this->actor.yDistToWater > 0.0f ? 1.0f : 0.0f; + f32 playbackSpeed = this->actor.depthInWater > 0.0f ? 1.0f : 0.0f; Animation_Change(&this->skelAnime, &D_06000124, playbackSpeed, 0.0f, frameCount, 2, 0); this->state = SHELLBLADE_LUNGE; @@ -191,7 +191,7 @@ void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { } this->state = SHELLBLADE_WAIT_CLOSED; if (changeSpeed) { - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { this->actor.speedXZ = -5.0f; if (this->actor.velocity.y < 0.0f) { this->actor.velocity.y = 2.1f; @@ -252,7 +252,7 @@ void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, invertedYaw, 1, 0x1F40, 0xA); if (this->actor.shape.rot.y == invertedYaw) { this->actor.world.rot.y = this->yawAngle; - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { this->actor.velocity.y = 3.0f; this->actor.speedXZ = 5.0f; this->actor.gravity = -0.35f; @@ -270,7 +270,7 @@ void EnSb_TurnAround(EnSb* this, GlobalContext* globalCtx) { void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (this->actor.velocity.y <= -0.1f || this->actor.bgCheckFlags & 2) { - if (!(this->actor.yDistToWater > 0.0f)) { + if (!(this->actor.depthInWater > 0.0f)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } this->actor.bgCheckFlags &= ~2; @@ -288,7 +288,7 @@ void EnSb_Bounce(EnSb* this, GlobalContext* globalCtx) { if (this->bounceCounter != 0) { this->bounceCounter--; this->attackTimer = 1; - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { this->actor.velocity.y = 3.0f; this->actor.speedXZ = 5.0f; this->actor.gravity = -0.35f; @@ -363,7 +363,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->isDead) { - if (this->actor.yDistToWater > 0.0f) { + if (this->actor.depthInWater > 0.0f) { this->actor.params = 4; } else { this->actor.params = 1; @@ -393,7 +393,7 @@ void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->isDrawn != false) { if (limbIndex < 7) { - phi_a2 = (this->actor.yDistToWater > 0) ? 4 : 1; + phi_a2 = (this->actor.depthInWater > 0) ? 4 : 1; func_800BBCEC(thisx, globalCtx, phi_a2, dList); } if (limbIndex == 6) { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index badcc5501..c939d4c11 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -302,7 +302,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (((this->actor.yDistToPlayer < 50.0f) && (this->actor.yDistToPlayer > -50.0f) ? true : false) && + if (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f) ? true : false) && ((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADB4F4; @@ -390,7 +390,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } } } else if (((this->actor.xzDistToPlayer < 80.0f) && - (((this->actor.yDistToPlayer < 50.0f) && (this->actor.yDistToPlayer > -50.0f)) ? true : false)) || + (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || this->actor.isTargeted) { func_800B85E0(&this->actor, globalCtx, 80.0f, 0x2A); if (player->transformation == PLAYER_FORM_DEKU) { @@ -416,7 +416,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } } - if (!(((this->actor.yDistToPlayer < 50.0f) && (this->actor.yDistToPlayer > -50.0f)) ? true : false) || + if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_34C = 4; func_8013BC6C(&this->skelAnime, D_80ADD990, 4); @@ -674,7 +674,7 @@ void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_334++; } } - } else if (this->actor.yDistToPlayer > 500.0f) { + } else if (this->actor.playerHeightRel > 500.0f) { ActorCutscene_Stop(this->cutscene); this->actionFunc = func_80ADC580; } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 3fd19ef91..13669d284 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -872,7 +872,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((this->unk_3DE != 6) && (this->unk_3DE != 7)) { - if ((this->actor.bgCheckFlags & 0x60) && (this->actor.yDistToWater >= 40.0f)) { + if ((this->actor.bgCheckFlags & 0x60) && (this->actor.depthInWater >= 40.0f)) { this->actor.colChkInfo.health = 0; this->unk_3E4 = 0; func_809961E4(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 7449b0f5d..d24f0ec0b 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -396,7 +396,7 @@ void func_80BAAF1C(EnSuttari* this) { } void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { - if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.yDistToPlayer < 100.0f)) { + if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.playerHeightRel < 100.0f)) { Vec3f effectVelOffset = { 0.0f, 0.0f, 0.0f }; Vec3f effectPos; Vec3f effectVel; @@ -428,7 +428,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { - if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.yDistToPlayer < 100.0f)) { + if ((this->actor.xzDistToPlayer < 500.0f) && (this->actor.playerHeightRel < 100.0f)) { Vec3f effectVelOffset = { 0.0f, 0.0f, 0.0f }; Vec3f effectPos; Vec3f effectVel; @@ -988,7 +988,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 0, 0); func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { - if (this->actor.yDistToPlayer < 60.0f && this->actor.xzDistToPlayer < 500.0f) { + if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { this->unk3F2 = this->unk2DE; this->actionFunc = func_80BACBB0; } @@ -1013,7 +1013,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } - if ((this->actor.yDistToPlayer < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { + if ((this->actor.playerHeightRel < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } else if (func_80BAA904(this, globalCtx)) { @@ -1043,7 +1043,7 @@ void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } - if ((this->actor.yDistToPlayer < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { + if ((this->actor.playerHeightRel < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { this->actionFunc = func_80BACBB0; Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); } else { diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index b303ed877..139a2f43b 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -505,7 +505,7 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); } - if ((this->actor.yDistToWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { this->unk_190 = -4096; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 75.0f)) { this->unk_190 = -Rand_S16Offset(2048, 2048); @@ -529,7 +529,7 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.yDistToWater < -40.0f)) { + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.depthInWater < -40.0f)) { func_80C118E4(this); } } @@ -574,7 +574,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) || (player->stateFlags1 & 0x800000) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->collider.base.atFlags & AT_HIT) || - (this->actor.bgCheckFlags & 1) || (this->actor.yDistToWater > -40.0f)) { + (this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); @@ -841,7 +841,7 @@ void func_80C126A8(EnThiefbird* this) { void func_80C126D8(EnThiefbird* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_ApproachS(&this->actor.shape.rot.x, 0x3000, 6, 0x1000); - if (this->actor.yDistToPlayer > 100.0f) { + if (this->actor.playerHeightRel > 100.0f) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 7a17a27b4..1afbd5ce5 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -231,7 +231,7 @@ s32 func_80893ADC(EnTite* this) { s32 func_80893B10(EnTite* this) { Math_StepToF(&this->actor.velocity.y, 0.0f, 2.0f); - return Math_StepToF(&this->actor.world.pos.y, (this->actor.world.pos.y + this->actor.yDistToWater) - 1.0f, 2.0f); + return Math_StepToF(&this->actor.world.pos.y, (this->actor.world.pos.y + this->actor.depthInWater) - 1.0f, 2.0f); } void func_80893B70(EnTite* this) { @@ -309,7 +309,7 @@ void func_80893F30(EnTite* this, GlobalContext* globalCtx) { if (this->unk_2BC > 0) { this->unk_2BC--; } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) && (this->actor.xzDistToPlayer < 300.0f) && - (this->actor.yDistToPlayer < 80.0f)) { + (this->actor.playerHeightRel < 80.0f)) { func_808945EC(this); } } @@ -337,7 +337,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { if (!func_80893ADC(this)) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); } else { - this->actor.world.pos.y += this->actor.yDistToWater; + this->actor.world.pos.y += this->actor.depthInWater; Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } @@ -376,7 +376,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { void func_808942B4(EnTite* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && (this->actor.velocity.y <= 0.0f)) { this->actor.speedXZ = 0.0f; this->collider.base.atFlags &= ~AT_HIT; @@ -410,7 +410,7 @@ void func_80894414(EnTite* this) { void func_80894454(EnTite* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || - (this->actor.yDistToPlayer > 80.0f)) { + (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { func_808945EC(this); @@ -427,7 +427,7 @@ void func_8089452C(EnTite* this, GlobalContext* globalCtx) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); - sp2C.y += this->actor.yDistToWater; + sp2C.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); @@ -473,11 +473,11 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { } if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || - (this->actor.yDistToPlayer > 80.0f)) { + (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater < 10.0f))) && + } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && Actor_IsActorFacingLink(&this->actor, 0xE38)) { - if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { func_80893A9C(this, globalCtx); } else { func_8089484C(this); @@ -494,7 +494,7 @@ void func_8089484C(EnTite* this) { this->actor.gravity = -1.0f; this->actor.speedXZ = 4.0f; if (func_80893ADC(this)) { - this->actor.world.pos.y += this->actor.yDistToWater; + this->actor.world.pos.y += this->actor.depthInWater; Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); @@ -512,7 +512,7 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { if (func_80893ADC(this)) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); - sp34.y += this->actor.yDistToWater; + sp34.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; EffectSsGRipple_Spawn(globalCtx, &sp34, 0, 500, 0); } @@ -520,7 +520,7 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { func_80893BCC(this, globalCtx); } - if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.yDistToWater > 0.0f))) && + if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && (this->actor.velocity.y <= 0.0f)) { this->actor.speedXZ = 0.0f; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4000); @@ -534,9 +534,9 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { } if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || - (this->actor.yDistToPlayer > 80.0f)) { + (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) { + } else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { func_808945EC(this); } else { func_8089484C(this); @@ -565,7 +565,7 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { if (func_80893ADC(this) && (this->actor.velocity.y <= 0.0f)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - this->actor.world.pos.y += this->actor.yDistToWater - 1.0f; + this->actor.world.pos.y += this->actor.depthInWater - 1.0f; } if (this->actor.bgCheckFlags & 0x40) { @@ -578,10 +578,10 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || - (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) && (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); - } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && Actor_IsActorFacingLink(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { @@ -607,7 +607,7 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { if ((func_80893ADC(this) != 0) && (this->actor.velocity.y <= 0.0f)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - this->actor.world.pos.y += this->actor.yDistToWater; + this->actor.world.pos.y += this->actor.depthInWater; } if (this->actor.bgCheckFlags & 0x40) { @@ -623,10 +623,10 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { } else if (this->unk_2B9 != 0) { func_808955E4(this); } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || - (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.yDistToPlayer > 80.0f)) && + (((this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) && (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); - } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) && + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && Actor_IsActorFacingLink(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { @@ -799,7 +799,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80893A18(this); if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (this->actor.xzDistToPlayer > 450.0f) || - (this->actor.yDistToPlayer > 80.0f)) { + (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { func_808945EC(this); @@ -1045,15 +1045,15 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); - sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } } else if (this->actor.bgCheckFlags & 0x20) { s32 temp = globalCtx->gameplayFrames & 7; - if (!(temp & 1) && (this->actor.yDistToWater < 10.0f)) { + if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); - sp48.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index d02573039..ba6945b84 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -108,7 +108,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { targetAlpha = 0; } else if (this->state == TORCH2_STATE_FADING_IN) { // Stay semitransparent until the player moves away - if ((this->actor.xzDistToPlayer > 32.0f) || (fabsf(this->actor.yDistToPlayer) > 70.0f)) { + if ((this->actor.xzDistToPlayer > 32.0f) || (fabsf(this->actor.playerHeightRel) > 70.0f)) { this->state = TORCH2_STATE_SOLID; } targetAlpha = 60; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index d808de961..8eafd140e 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -137,7 +137,7 @@ void EnTuboTrap_SpawnEffectsInWater(EnTuboTrap* this, GlobalContext* globalCtx) Vec3f* actorPos = &this->actor.world.pos; pos = *actorPos; - pos.y += this->actor.yDistToWater; + pos.y += this->actor.depthInWater; EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 0x190); @@ -172,7 +172,7 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Player* player2 = GET_PLAYER(globalCtx); - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f)) { + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { EnTuboTrap_SpawnEffectsInWater(this, globalCtx); Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); EnTuboTrap_DropCollectible(this, globalCtx); @@ -232,7 +232,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.world.pos.y <= player->actor.world.pos.y)) { startingRotation = this->actor.home.rot.z; - if ((startingRotation == 0) || (this->actor.yDistToPlayer <= (startingRotation * 10.0f))) { + if ((startingRotation == 0) || (this->actor.playerHeightRel <= (startingRotation * 10.0f))) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); currentHeight = this->actor.world.pos.y; this->actor.flags |= 0x11; // always update and can target diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index f46207777..0ff4d527b 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1086,7 +1086,7 @@ void func_809928CC(EnWf* this, GlobalContext* globalCtx) { func_8099223C(this); } } else if (Actor_IsActorFacingLink(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && - (fabsf(this->actor.yDistToPlayer) < 50.0f)) { + (fabsf(this->actor.playerHeightRel) < 50.0f)) { sp2A = player->actor.shape.rot.y - this->actor.shape.rot.y; if (!func_800BC5EC(globalCtx, &this->actor) && (((globalCtx->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 2111f1d0f..2b4b762f7 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -74,7 +74,7 @@ void func_80ACB6A0(ObjAqua* this, GlobalContext* globalCtx) { s32 angleOffset = 0; s32 i; - sp58.y = this->actor.world.pos.y + this->actor.yDistToWater; + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; for (i = 0; i < 4; i++) { sp58.x = this->actor.world.pos.x + Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; sp58.z = this->actor.world.pos.z + Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 8.0f; diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index f252efbd5..e4d9707be 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -140,9 +140,9 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { this->oscillationTimer = 30; this->burrowFlag &= ~1; } else if ((player->stateFlags3 & 0x2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && - (this->dyna.actor.yDistToPlayer > 0.0f)) { + (this->dyna.actor.playerHeightRel > 0.0f)) { // Player is hovering above the Deku Flower - minOscillationTimer = 10 - (s32)(this->dyna.actor.yDistToPlayer * 0.05f); + minOscillationTimer = 10 - (s32)(this->dyna.actor.playerHeightRel * 0.05f); if (this->oscillationTimer < minOscillationTimer) { this->oscillationTimer = minOscillationTimer; } diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index c6870edf1..9632088b7 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -103,7 +103,7 @@ void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20) && - (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.yDistToPlayer < 40.0f) && + (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.playerHeightRel < 40.0f) && OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { ObjHgdoor_SetChild(this, globalCtx); ObjHgdoor_SetParent(this, globalCtx); 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 3fc376dc4..7879bd1d9 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -213,7 +213,7 @@ void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) { Vec3f pos; Vec3f velocity; - pos.y = worldPos->y + this->actor.yDistToWater; + pos.y = worldPos->y + this->actor.depthInWater; for (angle = 0, i = 0; i < 5; i++, angle += 0x3333) { pos.x = (Math_SinS(((s32)(Rand_ZeroOne() * 6000.0f)) + angle) * 15.0f) + worldPos->x; pos.z = (Math_CosS(((s32)(Rand_ZeroOne() * 6000.0f)) + angle) * 15.0f) + worldPos->z; @@ -277,7 +277,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { ObjKibako_SpawnCollectible(this, globalCtx); } func_800B8E58(&this->actor, NA_SE_PL_PULL_UP_WOODBOX); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 19.0f)) { + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { ObjKibako_WaterBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 2756b1200..d1a6afb3e 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -40,7 +40,7 @@ void TGSw_ActionDecider(TGSw* this, GlobalContext* globalCtx) { scaledAbsoluteRotY = ABS_ALT(this->actor.world.rot.y) * 4.0f; scaledAbsoluteRotZ = ABS_ALT(this->actor.world.rot.z) * 4.0f; - if ((scaledAbsoluteRotZ < this->actor.xzDistToPlayer) || (scaledAbsoluteRotY < this->actor.yDistToPlayer)) { + if ((scaledAbsoluteRotZ < this->actor.xzDistToPlayer) || (scaledAbsoluteRotY < this->actor.playerHeightRel)) { return; } unk1F4 = globalCtx->actorCtx.unk1F4; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 24e0d0ad5..e1815e224 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -187,6 +187,8 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.yDistToWater" : "actor.depthInWater", + "actor.yDistToPlayer" : "actor.playerHeightRel", } def replace_anim(file): From 52960d5c2fd0bc957bf743fc8f0d43d1e4e6b99d Mon Sep 17 00:00:00 2001 From: Lucas Shaw <49287729+shawlucas@users.noreply.github.com> Date: Wed, 3 Nov 2021 09:55:08 -0400 Subject: [PATCH 63/86] z_path.c OK (#379) * z_path.c OK * Ran format --- include/functions.h | 6 ++-- src/code/z_path.c | 44 +++++++++++++++++++++-- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 2 +- tools/disasm/functions.txt | 6 ++-- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index fedeaf0f5..0b9685639 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2193,9 +2193,9 @@ void func_8011C808(GlobalContext* globalCtx); // void func_801210E0(void); // void func_80121F94(void); void func_80121FC4(GlobalContext* globalCtx); -s32 func_801224E0(s32 param_1, s16 param_2, s16 param_3); -f32 func_80122524(Actor* actor, Path* path, s16 arg2, s16* arg3); -// void func_801225CC(void); +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max); +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); +void Path_CopyLastPoint(Path* path, Vec3f* dest); // void func_80122660(void); // UNK_TYPE4 func_80122670(s32* param_1, Input* input); // void func_801226E0(void); diff --git a/src/code/z_path.c b/src/code/z_path.c index 15d940923..0462a40cd 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -1,7 +1,45 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_801224E0.s") +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_80122524.s") + if (index != max) { + path = &globalCtx->setupPathList[index]; + } else { + path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_801225CC.s") + return path; +} + +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { + f32 dx; + f32 dz; + Vec3s* pointPos; + + if (path == NULL) { + return -1.0; + } + + pointPos = Lib_SegmentedToVirtual(path->points); + pointPos = &pointPos[waypoint]; + + dx = pointPos->x - actor->world.pos.x; + dz = pointPos->z - actor->world.pos.z; + + *yaw = Math_Atan2S(dx, dz); + + return SQ(dx) + SQ(dz); +} + +void Path_CopyLastPoint(Path* path, Vec3f* dest) { + Vec3s* pointPos; + + if (path != NULL) { + pointPos = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[path->count - 1]; + + dest->x = pointPos->x; + dest->y = pointPos->y; + dest->z = pointPos->z; + } +} diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index f0a2327fd..c325a2b07 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -545,7 +545,7 @@ void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx) { void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { s32 pad; s16 sp4A; - f32 sp44 = func_80122524(&this->actor, this->path, this->unk_3F8, &sp4A); + f32 sp44 = Path_OrientAndGetDistSq(&this->actor, this->path, this->unk_3F8, &sp4A); Vec3s* points; Math_SmoothStepToS(&this->actor.world.rot.y, sp4A, 6, 0x800, 0x200); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4348bf5b5..d859d9057 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2167,9 +2167,9 @@ 0x801210E0:("func_801210E0",), 0x80121F94:("func_80121F94",), 0x80121FC4:("func_80121FC4",), - 0x801224E0:("func_801224E0",), - 0x80122524:("func_80122524",), - 0x801225CC:("func_801225CC",), + 0x801224E0:("Path_GetByIndex",), + 0x80122524:("Path_OrientAndGetDistSq",), + 0x801225CC:("Path_CopyLastPoint",), 0x80122660:("func_80122660",), 0x80122670:("func_80122670",), 0x801226E0:("func_801226E0",), From 888627d36468c18446a9792156fb590175c7e0c1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 3 Nov 2021 07:15:39 -0700 Subject: [PATCH 64/86] Common data OK (#398) * Matched common data * Change one hex to dec --- include/functions.h | 2 +- spec | 1 - src/code/title_setup.c | 2 +- src/code/z_common_data.c | 21 ++++++++++++++++++++- tools/disasm/functions.txt | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0b9685639..024d3fe7c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1542,7 +1542,7 @@ s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2); s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); -u8 func_800E9360(void); +void SaveContext_Init(void); void GameInfo_Init(void); // void func_800E9470(void); void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); diff --git a/spec b/spec index bf75a91ed..e2866c742 100644 --- a/spec +++ b/spec @@ -468,7 +468,6 @@ beginseg include "build/src/code/z_collision_check.o" include "build/src/code/code_800E8EA0.o" include "build/src/code/z_common_data.o" - include "build/data/code/z_common_data.bss.o" include "build/src/code/z_debug.o" include "build/src/code/z_debug_display.o" include "build/data/code/z_debug_display.data.o" diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 7df67a3b2..69790b60c 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -47,7 +47,7 @@ void TitleSetup_GameStateResetContext(void) { void TitleSetup_InitImpl(GameState* gameState) { func_80185908(); - func_800E9360(); + SaveContext_Init(); TitleSetup_GameStateResetContext(); gameState->running = 0; diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index d391ce153..88fa3e103 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -1,3 +1,22 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_common_data/func_800E9360.s") +SaveContext gSaveContext; + +void SaveContext_Init(void) { + bzero(&gSaveContext, sizeof(gSaveContext)); + gSaveContext.playerForm = 0; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.unk_3F46 = 0; + gSaveContext.nextCutsceneIndex = 0xFFEF; + gSaveContext.cutsceneTrigger = 0; + gSaveContext.unk_3F4D = 0; + gSaveContext.nextDayTime = 0xFFFF; + gSaveContext.environmentTime = 0; + gSaveContext.dogIsLost = true; + gSaveContext.nextTransition = 0xFF; + gSaveContext.unk_3F26 = 50; + gSaveContext.language = 1; + gSaveContext.audioSetting = 0; + gSaveContext.zTargetSetting = 0; +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d859d9057..38ed52486 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1518,7 +1518,7 @@ 0x800E8FA4:("func_800E8FA4",), 0x800E9138:("func_800E9138",), 0x800E9250:("func_800E9250",), - 0x800E9360:("func_800E9360",), + 0x800E9360:("SaveContext_Init",), 0x800E93E0:("GameInfo_Init",), 0x800E9470:("func_800E9470",), 0x800E9488:("DebugDisplay_AddObject",), From 11487db1ca48d0bc66cc0eccdd8702566e4fff6a Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Nov 2021 10:27:48 -0400 Subject: [PATCH 65/86] Updates contributing.md and reviewing.md for the new reservation board. (#402) * Updates contributing.md and reviewing.md for the new reservation board. * Updates contributing.md and reviewing.md for the new reservation board. * Removes Trello specific instructions. --- CONTRIBUTING.md | 10 +++++----- REVIEWING.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ae00f424..3ee29e99e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Useful Links ------------ - [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Trello board](https://trello.com/b/ruxw9n6m/majoras-mask-decompilation) - We use this to track decompilation progress, not GitHub Issues. +- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. - [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. @@ -50,12 +50,12 @@ An *actor* is any thing in the game that moves or performs actions or interactio You should [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. -We track who is working on what on the [Trello board](https://trello.com/b/ruxw9n6m/majoras-mask-decompilation). -After joining the Discord, ask to be added to the Trello board so you can claim your code file and avoid duplicate work. You may need to add a card if a card for your file does not currently exist. +We track who is working on what on the [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro). +After joining the Discord, open the Google Sheets reservation board so you can claim your code file and avoid duplicate work. The work flow is: Reserve a file, decompile it, submit a PR, and then repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR. -Please note that unless it is communicated beforehand you will be expected to fully complete the file if you reserve it on Trello. Exceptions are always easy to approve if it's communicated to the team. Real life circumstances can prevent someone from finishing. In these cases they should link their repo/branch in the trello and unreserve immediately. Communicate any issues with your reservations as early as possible. +Please note that unless it is communicated beforehand you will be expected to fully complete the file if you reserve it on Google Sheets reservation board. Exceptions are always easy to approve if it's communicated to the team. Real life circumstances can prevent someone from finishing. In these cases they should link their repo/branch in the Google Sheets reservation board and unreserve immediately. Communicate any issues with your reservations as early as possible. Style Guide & Conventions ------------------------- @@ -159,4 +159,4 @@ Once all comments are addressed, it is courteous to ping the reviewer on either After all the comments are addressed and at least one contributor has approved the review, the project lead can then review and merge the code. The project lead is also responsible for ensuring that all of these procedures are followed. -Throughout the PR process, you (the author) should update the card on [Trello board](https://trello.com/b/ruxw9n6m/majoras-mask-decompilation) with the appropriate column and labels. +Throughout the PR process, you (the author) should update the row on [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) with the appropriate information as the decompilation process progresses. diff --git a/REVIEWING.md b/REVIEWING.md index 8f1524a17..74f9dbac5 100644 --- a/REVIEWING.md +++ b/REVIEWING.md @@ -13,7 +13,7 @@ Useful Links ------------ - [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Trello board](https://trello.com/b/ruxw9n6m/majoras-mask-decompilation) - We use this to track decompilation progress, not GitHub Issues. +- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. - [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md) - Instructions for contributors. - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. From fcbd524b5dffe4a6496660844d219a3deccc8e07 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Wed, 3 Nov 2021 10:52:01 -0400 Subject: [PATCH 66/86] Debug display mostly OK (#399) * WIP * done? * remove something from variables.h * missed a warning * PR fixes (AngheloAlf) * fix lights * restore ZAPD makefile * format * format again * fix a graph alloc * Missed one in skin --- assets/xml/code/debug_display.xml | 29 +++++++ include/functions.h | 7 +- include/variables.h | 21 ----- include/z64.h | 10 +++ spec | 2 - src/code/z_debug_display.c | 122 ++++++++++++++++++++++++++++-- src/code/z_lights.c | 8 +- src/code/z_skin_matrix.c | 7 +- tools/disasm/functions.txt | 6 +- tools/disasm/variables.txt | 17 ++--- 10 files changed, 170 insertions(+), 59 deletions(-) create mode 100644 assets/xml/code/debug_display.xml diff --git a/assets/xml/code/debug_display.xml b/assets/xml/code/debug_display.xml new file mode 100644 index 000000000..c8ac659bc --- /dev/null +++ b/assets/xml/code/debug_display.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 024d3fe7c..a575fd6e0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1545,12 +1545,7 @@ s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* void SaveContext_Init(void); void GameInfo_Init(void); // void func_800E9470(void); -void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); -void DebugDisplay_DrawObjects(GlobalContext* globalCtx); -// void func_800E95F4(void); -// void func_800E97D8(void); -// void func_800E992C(void); -// void func_800E99B0(void); +DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); // void func_800E9C90(void); // void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3); // void func_800E9CFC(void); diff --git a/include/variables.h b/include/variables.h index d61be8307..2876f1432 100644 --- a/include/variables.h +++ b/include/variables.h @@ -882,26 +882,6 @@ extern ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX]; extern ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX]; extern EffShieldParticleInit shieldParticleInitMetal; extern EffShieldParticleInit shieldParticleInitWood; -extern UNK_TYPE1 D_801BA550; -// extern UNK_TYPE1 D_801BA750; -// extern UNK_TYPE1 D_801BA790; -// extern UNK_TYPE1 D_801BA7F0; -// extern UNK_TYPE1 D_801BA870; -// extern UNK_TYPE1 D_801BA8C0; -// extern UNK_TYPE1 D_801BAAC0; -// extern UNK_TYPE1 D_801BAB40; -// extern UNK_TYPE1 D_801BABB8; -// extern UNK_TYPE1 D_801BACB8; -// extern UNK_TYPE1 D_801BADB8; -// extern UNK_TYPE1 D_801BAEB8; -// extern UNK_TYPE1 D_801BAFB8; -// extern UNK_TYPE1 D_801BAFF8; -// extern UNK_TYPE1 D_801BB010; -// extern UNK_TYPE1 D_801BB018; -// extern UNK_TYPE1 D_801BB050; -// extern UNK_TYPE1 D_801BB058; -// extern UNK_TYPE2 D_801BB068; -// extern UNK_TYPE1 D_801BB08C; // extern UNK_TYPE4 D_801BB090; // extern UNK_TYPE1 D_801BB094; // extern UNK_TYPE1 D_801BB0DC; @@ -3264,7 +3244,6 @@ extern SaveContext gSaveContext; // extern UNK_TYPE1 D_801F3F4A; // extern UNK_TYPE1 D_801F3F5A; extern GameInfo* gGameInfo; -// extern UNK_TYPE1 D_801F3F70; // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; diff --git a/include/z64.h b/include/z64.h index 643a75f0e..66a6e6fd5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1684,6 +1684,16 @@ typedef struct { /* 0x20 */ u16 fracPart[4][4]; } MatrixInternal; // size = 0x40 +typedef struct DebugDispObject { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; + /* 0x14 */ Vec3f scale; + /* 0x20 */ Color_RGBA8 color; + /* 0x24 */ s16 type; + /* 0x28 */ struct DebugDispObject* next; + /* 0x2C */ s32 pad; //Padding not in the OOT version +} DebugDispObject; // size = 0x30 + typedef struct { /* 0x00 */ u8* value; /* 0x04 */ const char* name; diff --git a/spec b/spec index e2866c742..ac312ea30 100644 --- a/spec +++ b/spec @@ -470,8 +470,6 @@ beginseg include "build/src/code/z_common_data.o" include "build/src/code/z_debug.o" include "build/src/code/z_debug_display.o" - include "build/data/code/z_debug_display.data.o" - include "build/data/code/z_debug_display.bss.o" include "build/src/code/z_debug_mode.o" include "build/data/code/z_debug_mode.data.o" include "build/data/code/z_debug_mode.bss.o" diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index f61a90fad..2fe6b7977 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -1,15 +1,125 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E9470.s") +DebugDispObject* sDebugObjectListHead; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s") +typedef struct { + /* 0x00 */ s16 drawType; // indicates which draw function to use when displaying the object + /* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called +} DebugDispObjectInfo; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s") +typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E95F4.s") +void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, GlobalContext*); +void DebugDisplay_DrawPolygon(DebugDispObject*, void*, GlobalContext*); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E97D8.s") +DebugDispObject* DebugDisplay_Init(void) { + sDebugObjectListHead = NULL; + return sDebugObjectListHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E992C.s") +DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, + f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, + GraphicsContext* gfxCtx) { + DebugDispObject* oldHead = sDebugObjectListHead; + + sDebugObjectListHead = GRAPH_ALLOC(gfxCtx, sizeof(DebugDispObject)); + sDebugObjectListHead->pos.x = posX; + sDebugObjectListHead->pos.y = posY; + sDebugObjectListHead->pos.z = posZ; + sDebugObjectListHead->rot.x = rotX; + sDebugObjectListHead->rot.y = rotY; + sDebugObjectListHead->rot.z = rotZ; + sDebugObjectListHead->scale.x = scaleX; + sDebugObjectListHead->scale.y = scaleY; + sDebugObjectListHead->scale.z = scaleZ; + sDebugObjectListHead->color.r = red; + sDebugObjectListHead->color.g = green; + sDebugObjectListHead->color.b = blue; + sDebugObjectListHead->color.a = alpha; + sDebugObjectListHead->type = type; + sDebugObjectListHead->next = oldHead; + return sDebugObjectListHead; +} + +#include "code/debug_display/debug_display.c" + +DebugDispObject_DrawFunc sDebugObjectDrawFuncTable[] = { DebugDisplay_DrawSpriteI8, DebugDisplay_DrawPolygon }; + +DebugDispObjectInfo sDebugObjectInfoTable[] = { + { 0, sDebugDisplayCircleTex }, { 0, sDebugDisplayCrossTex }, { 0, sDebugDisplayBallTex }, + { 0, sDebugDisplayCursorTex }, { 1, &sDebugDisplay1DL }, { 1, &sDebugDisplay3DL }, + { 1, &sDebugDisplay2DL }, +}; + +void DebugDisplay_DrawObjects(GlobalContext* globalCtx) { + DebugDispObject* dispObj = sDebugObjectListHead; + DebugDispObjectInfo* objInfo; + + while (dispObj != NULL) { + objInfo = &sDebugObjectInfoTable[dispObj->type]; + sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx); + dispObj = dispObj->next; + } +} + +void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C6FC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); + Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, 0); + Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1); + Matrix_InsertMatrix(&globalCtx->mf_187FC, 1); + Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, 1); + + gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73); + +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C588(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); + + gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1); + + Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); + Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, arg1); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 D_801BB068[] = { + 0x00140000, 0x0000FFEC, 0x00000000, 0x00000014, 0x00000000, 0xFFEC0000, 0x00000000, 0x00140000, 0x0000FFEC, +}; + +s32 D_801BB08C = 0; + +Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1); + +void func_800E992C(GlobalContext* globalCtx, s32 arg1) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C560(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &D_801D1DE0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s") diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 80d3f7131..fb88fbc77 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -329,9 +329,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 Lights* lights; s32 i; - // TODO allocation should be a macro - lights = (Lights*)((int)gfxCtx->polyOpa.d - sizeof(Lights)); - gfxCtx->polyOpa.d = (void*)lights; + lights = GRAPH_ALLOC(gfxCtx, sizeof(Lights)); lights->l.a.l.col[0] = lights->l.a.l.colc[0] = ambientR; lights->l.a.l.col[1] = lights->l.a.l.colc[1] = ambientG; @@ -356,9 +354,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB) { Lights* lights; - // TODO allocation should be a macro - lights = (Lights*)((int)gfxCtx->polyOpa.d - sizeof(Lights)); - gfxCtx->polyOpa.d = (void*)lights; + lights = GRAPH_ALLOC(gfxCtx, sizeof(Lights)); lights->l.a.l.col[0] = ambientR; lights->l.a.l.colc[0] = ambientR; diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c index 1afc9a5d5..f355aec9b 100644 --- a/src/code/z_skin_matrix.c +++ b/src/code/z_skin_matrix.c @@ -577,12 +577,7 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { } Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) { - s32 pad; - Mtx* mtx; - - // TODO allocation should be a macro - mtx = (Mtx*)((int)gfxCtx->polyOpa.d - sizeof(Mtx)); - gfxCtx->polyOpa.d = (void*)mtx; + Mtx* mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); if (mtx == NULL) { return NULL; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 38ed52486..a51d44753 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1520,11 +1520,11 @@ 0x800E9250:("func_800E9250",), 0x800E9360:("SaveContext_Init",), 0x800E93E0:("GameInfo_Init",), - 0x800E9470:("func_800E9470",), + 0x800E9470:("DebugDisplay_Init",), 0x800E9488:("DebugDisplay_AddObject",), 0x800E9564:("DebugDisplay_DrawObjects",), - 0x800E95F4:("func_800E95F4",), - 0x800E97D8:("func_800E97D8",), + 0x800E95F4:("DebugDisplay_DrawSpriteI8",), + 0x800E97D8:("DebugDisplay_DrawPolygon",), 0x800E992C:("func_800E992C",), 0x800E99B0:("func_800E99B0",), 0x800E9C90:("func_800E9C90",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 15026d89f..3b4818a6e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -892,22 +892,21 @@ 0x801BA508:("shieldParticleInitWood","EffShieldParticleInit","",0x40), 0x801BA550:("D_801BA550","UNK_TYPE1","",0x1), 0x801BA750:("D_801BA750","UNK_TYPE1","",0x1), - 0x801BA790:("D_801BA790","UNK_TYPE1","",0x1), + 0x801BA790:("sDebugDisplay1DL","UNK_TYPE1","",0x1), 0x801BA7F0:("D_801BA7F0","UNK_TYPE1","",0x1), - 0x801BA870:("D_801BA870","UNK_TYPE1","",0x1), + 0x801BA870:("sDebugDisplay2DL","UNK_TYPE1","",0x1), 0x801BA8C0:("D_801BA8C0","UNK_TYPE1","",0x1), 0x801BAAC0:("D_801BAAC0","UNK_TYPE1","",0x1), - 0x801BAB40:("D_801BAB40","UNK_TYPE1","",0x1), + 0x801BAB40:("sDebugDisplay3DL","UNK_TYPE1","",0x1), 0x801BABB8:("D_801BABB8","UNK_TYPE1","",0x1), 0x801BACB8:("D_801BACB8","UNK_TYPE1","",0x1), 0x801BADB8:("D_801BADB8","UNK_TYPE1","",0x1), 0x801BAEB8:("D_801BAEB8","UNK_TYPE1","",0x1), 0x801BAFB8:("D_801BAFB8","UNK_TYPE1","",0x1), - 0x801BAFF8:("D_801BAFF8","UNK_TYPE1","",0x1), - 0x801BB010:("D_801BB010","UNK_TYPE1","",0x1), - 0x801BB018:("D_801BB018","UNK_TYPE1","",0x1), - 0x801BB050:("D_801BB050","UNK_TYPE1","",0x1), - 0x801BB058:("D_801BB058","UNK_TYPE1","",0x1), + 0x801BAFF8:("gDebugSpriteDL","UNK_TYPE1","",0x1), + 0x801BB010:("sDebugObjectDrawFuncTable","UNK_TYPE1","",0x1), + 0x801BB018:("sDebugObjectInfoTable","UNK_TYPE1","",0x1), + 0x801BB050:("sDebugDisplayLight1","Lights1","",0x24), 0x801BB068:("D_801BB068","UNK_TYPE2","",0x2), 0x801BB08C:("D_801BB08C","UNK_TYPE1","",0x1), 0x801BB090:("D_801BB090","UNK_TYPE4","",0x4), @@ -4022,7 +4021,7 @@ 0x801F3F58:("D_801F3F58","UNK_TYPE1","",0x1), 0x801F3F5A:("D_801F3F5A","UNK_TYPE1","",0x1), 0x801F3F60:("gGameInfo","GameInfo*","",0x4), - 0x801F3F70:("D_801F3F70","UNK_TYPE1","",0x1), + 0x801F3F70:("sDebugObjectListHead","UNK_TYPE1","",0x1), 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1), 0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1), 0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1), From 60b9cd789e808ceb9314f6aff3e611a64e9dbfdd Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Wed, 3 Nov 2021 08:10:54 -0700 Subject: [PATCH 67/86] Demo_Kankyo (Lost Woods Sparkles) (#380) * Demo_Kankyo * DemoKankyo: docs * DemoKankyo: documenting this is a pain... * found bug * DemoKankyo: docs * DemoKankyo: function renamed * DemoKankyo: docs * DemoKankyo: more docks * DemoKankyo: more docks * DemoKankyo: docs and format * DemoKankyo: requested changes * DemoKankyo: bug documented * PR feedback via docs * DemoKankyo: minor documentation and format * DemoKankyo: requested changes * DemoKankyo: removed some old comments Co-authored-by: Maide Co-authored-by: isghj8 Co-authored-by: engineer124 --- include/variables.h | 2 +- include/z64.h | 2 +- spec | 3 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 668 +++++++++++++++++- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.h | 38 +- 5 files changed, 692 insertions(+), 21 deletions(-) diff --git a/include/variables.h b/include/variables.h index 2876f1432..3770820bf 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4034,7 +4034,7 @@ extern Gfx D_04075B30[]; extern Gfx D_04076BC0[]; extern Gfx D_04077480[]; extern UNK_TYPE D_04079B10; -extern Gfx D_0407AB10[]; +extern Gfx D_0407AB10[]; // sun (sparkles when small) displaylist extern Gfx D_0407AB58[]; extern UNK_TYPE D_0407AFB0; extern Gfx D_0407D590[]; diff --git a/include/z64.h b/include/z64.h index 66a6e6fd5..dae4195b2 100644 --- a/include/z64.h +++ b/include/z64.h @@ -942,7 +942,7 @@ typedef struct { /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; /* 0xEE */ u8 unk_EE[4]; - /* 0xF2 */ u8 unk_F2[8]; + /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo particle count /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 diff --git a/spec b/spec index ac312ea30..7251410c2 100644 --- a/spec +++ b/spec @@ -1156,8 +1156,7 @@ beginseg name "ovl_Demo_Kankyo" compress include "build/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.o" - include "build/data/ovl_Demo_Kankyo/ovl_Demo_Kankyo.data.o" - include "build/data/ovl_Demo_Kankyo/ovl_Demo_Kankyo.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Kankyo/ovl_Demo_Kankyo_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index fcf3e0dec..6ff4f9096 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -15,12 +15,15 @@ void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx); void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808CF06C(DemoKankyo* this, GlobalContext* globalCtx); -void func_808CF0CC(DemoKankyo* this, GlobalContext* globalCtx); +void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx); -void DemoKankyo_SetupAction(DemoKankyo* this, DemoKankyoActionFunc actionFunc); +extern Gfx D_0407AB58[]; +extern Gfx D_06001000[]; // the bubble display list used by shabom in giants type +extern Gfx D_04023428[]; + +static u8 sLostWoodsSparklesMutex = false; // make sure only one can exist at once +static s16 sLostWoodsSkyFishParticleNum = 0; -#if 0 const ActorInit Demo_Kankyo_InitVars = { ACTOR_DEMO_KANKYO, ACTORCAT_ITEMACTION, @@ -33,24 +36,659 @@ const ActorInit Demo_Kankyo_InitVars = { (ActorFunc)DemoKankyo_Draw, }; -#endif +static s32 sObjectBubbleIndex = OBJECT_BUBBLE | 0x10000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/DemoKankyo_SetupAction.s") +void DemoKankyo_SetupAction(DemoKankyo* this, DemoKankyoActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/func_808CE45C.s") +void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + f32 randSkyfishParticleNum; + f32 repositionLimit; // Distance from posCenter when particles are relocated. Always set to 130.0f + f32 eyeToAtNormX; + f32 eyeToAtNormY; + f32 eyeToAtNormZ; + f32 eyeToAtMag; + f32 posCenterX; + f32 posCenterY; + f32 posCenterZ; + Vec3f eyeToAt; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/func_808CF06C.s") + if (globalCtx->roomCtx.unk7A[1] != 0) { + if (globalCtx->envCtx.unk_F2[3] != 0) { + globalCtx->envCtx.unk_F2[3]--; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + globalCtx->envCtx.unk_F2[3] += 16; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/func_808CF0CC.s") + // note: DemoKankyo can crash if placed in an area that snows (ObjectKankyo) + // because they both use unk_F2 as a particle counter, + // causing DemoKankyo to write beyond its particle array boundry + // this crash can occur if the two actors are in different scenes connected by an exit + // e.g. if you add DemoKankyo to GoronShrine, you will crash entering/leaving through door + for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { + repositionLimit = 130.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/DemoKankyo_Init.s") + eyeToAt.x = globalCtx->view.at.x - globalCtx->view.eye.x; + eyeToAt.y = globalCtx->view.at.y - globalCtx->view.eye.y; + eyeToAt.z = globalCtx->view.at.z - globalCtx->view.eye.z; + eyeToAtMag = sqrtf(SQXYZ(eyeToAt)); + eyeToAtNormX = eyeToAt.x / eyeToAtMag; + eyeToAtNormY = eyeToAt.y / eyeToAtMag; + eyeToAtNormZ = eyeToAt.z / eyeToAtMag; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/DemoKankyo_Destroy.s") + switch (this->particles[i].state) { + case DEMO_KANKYO_STATE_INIT: + this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); + this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); + this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/DemoKankyo_Update.s") + this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->particles[i].posOffset.y = 30.0f; + this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/func_808CF970.s") + this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->particles[i].alpha = 0; + this->particles[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 + this->particles[i].scale = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/func_808CFE04.s") + // speedClock is angles in radians, + // should have used Rand_ZeroOne() * 2 * M_PI + // however, due to properties of sine waves, this is effectively still random + this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->particles[i].pad50 = 0; + this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Kankyo/DemoKankyo_Draw.s") + case DEMO_KANKYO_STATE_SINGLE: + case DEMO_KANKYO_STATE_SKYFISH: + this->particles[i].alphaClock++; + posCenterX = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); + posCenterY = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); + posCenterZ = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); + this->particles[i].posOffsetPrev.x = this->particles[i].posOffset.x; + this->particles[i].posOffsetPrev.y = this->particles[i].posOffset.y; + this->particles[i].posOffsetPrev.z = this->particles[i].posOffset.z; + + if (this->particles[i].state == DEMO_KANKYO_STATE_SINGLE) { + + // The first 32 particles will become skyfish particles + // This block is also init code and only runs once + if (i < 32) { + if (Rand_ZeroOne() < 0.5f) { + this->particles[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; + } else { + this->particles[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); + } + this->particles[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; + this->particles[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; + + // Only the 31st particle matters as sLostWoodsSkyFishParticleNum will be overwritten + // every particle until the last skyfish particle is initialized + randSkyfishParticleNum = Rand_ZeroOne(); + if (randSkyfishParticleNum < 0.2f) { + sLostWoodsSkyFishParticleNum = 1; + } else if (randSkyfishParticleNum < 0.2f) { + // This case is never taken as the else-if conditional is identical to the previous one + sLostWoodsSkyFishParticleNum = 3; + } else if (randSkyfishParticleNum < 0.4f) { + sLostWoodsSkyFishParticleNum = 7; + } else { + sLostWoodsSkyFishParticleNum = 15; + } + + if ((i & sLostWoodsSkyFishParticleNum) == 0) { + // Head particle + this->particles[i].posOffset.y = 0.0f; + } + this->particles[i].state = DEMO_KANKYO_STATE_SKYFISH; + this->particles[i].speedTarget = 0.0f; + } + + Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); + this->particles[i].posOffset.x += + __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += + __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += + __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + + switch ((i >> 1) & 3) { + case 0: + this->particles[i].speedClock.x += 0.008f; + this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.015f; + break; + + case 1: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + break; + + case 2: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + break; + + case 3: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + break; + } + + } else if (this->particles[i].state == DEMO_KANKYO_STATE_SKYFISH) { + if ((i & sLostWoodsSkyFishParticleNum) == 0) { + // Head particle + Math_SmoothStepToF(&this->particles[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); + + Math_SmoothStepToF(&this->particles[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->particles[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, + 0.2f); + Math_SmoothStepToF(&this->particles[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); + + Math_SmoothStepToF(&this->particles[i].posOffset.x, + Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->particles[i].LostWoodsSkyFishPosOffsetMax, + 0.5f, 2.0f, 0.2f); + Math_SmoothStepToF(&this->particles[i].posOffset.z, + Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->particles[i].LostWoodsSkyFishPosOffsetMax, + 0.5f, 2.0f, 0.2f); + this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; + this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y); + this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation + this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; + this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation + + this->particles[i].posOffset.x = + Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->particles[i].LostWoodsSkyFishPosOffsetMax; + this->particles[i].posOffset.z = + Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->particles[i].LostWoodsSkyFishPosOffsetMax; + } else { + // Tail Particles + Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + + // Unused calculation, speed only used in posOffset calculations, + // but posOffset gets overwritten for tail particles immediately below + Math_SmoothStepToF(&this->particles[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); + + // particles in the skyfish's tail are moved to the previous position of the particle directly + // in front + this->particles[i].posOffset.x = + this->particles[i - 1].posOffsetPrev.x + + (this->particles[i - 1].posBase.x - this->particles[i].posBase.x); + this->particles[i].posOffset.y = + this->particles[i - 1].posOffsetPrev.y + + (this->particles[i - 1].posBase.y - this->particles[i].posBase.y); + this->particles[i].posOffset.z = + this->particles[i - 1].posOffsetPrev.z + + (this->particles[i - 1].posBase.z - this->particles[i].posBase.z); + } + } + + if ((this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) && + ((((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) > + repositionLimit) || + (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < + -repositionLimit) || + (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > + repositionLimit) || + (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < + -repositionLimit) || + (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > + repositionLimit) || + (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < + -repositionLimit))) { + if (((this->particles[i].posOffset.x + this->particles[i].posBase.x) - posCenterX) > + repositionLimit) { + this->particles[i].posOffset.x = 0.0f; + this->particles[i].posBase.x = posCenterX - repositionLimit; + } + + if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < + -repositionLimit) { + this->particles[i].posOffset.x = 0.0f; + this->particles[i].posBase.x = posCenterX + repositionLimit; + } + + if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > 50.0f) { + this->particles[i].posOffset.y = 0.0f; + this->particles[i].posBase.y = posCenterY - 50.0f; + } + + if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < -50.0f) { + this->particles[i].posOffset.y = 0.0f; + this->particles[i].posBase.y = posCenterY + 50.0f; + } + + if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > + repositionLimit) { + this->particles[i].posOffset.z = 0.0f; + this->particles[i].posBase.z = posCenterZ - repositionLimit; + } + + if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < + -repositionLimit) { + this->particles[i].posOffset.z = 0.0f; + this->particles[i].posBase.z = posCenterZ + repositionLimit; + } + } + break; + + case DEMO_KANKYO_STATE_DISABLED: + this->particles[i].state = DEMO_KANKYO_STATE_INIT; + break; + } + } +} + +void DemoKakyo_GiantObjectCheck(DemoKankyo* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->objectId)) { + this->isSafeToDrawGiants = true; + this->actor.objBankIndex = this->objectId; + DemoKankyo_SetupAction(this, DemoKakyo_MoonSparklesActionFunc); + } +} + +/* + * used by Moon AND giants types + */ +void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx) { + s32 i; + Vec3f eyeToAt; + f32 eyeToAtNormX; + f32 eyeToAtNormY; + f32 eyeToAtNormZ; + f32 eyeToAtMag; + f32 halfScreenWidth; + f32 randZeroOne; + f32 pad0; + Vec3f newEye; + f32 halfScreenHeight; + s32 pad1; + Vec3f worldPos; + + if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + globalCtx->envCtx.unk_F2[3] += 16; + } + + eyeToAt.x = globalCtx->view.at.x - globalCtx->view.eye.x; + eyeToAt.y = globalCtx->view.at.y - globalCtx->view.eye.y; + eyeToAt.z = globalCtx->view.at.z - globalCtx->view.eye.z; + eyeToAtMag = sqrtf(SQXYZ(eyeToAt)); + eyeToAtNormX = eyeToAt.x / eyeToAtMag; + eyeToAtNormY = eyeToAt.y / eyeToAtMag; + eyeToAtNormZ = eyeToAt.z / eyeToAtMag; + + halfScreenHeight = SCREEN_HEIGHT / 2; + + for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { + switch (this->particles[i].state) { + case DEMO_KANKYO_STATE_INIT: + this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); + this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); + this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + + this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->particles[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + + this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->particles[i].alpha = 0; + this->particles[i].alphaClock = (Rand_ZeroOne() * 65535); + this->particles[i].scale = 0.2f; + + // speedClock is angles in radians, + // should have used Rand_ZeroOne() * 2 * M_PI + // however, due to properties of sine waves, this is effectively still random + this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; + + this->particles[i].pad50 = 0; + this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + break; + + case DEMO_KANKYO_STATE_SINGLE: + case DEMO_KANKYO_STATE_SKYFISH: + this->particles[i].alphaClock++; + + if (this->actor.params == DEMO_KANKYO_TYPE_MOON) { // this function gets reused for giants too + this->particles[i].posBase.y = + globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); + } + + newEye.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); + newEye.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); + newEye.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + + Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); + + this->particles[i].posOffset.x += __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + + switch ((i >> 1) & 3) { + case 0: + this->particles[i].speedClock.x += 0.008f; + this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.015f; + break; + + case 1: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + break; + + case 2: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + break; + + case 3: + this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + break; + } + + if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) > halfScreenHeight) { + this->particles[i].posBase.x = newEye.x - halfScreenHeight; + } + + if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) < -halfScreenHeight) { + this->particles[i].posBase.x = newEye.x + halfScreenHeight; + } + + worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; + worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; + worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + + randZeroOne = Math_Vec3f_DistXZ(&worldPos, &globalCtx->view.eye) / 200.0f; + randZeroOne = CLAMP(randZeroOne, 0.0f, 1.0f); + halfScreenWidth = 100.0f + randZeroOne + 60.0f; // range 160 to 161...? thats about half screen width + + // I think this code is shifting the particles 1 frame -> half screen at a time to keep it in-view + if (halfScreenWidth < ((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y)) { + this->particles[i].posBase.y = newEye.y - halfScreenWidth; + } + + if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y) < -halfScreenWidth) { + this->particles[i].posBase.y = newEye.y + halfScreenWidth; + } + + if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) > halfScreenHeight) { + this->particles[i].posBase.z = newEye.z - halfScreenHeight; + } + + if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) < -halfScreenHeight) { + this->particles[i].posBase.z = newEye.z + halfScreenHeight; + } + + break; + + case DEMO_KANKYO_STATE_DISABLED: + this->particles[i].state = DEMO_KANKYO_STATE_INIT; + break; + } + } +} + +void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoKankyo* this = THIS; + s32 pad; + s32 i; + s32 objId; + + // This must be a single line to match, possibly a macro? + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->particles); i++) { this->particles[i].state = DEMO_KANKYO_STATE_INIT; } + // clang-format on + + if (1) {}; + + switch (this->actor.params) { + case DEMO_KANKYO_TYPE_LOSTWOODS: + objId = OBJECT_UNSET_0; + this->actor.room = -1; + if (sLostWoodsSparklesMutex == false) { + DemoKankyo_SetupAction(this, DemoKakyo_LostWoodsSparkleActionFunc); + sLostWoodsSparklesMutex = true; + } else { + Actor_MarkForDeath(&this->actor); + } + break; + + case DEMO_KANKYO_TYPE_GIANTS: + this->isSafeToDrawGiants = false; + objId = Object_GetIndex(&globalCtx->objectCtx, sObjectBubbleIndex); + DemoKankyo_SetupAction(this, DemoKakyo_GiantObjectCheck); + break; + + case DEMO_KANKYO_TYPE_MOON: + objId = OBJECT_UNSET_0; + this->isSafeToDrawGiants = true; + DemoKankyo_SetupAction(this, DemoKakyo_MoonSparklesActionFunc); + break; + + default: + //! @bug: this causes a crash because the actionfunc is never set + objId = -1; + break; + } + + if (objId > -1) { + this->objectId = objId; + } +} + +void DemoKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoKankyo* this = THIS; + + Actor_MarkForDeath(&this->actor); +} + +void DemoKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoKankyo* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { + DemoKankyo* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s16 i; + f32 scaleAlpha; + Vec3f worldPos; + Vec3f screenPos; + + // if not underwater + if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(&D_04079B10)); + gSPDisplayList(POLY_XLU_DISP++, D_0407AB10); + + for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { + worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; + worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; + worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + + func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT + + // checking if particle is on screen + if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && + screenPos.y < SCREEN_HEIGHT) { + Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + scaleAlpha = this->particles[i].alpha / 50.0f; + if (scaleAlpha > 1.0f) { + scaleAlpha = 1.0f; + } + + Matrix_Scale(this->particles[i].scale * scaleAlpha, this->particles[i].scale * scaleAlpha, + this->particles[i].scale * scaleAlpha, MTXMODE_APPLY); + + // adjust transparency of this particle + if (i < 32) { + // Skyfish particles + if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { + // still initializing + if (this->particles[i].alpha > 0) { // NOT DECR + this->particles[i].alpha--; + } + } else if (this->particles[i].alpha < 100) { + this->particles[i].alpha++; + } + } else if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if ((this->particles[i].alphaClock & 31) < 16) { + if (this->particles[i].alpha < 235) { + this->particles[i].alpha += 20; + } + } else if (this->particles[i].alpha > 20) { + this->particles[i].alpha -= 20; + } + } else if ((this->particles[i].alphaClock & 15) < 8) { + if (this->particles[i].alpha < 255) { + this->particles[i].alpha += 100; + } + } else if (this->particles[i].alpha > 10) { + this->particles[i].alpha -= 10; + } + + gDPPipeSync(POLY_XLU_DISP++); + + switch (i & 1) { + case 0: // gold particles + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->particles[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->particles[i].alpha); + break; + + case 1: // silver particles + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->particles[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->particles[i].alpha); + break; + } + + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_0407AB58); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// draw, giants and moon +void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { + DemoKankyo* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s16 i; + f32 alphaScale; + + if (this->isSafeToDrawGiants != false) { + Vec3f worldPos; + Vec3f screenPos; + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + func_8012C2DC(gfxCtx); + + for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { + worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; + worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; + worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + + func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT + + // checking if particle is on screen + if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && + screenPos.y < SCREEN_HEIGHT) { + Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + alphaScale = this->particles[i].alpha / 50.0f; + if (alphaScale > 1.0f) { + alphaScale = 1.0f; + } + Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, + this->particles[i].scale * alphaScale, MTXMODE_APPLY); + alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; + alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + + if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { + this->particles[i].alpha = 255.0f * alphaScale; + } else { + this->particles[i].alpha = 160.0f * alphaScale; + } + + gDPPipeSync(POLY_XLU_DISP++); + + switch (i & 1) { // half/half slightly different shades of yellow/tan + case 0: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->particles[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->particles[i].alpha); + break; + + case 1: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->particles[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->particles[i].alpha); + break; + } + + gSPDisplayList(POLY_XLU_DISP++, &D_04023348); + + Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + + Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { + gSPDisplayList(POLY_XLU_DISP++, D_06001000); + } else { + gSPDisplayList(POLY_XLU_DISP++, D_04023428); + } + } + } + + CLOSE_DISPS(gfxCtx); + } +} + +void DemoKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { + DemoKankyo* this = THIS; + + switch (this->actor.params) { + case DEMO_KANKYO_TYPE_LOSTWOODS: + DemoKakyo_DrawLostWoodsSparkle(&this->actor, globalCtx); + break; + + case DEMO_KANKYO_TYPE_GIANTS: + case DEMO_KANKYO_TYPE_MOON: + DemoKankyo_DrawMoonAndGiant(&this->actor, globalCtx); + break; + } +} diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index 9dfa597b4..d70616ed6 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -7,13 +7,47 @@ struct DemoKankyo; typedef void (*DemoKankyoActionFunc)(struct DemoKankyo*, GlobalContext*); +typedef struct { + /* 0x000 */ u8 state; + /* 0x004 */ Vec3f posOffset; + /* 0x010 */ Vec3f posOffsetPrev; + /* 0x01C */ Vec3f posBase; + /* 0x028 */ Vec3f speedClock; // cycles in radians + /* 0x034 */ f32 speed; + /* 0x038 */ f32 speedTarget; + /* 0x03C */ u16 alphaClock; + /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; + /* 0x040 */ u8 alpha; + /* 0x044 */ f32 scale; // size of the particle + /* 0x048 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 + /* 0x04A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 + /* 0x04C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. + /* 0x050 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it +} DemoKankyoParticle; // size = 0x54 + +#define DEMOKANKYO_PARTICLE_COUNT 64 + typedef struct DemoKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1500]; + /* 0x0144 */ DemoKankyoParticle particles[DEMOKANKYO_PARTICLE_COUNT]; /* 0x1644 */ DemoKankyoActionFunc actionFunc; - /* 0x1648 */ char unk_1648[0x8]; + /* 0x1648 */ s32 objectId; + /* 0x164C */ u8 isSafeToDrawGiants; } DemoKankyo; // size = 0x1650 +typedef enum { + /* 0 */ DEMO_KANKYO_TYPE_LOSTWOODS, + /* 1 */ DEMO_KANKYO_TYPE_GIANTS, + /* 2 */ DEMO_KANKYO_TYPE_MOON, +} DemoKankyoType; + +typedef enum { + /* 0 */ DEMO_KANKYO_STATE_INIT, + /* 1 */ DEMO_KANKYO_STATE_SINGLE, + /* 2 */ DEMO_KANKYO_STATE_SKYFISH, + /* 3 */ DEMO_KANKYO_STATE_DISABLED, +} DemoKankyoStateType; + extern const ActorInit Demo_Kankyo_InitVars; #endif // Z_DEMO_KANKYO_H From 5e7c19ce295268bffc42e7b037c751e76d0d0f8d Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Wed, 3 Nov 2021 12:23:37 -0300 Subject: [PATCH 68/86] Match `SkelAnime_GetFrameDataLegacy` (#392) * Properly rename SkelAnime_GetFrameDataLegacy * Match --- include/functions.h | 2 +- src/code/z_skelanime.c | 48 ++++---------------------------------- tools/disasm/functions.txt | 2 +- 3 files changed, 6 insertions(+), 46 deletions(-) diff --git a/include/functions.h b/include/functions.h index a575fd6e0..6e8b78e93 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2570,7 +2570,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel Mtx** mtx, Gfx* gfx); Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -s16 SkelAnime_GetFrameData2(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); +s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); s16 Animation_GetLength2(LegacyAnimationHeader* animation); s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index c8ab534de..e0df1d867 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -869,8 +869,6 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT * Unpacks frame data for the animation at the given frame into frameTable * Used by the legacy animation format */ -#ifdef NON_MATCHING -// equivalent, minor reordering s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); s16 limbCount = animHeader->limbCount; @@ -880,59 +878,21 @@ s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Ve s16* dynamicData = &frameData[frame]; s32 i; - /** - *Equivalent to the following, but the compiler optimizes the loop in a way I can't replicate - */ - /* - for(i = 0, frameTable++, key++; i < limbCount + 1; i++, key++, frameTable++) { - frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; - frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; - frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; - } - */ frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; - i = 1; frameTable++; key++; - if (limbCount & 1) {} - - if (limbCount > 0) { - if (limbCount & 1) { - i++; - frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; - frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; - frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; - key++; - frameTable++; - if (limbCount + 1 == i) { - goto ret; - } - } - do { - i += 2; - frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; - frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; - frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; - key++; - frameTable++; - frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; - frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; - frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; - key++; - frameTable++; - } while (i != limbCount + 1); + for (i = 1; i <= limbCount; i++, key++, frameTable++) { + frameTable->x = frame < key->xMax ? dynamicData[key->x] : staticData[key->x]; + frameTable->y = frame < key->yMax ? dynamicData[key->y] : staticData[key->y]; + frameTable->z = frame < key->zMax ? dynamicData[key->z] : staticData[key->z]; } -ret: return limbCount; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameData2.s") -#endif /** * Used by legacy animation format diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a51d44753..b2e479288 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2536,7 +2536,7 @@ 0x80134990:("SkelAnime_Draw",), 0x80134B54:("SkelAnime_DrawFlexLimb",), 0x80134DBC:("SkelAnime_DrawFlex",), - 0x80134FFC:("SkelAnime_GetFrameData2",), + 0x80134FFC:("SkelAnime_GetFrameDataLegacy",), 0x801353D4:("Animation_GetLimbCount2",), 0x801353F8:("Animation_GetLength2",), 0x8013541C:("Animation_GetLastFrame2",), From de6ef350c5dc72a06483342ecd9994dc3cedb09c Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Wed, 3 Nov 2021 08:44:05 -0700 Subject: [PATCH 69/86] epirawread OK (#390) * epirawread OK * Made tharo's suggestions --- src/libultra/io/epirawread.c | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/libultra/io/epirawread.c b/src/libultra/io/epirawread.c index e910cee4d..317f7d63e 100644 --- a/src/libultra/io/epirawread.c +++ b/src/libultra/io/epirawread.c @@ -1,3 +1,57 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawread/__osEPiRawReadIo.s") +s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) { + s32 status; + OSPiHandle* curHandle; + + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { + ; + } + + if (__osCurrentHandle[handle->domain]->type != handle->type) { + curHandle = __osCurrentHandle[handle->domain]; + + if (handle->domain == 0) { + if (curHandle->latency != handle->latency) { + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency; + } + + if (curHandle->pageSize != handle->pageSize) { + HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize; + } + + if (curHandle->relDuration != handle->relDuration) { + HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration; + } + + if (curHandle->pulse != handle->pulse) { + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse; + } + } else { + if (curHandle->latency != handle->latency) { + HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency; + } + + if (curHandle->pageSize != handle->pageSize) { + HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize; + } + + if (curHandle->relDuration != handle->relDuration) { + HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration; + } + + if (curHandle->pulse != handle->pulse) { + HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse; + } + } + + curHandle->type = handle->type; + curHandle->latency = handle->latency; + curHandle->pageSize = handle->pageSize; + curHandle->relDuration = handle->relDuration; + curHandle->pulse = handle->pulse; + } + + *data = HW_REG(handle->baseAddress | devAddr, u32); + return 0; +} From efbd87cac189786e259802543718cf0ecb4f7de1 Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Wed, 3 Nov 2021 08:57:15 -0700 Subject: [PATCH 70/86] epirawdma OK (#391) * epirawdma OK * Made tharo's suggestions * Fixed epirawwrite --- include/ultra64/hardware.h | 2 +- src/libultra/io/epirawdma.c | 69 ++++++++++++++++++++++++++++++++++- src/libultra/io/epirawwrite.c | 2 +- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index 30e2b898b..a420bb591 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -70,7 +70,7 @@ #define PI_STATUS_BUSY (1 << 0) #define PI_STATUS_IOBUSY (1 << 1) -#define PI_STATUS_ERROR (PI_STATUS_BUSY | PI_STATUS_IOBUSY) +#define PI_STATUS_ERROR (1 << 2) #define PI_STATUS_RESET_CONTROLLER (1 << 0) #define PI_STATUS_CLEAR_INTR (1 << 1) diff --git a/src/libultra/io/epirawdma.c b/src/libultra/io/epirawdma.c index f9e2e0f97..cbe43ce82 100644 --- a/src/libultra/io/epirawdma.c +++ b/src/libultra/io/epirawdma.c @@ -1,3 +1,70 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/epirawdma/__osEPiRawStartDma.s") +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size) { + s32 status; + OSPiHandle* curHandle; + + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { + ; + } + + if (__osCurrentHandle[handle->domain]->type != handle->type) { + curHandle = __osCurrentHandle[handle->domain]; + + if (handle->domain == 0) { + if (curHandle->latency != handle->latency) { + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency; + } + + if (curHandle->pageSize != handle->pageSize) { + HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize; + } + + if (curHandle->relDuration != handle->relDuration) { + HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration; + } + + if (curHandle->pulse != handle->pulse) { + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse; + } + } else { + if (curHandle->latency != handle->latency) { + HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency; + } + + if (curHandle->pageSize != handle->pageSize) { + HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize; + } + + if (curHandle->relDuration != handle->relDuration) { + HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration; + } + + if (curHandle->pulse != handle->pulse) { + HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse; + } + } + + curHandle->type = handle->type; + curHandle->latency = handle->latency; + curHandle->pageSize = handle->pageSize; + curHandle->relDuration = handle->relDuration; + curHandle->pulse = handle->pulse; + } + + HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr); + HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1fffffff); + + switch (direction) { + case OS_READ: + HW_REG(PI_WR_LEN_REG, u32) = size - 1; + break; + case OS_WRITE: + HW_REG(PI_RD_LEN_REG, u32) = size - 1; + break; + default: + return -1; + } + + return 0; +} diff --git a/src/libultra/io/epirawwrite.c b/src/libultra/io/epirawwrite.c index 7c5701e0d..dc169ecf7 100644 --- a/src/libultra/io/epirawwrite.c +++ b/src/libultra/io/epirawwrite.c @@ -4,7 +4,7 @@ s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) { s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } From b3438c85136bc3448cb29517662e685a2ca56139 Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Wed, 3 Nov 2021 10:35:15 -0700 Subject: [PATCH 71/86] pfssearchfile OK (#388) --- include/functions.h | 4 +-- src/libultra/io/pfssearchfile.c | 51 ++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6e8b78e93..747e604c3 100644 --- a/include/functions.h +++ b/include/functions.h @@ -316,7 +316,7 @@ OSId osGetThreadId(OSThread* t); void osSpTaskYield(void); s32 __osPfsGetNextPage(OSPfs* param_1, __OSInode* param_2, u8 param_3, u8 param_4); s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, s32 offset, s32 size_in_bytes, u8* data_buffer); -// void __osPfsGetStatus(void); +s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel); // void __osPfsRequestOneChannel(void); // void __osPfsGetOneChannelData(void); void guMtxIdentF(float mf[4][4]); @@ -346,7 +346,7 @@ s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank); u32 osGetCount(void); void guMtxL2F(MtxF* m1, Mtx* m2); u32 osGetMemSize(void); -// void osPfsFindFile(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m); f32 sqrtf(f32 __x); s32 osAfterPreNMI(void); diff --git a/src/libultra/io/pfssearchfile.c b/src/libultra/io/pfssearchfile.c index 572e3d0a7..c5f8bcce4 100644 --- a/src/libultra/io/pfssearchfile.c +++ b/src/libultra/io/pfssearchfile.c @@ -1,3 +1,52 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfssearchfile/osPfsFindFile.s") +s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo) { + s32 j; + s32 i; + __OSDir dir; + s32 ret = 0; + s32 err; + + if (!(pfs->status & PFS_INITIALIZED)) { + return PFS_ERR_INVALID; + } + + if ((ret = __osCheckId(pfs)) != 0) { + return ret; + } + + for (j = 0; j < pfs->dir_size; j++) { + if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)) != 0) { + return ret; + } + if ((ret = __osPfsGetStatus(pfs->queue, pfs->channel)) != 0) { + return ret; + } + + if ((dir.company_code == companyCode) && (dir.game_code == gameCode)) { + err = 0; + if (gameName != 0) { + for (i = 0; i < PFS_FILE_NAME_LEN; i++) { + if (dir.game_name[i] != gameName[i]) { + err = 1; + break; + } + } + } + if ((extName != 0) && (err == 0)) { + for (i = 0; i < PFS_FILE_EXT_LEN; i++) { + if (dir.ext_name[i] != extName[i]) { + err = 1; + break; + } + } + } + if (err == 0) { + *fileNo = j; + return ret; + } + } + } + *fileNo = -1; + return PFS_ERR_INVALID; +} From 8250fd0941b3227d64aa4de253c96e7b9ed902ba Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 3 Nov 2021 10:56:12 -0700 Subject: [PATCH 72/86] Match EnItem00_Update (#381) --- src/code/z_en_item00.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 7d4c050d4..c55bab0e1 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -434,15 +434,13 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// Minor regalloc issue where it uses v1 instead of v0 void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { EnItem00* this = THIS; s32 pad; Player* player = GET_PLAYER(globalCtx); s32 sp38 = player->stateFlags3 & 0x1000; s32 getItemId = GI_NONE; - s32 pad2; + s32 params; if (this->unk152 > 0) { this->unk152--; @@ -471,8 +469,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((this->actor.params == ITEM00_SHIELD_HERO) || (this->actor.params == ITEM00_MAP) || - (this->actor.params == ITEM00_COMPASS)) { + params = this->actor.params; + if ((params == ITEM00_SHIELD_HERO) || (params == ITEM00_MAP) || (params == ITEM00_COMPASS)) { this->actor.shape.yOffset = fabsf(Math_CosS(this->actor.shape.rot.x) * 37.0f); } @@ -622,9 +620,6 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk14A = 0; this->actionFunc = func_800A6A40; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/EnItem00_Update.s") -#endif void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx); void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx); From 8e88768a702c7888401a563620fbfe44769d3f4e Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:09:43 -0400 Subject: [PATCH 73/86] Fireobj Kinda OK (#400) * done * format * PR fixes * revert formatting z64.h * Update warnings_build_current.txt --- include/functions.h | 11 +- include/variables.h | 5 +- include/z64.h | 9 +- include/z64player.h | 2 +- spec | 1 - src/code/z_fireobj.c | 246 +++++++++++++++++++++++++++++++++++-- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 4 +- 8 files changed, 245 insertions(+), 37 deletions(-) diff --git a/include/functions.h b/include/functions.h index 747e604c3..d2eee6061 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1691,19 +1691,12 @@ void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpd s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); -void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init); -void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); -void FireObj_StepSize(FireObj* fire); -void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire); void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); -void FireObj_FiniLight(GlobalContext* globalCtx, FireObjLight* light); -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); -void FireObj_Fini(GlobalContext* globalCtx, FireObj* fire); +void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire); void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); -void FireObj_Update(GlobalContext* globalCtx, FireObj* fire); +void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); // void func_800F3940(void); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); diff --git a/include/variables.h b/include/variables.h index 3770820bf..8105107d4 100644 --- a/include/variables.h +++ b/include/variables.h @@ -914,8 +914,6 @@ extern Actor* actorCutsceneCurrentCutsceneActor; extern GlobalContext* actorCutscenesGlobalCtxt; extern s16 actorCutsceneReturnCamera; extern s16 D_801BD8C6; -extern ColliderCylinderInit fireObjCollisionInit; -extern FireObjLightParams D_801BD8FC[2]; extern GameStateOverlay gGameStateOverlayTable[]; extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA70; @@ -2515,8 +2513,6 @@ extern f32 D_801DD774; extern f32 D_801DD780; extern f32 D_801DD7B0; extern f32 D_801DD7C0; -extern f32 D_801DD7D0; -extern f32 D_801DD7D4; extern f32 D_801DD7E0; extern f32 D_801DD7E4; extern f32 D_801DD7E8; @@ -4074,4 +4070,5 @@ extern GfxMasterList D_0E000000; extern UNK_TYPE D_0F000000; + #endif diff --git a/include/z64.h b/include/z64.h index dae4195b2..533677efd 100644 --- a/include/z64.h +++ b/include/z64.h @@ -213,14 +213,9 @@ typedef struct { } FireObjInitParams; // size = 0xD typedef struct { - /* 0x0 */ u8 unk0; - /* 0x1 */ u8 unk1; - /* 0x2 */ u8 unk2; - /* 0x3 */ u8 unk3; + /* 0x0 */ Color_RGBA8 primColor; /* 0x4 */ u8 unk4; - /* 0x5 */ u8 unk5; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; + /* 0x5 */ Color_RGB8 envColor; } FireObjLightParams; // size = 0x8 //! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` diff --git a/include/z64player.h b/include/z64player.h index 8bab2605f..4f70c793d 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -251,7 +251,7 @@ typedef struct Player { /* 0xAEC */ f32 unk_AEC; /* 0xAF0 */ Vec3f unk_AF0[2]; /* 0xB08 */ f32 unk_B08[8]; - /* 0xB28 */ s16 unk_B28; + /* 0xB28 */ s16 unk_B28; //Burning stick timer? /* 0xB2A */ s8 unk_B2A; /* 0xB2B */ s8 unk_B2B; /* 0xB2C */ f32 windSpeed; diff --git a/spec b/spec index 7251410c2..961e5328c 100644 --- a/spec +++ b/spec @@ -491,7 +491,6 @@ beginseg include "build/src/code/z_fcurve_data_skelanime.o" include "build/data/code/code_801BD830.data.o" include "build/src/code/z_fireobj.o" - include "build/data/code/z_fireobj.data.o" include "build/src/code/z_game_dlftbls.o" include "build/src/code/z_horse.o" include "build/data/code/z_horse.data.o" diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index abc78fc4d..79041a713 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -1,27 +1,251 @@ #include "global.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitWithParams.s") +typedef enum { + FIRE_STATE_0, + FIRE_STATE_1, + FIRE_STATE_2, + FIRE_STATE_3, +} FireState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_SetState.s") +ColliderCylinderInit sFireObjCollisionInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 18, 67, 0, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_SetPosition.s") +FireObjLightParams sFireObjLightParams[2] = { + { 255, 255, 0, 255, 128, 255, 0, 0 }, + { 0, 200, 128, 128, 0, 127, 127, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_StepSize.s") +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); +void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateStateTransitions.s") +void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { + fire->size = init->size; + fire->sizeInv = 1.0f / init->size; + fire->dynamicSizeStep = init->dynamicSizeStep; + fire->state = init->state; + fire->sizeGrowsCos2 = init->sizeGrowsCos2; + fire->unk27 = init->unkA; + fire->flags = init->flags; + fire->xScale = 0.0f; + fire->yScale = 0.0f; + fire->dynamicSize = 0.0f; + fire->unk26 = Rand_ZeroOne() * 20.0f; + fire->ignitionDelay = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_Draw.s") +void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { + fire->state = newState & 0xFF; + if (fire->state == FIRE_STATE_3) { + fire->yScale = 0.0f; + fire->xScale = 0.0f; + fire->dynamicSize = 0.0f; + } else if (fire->state == FIRE_STATE_2) { + fire->xScale = fire->yScale = fire->size; + fire->dynamicSize = 1.0f; + } + fire->dynamicSizeStep = dynamicSizeStep; +} +void FireObj_SetPosition(FireObj* fire, Vec3f* pos) { + Math_Vec3f_Copy(&fire->position, pos); +} + +void FireObj_StepSize(FireObj* fire) { + if (fire->state == FIRE_STATE_0) { + if (Math_StepToF(&fire->dynamicSize, 1.0f, fire->dynamicSizeStep) != 0) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); + } + } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { + FireObj_SetState(fire, fire->dynamicSizeStep, 3); + } + if (fire->sizeGrowsCos2 == 1) { + if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { + fire->xScale = (1.0f - Math_CosS((fire->dynamicSize * fire->dynamicSize * 16384.0f))) * fire->size; + fire->yScale = fire->dynamicSize * fire->size; + } else { + fire->yScale = fire->dynamicSize * fire->size; + fire->xScale = fire->dynamicSize * fire->size; + } + return; + } else { + fire->yScale = fire->dynamicSize * fire->size; + } + fire->xScale = fire->dynamicSize * fire->size; +} + +void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { + Player* player = GET_PLAYER(globalCtx); + WaterBox* waterBox; + f32 sp44; + s32 sp40 = 0; + u8 nextState; + Vec3f dist; + + FireObj_StepSize(fire); + fire->unk26++; + if (fire->ignitionDelay > 0) { + fire->ignitionDelay--; + } else if (fire->ignitionDelay == 0) { + fire->ignitionDelay = -1; + if ((fire->state == FIRE_STATE_3) || (fire->state == FIRE_STATE_1)) { + nextState = FIRE_STATE_0; + } else { + nextState = FIRE_STATE_1; + } + FireObj_SetState(fire, fire->dynamicSizeStep, nextState); + } + if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && + (func_800CA1E8(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &sp44, &waterBox) != 0) && + ((fire->yScale * ((void)0, 6500.0f)) < (sp44 - fire->position.y))) { // Fake but IDK what else + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); + } + if ((fire->flags & 2) && (player->itemActionParam == 7)) { + Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); + if (Math3D_LengthSquared(&dist) < 400.0f) { + sp40 = 1; + } + } + if (sp40 != 0) { + if (fire->state == FIRE_STATE_3) { + if (player->unk_B28 > 0) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); + } + } else if (player->unk_B28 == 0) { + player->unk_B28 = 0xD2; + Audio_PlaySoundAtPosition(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); + } else if (player->unk_B28 < 0xC8) { + player->unk_B28 = 0xC8; + } + } +} + +void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { + s32 pad; + FireObjLightParams* lightParams = &sFireObjLightParams[fire->unk27]; + + if (fire->state != FIRE_STATE_3) { + Vec3s vec; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, lightParams->unk4, lightParams->primColor.r, lightParams->primColor.g, + lightParams->primColor.b, lightParams->primColor.a); + + gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); + + vec.x = 0; + vec.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + vec.z = 0; + Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); + Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +#ifdef NON_EQUIVALENT +// Accesses data incorrectly +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos) { + FireObjLightParams* objectParams = &sFireObjLightParams[*param_3]; + + Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->primColor.g, + objectParams->primColor.b, objectParams->primColor.a, objectParams->primColor.r); + light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, (LightInfo*)&light->lightInfo); + light->unk12 = *param_3; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitLight.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_FiniLight.s") +void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); +} +#ifdef NON_EQUIVALENT +// Accesses data incorrectly +void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { + FireObjLightParams* lightParams = &sFireObjLightParams[light->unk12]; + s16 radius; + + if (fire->state == FIRE_STATE_3) { + Lights_PointSetColorAndRadius((LightInfo*)&light->lightInfo, 0, 0, 0, -1); + } else { + radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); + + Lights_PointGlowSetInfo((LightInfo*)&light->lightInfo, fire->position.x, + (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, + ((s32)(Rand_ZeroOne() * lightParams->envColor.r) + lightParams->primColor.b), + ((s32)(Rand_ZeroOne() * lightParams->envColor.g) + lightParams->primColor.a), + ((s32)(Rand_ZeroOne() * lightParams->envColor.b) + lightParams->unk4), radius); + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateLight.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_Init.s") +void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { + FireObj* fire2 = fire; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_Fini.s") + FireObj_InitWithParams(globalCtx, fire, init); + Collider_InitCylinder(globalCtx, &fire->collision); + Collider_SetCylinder(globalCtx, &fire->collision, actor, &sFireObjCollisionInit); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_SetState2.s") + fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f; + fire2->collision.dim.height = fire->size * 16000.0f; + fire->collision.dim.yShift = fire->size * -1728.0f; + FireObj_InitLight(globalCtx, &fire->light, &init->unkC, &fire->position); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_Update.s") +void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { + Collider_DestroyCylinder(globalCtx, &fire->collision); + FireObj_DestroyLight(globalCtx, &fire->light); +} + +void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState) { + FireObj_SetState(fire, dynamicSizeStep, newState); +} + +void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { + s32 pad; // Gamestate cast? + EnArrow* arrow = (EnArrow*)fire->collision.base.ac; + + FireObj_UpdateStateTransitions(globalCtx, fire); + if (fire->state == 3) { + if ((fire->collision.base.acFlags & 2) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { + FireObj_SetState(fire, fire->dynamicSizeStep, 0); + } + } else if ((fire->collision.base.acFlags & 2) && (arrow->actor.update != NULL) && + (arrow->actor.id == ACTOR_EN_ARROW)) { + arrow->actor.params = 0; + arrow->unk_1C0 = 0x800; + } + fire->collision.dim.pos.x = fire->position.x; + fire->collision.dim.pos.y = fire->position.y; + fire->collision.dim.pos.z = fire->position.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &fire->collision.base); + FireObj_UpdateLight(globalCtx, &fire->light, fire); +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b2e479288..9ecd22762 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1677,10 +1677,10 @@ 0x800F2FFC:("FireObj_UpdateStateTransitions",), 0x800F31EC:("FireObj_Draw",), 0x800F33F4:("FireObj_InitLight",), - 0x800F34C4:("FireObj_FiniLight",), + 0x800F34C4:("FireObj_DestroyLight",), 0x800F34EC:("FireObj_UpdateLight",), 0x800F36CC:("FireObj_Init",), - 0x800F37B0:("FireObj_Fini",), + 0x800F37B0:("FireObj_Destroy",), 0x800F37F0:("FireObj_SetState2",), 0x800F3820:("FireObj_Update",), 0x800F3940:("func_800F3940",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3b4818a6e..3ca0fa02e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -941,8 +941,8 @@ 0x801BD8C0:("actorCutscenesGlobalCtxt","GlobalContext*","",0x4), 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), - 0x801BD8D0:("fireObjCollisionInit","ColliderCylinderInit","",0x2c), - 0x801BD8FC:("D_801BD8FC","FireObjLightParams","[2]",0x10), + 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), + 0x801BD8FC:("sFireObjLightParams","FireObjLightParams","[2]",0x10), 0x801BD910:("gGameStateOverlayTable","GameStateOverlay","[7]",0x150), 0x801BDA60:("graphNumGameStates","UNK_TYPE4","",0x4), 0x801BDA70:("D_801BDA70","UNK_TYPE2","",0x2), From e3830f6ab049df985295e98d3e6d231a68be060a Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Wed, 3 Nov 2021 12:12:10 -0700 Subject: [PATCH 74/86] pfsallocatefile OK (#387) * pfsallocatefile OK * Made tharo's suggestions --- include/functions.h | 7 +- src/libultra/io/pfsallocatefile.c | 137 +++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index d2eee6061..0970b330c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -246,7 +246,7 @@ void Sleep_Msec(u32 ms); void Sleep_Sec(u32 sec); // void __osSetCause(void); s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags); -// void osPfsFreeBlocks(void); +s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); void osViExtendVStart(u32 param_1); void osStopThread(OSThread* t); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); @@ -325,8 +325,9 @@ void osViSetMode(OSViMode* modep); // void __osSetConfig(void); void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); -// void osPfsAllocateFile(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void __osPfsDeclearPage(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo); +s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, + s32* finalPage); s32 osStopTimer(OSTimer* t); u32 __osProbeTLB(void* param_1); void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); diff --git a/src/libultra/io/pfsallocatefile.c b/src/libultra/io/pfsallocatefile.c index fd7bdeef3..821568b87 100644 --- a/src/libultra/io/pfsallocatefile.c +++ b/src/libultra/io/pfsallocatefile.c @@ -1,5 +1,138 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsallocatefile/osPfsAllocateFile.s") +s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo) { + s32 startPage; + s32 decleared; + s32 prevPage; + s32 oldPrevPage = 0; + s32 ret = 0; + s32 fileSizeInPages; + __OSInode inode; + __OSInode backupInode; + __OSDir dir; + u8 bank; + u8 prevBank = 0; + s32 firsttime = 0; + s32 bytes; + __OSInodeUnit fpage; -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsallocatefile/__osPfsDeclearPage.s") + if ((companyCode == 0) || (gameCode == 0)) { + return PFS_ERR_INVALID; + } + + fileSizeInPages = (fileSize + PFS_PAGE_SIZE - 1) / PFS_PAGE_SIZE; + + if (((ret = osPfsFindFile(pfs, companyCode, gameCode, gameName, extName, fileNo)) != 0) && + (ret != PFS_ERR_INVALID)) { + return ret; + } + if (*fileNo != -1) { + return PFS_ERR_EXIST; + } + + ret = osPfsFreeBlocks(pfs, &bytes); + if (fileSize > bytes) { + return PFS_DATA_FULL; + } + + if (fileSizeInPages == 0) { + return (PFS_ERR_INVALID); + } + + if (((ret = osPfsFindFile(pfs, 0, 0, NULL, NULL, fileNo)) != 0) && (ret != PFS_ERR_INVALID)) { + return ret; + } + if (*fileNo == -1) { + return PFS_DIR_FULL; + } + + for (bank = PFS_ID_BANK_256K; bank < pfs->banks; bank++) { + if ((ret = __osPfsRWInode(pfs, &inode, PFS_READ, bank)) != 0) { + return ret; + } + ret = __osPfsDeclearPage(pfs, &inode, fileSizeInPages, &startPage, bank, &decleared, &prevPage); + if (ret) { + return ret; + } + if (startPage != -1) { /* There is free space */ + if (firsttime == 0) { + fpage.inode_t.page = (u8)startPage; + fpage.inode_t.bank = bank; + } else { /* Writing previous bank inode */ + backupInode.inodePage[oldPrevPage].inode_t.bank = bank; + backupInode.inodePage[oldPrevPage].inode_t.page = (u8)startPage; + if ((ret = __osPfsRWInode(pfs, &backupInode, PFS_WRITE, prevBank)) != 0) { + return ret; + } + } + if (fileSizeInPages > decleared) { + bcopy(&inode, &backupInode, sizeof(__OSInode)); + oldPrevPage = prevPage; + prevBank = bank; + fileSizeInPages -= decleared; + firsttime++; + } else { + fileSizeInPages = 0; + if ((ret = __osPfsRWInode(pfs, &inode, PFS_WRITE, bank)) != 0) { + return ret; + } + break; + } + } + } + if ((fileSizeInPages > 0) || (startPage == -1)) { + return PFS_ERR_INCONSISTENT; + } + + dir.start_page = fpage; + dir.company_code = companyCode; + dir.game_code = gameCode; + dir.data_sum = 0; + + bcopy(gameName, dir.game_name, PFS_FILE_NAME_LEN); + bcopy(extName, dir.ext_name, PFS_FILE_EXT_LEN); + + return __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *fileNo, (u8*)&dir, 0); +} + +s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, + s32* finalPage) { + s32 j; + s32 spage, prevPage; + s32 ret = 0; + s32 offset = ((bank > PFS_ID_BANK_256K) ? 1 : pfs->inodeStartPage); + + for (j = offset; j < PFS_INODE_SIZE_PER_PAGE; j++) { + if (inode->inodePage[j].ipage == PFS_PAGE_NOT_USED) { + break; + } + } + if (j == PFS_INODE_SIZE_PER_PAGE) { + *startPage = -1; + return ret; + } + + spage = j; + *decleared = 1; + prevPage = j; + j++; + while ((fileSizeInPages > *decleared) && (j < PFS_INODE_SIZE_PER_PAGE)) { + if (inode->inodePage[j].ipage == PFS_PAGE_NOT_USED) { + inode->inodePage[prevPage].inode_t.bank = bank; + inode->inodePage[prevPage].inode_t.page = j; + prevPage = j; + (*decleared)++; + } + j++; + } + + *startPage = spage; + if ((j == (PFS_INODE_SIZE_PER_PAGE)) && (fileSizeInPages > *decleared)) { + *finalPage = prevPage; + } else { + inode->inodePage[prevPage].ipage = PFS_EOF; + *finalPage = 0; + } + return ret; +} From 78153a1bf46e8be1559ea03af6eb1521a1d3bae2 Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Wed, 3 Nov 2021 12:48:08 -0700 Subject: [PATCH 75/86] osspsetpc OK (#384) --- include/functions.h | 2 +- src/libultra/io/spsetpc.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0970b330c..56be51a78 100644 --- a/include/functions.h +++ b/include/functions.h @@ -478,7 +478,7 @@ float __ull_to_f(unsigned long long l); // void osVoiceControlGain(void); // void osVoiceStartReadData(void); void* osViGetCurrentFramebuffer(void); -s32 __osSpSetPc(void* data); +s32 __osSpSetPc(void* pc); // void __osVoiceContWrite4(void); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); diff --git a/src/libultra/io/spsetpc.c b/src/libultra/io/spsetpc.c index d87302bc2..2c3cc32ba 100644 --- a/src/libultra/io/spsetpc.c +++ b/src/libultra/io/spsetpc.c @@ -1,3 +1,13 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/spsetpc/__osSpSetPc.s") +s32 __osSpSetPc(void* pc) { + register u32 spStatus = HW_REG(SP_STATUS_REG, u32); + + if (!(spStatus & SP_STATUS_HALT)) { + return -1; + } else { + HW_REG(SP_PC_REG, void*) = pc; + } + + return 0; +} From ad4c16d40fa2465b50f207d2fa84f6fac810ac0f Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Wed, 3 Nov 2021 17:30:20 -0500 Subject: [PATCH 76/86] osFlash (#158) * some matches * Decompile code_0x80186A70 Add defines for KSEG0/1 and (Un)Cached RDRAM * format * cleanup * moved osFlash and imported data * implement fixes * format again * Update include/functions.h Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update include/variables.h Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update src/libultra/flash/osFlash.c Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update src/libultra/flash/osFlash.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * returns are needed * format * Update src/libultra/flash/osFlash.c Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update src/libultra/flash/osFlash.c Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update src/libultra/flash/osFlash.c Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Update src/libultra/flash/osFlash.c Co-authored-by: Kenix3 * Update src/libultra/flash/osFlash.c Co-authored-by: Kenix3 * Update src/libultra/flash/osFlash.c Co-authored-by: Kenix3 * should be fixed Co-authored-by: petrie911 Co-authored-by: MMDecomp Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Kenix3 --- Makefile | 2 + include/functions.h | 32 ++-- include/macros.h | 11 +- include/ultra64/hardware.h | 12 +- include/variables.h | 6 - include/z64.h | 39 +++++ spec | 3 +- src/code/osFlash.c | 39 ----- src/libultra/flash/osFlash.c | 325 +++++++++++++++++++++++++++++++++++ tools/disasm/functions.txt | 34 ++-- tools/disasm/variables.txt | 12 +- 11 files changed, 420 insertions(+), 95 deletions(-) delete mode 100644 src/code/osFlash.c create mode 100644 src/libultra/flash/osFlash.c diff --git a/Makefile b/Makefile index cf23794bd..6b62c2e64 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,8 @@ build/src/libultra/io/%.o: OPTFLAGS := -O2 build/src/libultra/libc/%.o: OPTFLAGS := -O2 build/src/libultra/gu/%.o: OPTFLAGS := -O2 build/src/libultra/rmon/%.o: OPTFLAGS := -O2 +build/src/libultra/flash/%.o: OPTFLAGS := -g +build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv diff --git a/include/functions.h b/include/functions.h index 56be51a78..5a954660a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -416,7 +416,7 @@ void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); f32 __cosf(f32 __x); -// void osEPiReadIo(void); +s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); @@ -439,7 +439,7 @@ u32 __osGetFpcCsr(void); // void corrupted_init(void); // void corrupted(void); u32 osAiGetLength(void); -// void osEPiWriteIo(void); +s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data); void osMapTLBRdb(void); void osYieldThread(void); // void guTranslate(void); @@ -3494,19 +3494,21 @@ void SysFlashrom_ThreadEntry(s80185D40* param_1); // void func_80185F04(void); // void func_80185F64(void); s32 func_80185F90(u32 param_1); -// void func_80186A70(void); -// void func_80186B78(void); -// void func_80186CAC(void); -// void func_80186D60(void); -// void func_80186E64(void); -// void func_80186EC8(void); -// void func_80187018(void); -// void func_80187080(void); -// void func_80187124(void); -// void func_80187284(void); -// void func_801872FC(void); -// void func_801873BC(void); -// void func_8018752C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +u32 osFlashGetAddr(u32 pageNum); +OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start); +void osFlashChange(u32 flashNum); +OSPiHandle* osFlashInit(void); +void osFlashReadStatus(u8* flashStatus); +void osFlashReadId(u32* flashType, u32* flashVendor); +void osFlashClearStatus(void); +s32 osFlashAllErase(void); +void osFlashAllEraseThrough(void); +s32 osFlashCheckEraseEnd(void); +s32 osFlashSectorErase(u32 pageNum); +void osFlashSectorEraseThrough(u32 pageNum); +s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq); +s32 osFlashWriteArray(u32 pageNum); +s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq); // void func_801877D0(void); // void func_80187B64(void); // void func_80187BEC(void); diff --git a/include/macros.h b/include/macros.h index ebe4b636e..7020fc01c 100644 --- a/include/macros.h +++ b/include/macros.h @@ -8,13 +8,10 @@ #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) -#define HW_REG(reg, type) *(volatile type*)((reg) | 0xa0000000) - -// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address -// rather than add/sub 0x80000000 -#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + 0x80000000) -#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr)-0x80000000) -#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr)-0x80000000) +// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000 +#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED) +#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr) - RDRAM_CACHED) +#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED) #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) #define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera]) diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index a420bb591..c3eb8dd4c 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -1,7 +1,17 @@ #ifndef _ULTRA64_HARDWARE_H_ #define _ULTRA64_HARDWARE_H_ -#define HW_REG(reg, type) *(volatile type*)((reg) | 0xa0000000) +// Segment Wrapper +// Uncached RDRAM +#define KSEG1 0xA0000000 // 0xA0000000 - 0xBFFFFFFF Physical memory, uncached, unmapped +#define RDRAM_UNCACHED KSEG1 + +// Cached RDRAM +#define KSEG0 0x80000000 // 0x80000000 - 0x9FFFFFFF Physical memory, cached, unmapped +#define RDRAM_CACHED KSEG0 + +// Volatile access wrapper, enforcing uncached memory +#define HW_REG(reg, type) *(volatile type*)((reg) | KSEG1) #define AI_DRAM_ADDR_REG 0x04500000 #define AI_LEN_REG 0x04500004 diff --git a/include/variables.h b/include/variables.h index 8105107d4..d7f22e776 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3538,12 +3538,6 @@ extern StackEntry sys_flashromStackEntry; extern OSThread sys_flashromOSThread; extern s80185D40 D_801FD008; extern OSMesg D_801FD034; -// extern UNK_TYPE1 D_801FD040; -extern OSIoMesg D_801FD050; -extern OSMesgQueue D_801FD068; -extern OSPiHandle D_801FD080; -// extern UNK_TYPE1 D_801FD0F4; -// extern UNK_TYPE1 D_801FD0F8; // extern UNK_TYPE1 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; diff --git a/include/z64.h b/include/z64.h index 533677efd..c5f1c7b4a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1694,4 +1694,43 @@ typedef struct { /* 0x04 */ const char* name; } FlagSetEntry; // size = 0x08 +// TODO: Dedicated Header? +#define FRAM_BASE_ADDRESS 0x08000000 // FRAM Base Address in Cart Memory +#define FRAM_STATUS_REGISTER FRAM_BASE_ADDRESS // FRAM Base Address in Cart Memory +#define FRAM_COMMAND_REGISTER 0x10000 // Located at 0x08010000 on the Cart + +enum fram_command { + /* Does nothing for FRAM_COMMAND_SET_MODE_READ_AND_STATUS, FRAM_MODE_NOP, FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS + Initializes fram to 0xFF in FRAM_MODE_ERASE + Writes Contents in FLASHRAM_MODE_WRITE + After execution, sets FRAM_MODE to FRAM_MODE_NOP */ + FRAM_COMMAND_EXECUTE = 0xD2000000, + /* flashram->erase_offset = (command & 0xffff) * 128; */ + FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET = 0x4B000000, + /* flashram->mode = FLASHRAM_MODE_ERASE; + flashram->status = 0x1111800800c20000LL; */ + FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS = 0x78000000, + /* flashram->erase_offset = (command & 0xffff) * 128; + flashram->status = 0x1111800400c20000LL; */ + FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET_AND_STATUS = 0xA5000000, + /* flashram->mode = FLASHRAM_MODE_WRITE; */ + FRAM_COMMAND_SET_MODE_WRITE = 0xB4000000, + /* flashram->mode = FLASHRAM_MODE_STATUS; + flashram->status = 0x1111800100c20000LL; */ + FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS = 0xE1000000, + /* flashram->mode = FLASHRAM_MODE_READ; + flashram->status = 0x11118004f0000000LL; */ + FRAM_COMMAND_SET_MODE_READ_AND_STATUS = 0xF0000000, + /* unk */ + FRAM_COMMAND_UNK_ERASE_OPERATION = 0x3C000000 +}; + +enum fram_mode { + FRAM_MODE_NOP = 0, + FRAM_MODE_ERASE, + FRAM_MODE_WRITE, + FRAM_MODE_READ, + FRAM_MODE_STATUS +}; + #endif diff --git a/spec b/spec index 961e5328c..fa3825d82 100644 --- a/spec +++ b/spec @@ -638,8 +638,7 @@ beginseg include "build/src/code/sys_flashrom.o" include "build/data/code/sys_flashrom.bss.o" include "build/asm/code/code_80185F90.text.o" // handwritten - include "build/src/code/osFlash.o" - include "build/data/code/osFlash.bss.o" + include "build/src/libultra/flash/osFlash.o" pad_text pad_text pad_text diff --git a/src/code/osFlash.c b/src/code/osFlash.c deleted file mode 100644 index e661bc9c7..000000000 --- a/src/code/osFlash.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186A70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186AB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186B78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186CAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186D60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80186EC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80187018.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80187080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80187124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_80187284.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_801872FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_801873BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/osFlash/func_8018752C.s") diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c new file mode 100644 index 000000000..bf3044029 --- /dev/null +++ b/src/libultra/flash/osFlash.c @@ -0,0 +1,325 @@ +#include "ultra64.h" +#include "global.h" + +static s32 framDeviceInfo[4]; +static OSIoMesg framDeviceInfoQuery; +static OSMesgQueue __osFlashMessageQ; +static OSPiHandle __osFlashHandler; +static OSMesg __osFlashMsgBuf; +static s32 __osFlashVersion; +static UNK_TYPE1 D_801FD0FC[0x14]; + +typedef enum { + FLASH_OLD, + FLASH_NEW, +} FlashVersion; + +u32 osFlashGetAddr(u32 pageNum) { + s32 addr = (__osFlashVersion == FLASH_OLD) ? pageNum << 6 : pageNum << 7; + + return addr; +} + +OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start) { + __osFlashHandler.baseAddress = RDRAM_UNCACHED | start; + __osFlashHandler.type++; + __osFlashHandler.latency = latency; + __osFlashHandler.pulse = pulse; + __osFlashHandler.pageSize = pageSize; + __osFlashHandler.relDuration = relDuration; + __osFlashHandler.domain = 1; + + return &__osFlashHandler; +} + +void osFlashChange(u32 flash_num) { + __osFlashHandler.baseAddress = RDRAM_UNCACHED | (FRAM_STATUS_REGISTER + (flash_num << 17)); + __osFlashHandler.type = 8 + flash_num; + + return; +} + +OSPiHandle* osFlashInit(void) { + u32 flashType; + u32 flashVendor; + + osCreateMesgQueue(&__osFlashMessageQ, &__osFlashMsgBuf, 1); + + if (__osFlashHandler.baseAddress == (RDRAM_UNCACHED | FRAM_BASE_ADDRESS)) { + return &__osFlashHandler; + } + + __osFlashHandler.type = 8; + __osFlashHandler.baseAddress = (RDRAM_UNCACHED | FRAM_BASE_ADDRESS); + __osFlashHandler.latency = 5; + __osFlashHandler.pulse = 12; + __osFlashHandler.pageSize = 15; + __osFlashHandler.relDuration = 2; + __osFlashHandler.domain = 1; + __osFlashHandler.speed = 0; + bzero(&__osFlashHandler.transferInfo, sizeof(__OSTranxInfo)); + + osEPiLinkHandle(&__osFlashHandler); + osFlashReadId(&flashType, &flashVendor); + + if (flashVendor == 0x00C2001E || flashVendor == 0x00C20001 || flashVendor == 0x00C20000) { + __osFlashVersion = FLASH_OLD; + } else { + __osFlashVersion = FLASH_NEW; + } + + return &__osFlashHandler; +} + +void osFlashReadStatus(u8* flashStatus) { + u32 outFlashStatus; + + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, FRAM_COMMAND_EXECUTE); + // read status using IO + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &outFlashStatus); + + // why twice ? + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, FRAM_COMMAND_EXECUTE); + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &outFlashStatus); + + *flashStatus = outFlashStatus & 0xFF; + + return; +} + +void osFlashReadId(u32* flashType, u32* flashVendor) { + u8 flashStatus; + + // why read status? + osFlashReadStatus(&flashStatus); + + // select silicon id read mode + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS); + + // read silicon id using DMA + framDeviceInfoQuery.hdr.pri = 0; + framDeviceInfoQuery.hdr.retQueue = &__osFlashMessageQ; + framDeviceInfoQuery.dramAddr = framDeviceInfo; + framDeviceInfoQuery.devAddr = 0; + framDeviceInfoQuery.size = 8; + + osInvalDCache(framDeviceInfo, sizeof(framDeviceInfo)); + osEPiStartDma(&__osFlashHandler, &framDeviceInfoQuery, OS_READ); + osRecvMesg(&__osFlashMessageQ, NULL, OS_MESG_BLOCK); + + *flashType = framDeviceInfo[0]; + *flashVendor = framDeviceInfo[1]; + + return; +} + +void osFlashClearStatus(void) { + // select status mode + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, FRAM_COMMAND_EXECUTE); + // clear status + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress, 0); + + return; +} + +s32 osFlashAllErase(void) { + u32 status; + OSTimer timer; + OSMesgQueue mq; + OSMesg msg; + + // start chip erase operation + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_UNK_ERASE_OPERATION); + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS); + + // wait for completion by polling erase-busy flag + osCreateMesgQueue(&mq, &msg, 1); + do { + osSetTimer(&timer, OS_USEC_TO_CYCLES(15000), 0, &mq, &msg); + osRecvMesg(&mq, &msg, OS_MESG_BLOCK); + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + } while ((status & 2) == 2); + + // check erase operation status, clear status + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + osFlashClearStatus(); + + if (((status & 0xFF) == 0x08) || ((status & 0xFF) == 0x48) || ((status & 0x08) == 0x08)) { + return 0; + } else { + return -1; + } +} + +void osFlashAllEraseThrough(void) { + // start chip erase operation + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_UNK_ERASE_OPERATION); + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS); +} + +s32 osFlashCheckEraseEnd(void) { + u8 status; + + // check if erase operation is completed + osFlashReadStatus(&status); + if ((status & 0x02) == 0x02) { + return 2; // busy + } else { + // check erase operation status, clear status + osFlashReadStatus(&status); + } + osFlashClearStatus(); + + if (((status & 0xFF) == 0x08) || ((status & 0xFF) == 0x48) || ((status & 0x08) == 0x08)) { + return 0; + } else { + return -1; + } +} + +s32 osFlashSectorErase(u32 pageNum) { + u32 status; + OSTimer timer; + OSMesgQueue mq; + OSMesg msg; + + // start sector erase operation + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET | pageNum); + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS); + + // wait for completion by polling erase-busy flag + osCreateMesgQueue(&mq, &msg, 1); + do { + osSetTimer(&timer, OS_USEC_TO_CYCLES(12500), 0, &mq, &msg); + osRecvMesg(&mq, &msg, OS_MESG_BLOCK); + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + } while ((status & 2) == 2); + + // check erase operation status, clear status + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + osFlashClearStatus(); + + if (((status & 0xFF) == 0x08) || ((status & 0xFF) == 0x48) || ((status & 0x08) == 0x08)) { + return 0; + } else { + return -1; + } +} + +void osFlashSectorEraseThrough(u32 pageNum) { + // start sector erase operation + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET | pageNum); + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS); +} + +s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq) { + s32 ret; + + // select load page mode + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, FRAM_COMMAND_SET_MODE_WRITE); + + // DMA 128-byte page + mb->hdr.pri = priority; + mb->hdr.retQueue = mq; + mb->dramAddr = dramAddr; + mb->devAddr = 0; + mb->size = 0x80; + + ret = osEPiStartDma(&__osFlashHandler, mb, OS_WRITE); + + return ret; +} + +s32 osFlashWriteArray(u32 pageNum) { + u32 status; + OSTimer timer; + OSMesgQueue mq; + OSMesg msg; + + // only needed for new flash ? + if (__osFlashVersion == FLASH_NEW) { + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_WRITE); + } + + // start program page operation + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET_AND_STATUS | pageNum); + + // wait for completion by polling write-busy flag + osCreateMesgQueue(&mq, &msg, 1); + do { + osSetTimer(&timer, OS_USEC_TO_CYCLES(200), 0, &mq, &msg); + osRecvMesg(&mq, &msg, OS_MESG_BLOCK); + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + } while ((status & 0x01) == 0x01); + + // check program operation status, clear status + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); + osFlashClearStatus(); + + if (((status & 0xFF) == 0x04) || ((status & 0xFF) == 0x44) || ((status & 0x04) == 0x04)) { + return 0; + } else { + return -1; + } +} + +s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq) { + s32 ret; + u32 dummy; + u32 last_page; + u32 pages; + + // select read array mode + osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FRAM_COMMAND_REGISTER, + FRAM_COMMAND_SET_MODE_READ_AND_STATUS); + + // dummy read to initiate "fast-page" reads ? + osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &dummy); + + // DMA requested pages + mb->hdr.pri = priority; + mb->hdr.retQueue = mq; + mb->dramAddr = dramAddr; + + last_page = pageNum + pageCount - 1; + + if ((last_page & 0xF00) != (pageNum & 0xF00)) { + + pages = 256 - (pageNum & 0xFF); + pageCount -= pages; + mb->size = pages << 7; + mb->devAddr = osFlashGetAddr(pageNum); + osEPiStartDma(&__osFlashHandler, mb, OS_READ); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + pageNum = (pageNum + 256) & 0xF00; + mb->dramAddr = (void*)((uintptr_t)mb->dramAddr + mb->size); + } + + while (pageCount > 256) { + pages = 256; + pageCount -= 256; + mb->size = pages << 7; + mb->devAddr = osFlashGetAddr(pageNum); + osEPiStartDma(&__osFlashHandler, mb, OS_READ); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + pageNum += 256; + mb->dramAddr = (void*)((uintptr_t)mb->dramAddr + mb->size); + } + + mb->size = pageCount << 7; + mb->devAddr = osFlashGetAddr(pageNum); + ret = osEPiStartDma(&__osFlashHandler, mb, OS_READ); + + return ret; +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9ecd22762..290705284 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3463,25 +3463,21 @@ 0x80185F04:("func_80185F04",), 0x80185F64:("func_80185F64",), 0x80185F90:("func_80185F90",), - 0x80186A70:("func_80186A70",), - 0x80186AB8:("func_80186AB8",), - 0x80186B28:("func_80186B28",), - 0x80186B30:("func_80186B30",), - 0x80186B38:("func_80186B38",), - 0x80186B68:("func_80186B68",), - 0x80186B70:("func_80186B70",), - 0x80186B78:("func_80186B78",), - 0x80186CAC:("func_80186CAC",), - 0x80186D60:("func_80186D60",), - 0x80186E64:("func_80186E64",), - 0x80186EC8:("func_80186EC8",), - 0x80187018:("func_80187018",), - 0x80187080:("func_80187080",), - 0x80187124:("func_80187124",), - 0x80187284:("func_80187284",), - 0x801872FC:("func_801872FC",), - 0x801873BC:("func_801873BC",), - 0x8018752C:("func_8018752C",), + 0x80186A70:("osFlashGetAddr",), + 0x80186AB8:("osFlashReInit",), + 0x80186B38:("osFlashChange",), + 0x80186B78:("osFlashInit",), + 0x80186CAC:("osFlashReadStatus",), + 0x80186D60:("osFlashReadId",), + 0x80186E64:("osFlashClearStatus",), + 0x80186EC8:("osFlashAllErase",), + 0x80187018:("osFlashAllEraseThrough",), + 0x80187080:("osFlashCheckEraseEnd",), + 0x80187124:("osFlashSectorErase",), + 0x80187284:("osFlashSectorEraseThrough",), + 0x801872FC:("osFlashWriteBuffer",), + 0x801873BC:("osFlashWriteArray",), + 0x8018752C:("osFlashReadArray",), 0x801877D0:("func_801877D0",), 0x80187B64:("func_80187B64",), 0x80187BEC:("func_80187BEC",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3ca0fa02e..b4fa7869b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -364,7 +364,7 @@ 0x8009F888:("viCounterMsg","OSIoMesg","",0x18), 0x8009F8A0:("viRetrace","u16","",0x2), 0x8009F8B0:("dmadata","DmaEntry","[1568]",0x6200), - 0x80186028:("D_80186028","UNK_TYPE1","",0x1), + 0x80186028:("D_80186028","s16","[1316]",0xa48), 0x801AAAB0:("D_801AAAB0","UNK_TYPE1","",0x1), 0x801ABAB0:("D_801ABAB0","UNK_TYPE1","",0x1), 0x801AD370:("D_801AD370","UNK_TYPE1","",0x1), @@ -4327,12 +4327,12 @@ 0x801FCE58:("sys_flashromOSThread","OSThread","",0x1b0), 0x801FD008:("D_801FD008","s80185D40","",0x2c), 0x801FD034:("D_801FD034","OSMesg","",0x4), - 0x801FD040:("D_801FD040","UNK_TYPE1","",0x1), + 0x801FD040:("D_801FD040","s32","",0x10), 0x801FD050:("D_801FD050","OSIoMesg","",0x18), - 0x801FD068:("D_801FD068","OSMesgQueue","",0x18), - 0x801FD080:("D_801FD080","OSPiHandle","",0x74), - 0x801FD0F4:("D_801FD0F4","UNK_TYPE1","",0x1), - 0x801FD0F8:("D_801FD0F8","UNK_TYPE1","",0x1), + 0x801FD068:("__osFlashMessageQ","OSMesgQueue","",0x18), + 0x801FD080:("__osFlashHandler","OSPiHandle","",0x74), + 0x801FD0F4:("__osFlashMsgBuf","OSMesg","",0x4), + 0x801FD0F8:("__osFlashVersion","u32","",0x4), 0x801FD120:("D_801FD120","UNK_TYPE1","",0x1), 0x801FD140:("D_801FD140","UNK_TYPE1","",0x1), 0x801FD158:("D_801FD158","UNK_TYPE1","",0x1), From 31e4089a4b21e1be07cbc8d2c8e764d231953cc4 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 4 Nov 2021 17:42:01 +0000 Subject: [PATCH 77/86] En_Goroiwa (3 non-matching) (#375) * En_Goroiwa * Fix names * Params * Revert PR --- include/functions.h | 6 +- spec | 5 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 1609 ++++++++++++++++- .../actors/ovl_En_Goroiwa/z_en_goroiwa.h | 71 +- undefined_syms.txt | 12 + 5 files changed, 1625 insertions(+), 78 deletions(-) diff --git a/include/functions.h b/include/functions.h index 5a954660a..ba2868e61 100644 --- a/include/functions.h +++ b/include/functions.h @@ -544,8 +544,8 @@ void func_800AE5A0(GlobalContext* globalCtx); // void func_800AE5E4(void); void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 param_3, s16 param_4); void func_800AE8EC(GlobalContext* globalCtx); -void func_800AE930(CollisionContext* colCtx, s32 param_2, float* param_3, f32 param_4, s16 param_5, CollisionPoly* param_6, s32 param_7); -// void func_800AEF44(void); +void func_800AE930(CollisionContext* colCtx, s32 param_2, Vec3f* param_3, f32 param_4, s16 param_5, CollisionPoly* param_6, s32 param_7); +void func_800AEF44(s32 arg0); void EffectTireMark_InitParticle(EffTireMarkParticle* particle); void EffectTireMark_Init(EffTireMarkParams* params, EffTireMarkInit* init); void EffectTireMark_Destroy(EffTireMarkParams* params); @@ -984,7 +984,7 @@ f32 func_800C4000(GlobalContext* globalCtx, CollisionContext* colCtx, s32* arg2, // void func_800C4058(void); f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Vec3f* pos); f32 func_800C411C(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Actor* actor, Vec3f* pos); -// void func_800C4188(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +f32 func_800C4188(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); // void func_800C41E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800C4240(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800C42A8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); diff --git a/spec b/spec index fa3825d82..90deac25b 100644 --- a/spec +++ b/spec @@ -1557,8 +1557,11 @@ beginseg name "ovl_En_Goroiwa" compress include "build/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.o" - include "build/data/ovl_En_Goroiwa/ovl_En_Goroiwa.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Goroiwa/ovl_En_Goroiwa_reloc.o" +#else include "build/data/ovl_En_Goroiwa/ovl_En_Goroiwa.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index e2ab6909c..e06c88689 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -1,7 +1,7 @@ /* * File: z_en_goroiwa.c * Overlay: ovl_En_Goroiwa - * Description: Rolling boulder + * Description: Rolling boulders */ #include "z_en_goroiwa.h" @@ -15,7 +15,36 @@ void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx); void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809419D0(EnGoroiwa* this); +void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx); +void func_809421E0(EnGoroiwa* this); +void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx); +void func_809425CC(EnGoroiwa* this); +void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941DB4(EnGoroiwa* this); +void func_80941E28(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941EB4(EnGoroiwa* this); +void func_80941F10(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80941F54(EnGoroiwa* this); +void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx); +void func_80942084(EnGoroiwa* this); +void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx); + +extern Gfx D_060032E0[]; +extern Gfx D_060082D0[]; +extern Gfx D_06005C20[]; +extern Gfx D_06003B40[]; +extern Gfx D_06008B90[]; +extern Gfx D_060042B0[]; +extern Gfx D_06004960[]; +extern Gfx D_06004EF0[]; +extern Gfx D_060003B0[]; +extern Gfx D_060028E0[]; +extern Gfx D_06002D70[]; +extern Gfx D_060072F0[]; +extern Gfx D_060077D0[]; +extern Gfx D_06007C60[]; + const ActorInit En_Goroiwa_InitVars = { ACTOR_EN_GOROIWA, ACTORCAT_PROP, @@ -28,141 +57,1577 @@ const ActorInit En_Goroiwa_InitVars = { (ActorFunc)EnGoroiwa_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80942DC0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 58 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80942DE4 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80942DC0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80942DF4 = { 0, 12, 60, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80942E78[] = { - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 160, ICHAIN_CONTINUE), +static f32 D_80942DFC[] = { + 10.0f, + 12.0f, + 14.0f, + 10.0f, +}; + +static Gfx* D_80942E0C[][3] = { + { D_060042B0, D_06004960, D_06004EF0 }, + { D_060003B0, D_060028E0, D_06002D70 }, + { D_060072F0, D_060077D0, D_06007C60 }, +}; + +static Color_RGBA8 D_80942E30[] = { + { 190, 195, 200, 255 }, + { 170, 130, 90, 255 }, +}; + +static Color_RGBA8 D_80942E38 = { 250, 250, 250, 255 }; + +static Color_RGBA8 D_80942E3C[] = { + { 130, 135, 140, 255 }, + { 100, 60, 20, 255 }, +}; + +static Color_RGBA8 D_80942E44 = { 180, 180, 180, 255 }; + +static Vec3f D_80942E48 = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_80942E54 = { 0.0f, 0.3f, 0.0f }; +static Vec3f D_80942E60 = { 0.0f, 1.0f, 0.0f }; +static Vec3f D_80942E6C = { 0.0f, 0.0f, 1.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 160, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), }; +static UNK_TYPE D_80942E8C[] = { + 0x0000003B, + 0x1A1A2864, +}; + +void func_8093E8A0(EnGoroiwa* this) { + s32 params = ENGOROIWA_GET_3000(&this->actor); + f32 phi_f2; + + if (params == ENGOROIWA_3000_0) { + phi_f2 = 0.1f; + } else if (params == ENGOROIWA_3000_1) { + phi_f2 = 0.05f; + } else { + phi_f2 = (Rand_ZeroOne() * (f32)0.04) + 0.04f; + } + + Actor_SetScale(&this->actor, phi_f2); +} + +void func_8093E91C(EnGoroiwa* this) { + this->unk_1DC = this->actor.scale.x * 595.0f; +} + +void func_8093E938(EnGoroiwa* this) { + Sphere16* worldSphere = &this->collider.elements->dim.worldSphere; + + worldSphere->center.x = this->actor.world.pos.x; + worldSphere->center.y = this->actor.world.pos.y + this->unk_1DC; + worldSphere->center.z = this->actor.world.pos.z; + this->collider.elements->dim.worldSphere.radius = this->unk_1DC - 1.0f; +} + +void func_8093E9B0(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 pad[2]; + s32 params = ENGOROIWA_GET_C000(&this->actor); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + func_8093E938(this); + this->collider.elements[0].dim.worldSphere.radius = this->unk_1DC - 1.0f; + + if ((params == ENGOROIWA_C000_1) || (params == ENGOROIWA_C000_2)) { + this->collider.elements[0].info.bumper.dmgFlags |= (0x4000 | 0x400 | 0x100); + if (params == ENGOROIWA_C000_1) { + this->collider.base.colType = COLTYPE_WOOD; + } else { + this->collider.elements[0].info.bumper.dmgFlags &= ~(0x400000 | 0x200 | 0x2); + this->collider.elements[0].info.bumper.dmgFlags |= (0x80000000 | 0x800 | 0x8); + this->collider.base.colType = COLTYPE_NONE; + } + } +} + +void func_8093EAB0(EnGoroiwa* this, u8 arg0) { + this->unk_1E5 &= ~7; + this->unk_1E5 |= arg0; +} + +s32 func_8093EAD4(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg1); + + if (temp_f0 < 0.001f) { + return false; + } + arg0->x = arg1->x * (1.0f / temp_f0); + arg0->y = arg1->y * (1.0f / temp_f0); + arg0->z = arg1->z * (1.0f / temp_f0); + return true; +} + +void func_8093EB58(EnGoroiwa* this, GlobalContext* globalCtx) { + this->unk_1E4 = (this->actor.home.rot.x >> 1) & 3; +} + +f32 func_8093EB74(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 i; + Path* path = &globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)]; + s32 temp_s4 = path->count; + f32 temp_f20 = 0.0f; + Vec3f sp54; + Vec3f sp48; + + Math_Vec3s_ToVec3f(&sp48, &this->unk_1D0[0]); + + for (i = 1; i < temp_s4; i++) { + Math_Vec3f_Copy(&sp54, &sp48); + Math_Vec3s_ToVec3f(&sp48, &this->unk_1D0[i]); + temp_f20 += Math3D_Distance(&sp54, &sp48); + } + + return temp_f20; +} + +void func_8093EC50(EnGoroiwa* this) { + Vec3s* var = &this->unk_1D0[this->unk_1D8]; + Vec3f sp18; + + sp18.x = var->x; + sp18.y = var->y; + sp18.z = var->z; + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp18); +} + +void func_8093ECD4(EnGoroiwa* this) { + s32 params = ENGOROIWA_GET_300(&this->actor); + + if (this->unk_1D8 < 0) { + if ((params == ENGOROIWA_300_0) || (params == ENGOROIWA_300_1)) { + this->unk_1D8 = this->unk_1D4 - 1; + this->unk_1DA = -1; + this->unk_1D6 = this->unk_1D4; + } else if (params == ENGOROIWA_300_3) { + this->unk_1D6 = 0; + this->unk_1D8 = 1; + this->unk_1DA = 1; + } + } else if (this->unk_1D4 < this->unk_1D8) { + if ((params == ENGOROIWA_300_0) || (params == ENGOROIWA_300_1)) { + this->unk_1D6 = 0; + this->unk_1D8 = 1; + this->unk_1DA = 1; + } else if (params == ENGOROIWA_300_3) { + this->unk_1D6 = this->unk_1D4; + this->unk_1D8 = this->unk_1D4 - 1; + this->unk_1DA = -1; + } + } +} + +void func_8093ED80(EnGoroiwa* this) { + this->unk_1D6 = this->unk_1D8; + this->unk_1D8 += this->unk_1DA; + func_8093ECD4(this); +} + +void func_8093EDB0(EnGoroiwa* this) { + this->unk_1DA = -this->unk_1DA; + this->unk_1D6 = this->unk_1D8; + this->unk_1D8 += this->unk_1DA; +} + +void func_8093EDD8(EnGoroiwa* this, GlobalContext* globalCtx) { + this->unk_1D4 = globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; + this->unk_1D6 = 0; + this->unk_1D8 = 1; + this->unk_1DA = 1; +} + +void func_8093EE18(EnGoroiwa* this, GlobalContext* globalCtx) { + this->unk_1D4 = globalCtx->setupPathList[ENGOROIWA_GET_FF(&this->actor)].count - 1; + this->unk_1D6 = this->actor.home.rot.y; + this->unk_1D8 = this->unk_1D6 + 1; + this->unk_1DA = 1; +} + +void func_8093EE64(EnGoroiwa* this, s32 arg1) { + Vec3s* temp_v0 = &this->unk_1D0[arg1]; + + this->actor.world.pos.x = temp_v0->x; + this->actor.world.pos.y = temp_v0->y; + this->actor.world.pos.z = temp_v0->z; +} + +void func_8093EEBC(EnGoroiwa* this) { + this->unk_1B4.x = 1.0f; + this->unk_1C4 = 1.0f; + this->unk_1A8.x = 1.0f; +} + +s32 func_8093EEDC(EnGoroiwa* this) { + Vec3s* temp_v1 = &this->unk_1D0[this->unk_1D8]; + Vec3s* temp_v0 = &this->unk_1D0[this->unk_1D6]; + + if ((temp_v1->x == temp_v0->x) && (temp_v1->z == temp_v0->z)) { + if (temp_v0->y < temp_v1->y) { + return 1; + } + return -1; + } + return 0; +} + +void func_8093EF54(GlobalContext* globalCtx, Vec3f* arg1, Color_RGBA8* arg2, Color_RGBA8* arg3, f32 arg4) { + Vec3f spC4; + f32 temp_f0; + f32 temp_f20; + f32 temp_f24; + f32 temp_f26; + s32 temp_f16; + s16 phi_s0; + s16 temp; + f32 temp_f28; + f32 temp_f30; + s32 i; + + temp_f0 = (arg4 + 0.1f) * 0.5f; + temp_f16 = temp_f0 * 165.0f; + temp_f24 = 470.0f * arg4; + temp_f30 = 400.0f * arg4; + temp_f26 = 800.0f * temp_f0; + temp_f28 = 600.0f * temp_f0; + temp = 0x10000 / temp_f16; + + for (i = 0, phi_s0 = 0; i < temp_f16; i++, phi_s0 += temp) { + // clang-format off + temp_f20 = Rand_ZeroOne(); spC4.x = (Math_SinS(phi_s0) * (temp_f24 * ((temp_f20 * 0.5f) + 0.5f))) + arg1->x; + spC4.y = ((Rand_ZeroOne() - 0.5f) * temp_f30) + arg1->y; + temp_f20 = Rand_ZeroOne(); spC4.z = (Math_CosS(phi_s0) * (temp_f24 * ((temp_f20 * 0.5f) + 0.5f))) + arg1->z; + // clang-format on + + func_800B0E48(globalCtx, &spC4, &D_80942E48, &D_80942E54, arg2, arg3, (Rand_ZeroOne() * temp_f28) + temp_f26, + temp_f26); + } +} + +void func_8093F198(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { + Vec3f sp74; + f32 temp_f20; + s32 temp_f16; + s16 temp_lo; + s16 phi_s0; + s32 i; + + temp_f16 = (arg2 + 0.1f) * 58.0f; + sp74.y = arg1->y; + temp_f20 = 550.0f * arg2; + temp_lo = 0x10000 / temp_f16; + + for (i = 0, phi_s0 = 0; i < temp_f16; i++, phi_s0 += temp_lo) { + sp74.x = (Math_SinS((s32)(Rand_ZeroOne() * temp_lo) + phi_s0) * temp_f20) + arg1->x; + sp74.z = (Math_CosS((s32)(Rand_ZeroOne() * temp_lo) + phi_s0) * temp_f20) + arg1->z; + EffectSsGSplash_Spawn(globalCtx, &sp74, NULL, NULL, 0, 0x15E); + } + + EffectSsGRipple_Spawn(globalCtx, arg1, 0x1F4, 0x384, 4); +} + +s32 func_8093F34C(EnGoroiwa* this) { + s32 pad[3]; + Vec3s* temp_v0; + f32 tempX; + f32 tempZ; + f32 x; + f32 z; + + Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); + Actor_SetVelocityYRotationAndGravity(&this->actor); + temp_v0 = &this->unk_1D0[this->unk_1D8]; + this->actor.velocity.y *= 0.97f; + x = temp_v0->x; + z = temp_v0->z; + + tempX = x - this->actor.world.pos.x; + tempZ = z - this->actor.world.pos.z; + + if (SQ(this->actor.speedXZ + 1.0f) < (SQ(tempX) + SQ(tempZ))) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->unk_1E5 &= ~0x40; + return false; + } + + this->actor.world.pos.x = x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z = z; + this->unk_1E5 |= 0x40; + return true; +} + +s32 func_8093F498(EnGoroiwa* this) { + s32 pad; + f32 temp_f0; + Vec3f sp2C; + Vec3s* temp_v0 = &this->unk_1D0[this->unk_1D8]; + + sp2C.x = temp_v0->x; + sp2C.y = temp_v0->y; + sp2C.z = temp_v0->z; + + Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); + Math_Vec3f_Diff(&sp2C, &this->actor.world.pos, &this->actor.velocity); + + temp_f0 = Math3D_Vec3fMagnitude(&this->actor.velocity); + if ((this->actor.speedXZ + 1.0f) < temp_f0) { + Math_Vec3f_Scale(&this->actor.velocity, this->actor.speedXZ / temp_f0); + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->unk_1E5 &= ~0x40; + return false; + } + + this->actor.world.pos.x = sp2C.x; + this->actor.world.pos.y = sp2C.y; + this->actor.world.pos.z = sp2C.z; + this->unk_1E5 |= 0x40; + return true; +} + +s32 func_8093F5EC(EnGoroiwa* this) { + s32 pad; + Vec3s* sp18 = &this->unk_1D0[this->unk_1D8]; + + if (this->actor.velocity.y < 0.0f) { + this->actor.velocity.y = 0.0f; + } + + Math_StepToF(&this->actor.velocity.y, D_80942DFC[this->unk_1E4] * 0.5f, 0.18f); + this->actor.world.pos.x = sp18->x; + this->actor.world.pos.z = sp18->z; + + if (Math_StepToF(&this->actor.world.pos.y, sp18->y, fabsf(this->actor.velocity.y))) { + this->unk_1E5 |= 0x40; + return true; + } + + this->unk_1E5 &= ~0x40; + return false; +} + +s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { + f32 temp_f14; + Vec3s* sp80 = &this->unk_1D0[this->unk_1D8]; + f32 sp7C = sp80->y; + f32 sp78; + f32 temp_f2; + + Math_StepToF(&this->actor.velocity.y, -18.367346f, 1.0f); + this->actor.velocity.y *= 0.98f; + this->actor.world.pos.x = sp80->x; + this->actor.world.pos.z = sp80->z; + sp78 = this->actor.world.pos.y; + this->actor.world.pos.y += this->actor.velocity.y; + + if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) { + if (this->unk_1CA == 0) { + if (this->actor.xzDistToPlayer < 400.0f) { + s16 sp72 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + Quake_SetSpeed(sp72, 0x4350); + Quake_SetQuakeValues(sp72, 3, 0, 0, 0); + Quake_SetCountdown(sp72, 7); + } + + this->unk_1C4 = 0.0f; + + if (!(this->unk_1E5 & 0x20)) { + CollisionPoly* sp6C; + Vec3f sp60; + s32 pad[2]; + s32 sp54; + Vec3f sp48; + + sp60.x = this->actor.world.pos.x; + sp60.y = this->actor.world.pos.y + 50.0f; + sp60.z = this->actor.world.pos.z; + + temp_f14 = func_800C4188(globalCtx, &globalCtx->colCtx, &sp6C, &sp54, &this->actor, &sp60); + temp_f2 = temp_f14 - this->actor.world.pos.y; + + if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { + if (this->actor.flags & 0x40) { + sp48.x = this->actor.world.pos.x; + sp48.y = temp_f14 + 10.0f; + sp48.z = this->actor.world.pos.z; + + func_8093EF54(globalCtx, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], + &D_80942E3C[ENGOROIWA_GET_C000(&this->actor)], this->actor.scale.x); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EV_BIGBALL_BOUND); + } + } + } + + if (this->unk_1CA > 0) { + this->unk_1E5 |= 0x40; + return true; + } + + this->unk_1CA++; + this->actor.velocity.y *= -0.3f; + this->actor.world.pos.y = sp7C - ((this->actor.world.pos.y - sp7C) * 0.3f); + } + + if (this->unk_1CA == 0) { + WaterBox* sp44; + f32 sp40; + + if (func_800CA1E8(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &sp44)) { + if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { + this->unk_1E5 |= 0x20; + if (sp40 < (this->unk_1DC + sp78)) { + if (this->actor.flags & 0x40) { + Vec3f sp34; + + sp34.x = this->actor.world.pos.x; + sp34.y = sp40; + sp34.z = this->actor.world.pos.z; + func_8093F198(globalCtx, &sp34, this->actor.scale.x); + } + this->actor.velocity.y *= 0.2f; + } + + if (this->actor.velocity.y < -8.0f) { + this->actor.velocity.y = -8.0f; + } + } + } + } + + this->unk_1E5 &= ~0x40; + return false; +} + +#ifdef NON_MATCHING +// Stack +void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { + f32 temp; + f32 sp7C; + Vec3f sp70; + Vec3f sp64; + MtxF sp24; + + if (this->unk_1E5 & 0x10) { + sp7C = this->unk_1C0; + } else { + temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); + this->unk_1C0 = temp / this->unk_1DC; + sp7C = this->unk_1C0; + } + + sp7C *= this->unk_1C4; + if (!(this->unk_1E5 & 0x10)) { + if (Math3D_LengthSquared(&this->actor.velocity) > 0.1f) { + Math_Vec3f_Copy(&this->unk_1A8, &this->actor.velocity); + } + } + + Math3D_CrossProduct(&D_80942E60, &this->unk_1A8, &sp70); + + if (func_8093EAD4(&sp64, &sp70)) { + this->unk_1B4 = sp64; + } else { + sp64 = this->unk_1B4; + } + + Matrix_InsertRotationAroundUnitVector_f(sp7C, &sp64, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp24); + func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") #endif -extern ColliderJntSphElementInit D_80942DC0[1]; -extern ColliderJntSphInit D_80942DE4; -extern CollisionCheckInfoInit D_80942DF4; -extern InitChainEntry D_80942E78[]; +void func_8093FC00(EnGoroiwa* this) { + s32 params = ENGOROIWA_GET_300(&this->actor); -extern UNK_TYPE D_060032E0; + func_8093ED80(this); + if (((params == ENGOROIWA_300_0) || (params == ENGOROIWA_300_1)) && + ((this->unk_1D6 == 0) || (this->unk_1D6 == this->unk_1D4))) { + func_8093EE64(this, this->unk_1D6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093E8A0.s") +void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + s16 temp_s3; + s16 phi_s0; + s16 temp; + s32 pad; + s32 sp80; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093E91C.s") + temp_f24 = (this->actor.scale.x + 0.1f) * 0.5f; + sp80 = temp_f24 * 150.0f; + temp_f28 = this->actor.scale.x * 600.0f; + temp = 0x10000 / sp80; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093E938.s") + for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { + temp_s3 = (u32)Rand_Next() >> 0x10; + temp_f20 = Math_SinS(temp_s3); + temp_f22 = Math_CosS(temp_s3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093E9B0.s") + spC0.x = Math_SinS(phi_s0); + spC0.z = Math_CosS(phi_s0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EAB0.s") + spB4.x = 2.0f * spC0.x; + spB4.y = (2.0f * Rand_ZeroOne()) + 1.0f; + spB4.z = 2.0f * spC0.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EAD4.s") + spC0.x *= temp_f22 * temp_f28; + spC0.y = temp_f20 * temp_f28; + spC0.z *= (temp_f22 * temp_f28); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EB58.s") + spC0.x += this->actor.world.pos.x; + spC0.y += this->actor.world.pos.y; + spC0.z += this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EB74.s") + spA8.x = spB4.x * -0.02f; + spA8.y = spB4.y * -0.05f; + spA8.z = spB4.z * -0.02f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EC50.s") + EffectSsIceSmoke_Spawn(globalCtx, &spC0, &spB4, &spA8, + ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f24 * 10.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093ECD4.s") + for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { + temp_f20 = (Rand_ZeroOne() * (450.0f * this->actor.scale.x)) + 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093ED80.s") + spC0.x = Math_SinS(phi_s0); + spC0.z = Math_CosS(phi_s0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EDB0.s") + spB4.x = spC0.x * 30.0f * temp_f24; + spB4.y = 0.0f; + spB4.z = spC0.z * 30.0f * temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EDD8.s") + spA8.x = spB4.x * -0.02f; + spA8.y = 0.03f; + spA8.z = spB4.z * -0.02f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EE18.s") + spC0.x = (spC0.x * temp_f20) + this->actor.world.pos.x; + spC0.y = (Rand_ZeroOne() * 20.0f) + this->actor.world.pos.y; + spC0.z = (spC0.z * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EE64.s") + EffectSsIceSmoke_Spawn(globalCtx, &spC0, &spB4, &spA8, (s32)(Rand_ZeroOne() * 1400.0f * temp_f24) + 100); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EEBC.s") +void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s32 i; + s32 sp120 = ENGOROIWA_GET_C000(&this->actor); + s32 phi_s0; + s32 phi_s3; + Vec3f sp10C; + Vec3f sp100; + Vec3f spF4; + s32 phi_s6; + f32 spEC; + Gfx* phi_s1; + s16 phi_s7; + f32 phi_f22; + s32 phi_s2; + s32 spD8; + s16 spA8; + f32 temp_f20; + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EEDC.s") + if (this->actor.flags & 0x40) { + spEC = (this->actor.scale.x + 0.1f) * 0.5f; + sp10C.x = this->actor.world.pos.x; + sp10C.y = this->actor.world.pos.y + this->unk_1DC; + sp10C.z = this->actor.world.pos.z; + if (1) {} + spD8 = spEC * 150.0f; + spA8 = 0x10000 / spD8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093EF54.s") + for (i = 0, phi_s7 = 0; i < spD8; i++, phi_s7 += spA8) { + if ((i & 3) == 0) { + phi_f22 = 1.0f; + phi_s1 = D_80942E0C[sp120][2]; + phi_s2 = -0x118; + phi_s3 = 0; + phi_s0 = 0x40; + } else { + phi_s2 = -0x190; + if ((i & 3) == 1) { + phi_s1 = D_80942E0C[sp120][1]; + phi_s2 = -0x154; + phi_s3 = 0; + phi_f22 = 0.9f; + if (Rand_ZeroOne() < 0.4f) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + } else { + phi_s1 = D_80942E0C[sp120][0]; + phi_s3 = 1; + phi_f22 = 0.8f; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093F198.s") + temp_f20 = (Rand_ZeroOne() * this->actor.scale.x * 400.0f) + 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093F34C.s") + sp100.x = Math_SinS((s32)(Rand_ZeroOne() * spA8) + phi_s7) * temp_f20; + sp100.y = (Rand_ZeroOne() - 0.4f) * temp_f20 * 1.6666666f; + sp100.z = Math_CosS((s32)(Rand_ZeroOne() * spA8) + phi_s7) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093F498.s") + spF4.x = sp100.x * 0.16f * phi_f22; + spF4.y = (Rand_ZeroOne() * 16.0f) + 3.0f; + spF4.z = sp100.z * 0.16f * phi_f22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093F5EC.s") + Math_Vec3f_Sum(&sp100, &sp10C, &sp100); + EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, + ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, 0xEF, + phi_s1); + if (this->unk_1E6 == 0) { + sp100.x += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.x; + sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; + sp100.z += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093F6F8.s") + func_800B0E48(globalCtx, &sp100, &D_80942E48, &D_80942E54, &D_80942E30[sp120], &D_80942E3C[sp120], + (Rand_ZeroOne() * 50.0f) + (400.0f * spEC), (Rand_ZeroOne() * 60.0f) + (500.0f * spEC)); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") + if (this->unk_1E6 != 0) { + func_8093FC6C(this, globalCtx); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FC00.s") +#ifdef NON_MATCHING +// Stack +void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { + Gfx* phi_s7; + Vec3f sp100; + Vec3f spF4; + Vec3f spE8; + f32 temp_f20; + s32 phi_fp; + s32 j; + s32 i; + s32 phi_s0; + s32 spD0; + s16 spCE; + s16 spC8; + f32 spB0; + f32 spAC; + s16 spA8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FC6C.s") + spD0 = (s32)(arg5 * 35.0f) + 6; + temp_f20 = (arg5 + 0.1f) * 0.5f; + spB0 = 550.0f * temp_f20; + spAC = 500.0f * temp_f20; + spA8 = 0x10000 / spD0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940090.s") + for (i = 0, spCE = 0; i < spD0; i++, spCE += spA8) { + temp_f20 = (Rand_ZeroOne() * arg5 * 500.0f) + 20.0f; + sp100.x = Math_SinS((s32)(Rand_ZeroOne() * spA8) + spCE) * temp_f20; + sp100.y = (Rand_ZeroOne() - 0.4f) * temp_f20 * 1.6666666f; + sp100.z = Math_CosS((s32)(Rand_ZeroOne() * spA8) + spCE) * temp_f20; + + spF4.x = sp100.x * 0.19f; + spF4.y = (Rand_ZeroOne() * 16.0f) + 3.0f; + spF4.z = sp100.z * 0.19f; + + Math_Vec3f_Sum(&sp100, arg1, &sp100); + + if ((i & 3) == 0) { + phi_s7 = arg2[0]; + phi_fp = -0x190; + spC8 = 1; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else { + spC8 = 0; + if ((i & 3) == 1) { + phi_fp = -0x154; + phi_s7 = arg2[1]; + if (Rand_ZeroOne() < 0.4f) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + } else { + phi_fp = -0x118; + phi_s0 = 0x40; + phi_s7 = arg2[2]; + } + } + + EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, + ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, 0xEF, phi_s7); + + for (j = 0; j < 2; j++) { + spE8.x = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.x; + spE8.y = (((Rand_ZeroOne() * 1300.0f) - 500.0f) * arg5) + sp100.y; + spE8.z = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.z; + func_800B0E48(globalCtx, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 80.0f) + spB0, + (Rand_ZeroOne() * 70.0f) + spAC); + } + } +} +#else +void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940588.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940A1C.s") +void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { + s32 i; + Vec3f spE8; + Vec3f spDC; + s32 phi_s2; + s32 phi_s0; + s32 phi_s3; + Gfx* phi_s1; + s32 spC8; + f32 temp_f20; + f32 spAC; + s16 spA8; + s16 phi_s6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940E38.s") + spC8 = (s32)(arg5 * 35.0f) + 5; + temp_f20 = (arg5 + 0.1f) * 0.5f; + spAC = 600.0f * temp_f20; + spA8 = 0x10000 / spC8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941060.s") + for (i = 0, phi_s6 = 0; i < spC8; i++, phi_s6 += spA8) { + temp_f20 = (Rand_ZeroOne() * arg5 * 400.0f) + 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941274.s") + spE8.x = Math_SinS((s32)(Rand_ZeroOne() * spA8) + phi_s6) * temp_f20; + spE8.y = (Rand_ZeroOne() - 0.2f) * temp_f20 * 0.8f; + spE8.z = Math_CosS((s32)(Rand_ZeroOne() * spA8) + phi_s6) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Init.s") + spDC.x = spE8.x * 0.17f; + spDC.y = (Rand_ZeroOne() * 14.0f) + 3.0f; + spDC.z = spE8.z * 0.17f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Destroy.s") + Math_Vec3f_Sum(&spE8, arg1, &spE8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8094156C.s") + if ((i & 3) == 0) { + phi_s1 = arg2[2]; + phi_s2 = -0x118; + phi_s3 = 0; + phi_s0 = 0x40; + } else { + phi_s3 = 1; + if ((i & 3) == 1) { + phi_s1 = arg2[1]; + phi_s2 = -0x154; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else { + phi_s1 = arg2[0]; + phi_s2 = -0x190; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_809419D0.s") + EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, + ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, 0xEF, phi_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941A10.s") + spE8.x += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; + spE8.y += ((Rand_ZeroOne() * 800.0f) - 250.0f) * arg5; + spE8.z += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941DB4.s") + func_800B0E48(globalCtx, &spE8, &D_80942E48, &D_80942E54, arg3, arg4, (Rand_ZeroOne() * 60.0f) + spAC, + (Rand_ZeroOne() * 30.0f) + spAC); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941E28.s") +void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { + f32 sp5C; + s32 pad; + f32 sp54; + Vec3f sp48; + s16 sp46; + s16 temp_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941EB4.s") + if (this->actor.flags & 0x40) { + if (this->actor.xzDistToPlayer < 1000.0f) { + sp5C = (1000.0f - this->actor.xzDistToPlayer) * 0.0012f * (this->actor.speedXZ * 0.1f); + if (Rand_ZeroOne() < sp5C) { + this->unk_1CE += 20000; + sp46 = (s32)Rand_ZeroFloat(20000.0f) + this->unk_1CE; + temp_a0 = sp46 - this->actor.world.rot.y; + if (ABS(temp_a0) < 0x4000) { + sp54 = Math_CosS(temp_a0) * 1.6f * this->unk_1DC; + } else { + sp54 = this->unk_1DC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941F10.s") + sp48.x = (Math_SinS(sp46) * sp54) + this->actor.world.pos.x; + sp48.y = this->actor.world.pos.y + 20.0f; + sp48.z = (Math_CosS(sp46) * sp54) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941F54.s") + func_800B0E48(globalCtx, &sp48, &D_80942E48, &D_80942E54, &D_80942E38, &D_80942E44, + (Rand_ZeroOne() * 600.0f) + (600.0f * (this->actor.scale.x + 0.1f) * 0.5f), + (s32)(Rand_ZeroOne() * 50.0f) + 30); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80941FA4.s") +void func_80941060(EnGoroiwa* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3s* vec = &this->collider.elements[0].info.bumper.hitPos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80942084.s") + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + vec->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + vec->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + vec->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_809420F0.s") + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_809421E0.s") + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8094220C.s") + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80942E38, &D_80942E44, (s32)(Rand_ZeroOne() * 30.0f) + 15, + (s32)(Rand_ZeroOne() * 40.0f) + 30); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_809425CC.s") +void func_80941274(EnGoroiwa* this, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_SNOWBALL_BROKEN); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80942604.s") +void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGoroiwa* this = THIS; + f32 temp_f0; + s32 params = ENGOROIWA_GET_FF(&this->actor); + s32 sp28 = params * 8; + Path* sp2C = &globalCtx->setupPathList[params]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.world.rot.x = 0; + this->actor.world.rot.z = 0; + this->actor.world.rot.y = Rand_Next() & 0xFFFF; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + func_8093E8A0(this); + func_8093E91C(this); + func_8093E9B0(this, globalCtx); + + if (sp28 == 0x7F8) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (sp2C->count < 2) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.home.rot.y >= (sp2C->count - 1)) && (this->actor.home.rot.y < 0)) { + this->actor.home.rot.y = 0; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 595.0f, func_800B3FC0, 9.4f); + this->actor.shape.shadowAlpha = 200; + func_8093EB58(this, globalCtx); + + this->unk_1D0 = (Vec3s*)Lib_SegmentedToVirtual(sp2C->points); + + func_8093EE18(this, globalCtx); + func_8093EE64(this, this->actor.home.rot.y); + func_8093EEBC(this); + func_8093EC50(this); + + if (ENGOROIWA_GET_3000(&this->actor) == ENGOROIWA_3000_2) { + temp_f0 = func_8093EB74(this, globalCtx); + + if (temp_f0 < 0.1f) { + this->unk_1E0 = 0.0f; + } else { + this->unk_1E0 = (D_80942DFC[this->unk_1E4] * ((s32)globalCtx->state.framerateDivisor * 0.5f)) / temp_f0; + this->unk_1E0 *= 0.020000001f; + if (this->unk_1E0 > 0.00037f) { + this->unk_1E0 = 0.00037f; + } else if (this->unk_1E0 < 0.00015f) { + this->unk_1E0 = 0.00015f; + } + } + } + + Effect_Add(globalCtx, &this->unk_248, 4, 0, 0, &D_80942E8C); + func_809419D0(this); +} + +void EnGoroiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGoroiwa* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); + Effect_Destroy(globalCtx, this->unk_248); +} + +s32 func_8094156C(EnGoroiwa* this, GlobalContext* globalCtx) { + Actor* actor = &this->actor; + s32 params = ENGOROIWA_GET_C000(&this->actor); + EnGoroiwaStruct* ptr; + s32 i; + s32 phi_s0_2 = false; + Vec3f sp80; + + if ((this->collider.base.acFlags & AC_HIT) && ((params == ENGOROIWA_C000_1) || (params == ENGOROIWA_C000_2))) { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { + s16 sp7E = BINANG_SUB(actor->yawTowardsPlayer, this->actor.world.rot.y); + f32 temp; + f32 temp2; + f32 temp3; + + this->unk_1CC = 50; + this->unk_1E8[0].unk_1E = BINANG_SUB(this->actor.yawTowardsPlayer, 0x4000); + this->unk_1E8[0].unk_24 = Rand_ZeroOne() * -600.0f; + this->unk_1E8[1].unk_1E = BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000); + this->unk_1E8[1].unk_24 = Rand_ZeroOne() * 600.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_1E8); i++) { + ptr = &this->unk_1E8[i]; + + ptr->unk_00.x = this->actor.world.pos.x; + ptr->unk_00.y = this->actor.world.pos.y + this->unk_1DC; + ptr->unk_00.z = this->actor.world.pos.z; + + temp = Rand_ZeroOne(); + temp2 = Math_SinS(ptr->unk_1E); + temp3 = Math_SinS(this->actor.world.rot.y); + + ptr->unk_0C = ((1.0f / D_80942DFC[this->unk_1E4]) * (temp3 * 14.0f * this->actor.speedXZ)) + + (temp2 * (temp + 5.0f)); + + ptr->unk_10 = (Rand_ZeroOne() * 11.0f) + 20.0f; + + temp = Rand_ZeroOne(); + temp2 = Math_CosS(ptr->unk_1E); + temp3 = Math_CosS(this->actor.world.rot.y); + ptr->unk_14 = ((1.0f / D_80942DFC[this->unk_1E4]) * ((temp3 * 14.0f) * this->actor.speedXZ)) + + (temp2 * (temp + 5.0f)); + + ptr->unk_1C = 0; + ptr->unk_20 = 0; + ptr->unk_22 = (s32)(Rand_ZeroOne() * 400.0f) + 1100; + + temp3 = Rand_ZeroOne(); + temp2 = Math_CosS(sp7E); + ptr->unk_26 = (s32)(temp2 * 3000.0f) + (s32)(600.0f * (temp3 - 0.5f)); + ptr->unk_2D = 0; + ptr->unk_2C = 0; + } + + func_809421E0(this); + sp80.x = this->actor.world.pos.x; + sp80.y = this->actor.world.pos.y + this->unk_1DC; + sp80.z = this->actor.world.pos.z; + func_80940588(globalCtx, &sp80, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], + this->actor.scale.x); + func_80941274(this, globalCtx); + phi_s0_2 = true; + } else if (((params == ENGOROIWA_C000_1) && + (this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x400 | 0x100))) || + ((params == ENGOROIWA_C000_2) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & + (0x80000000 | 0x800 | 0x400 | 0x100 | 0x8)))) { + this->unk_1CC = 50; + if ((params == ENGOROIWA_C000_2) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x800)) { + this->unk_1E6 = 1; + } + func_80940090(this, globalCtx); + func_80941274(this, globalCtx); + func_809425CC(this); + phi_s0_2 = true; + } else if ((params == ENGOROIWA_C000_2) && (this->unk_1E7 <= 0)) { + func_80941060(this, globalCtx); + this->unk_1E7 = 10; + } + } + + if (params == ENGOROIWA_C000_2) { + if (this->unk_1E7 > 0) { + this->unk_1E7--; + } + + if (phi_s0_2) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x20); + } + } + return phi_s0_2; +} + +void func_809419D0(EnGoroiwa* this) { + this->actionFunc = func_80941A10; + func_8093EAB0(this, 7); + this->unk_1C4 = 1.0f; +} + +void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { + static EnGoroiwaUnkFunc D_80942E94[] = { + &func_8093F498, + &func_8093F34C, + }; + static u16 D_80942E9C[][2] = { + { NA_SE_EV_BIGBALL_ROLL - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR - SFX_FLAG }, + { NA_SE_EV_BIGBALL_ROLL_2 - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR_2 - SFX_FLAG }, + { NA_SE_EV_BIGBALL_ROLL_3 - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR_3 - SFX_FLAG }, + { NA_SE_EV_BIGBALL_ROLL - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR - SFX_FLAG }, + }; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 sp44 = ENGOROIWA_GET_400(&this->actor); + s32 sp40 = ENGOROIWA_GET_3000(&this->actor); + s16 y; + s32 pad2; + + if (!func_8094156C(this, globalCtx)) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { + s32 sp34 = this->actor.home.rot.z & 3; + + if (sp34 == 2) { + func_80940090(this, globalCtx); + if (sp40 == ENGOROIWA_3000_2) { + func_8093E8A0(this); + func_8093E91C(this); + } + func_80941274(this, globalCtx); + func_8093EDD8(this, globalCtx); + func_8093EE64(this, 0); + func_8093EEBC(this); + } else { + this->unk_1E5 &= ~8; + y = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if ((y > -0x4000) && (y < 0x4000)) { + this->unk_1E5 |= 8; + if (sp44 || (sp34 != 1)) { + func_8093EDB0(this); + } + } + } + + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + + if (sp34 == 2) { + func_80941EB4(this); + } else if (!sp44) { + func_80941EB4(this); + } else { + func_80941DB4(this); + } + + func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + + if ((sp34 == 1) || (sp34 == 2)) { + this->unk_1CC = 50; + } + } else { + if (D_80942E94[sp44](this)) { + s32 sp30 = ENGOROIWA_GET_300(&this->actor); + + if ((sp30 == ENGOROIWA_300_1) && ((this->unk_1D8 == 0) || (this->unk_1D8 == this->unk_1D4))) { + func_80940090(this, globalCtx); + func_80941274(this, globalCtx); + } + + if (((sp30 == ENGOROIWA_300_1) || (sp30 == ENGOROIWA_300_0)) && (sp40 == ENGOROIWA_3000_2) && + ((this->unk_1D8 == 0) || (this->unk_1D8 == this->unk_1D4))) { + func_8093E8A0(this); + func_8093E91C(this); + } + + func_8093FC00(this); + + if ((sp30 == ENGOROIWA_300_3) && ((this->unk_1D6 == 0) || (this->unk_1D6 == this->unk_1D4))) { + func_80941EB4(this); + } else if (!sp44 && (this->unk_1D6 != 0) && (this->unk_1D6 != this->unk_1D4)) { + sp30 = func_8093EEDC(this); + if (sp30 > 0) { + func_80941F54(this); + } else if (sp30 < 0) { + func_80942084(this); + } else { + func_809419D0(this); + } + } else { + func_809419D0(this); + } + } + } + + if (this->actor.bgCheckFlags & 1) { + Audio_PlayActorSound2(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); + } + } +} + +void func_80941DB4(EnGoroiwa* this) { + this->actionFunc = func_80941E28; + func_8093EAB0(this, 6); + this->actor.gravity = -0.86f; + this->actor.minVelocityY = -15.0f; + this->actor.speedXZ *= 0.15f; + this->actor.velocity.y = 5.0f; + this->unk_1C4 = 1.0f; +} + +void func_80941E28(EnGoroiwa* this, GlobalContext* globalCtx) { + func_8093F34C(this); + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + if ((this->unk_1E5 & 8) && ((this->actor.home.rot.z & 3) == 1)) { + func_8093EDB0(this); + } + func_80941EB4(this); + } +} + +void func_80941EB4(EnGoroiwa* this) { + static s16 D_80942EAC[] = { 20, 6, 20 }; + + this->actionFunc = func_80941F10; + this->actor.speedXZ = 0.0f; + func_8093EAB0(this, 6); + this->unk_1C8 = D_80942EAC[this->actor.home.rot.z & 3]; + this->unk_1C4 = 0.0f; +} + +void func_80941F10(EnGoroiwa* this, GlobalContext* globalCtx) { + if (!func_8094156C(this, globalCtx)) { + if (this->unk_1C8 > 0) { + this->unk_1C8--; + } else { + func_809419D0(this); + } + } +} + +void func_80941F54(EnGoroiwa* this) { + this->actionFunc = func_80941FA4; + func_8093EAB0(this, 7); + this->unk_1C4 = 0.0f; + this->actor.velocity.y = fabsf(this->actor.speedXZ) * 0.1f; +} + +void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_8094156C(this, globalCtx) == 0) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { + this->unk_1CC = 50; + } + } else if (func_8093F5EC(this)) { + func_8093FC00(this); + func_809419D0(this); + this->actor.speedXZ = 0.0f; + } + } +} + +void func_80942084(EnGoroiwa* this) { + this->actionFunc = func_809420F0; + func_8093EAB0(this, 7); + this->unk_1C4 = 0.3f; + this->unk_1CA = 0; + this->actor.velocity.y = fabsf(this->actor.speedXZ) * -0.3f; + this->unk_1E5 |= 0x10; + this->unk_1E5 &= ~0x20; +} + +void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_8094156C(this, globalCtx) == 0) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { + this->unk_1CC = 50; + } + } else if (func_8093F6F8(this, globalCtx)) { + func_8093FC00(this); + func_809419D0(this); + this->unk_1E5 &= ~0x10; + this->actor.speedXZ = 0.0f; + } + } +} + +void func_809421E0(EnGoroiwa* this) { + this->actionFunc = func_8094220C; + func_8093EAB0(this, 0); +} + +void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 pad; + EnGoroiwaStruct* ptr; + s32 i; + s32 spD0; + Vec3f spC4; + Vec3f spB8; + f32 phi_f12; + f32 temp_f20; + f32 spAC; + s32 params; + Vec3f sp9C; + s16 sp9A; + + for (i = 0; i < ARRAY_COUNT(this->unk_1E8); i++) { + ptr = &this->unk_1E8[i]; + + if (!(ptr->unk_2D & 1)) { + ptr->unk_10 -= 6.0f; + if (ptr->unk_10 < -20.0f) { + ptr->unk_10 = -20.0f; + } + ptr->unk_00.x += ptr->unk_0C; + ptr->unk_00.y += ptr->unk_10; + ptr->unk_00.z += ptr->unk_14; + + ptr->unk_1C += ptr->unk_22; + ptr->unk_1E += ptr->unk_24; + ptr->unk_20 += ptr->unk_26; + + spC4.x = ptr->unk_00.x; + spC4.y = ptr->unk_00.y + 25.0f; + spC4.z = ptr->unk_00.z; + + ptr->unk_18 = func_800C411C(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); + + if (ptr->unk_10 <= 0.0f) { + Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, 0); + Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); + temp_f20 = this->unk_1DC * 0.9f; + + if (spB8.y > 0.0f) { + if (Math3D_AngleBetweenVectors(&D_80942E60, &spB8, &spAC)) { + phi_f12 = 1.0f; + } else { + phi_f12 = 1.0f - SQ(spAC); + } + + if (phi_f12 <= 0.0f) { + temp_f20 = 0.0f; + } else { + temp_f20 *= sqrtf(phi_f12); + } + } + + if (((ptr->unk_00.y + (this->unk_1DC - temp_f20)) < ptr->unk_18) || + (ptr->unk_18 < (BGCHECK_Y_MIN + 10))) { + params = ENGOROIWA_GET_C000(&this->actor); + ptr->unk_2D |= 1; + sp9C.x = ptr->unk_00.x; + sp9C.y = (ptr->unk_00.y - ptr->unk_10) + 10.0f; + sp9C.z = ptr->unk_00.z; + func_80940A1C(globalCtx, &sp9C, D_80942E0C[params], &D_80942E30[params], &D_80942E3C[params], + this->actor.scale.x); + } + } + } + } + + if ((this->unk_1E8[0].unk_2D & 1) && (this->unk_1E8[1].unk_2D & 1)) { + func_809425CC(this); + return; + } + + sp9A = this->actor.shape.shadowAlpha; + Math_StepToS(&sp9A, 0, 40); + this->actor.shape.shadowAlpha = sp9A; + + for (i = 0; i < ARRAY_COUNT(this->unk_1E8); i++) { + ptr = &this->unk_1E8[i]; + + if (ptr->unk_2D & 1) { + ptr->unk_2C = 0; + } else { + sp9A = ptr->unk_2C; + Math_StepToS(&sp9A, 160, 24); + ptr->unk_2C = sp9A; + } + } +} + +void func_809425CC(EnGoroiwa* this) { + this->actionFunc = func_80942604; + func_8093EAB0(this, 0); + this->unk_1C8 = 100; +} + +void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.shape.shadowAlpha; + + Math_StepToS(&sp22, 0, 40); + this->actor.shape.shadowAlpha = sp22; + if (this->unk_1C8 > 0) { + this->unk_1C8--; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +#ifdef NON_MATCHING +// stack for params and colCtx +void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGoroiwa* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 sp60; + s32 sp5C = false; + Vec3f sp50; + f32 sp4C; + s32 sp48 = true; + + if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { + if (this->unk_1CC > 0) { + this->unk_1CC--; + } + + if ((ENGOROIWA_GET_3000(&this->actor) == ENGOROIWA_3000_2) && (this->actor.bgCheckFlags & 1) && + (this->actionFunc == func_80941A10) && (this->actor.speedXZ > 2.0f)) { + Math_StepToF(&this->actor.scale.x, 0.16f, + (this->actor.xzDistToPlayer < 400.0f) ? this->unk_1E0 * 1.4f : this->unk_1E0); + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + func_8093E91C(this); + sp5C = true; + + if (this->actor.flags & 0x40) { + if (this->actor.floorPoly != NULL) { + u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + + if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { + if (!(this->unk_1E5 & 0x40)) { + sp50.x = this->actor.world.pos.x; + sp50.y = this->actor.floorHeight; + sp50.z = this->actor.world.pos.z; + sp4C = (((Rand_ZeroOne() * 36.0f) + 250.0f) * this->actor.scale.x) + 10.0f; + func_800AE930(&globalCtx->colCtx, Effect_GetParams(this->unk_248), &sp50, sp4C, + this->actor.world.rot.y, this->actor.floorPoly, this->actor.floorBgId); + } + sp48 = false; + } + } + } + } + + if (sp48) { + func_800AEF44(Effect_GetParams(this->unk_248)); + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + func_8093EC50(this); + + if (sp5C) { + func_80940E38(this, globalCtx); + } + + switch (ENGOROIWA_GET_400(&this->actor)) { + case ENGOROIWA_400_1: + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); + break; + + case ENGOROIWA_400_0: + sp50.x = this->actor.world.pos.x; + sp50.y = this->actor.world.pos.y + 50.0f; + sp50.z = this->actor.world.pos.z; + this->actor.floorHeight = + func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp60, &this->actor, &sp50); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + this->actor.floorBgId = sp60; + if (this->actor.world.pos.y <= (this->actor.floorHeight + 2.0f)) { + this->actor.bgCheckFlags |= 1; + } else { + this->actor.bgCheckFlags &= ~1; + } + } else { + this->actor.bgCheckFlags &= ~1; + this->actor.floorBgId = 50; + } + break; + } + + func_8093FAA4(this, globalCtx); + + if (this->actor.flags & 0x40) { + s32 params = ENGOROIWA_GET_C000(&this->actor); + + func_8093E938(this); + + if ((this->unk_1E5 & 1) && (this->unk_1CC <= 0) && + (!(player->stateFlags3 & 0x2000000) || (player->transformation != PLAYER_FORM_GORON) || + ((params != ENGOROIWA_C000_1) && (params != ENGOROIWA_C000_2)))) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.atFlags &= ~AT_HIT; + } + + if (this->unk_1E5 & 2) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + if ((this->unk_1E5 & 4) && (this->unk_1CC <= 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.ocFlags1 &= ~OC1_HIT; + } + } else { + this->collider.base.atFlags &= ~AT_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.acFlags &= ~AC_HIT; + } + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Update.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80942B1C.s") +void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s32 i; + EnGoroiwaStruct* ptr; + s32 params = ENGOROIWA_GET_C000(&this->actor); + Gfx* phi_fp; + MtxF sp88; + Vec3s sp80; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Draw.s") + if (params == ENGOROIWA_C000_1) { + phi_fp = D_060032E0; + } else { + phi_fp = D_060082D0; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_1E8); i++) { + ptr = &this->unk_1E8[i]; + + if (!(ptr->unk_2D & 1)) { + sp80.x = ptr->unk_1C; + sp80.y = ptr->unk_1E; + sp80.z = ptr->unk_20; + + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + func_800BDFC0(globalCtx, phi_fp); + + if ((ptr->unk_28 != 0) && (ptr->unk_2C > 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, + 0, COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); + + func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); + Matrix_SetCurrentState(&sp88); + Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, 1); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_04076BC0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} + +void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80942EB4[] = { + D_06005C20, + D_06003B40, + D_06008B90, + }; + EnGoroiwa* this = THIS; + s32 params = ENGOROIWA_GET_C000(&this->actor); + + if (this->actionFunc == func_8094220C) { + func_80942B1C(this, globalCtx); + } else if (this->actionFunc != func_80942604) { + func_800BDFC0(globalCtx, D_80942EB4[params]); + } +} diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h index dfa60adf1..2a3ae2505 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h @@ -6,12 +6,79 @@ struct EnGoroiwa; typedef void (*EnGoroiwaActionFunc)(struct EnGoroiwa*, GlobalContext*); +typedef s32 (*EnGoroiwaUnkFunc)(struct EnGoroiwa*); + +#define ENGOROIWA_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) +#define ENGOROIWA_GET_3000(thisx) (((thisx)->params >> 0xC) & 3) +#define ENGOROIWA_GET_400(thisx) (((thisx)->params >> 0xA) & 1) +#define ENGOROIWA_GET_300(thisx) (((thisx)->params >> 0x8) & 3) +#define ENGOROIWA_GET_FF(thisx) ((thisx)->params & 0xFF) + +enum { + /* 0 */ ENGOROIWA_300_0, + /* 1 */ ENGOROIWA_300_1, + /* 3 */ ENGOROIWA_300_3 = 3, +}; + +enum { + /* 0 */ ENGOROIWA_400_0, + /* 1 */ ENGOROIWA_400_1, +}; + +enum { + /* 0 */ ENGOROIWA_3000_0, + /* 1 */ ENGOROIWA_3000_1, + /* 2 */ ENGOROIWA_3000_2, +}; + +enum { + /* 1 */ ENGOROIWA_C000_1 = 1, + /* 2 */ ENGOROIWA_C000_2, +}; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ CollisionPoly* unk_28; + /* 0x2C */ u8 unk_2C; + /* 0x2D */ u8 unk_2D; +} EnGoroiwaStruct; // size = 0x30 typedef struct EnGoroiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ EnGoroiwaActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0xA4]; + /* 0x01A8 */ Vec3f unk_1A8; + /* 0x01B4 */ Vec3f unk_1B4; + /* 0x01C0 */ f32 unk_1C0; + /* 0x01C4 */ f32 unk_1C4; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CA */ s16 unk_1CA; + /* 0x01CC */ s16 unk_1CC; + /* 0x01CE */ s16 unk_1CE; + /* 0x01D0 */ Vec3s* unk_1D0; + /* 0x01D4 */ s16 unk_1D4; + /* 0x01D6 */ s16 unk_1D6; + /* 0x01D8 */ s16 unk_1D8; + /* 0x01DA */ s16 unk_1DA; + /* 0x01DC */ f32 unk_1DC; + /* 0x01E0 */ f32 unk_1E0; + /* 0x01E4 */ s8 unk_1E4; + /* 0x01E5 */ u8 unk_1E5; + /* 0x01E6 */ s8 unk_1E6; + /* 0x01E7 */ s8 unk_1E7; + /* 0x01E8 */ EnGoroiwaStruct unk_1E8[2]; + /* 0x0248 */ s32 unk_248; } EnGoroiwa; // size = 0x24C extern const ActorInit En_Goroiwa_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 0c7b23172..75a9b5cdc 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2388,6 +2388,18 @@ D_06014D00 = 0x06014D00; D_060032E0 = 0x060032E0; D_060082D0 = 0x060082D0; +D_06005C20 = 0x06005C20; +D_06003B40 = 0x06003B40; +D_06008B90 = 0x06008B90; +D_060042B0 = 0x060042B0; +D_06004960 = 0x06004960; +D_06004EF0 = 0x06004EF0; +D_060003B0 = 0x060003B0; +D_060028E0 = 0x060028E0; +D_06002D70 = 0x06002D70; +D_060072F0 = 0x060072F0; +D_060077D0 = 0x060077D0; +D_06007C60 = 0x06007C60; // ovl_En_Grasshopper From 418e09bf6f7ecfef792cbbe3e85f54b077038e17 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 4 Nov 2021 22:30:05 +0000 Subject: [PATCH 78/86] En_Floormas (#307) * En_Floormas * Format --- include/functions.h | 4 +- spec | 3 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 1172 +++++++++++++++-- .../actors/ovl_En_Floormas/z_en_floormas.h | 25 +- tools/disasm/functions.txt | 4 +- 5 files changed, 1115 insertions(+), 93 deletions(-) diff --git a/include/functions.h b/include/functions.h index ba2868e61..0bb53fe0c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -538,10 +538,10 @@ void EffectSpark_Init(EffSparkParams* params, EffSparkParams* init); void EffectSpark_Destroy(EffSparkParams* params); s32 EffectSpark_Update(EffSparkParams* params); void EffectSpark_Draw(EffSparkParams* params, GraphicsContext* gfxCtx); -// void func_800AE2A0(void); +void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3); void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 sParm3, s16 sParm4); void func_800AE5A0(GlobalContext* globalCtx); -// void func_800AE5E4(void); +void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3); void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 param_3, s16 param_4); void func_800AE8EC(GlobalContext* globalCtx); void func_800AE930(CollisionContext* colCtx, s32 param_2, Vec3f* param_3, f32 param_4, s16 param_5, CollisionPoly* param_6, s32 param_7); diff --git a/spec b/spec index 90deac25b..4eb2b0eb6 100644 --- a/spec +++ b/spec @@ -1161,8 +1161,7 @@ beginseg name "ovl_En_Floormas" compress include "build/src/overlays/actors/ovl_En_Floormas/z_en_floormas.o" - include "build/data/ovl_En_Floormas/ovl_En_Floormas.data.o" - include "build/data/ovl_En_Floormas/ovl_En_Floormas.reloc.o" + include "build/src/overlays/actors/ovl_En_Floormas/ovl_En_Floormas_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index f804e398a..a1818b095 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -15,30 +15,63 @@ void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx); void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808D0B08(EnFloormas* this); void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0C14(EnFloormas* this); void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0CE4(EnFloormas* this); void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0ECC(EnFloormas* this); void func_808D0F14(EnFloormas* this, GlobalContext* globalCtx); +void func_808D0F50(EnFloormas* this); void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx); +void func_808D108C(EnFloormas* this); void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1380(EnFloormas* this, GlobalContext* globalCtx); void func_808D1458(EnFloormas* this, GlobalContext* globalCtx); +void func_808D161C(EnFloormas* this); void func_808D1650(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1740(EnFloormas* this); void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx); +void func_808D19D4(EnFloormas* this); void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1BCC(EnFloormas* this); void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1D0C(EnFloormas* this); void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx); void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx); +void func_808D1FD4(EnFloormas* this); void func_808D2040(EnFloormas* this, GlobalContext* globalCtx); +void func_808D217C(EnFloormas* this, Player* player); void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2484(EnFloormas* this); void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2700(EnFloormas* this); void func_808D2764(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2A20(EnFloormas* this); void func_808D2AA8(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2AB8(EnFloormas* this); void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx); void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx); +void func_808D2CDC(EnFloormas* this); void func_808D2D30(EnFloormas* this, GlobalContext* globalCtx); void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx); +void func_808D3754(Actor* thisx, GlobalContext* globalCtx); + +extern AnimationHeader D_06000590; +extern AnimationHeader D_06000EA4; +extern AnimationHeader D_060019CC; +extern AnimationHeader D_06002158; +extern AnimationHeader D_060039B0; +extern AnimationHeader D_060041F4; +extern Gfx D_06008688[]; +extern FlexSkeletonHeader D_06008FB0; +extern AnimationHeader D_06009244; +extern AnimationHeader D_06009520; +extern AnimationHeader D_06009DB0; +extern AnimationHeader D_0600A054; -#if 0 const ActorInit En_Floormas_InitVars = { ACTOR_EN_FLOORMAS, ACTORCAT_ENEMY, @@ -51,18 +84,29 @@ const ActorInit En_Floormas_InitVars = { (ActorFunc)EnFloormas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808D38A0 = { - { COLTYPE_HIT0, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7EFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7EFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 25, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808D38CC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static DamageTable sDamageTable = { -static DamageTable D_808D38D4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -97,144 +141,1102 @@ static DamageTable D_808D38D4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D38F4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 49, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +static Vec3f D_808D3900[] = { + { 25.0f, 45.0f, -7.0f }, { 25.0f, 40.0f, -12.0f }, { 25.0f, 35.0f, -2.0f }, + { 10.0f, 20.0f, -4.0f }, { 15.0f, 25.0f, -2.0f }, +}; -extern ColliderCylinderInit D_808D38A0; -extern CollisionCheckInfoInit D_808D38CC; -extern DamageTable D_808D38D4; -extern InitChainEntry D_808D38F4[]; +static s8 D_808D393C[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_06002158; -extern UNK_TYPE D_060039B0; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +static Color_RGBA8 D_808D3958 = { 0, 255, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/EnFloormas_Init.s") +void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnFloormas* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 pad; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/EnFloormas_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008FB0, &D_06009DB0, this->jointTable, this->morphTable, 25); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D08D0.s") + this->unk_192 = -1600; + params = ENFLOORMAS_GET_8000(&this->actor); + this->actor.params = ENFLOORMAS_GET_7FFF(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0908.s") + if (params != 0) { + this->actor.flags |= 0x80; + this->actor.draw = func_808D3754; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0930.s") + if (this->actor.params == ENFLOORMAS_GET_7FFF_10) { + this->actor.draw = NULL; + this->actor.flags &= ~1; + this->actionFunc = func_808D2AA8; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D09CC.s") + this->actor.parent = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, params + 0x10, -1, this->actor.unk20, NULL); + if (this->actor.parent == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0A48.s") + this->actor.child = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, params + 0x10, -1, this->actor.unk20, NULL); + if (this->actor.child == NULL) { + Actor_MarkForDeath(this->actor.parent); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0B08.s") + this->actor.parent->child = &this->actor; + this->actor.parent->parent = this->actor.child; + this->actor.child->parent = &this->actor; + this->actor.child->child = this->actor.parent; + func_808D0B08(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0B50.s") +void EnFloormas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0C14.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0C58.s") +void func_808D08D0(EnFloormas* this) { + this->collider.base.colType = COLTYPE_HARD; + this->collider.base.acFlags |= AC_HARD; + this->collider.info.bumper.dmgFlags &= ~0x8000; + this->unk_190 = 40; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0CE4.s") +void func_808D0908(EnFloormas* this) { + this->collider.base.colType = COLTYPE_HIT0; + this->collider.base.acFlags &= ~AC_HARD; + this->collider.info.bumper.dmgFlags |= 0x8000; + this->unk_190 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0D70.s") +void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { + if (this->actor.scale.x > 0.009f) { + this->actor.shape.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); + func_808D19D4((EnFloormas*)this->actor.child); + func_808D19D4((EnFloormas*)this->actor.parent); + func_808D19D4(this); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + func_808D1ED4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0ECC.s") +void func_808D09CC(EnFloormas* this) { + this->unk_18C = 10; + this->unk_2C8 = 0.55f; + this->unk_2CC = 0.82500005f; + this->unk_2C4 = 1.0f; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_18E = 80; + this->actor.flags &= ~(0x400 | 0x200); + func_800BCB70(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0F14.s") +void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { + if (this->unk_18C == 10) { + this->unk_18C = 0; + this->collider.base.colType = COLTYPE_HIT0; + this->unk_2C4 = 0.0f; + func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); + if (this->actor.scale.x > 0.009f) { + this->actor.flags |= 0x400; + } else { + this->actor.flags |= 0x200; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0F50.s") +void func_808D0B08(EnFloormas* this) { + Animation_PlayOnce(&this->skelAnime, &D_06009DB0); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D0B50; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D0F80.s") +void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + this->unk_190 = this->actor.yawTowardsPlayer; + func_808D108C(this); + } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000)) { + func_808D1380(this, globalCtx); + } else { + func_808D0C14(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D108C.s") +void func_808D0C14(EnFloormas* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A054, -3.0f); + this->actionFunc = func_808D0C58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D11BC.s") +void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.scale.x > 0.009f) { + func_808D0CE4(this); + } else if (this->actor.params == ENFLOORMAS_GET_7FFF_20) { + func_808D1D0C(this); + } else { + func_808D1BCC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1380.s") +void func_808D0CE4(EnFloormas* this) { + if (this->actionFunc != func_808D0F80) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &D_060041F4, 1.5f); + } else { + this->skelAnime.playSpeed = 1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1458.s") + this->unk_18E = Rand_S16Offset(2, 4); + this->actor.speedXZ = 1.5f; + this->actionFunc = func_808D0D70; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D14DC.s") +void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D161C.s") + SkelAnime_Update(&this->skelAnime); + temp_v0 = Animation_OnFrame(&this->skelAnime, 0.0f); + if ((temp_v0 != 0) && (this->unk_18E != 0)) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1650.s") + if ((temp_v0 != 0) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || + Animation_OnFrame(&this->skelAnime, 36.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1740.s") + if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsActorFacingLink(&this->actor, 0x4000)) { + func_808D0F50(this); + } else if (this->actor.bgCheckFlags & 8) { + this->unk_190 = this->actor.wallYaw; + func_808D108C(this); + } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + this->unk_190 = this->actor.yawTowardsPlayer; + func_808D108C(this); + } else if (this->unk_18E == 0) { + func_808D0ECC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D17EC.s") +void func_808D0ECC(EnFloormas* this) { + Animation_PlayOnce(&this->skelAnime, &D_06009244); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D0F14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D19D4.s") +void func_808D0F14(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + func_808D0B08(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1B44.s") +void func_808D0F50(EnFloormas* this) { + this->unk_18E = 0; + this->actor.speedXZ = 5.0f; + this->skelAnime.playSpeed = 3.0f; + this->actionFunc = func_808D0F80; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1BCC.s") +void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || + Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1C1C.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); + if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000) && + !(this->actor.bgCheckFlags & 8)) { + func_808D1380(this, globalCtx); + } else if (this->actor.xzDistToPlayer > 400.0f) { + func_808D0CE4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1D0C.s") +void func_808D108C(EnFloormas* this) { + s16 sp36 = this->unk_190 - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1D6C.s") + this->actor.speedXZ = 0.0f; + if (sp36 > 0) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06002158, -3.0f); + } else { + Animation_Change(&this->skelAnime, &D_06002158, -1.0f, Animation_GetLastFrame(&D_06002158.common), 0.0f, 2, + -3.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1ED4.s") + if (this->actor.scale.x > 0.009f) { + this->unk_190 = sp36 * (1.0f / 15.0f); + } else { + this->skelAnime.playSpeed *= 2.0f; + this->unk_190 = sp36 * (2.0f / 15.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1F7C.s") + this->actionFunc = func_808D11BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D1FD4.s") +void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { + f32 frame; + f32 sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2040.s") + if (SkelAnime_Update(&this->skelAnime)) { + func_808D0C14(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D217C.s") + if (((this->skelAnime.playSpeed > 0.0f) && Animation_OnFrame(&this->skelAnime, 21.0f)) || + ((this->skelAnime.playSpeed < 0.0f) && Animation_OnFrame(&this->skelAnime, 6.0f))) { + if (this->actor.scale.x > 0.009f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D22C8.s") + frame = this->skelAnime.curFrame; + if ((frame >= 7.0f) && (frame < 22.0f)) { + sp30 = Math_SinS(this->actor.shape.rot.y + 0x4268); + sp2C = Math_CosS(this->actor.shape.rot.y + 0x4268); + this->actor.shape.rot.y += this->unk_190; + this->actor.world.pos.x -= this->actor.scale.x * 2700.0f * (Math_SinS(this->actor.shape.rot.y + 0x4268) - sp30); + this->actor.world.pos.z -= this->actor.scale.x * 2700.0f * (Math_CosS(this->actor.shape.rot.y + 0x4268) - sp2C); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2484.s") +void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &D_06009520, 3.0f, 0.0f, Animation_GetLastFrame(&D_06009520.common), 2, -3.0f); + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + func_808D08D0(this); + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); + this->actionFunc = func_808D1458; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D24F0.s") +void func_808D1458(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + func_808D161C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2700.s") + this->actor.shape.rot.x += 0x140; + this->actor.world.pos.y += 10.0f; + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xAAA); + Math_StepToS(&this->unk_192, 1200, 100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2764.s") +void func_808D14DC(EnFloormas* this, GlobalContext* globalCtx) { + Vec3f sp34; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2A20.s") + sp34.x = this->actor.world.pos.x; + sp34.z = this->actor.world.pos.z; + sp34.y = this->actor.floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2AA8.s") + sp28.y = 2.0f; + sp28.x = Math_SinS(this->actor.shape.rot.y + 0x6000) * 7.0f; + sp28.z = Math_CosS(this->actor.shape.rot.y + 0x6000) * 7.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2AB8.s") + func_800B1210(globalCtx, &sp34, &sp28, &D_801D15B0, 0x1C2, 0x64); + sp28.x = Math_SinS(this->actor.shape.rot.y - 0x6000) * 7.0f; + sp28.z = Math_CosS(this->actor.shape.rot.y - 0x6000) * 7.0f; + func_800B1210(globalCtx, &sp34, &sp28, &D_801D15B0, 0x1C2, 0x64); + func_800B9010(&this->actor, NA_SE_EN_FLOORMASTER_SLIDING - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2AF4.s") +void func_808D161C(EnFloormas* this) { + this->unk_18E = 25; + this->actor.gravity = -0.15f; + this->actor.speedXZ = 0.5f; + this->actionFunc = func_808D1650; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2B18.s") +void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { + f32 temp_f0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2C08.s") + if (this->unk_18E != 0) { + this->unk_18E--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2CDC.s") + Math_StepToF(&this->actor.speedXZ, 15.0f, SQ(this->actor.speedXZ) * (1.0f / 3.0f)); + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x1680, 0x140); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2D30.s") + temp_f0_2 = this->actor.world.pos.y - this->actor.floorHeight; + if (temp_f0_2 < 10.0f) { + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2D6C.s") + if (temp_f0_2 < 12.0f) { + func_808D14DC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2DC0.s") + if ((this->actor.bgCheckFlags & 8) || (this->unk_18E == 0)) { + func_808D1740(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D2E34.s") +void func_808D1740(EnFloormas* this) { + Animation_Change(&this->skelAnime, &D_060019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { + this->unk_18E = 30; + } else { + this->unk_18E = 45; + } + this->actor.gravity = -1.0f; + this->actionFunc = func_808D17EC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/EnFloormas_Update.s") +void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { + s32 sp24 = this->actor.bgCheckFlags & 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D3488.s") + if (this->actor.bgCheckFlags & 2) { + if (this->actor.params != ENFLOORMAS_GET_7FFF_40) { + func_808D0908(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D34C4.s") + if (this->actor.velocity.y < -4.0f) { + if (this->actor.scale.x > 0.009f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_LAND); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/EnFloormas_Draw.s") + if (this->actor.bgCheckFlags & 8) { + this->actor.speedXZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Floormas/func_808D3754.s") + if (sp24 != 0) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); + } + + if ((this->actor.speedXZ > 0.0f) && ((this->actor.world.pos.y - this->actor.floorHeight) < 12.0f)) { + func_808D14DC(this, globalCtx); + } + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_18E != 0) { + this->unk_18E--; + } + + if ((this->unk_18E == 0) && (sp24 != 0)) { + if (this->skelAnime.endFrame < 45.0f) { + this->skelAnime.endFrame = Animation_GetLastFrame(&D_060019CC.common); + } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { + func_808D2700(this); + } else { + func_808D0C14(this); + this->unk_194 = 50; + } + } + } + + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x140); + Math_StepToS(&this->unk_192, -1600, 100); +} + +void func_808D19D4(EnFloormas* this) { + Actor* parent; + + this->actor.colorFilterTimer = 0; + this->unk_2C4 = 0.0f; + Actor_SetScale(&this->actor, 0.004f); + this->actor.flags |= 0x10; + if ((this->actor.flags & 0x80) == 0x80) { + this->actor.draw = func_808D3754; + } else { + this->actor.draw = EnFloormas_Draw; + } + + parent = this->actor.parent; + this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; + this->actor.world.pos = parent->world.pos; + this->actor.params = ENFLOORMAS_GET_7FFF_10; + Animation_Change(&this->skelAnime, &D_060019CC, 1.0f, 41.0f, Animation_GetLastFrame(&D_060019CC.common), 2, 0.0f); + this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; + this->collider.dim.height = sCylinderInit.dim.height * 0.6f; + this->actor.flags &= ~0x400; + this->actor.flags |= 0x200; + this->actor.colChkInfo.health = 1; + this->actor.speedXZ = 4.0f; + this->actor.velocity.y = 7.0f; + this->actionFunc = func_808D1B44; +} + +void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 1) { + if (SkelAnime_Update(&this->skelAnime)) { + this->actor.flags |= 1; + this->unk_194 = 50; + func_808D0C14(this); + } + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + } + if (this->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + } +} + +void func_808D1BCC(EnFloormas* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &D_060041F4, 4.5f); + this->actor.speedXZ = 5.0f; + this->actionFunc = func_808D1C1C; +} + +void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->unk_194 != 0) { + this->unk_194--; + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + + if (this->unk_194 == 0) { + func_808D1D0C(this); + } else if (this->actor.bgCheckFlags & 8) { + this->unk_190 = this->actor.wallYaw; + func_808D108C(this); + } else if (this->actor.xzDistToPlayer < 120.0f) { + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 0x38E); + } +} + +void func_808D1D0C(EnFloormas* this) { + if (this->actionFunc != func_808D1C1C) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &D_060041F4, 4.5f); + } + this->actor.speedXZ = 5.0f; + this->actionFunc = func_808D1D6C; +} + +void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx) { + Actor* sp2C; + s32 flags; + + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + } + + flags = this->actor.bgCheckFlags & 8; + if (flags) { + this->unk_190 = this->actor.wallYaw; + func_808D108C(this); + } else if (this->actor.params == ENFLOORMAS_GET_7FFF_20) { + if (this->actor.parent->params == ENFLOORMAS_GET_7FFF_40) { + sp2C = this->actor.parent; + } else if (this->actor.child->params == ENFLOORMAS_GET_7FFF_40) { + sp2C = this->actor.child; + } else { + this->actor.params = ENFLOORMAS_GET_7FFF_10; + return; + } + + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, sp2C), 0x38E); + + if (Actor_XZDistanceBetweenActors(&this->actor, sp2C) < 80.0f) { + func_808D2484(this); + } + } else { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); + if (this->actor.xzDistToPlayer < 80.0f) { + func_808D1FD4(this); + } + } +} + +void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx) { + Vec3f sp34; + + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + sp34.x = this->actor.world.pos.x; + sp34.y = this->actor.world.pos.y + 15.0f; + sp34.z = this->actor.world.pos.z; + func_800B3030(globalCtx, &sp34, &D_801D15B0, &D_801D15B0, 150, -10, 2); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = func_808D1F7C; +} + +void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + func_808D2A20(this); + } + this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; +} + +void func_808D1FD4(EnFloormas* this) { + Animation_Change(&this->skelAnime, &D_060019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D2040; +} + +void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame < 20.0f) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); + } else if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 7.0f; + } else if (this->actor.bgCheckFlags & 2) { + this->unk_18E = 50; + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + func_808D1740(this); + } else if ((this->actor.playerHeightRel < -10.0f) && (this->collider.base.ocFlags1 & OC1_HIT) && + (&player->actor == this->collider.base.oc)) { + globalCtx->grabPlayer(globalCtx, player); + func_808D217C(this, player); + } +} + +void func_808D217C(EnFloormas* this, Player* player) { + Vec3f* ptr; + u8 playerForm; + + Animation_Change(&this->skelAnime, &D_060019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); + this->actor.flags &= ~1; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_808D08D0(this); + playerForm = gSaveContext.playerForm; + ptr = &D_808D3900[playerForm]; + this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); + this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); + this->actor.home.pos.z = ptr->z * Math_CosS(this->actor.shape.rot.y); + Math_Vec3f_Sum(&player->actor.world.pos, &this->actor.home.pos, &this->actor.world.pos); + this->actor.shape.rot.x = -0x4CE0; + this->actionFunc = func_808D22C8; +} + +void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.playSpeed > 0.0f) { + this->skelAnime.playSpeed = -1.0f; + this->skelAnime.endFrame = 36.0f; + this->skelAnime.startFrame = 45.0f; + } else { + this->skelAnime.playSpeed = 1.0f; + this->skelAnime.endFrame = 45.0f; + this->skelAnime.startFrame = 36.0f; + } + } + + Math_Vec3f_Sum(&player->actor.world.pos, &this->actor.home.pos, &this->actor.world.pos); + + if (!(player->stateFlags2 & 0x80) || (player->invincibilityTimer < 0)) { + EnFloormas* parent = (EnFloormas*)this->actor.parent; + EnFloormas* child = (EnFloormas*)this->actor.child; + + if (((parent->actionFunc == func_808D22C8) || (parent->actionFunc == func_808D2AA8)) && + ((child->actionFunc == func_808D22C8) || (child->actionFunc == func_808D2AA8))) { + parent->actor.params = ENFLOORMAS_GET_7FFF_20; + child->actor.params = ENFLOORMAS_GET_7FFF_20; + this->actor.params = ENFLOORMAS_GET_7FFF_40; + } + + this->actor.shape.rot.x = 0; + this->actor.velocity.y = 6.0f; + this->actor.flags |= 1; + this->actor.speedXZ = -3.0f; + func_808D1740(this); + } else if ((this->unk_190 % 20) == 0) { + func_800B8E58(&player->actor, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + globalCtx->damagePlayer(globalCtx, -4); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); +} + +void func_808D2484(EnFloormas* this) { + Animation_Change(&this->skelAnime, &D_060019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_808D24F0; +} + +void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { + Actor* phi_s1; + + SkelAnime_Update(&this->skelAnime); + if (this->actor.parent->params == ENFLOORMAS_GET_7FFF_40) { + phi_s1 = this->actor.parent; + } else if (this->actor.child->params == ENFLOORMAS_GET_7FFF_40) { + phi_s1 = this->actor.child; + } else { + if (this->actor.bgCheckFlags & 2) { + this->actor.params = ENFLOORMAS_GET_7FFF_10; + func_808D1740(this); + } + return; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 7.0f; + } else if (this->skelAnime.curFrame < 20.0f) { + Math_ApproachS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, phi_s1), 2, 0xE38); + } else if (((phi_s1->world.pos.y - this->actor.world.pos.y) < -10.0f) && + (fabsf(this->actor.world.pos.x - phi_s1->world.pos.x) < 10.0f) && + (fabsf(this->actor.world.pos.z - phi_s1->world.pos.z) < 10.0f)) { + func_808D2A20(this); + this->collider.base.ocFlags1 |= OC1_ON; + } else if (this->actor.bgCheckFlags & 2) { + this->actor.speedXZ = 0.0f; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + func_808D1740(this); + } + + if ((fabsf(this->actor.world.pos.x - phi_s1->world.pos.x) < 5.0f) && + (fabsf(this->actor.world.pos.z - phi_s1->world.pos.z) < 5.0f)) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); + } +} + +void func_808D2700(EnFloormas* this) { + Animation_PlayOnce(&this->skelAnime, &D_06009DB0); + this->unk_18E = 0; + this->unk_194 = 1500; + this->actor.params = ENFLOORMAS_GET_7FFF_40; + this->actor.speedXZ = 0.0f; + func_808D08D0(this); + this->actionFunc = func_808D2764; +} + +void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { + EnFloormas* parent; + EnFloormas* child; + s32 phi_a2 = 0; + f32 temp_f2; + + if (this->unk_194 != 0) { + this->unk_194--; + } + + parent = (EnFloormas*)this->actor.parent; + child = (EnFloormas*)this->actor.child; + if (this->unk_194 == 0) { + if (parent->actionFunc != func_808D2AA8) { + func_808D1ED4(parent, globalCtx); + } + if (child->actionFunc != func_808D2AA8) { + func_808D1ED4(child, globalCtx); + } + } else { + if ((parent->actionFunc != func_808D2AA8) && (parent->actionFunc != func_808D1F7C)) { + phi_a2 = 1; + } + + if ((child->actionFunc != func_808D2AA8) && (child->actionFunc != func_808D1F7C)) { + phi_a2++; + } + } + + temp_f2 = this->actor.scale.x; + + if (phi_a2 == 1) { + Math_StepToF(&this->actor.scale.x, 0.007f, 0.0005f); + } else if (phi_a2 == 0) { + Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f); + } + + this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; + + if (((temp_f2 == 0.007f) || (temp_f2 == 0.004f)) && (temp_f2 != this->actor.scale.x)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); + } + + this->collider.dim.radius = sCylinderInit.dim.radius * 100.0f * this->actor.scale.x; + this->collider.dim.height = sCylinderInit.dim.height * 100.0f * this->actor.scale.x; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.scale.x >= 0.01f) { + this->actor.flags &= ~0x10; + func_808D0908(this); + this->actor.params = ENFLOORMAS_GET_7FFF_0; + this->actor.flags &= ~0x200; + this->actor.flags |= 0x400; + this->actor.colChkInfo.health = sColChkInfoInit.health; + func_808D0C14(this); + } else if (this->unk_18E == 0) { + Animation_PlayOnce(&this->skelAnime, &D_060039B0); + this->unk_18E = 1; + } else { + Animation_PlayOnce(&this->skelAnime, &D_06009DB0); + this->unk_18E = 0; + } + } + + func_800B9010(&this->actor, NA_SE_EN_FLOORMASTER_RESTORE - SFX_FLAG); +} + +void func_808D2A20(EnFloormas* this) { + EnFloormas* parent = (EnFloormas*)this->actor.parent; + EnFloormas* child = (EnFloormas*)this->actor.child; + + this->unk_2C4 = 0.0f; + + if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { + func_808D2AB8(parent); + func_808D2AB8(child); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.draw = NULL; + this->actor.flags &= ~(0x10 | 0x1); + this->actionFunc = func_808D2AA8; + } +} + +void func_808D2AA8(EnFloormas* this, GlobalContext* globalCtx) { +} + +void func_808D2AB8(EnFloormas* this) { + this->collider.base.atFlags &= ~(AT_HIT | AT_ON); + this->collider.base.acFlags &= ~(AC_HIT | AC_ON); + this->collider.base.ocFlags1 &= ~(OC1_HIT | OC1_ON); + this->actionFunc = func_808D2AF4; +} + +void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +void func_808D2B18(EnFloormas* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000590, -3.0f); + func_800BE504(&this->actor, &this->collider); + func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 5.5f; + if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { + EnFloormas* parent = (EnFloormas*)this->actor.parent; + + if ((parent->actionFunc != func_808D2AA8) && (parent->actor.colChkInfo.health > 0)) { + func_808D2700(parent); + } else { + EnFloormas* child = (EnFloormas*)this->actor.child; + + if ((child->actionFunc != func_808D2AA8) && (child->actor.colChkInfo.health > 0)) { + func_808D2700(child); + } + } + this->actor.params = ENFLOORMAS_GET_7FFF_20; + } + this->actionFunc = func_808D2C08; +} + +void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { + if (this->actor.colChkInfo.health == 0) { + func_808D0930(this, globalCtx); + } else { + func_808D2CDC(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + if (this->actor.scale.x > 0.009f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void func_808D2CDC(EnFloormas* this) { + Animation_PlayOnce(&this->skelAnime, &D_06000EA4); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_808D2D30; +} + +void func_808D2D30(EnFloormas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + func_808D0C14(this); + } +} + +void func_808D2D6C(EnFloormas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + func_800BE504(&this->actor, &this->collider); + this->actionFunc = func_808D2DC0; +} + +void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx) { + if (this->unk_18E != 0) { + this->unk_18E--; + } + + if (this->unk_18E == 0) { + func_808D0A48(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + this->collider.base.acFlags |= AC_ON; + func_808D0930(this, globalCtx); + } else { + func_808D0C14(this); + } + } +} + +void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + func_800BE258(&this->actor, &this->collider.info); + if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if (this->actor.colChkInfo.damageEffect == 0xE) { + func_808D0908(this); + this->actor.colorFilterTimer = 0; + this->actor.colChkInfo.damage = 4; + this->unk_192 = -1600; + this->actor.gravity = -1.0f; + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.55f; + this->unk_18C = 20; + } + + if (this->collider.base.colType != COLTYPE_HARD) { + if (!Actor_ApplyDamage(&this->actor)) { + if (this->actor.scale.x > 0.009f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); + } + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->actor.flags &= ~1; + } else if (this->actor.colChkInfo.damage != 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DAMAGE); + } + + func_808D0A48(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != 0xF) { + if (this->actor.colChkInfo.damageEffect == 3) { + func_808D09CC(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_18E = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_808D2D6C(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_18E = 40; + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_808D2D6C(this); + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_18E = 40; + func_800BCB70(&this->actor, 0, 255, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2C8 = 0.55f; + this->unk_2C4 = 2.0f; + this->unk_18C = 31; + func_808D2D6C(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.55f; + this->unk_18C = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2C4 = 4.0f; + this->unk_2C8 = 0.55f; + this->unk_18C = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, + (this->actor.scale.x > 0.009f) ? CLEAR_TAG_LARGE_LIGHT_RAYS + : CLEAR_TAG_SMALL_LIGHT_RAYS); + } + func_808D2B18(this); + } + } + } + } + } +} + +void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* this = THIS; + s32 pad; + + if (this->actionFunc != func_808D2AA8) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.speedXZ *= -0.5f; + this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, -5.0f); + this->actor.velocity.y = 5.0f; + func_808D1740(this); + } + + func_808D2E34(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->actionFunc != func_808D2AF4) { + if (this->actionFunc != func_808D2C08) { + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (this->actionFunc != func_808D22C8) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->actionFunc == func_808D1650) { + this->actor.flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actionFunc != func_808D22C8) { + if ((this->actionFunc != func_808D1B44) && (this->actionFunc != func_808D2C08) && + (this->actionFunc != func_808D1F7C)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if ((this->actionFunc != func_808D24F0) || (this->skelAnime.curFrame < 20.0f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetHeight(&this->actor, this->actor.scale.x * 2500.0f); + if (this->collider.base.colType == COLTYPE_HARD) { + if (this->unk_190 != 0) { + this->unk_190--; + } + + if (this->unk_190 == 0) { + this->unk_190 = 40; + } + } + + if (this->unk_2C4 > 0.0f) { + if (this->unk_18C != 10) { + Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); + this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.275f; + this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.55f); + } else if (!Math_StepToF(&this->unk_2CC, 0.55f, 0.01375f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } + } +} + +s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + EnFloormas* this = THIS; + + if (limbIndex == 1) { + pos->z += this->unk_192; + } + return false; +} + +void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnFloormas* this = THIS; + + if (D_808D393C[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2D0[D_808D393C[limbIndex]]); + } + + if (limbIndex == 19) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_2D0[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->unk_2D0[10]); + return; + } + + if (limbIndex == 2) { + Matrix_StatePush(); + Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); + Matrix_InsertZRotation_f(M_PI / 12, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, D_06008688); + + Matrix_StatePop(); + } +} + +void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->collider.base.colType == COLTYPE_HARD) { + func_800AE2A0(globalCtx, &D_808D3958, this->unk_190 % 40, 40); + } + + POLY_OPA_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, &this->actor, POLY_OPA_DISP); + if (this->collider.base.colType == COLTYPE_HARD) { + func_800AE5A0(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), + 100.0f * (this->unk_2C8 * this->actor.scale.x), 100.0f * (this->unk_2CC * this->actor.scale.x), + this->unk_2C4, this->unk_18C); +} + +void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { + EnFloormas* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + if (this->collider.base.colType == COLTYPE_HARD) { + func_800AE5E4(globalCtx, &D_808D3958, this->unk_190 % 40, 40); + } + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnFloormas_OverrideLimbDraw, EnFloormas_PostLimbDraw, &this->actor, POLY_XLU_DISP); + if (this->collider.base.colType == COLTYPE_HARD) { + func_800AE8EC(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), + this->unk_2C8 * this->actor.scale.x * 100.0f, this->unk_2CC * this->actor.scale.x * 100.0f, + this->unk_2C4, this->unk_18C); +} diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index 14f2a738b..ebfa17777 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -7,11 +7,32 @@ struct EnFloormas; typedef void (*EnFloormasActionFunc)(struct EnFloormas*, GlobalContext*); +#define ENFLOORMAS_GET_7FFF(thisx) ((thisx)->params & 0x7FFF) +#define ENFLOORMAS_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0x00 */ ENFLOORMAS_GET_7FFF_0, + /* 0x10 */ ENFLOORMAS_GET_7FFF_10 = 0x10, + /* 0x20 */ ENFLOORMAS_GET_7FFF_20 = 0x20, + /* 0x40 */ ENFLOORMAS_GET_7FFF_40 = 0x40, +}; + typedef struct EnFloormas { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x214]; + /* 0x018C */ u8 unk_18C; + /* 0x018E */ s16 unk_18E; + /* 0x0190 */ s16 unk_190; + /* 0x0192 */ s16 unk_192; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ Vec3s jointTable[25]; + /* 0x022C */ Vec3s morphTable[25]; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ Vec3f unk_2D0[11]; + /* 0x0354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 extern const ActorInit En_Floormas_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 290705284..12eb8ee6c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6338,8 +6338,8 @@ 0x808D2DC0:("func_808D2DC0",), 0x808D2E34:("func_808D2E34",), 0x808D316C:("EnFloormas_Update",), - 0x808D3488:("func_808D3488",), - 0x808D34C4:("func_808D34C4",), + 0x808D3488:("EnFloormas_OverrideLimbDraw",), + 0x808D34C4:("EnFloormas_PostLimbDraw",), 0x808D3630:("EnFloormas_Draw",), 0x808D3754:("func_808D3754",), 0x808D3E20:("EnRd_Init",), From fcb09f5e2885c7e70df098bfb71a5de38ee02f71 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Thu, 4 Nov 2021 20:36:02 -0300 Subject: [PATCH 79/86] Texture alignment macros (#284) * Add ALIGNED8 * Add designated initializer macro * Update include/command_macros_base.h Co-authored-by: rylieb <31797144+rylieb@users.noreply.github.com> * Remove braces Co-authored-by: rylieb <31797144+rylieb@users.noreply.github.com> --- include/command_macros_base.h | 10 ++++++++-- include/macros.h | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/command_macros_base.h b/include/command_macros_base.h index c0d2ac4e8..bb5ce1648 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -3,7 +3,7 @@ /** * Command Base macros intended for use in designing of more specific command macros - * Each macro packs bytes (B), halfowrds (H) and words (W, for consistency) into a single word + * Each macro packs bytes (B), halfwords (H) and words (W, for consistency) into a single word */ #define CMD_BBBB(a, b, c, d) (_SHIFTL(a, 24, 8) | _SHIFTL(b, 16, 8) | _SHIFTL(c, 8, 8) | _SHIFTL(d, 0, 8)) @@ -16,6 +16,12 @@ #define CMD_W(a) (a) -#define CMD_PTR(a) (u32)(a) +#ifdef __GNUC__ +#define CMD_F(a) {.f = (a)} +#else +#define CMD_F(a) {(a)} +#endif + +#define CMD_PTR(a) (uintptr_t)(a) #endif diff --git a/include/macros.h b/include/macros.h index 7020fc01c..7dd84fc8e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -139,4 +139,10 @@ extern GraphicsContext* __gfxCtx; (b) = _temp; \ } +#ifdef __GNUC__ +#define ALIGNED8 __attribute__ ((aligned (8))) +#else +#define ALIGNED8 +#endif + #endif // _MACROS_H_ From 693c701025cf97dba4f1752826f05956f6e12696 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 5 Nov 2021 12:04:10 +0000 Subject: [PATCH 80/86] Boss_02 (3 non-matching) (#324) * Boss_02 * Fixups * Warnings --- include/functions.h | 10 +- include/variables.h | 7 +- spec | 8 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2160 ++++++++++++++++- src/overlays/actors/ovl_Boss_02/z_boss_02.h | 82 +- .../actors/ovl_Door_Warp1/z_door_warp1.h | 5 +- tools/actorfixer.py | 1 + tools/disasm/variables.txt | 4 +- undefined_syms.txt | 22 + 9 files changed, 2206 insertions(+), 93 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0bb53fe0c..be85d8642 100644 --- a/include/functions.h +++ b/include/functions.h @@ -979,7 +979,7 @@ CollisionHeader* BgCheck_GetActorMeshHeader(CollisionContext* colCtx, s32 index) // void func_800C3C94(void); f32 func_800C3D50(s32 arg0, CollisionContext* colCtx, s32 arg2, CollisionPoly** arg3, s32* arg4, Vec3f* pos, Actor* actor, s32 arg7, f32 arg8, s32 arg9); // void func_800C3F40(void); -// void func_800C3FA0(void); +f32 func_800C3FA0(CollisionContext* colCtx, CollisionPoly** arg1, Vec3f* arg2); f32 func_800C4000(GlobalContext* globalCtx, CollisionContext* colCtx, s32* arg2, Vec3f* arg3); // void func_800C4058(void); f32 func_800C40B4(CollisionContext* colCtx, CollisionPoly** arg1, s32* arg2, Vec3f* pos); @@ -2742,7 +2742,7 @@ s32 func_8013E5CC(Vec3f* param_1, Vec3s* param_2, Vec3f* param_3, Vec3f* param_4 // void func_8013E8F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); s32 func_8013E950(Vec3f* param_1, Vec3f* param_2, s16 param_3, Vec3f* param_4, Vec3f* param_5, s16* param_6, s16* param_7, s16* param_8, s16* param_9, u16 param_10, u16 param_11, u16 param_12, u16 param_13); // void func_8013EC10(void); -// void func_8013EC44(void); +void func_8013EC44(f32 arg0, u8 arg1, u8 arg2, u8 arg3); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); void func_8013EDD0(void); @@ -3007,8 +3007,8 @@ void func_80165438(UNK_PTR param_1); // void func_80165608(void); // void func_80165630(void); // void func_80165658(void); -// void func_8016566C(void); -// void func_80165690(void); +void func_8016566C(s32 arg0); +void func_80165690(void); // void func_801656A4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); // void func_80165DCC(void); // void func_80165DF0(void); @@ -3044,7 +3044,7 @@ void func_80169600(GlobalContext* globalCtx, s16 param_2); // void func_80169668(void); Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); -// void func_8016981C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +void func_8016981C(GlobalContext* globalCtx, s16 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4); // void func_80169940(void); // void func_80169988(void); void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); diff --git a/include/variables.h b/include/variables.h index d7f22e776..b0b3e5c8c 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3258,7 +3258,7 @@ extern u8 actorCutsceneWaiting[16]; // extern UNK_TYPE1 D_801F4E08; extern u8 actorCutsceneNextCutscenes[16]; // extern UNK_TYPE1 D_801F4E20; -// extern UNK_TYPE1 D_801F4E30; +extern u8 D_801F4E30; // extern UNK_TYPE1 D_801F4E31; // extern UNK_TYPE1 D_801F4E32; // extern UNK_TYPE1 D_801F4E38; @@ -3920,7 +3920,7 @@ extern UNK_TYPE D_04015FA0; extern UNK_TYPE D_04016360; extern UNK_TYPE D_0401A4D0; extern UNK_TYPE D_0401A538; -extern UNK_TYPE D_0401A620; +extern Gfx D_0401A620[]; extern Gfx D_0401C430[]; extern UNK_TYPE D_0401F740; extern UNK_TYPE D_0401F7C0; @@ -3932,7 +3932,8 @@ extern UNK_TYPE D_04023100; extern UNK_TYPE D_04023130; extern Gfx D_04023210[]; extern UNK_TYPE D_04023288; -extern UNK_TYPE D_04023348; +extern Gfx D_04023348[]; +extern Gfx D_04023428[]; extern UNK_TYPE D_04025850; extern UNK_TYPE D_04025DD0; extern UNK_TYPE D_040281DC; diff --git a/spec b/spec index 4eb2b0eb6..e09614dbe 100644 --- a/spec +++ b/spec @@ -2548,9 +2548,11 @@ beginseg name "ovl_Boss_02" compress include "build/src/overlays/actors/ovl_Boss_02/z_boss_02.o" - include "build/data/ovl_Boss_02/ovl_Boss_02.data.o" - include "build/data/ovl_Boss_02/ovl_Boss_02.bss.o" - include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" + #ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" + #else + include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" + #endif endseg beginseg diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index df36e8e2d..6b3c944f4 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -5,6 +5,8 @@ */ #include "z_boss_02.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" #define FLAGS 0x00000035 @@ -15,12 +17,59 @@ void Boss02_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss02_Update(Actor* thisx, GlobalContext* globalCtx); void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809DAA74(Boss02* this, GlobalContext* globalCtx); void func_809DAA98(Boss02* this, GlobalContext* globalCtx); +void func_809DAAA8(Boss02* this, GlobalContext* globalCtx); void func_809DAB78(Boss02* this, GlobalContext* globalCtx); +void func_809DC218(Actor* thisx, GlobalContext* globalCtx); +void func_809DC78C(Actor* thisx, GlobalContext* globalCtx); +void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx); +void func_809DD0CC(GlobalContext* globalCtx); +void func_809DD2F8(GlobalContext* globalCtx); +void func_809DD934(Boss02* this, GlobalContext* globalCtx); +void func_809DEAC4(Boss02* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_809DF550 = { +extern Gfx D_06000230[]; +extern Gfx D_060002E0[]; +extern UNK_TYPE D_060003A0; +extern UNK_TYPE D_060041A0; +extern UNK_TYPE D_06008650; +extern SkeletonHeader D_06009B10; +extern AnimationHeader D_06009C78; +extern Gfx D_0600ECF0[]; +extern Gfx D_0600EF90[]; +extern Gfx D_0600F310[]; +extern Gfx D_0600F690[]; +extern Gfx D_0600FA10[]; +extern Gfx D_0600FD90[]; +extern Gfx D_06010110[]; +extern Gfx D_06010490[]; +extern Gfx D_06010810[]; +extern Gfx D_06010B90[]; +extern Gfx D_06010F10[]; +extern Gfx D_06011290[]; +extern Gfx D_06011610[]; +extern Gfx D_06011990[]; +extern Gfx D_06011D10[]; +extern Gfx D_06012090[]; +extern Gfx D_06012410[]; +extern Gfx D_06012790[]; +extern Gfx D_06012B10[]; +extern Gfx D_06012E90[]; +extern Gfx D_06013210[]; +extern Gfx D_06013590[]; + +static u8 D_809E0420; +static u8 D_809E0421; +static u8 D_809E0422; +static Boss02* D_809E0424; +static Boss02* D_809E0428; +static Boss02* D_809E042C; +static u8 D_809E0430; +static DoorWarp1* D_809E0434; +static Boss02Effects D_809E0438[150]; + +static DamageTable sDamageTable1 = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -55,8 +104,7 @@ static DamageTable D_809DF550 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static DamageTable sDamageTable = { -static DamageTable D_809DF570 = { +static DamageTable sDamageTable2 = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -103,186 +151,2144 @@ const ActorInit Boss_02_InitVars = { (ActorFunc)Boss02_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[22] = { -static ColliderJntSphElementInit D_809DF614[22] = { +static f32 D_809DF5B0 = 1.0f; + +static s16 D_809DF5B4[] = { + 0, 195, 190, 185, 180, 175, 170, 165, 160, 155, 150, 145, 140, 135, 130, 125, 120, 115, 110, 105, 100, 95, 90, 0, +}; + +static s16 D_809DF5E4[] = { + 0, 196, 192, 188, 184, 180, 176, 172, 168, 164, 160, 156, 152, 148, 144, 140, 136, 132, 128, 124, 120, 116, 112, +}; + +static ColliderJntSphElementInit sJntSphElementsInit1[22] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 2, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 3, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 4, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 5, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 7, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 8, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 10, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 11, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 12, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 14, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 15, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 16, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 19, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 21, { { 0, 0, 0 }, 85 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 130 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809DF92C = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 22, D_809DF614, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 22, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809DF93C[2] = { +static ColliderJntSphElementInit sJntSphElementsInit2[2] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 130 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 22, { { 0, 0, 0 }, 110 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809DF984 = { - { COLTYPE_HIT0, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809DF93C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_HIT0, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit2, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809DF994 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x04, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x04, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 150, 200, 0, { 0, 0, 0 } }, }; +static Vec3f D_809DF9C0[] = { + { 0.0f, -200.0f, 1000.0f }, { 0.0f, 500.0f, 1000.0f }, { 0.0f, 1000.0f, 1000.0f }, + { 1000.0f, 500.0f, 1000.0f }, { 1000.0f, 1000.0f, -1000.0f }, { -1000.0f, 500.0f, -1000.0f }, + { -1000.0f, 500.0f, 1000.0f }, { -1000.0f, -1000.0f, -1000.0f }, { -1000.0f, -1000.0f, -1000.0f }, +}; + +static Vec3f D_809DFA2C[] = { + { 0.0f, -200.0f, -800.0f }, { 0.0f, 800.0f, -800.0f }, { 800.0f, 300.0f, -800.0f }, + { -800.0f, 800.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, + { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, { -800.0f, -1000.0f, 0.0f }, +}; + +void func_809DA1D0(GlobalContext* globalCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4) { + MREG(64) = 1; + MREG(65) = arg1; + MREG(66) = arg2; + MREG(67) = arg3; + MREG(68) = arg4; +} + +void func_809DA22C(GlobalContext* globalCtx, u8 arg1) { + MREG(68) = arg1; +} + +void func_809DA24C(GlobalContext* globalCtx) { + MREG(64) = 0; +} + +void func_809DA264(Boss02Effects* effects, Vec3f* vec, f32 arg2) { + s16 i; + + for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { + if (effects->unk_24 == 0) { + effects->unk_24 = 1; + effects->unk_00 = *vec; + effects->unk_0C.x = randPlusMinusPoint5Scaled(30.0f); + effects->unk_0C.y = Rand_ZeroFloat(7.0f) + 7.0f; + effects->unk_0C.z = randPlusMinusPoint5Scaled(30.0f); + effects->unk_18.y = -0.3f; + effects->unk_34 = arg2; + effects->unk_2C = 255; + effects->unk_26 = 0; + effects->unk_38 = 2.0f * arg2; + effects->unk_18.x = effects->unk_18.z = 0.0f; + break; + } + } +} + +void func_809DA344(Boss02Effects* effects, Vec3f* vec) { + s16 i; + + for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { + if (effects->unk_24 == 0) { + effects->unk_24 = 3; + effects->unk_00 = *vec; + effects->unk_26 = Rand_ZeroFloat(20.0f); + effects->unk_0C.x = randPlusMinusPoint5Scaled(50.0f); + effects->unk_0C.y = randPlusMinusPoint5Scaled(50.0f); + effects->unk_0C.z = randPlusMinusPoint5Scaled(50.0f); + effects->unk_18.z = 0.0f; + effects->unk_18.x = 0.0f; + effects->unk_18.y = -1.5f; + effects->unk_34 = Rand_ZeroFloat(0.04f) + 0.02f; + effects->unk_30 = Rand_ZeroFloat(32767.0f); + effects->unk_2E = Rand_ZeroFloat(32767.0f); + break; + } + } +} + +void func_809DA460(Boss02Effects* effects, Vec3f* vec) { + s16 i; + + for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { + if ((effects->unk_24 == 0) || (effects->unk_24 == 3)) { + effects->unk_24 = 4; + effects->unk_00 = *vec; + Math_Vec3f_Copy(&effects->unk_0C, &D_801D15B0); + Math_Vec3f_Copy(&effects->unk_18, &D_801D15B0); + effects->unk_2C = 0xFF; + effects->unk_34 = 0.0f; + break; + } + } +} + +void func_809DA50C(s32 arg0, ColliderJntSph* collider, Vec3f* arg2) { + collider->elements[arg0].dim.worldSphere.center.x = arg2->x; + collider->elements[arg0].dim.worldSphere.center.y = arg2->y; + collider->elements[arg0].dim.worldSphere.center.z = arg2->z; + collider->elements[arg0].dim.worldSphere.radius = + collider->elements[arg0].dim.modelSphere.radius * collider->elements[arg0].dim.scale * D_809DF5B0; +} + +void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { + Boss02* this = THIS; + s32 i; + s32 pad[2]; + + if ((gSaveContext.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { + D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, + 0.0f, 60.0f, 0.0f, 0, 0, 0, 1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); + } + + this->actor.targetMode = 10; + this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; + this->unk_1D3C.y = 1.0f; + if (this->actor.params == 200) { + D_809E042C = this; + globalCtx->specialEffects = (void*)D_809E0438; + this->actor.update = func_809DC78C; + this->actor.draw = func_809DD0A8; + this->actor.flags &= ~1; + this->unk_1D70 = 0.00999999977648f; + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { + this->unk_1D20 = 0; + D_809E0430 = KREG(15) + 20; + } else { + this->unk_1D20 = 1; + } + XREG(41) = KREG(14) + 20; + this->unk_01AC = 1.0f; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON5, 0.0f, 1000.0f, 0.0f, 0, 0, + 0, 0); + } else if (this->actor.params == 100) { + this->actor.update = func_809DC218; + this->actor.draw = NULL; + this->actor.hintId = 0x2E; + } else { + if (this->actor.params != 35) { + this->actor.params = 0; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); + D_809E0424 = this; + D_809E0428 = (Boss02*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_02, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 35); + D_809E0424->actor.colChkInfo.damageTable = &sDamageTable2; + D_809E0428->actor.colChkInfo.damageTable = &sDamageTable1; + D_809E0424->unk_1674 = D_809E0428; + D_809E0428->unk_1674 = D_809E0424; + } + + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 20; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06009B10, &D_06009C78, this->jointTable, this->morphTable, 13); + Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, + this->colliderSphere1Elements); + Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, + this->colliderSphere2Elements); + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + + if (D_809E0434 != NULL) { + func_809DAA74(this, globalCtx); + } else { + func_809DAAA8(this, globalCtx); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { + this->unk_01BC[i].x = this->actor.world.pos.x; + this->unk_01BC[i].y = this->actor.world.pos.y; + this->unk_01BC[i].z = this->actor.world.pos.z; + } + + this->unk_014C = Rand_ZeroFloat(1000.0f); + this->unk_1678 = 22; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, + 100); + } +} + +void Boss02_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_809DAA74(Boss02* this, GlobalContext* globalCtx) { + this->actionFunc = func_809DAA98; + this->actor.world.pos.y = -3000.0f; +} + +void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { +} + +void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { + this->actionFunc = func_809DAB78; + Animation_MorphToLoop(&this->skelAnime, &D_06009C78, 0.0f); + if (D_809E042C->unk_1D20 != 0) { + this->unk_0144 = 10; + } else { + this->unk_0144 = 100; + this->unk_01A8 = 25.0f; + D_809E042C->unk_1D7E = 100; + this->actor.world.pos.x = 0.0f; + if (D_809E0424 == this) { + this->actor.world.pos.z = -1000.0f; + } else { + this->actor.world.pos.z = 1400.0f; + } + } + this->actor.world.pos.y = -500.0f; +} + +#ifdef NON_MATCHING +// Saving to spC8 rather than spC4 at line 18dc +void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_809DFA98 = { 185, 140, 70, 255 }; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + CollisionPoly* spDC; + Vec3f spD0; + f32 spCC; + f32 spC8; + f32 spC4; + s32 i; + f32 temp_f0; + f32 phi_f2; + s16 temp_s0; + s16 temp_s2; + Boss02* spB0 = this->unk_1674; + Vec3f spA4; + f32 spA0; + f32 sp9C; + Vec3f sp90; + CollisionPoly* sp8C; + s32 sp88; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + + spCC = this->unk_01B0.x - this->actor.world.pos.x; + spC8 = this->unk_01B0.y - this->actor.world.pos.y; + spC4 = this->unk_01B0.z - this->actor.world.pos.z; + + if ((this->unk_0144 != 10) && (this->unk_0144 <= 20)) { + SkelAnime_Update(&this->skelAnime); + temp_s0 = Math_Atan2S(spCC, spC4); + temp_s2 = Math_Atan2S(spC8, sqrtf(SQ(spCC) + SQ(spC4))); + Math_ApproachS(&this->actor.world.rot.y, temp_s0, 0x14, this->unk_0164); + Math_ApproachS(&this->actor.shape.rot.x, temp_s2, 0x14, this->unk_0164); + Math_ApproachS(&this->unk_0198, this->unk_019A, 1, 0x20); + this->unk_0196 += this->unk_0198; + Math_ApproachF(&this->unk_019C, this->unk_01A0, 0.1f, 100.0f); + this->unk_01A4 = Math_SinS(this->unk_0196) * this->unk_019C; + this->actor.world.rot.x = this->actor.shape.rot.x + this->unk_01A4; + + if (!(this->unk_014C & 0x1F) && (D_809E042C->unk_1D20 == 0)) { + this->unk_01A0 = Rand_ZeroFloat(0x1000) + 0x800; + this->unk_019A = Rand_ZeroFloat(0x400) + 0x200; + } + + if (this->unk_0195 != 0) { + Math_ApproachF(&this->unk_0164, this->unk_0168 * 1.25f, 1.0f, 62.5f); + } else { + Math_ApproachF(&this->unk_0164, this->unk_0168, 1.0f, 50.0f); + } + + this->unk_0168 = 2000.0f; + if (this->unk_0195 != 0) { + this->actor.speedXZ = this->unk_01A8 * D_809DF5B0 * 1.25f; + this->skelAnime.playSpeed = 2.0f; + } else { + this->actor.speedXZ = this->unk_01A8 * D_809DF5B0; + } + + Actor_SetVelocityXYRotation(&this->actor); + Actor_ApplyMovement(&this->actor); + + spD0 = this->actor.world.pos; + if (D_809E0422 != 0) { + spD0.y = 5000.0f; + } else { + spD0.y = 2000.0f; + } + + temp_f0 = func_800C3FA0(&globalCtx->colCtx, &spDC, &spD0); + if (((this->unk_017C.y < temp_f0) && (temp_f0 <= this->unk_0188.y)) || + ((temp_f0 < this->unk_017C.y) && (this->unk_0188.y <= temp_f0))) { + this->unk_0170 = this->unk_017C; + this->unk_0170.y = temp_f0; + this->unk_016C = 120; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + } + + this->actor.flags &= ~1; + if (this->unk_0195 != 0) { + this->actor.world.rot.z = Math_SinS(this->unk_014C * 0x1200) * 0xE00; + } else { + this->actor.world.rot.z = Math_SinS(this->unk_014C * 0xC00) * 0xE00; + } + + this->unk_014E++; + if (this->unk_014E >= ARRAY_COUNT(this->unk_01BC)) { + this->unk_014E = 0; + } + + this->unk_01BC[this->unk_014E].x = this->actor.world.pos.x; + this->unk_01BC[this->unk_014E].y = this->actor.world.pos.y; + this->unk_01BC[this->unk_014E].z = this->actor.world.pos.z; + + this->unk_0B1C[this->unk_014E].x = BINANG_TO_RAD(this->actor.world.rot.x); + this->unk_0B1C[this->unk_014E].y = BINANG_TO_RAD(this->actor.world.rot.y); + this->unk_0B1C[this->unk_014E].z = BINANG_TO_RAD(this->actor.world.rot.z); + } + + if ((this->unk_0144 < 10) && (spB0->unk_0144 >= 20)) { + this->unk_01B0.y = -1000.0f * D_809DF5B0; + if (D_809E0422 != 0) { + this->unk_01B0.y += 3150.0f; + } + this->unk_0144 = 3; + this->unk_0146[0] = 50; + } + + switch (this->unk_0144) { + default: + return; + + case 0: + if ((this->actor.params == 0) && (Rand_ZeroOne() < 0.75f)) { + this->actor.world.pos.x = player->actor.world.pos.x; + this->actor.world.pos.z = player->actor.world.pos.z; + this->actor.world.pos.y = player->actor.world.pos.y - (600.0f * D_809DF5B0); + } else { + this->actor.world.pos.x = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); + this->actor.world.pos.z = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); + this->actor.world.pos.y = -500.0f * D_809DF5B0; + if (D_809E0422 != 0) { + this->actor.world.pos.y += 3150.0f; + } + } + + if ((fabsf(this->actor.world.pos.x) < (500.0f * D_809DF5B0)) && + (fabsf(this->actor.world.pos.z) < (500.0f * D_809DF5B0))) { + return; + } + + case 100: + this->actor.shape.rot.x = 0x4000; + this->unk_01B0.x = this->actor.world.pos.x; + this->unk_01B0.y = this->actor.world.pos.y + (1000.0f * D_809DF5B0); + this->unk_01B0.z = this->actor.world.pos.z; + this->unk_0146[0] = 100; + this->unk_0144 = 1; + + case 1: + if (this->unk_0146[0] == 0) { + if (Rand_ZeroOne() < 0.3f) { + this->unk_0144 = 5; + this->unk_0146[0] = 150; + } else { + this->unk_0144 = 2; + this->unk_01B0.x = randPlusMinusPoint5Scaled(3000.0f * D_809DF5B0); + this->unk_01B0.z = randPlusMinusPoint5Scaled(3000.0f * D_809DF5B0); + if ((fabsf(this->unk_01B0.x) < (500.0f * D_809DF5B0)) && + (fabsf(this->unk_01B0.z) < (500.0f * D_809DF5B0))) { + this->unk_01B0.x = 500.0f; + this->unk_01B0.z = 500.0f; + } + this->unk_01B0.y = Rand_ZeroFloat(800.0f * D_809DF5B0) + (200.0f * D_809DF5B0); + if (D_809E0422 != 0) { + this->unk_01B0.y += 3150.0f; + } + } + this->unk_0164 = 0.0f; + } + return; + + case 2: + if (this->unk_0195 != 0) { + phi_f2 = 700.0f; + } else { + phi_f2 = 500.0f; + } + if (sqrtf(SQ(spCC) + SQ(spC8) + SQ(spC4)) < (phi_f2 * D_809DF5B0)) { + this->unk_0144 = 3; + this->unk_01B0.y = -3000.0f * D_809DF5B0; + if (D_809E0422 != 0) { + this->unk_01B0.y += 3150.0f; + } + this->unk_0146[0] = 150; + this->unk_0164 = 0.0f; + } + return; + + case 3: + if (this->unk_0146[0] == 0) { + this->unk_0144 = 0; + } + return; + + case 5: + this->unk_01B0.x = player->actor.world.pos.x; + this->unk_01B0.y = player->actor.world.pos.y + (100.0f * D_809DF5B0); + this->unk_01B0.z = player->actor.world.pos.z; + if (this->unk_0146[0] == 0) { + this->unk_0144 = 3; + this->unk_01B0.x = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.x; + this->unk_01B0.y = -3000.0f * D_809DF5B0; + if (D_809E0422 != 0) { + this->unk_01B0.y += 3150.0f; + } + this->unk_01B0.z = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.z; + this->unk_0146[0] = 150; + this->unk_0164 = 0.0f; + } + return; + + case 10: + if (this->unk_1678 != 0) { + this->unk_019A = 0x500; + this->unk_01A0 = 0x1200; + } else { + this->colliderCylinder.dim.radius = 150.0f * D_809DF5B0; + this->colliderCylinder.dim.height = 200.0f * D_809DF5B0; + this->colliderCylinder.dim.yShift = 0; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + return; + + case 11: + if (this == D_809E0424) { + this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; + this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; + this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; + } else { + this->unk_01B0.x = D_809DFA2C[this->unk_1D1A].x; + this->unk_01B0.y = D_809DFA2C[this->unk_1D1A].y; + this->unk_01B0.z = D_809DFA2C[this->unk_1D1A].z; + } + this->actor.shape.rot.x = 0x4000; + this->unk_0144 = 12; + this->actor.world.pos.x = this->unk_01B0.x; + this->actor.world.pos.y = -200.0f; + this->actor.world.pos.z = this->unk_01B0.z; + this->unk_01A8 = 25.0f; + return; + + case 12: + if (sqrtf(SQ(spCC) + SQ(spC8) + SQ(spC4)) < 500.0f) { + this->unk_1D1A++; + this->unk_0164 = 0.0f; + if (this->unk_1D1A > 8) { + this->unk_1D1A = 8; + } + if (this == D_809E0424) { + this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; + this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; + this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; + } else { + this->unk_01B0.x = D_809DFA2C[this->unk_1D1A].x; + this->unk_01B0.y = D_809DFA2C[this->unk_1D1A].y; + this->unk_01B0.z = D_809DFA2C[this->unk_1D1A].z; + } + } + return; + + case 20: + this->unk_0152 = 15; + if ((s16)(BREG(71) + 140) < this->unk_0146[1]) { + if (this->unk_0146[0] == 0) { + Matrix_RotateY(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(1500.0f * D_809DF5B0, &spA4); + this->unk_0146[0] = 50; + this->unk_01B0.x = player->actor.world.pos.x + spA4.x; + this->unk_01B0.y = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + (600.0f * D_809DF5B0); + if (D_809E0422 != 0) { + this->unk_01B0.y += 3150.0f; + } + this->unk_01B0.z = player->actor.world.pos.z + spA4.z; + } + this->unk_0168 = 3000.0f; + } else { + this->unk_01B0.y += 10.0f * D_809DF5B0; + this->unk_0168 = 5000.0f; + } + this->unk_019A = 0x1000; + this->unk_01A8 = 25.0f; + this->unk_01A0 = 0x1800; + if (this->unk_0146[1] == 0) { + this->unk_015C = 1; + this->unk_0144 = 21; + this->unk_0146[0] = 20; + this->unk_0152 = 0; + D_809E042C->unk_1D20 = 102; + D_809E042C->unk_1D5C = 0.0f; + play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); + } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + } + return; + + case 21: + this->unk_01A8 = 0.0f; + this->actor.speedXZ = 0.0f; + if (this->unk_0146[0] == 0) { + this->unk_0146[0] = 3; + + for (i = 0; i < 35; i++) { + func_809DA344(globalCtx->specialEffects, &this->unk_147C[this->unk_1678]); + } + + func_809DA460(globalCtx->specialEffects, &this->unk_147C[this->unk_1678]); + play_sound(NA_SE_EV_EXPLOSION); + + this->unk_1678--; + if (this->unk_1678 <= 0) { + this->unk_0144 = 22; + this->actor.gravity = -1.0f * D_809DF5B0; + this->actor.velocity.y = 0.0f; + this->actor.minVelocityY = -1000.0f * D_809DF5B0; + this->unk_0164 = randPlusMinusPoint5Scaled(0.05f); + + spC4 = player->actor.world.pos.x - this->actor.world.pos.x; + spC8 = player->actor.world.pos.z - this->actor.world.pos.z; + if (sqrtf(SQ(spC4) + SQ(spC8)) < (400.0f * D_809DF5B0)) { + this->actor.speedXZ = 15.0f * D_809DF5B0; + } + + spC4 = this->actor.world.pos.x; + spC8 = this->actor.world.pos.z; + if (sqrtf(SQ(spC4) + SQ(spC8)) < (400.0f * D_809DF5B0)) { + this->actor.speedXZ = 15.0f * D_809DF5B0; + } + + if (spB0->unk_0144 >= 10) { + Audio_QueueSeqCmd(0x8021); + } + + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); + } + } + return; + + case 22: + i = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); + + Math_Vec3f_Copy(&this->unk_01BC[i], &this->actor.world.pos); + this->unk_0B1C[i].y += this->unk_0164; + Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.1f, 0.07f); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + + if (this->actor.bgCheckFlags & 1) { + this->unk_0144 = 23; + this->actor.speedXZ = 0.0f; + this->unk_0170 = this->unk_017C; + this->unk_016C = 30; + this->unk_0170.y = this->actor.floorHeight; + D_809E042C->unk_1D20 = 103; + D_809E042C->unk_1D1C = 0; + D_809E042C->unk_0146[0] = 15; + D_809E042C->unk_0150 = 0; + play_sound(NA_SE_EV_LIGHTNING); + + for (i = 0; i < 30; i++) { + func_809DA344(globalCtx->specialEffects, &this->unk_0170); + } + + this->unk_0146[0] = 10; + } + break; + + case 23: + i = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); + Math_Vec3f_Copy(&this->unk_01BC[i], &this->actor.world.pos); + Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.05f, 0.07f); + + if (this->unk_0146[0] & 1) { + sp9C = Rand_ZeroFloat(M_PI); + + for (i = 0; i < 15; i++) { + Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, 0); + Matrix_GetStateTranslationAndScaledZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, + &sp90); + spD0.x = this->unk_0170.x + sp90.x; + spD0.y = this->unk_0170.y + (1000.0f * D_809DF5B0); + spD0.z = this->unk_0170.z + sp90.z; + if (func_800C40B4(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { + spA0 = func_800C3FA0(&globalCtx->colCtx, &sp8C, &spD0); + Matrix_GetStateTranslationAndScaledZ(5.0f * D_809DF5B0, &sp70); + sp70.y = 2.0f * D_809DF5B0; + sp64.y = 0.3f * D_809DF5B0; + sp64.z = 0.0f; + sp64.x = 0.0f; + sp7C.x = spD0.x; + sp7C.y = spA0; + sp7C.z = spD0.z; + func_800B0F18(globalCtx, &sp7C, &sp70, &sp64, &D_809DFA98, &D_809DFA98, + (Rand_ZeroFloat(500.0f) + 1200.0f) * D_809DF5B0, 20.0f * D_809DF5B0, + Rand_ZeroFloat(5.0f) + 14.0f); + } + } + } + } + + this->colliderCylinder.dim.radius = 150.0f * D_809DF5B0; + this->colliderCylinder.dim.height = 200.0f * D_809DF5B0; + this->colliderCylinder.dim.yShift = 0; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} +#else +static Color_RGBA8 D_809DFA98 = { 185, 140, 70, 255 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DAB78.s") #endif -extern DamageTable D_809DF550; -extern DamageTable D_809DF570; -extern ColliderJntSphElementInit D_809DF614[22]; -extern ColliderJntSphInit D_809DF92C; -extern ColliderJntSphElementInit D_809DF93C[2]; -extern ColliderJntSphInit D_809DF984; -extern ColliderCylinderInit D_809DF994; +void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { + Boss02* temp_s6 = this->unk_1674; + s32 temp; + s32 i; + u8 damage; -extern UNK_TYPE D_060002E0; -extern UNK_TYPE D_060003A0; -extern UNK_TYPE D_06008650; -extern UNK_TYPE D_06009C78; + if (this->unk_0154 == 0) { + if (D_809E0422 != 0) { + temp = 0; + } else { + temp = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA1D0.s") + for (i = temp; i < ARRAY_COUNT(this->colliderSphere2Elements); i++) { + if (this->colliderSphere2.elements[i].info.bumperFlags & BUMP_HIT) { + this->colliderSphere2.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_0154 = 15; + this->unk_0156 = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA22C.s") + if (i == 0) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + this->unk_015C = 1; + } else { + func_8019F1C0(&this->unk_167C, NA_SE_EN_INBOSS_DAMAGE_OLD); + this->unk_015C = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA24C.s") + if (D_809E0422 != 0) { + this->unk_0152 = 15; + } else { + this->unk_0152 = 12; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA264.s") + damage = this->actor.colChkInfo.damage; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA344.s") + if (temp_s6->unk_0144 < 20) { + do { + do { + this->actor.colChkInfo.health -= damage; + } while (0); + } while (0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA460.s") + if ((s8)this->actor.colChkInfo.health <= 0) { + Actor_MarkForDeath(this->actor.child); + this->actor.child = NULL; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->skelAnime.playSpeed = 2.0f; + this->unk_0144 = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DA50C.s") + if (temp_s6->unk_0144 >= 10) { + Audio_QueueSeqCmd(0x100100FF); + } else { + temp_s6->unk_0195 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Init.s") + this->unk_0146[1] = BREG(70) + 170; + this->unk_0146[0] = 0; + this->actor.shape.rot.x = 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Destroy.s") + if (D_809E0422 == 0) { + if (this->actor.world.pos.y < -200.0f) { + this->actor.world.pos.y = -200.0f; + } + } else if (this->actor.world.pos.y < 3130.0f) { + this->actor.world.pos.y = 3130.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DAA74.s") + D_809E042C->unk_1D20 = 100; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DAA98.s") + if (this == D_809E0424) { + D_809E042C->unk_0194 = 0; + } else { + D_809E042C->unk_0194 = 1; + } + } + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DAAA8.s") +void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { + Boss02* this = THIS; + s32 pad; + Vec3f sp24; + CollisionPoly* sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DAB78.s") + this->unk_014C++; + if ((this->unk_014C + this->actor.params) & 1) { + sp24 = this->actor.world.pos; + this->actor.focus.pos = this->actor.world.pos; + if (D_809E0422 != 0) { + sp24.y = 5000.0f; + } else { + sp24.y = 2000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DBFB4.s") + if ((this->actor.focus.pos.y < func_800C3FA0(&globalCtx->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { + this->actor.flags &= ~1; + } else { + this->actor.flags |= 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DC218.s") +void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f sp3C; + Boss02* this = THIS; + s32 pad; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Update.s") + if (D_809E0422 == 0) { + Actor_SetScale(&this->actor, 0.6f); + } else { + Actor_SetScale(&this->actor, 0.060000001f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DC78C.s") + if (D_809E042C->unk_1D18 == 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_0146); i++) { + if (this->unk_0146[i] != 0) { + this->unk_0146[i]--; + } + } + if (this->unk_016C != 0) { + this->unk_016C--; + } + + if (this->unk_0154 != 0) { + this->unk_0154--; + } + + if (this->unk_0156 != 0) { + this->unk_0156--; + } + + if (this->unk_0152 != 0) { + this->unk_0152--; + } + + this->unk_014C++; + + this->actionFunc(this, globalCtx); + + if (this->unk_016C != 0) { + if ((this->unk_016C == 60) && (this->unk_0144 < 20)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); + + if (this->unk_0144 > 20) { + sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; + sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; + sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; + func_809DA264(globalCtx->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + } + + if ((this->unk_014C % 2) == 0) { + sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; + sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; + sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; + func_809DA264(globalCtx->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + } + } + + if ((this->unk_0144 < 20) && (this->unk_0144 != 10)) { + func_809DBFB4(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere2.base); + } + + switch (this->unk_015C) { + case 1: + this->unk_015A = 0; + this->unk_0158 = this->unk_015A; + this->unk_015C++; + + case 2: + this->unk_015A += 2; + if (this->unk_015A > 20) { + this->unk_015C++; + } + this->unk_0156 |= 4; + break; + + case 3: + this->unk_0158 += 2; + if (this->unk_0158 > 20) { + this->unk_015C = 0; + } + this->unk_0156 |= 4; + break; + + case 10: + this->unk_015A = 21; + this->unk_0158 = this->unk_015A; + this->unk_015C++; + + case 11: + this->unk_0158 -= 2; + if (this->unk_0158 <= 0) { + this->unk_0158 = 0; + this->unk_015C++; + } + this->unk_0156 |= 4; + break; + + case 12: + this->unk_015A -= 2; + if (this->unk_015A <= 0) { + this->unk_015A = 0; + this->unk_015C = 0; + } + this->unk_0156 |= 4; + break; + } + } +} + +void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { + Boss02* this = THIS; + + this->unk_01AC = D_809DF5B0; + globalCtx->envCtx.unk_EA = 0xD; + + if (D_809E0434 != NULL) { + this->unk_1D74 = KREG(23) + -15.0f; + D_801F4E30 = 0; + globalCtx->envCtx.unk_C3 = 1; + globalCtx->skyboxId = 1; + } else if (D_809E0422 == 0) { + this->unk_1D74 = 0.0f; + D_801F4E30 = this->unk_1D7C; + globalCtx->envCtx.unk_C3 = 0; + globalCtx->skyboxId = 2; + } else { + this->unk_1D74 = KREG(23) + -15.0f; + D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; + globalCtx->envCtx.unk_C3 = 1; + globalCtx->skyboxId = 1; + } + + Math_ApproachS(&this->unk_1D7C, this->unk_1D7E, 1, 3); + + if (this->unk_0146[0] != 0) { + this->unk_0146[0]--; + } + + if (D_809E0434 == NULL) { + if (D_809E0430 != 0) { + D_809E0430--; + if (D_809E0430 == 0) { + Audio_QueueSeqCmd(0x801B); + } + } + } + + func_809DD0CC(globalCtx); + func_809DEAC4(this, globalCtx); + func_809DD934(this, globalCtx); +} + +#ifdef NON_MATCHING +// matrix stuff at the start? +void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { + static Gfx* D_809DFA9C[] = { + D_0600ECF0, D_0600EF90, D_0600F310, D_0600F690, D_0600FA10, D_0600FD90, D_06010110, D_06010490, + D_06010810, D_06010B90, D_06010F10, D_06011290, D_06011610, D_06011990, D_06011D10, D_06012090, + D_06012410, D_06012790, D_06012B10, D_06012E90, D_06013210, D_06013590, + }; + static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; + Boss02* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 i; + s32 idx; + RSPMatrix* matrix; + s32 pad; + s32 phi_v0; + f32 phi_f12; + f32 spAC; + f32 spA8; + f32 spA4; + f32 spA0; + f32 sp9C; + f32 sp98; + + matrix = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actor.params == 0) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_060003A0)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&D_060041A0)); + } + + gSPSegment(POLY_OPA_DISP++, 0x0D, matrix); + + if (D_809E0422 == 0) { + sp98 = -500.0f; + } else { + sp98 = 3100.0f; + } + + sp9C = this->unk_0152 * (M_PI / 4) * (1.0f / 15); + if (this->unk_0144 < 20) { + spAC = Math_SinS(this->unk_014C * 0x2200) * sp9C * 0.5f; + spA8 = Math_CosS(this->unk_014C * 0x3200) * sp9C; + } else { + spAC = Math_SinS(this->unk_014C * 0x1000) * sp9C * 0.5f; + spA8 = Math_CosS(this->unk_014C * 0x1500) * sp9C; + } + + idx = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); + Matrix_InsertTranslation(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); + Matrix_InsertYRotation_f(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(spAC - this->unk_0B1C[idx].x); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(150.0f, &this->unk_147C[0]); + this->unk_0188 = this->unk_017C; + Matrix_GetStateTranslationAndScaledZ(300.0f, &this->unk_017C); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_017C); + + if ((this->unk_0156 & 1) && (this->unk_0158 == 0)) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); + } + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + spA4 = 0.0f; + spA0 = 0.0f; + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++) { + if (this->unk_0195 != 0) { + phi_v0 = (D_809DF5E4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + } else { + phi_v0 = (D_809DF5B4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + } + + if ((i == 21) && (this->unk_0144 < 20)) { + spA4 = spAC; + spA0 = spA8; + } + + Matrix_InsertTranslation(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, + MTXMODE_NEW); + Matrix_InsertYRotation_f(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(spA4 - this->unk_0B1C[phi_v0].x); + Matrix_InsertZRotation_f(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(-(M_PI / 2)); + Matrix_GetStateAsRSPMatrix(&matrix[i]); + + gSPMatrix(POLY_OPA_DISP++, &matrix[i], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); + } + + if (i < this->unk_1678) { + if (sp98 < this->unk_01BC[phi_v0].y) { + gSPDisplayList(POLY_OPA_DISP++, D_809DFA9C[i]); + } + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + if (i == 21) { + phi_f12 = 600.0f; + } else { + phi_f12 = 200.0f; + } + + Matrix_GetStateTranslationAndScaledX(phi_f12, &this->unk_147C[i + 1]); + + if (i == 21) { + Actor* child = this->actor.child; + + if (child != NULL) { + Matrix_GetStateTranslationAndScaledX(500.0f, &child->world.pos); + } + + func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->projectionMatrix, &this->unk_147C[i + 1], &this->unk_167C, + &this->actor.projectedW); + } else { + func_809DA50C(i, &this->colliderSphere1, &this->unk_147C[i + 1]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (D_809E0422 == 0) { + func_809DA50C(0, &this->colliderSphere2, &D_809DFAF4); + func_809DA50C(21, &this->colliderSphere1, &this->unk_147C[0]); + } else { + func_809DA50C(0, &this->colliderSphere2, &this->unk_147C[0]); + func_809DA50C(21, &this->colliderSphere1, &D_809DFAF4); + } +} +#else +static Gfx* D_809DFA9C[] = { + D_0600ECF0, D_0600EF90, D_0600F310, D_0600F690, D_0600FA10, D_0600FD90, D_06010110, D_06010490, + D_06010810, D_06010B90, D_06010F10, D_06011290, D_06011610, D_06011990, D_06011D10, D_06012090, + D_06012410, D_06012790, D_06012B10, D_06012E90, D_06013210, D_06013590, +}; +static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Draw.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD0A8.s") +void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { + func_809DD2F8(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD0CC.s") +void func_809DD0CC(GlobalContext* globalCtx) { + Boss02Effects* effect = (Boss02Effects*)globalCtx->specialEffects; + f32 phi_f22; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD2F8.s") + if (D_809E0422 == 0) { + phi_f22 = 0.0f; + } else { + phi_f22 = 3150.0f; + } + for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { + if (effect->unk_24) { + effect->unk_26++; + effect->unk_00.x += effect->unk_0C.x * D_809DF5B0; + effect->unk_00.y += effect->unk_0C.y * D_809DF5B0; + effect->unk_00.z += effect->unk_0C.z * D_809DF5B0; + effect->unk_0C.y += effect->unk_18.y; + + if (effect->unk_24 < 3) { + Math_ApproachF(&effect->unk_34, effect->unk_38, 0.1f, 0.1f); + if (effect->unk_24 == 2) { + effect->unk_2C -= 18; + } else { + effect->unk_2C -= 15; + } + if (effect->unk_2C <= 0) { + effect->unk_24 = 0; + } + } else if (effect->unk_24 == 3) { + effect->unk_2E += 0x1000; + effect->unk_30 += 0x1500; + if ((effect->unk_00.y < phi_f22) || (effect->unk_26 > 50)) { + effect->unk_24 = 0; + } + } else if (effect->unk_24 == 4) { + Math_ApproachF(&effect->unk_34, 80.0f, 0.2f, 20.0f); + effect->unk_2C -= 15; + if (effect->unk_2C <= 0) { + effect->unk_24 = 0; + } + } + } + } +} + +void func_809DD2F8(GlobalContext* globalCtx) { + u8 flag = false; + Boss02Effects* effect = (Boss02Effects*)globalCtx->specialEffects; + s16 i; + u8 phi_a0; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { + if (effect->unk_24 == 1) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, D_06000230); + gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); + flag++; + } + + phi_a0 = effect->unk_2C; + if (effect->unk_2C > 255) { + phi_a0 = 255; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 185, 140, 70, phi_a0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), + (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_060002E0); + } + } + + effect = (Boss02Effects*)globalCtx->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { + if (effect->unk_24 == 3) { + if (!flag) { + gDPSetCombineLERP(POLY_OPA_DISP++, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, + 0, SHADE, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); + flag++; + } + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(effect->unk_30, MTXMODE_APPLY); + Matrix_InsertXRotation_s(effect->unk_2E, MTXMODE_APPLY); + Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, + MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_0401A620); + } + } + + effect = (Boss02Effects*)globalCtx->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { + if (effect->unk_24 == 4) { + if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? + gSPDisplayList(POLY_XLU_DISP++, D_04023348); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); + + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_04023428); + } + } + + effect = (Boss02Effects*)globalCtx->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { + if (effect->unk_24 == 2) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, D_06000230); + gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 30, 30, 30, (u8)effect->unk_2C); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), + (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, 0); + Matrix_NormalizeXYZ(&globalCtx->mf_187FC); + Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_060002E0); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +#ifdef NON_MATCHING +// Small ordering in the last loop +void func_809DD934(Boss02* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 i; + Actor* temp_a0_5; + Vec3f sp58; + u8 sp57 = 0; + f32 phi_f0_2; + s16 phi_v1; + + this->unk_1D14++; + + switch (this->unk_1D18) { + case 0: + if (player->stateFlags1 & 0x100) { + func_800EA0D4(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = func_801694DC(globalCtx); + func_80169590(globalCtx, 0, 1); + func_80169590(globalCtx, this->unk_1D22, 7); + func_8016566C(150); + this->unk_1D14 = 0; + this->unk_1D5C = 0.0f; + this->unk_1D58 = 0.0f; + if (D_809E0422 == 0) { + this->unk_1D18 = 1; + this->unk_1D68 = 10.0f; + this->unk_1D64 = 60.0f; + this->unk_1D6C = 23.0f; + this->unk_1D70 = 0.01f; + this->unk_1D74 = 0.0f; + goto label1; + } else { + this->unk_1D18 = 10; + this->unk_1D68 = 10.0f; + this->unk_1D64 = 200.0f; + this->unk_1D6C = 273.0f; + this->unk_1D70 = 0.1f; + this->unk_1D74 = -100.0f; + sp57 = 1; + goto label2; + } + } + break; + + case 1: + if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && + CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { + this->unk_1D18++; + this->unk_1D78 = 1; + this->unk_1D14 = 0; + } else { + label1: + if (this->unk_1D14 >= 50U) { + if (this->unk_1D14 == (u32)(BREG(43) + 60)) { + play_sound(NA_SE_PL_TRANSFORM_GIANT); + } + Math_ApproachF(&this->unk_1D64, 200.0f, 0.1f, this->unk_1D5C * 640.0f); + Math_ApproachF(&this->unk_1D6C, 273.0f, 0.1f, this->unk_1D5C * 150.0f); + Math_ApproachF(&this->unk_1D70, 0.1f, 0.2f, this->unk_1D5C * 0.1f); + Math_ApproachF(&this->unk_1D74, -100.0f, 1.0f, this->unk_1D5C * 100.0f); + Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.001f); + } else { + Math_ApproachF(&this->unk_1D64, 30.0f, 0.1f, 1.0f); + } + + if (this->unk_1D14 > 50U) { + Math_ApproachZeroF(&this->unk_1D58, 1.0f, 0.06f); + } else { + Math_ApproachF(&this->unk_1D58, 0.4f, 1.0f, 0.02f); + } + + if (this->unk_1D14 == 107U) { + this->unk_1D78 = 1; + } + + if (this->unk_1D14 < 121U) { + break; + } + + sp57 = 1; + D_809E0420 = 1; + goto block_38; + } + break; + + case 2: + if (this->unk_1D14 < 8U) { + break; + } + sp57 = 1; + goto block_38; + + case 10: + if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && + CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { + this->unk_1D18++; + this->unk_1D78 = 1; + this->unk_1D14 = 0; + break; + } + + label2: + if (this->unk_1D14 != 0U) { + if (this->unk_1D14 == (u32)(BREG(44) + 10)) { + play_sound(NA_SE_PL_TRANSFORM_NORAML); + } + Math_ApproachF(&this->unk_1D64, 60.0f, 0.1f, this->unk_1D5C * 640.0f); + Math_ApproachF(&this->unk_1D6C, 23.0f, 0.1f, this->unk_1D5C * 150.0f); + Math_ApproachF(&this->unk_1D70, 0.01f, 0.1f, 0.003f); + Math_ApproachF(&this->unk_1D74, 0.0f, 1.0f, this->unk_1D5C * 100.0f); + Math_ApproachF(&this->unk_1D5C, 2.0f, 1.0f, 0.01f); + } + + if (this->unk_1D14 == 42U) { + this->unk_1D78 = 1; + } + + if (this->unk_1D14 > 50U) { + D_809E0421 = 1; + goto block_38; + } + break; + + case 11: + if (this->unk_1D14 < 8U) { + break; + } + + block_38: + case 20: + this->unk_1D18 = 0; + func_80169AFC(globalCtx, this->unk_1D22, 0); + this->unk_1D22 = 0; + func_800EA0EC(globalCtx, &globalCtx->csCtx); + this->actor.flags |= 1; + player->stateFlags1 &= ~0x100; + this->unk_1D70 = 0.01f; + func_80165690(); + break; + } + + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + Actor_SetScale(&player->actor, this->unk_1D70 * 1.5f); + } else { + Actor_SetScale(&player->actor, this->unk_1D70); + } + + globalCtx->envCtx.unk_8C.fogNear = this->unk_1D74; + + if (sp57) { + D_809E0422 = 1 - D_809E0422; + if (D_809E0422 == 0) { + D_809DF5B0 = 1.0f; + } else { + D_809DF5B0 = 0.1f; + } + + this->unk_01AC = D_809DF5B0; + if (D_809E0422 == 0) { + if (D_809E0434 != NULL) { + D_809E0434->unk_203 = 0; + D_809E0434->unk_204 = 1.0f; + D_809E0434->actor.world.pos.y = 60.0f; + } + + player->actor.world.pos.x *= 10.0f; + player->actor.world.pos.y -= 3150.0f; + player->actor.world.pos.y *= 10.0f; + player->unk_B68 = player->actor.world.pos.y; + player->actor.world.pos.z *= 10.0f; + + if ((D_809E0434 != NULL) && ((SQ(player->actor.world.pos.z) + SQ(player->actor.world.pos.x)) < SQ(60.0f))) { + player->actor.world.pos.z = 60.0f; + player->actor.world.pos.x = 60.0f; + } + + D_809E0424->actor.world.pos.x *= 10.0f; + D_809E0424->actor.world.pos.y -= 3150.0f; + D_809E0424->actor.world.pos.y *= 10.0f; + D_809E0424->actor.world.pos.z *= 10.0f; + + D_809E0424->unk_0170.x *= 10.0f; + D_809E0424->unk_0170.y -= 3150.0f; + D_809E0424->unk_0170.y *= 10.0f; + D_809E0424->unk_0170.z *= 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { + D_809E0424->unk_01BC[i].x *= 10.0f; + D_809E0424->unk_01BC[i].y -= 3150.0f; + D_809E0424->unk_01BC[i].y *= 10.0f; + D_809E0424->unk_01BC[i].z *= 10.0f; + } + + D_809E0424->unk_01B0.x *= 10.0f; + D_809E0424->unk_01B0.y -= 3150.0f; + D_809E0424->unk_01B0.y *= 10.0f; + D_809E0424->unk_01B0.z *= 10.0f; + + D_809E0424->unk_017C.y -= 3150.0f; + D_809E0424->unk_017C.y *= 10.0f; + D_809E0424->unk_0188.y -= 3150.0f; + D_809E0424->unk_0188.y *= 10.0f; + + D_809E0428->actor.world.pos.x *= 10.0f; + D_809E0428->actor.world.pos.y -= 3150.0f; + D_809E0428->actor.world.pos.y *= 10.0f; + D_809E0428->actor.world.pos.z *= 10.0f; + + D_809E0428->unk_0170.x *= 10.0f; + D_809E0428->unk_0170.y -= 3150.0f; + D_809E0428->unk_0170.y *= 10.0f; + D_809E0428->unk_0170.z *= 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { + D_809E0428->unk_01BC[i].x *= 10.0f; + D_809E0428->unk_01BC[i].y -= 3150.0f; + D_809E0428->unk_01BC[i].y *= 10.0f; + D_809E0428->unk_01BC[i].z *= 10.0f; + } + + D_809E0428->unk_01B0.x *= 10.0f; + D_809E0428->unk_01B0.y -= 3150.0f; + D_809E0428->unk_01B0.y *= 10.0f; + D_809E0428->unk_01B0.z *= 10.0f; + + D_809E0428->unk_017C.y -= 3150.0f; + D_809E0428->unk_017C.y *= 10.0f; + D_809E0428->unk_0188.y -= 3150.0f; + D_809E0428->unk_0188.y *= 10.0f; + + } else { + if (D_809E0434 != 0) { + D_809E0434->unk_203 = 1; + D_809E0434->unk_204 = 0.1f; + D_809E0434->actor.world.pos.y = 3155.0f; + } + + player->actor.world.pos.x *= 0.1f; + player->actor.world.pos.y *= 0.1f; + player->actor.world.pos.y += 3150.0f; + player->unk_B68 = player->actor.world.pos.y; + player->actor.world.pos.z *= 0.1f; + + D_809E0424->actor.world.pos.x *= 0.1f; + D_809E0424->actor.world.pos.y *= 0.1f; + D_809E0424->actor.world.pos.y += 3150.0f; + D_809E0424->actor.world.pos.z *= 0.1f; + + D_809E0424->unk_0170.x *= 0.1f; + D_809E0424->unk_0170.y *= 0.1f; + D_809E0424->unk_0170.y += 3150.0f; + D_809E0424->unk_0170.z *= 0.1f; + + for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { + D_809E0424->unk_01BC[i].x *= 0.1f; + D_809E0424->unk_01BC[i].y *= 0.1f; + D_809E0424->unk_01BC[i].y += 3150.0f; + D_809E0424->unk_01BC[i].z *= 0.1f; + } + + D_809E0424->unk_01B0.x *= 0.1f; + D_809E0424->unk_01B0.y *= 0.1f; + D_809E0424->unk_01B0.y += 3150.0f; + D_809E0424->unk_01B0.z *= 0.1f; + + D_809E0424->unk_017C.y *= 0.1f; + D_809E0424->unk_017C.y += 3150.0f; + D_809E0424->unk_0188.y *= 0.1f; + D_809E0424->unk_0188.y += 3150.0f; + + D_809E0428->actor.world.pos.x *= 0.1f; + D_809E0428->actor.world.pos.y *= 0.1f; + D_809E0428->actor.world.pos.y += 3150.0f; + D_809E0428->actor.world.pos.z *= 0.1f; + + D_809E0428->unk_0170.x *= 0.1f; + D_809E0428->unk_0170.y *= 0.1f; + D_809E0428->unk_0170.y += 3150.0f; + D_809E0428->unk_0170.z *= 0.1f; + + for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { + D_809E0428->unk_01BC[i].x *= 0.1f; + D_809E0428->unk_01BC[i].y *= 0.1f; + D_809E0428->unk_01BC[i].y += 3150.0f; + D_809E0428->unk_01BC[i].z *= 0.1f; + } + + D_809E0428->unk_01B0.x *= 0.1f; + D_809E0428->unk_01B0.y *= 0.1f; + D_809E0428->unk_01B0.y += 3150.0f; + D_809E0428->unk_01B0.z *= 0.1f; + + D_809E0428->unk_017C.y *= 0.1f; + D_809E0428->unk_017C.y += 3150.0f; + D_809E0428->unk_0188.y *= 0.1f; + D_809E0428->unk_0188.y += 3150.0f; + } + + player->actor.home.pos = player->actor.world.pos; + player->actor.prevPos = player->actor.world.pos; + + temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + while (temp_a0_5 != NULL) { + if (temp_a0_5->id == ACTOR_BG_INIBS_MOVEBG) { + Actor_MarkForDeath(temp_a0_5); + break; + } + temp_a0_5 = temp_a0_5->next; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, + D_809E0422); + + temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BOSS].first; + while (temp_a0_5 != NULL) { + if ((temp_a0_5->id == ACTOR_EN_TANRON5) || (temp_a0_5->id == ACTOR_ITEM_B_HEART)) { + if (D_809E0422 == 0) { + temp_a0_5->world.pos.y -= 3150.0f; + temp_a0_5->world.pos.y *= 10.0f; + + temp_a0_5->floorHeight -= 3150.0f; + temp_a0_5->floorHeight *= 10.0f; + + phi_f0_2 = 10.0f; + } else { + temp_a0_5->world.pos.y *= 0.1f; + temp_a0_5->world.pos.y += 3150.0f; + + temp_a0_5->floorHeight *= 0.1f; + temp_a0_5->floorHeight += 3150.0f; + + phi_f0_2 = 0.1f; + } + + temp_a0_5->world.pos.x *= phi_f0_2; + temp_a0_5->world.pos.z *= phi_f0_2; + + temp_a0_5->speedXZ *= phi_f0_2; + + temp_a0_5->velocity.x *= phi_f0_2; + temp_a0_5->velocity.y *= phi_f0_2; + temp_a0_5->velocity.z *= phi_f0_2; + + temp_a0_5->gravity *= phi_f0_2; + temp_a0_5->minVelocityY *= phi_f0_2; + + temp_a0_5->scale.x *= phi_f0_2; + temp_a0_5->scale.y *= phi_f0_2; + temp_a0_5->scale.z *= phi_f0_2; + + if (temp_a0_5->id == ACTOR_ITEM_B_HEART) { + ((ItemBHeart*)temp_a0_5)->unk_168 *= phi_f0_2; + } + } + temp_a0_5 = temp_a0_5->next; + } + } + + switch (this->unk_1D78) { + case 0: + break; + + case 1: + this->unk_1D7A = 0; + func_809DA1D0(globalCtx, 255, 255, 255, 0); + this->unk_1D78 = 2; + play_sound(NA_SE_SY_TRANSFORM_MASK_FLASH); + + case 2: + this->unk_1D7A += 40; + if (this->unk_1D7A >= 400) { + this->unk_1D78 = 3; + } + phi_v1 = this->unk_1D7A; + if (phi_v1 > 255) { + phi_v1 = 255; + } + func_809DA22C(globalCtx, phi_v1); + break; + + case 3: + this->unk_1D7A -= 40; + if (this->unk_1D7A <= 0) { + this->unk_1D7A = 0; + this->unk_1D78 = 0; + func_809DA24C(globalCtx); + } else { + phi_v1 = this->unk_1D7A; + if (phi_v1 > 255) { + phi_v1 = 255; + } + func_809DA22C(globalCtx, phi_v1); + } + break; + } + + if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { + Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->unk_1D64, &sp58); + + this->unk_1D24.x = player->actor.world.pos.x + sp58.x; + this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; + this->unk_1D24.z = player->actor.world.pos.z + sp58.z; + + this->unk_1D30.x = player->actor.world.pos.x; + this->unk_1D30.y = player->actor.world.pos.y + this->unk_1D6C; + this->unk_1D30.z = player->actor.world.pos.z; + + this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; + Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + ShrinkWindow_SetLetterboxTarget(0x1B); + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD934.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DEAC4.s") +void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Boss02* sp68; + Vec3f sp5C; + f32 sp58 = 0.0f; + + this->unk_1D1C++; + if (this->unk_0194 == 0) { + sp68 = D_809E0424; + } else { + sp68 = D_809E0428; + } + + switch (this->unk_1D20) { + case 0: + break; + + case 1: + if ((gSaveContext.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + break; + } + func_800EA0D4(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = func_801694DC(globalCtx); + func_80169590(globalCtx, 0, 1); + func_80169590(globalCtx, this->unk_1D22, 7); + this->unk_1D20 = 2; + this->unk_1D1C = 0; + + case 2: + player->actor.shape.rot.y = -0x8000; + player->actor.world.rot.y = player->actor.shape.rot.y; + this->unk_1D24.x = player->actor.world.pos.x - 20.0f; + this->unk_1D24.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 29.0f; + this->unk_1D24.z = player->actor.world.pos.z - 50; + + this->unk_1D30.x = player->actor.world.pos.x; + this->unk_1D30.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 17.0f; + this->unk_1D30.z = player->actor.world.pos.z; + if (this->unk_1D1C >= 30) { + if (this->unk_1D1C == 30) { + func_8013EC44(0.0f, 50, 200, 1); + } + this->unk_0150 += 0x4000; + sp58 = (Math_SinS(this->unk_0150) * (BREG(19) + 5)) * 0.1f; + Matrix_InsertZRotation_f(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), + MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + } + + if (this->unk_1D1C == 20) { + this->unk_1D7E = 100; + } + + if (this->unk_1D1C == 45) { + func_800B7298(globalCtx, &this->actor, 21); + D_809E0430 = KREG(91) + 43; + } + + if (this->unk_1D1C == 85) { + D_809E0424->unk_0144 = 11; + D_809E0424->unk_014C = 0; + } + + if (this->unk_1D1C == 92) { + func_8013EC44(0.0f, 255, 30, 100); + } + + if (this->unk_1D1C == 100) { + func_800B7298(globalCtx, &this->actor, 0x73); + } + + if (this->unk_1D1C == 112) { + this->unk_1D20 = 10; + this->unk_1D1C = 0; + } + break; + + case 10: + if (this->unk_1D1C < 310) { + this->unk_1D48 = sp68->actor.world.pos; + this->unk_1D24.x = (sp68->actor.world.pos.x * 50.0f) * 0.001f; + this->unk_1D24.y = (sp68->actor.world.pos.y * 50.0f) * 0.001f; + if (this->unk_1D24.y < 100.0f) { + this->unk_1D24.y = 100.0f; + } + this->unk_1D24.z = (sp68->actor.world.pos.z * 100) * 0.001f; + } + + Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.1f, 3000.0f); + Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.1f, 3000.0f); + Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.1f, 3000.0f); + + if (this->unk_1D1C == 100) { + D_809E0428->unk_0144 = 11; + D_809E0428->unk_014C = 0; + this->unk_0194 = 1; + } + + if (this->unk_1D1C == (u32)(KREG(92) + 125)) { + Actor_TitleCardCreate(globalCtx, &globalCtx->actorCtx.titleCtxt, Lib_SegmentedToVirtual(&D_06008650), + 160, 180, 128, 40); + } + + if (this->unk_1D1C == (u32)(BREG(27) + 335)) { + func_80169AFC(globalCtx, this->unk_1D22, 0); + this->unk_1D22 = 0; + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->actor.flags |= 1; + this->unk_1D20 = 0; + D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; + D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; + gSaveContext.eventInf[5] |= 0x20; + } + break; + + case 100: + if (ActorCutscene_GetCurrentIndex() == -1) { + func_800EA0D4(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = func_801694DC(globalCtx); + func_80169590(globalCtx, 0, 1); + func_80169590(globalCtx, this->unk_1D22, 7); + this->unk_1D20 = 101; + this->unk_1D1C = 0; + this->unk_1D5C = 1.0f; + this->unk_1D30 = sp68->actor.world.pos; + } else { + break; + } + + case 101: + case 102: + case_10x: + if ((this->unk_1D20 == 101) || (this->unk_1D20 == 103)) { + this->unk_1D48 = sp68->actor.world.pos; + } else { + this->unk_1D48 = sp68->unk_147C[sp68->unk_1678]; + } + + this->unk_1D24.x = player->actor.world.pos.x; + this->unk_1D24.y = player->actor.world.pos.y + 100.0f; + if (D_809E0422 == 0) { + if (this->unk_1D24.y < 100.0f) { + this->unk_1D24.y = 100.0f; + } + } else if (this->unk_1D24.y < 3160.0f) { + this->unk_1D24.y = 3160.0f; + } + + if (this->unk_1D48.y < (100.0f * D_809DF5B0)) { + this->unk_1D48.y = (100.0f * D_809DF5B0); + } + + this->unk_1D24.z = player->actor.world.pos.z; + Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.3f, this->unk_1D5C * 500.0f); + Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.3f, this->unk_1D5C * 500.0f); + Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.3f, this->unk_1D5C * 500.0f); + Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.02f); + break; + + case 103: + this->unk_0150 += 0x4000; + sp58 = Math_SinS(this->unk_0150); + sp58 = (sp58 * this->unk_0146[0]) * 1.5f; + if (this->unk_1D1C == 30) { + func_80169AFC(globalCtx, this->unk_1D22, 0); + this->unk_1D22 = 0; + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->unk_1D20 = 0; + this->actor.flags |= 1; + sp68->unk_0144 = 10; + if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { + f32 phi_f0; + + this->unk_1D7E = 0; + if (D_809E0422 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, + 0); + phi_f0 = 60.0f; + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 3153.0f, -15.0f, 0, 1, 0, + 35); + phi_f0 = 3155.0f; + } + D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, + ACTOR_DOOR_WARP1, 0.0f, phi_f0, 0.0f, 0, 0, 0, 1); + + if (D_809E0422 == 0) { + D_809E0434->unk_203 = 0; + D_809E0434->unk_204 = 1.0f; + } else { + D_809E0434->unk_203 = 1; + D_809E0434->unk_204 = 0.1f; + } + } + } + goto case_10x; + } + + if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { + sp5C = this->unk_1D24; + sp5C.y += sp58 * D_809DF5B0; + func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); + this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; + this->unk_1D3C.y = 1.0f; + ShrinkWindow_SetLetterboxTarget(0x1B); + } +} diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index 4e000b3ee..d630acb8f 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -7,11 +7,89 @@ struct Boss02; typedef void (*Boss02ActionFunc)(struct Boss02*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ s16 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} Boss02Effects; // size = 0x3C + typedef struct Boss02 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x152C]; + /* 0x0144 */ u8 unk_0144; + /* 0x0146 */ s16 unk_0146[3]; + /* 0x014C */ s16 unk_014C; + /* 0x014E */ s16 unk_014E; + /* 0x0150 */ s16 unk_0150; + /* 0x0152 */ s16 unk_0152; + /* 0x0154 */ s16 unk_0154; + /* 0x0156 */ s16 unk_0156; + /* 0x0158 */ s16 unk_0158; + /* 0x015A */ s16 unk_015A; + /* 0x015C */ u8 unk_015C; + /* 0x015D */ UNK_TYPE1 unk015D[0x7]; + /* 0x0164 */ f32 unk_0164; + /* 0x0168 */ f32 unk_0168; + /* 0x016C */ s16 unk_016C; + /* 0x0170 */ Vec3f unk_0170; + /* 0x017C */ Vec3f unk_017C; + /* 0x018C */ Vec3f unk_0188; + /* 0x0194 */ u8 unk_0194; + /* 0x0195 */ u8 unk_0195; + /* 0x0196 */ s16 unk_0196; + /* 0x0198 */ s16 unk_0198; + /* 0x019A */ s16 unk_019A; + /* 0x019C */ f32 unk_019C; + /* 0x01A0 */ f32 unk_01A0; + /* 0x01A4 */ s16 unk_01A4; + /* 0x01A8 */ f32 unk_01A8; + /* 0x01AC */ f32 unk_01AC; + /* 0x01B0 */ Vec3f unk_01B0; + /* 0x01BC */ Vec3f unk_01BC[200]; + /* 0x0B1c */ Vec3f unk_0B1C[200]; + /* 0x147C */ Vec3f unk_147C[23]; + /* 0x1590 */ SkelAnime skelAnime; + /* 0x15D4 */ Vec3s jointTable[13]; + /* 0x1622 */ Vec3s morphTable[13]; /* 0x1670 */ Boss02ActionFunc actionFunc; - /* 0x1674 */ char unk_1674[0x70C]; + /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance + /* 0x1678 */ s32 unk_1678; + /* 0x167C */ Vec3f unk_167C; + /* 0x1688 */ ColliderJntSph colliderSphere1; + /* 0x16A8 */ ColliderJntSphElement colliderSphere1Elements[22]; + /* 0x1C28 */ ColliderJntSph colliderSphere2; + /* 0x1C48 */ ColliderJntSphElement colliderSphere2Elements[2]; + /* 0x1CC8 */ ColliderCylinder colliderCylinder; + /* 0x1D14 */ u32 unk_1D14; + /* 0x1D18 */ s16 unk_1D18; + /* 0x1D1A */ s16 unk_1D1A; + /* 0x1D1C */ u32 unk_1D1C; + /* 0x1D20 */ s16 unk_1D20; + /* 0x1D22 */ s16 unk_1D22; + /* 0x1D24 */ Vec3f unk_1D24; + /* 0x1D30 */ Vec3f unk_1D30; + /* 0x1D3C */ Vec3f unk_1D3C; + /* 0x1D48 */ Vec3f unk_1D48; + /* 0x1D54 */ f32 unk_1D54; + /* 0x1D58 */ f32 unk_1D58; + /* 0x1D5C */ f32 unk_1D5C; + /* 0x1D60 */ UNK_TYPE1 unk1D60[0x4]; + /* 0x1D64 */ f32 unk_1D64; + /* 0x1D68 */ f32 unk_1D68; + /* 0x1D6C */ f32 unk_1D6C; + /* 0x1D70 */ f32 unk_1D70; + /* 0x1D74 */ f32 unk_1D74; + /* 0x1D78 */ u8 unk_1D78; + /* 0x1D7A */ s16 unk_1D7A; + /* 0x1D7C */ s16 unk_1D7C; + /* 0x1D7E */ s16 unk_1D7E; } Boss02; // size = 0x1D80 extern const ActorInit Boss_02_InitVars; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h index 8085af445..e7b67312e 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -11,7 +11,10 @@ typedef struct DoorWarp1 { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x94]; /* 0x01D8 */ DoorWarp1ActionFunc actionFunc; - /* 0x01DC */ char unk_1DC[0x30]; + /* 0x01DC */ char unk_1DC[0x27]; + /* 0x0203 */ u8 unk_203; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ char unk_208[0x4]; } DoorWarp1; // size = 0x20C extern const ActorInit Door_Warp1_InitVars; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index e1815e224..e89303ba5 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -45,6 +45,7 @@ animdict = { "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", + "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b4fa7869b..8f63c1c89 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -10420,8 +10420,8 @@ 0x809DF570:("D_809DF570","UNK_TYPE1","",0x1), 0x809DF590:("Boss_02_InitVars","UNK_TYPE1","",0x1), 0x809DF5B0:("D_809DF5B0","f32","",0x4), - 0x809DF5B6:("D_809DF5B6","UNK_TYPE2","",0x2), - 0x809DF5E6:("D_809DF5E6","UNK_TYPE2","",0x2), + 0x809DF5B4:("D_809DF5B4","UNK_TYPE2","[24]",0x30), + 0x809DF5E4:("D_809DF5E4","UNK_TYPE2","[24]",0x30), 0x809DF614:("D_809DF614","UNK_TYPE1","",0x1), 0x809DF92C:("D_809DF92C","UNK_TYPE1","",0x1), 0x809DF93C:("D_809DF93C","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 75a9b5cdc..6c17154b8 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1017,6 +1017,28 @@ D_060041A0 = 0x060041A0; D_06008650 = 0x06008650; D_06009B10 = 0x06009B10; D_06009C78 = 0x06009C78; +D_0600ECF0 = 0x0600ECF0; +D_0600EF90 = 0x0600EF90; +D_0600F310 = 0x0600F310; +D_0600F690 = 0x0600F690; +D_0600FA10 = 0x0600FA10; +D_0600FD90 = 0x0600FD90; +D_06010110 = 0x06010110; +D_06010490 = 0x06010490; +D_06010810 = 0x06010810; +D_06010B90 = 0x06010B90; +D_06010F10 = 0x06010F10; +D_06011290 = 0x06011290; +D_06011610 = 0x06011610; +D_06011990 = 0x06011990; +D_06011D10 = 0x06011D10; +D_06012090 = 0x06012090; +D_06012410 = 0x06012410; +D_06012790 = 0x06012790; +D_06012B10 = 0x06012B10; +D_06012E90 = 0x06012E90; +D_06013210 = 0x06013210; +D_06013590 = 0x06013590; // ovl_Boss_03 From c706b2be70c7c4934e619738e7f3251ba83d63ed Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 5 Nov 2021 06:14:22 -0700 Subject: [PATCH 81/86] En_Baguo (Nejiron) OK and mostly documented (#351) * Migrate data to C * EnBaguo_Init OK * EnBaguo_Destroy OK * func_80A3B220 OK * func_80A3B2CC OK * func_80A3B2CC OK * func_80A3B794 OK * func_80A3B5E0 OK * func_80A3B7B8 OK * EnBaguo_Update OK * func_80A3B8F8 * func_80A3BE24 OK, some other not-OK junk * func_80A3BE60 OK (wow this is bad!) * Document the blink system * func_80A3C17C OK * Document timer and fix warnings * func_80A3C008 OK * Rename x/y/z so it's clear they are positions * func_80A3BE60 OK in a not-crazy way * func_80A3B958 OK * func_80A3BF0C OK * Make the rotation a Vec3s * Update the spec to use the built reloc * Use ARRAY_COUNT instead of hardcoded length * Document the state stuff * Document NejironParticle * Document the rolling rotation stuff * unk_1BC -> maxDistanceFromHome * unk_1B8 -> zRollDirection * Name the two draw functions * Name the static variables properly * Name all other functions * Clean up forward declares * Last bit of documentation and cleanup * Add an enum for the rolling direction * Add explanatory comment * state -> action and move action descriptions inline * Use enum for Stone Mask * Use "Setup" for the setup function * Document the damage effect * Add some space around the for-loop * ./format.sh * Use % 8 everywhere * Use -= instead of += a negative number * Switch order of max check * Use CLEAR_TAG_POP enum value * eyeIndexTemp -> eyeIndex * visible -> isVisible * Move enums above structs * Merge animation system changes * yDist fix * Respond to review feedback --- spec | 3 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 500 +++++++++++++++--- src/overlays/actors/ovl_En_Baguo/z_en_baguo.h | 50 +- tools/disasm/functions.txt | 26 +- undefined_syms.txt | 3 + 5 files changed, 499 insertions(+), 83 deletions(-) diff --git a/spec b/spec index e09614dbe..62d1aa3dd 100644 --- a/spec +++ b/spec @@ -2863,8 +2863,7 @@ beginseg name "ovl_En_Baguo" compress include "build/src/overlays/actors/ovl_En_Baguo/z_en_baguo.o" - include "build/data/ovl_En_Baguo/ovl_En_Baguo.data.o" - include "build/data/ovl_En_Baguo/ovl_En_Baguo.reloc.o" + include "build/src/overlays/actors/ovl_En_Baguo/ovl_En_Baguo_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index edfd63ede..a24e35c15 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -1,5 +1,5 @@ /* - * File z_en_baguo.c + * File: z_en_baguo.c * Overlay: ovl_En_Baguo * Description: Nejiron */ @@ -14,7 +14,18 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx); void EnBaguo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_SetupRetreatUnderground(EnBaguo* this); +void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx); +void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 timer); +void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx); + const ActorInit En_Baguo_InitVars = { ACTOR_EN_BAGUO, ACTORCAT_ENEMY, @@ -27,92 +38,453 @@ const ActorInit En_Baguo_InitVars = { (ActorFunc)NULL, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A3C2F0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A3C314 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A3C2F0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A3C324 = { - /* Deku Nut */ DMG_ENTRY(0, 0xF), - /* Deku Stick */ DMG_ENTRY(0, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xE), - /* Zora boomerang */ DMG_ENTRY(3, 0xE), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(3, 0xE), - /* Goron punch */ DMG_ENTRY(2, 0xE), - /* Sword */ DMG_ENTRY(1, 0xE), - /* Goron pound */ DMG_ENTRY(1, 0xE), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(1, 0xE), - /* Goron spikes */ DMG_ENTRY(2, 0xE), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0xF), - /* Deku launch */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0xF), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0xE), - /* Spin attack */ DMG_ENTRY(1, 0xE), - /* 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), +typedef enum { + /* 0x0 */ NEJIRON_DMGEFF_NONE, // Does not interact with the Nejiron at all + /* 0xE */ NEJIRON_DMGEFF_KILL = 14, // Kills and detonates the Nejiron + /* 0xF */ NEJIRON_DMGEFF_RECOIL // Deals no damage, but displays the appropriate hit mark and recoil animation +} NejironDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Deku Stick */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Horse trample */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Zora boomerang */ DMG_ENTRY(3, NEJIRON_DMGEFF_KILL), + /* Normal arrow */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(3, NEJIRON_DMGEFF_KILL), + /* Goron punch */ DMG_ENTRY(2, NEJIRON_DMGEFF_KILL), + /* Sword */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Goron pound */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Fire arrow */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Ice arrow */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Goron spikes */ DMG_ENTRY(2, NEJIRON_DMGEFF_KILL), + /* Deku spin */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Deku bubble */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, NEJIRON_DMGEFF_RECOIL), + /* Zora barrier */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Spin attack */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), + /* Sword beam */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, NEJIRON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), }; -#endif +extern Gfx D_060014C8; +extern Gfx D_060018C8; +extern Gfx D_06001CC8; +extern SkeletonHeader D_060020E8; -extern ColliderJntSphElementInit D_80A3C2F0[1]; -extern ColliderJntSphInit D_80A3C314; -extern DamageTable D_80A3C324; +void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBaguo* this = THIS; -extern UNK_TYPE D_060020E8; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_060020E8, NULL, this->jointTable, this->morphTable, 3); + this->actor.hintId = 0xB; + this->maxDistanceFromHome = 240.0f; + this->maxDistanceFromHome += this->actor.world.rot.z * 40.0f; + this->actor.world.rot.z = 0; + Actor_SetScale(&this->actor, 0.01f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 2; + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].dim.modelSphere.radius = 30; + this->collider.elements[0].dim.scale = 1.0f; + this->collider.elements[0].dim.modelSphere.center.x = 80; + this->collider.elements[0].dim.modelSphere.center.y = 80; + this->collider.elements[0].dim.modelSphere.center.z = 0; + this->actor.shape.yOffset = -3000.0f; + this->actor.gravity = -3.0f; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.flags |= 0x8000000; + this->actor.flags &= ~1; + this->collider.base.acFlags |= AC_HARD; + this->actionFunc = EnBaguo_UndergroundIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/EnBaguo_Init.s") +void EnBaguo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBaguo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/EnBaguo_Destroy.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B220.s") +void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { + this->action = NEJIRON_ACTION_INACTIVE; + if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) { + this->actor.draw = EnBaguo_DrawBody; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + this->actor.world.rot.z = 0; + this->actor.world.rot.x = this->actor.world.rot.z; + this->actor.flags &= ~0x8000000; + this->actor.flags |= 1; + this->actionFunc = EnBaguo_EmergeFromUnderground; + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B2CC.s") +void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx) { + this->actor.world.rot.y += 0x1518; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((globalCtx->gameplayFrames % 8) == 0) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, + 500, 10, 1); + } + Math_ApproachF(&this->actor.shape.shadowScale, 50.0f, 0.3f, 5.0f); + Math_ApproachF(&this->actor.shape.yOffset, 2700.0f, 100.0f, 500.0f); + if (this->actor.shape.yOffset > 2650.0f) { + this->action = NEJIRON_ACTION_ACTIVE; + this->actor.shape.yOffset = 2700.0f; + this->timer = 60; + this->actionFunc = EnBaguo_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B3E0.s") +void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { + s16 absoluteYaw; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B5E0.s") + if (this->timer != 0) { + // Depending on how the last roll ended, this actor may be "sitting" on + // something other than its legs. This slowly corrects that. + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 10, 100, 1000); + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 10, 100, 1000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B794.s") + // If this actor isn't mostly facing the player, do a discrete turn towards + // them. It takes 8 frames to turn, and we must wait 8 frames to do another. + if ((this->timer & 8) != 0) { + if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) > 200.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 30, 300, 1000); + if ((globalCtx->gameplayFrames % 8) == 0) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_VOICE); + } + } + } + this->actor.shape.rot.y = this->actor.world.rot.y; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B7B8.s") + yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + absoluteYaw = ABS_ALT(yaw); + Math_Vec3f_Copy(&this->targetRotation, &D_801D15B0); + Math_Vec3f_Copy(&this->currentRotation, &D_801D15B0); + if (absoluteYaw < 0x2000) { + this->targetRotation.x = 2000.0f; + } else { + this->zRollDirection = NEJIRON_DIRECTION_RIGHT; + this->targetRotation.z = 2000.0f; + if ((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0) { + this->zRollDirection = NEJIRON_DIRECTION_LEFT; + } + } + this->timer = 38; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->hardHitFlag = 0; + this->actionFunc = EnBaguo_Roll; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B8F8.s") +void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx) { + f32 xDistanceFromHome = this->actor.home.pos.x - this->actor.world.pos.x; + f32 zDistanceFromHome = this->actor.home.pos.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3B958.s") + if ((sqrtf(SQ(xDistanceFromHome) + SQ(zDistanceFromHome)) > this->maxDistanceFromHome) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK)) { + EnBaguo_SetupRetreatUnderground(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/EnBaguo_Update.s") + if (this->timer == 0) { + this->timer = 100; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBaguo_Idle; + this->actor.speedXZ = 0.0f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3BE24.s") + if (!this->hardHitFlag && this->collider.base.atFlags & AC_HARD) { + this->zRollDirection ^= 1; + this->hardHitFlag = 1; + this->actor.speedXZ = -7.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3BE60.s") + Math_ApproachF(&this->currentRotation.x, this->targetRotation.x, 0.2f, 1000.0f); + Math_ApproachF(&this->currentRotation.z, this->targetRotation.z, 0.2f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 0.5f); + this->actor.world.rot.x += (s16)this->currentRotation.x; + if (this->currentRotation.z != 0.0f) { + if (this->zRollDirection == NEJIRON_DIRECTION_RIGHT) { + this->actor.world.rot.z += (s16)this->currentRotation.z; + } else { + this->actor.world.rot.z -= (s16)this->currentRotation.z; + } + } + Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3BF0C.s") +void EnBaguo_SetupRetreatUnderground(EnBaguo* this) { + this->action = NEJIRON_ACTION_RETREATING; + this->actionFunc = EnBaguo_RetreatUnderground; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3C008.s") +void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { + this->actor.world.rot.y -= 0x1518; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((globalCtx->gameplayFrames % 8) == 0) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, + 500, 10, 1); + } + Math_ApproachF(&this->actor.shape.yOffset, -3000.0f, 100.0f, 500.0f); + Math_ApproachZeroF(&this->actor.shape.shadowScale, 0.3f, 5.0f); + if (this->actor.shape.yOffset < -2970.0f) { + this->actor.shape.yOffset = -3000.0f; + this->actor.draw = EnBaguo_DrawBody; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + this->actor.flags |= 0x8000000; + this->actor.flags &= ~1; + this->actionFunc = EnBaguo_UndergroundIdle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baguo/func_80A3C17C.s") +void EnBaguo_PostDetonation(EnBaguo* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } + if (this->timer >= 26) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + s32 i; + + // In order to match, this variable must act as both a boolean to check if + // the Nejiron should forcibly explode and as a loop index. + i = false; + if (this->action != NEJIRON_ACTION_EXPLODING && this->action != NEJIRON_ACTION_RETREATING) { + if (!(this->actor.bgCheckFlags & 1) && this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { + // Force a detonation if we're off the ground and have fallen + // below our home position (e.g., we rolled off a ledge). + i = true; + } + if (this->actor.bgCheckFlags & 0x60 && this->actor.depthInWater >= 40.0f) { + // Force a detonation if we're too far below the water's surface. + i = true; + } + if ((this->collider.base.acFlags & AC_HIT || i)) { + this->collider.base.acFlags &= ~AC_HIT; + if (i || this->actor.colChkInfo.damageEffect == NEJIRON_DMGEFF_KILL) { + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + this->action = NEJIRON_ACTION_EXPLODING; + this->actor.speedXZ = 0.0f; + this->actor.shape.shadowScale = 0.0f; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++) { + acceleration.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + acceleration.y = -1.0f; + acceleration.z = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.x = (Rand_ZeroOne() - 0.5f) * 14.0f; + velocity.y = Rand_ZeroOne() * 30.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 14.0f; + EnBaguo_InitializeParticle(this, &this->actor.focus.pos, &velocity, &acceleration, + (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_POP); + Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_DEAD); + this->timer = 30; + this->actor.flags |= 0x8000000; + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, 0.0f); + this->collider.elements->dim.scale = 3.0f; + this->collider.elements->info.toucher.damage = 8; + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0xB0); + this->actionFunc = EnBaguo_PostDetonation; + } + } + } +} + +void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBaguo* this = THIS; + + Actor_SetHeight(&this->actor, 30.0f); + EnBaguo_UpdateParticles(this, globalCtx); + EnBaguo_CheckForDetonation(this, globalCtx); + this->actionFunc(this, globalCtx); + + DECR(this->blinkTimer); + DECR(this->timer); + + if (this->action != NEJIRON_ACTION_EXPLODING && this->action != NEJIRON_ACTION_INACTIVE) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->action != NEJIRON_ACTION_EXPLODING) { + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->blinkTimer == 0) { + this->eyeIndex++; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + this->blinkTimer = Rand_ZeroFloat(60.0f) + 20.0f; + } + } + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if (this->action != NEJIRON_ACTION_INACTIVE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->action != NEJIRON_ACTION_EXPLODING) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void EnBaguo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBaguo* this = THIS; + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { &D_060014C8, &D_060018C8, &D_06001CC8 }; + EnBaguo* this = THIS; + Gfx* gfx; + s32 eyeIndex; + void* virtualAddress; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + eyeIndex = this->eyeIndex; + virtualAddress = Lib_SegmentedToVirtual(sEyeTextures[eyeIndex]); + gSPSegment(&gfx[0], 0x08, virtualAddress); + + POLY_OPA_DISP = &gfx[1]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnBaguo_PostLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + EnBaguo_DrawRockParticles(this, globalCtx); +} + +void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 timer) { + s16 i; + NejironParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (!particle->isVisible) { + particle->isVisible = true; + particle->position = *position; + particle->velocity = *velocity; + particle->acceleration = *acceleration; + particle->scale = scale; + particle->timer = timer; + particle->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx) { + s32 i; + NejironParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + particle->position.x += particle->velocity.x; + particle->position.y += particle->velocity.y; + particle->position.z += particle->velocity.z; + particle->rotation.x += 0xBB8; + particle->rotation.y += 0xBB8; + particle->rotation.z += 0xBB8; + particle->velocity.x += particle->acceleration.x; + particle->velocity.y += particle->acceleration.y; + particle->velocity.z += particle->acceleration.z; + if (particle->position.y < (this->actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); + if (particle->scale <= 0.0001f) { + particle->timer = 0; + } + } + if (particle->timer != 0) { + particle->timer--; + } else { + particle->isVisible = false; + } + } + } +} + +void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { + s16 i; + NejironParticle* particle = this->particles; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, &D_0401FA40); + } + } + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h index c31dac7a0..2dc1d7b2c 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h @@ -7,11 +7,53 @@ struct EnBaguo; typedef void (*EnBaguoActionFunc)(struct EnBaguo*, GlobalContext*); +typedef enum { + /* 0x0 */ NEJIRON_ACTION_INACTIVE, // The Nejiron is either underground or emerging from underground + /* 0x1 */ NEJIRON_ACTION_ACTIVE, // The Nejiron is above ground and actively chasing the player + /* 0x2 */ NEJIRON_ACTION_RETREATING, // The Nejiron is burrowing back underground + /* 0x3 */ NEJIRON_ACTION_EXPLODING // The Nejiron has detonated +} NejironAction; + +/** + * These directions are relative to the Nejiron. + */ +typedef enum { + /* 0x0 */ NEJIRON_DIRECTION_RIGHT, + /* 0x1 */ NEJIRON_DIRECTION_LEFT +} NejironRollDirection; + +/** + * When a Nejiron explodes, rock particles fly out from where it exploded. + * This struct governs how these rock particles behave. + */ +typedef struct NejironParticle { + /* 0x00 */ u8 isVisible; + /* 0x04 */ Vec3f position; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f acceleration; + /* 0x28 */ Vec3s rotation; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} NejironParticle; // size = 0x38 + typedef struct EnBaguo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; - /* 0x01AC */ EnBaguoActionFunc actionFunc; - /* 0x01B0 */ char unk_1B0[0x71C]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[3]; + /* 0x19A */ Vec3s morphTable[3]; + /* 0x1AC */ EnBaguoActionFunc actionFunc; + /* 0x1B0 */ s16 eyeIndex; + /* 0x1B2 */ s16 blinkTimer; + /* 0x1B4 */ s16 timer; + /* 0x1B6 */ s16 action; + /* 0x1B8 */ s16 zRollDirection; + /* 0x1BC */ f32 maxDistanceFromHome; + /* 0x1C0 */ u8 hardHitFlag; + /* 0x1C4 */ Vec3f currentRotation; + /* 0x1D0 */ Vec3f targetRotation; + /* 0x1DC */ ColliderJntSph collider; + /* 0x1FC */ ColliderJntSphElement colliderElements[1]; + /* 0x23C */ NejironParticle particles[30]; } EnBaguo; // size = 0x8CC extern const ActorInit En_Baguo_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 12eb8ee6c..06583a169 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10297,20 +10297,20 @@ 0x80A3AEC8:("DmTsg_Draw",), 0x80A3B080:("EnBaguo_Init",), 0x80A3B1F4:("EnBaguo_Destroy",), - 0x80A3B220:("func_80A3B220",), - 0x80A3B2CC:("func_80A3B2CC",), - 0x80A3B3E0:("func_80A3B3E0",), - 0x80A3B5E0:("func_80A3B5E0",), - 0x80A3B794:("func_80A3B794",), - 0x80A3B7B8:("func_80A3B7B8",), - 0x80A3B8F8:("func_80A3B8F8",), - 0x80A3B958:("func_80A3B958",), + 0x80A3B220:("EnBaguo_UndergroundIdle",), + 0x80A3B2CC:("EnBaguo_EmergeFromUnderground",), + 0x80A3B3E0:("EnBaguo_Idle",), + 0x80A3B5E0:("EnBaguo_Roll",), + 0x80A3B794:("EnBaguo_SetupRetreatUnderground",), + 0x80A3B7B8:("EnBaguo_RetreatUnderground",), + 0x80A3B8F8:("EnBaguo_PostDetonation",), + 0x80A3B958:("EnBaguo_CheckForDetonation",), 0x80A3BC88:("EnBaguo_Update",), - 0x80A3BE24:("func_80A3BE24",), - 0x80A3BE60:("func_80A3BE60",), - 0x80A3BF0C:("func_80A3BF0C",), - 0x80A3C008:("func_80A3C008",), - 0x80A3C17C:("func_80A3C17C",), + 0x80A3BE24:("EnBaguo_PostLimbDraw",), + 0x80A3BE60:("EnBaguo_DrawBody",), + 0x80A3BF0C:("EnBaguo_InitializeParticle",), + 0x80A3C008:("EnBaguo_UpdateParticles",), + 0x80A3C17C:("EnBaguo_DrawRockParticles",), 0x80A3C4E0:("func_80A3C4E0",), 0x80A3C560:("func_80A3C560",), 0x80A3C658:("func_80A3C658",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 6c17154b8..058ec41a8 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1514,6 +1514,9 @@ D_060092A0 = 0x060092A0; // ovl_En_Baguo +D_060014C8 = 0x060014C8; +D_060018C8 = 0x060018C8; +D_06001CC8 = 0x06001CC8; D_060020E8 = 0x060020E8; // ovl_En_Baisen From 2907da61c3268f440e9ebb706ac1939f21a5aa7e Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Fri, 5 Nov 2021 15:03:11 +0000 Subject: [PATCH 82/86] xlitob.c OK (#417) * xlitob.c OK * spec --- include/variables.h | 4 +-- include/xstdio.h | 9 +++++- include/z64.h | 2 -- spec | 1 - src/libultra/rmon/xlitob.c | 55 ++++++++++++++++++++++++++++++++++++- src/libultra/rmon/xprintf.c | 6 ---- tools/disasm/variables.txt | 4 +-- 7 files changed, 66 insertions(+), 15 deletions(-) diff --git a/include/variables.h b/include/variables.h index b0b3e5c8c..c880ed136 100644 --- a/include/variables.h +++ b/include/variables.h @@ -86,8 +86,8 @@ extern __OSViContext* __osViCurr; extern __OSViContext* __osViNext; // extern UNK_TYPE4 D_800980D0; extern OSViMode osViModeFpalLan1; -extern char ldigs[]; -extern char udigs[]; +// extern u8 ldigs[]; +// extern u8 udigs[]; extern OSDevMgr __osViDevMgr; extern UNK_TYPE4 __additional_scanline; // extern UNK_TYPE1 D_80098180; diff --git a/include/xstdio.h b/include/xstdio.h index 6ea17e1c7..bb297e590 100644 --- a/include/xstdio.h +++ b/include/xstdio.h @@ -2,7 +2,6 @@ #define _XSTDIO_H_ #include "stdarg.h" - typedef struct { /* 0x0 */ union { /* 0x0 */ s64 ll; @@ -22,4 +21,12 @@ typedef struct { /* 0x34 */ u8 qual; } _Pft; +typedef void* (*PrintCallback)(void*, const char*, size_t); + +#define FLAGS_SPACE 1 +#define FLAGS_PLUS 2 +#define FLAGS_MINUS 4 +#define FLAGS_HASH 8 +#define FLAGS_ZERO 16 + #endif diff --git a/include/z64.h b/include/z64.h index c5f1c7b4a..6def660e0 100644 --- a/include/z64.h +++ b/include/z64.h @@ -498,8 +498,6 @@ typedef struct { typedef void(*osCreateThread_func)(void*); -typedef void* (*PrintCallback)(void*, const char*, size_t); - typedef enum { SLOWLY_CALLBACK_NO_ARGS, SLOWLY_CALLBACK_ONE_ARG, diff --git a/spec b/spec index 62d1aa3dd..f7bd47689 100644 --- a/spec +++ b/spec @@ -217,7 +217,6 @@ beginseg include "build/src/libultra/os/settimer.o" include "build/data/boot/__libm_qnan_f.rodata.o" include "build/src/libultra/rmon/xldtob.o" - include "build/data/boot/xldtob.data.o" include "build/src/libultra/libc/ldiv.o" include "build/src/libultra/rmon/xlitob.o" include "build/src/libultra/io/sirawwrite.o" diff --git a/src/libultra/rmon/xlitob.c b/src/libultra/rmon/xlitob.c index e5a280c5e..f200e01a4 100644 --- a/src/libultra/rmon/xlitob.c +++ b/src/libultra/rmon/xlitob.c @@ -1,3 +1,56 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/xlitob/_Litob.s") +#define BUFF_LEN 0x18 + +u8 ldigs[] = "0123456789abcdef"; +u8 udigs[] = "0123456789ABCDEF"; + +void _Litob(_Pft* args, u8 type) { + u8 buff[BUFF_LEN]; + const u8* numMap; + s32 base; + s32 idx; + u64 num; + lldiv_t quotrem; + + if (type == 'X') { + numMap = udigs; + } else { + numMap = ldigs; + } + + base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16); + idx = BUFF_LEN; + num = args->v.ll; + + if ((type == 'd' || type == 'i') && args->v.ll < 0) { + num = -num; + } + + if (num != 0 || args->prec != 0) { + buff[--idx] = numMap[num % base]; + } + + args->v.ll = num / base; + + while (args->v.ll > 0 && idx > 0) { + quotrem = lldiv(args->v.ll, base); + args->v.ll = quotrem.quot; + buff[--idx] = numMap[quotrem.rem]; + } + + args->n1 = BUFF_LEN - idx; + + memcpy(args->s, buff + idx, args->n1); + + if (args->n1 < args->prec) { + args->nz0 = args->prec - args->n1; + } + + if (args->prec < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { + idx = args->width - args->n0 - args->nz0 - args->n1; + if (idx > 0) { + args->nz0 += idx; + } + } +} diff --git a/src/libultra/rmon/xprintf.c b/src/libultra/rmon/xprintf.c index 0f4353f2a..313adc2e6 100644 --- a/src/libultra/rmon/xprintf.c +++ b/src/libultra/rmon/xprintf.c @@ -25,12 +25,6 @@ } \ } -#define FLAGS_SPACE 1 -#define FLAGS_PLUS 2 -#define FLAGS_MINUS 4 -#define FLAGS_HASH 8 -#define FLAGS_ZERO 16 - char spaces[] = " "; char zeroes[] = "00000000000000000000000000000000"; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 8f63c1c89..b320e233f 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -80,8 +80,8 @@ 0x800980C4:("__osViNext","__OSViContext*","",0x4), 0x800980D0:("D_800980D0","UNK_TYPE4","",0x4), 0x800980E0:("osViModeFpalLan1","OSViMode","",0x50), - 0x80098130:("ldigs","char","[]",0x14), - 0x80098144:("udigs","char","[]",0x14), + 0x80098130:("ldigs","u8","[]",0x14), + 0x80098144:("udigs","u8","[]",0x14), 0x80098160:("__osViDevMgr","OSDevMgr","",0x1c), 0x8009817C:("__additional_scanline","UNK_TYPE4","",0x4), 0x80098180:("D_80098180","UNK_TYPE1","",0x1), From 49f55ff0052340d29cffe2767fdc7d2ee5adb9f4 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 5 Nov 2021 19:15:47 -0700 Subject: [PATCH 83/86] EnvFlags OK (#404) * Matched * Remove magic number * Rename system to EnvFlags --- include/functions.h | 8 ++--- spec | 2 +- src/code/code_800F12D0.c | 9 ----- src/code/z_env_flags.c | 33 +++++++++++++++++++ src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 2 +- tools/disasm/files.txt | 2 +- tools/disasm/functions.txt | 8 ++--- 7 files changed, 44 insertions(+), 20 deletions(-) delete mode 100644 src/code/code_800F12D0.c create mode 100644 src/code/z_env_flags.c diff --git a/include/functions.h b/include/functions.h index be85d8642..1cacc5fed 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1652,10 +1652,10 @@ void func_800F0590(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2, s32 arg3); // void func_800F10AC(void); // void func_800F112C(void); u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); -void func_800F12D0(GlobalContext* globalCtx); -void func_800F1304(GlobalContext* globalCtx, s16 param_2); -void func_800F1374(s32 param_1, s16 param_2); -s16 func_800F13E8(GlobalContext* globalCtx, s16 param_2); +void EnvFlags_UnsetAll(GlobalContext* globalCtx); +void EnvFlags_Set(GlobalContext* globalCtx, s16 flag); +void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag); +s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag); s16 func_800F1460(s16 param_1); ActorCutscene* ActorCutscene_GetCutsceneImpl(s16 index); void ActorCutscene_Init(GlobalContext* globalCtx, ActorCutscene* cutscenes, s32 num); diff --git a/spec b/spec index f7bd47689..2350931e9 100644 --- a/spec +++ b/spec @@ -483,7 +483,7 @@ beginseg include "build/src/code/code_800F07C0.o" include "build/data/code/code_801BC2A0.data.o" include "build/src/code/z_face_reaction.o" - include "build/src/code/code_800F12D0.o" + include "build/src/code/z_env_flags.o" include "build/src/code/z_eventmgr.o" include "build/data/code/z_eventmgr.bss.o" include "build/src/code/z_fcurve_data.o" diff --git a/src/code/code_800F12D0.c b/src/code/code_800F12D0.c deleted file mode 100644 index d34f11e81..000000000 --- a/src/code/code_800F12D0.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F12D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F1304.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F1374.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F12D0/func_800F13E8.s") diff --git a/src/code/z_env_flags.c b/src/code/z_env_flags.c new file mode 100644 index 000000000..d76681512 --- /dev/null +++ b/src/code/z_env_flags.c @@ -0,0 +1,33 @@ +#include "global.h" + +void EnvFlags_UnsetAll(GlobalContext* globalCtx) { + u8 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->envFlags); i++) { + globalCtx->envFlags[i] = 0; + } +} + +void EnvFlags_Set(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = 1 << bit; + + globalCtx->envFlags[index] |= mask; +} + +void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = (1 << bit) ^ 0xFFFF; + + globalCtx->envFlags[index] &= mask; +} + +s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = 1 << bit; + + return globalCtx->envFlags[index] & mask; +} diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index ed485a110..fb983aa6f 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -98,7 +98,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { if (grottoType == DOORANA_TYPE_UNK) { // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (func_800F13E8(globalCtx, 5))) { + if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (EnvFlags_Get(globalCtx, 5))) { grottoIsOpen = 1; this->actor.flags &= ~0x10; // always update OFF } diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index f1938cf4c..c67027a73 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -379,7 +379,7 @@ 0x800F05C0 : "z_elf_message", 0x800F07C0 : "code_800F07C0", 0x800F1250 : "z_face_reaction", - 0x800F12D0 : "code_800F12D0", + 0x800F12D0 : "z_env_flags", 0x800F1460 : "z_eventmgr", 0x800F23E0 : "z_fcurve_data", 0x800F2620 : "z_fcurve_data_skelanime", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 06583a169..7e30deb3e 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1632,10 +1632,10 @@ 0x800F10AC:("func_800F10AC",), 0x800F112C:("func_800F112C",), 0x800F1250:("Text_GetFaceReaction",), - 0x800F12D0:("func_800F12D0",), - 0x800F1304:("func_800F1304",), - 0x800F1374:("func_800F1374",), - 0x800F13E8:("func_800F13E8",), + 0x800F12D0:("EnvFlags_UnsetAll",), + 0x800F1304:("EnvFlags_Set",), + 0x800F1374:("EnvFlags_Unset",), + 0x800F13E8:("EnvFlags_Get",), 0x800F1460:("func_800F1460",), 0x800F14F8:("ActorCutscene_GetCutsceneImpl",), 0x800F1544:("ActorCutscene_Init",), From e70a8fbb992eb05d606406ae70974e56bcf912dc Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Fri, 5 Nov 2021 23:44:58 -0300 Subject: [PATCH 84/86] Add `stddef.h` and libc headers cleanup (#396) * Move headers to include/libc * stddef * move math.h * General cleanup * move fabs, sqrtf and sqrt to math.h * move alloca and assert * whoops --- Makefile | 4 ++-- include/assert.h | 4 ---- include/convert.h | 2 +- include/functions.h | 7 ------- include/ichain.h | 6 +++--- include/{ => libc}/alloca.h | 0 include/libc/assert.h | 4 ++++ include/{ => libc}/math.h | 11 ++++++++-- include/{ => libc}/stdarg.h | 9 +++++---- include/{ => libc}/stdbool.h | 6 +++--- include/libc/stddef.h | 20 +++++++++++++++++++ include/{ => libc}/stdint.h | 8 ++++---- include/{ => libc}/stdlib.h | 12 +++++------ include/macros.h | 2 +- include/os.h | 2 +- include/osint.h | 2 +- include/xstdio.h | 3 ++- include/z64.h | 11 +++++----- src/libultra/gu/cosf.c | 2 +- src/libultra/gu/sinf.c | 2 +- src/libultra/gu/sins.c | 2 +- src/libultra/os/virtualtophysical.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- 23 files changed, 72 insertions(+), 51 deletions(-) delete mode 100644 include/assert.h rename include/{ => libc}/alloca.h (100%) create mode 100644 include/libc/assert.h rename include/{ => libc}/math.h (74%) rename include/{ => libc}/stdarg.h (96%) rename include/{ => libc}/stdbool.h (72%) create mode 100644 include/libc/stddef.h rename include/{ => libc}/stdint.h (86%) rename include/{ => libc}/stdlib.h (77%) diff --git a/Makefile b/Makefile index 6b62c2e64..b202b95c0 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ endif # Check code syntax with host compiler CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -include stdarg.h $(CHECK_WARNINGS) +CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) CPP := cpp ELF2ROM := tools/buildtools/elf2rom @@ -92,7 +92,7 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU diff --git a/include/assert.h b/include/assert.h deleted file mode 100644 index 04831e48f..000000000 --- a/include/assert.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _ASSERT_H_ -#define _ASSERT_H_ - -#endif diff --git a/include/convert.h b/include/convert.h index 456e4b198..c453e18e3 100644 --- a/include/convert.h +++ b/include/convert.h @@ -1,7 +1,7 @@ #ifndef _ULTRA64_CONVERT_H_ #define _ULTRA64_CONVERT_H_ -#include "stdint.h" +#include "libc/stdint.h" #define OS_CLOCK_RATE 62500000LL #define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) diff --git a/include/functions.h b/include/functions.h index 1cacc5fed..ad01b7a82 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3,13 +3,6 @@ #include "z64.h" -float fabsf(float f); -#pragma intrinsic(fabsf) -float sqrtf(float f); -#pragma intrinsic(sqrtf) -double sqrt(double d); -#pragma intrinsic(sqrt) - void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 arg0); diff --git a/include/ichain.h b/include/ichain.h index 8b1112191..f9131545c 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,6 +1,8 @@ #ifndef _ICHAIN_H_ #define _ICHAIN_H_ +#include "libc/stddef.h" + typedef struct { u32 cont: 1; u32 type: 4; @@ -8,8 +10,6 @@ typedef struct { s32 value: 16; } InitChainEntry; -#define OFFSETOF(structure, member) ((size_t)&(((structure*)0)->member)) - typedef enum { /* 0x0 */ ICHAINTYPE_U8, // sets byte /* 0x1 */ ICHAINTYPE_S8, @@ -38,7 +38,7 @@ typedef enum { * * cont ----- ICHAIN_CONTINUE (or ICHAIN_STOP) to continue (or stop) parsing */ #define ICHAIN(type, member, value, cont) \ - { cont, type, OFFSETOF(Actor, member), value } + { cont, type, offsetof(Actor, member), value } #define ICHAIN_U8(member, val, cont) ICHAIN(ICHAINTYPE_U8, member, val, cont) #define ICHAIN_S8(member, val, cont) ICHAIN(ICHAINTYPE_S8, member, val, cont) diff --git a/include/alloca.h b/include/libc/alloca.h similarity index 100% rename from include/alloca.h rename to include/libc/alloca.h diff --git a/include/libc/assert.h b/include/libc/assert.h new file mode 100644 index 000000000..1bc72e314 --- /dev/null +++ b/include/libc/assert.h @@ -0,0 +1,4 @@ +#ifndef ASSERT_H +#define ASSERT_H + +#endif diff --git a/include/math.h b/include/libc/math.h similarity index 74% rename from include/math.h rename to include/libc/math.h index 20fa352fa..c6756d959 100644 --- a/include/math.h +++ b/include/libc/math.h @@ -1,5 +1,5 @@ -#ifndef _MATH_H_ -#define _MATH_H_ +#ifndef MATH_H +#define MATH_H #include "PR/ultratypes.h" @@ -26,4 +26,11 @@ typedef union { extern f32 __libm_qnan_f; +float fabsf(float f); +#pragma intrinsic(fabsf) +float sqrtf(float f); +#pragma intrinsic(sqrtf) +double sqrt(double d); +#pragma intrinsic(sqrt) + #endif diff --git a/include/stdarg.h b/include/libc/stdarg.h similarity index 96% rename from include/stdarg.h rename to include/libc/stdarg.h index 26a67e580..77b8b8866 100644 --- a/include/stdarg.h +++ b/include/libc/stdarg.h @@ -1,5 +1,5 @@ -#ifndef _STDARG_H_ -#define _STDARG_H_ +#ifndef STDARG_H +#define STDARG_H #include "ultra64.h" @@ -41,5 +41,6 @@ typedef char *va_list; : __va_stack_arg(list, mode))))[-1] #define va_end(__list) -#endif -#endif +#endif /* __GNUC__ */ + +#endif /* STDARG_H */ diff --git a/include/stdbool.h b/include/libc/stdbool.h similarity index 72% rename from include/stdbool.h rename to include/libc/stdbool.h index 519806b31..d441054c1 100644 --- a/include/stdbool.h +++ b/include/libc/stdbool.h @@ -1,5 +1,5 @@ -#ifndef _STDBOOL -#define _STDBOOL +#ifndef STDBOOL +#define STDBOOL #define __bool_true_false_are_defined 1 @@ -11,4 +11,4 @@ #endif /* __cplusplus */ -#endif /* _STDBOOL */ +#endif /* STDBOOL */ diff --git a/include/libc/stddef.h b/include/libc/stddef.h new file mode 100644 index 000000000..4f55e5725 --- /dev/null +++ b/include/libc/stddef.h @@ -0,0 +1,20 @@ +#ifndef STDDEF_H +#define STDDEF_H + +#include "PR/ultratypes.h" + +typedef u32 size_t; + +typedef s32 ptrdiff_t; + +#ifndef NULL +#define NULL (void*)0 +#endif + +#ifdef __GNUC__ +#define offsetof(structure, member) __builtin_offsetof (structure, member) +#else +#define offsetof(structure, member) ((size_t)&(((structure*)0)->member)) +#endif + +#endif /* STDDEF_H */ diff --git a/include/stdint.h b/include/libc/stdint.h similarity index 86% rename from include/stdint.h rename to include/libc/stdint.h index 67e9e6862..1696615a7 100644 --- a/include/stdint.h +++ b/include/libc/stdint.h @@ -1,7 +1,7 @@ -#ifndef _STDINT_H_ -#define _STDINT_H_ +#ifndef STDINT_H +#define STDINT_H -#include "ultra64.h" +#include "PR/ultratypes.h" typedef s32 intptr_t; typedef u32 uintptr_t; @@ -26,4 +26,4 @@ typedef u32 uintptr_t; #define UINTPTR_MAX 0xffffffff -#endif /* _STDINT_H_ */ +#endif /* STDINT_H */ diff --git a/include/stdlib.h b/include/libc/stdlib.h similarity index 77% rename from include/stdlib.h rename to include/libc/stdlib.h index a7b44961a..57d352a13 100644 --- a/include/stdlib.h +++ b/include/libc/stdlib.h @@ -1,27 +1,25 @@ -#ifndef _STDLIB_H_ -#define _STDLIB_H_ +#ifndef STDLIB_H +#define STDLIB_H + +#include "libc/stddef.h" typedef struct { /* 0x0 */ int quot; /* 0x4 */ int rem; } div_t; - typedef struct { /* 0x0 */ long quot; /* 0x4 */ long rem; } ldiv_t; - typedef struct { /* 0x0 */ long long quot; /* 0x8 */ long long rem; } lldiv_t; -typedef unsigned long size_t; - typedef int ssize_t; typedef long wchar_t; -#endif +#endif /* STDLIB_H */ diff --git a/include/macros.h b/include/macros.h index 7dd84fc8e..2cff3c814 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,7 +1,7 @@ #ifndef _MACROS_H_ #define _MACROS_H_ -#include "stdint.h" +#include "libc/stdint.h" #include "convert.h" #include "z64.h" diff --git a/include/os.h b/include/os.h index f89239874..e9a5da37d 100644 --- a/include/os.h +++ b/include/os.h @@ -1,7 +1,7 @@ #ifndef _OS_H_ #define _OS_H_ -#include "stdlib.h" +#include "libc/stdlib.h" #include "ultra64/thread.h" #include "ultra64/message.h" diff --git a/include/osint.h b/include/osint.h index f4da044c6..71781ab6d 100644 --- a/include/osint.h +++ b/include/osint.h @@ -3,7 +3,7 @@ // TODO should be in libultra/os -#include "stdarg.h" +#include "libc/stdarg.h" #include "os.h" #include "os_internal.h" #include "ultraerror.h" diff --git a/include/xstdio.h b/include/xstdio.h index bb297e590..102a25ee4 100644 --- a/include/xstdio.h +++ b/include/xstdio.h @@ -1,6 +1,7 @@ #ifndef _XSTDIO_H_ #define _XSTDIO_H_ -#include "stdarg.h" + +#include "libc/stdarg.h" typedef struct { /* 0x0 */ union { diff --git a/include/z64.h b/include/z64.h index 6def660e0..99f05d653 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1,16 +1,17 @@ #ifndef _Z64_H_ #define _Z64_H_ -#include "stdarg.h" -#include "stdbool.h" -#include "stdint.h" +#include "libc/math.h" +#include "libc/stdarg.h" +#include "libc/stdbool.h" +#include "libc/stddef.h" +#include "libc/stdint.h" +#include "libc/stdlib.h" #include "ultra64.h" #include "io/controller.h" #include "osint.h" -#include "math.h" #include "os.h" -#include "stdlib.h" #include "xstdio.h" #include "bgm.h" diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index 72d154d70..b71ba7234 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -1,4 +1,4 @@ -#include "math.h" +#include "libc/math.h" #include "macros.h" // A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index 5f3455ec5..746d141a4 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -1,4 +1,4 @@ -#include "math.h" +#include "libc/math.h" #include "macros.h" // A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 diff --git a/src/libultra/gu/sins.c b/src/libultra/gu/sins.c index 69b3b7e39..39bc7ce0c 100644 --- a/src/libultra/gu/sins.c +++ b/src/libultra/gu/sins.c @@ -1,4 +1,4 @@ -#include "math.h" +#include "libc/math.h" static s16 sintable[0x400] = { 0x0000, 0x0032, 0x0064, 0x0096, 0x00C9, 0x00FB, 0x012D, 0x0160, 0x0192, 0x01C4, 0x01F7, 0x0229, 0x025B, 0x028E, diff --git a/src/libultra/os/virtualtophysical.c b/src/libultra/os/virtualtophysical.c index 40d286479..6bdb2ccb3 100644 --- a/src/libultra/os/virtualtophysical.c +++ b/src/libultra/os/virtualtophysical.c @@ -1,6 +1,6 @@ #include "PR/ultratypes.h" #include "osint.h" -#include "stdint.h" +#include "libc/stdint.h" #include "global.h" uintptr_t osVirtualToPhysical(void* virtualAddress) { diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index d58f7ac85..550bbbc8e 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -5,7 +5,7 @@ */ #include "z_select.h" -#include "alloca.h" +#include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" void Select_LoadTitle(SelectContext* this) { From 278ff4a4b372c7ef6e2ba8b7d114d76adcfbcecc Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 6 Nov 2021 00:29:56 -0300 Subject: [PATCH 85/86] `motor.c` OK (#397) * use motor in the spec * import bss * Delete viextendvstart.c * rename functions * move stuff and format * remove globals.h and ultra64.h * Update src/libultra/io/motor.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * add motor.h to padmgr * fix Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- include/functions.h | 4 +--- include/io/controller.h | 6 ++++++ include/ultra64/motor.h | 17 +++++++++++++++++ include/variables.h | 9 ++------- spec | 3 +-- src/boot_O1/viextendvstart.c | 5 ----- src/code/padmgr.c | 1 + src/libultra/io/motor.c | 21 +++++++++++++-------- src/libultra/io/rumblepak.c | 7 ------- tools/disasm/files.txt | 4 ++-- tools/disasm/functions.txt | 6 +++--- tools/sizes/boot_functions.csv | 6 +++--- 12 files changed, 49 insertions(+), 40 deletions(-) create mode 100644 include/ultra64/motor.h delete mode 100644 src/boot_O1/viextendvstart.c delete mode 100644 src/libultra/io/rumblepak.c diff --git a/include/functions.h b/include/functions.h index ad01b7a82..ced71293c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -276,9 +276,7 @@ void __osDequeueThread(OSThread** param_1, OSThread* param_2); void osDestroyThread(OSThread* puParm1); // void __osVoiceCheckResult(void); void bzero(void* begin, s32 length); -s32 osSetRumble(OSPfs* pfs, u32 vibrate); -// void osSetUpMempakWrite(void); -// void osProbeRumblePak(void); + void __osSiCreateAccessQueue(void); void __osSiGetAccess(void); void __osSiRelAccess(void); diff --git a/include/io/controller.h b/include/io/controller.h index 50add3561..91cbd51f8 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -145,5 +145,11 @@ typedef struct { /* 0x26 */ u8 datacrc; } __OSContRamReadFormat; +extern OSPifRam __osContPifRam; +// extern UNK_TYPE1 D_8009CF0C; +extern u8 __osContLastCmd; +extern u8 __osMaxControllers; +// extern OSMesgQueue D_8009CF38; +// extern OSMesg D_8009CF50; #endif diff --git a/include/ultra64/motor.h b/include/ultra64/motor.h new file mode 100644 index 000000000..ad6828132 --- /dev/null +++ b/include/ultra64/motor.h @@ -0,0 +1,17 @@ +#ifndef ULTRA64_MOTOR_H +#define ULTRA64_MOTOR_H + +#include "PR/ultratypes.h" +#include "PR/pfs.h" +#include "ultra64/message.h" + +#define MOTOR_START 1 +#define MOTOR_STOP 0 + +#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) +#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) + +s32 __osMotorAccess(OSPfs* pfs, u32 vibrate); +s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel); + +#endif diff --git a/include/variables.h b/include/variables.h index c880ed136..6b5fbe620 100644 --- a/include/variables.h +++ b/include/variables.h @@ -325,15 +325,10 @@ extern FaultDrawer sFaultDrawerStruct; extern u32 sRandFloat; // extern UNK_TYPE4 sArenaLockMsg; extern OSTask tmp_task; -extern OSPifRam osPifBuffers[4]; + extern OSMesg siAccessBuf[1]; extern OSMesgQueue __osSiAccessQueue; -extern OSPifRam __osContPifRam; -// extern UNK_TYPE1 D_8009CF0C; -extern u8 __osContLastCmd; -extern u8 __osMaxControllers; -// extern OSMesgQueue D_8009CF38; -// extern OSMesg D_8009CF50; + extern UNK_TYPE1 D_8009CF60; // extern UNK_TYPE4 D_8009CF70; extern OSThread __osThreadSave; diff --git a/spec b/spec index 2350931e9..a605ba93a 100644 --- a/spec +++ b/spec @@ -74,8 +74,7 @@ beginseg include "build/src/libultra/os/destroythread.o" include "build/src/libultra/voice/voicecheckresult.o" include "build/asm/boot/bzero.text.o" - include "build/src/libultra/io/rumblepak.o" - include "build/data/boot/rumblepak.bss.o" + include "build/src/libultra/io/motor.o" include "build/src/libultra/io/siacs.o" include "build/src/libultra/io/controller.o" include "build/src/libultra/os/createthread.o" diff --git a/src/boot_O1/viextendvstart.c b/src/boot_O1/viextendvstart.c deleted file mode 100644 index ce9f718d0..000000000 --- a/src/boot_O1/viextendvstart.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "global.h" - -void osViExtendVStart(u32 a0) { - __additional_scanline = a0; -} diff --git a/src/code/padmgr.c b/src/code/padmgr.c index a8ef1db15..0d539126a 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ultra64/motor.h" #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetControllerBitmask.s") diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index 25254c61b..4c0bfb67a 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -1,12 +1,16 @@ -#include "ultra64.h" -#include "global.h" +#include "ultra64/motor.h" + +#include "io/controller.h" +#include "functions.h" #define BANK_ADDR 0x400 #define MOTOR_ID 0x80 +OSPifRam osPifBuffers[MAXCONTROLLERS]; + s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); -s32 osSetRumble(OSPfs* pfs, u32 vibrate) { +s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { s32 i; s32 ret; u8* buf = (u8*)&osPifBuffers[pfs->channel]; @@ -45,10 +49,11 @@ s32 osSetRumble(OSPfs* pfs, u32 vibrate) { return ret; } -void osSetUpMempakWrite(u32 channel, OSPifRam* buf) { + +void _MakeMotorData(s32 channel, OSPifRam* buf) { u8* bufptr = (u8*)buf; __OSContRamReadFormat mempakwr; - u32 i; + s32 i; mempakwr.dummy = 0xFF; mempakwr.txsize = 0x23; @@ -68,7 +73,7 @@ void osSetUpMempakWrite(u32 channel, OSPifRam* buf) { *bufptr = 0xFE; } -s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { +s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) { s32 ret; u8 sp24[BLOCKSIZE]; @@ -111,8 +116,8 @@ s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { if (sp24[BLOCKSIZE - 1] != MOTOR_ID) { return 0xB; } - if ((pfs->status & PFS_MOTOR_INITIALIZED) == 0) { - osSetUpMempakWrite(channel, &osPifBuffers[channel]); + if (!(pfs->status & PFS_MOTOR_INITIALIZED)) { + _MakeMotorData(channel, &osPifBuffers[channel]); } pfs->status = PFS_MOTOR_INITIALIZED; diff --git a/src/libultra/io/rumblepak.c b/src/libultra/io/rumblepak.c deleted file mode 100644 index 3353059da..000000000 --- a/src/libultra/io/rumblepak.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osSetRumble.s") - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osSetUpMempakWrite.s") - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osProbeRumblePak.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index c67027a73..b9a7a0dfd 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -86,7 +86,7 @@ 0x80089470 : "destroythread", 0x80089580 : "voicecheckresult", 0x80089630 : "bzero", - 0x800896D0 : "rumblepak", + 0x800896D0 : "motor", 0x80089AA0 : "siacs", 0x80089B60 : "controller", 0x80089E40 : "createthread", @@ -321,7 +321,7 @@ 0x8009CD50 : "rand", 0x8009CD60 : "__osMalloc", 0x8009CD70 : "sptask", - 0x8009CDB0 : "rumblepak", + 0x8009CDB0 : "motor", 0x8009CEB0 : "siacs", 0x8009CED0 : "controller", 0x8009CF60 : "voicegetreaddata", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7e30deb3e..60dc19aca 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -280,9 +280,9 @@ 0x80089470:("osDestroyThread",), 0x80089580:("__osVoiceCheckResult",), 0x80089630:("bzero",), - 0x800896D0:("osSetRumble",), - 0x80089838:("osSetUpMempakWrite",), - 0x80089944:("osProbeRumblePak",), + 0x800896D0:("__osMotorAccess",), + 0x80089838:("_MakeMotorData",), + 0x80089944:("osMotorInit",), 0x80089AA0:("__osSiCreateAccessQueue",), 0x80089AF0:("__osSiGetAccess",), 0x80089B34:("__osSiRelAccess",), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 9d9b2d8b0..46e57b75c 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -277,9 +277,9 @@ asm/non_matchings/boot/thread/__osDequeueThread.s,__osDequeueThread,0x80089430,0 asm/non_matchings/boot/destroythread/osDestroyThread.s,osDestroyThread,0x80089470,0x44 asm/non_matchings/boot/voicecheckresult/__osVoiceCheckResult.s,__osVoiceCheckResult,0x80089580,0x2C asm/non_matchings/boot/bzero/bzero.s,bzero,0x80089630,0x28 -asm/non_matchings/boot/rumblepak/osSetRumble.s,osSetRumble,0x800896D0,0x5A -asm/non_matchings/boot/rumblepak/osSetUpMempakWrite.s,osSetUpMempakWrite,0x80089838,0x43 -asm/non_matchings/boot/rumblepak/osProbeRumblePak.s,osProbeRumblePak,0x80089944,0x57 +asm/non_matchings/boot/rumblepak/__osMotorAccess.s,__osMotorAccess,0x800896D0,0x5A +asm/non_matchings/boot/rumblepak/_MakeMotorData.s,_MakeMotorData,0x80089838,0x43 +asm/non_matchings/boot/rumblepak/osMotorInit.s,osMotorInit,0x80089944,0x57 asm/non_matchings/boot/siacs/__osSiCreateAccessQueue.s,__osSiCreateAccessQueue,0x80089AA0,0x14 asm/non_matchings/boot/siacs/__osSiGetAccess.s,__osSiGetAccess,0x80089AF0,0x11 asm/non_matchings/boot/siacs/__osSiRelAccess.s,__osSiRelAccess,0x80089B34,0xB From 77b9431f11a6ca9a1565f3041439f38b74139af6 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Fri, 5 Nov 2021 23:59:45 -0400 Subject: [PATCH 86/86] En_hakurock rOcK (#355) * inital commit with a good chunk done * adsjfkalsdfh * can't figure this out for the life of me... * I'll come back to this later * not finished, but at least OKs * blah, still stuck * en_hakurock OK * minor clean up * formatting and pushing up changes * fixing spec * fixing warnings and addressing feedback * addressing PR comments from engineer * fixing enum * format --- spec | 3 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.h | 13 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 334 ++++++++++++++++-- .../actors/ovl_En_Hakurock/z_en_hakurock.h | 15 +- tools/disasm/functions.txt | 2 +- 5 files changed, 330 insertions(+), 37 deletions(-) diff --git a/spec b/spec index a605ba93a..f3cd6c8ba 100644 --- a/spec +++ b/spec @@ -3984,8 +3984,7 @@ beginseg name "ovl_En_Hakurock" compress include "build/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.o" - include "build/data/ovl_En_Hakurock/ovl_En_Hakurock.data.o" - include "build/data/ovl_En_Hakurock/ovl_En_Hakurock.reloc.o" + include "build/src/overlays/actors/ovl_En_Hakurock/ovl_En_Hakurock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index 4f5686aea..5e29a3815 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -7,11 +7,22 @@ struct BossHakugin; typedef void (*BossHakuginActionFunc)(struct BossHakugin*, GlobalContext*); +typedef struct BossHakuginParticle { + /* 0x00 */ Vec3f unk_0; + /* 0x0C */ Vec3f unk_C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ f32 unk_24; +} BossHakuginParticle; // size = 0x28 + typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x3684]; + /* 0x018C */ char unk_18C[0x86C]; + /* 0x09F8 */ BossHakuginParticle unk_9F8[180]; + /* 0x0A14 */ char unk_A04[0x2DFC]; } BossHakugin; // size = 0x3810 extern const ActorInit Boss_Hakugin_InitVars; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 039397802..167180dab 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -1,10 +1,11 @@ /* * File: z_en_hakurock.c - * Overlay: ovl_En_Hakurock - * Description: Rocks Kicked Up by Goht + * Overlay: En_Hakurock + * Description: Goht Debris */ #include "z_en_hakurock.h" +#include "overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h" #define FLAGS 0x00000030 @@ -14,13 +15,21 @@ void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx); void EnHakurock_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2); +void func_80B21EA4(EnHakurock* this, s32 arg1); +void func_80B21FFC(EnHakurock* this); void func_80B22040(EnHakurock* this, GlobalContext* globalCtx); +void func_80B220A8(EnHakurock* this); void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx); +void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx); void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx); +void func_80B224C0(EnHakurock* this); void func_80B22500(EnHakurock* this, GlobalContext* globalCtx); +void func_80B226AC(EnHakurock* this); void func_80B22750(EnHakurock* this, GlobalContext* globalCtx); +void func_80B228F4(Actor* thisx, GlobalContext* globalCtx); +void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hakurock_InitVars = { ACTOR_EN_HAKUROCK, ACTORCAT_ITEMACTION, @@ -33,53 +42,318 @@ const ActorInit En_Hakurock_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B22A80 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x00 }, { 0xF3CFBBFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x00 }, + { 0xF3CFBBFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 60, 60, -30, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B22AAC = { 0, 60, 60, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 60, 60, MASS_IMMOVABLE }; -#endif +extern Gfx D_06011100[]; -extern ColliderCylinderInit D_80B22A80; -extern CollisionCheckInfoInit D_80B22AAC; +// Stalactite +extern Gfx D_06011178[]; -extern UNK_TYPE D_06011100; +void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHakurock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/EnHakurock_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 52.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { + this->actor.gravity = -1.5f; + } else { + this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; + this->actor.minVelocityY = -100.0f; + this->actor.gravity = -7.0f; + } + func_80B21FFC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/EnHakurock_Destroy.s") +void EnHakurock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHakurock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B21BE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B21EA4.s") +void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B21FFC.s") + for (i = 0; i < ARRAY_COUNT(parent->unk_9F8); i++) { + BossHakuginParticle* gohtParticle = &parent->unk_9F8[i]; + if (gohtParticle->unk_18 < 0) { + s16 sp2E; + s16 sp2C; + f32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B22040.s") + Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); + sp2C = Rand_S16Offset(0x1000, 0x3000); + sp2E = (u32)Rand_Next() >> 0x10; + sp28 = Rand_ZeroFloat(5.0f) + 10.0f; + gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); + gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); + gohtParticle->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); + if ((arg2 == 1) || (arg2 == 3)) { + gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); + gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.x) + arg1->x; + gohtParticle->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.y) + arg1->y; + gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.z) + arg1->z; + gohtParticle->unk_1A = 1; + } else { + gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); + gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.x) + arg1->x; + gohtParticle->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtParticle->unk_C.y) + arg1->y; + gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; + gohtParticle->unk_1A = 0; + } + gohtParticle->unk_1C.x = Rand_Next() >> 0x10; + gohtParticle->unk_1C.y = Rand_Next() >> 0x10; + gohtParticle->unk_1C.z = Rand_Next() >> 0x10; + gohtParticle->unk_18 = 0x28; + return; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B220A8.s") +void func_80B21EA4(EnHakurock* this, s32 arg1) { + Vec3f sp4C; + s32 i; + f32 scaleFactor; + s32 tmp; + s32 phi_s5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B221E8.s") + if (arg1 == 0) { + for (i = 0; i < 20; i++) { + func_80B21BE0((BossHakugin*)this->actor.parent, &this->actor.world.pos, arg1); + } + } else if (arg1 == 2) { + for (i = 0; i < 10; i++) { + func_80B21BE0((BossHakugin*)this->actor.parent, &this->actor.world.pos, arg1); + } + } else { + Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); + scaleFactor = this->actor.scale.x * 600.0f; + if (arg1 == 1) { + sp4C.y -= scaleFactor; + i = 0; + } else { + i = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B222AC.s") + for (; i < 3; i++) { + tmp = (i * 5) + 5; + for (phi_s5 = 0; phi_s5 < tmp; phi_s5++) { + func_80B21BE0((BossHakugin*)this->actor.parent, &sp4C, arg1); + } + sp4C.y += scaleFactor; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B2242C.s") +void func_80B21FFC(EnHakurock* this) { + this->actor.bgCheckFlags &= ~1; + this->collider.base.atFlags &= ~AT_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->actor.draw = NULL; + this->actor.params = EN_HAKUROCK_TYPE_UNK_0; + this->actionFunc = func_80B22040; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B224C0.s") +void func_80B22040(EnHakurock* this, GlobalContext* globalCtx) { + if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { + func_80B220A8(this); + } else if (this->actor.params == EN_HAKUROCK_TYPE_UNK_2) { + func_80B222AC(this, globalCtx); + } else if (this->actor.params == EN_HAKUROCK_TYPE_FENCE_PILLAR) { + func_80B226AC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B22500.s") +void func_80B220A8(EnHakurock* this) { + this->actor.params = EN_HAKUROCK_TYPE_BOULDER; + this->actor.draw = func_80B228F4; + this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; + this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; + Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); + this->actor.world.rot.y = (Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; + this->actor.shape.rot.x = Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; + this->actor.shape.rot.z = Rand_Next() >> 0x10; + this->collider.dim.radius = (this->actor.scale.x * 2500.0f); + this->collider.dim.yShift = -this->collider.dim.radius; + this->collider.dim.height = this->collider.dim.radius * 2; + this->counter = 10; + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + this->actionFunc = func_80B221E8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B226AC.s") +void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { + if (this->counter > 0) { + this->counter--; + } + this->actor.shape.rot.x += 0x700; + this->actor.shape.rot.y += 0x900; + this->actor.shape.rot.z += 0xB00; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B22750.s") + if (this->collider.base.atFlags & AT_HIT || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || + ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f))) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); + func_80B21EA4(this, 0); + func_80B21FFC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/EnHakurock_Update.s") +void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B228F4.s") + this->actor.draw = EnHakurock_Draw; + angle = (Rand_Next() >> 0x13) + player->actor.shape.rot.y; + this->actor.shape.rot.y = Rand_Next() >> 0x10; + this->actor.world.pos.x = (Math_SinS(angle) * 600.0f) + player->actor.world.pos.x; + this->actor.world.pos.y = player->actor.world.pos.y + 700.0f; + this->actor.world.pos.z = (Math_CosS(angle) * 600.0f) + player->actor.world.pos.z; + this->actor.shape.shadowScale = 5.0f; + this->actor.velocity.y = -10.0f; + Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 17.0f) * 0.01f); + this->actor.scale.x *= 0.6f; + this->actor.scale.z *= 0.6f; + this->collider.dim.radius = (this->actor.scale.x * 150.0f); + this->collider.dim.yShift = (this->actor.scale.y * -750.0f); + this->collider.dim.height = this->collider.dim.yShift * -2; + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + this->actor.params = EN_HAKUROCK_TYPE_UNK_2; + this->actionFunc = func_80B2242C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hakurock/func_80B229A4.s") +void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx) { + if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.oc == this->actor.parent)) { + func_80B21EA4(this, 1); + func_80B21FFC(this); + } else if ((this->actor.bgCheckFlags & 1)) { + func_80B21EA4(this, 2); + Audio_PlayActorSound2(&this->actor, NA_SE_EV_OBJECT_STICK); + func_80B224C0(this); + } +} + +void func_80B224C0(EnHakurock* this) { + this->actor.params = EN_HAKUROCK_TYPE_STALACTITE; + this->counter = 10; + this->actor.shape.shadowScale = 0.0f; + this->actor.world.pos.y += 4.0f; + this->actionFunc = func_80B22500; +} + +void func_80B22500(EnHakurock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->counter > 0) { + this->counter--; + if ((this->counter & 1) == 0) { + this->actor.world.pos.y = (sin_rad(this->counter * (M_PI / 20)) * 4.0f) + this->actor.floorHeight; + } else { + this->actor.world.pos.y = this->actor.floorHeight; + } + } + if (this->collider.base.ocFlags1 & OC1_HIT) { + if ((this->collider.base.oc == this->actor.parent) || + ((this->collider.base.oc->id == ACTOR_EN_HAKUROCK) && + (this->collider.base.oc->params == EN_HAKUROCK_TYPE_UNK_2))) { + func_80B21EA4(this, 3); + func_80B21FFC(this); + } else if ((&player->actor == this->collider.base.oc) && ((player->stateFlags3 & 0x81000) != 0) && + (player->linearVelocity > 8.0f)) { + player->unk_B08[0] = player->linearVelocity = -5.0f; + player->unk_B08[1] += (player->linearVelocity * 0.05f); + player->actor.velocity.y = 5.0f; + player->currentYaw = player->actor.world.rot.y; + player->actor.home.rot.y = player->actor.world.rot.y; + player->actor.shape.rot.y = player->actor.world.rot.y; + player->unk_B8C = 4; + } + + } else if ((this->actor.xzDistToPlayer > 1000.0f) && (this->actor.projectedPos.z < 0.0f)) { + func_80B21FFC(this); + } +} + +void func_80B226AC(EnHakurock* this) { + f32 shiftFactor; + + this->actor.draw = EnHakurock_Draw; + Actor_SetScale(&this->actor, 0.35f); + this->actor.scale.y = 0.5f; + this->collider.dim.radius = this->actor.scale.x * 270.0f; + shiftFactor = -750.0f; + this->collider.dim.yShift = 0.5f * shiftFactor; + this->counter = 0; + this->actor.shape.shadowScale = 0.0f; + this->collider.dim.height = this->collider.dim.yShift * -2; + this->actionFunc = func_80B22750; +} + +void func_80B22750(EnHakurock* this, GlobalContext* globalCtx) { + if (this->actor.params == EN_HAKUROCK_TYPE_UNK_0) { + func_80B21EA4(this, 3); + func_80B21FFC(this); + } +} + +void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHakurock* this = THIS; + s16 rockParams; + + this->actionFunc(this, globalCtx); + rockParams = this->actor.params; + if ((rockParams == EN_HAKUROCK_TYPE_BOULDER) || (rockParams == EN_HAKUROCK_TYPE_UNK_2)) { + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); + if (this->actor.floorHeight == BGCHECK_Y_MIN) { + func_80B21FFC(this); + } else { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else if ((rockParams == EN_HAKUROCK_TYPE_STALACTITE) || (rockParams == EN_HAKUROCK_TYPE_FENCE_PILLAR)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B228F4(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 185, 24, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &D_0406AB30); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, 1); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_06011100); + gSPDisplayList(POLY_OPA_DISP++, D_06011178); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h index 4890438aa..eb1c4eb5d 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.h @@ -7,10 +7,19 @@ struct EnHakurock; typedef void (*EnHakurockActionFunc)(struct EnHakurock*, GlobalContext*); +typedef enum { + /* 0x0 */ EN_HAKUROCK_TYPE_UNK_0, + /* 0x1 */ EN_HAKUROCK_TYPE_BOULDER, + /* 0x2 */ EN_HAKUROCK_TYPE_UNK_2, + /* 0x3 */ EN_HAKUROCK_TYPE_STALACTITE, + /* 0x4 */ EN_HAKUROCK_TYPE_FENCE_PILLAR +} EnHakurockType; + typedef struct EnHakurock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnHakurockActionFunc actionFunc; - /* 0x0148 */ char unk_144[0x50]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnHakurockActionFunc actionFunc; + /* 0x148 */ s32 counter; + /* 0x14C */ ColliderCylinder collider; } EnHakurock; // size = 0x198 extern const ActorInit En_Hakurock_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 60dc19aca..b6ec70b65 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13250,7 +13250,7 @@ 0x80B22750:("func_80B22750",), 0x80B2278C:("EnHakurock_Update",), 0x80B228F4:("func_80B228F4",), - 0x80B229A4:("func_80B229A4",), + 0x80B229A4:("EnHakurock_Draw",), 0x80B22C00:("func_80B22C00",), 0x80B22C2C:("func_80B22C2C",), 0x80B22C80:("func_80B22C80",),