From 3374f41d1ceeb46cb1c82e5b2529dfb5ffbe563c Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Wed, 25 May 2022 18:16:04 -0600 Subject: [PATCH] En_wiz_brock OK and documented (#817) * wiz brock OK * wiz_brok OK and documented * fixing text * fixing PR comments * addressing PR * fixing comma for format --- assets/xml/objects/object_wiz.xml | 6 +- spec | 3 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 119 ++++++++++++++++-- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h | 12 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 7 -- 6 files changed, 123 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index d9c8a15898..947cab3c7c 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ - + - + diff --git a/spec b/spec index f6b19ee8a9..e62c6ef3bb 100644 --- a/spec +++ b/spec @@ -2837,8 +2837,7 @@ beginseg name "ovl_En_Wiz_Brock" compress include "build/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.data.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d6ae083312..d3fffb6672 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -5,17 +5,29 @@ */ #include "z_en_wiz_brock.h" +#include "objects/object_wiz/object_wiz.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) +typedef enum { + PLATFORM_TYPE_INACTIVE, + PLATFORM_TYPE_FIRE, + PLATFORM_TYPE_ICE, + PLATFORM_TYPE_MAX, +} PlatformType; + void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); + +s16 platformCount = 0; + const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, ACTORCAT_PROP, @@ -28,19 +40,106 @@ const ActorInit En_Wiz_Brock_InitVars = { (ActorFunc)EnWizBrock_Draw, }; -#endif +void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060010E8; -extern UNK_TYPE D_06001690; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->dyna.actor.colChkInfo.health = 3; + this->unk_1A6 = 0; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->platformNum = platformCount++; + this->actionFunc = EnWizBrock_SetupUpdateStatus; + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 0.01f; + this->alpha = 255.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Init.s") +void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490E4.s") +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + this->actionFunc = EnWizBrock_UpdateStatus; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490FC.s") +/** + * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * count up to 30 at which point the platforms are despawned. + */ +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + if (this->platformType == PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + this->platformType = this->dyna.actor.colChkInfo.health; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Update.s") + if (this->dyna.actor.colChkInfo.health == 0) { + this->timer++; + if (this->timer > (BREG(49) + 30)) { + Math_ApproachZeroF(&this->dyna.actor.scale.y, (BREG(50) / 10.0f) + 0.3f, (BREG(51) / 10000.0f) + 0.003f); + Math_ApproachZeroF(&this->alpha, (BREG(52) / 10.0f) + 1.0f, (BREG(53) / 10.0f) + 35.0f); + Math_ApproachF(&this->dyna.actor.scale.x, (BREG(54) / 100.0f) + 0.02f, (BREG(55) / 100.0f) + 0.2f, + (BREG(56) / 1000.0f) + 0.002f); + this->dyna.actor.scale.z = this->dyna.actor.scale.x; + if (this->dyna.actor.scale.y < 0.001f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Draw.s") +void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizBrock* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + if (this->dyna.actor.colChkInfo.health != 0) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Gfx_DrawDListOpa(globalCtx, gWizzrobePlatform); + + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); + Gfx_DrawDListXlu(globalCtx, gWizzrobePlatform); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->platformType != PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + if (this->platformType == PLATFORM_TYPE_FIRE) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h index 30932c5ac5..ac900777e7 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h @@ -8,10 +8,14 @@ struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); typedef struct EnWizBrock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnWizBrockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; + /* 0x1A0 */ EnWizBrockActionFunc actionFunc; + /* 0x1A4 */ s16 timer; // Counter for despawing blocks (Max of 37) + /* 0x1A6 */ s16 unk_1A6; // TODO: set but not used maybe used in wizzrobe? + /* 0x1A8 */ s16 platformNum; // Numeric identifier for platform + /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) + /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 extern const ActorInit En_Wiz_Brock_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4967ab0a2a..eac58c3e6f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10469,8 +10469,8 @@ 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), - 0x80A490E4:("func_80A490E4",), - 0x80A490FC:("func_80A490FC",), + 0x80A490E4:("EnWizBrock_SetupUpdateStatus",), + 0x80A490FC:("EnWizBrock_UpdateStatus",), 0x80A492E4:("EnWizBrock_Update",), 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1567d0b70f..1d5ea0bd3e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1555,13 +1555,6 @@ D_060025F0 = 0x060025F0; D_060066C0 = 0x060066C0; D_0600B320 = 0x0600B320; -// ovl_En_Wiz_Brock - -D_060010E8 = 0x060010E8; -D_06001690 = 0x06001690; -D_06005870 = 0x06005870; -D_06005C64 = 0x06005C64; - // ovl_En_Zl4 D_06013328 = 0x06013328;