Skip to content

Commit 90fd857

Browse files
authored
zLightEffect: enable match (#390)
1 parent 0281478 commit 90fd857

File tree

4 files changed

+60
-103
lines changed

4 files changed

+60
-103
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
365365
Object(NonMatching, "SB/Game/zHud.cpp"),
366366
Object(NonMatching, "SB/Game/zLasso.cpp"),
367367
Object(NonMatching, "SB/Game/zLight.cpp"),
368-
Object(NonMatching, "SB/Game/zLightEffect.cpp"),
368+
Object(Matching, "SB/Game/zLightEffect.cpp"),
369369
Object(NonMatching, "SB/Game/zLightning.cpp"),
370370
Object(NonMatching, "SB/Game/zLOD.cpp"),
371371
Object(NonMatching, "SB/Game/zMain.cpp"),

src/SB/Game/zLight.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ extern _zLight* gTemporaryLights[32];
2020
extern F32 zLight_float;
2121
extern xVec3 sDefaultShadowVec;
2222
extern void (*sEffectFuncs[18])(_zLight*, F32);
23+
extern lightInitFunc sEffectInitFuncs[18];
24+
25+
void zLightEffectSet(_zLight* zlight, S32 idx)
26+
{
27+
if (zlight->reg)
28+
{
29+
zlight->effect_idx = idx;
30+
if (sEffectInitFuncs[zlight->effect_idx] != NULL)
31+
{
32+
sEffectInitFuncs[zlight->effect_idx](zlight);
33+
}
34+
}
35+
}
2336

2437
#ifdef NON_MATCHING
2538

@@ -40,6 +53,8 @@ void zLightResetAll(xEnv* env)
4053
}
4154
#endif
4255

56+
57+
4358
void zLightInit(void* b, void* tasset)
4459
{
4560
zLightInit((xBase*)b, (zLightAsset*)tasset);
@@ -285,3 +300,15 @@ void zLightSetVolume(zVolume* vol)
285300
}
286301
}
287302
}
303+
304+
void zLightOn(_zLight* zl, S32 on)
305+
{
306+
if (on)
307+
{
308+
zl->flags |= 1;
309+
}
310+
else
311+
{
312+
zl->flags &= 0xfffffffe;
313+
}
314+
}

src/SB/Game/zLightEffect.cpp

Lines changed: 30 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,6 @@
55
#include <types.h>
66
#include <stdlib.h>
77

8-
extern lightInitFunc sEffectInitFuncs[18];
9-
10-
void zLightEffectSet(_zLight* zlight, S32 idx)
11-
{
12-
if (zlight->reg)
13-
{
14-
zlight->effect_idx = idx;
15-
if (sEffectInitFuncs[zlight->effect_idx] != NULL)
16-
{
17-
sEffectInitFuncs[zlight->effect_idx](zlight);
18-
}
19-
}
20-
}
21-
22-
void zLightOn(_zLight* zl, S32 on)
23-
{
24-
if (on)
25-
{
26-
zl->flags |= 1;
27-
}
28-
else
29-
{
30-
zl->flags &= 0xfffffffe;
31-
}
32-
}
33-
348
static F32 leGetRandom()
359
{
3610
F32 ret = (U16)rand() / (F32)0xffff;
@@ -123,99 +97,51 @@ void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds)
12397
EffectFlicker(zlight, seconds, 0.0f, 0.1f);
12498
}
12599

126-
void zLightEffectStrobeSlow()
127-
{
128-
}
129-
130-
void zLightEffectStrobe()
131-
{
132-
}
133-
134-
void zLightEffectStrobeFast()
135-
{
136-
}
137-
138-
void zLightEffectDimSlow()
139-
{
140-
}
141-
142-
void zLightEffectDim()
143-
{
144-
}
145-
146-
void zLightEffectDimFast()
147-
{
148-
}
149-
150-
void zLightEffectHalfDimSlow()
151-
{
152-
}
153-
154-
void zLightEffectHalfDim()
155-
{
156-
}
157-
158-
void zLightEffectHalfDimFast()
159-
{
160-
}
161-
162-
void zLightEffectRandomColSlow()
163-
{
164-
}
165-
166-
void zLightEffectRandomCol()
167-
{
168-
}
169-
170-
void zLightEffectRandomColFast()
100+
void zLightEffectStrobeSlow(_zLight*, F32)
171101
{
172102
}
173103

