From 83ae92c3b40251f7d27ed7c8b79eedf3346ae7ff Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:03:24 -0800 Subject: [PATCH 1/8] lb: Match lbRefract, lbBgFlash, lbAudio, and lbColl functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match the following functions: - lbRefract_80022560, lbRefract_800225D4, fn_80022608, fn_80021F34 - lbBgFlash_800205F0, fn_8002087C (with improved struct types) - lbColl_80009DD4 (debug quad drawing) - fn_800263B4 (lbaudio_ax memory free) Also updates lbBgFlash_800205F0 signature from void(void) to void(s32) and updates the caller in gm_17C0.c accordingly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/gm/gm_17C0.c | 2 +- src/melee/lb/lbaudio_ax.c | 9 +++-- src/melee/lb/lbaudio_ax.h | 2 +- src/melee/lb/lbbgflash.c | 73 +++++++++++++++++++++++++++----------- src/melee/lb/lbbgflash.h | 8 ++--- src/melee/lb/lbcollision.c | 45 +++++++++++++++++++++++ src/melee/lb/lbrefract.c | 49 ++++++++++++++++++++++++- 7 files changed, 159 insertions(+), 29 deletions(-) diff --git a/src/melee/gm/gm_17C0.c b/src/melee/gm/gm_17C0.c index f2ce7c2a0a..0226b70473 100644 --- a/src/melee/gm/gm_17C0.c +++ b/src/melee/gm/gm_17C0.c @@ -230,7 +230,7 @@ void fn_8017C1A4(HSD_GObj* unused) gm_SetGameSpeed(0.5f); lbBgFlash_80020688(temp_r27); } else if (tmp->x8 == temp_r28) { - lbBgFlash_800205F0(); + lbBgFlash_800205F0(temp_r3); } else if (tmp->x8 >= temp_r29_2) { lbAudioAx_80028B90(); gm_SetGameSpeed(1.0f); diff --git a/src/melee/lb/lbaudio_ax.c b/src/melee/lb/lbaudio_ax.c index 5245c2fb54..9d294131e6 100644 --- a/src/melee/lb/lbaudio_ax.c +++ b/src/melee/lb/lbaudio_ax.c @@ -806,8 +806,13 @@ int fn_800250A0(int arg0, int arg1, int arg2, int arg3) /// #fn_800262A0 -/// #fn_800263B4 - +void fn_800263B4(void* ptr) +{ + if (ptr != NULL) { + void* p = ptr; + HSD_ObjFree(&lbl_80433710, p); + } +} /// #lbAudioAx_800263E8 /// #lbAudioAx_800264E4 diff --git a/src/melee/lb/lbaudio_ax.h b/src/melee/lb/lbaudio_ax.h index 0e4cb2df83..bb001f189e 100644 --- a/src/melee/lb/lbaudio_ax.h +++ b/src/melee/lb/lbaudio_ax.h @@ -77,7 +77,7 @@ /* 025E38 */ bool fn_80025E38(HSD_GObj* gobj); /* 025FAC */ UNK_RET fn_80025FAC(UNK_PARAMS); /* 0262A0 */ UNK_RET fn_800262A0(UNK_PARAMS); -/* 0263B4 */ UNK_RET fn_800263B4(UNK_PARAMS); +/* 0263B4 */ void fn_800263B4(void* ptr); /* 0263E8 */ HSD_GObj* lbAudioAx_800263E8(float, HSD_GObj*, int, int, int, int, int, int, int, int, int); /* 0264E4 */ bool lbAudioAx_800264E4(UNK_T); /* 026510 */ void lbAudioAx_80026510(HSD_GObj*); diff --git a/src/melee/lb/lbbgflash.c b/src/melee/lb/lbbgflash.c index 4d1d557455..60f126e8d8 100644 --- a/src/melee/lb/lbbgflash.c +++ b/src/melee/lb/lbbgflash.c @@ -1,21 +1,34 @@ #include "lbbgflash.h" #include +#include "lb/forward.h" +#include "lb/lb_00F9.h" + +typedef struct BgFlashState { + u8 active : 1; + u8 mode : 7; +} BgFlashState; + +typedef struct BgFlashData { + BgFlashState state; + u8 pad[3]; + int x4; + int x8; + int xC; +} BgFlashData; + +extern BgFlashData lbl_80433658; #include #include +/* 021A10 */ static void lbBgFlash_80021A10(f32 arg8); /* 021C18 */ static void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2); - -typedef struct lbl_80433658_t { - u8 _0 : 1; - u8 field : 7; - u8 bytes[0x47]; -} lbl_80433658_t; +/* 02087C */ void fn_8002087C(int* arg0); extern s32 lbl_804D3840; extern s32 lbl_804D3844; -extern lbl_80433658_t lbl_80433658; +extern s32 lbl_804D3848; /// #fn_8001FC08 @@ -23,7 +36,14 @@ extern lbl_80433658_t lbl_80433658; /// #fn_800204C8 -/// #lbBgFlash_800205F0 +void lbBgFlash_800205F0(s32 arg0) +{ + if (arg0 < 1) { + arg0 = 1; + } + lbBgFlash_800206D4(&lbl_804D3848, &lbl_804D3840, arg0); + lbl_80433658.state.mode = 0; +} void lbBgFlash_8002063C(int count) { @@ -31,15 +51,19 @@ void lbBgFlash_8002063C(int count) count = 1; } lbBgFlash_800206D4(&lbl_804D3844, &lbl_804D3840, count); - lbl_80433658.field = 0; + lbl_80433658.state.mode = 0; } /// #lbBgFlash_80020688 /// #lbBgFlash_800206D4 -/// #fn_8002087C - +void fn_8002087C(int* arg0) +{ + lbl_80433658.state.active = 0; + lbl_80433658.state.mode = 5; + lbl_80433658.xC = *arg0; +} /// #fn_800208B0 /// #lbBgFlash_800208EC @@ -58,7 +82,15 @@ void lbBgFlash_8002063C(int count) f32 lbl_804D63D8; -void lbBgFlash_80021A10(f32 arg8) +typedef struct { + char pad[0x2C]; + void* x2C; +} BgFlashGlobal; + +extern BgFlashGlobal* lbl_804D63E0; +extern struct Fighter_804D653C_t* lbl_804D63DC; + +static void lbBgFlash_80021A10(f32 arg8) { lbl_804D63D8 = arg8; } @@ -67,20 +99,21 @@ void lbBgFlash_80021A10(f32 arg8) /// #fn_80021B04 -void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2) {} +static void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2) {} /// #fn_80021C1C -/// #lbBgFlash_80021C48 +void lbBgFlash_80021C48(u32 arg0, u32 arg1) +{ + ColorOverlay* overlay = (ColorOverlay*)((u8*)lbl_804D63E0->x2C + 4); + lb_800144C8(overlay, lbl_804D63DC, arg0, arg1); +} void fn_80021C80(HSD_GObj* gobj) { - struct { - u8 unk0[4]; - ColorOverlay x4; - }* user_data = gobj->user_data; + u8* user_data = gobj->user_data; - while (lb_80014258(gobj, &user_data->x4, fn_80021C18)) { - lb_80014498(&user_data->x4); + while (lb_80014258(gobj, (ColorOverlay*)(user_data + 4), fn_80021C18)) { + lb_80014498((ColorOverlay*)(user_data + 4)); } } diff --git a/src/melee/lb/lbbgflash.h b/src/melee/lb/lbbgflash.h index 593c6dd4b4..dfc654f26b 100644 --- a/src/melee/lb/lbbgflash.h +++ b/src/melee/lb/lbbgflash.h @@ -9,11 +9,11 @@ /* 01FC08 */ UNK_RET fn_8001FC08(UNK_PARAMS); /* 01FEC4 */ UNK_RET fn_8001FEC4(UNK_PARAMS); /* 0204C8 */ UNK_RET fn_800204C8(UNK_PARAMS); -/* 0205F0 */ void lbBgFlash_800205F0(void); +/* 0205F0 */ void lbBgFlash_800205F0(s32); /* 02063C */ void lbBgFlash_8002063C(int); /* 020688 */ void lbBgFlash_80020688(int); -/* 0206D4 */ void lbBgFlash_800206D4(s32*, s32*, int); -/* 02087C */ UNK_RET fn_8002087C(UNK_PARAMS); +/* 0206D4 */ void lbBgFlash_800206D4(void*, s32*, int); +/* 02087C */ void fn_8002087C(int* arg0); /* 0208B0 */ UNK_RET fn_800208B0(UNK_PARAMS); /* 0208EC */ UNK_RET lbBgFlash_800208EC(UNK_PARAMS); /* 0209F4 */ void lbBgFlash_800209F4(void); @@ -22,7 +22,7 @@ /* 02113C */ UNK_RET fn_8002113C(UNK_PARAMS); /* 021410 */ UNK_RET lbBgFlash_80021410(UNK_PARAMS); /* 0219E4 */ UNK_RET fn_800219E4(UNK_PARAMS); -/* 021A10 */ void lbBgFlash_80021A10(f32); +/* 021A10 is static, declaration in lbbgflash.c */ /* 021A18 */ void lbBgFlash_80021A18(int); /* 021B04 */ UNK_RET fn_80021B04(UNK_PARAMS); /* 021C1C */ UNK_RET fn_80021C1C(UNK_PARAMS); diff --git a/src/melee/lb/lbcollision.c b/src/melee/lb/lbcollision.c index 6252fb9ae0..5738f3dfb7 100644 --- a/src/melee/lb/lbcollision.c +++ b/src/melee/lb/lbcollision.c @@ -2274,6 +2274,51 @@ void lbColl_800096B4(MtxPtr arg0, Vec3 arg1, Vec3 arg2, GXColor* arg3, GXColor* HSD_StateInitTev(); } +void lbColl_80009DD4(Vec3* v0, Vec3* v1, GXColor* clr) +{ + Mtx viewMtx; + float x0, y0, z0, x1, y1; + u8 r, g, b, a; + + HSD_StateInvalidate(-1); + HSD_StateInitTev(); + lbColl_80008DA4(clr, clr); + HSD_ClearVtxDesc(); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetCurrentMtx(0); + GXSetCullMode(GX_CULL_NONE); + HSD_CObjGetViewingMtx(HSD_CObjGetCurrent(), viewMtx); + GXLoadPosMtxImm(viewMtx, 0); + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + z0 = v0->z; + y0 = v0->y; + x0 = v0->x; + GXPosition3f32(x0, y0, z0); + a = clr->a; + b = clr->b; + g = clr->g; + r = clr->r; + GXColor4u8(r, g, b, a); + + x1 = v1->x; + GXPosition3f32(x1, y0, z0); + GXColor4u8(r, g, b, a); + + y1 = v1->y; + GXPosition3f32(x1, y1, z0); + GXColor4u8(r, g, b, a); + + GXPosition3f32(x0, y1, z0); + GXColor4u8(r, g, b, a); + + HSD_StateInvalidate(-1); + HSD_StateInitTev(); +} + extern GXColor lbColl_804D36A0; extern GXColor lbColl_804D36A4; extern GXColor lbColl_804D36A8; diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index 5f29de54f3..b2392da629 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -5,13 +5,20 @@ #include #include #include +#include +#include #include -/* 021F34 */ static UNK_RET fn_80021F34(UNK_PARAMS); +extern HSD_DObjInfo hsdDObj; + +/* 021F34 */ static void fn_80021F34(lbRefract_CallbackData* arg0, s32 arg1, + u32 arg2, u32 arg3, u8 arg4, u8 arg5, + u8 arg6); /* 021F70 */ static UNK_RET fn_80021F70(UNK_PARAMS); /* 021FB4 */ static UNK_RET fn_80021FB4(UNK_PARAMS); /* 021FF8 */ static UNK_RET fn_80021FF8(UNK_PARAMS); /* 02206C */ static UNK_RET fn_8002206C(UNK_PARAMS); +/* 022608 */ static void fn_80022608(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode); /* 022120 */ static void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, u32* arg3, u32* arg4, u8* arg5, u8* arg6); @@ -32,6 +39,21 @@ extern float MSL_TrigF_80400770[], MSL_TrigF_80400774[]; #define NAN MSL_TrigF_80400770[0] #define INF MSL_TrigF_80400774[0] +static void fn_80021F34(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, + u32 arg3, u8 arg4, u8 arg5, u8 arg6) +{ + s32 t0, t1, t2; + u8* ptr; + + t0 = arg0->unk4; + t1 = arg2 >> 2; + t2 = arg0->unk0; + ptr = (u8*)(t2 + t1 * t0 + ((arg1 << 3) & 0xFFFFFFE0)); + t0 = ((arg1 & 3) + ((arg2 << 2) & 0xC)) << 1; + ptr[t0] = arg6; + ptr[t0 + 1] = arg5; +} + void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, u32* arg3, u32* arg4, u8* arg5, u8* arg6) { @@ -87,6 +109,31 @@ s32 lbRefract_8002219C(lbRefract_CallbackData* arg0, s32 arg1, s32 arg2, } } +void lbRefract_80022560(void) +{ + if (lbl_804336D0[0] != 0) { + GXSetTexCopySrc(0, 0, 0x280, 0x1E0); + GXSetTexCopyDst(0x140, 0xF0, 4, 1); + GXCopyTex((void*)lbl_804336D0[1], 0); + GXPixModeSync(); + GXInvalidateTexAll(); + } +} + +void lbRefract_800225D4(void) +{ + GXSetTevDirect(0); + GXSetNumIndStages(0); + HSD_StateInvalidate(-1); +} + +void fn_80022608(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode) +{ + hsdDObj.disp(dobj, vmtx, pmtx, rendermode); + GXSetTevDirect(0); + GXSetNumIndStages(0); + HSD_StateInvalidate(-1); +} void lbRefract_80022BB8(void) { lbl_804336D0[0] += 1; From ea205b3ec3e7d9e1e6fa4b590125b4e1acf366a3 Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:36:59 -0800 Subject: [PATCH 2/8] docs(lb): document fn_ functions with descriptive names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - lbRefract: fn_80021F34 → lbRefract_WriteTexCoordIA4 - lbRefract: fn_80022608 → lbRefract_DObjDispReset - lbBgFlash: fn_8002087C → lbBgFlash_InitState - lbAudioAx: fn_800263B4 → lbAudioAx_ObjFree Added @brief documentation and improved parameter names. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/lb/lbaudio_ax.c | 7 ++++--- src/melee/lb/lbaudio_ax.h | 3 ++- src/melee/lb/lbbgflash.c | 7 ++++--- src/melee/lb/lbbgflash.h | 3 ++- src/melee/lb/lbrefract.c | 20 ++++++++++++-------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/melee/lb/lbaudio_ax.c b/src/melee/lb/lbaudio_ax.c index 9d294131e6..19fad9f099 100644 --- a/src/melee/lb/lbaudio_ax.c +++ b/src/melee/lb/lbaudio_ax.c @@ -806,10 +806,11 @@ int fn_800250A0(int arg0, int arg1, int arg2, int arg3) /// #fn_800262A0 -void fn_800263B4(void* ptr) +/// @brief Free an object from the audio allocator pool. +void lbAudioAx_ObjFree(void* obj) { - if (ptr != NULL) { - void* p = ptr; + if (obj != NULL) { + void* p = obj; HSD_ObjFree(&lbl_80433710, p); } } diff --git a/src/melee/lb/lbaudio_ax.h b/src/melee/lb/lbaudio_ax.h index bb001f189e..a3e01e2555 100644 --- a/src/melee/lb/lbaudio_ax.h +++ b/src/melee/lb/lbaudio_ax.h @@ -77,7 +77,8 @@ /* 025E38 */ bool fn_80025E38(HSD_GObj* gobj); /* 025FAC */ UNK_RET fn_80025FAC(UNK_PARAMS); /* 0262A0 */ UNK_RET fn_800262A0(UNK_PARAMS); -/* 0263B4 */ void fn_800263B4(void* ptr); +/// @brief Free an object from the audio allocator pool. +/* 0263B4 */ void lbAudioAx_ObjFree(void* obj); /* 0263E8 */ HSD_GObj* lbAudioAx_800263E8(float, HSD_GObj*, int, int, int, int, int, int, int, int, int); /* 0264E4 */ bool lbAudioAx_800264E4(UNK_T); /* 026510 */ void lbAudioAx_80026510(HSD_GObj*); diff --git a/src/melee/lb/lbbgflash.c b/src/melee/lb/lbbgflash.c index 60f126e8d8..193b659ff1 100644 --- a/src/melee/lb/lbbgflash.c +++ b/src/melee/lb/lbbgflash.c @@ -24,7 +24,8 @@ extern BgFlashData lbl_80433658; /* 021A10 */ static void lbBgFlash_80021A10(f32 arg8); /* 021C18 */ static void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2); -/* 02087C */ void fn_8002087C(int* arg0); +/// @brief Initialize background flash state for mode 5. +/* 02087C */ void lbBgFlash_InitState(int* duration); extern s32 lbl_804D3840; extern s32 lbl_804D3844; @@ -58,11 +59,11 @@ void lbBgFlash_8002063C(int count) /// #lbBgFlash_800206D4 -void fn_8002087C(int* arg0) +void lbBgFlash_InitState(int* duration) { lbl_80433658.state.active = 0; lbl_80433658.state.mode = 5; - lbl_80433658.xC = *arg0; + lbl_80433658.xC = *duration; } /// #fn_800208B0 diff --git a/src/melee/lb/lbbgflash.h b/src/melee/lb/lbbgflash.h index dfc654f26b..bc4f88308c 100644 --- a/src/melee/lb/lbbgflash.h +++ b/src/melee/lb/lbbgflash.h @@ -13,7 +13,8 @@ /* 02063C */ void lbBgFlash_8002063C(int); /* 020688 */ void lbBgFlash_80020688(int); /* 0206D4 */ void lbBgFlash_800206D4(void*, s32*, int); -/* 02087C */ void fn_8002087C(int* arg0); +/// @brief Initialize background flash state for mode 5. +/* 02087C */ void lbBgFlash_InitState(int* duration); /* 0208B0 */ UNK_RET fn_800208B0(UNK_PARAMS); /* 0208EC */ UNK_RET lbBgFlash_800208EC(UNK_PARAMS); /* 0209F4 */ void lbBgFlash_800209F4(void); diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index b2392da629..40c334981b 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -11,14 +11,16 @@ extern HSD_DObjInfo hsdDObj; -/* 021F34 */ static void fn_80021F34(lbRefract_CallbackData* arg0, s32 arg1, - u32 arg2, u32 arg3, u8 arg4, u8 arg5, - u8 arg6); +/// @brief Write IA4 texture coordinate to refraction buffer. +/* 021F34 */ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* arg0, + s32 arg1, u32 arg2, u32 arg3, + u8 arg4, u8 arg5, u8 arg6); /* 021F70 */ static UNK_RET fn_80021F70(UNK_PARAMS); /* 021FB4 */ static UNK_RET fn_80021FB4(UNK_PARAMS); /* 021FF8 */ static UNK_RET fn_80021FF8(UNK_PARAMS); /* 02206C */ static UNK_RET fn_8002206C(UNK_PARAMS); -/* 022608 */ static void fn_80022608(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode); +/// @brief Display DObj then reset TEV/indirect stages for refraction cleanup. +/* 022608 */ static void lbRefract_DObjDispReset(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode); /* 022120 */ static void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, u32* arg3, u32* arg4, u8* arg5, u8* arg6); @@ -39,8 +41,9 @@ extern float MSL_TrigF_80400770[], MSL_TrigF_80400774[]; #define NAN MSL_TrigF_80400770[0] #define INF MSL_TrigF_80400774[0] -static void fn_80021F34(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, - u32 arg3, u8 arg4, u8 arg5, u8 arg6) +static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* arg0, s32 arg1, + u32 arg2, u32 arg3, u8 arg4, u8 arg5, + u8 arg6) { s32 t0, t1, t2; u8* ptr; @@ -87,7 +90,7 @@ s32 lbRefract_8002219C(lbRefract_CallbackData* arg0, s32 arg1, s32 arg2, arg0->unk5 = GXGetTexBufferSize(arg3, arg4, arg2, 0U, 0U); switch (arg2) { /* irregular */ case 3: - arg0->callback0 = fn_80021F34; + arg0->callback0 = lbRefract_WriteTexCoordIA4; arg0->callback1 = fn_80021FF8; arg0->unk4 = (arg3 * 8) & 0xFFFFFFE0; block_11: @@ -127,7 +130,8 @@ void lbRefract_800225D4(void) HSD_StateInvalidate(-1); } -void fn_80022608(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode) +static void lbRefract_DObjDispReset(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, + u32 rendermode) { hsdDObj.disp(dobj, vmtx, pmtx, rendermode); GXSetTevDirect(0); From fbd96b72c3d699972a083582fea6c5237f9e757a Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:14:02 -0800 Subject: [PATCH 3/8] docs(lb): improve lbRefract_WriteTexCoordIA4 parameter names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename parameters and locals to describe their purpose: - arg0 → data, arg1 → row, arg2 → col - arg5 → intensity, arg6 → alpha - t0/t1/t2 → tile_offset/tile_col/base_addr - ptr → dst Added @param documentation for each parameter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/lb/lbrefract.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index cb749786d2..a349deff9b 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -12,9 +12,15 @@ extern HSD_DObjInfo hsdDObj; /// @brief Write IA4 texture coordinate to refraction buffer. -/* 021F34 */ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* arg0, - s32 arg1, u32 arg2, u32 arg3, - u8 arg4, u8 arg5, u8 arg6); +/// @param data Refraction callback data containing buffer info. +/// @param row Texture row index. +/// @param col Texture column index. +/// @param intensity Intensity value (0-255). +/// @param alpha Alpha value (0-255). +/* 021F34 */ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, + s32 row, u32 col, u32 arg3, + u8 arg4, u8 intensity, + u8 alpha); /* 021F70 */ static UNK_RET fn_80021F70(UNK_PARAMS); /* 021FB4 */ static UNK_RET fn_80021FB4(UNK_PARAMS); /* 021FF8 */ static UNK_RET fn_80021FF8(UNK_PARAMS); @@ -41,20 +47,20 @@ extern float MSL_TrigF_80400770[], MSL_TrigF_80400774[]; #define NAN MSL_TrigF_80400770[0] #define INF MSL_TrigF_80400774[0] -static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* arg0, s32 arg1, - u32 arg2, u32 arg3, u8 arg4, u8 arg5, - u8 arg6) +static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, + u32 col, u32 arg3, u8 arg4, u8 intensity, + u8 alpha) { - s32 t0, t1, t2; - u8* ptr; - - t0 = arg0->unk4; - t1 = arg2 >> 2; - t2 = arg0->unk0; - ptr = (u8*)(t2 + t1 * t0 + ((arg1 << 3) & 0xFFFFFFE0)); - t0 = ((arg1 & 3) + ((arg2 << 2) & 0xC)) << 1; - ptr[t0] = arg6; - ptr[t0 + 1] = arg5; + s32 tile_offset, tile_col, base_addr; + u8* dst; + + tile_offset = data->unk4; + tile_col = col >> 2; + base_addr = data->unk0; + dst = (u8*) (base_addr + tile_col * tile_offset + ((row << 3) & 0xFFFFFFE0)); + tile_offset = ((row & 3) + ((col << 2) & 0xC)) << 1; + dst[tile_offset] = alpha; + dst[tile_offset + 1] = intensity; } void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, u32* arg3, From ed9a498db7c31ba043b0cb13fdf0abd541ec64ac Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:16:01 -0800 Subject: [PATCH 4/8] docs(lb): document lbRefract_CallbackData struct fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename struct fields based on usage analysis: - unk0 → buffer (base address of texture buffer) - unk1 → format (3=IA4, 4=IA8, 6=RGBA8) - unk2 → width, unk3 → height - unk4 → row_stride (bytes per row, 32/64-byte aligned) - unk5 → buffer_size Also improve lbRefract_8002219C parameter names and add documentation for the init function. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/lb/lbrefract.c | 98 ++++++++++++++++++++++------------------ src/melee/lb/types.h | 16 +++---- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index a349deff9b..89bc69c030 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -27,12 +27,13 @@ extern HSD_DObjInfo hsdDObj; /* 02206C */ static UNK_RET fn_8002206C(UNK_PARAMS); /// @brief Display DObj then reset TEV/indirect stages for refraction cleanup. /* 022608 */ static void lbRefract_DObjDispReset(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode); -/* 022120 */ static void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, - u32 arg2, u32* arg3, u32* arg4, u8* arg5, - u8* arg6); +/* 022120 */ static void fn_80022120(lbRefract_CallbackData* data, s32 row, + u32 col, u32* out_r, u32* out_g, u8* out_b, + u8* out_a); /* 022DF8 */ static inline float lbRefract_80022DF8(float x); -/* 02219C */ s32 lbRefract_8002219C(lbRefract_CallbackData*, s32, s32, u16, - u16); +/// @brief Initialize refraction callback data for a texture buffer. +/* 02219C */ s32 lbRefract_8002219C(lbRefract_CallbackData* data, s32 buffer, + s32 format, u16 width, u16 height); static int lbl_804336D0[0x10]; @@ -51,65 +52,72 @@ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, u32 col, u32 arg3, u8 arg4, u8 intensity, u8 alpha) { - s32 tile_offset, tile_col, base_addr; + s32 offset, tile_col, base_addr; u8* dst; - tile_offset = data->unk4; + offset = data->row_stride; tile_col = col >> 2; - base_addr = data->unk0; - dst = (u8*) (base_addr + tile_col * tile_offset + ((row << 3) & 0xFFFFFFE0)); - tile_offset = ((row & 3) + ((col << 2) & 0xC)) << 1; - dst[tile_offset] = alpha; - dst[tile_offset + 1] = intensity; + base_addr = data->buffer; + dst = (u8*) (base_addr + tile_col * offset + ((row << 3) & 0xFFFFFFE0)); + offset = ((row & 3) + ((col << 2) & 0xC)) << 1; + dst[offset] = alpha; + dst[offset + 1] = intensity; } -void fn_80022120(lbRefract_CallbackData* arg0, s32 arg1, u32 arg2, u32* arg3, - u32* arg4, u8* arg5, u8* arg6) +void fn_80022120(lbRefract_CallbackData* data, s32 row, u32 col, u32* out_r, + u32* out_g, u8* out_b, u8* out_a) { - s32 temp_r10; - s32 temp_r4; - - temp_r10 = arg0->unk0 + - (((arg2 >> 2U) * arg0->unk4) + ((arg1 * 0x10) & 0xFFFFFFC0)); - temp_r4 = ((arg1 & 3) + ((arg2 * 4) & 0xC)) * 2; - if (arg6 != NULL) { - *arg6 = temp_r10 + temp_r4; + s32 base_offset; + s32 pixel_offset; + + base_offset = data->buffer + + (((col >> 2U) * data->row_stride) + ((row * 0x10) & 0xFFFFFFC0)); + pixel_offset = ((row & 3) + ((col * 4) & 0xC)) * 2; + if (out_a != NULL) { + *out_a = base_offset + pixel_offset; } - if (arg3 != NULL) { - *arg3 = temp_r10 + temp_r4 + 0x01; + if (out_r != NULL) { + *out_r = base_offset + pixel_offset + 0x01; } - if (arg4 != NULL) { - *arg4 = temp_r10 + temp_r4 + 0x20; + if (out_g != NULL) { + *out_g = base_offset + pixel_offset + 0x20; } - if (arg5 != NULL) { - *arg5 = (s32) (temp_r10 + temp_r4 + 0x21); + if (out_b != NULL) { + *out_b = (s32) (base_offset + pixel_offset + 0x21); } } -s32 lbRefract_8002219C(lbRefract_CallbackData* arg0, s32 arg1, s32 arg2, - u16 arg3, u16 arg4) +/// @brief Initialize refraction callback data for a texture buffer. +/// @param data Callback data to initialize. +/// @param buffer Base address of texture buffer. +/// @param format Texture format (3=IA4, 4=IA8, 6=RGBA8). +/// @param width Texture width in pixels. +/// @param height Texture height in pixels. +/// @return 0 on success, -1 if format is unsupported. +s32 lbRefract_8002219C(lbRefract_CallbackData* data, s32 buffer, s32 format, + u16 width, u16 height) { - arg0->unk0 = arg1; - arg0->unk1 = arg2; - arg0->unk2 = (s32) arg3; - arg0->unk3 = (s32) arg4; - arg0->unk5 = GXGetTexBufferSize(arg3, arg4, arg2, 0U, 0U); - switch (arg2) { /* irregular */ + data->buffer = buffer; + data->format = format; + data->width = (s32) width; + data->height = (s32) height; + data->buffer_size = GXGetTexBufferSize(width, height, format, 0U, 0U); + switch (format) { /* irregular */ case 3: - arg0->callback0 = lbRefract_WriteTexCoordIA4; - arg0->callback1 = fn_80021FF8; - arg0->unk4 = (arg3 * 8) & 0xFFFFFFE0; + data->callback0 = lbRefract_WriteTexCoordIA4; + data->callback1 = fn_80021FF8; + data->row_stride = (width * 8) & 0xFFFFFFE0; block_11: return 0; case 4: - arg0->callback0 = fn_80021F70; - arg0->callback1 = fn_8002206C; - arg0->unk4 = (arg3 * 8) & 0xFFFFFFE0; + data->callback0 = fn_80021F70; + data->callback1 = fn_8002206C; + data->row_stride = (width * 8) & 0xFFFFFFE0; goto block_11; case 6: - arg0->callback0 = fn_80021FB4; - arg0->callback1 = fn_80022120; - arg0->unk4 = (arg3 * 0x10) & 0xFFFFFFC0; + data->callback0 = fn_80021FB4; + data->callback1 = fn_80022120; + data->row_stride = (width * 0x10) & 0xFFFFFFC0; goto block_11; case 5: /* fallthrough */ diff --git a/src/melee/lb/types.h b/src/melee/lb/types.h index e26f2508f3..d8eb1eb6ab 100644 --- a/src/melee/lb/types.h +++ b/src/melee/lb/types.h @@ -141,14 +141,14 @@ struct ShieldDesc { }; struct lbRefract_CallbackData { - s32 unk0; // x00 - s32 unk1; // x04 - s32 unk2; // x08 - s32 unk3; // x08 - s32 unk4; // x10 - s32 unk5; // x14 - void* callback0; // x1C - void* callback1; // x20 + s32 buffer; /// @brief Base address of texture buffer. + s32 format; /// @brief Texture format (3=IA4, 4=IA8, 6=RGBA8). + s32 width; /// @brief Texture width in pixels. + s32 height; /// @brief Texture height in pixels. + s32 row_stride; /// @brief Bytes per row (32/64-byte aligned). + s32 buffer_size; /// @brief Total buffer size from GXGetTexBufferSize. + void* callback0; /// @brief Write callback function. + void* callback1; /// @brief Read callback function. }; typedef struct _ECBFlagStruct { From a13ebe96d7a946384e9c17040bddccfe7a12ec62 Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 14:17:14 -0800 Subject: [PATCH 5/8] docs(lb): add documentation to lbRefract and lbBgFlash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add file-level documentation for lbrefract.c/h and lbbgflash.c/h - Rename fn_80022120 to lbRefract_ReadTexCoordRGBA8 - Add @brief comments to matched functions - Rename arg0 to duration in lbBgFlash_800205F0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/lb/lbbgflash.c | 22 +++++++++++++++++----- src/melee/lb/lbbgflash.h | 13 ++++++++++--- src/melee/lb/lbrefract.c | 36 +++++++++++++++++++++++------------- src/melee/lb/lbrefract.h | 9 +++++++++ 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/src/melee/lb/lbbgflash.c b/src/melee/lb/lbbgflash.c index 7b83055ad0..b164089c83 100644 --- a/src/melee/lb/lbbgflash.c +++ b/src/melee/lb/lbbgflash.c @@ -1,3 +1,11 @@ +/** + * @file lbbgflash.c + * @brief Background flash effects for dramatic game events. + * + * Provides full-screen color overlay flashes triggered by various game events. + * Called from game mode code (gmallstar.c, gm_17C0.c, gm_1A4C.c, etc). + */ + #include "lbbgflash.h" #include @@ -24,7 +32,7 @@ extern BgFlashData lbl_80433658; /* 021A10 */ static void lbBgFlash_80021A10(f32 arg8); /* 021C18 */ static void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2); -/// @brief Initialize background flash state for mode 5. +/// @brief Initialize background flash state. /* 02087C */ void lbBgFlash_InitState(int* duration); extern s32 lbl_804D3840; @@ -37,15 +45,19 @@ extern s32 lbl_804D3848; /// #fn_800204C8 -void lbBgFlash_800205F0(s32 arg0) +/// @brief Trigger background flash. +/// @param duration Flash duration in frames (minimum 1). +void lbBgFlash_800205F0(s32 duration) { - if (arg0 < 1) { - arg0 = 1; + if (duration < 1) { + duration = 1; } - lbBgFlash_800206D4(&lbl_804D3848, &lbl_804D3840, arg0); + lbBgFlash_800206D4(&lbl_804D3848, &lbl_804D3840, duration); lbl_80433658.state.mode = 0; } +/// @brief Trigger background flash. +/// @param count Flash duration in frames (minimum 1). void lbBgFlash_8002063C(int count) { if (count < 1) { diff --git a/src/melee/lb/lbbgflash.h b/src/melee/lb/lbbgflash.h index bc4f88308c..9ad3be9171 100644 --- a/src/melee/lb/lbbgflash.h +++ b/src/melee/lb/lbbgflash.h @@ -1,3 +1,8 @@ +/** + * @file lbbgflash.h + * @brief Background flash effects for dramatic game events. + */ + #ifndef GALE01_01FC08 #define GALE01_01FC08 @@ -9,11 +14,13 @@ /* 01FC08 */ UNK_RET fn_8001FC08(UNK_PARAMS); /* 01FEC4 */ UNK_RET fn_8001FEC4(UNK_PARAMS); /* 0204C8 */ UNK_RET fn_800204C8(UNK_PARAMS); -/* 0205F0 */ void lbBgFlash_800205F0(s32); -/* 02063C */ void lbBgFlash_8002063C(int); +/// @brief Trigger background flash. +/* 0205F0 */ void lbBgFlash_800205F0(s32 duration); +/// @brief Trigger background flash. +/* 02063C */ void lbBgFlash_8002063C(int count); /* 020688 */ void lbBgFlash_80020688(int); /* 0206D4 */ void lbBgFlash_800206D4(void*, s32*, int); -/// @brief Initialize background flash state for mode 5. +/// @brief Initialize background flash state. /* 02087C */ void lbBgFlash_InitState(int* duration); /* 0208B0 */ UNK_RET fn_800208B0(UNK_PARAMS); /* 0208EC */ UNK_RET lbBgFlash_800208EC(UNK_PARAMS); diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index 89bc69c030..e3d76bfa4b 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -1,3 +1,11 @@ +/** + * @file lbrefract.c + * @brief Refraction visual effects using GX indirect textures. + * + * Uses reference counting to track active effect users. + * Supports IA4, IA8, and RGBA8 texture formats. + */ + #include "lbrefract.h" #include "lb/types.h" @@ -12,11 +20,6 @@ extern HSD_DObjInfo hsdDObj; /// @brief Write IA4 texture coordinate to refraction buffer. -/// @param data Refraction callback data containing buffer info. -/// @param row Texture row index. -/// @param col Texture column index. -/// @param intensity Intensity value (0-255). -/// @param alpha Alpha value (0-255). /* 021F34 */ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, u32 col, u32 arg3, u8 arg4, u8 intensity, @@ -27,9 +30,11 @@ extern HSD_DObjInfo hsdDObj; /* 02206C */ static UNK_RET fn_8002206C(UNK_PARAMS); /// @brief Display DObj then reset TEV/indirect stages for refraction cleanup. /* 022608 */ static void lbRefract_DObjDispReset(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, u32 rendermode); -/* 022120 */ static void fn_80022120(lbRefract_CallbackData* data, s32 row, - u32 col, u32* out_r, u32* out_g, u8* out_b, - u8* out_a); +/// @brief Read RGBA8 texture coordinate addresses from refraction buffer. +/* 022120 */ static void lbRefract_ReadTexCoordRGBA8(lbRefract_CallbackData* data, + s32 row, u32 col, + u32* out_r, u32* out_g, + u8* out_b, u8* out_a); /* 022DF8 */ static inline float lbRefract_80022DF8(float x); /// @brief Initialize refraction callback data for a texture buffer. /* 02219C */ s32 lbRefract_8002219C(lbRefract_CallbackData* data, s32 buffer, @@ -49,8 +54,8 @@ extern float MSL_TrigF_80400770[], MSL_TrigF_80400774[]; #define INF MSL_TrigF_80400774[0] static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, - u32 col, u32 arg3, u8 arg4, u8 intensity, - u8 alpha) + u32 col, u32 arg3, u8 arg4, + u8 intensity, u8 alpha) { s32 offset, tile_col, base_addr; u8* dst; @@ -64,8 +69,9 @@ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, dst[offset + 1] = intensity; } -void fn_80022120(lbRefract_CallbackData* data, s32 row, u32 col, u32* out_r, - u32* out_g, u8* out_b, u8* out_a) +static void lbRefract_ReadTexCoordRGBA8(lbRefract_CallbackData* data, s32 row, + u32 col, u32* out_r, u32* out_g, + u8* out_b, u8* out_a) { s32 base_offset; s32 pixel_offset; @@ -116,7 +122,7 @@ s32 lbRefract_8002219C(lbRefract_CallbackData* data, s32 buffer, s32 format, goto block_11; case 6: data->callback0 = fn_80021FB4; - data->callback1 = fn_80022120; + data->callback1 = lbRefract_ReadTexCoordRGBA8; data->row_stride = (width * 0x10) & 0xFFFFFFC0; goto block_11; case 5: @@ -126,6 +132,7 @@ s32 lbRefract_8002219C(lbRefract_CallbackData* data, s32 buffer, s32 format, } } +/// @brief Copy framebuffer to refraction source texture. void lbRefract_80022560(void) { if (lbl_804336D0[0] != 0) { @@ -137,6 +144,7 @@ void lbRefract_80022560(void) } } +/// @brief Reset TEV and indirect texture stages. void lbRefract_800225D4(void) { GXSetTevDirect(0); @@ -153,11 +161,13 @@ static void lbRefract_DObjDispReset(HSD_DObj* dobj, Mtx vmtx, Mtx pmtx, HSD_StateInvalidate(-1); } +/// @brief Increment refraction effect user count. void lbRefract_80022BB8(void) { lbl_804336D0[0] += 1; } +/// @brief Decrement refraction effect user count. void lbRefract_80022BD0(void) { lbl_804336D0[0] -= 1; diff --git a/src/melee/lb/lbrefract.h b/src/melee/lb/lbrefract.h index 5bab330e6e..6c0eac7bbe 100644 --- a/src/melee/lb/lbrefract.h +++ b/src/melee/lb/lbrefract.h @@ -1,3 +1,8 @@ +/** + * @file lbrefract.h + * @brief Refraction visual effects using GX indirect textures. + */ + #ifndef GALE01_021CE8 #define GALE01_021CE8 @@ -7,11 +12,15 @@ void lbRefract_800222A4(void); void lbRefract_8002247C(HSD_CObj*); +/// @brief Copy framebuffer to refraction source texture. void lbRefract_80022560(void); +/// @brief Reset TEV and indirect texture stages. void lbRefract_800225D4(void); s32 lbRefract_PObjLoad(HSD_PObj* pobj, HSD_PObjDesc* desc); void lbRefract_80022998(HSD_MObj*, u32 rendermode, s8); +/// @brief Increment refraction effect user count. void lbRefract_80022BB8(void); +/// @brief Decrement refraction effect user count. void lbRefract_80022BD0(void); float atan2f(float y, float x); float acosf(float); From c3ce5fa4b77ea1009e6ff488bf39205abfc5ef63 Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Wed, 31 Dec 2025 23:49:06 -0800 Subject: [PATCH 6/8] Fix lbRefract symbol names for decompiled functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update symbols.txt to use proper function names: - fn_80021F34 -> lbRefract_WriteTexCoordIA4 (81.3% match) - fn_80022608 -> lbRefract_DObjDispReset (100% match) These functions were decompiled but the symbol names weren't updated, causing them to appear as unlinked in the report. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- config/GALE01/symbols.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/GALE01/symbols.txt b/config/GALE01/symbols.txt index 1799681f89..1bad34424e 100644 --- a/config/GALE01/symbols.txt +++ b/config/GALE01/symbols.txt @@ -533,7 +533,7 @@ fn_80021C1C = .text:0x80021C1C; // type:function size:0x2C lbBgFlash_80021C48 = .text:0x80021C48; // type:function size:0x38 scope:global fn_80021C80 = .text:0x80021C80; // type:function size:0x68 lbRefract_80021CE8 = .text:0x80021CE8; // type:function size:0x24C scope:global -fn_80021F34 = .text:0x80021F34; // type:function size:0x3C +lbRefract_WriteTexCoordIA4 = .text:0x80021F34; // type:function size:0x3C scope:local fn_80021F70 = .text:0x80021F70; // type:function size:0x44 fn_80021FB4 = .text:0x80021FB4; // type:function size:0x44 fn_80021FF8 = .text:0x80021FF8; // type:function size:0x74 @@ -544,7 +544,7 @@ lbRefract_800222A4 = .text:0x800222A4; // type:function size:0x1D8 scope:global lbRefract_8002247C = .text:0x8002247C; // type:function size:0xE4 scope:global lbRefract_80022560 = .text:0x80022560; // type:function size:0x74 scope:global lbRefract_800225D4 = .text:0x800225D4; // type:function size:0x34 scope:global -fn_80022608 = .text:0x80022608; // type:function size:0x48 +lbRefract_DObjDispReset = .text:0x80022608; // type:function size:0x48 scope:local fn_80022650 = .text:0x80022650; // type:function size:0x58 lbRefract_PObjLoad = .text:0x800226A8; // type:function size:0x298 scope:global fn_80022940 = .text:0x80022940; // type:function size:0x58 From 82c7ce0e2d35c98488d0b2b115d60f2ca5a7eced Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Thu, 1 Jan 2026 17:28:53 -0800 Subject: [PATCH 7/8] fix(lb): update symbols.txt for lbRefract_ReadTexCoordRGBA8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function was renamed in the source but the symbol name wasn't updated, causing a match regression from 62.74% to 0%. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- config/GALE01/symbols.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/GALE01/symbols.txt b/config/GALE01/symbols.txt index 1bad34424e..e1cfc39870 100644 --- a/config/GALE01/symbols.txt +++ b/config/GALE01/symbols.txt @@ -538,7 +538,7 @@ fn_80021F70 = .text:0x80021F70; // type:function size:0x44 fn_80021FB4 = .text:0x80021FB4; // type:function size:0x44 fn_80021FF8 = .text:0x80021FF8; // type:function size:0x74 fn_8002206C = .text:0x8002206C; // type:function size:0xB4 -fn_80022120 = .text:0x80022120; // type:function size:0x7C +lbRefract_ReadTexCoordRGBA8 = .text:0x80022120; // type:function size:0x7C lbRefract_8002219C = .text:0x8002219C; // type:function size:0x108 scope:global lbRefract_800222A4 = .text:0x800222A4; // type:function size:0x1D8 scope:global lbRefract_8002247C = .text:0x8002247C; // type:function size:0xE4 scope:global From 572bbb5e0e7896911c1399c44852e06c16b75c1c Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Sat, 3 Jan 2026 11:37:41 -0800 Subject: [PATCH 8/8] fix(lb): use struct access instead of pointer arithmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review feedback: replace pointer arithmetic with temporary struct access patterns in lbBgFlash_80021C48 and lbRefract_WriteTexCoordIA4. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/lb/lbbgflash.c | 7 +++++-- src/melee/lb/lbrefract.c | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/melee/lb/lbbgflash.c b/src/melee/lb/lbbgflash.c index b164089c83..ea76ee59f8 100644 --- a/src/melee/lb/lbbgflash.c +++ b/src/melee/lb/lbbgflash.c @@ -118,8 +118,11 @@ static void fn_80021C18(HSD_GObj* gobj, CommandInfo* cmd, int arg2) {} void lbBgFlash_80021C48(u32 arg0, u32 arg1) { - ColorOverlay* overlay = (ColorOverlay*)((u8*)lbl_804D63E0->x2C + 4); - lb_800144C8(overlay, lbl_804D63DC, arg0, arg1); + struct { + u8 unk0[4]; + ColorOverlay x4; + }* data = lbl_804D63E0->x2C; + lb_800144C8(&data->x4, lbl_804D63DC, arg0, arg1); } void fn_80021C80(HSD_GObj* gobj) diff --git a/src/melee/lb/lbrefract.c b/src/melee/lb/lbrefract.c index e3d76bfa4b..3bdd5908fa 100644 --- a/src/melee/lb/lbrefract.c +++ b/src/melee/lb/lbrefract.c @@ -57,16 +57,18 @@ static void lbRefract_WriteTexCoordIA4(lbRefract_CallbackData* data, s32 row, u32 col, u32 arg3, u8 arg4, u8 intensity, u8 alpha) { - s32 offset, tile_col, base_addr; - u8* dst; - - offset = data->row_stride; - tile_col = col >> 2; - base_addr = data->buffer; - dst = (u8*) (base_addr + tile_col * offset + ((row << 3) & 0xFFFFFFE0)); - offset = ((row & 3) + ((col << 2) & 0xC)) << 1; - dst[offset] = alpha; - dst[offset + 1] = intensity; + struct { + u8 alpha; + u8 intensity; + }* pixel; + s32 row_stride = data->row_stride; + s32 tile_col = col >> 2; + s32 tile_base = data->buffer + tile_col * row_stride + ((row << 3) & 0xFFFFFFE0); + s32 pixel_offset = ((row & 3) + ((col << 2) & 0xC)) << 1; + + pixel = (void*) (tile_base + pixel_offset); + pixel->alpha = alpha; + pixel->intensity = intensity; } static void lbRefract_ReadTexCoordRGBA8(lbRefract_CallbackData* data, s32 row,