From ad106ff1e287111244e310a793f2fa64e9c4bd64 Mon Sep 17 00:00:00 2001 From: escape209 Date: Thu, 10 Oct 2024 16:25:05 +0100 Subject: [PATCH] zLightEffect: enable match --- configure.py | 2 +- src/SB/Game/zLight.cpp | 27 ++++++++ src/SB/Game/zLightEffect.cpp | 119 +++++++++-------------------------- src/SB/Game/zLightEffect.h | 15 +---- 4 files changed, 60 insertions(+), 103 deletions(-) diff --git a/configure.py b/configure.py index 89b9cc1a..b052f9b8 100644 --- a/configure.py +++ b/configure.py @@ -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"), diff --git a/src/SB/Game/zLight.cpp b/src/SB/Game/zLight.cpp index 3ac8fdf7..bb34199d 100644 --- a/src/SB/Game/zLight.cpp +++ b/src/SB/Game/zLight.cpp @@ -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 @@ -40,6 +53,8 @@ void zLightResetAll(xEnv* env) } #endif + + void zLightInit(void* b, void* tasset) { zLightInit((xBase*)b, (zLightAsset*)tasset); @@ -285,3 +300,15 @@ void zLightSetVolume(zVolume* vol) } } } + +void zLightOn(_zLight* zl, S32 on) +{ + if (on) + { + zl->flags |= 1; + } + else + { + zl->flags &= 0xfffffffe; + } +} diff --git a/src/SB/Game/zLightEffect.cpp b/src/SB/Game/zLightEffect.cpp index 83350b37..f6cbfbd2 100644 --- a/src/SB/Game/zLightEffect.cpp +++ b/src/SB/Game/zLightEffect.cpp @@ -5,32 +5,6 @@ #include #include -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; @@ -123,71 +97,27 @@ 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) { } @@ -195,27 +125,23 @@ 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) { } @@ -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); +} diff --git a/src/SB/Game/zLightEffect.h b/src/SB/Game/zLightEffect.h index 84fd4d41..19f2a694 100644 --- a/src/SB/Game/zLightEffect.h +++ b/src/SB/Game/zLightEffect.h @@ -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