From 6661b566a94f0dda28cc1e6abf5135f85eb0f79c Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 19 Jul 2022 09:32:00 -0700 Subject: [PATCH] Effect Gripple (#940) * OK * description * undef * format --- assets/xml/objects/gameplay_keep.xml | 4 +- spec | 3 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 2 +- .../z_eff_ss_g_ripple.c | 125 ++++++++++++++++-- tools/disasm/functions.txt | 2 +- 5 files changed, 122 insertions(+), 14 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index f0de8666cc..8357f3f3f0 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1041,8 +1041,8 @@ - - + + diff --git a/spec b/spec index 29b59edc7c..dd7177e5f5 100644 --- a/spec +++ b/spec @@ -1810,8 +1810,7 @@ beginseg name "ovl_Effect_Ss_G_Ripple" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.data.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index afc1510322..4f19b73a81 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -670,7 +670,7 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0377B0); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterRippleDL); } tanron2 = tanron2->next; } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c index 79cb97234c..b820d81688 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c @@ -1,29 +1,138 @@ /* * File: z_eff_ss_g_ripple.c * Overlay: ovl_Effect_Ss_G_Ripple - * Description: + * Description: Water Ripple */ #include "z_eff_ss_g_ripple.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rWaterBoxNum regs[0] +#define rRadius regs[1] +#define rRadiusMax regs[2] +#define rPrimColorR regs[3] +#define rPrimColorG regs[4] +#define rPrimColorB regs[5] +#define rPrimColorA regs[6] +#define rEnvColorR regs[7] +#define rEnvColorG regs[8] +#define rEnvColorB regs[9] +#define rEnvColorA regs[10] +#define rLifespan regs[11] +#define rBgId regs[12] #define PARAMS ((EffectSsGRippleInitParams*)initParamsx) -s32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Ripple_InitVars = { EFFECT_SS_G_RIPPLE, EffectSsGRipple_Init, }; -#endif +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGRippleInitParams* initParams = PARAMS; + WaterBox* waterBox = NULL; + s32 pad; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Init.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->gfx = gEffWaterRippleDL; + this->life = initParams->life + 20; + this->flags = 0; + this->draw = EffectSsGRipple_Draw; + this->update = EffectSsGRipple_Update; + this->rRadius = initParams->radius; + this->rRadiusMax = initParams->radiusMax; + this->rLifespan = initParams->life; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 255; + this->rPrimColorA = 255; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &initParams->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/func_80979C38.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Draw.s") +void EffectSsGRipple_DrawRipple(PlayState* play2, EffectSs* this, TexturePtr tex) { + PlayState* play = play2; + f32 radius; + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 yPos; + CollisionHeader* colHeader; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Update.s") + OPEN_DISPS(gfxCtx); + + radius = this->rRadius * 0.0025f; + colHeader = BgCheck_GetCollisionHeader(&play->colCtx, this->rBgId); + + if ((this->rWaterBoxNum != -1) && (colHeader != NULL) && (this->rWaterBoxNum < colHeader->numWaterBoxes)) { + yPos = func_800CA568(&play->colCtx, this->rWaterBoxNum, this->rBgId); + } else { + yPos = this->pos.y; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, yPos, this->pos.z); + SkinMatrix_SetScale(&mfScale, radius, radius, radius); + 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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this) { + if (this->rLifespan == 0) { + EffectSsGRipple_DrawRipple(play, this, gEffWaterRippleTex); + } +} + +void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this) { + f32 radius; + f32 primAlpha; + f32 envAlpha; + WaterBox* waterBox; + s32 bgId; + + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &this->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; + + if (DECR(this->rLifespan) == 0) { + radius = this->rRadius; + Math_SmoothStepToF(&radius, this->rRadiusMax, 0.2f, 30.0f, 1.0f); + this->rRadius = radius; + + primAlpha = this->rPrimColorA; + envAlpha = this->rEnvColorA; + + Math_SmoothStepToF(&primAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + Math_SmoothStepToF(&envAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + + this->rPrimColorA = primAlpha; + this->rEnvColorA = envAlpha; + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fc4e3697a2..c7d6b66f79 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8155,7 +8155,7 @@ 0x80979738:("EffectSsBubble_Draw",), 0x8097985C:("EffectSsBubble_Update",), 0x80979B30:("EffectSsGRipple_Init",), - 0x80979C38:("func_80979C38",), + 0x80979C38:("EffectSsGRipple_DrawRipple",), 0x80979E48:("EffectSsGRipple_Draw",), 0x80979E80:("EffectSsGRipple_Update",), 0x8097A050:("EffectSsGSplash_Init",),