diff --git a/include/functions.h b/include/functions.h index 272beddb41..46f74926eb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1617,7 +1617,7 @@ void func_800EDE34(Actor* actor, GlobalContext* globalCtx, s32 param_3); void func_800EDF24(Actor* actor, GlobalContext* globalCtx, u32 arg2); void func_800EDF78(Actor* actor, GlobalContext* globalCtx, s32 iParm3); void func_800EE0CC(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -// void func_800EE1D8(void); +s32 func_800EE1D8(GlobalContext* globalCtx); u32 func_800EE200(GlobalContext* globalCtx, u32 uParm2); u32 func_800EE29C(GlobalContext* globalCtx, u32 uParm2); u32 func_800EE2F4(GlobalContext* globalCtx); @@ -2133,7 +2133,7 @@ f32 func_8010C36C(f32 a, f32 b); // void func_8010DE38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // void func_8010E028(void); // void func_8010E968(void); -// void func_8010E9F0(void); +void func_8010E9F0(s16 arg0, s16 arg1); // void func_8010EA9C(void); // void func_8010EB50(void); // void func_8010EBA0(void); @@ -2146,7 +2146,7 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80110038(void); // void func_80111CB4(void); // void func_801129E4(void); -// void func_80112AFC(void); +void func_80112AFC(GlobalContext* globalCtx); // void func_80112B40(void); // void func_80112BE4(void); // void func_80112C0C(void); @@ -3856,7 +3856,7 @@ void func_8019F128(u16 sfxId); // void func_8019F170(void); void func_8019F1C0(Vec3f* pos, u16 sfxId); void func_8019F208(void); -void func_8019F230(void); +void func_8019F230(void); // Plays "No" sound // void func_8019F258(void); // void func_8019F300(void); // void func_8019F420(void); @@ -4027,7 +4027,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(UNK_TYPE arg0); +void func_801A89A8(s32 arg0); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); diff --git a/include/sfx.h b/include/sfx.h index 2b68b8b3b8..7430f8581f 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -1055,7 +1055,7 @@ #define NA_SE_EV_ZORA_KIDS_SWIM_2 0x29BC #define NA_SE_EV_DARUMA_VANISH 0x29BD #define NA_SE_EV_IKANA_SOUL_TRANSFORM 0x29BE -#define NA_SE_EV_ROMANY_BOW_FLICK 0x29BF +#define NA_SE_EV_ROMANI_BOW_FLICK 0x29BF #define NA_SE_EV_WHITE_FAIRY_SHOT_DASH 0x29C0 #define NA_SE_EV_BLACK_FAIRY_SHOT_DASH 0x29C1 #define NA_SE_EV_SWORD_FORGE 0x29C2 diff --git a/include/z64.h b/include/z64.h index 83e9cdbd44..26714b538d 100644 --- a/include/z64.h +++ b/include/z64.h @@ -749,8 +749,8 @@ typedef struct { /* 0x220 */ s16 unk_220; /* 0x222 */ s16 unk_222; /* 0x224 */ s16 unk_224; - /* 0x226 */ s16 unk_226; - /* 0x228 */ s16 unk_228; + /* 0x226 */ s16 lifeColorChange; + /* 0x228 */ s16 lifeColorChangeDirection; /* 0x22A */ s16 beatingHeartPrim[3]; /* 0x230 */ s16 beatingHeartEnv[3]; /* 0x236 */ s16 heartsPrimR[2]; @@ -761,8 +761,8 @@ typedef struct { /* 0x24A */ s16 heartsEnvB[2]; /* 0x24E */ s16 unk_24E; /* 0x250 */ s16 unk_250; - /* 0x252 */ s16 unk_252; - /* 0x254 */ s16 beatingHeartState; // 1 means shrinking, 0 growing + /* 0x252 */ s16 lifeSizeChange; + /* 0x254 */ s16 lifeSizeChangeDirection; // 1 means shrinking, 0 growing /* 0x256 */ s16 unk_256; /* 0x258 */ s16 unk_258; /* 0x25A */ u8 numHorseBoosts; @@ -986,7 +986,11 @@ typedef struct { /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; /* 0x12078 */ s32 bankRupeesSelected; /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x60]; + /* 0x12080 */ UNK_TYPE1 pad12080[0x30]; + /* 0x120B0 */ UNK_TYPE1 pad120B0[0x1]; + /* 0x120B1 */ u8 unk_120B1; + /* 0x120B2 */ UNK_TYPE1 pad120B2[0x2]; + /* 0x120B4 */ UNK_TYPE1 pad120B4[0x2C]; } MessageContext; // size = 0x120E0 typedef struct ActorBgMbarChair ActorBgMbarChair; @@ -1576,7 +1580,11 @@ struct ActorContext { /* 0x250 */ void* unk250; // allocation of 0x20f0 bytes? /* 0x254 */ u32 unk254[5]; /* 0x268 */ u8 unk268; - /* 0x269 */ UNK_TYPE1 pad269[0x1B]; + /* 0x269 */ UNK_TYPE1 pad269[0x3]; + /* 0x26C */ UNK_TYPE1 pad26C[0xC]; + /* 0x278 */ u16 unk278; + /* 0x27A */ UNK_TYPE1 pad27A[0x2]; + /* 0x27C */ UNK_TYPE1 pad27C[0x8]; }; // size = 0x284 typedef struct { diff --git a/include/z64actor.h b/include/z64actor.h index 986dd0b5a5..6ef8dcf24c 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -39,7 +39,7 @@ typedef struct { /* 0x04 */ s16 cylHeight; /* 0x06 */ s16 cylYShift; /* 0x08 */ u8 mass; -} CollisionCheckInfoInit2; +} CollisionCheckInfoInit2; // size = 0xC typedef struct { /* 0x00 */ DamageTable* damageTable; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index c173698d1e..1ae1c28f6a 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -5618,9 +5618,9 @@ SECTIONS ovl_En_Ma4 : AT(RomLocation) { build/src/overlays/actors/ovl_En_Ma4/z_en_ma4.o(.text) - build/asm/overlays/ovl_En_Ma4_data.o(.data) + build/src/overlays/actors/ovl_En_Ma4/z_en_ma4.o(.data) build/src/overlays/actors/ovl_En_Ma4/z_en_ma4.o(.rodata) - build/asm/overlays/ovl_En_Ma4_rodata.o(.rodata) + build/src/overlays/actors/ovl_En_Ma4/z_en_ma4_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index 8c060c8733..3dfa284a36 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -437,6 +437,32 @@ D_04048DF0 = 0x04048DF0; D_04057B10 = 0x04057B10; D_04089070 = 0x04089070; +/* z_en_ma4 */ +D_060003B0 = 0x060003B0; +D_06007328 = 0x06007328; +D_06002A8C = 0x06002A8C; +D_06015B7C = 0x06015B7C; +D_06013928 = 0x06013928; +D_0600FFC8 = 0x0600FFC8; +D_060107C8 = 0x060107C8; +D_06010FC8 = 0x06010FC8; +D_060117C8 = 0x060117C8; +D_06011FC8 = 0x06011FC8; +D_060127C8 = 0x060127C8; +D_06012BC8 = 0x06012BC8; +D_06012FC8 = 0x06012FC8; +D_060133C8 = 0x060133C8; +D_06009E58 = 0x06009E58; +D_06002A8C = 0x06002A8C; +D_06018948 = 0x06018948; +D_0601B76C = 0x0601B76C; +D_06007328 = 0x06007328; +D_06014088 = 0x06014088; +D_06015B7C = 0x06015B7C; +D_06007D98 = 0x06007D98; +D_0600852C = 0x0600852C; +D_06008F6C = 0x06008F6C; + /* z_en_toto */ D_06000C80 = 0x06000C80; D_06001324 = 0x06001324; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index c8170b17f2..9cddb50934 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -316,7 +316,7 @@ void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0D: Path List void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = (void*)Lib_SegmentedToVirtual(cmd->pathList.segment); + globalCtx->setupPathList = (Path*)Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index bdf60720e0..e546b37a3d 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -39,7 +39,7 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) { #ifdef NON_MATCHING // Matches besides rodata, since rodata is not merged into the asm in code files yet. void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) { - GlobalContext* globalCtx = (GlobalContext*)state; + GlobalContext* globalCtx = (GlobalContext*)gamestate; u32 size; void* offset; s32 pad; 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 ba858292c0..499fca5881 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -1,3 +1,9 @@ +/* + * File: z_en_ma4.c + * Overlay: ovl_En_Ma4 + * Description: Romani. + */ + #include "z_en_ma4.h" #define FLAGS 0x02000039 @@ -9,7 +15,74 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMa4_Update(Actor* thisx, GlobalContext* globalCtx); void EnMa4_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void EnMa4_SetupWait(EnMa4* this); +void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupDialogueHandler(EnMa4* this); +void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupBeginHorsebackGame(EnMa4* this); +void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupBeginEponasSongCs(EnMa4* this); +void EnMa4_BeginEponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupEponasSongCs(EnMa4* this); +void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupEndEponasSongCs(EnMa4* this); +void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetupBeginDescribeThemCs(EnMa4* this); +void EnMa4_BeginDescribeThemCs(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx); +void EnMa4_SetFaceExpression(EnMa4* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); +void EnMa4_InitFaceExpression(EnMa4* this); + +typedef enum { + /* 0 */ MA4_TYPE_DAY1, + /* 1 */ MA4_TYPE_ALIENS_DEFEATED, + /* 2 */ MA4_TYPE_ALIENS_WON, +} EnMa4Type; + +typedef enum { + /* 0 */ MA4_STATE_DEFAULT, + /* 1 */ MA4_STATE_HORSEBACKGAME, + /* 2 */ MA4_STATE_AFTERHORSEBACKGAME, + /* 3 */ MA4_STATE_AFTERDESCRIBETHEMCS, +} EnMa4State; + +extern FlexSkeletonHeader D_06013928; + +extern AnimationHeader D_06009E58; +extern AnimationHeader D_06002A8C; +extern AnimationHeader D_06018948; +extern AnimationHeader D_0601B76C; +extern AnimationHeader D_06007328; +extern AnimationHeader D_06014088; +extern AnimationHeader D_06015B7C; +extern AnimationHeader D_06007D98; +extern AnimationHeader D_0600852C; +extern AnimationHeader D_06008F6C; + +extern u64 D_0600FFC8[]; +extern u64 D_060107C8[]; +extern u64 D_06010FC8[]; +extern u64 D_060117C8[]; +extern u64 D_06011FC8[]; + +extern u64 D_060127C8[]; +extern u64 D_06012BC8[]; +extern u64 D_06012FC8[]; +extern u64 D_060133C8[]; + +extern Gfx D_060003B0[]; + +// Box +extern Gfx D_06000A20[]; + const ActorInit En_Ma4_InitVars = { ACTOR_EN_MA4, ACTORCAT_NPC, @@ -21,78 +94,1011 @@ const ActorInit En_Ma4_InitVars = { (ActorFunc)EnMa4_Update, (ActorFunc)EnMa4_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABDCA0.asm") +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 18, 46, 0, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABDD2C.asm") +static CollisionCheckInfoInit2 D_80AC00DC = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABDD9C.asm") +static void* sEyeTextures[] = { + D_0600FFC8, D_060107C8, D_06010FC8, D_060117C8, D_06011FC8, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABDE60.asm") +static void* sMouthTextures[] = { + D_060127C8, + D_06012BC8, + D_06012FC8, + D_060133C8, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/EnMa4_Init.asm") +void EnMa4_UpdateEyes(EnMa4* this) { + if (this->overrideEyeTexIndex != 0) { + this->eyeTexIndex = this->overrideEyeTexIndex; + } else if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/EnMa4_Destroy.asm") +static struct_80B8E1A8 sAnimationInfo[] = { + { &D_06009E58, 1.0f, 0, 0.0f }, { &D_06009E58, 1.0f, 0, -6.0f }, // Idle anim + { &D_06002A8C, 1.0f, 0, 0.0f }, { &D_06002A8C, 1.0f, 0, -6.0f }, // Looking around anim + { &D_06018948, 1.0f, 2, 0.0f }, { &D_06018948, 1.0f, 2, -6.0f }, // Starts holding hands anim + { &D_0601B76C, 1.0f, 0, 0.0f }, { &D_0601B76C, 1.0f, 0, -6.0f }, // Holnding hands anim + { &D_06007328, 1.0f, 0, 0.0f }, { &D_06007328, 1.0f, 0, -6.0f }, // Walking anim + { &D_06014088, 1.0f, 0, 0.0f }, { &D_06014088, 1.0f, 0, -6.0f }, // + { &D_06015B7C, 1.0f, 2, 0.0f }, { &D_06015B7C, 1.0f, 2, -6.0f }, // Shoot arrow anim + { &D_06007D98, 1.0f, 0, 0.0f }, { &D_06007D98, 1.0f, 0, -6.0f }, // Sitting anim + { &D_0600852C, 1.0f, 0, 0.0f }, { &D_0600852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim + { &D_06008F6C, 1.0f, 0, 0.0f }, { &D_06008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABE1C4.asm") +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); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABE4A4.asm") +void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 flag; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABE560.asm") + if (this->unk_1D8.unk_00 == 0 && + ((this->skelAnime.animCurrentSeg == &D_06007328) || (this->skelAnime.animCurrentSeg == &D_06002A8C) || + (this->skelAnime.animCurrentSeg == &D_06015B7C))) { + flag = 1; + } else { + flag = (this->type == MA4_TYPE_ALIENS_WON && this->actionFunc != EnMa4_DialogueHandler) ? 1 : 0; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABE6C8.asm") + this->unk_1D8.unk_18 = player->actor.world.pos; + this->unk_1D8.unk_18.y -= -10.0f; + func_800BD888(&this->actor, &this->unk_1D8, 0, flag); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABEB6C.asm") +void EnMa4_InitPath(EnMa4* this, GlobalContext* globalCtx) { + Path* path; + Vec3f nextPoint; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABEF34.asm") + path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->pathIndex = 0; + this->pathPointsCount = path->count; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABEF8C.asm") + this->actor.home.pos.x = this->pathPoints[0].x; + this->actor.home.pos.y = this->pathPoints[0].y; + this->actor.home.pos.z = this->pathPoints[0].z; + nextPoint.x = this->pathPoints[1].x; + nextPoint.y = this->pathPoints[1].y; + nextPoint.z = this->pathPoints[1].z; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF070.asm") + this->actor.world.pos = this->actor.home.pos; + this->actor.shape.rot.y = this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &nextPoint); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF084.asm") +void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMa4* this = THIS; + s32 pad; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF0D8.asm") + 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); -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF160.asm") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &D_80AC00DC); -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF198.asm") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF218.asm") + this->actor.targetMode = 0; + this->unk_1D8.unk_00 = 0; + this->unk_334 = 0; + this->hasBow = true; + this->mouthTexIndex = 0; + this->animTimer = 0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF254.asm") + if (CURRENT_DAY == 1) { + this->type = MA4_TYPE_DAY1; + } else if (gSaveContext.weekEventReg[0x16] & 1) { // Aliens defeated + this->type = MA4_TYPE_ALIENS_DEFEATED; + } else { + this->type = MA4_TYPE_ALIENS_WON; + this->hasBow = false; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF2FC.asm") + if (func_800EE1D8(globalCtx) != 0) { // if (sceneSetupIndex != 0) + EnMa4_ChangeAnim(this, 0); + this->state = MA4_STATE_HORSEBACKGAME; + EnMa4_InitHorsebackGame(this, globalCtx); + } else { + EnMa4_InitPath(this, globalCtx); -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF354.asm") + if (gSaveContext.entranceIndex == 0x6410) { + EnMa4_ChangeAnim(this, 0); + this->state = MA4_STATE_AFTERHORSEBACKGAME; + } else if (gSaveContext.entranceIndex == 0x64A0) { + EnMa4_ChangeAnim(this, 0); + this->state = MA4_STATE_AFTERDESCRIBETHEMCS; + } else { + if (this->type == MA4_TYPE_ALIENS_WON) { + EnMa4_ChangeAnim(this, 14); + this->actor.shape.shadowScale = 0.0f; + } else { + EnMa4_ChangeAnim(this, 8); + } + this->state = MA4_STATE_DEFAULT; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF494.asm") + EnMa4_SetupWait(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF4A8.asm") +void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMa4* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF51C.asm") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.weekEventReg[0x8] &= (u8)~0x01; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF534.asm") +// Running in circles in the ranch +void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { + static s32 sCurrentAnim = 9; + static s32 D_80AC0250 = 0; + static s16 D_80AC0254 = 10; + Vec3f sp34; + s32 pad; + s16 sp2E; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF69C.asm") + if (sCurrentAnim != 9 && func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + if (sCurrentAnim == 3) { + if (D_80AC0250 < 3) { + D_80AC0250++; + } else { + D_80AC0250 = 0; + EnMa4_ChangeAnim(this, 13); + sCurrentAnim = 13; + } + } else { + this->actor.speedXZ = 2.7f; + EnMa4_ChangeAnim(this, 9); + sCurrentAnim = 9; + } + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF6B0.asm") + if (sCurrentAnim == 13 && func_801378B8(&this->skelAnime, 37.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF760.asm") + sp34.x = this->pathPoints[this->pathIndex].x; + sp34.y = this->pathPoints[this->pathIndex].y; + sp34.z = this->pathPoints[this->pathIndex].z; + sp2E = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34) > 50.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, sp2E, 10, 0x3000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, sp2E, 5, 0x3000, 0x100); + } else { + if ((D_80AC0254 == 0) && ((Rand_Next() % 4) == 0)) { + this->actor.speedXZ = 0.0f; + D_80AC0254 = 2; + EnMa4_ChangeAnim(this, 3); + sCurrentAnim = 3; + } else { + if (D_80AC0254 > 0) { + D_80AC0254--; + } + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF774.asm") + if (this->pathIndex < this->pathPointsCount - 1) { + this->pathIndex++; + } else { + this->pathIndex = 0; + } + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABF7C8.asm") + 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)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABFCAC.asm") +void EnMa4_SetupWait(EnMa4* this) { + if ((this->state != MA4_STATE_AFTERHORSEBACKGAME) && (this->state != MA4_STATE_AFTERDESCRIBETHEMCS)) { + if (this->type != MA4_TYPE_ALIENS_WON) { + EnMa4_ChangeAnim(this, 9); + this->actor.speedXZ = 2.7f; + } else { + EnMa4_ChangeAnim(this, 15); + this->actor.speedXZ = 0.0f; + } + } else { + EnMa4_ChangeAnim(this, 1); + this->actor.speedXZ = 0.0f; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABFCD4.asm") + this->actor.gravity = -0.2f; + this->animTimer = 0; + EnMa4_InitFaceExpression(this); + this->actionFunc = EnMa4_Wait; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/EnMa4_Update.asm") +void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABFD9C.asm") + if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { + 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)) { + this->animTimer++; + if (this->animTimer == 5) { + EnMa4_ChangeAnim(this, 17); // Traumatized anim + } else if (this->animTimer == 8) { + this->animTimer = 0; + EnMa4_ChangeAnim(this, 15); // Sitting anim + } + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/func_80ABFE48.asm") + if (func_800B84D0(&this->actor, globalCtx) != 0) { + EnMa4_StartDialogue(this, globalCtx); + EnMa4_SetupDialogueHandler(this); + } else if (this->type != MA4_TYPE_ALIENS_WON || ABS_ALT(yaw) < 0x4000) { + if (!(player->stateFlags1 & 0x800000)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Ma4_0x80ABDCA0/EnMa4_Draw.asm") +// Chooses the next dialogue based on player's selection +void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx) != 0) { + switch (this->textId) { + case 0x3339: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_801518B0(globalCtx, 0x333A, &this->actor); + this->textId = 0x333A; + } else { + func_8019F208(); + func_801518B0(globalCtx, 0x333B, &this->actor); + this->textId = 0x333B; + } + break; + + case 0x3341: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + gSaveContext.weekEventReg[0x15] |= 0x20; + func_801518B0(globalCtx, 0x3343, &this->actor); + this->textId = 0x3343; + } else { + func_8019F230(); + EnMa4_SetFaceExpression(this, 0, 1); + func_801518B0(globalCtx, 0x3342, &this->actor); + this->textId = 0x3342; + this->state = MA4_STATE_DEFAULT; + func_80151BB4(globalCtx, 5); + } + break; + + case 0x3346: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + gSaveContext.weekEventReg[0x15] |= 0x20; + func_801518B0(globalCtx, 0x3343, &this->actor); + this->textId = 0x3343; + } else { + func_8019F230(); + EnMa4_SetFaceExpression(this, 0, 1); + func_801518B0(globalCtx, 0x3342, &this->actor); + this->textId = 0x3342; + } + break; + + case 0x3347: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_801518B0(globalCtx, 0x3349, &this->actor); + this->textId = 0x3349; + } else { + func_8019F230(); + func_801518B0(globalCtx, 0x3348, &this->actor); + this->textId = 0x3348; + func_80151BB4(globalCtx, 5); + } + break; + + case 0x334D: // Asks if you understood her explanation. + if (globalCtx->msgCtx.choiceIndex == 0) { // Yes + s32 aux; + + func_8019F208(); + func_801518B0(globalCtx, 0x334E, &this->actor); + this->textId = 0x334E; + if ((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE]) { + func_80151BB4(globalCtx, 0x1C); + } + func_80151BB4(globalCtx, 5); + } else { // No. + func_8019F230(); + EnMa4_SetFaceExpression(this, 0, 0); + func_801518B0(globalCtx, 0x334C, &this->actor); + this->textId = 0x334C; + } + break; + + case 0x3354: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_801518B0(globalCtx, 0x3349, &this->actor); + this->textId = 0x3349; + } else { + func_8019F230(); + EnMa4_SetFaceExpression(this, 1, 0); + func_801518B0(globalCtx, 0x3355, &this->actor); + this->textId = 0x3355; + func_80151BB4(globalCtx, 5); + } + break; + + case 0x3356: + // "Try again?" + if (globalCtx->msgCtx.choiceIndex == 0) { // Yes + func_8019F208(); + func_801477B4(globalCtx); + EnMa4_SetupBeginHorsebackGame(this); + } else { // No + if (this->type == MA4_TYPE_ALIENS_DEFEATED) { + func_8019F230(); + EnMa4_SetFaceExpression(this, 3, 3); + func_801518B0(globalCtx, 0x3357, &this->actor); + this->textId = 0x3357; + func_80151BB4(globalCtx, 5); + } else { + func_8019F230(); + EnMa4_SetFaceExpression(this, 4, 2); + func_801518B0(globalCtx, 0x335B, &this->actor); + this->textId = 0x335B; + func_80151BB4(globalCtx, 5); + } + } + break; + + case 0x3359: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_801518B0(globalCtx, 0x3349, &this->actor); + this->textId = 0x3349; + } else { + func_8019F230(); + EnMa4_SetFaceExpression(this, 4, 2); + func_801518B0(globalCtx, 0x335A, &this->actor); + this->textId = 0x335A; + func_80151BB4(globalCtx, 5); + } + break; + } + } +} + +void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s32 aux; + + if (func_80147624(globalCtx) != 0) { + switch (this->textId) { + case 0x2390: + func_801477B4(globalCtx); + EnMa4_SetupBeginHorsebackGame(this); + break; + + case 0x3335: + EnMa4_SetFaceExpression(this, 0, 3); + func_801518B0(globalCtx, 0x3336, &this->actor); + this->textId = 0x3336; + func_80151BB4(globalCtx, 5); + break; + + case 0x3338: + func_801518B0(globalCtx, 0x3339, &this->actor); + this->textId = 0x3339; + break; + + case 0x333A: + case 0x333B: + EnMa4_SetFaceExpression(this, 0, 3); + func_801518B0(globalCtx, 0x333C, &this->actor); + this->textId = 0x333C; + break; + + case 0x333C: + EnMa4_SetFaceExpression(this, 0, 2); + func_801518B0(globalCtx, 0x333D, &this->actor); + this->textId = 0x333D; + break; + + case 0x333D: + func_801518B0(globalCtx, 0x333E, &this->actor); + this->textId = 0x333E; + break; + + case 0x333E: + func_801477B4(globalCtx); + EnMa4_SetupBeginDescribeThemCs(this); + break; + + case 0x333F: + func_801518B0(globalCtx, 0x3340, &this->actor); + this->textId = 0x3340; + break; + + case 0x3340: + EnMa4_SetFaceExpression(this, 0, 3); + func_801518B0(globalCtx, 0x3341, &this->actor); + this->textId = 0x3341; + break; + + case 0x3343: + EnMa4_SetFaceExpression(this, 0, 0); + func_801518B0(globalCtx, 0x3344, &this->actor); + this->textId = 0x3344; + break; + + case 0x3344: + func_801518B0(globalCtx, 0x3345, &this->actor); + this->textId = 0x3345; + break; + + case 0x3345: + func_801518B0(globalCtx, 0x3349, &this->actor); + this->textId = 0x3349; + break; + + case 0x3349: + func_801518B0(globalCtx, 0x334A, &this->actor); + this->textId = 0x334A; + break; + + case 0x334A: + func_801477B4(globalCtx); + EnMa4_SetupBeginHorsebackGame(this); + break; + + case 0x334C: + func_801518B0(globalCtx, 0x334D, &this->actor); + this->textId = 0x334D; + break; + + case 0x3350: + case 0x3351: + case 0x335D: + case 0x335E: + if (this->type == MA4_TYPE_DAY1) { + func_801518B0(globalCtx, 0x3352, &this->actor); + this->textId = 0x3352; + } else { + func_801518B0(globalCtx, 0x3356, &this->actor); + this->textId = 0x3356; + } + break; + + case 0x3352: // Win minigame + case 0x336D: // Lose minigame + EnMa4_SetFaceExpression(this, 0, 0); + + // Check if player has Epona's song + if ((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE]) { + func_801518B0(globalCtx, 0x334C, &this->actor); + this->textId = 0x334C; + } else { + func_801477B4(globalCtx); + player->stateFlags1 |= 0x20; + EnMa4_SetupBeginEponasSongCs(this); + EnMa4_BeginEponasSongCs(this, globalCtx); + } + break; + + case 0x3358: + if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || + !((aux = gSaveContext.inventory.questItems) & gBitFlags[0xE])) { + func_801518B0(globalCtx, 0x335C, &this->actor); + this->textId = 0x335C; + func_80151BB4(globalCtx, 5); + } else { + func_801518B0(globalCtx, 0x3359, &this->actor); + this->textId = 0x3359; + } + break; + } + } +} + +void EnMa4_SetupDialogueHandler(EnMa4* this) { + if (this->type != MA4_TYPE_ALIENS_WON) { + EnMa4_ChangeAnim(this, 1); + } else { + EnMa4_ChangeAnim(this, 15); + } + this->actionFunc = EnMa4_DialogueHandler; +} + +void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { + s32 temp_v0; + + switch (func_80152498(&globalCtx->msgCtx)) { + default: + break; + + case 4: // Player answered a question + EnMa4_HandlePlayerChoice(this, globalCtx); + break; + + case 5: // End message block + EnMa4_ChooseNextDialogue(this, globalCtx); + break; + + case 6: // End conversation + if (func_80147624(globalCtx) != 0) { + if ((globalCtx->msgCtx.unk_120B1 == 0) || + (((temp_v0 = gSaveContext.inventory.questItems) & gBitFlags[0x12]) == 0)) { + EnMa4_SetupWait(this); + } + } + + case 0: + case 1: + case 2: + case 3: + break; + } + + if (this->type != MA4_TYPE_ALIENS_WON) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 1000); + } +} + +void EnMa4_SetupBeginHorsebackGame(EnMa4* this) { + this->actionFunc = EnMa4_BeginHorsebackGame; +} + +void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x6400; + gSaveContext.unk_3F4A = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; +} + +void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + // "You're feeling confident" + func_801518B0(globalCtx, 0x336E, &this->actor); + this->actionFunc = EnMa4_HorsebackGameTalking; + } else if ((gSaveContext.unk_3DE0[4] < 115 * 100)) { // timer < 115 seconds + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx) { + if (func_800B867C(&this->actor, globalCtx)) { + this->actionFunc = EnMa4_HorsebackGameWait; + } +} + +void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + globalCtx->interfaceCtx.unk_280 = 1; + func_8010E9F0(4, 0); + gSaveContext.weekEventReg[0x8] |= 0x01; + func_80112AFC(globalCtx); + player->stateFlags1 |= 0x20; + this->actionFunc = EnMa4_SetupHorsebackGameWait; +} + +void EnMa4_SetupHorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (globalCtx->interfaceCtx.unk_280 == 8) { + this->actionFunc = EnMa4_HorsebackGameWait; + player->stateFlags1 &= ~0x20; + } +} + +void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { + static s16 D_80AC0258 = 0; + Player* player = PLAYER; + + player->stateFlags3 |= 0x400; + EnMa4_HorsebackGameCheckPlayerInteractions(this, globalCtx); + + if (this->poppedBalloonCounter != D_80AC0258) { + D_80AC0258 = this->poppedBalloonCounter; + globalCtx->interfaceCtx.unk_25C = 1; + } + + if ((gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) // timer >= 2 minutes + || (this->poppedBalloonCounter == 10)) { + gSaveContext.unk_3DD0[4] = 6; + EnMa4_SetupHorsebackGameEnd(this, globalCtx); + D_80AC0258 = 0; + } +} + +void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { + gSaveContext.weekEventReg[0x8] &= (u8)~0x01; + this->actionFunc = EnMa4_HorsebackGameEnd; + func_801A89A8(0x100000FF); + func_801A89A8(0x8041); +} + +void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { + static s32 sFrameCounter = 0; + Player* player = PLAYER; + + if (player->stateFlags1 & 0x100000) { + globalCtx->actorCtx.unk268 = 1; + globalCtx->actorCtx.unk278 = 0x8000; + } else { + globalCtx->actorCtx.unk268 = 1; + } + + if (sFrameCounter == 25) { + if (this->poppedBalloonCounter == 10) { + func_801518B0(globalCtx, 0x334F, &this->actor); + this->textId = 0x334F; + } else { + func_801518B0(globalCtx, 0x334B, &this->actor); + this->textId = 0x334B; + } + } else if (sFrameCounter == 50) { + globalCtx->actorCtx.unk268 = 0; + globalCtx->nextEntranceIndex = 0x6410; + gSaveContext.unk_3F4A = 0; + sFrameCounter = 0; + globalCtx->sceneLoadFlag = 0x14; + + if (this->poppedBalloonCounter == 10) { + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; + } else { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; + } + + this->poppedBalloonCounter = 0; + } + + sFrameCounter++; +} + +void EnMa4_SetupBeginEponasSongCs(EnMa4* this) { + this->actionFunc = EnMa4_BeginEponasSongCs; +} + +// Epona's Song cutscene is an ActorCutscene +void EnMa4_BeginEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { + s16 cutsceneIndex = this->actor.cutscene; + + if (ActorCutscene_GetCanPlayNext(cutsceneIndex) != 0) { + ActorCutscene_Start(cutsceneIndex, &this->actor); + EnMa4_SetupEponasSongCs(this); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(cutsceneIndex); + } +} + +void EnMa4_SetupEponasSongCs(EnMa4* this) { + this->animTimer = 0; + this->actionFunc = EnMa4_EponasSongCs; +} + +static u16 D_80AC0260 = 99; +void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x78) != 0) { + u32 actionIndex = func_800EE200(globalCtx, 0x78); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80AC0260) { + D_80AC0260 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + this->animTimer = 0; + + switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + case 1: + this->hasBow = true; + EnMa4_ChangeAnim(this, 1); + break; + + case 2: + this->hasBow = false; + EnMa4_ChangeAnim(this, 4); + break; + } + } + } + + func_800EDF24(&this->actor, globalCtx, actionIndex); + if (D_80AC0260 == 2 && this->animTimer == 0 && + func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) { + EnMa4_ChangeAnim(this, 7); + } + } else { + Player* player = PLAYER; + + player->stateFlags1 |= 0x20; + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + D_80AC0260 = 99; + this->hasBow = true; + EnMa4_SetupEndEponasSongCs(this); + } +} + +void EnMa4_SetupEndEponasSongCs(EnMa4* this) { + this->actionFunc = EnMa4_EndEponasSongCs; +} + +void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + this->actor.flags |= 0x10000; + if (func_800B84D0(&this->actor, globalCtx) != 0) { + player->stateFlags1 &= ~0x20; + func_801518B0(globalCtx, 0x334C, &this->actor); + this->textId = 0x334C; + this->actor.flags &= ~0x10000; + EnMa4_SetupDialogueHandler(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +void EnMa4_SetupBeginDescribeThemCs(EnMa4* this) { + this->actionFunc = EnMa4_BeginDescribeThemCs; +} + +void EnMa4_BeginDescribeThemCs(EnMa4* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x6400; + gSaveContext.unk_3F4A = 0xFFF5; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; +} + +void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { + s32 pad; + OSTime time; + + switch (this->type) { + case MA4_TYPE_DAY1: + if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + EnMa4_SetFaceExpression(this, 3, 3); + func_801518B0(globalCtx, 0x3337, &this->actor); + this->textId = 0x3337; + func_80151BB4(globalCtx, 5); + } else { + func_801518B0(globalCtx, 0x3335, &this->actor); + this->textId = 0x3335; + gSaveContext.weekEventReg[0x15] |= 0x80; + } + } else if (this->state == MA4_STATE_DEFAULT) { + if ((gSaveContext.weekEventReg[0x15] & 0x40)) { + if (!(gSaveContext.weekEventReg[0x15] & 0x20)) { + func_801518B0(globalCtx, 0x3346, &this->actor); + this->textId = 0x3346; + } else { + func_801518B0(globalCtx, 0x3347, &this->actor); + this->textId = 0x3347; + } + } else { + func_801518B0(globalCtx, 0x3338, &this->actor); + this->textId = 0x3338; + gSaveContext.weekEventReg[0x15] |= 0x40; + } + } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { + if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + // "Too bad Grasshopper" + EnMa4_SetFaceExpression(this, 0, 0); + func_801518B0(globalCtx, 0x336D, &this->actor); + this->textId = 0x336D; + } else { + time = gSaveContext.unk_3DE0[4]; + if ((s32)time < (s32)gSaveContext.roomInf[127][4]) { + // [Score] New record! + gSaveContext.roomInf[127][4] = time; + EnMa4_SetFaceExpression(this, 0, 3); + func_801518B0(globalCtx, 0x3350, &this->actor); + this->textId = 0x3350; + } else { + // [Score] Great. + func_801518B0(globalCtx, 0x3351, &this->actor); + this->textId = 0x3351; + } + } + this->state = MA4_STATE_DEFAULT; + this->actor.flags &= ~0x10000; + } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { + // "Cremia doesn't believe me..." + func_801518B0(globalCtx, 0x3340, &this->actor); + this->textId = 0x3340; + this->actor.flags &= ~0x10000; + } + break; + + case MA4_TYPE_ALIENS_DEFEATED: + if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + EnMa4_SetFaceExpression(this, 3, 3); + func_801518B0(globalCtx, 0x3337, &this->actor); + this->textId = 0x3337; + func_80151BB4(globalCtx, 5); + } else { + func_801518B0(globalCtx, 0x3335, &this->actor); + this->textId = 0x3335; + gSaveContext.weekEventReg[0x15] |= 0x80; + } + } else if (this->state == MA4_STATE_DEFAULT) { + func_801518B0(globalCtx, 0x3354, &this->actor); + this->textId = 0x3354; + } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { + if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + // "Try again?" + func_801518B0(globalCtx, 0x3356, &this->actor); + this->textId = 0x3356; + } else { + time = gSaveContext.unk_3DE0[4]; + if ((s32)time < (s32)gSaveContext.roomInf[127][4]) { + gSaveContext.roomInf[127][4] = time; + EnMa4_SetFaceExpression(this, 0, 3); + func_801518B0(globalCtx, 0x3350, &this->actor); + this->textId = 0x3350; + } else { + func_801518B0(globalCtx, 0x3351, &this->actor); + this->textId = 0x3351; + } + } + this->state = MA4_STATE_DEFAULT; + this->actor.flags &= ~0x10000; + } + break; + + case MA4_TYPE_ALIENS_WON: + if (this->state == MA4_STATE_DEFAULT) { + // "Huh... You?" + func_801518B0(globalCtx, 0x3358, &this->actor); + this->textId = 0x3358; + } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { + if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + // "Try again?" + func_801518B0(globalCtx, 0x3356, &this->actor); + this->textId = 0x3356; + } else { + time = gSaveContext.unk_3DE0[4]; + if ((s32)time < (s32)gSaveContext.roomInf[127][4]) { + // New record + gSaveContext.roomInf[127][4] = time; + func_801518B0(globalCtx, 0x335D, &this->actor); + this->textId = 0x335D; + } else { + // "Old record was: [record]" + func_801518B0(globalCtx, 0x335E, &this->actor); + this->textId = 0x335E; + } + } + this->state = MA4_STATE_DEFAULT; + this->actor.flags &= ~0x10000; + } + break; + + default: + // Dead code + func_801518B0(globalCtx, 0x3335, &this->actor); + this->textId = 0x3335; + break; + } +} + +void EnMa4_SetFaceExpression(EnMa4* this, s16 overrideEyeTexIndex, s16 mouthTexIndex) { + this->overrideEyeTexIndex = overrideEyeTexIndex; + this->mouthTexIndex = mouthTexIndex; +} + +void EnMa4_InitFaceExpression(EnMa4* this) { + if (this->type != MA4_TYPE_ALIENS_WON) { + EnMa4_SetFaceExpression(this, 0, 0); + } else { + EnMa4_SetFaceExpression(this, 1, 2); + } +} + +void EnMa4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMa4* this = THIS; + s32 pad; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + EnMa4_UpdateEyes(this); + this->actionFunc(this, globalCtx); + func_80ABDD9C(this, globalCtx); +} + +s32 EnMa4_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMa4* this = THIS; + Vec3s sp4; + + if (limbIndex == MA1_LIMB_HEAD) { + sp4 = this->unk_1D8.unk_08; + rot->x = rot->x + sp4.y; + rot->z = rot->z + sp4.x; + } + if (limbIndex == MA1_LIMB_TORSO) { + sp4 = this->unk_1D8.unk_0E; + rot->x = rot->x - sp4.y; + rot->z = rot->z - sp4.x; + } + + return false; +} + +void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMa4* this = THIS; + Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; + + if (limbIndex == MA1_LIMB_HEAD) { + SysMatrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); + } else if (limbIndex == MA1_LIMB_HAND_LEFT) { + if (this->hasBow == true) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, D_060003B0); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnMa4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMa4* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (this->type == MA4_TYPE_ALIENS_WON) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_06000A20); + } + + func_8012C28C(globalCtx->state.gfxCtx); + + 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); + + 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 50c003e840..3a6b874052 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h @@ -2,15 +2,37 @@ #define Z_EN_MA4_H #include +#include "overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h" struct EnMa4; +typedef void (*EnMa4ActionFunc)(struct EnMa4*, GlobalContext*); + typedef struct EnMa4 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1F4]; - /* 0x338 */ s16 unk338; // modified by EnPoFusen - /* 0x33A */ char unk33A[0x6]; - + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnMa4ActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; + /* 0x200 */ Vec3s* pathPoints; + /* 0x204 */ Vec3s limbDrawTable[MA1_LIMB_MAX]; + /* 0x28E */ UNK_TYPE1 unk28E[0x6]; + /* 0x294 */ Vec3s transitionDrawTable[MA1_LIMB_MAX]; + /* 0x31E */ UNK_TYPE1 unk31E[0x6]; + /* 0x324 */ s16 pathIndex; + /* 0x326 */ s16 pathPointsCount; + /* 0x328 */ UNK_TYPE1 unk_328[0x2]; + /* 0x32A */ s16 blinkTimer; + /* 0x33C */ s16 overrideEyeTexIndex; + /* 0x32E */ s16 eyeTexIndex; + /* 0x330 */ s16 mouthTexIndex; + /* 0x332 */ s16 type; + /* 0x334 */ u16 unk_334; // set but not used + /* 0x336 */ s16 state; + /* 0x338 */ s16 poppedBalloonCounter; // modified by EnPoFusen + /* 0x33A */ s16 hasBow; + /* 0x33C */ s16 animTimer; + /* 0x33E */ u16 textId; } EnMa4; // size = 0x340 extern const ActorInit En_Ma4_InitVars; 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 69f852bd78..3021f5c5e3 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 @@ -1,6 +1,6 @@ /* - * File: z_en_ma_yto.c - * Overlay: ovl_En_Ma_Yto + * File: z_en_ma_yts.c + * Overlay: ovl_En_Ma_Yts * Description: Romani. As oposed as EnMa4, this actor is used in conjunction of another actor, like EnMaYto. */ @@ -111,17 +111,26 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 D_80B8E1A8[] = { - { &D_06009E58, 1.0f, 0, 0.0f }, { &D_06009E58, 1.0f, 0, -6.0f }, { &D_06018948, 1.0f, 2, 0.0f }, - { &D_06018948, 1.0f, 2, -6.0f }, { &D_0601B76C, 1.0f, 0, 0.0f }, { &D_0601B76C, 1.0f, 0, -6.0f }, - { &D_06007328, 1.0f, 0, 0.0f }, { &D_06007328, 1.0f, 0, -6.0f }, { &D_06014088, 1.0f, 0, 0.0f }, - { &D_06014088, 1.0f, 0, -6.0f }, { &D_06002A8C, 1.0f, 0, 0.0f }, { &D_06002A8C, 1.0f, 0, -6.0f }, - { &D_06015B7C, 1.0f, 0, 0.0f }, { &D_06015B7C, 1.0f, 0, -6.0f }, { &D_06007D98, 1.0f, 0, 0.0f }, - { &D_06007D98, 1.0f, 0, -6.0f }, { &D_0600852C, 1.0f, 0, 0.0f }, { &D_0600852C, 1.0f, 0, -6.0f }, - { &D_06008F6C, 1.0f, 0, 0.0f }, { &D_06008F6C, 1.0f, 0, -6.0f }, { &D_060180DC, 1.0f, 2, 0.0f }, - { &D_060180DC, 1.0f, 2, -6.0f }, +static struct_80B8E1A8 sAnimationInfo[] = { + { &D_06009E58, 1.0f, 0, 0.0f }, { &D_06009E58, 1.0f, 0, -6.0f }, // Idle anim + { &D_06018948, 1.0f, 2, 0.0f }, { &D_06018948, 1.0f, 2, -6.0f }, // Starts holding hands anim + { &D_0601B76C, 1.0f, 0, 0.0f }, { &D_0601B76C, 1.0f, 0, -6.0f }, // Holnding hands anim + { &D_06007328, 1.0f, 0, 0.0f }, { &D_06007328, 1.0f, 0, -6.0f }, // Walking anim + { &D_06014088, 1.0f, 0, 0.0f }, { &D_06014088, 1.0f, 0, -6.0f }, // + { &D_06002A8C, 1.0f, 0, 0.0f }, { &D_06002A8C, 1.0f, 0, -6.0f }, // Looking around anim + { &D_06015B7C, 1.0f, 0, 0.0f }, { &D_06015B7C, 1.0f, 0, -6.0f }, // Shoot arrow anim + { &D_06007D98, 1.0f, 0, 0.0f }, { &D_06007D98, 1.0f, 0, -6.0f }, // Sitting anim + { &D_0600852C, 1.0f, 0, 0.0f }, { &D_0600852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim + { &D_06008F6C, 1.0f, 0, 0.0f }, { &D_06008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim + { &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, @@ -133,14 +142,6 @@ static void* sEyeTextures[] = { D_0600FFC8, D_060107C8, D_06010FC8, D_060117C8, D_06011FC8, }; -static u16 D_80B8E32C = 99; - -void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - SkelAnime_ChangeAnim(&this->skelAnime, D_80B8E1A8[index].animationSeg, 1.0f, 0.0f, - SkelAnime_GetFrameCount(&D_80B8E1A8[index].animationSeg->common), D_80B8E1A8[index].mode, - D_80B8E1A8[index].transitionRate); -} - void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { Player* player = PLAYER; s16 flag = this->unk_32C == 2 ? true : false; @@ -158,12 +159,12 @@ void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { switch (this->type) { - case EN_NA_YTS_TYPE_BARN: + case MA_YTS_TYPE_BARN: this->actor.targetMode = 0; EnMaYts_ChangeAnim(this, 0); break; - case EN_NA_YTS_TYPE_SITTING: + case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { @@ -173,13 +174,13 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { } break; - case EN_NA_YTS_TYPE_SLEEPING: + case MA_YTS_TYPE_SLEEPING: this->actor.targetMode = 0; this->actor.draw = EnMaYts_DrawSleeping; EnMaYts_ChangeAnim(this, 0); break; - case EN_NA_YTS_TYPE_ENDCREDITS: + case MA_YTS_TYPE_ENDCREDITS: this->actor.targetMode = 0; EnMaYts_ChangeAnim(this, 0); break; @@ -192,7 +193,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { switch (this->type) { - case EN_NA_YTS_TYPE_SITTING: + case MA_YTS_TYPE_SITTING: switch (CURRENT_DAY) { case 1: break; @@ -213,7 +214,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { } break; - case EN_NA_YTS_TYPE_BARN: + case MA_YTS_TYPE_BARN: // Failing the alien invasion if (!(gSaveContext.weekEventReg[0x16] & 1)) { return false; @@ -222,14 +223,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { } break; - case EN_NA_YTS_TYPE_SLEEPING: + case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion if (gSaveContext.weekEventReg[0x16] & 1) { return false; } break; - case EN_NA_YTS_TYPE_ENDCREDITS: + case MA_YTS_TYPE_ENDCREDITS: break; } @@ -246,14 +247,14 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06013928, NULL, this->limbDrawTbl, this->transitionDrawTbl, - OBJECT_MA1_LIMB_TABLE_COUNT); + MA1_LIMB_MAX); EnMaYts_InitAnimation(this, globalCtx); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit2); - if (this->type == EN_NA_YTS_TYPE_SLEEPING) { + if (this->type == MA_YTS_TYPE_SLEEPING) { this->collider.dim.radius = 40; } @@ -264,7 +265,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_200 = 0; this->blinkTimer = 0; - if (this->type == EN_NA_YTS_TYPE_ENDCREDITS) { + if (this->type == MA_YTS_TYPE_ENDCREDITS) { this->hasBow = true; } else { this->hasBow = false; @@ -282,7 +283,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_32C = 2; } - if (this->type == EN_NA_YTS_TYPE_ENDCREDITS) { + if (this->type == MA_YTS_TYPE_ENDCREDITS) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -317,7 +318,7 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if (func_800B84D0(&this->actor, globalCtx)) { // if (Actor_IsTalking) - if (!(gSaveContext.playerForm == 4)) { // PLAYER_FORM != HUMAN_FORM + if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (!(gSaveContext.weekEventReg[0x41] & 0x80)) { // Saying to non-human Link: "Cremia went to town." gSaveContext.weekEventReg[0x41] |= 0x80; @@ -399,11 +400,11 @@ void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { this->actionFunc = EnMaYts_EndCreditsHandler; } +static u16 D_80B8E32C = 99; void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { - u32 actionIndex; - if (func_800EE29C(globalCtx, 0x78) != 0) { - actionIndex = func_800EE200(globalCtx, 0x78); + u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80B8E32C) { D_80B8E32C = globalCtx->csCtx.npcActions[actionIndex]->unk0; @@ -526,13 +527,13 @@ s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnMaYts* this = THIS; Vec3s sp4; - if (limbIndex == OBJECT_MA1_LIMB_HAIR_TOP) { + 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)) { rot->z += sp4.x; } - } else if (limbIndex == OBJECT_MA1_LIMB_HEAD) { + } else if (limbIndex == MA1_LIMB_TORSO) { sp4 = this->unk_1D8.unk_0E; rot->x += sp4.y; rot->z += sp4.x; @@ -544,9 +545,9 @@ s32 EnMaYts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMaYts* this = THIS; - if (limbIndex == OBJECT_MA1_LIMB_HAIR_TOP) { + if (limbIndex == MA1_LIMB_HEAD) { SysMatrix_GetStateTranslation(&this->actor.focus.pos); - } else if (limbIndex == OBJECT_MA1_LIMB_ARM_RIGHT) { + } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_060003B0); 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 69c35793fb..449eb33746 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 @@ -8,30 +8,31 @@ struct EnMaYts; typedef void (*EnMaYtsActionFunc)(struct EnMaYts*, GlobalContext*); // Limbs of OBJECT_MA1 -#define OBJECT_MA1_LIMB_TABLE_COUNT 23 typedef enum { - /* 00 */ OBJECT_MA1_LIMB_00, - /* 01 */ OBJECT_MA1_LIMB_PELVIS, - /* 02 */ OBJECT_MA1_LIMB_TIGHT_LEFT, - /* 03 */ OBJECT_MA1_LIMB_LEG_LEFT, - /* 04 */ OBJECT_MA1_LIMB_FOOT_LEFT, - /* 05 */ OBJECT_MA1_LIMB_TIGHT_RIGHT, - /* 06 */ OBJECT_MA1_LIMB_LEG_RIGHT, - /* 07 */ OBJECT_MA1_LIMB_FOOT_RIGHT, - /* 08 */ OBJECT_MA1_LIMB_DRESS_0, - /* 09 */ OBJECT_MA1_LIMB_DRESS_1, - /* 10 */ OBJECT_MA1_LIMB_DRESS_2, - /* 11 */ OBJECT_MA1_LIMB_DRESS_3, - /* 12 */ OBJECT_MA1_LIMB_TORSO, - /* 13 */ OBJECT_MA1_LIMB_HEAD, - /* 14 */ OBJECT_MA1_LIMB_HAIR_TOP, - /* 15 */ OBJECT_MA1_LIMB_HAIR_BOTTOM, - /* 16 */ OBJECT_MA1_LIMB_ARM_LEFT, - /* 17 */ OBJECT_MA1_LIMB_FOREARM_LEFT, - /* 18 */ OBJECT_MA1_LIMB_HAND_LEFT, - /* 19 */ OBJECT_MA1_LIMB_ARM_RIGHT, - /* 20 */ OBJECT_MA1_LIMB_FOREARM_RIGHT, - /* 21 */ OBJECT_MA1_LIMB_HAND_RIGHT + /* 00 */ MA1_LIMB_NONE, + /* 01 */ MA1_LIMB_ROOT, + /* 02 */ MA1_LIMB_PELVIS, + /* 03 */ MA1_LIMB_TIGHT_LEFT, + /* 04 */ MA1_LIMB_LEG_LEFT, + /* 05 */ MA1_LIMB_FOOT_LEFT, + /* 06 */ MA1_LIMB_TIGHT_RIGHT, + /* 07 */ MA1_LIMB_LEG_RIGHT, + /* 08 */ MA1_LIMB_FOOT_RIGHT, + /* 09 */ MA1_LIMB_DRESS_0, + /* 00 */ MA1_LIMB_DRESS_1, + /* 11 */ MA1_LIMB_DRESS_2, + /* 12 */ MA1_LIMB_DRESS_3, + /* 13 */ MA1_LIMB_TORSO, + /* 14 */ MA1_LIMB_HEAD, + /* 15 */ MA1_LIMB_HAIR_TOP, + /* 16 */ MA1_LIMB_HAIR_BOTTOM, + /* 17 */ MA1_LIMB_ARM_LEFT, + /* 18 */ MA1_LIMB_FOREARM_LEFT, + /* 19 */ MA1_LIMB_HAND_LEFT, + /* 20 */ MA1_LIMB_ARM_RIGHT, + /* 21 */ MA1_LIMB_FOREARM_RIGHT, + /* 22 */ MA1_LIMB_HAND_RIGHT, + /* 23 */ MA1_LIMB_MAX } ObjectMa1Limbs; typedef struct EnMaYts { @@ -41,9 +42,9 @@ typedef struct EnMaYts { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; /* 0x200 */ s32 unk_200; // Set, but not used - /* 0x204 */ Vec3s limbDrawTbl[OBJECT_MA1_LIMB_TABLE_COUNT]; + /* 0x204 */ Vec3s limbDrawTbl[MA1_LIMB_MAX]; /* 0x28E */ char unk_28E[0x6]; - /* 0x294 */ Vec3s transitionDrawTbl[OBJECT_MA1_LIMB_TABLE_COUNT]; + /* 0x294 */ Vec3s transitionDrawTbl[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 @@ -60,20 +61,20 @@ typedef struct EnMaYts { extern const ActorInit En_Ma_Yts_InitVars; typedef enum { - /* 0 */ EN_NA_YTS_TYPE_BARN, - /* 1 */ EN_NA_YTS_TYPE_SITTING, - /* 2 */ EN_NA_YTS_TYPE_SLEEPING, - /* 3 */ EN_NA_YTS_TYPE_ENDCREDITS + /* 0 */ MA_YTS_TYPE_BARN, + /* 1 */ MA_YTS_TYPE_SITTING, + /* 2 */ MA_YTS_TYPE_SLEEPING, + /* 3 */ MA_YTS_TYPE_ENDCREDITS } EnMaYtsType; -#define EN_MA_YTS_PARSE_TYPE(actor) (((actor->params)&0xF000) >> 12) +#define EN_MA_YTS_PARSE_TYPE(actor) ((((actor)->params)&0xF000) >> 12) #define EN_MA_YTS_PARAM(enMaYtsType) ((enMaYtsType) << 12) /** - * EN_NA_YTS_TYPE_BARN: In the barn, accompanying Cremia. Cremia's actor will handle her dialogue if spoken to. - * EN_NA_YTS_TYPE_SITTING: Having dinner or looking after the ranch. - * EN_NA_YTS_TYPE_SLEEPING: Sleeping. Can be seen in the second night in her house if the player failed the alien invasion. - * EN_NA_YTS_TYPE_ENDCREDITS: Used in the end credits sequence. + * MA_YTS_TYPE_BARN: In the barn, accompanying Cremia. Cremia's actor will handle her dialogue if spoken to. + * MA_YTS_TYPE_SITTING: Having dinner or looking after the ranch. + * MA_YTS_TYPE_SLEEPING: Sleeping. Can be seen in the second night in her house if the player failed the alien invasion. + * MA_YTS_TYPE_ENDCREDITS: Used in the end credits sequence. */ #endif // Z_EN_MA_YTS_H 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 696f538e8c..3bb650b558 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 @@ -1,3 +1,9 @@ +/* + * File: z_en_po_fusen.c + * Overlay: ovl_En_Po_Fusen + * Description: Romani Ranch - Poe Balloon + */ + #include "z_en_po_fusen.h" #include "overlays/actors/ovl_En_Ma4/z_en_ma4.h" @@ -66,7 +72,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoFusen* this = THIS; f32 heightTemp; - this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.00700000021607; + this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.007f; this->actor.targetMode = 6; this->actor.colChkInfo.damageTable = &sDamageTable; @@ -133,7 +139,7 @@ u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { } u16 EnPoFusen_CheckCollision(EnPoFusen* this, GlobalContext* globalCtx) { - if ((u32)this->actionFunc == (u32)EnPoFusen_IdleFuse) { + if (this->actionFunc == EnPoFusen_IdleFuse) { return 0; } @@ -191,13 +197,13 @@ void EnPoFusen_Idle(EnPoFusen* this, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = (shadowAlphaTmp > f255) ? (u8)f255 : (u8)shadowAlphaTmp; } -void EnPoFusen_IncrementMalonPop(EnPoFusen* this) { +void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { Actor* parent = this->actor.parent; EnMa4* romani; - if ((parent != 0) && (parent->id == ACTOR_EN_MA4)) { + if ((parent != NULL) && (parent->id == ACTOR_EN_MA4)) { romani = (EnMa4*)parent; - romani->unk338++; + romani->poppedBalloonCounter++; } this->actor.draw = NULL; @@ -222,7 +228,7 @@ void EnPoFusen_InitFuse(EnPoFusen* this) { void EnPoFusen_IdleFuse(EnPoFusen* this, GlobalContext* globalCtx) { EnPoFusen_Idle(this, globalCtx); if (this->fuse-- == 0) { - EnPoFusen_IncrementMalonPop(this); + EnPoFusen_IncrementRomaniPop(this); } } @@ -230,7 +236,7 @@ void EnPoFusen_Update(Actor* thisx, GlobalContext* globalCtx) { EnPoFusen* this = THIS; this->actionFunc(this, globalCtx); if (EnPoFusen_CheckCollision(this, globalCtx) != 0) { - EnPoFusen_IncrementMalonPop(this); + EnPoFusen_IncrementRomaniPop(this); } } @@ -246,10 +252,10 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL s16 xRot; if (limbIndex == 2) { - zScale = (Math_CosS(this->randScaleChange) * 0.0799999982119f) + 1.0f; + zScale = (Math_CosS(this->randScaleChange) * 0.08f) + 1.0f; xScale = zScale; if (!zScale) {} - yScale = (Math_SinS(this->randScaleChange) * 0.0799999982119f) + 1.0f; + yScale = (Math_SinS(this->randScaleChange) * 0.08f) + 1.0f; yScale = yScale * yScale; xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); diff --git a/tables/functions.txt b/tables/functions.txt index 0914737aba..8a6a331140 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -11852,41 +11852,41 @@ 0x80ABDB98:("BgHakuginElvpole_Update",), 0x80ABDBBC:("BgHakuginElvpole_Draw",), 0x80ABDCA0:("func_80ABDCA0",), - 0x80ABDD2C:("func_80ABDD2C",), + 0x80ABDD2C:("EnMa4_ChangeAnim",), 0x80ABDD9C:("func_80ABDD9C",), - 0x80ABDE60:("func_80ABDE60",), + 0x80ABDE60:("EnMa4_InitPath",), 0x80ABDF70:("EnMa4_Init",), 0x80ABE188:("EnMa4_Destroy",), - 0x80ABE1C4:("func_80ABE1C4",), - 0x80ABE4A4:("func_80ABE4A4",), - 0x80ABE560:("func_80ABE560",), - 0x80ABE6C8:("func_80ABE6C8",), - 0x80ABEB6C:("func_80ABEB6C",), - 0x80ABEF34:("func_80ABEF34",), - 0x80ABEF8C:("func_80ABEF8C",), - 0x80ABF070:("func_80ABF070",), - 0x80ABF084:("func_80ABF084",), - 0x80ABF0D8:("func_80ABF0D8",), - 0x80ABF160:("func_80ABF160",), - 0x80ABF198:("func_80ABF198",), - 0x80ABF218:("func_80ABF218",), - 0x80ABF254:("func_80ABF254",), - 0x80ABF2FC:("func_80ABF2FC",), - 0x80ABF354:("func_80ABF354",), - 0x80ABF494:("func_80ABF494",), - 0x80ABF4A8:("func_80ABF4A8",), - 0x80ABF51C:("func_80ABF51C",), - 0x80ABF534:("func_80ABF534",), - 0x80ABF69C:("func_80ABF69C",), - 0x80ABF6B0:("func_80ABF6B0",), - 0x80ABF760:("func_80ABF760",), - 0x80ABF774:("func_80ABF774",), - 0x80ABF7C8:("func_80ABF7C8",), - 0x80ABFCAC:("func_80ABFCAC",), - 0x80ABFCD4:("func_80ABFCD4",), + 0x80ABE1C4:("EnMa4_RunInCircles",), + 0x80ABE4A4:("EnMa4_SetupWait",), + 0x80ABE560:("EnMa4_Wait",), + 0x80ABE6C8:("EnMa4_HandlePlayerChoice",), + 0x80ABEB6C:("EnMa4_ChooseNextDialogue",), + 0x80ABEF34:("EnMa4_SetupDialogueHandler",), + 0x80ABEF8C:("EnMa4_DialogueHandler",), + 0x80ABF070:("EnMa4_SetupBeginHorsebackGame",), + 0x80ABF084:("EnMa4_BeginHorsebackGame",), + 0x80ABF0D8:("EnMa4_HorsebackGameCheckPlayerInteractions",), + 0x80ABF160:("EnMa4_HorsebackGameTalking",), + 0x80ABF198:("EnMa4_InitHorsebackGame",), + 0x80ABF218:("EnMa4_SetupHorsebackGameWait",), + 0x80ABF254:("EnMa4_HorsebackGameWait",), + 0x80ABF2FC:("EnMa4_SetupHorsebackGameEnd",), + 0x80ABF354:("EnMa4_HorsebackGameEnd",), + 0x80ABF494:("EnMa4_SetupBeginEponasSongCs",), + 0x80ABF4A8:("EnMa4_BeginEponasSongCs",), + 0x80ABF51C:("EnMa4_SetupEponasSongCs",), + 0x80ABF534:("EnMa4_EponasSongCs",), + 0x80ABF69C:("EnMa4_SetupEndEponasSongCs",), + 0x80ABF6B0:("EnMa4_EndEponasSongCs",), + 0x80ABF760:("EnMa4_SetupBeginDescribeThemCs",), + 0x80ABF774:("EnMa4_BeginDescribeThemCs",), + 0x80ABF7C8:("EnMa4_StartDialogue",), + 0x80ABFCAC:("EnMa4_SetFaceExpression",), + 0x80ABFCD4:("EnMa4_InitFaceExpression",), 0x80ABFD18:("EnMa4_Update",), - 0x80ABFD9C:("func_80ABFD9C",), - 0x80ABFE48:("func_80ABFE48",), + 0x80ABFD9C:("EnMa4_OverrideLimbDraw",), + 0x80ABFE48:("EnMa4_PostLimbDraw",), 0x80ABFEF4:("EnMa4_Draw",), 0x80AC0830:("EnTwig_Init",), 0x80AC0A20:("EnTwig_Destroy",), diff --git a/tables/variables.txt b/tables/variables.txt index dd1e35a14b..18bd328e8f 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -14190,24 +14190,6 @@ 0x80ABDC84:("bgHakuginElvpoleOverlayRelocations","u32","[6]",0x18), 0x80ABDC9C:("bgHakuginElvpoleOverlayInfoOffset","u32","",0x4), 0x80AC0090:("En_Ma4_InitVars","UNK_TYPE1","",0x1), - 0x80AC00B0:("D_80AC00B0","UNK_TYPE1","",0x1), - 0x80AC00DC:("D_80AC00DC","UNK_TYPE1","",0x1), - 0x80AC00E8:("D_80AC00E8","UNK_TYPE1","",0x1), - 0x80AC00FC:("D_80AC00FC","UNK_TYPE1","",0x1), - 0x80AC010C:("D_80AC010C","UNK_TYPE1","",0x1), - 0x80AC024C:("D_80AC024C","UNK_TYPE4","",0x4), - 0x80AC0250:("D_80AC0250","UNK_TYPE4","",0x4), - 0x80AC0254:("D_80AC0254","UNK_TYPE2","",0x2), - 0x80AC0258:("D_80AC0258","UNK_TYPE2","",0x2), - 0x80AC025C:("D_80AC025C","UNK_TYPE4","",0x4), - 0x80AC0260:("D_80AC0260","UNK_TYPE2","",0x2), - 0x80AC0264:("D_80AC0264","UNK_TYPE4","",0x4), - 0x80AC0270:("D_80AC0270","f32","",0x4), - 0x80AC0274:("D_80AC0274","f32","",0x4), - 0x80AC0278:("D_80AC0278","f32","",0x4), - 0x80AC027C:("jtbl_D_80AC027C","UNK_PTR","",0x4), - 0x80AC0300:("jtbl_D_80AC0300","UNK_PTR","",0x4), - 0x80AC03E4:("jtbl_D_80AC03E4","UNK_PTR","",0x4), 0x80AC0400:("enMa4OverlayInfo","OverlayRelocationSection","",0x14), 0x80AC0414:("enMa4OverlayRelocations","u32","[262]",0x418), 0x80AC082C:("enMa4OverlayInfoOffset","u32","",0x4), @@ -16958,7 +16940,6 @@ 0x80B8E150:("En_Ma_Yts_InitVars","UNK_TYPE1","",0x1), 0x80B8E170:("D_80B8E170","ColliderCylinderInit","",0x2C), 0x80B8E19C:("D_80B8E19C","CollisionCheckInfoInit2","",0xC), - 0x80B8E1A8:("D_80B8E1A8","UNK_TYPE1","",0x1), 0x80B8E308:("D_80B8E308","void*","",0x4), 0x80B8E318:("D_80B8E318","UNK_TYPE1","",0x1), 0x80B8E32C:("D_80B8E32C","UNK_TYPE2","",0x2), diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 199576761d..c3e34df543 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -12,6 +12,9 @@ animdict ={ "Matrix_Push": "SysMatrix_StatePush", "Matrix_Init": "SysMatrix_StateAlloc", "Matrix_Put": "SysMatrix_SetCurrentState", + "func_800B78B8": "Actor_UpdateBgCheckInfo", + "func_8012403C": "Player_GetMask", + "func_8012404c": "Player_RemoveMask", } def replace_anim(file):