diff --git a/spec b/spec index 18b8558b74..5d82b9e2fd 100644 --- a/spec +++ b/spec @@ -5319,8 +5319,7 @@ beginseg name "ovl_Dm_Gm" compress include "build/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.data.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Gm/ovl_Dm_Gm_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index c2edb33a0e..88a99ad533 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -5,6 +5,8 @@ */ #include "z_dm_gm.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -17,8 +19,8 @@ void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C248A8(DmGm* this, GlobalContext* globalCtx); void func_80C24A00(DmGm* this, GlobalContext* globalCtx); void func_80C24BD0(DmGm* this, GlobalContext* globalCtx); +void func_80C25000(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, @@ -31,37 +33,337 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24360.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24428.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24504.s") +s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2457C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2478C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24838.s") +void func_80C24504(DmGm* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C248A8.s") +s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24A00.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24BD0.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24CD0.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24E4C.s") +s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C2457C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C25000.s") +Actor* func_80C24838(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C24428(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C25000; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(globalCtx); + func_80C24428(this, globalCtx, 1); + this->actionFunc = func_80C24BD0; + } else { + this->actionFunc = func_80C24A00; + } + } +} + +void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C24428(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C24428(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C24428(this, globalCtx, this->unk_2CC); + } +} + +void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +} + +void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C248A8; +} + +void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C2478C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C24360(this, globalCtx); + func_80C24504(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C25224 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C2522C = { 1000.0f, 0.0f, 0.0f }; + +void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmGm* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C25218, &D_80C25224); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmGm* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C25238[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C25244[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C25244[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C25238[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 8b416d7b7f..6f2307378b 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -2,6 +2,7 @@ #define Z_DM_GM_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmGm; @@ -9,9 +10,30 @@ typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); typedef struct DmGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5a74487018..fd1b38a799 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -17112,8 +17112,8 @@ 0x80C24BE0:("DmGm_Init",), 0x80C24C34:("DmGm_Destroy",), 0x80C24C44:("DmGm_Update",), - 0x80C24CD0:("func_80C24CD0",), - 0x80C24E4C:("func_80C24E4C",), + 0x80C24CD0:("DmGm_PostLimbDraw",), + 0x80C24E4C:("DmGm_TransformLimbDraw",), 0x80C25000:("func_80C25000",), 0x80C25360:("func_80C25360",), 0x80C253D0:("func_80C253D0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3b9d3fbe9c..0952a6663b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -911,11 +911,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Gm - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Opstage D_06000970 = 0x06000970;