From 689ef2fe0b919f21cc557373bb2a3a662fb5e028 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:18:54 -0700 Subject: [PATCH] Effect Icepiece OK (#839) * OK * Final cleanup * format * PR plus forgot to rename Matrix_RotateY --- assets/xml/objects/gameplay_keep.xml | 2 +- spec | 3 +- .../z_eff_ss_ice_piece.c | 71 +++++++++++++++++-- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 969954b326..e1a35f83b6 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1110,7 +1110,7 @@ - + diff --git a/spec b/spec index 3ca89286a7..4991f66a7a 100644 --- a/spec +++ b/spec @@ -1930,8 +1930,7 @@ beginseg name "ovl_Effect_Ss_Ice_Piece" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.data.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c index 5bd800a203..0fa12d248b 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c @@ -1,27 +1,84 @@ /* * File: z_eff_ss_ice_piece.c * Overlay: ovl_Effect_Ss_Ice_Piece - * Description: + * Description: Ice Shards */ #include "z_eff_ss_ice_piece.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rLifespan regs[0] +#define rYaw regs[1] +#define rPitch regs[2] +#define rRotSpeed regs[3] +#define rScale regs[4] #define PARAMS ((EffectSsIcePieceInitParams*)initParamsx) -s32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -#endif +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIcePieceInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Init.s") + this->pos = initParams->pos; + this->vec = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->draw = EffectSsIcePiece_Draw; + this->update = EffectSsIcePiece_Update; + this->rLifespan = initParams->life; + this->rScale = initParams->scale * 100.0f; + this->rYaw = Math_FAtan2F(initParams->velocity.z, initParams->velocity.x); + this->rPitch = 0; + this->rRotSpeed = + ((fabsf(initParams->velocity.x) + fabsf(initParams->velocity.y)) * 100.0f) * (Rand_ZeroFloat(1.0f) + 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Update.s") +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 frames = globalCtx->state.frames; + f32 alpha; + + OPEN_DISPS(gfxCtx); + + if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { + alpha = (this->life * 2.0f) / this->rLifespan; + alpha *= 255.0f; + } else { + alpha = 255.0f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (s32)alpha & 0xFF); + func_800BCC68(&this->pos, globalCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, + 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragmentDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rPitch += this->rRotSpeed; + this->velocity.x *= 0.85f; + this->velocity.y *= 0.85f; + this->velocity.z *= 0.85f; +}