diff options
| author | Dragorn421 <Dragorn421@users.noreply.github.com> | 2023-08-16 02:28:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-15 20:28:12 -0400 |
| commit | d6207b17c2c6dd51d6136a86bee3deee66f45734 (patch) | |
| tree | b397e7c101222fe792c72a09524f5acf7a866225 /src/code | |
| parent | 4dea0bfb26951a8a07ee4cbb9642d8bcd52ba71a (diff) | |
Doc/cleanup pass on effects 1 (#1421)
* Some doc/cleanup on `Effect_Ss_Fhg_Flash`
* Some doc/cleanup on `Effect_Ss_Blast`
* 11DA0 -> Billboard
* doc three lerp funcs in effectss
* Some doc/cleanup on `Effect_Ss_Bomb`
* `rTexIdx` -> `rTexIndex`
* lifespan
* `LIFESPAN` -> `EFFSSBOMB_LIFESPAN`
* --parentheses
* Add todo about "having zapd forward declare static variables"
* try rework comments on effects scale
* lightning -> "a ball of electrical arcs" ?
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_eff_blure.c | 96 | ||||
| -rw-r--r-- | src/code/z_effect_soft_sprite.c | 21 | ||||
| -rw-r--r-- | src/code/z_effect_soft_sprite_old_init.c | 72 |
3 files changed, 112 insertions, 77 deletions
diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 242dac94d..75f8d80bc 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -295,9 +295,9 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 switch (this->calcMode) { case 1: - vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vec1->z = func_80027E34(elem->p1.z, elem->p2.z, ratio); + vec1->x = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vec1->y = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vec1->z = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); vec2->x = elem->p2.x; vec2->y = elem->p2.y; vec2->z = elem->p2.z; @@ -307,19 +307,19 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 vec1->x = elem->p1.x; vec1->y = elem->p1.y; vec1->z = elem->p1.z; - vec2->x = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vec2->y = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vec2->z = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vec2->x = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vec2->y = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vec2->z = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); break; case 3: ratio *= 0.5f; - vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vec1->z = func_80027E34(elem->p1.z, elem->p2.z, ratio); - vec2->x = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vec2->y = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vec2->z = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vec1->x = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vec1->y = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vec1->z = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); + vec2->x = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vec2->y = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vec2->z = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); ratio *= 2.0f; break; @@ -356,14 +356,14 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; } else { - color1->r = func_80027E84(this->p1StartColor[0], this->p1EndColor[0], ratio); - color1->g = func_80027E84(this->p1StartColor[1], this->p1EndColor[1], ratio); - color1->b = func_80027E84(this->p1StartColor[2], this->p1EndColor[2], ratio); - color1->a = func_80027E84(this->p1StartColor[3], this->p1EndColor[3], ratio); - color2->r = func_80027E84(this->p2StartColor[0], this->p2EndColor[0], ratio); - color2->g = func_80027E84(this->p2StartColor[1], this->p2EndColor[1], ratio); - color2->b = func_80027E84(this->p2StartColor[2], this->p2EndColor[2], ratio); - color2->a = func_80027E84(this->p2StartColor[3], this->p2EndColor[3], ratio); + color1->r = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); + color1->g = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); + color1->b = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); + color1->a = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); + color2->r = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); + color2->g = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); + color2->b = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); + color2->a = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); } } @@ -618,18 +618,18 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem vtx[j1].v.ob[0] = Math_FNearbyIntF(sp158.x); vtx[j1].v.ob[1] = Math_FNearbyIntF(sp158.y); vtx[j1].v.ob[2] = Math_FNearbyIntF(sp158.z); - vtx[j1].v.cn[0] = func_80027E84(sp1A4.r, sp19C.r, temp_f28); - vtx[j1].v.cn[1] = func_80027E84(sp1A4.g, sp19C.g, temp_f28); - vtx[j1].v.cn[2] = func_80027E84(sp1A4.b, sp19C.b, temp_f28); - vtx[j1].v.cn[3] = func_80027E84(sp1A4.a, sp19C.a, temp_f28); + vtx[j1].v.cn[0] = EffectSs_LerpU8(sp1A4.r, sp19C.r, temp_f28); + vtx[j1].v.cn[1] = EffectSs_LerpU8(sp1A4.g, sp19C.g, temp_f28); + vtx[j1].v.cn[2] = EffectSs_LerpU8(sp1A4.b, sp19C.b, temp_f28); + vtx[j1].v.cn[3] = EffectSs_LerpU8(sp1A4.a, sp19C.a, temp_f28); vtx[j2].v.ob[0] = Math_FNearbyIntF(sp14C.x); vtx[j2].v.ob[1] = Math_FNearbyIntF(sp14C.y); vtx[j2].v.ob[2] = Math_FNearbyIntF(sp14C.z); - vtx[j2].v.cn[0] = func_80027E84(sp1A0.r, sp198.r, temp_f28); - vtx[j2].v.cn[1] = func_80027E84(sp1A0.g, sp198.g, temp_f28); - vtx[j2].v.cn[2] = func_80027E84(sp1A0.b, sp198.b, temp_f28); - vtx[j2].v.cn[3] = func_80027E84(sp1A0.a, sp198.a, temp_f28); + vtx[j2].v.cn[0] = EffectSs_LerpU8(sp1A0.r, sp198.r, temp_f28); + vtx[j2].v.cn[1] = EffectSs_LerpU8(sp1A0.g, sp198.g, temp_f28); + vtx[j2].v.cn[2] = EffectSs_LerpU8(sp1A0.b, sp198.b, temp_f28); + vtx[j2].v.cn[3] = EffectSs_LerpU8(sp1A0.a, sp198.a, temp_f28); } gSPVertex(POLY_XLU_DISP++, vtx, 16, 0); @@ -957,9 +957,9 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { switch (this->calcMode) { case 1: - vtx[j].v.ob[0] = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vtx[j].v.ob[1] = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vtx[j].v.ob[2] = func_80027E34(elem->p1.z, elem->p2.z, ratio); + vtx[j].v.ob[0] = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); vtx[j + 1].v.ob[0] = elem->p2.x; vtx[j + 1].v.ob[1] = elem->p2.y; vtx[j + 1].v.ob[2] = elem->p2.z; @@ -968,18 +968,18 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.ob[0] = elem->p1.x; vtx[j].v.ob[1] = elem->p1.y; vtx[j].v.ob[2] = elem->p1.z; - vtx[j + 1].v.ob[0] = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vtx[j + 1].v.ob[1] = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vtx[j + 1].v.ob[2] = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vtx[j + 1].v.ob[0] = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); break; case 3: ratio = ratio * 0.5f; - vtx[j].v.ob[0] = func_80027E34(elem->p1.x, elem->p2.x, ratio); - vtx[j].v.ob[1] = func_80027E34(elem->p1.y, elem->p2.y, ratio); - vtx[j].v.ob[2] = func_80027E34(elem->p1.z, elem->p2.z, ratio); - vtx[j + 1].v.ob[0] = func_80027E34(elem->p2.x, elem->p1.x, ratio); - vtx[j + 1].v.ob[1] = func_80027E34(elem->p2.y, elem->p1.y, ratio); - vtx[j + 1].v.ob[2] = func_80027E34(elem->p2.z, elem->p1.z, ratio); + vtx[j].v.ob[0] = EffectSs_LerpS16(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = EffectSs_LerpS16(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = EffectSs_LerpS16(elem->p1.z, elem->p2.z, ratio); + vtx[j + 1].v.ob[0] = EffectSs_LerpS16(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = EffectSs_LerpS16(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = EffectSs_LerpS16(elem->p2.z, elem->p1.z, ratio); ratio = ratio + ratio; break; case 0: @@ -996,19 +996,19 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p1StartColor[0], this->p1EndColor[0], ratio); - vtx[j].v.cn[1] = func_80027E84(this->p1StartColor[1], this->p1EndColor[1], ratio); - vtx[j].v.cn[2] = func_80027E84(this->p1StartColor[2], this->p1EndColor[2], ratio); - vtx[j].v.cn[3] = func_80027E84(this->p1StartColor[3], this->p1EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p1StartColor[0], this->p1EndColor[0], ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p1StartColor[1], this->p1EndColor[1], ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p1StartColor[2], this->p1EndColor[2], ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p1StartColor[3], this->p1EndColor[3], ratio); j++; vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_80027E84(this->p2StartColor[0], this->p2EndColor[0], ratio); - vtx[j].v.cn[1] = func_80027E84(this->p2StartColor[1], this->p2EndColor[1], ratio); - vtx[j].v.cn[2] = func_80027E84(this->p2StartColor[2], this->p2EndColor[2], ratio); - vtx[j].v.cn[3] = func_80027E84(this->p2StartColor[3], this->p2EndColor[3], ratio); + vtx[j].v.cn[0] = EffectSs_LerpU8(this->p2StartColor[0], this->p2EndColor[0], ratio); + vtx[j].v.cn[1] = EffectSs_LerpU8(this->p2StartColor[1], this->p2EndColor[1], ratio); + vtx[j].v.cn[2] = EffectSs_LerpU8(this->p2StartColor[2], this->p2EndColor[2], ratio); + vtx[j].v.cn[3] = EffectSs_LerpU8(this->p2StartColor[3], this->p2EndColor[3], ratio); j++; } } diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 55a1245a3..6fb6e05d3 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -324,16 +324,25 @@ void EffectSs_DrawAll(PlayState* play) { } } -s16 func_80027DD4(s16 arg0, s16 arg1, s32 arg2) { - s16 ret = (arg2 == 0) ? arg1 : (arg0 + (s32)((arg1 - arg0) / (f32)arg2)); +/** + * Lerp from `a` (weightInv == inf) to `b` (weightInv == 1 or 0). + */ +s16 EffectSs_LerpInv(s16 a, s16 b, s32 weightInv) { + s16 ret = (weightInv == 0) ? b : (a + (s32)((b - a) / (f32)weightInv)); return ret; } -s16 func_80027E34(s16 arg0, s16 arg1, f32 arg2) { - return (arg1 - arg0) * arg2 + arg0; +/** + * Lerp from `a` (weight == 0) to `b` (weight == 1). + */ +s16 EffectSs_LerpS16(s16 a, s16 b, f32 weight) { + return (b - a) * weight + a; } -u8 func_80027E84(u8 arg0, u8 arg1, f32 arg2) { - return arg2 * ((f32)arg1 - (f32)arg0) + arg0; +/** + * Lerp from `a` (weight == 0) to `b` (weight == 1). + */ +u8 EffectSs_LerpU8(u8 a, u8 b, f32 weight) { + return weight * ((f32)b - (f32)a) + a; } diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 5c6b95711..f2d7d0a54 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -46,7 +46,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { MtxF mfTrans; MtxF mfScale; MtxF mfResult; - MtxF mfTrans11DA0; + MtxF mfTransBillboard; s32 pad1; Mtx* mtx; void* object = play->objectCtx.status[this->rgObjBankIdx].segment; @@ -56,8 +56,8 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { scale = this->rgScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); - SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); gSegments[6] = VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); @@ -316,15 +316,26 @@ void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Ve // EffectSsBlast Spawn Functions -void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { +/** + * Spawn a ring-shaped shockwave effect. + * + * @param pos Position from which to find collision to draw the shockwave along. + * @param innerColor Color on the inside of the ring. Alpha is effect's alpha. + * @param outerColor Color on the outside of the ring. + * @param scale How large the shockwave is initially. The shockwave will be `scale*64/400` units wide. + * @param scaleStep How much to increase `scale` by each frame. + * @param scaleStepDecay How much to decrease `scaleStep` by each frame + * (should be a divisor of `scaleStep`, or small enough that `scaleStep` won't go negative). + */ +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* innerColor, + Color_RGBA8* outerColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { EffectSsBlastParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - Color_RGBA8_Copy(&initParams.primColor, primColor); - Color_RGBA8_Copy(&initParams.envColor, envColor); + Color_RGBA8_Copy(&initParams.innerColor, innerColor); + Color_RGBA8_Copy(&initParams.outerColor, outerColor); initParams.scale = scale; initParams.scaleStep = scaleStep; initParams.scaleStepDecay = scaleStepDecay; @@ -333,24 +344,39 @@ void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams); } -void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep, s16 life) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 200, 200, 0 }; +/** + * Spawn a white shockwave effect. + * + * @see EffectSsBlast_Spawn + */ +void EffectSsBlast_SpawnWhiteShockwaveSetScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16 scaleStep, s16 life) { + static Color_RGBA8 innerColor = { 255, 255, 255, 255 }; + static Color_RGBA8 outerColor = { 200, 200, 200, 0 }; - EffectSsBlast_Spawn(play, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); + EffectSsBlast_Spawn(play, pos, velocity, accel, &innerColor, &outerColor, scale, scaleStep, 35, life); } -void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 life) { - EffectSsBlast_Spawn(play, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); +/** + * Spawn a shockwave effect, quickly expanding. + * + * @see EffectSsBlast_Spawn + */ +void EffectSsBlast_SpawnShockwaveSetColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, + Color_RGBA8* innerColor, Color_RGBA8* outerColor, s16 life) { + EffectSsBlast_Spawn(play, pos, velocity, accel, innerColor, outerColor, 100, 375, 35, life); } +/** + * Spawn a white shockwave effect, quickly expanding, for 10 frames. + * + * @see EffectSsBlast_Spawn + */ void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - static Color_RGBA8 primColor = { 255, 255, 255, 255 }; - static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + static Color_RGBA8 innerColor = { 255, 255, 255, 255 }; + static Color_RGBA8 outerColor = { 200, 200, 200, 0 }; - EffectSsBlast_SpawnShockwave(play, pos, velocity, accel, &primColor, &envColor, 10); + EffectSsBlast_SpawnShockwaveSetColor(play, pos, velocity, accel, &innerColor, &outerColor, 10); } // EffectSsGSpk Spawn Functions @@ -745,12 +771,12 @@ void EffectSsFhgFlash_SpawnLightBall(PlayState* play, Vec3f* pos, Vec3f* velocit } /** - * Spawn a shock effect + * Spawn a purple shock effect (a ball of electrical arcs). * - * param determines where the ligntning should go - * 0: don't attach to any actor. spawns at the position specified by pos - * 1: spawn at one of Player's body parts, chosen at random - * 2: spawn at one of Phantom Ganon's body parts, chosen at random + * @param actor If param is `FHGFLASH_SHOCK_PG`, the Phantom Ganon actor. Unused otherwise. + * @param pos If param is `FHGFLASH_SHOCK_NO_ACTOR`, the position of the effect. Unused otherwise. + * @param scale The effect will be around `scale*20/100` units wide (randomized). + * @param param Determines what the effect attaches to. See `FhgFlashLightningParam`. */ void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 param) { EffectSsFhgFlashInitParams initParams; |
