From fec695b560f4db574c3a4ef8c49ce6e81a4c0cf8 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 3 Apr 2025 17:49:39 -0500 Subject: [PATCH 1/5] zActionLine: Match RenderActionLine function scope --- src/SB/Game/zActionLine.cpp | 2 +- src/SB/Game/zActionLine.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index 2dc163c62..42b67c46f 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -45,7 +45,7 @@ void zActionLineUpdate(F32 seconds) } } -void RenderActionLine(_tagActionLine* l) +static void RenderActionLine(_tagActionLine* l) { static RxObjSpace3DVertex sStripVert[4]; diff --git a/src/SB/Game/zActionLine.h b/src/SB/Game/zActionLine.h index 0818ed48c..39402638f 100644 --- a/src/SB/Game/zActionLine.h +++ b/src/SB/Game/zActionLine.h @@ -13,6 +13,5 @@ struct _tagActionLine void zActionLineInit(); void zActionLineUpdate(F32 seconds); void zActionLineRender(); -void RenderActionLine(_tagActionLine* l); #endif From 0e0453fa7ecf09fe90c2ece12415c0b6f4288665 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 3 Apr 2025 17:49:56 -0500 Subject: [PATCH 2/5] zActionLIne: Match zActionLine data scope --- src/SB/Game/zActionLine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index 42b67c46f..75f4a1e5e 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -6,8 +6,8 @@ #include "zActionLine.h" -_tagActionLine* sActionLine[8]; -RwRaster* sActionLineRaster; +static _tagActionLine* sActionLine[8]; +static RwRaster* sActionLineRaster; // Equivalent. Compiler doesn't generate the stwu instruction unless we remove `sActionLineRaster = NULL`, but we need it. void zActionLineInit() From bb86d53c4116174c6bc2c1a5266bd513abc731ec Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 3 Apr 2025 17:50:16 -0500 Subject: [PATCH 3/5] zActionLine: Increase zActionLineInit to 100% match --- src/SB/Game/zActionLine.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index 75f4a1e5e..e87eaee0b 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -9,17 +9,18 @@ static _tagActionLine* sActionLine[8]; static RwRaster* sActionLineRaster; -// Equivalent. Compiler doesn't generate the stwu instruction unless we remove `sActionLineRaster = NULL`, but we need it. void zActionLineInit() { + _tagActionLine** actionLine = sActionLine; + const char* actionLineStr = "ACTIONLINES"; + for (S32 i = 0; i < 8; i++) { - sActionLine[i] = NULL; + actionLine[i] = NULL; } - sActionLineRaster = NULL; - RwTexture* tex = (RwTexture*)xSTFindAsset(xStrHash("ACTIONLINES"), 0); + RwTexture* tex = (RwTexture*)xSTFindAsset(xStrHash(actionLineStr), NULL); if (tex != NULL) { sActionLineRaster = tex->raster; @@ -47,25 +48,15 @@ void zActionLineUpdate(F32 seconds) static void RenderActionLine(_tagActionLine* l) { + RxObjSpace3DVertex* vert; + S32 i; + RwRGBA* _col; static RxObjSpace3DVertex sStripVert[4]; - /* - this loop is hard to understand with ghidra. - The compiler will unroll it, - but the order that it does things in - is very confusing to me. - - This is sort of close, but needs a lot - of work in the loop to make it closer. - - It also may not even be a loop, - but it probably is because S32 i - is defined in the dwarf data - */ - for (S32 i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { - RxObjSpace3DVertex* vert = &sStripVert[i]; - RwRGBA* _col = &vert->c.color; + vert = &sStripVert[i]; + _col = &vert->c.color; vert->objVertex.x = l->pos[i].x; vert->objVertex.y = l->pos[i].y; @@ -80,7 +71,7 @@ static void RenderActionLine(_tagActionLine* l) vert->v = 1.0f; } - if (RwIm3DTransform(sStripVert, 4, NULL, 0x19)) + if (RwIm3DTransform(sStripVert, 4, NULL, 0x19) != NULL) { RwIm3DRenderPrimitive(rwPRIMTYPETRISTRIP); RwIm3DEnd(); From f7e381e5ad7ea7cfc5001a4880670be04cfbd833 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 3 Apr 2025 21:33:20 -0500 Subject: [PATCH 4/5] RenderWare Core: Update member order for _RxObjSpace3DVertex Used as the base struct definition for RxObjSpace3DVertex, RxObjSpace3DLitVertex, and RwIm3DVertex --- include/rwsdk/rwcore.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/rwsdk/rwcore.h b/include/rwsdk/rwcore.h index d372ebee1..c35c9e823 100644 --- a/include/rwsdk/rwcore.h +++ b/include/rwsdk/rwcore.h @@ -11,11 +11,16 @@ union RxColorUnion RwRGBA color; }; +// TODO: Determine whether c should go before or after objNormal +// Context: These headers came from an official header source (unsure of release platform) +// However, currently decomped functions seem to pack the struct +// in this particular way so it's like this for now. +// See: zActionLIne.cpp struct _RxObjSpace3DVertex { RwV3d objVertex; - RxColorUnion c; RwV3d objNormal; + RxColorUnion c; RwReal u; RwReal v; }; From 8b8b6a38ce9d1450919fcae6fdb448c12217b79c Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Thu, 3 Apr 2025 21:34:51 -0500 Subject: [PATCH 5/5] zActionLine: Increase RenderActionLine match to 62% code match --- src/SB/Game/zActionLine.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index e87eaee0b..f58031845 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -48,27 +48,19 @@ void zActionLineUpdate(F32 seconds) static void RenderActionLine(_tagActionLine* l) { - RxObjSpace3DVertex* vert; - S32 i; - RwRGBA* _col; static RxObjSpace3DVertex sStripVert[4]; - for (i = 0; i < 4; i++) + for (S32 i = 0; i < 4; i++) { - vert = &sStripVert[i]; - _col = &vert->c.color; - - vert->objVertex.x = l->pos[i].x; - vert->objVertex.y = l->pos[i].y; - vert->objVertex.z = l->pos[i].z; - - _col->red = 0xff; - _col->blue = 0xff; - _col->green = 0xff; - _col->alpha = 0x80; - - vert->u = 0.0f; - vert->v = 1.0f; + sStripVert[i].objVertex.y = l->pos[i].y; + sStripVert[i].objVertex.z = l->pos[i].z; + sStripVert[i].objVertex.x = l->pos[i].x; + sStripVert[i].u = 0.0f; + sStripVert[i].v = 0.0f; + sStripVert[i].c.color.red = 0xFF; + sStripVert[i].c.color.green = 0xFF; + sStripVert[i].c.color.blue = 0xFF; + sStripVert[i].c.color.alpha = 0x80; } if (RwIm3DTransform(sStripVert, 4, NULL, 0x19) != NULL)