Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/rwsdk/rwcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
53 changes: 18 additions & 35 deletions src/SB/Game/zActionLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/SB/Game/zActionLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ struct _tagActionLine
void zActionLineInit();
void zActionLineUpdate(F32 seconds);
void zActionLineRender();
void RenderActionLine(_tagActionLine* l);

#endif