diff --git a/include/effect.h b/include/effect.h index 060b6cd090..97412e2f33 100644 --- a/include/effect.h +++ b/include/effect.h @@ -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); diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index fea0102140..c6ae48eb24 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -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); } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index f883658f4a..7919754875 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -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 { diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 8d5605e763..f9e9cb1aa7 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -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; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h index e9e3c11148..0559821590 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h @@ -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