- [Psy-X] a lot more friendly polygon code

- [Psy-X] moved some vital defines to PGXP_CONFIG.H
This commit is contained in:
Ilya Shurumov 2020-12-11 02:47:44 +06:00
parent 2517f0418e
commit 79e7985879
14 changed files with 185 additions and 457 deletions

View File

@ -155,7 +155,7 @@ void Debug_Line2D(SXYPAIR& pointA, SXYPAIR& pointB, CVECTOR& color)
line->g0 = color.g; line->g0 = color.g;
line->b0 = color.b; line->b0 = color.b;
#if defined(PGXP) && defined(USE_32_BIT_ADDR) #if defined(USE_PGXP) && defined(USE_EXTENDED_PRIM_POINTERS)
line->pgxp_index = 0xFFFF; line->pgxp_index = 0xFFFF;
#endif #endif

View File

@ -17,7 +17,7 @@
#include "CARS.H" #include "CARS.H"
#include "CONVERT.H" #include "CONVERT.H"
#ifdef PGXP #ifdef USE_PGXP
#include <math.h> #include <math.h>
#endif #endif
@ -607,7 +607,7 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP
prims->x3 = v2[0] - FIXEDH(cs) - dx1; prims->x3 = v2[0] - FIXEDH(cs) - dx1;
prims->y3 = v2[1] - FIXEDH(sn) - dy1; prims->y3 = v2[1] - FIXEDH(sn) - dy1;
#ifdef PGXP #ifdef USE_PGXP
PGXPVData vdata1, vdata2; PGXPVData vdata1, vdata2;
PGXP_GetCacheData(vdata1, PGXP_LOOKUP_VALUE(v1[0], v1[1]), 0); PGXP_GetCacheData(vdata1, PGXP_LOOKUP_VALUE(v1[0], v1[1]), 0);

View File

