From ef0b45a19c57e1c1744dd46d46256cb29dd2b826 Mon Sep 17 00:00:00 2001 From: escape209 Date: Thu, 12 Sep 2024 01:02:37 +0100 Subject: [PATCH] zLightning work (#366) * zLightning work * Correct sLightning size * Remove xDebugAddTweak def from header --- src/SB/Game/zLightning.cpp | 90 ++++++++++++++++++++++++++------------ src/SB/Game/zLightning.h | 1 - 2 files changed, 62 insertions(+), 29 deletions(-) diff --git a/src/SB/Game/zLightning.cpp b/src/SB/Game/zLightning.cpp index f4795b05..c0a5f69f 100644 --- a/src/SB/Game/zLightning.cpp +++ b/src/SB/Game/zLightning.cpp @@ -1,49 +1,64 @@ #include "zLightning.h" #include "zGlobals.h" +#include "xDebug.h" + #include #include extern _tagLightningAdd gLightningTweakAddInfo; -extern zLightning sLightning[0x30]; +extern zLightning* sLightning[0x30]; extern RwRaster* sLightningRaster; extern xVec3 sTweakStart; extern xVec3 sTweakEnd; -#if 0 -// WIP. -void lightningTweakChangeType(tweak_info& t) +extern char stringBase0[]; + +void xDebugAddTweak(const char*, F32*, F32, F32, const tweak_callback*, void*, U32) { - xDebugRemoveTweak(WEFEW); - if (gLightningTweakAddInfo.type == 1) - { - xDebugAddTweaK(WEFEWFEF, &gLightningTweakAddInfo.setup_degrees, @668, @669, NULL, NULL, 2); - xDebugAddTweaK(WEFEWFEF, &gLightningTweakAddInfo.move_degrees, @668, @669, NULL, NULL, 2); - } - else if (FFWEFEWF) +} + +void lightningTweakChangeType(const tweak_info& t) +{ + // "Lightning|\x01Type Info" + xDebugRemoveTweak(stringBase0 + 0x18); + + switch (gLightningTweakAddInfo.type) { - // TODO!!! + case 0: + break; + + case 1: + // "Lightning|\x01Type Info|Setup Degrees" + xDebugAddTweak(stringBase0 + 0x2d, &gLightningTweakAddInfo.setup_degrees, -1e9, 1e9, NULL, NULL, 2); + + // "Lightning|\x01Type Info|Move Degrees" + xDebugAddTweak(stringBase0 + 0x50, &gLightningTweakAddInfo.move_degrees, -1e9, 1e9, NULL, NULL, 2); + break; + + case 2: + // "Lightning|\x01Type Info|Normal Offset" + xDebugAddTweak(stringBase0 + 0x72, &gLightningTweakAddInfo.zeus_normal_offset, -100.0, 100.0, NULL, NULL, 2); + + // "Lightning|\x01Type Info|Back Offset" + xDebugAddTweak(stringBase0 + 0x95, &gLightningTweakAddInfo.zeus_back_offset, -100.0, 100.0, NULL, NULL, 2); + + // "Lightning|\x01Type Info|Side Offset" + xDebugAddTweak(stringBase0 + 0xb6, &gLightningTweakAddInfo.zeus_side_offset, 0.0, 100.0, NULL, NULL, 2); + break; } } -#endif - -#if 0 -// Structure is off? -void lightningTweakStart(tweak_info& t) +static void lightningTweakStart(const tweak_info& t) { xVec3 s, e; - xVec3Add(&s, (xVec3*)&globals.player.ent.collModel->Mat->pos, &sTweakStart); - xVec3Add(&e, (xVec3*)&globals.player.ent.collModel->Mat->pos, &sTweakEnd); + xVec3Add(&s, (xVec3*)&globals.player.ent.model->Mat->pos, &sTweakStart); + xVec3Add(&e, (xVec3*)&globals.player.ent.model->Mat->pos, &sTweakEnd); gLightningTweakAddInfo.start = &s; gLightningTweakAddInfo.end = &e; zLightningAdd(&gLightningTweakAddInfo); } -#endif - -#if 0 -// WIP. void zLightningRender() { if (sLightningRaster != NULL) @@ -52,17 +67,15 @@ void zLightningRender() } RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); - for (S32 i = 0; i < 0x30; i++) + for (S32 i = 0; i < (S32)(sizeof(sLightning) / sizeof(zLightning*)); i++) { - if (&sLightning[i] != NULL && sLightning[i].flags & 0x41 == 0x41) + if (sLightning[i] != NULL && (sLightning[i]->flags & 0x41) == 0x41) { - RenderLightning(&sLightning[i]); + RenderLightning(sLightning[i]); } } } -#endif - void zLightningShow(zLightning* l, S32 show) { if (show) @@ -80,6 +93,27 @@ void zLightningKill(zLightning* l) l->flags &= 0xfffffefe; } +static zLightning* FindFreeLightning() +{ + for (int i = 0; i != (sizeof(sLightning) / sizeof(zLightning*)); i++) + { + if (sLightning[i] != NULL) + { + if (!(sLightning[i]->flags & 1)) + { + return sLightning[i]; + } + } + else + { + sLightning[i] = (zLightning*)xMemAlloc(gActiveHeap, 0x234, 0); + return sLightning[i]; + } + } + + return 0; +} + void xDebugAddTweak(const char*, S16*, S16, S16, const tweak_callback*, void*, U32) { } diff --git a/src/SB/Game/zLightning.h b/src/SB/Game/zLightning.h index 1ac428fa..ad8fb7c4 100644 --- a/src/SB/Game/zLightning.h +++ b/src/SB/Game/zLightning.h @@ -91,7 +91,6 @@ struct zLightning void lightningTweakChangeType(tweak_info& t); void lightningTweakStart(tweak_info& t); void zLightningInit(); -zLightning* FindFreeLightning(); zLightning* zLightningAdd(_tagLightningAdd* add); void UpdateLightning(zLightning* l, F32 seconds); void zLightningUpdate(F32 seconds);