From 6dd31c00e57df38c72d1d3428e05da88a4831b20 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Fri, 22 Jul 2022 02:09:44 -0300 Subject: [PATCH] ovl_Eff_Change Decompiled (#946) * all functions matching * progress * ovl_Eff_Change Decompiled * ovl_Eff_Change Decompiled * space * spec --- assets/xml/objects/gameplay_keep.xml | 6 +- spec | 3 +- .../actors/ovl_Eff_Change/z_eff_change.c | 121 ++++++++++++++++-- .../actors/ovl_Eff_Change/z_eff_change.h | 10 +- tools/disasm/functions.txt | 4 +- 5 files changed, 129 insertions(+), 15 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 7e30cfdb19..d87ef3f31b 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -924,12 +924,14 @@ - + + - + + diff --git a/spec b/spec index f4fd4589f2..128d113201 100644 --- a/spec +++ b/spec @@ -2789,8 +2789,7 @@ beginseg name "ovl_Eff_Change" compress include "build/src/overlays/actors/ovl_Eff_Change/z_eff_change.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.data.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Change/ovl_Eff_Change_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 127a24ddf1..0f52456175 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -13,8 +13,11 @@ void EffChange_Init(Actor* thisx, PlayState* play); void EffChange_Destroy(Actor* thisx, PlayState* play); void EffChange_Update(Actor* thisx, PlayState* play); +void EffChange_Draw(Actor* thisx, PlayState* play); + +void EffChange_SetColors(EffChange* this, s32 arg1); +void func_80A4C5CC(EffChange* this, PlayState* play); -#if 0 const ActorInit Eff_Change_InitVars = { ACTOR_EFF_CHANGE, ACTORCAT_ITEMACTION, @@ -27,16 +30,118 @@ const ActorInit Eff_Change_InitVars = { (ActorFunc)NULL, }; -#endif +static u8 D_80A4C920[] = { + // prim r g b env r g b + 255, 255, 170, 0, 100, 0, // COLOR_0 + 255, 255, 170, 200, 0, 0, // COLOR_1 + 170, 255, 255, 0, 100, 255, // COLOR_2 + 255, 255, 170, 200, 150, 0, // COLOR_3 + 255, 255, 170, 0, 100, 0, // COLOR_4 + 255, 255, 170, 0, 100, 0, // COLOR_5 + 255, 255, 170, 0, 100, 0, // COLOR_6 + 255, 255, 170, 0, 100, 0 // COLOR_7 +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Init.s") +void EffChange_Init(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Destroy.s") + this->actionFunc = func_80A4C5CC; + this->actor.draw = EffChange_Draw; + EffChange_SetColors(this, EFFCHANGE_GET_COLORS(thisx)); + Actor_SetScale(&this->actor, 0.075f); + this->primColors[3] = 0; + func_80183430(&this->skeletonInfo, gameplay_keep_Blob_02900C, gameplay_keep_Blob_0281DC, this->jointTable, + this->morphTable, NULL); + func_801834A8(&this->skeletonInfo, gameplay_keep_Blob_0281DC); + this->step = 0; + this->actor.shape.rot.y = 0; + this->skeletonInfo.frameCtrl.unk_C = (2.0f / 3.0f); + ActorCutscene_SetIntentToPlay(0x7B); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C578.s") +void EffChange_Destroy(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C5CC.s") + func_8018349C(&this->skeletonInfo); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Update.s") +void EffChange_SetColors(EffChange* this, s32 arg1) { + arg1 *= 6; + this->primColors[0] = D_80A4C920[arg1]; + this->primColors[1] = D_80A4C920[arg1 + 1]; + this->primColors[2] = D_80A4C920[arg1 + 2]; + this->envColors[0] = D_80A4C920[arg1 + 3]; + this->envColors[1] = D_80A4C920[arg1 + 4]; + this->envColors[2] = D_80A4C920[arg1 + 5]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C7B0.s") +void func_80A4C5CC(EffChange* this, PlayState* play) { + f32 phi_fv0; + + if (func_80183DE0(&this->skeletonInfo)) { + Actor_MarkForDeath(&this->actor); + ActorCutscene_Stop(0x7B); + func_800FD2B4(play, 0.0f, 850.0f, 0.2f, 0.0f); + } else { + this->step++; + if (this->skeletonInfo.frameCtrl.unk_10 < 20.0f) { + if ((this->primColors[3]) < 242) { + this->primColors[3] += 13; + } else { + this->primColors[3] = 255; + } + } else if (this->skeletonInfo.frameCtrl.unk_10 > 70.0f) { + if ((this->primColors[3]) >= 14) { + this->primColors[3] -= 13; + } else { + this->primColors[3] = 0; + } + } else { + this->primColors[3] = 255; + } + + phi_fv0 = this->primColors[3] * (1.0f / 255.0f); + if (phi_fv0 > 1.0f) { + phi_fv0 = 1.0f; + } else if (phi_fv0 < 0.0f) { + phi_fv0 = 0.0f; + } + func_800FD2B4(play, phi_fv0, 850.0f, 0.2f, 0.0f); + if (ActorCutscene_GetCurrentIndex() != 0x7B) { + if (ActorCutscene_GetCanPlayNext(0x7B)) { + ActorCutscene_Start(0x7B, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(0x7B); + } + } + } +} + +void EffChange_Update(Actor* thisx, PlayState* play) { + EffChange* this = THIS; + + this->actionFunc(this, play); +} + +void EffChange_Draw(Actor* thisx, PlayState* play) { + s32 pad; + Mtx* mtx; + EffChange* this = THIS; + + AnimatedMat_DrawStepXlu(play, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_028FEC), this->step); + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->primColors[0], this->primColors[1], this->primColors[2], + this->primColors[3]); + gDPSetEnvColor(POLY_XLU_DISP++, this->envColors[0], this->envColors[1], this->envColors[2], 255); + func_8018450C(play, &this->skeletonInfo, mtx, NULL, NULL, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h index 9860d13ebe..aed7e534a8 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h @@ -2,6 +2,9 @@ #define Z_EFF_CHANGE_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define EFFCHANGE_GET_COLORS(thisx) ((thisx)->params & 7) struct EffChange; @@ -9,7 +12,12 @@ typedef void (*EffChangeActionFunc)(struct EffChange*, PlayState*); typedef struct EffChange { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s jointTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x198 */ Vec3s morphTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x1BC */ s16 step; + /* 0x1BE */ u8 primColors[4]; + /* 0x1C2 */ u8 envColors[4]; /* 0x1C8 */ EffChangeActionFunc actionFunc; } EffChange; // size = 0x1CC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 79eacb3264..491b33a403 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10491,10 +10491,10 @@ 0x80A4BF78:("func_80A4BF78",), 0x80A4C490:("EffChange_Init",), 0x80A4C54C:("EffChange_Destroy",), - 0x80A4C578:("func_80A4C578",), + 0x80A4C578:("EffChange_SetColors",), 0x80A4C5CC:("func_80A4C5CC",), 0x80A4C78C:("EffChange_Update",), - 0x80A4C7B0:("func_80A4C7B0",), + 0x80A4C7B0:("EffChange_Draw",), 0x80A4C9B0:("DmStatue_Init",), 0x80A4C9D4:("DmStatue_Destroy",), 0x80A4C9E4:("DmStatue_Update",),