Effect Icepiece OK (#839)

* OK

* Final cleanup

* format

* PR plus forgot to rename Matrix_RotateY
This commit is contained in:
Derek Hensley 2022-06-19 15:18:54 -07:00 committed by GitHub
parent 1a37ef95d1
commit 689ef2fe0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 10 deletions

View File

@ -1110,7 +1110,7 @@
<Texture Name="gameplay_keep_Tex_04E220" OutName="tex_04E220" Format="i8" Width="64" Height="64" Offset="0x4E220" />
<DList Name="gameplay_keep_DL_04F250" Offset="0x4F250" />
<Texture Name="gameplay_keep_Tex_04F2C0" OutName="tex_04F2C0" Format="ia16" Width="32" Height="64" Offset="0x4F2C0" />
<DList Name="gameplay_keep_DL_050550" Offset="0x50550" />
<DList Name="gEffIceFragmentDL" Offset="0x50550" />
<DList Name="gFrozenIceDL" Offset="0x50648" />
<DList Name="gFrozenIceVtxDL" Offset="0x506E0" />
<DList Name="gameplay_keep_DL_050D10" Offset="0x50D10" />

3
spec
View File

@ -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

View File

@ -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;
}