Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
escape209 committed Oct 12, 2024
2 parents 19cdc34 + 90fd857 commit a9b1f04
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 127 deletions.
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "SB/Core/x/xHudUnitMeter.cpp"),
Object(Matching, "SB/Core/x/xIni.cpp"),
Object(NonMatching, "SB/Core/x/xMath.cpp"),
Object(NonMatching, "SB/Core/x/xMath2.cpp"),
Object(Matching, "SB/Core/x/xMath2.cpp"),
Object(NonMatching, "SB/Core/x/xMath3.cpp"),
Object(NonMatching, "SB/Core/x/xMemMgr.cpp"),
Object(NonMatching, "SB/Core/x/xModel.cpp"),
Expand Down 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
5 changes: 4 additions & 1 deletion src/SB/Core/x/xMath2.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#include "xMath2.h"
#include "xMath2.h"

const basic_rect<F32> basic_rect<F32>::m_Null = { 0.0f, 0.0f, 0.0f, 0.0f };
const basic_rect<F32> basic_rect<F32>::m_Unit = { 0.0f, 0.0f, 1.0f, 1.0f };
4 changes: 2 additions & 2 deletions src/SB/Core/x/xMath2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ template <class T> struct basic_rect
T w;
T h;

static basic_rect m_Null;
static basic_rect m_Unit;
const static basic_rect m_Null;
const static basic_rect m_Unit;

basic_rect& assign(T x, T y, T w, T h);
basic_rect& contract(T x, T y, T w, T h);
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;
}
}
192 changes: 84 additions & 108 deletions src/SB/Game/zLightEffect.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
#include "zLightEffect.h"

#include "xMath.h"

#include <types.h>
#include <stdlib.h>

extern lightInitFunc sEffectInitFuncs[18];
extern F32 lbl_803CDB60; // 65535f
extern F32 lbl_803CDB68; // 176f
extern F32 lbl_803CDB70; // 0.0f
extern F32 lbl_803CDB74; // 0.1f
extern F32 lbl_803CDB78; // 0.2f
extern F32 lbl_803CDB80; // 0.05f
extern F32 lbl_803CDB84; // 0.3f

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 All @@ -60,158 +29,165 @@ void zLightEffectInitRandomCol(_zLight* zlight)

void zLightEffectInitFlicker(_zLight* zlight)
{
*zlight->reg = lbl_803CDB70;
*zlight->reg = 0.0f;
zLightOn(zlight, true);
}

#if 0
// WIP.
void EffectFlicker(_zLight* zlight, F32 seconds, F32 min, F32 rnd)
{
}

#endif

void zLightEffectFlicker(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, lbl_803CDB80, lbl_803CDB78);
}

void zLightEffectFlickerSlow(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, lbl_803CDB78, lbl_803CDB84);
}
iLight* l = &zlight->light;
F32* reg = zlight->reg;

void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, lbl_803CDB70, lbl_803CDB74);
}
*reg -= seconds;

void zLightEffectStrobeSlow()
{
}
if (*reg <= 0.0f)
{
*reg = (rnd * leGetRandom());
*reg += min;

void zLightEffectStrobe()
{
}
l->color.r = zlight->tasset->lightColor[0] - (leGetRandom() * 0.2f + 0.1f);
l->color.g = zlight->tasset->lightColor[1] - (leGetRandom() * 0.2f + 0.1f);
l->color.b = zlight->tasset->lightColor[2] - (leGetRandom() * 0.2f + 0.1f);

void zLightEffectStrobeFast()
{
}
// Clamp light color RGB between 0.0 and 1.0

void zLightEffectDimSlow()
{
}

void zLightEffectDim()
{
}
if (l->color.r > 1.0f)
{
l->color.r = 1.0f;
}
else if (l->color.r < 0.0f)
{
l->color.r = 0.0f;
}

void zLightEffectDimFast()
{
}
if (l->color.g > 1.0f)
{
l->color.g = 1.0f;
}
else if (l->color.g < 0.0f)
{
l->color.g = 0.0f;
}

void zLightEffectHalfDimSlow()
{
}
if (l->color.b > 1.0f)
{
l->color.b = 1.0f;
}
else if (l->color.b < 0.0f)
{
l->color.b = 0.0f;
}

void zLightEffectHalfDim()
{
iLightSetColor(l, &l->color);
}
}

void zLightEffectHalfDimFast()
void zLightEffectFlicker(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, 0.05f, 0.2f);
}

void zLightEffectRandomColSlow()
void zLightEffectFlickerSlow(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, 0.2f, 0.3f);
}

void zLightEffectRandomCol()
void zLightEffectFlickerErratic(_zLight* zlight, F32 seconds)
{
EffectFlicker(zlight, seconds, 0.0f, 0.1f);
}

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)
{
}

void zLightEffectInitCauldron(_zLight* zlight)
{
*zlight->reg = lbl_803CDB70;
*zlight->reg = 0.0f;
zLightOn(zlight, true);
}

#if 0
// Need to figure out proper conditional checks.
F32 leBlendToCol(F32 f1, F32 f2, F32 f3)
{
if (f1 > f2)
{
f1 -= f3;
return f1 >= f2 ? f1 : f2;
return (f1 < f2) ? f2 : f1;
}
else if (f1 < f2)
{
f1 += f3;
return (f1 > f2) ? f2 : f1;
}
if (f1 >= f2)
else
{
return f1;
}
f1 += f3;
return f1 <= f2 ? f1 : f2;
}

#endif

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

#endif
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);
}

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);
}
17 changes: 3 additions & 14 deletions src/SB/Game/zLightEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,13 @@ void zLightEffectInitDim(_zLight* zlight);
void zLightEffectInitHalfDim(_zLight* zlight);
void zLightEffectInitRandomCol(_zLight* zlight);
void zLightEffectInitFlicker(_zLight* zlight);
void EffectFlicker(_zLight* zlight, F32 seconds, F32 min, F32 rnd);
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

0 comments on commit a9b1f04

Please sign in to comment.