From f3c6e451fbc276912b3258614c5d17dba148d9c1 Mon Sep 17 00:00:00 2001 From: Lucas <60241136+ordlucas@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:33:57 -0400 Subject: [PATCH] ovl_Dm_Char06 OK (#986) * `ovl_Dm_Char06` decompiled * Suggested changes * Minor changes * Formatting --- spec | 3 +- .../actors/ovl_Dm_Char06/z_dm_char06.c | 62 +++++++++++++++---- .../actors/ovl_Dm_Char06/z_dm_char06.h | 6 +- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/spec b/spec index f083fab8b0..81385e64ec 100644 --- a/spec +++ b/spec @@ -3137,8 +3137,7 @@ beginseg name "ovl_Dm_Char06" compress include "build/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.o" - include "build/data/ovl_Dm_Char06/ovl_Dm_Char06.data.o" - include "build/data/ovl_Dm_Char06/ovl_Dm_Char06.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char06/ovl_Dm_Char06_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index 191fb16c4d..a419ed5aa9 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -15,11 +15,9 @@ void DmChar06_Destroy(Actor* thisx, PlayState* play); void DmChar06_Update(Actor* thisx, PlayState* play); void DmChar06_Draw(Actor* thisx, PlayState* play); +void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc); void func_80AAE6F0(DmChar06* this, PlayState* play); -void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc); - -#if 0 const ActorInit Dm_Char06_InitVars = { ACTOR_DM_CHAR06, ACTORCAT_ITEMACTION, @@ -32,18 +30,60 @@ const ActorInit Dm_Char06_InitVars = { (ActorFunc)DmChar06_Draw, }; -#endif +void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern UNK_TYPE D_06006868; +void DmChar06_Init(Actor* thisx, PlayState* play) { + DmChar06* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_SetupAction.s") + gSaveContext.save.weekEventReg[33] |= 0x80; + Actor_SetScale(&this->actor, 1.0f); + this->alpha = 255; + DmChar06_SetupAction(this, func_80AAE6F0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Init.s") +void DmChar06_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Destroy.s") +void func_80AAE6F0(DmChar06* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1CF)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, 0x1CF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/func_80AAE6F0.s") + if ((play->csCtx.frames >= play->csCtx.actorActions[actionIndex]->startFrame) && + (play->csCtx.actorActions[actionIndex]->endFrame >= play->csCtx.frames)) { + if (play->csCtx.actorActions[actionIndex]->action == 1) { + this->alpha = 255; + } else if (play->csCtx.actorActions[actionIndex]->action == 2) { + f32 lerp = 1.0f - Environment_LerpWeight(play->csCtx.actorActions[actionIndex]->endFrame, + play->csCtx.actorActions[actionIndex]->startFrame, + play->csCtx.frames); + this->alpha = 255 * lerp; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Update.s") +void DmChar06_Update(Actor* thisx, PlayState* play) { + DmChar06* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char06/DmChar06_Draw.s") + this->actionFunc(this, play); +} + +void DmChar06_Draw(Actor* thisx, PlayState* play) { + s32 pad; + DmChar06* this = THIS; + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_yukiyama_Matanimheader_006868)); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_yukiyama_DL_0013A8); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h index 49a026063f..c6b83b4ff1 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h @@ -2,6 +2,7 @@ #define Z_DM_CHAR06_H #include "global.h" +#include "assets/objects/object_yukiyama/object_yukiyama.h" struct DmChar06; @@ -9,9 +10,10 @@ typedef void (*DmChar06ActionFunc)(struct DmChar06*, PlayState*); typedef struct DmChar06 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x14C]; + /* 0x144 */ UNK_TYPE1 pad144[0x14C]; /* 0x290 */ DmChar06ActionFunc actionFunc; - /* 0x294 */ char unk_294[0x10]; + /* 0x294 */ UNK_TYPE1 pad294[0xC]; + /* 0x2A0 */ u8 alpha; } DmChar06; // size = 0x2A4 extern const ActorInit Dm_Char06_InitVars;