Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zLightEffect: enable match #390

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "SB/Game/zHud.cpp"),
Object(NonMatching, "SB/Game/zLasso.cpp"),
Object(NonMatching, "SB/Game/zLight.cpp"),
Object(NonMatching, "SB/Game/zLightEffect.cpp"),
Object(Matching, "SB/Game/zLightEffect.cpp"),
Object(NonMatching, "SB/Game/zLightning.cpp"),
Object(NonMatching, "SB/Game/zLOD.cpp"),
Object(NonMatching, "SB/Game/zMain.cpp"),
Expand Down
27 changes: 27 additions & 0 deletions src/SB/Game/zLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ extern _zLight* gTemporaryLights[32];
extern F32 zLight_float;
extern xVec3 sDefaultShadowVec;
extern void (*sEffectFuncs[18])(_zLight*, F32);
extern lightInitFunc sEffectInitFuncs[18];

void zLightEffectSet(_zLight* zlight, S32 idx)
{
if (zlight->reg)
{
zlight->effect_idx = idx;
if (sEffectInitFuncs[zlight->effect_idx] != NULL)
{
sEffectInitFuncs[zlight->effect_idx](zlight);
}
}
}

#ifdef NON_MATCHING

Expand All @@ -40,6 +53,8 @@ void zLightResetAll(xEnv* env)
}
#endif



void zLightInit(void* b, void* tasset)
{
zLightInit((xBase*)b, (zLightAsset*)tasset);
Expand Down Expand Up @@ -285,3 +300,15 @@ void zLightSetVolume(zVolume* vol)
}
}
}

void zLightOn(_zLight* zl, S32 on)
{
if (on)
{
zl->flags |= 1;
}
else
{
zl->flags &= 0xfffffffe;
}
}
119 changes: 30 additions & 89 deletions src/SB/Game/zLightEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,6 @@
#include <types.h>
#include <stdlib.h>

extern lightInitFunc sEffectInitFuncs[18];

void zLightEffectSet(_zLight* zlight, S32 idx)
{
if (zlight->reg)
{
zlight->effect_idx = idx;
if (sEffectInitFuncs[zlight->effect_idx] != NULL)
{
sEffectInitFuncs[zlight->effect_idx](zlight);
}
}
}

void zLightOn(_zLight* zl, S32 on)
{
if (on)
{
zl->flags |= 1;
}
else
{
zl->flags &= 0xfffffffe;
}
}

static F32 leGetRandom()
{
F32 ret = (U16)rand() / (F32)0xffff;
Expand Down Expand Up @@ -123,99 +97,51 @@ void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds)
EffectFlicker(zlight, seconds, 0.0f, 0.1f);
}

void zLightEffectStrobeSlow()
{
}

void zLightEffectStrobe()
{
}

void zLightEffectStrobeFast()
{
}

void zLightEffectDimSlow()
{
}

void zLightEffectDim()
{
}

void zLightEffectDimFast()
{
}

void zLightEffectHalfDimSlow()
{
}

void zLightEffectHalfDim()
{
}

void zLightEffectHalfDimFast()
{
}

void zLightEffectRandomColSlow()
{
}

void zLightEffectRandomCol()
{
}

void zLightEffectRandomColFast()
void zLightEffectStrobeSlow(_zLight*, F32)
{
}

void zLightEffectRandomColFast(_zLight*, F32)
void zLightEffectStrobe(_zLight*, F32)
{
}

void zLightEffectRandomCol(_zLight*, F32)
void zLightEffectStrobeFast(_zLight*, F32)
{
}

void zLightEffectRandomColSlow(_zLight*, F32)
void zLightEffectDimSlow(_zLight*, F32)
{
}

void zLightEffectHalfDimFast(_zLight*, F32)
void zLightEffectDim(_zLight*, F32)
{
}

void zLightEffectHalfDim(_zLight*, F32)
void zLightEffectDimFast(_zLight*, F32)
{
}

void zLightEffectHalfDimSlow(_zLight*, F32)
{
}

void zLightEffectDimFast(_zLight*, F32)
{
}

void zLightEffectDim(_zLight*, F32)
void zLightEffectHalfDim(_zLight*, F32)
{
}

void zLightEffectDimSlow(_zLight*, F32)
void zLightEffectHalfDimFast(_zLight*, F32)
{
}

void zLightEffectStrobeFast(_zLight*, F32)
void zLightEffectRandomColSlow(_zLight*, F32)
{
}

void zLightEffectStrobe(_zLight*, F32)
void zLightEffectRandomCol(_zLight*, F32)
{
}

void zLightEffectStrobeSlow(_zLight*, F32)
void zLightEffectRandomColFast(_zLight*, F32)
{
}

Expand Down Expand Up @@ -243,10 +169,25 @@ F32 leBlendToCol(F32 f1, F32 f2, F32 f3)
}
}

#if 0
// WIP.
void zLightEffectCauldron(_zLight* zlight, F32 seconds)
{
}
iLight* l = &zlight->light;

F32* reg = zlight->reg;
*reg -= seconds;

if (*reg <= 0.0f)
{
reg[0] = 0.25f;
reg[1] = (leGetRandom() * 0.5f);
reg[2] = (leGetRandom() * 0.4f + 0.6f);
reg[3] = (leGetRandom() * 0.5f);
}

#endif
F32 amount = (seconds * 3.0f);
l->color.r = leBlendToCol(l->color.r, reg[1], amount);
l->color.g = leBlendToCol(l->color.g, reg[2], amount);
l->color.b = leBlendToCol(l->color.b, reg[3], amount);

iLightSetColor(l, &l->color);
}
15 changes: 2 additions & 13 deletions src/SB/Game/zLightEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,9 @@ static void EffectFlicker(_zLight* zlight, F32 seconds, F32 min, F32 rnd);
void zLightEffectFlicker(_zLight* zlight, F32 seconds);
void zLightEffectFlickerSlow(_zLight* zlight, F32 seconds);
void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds);
void zLightEffectStrobeSlow();
void zLightEffectStrobe();
void zLightEffectStrobeFast();
void zLightEffectDimSlow();
void zLightEffectDim();
void zLightEffectDimFast();
void zLightEffectHalfDimSlow();
void zLightEffectHalfDim();
void zLightEffectHalfDimFast();
void zLightEffectRandomColSlow();
void zLightEffectRandomCol();
void zLightEffectRandomColFast();

void zLightEffectInitCauldron(_zLight* zlight);
F32 leBlendToCol(F32 f1, F32 f2, F32 f3);
static F32 leBlendToCol(F32 f1, F32 f2, F32 f3);
void zLightEffectCauldron(_zLight* zlight, F32 seconds);

#endif