port: halfassed solution for segmented addresses; fix some dyntex related stuff

This commit is contained in:
fgsfds committed 2023-08-08 14:30:59 +02:00
1 parent f9b27d7d01
commit 62f3007d2a
8 files changed
+125 -81

No files matched your search

+18
View File
@@ -1568,12 +1568,21 @@ typedef struct {
} GunkC0;
typedef struct {
#ifdef PLATFORM_BIG_ENDIAN
unsigned int cmd:8;
unsigned int unk08:4;
unsigned int unk0c:4;
unsigned int unk10:16;
unsigned int seg:8;
unsigned int offset:24;
#else
unsigned int unk10:16;
unsigned int unk0c:4;
unsigned int unk08:4;
unsigned int cmd:8;
unsigned int offset:24;
unsigned int seg:8;
#endif
} Gvtx;
/*
@@ -1920,6 +1929,15 @@ typedef union {
#define gsSPSegment(segment, base) \
gsMoveWd(G_MW_SEGMENT, (segment)*4, base)
#ifdef PLATFORM_N64
#define SEGADDR(x) x
#define UNSEGADDR(x) x
#else
// we mark all segmented addresses so that it'll be easier to recognize them later
#define SEGADDR(x) ((void *)((uintptr_t)(x) | 1))
#define UNSEGADDR(x) ((uintptr_t)(x) & ~1)
#endif
/*
* Clipping Macros
*/
+6 -14
View File
@@ -2226,25 +2226,17 @@ static void gfx_dp_set_other_mode(uint32_t h, uint32_t l) {
rdp.other_mode_l = l;
}
// TODO: figure out a proper way to deal with this shit, this won't work
static inline void *seg_addr(uintptr_t w1) {
// any address higher than 0x0fffffff is not segmented
if ((w1 & 0xf0000000) == 0) {
// all segmented addresses have the least significant bit set
if (w1 & 1) {
// seg 0 is reserved and doesn't count here
const uintptr_t seg = (w1 & 0x0f000000) >> 24;
// only segments 2-6 and 13-15 are used in PD
if ((seg >= 2 && seg <= 6) || (seg >= 13)) {
// maybe segmented, check if we have that segment loaded
if (seg && segmentPointers[seg]) {
// we do but we can't really confirm whether or not it is actually segmented
const uintptr_t addr = (w1 & 0x00ffffff);
if (addr > 512 * 1024)
return (void *) w1; // PROBABLY isn't segmented because no seg should be that big
return (void *)(addr + segmentPointers[seg]);
}
if (seg && segmentPointers[seg]) {
const uintptr_t addr = (w1 & 0x00fffffe);
return (void *)(segmentPointers[seg] + addr);
}
}
return (void *) w1;
return (void *)w1;
}
uintptr_t clearMtx;
+26 -12
View File
@@ -157,18 +157,24 @@ static inline void preprocessGfx(Gfx *gdl, u8 *base, uintptr_t ofs)
PD_SWAP_VAL(gdl->words.w1);
if (opcode == (s8)G_ENDDL) {
break;
} else if (opcode == (s8)G_DL) {
/*
if ((gdl->words.w0 >> 16) & ((1U << 1) - 1) == 0) {
if (gdl->words.w1) {
preprocessGfx(PD_PTR_BASEOFS(gdl->words.w1, base, ofs), base, ofs);
}
} else {
gdl = PD_PTR_BASEOFS(gdl->words.w1, base, ofs);
--gdl;
}
*/
}
// mark all addresses in the DL as segmented
switch (opcode) {
case (s8)G_SETTIMG:
case (s8)G_SETCIMG:
case (s8)G_SETZIMG:
case G_MOVEMEM:
case G_MTX:
case G_VTX:
case G_COL:
case G_DL:
gdl->words.w1 |= 1;
break;
default:
break;
}
++gdl;
}
}
@@ -197,10 +203,12 @@ static void preprocessModelGunDL(struct modelrodata_gundl *gundl, u8 *base, u32
if (gundl->opagdl) {
PD_SWAP_PTR(gundl->opagdl);
preprocessGfx(PD_PTR_BASEOFS(gundl->opagdl, base, ofs), base, ofs);
gundl->opagdl = SEGADDR(gundl->opagdl);
}
if (gundl->xlugdl) {
PD_SWAP_PTR(gundl->xlugdl);
preprocessGfx(PD_PTR_BASEOFS(gundl->xlugdl, base, ofs), base, ofs);
gundl->xlugdl = SEGADDR(gundl->xlugdl);
}
}
@@ -222,10 +230,12 @@ static void preprocessModelDL(struct modelrodata_dl *dl, u8 *base, u32 ofs)
if (dl->opagdl) {
PD_SWAP_PTR(dl->opagdl);
preprocessGfx(PD_PTR_BASEOFS(dl->opagdl, base, ofs), base, ofs);
dl->opagdl = SEGADDR(dl->opagdl);
}
if (dl->xlugdl) {
PD_SWAP_PTR(dl->xlugdl);
preprocessGfx(PD_PTR_BASEOFS(dl->xlugdl, base, ofs), base, ofs);
dl->xlugdl = SEGADDR(dl->xlugdl);
}
}
@@ -329,9 +339,13 @@ static void preprocessModelNode(struct modelnode *node, u8 *base, u32 ofs)
break;
case MODELNODETYPE_STARGUNFIRE:
PD_SWAP_VAL(ro->stargunfire.unk00);
PD_SWAP_PTR(ro->stargunfire.gdl);
PD_SWAP_PTR(ro->stargunfire.vertices);
PD_SWAP_PTR(ro->stargunfire.baseaddr);
if (ro->stargunfire.gdl) {
PD_SWAP_PTR(ro->stargunfire.gdl);
preprocessGfx(PD_PTR_BASEOFS(ro->stargunfire.gdl, base, ofs), base, ofs);
ro->stargunfire.gdl = SEGADDR(ro->stargunfire.gdl);
}
break;
case MODELNODETYPE_HEADSPOT:
PD_SWAP_VAL(ro->headspot.rwdataindex);
+8 -8
View File
@@ -710,7 +710,7 @@ Gfx *bgRenderGdlInXray(Gfx *gdl, s8 *readgdl, Vtx *vertices, s16 arg3[3])
Gfx *cmd = (Gfx *) readgdl;
s32 dmemindex = cmd->bytes[GFX_W0_BYTE(1)] & 0xf;
s32 numvertices = ((u32) cmd->bytes[GFX_W0_BYTE(1)] >> 4) + 1;
u32 offset = cmd->words.w1 & 0xffffff;
u32 offset = UNSEGADDR(cmd->words.w1) & 0xffffff;
for (i = 0; i < numvertices; i++) {
Vtx *vtx = (Vtx *) (verticesu8 + offset);
@@ -3300,7 +3300,7 @@ s32 bgPopulateVtxBatchType(s32 roomnum, struct vtxbatch *batches, Gfx *gdl, s32
}
numvertices = (((u32)gdl[i].bytes[GFX_W0_BYTE(1)] >> 4) & 0xf) + 1;
batchvertices = (Vtx *)((uintptr_t)vertices + (gdl[i].words.w1 & 0xffffff));
batchvertices = (Vtx *)((uintptr_t)vertices + (UNSEGADDR(gdl[i].words.w1) & 0xffffff));
for (j = 0; j < numvertices; j++) {
f32 x = batchvertices[j].x;
@@ -3609,7 +3609,7 @@ bool bgTestHitOnObj(struct coord *arg0, struct coord *arg1, struct coord *arg2,
} else if (gdl->dma.cmd == G_VTX) {
ptr = var800a6470;
count = gdl->bytes[GFX_W0_BYTE(1)] & 0xf;
offset = (gdl->words.w1 & 0xffffff);
offset = (UNSEGADDR(gdl->words.w1) & 0xffffff);
numvertices = (((u32) gdl->bytes[GFX_W0_BYTE(1)] >> 4) & 0xf) + 1;
vtx = (Vtx *)((uintptr_t)vertices + offset);
vtx -= count;
@@ -3814,7 +3814,7 @@ bool bgTestHitOnObj(struct coord *arg0, struct coord *arg1, struct coord *arg2,
|| (imggdl->words.w1 & 0x05000000) == 0x05000000) {
texturenum = -1;
} else {
s32 tmp = PHYS_TO_K0(imggdl->words.w1 - 8);
s32 tmp = PHYS_TO_K0(UNSEGADDR(imggdl->words.w1) - 8);
texturenum = *(s16 *) tmp;
}
@@ -3905,12 +3905,12 @@ bool bgTestHitOnChr(struct model *model, struct coord *arg1, struct coord *arg2,
}
break;
} else if (gdl->dma.cmd == G_MTX) {
word = gdl->words.w1 & 0xffffff;
word = UNSEGADDR(gdl->words.w1) & 0xffffff;
i = word / sizeof(Mtxf);
mtx = &model->matrices[i];
} else if (gdl->dma.cmd == G_VTX) {
count = (gdl->bytes[GFX_W0_BYTE(1)] & 0xf);
word = gdl->words.w1 & 0xffffff;
word = UNSEGADDR(gdl->words.w1) & 0xffffff;
numvertices = ((u32) gdl->bytes[GFX_W0_BYTE(1)] >> 4) + 1;
vtx = (Vtx *)((uintptr_t)vertices + word);
@@ -4171,7 +4171,7 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a
vtx = bgFindVerticesForGdl(roomnum, gdl);
iter = &gdl[batch->gbicmdindex];
vtx = (Vtx *)((iter->words.w1 & 0xffffff) + (s32)vtx);
vtx = (Vtx *)((UNSEGADDR(iter->words.w1) & 0xffffff) + (s32)vtx);
numvertices = (((u32) iter->bytes[GFX_W0_BYTE(1)] >> 4) & 0xf) + 1;
ptr = var800a6470;
@@ -4311,7 +4311,7 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a
|| (tmpgdl->words.w1 & 0x05000000) == 0x05000000) {
texturenum = -1;
} else {
s32 tmp = tmpgdl->words.w1 - 8;
s32 tmp = UNSEGADDR(tmpgdl->words.w1) - 8;
texturenum = *(s16 *) PHYS_TO_K0(tmp);
}
+48 -28
View File
@@ -3731,13 +3731,13 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
// use the space... after the model definition's colour table?
// Let's hope that's not being used by other instances...
if (rwdata->gdl == rodata->opagdl) {
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((uintptr_t)rodata->opagdl & 0xffffff));
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((uintptr_t)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
gdlptr = rwdata->gdl;
}
if (rodata->xlugdl) {
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((uintptr_t)rodata->xlugdl & 0xffffff));
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((uintptr_t)UNSEGADDR(rodata->xlugdl) & 0xffffff));
} else {
gdlptr2 = NULL;
}
@@ -3745,7 +3745,11 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
// Iterate the primary DL, and once the end is reached
// iterate the secondary DL if we have one.
while (true) {
#ifdef PLATFORM_N64
op = *(s8 *)&gdlptr->words.w0;
#else
op = (s8)gdlptr->bytes[GFX_W0_BYTE(0)];
#endif
if (op == G_ENDDL) {
if (gdlptr2) {
@@ -3761,12 +3765,12 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
// Note: We should have found an MTX op before VTX.
if (op == G_VTX) {
u8 *ptr = (u8 *)&gdlptr->words.w0;
u32 word = gdlptr->words.w1 & 0xffffff;
u32 word = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
s32 numverts;
s32 i;
vertices = (Vtx *)((uintptr_t)rodata->vertices + word);
numverts = (u32)ptr[1] / 16 + 1;
numverts = (u32)ptr[GFX_W0_BYTE(1)] / 16 + 1;
if (posnode) {
for (i = 0; i < numverts; i++) {
@@ -3785,7 +3789,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
}
}
} else if (op == G_MTX) {
u32 addr = gdlptr->words.w1 & 0xffffff;
u32 addr = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf));
modelNodeGetModelRelativePosition(model, posnode, &spd4);
@@ -3850,19 +3854,23 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
}
if (rwdata->gdl == rodata->opagdl) {
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->opagdl & 0xffffff));
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
gdlptr = rwdata->gdl;
}
if (rodata->xlugdl) {
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->xlugdl & 0xffffff));
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
} else {
gdlptr2 = NULL;
}
while (true) {
#ifdef PLATFORM_N64
s32 op = *(s8 *)&gdlptr->words.w0;
#else
s32 op = (s8)gdlptr->bytes[GFX_W0_BYTE(0)];
#endif
if (op == G_ENDDL) {
if (gdlptr2) {
@@ -3878,9 +3886,9 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
// Note: We should have found an MTX op before VTX.
if (op == G_VTX) {
u8 *ptr = (u8 *)&gdlptr->words.w0;
u32 word = gdlptr->words.w1 & 0xffffff;
u32 word = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
Vtx *vertices = (Vtx *)((uintptr_t)rodata->vertices + word);
s32 numverts = (u32)ptr[1] / 16 + 1;
s32 numverts = (u32)ptr[GFX_W0_BYTE(1)] / 16 + 1;
s32 i;
if (posnode) {
@@ -3915,11 +3923,11 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc
}
}
} else if (op == G_MTX) {
u32 addr = gdlptr->words.w1 & 0xffffff;
u32 addr = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf));
modelNodeGetModelRelativePosition(model, posnode, &spd4);
} else if (op == G_COL) {
spac = gdlptr->words.w1 & 0xffffff;
spac = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
}
gdlptr++;
@@ -4006,13 +4014,13 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
// use the space... after the model definition's colour table?
// Let's hope that's not being used by other instances...
if (rwdata->gdl == rodata->opagdl) {
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->opagdl & 0xffffff));
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
gdlptr = rwdata->gdl;
}
if (rodata->xlugdl) {
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->xlugdl & 0xffffff));
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
} else {
gdlptr2 = NULL;
}
@@ -4020,7 +4028,11 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
// Iterate the primary DL, and once the end is reached
// iterate the secondary DL if we have one.
while (true) {
#ifdef PLATFORM_N64
op = *(s8 *)&gdlptr->words.w0;
#else
op = (s8)gdlptr->bytes[GFX_W0_BYTE(0)];
#endif
if (op == G_ENDDL) {
if (gdlptr2) {
@@ -4036,12 +4048,12 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
// Note: We should have found an MTX op before VTX.
if (op == G_VTX) {
u8 *ptr = (u8 *)&gdlptr->words.w0;
u32 word = gdlptr->words.w1 & 0xffffff;
u32 word = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
s32 numverts;
s32 i;
vertices = (Vtx *)((uintptr_t)rodata->vertices + word);
numverts = (u32)ptr[1] / 16 + 1;
numverts = (u32)ptr[GFX_W0_BYTE(1)] / 16 + 1;
if (posnode) {
for (i = 0; i < numverts; i++) {
@@ -4060,7 +4072,7 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
}
}
} else if (op == G_MTX) {
u32 addr = gdlptr->words.w1 & 0xffffff;
u32 addr = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf));
modelNodeGetModelRelativePosition(model, posnode, &spd4);
@@ -4144,19 +4156,23 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
}
if (rwdata->gdl == rodata->opagdl) {
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->opagdl & 0xffffff));
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
gdlptr = rwdata->gdl;
}
if (rodata->xlugdl) {
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->xlugdl & 0xffffff));
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
} else {
gdlptr2 = NULL;
}
while (true) {
s32 op = *(s8 *)&gdlptr->words.w0;
#ifdef PLATFORM_N64
s32 op = *(s8 *)&gdlptr->words.w0;
#else
s32 op = (s8)gdlptr->bytes[GFX_W0_BYTE(0)];
#endif
if (op == G_ENDDL) {
if (gdlptr2) {
@@ -4172,9 +4188,9 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
// Note: We should have found an MTX op before VTX.
if (op == G_VTX) {
u8 *ptr = (u8 *)&gdlptr->words.w0;
u32 word = gdlptr->words.w1 & 0xffffff;
u32 word = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
Vtx *vertices = (Vtx *)((uintptr_t)rodata->vertices + word);
s32 numverts = (u32)ptr[1] / 16 + 1;
s32 numverts = (u32)ptr[GFX_W0_BYTE(1)] / 16 + 1;
s32 i;
if (posnode) {
@@ -4213,11 +4229,11 @@ void chrBruise(struct model *model, s32 hitpart, struct modelnode *node, struct
}
}
} else if (op == G_MTX) {
u32 addr = gdlptr->words.w1 & 0xffffff;
u32 addr = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf));
modelNodeGetModelRelativePosition(model, posnode, &spd4);
} else if (op == G_COL) {
spac = gdlptr->words.w1 & 0xffffff;
spac = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
}
gdlptr++;
@@ -4335,19 +4351,23 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius)
if (rwdata->vertices != rodata->vertices
&& (uintptr_t)rwdata->colours != ALIGN8((uintptr_t)&rodata->vertices[rodata->numvertices])) {
if (rwdata->gdl == rodata->opagdl) {
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((s32)rodata->opagdl & 0xffffff));
gdlptr = (Gfx *)((uintptr_t)rodata->colours + ((s32)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
gdlptr = rwdata->gdl;
}
if (rodata->xlugdl) {
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((s32)rodata->xlugdl & 0xffffff));
gdlptr2 = (Gfx *)((uintptr_t)rodata->colours + ((s32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
} else {
gdlptr2 = NULL;
}
while (true) {
#ifdef PLATFORM_N64
s32 op = *(s8 *)&gdlptr->words.w0;
#else
s32 op = (s8)gdlptr->bytes[GFX_W0_BYTE(0)];
#endif
if (op == G_ENDDL) {
if (gdlptr2 == NULL) {
@@ -4365,11 +4385,11 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius)
if (op == G_VTX) {
// Iterate the vertex table and fudge them
u8 *ptr = (u8 *)&gdlptr->words.w0;
s32 word = gdlptr->words.w1 & 0xffffff;
s32 word = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
s32 numverts;
vertices = (Vtx *)((uintptr_t)rwdata->vertices + word);
numverts = (u32)ptr[1] / 16 + 1;
numverts = (u32)ptr[GFX_W0_BYTE(1)] / 16 + 1;
if (posnode) {
for (i = 0; i < numverts; i++) {
@@ -4397,7 +4417,7 @@ void chrDisfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius)
}
} else if (op == G_MTX) {
// Get the position of the node relative to the model
u32 addr = gdlptr->words.w1 & 0xffffff;
u32 addr = UNSEGADDR(gdlptr->words.w1) & 0xffffff;
posnode = modelFindNodeByMtxIndex(model, addr / sizeof(Mtxf));
modelNodeGetModelRelativePosition(model, posnode, &pos);
}
+8 -8
View File
@@ -128,12 +128,12 @@ void modeldef0f1a7560(struct modeldef *modeldef, u16 filenum, u32 arg2, struct m
s5 = gdl;
if (gdl) {
s32 v1 = allocsize - (loadedsize - (s32)(((uintptr_t)modeldef + (gdl & 0xffffff)) - (uintptr_t)modeldef));
sp84 = (s32)v1 + (s32)((uintptr_t)modeldef - ((uintptr_t)modeldef + (gdl & 0xffffff)));
s32 v1 = allocsize - (loadedsize - (s32)(((uintptr_t)modeldef + (UNSEGADDR(gdl) & 0xffffff)) - (uintptr_t)modeldef));
sp84 = (s32)v1 + (s32)((uintptr_t)modeldef - ((uintptr_t)modeldef + (UNSEGADDR(gdl) & 0xffffff)));
texCopyGdls((Gfx *)((uintptr_t)modeldef + (gdl & 0xffffff)),
texCopyGdls((Gfx *)((uintptr_t)modeldef + (UNSEGADDR(gdl) & 0xffffff)),
(Gfx *)(v1 + (uintptr_t)modeldef),
loadedsize - (s32)(((uintptr_t)modeldef + (gdl & 0xffffff)) - (uintptr_t)modeldef));
loadedsize - (s32)(((uintptr_t)modeldef + (UNSEGADDR(gdl) & 0xffffff)) - (uintptr_t)modeldef));
texLoadFromConfigs(modeldef->texconfigs, modeldef->numtexconfigs, texpool, (uintptr_t)modeldef2 - arg2);
while (node) {
@@ -143,9 +143,9 @@ void modeldef0f1a7560(struct modeldef *modeldef, u16 filenum, u32 arg2, struct m
modelIterateDisplayLists(modeldef, &node, (Gfx **) &gdl);
if (gdl) {
s4 = gdl - s0;
s4 = UNSEGADDR(gdl) - UNSEGADDR(s0);
} else {
s4 = loadedsize + (uintptr_t)modeldef - (uintptr_t)modeldef - (s0 & 0xffffff);
s4 = loadedsize + (uintptr_t)modeldef - (uintptr_t)modeldef - (UNSEGADDR(s0) & 0xffffff);
}
modelNodeReplaceGdl(modeldef, prevnode, (Gfx *) s0, (Gfx *) s5);
@@ -157,10 +157,10 @@ void modeldef0f1a7560(struct modeldef *modeldef, u16 filenum, u32 arg2, struct m
vertices = NULL;
}
s5 += texLoadFromGdl((Gfx *)((uintptr_t)modeldef + (s0 & 0xffffff) + sp84), s4, (Gfx *)((uintptr_t)modeldef + (s5 & 0xffffff)), texpool, (u8 *) vertices);
s5 += texLoadFromGdl((Gfx *)((uintptr_t)modeldef + (UNSEGADDR(s0) & 0xffffff) + sp84), s4, (Gfx *)((uintptr_t)modeldef + (UNSEGADDR(s5) & 0xffffff)), texpool, (u8 *) vertices);
}
fileSetSize(filenum, modeldef, (((uintptr_t)modeldef + (s5 & 0xffffff)) - (uintptr_t)modeldef + 0xf) & ~0xf, arg5);
fileSetSize(filenum, modeldef, (((uintptr_t)modeldef + (UNSEGADDR(s5) & 0xffffff)) - (uintptr_t)modeldef + 0xf) & ~0xf, arg5);
}
}
+9 -9
View File
@@ -2914,13 +2914,13 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno
if (rwdata->gdl != NULL) {
if (rwdata->gdl == rodata->dl.opagdl) {
s4 = (Gfx *)((uintptr_t)rodata->dl.colours + ((uintptr_t)rodata->dl.opagdl & 0xffffff));
s4 = (Gfx *)((uintptr_t)rodata->dl.colours + ((uintptr_t)UNSEGADDR(rodata->dl.opagdl) & 0xffffff));
} else {
s4 = rwdata->gdl;
}
if (rodata->dl.xlugdl != NULL) {
s6 = (Gfx *)((uintptr_t)rodata->dl.colours + ((uintptr_t)rodata->dl.xlugdl & 0xffffff));
s6 = (Gfx *)((uintptr_t)rodata->dl.colours + ((uintptr_t)UNSEGADDR(rodata->dl.xlugdl) & 0xffffff));
}
vertices = rwdata->vertices;
@@ -2932,10 +2932,10 @@ bool func0f06bea0(struct model *model, struct modelnode *endnode, struct modelno
if (node->rodata->gundl.opagdl != NULL) {
s32 base = (intptr_t)node->rodata->gundl.baseaddr;
s4 = (Gfx *)(base + ((uintptr_t)node->rodata->gundl.opagdl & 0xffffff));
s4 = (Gfx *)(base + ((uintptr_t)UNSEGADDR(node->rodata->gundl.opagdl) & 0xffffff));
if (node->rodata->gundl.xlugdl != NULL) {
s6 = (Gfx *)(base + ((uintptr_t)node->rodata->gundl.xlugdl & 0xffffff));
s6 = (Gfx *)(base + ((uintptr_t)UNSEGADDR(node->rodata->gundl.xlugdl) & 0xffffff));
}
vertices = (Vtx *)base;
@@ -13314,7 +13314,7 @@ Gfx *tvscreenRender(struct model *model, struct modelnode *node, struct tvscreen
gSPMatrix(gdl++, osVirtualToPhysical(model->matrices), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPSegment(gdl++, SPSEGMENT_MODEL_VTX, osVirtualToPhysical(vertices));
gSPColor(gdl++, osVirtualToPhysical(colours), 1);
gSPVertex(gdl++, SPSEGMENT_MODEL_VTX << 24, 4, 0);
gSPVertex(gdl++, SEGADDR(SPSEGMENT_MODEL_VTX << 24), 4, 0);
gSPTri2(gdl++, 0, 1, 2, 0, 2, 3);
gSPEndDisplayList(gdl++);
@@ -14982,13 +14982,13 @@ bool func0f0849dc(struct model *model, struct modelnode *nodearg, struct coord *
if (rwdata->gdl != NULL) {
if (rwdata->gdl == rodata->opagdl) {
s3 = (Gfx *)((uintptr_t)rodata->colours + ((u32)rodata->opagdl & 0xffffff));
s3 = (Gfx *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->opagdl) & 0xffffff));
} else {
s3 = rwdata->gdl;
}
if (rodata->xlugdl != NULL) {
s5 = (void *)((uintptr_t)rodata->colours + ((u32)rodata->xlugdl & 0xffffff));
s5 = (void *)((uintptr_t)rodata->colours + ((u32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
}
vertices = rwdata->vertices;
@@ -15000,10 +15000,10 @@ bool func0f0849dc(struct model *model, struct modelnode *nodearg, struct coord *
struct modelrodata_gundl *rodata = &node->rodata->gundl;
if (rodata->opagdl != NULL) {
s3 = (Gfx *)((uintptr_t)rodata->baseaddr + ((u32)rodata->opagdl & 0xffffff));
s3 = (Gfx *)((uintptr_t)rodata->baseaddr + ((u32)UNSEGADDR(rodata->opagdl) & 0xffffff));
if (rodata->xlugdl != NULL) {
s5 = (Gfx *)((uintptr_t)rodata->baseaddr + ((u32)rodata->xlugdl & 0xffffff));
s5 = (Gfx *)((uintptr_t)rodata->baseaddr + ((u32)UNSEGADDR(rodata->xlugdl) & 0xffffff));
}
vertices = (void *)(uintptr_t)rodata->baseaddr;
+2 -2
View File
@@ -980,7 +980,7 @@ s32 texLoadFromGdl(Gfx *arg0, s32 gdlsizeinbytes, Gfx *arg2, struct texpool *poo
if (spe0) {
start = s5->bytes[GFX_W0_BYTE(1)] & 0xf;
count = s5->vtx.unk08 + 1;
vtx = (Vtx *)(s5->dma.addr & 0x00ffffff);
vtx = (Vtx *)(UNSEGADDR(s5->dma.addr) & 0x00ffffff);
for (i = start; i < start + count; i++) {
if (animated && sp90[i]) {
@@ -998,7 +998,7 @@ s32 texLoadFromGdl(Gfx *arg0, s32 gdlsizeinbytes, Gfx *arg2, struct texpool *poo
Vtx *vtx;
s32 i;
offset = s5->dma.addr & 0x00ffffff;
offset = UNSEGADDR(s5->dma.addr) & 0x00ffffff;
vtx = (Vtx *) (arg4 + offset);
for (i = 0; i < count; i++) {