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; }; diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index 2dc163c62..f58031845 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -6,20 +6,21 @@ #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() { + _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; @@ -45,42 +46,24 @@ void zActionLineUpdate(F32 seconds) } } -void RenderActionLine(_tagActionLine* l) +static void RenderActionLine(_tagActionLine* l) { 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++) { - RxObjSpace3DVertex* vert = &sStripVert[i]; - RwRGBA* _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)) + if (RwIm3DTransform(sStripVert, 4, NULL, 0x19) != NULL) { RwIm3DRenderPrimitive(rwPRIMTYPETRISTRIP); RwIm3DEnd(); 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