@ -291,7 +291,7 @@ void LoadSky(void)
} }
// [D] [T] // [D] [T]
#ifdef PGXP #ifdef USE_PGXP
void DisplaySun(DVECTORF* pos, CVECTOR* col, int flare_col) void DisplaySun(DVECTORF* pos, CVECTOR* col, int flare_col)
#else #else
void DisplaySun(DVECTOR* pos, CVECTOR* col, int flare_col) void DisplaySun(DVECTOR* pos, CVECTOR* col, int flare_col)
@ -405,7 +405,7 @@ void DisplaySun(DVECTOR* pos, CVECTOR* col, int flare_col)
} }
// [D] [T] // [D] [T]
#ifdef PGXP #ifdef USE_PGXP
void DisplayMoon(DVECTORF* pos, CVECTOR* col, int flip) void DisplayMoon(DVECTORF* pos, CVECTOR* col, int flip)
#else #else
void DisplayMoon(DVECTOR* pos, CVECTOR* col, int flip) void DisplayMoon(DVECTOR* pos, CVECTOR* col, int flip)
@ -496,7 +496,7 @@ void DrawLensFlare(void)
int haze_col; int haze_col;
#ifdef PGXP #ifdef USE_PGXP
DVECTORF sun_pers_conv_position; DVECTORF sun_pers_conv_position;
#else #else
DVECTOR sun_pers_conv_position; DVECTOR sun_pers_conv_position;
@ -825,7 +825,7 @@ void calc_sky_brightness(void)
// offset: 0x1f800020 // offset: 0x1f800020
extern _pct plotContext; extern _pct plotContext;
#ifdef PGXP #ifdef USE_PGXP
DVECTORF scratchPad_skyVertices[35]; // 1f800044 DVECTORF scratchPad_skyVertices[35]; // 1f800044
#else #else
DVECTOR scratchPad_skyVertices[35]; // 1f800044 DVECTOR scratchPad_skyVertices[35]; // 1f800044
@ -842,7 +842,7 @@ void PlotSkyPoly(POLYFT4* polys, int skytexnum, unsigned char r, unsigned char g
src = polys; src = polys;
poly = (POLY_FT4*)current->primptr; poly = (POLY_FT4*)current->primptr;
#ifdef PGXP #ifdef USE_PGXP
DVECTORF* outpoints = scratchPad_skyVertices; DVECTORF* outpoints = scratchPad_skyVertices;
#else #else
DVECTOR* outpoints = scratchPad_skyVertices; DVECTOR* outpoints = scratchPad_skyVertices;
@ -875,7 +875,7 @@ void PlotSkyPoly(POLYFT4* polys, int skytexnum, unsigned char r, unsigned char g
addPrim(current->ot + 0x107f, poly); addPrim(current->ot + 0x107f, poly);
#if defined(PGXP) && defined(USE_32_BIT_ADDR) #if defined(USE_PGXP) && defined(USE_EXTENDED_PRIM_POINTERS)
poly->pgxp_index = outpoints[src->v0].pgxp_index; poly->pgxp_index = outpoints[src->v0].pgxp_index;
#endif #endif
@ -888,7 +888,7 @@ void PlotHorizonMDL(MODEL* model, int horizontaboffset)
{ {
SVECTOR* verts; SVECTOR* verts;
#ifdef PGXP #ifdef USE_PGXP
DVECTORF* dv0; DVECTORF* dv0;
DVECTORF* dv1; DVECTORF* dv1;
DVECTORF* dv2; DVECTORF* dv2;
@ -953,7 +953,7 @@ void PlotHorizonMDL(MODEL* model, int horizontaboffset)
if(count == 15) if(count == 15)
gte_stszotz(&z); gte_stszotz(&z);
#ifdef PGXP #ifdef USE_PGXP
// store PGXP index // store PGXP index
// HACK: -1 is needed here for some reason // HACK: -1 is needed here for some reason
dv0->pgxp_index = dv1->pgxp_index = dv2->pgxp_index = PGXP_GetIndex() - 1; dv0->pgxp_index = dv1->pgxp_index = dv2->pgxp_index = PGXP_GetIndex() - 1;

View File

@ -87,7 +87,7 @@ extern DB* current;
#define OTSIZE 0x1080 /* ordering table size */ #define OTSIZE 0x1080 /* ordering table size */
#ifdef USE_32_BIT_ADDR #ifdef USE_EXTENDED_PRIM_POINTERS
# define PRIMTAB_SIZE 0x50000 # define PRIMTAB_SIZE 0x50000
#else #else
# define PRIMTAB_SIZE 0x1e000 # define PRIMTAB_SIZE 0x1e000

View File

@ -9,6 +9,7 @@
#endif #endif
// Necessary types // Necessary types
// It's size should match P_LEN*4
#ifdef PSX #ifdef PSX
typedef u_long OTTYPE; typedef u_long OTTYPE;
#else #else

View File

@ -71,7 +71,7 @@ KeyboardMapping g_keyboard_mapping;
// without clamping // without clamping
inline void ScreenCoordsToEmulator(Vertex* vertex, int count) inline void ScreenCoordsToEmulator(Vertex* vertex, int count)
{ {
#ifdef PGXP #ifdef USE_PGXP
while (count--) while (count--)
{ {
float psxScreenW = activeDispEnv.disp.w; float psxScreenW = activeDispEnv.disp.w;
@ -516,7 +516,7 @@ void Emulator_GenerateLineArray(struct Vertex* vertex, VERTTYPE* p0, VERTTYPE* p
vertex[3].y = vertex[0].y; vertex[3].y = vertex[0].y;
} // TODO diagonal line alignment } // TODO diagonal line alignment
#ifdef PGXP #ifdef USE_PGXP
vertex[0].scr_h = vertex[1].scr_h = vertex[2].scr_h = vertex[3].scr_h = 0.0f; vertex[0].scr_h = vertex[1].scr_h = vertex[2].scr_h = vertex[3].scr_h = 0.0f;
#endif #endif
@ -527,7 +527,7 @@ void Emulator_GenerateLineArray(struct Vertex* vertex, VERTTYPE* p0, VERTTYPE* p
inline void Emulator_ApplyVertexPGXP(Vertex* v, VERTTYPE* p, float ofsX, float ofsY, ushort gteidx) inline void Emulator_ApplyVertexPGXP(Vertex* v, VERTTYPE* p, float ofsX, float ofsY, ushort gteidx)
{ {
#ifdef PGXP #ifdef USE_PGXP
uint lookup = PGXP_LOOKUP_VALUE(p[0], p[1]); uint lookup = PGXP_LOOKUP_VALUE(p[0], p[1]);
PGXPVData vd; PGXPVData vd;
if(g_pgxpTextureCorrection && PGXP_GetCacheData(vd, lookup, gteidx)) if(g_pgxpTextureCorrection && PGXP_GetCacheData(vd, lookup, gteidx))
@ -638,7 +638,7 @@ void Emulator_GenerateVertexArrayRect(struct Vertex* vertex, VERTTYPE* p0, short
vertex[3].x = vertex[0].x + w; vertex[3].x = vertex[0].x + w;
vertex[3].y = vertex[0].y; vertex[3].y = vertex[0].y;
#ifdef PGXP #ifdef USE_PGXP
vertex[0].scr_h = vertex[1].scr_h = vertex[2].scr_h = vertex[3].scr_h = 0.0f; vertex[0].scr_h = vertex[1].scr_h = vertex[2].scr_h = vertex[3].scr_h = 0.0f;
#endif #endif
@ -1029,7 +1029,7 @@ GLint u_Projection3D;
" vec2 VRAM(vec2 uv) { return texture2D(s_texture, uv).rg; }\n" " vec2 VRAM(vec2 uv) { return texture2D(s_texture, uv).rg; }\n"
#endif #endif
#ifdef PGXP #ifdef USE_PGXP
#define GTE_PERSPECTIVE_CORRECTION \ #define GTE_PERSPECTIVE_CORRECTION \
" mat4 ofsMat = mat4(\n"\ " mat4 ofsMat = mat4(\n"\
" vec4(1.0, 0.0, 0.0, 0.0),\n"\ " vec4(1.0, 0.0, 0.0, 0.0),\n"\
@ -1240,7 +1240,7 @@ ShaderID Shader_Compile(const char *source)
#ifdef PGXP #ifdef USE_PGXP
glBindAttribLocation(program, a_zw, "a_zw"); glBindAttribLocation(program, a_zw, "a_zw");
#endif #endif
@ -1267,7 +1267,7 @@ void Emulator_CreateGlobalShaders()
#if defined(OGL) || defined(OGLES) #if defined(OGL) || defined(OGLES)
u_Projection = glGetUniformLocation(g_gte_shader_4, "Projection"); u_Projection = glGetUniformLocation(g_gte_shader_4, "Projection");
#ifdef PGXP #ifdef USE_PGXP
u_Projection3D = glGetUniformLocation(g_gte_shader_4, "Projection3D"); u_Projection3D = glGetUniformLocation(g_gte_shader_4, "Projection3D");
#endif #endif
#endif #endif
@ -1324,7 +1324,7 @@ int Emulator_Initialise()
glEnableVertexAttribArray(a_texcoord); glEnableVertexAttribArray(a_texcoord);
glEnableVertexAttribArray(a_color); glEnableVertexAttribArray(a_color);
#if defined(PGXP) #if defined(USE_PGXP)
glVertexAttribPointer(a_position, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &((Vertex*)NULL)->x); glVertexAttribPointer(a_position, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &((Vertex*)NULL)->x);
glVertexAttribPointer(a_zw, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &((Vertex*)NULL)->z); glVertexAttribPointer(a_zw, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &((Vertex*)NULL)->z);
@ -1415,7 +1415,7 @@ void Emulator_SetupClipMode(const RECT16& rect)
{ {
clipRectX -= 0.5f; clipRectX -= 0.5f;
#ifdef PGXP #ifdef USE_PGXP
float emuScreenAspect = float(windowWidth) / float(windowHeight); float emuScreenAspect = float(windowWidth) / float(windowHeight);
#else #else
float emuScreenAspect = (320.0f / 240.0f); float emuScreenAspect = (320.0f / 240.0f);
@ -1446,7 +1446,7 @@ void Emulator_SetupClipMode(const RECT16& rect)
void Emulator_GetPSXWidescreenMappedViewport(RECT16* rect) void Emulator_GetPSXWidescreenMappedViewport(RECT16* rect)
{ {
#ifdef PGXP #ifdef USE_PGXP
float emuScreenAspect = float(windowWidth) / float(windowHeight); float emuScreenAspect = float(windowWidth) / float(windowHeight);
float psxScreenW = activeDispEnv.disp.w; float psxScreenW = activeDispEnv.disp.w;
@ -1477,7 +1477,7 @@ void Emulator_SetShader(const ShaderID &shader)
#error #error
#endif #endif
#ifdef PGXP #ifdef USE_PGXP
float emuScreenAspect = float(windowWidth) / float(windowHeight); float emuScreenAspect = float(windowWidth) / float(windowHeight);
Emulator_Ortho2D(-0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f, -0.5f, -1.0f, 1.0f); Emulator_Ortho2D(-0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f, -0.5f, -1.0f, 1.0f);
Emulator_Perspective3D(0.9265f, 1.0f, 1.0f / (emuScreenAspect * PSX_SCREEN_ASPECT), 1.0f, 1000.0f); Emulator_Perspective3D(0.9265f, 1.0f, 1.0f / (emuScreenAspect * PSX_SCREEN_ASPECT), 1.0f, 1000.0f);

View File

@ -128,7 +128,7 @@ extern SysCounter counters[3];
#pragma pack(push,1) #pragma pack(push,1)
struct Vertex struct Vertex
{ {
#if defined(PGXP) #if defined(USE_PGXP)
float x, y, page, clut; float x, y, page, clut;
#else #else
short x, y, page, clut; short x, y, page, clut;
@ -137,7 +137,7 @@ struct Vertex
u_char u, v, bright, dither; u_char u, v, bright, dither;
u_char r, g, b, a; u_char r, g, b, a;
#if defined(PGXP) #if defined(USE_PGXP)
float z, scr_h, ofsX, ofsY; float z, scr_h, ofsX, ofsY;
#endif #endif
}; };

View File

@ -146,7 +146,7 @@ extern int docop2(int op);
#define gte_lddp( r0 ) \ #define gte_lddp( r0 ) \
MTC2(*(uint*)r0, 8); MTC2(*(uint*)r0, 8);
#if defined(PGXP) #if defined(USE_PGXP)
// swc2 14 // swc2 14
#define gte_stsxy( r0 ) \ #define gte_stsxy( r0 ) \

View File

@ -193,7 +193,7 @@ void ResetPolyState()
s_lastPolyType = 0xFFFF; s_lastPolyType = 0xFFFF;
} }
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
u_long terminator[2] = { 0xffffffff, 0 }; // P_TAG with zero length u_long terminator[2] = { 0xffffffff, 0 }; // P_TAG with zero length
#else #else
u_long terminator = 0xffffffff; u_long terminator = 0xffffffff;
@ -271,7 +271,7 @@ int MargePrim(void* p0, void* p1)
return -1; return -1;
#endif //0 #endif //0
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
int v0 = ((int*)p0)[1]; int v0 = ((int*)p0)[1];
int v1 = ((int*)p1)[1]; int v1 = ((int*)p1)[1];
#else #else
@ -282,13 +282,13 @@ int MargePrim(void* p0, void* p1)
v0 += v1; v0 += v1;
v1 = v0 + 1; v1 = v0 + 1;
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
if (v1 < 0x12) if (v1 < 0x12)
#else #else
if (v1 < 0x11) if (v1 < 0x11)
#endif #endif
{ {
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
((int*)p0)[1] = v1; ((int*)p0)[1] = v1;
((int*)p1)[1] = 0; ((int*)p1)[1] = 0;
#else #else
@ -334,11 +334,6 @@ int StoreImage2(RECT16 *RECT16, u_long *p)
return result; return result;
} }
#ifdef USE_32_BIT_ADDR
# define OT_WIDTH 2 // two longs
#else
# define OT_WIDTH 1 // single long
#endif
u_long* ClearOTag(u_long* ot, int n) u_long* ClearOTag(u_long* ot, int n)
{ {
@ -346,13 +341,13 @@ u_long* ClearOTag(u_long* ot, int n)
return NULL; return NULL;
// last is aspecial terminator // last is aspecial terminator
setaddr(&ot[n - OT_WIDTH], &terminator); setaddr(&ot[n - P_LEN], &terminator);
setlen(&ot[n - OT_WIDTH], 0); setlen(&ot[n - P_LEN], 0);
// make a linked list with it's next items // make a linked list with it's next items
for (int i = (n-1) * OT_WIDTH; i >= 0; i -= OT_WIDTH) for (int i = (n-1) * P_LEN; i >= 0; i -= P_LEN)
{ {
setaddr(&ot[i], &ot[i + OT_WIDTH]); setaddr(&ot[i], &ot[i + P_LEN]);
setlen(&ot[i], 0); setlen(&ot[i], 0);
} }
@ -369,9 +364,9 @@ u_long* ClearOTagR(u_long* ot, int n)
setlen(ot, 0); setlen(ot, 0);
// initialize a linked list with it's previous items // initialize a linked list with it's previous items
for (int i = OT_WIDTH; i < n * OT_WIDTH; i += OT_WIDTH) for (int i = P_LEN; i < n * P_LEN; i += P_LEN)
{ {
setaddr(&ot[i], &ot[i - OT_WIDTH]); setaddr(&ot[i], &ot[i - P_LEN]);
setlen(&ot[i], 0); setlen(&ot[i], 0);
} }
@ -476,10 +471,9 @@ void SetDrawEnv(DR_ENV* dr_env, DRAWENV* env)
dr_env->code[3] = 32 * (((256 - env->tw.h) >> 3) & 0x1F) | ((256 - env->tw.w) >> 3) & 0x1F | (((env->tw.y >> 3) & 0x1F) << 15) | (((env->tw.x >> 3) & 0x1F) << 10) | 0xE2000000; dr_env->code[3] = 32 * (((256 - env->tw.h) >> 3) & 0x1F) | ((256 - env->tw.w) >> 3) & 0x1F | (((env->tw.y >> 3) & 0x1F) << 15) | (((env->tw.x >> 3) & 0x1F) << 10) | 0xE2000000;
dr_env->code[4] = ((env->dtd != 0) << 9) | ((env->dfe != 0) << 10) | env->tpage & 0x1FF | 0xE1000000; dr_env->code[4] = ((env->dtd != 0) << 9) | ((env->dfe != 0) << 10) | env->tpage & 0x1FF | 0xE1000000;
#ifdef USE_32_BIT_ADDR // TODO: add missing logic when env->isbg != 0
dr_env->len = 5;
#endif setlen(dr_env, 5);
dr_env->tag = dr_env->tag & 0xFFFFFF | 0x5000000;
} }
void SetDrawMode(DR_MODE* p, int dfe, int dtd, int tpage, RECT16* tw) void SetDrawMode(DR_MODE* p, int dfe, int dtd, int tpage, RECT16* tw)
@ -491,10 +485,8 @@ void SetDrawArea(DR_AREA *p, RECT16 *r)
{ {
p->code[0] = (r->x & 0x3FF | ((r->y & 0x3FF) << 10)) | 0xE3000000; p->code[0] = (r->x & 0x3FF | ((r->y & 0x3FF) << 10)) | 0xE3000000;
p->code[1] = (((r->x + r->w) & 0x3FF) | (((r->y + r->h) & 0x3FF) << 10)) | 0xE4000000; p->code[1] = (((r->x + r->w) & 0x3FF) | (((r->y + r->h) & 0x3FF) << 10)) | 0xE4000000;
#ifdef USE_32_BIT_ADDR
p->len = 2; setlen(p, 2);
#endif
p->tag = p->tag & 0xFFFFFF | 0x2000000;
} }
void SetDrawMove(DR_MOVE* p, RECT16* rect, int x, int y) void SetDrawMove(DR_MOVE* p, RECT16* rect, int x, int y)
@ -512,10 +504,7 @@ void SetDrawMove(DR_MOVE* p, RECT16* rect, int x, int y)
p->code[3] = y << 0x10 | x & 0xffffU; p->code[3] = y << 0x10 | x & 0xffffU;
p->code[4] = *(ulong *)&rect->w; p->code[4] = *(ulong *)&rect->w;
#ifdef USE_32_BIT_ADDR setlen(p, len);
p->len = len;
#endif
p->tag = p->tag & 0xFFFFFF | 0x1000000;
} }
void SetDrawLoad(DR_LOAD* p, RECT16* RECT16) void SetDrawLoad(DR_LOAD* p, RECT16* RECT16)
@ -611,7 +600,7 @@ void DrawAggregatedSplits()
eprintf("==========================================\n"); eprintf("==========================================\n");
eprintf("POLYGON: %d\n", g_polygonSelected); eprintf("POLYGON: %d\n", g_polygonSelected);
#ifdef PGXP #ifdef USE_PGXP
eprintf("X: %.2f Y: %.2f\n", vert->x, vert->y); eprintf("X: %.2f Y: %.2f\n", vert->x, vert->y);
eprintf("U: %.2f V: %.2f\n", vert->u, vert->v); eprintf("U: %.2f V: %.2f\n", vert->u, vert->v);
#else #else
@ -633,7 +622,7 @@ void DrawAggregatedSplits()
ClearVBO(); ClearVBO();
#ifdef PGXP #ifdef USE_PGXP
PGXP_ClearCache(); PGXP_ClearCache();
#endif #endif
} }
@ -649,10 +638,11 @@ void AggregatePTAGsToSplits(u_long* p, bool singlePrimitive)
if (singlePrimitive) if (singlePrimitive)
{ {
#if defined(PGXP) && defined(USE_32_BIT_ADDR) #if defined(USE_PGXP) && defined(USE_EXTENDED_PRIM_POINTERS)
P_TAG* pTag = (P_TAG*)p; P_TAG* pTag = (P_TAG*)p;
pTag->pgxp_index = 0xFFFF; // force pTag->pgxp_index = 0xFFFF; // force
#endif #endif
// single primitive // single primitive
ParsePrimitive((uintptr_t)p); ParsePrimitive((uintptr_t)p);
g_splits[g_splitIndex].vCount = g_vertexIndex - g_splits[g_splitIndex].vIndex; g_splits[g_splitIndex].vCount = g_vertexIndex - g_splits[g_splitIndex].vIndex;
@ -667,12 +657,14 @@ void AggregatePTAGsToSplits(u_long* p, bool singlePrimitive)
{ {
if (pTag->len > 0) if (pTag->len > 0)
{ {
int lastSize = ParseLinkedPrimitiveList((uintptr_t)pTag, (uintptr_t)pTag + (uintptr_t)(pTag->len * 4) + 4 + LEN_OFFSET); uintptr_t packetEnd = (uintptr_t)pTag + (pTag->len + P_LEN) * sizeof(u_long);
int lastSize = ParseLinkedPrimitiveList((uintptr_t)pTag, packetEnd);
if (lastSize == -1) if (lastSize == -1)
break; // safe bailout break; // safe bailout
} }
pTag = (P_TAG*)(pTag->addr); pTag = (P_TAG*)pTag->addr;
} }
} }
} }
@ -694,7 +686,7 @@ void DrawOTag(u_long* p)
ClearVBO(); ClearVBO();
ResetPolyState(); ResetPolyState();
#ifdef PGXP #ifdef USE_PGXP
PGXP_ClearCache(); PGXP_ClearCache();
#endif #endif
return; return;
@ -735,7 +727,7 @@ void DrawPrim(void* p)
ClearVBO(); ClearVBO();
ResetPolyState(); ResetPolyState();
#ifdef PGXP #ifdef USE_PGXP
PGXP_ClearCache(); PGXP_ClearCache();
#endif #endif
return; return;
@ -796,7 +788,7 @@ int ParsePrimitive(uintptr_t primPtr)
bool semi_transparent = (pTag->code & 2) != 0; bool semi_transparent = (pTag->code & 2) != 0;
#if defined(PGXP) && defined(USE_32_BIT_ADDR) #if defined(USE_PGXP) && defined(USE_EXTENDED_PRIM_POINTERS)
unsigned short gte_index = pTag->pgxp_index; unsigned short gte_index = pTag->pgxp_index;
#else #else
unsigned short gte_index = 0xFFFF; unsigned short gte_index = 0xFFFF;
@ -1367,7 +1359,7 @@ int ParsePrimitive(uintptr_t primPtr)
} }
} }
#ifdef USE_32_BIT_ADDR #ifdef USE_EXTENDED_PRIM_POINTERS
return (pTag->len + 2) * sizeof(long); return (pTag->len + 2) * sizeof(long);
#else #else
return (pTag->len + 1) * sizeof(long); return (pTag->len + 1) * sizeof(long);
@ -1380,7 +1372,7 @@ int ParseLinkedPrimitiveList(uintptr_t packetStart, uintptr_t packetEnd)
int lastSize = -1; int lastSize = -1;
while (currentAddress < packetEnd) while (currentAddress != packetEnd)
{ {
lastSize = ParsePrimitive(currentAddress); lastSize = ParsePrimitive(currentAddress);

View File

@ -180,29 +180,37 @@ extern int (*GPU_printf)(const char *fmt, ...);
* Primitive Handling Macros * Primitive Handling Macros
*/ */
#define LEN_OFFSET (4) #if defined(USE_EXTENDED_PRIM_POINTERS)
#define isendprim(p) ((((P_TAG *)(p))->addr) == 0xffffffff)
#define nextPrim(p) (void *)(((P_TAG *)(p))->addr)
#define setaddr(p, _addr) (((P_TAG *)(p))->addr = (uintptr_t)((u_long*)_addr))
#define getaddr(p) (uintptr_t)(((P_TAG *)(p))->addr)
#else
#define isendprim(p) ((((P_TAG *)(p))->addr)==0xffffff)
#define nextPrim(p) (void *)((((P_TAG *)(p))->addr)|0x80000000)
#define setaddr(p, _addr) (((P_TAG *)(p))->addr = (u_long)((u_long*)_addr))
#define getaddr(p) (u_long)(((P_TAG *)(p))->addr)
#endif
#define setlen( p, _len) (((P_TAG *)(p))->len = (u_char)(_len)) #define setlen( p, _len) (((P_TAG *)(p))->len = (u_char)(_len))
#define setaddr(p, _addr) (((P_TAG *)(p))->addr = (u_long)((u_long*)_addr))
#define setcode(p, _code) (((P_TAG *)(p))->code = (u_char)(_code)) #define setcode(p, _code) (((P_TAG *)(p))->code = (u_char)(_code))
#define getlen(p) (u_char)(((P_TAG *)(p))->len) #define getlen(p) (u_char)(((P_TAG *)(p))->len)
#define getcode(p) (u_char)(((P_TAG *)(p))->code) #define getcode(p) (u_char)(((P_TAG *)(p))->code)
#define getaddr(p) (u_long)(((P_TAG *)(p))->addr)
#if defined(PGXP) && defined(USE_32_BIT_ADDR) #if defined(USE_PGXP) && defined(USE_EXTENDED_PRIM_POINTERS)
#define setpgxpindex(p, _pgxp_index) (((P_TAG *)(p))->pgxp_index = (u_short)(_pgxp_index)) #define setpgxpindex(p, i) (((P_TAG *)(p))->pgxp_index = (u_short)(i))
#define isendprim(p) ((((P_TAG *)(p))->addr)==0xffffffff)
#define nextPrim(p) (void *)(((P_TAG *)(p))->addr)
#define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p), setpgxpindex(p, PGXP_GetIndex()) #define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p), setpgxpindex(p, PGXP_GetIndex())
#else #else
#define isendprim(p) ((((P_TAG *)(p))->addr)==0xffffff)
#define nextPrim(p) (void *)((((P_TAG *)(p))->addr)|0x80000000)
#define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p) #define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p)
#endif #endif
#define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)),setaddr(ot, p0) #define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)),setaddr(ot, p0)
#define catPrim(p0, p1) setaddr(p0, p1) #define catPrim(p0, p1) setaddr(p0, p1)
@ -234,7 +242,7 @@ extern int (*GPU_printf)(const char *fmt, ...);
((0xe1000000)|((dtd)?0x0200:0)| \ ((0xe1000000)|((dtd)?0x0200:0)| \
((dfe)?0x0400:0)|((tpage)&0x9ff)) ((dfe)?0x0400:0)|((tpage)&0x9ff))
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
#define setDrawTPage(p, dfe, dtd, tpage) \ #define setDrawTPage(p, dfe, dtd, tpage) \
setlen(p, 1), \ setlen(p, 1), \
((u_long *)(p))[2] = _get_mode(dfe, dtd, tpage) ((u_long *)(p))[2] = _get_mode(dfe, dtd, tpage)
@ -273,7 +281,7 @@ extern int (*GPU_printf)(const char *fmt, ...);
((u_long *)p)[1] = 0xe6000000|(pbw?0x01:0), \ ((u_long *)p)[1] = 0xe6000000|(pbw?0x01:0), \
((u_long *)p)[2] = 0 ((u_long *)p)[2] = 0
#if defined(USE_32_BIT_ADDR) #if defined(USE_EXTENDED_PRIM_POINTERS)
#define setDrawMode(p, dfe, dtd, tpage, tw) \ #define setDrawMode(p, dfe, dtd, tpage, tw) \
setlen(p, 3), \ setlen(p, 3), \
((u_long *)p)[2] = _get_mode(dfe, dtd, tpage), \ ((u_long *)p)[2] = _get_mode(dfe, dtd, tpage), \
@ -330,21 +338,303 @@ typedef struct {
int w, h; /* width and height */ int w, h; /* width and height */
} RECT32; } RECT32;
// Psy-X custom struct to handle polygons
#if defined(USE_EXTENDED_PRIM_POINTERS)
#if defined(_M_X64) || defined(__amd64__)
#error Please add 64 bit support!
#define DECLARE_P_ADDR
#define P_LEN 4 // 4 longs
#else
#define DECLARE_P_ADDR \
uintptr_t addr; \
uint len : 16; \
uint pgxp_index : 16;
#define P_LEN 2 // 2 longs
#endif
#else // just don't use that, okay... it's just for reference
#define DECLARE_P_ADDR \
unsigned addr : 24; \
unsigned len : 8;
#define P_LEN 1 // 1 long
#endif
/*
* Polygon Primitive Definitions
*/
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
} P_TAG;
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
} POLY_F3; /* Flat Triangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
VERTTYPE x3, y3;
} POLY_F4; /* Flat Quadrangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad1;
} POLY_FT3; /* Flat Textured Triangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad1;
VERTTYPE x3, y3;
u_char u3, v3; u_short pad2;
} POLY_FT4; /* Flat Textured Quadrangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, pad1;
VERTTYPE x1, y1;
u_char r2, g2, b2, pad2;
VERTTYPE x2, y2;
} POLY_G3; /* Gouraud Triangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, pad1;
VERTTYPE x1, y1;
u_char r2, g2, b2, pad2;
VERTTYPE x2, y2;
u_char r3, g3, b3, pad3;
VERTTYPE x3, y3;
} POLY_G4; /* Gouraud Quadrangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad2;
} POLY_GT3; /* Gouraud Textured Triangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad2;
u_char r3, g3, b3, p3;//10
VERTTYPE x3, y3;//11
u_char u3, v3; u_short pad3;
} POLY_GT4; /* Gouraud Textured Quadrangle */
/*
* Line Primitive Definitions
*/
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
} LINE_F2; /* Unconnected Flat Line */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
} LINE_G2; /* Unconnected Gouraud Line */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
u_long pad;
} LINE_F3; /* 2 connected Flat Line */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_long pad;
} LINE_G3; /* 2 connected Gouraud Line */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
VERTTYPE x3, y3;
u_long pad;
} LINE_F4; /* 3 connected Flat Line Quadrangle */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char r3, g3, b3, p3;
VERTTYPE x3, y3;
u_long pad;
} LINE_G4; /* 3 connected Gouraud Line */
/*
* Sprite Primitive Definitions
*/
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE w, h;
} SPRT; /* free size Sprite */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
} SPRT_16; /* 16x16 Sprite */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
} SPRT_8; /* 8x8 Sprite */
/*
* Tile Primitive Definitions
*/
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE w, h;
} TILE; /* free size Tile */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_16; /* 16x16 Tile */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_8; /* 8x8 Tile */
typedef struct {
DECLARE_P_ADDR
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_1; /* 1x1 Tile */
/*
* Special Primitive Definitions
*/
typedef struct {
DECLARE_P_ADDR
u_long code[2];
} DR_MODE; /* Drawing Mode */
typedef struct {
DECLARE_P_ADDR
u_long code[2];
} DR_TWIN; /* Texture Window */
typedef struct {
DECLARE_P_ADDR
u_long code[2];
} DR_AREA; /* Drawing Area */
typedef struct {
DECLARE_P_ADDR
u_long code[2];
} DR_OFFSET; /* Drawing Offset */
typedef struct { /* MoveImage */
DECLARE_P_ADDR
u_long code[5];
} DR_MOVE;
typedef struct { /* LoadImage */
DECLARE_P_ADDR
u_long code[3];
u_long p[13];
} DR_LOAD;
typedef struct {
DECLARE_P_ADDR
u_long code[1];
} DR_TPAGE; /* Drawing TPage */
typedef struct {
DECLARE_P_ADDR
u_long code[2];
} DR_STP; /* Drawing STP */
/* /*
* Environment * Environment
*/ */
typedef struct { typedef struct {
#if defined(USE_32_BIT_ADDR) DECLARE_P_ADDR
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[15]; u_long code[15];
} DR_ENV; /* Packed Drawing Environment */ } DR_ENV; /* Packed Drawing Environment */
@ -368,569 +658,6 @@ typedef struct {
u_char pad0, pad1; /* reserved */ u_char pad0, pad1; /* reserved */
} DISPENV; } DISPENV;
/*
* Polygon Primitive Definitions
*/
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long addr;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
unsigned addr: 24;
unsigned len: 8;
#endif
u_char r0, g0, b0, code;
} P_TAG;
typedef struct {
u_char r0, g0, b0, code;
} P_CODE;
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
} POLY_F3; /* Flat Triangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
VERTTYPE x3, y3;
} POLY_F4; /* Flat Quadrangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad1;
} POLY_FT3; /* Flat Textured Triangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad1;
VERTTYPE x3, y3;
u_char u3, v3; u_short pad2;
} POLY_FT4; /* Flat Textured Quadrangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, pad1;
VERTTYPE x1, y1;
u_char r2, g2, b2, pad2;
VERTTYPE x2, y2;
} POLY_G3; /* Gouraud Triangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, pad1;
VERTTYPE x1, y1;
u_char r2, g2, b2, pad2;
VERTTYPE x2, y2;
u_char r3, g3, b3, pad3;
VERTTYPE x3, y3;
} POLY_G4; /* Gouraud Quadrangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad2;
} POLY_GT3; /* Gouraud Textured Triangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char u1, v1; u_short tpage;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char u2, v2; u_short pad2;
u_char r3, g3, b3, p3;//10
VERTTYPE x3, y3;//11
u_char u3, v3; u_short pad3;
} POLY_GT4; /* Gouraud Textured Quadrangle */
/*
* Line Primitive Definitions
*/
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
} LINE_F2; /* Unconnected Flat Line */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
} LINE_G2; /* Unconnected Gouraud Line */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
u_long pad;
} LINE_F3; /* 2 connected Flat Line */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_long pad;
} LINE_G3; /* 2 connected Gouraud Line */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE x1, y1;
VERTTYPE x2, y2;
VERTTYPE x3, y3;
u_long pad;
} LINE_F4; /* 3 connected Flat Line Quadrangle */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char r1, g1, b1, p1;
VERTTYPE x1, y1;
u_char r2, g2, b2, p2;
VERTTYPE x2, y2;
u_char r3, g3, b3, p3;
VERTTYPE x3, y3;
u_long pad;
} LINE_G4; /* 3 connected Gouraud Line */
/*
* Sprite Primitive Definitions
*/
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
VERTTYPE w, h;
} SPRT; /* free size Sprite */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
} SPRT_16; /* 16x16 Sprite */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
u_char u0, v0; u_short clut;
} SPRT_8; /* 8x8 Sprite */
/*
* Tile Primitive Definitions
*/
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
VERTTYPE w, h;
} TILE; /* free size Tile */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_16; /* 16x16 Tile */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_8; /* 8x8 Tile */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_char r0, g0, b0, code;
VERTTYPE x0, y0;
} TILE_1; /* 1x1 Tile */
/*
* Special Primitive Definitions
*/
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[2];
} DR_MODE; /* Drawing Mode */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[2];
} DR_TWIN; /* Texture Window */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[2];
} DR_AREA; /* Drawing Area */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[2];
} DR_OFFSET; /* Drawing Offset */
typedef struct { /* MoveImage */
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[5];
} DR_MOVE;
typedef struct { /* LoadImage */
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[3];
u_long p[13];
} DR_LOAD;
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[1];
} DR_TPAGE; /* Drawing TPage */
typedef struct {
#if defined(USE_32_BIT_ADDR)
unsigned long tag;
#if defined(PGXP)
unsigned short len;
unsigned short pgxp_index;
#else
unsigned long len;
#endif
#else
u_long tag;
#endif
u_long code[2];
} DR_STP; /* Drawing STP */
/* /*
* Font Stream Parameters * Font Stream Parameters
*/ */

