diff --git a/include/functions.h b/include/functions.h index 9a585dee10..82e33bb1c6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -807,11 +807,11 @@ f32* func_800B8248(PosRot* param_1, ActorPlayer* param_2); // void func_800B83F8(void); s32 func_800B84D0(Actor* actor, GlobalContext* globalCtx); // Actor_IsTalking s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 fParm3, f32 fParm4, s32 param_5); -void func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 uParm3, s32 uParm4); -void func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 uParm3); -void func_800B863C(Actor* actor, GlobalContext* globalCtx); +s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 uParm3, s32 uParm4); +s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 uParm3); +s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); u32 func_800B867C(Actor* actor, GlobalContext* globalCtx); -// UNK_TYPE4 func_800B86C8(UNK_TYPE4 param_1, GlobalContext* globalCtx, UNK_TYPE4 param_3); +UNK_TYPE4 func_800B86C8(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); s32 func_800B8708(GlobalContext* globalCtx); // void func_800B8718(void); // void func_800B874C(void); @@ -819,7 +819,7 @@ s32 func_800B8708(GlobalContext* globalCtx); // void func_800B882C(void); // void func_800B886C(void); void func_800B8898(GlobalContext* globalCtx, Actor* actor, UNK_PTR param_3, UNK_PTR param_4); -// void func_800B8934(void); +s32 func_800B8934(GlobalContext* globalCtx, Actor* actor); u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); UNK_TYPE4 func_800B8A1C(Actor* actor, GlobalContext* globalCtx, s32 iParm3, f32 fParm4, f32 param_5); // void func_800B8B84(void); @@ -1723,7 +1723,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire); // void func_800F3ED4(void); void func_800F40A0(GlobalContext* globalCtx, s32 param_2); // void func_800F415C(void); -// void func_800F41E4(void); +UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); // void func_800F42A0(void); // void func_800F43BC(void); // void func_800F44F4(void); @@ -1789,7 +1789,7 @@ void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); -// void func_800FD750(void); +void func_800FD750(UNK_TYPE arg0); // void func_800FD768(void); void func_800FD78C(GlobalContext* globalCtx); void func_800FD858(GlobalContext* globalCtx); @@ -2149,7 +2149,7 @@ u32 Item_Give(GlobalContext* globalCtx, u8 param_2); // void func_80114A9C(void); // void func_80114B84(void); // void func_80114CA0(void); -// void func_80114E90(void); +UNK_TYPE func_80114E90(void); // void func_80114F2C(void); // void func_80114FD0(void); // void func_80115130(void); @@ -2162,7 +2162,7 @@ u32 Item_Give(GlobalContext* globalCtx, u8 param_2); void func_80115844(GlobalContext* globalCtx, s16 param_2); void func_80115908(GlobalContext* globalCtx, u8 param_2); void func_801159c0(s16 param_1); -// void func_801159EC(void); +void func_801159EC(s16 arg0); // void func_80115A14(void); // void Parameter_AddMagic(void); // void func_80115D5C(void); @@ -2709,18 +2709,18 @@ UNK_TYPE func_8013BC6C(SkelAnime* skelAnime, UNK_PTR arg1, s32 arg2); // void func_8013CD64(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); // void func_8013CF04(void); // void func_8013D0E0(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_8013D2E0(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_8013D5E8(void); -// void func_8013D648(void); -// void func_8013D68C(void); +void func_8013D2E0(Vec3f* arg0, PosRot* arg1, ActorShape* arg2, s16* arg3, s16* arg4, s16* arg5, s16* arg6); +UNK_TYPE func_8013D5E8(s16 arg0, UNK_TYPE arg1, s16 arg2); +u8* func_8013D648(GlobalContext *globalCtx, s16 arg1, s32 arg2); +UNK_TYPE func_8013D68C(u8* arg0, s16 arg1, UNK_PTR arg2); // void func_8013D720(void); -// void func_8013D768(void); +UNK_TYPE func_8013D768(Actor* actor, UNK_PTR arg1, s16 arg2); // void func_8013D83C(void); // void func_8013D8DC(void); // void func_8013D924(void); Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, struct Actor* actorListStart, s32 actorCategory, s32 actorId); -// void func_8013D9C8(void); -// void func_8013DB90(void); +void func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, UNK_TYPE arg3); +u8 func_8013DB90(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); // void func_8013DC40(void); // void func_8013DCE0(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_TYPE1 param_10); // void func_8013DE04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -3860,7 +3860,7 @@ void func_8019F230(void); // void func_8019F780(void); // void func_8019F7D8(void); // void func_8019F830(void); -// void func_8019F88C(void); +void func_8019F88C(Vec3f* arg0, UNK_TYPE arg1, UNK_TYPE arg2); // void func_8019F900(void); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 param_2, f32 param_3); diff --git a/include/variables.h b/include/variables.h index 0faa35c66d..f61e8cdc74 100644 --- a/include/variables.h +++ b/include/variables.h @@ -957,7 +957,7 @@ extern GameStateOverlay daytelopGameStateInfo; // extern UNK_TYPE2 D_801BDA78; // extern UNK_TYPE2 D_801BDA7C; // extern UNK_TYPE4 D_801BDA9C; -// extern UNK_TYPE4 D_801BDAA0; +extern UNK_TYPE4 D_801BDAA0; // extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; diff --git a/include/z64actor.h b/include/z64actor.h index 2a0ef14d06..be246d0598 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -358,6 +358,15 @@ typedef struct { /* 0x14 */ f32 morphFrames; } ActorAnimationEntry; // size = 0x18 +typedef struct { + /* 0x00 */ AnimationHeader* animationSeg; + /* 0x04 */ f32 playbackSpeed; + /* 0x08 */ s16 frame; + /* 0x0A */ s16 frameCount; + /* 0x0C */ u8 mode; + /* 0x0E */ s16 transitionRate; +} ActorAnimationEntryS; // size = 0x10 + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index c04a668ceb..20eb6af011 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -1827,9 +1827,9 @@ SECTIONS ovl_En_In : AT(RomLocation) { build/src/overlays/actors/ovl_En_In/z_en_in.o(.text) - build/asm/overlays/ovl_En_In_data.o(.data) + build/src/overlays/actors/ovl_En_In/z_en_in.o(.data) build/src/overlays/actors/ovl_En_In/z_en_in.o(.rodata) - build/asm/overlays/ovl_En_In_rodata.o(.rodata) + build/src/overlays/actors/ovl_En_In/z_en_in_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index 9451eddbbc..1a745c1b43 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -263,6 +263,55 @@ D_060000D0 = 0x060000D0; D_06001290 = 0x06001290; D_06001470 = 0x06001470; +/* en_in */ +D_06014EA8 = 0x06014EA8; +D_06015E38 = 0x06015E38; +D_06016484 = 0x06016484; +D_06016A60 = 0x06016A60; +D_060170DC = 0x060170DC; +D_060177AC = 0x060177AC; +D_06018240 = 0x06018240; +D_060187C8 = 0x060187C8; +D_060198A8 = 0x060198A8; +D_06007A70 = 0x06007A70; +D_06007C48 = 0x06007C48; +D_0601C528 = 0x0601C528; +D_06001C30 = 0x06001C30; +D_06003520 = 0x06003520; +D_060035E0 = 0x060035E0; +D_06004820 = 0x06004820; +D_06004C20 = 0x06004C20; +D_060043E0 = 0x060043E0; +D_06001D10 = 0x06001D10; +D_06014F8C = 0x06014F8C; +D_06000CB0 = 0x06000CB0; +D_060003B4 = 0x060003B4; +D_06001BE0 = 0x06001BE0; +D_06015918 = 0x06015918; +D_0601C0B0 = 0x0601C0B0; +D_0601A140 = 0x0601A140; +D_0601B904 = 0x0601B904; +D_0601B3C4 = 0x0601B3C4; +D_06019EB4 = 0x06019EB4; +D_06014C30 = 0x06014C30; +D_060138D0 = 0x060138D0; +D_060149A8 = 0x060149A8; +D_06014710 = 0x06014710; +D_06013DE0 = 0x06013DE0; +D_06014420 = 0x06014420; +D_06014040 = 0x06014040; +D_06013A00 = 0x06013A00; +D_06013440 = 0x06013440; +D_06013670 = 0x06013670; +D_060145D8 = 0x060145D8; +D_06013F10 = 0x06013F10; +D_06013540 = 0x06013540; +D_06012DF8 = 0x06012DF8; +D_06014AE0 = 0x06014AE0; +D_06012A78 = 0x06012A78; +D_060137A0 = 0x060137A0; +D_06014860 = 0x06014860; + /* z_dm_statue */ D_06001788 = 0x06001788; D_06000520 = 0x06000520; 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 cfb90a2353..8ec88c03b2 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -31,7 +31,7 @@ extern UNK_TYPE D_06000990; extern FlexSkeletonHeader D_06008C40; -// Probably the same struct as EnFgAnimation, need more info from func_8013BC6C +// Probably the same struct as ActorAnimationEntryS, need more info from func_8013BC6C static UNK_TYPE D_80C1E200[] = { &D_06000990, 0x3F800000, 0x0000FFFF, 0x00000000 }; s32 func_80C1DED0(DmNb* this, s32 arg1) { 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 e253b862b4..7fa6d897ce 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -79,7 +79,7 @@ static DamageTable sDamageTable = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static EnFgAnimation sAnimations[] = { +static ActorAnimationEntryS sAnimations[] = { { &D_06001534, 1.0f, 0, -1, 0, 0 }, { &D_06001534, 1.0f, 0, -1, 0, -4 }, { &D_060011C0, 1.0f, 0, -1, 0, -4 }, 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 f21bace332..b7ecca4841 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.h +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.h @@ -26,17 +26,6 @@ typedef enum { /* 0x05 */ FG_DMGEFFECT_ICEARROW, } FrogDamageEffect; -// TODO: This is a common struct and may be moved to a more global header -// Typically the frame/transition data is f32, not s16. -typedef struct { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; - /* 0x08 */ s16 frame; - /* 0x0A */ s16 frameCount; - /* 0x0C */ u8 mode; - /* 0x0E */ s16 transitionRate; -} EnFgAnimation; // size = 0x10 - typedef struct { /* 0x0000 */ u8 type; /* 0x0001 */ u8 timer; 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 9148a735db..1ae3545124 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 @@ -445,7 +445,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->previousBankValue = (s16)(gSaveContext.roomInf[127][0] & 0xFFFF); gSaveContext.roomInf[127][0] = (gSaveContext.roomInf[127][0] & 0xFFFF0000) | (((gSaveContext.roomInf[127][0] & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - this->serviceFee); - func_801159EC((s16)globalCtx->msgCtx.bankRupeesSelected, &gSaveContext); + func_801159EC(globalCtx->msgCtx.bankRupeesSelected); } } else { func_8019F230(); 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 a53bb8ab9d..1f4327d3cb 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1,15 +1,39 @@ +/* + * File z_en_in.c + * Overlay: ovl_en_in + * Description: Gorman Bros + */ + #include "z_en_in.h" #define FLAGS 0x00000019 #define THIS ((EnIn*)thisx) +#define SET_FLAGS_FINISH_RACE \ + { \ + gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ + gSaveContext.weekEventReg[92] = \ + gSaveContext.weekEventReg[92] | (u8)(gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)); \ + } + +#define SET_FLAGS_START_RACE \ + { \ + gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ + gSaveContext.weekEventReg[92] = \ + gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)) | 1); \ + } + void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void func_808F5A94(EnIn* this, GlobalContext* globalCtx); +void func_808F3690(EnIn* this, GlobalContext* globalCtx); +void func_808F5A34(EnIn* this, GlobalContext* globalCtx); +s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3); + const ActorInit En_In_InitVars = { ACTOR_EN_IN, ACTORCAT_NPC, @@ -21,92 +45,1572 @@ const ActorInit En_In_InitVars = { (ActorFunc)EnIn_Update, (ActorFunc)EnIn_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F30B0.asm") +extern FlexSkeletonHeader D_06014EA8; +extern AnimationHeader D_06015E38; +extern AnimationHeader D_06016484; +extern AnimationHeader D_06016A60; +extern AnimationHeader D_060170DC; +extern AnimationHeader D_060177AC; +extern AnimationHeader D_06018240; +extern AnimationHeader D_060187C8; +extern AnimationHeader D_060198A8; +extern Gfx D_06007A70[]; +extern Gfx D_06007C48[]; +extern Gfx D_0601C528[]; +extern AnimatedMaterial D_06001C30; +extern UNK_TYPE D_06003520; +extern UNK_TYPE D_060035E0; +extern UNK_TYPE D_06004820; +extern UNK_TYPE D_06004C20; +extern UNK_TYPE D_060043E0; +extern AnimationHeader D_06001D10; +extern AnimationHeader D_06014F8C; +extern AnimationHeader D_06000CB0; +extern AnimationHeader D_060003B4; +extern AnimationHeader D_06001BE0; +extern AnimationHeader D_06015918; +extern AnimationHeader D_0601C0B0; +extern AnimationHeader D_0601A140; +extern AnimationHeader D_0601B904; +extern AnimationHeader D_0601B3C4; +extern AnimationHeader D_06019EB4; +extern Gfx D_060137A0[]; +extern Gfx D_06014420[]; +extern Gfx D_06014040[]; +extern Gfx D_06013670[]; +extern Gfx D_06014AE0[]; +extern Gfx D_06012A78[]; +extern Gfx D_06013DE0[]; +extern Gfx D_060138D0[]; +extern Gfx D_06013540[]; +extern Gfx D_06012DF8[]; +extern Gfx D_060145D8[]; +extern Gfx D_06014860[]; +extern Gfx D_06014710[]; +extern Gfx D_06013A00[]; +extern Gfx D_06013F10[]; +extern Gfx D_06014C30[]; +extern Gfx D_060149A8[]; +extern Gfx D_06013440[]; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3178.asm") +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 18, 64, 0, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F322C.asm") +static ColliderJntSphElementInit sJntSphElementsInit[1] = { + { + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { 12, { { 1600, 0, 0 }, 5 }, 200 }, + }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F32A0.asm") +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3310.asm") +CollisionCheckInfoInit2 sColChkInfoInit2 = { + 0, 0, 0, 0, MASS_HEAVY, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3334.asm") +static DamageTable sDamageTable = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F33B8.asm") +static ActorAnimationEntryS sAnimations[] = { + { &D_06001D10, 1.0f, 0, -1, 0, 0 }, { &D_06001D10, 1.0f, 0, -1, 0, -4 }, { &D_06014F8C, 1.0f, 0, -1, 0, 0 }, + { &D_06014F8C, 1.0f, 0, -1, 0, -4 }, { &D_06000CB0, 1.0f, 0, -1, 0, -4 }, { &D_060003B4, 1.0f, 0, -1, 0, -4 }, + { &D_06001BE0, 1.0f, 0, -1, 0, -4 }, { &D_06015918, 1.0f, 0, -1, 0, -4 }, { &D_0601C0B0, 1.0f, 0, -1, 0, 0 }, + { &D_0601C0B0, 1.0f, 0, -1, 0, -4 }, { &D_0601A140, 1.0f, 0, -1, 0, 0 }, { &D_0601A140, 1.0f, 0, -1, 0, -4 }, + { &D_0601B904, 1.0f, 0, -1, 0, 0 }, { &D_0601B904, 1.0f, 0, -1, 0, -4 }, { &D_0601B3C4, 1.0f, 0, -1, 0, 0 }, + { &D_0601B3C4, 0.0f, 0, -1, 2, 0 }, { &D_0601B3C4, 1.0f, 0, -1, 0, -4 }, { &D_06019EB4, 1.0f, 0, -1, 2, -4 }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3414.asm") +static s16 D_808F6C0C[] = { + 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F35AC.asm") +s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { + s16 frameCount; + s32 ret = false; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F35D8.asm") + if (animIndex >= 0 && animIndex < 18) { + ret = true; + frameCount = sAnimations[animIndex].frameCount; + if (frameCount < 0) { + frameCount = SkelAnime_GetFrameCount(&sAnimations[animIndex].animationSeg->common); + } + SkelAnime_ChangeAnim(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, + sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].transitionRate); + } + return ret; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3608.asm") +s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { + u8 prevUnk260 = this->unk260; + u8 prevUnk261 = this->unk261; + u8 tmp; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3618.asm") + this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + if (this->unk260 != 0 && prevUnk260 == 0 && tmp & 0xFF) { + Audio_PlayActorSound2(&this->actor, 0x802); + } + this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + if (this->unk261 != 0 && prevUnk261 == 0 && tmp & 0xFF) { + Audio_PlayActorSound2(&this->actor, 0x802); + } + return 0; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3690.asm") +void func_808F322C(EnIn* this, s32 arg1) { + if (DECR(this->unk484) == 0) { + this->unk482++; + if (this->unk482 >= arg1) { + this->unk482 = 0; + this->unk484 = Rand_S16Offset(30, 30); + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F374C.asm") +void func_808F32A0(EnIn* this, GlobalContext* globalCtx) { + this->colliderCylinder.dim.pos.x = this->actor.world.pos.x; + this->colliderCylinder.dim.pos.y = this->actor.world.pos.y; + this->colliderCylinder.dim.pos.z = this->actor.world.pos.z; + if (this->unk23D == 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->colliderCylinder.base); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F38F8.asm") +s32 func_808F3310(EnIn* this, GlobalContext* globalCtx) { + if (this->colliderCylinder.base.acFlags & 2) { + this->colliderCylinder.base.acFlags &= ~2; + } + return 0; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F395C.asm") +s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { + ActorPlayer* player = PLAYER; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F39DC.asm") + if (this->colliderJntSph.base.atFlags & 2) { + this->colliderJntSph.base.atFlags &= ~2; + if (this->colliderJntSph.base.atFlags & 4) { + return 0; + } + Audio_PlayActorSound2(&player->base, 0x83E); + func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); + } + return 1; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3AD4.asm") +s32 func_808F33B8(void) { + s32 ret; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3B40.asm") + if (((ret = gSaveContext.day == 1) && (ret = gSaveContext.time >= 0x3AAA) && (ret = gSaveContext.time <= 0x4000)) || + (ret = gSaveContext.day >= 2)) { + ret = (gSaveContext.weekEventReg[22] & 1) == 0; + } + return ret; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3BD4.asm") +void func_808F3414(EnIn* this, GlobalContext* globalCtx) { + ActorPlayer* player = PLAYER; + Vec3f sp30; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3C40.asm") + if (this->unk23D == 0) { + this->unk494 = SkelAnime_FrameUpdateMatrix(&this->skelAnime); + } + if (func_8013D5E8(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + sp30.x = player->base.world.pos.x; + sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp30.z = player->base.world.pos.z; + func_8013D2E0(&sp30, &this->actor.focus, &this->actor.shape, &this->unk352, &this->unk358, &this->unk35E, + D_808F6C0C); + } else { + Math_SmoothStepToS(&this->unk352, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk354, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk358, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35A, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35E, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk360, 0, 4, 1000, 1); + } + func_808F322C(this, 3); + func_808F3178(this, globalCtx); + func_8013D9C8(globalCtx, this->unk376, this->unk39E, 20); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3CD4.asm") +void func_808F35AC(EnIn* this, GlobalContext* globalCtx) { + this->unk4AC |= 0x10; + if (this->unk4A4 != NULL) { + this->unk4A4->unk4AC |= 0x10; + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3D40.asm") +void func_808F35D8(EnIn* this, GlobalContext* globalCtx) { + this->unk4AC &= ~0x10; + if (this->unk4A4 != NULL) { + this->unk4A4->unk4AC &= ~0x10; + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F3DD4.asm") +void EnIn_DoNothing(EnIn* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F4054.asm") +void func_808F3618(EnIn* this, GlobalContext* globalCtx) { + if (ENIN_GET_WALKING_FLAG(&this->actor) != 0x3F) { + func_808F30B0(&this->skelAnime, 9); + } + if (ENIN_GET_WALKING_FLAG(&this->actor) != 0x3F) { + this->actionFunc = func_808F3690; + } else { + this->actionFunc = EnIn_DoNothing; + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F4108.asm") +void func_808F3690(EnIn* this, GlobalContext* globalCtx) { + s16 sp36; + Vec3f sp28; // unsure if Vec3f, but it is probably size 0xC -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F4150.asm") + Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); + sp36 = this->actor.speedXZ * 400.0f; + if (func_8013D68C(this->unk240, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + this->unk244++; + if (this->unk244 >= *this->unk240) { + this->unk244 = 0; + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F4270.asm") +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 }; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F43E0.asm") + if (this->skelAnime.animCurrentSeg == &D_06016484 || this->skelAnime.animCurrentSeg == &D_060170DC) { + if (func_801378B8(&this->skelAnime, 8.0f)) { + func_8019F88C(&this->actor.projectedPos, 0x6856, 2); + if (Rand_ZeroOne() < 0.3f) { + func_8019F1C0(&this->actor.projectedPos, 0x1844); + } + func_8019F1C0(&this->actor.projectedPos, 0x181E); + } + } + if (this->skelAnime.animCurrentSeg == &D_060198A8 && func_801378B8(&this->skelAnime, 20.0f)) { + Audio_PlayActorSound2(&this->actor, 0x6854); + } + if (SkelAnime_FrameUpdateMatrix(&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); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F4414.asm") +void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { + this->unk4A4 = NULL; + while (true) { + //! @bug: Infinite loop if there is only one ACTOR_EN_IN + this->unk4A4 = (EnIn*)func_ActorCategoryIterateById(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); + if (this->unk4A4 != NULL && this->unk4A4 != this) { + break; + } + this->unk4A4 = (EnIn*)this->unk4A4->actor.next; + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5674.asm") +void func_808F395C(EnIn* this, GlobalContext* globalCtx) { + if (this->unk4B0 == 0) { + this->actionFunc = func_808F5A94; + } + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + this->actionFunc = func_808F5A34; + this->unk48C = 1; + } else { + func_800B8614(&this->actor, globalCtx, 200.0f); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5728.asm") +void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { + u16 textId = 0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5994.asm") + if (gSaveContext.day != 3) { + switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { + case 2: + textId = 0x347A; + break; + case 3: + textId = 0x3476; + break; + } + SET_FLAGS_FINISH_RACE; + } else { + switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { + case 2: + textId = 0x349D; + break; + case 3: + textId = 0x3499; + break; + } + SET_FLAGS_FINISH_RACE; + } + this->actor.flags |= 0x10000; + this->actor.textId = textId; + this->actionFunc = func_808F395C; + if (this->unk4B0 == 2) { + Audio_PlayActorSound2(&this->actor, 0x6855); + } else { + Audio_PlayActorSound2(&this->actor, 0x687C); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5A34.asm") +void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + this->unk48C = 1; + this->actionFunc = func_808F5A94; + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5A94.asm") +void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5B58.asm") + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actor.flags |= 0x10000; + this->actionFunc = func_808F3AD4; + textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; + this->actor.textId = textId; + } else { + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F5C98.asm") +void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + this->unk48C = 1; + this->actionFunc = func_808F5A94; + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/EnIn_Init.asm") +void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/EnIn_Destroy.asm") + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actor.flags |= 0x10000; + this->actionFunc = func_808F3BD4; + textId = gSaveContext.day != 3 ? 0x346A : 0x3492; + this->actor.textId = textId; + } else { + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/EnIn_Update.asm") +void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + this->unk48C = 1; + this->actionFunc = func_808F5A94; + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F6334.asm") +void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F64A0.asm") + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_808F3CD4; + textId = gSaveContext.day != 3 ? 0x347D : 0x34A0; + this->actor.textId = textId; + this->actor.flags |= 0x10000; + } else { + func_800B8A1C(&this->actor, globalCtx, 0x81, 500.0f, 100.0f); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/func_808F67F8.asm") +u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { + u16 textId = 0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_In_0x808F30B0/EnIn_Draw.asm") + if (func_8012403C(globalCtx) == 8) { + if (!(gSaveContext.weekEventReg[63] & 0x40)) { + return 0x34A9; + } else if (this->unk4AC & 8) { + return 0x34B1; + } else { + textId = 0x34AF; + } + dummy_label_895710:; // POSSIBLE FAKE MATCH + } else { + switch (arg2) { + case 0: + if ((gSaveContext.playerForm == 2) || (gSaveContext.playerForm == 1)) { + textId = 0x345C; + } else if (gSaveContext.playerForm == 3) { + textId = 0x3460; + } else if (!(gSaveContext.weekEventReg[15] & 8)) { + textId = 0x3458; + } else { + textId = 0x345B; + } + break; + case 1: + if (!(gSaveContext.weekEventReg[15] & 0x10)) { + textId = 0x3463; + } else { + textId = 0x346B; + } + break; + case 3: + if (gSaveContext.playerForm == 3) { + textId = 0x3485; + } else if (gSaveContext.playerForm == 2 || gSaveContext.playerForm == 1) { + textId = 0x3484; + } else if (!(gSaveContext.weekEventReg[56] & 4)) { + textId = 0x346D; + } else { + textId = 0x3482; + } + break; + case 4: + if (gSaveContext.playerForm == 2 || gSaveContext.playerForm == 1) { + textId = 0x348A; + } else if (gSaveContext.playerForm == 3) { + textId = 0x348B; + } else if (!(gSaveContext.weekEventReg[16] & 1)) { + textId = 0x3486; + } else { + textId = 0x3489; + } + break; + case 5: + if (func_808F33B8()) { + textId = 0x34B3; + } else if (!(gSaveContext.weekEventReg[16] & 2)) { + textId = 0x348E; + } else { + textId = 0x3493; + } + break; + case 7: + if (gSaveContext.playerForm == 3) { + textId = 0x34A8; + } else if (gSaveContext.playerForm == 2 || gSaveContext.playerForm == 1) { + textId = 0x34A7; + } else if (!(gSaveContext.weekEventReg[16] & 4)) { + textId = 0x3495; + } else { + textId = 0x34A5; + } + } + if (textId == 0) { + textId = 1; + } + } + return textId; +} + +void func_808F4054(GlobalContext* globalCtx, EnIn* this, s32 arg2, u16 textId) { + s32 unused; + + if (textId == 0x34AE || textId == 0x34B0 || textId == 0x34B2) { + unused = textId; + func_80151BB4(globalCtx, 0x11); + } + switch (arg2) { + case 1: + case 5: + case 7: + if (textId == 0x3473) { + func_808F35D8(this, globalCtx); + } + break; + case 2: + if (textId == 0x3473) { + func_808F35D8(this, globalCtx); + } + break; + case 0: + break; + } +} + +void func_808F4108(EnIn* this, GlobalContext* globalCtx, u16 arg2) { + func_800B86C8(&this->actor, globalCtx, &this->unk4A4->actor); + this->actor.textId = 0; + this->unk4A4->actor.textId = arg2; + this->unk4A4->unk48C = 2; + this->unk48C = 0; +} + +s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext* msgCtx) { + EnIn* this2 = this; + + if (msgCtx->choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + func_801159EC(-globalCtx->msgCtx.unk1206C); + if (!(gSaveContext.weekEventReg[57] & 1)) { + func_808F4108(this, globalCtx, 0x3474); + } else if (this->unk4AC & 8) { + func_808F4108(this, globalCtx, 0x3475); + } else { + func_800E8EA0(globalCtx, &this->actor, 0x3475); + } + } else { + play_sound(0x4806); + func_800E8EA0(globalCtx, &this->actor, 0x3473); + } + } else { + func_8019F230(); + func_800E8EA0(globalCtx, &this->actor, 0x3472); + } + return 0; +} + +s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext* msgCtx, s32 arg4) { + s32 pad; + s32 fee = globalCtx->msgCtx.unk1206C != 0xFFFF ? globalCtx->msgCtx.unk1206C : 10; + + if (msgCtx->choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.rupees >= fee) { + func_801159EC(-fee); + if (!(gSaveContext.weekEventReg[57] & 1)) { + if (arg4 != 0) { + func_800E8EA0(globalCtx, &this->actor, 0x3474); + } else { + func_808F4108(this, globalCtx, 0x3474); + } + } else { + if (arg4 != 0) { + func_800E8EA0(globalCtx, &this->actor, 0x3475); + } else { + func_808F4108(this, globalCtx, 0x3475); + } + } + } else { + play_sound(0x4806); + if (arg4 != 0) { + func_800E8EA0(globalCtx, &this->actor, 0x3473); + } else { + func_808F4108(this, globalCtx, 0x3473); + } + } + } else { + func_8019F230(); + func_800E8EA0(globalCtx, &this->actor, 0x3472); + } + return 0; +} + +s32 func_808F43E0(EnIn* this) { + this->unk48C = 0; + this->actor.textId = 0; + SET_FLAGS_FINISH_RACE; + return 0; +} + +s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { + u16 textId = this->actor.textId; + s32 ret = true; + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 pad[2]; + + switch (textId) { + case 0x34AF: + func_800E8EA0(globalCtx, &this->actor, 0x34B0); + ret = false; + break; + case 0x34A9: + func_808F4108(this, globalCtx, 0x34AA); + gSaveContext.weekEventReg[63] |= 0x40; + ret = false; + break; + case 0x34AA: + func_808F4108(this, globalCtx, 0x34AB); + ret = false; + break; + case 0x34AB: + func_808F4108(this, globalCtx, 0x34AC); + ret = false; + break; + case 0x34AC: + func_808F4108(this, globalCtx, 0x34AD); + ret = false; + break; + case 0x34AD: + func_800E8EA0(globalCtx, &this->actor, 0x34AE); + ret = false; + break; + case 0x34B1: + func_800E8EA0(globalCtx, &this->actor, 0x34B2); + ret = false; + break; + default: + break; + } + + switch (arg2) { + case 0: + switch (textId) { + case 0x3458: + gSaveContext.weekEventReg[15] |= 8; + func_800E8EA0(globalCtx, &this->actor, 0x3459); + ret = false; + break; + case 0x3459: + func_800E8EA0(globalCtx, &this->actor, 0x345A); + ret = false; + break; + case 0x345A: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x345B: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x345C: + func_800E8EA0(globalCtx, &this->actor, 0x345D); + ret = false; + break; + case 0x345D: + func_800E8EA0(globalCtx, &this->actor, 0x345E); + ret = false; + break; + case 0x345E: + func_800E8EA0(globalCtx, &this->actor, 0x345F); + ret = false; + break; + case 0x345F: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x3460: + func_800E8EA0(globalCtx, &this->actor, 0x3461); + ret = false; + break; + case 0x3461: + func_800E8EA0(globalCtx, &this->actor, 0x3462); + ret = false; + break; + case 0x3462: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + } + break; + case 1: + switch (textId) { + case 0x3463: + gSaveContext.weekEventReg[15] |= 16; + func_800E8EA0(globalCtx, &this->actor, 0x3464); + ret = false; + break; + case 0x3464: + func_800E8EA0(globalCtx, &this->actor, 0x3465); + ret = false; + break; + case 0x3465: + func_800E8EA0(globalCtx, &this->actor, 0x3466); + ret = false; + break; + case 0x3466: + if (msgCtx->choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (func_80114E90()) { + this->actionFunc = func_808F3C40; + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + func_801159EC(-globalCtx->msgCtx.unk1206C); + ret = true; + } else { + func_800E8EA0(globalCtx, &this->actor, 0x3469); + ret = false; + } + } else { + play_sound(0x4806); + func_800E8EA0(globalCtx, &this->actor, 0x3468); + ret = false; + } + } else { + func_8019F230(); + func_800E8EA0(globalCtx, &this->actor, 0x3467); + ret = false; + } + break; + case 0x3467: + case 0x3468: + case 0x3469: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x346B: + func_800E8EA0(globalCtx, &this->actor, 0x346C); + ret = false; + break; + case 0x346C: + func_800E8EA0(globalCtx, &this->actor, 0x3466); + ret = false; + break; + case 0x346A: + this->actionFunc = func_808F5A94; + func_80151BB4(globalCtx, 0x11); + break; + } + break; + case 2: + switch (textId) { + case 0x346E: + func_808F4108(this, globalCtx, 0x346F); + ret = false; + break; + case 0x3470: + func_800E8EA0(globalCtx, &this->actor, 0x3471); + ret = false; + break; + case 0x3483: + func_800E8EA0(globalCtx, &this->actor, 0x3471); + ret = false; + break; + case 0x3471: + func_808F4150(globalCtx, this, arg2, msgCtx); + ret = false; + break; + case 0x3472: + func_808F43E0(this); + gSaveContext.weekEventReg[56] &= (u8)~8; + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x3473: + gSaveContext.weekEventReg[56] &= (u8)~8; + func_80151BB4(globalCtx, 0x11); + break; + case 0x3475: + SET_FLAGS_START_RACE; + func_800FD750(0x40); + globalCtx->nextEntranceIndex = 0xCE50; + globalCtx->unk1887F = 5; + globalCtx->unk18875 = 0x14; + gSaveContext.weekEventReg[57] |= 1; + break; + case 0x3478: + if (msgCtx->choiceIndex == 0) { + func_808F4150(globalCtx, this, arg2, msgCtx); + ret = false; + } else { + func_8019F230(); + gSaveContext.weekEventReg[56] &= (u8)~8; + func_808F4108(this, globalCtx, 0x3479); + ret = false; + } + break; + case 0x347B: + func_808F4108(this, globalCtx, 0x347C); + gSaveContext.weekEventReg[56] &= (u8)~8; + ret = false; + break; + } + break; + case 3: + switch (textId) { + case 0x346D: + func_808F4108(this, globalCtx, 0x346E); + gSaveContext.weekEventReg[56] |= 4; + gSaveContext.weekEventReg[56] |= 8; + ret = false; + break; + case 0x346F: + func_808F4108(this, globalCtx, 0x3470); + ret = false; + break; + case 0x3482: + func_808F4108(this, globalCtx, 0x3483); + gSaveContext.weekEventReg[56] |= 8; + ret = false; + break; + case 0x3484: + func_80151BB4(globalCtx, 0x11); + break; + case 0x3485: + func_80151BB4(globalCtx, 0x11); + break; + case 0x3474: + func_808F4108(this, globalCtx, 0x3475); + ret = false; + break; + case 0x3476: + func_800E8EA0(globalCtx, &this->actor, 0x3477); + func_808F30B0(&this->skelAnime, 1); + func_808F30B0(&this->unk4A4->skelAnime, 7); + ret = false; + break; + case 0x3477: + gSaveContext.weekEventReg[56] |= 8; + func_808F4108(this, globalCtx, 0x3478); + ret = false; + break; + case 0x347A: + func_808F30B0(&this->skelAnime, 1); + func_808F30B0(&this->unk4A4->skelAnime, 7); + if (gSaveContext.inventory.items[gItemSlots[59]] == 59) { + func_800E8EA0(globalCtx, &this->actor, 0x347E); + ret = false; + } else { + gSaveContext.weekEventReg[56] |= 8; + func_808F4108(this, globalCtx, 0x347B); + ret = false; + } + break; + case 0x347E: + func_808F35D8(this, globalCtx); + if (func_80114E90()) { + this->actionFunc = func_808F3B40; + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + ret = true; + } else { + func_800E8EA0(globalCtx, &this->actor, 0x347F); + ret = false; + } + break; + case 0x347F: + func_800E8EA0(globalCtx, &this->actor, 0x3480); + ret = false; + break; + case 0x3480: + func_808F43E0(this); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x3479: + func_808F43E0(this); + func_808F35D8(this, globalCtx); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x347C: + this->actionFunc = func_808F3D40; + func_800B8A1C(&this->actor, globalCtx, 0x81, 500.0f, 100.0f); + func_808F35D8(this, globalCtx); + ret = true; + break; + case 0x3481: + this->actionFunc = func_808F5A34; + func_808F43E0(this); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x347D: + this->actionFunc = func_808F5A34; + func_808F43E0(this); + func_80151BB4(globalCtx, 0x11); + func_80151BB4(globalCtx, 0x2F); + ret = true; + break; + } + break; + case 4: + switch (textId) { + case 0x3486: + func_800E8EA0(globalCtx, &this->actor, 0x3487); + gSaveContext.weekEventReg[16] |= 1; + ret = false; + break; + case 0x3487: + func_800E8EA0(globalCtx, &this->actor, 0x3488); + ret = false; + break; + case 0x3488: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x3489: + func_80151BB4(globalCtx, 0x11); + break; + case 0x348A: + func_80151BB4(globalCtx, 0x11); + break; + case 0x348B: + func_800E8EA0(globalCtx, &this->actor, 0x348C); + ret = false; + break; + case 0x348C: + func_800E8EA0(globalCtx, &this->actor, 0x348D); + ret = false; + break; + case 0x348D: + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + } + break; + case 5: + switch (textId) { + case 0x3468: + case 0x3469: + case 0x3491: + func_80151BB4(globalCtx, 0x11); + break; + case 0x348E: + case 0x34B3: + func_800E8EA0(globalCtx, &this->actor, 0x348F); + gSaveContext.weekEventReg[16] |= 2; + ret = false; + break; + case 0x3493: + func_800E8EA0(globalCtx, &this->actor, 0x3494); + ret = false; + break; + case 0x348F: + case 0x3494: + func_800E8EA0(globalCtx, &this->actor, 0x3490); + ret = false; + break; + case 0x3490: + if (msgCtx->choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (func_80114E90()) { + this->actionFunc = func_808F3C40; + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + func_801159EC(-globalCtx->msgCtx.unk1206C); + ret = true; + } else { + func_800E8EA0(globalCtx, &this->actor, 0x3469); + ret = false; + } + } else { + play_sound(0x4806); + func_800E8EA0(globalCtx, &this->actor, 0x3468); + ret = false; + } + } else { + func_8019F230(); + func_800E8EA0(globalCtx, &this->actor, 0x3491); + ret = false; + } + break; + case 0x3492: + this->actionFunc = func_808F5A94; + func_80151BB4(globalCtx, 0x11); + break; + } + break; + case 7: + switch (textId) { + case 0x34A8: + func_80151BB4(globalCtx, 0x11); + break; + case 0x34A7: + func_80151BB4(globalCtx, 0x11); + break; + case 0x3495: + func_808F4108(this, globalCtx, 0x3496); + gSaveContext.weekEventReg[16] |= 4; + gSaveContext.weekEventReg[56] |= 8; + ret = false; + break; + case 0x3497: + func_808F4108(this, globalCtx, 0x3498); + ret = false; + break; + case 0x34A4: + this->actionFunc = func_808F5A34; + func_808F43E0(this); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x34A5: + func_808F4108(this, globalCtx, 0x34A6); + gSaveContext.weekEventReg[56] |= 8; + ret = false; + break; + case 0x3473: + gSaveContext.weekEventReg[56] &= (u8)~8; + func_80151BB4(globalCtx, 0x11); + break; + case 0x3474: + func_800E8EA0(globalCtx, &this->actor, 0x3475); + ret = false; + break; + case 0x3475: + SET_FLAGS_START_RACE; + func_800FD750(0x40); + globalCtx->nextEntranceIndex = 0xCE50; + globalCtx->unk1887F = 5; + globalCtx->unk18875 = 0x14; + gSaveContext.weekEventReg[57] |= 1; + break; + case 0x349D: + func_808F30B0(&this->skelAnime, 1); + func_808F30B0(&this->unk4A4->skelAnime, 7); + if (gSaveContext.inventory.items[gItemSlots[59]] == 59) { + func_800E8EA0(globalCtx, &this->actor, 0x34A1); + ret = false; + } else { + gSaveContext.weekEventReg[56] |= 8; + func_808F4108(this, globalCtx, 0x349E); + ret = false; + } + break; + case 0x349F: + this->actionFunc = func_808F3D40; + func_800B8A1C(&this->actor, globalCtx, 0x81, 500.0f, 100.0f); + func_808F35D8(this, globalCtx); + ret = true; + break; + case 0x34A0: + this->actionFunc = func_808F5A34; + func_80151BB4(globalCtx, 0x11); + func_80151BB4(globalCtx, 0x2F); + func_808F43E0(this); + ret = true; + break; + case 0x34A1: + func_808F35D8(this, globalCtx); + if (func_80114E90()) { + this->actionFunc = func_808F3B40; + func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + ret = true; + } else { + func_800E8EA0(globalCtx, &this->actor, 0x34A2); + ret = false; + } + break; + case 0x34A2: + func_800E8EA0(globalCtx, &this->actor, 0x34A3); + ret = false; + break; + case 0x34A3: + func_808F43E0(this); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x3499: + func_800E8EA0(globalCtx, &this->actor, 0x349A); + func_808F30B0(&this->skelAnime, 1); + func_808F30B0(&this->unk4A4->skelAnime, 7); + ret = false; + break; + case 0x349A: + func_800E8EA0(globalCtx, &this->actor, 0x349B); + ret = false; + break; + case 0x349B: + if (msgCtx->choiceIndex == 0) { + func_808F4270(globalCtx, this, arg2, msgCtx, 1); + ret = false; + } else { + func_8019F230(); + func_800E8EA0(globalCtx, &this->actor, 0x349C); + ret = false; + } + break; + case 0x349C: + func_808F43E0(this); + func_808F35D8(this, globalCtx); + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + } + break; + case 6: + switch (textId) { + case 0x3496: + func_808F4108(this, globalCtx, 0x3497); + ret = false; + break; + case 0x3498: + case 0x34A6: + func_800E8EA0(globalCtx, &this->actor, 0x3471); + ret = false; + break; + case 0x3471: + func_808F4270(globalCtx, this, arg2, msgCtx, 0); + ret = false; + break; + case 0x3472: + func_808F43E0(this); + gSaveContext.weekEventReg[56] &= (u8)~8; + func_80151BB4(globalCtx, 0x11); + ret = true; + break; + case 0x349E: + func_808F4108(this, globalCtx, 0x349F); + gSaveContext.weekEventReg[56] &= (u8)~8; + ret = false; + break; + } + break; + } + return ret; +} + +s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { + s32 pad; + s32 ret = false; + + switch (func_80152498(&globalCtx->msgCtx)) { + case 2: + func_808F4054(globalCtx, this, arg2, this->actor.textId); + ret = true; + break; + case 4: + case 5: + if (func_80147624(globalCtx) && func_808F4414(globalCtx, this, arg2)) { + func_801477B4(globalCtx); + ret = true; + } + break; + } + return ret; +} + +s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { + s16 rotDiff; + s16 yawDiff; + s16 yawDiffA; + ActorPlayer* player; + + if (*arg3 == 4) { + return 0; + } + if (*arg3 == 2) { + func_801518B0(globalCtx, this->actor.textId, &this->actor); + *arg3 = 1; + return 0; + } + if (*arg3 == 3) { + func_80151938(globalCtx, this->actor.textId); + *arg3 = 1; + return 0; + } + if (func_800B84D0(&this->actor, globalCtx)) { + *arg3 = 1; + return 1; + } + if (*arg3 == 1) { + player = PLAYER; + func_808F5994(this, globalCtx, &player->base.world.pos, 0xC80); + dummy_label_895711:; // POSSIBLE FAKE MATCH + } else { + rotDiff = this->actor.home.rot.y - this->actor.world.rot.y; + if (rotDiff > 0x320) { + this->actor.world.rot.y += 0x320; + } else if (rotDiff < -0x320) { + this->actor.world.rot.y -= 0x320; + } else { + this->actor.world.rot.y += rotDiff; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + if (*arg3 == 1) { + if (func_808F5674(globalCtx, this, arg2)) { + *arg3 = 0; + } + return 0; + } + if (!func_800B8934(globalCtx, &this->actor)) { + return 0; + } + yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + yawDiffA = ABS_ALT(yawDiff); + if (yawDiffA >= 0x4300) { + return 0; + } + if (this->actor.xyzDistToPlayerSq > SQ(160.0f) && !this->actor.isTargeted) { + return 0; + } + if (this->actor.xyzDistToPlayerSq <= SQ(80.0f)) { + if (func_800B8614(&this->actor, globalCtx, 80.0f)) { + this->actor.textId = func_808F3DD4(globalCtx, this, arg2); + } + } else if (func_800B863C(&this->actor, globalCtx)) { + this->actor.textId = func_808F3DD4(globalCtx, this, arg2); + } + return 0; +} + +s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { + s32 ret = 0; + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, arg2) - this->actor.world.rot.y; + + if (yaw > arg3) { + this->actor.world.rot.y += arg3; + } else if (yaw < -arg3) { + this->actor.world.rot.y -= arg3; + } else { + this->actor.world.rot.y += yaw; + ret = 1; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + + return ret; +} + +void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { + if (gSaveContext.day != 3) { + func_808F5728(globalCtx, this, 3, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 7, &this->unk48C); + } +} + +void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { + if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { + if (gSaveContext.day == 3) { + func_808F5728(globalCtx, this, 7, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 3, &this->unk48C); + } + } else { + if (gSaveContext.day == 3) { + func_808F5728(globalCtx, this, 5, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 1, &this->unk48C); + } + } +} + +void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { + if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { + if ((func_8012403C(globalCtx) == 8 && gSaveContext.weekEventReg[63] & 0x40) || + gSaveContext.weekEventReg[56] & 8) { + if (gSaveContext.day == 3) { + func_808F5728(globalCtx, this, 6, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 2, &this->unk48C); + } + } + } else if (func_8012403C(globalCtx) != 8 || + (func_8012403C(globalCtx) == 8 && gSaveContext.weekEventReg[63] & 0x40)) { + if (gSaveContext.day == 3) { + func_808F5728(globalCtx, this, 4, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 0, &this->unk48C); + } + } +} + +void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { + if (this->unk4B0 == 0) { + this->actionFunc = func_808F5B58; + } + if ((func_8012403C(globalCtx) == 8 && gSaveContext.weekEventReg[63] & 0x40) || gSaveContext.weekEventReg[56] & 8) { + if (gSaveContext.day != 3) { + func_808F5728(globalCtx, this, 2, &this->unk48C); + } else { + func_808F5728(globalCtx, this, 6, &this->unk48C); + } + } + if (this->unk4A8 == 2) { + if (this->unk4B0 == 2) { + Audio_PlayActorSound2(&this->actor, 0x6855); + } else { + Audio_PlayActorSound2(&this->actor, 0x687C); + } + this->unk4A8 = 3; + } else if (this->unk4A8 < 3) { + this->unk4A8++; + } +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), +}; + +void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnIn* this = THIS; + s32 pad[2]; + s16 type; + + 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); + func_808F30B0(&this->skelAnime, 0); + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); + this->unk48A = 0; + this->unk48C = 0; + this->unk4AC = 0; + type = ENIN_GET_TYPE(thisx); + this->unk4B0 = gSaveContext.weekEventReg[92] & (1 | 2 | 4); + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + this->unk4AC |= 8; + } + 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); + Actor_SetScale(&this->actor, 0.01f); + this->unk23C = 0; + this->unk23D = 1; + this->actionFunc = func_808F374C; + } else { + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = -4.0f; + this->unk240 = func_8013D648(globalCtx, ENIN_GET_WALKING_FLAG(&this->actor), 0x3F); + this->unk23D = 0; + if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { + if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2 || + (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 3) { + gSaveContext.weekEventReg[56] &= (u8)~8; + this->unk4A8 = 0; + this->unk4AC |= 2; + func_808F35AC(this, globalCtx); + this->unk23C = 0; + D_801BDAA0 = 0; + if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + func_808F30B0(&this->skelAnime, 6); + } else { + 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; + } + if (this->unk4AC & 8) { + this->actionFunc = func_808F39DC; + } else { + this->actionFunc = func_808F5C98; + } + } else { + if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) != 1) { + gSaveContext.weekEventReg[56] &= (u8)~8; + this->unk23C = 0; + this->unk4AC |= 2; + if (type == ENIN_BLUE_SHIRT) { + if (func_808F33B8()) { + func_808F30B0(&this->skelAnime, 0); + this->actionFunc = func_808F5A94; + } else { + if (gSaveContext.weekEventReg[52] & 1) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, this->actor.shape.rot.z, 0xF); + Actor_MarkForDeath(&this->actor); + } else { + func_808F30B0(&this->skelAnime, 0); + this->actionFunc = func_808F5A94; + } + } + } else { + if (gSaveContext.weekEventReg[52] & 1) { + Actor_MarkForDeath(&this->actor); + } else { + func_808F30B0(&this->skelAnime, 7); + this->actionFunc = func_808F5B58; + } + } + } else { + Actor_MarkForDeath(&this->actor); + } + } + } else { + this->actionFunc = func_808F3618; + } + } +} + +void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnIn* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} + +void EnIn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnIn* this = THIS; + + func_808F3310(this, globalCtx); + func_808F3334(this, globalCtx); + if (this->unk4AC & 2) { + this->unk4AC &= ~2; + func_808F38F8(this, globalCtx); + } + if (func_8012403C(globalCtx) == 8) { + this->unk4AC |= 0x40; + } else { + this->unk4AC &= ~0x40; + } + this->actionFunc(this, globalCtx); + func_800B78B8(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_808F3414(this, globalCtx); + func_808F32A0(this, globalCtx); +} + +void func_808F6334(EnIn* this, GlobalContext* globalCtx) { + ActorPlayer* player = PLAYER; + s32 newUnk4C8; + + newUnk4C8 = func_80152498(&globalCtx->msgCtx); + 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); + if (this == (EnIn*)player->unkA88 && !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && + newUnk4C8 == 3 && this->unk4C8 == 3) { + if (!(globalCtx->state.frames & 1)) { + this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; + } + } else { + this->unk4C0 = 0.0f; + } + this->unk4C8 = newUnk4C8; +} + +s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnIn* this = THIS; + s32 pad; + Gfx* sp50[] = { + NULL, NULL, D_060149A8, D_06014AE0, D_06014C30, D_060145D8, D_06014710, + D_06014860, D_06014420, D_06012A78, D_06013DE0, D_06013F10, D_06014040, D_060137A0, + D_060138D0, D_06013A00, D_06012DF8, D_06013670, D_06013540, D_06013440, + }; + + if (this->unk23C != 0 && limbIndex != 16) { + if (sp50[limbIndex] != NULL) { + *dList = sp50[limbIndex]; + } + } + if (this->unk4AC & 4 && limbIndex == 16) { + *dList = D_0601C528; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (limbIndex == 16) { + void* sp38[] = { &D_060035E0, &D_06004820, &D_06004C20, &D_060043E0 }; + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp38[this->unk482])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(&D_06003520)); + } else { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&D_06001C30), this->unk4AC & 8 ? 1 : 0); + } + 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); + func_808F6334(this, globalCtx); + } + if (limbIndex == 9) { + Matrix_RotateY(this->unk360, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->unk35E, MTXMODE_APPLY); + } + if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { + rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk39E[limbIndex]) * 200.0f); + } + if (this->unk4AC & 0x40) { + if (limbIndex == 18) { + rot->x = 0x1F40; + rot->y = -0x3E8; + rot->z = 0x1D4C; + } else if (limbIndex == 17) { + rot->x = -0x1F40; + rot->y = 0x3E8; + rot->z = 0x1D4C; + } else if (limbIndex == 19) { + rot->x = 0; + rot->y = 0x7FFF; + rot->z = -0x2328; + } + } + return 0; +} + +void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnIn* this = THIS; + Vec3f sp50 = { 1600.0f, 0.0f, 0.0f }; + Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 16) { + SysMatrix_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); + } + if (limbIndex == 7) { + SysMatrix_MultiplyVector3fByState(&sp44, &this->unk254); + } + if (this->unk23C == 0) { + if (!(this->unk4AC & 8)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + if (limbIndex == 12) { + gSPDisplayList(POLY_OPA_DISP++, D_06007A70); + } + if (limbIndex == 15) { + gSPDisplayList(POLY_OPA_DISP++, D_06007C48); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } + if (this->unk4AC & 0x20) { + OPEN_DISPS(globalCtx->state.gfxCtx); + if (limbIndex == 12) { + gSPDisplayList(POLY_OPA_DISP++, D_06007C48); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnIn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnIn* this = THIS; + + 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); + 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 77ff0e4eb9..51e9058146 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -5,9 +5,66 @@ struct EnIn; +typedef void (*EnInActionFunc)(struct EnIn*, GlobalContext*); + +typedef enum { + /* 0 */ ENIN_UNK_TYPE, + /* 1 */ ENIN_HORSE_RIDER_YELLOW_SHIRT, + /* 2 */ ENIN_HORSE_RIDER_BLUE_SHIRT, + /* 3 */ ENIN_YELLOW_SHIRT, + /* 4 */ ENIN_BLUE_SHIRT +} EnInType; + +#define ENIN_GET_TYPE(thisx) ((thisx)->params & 0x1FF) +#define ENIN_GET_WALKING_FLAG(thisx) (((thisx)->params & 0x7E00) >> 9) // Only used with ENIN_UNK_TYPE + typedef struct EnIn { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x388]; + /* 0x144 */ EnInActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderJntSph colliderJntSph; + /* 0x1AC */ ColliderJntSphElement colliderJntSphElement; + /* 0x1EC */ ColliderCylinder colliderCylinder; + /* 0x238 */ char unk238[0x4]; + /* 0x23C */ u8 unk23C; + /* 0x23D */ u8 unk23D; + /* 0x240 */ u8 *unk240; + /* 0x244 */ s16 unk244; + /* 0x248 */ Vec3f unk248; + /* 0x254 */ Vec3f unk254; + /* 0x260 */ u8 unk260; + /* 0x261 */ u8 unk261; + /* 0x262 */ Vec3s limbDrawTbl[20]; + /* 0x2DA */ Vec3s transitionDrawTbl[20]; + /* 0x352 */ s16 unk352; + /* 0x354 */ s16 unk354; + /* 0x356 */ char unk356[0x2]; + /* 0x358 */ s16 unk358; + /* 0x35A */ s16 unk35A; + /* 0x35C */ char unk35C[0x2]; + /* 0x35E */ s16 unk35E; + /* 0x360 */ s16 unk360; + /* 0x362 */ char unk362[0x14]; + /* 0x376 */ s16 unk376[20]; + /* 0x39E */ s16 unk39E[20]; + /* 0x3C6 */ char unk3C6[0xBC]; + /* 0x482 */ s16 unk482; + /* 0x484 */ s16 unk484; + /* 0x486 */ s16 unk486; + /* 0x488 */ s16 unk488; + /* 0x48A */ u16 unk48A; + /* 0x48C */ s32 unk48C; + /* 0x490 */ char unk490[0x4]; + /* 0x494 */ s32 unk494; + /* 0x498 */ char unk498[0xC]; + /* 0x4A4 */ struct EnIn* unk4A4; + /* 0x4A8 */ s32 unk4A8; + /* 0x4AC */ s32 unk4AC; + /* 0x4B0 */ s32 unk4B0; + /* 0x4B4 */ Vec3f unk4B4; + /* 0x4C0 */ f32 unk4C0; + /* 0x4C0 */ f32 unk4C4; + /* 0x4C0 */ s32 unk4C8; } EnIn; // size = 0x4CC extern const ActorInit En_In_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index b25c0999a6..d8037f45b6 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -6726,7 +6726,7 @@ 0x808F3414:("func_808F3414",), 0x808F35AC:("func_808F35AC",), 0x808F35D8:("func_808F35D8",), - 0x808F3608:("func_808F3608",), + 0x808F3608:("EnIn_DoNothing",), 0x808F3618:("func_808F3618",), 0x808F3690:("func_808F3690",), 0x808F374C:("func_808F374C",), @@ -6757,8 +6757,8 @@ 0x808F621C:("EnIn_Destroy",), 0x808F6248:("EnIn_Update",), 0x808F6334:("func_808F6334",), - 0x808F64A0:("func_808F64A0",), - 0x808F67F8:("func_808F67F8",), + 0x808F64A0:("EnIn_OverrideLimbDraw",), + 0x808F67F8:("EnIn_PostLimbDraw",), 0x808F69B4:("EnIn_Draw",), 0x808F74B0:("EnBomChu_Init",), 0x808F7580:("EnBomChu_Destroy",),