diff --git a/spec b/spec index cb1adb6e40..46beb00b0f 100644 --- a/spec +++ b/spec @@ -1625,8 +1625,7 @@ beginseg name "ovl_En_Mk" compress include "build/src/overlays/actors/ovl_En_Mk/z_en_mk.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.data.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mk/ovl_En_Mk_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 1cc0cffcea..51d4243b39 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -15,6 +15,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80959524(GlobalContext* globalCtx); void func_809596A0(EnMk* this, GlobalContext* globalCtx); void func_80959774(EnMk* this, GlobalContext* globalCtx); void func_80959A24(EnMk* this, GlobalContext* globalCtx); @@ -22,7 +23,6 @@ void func_80959C94(EnMk* this, GlobalContext* globalCtx); void func_80959D28(EnMk* this, GlobalContext* globalCtx); void func_80959E18(EnMk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, @@ -35,49 +35,453 @@ const ActorInit En_Mk_InitVars = { (ActorFunc)EnMk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095A260 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +s32 func_809592E0(EnMk* this, s16 index) { + AnimationHeader* sAnimations[] = { + &object_mk_Anim_001C38, &object_mk_Anim_000438, &object_mk_Anim_0007D8, + &object_mk_Anim_0010F4, &object_mk_Anim_001964, + }; -extern ColliderCylinderInit D_8095A260; + if (index == this->unk_27C) { + return false; + } -extern UNK_TYPE D_06001C38; + if ((index < 0) || (index >= 5)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809592E0.s") + Animation_PlayLoop(&this->skelAnime, sAnimations[index]); + this->unk_27C = index; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Init.s") +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + s16 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Destroy.s") + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, + this->morphTable, OBJECT_MK_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959524.s") + this->unk_27C = -1; + func_809592E0(this, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095954C.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959624.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809596A0.s") + this->actionFunc = func_80959E18; + this->unk_27A = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959774.s") + if (func_80959524(globalCtx) < 7) { + this->unk_27A |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959844.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_276); i++) { + this->unk_276[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959A24.s") + this->actor.cutscene = this->unk_276[0]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959C94.s") +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959D28.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959E18.s") +s32 func_80959524(GlobalContext* globalCtx) { + return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Update.s") +void func_8095954C(EnMk* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A150.s") + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + case 1: + case 2: + case 3: + case 4: + case 5: + func_809592E0(this, + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + break; + } + } else { + func_809592E0(this, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A198.s") +void func_80959624(EnMk* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Draw.s") + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (this->unk_27A & 4) { + textId = 0xFB9; + } else if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFBC; + } else { + textId = 0xFBB; + } + } else { + textId = 0xFBA; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_809596A0(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->msgCtx.unk11F04 == 0xFB9) || (globalCtx->msgCtx.unk11F04 == 0xFBB) || + (globalCtx->msgCtx.unk11F04 == 0xFBC)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80959774; + } + break; + + case 2: + this->actionFunc = func_80959774; + break; + } +} + +void func_80959774(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959624(this, globalCtx); + this->actionFunc = func_809596A0; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + + func_8095954C(this, globalCtx); +} + +void func_80959844(EnMk* this, GlobalContext* globalCtx) { + u16 textId; + + if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + textId = 0xFB3; + } else if (gSaveContext.weekEventReg[20] & 0x40) { + textId = 0xFB9; + } else if (gSaveContext.weekEventReg[19] & 0x40) { + textId = 0xFB5; + } else if (func_80959524(globalCtx) >= 7) { + textId = 0xFB3; + } else { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_DEKU: + if (gSaveContext.weekEventReg[19] & 0x10) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFAF; + } else { + textId = 0xFAE; + } + } else { + textId = 0xFAC; + } + break; + + case PLAYER_FORM_GORON: + if (gSaveContext.weekEventReg[19] & 8) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFAB; + } else { + textId = 0xFAA; + } + } else { + textId = 0xFA8; + } + break; + + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_HUMAN: + if (func_80959524(globalCtx) > 0) { + textId = 0xFA7; + } else if (gSaveContext.weekEventReg[19] & 4) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFBF; + } else { + textId = 0xFA6; + } + } else { + textId = 0xFA0; + } + break; + + default: + if (func_80959524(globalCtx) > 0) { + textId = 0xFB0; + } else if (gSaveContext.weekEventReg[19] & 0x20) { + textId = 0xFB2; + } else { + textId = 0xFB1; + } + break; + } + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80959A24(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_27A |= 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0xFA1: + case 0xFA3: + case 0xFA4: + case 0xFAA: + case 0xFAE: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0xFA2: + if (gSaveContext.weekEventReg[55] & 0x80) { + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0xFA5: + case 0xFA6: + case 0xFA7: + case 0xFA9: + case 0xFAB: + case 0xFAD: + case 0xFAF: + case 0xFB0: + case 0xFB2: + case 0xFBD: + case 0xFBE: + case 0xFBF: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFA0: + gSaveContext.weekEventReg[19] |= 4; + func_80151938(globalCtx, 0xFA1); + break; + + case 0xFA8: + gSaveContext.weekEventReg[19] |= 8; + if (gSaveContext.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBD); + break; + } + func_80151938(globalCtx, 0xFA9); + break; + + case 0xFAC: + gSaveContext.weekEventReg[19] |= 0x10; + if (gSaveContext.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBE); + break; + } + func_80151938(globalCtx, 0xFAD); + break; + + case 0xFB1: + gSaveContext.weekEventReg[19] |= 0x20; + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFB3: + case 0xFB4: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + this->actor.flags &= ~ACTOR_FLAG_10000; + break; + + case 0xFB5: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + } + break; + } +} + +void func_80959C94(EnMk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80959A24; + this->unk_27A &= ~2; + Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + } +} + +void func_80959D28(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (gSaveContext.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + this->unk_27A |= 4; + } else { + this->actionFunc = func_80959E18; + } + this->actor.cutscene = this->unk_276[0]; + } else { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = -1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + func_8095954C(this, globalCtx); + } +} + +void func_80959E18(EnMk* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + SkelAnime_Update(&this->skelAnime); + + if (gSaveContext.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + return; + } + + if (func_800B8718(&this->actor, &globalCtx->state)) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = func_80959D28; + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.cutscene = this->unk_276[0]; + gSaveContext.weekEventReg[20] |= 0x40; + Item_Give(globalCtx, ITEM_SONG_NOVA); + } else { + this->actor.cutscene = this->unk_276[1]; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959844(this, globalCtx); + this->actionFunc = func_80959A24; + this->unk_27A |= 1; + } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + this->actionFunc = func_80959C94; + } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { + this->unk_27A |= 1; + func_800B8614(&this->actor, globalCtx, 200.0f); + if (!(gSaveContext.weekEventReg[20] & 0x40) && (gSaveContext.weekEventReg[19] & 0x40)) { + func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + } + } else { + this->unk_27A &= ~1; + } + func_8095954C(this, globalCtx); +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMk* this = THIS; + Vec3s sp38; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { + func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + rot->y -= this->unk_270.y; + rot->z += this->unk_270.x; + } + return false; +} + +Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index 715a07c84d..fee132ccd4 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -2,6 +2,7 @@ #define Z_EN_MK_H #include "global.h" +#include "objects/object_mk/object_mk.h" struct EnMk; @@ -9,7 +10,14 @@ typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); typedef struct EnMk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x0270 */ Vec3s unk_270; + /* 0x0276 */ s16 unk_276[2]; + /* 0x027A */ u16 unk_27A; + /* 0x027C */ s16 unk_27C; /* 0x0280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f3217aeac5..83923c05ba 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7702,8 +7702,8 @@ 0x80959D28:("func_80959D28",), 0x80959E18:("func_80959E18",), 0x8095A028:("EnMk_Update",), - 0x8095A150:("func_8095A150",), - 0x8095A198:("func_8095A198",), + 0x8095A150:("EnMk_OverrideLimbDraw",), + 0x8095A198:("EnMk_PostLimbDraw",), 0x8095A1D8:("EnMk_Draw",), 0x8095A510:("func_8095A510",), 0x8095A560:("EnOwl_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ff84de04f7..717a26c8c5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1496,11 +1496,6 @@ D_06011E48 = 0x06011E48; D_06002EC0 = 0x06002EC0; -// ovl_En_Mk - -D_06001C38 = 0x06001C38; -D_06006CA0 = 0x06006CA0; - // ovl_En_Mnk D_06003584 = 0x06003584;