port: fix hitscans and other uses of Gtri
This commit is contained in:
parent
c2d1d9b4bf
commit
a9b772ef99
|
|
@ -1029,10 +1029,21 @@ typedef union {
|
|||
* Triangle face
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef PLATFORM_BIG_ENDIAN
|
||||
unsigned char flag;
|
||||
unsigned char v[3];
|
||||
#else
|
||||
unsigned char v[3]; // reverse order
|
||||
unsigned char flag;
|
||||
#endif
|
||||
} Tri;
|
||||
|
||||
#ifdef PLATFORM_BIG_ENDIAN
|
||||
#define GFX_TRI_VTX(i) (i)
|
||||
#else
|
||||
#define GFX_TRI_VTX(i) (2 - i)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 4x4 matrix, fixed point s15.16 format.
|
||||
* First 8 words are integer portion of the 4x4 matrix
|
||||
|
|
@ -1308,12 +1319,18 @@ typedef struct {
|
|||
* Graphics Immediate Mode Packet types
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef PLATFORM_BIG_ENDIAN
|
||||
int cmd:8;
|
||||
int pad:24;
|
||||
#else
|
||||
int pad:24;
|
||||
int cmd:8;
|
||||
#endif
|
||||
Tri tri;
|
||||
} Gtri;
|
||||
|
||||
typedef struct {
|
||||
#ifdef PLATFORM_BIG_ENDIAN
|
||||
unsigned char cmd:8;
|
||||
unsigned char pad:8;
|
||||
unsigned char z4:4;
|
||||
|
|
@ -1328,6 +1345,22 @@ typedef struct {
|
|||
unsigned char x2:4;
|
||||
unsigned char y1:4;
|
||||
unsigned char x1:4;
|
||||
#else
|
||||
unsigned char z1:4;
|
||||
unsigned char z2:4;
|
||||
unsigned char z3:4;
|
||||
unsigned char z4:4;
|
||||
unsigned char pad:8;
|
||||
unsigned char cmd:8;
|
||||
unsigned char x1:4;
|
||||
unsigned char y1:4;
|
||||
unsigned char x2:4;
|
||||
unsigned char y2:4;
|
||||
unsigned char x3:4;
|
||||
unsigned char y3:4;
|
||||
unsigned char x4:4;
|
||||
unsigned char y4:4;
|
||||
#endif
|
||||
} Gtri4;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -725,9 +725,9 @@ Gfx *bgRenderGdlInXray(Gfx *gdl, s8 *readgdl, Vtx *vertices, s16 arg3[3])
|
|||
}
|
||||
} else if (readgdl[0] == G_TRI1) {
|
||||
Gfx *cmd = (Gfx *) readgdl;
|
||||
s16 x = cmd->tri.tri.v[0] / 10;
|
||||
s16 y = cmd->tri.tri.v[1] / 10;
|
||||
s16 z = cmd->tri.tri.v[2] / 10;
|
||||
s16 x = cmd->tri.tri.v[GFX_TRI_VTX(0)] / 10;
|
||||
s16 y = cmd->tri.tri.v[GFX_TRI_VTX(1)] / 10;
|
||||
s16 z = cmd->tri.tri.v[GFX_TRI_VTX(2)] / 10;
|
||||
|
||||
gdl = bgProcessXrayTri(gdl, &xraydata, dmemvertices[x], dmemvertices[y], dmemvertices[z], dmemcolours[x], dmemcolours[y], dmemcolours[z], inrange[x], inrange[y], inrange[z]);
|
||||
} else if (readgdl[0] == G_TRI4) {
|
||||
|
|
@ -3714,9 +3714,9 @@ bool bgTestHitOnObj(struct coord *arg0, struct coord *arg1, struct coord *arg2,
|
|||
if (gdl->dma.cmd == G_TRI1) {
|
||||
trisremaining = 0;
|
||||
triref = 0;
|
||||
points[0] = gdl->tri.tri.v[0] / 10;
|
||||
points[1] = gdl->tri.tri.v[1] / 10;
|
||||
points[2] = gdl->tri.tri.v[2] / 10;
|
||||
points[0] = gdl->tri.tri.v[GFX_TRI_VTX(0)] / 10;
|
||||
points[1] = gdl->tri.tri.v[GFX_TRI_VTX(1)] / 10;
|
||||
points[2] = gdl->tri.tri.v[GFX_TRI_VTX(2)] / 10;
|
||||
} else if (gdl->dma.cmd == G_TRI4) {
|
||||
tri4gdl = gdl;
|
||||
trisremaining = 3;
|
||||
|
|
@ -4001,9 +4001,9 @@ bool bgTestHitOnChr(struct model *model, struct coord *arg1, struct coord *arg2,
|
|||
if (gdl->dma.cmd == G_TRI1) {
|
||||
i = 0;
|
||||
triref = 0;
|
||||
points[0] = gdl->tri.tri.v[0] / 10;
|
||||
points[1] = gdl->tri.tri.v[1] / 10;
|
||||
points[2] = gdl->tri.tri.v[2] / 10;
|
||||
points[0] = gdl->tri.tri.v[GFX_TRI_VTX(0)] / 10;
|
||||
points[1] = gdl->tri.tri.v[GFX_TRI_VTX(1)] / 10;
|
||||
points[2] = gdl->tri.tri.v[GFX_TRI_VTX(2)] / 10;
|
||||
} else if (gdl->dma.cmd == G_TRI4) {
|
||||
tri4gdl = gdl;
|
||||
i = 3;
|
||||
|
|
@ -4199,9 +4199,9 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a
|
|||
if (iter->dma.cmd == G_TRI1) {
|
||||
trisremaining = 0;
|
||||
triref = 0;
|
||||
points[0] = iter->tri.tri.v[0] / 10;
|
||||
points[1] = iter->tri.tri.v[1] / 10;
|
||||
points[2] = iter->tri.tri.v[2] / 10;
|
||||
points[0] = iter->tri.tri.v[GFX_TRI_VTX(0)] / 10;
|
||||
points[1] = iter->tri.tri.v[GFX_TRI_VTX(1)] / 10;
|
||||
points[2] = iter->tri.tri.v[GFX_TRI_VTX(2)] / 10;
|
||||
} else if (iter->dma.cmd == G_TRI4) {
|
||||
tri4gdl = iter;
|
||||
trisremaining = 3;
|
||||
|
|
|
|||
|
|
@ -1022,9 +1022,9 @@ s32 texLoadFromGdl(Gfx *arg0, s32 gdlsizeinbytes, Gfx *arg2, struct texpool *poo
|
|||
case (u8) G_TRI1:
|
||||
if (animated) {
|
||||
if (s5->texture.cmd == (u8) G_TRI1) {
|
||||
sp90[s5->tri.tri.v[0] / 10] = 1;
|
||||
sp90[s5->tri.tri.v[1] / 10] = 1;
|
||||
sp90[s5->tri.tri.v[2] / 10] = 1;
|
||||
sp90[s5->tri.tri.v[GFX_TRI_VTX(0)] / 10] = 1;
|
||||
sp90[s5->tri.tri.v[GFX_TRI_VTX(1)] / 10] = 1;
|
||||
sp90[s5->tri.tri.v[GFX_TRI_VTX(2)] / 10] = 1;
|
||||
} else {
|
||||
Gfx *tmp = s5;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue