From 7d476f7c7109035811e29343209c8847b7c8e06c Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 2 Jun 2021 14:04:04 -0700 Subject: [PATCH] Ovl_Dm_Nb OK (#162) * match but func_80C1DF18 * Everything matches * Add comment about unknown pointer * Rename vars * Update comment * format * Added header description * Remove raw pointer * Remove unnecessary foward declarations * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/functions.h | 4 +- linker_scripts/code_script.txt | 4 +- linker_scripts/object_script.txt | 4 ++ src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 86 ++++++++++++++++++++++--- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h | 11 +++- tables/functions.txt | 2 +- 6 files changed, 96 insertions(+), 15 deletions(-) diff --git a/include/functions.h b/include/functions.h index bbcbc645f0..b4a7ced1f9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1595,7 +1595,7 @@ void nop_800EDDB0(GlobalContext* globalCtx); // void func_800EDDBC(void); void func_800EDDCC(GlobalContext* globalCtx, u32 uParm2); void func_800EDE34(Actor* actor, GlobalContext* globalCtx, s32 param_3); -// void func_800EDF24(void); +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); @@ -2687,7 +2687,7 @@ void func_8013AED4(u16* param_1, u16 param_2, u16 param_3); // void func_8013B878(void); // void func_8013BB34(void); // void func_8013BB7C(void); -// void func_8013BC6C(void); +UNK_TYPE func_8013BC6C(SkelAnime* skelAnime, UNK_PTR arg1, s32 arg2); // void func_8013BD40(void); // void func_8013BEDC(void); // void func_8013C068(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 735600505c..14d6fe8238 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -9175,9 +9175,9 @@ SECTIONS ovl_Dm_Nb : AT(RomLocation) { build/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.o(.text) - build/asm/overlays/ovl_Dm_Nb_data.o(.data) + build/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.o(.data) build/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.o(.rodata) - build/asm/overlays/ovl_Dm_Nb_rodata.o(.rodata) + build/src/overlays/actors/ovl_Dm_Nb/z_dm_nb_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index 5f42b5d334..ae27805e3e 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -84,6 +84,10 @@ D_060011E0 = 0x060011E0; D_06000288 = 0x06000288; D_060019B4 = 0x060019B4; +/* dm_nb */ +D_06000990 = 0x06000990; +D_06008C40 = 0x06008C40; + /* z_en_ending_hero5 */ D_0600A850 = 0x0600A850; D_06002FA0 = 0x06002FA0; diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 2bb4ac2086..24f432cff6 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_nb.c + * Overlay: ovl_Dm_Nb + * Description: Anju's Grandma at wedding during the credits + */ + #include "z_dm_nb.h" #define FLAGS 0x00000009 @@ -9,7 +15,7 @@ void DmNb_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmNb_Update(Actor* thisx, GlobalContext* globalCtx); void DmNb_Draw(Actor* thisx, GlobalContext* globalCtx); -/* + const ActorInit Dm_Nb_InitVars = { ACTOR_DM_NB, ACTORCAT_NPC, @@ -21,18 +27,80 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Update, (ActorFunc)DmNb_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/func_80C1DED0.asm") +extern UNK_TYPE D_06000990; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/func_80C1DF18.asm") +extern FlexSkeletonHeader D_06008C40; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/DmNb_Init.asm") +// Probably the same struct as EnFgAnimation, need more info from func_8013BC6C +static UNK_TYPE D_80C1E200[] = { &D_06000990, 0x3F800000, 0x0000FFFF, 0x00000000 }; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/DmNb_Destroy.asm") +s32 func_80C1DED0(DmNb* this, s32 arg1) { + s32 ret = 0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/DmNb_Update.asm") + if (arg1 != this->unk1F0) { + this->unk1F0 = arg1; + ret = func_8013BC6C(&this->skelAnime, &D_80C1E200, arg1); + } + return ret; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/func_80C1E168.asm") +void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { + s32 sp2C[] = { 0, 0, 0, 0, 0 }; + u16 actionUnk0; + u32 actionIndex; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Nb_0x80C1DED0/DmNb_Draw.asm") + if (globalCtx->csCtx.state != 0) { + if (this->unk1F8 == 0) { + this->unk1EC = 0xFF; + this->unk1F8 = 1; + this->unk1F4 = this->unk1F0; + } + if (func_800EE29C(globalCtx, 0x232)) { + actionIndex = func_800EE200(globalCtx, 0x232); + actionUnk0 = globalCtx->csCtx.actorActions[actionIndex]->unk0; + if (this->unk1EC != (actionUnk0 & 0xFF)) { + this->unk1EC = actionUnk0; + func_80C1DED0(this, sp2C[actionUnk0]); + } + func_800EDF24(&this->actor, globalCtx, actionIndex); + } + } else if (this->unk1F8 != 0) { + this->unk1F8 = 0; + func_80C1DED0(this, this->unk1F4); + } +} + +void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { + DmNb* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06008C40, NULL, this->limbDrawTable, this->transitionDrawTable, 8); + this->unk1F0 = -1; + func_80C1DED0(this, 0); + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80C1DF18; +} + +void DmNb_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmNb_Update(Actor* thisx, GlobalContext* globalCtx) { + DmNb* this = THIS; + + this->actionFunc(this, globalCtx); + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + func_800B78B8(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +void DmNb_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* actor) { +} + +void DmNb_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmNb* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount, NULL, + NULL, DmNb_UnkActorDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h index d6716621ee..71080324db 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h @@ -5,9 +5,18 @@ struct DmNb; +typedef void (*DmNbActionFunc)(struct DmNb*, GlobalContext*); + typedef struct DmNb { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xB8]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmNbActionFunc actionFunc; + /* 0x18C */ Vec3s limbDrawTable[8]; + /* 0x1BC */ Vec3s transitionDrawTable[8]; + /* 0x1EC */ u8 unk1EC; + /* 0x1F0 */ s32 unk1F0; + /* 0x1F4 */ s32 unk1F4; + /* 0x1F8 */ s32 unk1F8; } DmNb; // size = 0x1FC extern const ActorInit Dm_Nb_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index 343821ebb4..0d79e0d7b7 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -16985,7 +16985,7 @@ 0x80C1E048:("DmNb_Init",), 0x80C1E0F8:("DmNb_Destroy",), 0x80C1E108:("DmNb_Update",), - 0x80C1E168:("func_80C1E168",), + 0x80C1E168:("DmNb_UnkActorDraw",), 0x80C1E17C:("DmNb_Draw",), 0x80C1E290:("func_80C1E290",), 0x80C1E2D4:("func_80C1E2D4",),