From b5a9189cef20a81439cb98475e7502bb89f8fa4a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 24 Sep 2022 10:21:08 -0700 Subject: [PATCH] Effect Deaddb OK (#1037) * OK * Add description * format * Fix EffectSsDeadDbInitParams size comment --- assets/xml/objects/gameplay_keep.xml | 22 ++-- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 6 +- .../ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c | 116 ++++++++++++++++-- .../ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h | 4 +- undefined_syms.txt | 1 - 7 files changed, 128 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 9f958e974d..372c6031ee 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1075,17 +1075,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/spec b/spec index b0ad8b8b86..501335c57c 100644 --- a/spec +++ b/spec @@ -1923,8 +1923,7 @@ beginseg name "ovl_Effect_Ss_Dead_Db" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.data.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 35302a22e5..09c3621ad6 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -940,7 +940,7 @@ void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac // EffectSsDeadDb Spawn Functions void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, - Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) { + Color_RGBA8* env, s16 scale, s16 scaleStep, s32 life) { EffectSsDeadDbInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -955,7 +955,7 @@ void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* a initParams.envColor.r = env->r; initParams.envColor.g = env->g; initParams.envColor.b = env->b; - initParams.unk_30 = unk; + initParams.life = life; EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams); } diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 5ce0f0286a..2dedc7c2ac 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -144,8 +144,8 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; TexturePtr D_808CD58C[] = { - gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, - gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, }; static InitChainEntry sInitChain[] = { @@ -532,7 +532,7 @@ void EnVm_Draw(Actor* thisx, PlayState* play) { gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); gSPSegment(&gfx[5], 0x08, D_808CD58C[play->gameplayFrames & 7]); - gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + gSPDisplayList(&gfx[6], gEffEnemyDeathFlameDL); POLY_XLU_DISP = &gfx[7]; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c index 616d30d03c..54963eb3bb 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c @@ -1,27 +1,129 @@ /* * File: z_eff_ss_dead_db.c * Overlay: ovl_Effect_Ss_Dead_Db - * Description: + * Description: Enemy Death Flames */ #include "z_eff_ss_dead_db.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTexIndex regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rPrimColorA regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rScaleStep regs[9] +#define rTotalLife regs[11] #define PARAMS ((EffectSsDeadDbInitParams*)initParamsx) -s32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dead_Db_InitVars = { EFFECT_SS_DEAD_DB, EffectSsDeadDb_Init, }; -#endif +static TexturePtr sTextures[] = { + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, + gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Init.s") +u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDbInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Draw.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffEnemyDeathFlameDL; + this->life = initParams->life; + this->flags = 4; + this->rScaleStep = initParams->scaleStep; + this->rTotalLife = initParams->life; + this->draw = EffectSsDeadDb_Draw; + this->update = EffectSsDeadDb_Update; + this->rScale = initParams->scale; + this->rTexIndex = 0; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Update.s") + return 1; +} + +void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.01f; + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, scale); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this) { + this->rTexIndex = (f32)((this->rTotalLife - this->life) * 9) / this->rTotalLife; + this->rScale += this->rScaleStep; + + this->rPrimColorR -= 10; + if (this->rPrimColorR < 0) { + this->rPrimColorR = 0; + } + + this->rPrimColorG -= 10; + if (this->rPrimColorG < 0) { + this->rPrimColorG = 0; + } + + this->rPrimColorB -= 10; + if (this->rPrimColorB < 0) { + this->rPrimColorB = 0; + } + + this->rEnvColorR -= 10; + if (this->rEnvColorR < 0) { + this->rEnvColorR = 0; + } + + this->rEnvColorG -= 10; + if (this->rEnvColorG < 0) { + this->rEnvColorG = 0; + } + + this->rEnvColorB -= 10; + if (this->rEnvColorB < 0) { + this->rEnvColorB = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h index bbdf3c2909..a1ac62167d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h @@ -11,8 +11,8 @@ typedef struct { /* 0x26 */ s16 scaleStep; /* 0x28 */ Color_RGBA8 primColor; /* 0x2C */ Color_RGBA8 envColor; - /* 0x30 */ s32 unk_30; -} EffectSsDeadDbInitParams; // size = 0x30 + /* 0x30 */ s32 life; +} EffectSsDeadDbInitParams; // size = 0x34 extern const EffectSsInit Effect_Ss_Dead_Db_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 20a4cf5e25..6623ed8ace 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -428,7 +428,6 @@ D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; D_0403F230 = 0x0403F230; -D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; D_04050550 = 0x04050550; D_04050D10 = 0x04050D10;