From 1f4973d9b4fbb39b01bf2e60564991c19dad2f1e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 2 Sep 2021 16:27:26 +0100 Subject: [PATCH] En_Kgy (#244) * En_Kgy * NBS * PR * PR * PR --- include/functions.h | 2 +- include/macros.h | 2 + include/z64.h | 5 + spec | 3 +- src/code/code_8012EC80.c | 13 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 5 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 1172 +++++++++++++++++++-- src/overlays/actors/ovl_En_Kgy/z_en_kgy.h | 29 +- undefined_syms.txt | 11 + 9 files changed, 1161 insertions(+), 81 deletions(-) diff --git a/include/functions.h b/include/functions.h index 33f1843e6c..d28605436a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2135,7 +2135,7 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80111CB4(void); // void func_801129E4(void); void func_80112AFC(GlobalContext* globalCtx); -// void func_80112B40(void); +void func_80112B40(GlobalContext* globalCtx, s32 arg1); // void func_80112BE4(void); // void func_80112C0C(void); u32 Item_Give(GlobalContext* globalCtx, u8 param_2); diff --git a/include/macros.h b/include/macros.h index be3ec0c93e..b7a0ff2170 100644 --- a/include/macros.h +++ b/include/macros.h @@ -52,6 +52,8 @@ #define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip]))) +#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[gSaveContext.playerForm == PLAYER_FORM_HUMAN ? 0 : gSaveContext.playerForm][button]) #define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] diff --git a/include/z64.h b/include/z64.h index fd85a21a4a..d6f097cfbf 100644 --- a/include/z64.h +++ b/include/z64.h @@ -56,6 +56,11 @@ #define Z_PRIORITY_DMAMGR 17 #define Z_PRIORITY_IRQMGR 18 +#define EQUIP_SLOT_B 0 +#define EQUIP_SLOT_C_LEFT 1 +#define EQUIP_SLOT_C_DOWN 2 +#define EQUIP_SLOT_C_RIGHT 3 + typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority /* 0x2 */ s16 length; diff --git a/spec b/spec index e4eee76b04..51ddb80022 100644 --- a/spec +++ b/spec @@ -4185,8 +4185,7 @@ beginseg name "ovl_En_Kgy" compress include "build/src/overlays/actors/ovl_En_Kgy/z_en_kgy.o" - include "build/data/ovl_En_Kgy/ovl_En_Kgy.data.o" - include "build/data/ovl_En_Kgy/ovl_En_Kgy.reloc.o" + include "build/src/overlays/actors/ovl_En_Kgy/ovl_En_Kgy_reloc.o" endseg beginseg diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index feec42940f..084e918726 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -177,19 +177,18 @@ u16 gScenesPerRegion[11][27] = { s32 func_8012EC80(GlobalContext* globalCtx) { if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { - return 0xFF; - } else if (gSaveContext.unk_1015 == 0xFF) { - return 0xFF; - } else if (gSaveContext.equips.buttonItems[((gSaveContext.playerForm == 4) ? 0 : gSaveContext.playerForm)][0] == - 0xFF) { + return ITEM_NONE; + } else if (gSaveContext.unk_1015 == ITEM_NONE) { + return ITEM_NONE; + } else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { if (globalCtx->interfaceCtx.unk_21C != 0) { if (globalCtx->interfaceCtx.unk_21E != 0) { return globalCtx->interfaceCtx.unk_21E; } } - return 0xFF; + return ITEM_NONE; } else { - return gSaveContext.equips.buttonItems[((gSaveContext.playerForm == 4) ? 0 : gSaveContext.playerForm)][0]; + return CUR_FORM_EQUIP(EQUIP_SLOT_B); } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 44a3d1eccd..319bb02d82 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -911,10 +911,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > 0) { if (player->heldItemButton == 0) { - buttonItem = - gSaveContext.equips - .buttonItems[(gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm] - [player->heldItemButton]; + buttonItem = CUR_FORM_EQUIP(player->heldItemButton); } else { buttonItem = gSaveContext.equips.buttonItems[0][player->heldItemButton]; } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index cd641d50e4..6a37e5e053 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -1,3 +1,11 @@ +/* + * File: z_en_kgy.c + * Overlay: ovl_En_Kgy + * Description: Blacksmith - Gabora + */ + +#include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #include "z_en_kgy.h" #define FLAGS 0x00000009 @@ -9,26 +17,38 @@ void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx); void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B417B8(EnKgy* this, GlobalContext* globalCtx); -void func_80B41858(EnKgy* this, GlobalContext* globalCtx); +void EnKgy_ChangeAnim(EnKgy* this, s16 arg1, u8 arg2, f32 arg3); +EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx); +ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx); +void func_80B40D30(GlobalContext* globalCtx); +s32 func_80B40D64(GlobalContext* globalCtx); +s32 func_80B40DB4(GlobalContext* globalCtx); void func_80B419B0(EnKgy* this, GlobalContext* globalCtx); void func_80B41A48(EnKgy* this, GlobalContext* globalCtx); -void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx); -void func_80B41C30(EnKgy* this, GlobalContext* globalCtx); -void func_80B41C54(EnKgy* this, GlobalContext* globalCtx); -void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx); -void func_80B41D64(EnKgy* this, GlobalContext* globalCtx); void func_80B41E18(EnKgy* this, GlobalContext* globalCtx); void func_80B42508(EnKgy* this, GlobalContext* globalCtx); void func_80B425A0(EnKgy* this, GlobalContext* globalCtx); -void func_80B42660(EnKgy* this, GlobalContext* globalCtx); void func_80B42714(EnKgy* this, GlobalContext* globalCtx); -void func_80B427C8(EnKgy* this, GlobalContext* globalCtx); -void func_80B4296C(EnKgy* this, GlobalContext* globalCtx); -void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx); void func_80B42D28(EnKgy* this, GlobalContext* globalCtx); -#if 0 +extern AnimationHeader D_060008FC; +extern AnimationHeader D_06001764; +extern Gfx D_04001D00[]; +extern AnimationHeader D_06001EA4; +extern Gfx D_040021A8[]; +extern AnimationHeader D_0600292C; +extern AnimationHeader D_06003334; +extern AnimationHeader D_06003D88; +extern AnimationHeader D_060042E4; +extern AnimationHeader D_06004B98; +extern Gfx D_0600E8F0[]; +extern Gfx D_0600EE58[]; +extern Gfx D_0600F180[]; +extern Gfx D_0600F6A0[]; +extern FlexSkeletonHeader D_0600F910; +extern AnimationHeader D_06010B84; +extern AnimationHeader D_060101F0; + const ActorInit En_Kgy_InitVars = { ACTOR_EN_KGY, ACTORCAT_NPC, @@ -41,105 +61,1129 @@ const ActorInit En_Kgy_InitVars = { (ActorFunc)EnKgy_Draw, }; -#endif +void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKgy* this = THIS; + s16 cs; + s32 i; -extern UNK_TYPE D_06004B98; -extern UNK_TYPE D_0600F6A0; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600F910, &D_06004B98, this->jointTable, this->morphTable, 23); + this->unk_2D2 = -1; + this->unk_29C = 0; + this->unk_2E4 = 0; + this->unk_2E2 = -1; + this->zubora = EnKgy_FindZubora(globalCtx); + this->iceBlock = EnKgy_FindIceBlock(globalCtx); + Actor_UnsetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { + Actor_SetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + globalCtx->envCtx.unk_C3 = 1; + gSaveContext.weekEventReg[21] |= 1; + if (!func_80B40D64(globalCtx)) { + EnKgy_ChangeAnim(this, 4, 0, 0); + this->actionFunc = func_80B425A0; + this->actor.textId = 0xC35; + } else if (!func_80B40DB4(globalCtx)) { + EnKgy_ChangeAnim(this, 6, 2, 0); + this->actionFunc = func_80B419B0; + this->actor.textId = 0xC4E; + this->unk_29C |= 1; + this->unk_2EA = 3; + } else { + EnKgy_ChangeAnim(this, 4, 0, 0); + this->actionFunc = func_80B42714; + this->actor.textId = 0xC50; + } + } else { + if (gSaveContext.weekEventReg[20] & 0x80) { + EnKgy_ChangeAnim(this, 4, 0, 0); + } else { + EnKgy_ChangeAnim(this, 0, 0, 0); + } + this->actionFunc = func_80B42D28; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/EnKgy_Init.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_2D4); i++) { + this->unk_2D4[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/EnKgy_Destroy.s") + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 64, 64, -1); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + this->unk_300 = -1; + this->actor.flags &= ~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40B38.s") +void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKgy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40BC0.s") + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40BFC.s") +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 transitionRate) { + static AnimationHeader* sAnimations[] = { + &D_06004B98, &D_060008FC, &D_0600292C, &D_060042E4, &D_060101F0, + &D_06001764, &D_06003334, &D_06010B84, &D_06001EA4, &D_06003D88, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40C38.s") + SkelAnime_ChangeAnim(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, + SkelAnime_GetFrameCount(&sAnimations[animIndex]->common), mode, transitionRate); + this->unk_2D2 = animIndex; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40C74.s") +void func_80B40BC0(EnKgy* this, s16 arg1) { + if (arg1 != this->unk_2D2) { + EnKgy_ChangeAnim(this, arg1, 0, -5.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40D00.s") +EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40D30.s") + while (actor != NULL) { + if (actor->id == ACTOR_EN_KBT) { + return (EnKbt*)actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40D64.s") +ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40D8C.s") + while (actor != NULL) { + if (actor->id == ACTOR_OBJ_ICE_POLY) { + return (ObjIcePoly*)actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40DB4.s") +void func_80B40C74(GlobalContext* globalCtx) { + gSaveContext.roomInf[globalCtx->sceneNum][5] |= 1; + if (CURRENT_DAY == 1) { + gSaveContext.roomInf[globalCtx->sceneNum][5] |= 2; + } else { + gSaveContext.roomInf[globalCtx->sceneNum][5] &= ~2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40E18.s") +void func_80B40D00(GlobalContext* globalCtx) { + gSaveContext.roomInf[globalCtx->sceneNum][5] |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40E38.s") +void func_80B40D30(GlobalContext* globalCtx) { + gSaveContext.roomInf[globalCtx->sceneNum][5] &= ~7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40E54.s") +s32 func_80B40D64(GlobalContext* globalCtx) { + return gSaveContext.roomInf[globalCtx->sceneNum][5] & 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40E74.s") +s32 func_80B40D8C(GlobalContext* globalCtx) { + return gSaveContext.roomInf[globalCtx->sceneNum][5] & 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40EBC.s") +s32 func_80B40DB4(GlobalContext* globalCtx) { + if ((CURRENT_DAY == 3) || ((CURRENT_DAY == 2) && (gSaveContext.roomInf[globalCtx->sceneNum][5] & 2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B40EE8.s") +void func_80B40E18(EnKgy* this, u16 textId) { + if (this->zubora != NULL) { + this->zubora->actor.textId = textId; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B411DC.s") +void func_80B40E38(EnKgy* this) { + if (this->zubora != NULL) { + this->zubora->actor.home.rot.z = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41368.s") +s32 func_80B40E54(EnKgy* this) { + if (this->zubora != NULL) { + return this->zubora->actor.home.rot.z; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B413C8.s") +void func_80B40E74(EnKgy* this, GlobalContext* globalCtx, u16 textId) { + func_80151938(globalCtx, textId); + this->actor.textId = textId; + func_80B40E18(this, this->actor.textId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41460.s") +void func_80B40EBC(EnKgy* this, GlobalContext* globalCtx, u16 arg2) { + func_80B40E74(this, globalCtx, ++arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41528.s") +void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B415A8.s") + if (this->unk_2E4 > 0) { + this->unk_2E4--; + if ((this->unk_2E4 == 0) && (this->unk_2E2 >= 0)) { + if (this->unk_2E2 == 3) { + EnKgy_ChangeAnim(this, 3, 2, -5.0f); + } else { + func_80B40BC0(this, this->unk_2E2); + } + this->unk_2E2 = -1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B4163C.s") + if ((this->unk_2E0 != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_2D4[this->unk_2E0])) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D4[this->unk_2E0]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_2D4[this->unk_2E0])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[this->unk_2E0], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_2D4[this->unk_2E0]); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B417B8.s") + if (this->unk_29C & 2) { + Vec3f sp38; + f32 sp34; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41858.s") + func_800B4EDC(globalCtx, &this->unk_2B4, &sp38, &sp34); + temp_f0 = sp38.x * sp34; + if (this->unk_2E6 > 0) { + this->unk_2E6--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B418C4.s") + if (((temp_f0 < 0.15f) && (temp_f0 > -0.15f)) || (this->unk_2E6 == 0)) { + func_80151938(globalCtx, this->actor.textId); + this->unk_29C &= ~0x2; + func_80B40E18(this, this->actor.textId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B419B0.s") + switch (this->actor.textId) { + case 0xC22: + this->unk_2E4 = 20; + this->unk_2E2 = 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41A48.s") + case 0xC43: + if (func_80B40D64(globalCtx)) { + func_80B40BC0(this, 7); + } else { + func_80B40BC0(this, 1); + } + this->unk_2E4 = 30; + this->actionFunc = func_80B41A48; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41ACC.s") + case 0xC52: + case 0xC54: + func_80B40BC0(this, 1); + break; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41C30.s") + if (this->unk_29C & 4) { + if (this->unk_2E8 > 0) { + this->unk_2E8--; + } else { + this->unk_2E8 = 0; + } + if (this->unk_2E8 == 0) { + if ((this->actor.textId == 0xC1D) || (this->actor.textId == 0xC2D)) { + this->unk_2E4 = 20; + this->unk_2E2 = 3; + func_80B40EBC(this, globalCtx, this->actor.textId); + } else { + func_80B40EBC(this, globalCtx, this->actor.textId); + } + this->unk_29C &= ~4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41C54.s") +void func_80B411DC(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { + Player* player = PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41CBC.s") + switch (arg2) { + case 0: + this->unk_2B4 = this->unk_2A8; + this->actor.focus.pos = this->unk_2A8; + this->unk_2E0 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41D64.s") + case 1: + if (this->zubora != NULL) { + this->unk_2B4 = this->zubora->actor.focus.pos; + this->actor.focus.pos = this->zubora->actor.focus.pos; + } + this->unk_2E0 = 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B41E18.s") + case 2: + if (this->iceBlock != NULL) { + this->unk_2B4 = this->iceBlock->actor.world.pos; + this->actor.focus.pos = this->iceBlock->actor.focus.pos; + } + this->unk_2E0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42508.s") + case 3: + this->unk_2B4 = player->actor.world.pos; + if (this->zubora != NULL) { + this->actor.focus.pos = this->zubora->actor.focus.pos; + } + this->unk_2E0 = 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B425A0.s") + case 4: + if (this->zubora != NULL) { + this->unk_2B4 = this->zubora->actor.focus.pos; + this->actor.focus.pos = this->zubora->actor.focus.pos; + } + this->unk_2E0 = 4; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42660.s") +void func_80B41368(EnKgy* this, GlobalContext* globalCtx, s32 arg2) { + ActorCutscene_Stop(this->unk_2D4[this->unk_2E0]); + func_80B411DC(this, globalCtx, arg2); + this->unk_2E6 = 20; + this->unk_29C |= 2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42714.s") +void func_80B413C8(EnKgy* this) { + Vec3f sp1C = this->unk_2A8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B427C8.s") + this->unk_2B4 = sp1C; + this->actor.focus.pos = sp1C; + ActorCutscene_Stop(this->unk_2D4[this->unk_2E0]); + this->unk_2E0 = -1; + this->unk_2E6 = 0; + this->unk_29C &= ~2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B4296C.s") +s32 func_80B41460(void) { + if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || + ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { + return 0xC38; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42A8C.s") + if (CURRENT_DAY == 3) { + return 0xC39; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42D28.s") + return 0xC3A; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/EnKgy_Update.s") +s32 func_80B41528(GlobalContext* globalCtx) { + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_SWORD_GILDED) { + return 0xC4C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B42FA0.s") + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_SWORD_RAZOR) { + return 0xC45; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B43008.s") + return 0xC3B; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/func_80B43074.s") +void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { + static EffShieldParticleInit D_80B43298 = { + 16, + { 0, 0, 0 }, + { 0, 200, 255, 255 }, + { 255, 255, 255, 255 }, + { 255, 255, 128, 255 }, + { 255, 255, 0, 255 }, + { 255, 64, 0, 200 }, + { 255, 0, 0, 255 }, + 2.0f, + 15.0f, + 10.0f, + 4, + { 0, 0, 0, { 0, 128, 255 }, 0, 300 }, + 0, + }; + s32 effectIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kgy/EnKgy_Draw.s") + D_80B43298.position.x = arg1->x; + D_80B43298.position.y = arg1->y; + D_80B43298.position.z = arg1->z; + D_80B43298.lightPoint.x = D_80B43298.position.x; + D_80B43298.lightPoint.y = D_80B43298.position.y; + D_80B43298.lightPoint.z = D_80B43298.position.z; + + Effect_Add(globalCtx, &effectIndex, 3, 0, 1, &D_80B43298); +} + +void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { + this->actor.focus.pos = this->unk_2A8; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->unk_2D2 == 6) { + if (this->unk_2EA > 0) { + EnKgy_ChangeAnim(this, 6, 2, 0.0f); + this->unk_2EA--; + } else { + EnKgy_ChangeAnim(this, 9, 2, -5.0f); + this->unk_2EA = (s32)Rand_ZeroFloat(3.0f) + 2; + } + } else { + EnKgy_ChangeAnim(this, 6, 2, -5.0f); + } + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + } + + switch ((s32)this->skelAnime.animCurrentFrame) { + case 1: + case 7: + case 13: + case 19: + case 25: + func_80B415A8(globalCtx, &this->unk_2C0); + this->lightInfo.params.point.x = this->unk_2C0.x; + this->lightInfo.params.point.y = this->unk_2C0.y; + this->lightInfo.params.point.z = this->unk_2C0.z; + this->unk_300 = 200; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_SWORD_FORGE); + break; + } + + this->lightInfo.params.point.radius = this->unk_300; + if (this->unk_300 > 0) { + this->unk_300 -= 50; + } +} + +void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { + func_80B4163C(this, globalCtx); + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80B413C8(this); + this->actor.flags &= ~0x100; + this->actionFunc = func_80B419B0; + func_80B40E18(this, 7); + } + func_80B40EE8(this, globalCtx); +} + +void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { + func_80B4163C(this, globalCtx); + if (ActorCutscene_GetCanPlayNext(this->unk_2D4[5])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[5], &this->actor); + this->actionFunc = func_80B419B0; + func_80B40E18(this, 7); + } else { + ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); + } +} + +void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { + func_80B4163C(this, globalCtx); + if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && + (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && + ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { + func_801477B4(globalCtx); + this->actor.textId = 0xC4F; + func_80B413C8(this); + ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); + this->actionFunc = func_80B41858; + this->actor.flags &= ~0x100; + } + func_80B40EE8(this, globalCtx); +} + +void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + + func_80B4163C(this, globalCtx); + if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + func_80B411DC(this, globalCtx, 4); + func_80B40E18(this, this->actor.textId); + if (this->actor.textId == 0xC37) { + this->actionFunc = func_80B417B8; + } else { + this->actionFunc = func_80B418C4; + } + } +} + +void func_80B41A48(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->unk_2E4 > 0) { + this->unk_2E4--; + } else { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENKGY_GET_1F(&this->actor)]; + globalCtx->sceneLoadFlag = 20; + } +} + +void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { + s32 temp_v0; + Player* player = PLAYER; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_80152498(&globalCtx->msgCtx) == 0x10) { + temp_v0 = func_80123810(globalCtx); + if (temp_v0 != 0) { + this->actionFunc = func_80B41E18; + } + + if (temp_v0 > 0) { + func_801477B4(globalCtx); + if (temp_v0 == 0x1B) { + if (this->unk_29C & 0x10) { + this->actor.textId = 0xC55; + player->actor.textId = 0xC55; + } else { + this->actor.textId = 0xC46; + player->actor.textId = 0xC46; + func_80B40D00(globalCtx); + } + } else if (this->unk_29C & 0x10) { + this->actor.textId = 0xC57; + player->actor.textId = 0xC57; + } else { + this->actor.textId = 0xC47; + player->actor.textId = 0xC47; + } + this->unk_29C |= 8; + } else if (temp_v0 < 0) { + if (this->unk_29C & 0x10) { + this->actor.textId = 0xC57; + } else { + this->actor.textId = 0xC47; + } + player->actor.textId = 0; + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 4); + } + } + func_80B40EE8(this, globalCtx); +} + +void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + if (&this->actor != player->targetActor) { + this->actionFunc = func_80B42508; + } +} + +void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_800B867C(&this->actor, globalCtx)) { + this->actionFunc = func_80B41C30; + this->actor.flags &= ~0x100; + } + func_80B40EE8(this, globalCtx); +} + +void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10000; + func_80B40E18(this, this->actor.textId); + this->actionFunc = func_80B41E18; + func_80B411DC(this, globalCtx, 4); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actionFunc = func_80B41CBC; + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + } + func_80B40EE8(this, globalCtx); +} + +void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { + u16 temp; + s32 pad; + Player* player = PLAYER; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 3)) { + func_80B40BC0(this, 4); + } + + if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { + switch (func_80152498(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx)) { + temp = globalCtx->msgCtx.unk11F04; + + switch (temp) { + case 0xC3B: + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + play_sound(NA_SE_SY_ERROR); + func_80B40E74(this, globalCtx, 0xC3F); + } else { + func_8019F208(); + func_80B40E74(this, globalCtx, 0xC42); + func_801159EC(-globalCtx->msgCtx.unk1206C); + } + break; + + case 1: + func_8019F230(); + func_80B40EBC(this, globalCtx, temp); + break; + } + break; + + case 0xC3E: + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80B40E74(this, globalCtx, func_80B41460()); + break; + + case 1: + func_8019F230(); + func_80B40E74(this, globalCtx, 0xC3C); + break; + } + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + temp = globalCtx->msgCtx.unk11F04; + + switch (temp) { + case 0xC35: + globalCtx->msgCtx.unk11F10 = 0; + this->actor.textId = temp; + this->unk_29C |= 4; + this->unk_2E8 = 3; + func_80B40E38(this); + break; + + case 0xC36: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 4); + this->actor.textId = func_80B41460(); + break; + + case 0xC38: + case 0xC39: + case 0xC52: + case 0xC54: + func_801477B4(globalCtx); + this->actionFunc = func_80B425A0; + func_80B413C8(this); + func_80B40E18(this, 5); + func_80B40BC0(this, 4); + this->actor.textId = 0xC35; + break; + + case 0xC3A: + func_80B40E74(this, globalCtx, func_80B41528(globalCtx)); + func_80B40BC0(this, 4); + break; + + case 0xC3C: + case 0xC3F: + case 0xC4C: + func_80B40EBC(this, globalCtx, temp); + break; + + case 0xC3D: + func_801477B4(globalCtx); + this->actionFunc = func_80B41C54; + this->actor.textId = 0xC3E; + func_80B413C8(this); + func_80B40E18(this, 2); + break; + + case 0xC40: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 0); + this->actor.textId = 0xC43; + break; + + case 0xC42: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 0); + this->actor.textId = 0xC43; + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; + TAKE_EQUIPPED_ITEM(EQUIP_SWORD); + func_80112B40(globalCtx, 0); + func_80B40C74(globalCtx); + break; + + case 0xC4D: + case 0xC58: + this->unk_29C |= 0x10; + + case 0xC45: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 3); + this->actor.textId = 0xFF; + this->actionFunc = func_80B41ACC; + break; + + case 0xC57: + this->unk_29C &= ~0x8; + func_801477B4(globalCtx); + this->actionFunc = func_80B41C54; + this->actor.textId = 0xC58; + func_80B413C8(this); + func_80B40E18(this, 3); + break; + + case 0xC46: + case 0xC55: + func_80123D50(globalCtx, PLAYER, 0x12, 0x15); + player->unk_A87 = 0; + this->unk_29C &= ~0x8; + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 4); + if (this->unk_29C & 0x10) { + this->actor.textId = 0xC56; + func_801159EC(globalCtx->msgCtx.unk1206C); + } else { + this->actor.textId = 0xC42; + } + break; + + case 0xC47: + func_80B40BC0(this, 1); + if (this->unk_29C & 8) { + player->unk_A87 = 0; + this->unk_29C &= ~8; + } + func_80B40EBC(this, globalCtx, temp); + break; + + case 0xC48: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 0); + this->actor.textId = temp + 1; + break; + + case 0xC49: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 4); + this->actor.textId = temp + 1; + break; + + case 0xC4A: + case 0xC4B: + func_80B40BC0(this, 4); + func_801477B4(globalCtx); + this->actionFunc = func_80B41C54; + this->actor.textId = 0xC4B; + func_80B413C8(this); + func_80B40E18(this, 4); + break; + + case 0xC50: + if (func_80B40D8C(globalCtx)) { + this->unk_2EA = 57; + this->actor.textId = 0xC53; + } else { + this->unk_2EA = 56; + this->actor.textId = 0xC51; + } + func_801477B4(globalCtx); + this->actionFunc = func_80B41D64; + func_80B413C8(this); + func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + break; + + case 0xC51: + case 0xC53: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 0); + this->actor.textId = temp + 1; + func_80B40D30(globalCtx); + break; + + case 0xC56: + func_801477B4(globalCtx); + this->actionFunc = func_80B41C54; + this->actor.textId = 0xC56; + func_80B413C8(this); + func_80B40E18(this, 8); + break; + } + } + break; + } + } + + func_80B40EE8(this, globalCtx); +} + +void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->actor.focus.pos = this->unk_2A8; + if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + this->actionFunc = func_80B41E18; + func_80B411DC(this, globalCtx, 4); + func_80B40E18(this, this->actor.textId); + } +} + +void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->actor.focus.pos = this->unk_2A8; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B41E18; + func_80B40BC0(this, 1); + func_80B411DC(this, globalCtx, 0); + func_80B40E18(this, this->actor.textId); + } else if (this->actor.xzDistToPlayer < 200.0f) { + func_800B8614(&this->actor, globalCtx, 210.0f); + } +} + +void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->actor.focus.pos = this->unk_2A8; + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80B413C8(this); + this->actor.flags &= ~0x100; + this->actionFunc = func_80B42714; + func_80B40E18(this, 7); + } + func_80B40EE8(this, globalCtx); +} + +void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + this->actor.focus.pos = this->unk_2A8; + if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + func_80B411DC(this, globalCtx, 4); + func_80B40E18(this, this->actor.textId); + if (this->actor.textId == 0xC37) { + this->actionFunc = func_80B42660; + } else { + this->actionFunc = func_80B41E18; + } + } +} + +void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a2; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->unk_2D2 == 5) { + func_80B40BC0(this, 7); + } + if (this->unk_2D2 == 3) { + func_80B40BC0(this, 4); + } + } + + if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && + (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + temp_a2 = globalCtx->msgCtx.unk11F04; + + switch (temp_a2) { + case 0xC30: + globalCtx->msgCtx.unk11F10 = 0; + this->actor.textId = temp_a2; + this->unk_29C |= 4; + this->unk_2E8 = 3; + break; + + case 0xC31: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 4); + this->actor.textId = temp_a2 + 1; + break; + + case 0xC32: + case 0xC33: + func_80B40EBC(this, globalCtx, temp_a2); + break; + + case 0xC34: + func_801477B4(globalCtx); + this->actionFunc = func_80B41C54; + func_80B413C8(this); + func_80B40E18(this, 6); + func_80B40BC0(this, 4); + this->actor.textId = 0xC3A; + break; + } + } + func_80B40EE8(this, globalCtx); +} + +void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 8)) { + func_80B40BC0(this, 2); + } + + this->actor.focus.pos = this->unk_2A8; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B427C8; + if (this->unk_2D2 == 4) { + func_80B40BC0(this, 7); + } else { + EnKgy_ChangeAnim(this, 5, 2, -5.0f); + } + func_80B411DC(this, globalCtx, 0); + func_80B40E18(this, this->actor.textId); + this->actor.flags &= ~0x10000; + } else { + this->actor.flags |= 0x10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, 0); + } +} + +void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { + u16 temp_a2; + s32 pad; + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->unk_2D2 == 5) { + func_80B40BC0(this, 1); + } + + if (this->unk_2D2 == 3) { + func_80B40BC0(this, 4); + } + } + + if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && + (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + temp_a2 = globalCtx->msgCtx.unk11F04; + switch (temp_a2) { + case 0xC1D: + case 0xC2D: + globalCtx->msgCtx.unk11F10 = 0; + this->actor.textId = temp_a2; + this->unk_29C |= 4; + this->unk_2E8 = 3; + break; + + case 0xC1E: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 1); + this->actor.textId = temp_a2 + 1; + func_80B40E38(this); + break; + + case 0xC1F: + case 0xC23: + case 0xC24: + case 0xC27: + func_80B40EBC(this, globalCtx, temp_a2); + break; + + case 0xC20: + case 0xC28: + func_80B40BC0(this, 1); + globalCtx->msgCtx.unk11F10 = 0; + this->unk_29C |= 4; + this->unk_2E8 = 3; + this->actor.textId = temp_a2; + func_80B40E38(this); + break; + + case 0xC21: + case 0xC29: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 0); + this->actor.textId = temp_a2 + 1; + break; + + case 0xC22: + case 0xC26: + case 0xC2B: + case 0xC2E: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 1); + this->actor.textId = temp_a2 + 1; + break; + + case 0xC25: + globalCtx->msgCtx.unk11F10 = 0; + func_80B41368(this, globalCtx, 2); + this->actor.textId = temp_a2 + 1; + break; + + case 0xC2A: + this->unk_2E4 = 20; + this->unk_2E2 = 3; + func_80B40EBC(this, globalCtx, this->actor.textId); + break; + + case 0xC2C: + case 0xC2F: + func_801477B4(globalCtx); + this->actionFunc = func_80B42D28; + func_80B413C8(this); + func_80B40E18(this, 1); + break; + } + } + func_80B40EE8(this, globalCtx); +} + +void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime) && (this->unk_2D2 == 8)) { + func_80B40BC0(this, 2); + } + + this->actor.focus.pos = this->unk_2A8; + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = func_80B42A8C; + if (this->actor.textId == 0xC2D) { + func_80B40BC0(this, 1); + } else { + EnKgy_ChangeAnim(this, 5, 2, -5.0f); + gSaveContext.weekEventReg[20] |= 0x80; + } + func_80B411DC(this, globalCtx, 0); + func_80B40E18(this, this->actor.textId); + } else { + if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor))) { + this->actor.textId = 0xC30; + this->actionFunc = func_80B4296C; + gSaveContext.weekEventReg[21] |= 1; + } else if (this->actor.xzDistToPlayer < 200.0f) { + if (this->unk_2D2 == 4) { + this->actor.textId = 0xC2D; + } else { + this->actor.textId = 0xC1D; + } + func_800B8614(&this->actor, globalCtx, 210.0f); + } + + if ((this->unk_2D2 == 0) && (this->actor.xzDistToPlayer < 200.0f)) { + EnKgy_ChangeAnim(this, 8, 2, 5.0f); + } + } +} + +void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKgy* this = THIS; + s32 pad; + Vec3s sp30; + + this->actionFunc(this, globalCtx); + if (this->unk_2D2 == 2) { + sp30.z = 0; + sp30.y = 0; + sp30.x = 0; + func_800E9250(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2CC.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2CC.y, 0, 6, 6200, 100); + } +} + +s32 EnKgy_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKgy* this = THIS; + + if (!(this->unk_29C & 1)) { + if (limbIndex == 17) { + *dList = NULL; + } + } else if (limbIndex == 16) { + *dList = NULL; + } + + if (limbIndex == 11) { + rot->x += this->unk_2CC.y; + } + + return false; +} + +void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B432D8 = { 1000.0f, 2000.0f, 0.0f }; + static Vec3f D_80B432E4 = { 3000.0f, 4000.0f, 300.0f }; + EnKgy* this = THIS; + + if (limbIndex == 11) { + SysMatrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); + } + + if (limbIndex == 16) { + SysMatrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); + } +} + +void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { + s32 pad; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); + SysMatrix_StatePush(); + SysMatrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + + if (func_80B40D8C(globalCtx)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(D_0600F6A0)); + } else { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(D_0600EE58)); + } + + gfx = POLY_OPA_DISP; + gSPMatrix(gfx, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (func_80B40D8C(globalCtx)) { + gSPDisplayList(&gfx[1], D_04001D00); + gSPDisplayList(&gfx[2], D_0600F180); + } else { + gSPDisplayList(&gfx[1], D_040021A8); + gSPDisplayList(&gfx[2], D_0600E8F0); + } + POLY_OPA_DISP = &gfx[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SysMatrix_StatePop(); +} + +void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKgy* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_29C & 1) { + func_80B43074(this, globalCtx); + } + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + EnKgy_OverrideLimbDraw, EnKgy_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h index 30daeff080..6f55b2e58a 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h @@ -7,10 +7,33 @@ struct EnKgy; typedef void (*EnKgyActionFunc)(struct EnKgy*, GlobalContext*); +#define ENKGY_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENKGY_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct EnKgy { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C0]; - /* 0x0304 */ EnKgyActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[23]; + /* 0x212 */ Vec3s morphTable[23]; + /* 0x29C */ u16 unk_29C; + /* 0x2A0 */ EnKbt* zubora; + /* 0x2A4 */ ObjIcePoly* iceBlock; + /* 0x2A8 */ Vec3f unk_2A8; + /* 0x2B4 */ Vec3f unk_2B4; + /* 0x2C0 */ Vec3f unk_2C0; + /* 0x2CC */ Vec3s unk_2CC; + /* 0x2D2 */ s16 unk_2D2; + /* 0x2D4 */ s16 unk_2D4[6]; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ s16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EA */ s16 unk_2EA; + /* 0x2EC */ LightInfo lightInfo; + /* 0x2FC */ LightNode* lightNode; + /* 0x300 */ s16 unk_300; + /* 0x304 */ EnKgyActionFunc actionFunc; } EnKgy; // size = 0x308 extern const ActorInit En_Kgy_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 4ca15c4b33..6fae5c43c1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2668,6 +2668,17 @@ D_0600EE58 = 0x0600EE58; D_0600F180 = 0x0600F180; D_0600F6A0 = 0x0600F6A0; D_0600F910 = 0x0600F910; +D_060008FC = 0x060008FC; +D_0600292C = 0x0600292C; +D_060042E4 = 0x060042E4; +D_060101F0 = 0x060101F0; +D_06001764 = 0x06001764; +D_06003334 = 0x06003334; +D_06010B84 = 0x06010B84; +D_06001EA4 = 0x06001EA4; +D_06003D88 = 0x06003D88; +D_04001D00 = 0x04001D00; +D_040021A8 = 0x040021A8; // ovl_En_Kitan