mirror of
https://github.com/zeldaret/oot
synced 2026-08-22 14:50:17 -04:00
Document z_eff_ss_stone1.[ch] (#2670)
* Document z_eff_ss_stone1.[ch] * Incorporate feedback from PR review. From https://github.com/zeldaret/oot/pull/2670: - Shortened excessively verbose suppressRTransFadeFlashAlphaStepAfterTwoFrames name to suppressFadeFlash - Fixed up comment that went waaaaaay beyond the column limit in z_eff_ss_stone1.h - Shortened comparison with 0 of variable bool semantics in z_eff_ss_stone1.c Signed-off-by: Gabriel Ravier <gabravier@gmail.com> * Fix misnaming from PR review and document some more From https://github.com/zeldaret/oot/pull/2670: - shortenFadeFlash is incorrect - renamed to freezeFadeFlash - Used `false` instead of 0 in EnArrow_Fly - Elaborated comments about what exactly freezeFadeFlash does Also added a few extra comments to z_eff_ss_stone1.c * Ran clang-format * More feedback from PR review, clarified comment From https://github.com/zeldaret/oot/pull/2670: - Change 0 to false in header comment - Remove verbose speculation about former use of unused variable - Made comment on use of viewDepth clearer - Separated matrix and gfx code with a newline Signed-off-by: Gabriel Ravier <gabravier@gmail.com> * Marked the "1500" as being in units --------- Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
+1
-1
@@ -391,7 +391,7 @@ void EffectSsSibuki_SpawnBurst(struct PlayState* play, Vec3f* pos);
|
||||
void EffectSsSibuki2_Spawn(struct PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale);
|
||||
void EffectSsGMagma2_Spawn(struct PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor,
|
||||
s16 updateRate, s16 drawMode, s16 scale);
|
||||
void EffectSsStone1_Spawn(struct PlayState* play, Vec3f* pos, s32 arg2);
|
||||
void EffectSsStone1_Spawn(struct PlayState* play, Vec3f* pos, s32 freezeFadeFlash);
|
||||
void EffectSsHitMark_Spawn(struct PlayState* play, s32 type, s16 scale, Vec3f* pos);
|
||||
void EffectSsHitMark_SpawnFixedScale(struct PlayState* play, s32 type, Vec3f* pos);
|
||||
void EffectSsHitMark_SpawnCustomScale(struct PlayState* play, s32 type, s16 scale, Vec3f* pos);
|
||||
|
||||
@@ -733,11 +733,11 @@ void EffectSsGMagma2_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor,
|
||||
|
||||
// EffectSsStone1 Spawn Functions
|
||||
|
||||
void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 arg2) {
|
||||
void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 freezeFadeFlash) {
|
||||
EffectSsStone1InitParams initParams;
|
||||
|
||||
initParams.pos = *pos;
|
||||
initParams.unk_C = arg2;
|
||||
initParams.freezeFadeFlash = freezeFadeFlash;
|
||||
|
||||
EffectSs_Spawn(play, EFFECT_SS_STONE1, 128, &initParams);
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ void EnArrow_Fly(EnArrow* this, PlayState* play) {
|
||||
sfxId = NA_SE_IT_SLING_REFLECT;
|
||||
}
|
||||
|
||||
EffectSsStone1_Spawn(play, &this->actor.world.pos, 0);
|
||||
EffectSsStone1_Spawn(play, &this->actor.world.pos, false);
|
||||
SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, sfxId);
|
||||
Actor_Kill(&this->actor);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File: z_eff_ss_stone1.c
|
||||
* Overlay: ovl_Effect_Ss_Stone1
|
||||
* Description:
|
||||
* Description: Impact effect for deku nuts and seeds
|
||||
*/
|
||||
|
||||
#include "z_eff_ss_stone1.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "assets/objects/gameplay_keep/unknown_eff_stone.h"
|
||||
|
||||
#define rReg0 regs[0]
|
||||
#define rFreezeFadeFlash regs[0]
|
||||
|
||||
u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx);
|
||||
void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this);
|
||||
@@ -35,6 +35,7 @@ typedef struct EffStoneDrawInfo {
|
||||
/* 0x08 */ Color_RGBA8 envColor;
|
||||
} EffStoneDrawInfo;
|
||||
|
||||
// Indexed by the decreasing life (from 7 to 0), so in reverse order
|
||||
static EffStoneDrawInfo sDrawInfo[] = {
|
||||
{ gUnknownEffStone8Tex, { 200, 0, 0, 255 }, { 0, 0, 0, 255 } },
|
||||
{ gUnknownEffStone7Tex, { 255, 100, 0, 255 }, { 100, 0, 0, 255 } },
|
||||
@@ -53,7 +54,7 @@ u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initPa
|
||||
this->pos = pos;
|
||||
this->vec = pos;
|
||||
this->life = 8;
|
||||
this->rReg0 = initParams->unk_C;
|
||||
this->rFreezeFadeFlash = initParams->freezeFadeFlash;
|
||||
this->draw = EffectSsStone1_Draw;
|
||||
this->update = EffectSsStone1_Update;
|
||||
|
||||
@@ -63,17 +64,20 @@ u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initPa
|
||||
void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) {
|
||||
GraphicsContext* gfxCtx = play->state.gfxCtx;
|
||||
EffStoneDrawInfo* drawParams = &sDrawInfo[this->life];
|
||||
Vec3f mfVec;
|
||||
f32 mfW;
|
||||
Vec3f unusedProjectedPos;
|
||||
f32 viewDepth;
|
||||
f32 scale;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_eff_ss_stone1.c", 154);
|
||||
|
||||
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->pos, &mfVec, &mfW);
|
||||
scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f;
|
||||
// Grow the effect with distance (when above 1500 units) so as to keep a roughly constant on-screen size when far
|
||||
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->pos, &unusedProjectedPos, &viewDepth);
|
||||
scale = (viewDepth < 1500.0f) ? 3.0f : (viewDepth / 1500.0f) * 3.0f;
|
||||
|
||||
Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW);
|
||||
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
|
||||
MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx, "../z_eff_ss_stone1.c", 168);
|
||||
|
||||
Gfx_SetupDL_61Xlu(gfxCtx);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(drawParams->texture));
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, drawParams->primColor.r, drawParams->primColor.g, drawParams->primColor.b,
|
||||
@@ -85,7 +89,8 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) {
|
||||
}
|
||||
|
||||
void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this) {
|
||||
if ((this->life == 6) && (this->rReg0 != 0)) {
|
||||
if ((this->life == 6) && this->rFreezeFadeFlash) {
|
||||
//! @bug freezes the screen (see z_eff_ss_stone1.h)
|
||||
R_TRANS_FADE_FLASH_ALPHA_STEP = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,19 @@
|
||||
|
||||
typedef struct EffectSsStone1InitParams {
|
||||
/* 0x00 */ Vec3f pos;
|
||||
/* 0x0C */ s32 unk_C;
|
||||
} EffectSsStone1InitParams; // size = 0x
|
||||
|
||||
/**
|
||||
* If this is non-zero, then on the 2nd frame after being spawned,
|
||||
* the effect will set R_TRANS_FADE_FLASH_ALPHA_STEP to 0,
|
||||
* which results in the flash simply freezing as it is after 2 frames -
|
||||
* that is, the screen stays as bright as it is after 2 frames of a flash
|
||||
* (basically stuck with an opaque layer of white),
|
||||
* until R_TRANS_FADE_FLASH_ALPHA_STEP is set again or the play state is reentered
|
||||
* (e.g. on entrance transitions).
|
||||
*
|
||||
* All current users of EffectSsStone1InitParams set this to false.
|
||||
*/
|
||||
/* 0x0C */ s32 freezeFadeFlash;
|
||||
} EffectSsStone1InitParams; // size = 0x10
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user