Decompile DRA RenderPrimitives (#1371)

Got this working with the aid of PSP!

Scratches here:

PS1: https://decomp.me/scratch/FDWxW
PSP: https://decomp.me/scratch/SObUR

These are identical aside from the versions defined at the top of the
context, and everything else is done with `ifdef`.

Several of the `ifdef` differences are in structs that are defined in
`include/psxsdk/libgpu.h`, and since they're in the PSX SDK, I don't
want to add those PSP differences into that file. I imagine at some
point we'll have a PSP libgpu.h or something, but until then, this
function will not actually match on PSP. But since PSP is not the focus
of this decomp, I think that's okay.

This is 99% similar to Xeeynamo's scratch, the main difference is the
treatment of the lines that look like `setSemiTrans(&primbuf->g2,
var_s0->drawMode & DRAW_TRANSP);`.
This commit is contained in:
bismurphy 2024-07-02 14:14:59 -04:00 committed by GitHub
parent cae2cd1030
commit 2399ca62cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 197 additions and 125 deletions

View File

@ -100,8 +100,15 @@ typedef struct Prim {
#define COLOR_LEN ((COLOR_BPP) / 8) #define COLOR_LEN ((COLOR_BPP) / 8)
#define PALETTE_LEN ((COLORS_PER_PAL) * ((COLOR_BPP) / 8)) #define PALETTE_LEN ((COLORS_PER_PAL) * ((COLOR_BPP) / 8))
#define COLOR16(r, g, b, a) (r) + ((g) << 5) + ((b) << 10) + ((a) << 15) #define COLOR16(r, g, b, a) (r) + ((g) << 5) + ((b) << 10) + ((a) << 15)
// PS1 and PSP use different values for these two
#ifndef VERSION_PSP
#define OTSIZE 0x200 #define OTSIZE 0x200
#define MAXSPRT16 0x280 #define MAXSPRT16 0x280
#endif
#ifdef VERSION_PSP
#define OTSIZE 0x600
#define MAXSPRT16 0x320
#endif
#define MAX_DRAW_MODES 0x400 #define MAX_DRAW_MODES 0x400
#define MAX_TILE_COUNT 0x100 #define MAX_TILE_COUNT 0x100
#define MAX_LINE_G2_COUNT 0x100 #define MAX_LINE_G2_COUNT 0x100

View File

@ -1768,21 +1768,6 @@ void FreePrimitives(s32 primitiveIndex) {
} }
} }
#ifndef NON_MATCHING
INCLUDE_ASM("dra/nonmatchings/4A538", RenderPrimitives);
#else
typedef struct {
/* 0x1F800000 */ OT_TYPE* ot;
/* 0x1F800004 */ POLY_GT4* gt4;
/* 0x1F800008 */ POLY_G4* g4;
/* 0x1F80000C */ POLY_GT3* gt3;
/* 0x1F800010 */ LINE_G2* g2;
/* 0x1F800014 */ TILE* tile;
/* 0x1F800018 */ DR_MODE* dr;
/* 0x1F80001C */ SPRT* sprt;
/* 0x1F800020 */ DR_ENV* env;
} PrimitivesRenderer;
typedef union { typedef union {
TILE tile; TILE tile;
LINE_G2 g2; LINE_G2 g2;
@ -1792,37 +1777,50 @@ typedef union {
SPRT sprt; SPRT sprt;
} PrimBuf; } PrimBuf;
void RenderPrimitives(void) { typedef struct {
#ifdef VERSION_PC u_long* ot;
RECT _rect; POLY_GT4* gt4;
RECT* rect = &_rect; POLY_G4* g4;
PrimitivesRenderer _r; POLY_GT3* gt3;
PrimitivesRenderer* r = &_r; LINE_G2* g2;
PrimBuf _primbuf; TILE* tile;
PrimBuf* primbuf = &_primbuf; DR_MODE* dr;
#else SPRT* sprt;
RECT* rect = (RECT*)0x1F800128; DR_ENV* env;
PrimitivesRenderer* r = (PrimitivesRenderer*)0x1F800000; } PrimitivesRenderer;
PrimBuf* primbuf = (PrimBuf*)0x1F800024;
#ifndef VERSION_PSP
#define OT_MULT 1
#endif
#ifdef VERSION_PSP
#define OT_MULT 3
#endif #endif
DRAWENV sp18; void RenderPrimitives(void) {
s32 i; #ifdef VERSION_PC
s16 sp80; u8 sp[SP_LEN];
Primitive* prim; #endif
DR_ENV* env; #ifdef VERSION_PSP
s32 useShadeTex; #define RECT_LOC 0x12C
s32 var_a1; #endif
s32 tpage; #ifndef VERSION_PSP
s32 dtd; #define RECT_LOC 0x128
u16 var_v0; #endif
u16 drawMode; RECT* rect = (RECT*)SP(RECT_LOC);
u8 primType; PrimitivesRenderer* r = (PrimitivesRenderer*)SP(0x000);
PrimBuf* primbuf = (PrimBuf*)SP(0x024);
s32 i;
Primitive* prim;
u8 primType;
bool useShadeTex;
bool dtd;
bool unkBool;
DRAWENV drawEnv;
s16 drawOfs;
DR_ENV* env;
rect->x = 0;
rect->y = 0;
rect->w = 255;
rect->h = 255;
r->ot = g_CurrentBuffer->ot; r->ot = g_CurrentBuffer->ot;
r->gt4 = &g_CurrentBuffer->polyGT4[g_GpuUsage.gt4]; r->gt4 = &g_CurrentBuffer->polyGT4[g_GpuUsage.gt4];
r->g4 = &g_CurrentBuffer->polyG4[g_GpuUsage.g4]; r->g4 = &g_CurrentBuffer->polyG4[g_GpuUsage.g4];
@ -1832,6 +1830,10 @@ void RenderPrimitives(void) {
r->dr = &g_CurrentBuffer->drawModes[g_GpuUsage.drawModes]; r->dr = &g_CurrentBuffer->drawModes[g_GpuUsage.drawModes];
r->sprt = &g_CurrentBuffer->sprite[g_GpuUsage.sp]; r->sprt = &g_CurrentBuffer->sprite[g_GpuUsage.sp];
r->env = &g_CurrentBuffer->env[g_GpuUsage.env]; r->env = &g_CurrentBuffer->env[g_GpuUsage.env];
rect->x = 0;
rect->y = 0;
rect->w = 255;
rect->h = 255;
if (D_8003C0EC[3]) { if (D_8003C0EC[3]) {
if (g_GpuUsage.tile < MAX_TILE_COUNT) { if (g_GpuUsage.tile < MAX_TILE_COUNT) {
setSemiTrans(r->tile, false); setSemiTrans(r->tile, false);
@ -1847,21 +1849,21 @@ void RenderPrimitives(void) {
D_8003C0EC[3]--; D_8003C0EC[3]--;
} }
} else { } else {
var_a1 = 0; unkBool = 0;
i = 0; for (i = 0, prim = &g_PrimBuf[0]; i < MAX_PRIM_COUNT; prim++, i++) {
prim = g_PrimBuf + i;
for (; i < MAX_PRIM_COUNT; prim++, i++) {
primType = prim->type; primType = prim->type;
if (!primType) { if (!primType) {
continue; continue;
} }
drawMode = prim->drawMode; if (prim->drawMode & DRAW_HIDE) {
if (drawMode & DRAW_HIDE) {
continue; continue;
} }
var_v0 = drawMode & DRAW_COLORS; if (prim->drawMode & DRAW_COLORS) {
useShadeTex = var_v0 < 1; useShadeTex = false;
if (D_800973EC != 0 && !(drawMode & DRAW_MENU)) { } else {
useShadeTex = true;
}
if (D_800973EC != 0 && !(prim->drawMode & DRAW_MENU)) {
continue; continue;
} }
if (prim->x0 < -512 || prim->x0 > 512) { if (prim->x0 < -512 || prim->x0 > 512) {
@ -1870,25 +1872,28 @@ void RenderPrimitives(void) {
if (prim->y0 < -512 || prim->y0 > 512) { if (prim->y0 < -512 || prim->y0 > 512) {
continue; continue;
} }
if (drawMode & DRAW_UNK_400) { if (prim->drawMode & DRAW_UNK_400) {
dtd = 1; dtd = true;
if (var_a1 == 0) { if (!unkBool) {
SetDrawMode(r->dr, 0, 0, 0, rect); SetDrawMode(r->dr, 0, 0, 0, rect);
addPrim(&r->ot[prim->priority], r->dr); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
} else { } else {
dtd = 0; dtd = false;
} }
switch (primType) { switch (primType) {
case PRIM_TILE: case PRIM_TILE:
case PRIM_TILE_ALT: case PRIM_TILE_ALT:
setTile(&primbuf->tile); setTile(&primbuf->tile);
if (g_GpuUsage.tile < MAX_TILE_COUNT) { if (g_GpuUsage.tile < MAX_TILE_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->tile, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->tile, true);
}
primbuf->tile.r0 = prim->r0; primbuf->tile.r0 = prim->r0;
primbuf->tile.g0 = prim->g0; primbuf->tile.g0 = prim->g0;
primbuf->tile.b0 = prim->b0; primbuf->tile.b0 = prim->b0;
@ -1901,15 +1906,24 @@ void RenderPrimitives(void) {
} }
primbuf->tile.w = prim->u0; primbuf->tile.w = prim->u0;
primbuf->tile.h = prim->v0; primbuf->tile.h = prim->v0;
__builtin_memcpy(r->tile, &primbuf->tile, sizeof(TILE)); *r->tile = primbuf->tile;
addPrim(&r->ot[prim->priority], r->tile); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->tile);
r->tile++; r->tile++;
g_GpuUsage.tile++; g_GpuUsage.tile++;
if ((primType & 0x10) == 0 && if (!(primType & 0x10) &&
g_GpuUsage.drawModes < MAX_DRAW_MODES) { g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = prim->drawMode & 0x60; SetDrawMode(r->dr, 0, dtd, prim->drawMode & 0x60, rect);
SetDrawMode(r->dr, 0, dtd, tpage, rect); #ifdef VERSION_PSP
addPrim(&r->ot[prim->priority], r->dr); if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -1919,10 +1933,8 @@ void RenderPrimitives(void) {
case 18: case 18:
setLineG2(&primbuf->g2); setLineG2(&primbuf->g2);
if (g_GpuUsage.line < MAX_LINE_G2_COUNT) { if (g_GpuUsage.line < MAX_LINE_G2_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->g2, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->g2, true); setShadeTex(&primbuf->g2, useShadeTex);
}
setShadeTex(&primbuf->g2, !!useShadeTex);
primbuf->g2.r0 = prim->r0; primbuf->g2.r0 = prim->r0;
primbuf->g2.g0 = prim->g0; primbuf->g2.g0 = prim->g0;
primbuf->g2.b0 = prim->b0; primbuf->g2.b0 = prim->b0;
@ -1940,15 +1952,24 @@ void RenderPrimitives(void) {
primbuf->g2.x1 = prim->x1 + g_backbufferX; primbuf->g2.x1 = prim->x1 + g_backbufferX;
primbuf->g2.y1 = prim->y1 + g_backbufferY; primbuf->g2.y1 = prim->y1 + g_backbufferY;
} }
__builtin_memcpy(r->g2, &primbuf->g2, sizeof(LINE_G2)); *r->g2 = primbuf->g2;
addPrim(&r->ot[prim->priority], r->g2); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->g2);
r->g2++; r->g2++;
g_GpuUsage.line++; g_GpuUsage.line++;
if ((primType & 0x10) == 0 && if ((primType & 0x10) == 0 &&
g_GpuUsage.drawModes < MAX_DRAW_MODES) { g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = prim->drawMode & 0x60; SetDrawMode(r->dr, 0, dtd, prim->drawMode & 0x60, rect);
SetDrawMode(r->dr, 0, dtd, tpage, rect); #ifdef VERSION_PSP
addPrim(&r->ot[prim->priority], r->dr); if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -1958,10 +1979,8 @@ void RenderPrimitives(void) {
case 19: case 19:
setPolyG4(&primbuf->g4); setPolyG4(&primbuf->g4);
if (g_GpuUsage.g4 < MAX_POLY_G4_COUNT) { if (g_GpuUsage.g4 < MAX_POLY_G4_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->g4, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->g4, true); setShadeTex(&primbuf->g4, useShadeTex);
}
setShadeTex(&primbuf->g4, !!useShadeTex);
primbuf->g4.r0 = prim->r0; primbuf->g4.r0 = prim->r0;
primbuf->g4.g0 = prim->g0; primbuf->g4.g0 = prim->g0;
primbuf->g4.b0 = prim->b0; primbuf->g4.b0 = prim->b0;
@ -1993,15 +2012,24 @@ void RenderPrimitives(void) {
primbuf->g4.x3 = prim->x3 + g_backbufferX; primbuf->g4.x3 = prim->x3 + g_backbufferX;
primbuf->g4.y3 = prim->y3 + g_backbufferY; primbuf->g4.y3 = prim->y3 + g_backbufferY;
} }
__builtin_memcpy(r->g4, &primbuf->g4, sizeof(POLY_G4)); *r->g4 = primbuf->g4;
addPrim(&r->ot[prim->priority], r->g4); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->g4);
r->g4++; r->g4++;
g_GpuUsage.g4++; g_GpuUsage.g4++;
if ((primType & 0x10) == 0 && if ((primType & 0x10) == 0 &&
g_GpuUsage.drawModes < MAX_DRAW_MODES) { g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = prim->drawMode & 0x60; SetDrawMode(r->dr, 0, dtd, prim->drawMode & 0x60, rect);
SetDrawMode(r->dr, 0, dtd, tpage, rect); #ifdef VERSION_PSP
addPrim(&r->ot[prim->priority], r->dr); if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -2010,10 +2038,8 @@ void RenderPrimitives(void) {
case PRIM_GT4: case PRIM_GT4:
setPolyGT4(&primbuf->gt4); setPolyGT4(&primbuf->gt4);
if (g_GpuUsage.gt4 < MAX_POLY_GT4_COUNT) { if (g_GpuUsage.gt4 < MAX_POLY_GT4_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->gt4, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->gt4, true); setShadeTex(&primbuf->gt4, useShadeTex);
}
setShadeTex(&primbuf->gt4, !!useShadeTex);
primbuf->gt4.r0 = prim->r0; primbuf->gt4.r0 = prim->r0;
primbuf->gt4.g0 = prim->g0; primbuf->gt4.g0 = prim->g0;
primbuf->gt4.b0 = prim->b0; primbuf->gt4.b0 = prim->b0;
@ -2055,14 +2081,23 @@ void RenderPrimitives(void) {
primbuf->gt4.v3 = prim->v3; primbuf->gt4.v3 = prim->v3;
primbuf->gt4.tpage = prim->tpage + (prim->drawMode & 0x60); primbuf->gt4.tpage = prim->tpage + (prim->drawMode & 0x60);
primbuf->gt4.clut = g_ClutIds[prim->clut]; primbuf->gt4.clut = g_ClutIds[prim->clut];
__builtin_memcpy(r->gt4, &primbuf->gt4, sizeof(POLY_GT4)); *r->gt4 = primbuf->gt4;
addPrim(&r->ot[prim->priority], r->gt4); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->gt4);
r->gt4++; r->gt4++;
g_GpuUsage.gt4++; g_GpuUsage.gt4++;
if (dtd && g_GpuUsage.drawModes < MAX_DRAW_MODES) { if (dtd && g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = 0; SetDrawMode(r->dr, 0, dtd, 0, rect);
SetDrawMode(r->dr, 0, dtd, tpage, rect); #ifdef VERSION_PSP
addPrim(&r->ot[prim->priority], r->dr); if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -2071,10 +2106,8 @@ void RenderPrimitives(void) {
case PRIM_GT3: case PRIM_GT3:
setPolyGT3(&primbuf->gt3); setPolyGT3(&primbuf->gt3);
if (g_GpuUsage.gt3 < MAX_POLY_GT3_COUNT) { if (g_GpuUsage.gt3 < MAX_POLY_GT3_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->gt3, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->gt3, true); setShadeTex(&primbuf->gt3, useShadeTex);
}
setShadeTex(&primbuf->gt3, !!useShadeTex);
primbuf->gt3.r0 = prim->r0; primbuf->gt3.r0 = prim->r0;
primbuf->gt3.g0 = prim->g0; primbuf->gt3.g0 = prim->g0;
primbuf->gt3.b0 = prim->b0; primbuf->gt3.b0 = prim->b0;
@ -2108,14 +2141,23 @@ void RenderPrimitives(void) {
primbuf->gt3.tpage = prim->tpage + (prim->drawMode & 0x60); primbuf->gt3.tpage = prim->tpage + (prim->drawMode & 0x60);
primbuf->gt3.clut = g_ClutIds[prim->clut]; primbuf->gt3.clut = g_ClutIds[prim->clut];
__builtin_memcpy(r->gt3, &primbuf->gt3, sizeof(POLY_GT3)); *r->gt3 = primbuf->gt3;
addPrim(&r->ot[prim->priority], r->gt3); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->gt3);
r->gt3++; r->gt3++;
g_GpuUsage.gt3++; g_GpuUsage.gt3++;
if (dtd && g_GpuUsage.drawModes < MAX_DRAW_MODES) { if (dtd && g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = 0; SetDrawMode(r->dr, 0, dtd, 0, rect);
SetDrawMode(r->dr, 0, dtd, tpage, rect); #ifdef VERSION_PSP
addPrim(&r->ot[prim->priority], r->dr); if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -2125,10 +2167,8 @@ void RenderPrimitives(void) {
case 22: case 22:
setSprt(&primbuf->sprt); setSprt(&primbuf->sprt);
if (g_GpuUsage.sp < MAX_SPRT_COUNT) { if (g_GpuUsage.sp < MAX_SPRT_COUNT) {
if (prim->drawMode & DRAW_TRANSP) { setSemiTrans(&primbuf->sprt, prim->drawMode & DRAW_TRANSP);
setSemiTrans(&primbuf->sprt, true); setShadeTex(&primbuf->sprt, useShadeTex);
}
setShadeTex(&primbuf->sprt, !!useShadeTex);
primbuf->sprt.r0 = prim->r0; primbuf->sprt.r0 = prim->r0;
primbuf->sprt.g0 = prim->g0; primbuf->sprt.g0 = prim->g0;
primbuf->sprt.b0 = prim->b0; primbuf->sprt.b0 = prim->b0;
@ -2144,15 +2184,26 @@ void RenderPrimitives(void) {
primbuf->sprt.w = prim->u1; primbuf->sprt.w = prim->u1;
primbuf->sprt.h = prim->v1; primbuf->sprt.h = prim->v1;
primbuf->sprt.clut = g_ClutIds[prim->clut]; primbuf->sprt.clut = g_ClutIds[prim->clut];
__builtin_memcpy(r->sprt, &primbuf->sprt, sizeof(SPRT)); *r->sprt = primbuf->sprt;
addPrim(&r->ot[prim->priority], r->sprt); #ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->sprt);
r->sprt++; r->sprt++;
g_GpuUsage.sp++; g_GpuUsage.sp++;
if ((primType & 0x10) == 0 && if ((primType & 0x10) == 0 &&
g_GpuUsage.drawModes < MAX_DRAW_MODES) { g_GpuUsage.drawModes < MAX_DRAW_MODES) {
tpage = prim->tpage + (prim->drawMode & 0x60); SetDrawMode(
SetDrawMode(r->dr, 0, dtd, tpage, rect); r->dr, 0, dtd,
addPrim(&r->ot[prim->priority], r->dr); prim->tpage + (prim->drawMode & 0x60), rect);
#ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->dr);
r->dr++; r->dr++;
g_GpuUsage.drawModes++; g_GpuUsage.drawModes++;
} }
@ -2162,31 +2213,45 @@ void RenderPrimitives(void) {
if (g_GpuUsage.env < MAX_ENV_COUNT) { if (g_GpuUsage.env < MAX_ENV_COUNT) {
env = *(DR_ENV**)&prim->r1; env = *(DR_ENV**)&prim->r1;
if (prim->drawMode & DRAW_UNK_1000) { if (prim->drawMode & DRAW_UNK_1000) {
sp80 = g_CurrentBuffer->draw.ofs[0]; drawOfs = g_CurrentBuffer->draw.ofs[0];
*(s16*)&env->code[2] = sp80; #ifndef VERSION_PSP
*(s16*)&env->code[7] = sp80; *(s16*)&env->code[2] = drawOfs;
*(s16*)&env->code[7] = drawOfs;
#endif
#ifdef VERSION_PSP
*(s16*)&env->code[3] = drawOfs;
*(s16*)&env->code[1] = drawOfs;
#endif
} }
if (prim->drawMode & DRAW_UNK_800) { if (prim->drawMode & DRAW_UNK_800) {
__builtin_memcpy( drawEnv = g_CurrentBuffer->draw;
&sp18, &g_CurrentBuffer->draw, sizeof(DRAWENV)); drawEnv.isbg = 0;
sp18.isbg = 0; SetDrawEnv(env, &drawEnv);
SetDrawEnv(env, &sp18);
} }
__builtin_memcpy(r->env, env, sizeof(DR_ENV)); *r->env = *env;
#ifndef VERSION_PSP
if (prim->drawMode & DRAW_UNK_1000) { if (prim->drawMode & DRAW_UNK_1000) {
env = r->env; env = r->env;
*(s16*)&env->code[0] += sp80; *(s16*)&env->code[0] += drawOfs;
*(s16*)&env->code[1] += sp80; *(s16*)&env->code[1] += drawOfs;
} }
addPrim(&r->ot[prim->priority], r->env); #endif
#ifdef VERSION_PSP
if (prim->priority < 0 || prim->priority >= 0x200) {
prim->priority = 0x1FF;
}
#endif
addPrim(&r->ot[prim->priority * OT_MULT], r->env);
r->env++; r->env++;
g_GpuUsage.env++; g_GpuUsage.env++;
} }
break; break;
} }
var_v0 = primType & 0x10; if (primType & 0x10) {
var_a1 = var_v0 != 0; unkBool = true;
} else {
unkBool = false;
}
} }
} }
} }
#endif