diff --git a/spec b/spec index eb6d19dcaa..1861e3ec70 100644 --- a/spec +++ b/spec @@ -1598,8 +1598,7 @@ beginseg name "ovl_En_Daiku" compress include "build/src/overlays/actors/ovl_En_Daiku/z_en_daiku.o" - include "build/data/ovl_En_Daiku/ovl_En_Daiku.data.o" - include "build/data/ovl_En_Daiku/ovl_En_Daiku.reloc.o" + include "build/src/overlays/actors/ovl_En_Daiku/ovl_En_Daiku_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 170b795cf5..e254084de8 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -1,3 +1,9 @@ +/* + * File: z_en_daiku.c + * Overlay: ovl_En_Daiku + * Description: Carpenter + */ + #include "z_en_daiku.h" #define FLAGS 0x00000009 @@ -9,10 +15,27 @@ void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx); void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809438F8(EnDaiku* this, GlobalContext* globalCtx); +void func_80943820(EnDaiku* this); +void func_80943BC0(EnDaiku* this); void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx); +void func_809438F8(EnDaiku* this, GlobalContext* globalCtx); + +extern AnimationHeader D_06000600; +extern AnimationHeader D_06000C44; +extern AnimationHeader D_06001114; +extern AnimationHeader D_06002FA0; +extern FlexSkeletonHeader D_0600A850; +extern AnimationHeader D_0600ACD0; +extern AnimationHeader D_0600B690; +extern AnimationHeader D_0600BEAC; +extern AnimationHeader D_0600C234; +extern AnimationHeader D_0600C92C; +extern Gfx D_06006D70[]; +extern Gfx D_06006E80[]; +extern Gfx D_06006FB0[]; +extern Gfx D_060070C0[]; +extern Gfx D_06008EC8[]; -#if 0 const ActorInit En_Daiku_InitVars = { ACTOR_EN_DAIKU, ACTORCAT_NPC, @@ -25,40 +48,315 @@ const ActorInit En_Daiku_InitVars = { (ActorFunc)EnDaiku_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80944078 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static u16 sTextIds[] = { + 0x061C, 0x061A, 0x061B, 0x061C, 0x061C, 0x061D, 0x061E, 0x061F, 0x061C, 0x0620, 0x0621, 0x0622, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDaiku* this = THIS; -extern ColliderCylinderInit D_80944078; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + this->actor.targetMode = 0; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_278 = ENDAIKU_GET_FF(&this->actor); + if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { + this->unk_288 = ENDAIKU_GET_FF00(&this->actor); + this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { + this->unk_264 = -2000; + } -extern UNK_TYPE D_06002FA0; -extern UNK_TYPE D_06008EC8; + if (this->unk_278 == ENDAIKU_PARAMS_FF_0) { + this->collider.dim.radius = 30; + this->collider.dim.height = 60; + this->collider.dim.yShift = 0; + this->actor.flags |= 0x8000000; + if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } else if ((gSaveContext.day == 3) && gSaveContext.isNight) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/EnDaiku_Init.s") + Math_Vec3f_Copy(&this->unk_26C, &this->actor.world.pos); + this->unk_280 = this->actor.world.rot.y; + this->actor.gravity = -3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/EnDaiku_Destroy.s") + switch (this->unk_278) { + case ENDAIKU_PARAMS_FF_0: + this->unk_27E = this->unk_278 * 4 + 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_8094373C.s") + case ENDAIKU_PARAMS_FF_1: + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, + 17); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_809437C8.s") + case ENDAIKU_PARAMS_FF_2: + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_0600B690, this->jointTable, this->morphTable, + 17); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_80943820.s") + case ENDAIKU_PARAMS_FF_3: + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_0600A850, &D_06001114, this->jointTable, this->morphTable, + 17); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_809438F8.s") + func_80943820(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_80943BC0.s") +void EnDaiku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDaiku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_80943BDC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/EnDaiku_Update.s") +void func_8094373C(EnDaiku* this, s32 arg1) { + static AnimationHeader* D_809440A4[] = { + &D_06002FA0, &D_0600ACD0, &D_0600C92C, &D_06000C44, &D_0600C234, + &D_06000600, &D_06001114, &D_0600B690, &D_0600BEAC, + }; + static u8 D_809440C8[] = { + 0, 0, 0, 0, 2, 0, 0, 2, 2, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_80943E18.s") + this->unk_284 = SkelAnime_GetFrameCount(&D_809440A4[arg1]->common); + SkelAnime_ChangeAnim(&this->skelAnime, D_809440A4[arg1], 1.0f, 0.0f, this->unk_284, D_809440C8[arg1], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/func_80943E60.s") +void func_809437C8(EnDaiku* this) { + if ((this->unk_288 != -1) && (this->unk_258 != 0)) { + if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Daiku/EnDaiku_Draw.s") +void func_80943820(EnDaiku* this) { + s32 day = gSaveContext.day - 1; + + switch (this->unk_278) { + case 0: + case 1: + func_8094373C(this, 0); + break; + + case 2: + func_8094373C(this, 7); + break; + + case 3: + func_8094373C(this, 6); + break; + } + + this->unk_28C = (day * 4) + this->unk_278; + this->actor.textId = sTextIds[this->unk_28C]; + this->unk_280 = this->actor.shape.rot.y; + this->unk_28A = 0; + this->actionFunc = func_809438F8; +} + +void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { + f32 currentFrame = this->skelAnime.animCurrentFrame; + s32 pad; + s32 day = gSaveContext.day - 1; + s32 pad2; + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + if (this->unk_278 == ENDAIKU_PARAMS_FF_1) { + this->actor.textId = 0x2365; + } else { + this->actor.textId = 0x2366; + } + } else { + this->unk_28C = (day * 4) + this->unk_278; + this->actor.textId = sTextIds[this->unk_28C]; + } + + if (func_800B84D0(&this->actor, globalCtx)) { + func_80943BC0(this); + return; + } + + if ((this->unk_278 == ENDAIKU_PARAMS_FF_2) && (this->unk_284 <= currentFrame)) { + if (Rand_ZeroOne() < 0.5f) { + func_8094373C(this, 7); + } else { + func_8094373C(this, 8); + } + } + + if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { + f32 sq, abs; + + Math_ApproachF(&this->actor.world.pos.x, this->unk_26C.x, 0.5f, + fabsf(2.0f * Math_SinS(this->actor.world.rot.y))); + Math_ApproachF(&this->actor.world.pos.z, this->unk_26C.z, 0.5f, + fabsf(2.0f * Math_CosS(this->actor.world.rot.y))); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_282, 1, 0x7D0, 0xA); + + sq = sqrtf(SQ(this->actor.world.pos.x - this->unk_26C.x) + SQ(this->actor.world.pos.z - this->unk_26C.z)); + abs = fabsf(this->actor.world.rot.y - this->unk_282); + if ((sq < SQ(2.0f)) && (this->unk_258 != NULL) && (abs < 10.0f)) { + this->unk_25C++; + if (this->unk_25C >= this->unk_258->count) { + this->unk_25C = 0; + } + + func_809437C8(this); + this->unk_282 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_26C); + } + } + + if (this->unk_278 != ENDAIKU_PARAMS_FF_0) { + s16 angle = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); + this->unk_280 = this->actor.yawTowardsPlayer; + if ((this->unk_278 == ENDAIKU_PARAMS_FF_1) || (this->unk_278 == ENDAIKU_PARAMS_FF_2) || (angle <= 0x2890)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } +} + +void func_80943BC0(EnDaiku* this) { + this->unk_28A = 1; + this->actionFunc = func_80943BDC; +} + +void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { + f32 currentFrame = this->skelAnime.animCurrentFrame; + + if ((this->unk_278 == ENDAIKU_PARAMS_FF_2) && (this->unk_284 <= currentFrame)) { + if (Rand_ZeroOne() < 0.5f) { + func_8094373C(this, 7); + } else { + func_8094373C(this, 8); + } + } + + if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80943820(this); + } +} + +void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDaiku* this = THIS; + s32 pad; + + if (this->unk_27E == 0) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + } + + if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.day == 3) && (gSaveContext.isNight)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actionFunc(this, globalCtx); + + if (this->unk_27C != 0) { + this->unk_27C--; + } + + if (this->unk_27E != 0) { + this->unk_27E--; + } + + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_SetHeight(&this->actor, 65.0f); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Math_SmoothStepToS(&this->unk_260, this->unk_266, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->unk_25E, this->unk_264, 1, 0xBB8, 0); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 650.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80943E18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDaiku* this = THIS; + + if (limbIndex == 15) { + rot->x += this->unk_260; + rot->z += this->unk_25E; + } + + return 0; +} + +void func_80943E60(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Gfx* D_809440D4[] = { + D_060070C0, D_06006FB0, D_06006E80, D_06006D70, + }; + EnDaiku* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == 15) { + gSPDisplayList(POLY_OPA_DISP++, D_809440D4[this->unk_278]); + } + + if ((this->unk_278 == ENDAIKU_PARAMS_FF_3) && (limbIndex == 8)) { + gSPDisplayList(POLY_OPA_DISP++, D_06008EC8); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnDaiku_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDaiku* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + switch (this->unk_278) { + case 0: + gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); + break; + + case 1: + gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); + break; + + case 2: + gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); + break; + + case 3: + gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); + break; + + case 4: + gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 0, 255); + break; + } + + SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, + func_80943E18, func_80943E60, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h index c5f127a71a..01395648d9 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h @@ -5,13 +5,44 @@ struct EnDaiku; -typedef void (*EnDaikuActionFunc)(struct EnDaiku* this, GlobalContext* globalCtx); +typedef void (*EnDaikuActionFunc)(struct EnDaiku*, GlobalContext*); + +#define ENDAIKU_GET_FF(thisx) ((thisx)->params & 0xFF); +#define ENDAIKU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); + +enum { + /* 0x0 */ ENDAIKU_PARAMS_FF_0, + /* 0x1 */ ENDAIKU_PARAMS_FF_1, + /* 0x2 */ ENDAIKU_PARAMS_FF_2, + /* 0x3 */ ENDAIKU_PARAMS_FF_3, +}; typedef struct EnDaiku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnDaikuActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x90]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; + /* 0x254 */ EnDaikuActionFunc actionFunc; + /* 0x258 */ Path* unk_258; + /* 0x25C */ s16 unk_25C; + /* 0x25E */ s16 unk_25E; + /* 0x260 */ s16 unk_260; + /* 0x262 */ UNK_TYPE1 unk_262[0x2]; + /* 0x264 */ s16 unk_264; + /* 0x266 */ s16 unk_266; + /* 0x268 */ UNK_TYPE1 unk_268[0x4]; + /* 0x26C */ Vec3f unk_26C; + /* 0x278 */ s32 unk_278; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ f32 unk_284; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28E */ UNK_TYPE1 unk_28E[0xE]; + /* 0x29C */ ColliderCylinder collider; } EnDaiku; // size = 0x2E8 extern const ActorInit En_Daiku_InitVars; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0ba0f9fd7a..9b8b9e7a25 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -8718,7 +8718,7 @@ 0x80942FAC:("D_80942FAC","f32","",0x4), 0x80942FB0:("D_80942FB0","f32","",0x4), 0x80944040:("En_Daiku_InitVars","UNK_TYPE1","",0x1), - 0x80944060:("D_80944060","UNK_TYPE1","",0x1), + 0x80944060:("sTextIds","UNK_TYPE1","",0x1), 0x80944078:("D_80944078","UNK_TYPE1","",0x1), 0x809440A4:("D_809440A4","UNK_TYPE1","",0x1), 0x809440C8:("D_809440C8","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3950de0719..79a80f84da 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1715,6 +1715,16 @@ D_06002FA0 = 0x06002FA0; D_06008EC8 = 0x06008EC8; D_0600A850 = 0x0600A850; D_0600B690 = 0x0600B690; +D_0600ACD0 = 0x0600ACD0; +D_0600C92C = 0x0600C92C; +D_06000C44 = 0x06000C44; +D_0600C234 = 0x0600C234; +D_06000600 = 0x06000600; +D_0600BEAC = 0x0600BEAC; +D_060070C0 = 0x060070C0; +D_06006FB0 = 0x06006FB0; +D_06006E80 = 0x06006E80; +D_06006D70 = 0x06006D70; // ovl_En_Daiku2