View File

@ -462,7 +462,7 @@ int Lm_H(long long value, int sf) {
return value_12; return value_12;
} }
#ifdef PGXP #ifdef USE_PGXP
PGXPVector3D g_FP_SXYZ0; // direct access PGXP without table lookup PGXPVector3D g_FP_SXYZ0; // direct access PGXP without table lookup
PGXPVector3D g_FP_SXYZ1; PGXPVector3D g_FP_SXYZ1;
PGXPVector3D g_FP_SXYZ2; PGXPVector3D g_FP_SXYZ2;
@ -530,7 +530,7 @@ bool PGXP_GetCacheData(PGXPVData& out, uint lookup, ushort indexhint)
return false; return false;
} }
#endif // PGXP #endif // USE_PGXP
int GTE_RotTransPers(int idx, int lm) int GTE_RotTransPers(int idx, int lm)
{ {
@ -552,7 +552,7 @@ int GTE_RotTransPers(int idx, int lm)
C2_SX2 = Lm_G1(F((long long)C2_OFX + ((long long)C2_IR1 * h_over_sz3)) >> 16); C2_SX2 = Lm_G1(F((long long)C2_OFX + ((long long)C2_IR1 * h_over_sz3)) >> 16);
C2_SY2 = Lm_G2(F((long long)C2_OFY + ((long long)C2_IR2 * h_over_sz3)) >> 16); C2_SY2 = Lm_G2(F((long long)C2_OFY + ((long long)C2_IR2 * h_over_sz3)) >> 16);
#if defined(PGXP) #if defined(USE_PGXP)
// perform the same but in floating point // perform the same but in floating point
double fMAC1 = (/*int44*/(double)((float)C2_TRX * 4096.0f) + ((float)C2_R11 * (float)VX(idx)) + ((float)C2_R12 * (float)VY(idx)) + ((float)C2_R13 * (float)VZ(idx))); double fMAC1 = (/*int44*/(double)((float)C2_TRX * 4096.0f) + ((float)C2_R11 * (float)VX(idx)) + ((float)C2_R12 * (float)VY(idx)) + ((float)C2_R13 * (float)VZ(idx)));
double fMAC2 = (/*int44*/(double)((float)C2_TRY * 4096.0f) + ((float)C2_R21 * (float)VX(idx)) + ((float)C2_R22 * (float)VY(idx)) + ((float)C2_R23 * (float)VZ(idx))); double fMAC2 = (/*int44*/(double)((float)C2_TRY * 4096.0f) + ((float)C2_R21 * (float)VX(idx)) + ((float)C2_R22 * (float)VY(idx)) + ((float)C2_R23 * (float)VZ(idx)));
@ -621,7 +621,7 @@ int docop2(int op) {
GTELOG("%08x NCLIP", op); GTELOG("%08x NCLIP", op);
#endif #endif
#ifdef PGXP #ifdef USE_PGXP
{ {
float fSX0 = g_FP_SXYZ0.px; float fSX0 = g_FP_SXYZ0.px;
float fSY0 = g_FP_SXYZ0.py; float fSY0 = g_FP_SXYZ0.py;

View File

@ -1,7 +1,7 @@
#ifndef PGXP_DEFS_H #ifndef PGXP_DEFS_H
#define PGXP_DEFS_H #define PGXP_DEFS_H
#ifdef PGXP #ifdef USE_PGXP
#include "GTE/half_float.h" #include "GTE/half_float.h"
typedef half VERTTYPE; typedef half VERTTYPE;

View File

@ -0,0 +1,12 @@
#ifndef PSYX_CONFIG_H
#define PSYX_CONFIG_H
// Required. Uses 32 bit pointers on P_TAG and other primitives
#define USE_EXTENDED_PRIM_POINTERS
// PGXP-Z: Precise GTE transform pipeline with Z-depth and widescreen fixes. Recommended
#define USE_PGXP
#endif // PSYX_CONFIG_H

View File

@ -1,6 +1,8 @@
#ifndef _SYS_TYPES_H #ifndef _SYS_TYPES_H
#define _SYS_TYPES_H #define _SYS_TYPES_H
#include "PSYX_CONFIG.H"
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
@ -62,12 +64,6 @@ typedef long * qaddr_t;
typedef long swblk_t; typedef long swblk_t;
#endif #endif
#if !defined(__EMSCRIPTEN__)
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int size_t;
#endif
#endif
//typedef long time_t; //typedef long time_t;
//typedef short dev_t; //typedef short dev_t;