174-
void zLightEffectRandomColFast(_zLight*, F32)
104+
void zLightEffectStrobe(_zLight*, F32)
175105
{
176106
}
177107

178-
void zLightEffectRandomCol(_zLight*, F32)
108+
void zLightEffectStrobeFast(_zLight*, F32)
179109
{
180110
}
181111

182-
void zLightEffectRandomColSlow(_zLight*, F32)
112+
void zLightEffectDimSlow(_zLight*, F32)
183113
{
184114
}
185115

186-
void zLightEffectHalfDimFast(_zLight*, F32)
116+
void zLightEffectDim(_zLight*, F32)
187117
{
188118
}
189119

190-
void zLightEffectHalfDim(_zLight*, F32)
120+
void zLightEffectDimFast(_zLight*, F32)
191121
{
192122
}
193123

194124
void zLightEffectHalfDimSlow(_zLight*, F32)
195125
{
196126
}
197127

198-
void zLightEffectDimFast(_zLight*, F32)
199-
{
200-
}
201-
202-
void zLightEffectDim(_zLight*, F32)
128+
void zLightEffectHalfDim(_zLight*, F32)
203129
{
204130
}
205131

206-
void zLightEffectDimSlow(_zLight*, F32)
132+
void zLightEffectHalfDimFast(_zLight*, F32)
207133
{
208134
}
209135

210-
void zLightEffectStrobeFast(_zLight*, F32)
136+
void zLightEffectRandomColSlow(_zLight*, F32)
211137
{
212138
}
213139

214-
void zLightEffectStrobe(_zLight*, F32)
140+
void zLightEffectRandomCol(_zLight*, F32)
215141
{
216142
}
217143

218-
void zLightEffectStrobeSlow(_zLight*, F32)
144+
void zLightEffectRandomColFast(_zLight*, F32)
219145
{
220146
}
221147

@@ -243,10 +169,25 @@ F32 leBlendToCol(F32 f1, F32 f2, F32 f3)
243169
}
244170
}
245171

246-
#if 0
247-
// WIP.
248172
void zLightEffectCauldron(_zLight* zlight, F32 seconds)
249173
{
250-
}
174+
iLight* l = &zlight->light;
175+
176+
F32* reg = zlight->reg;
177+
*reg -= seconds;
178+
179+
if (*reg <= 0.0f)
180+
{
181+
reg[0] = 0.25f;
182+
reg[1] = (leGetRandom() * 0.5f);
183+
reg[2] = (leGetRandom() * 0.4f + 0.6f);
184+
reg[3] = (leGetRandom() * 0.5f);
185+
}
251186

252-
#endif
187+
F32 amount = (seconds * 3.0f);
188+
l->color.r = leBlendToCol(l->color.r, reg[1], amount);
189+
l->color.g = leBlendToCol(l->color.g, reg[2], amount);
190+
l->color.b = leBlendToCol(l->color.b, reg[3], amount);
191+
192+
iLightSetColor(l, &l->color);
193+
}

src/SB/Game/zLightEffect.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,9 @@ static void EffectFlicker(_zLight* zlight, F32 seconds, F32 min, F32 rnd);
2121
void zLightEffectFlicker(_zLight* zlight, F32 seconds);
2222
void zLightEffectFlickerSlow(_zLight* zlight, F32 seconds);
2323
void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds);
24-
void zLightEffectStrobeSlow();
25-
void zLightEffectStrobe();
26-
void zLightEffectStrobeFast();
27-
void zLightEffectDimSlow();
28-
void zLightEffectDim();
29-
void zLightEffectDimFast();
30-
void zLightEffectHalfDimSlow();
31-
void zLightEffectHalfDim();
32-
void zLightEffectHalfDimFast();
33-
void zLightEffectRandomColSlow();
34-
void zLightEffectRandomCol();
35-
void zLightEffectRandomColFast();
24+
3625
void zLightEffectInitCauldron(_zLight* zlight);
37-
F32 leBlendToCol(F32 f1, F32 f2, F32 f3);
26+
static F32 leBlendToCol(F32 f1, F32 f2, F32 f3);
3827
void zLightEffectCauldron(_zLight* zlight, F32 seconds);
3928

4029
#endif

0 commit comments

Comments
 (0)