From b6ac4566ef7d828168c7ad15c4255aa770e47423 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Mon, 10 May 2021 17:46:02 +0600 Subject: [PATCH] - [Psy-X] make PGXP_LOOKUP_VALUE macro simpler to use --- src_rebuild/Game/C/motion_c.c | 12 ++++++------ src_rebuild/PsyX/include/PsyX/common/pgxp_defs.h | 2 +- src_rebuild/PsyX/include/psx/inline_c.h | 2 +- src_rebuild/PsyX/src/gpu/PsyX_GPU.cpp | 3 ++- src_rebuild/PsyX/src/gte/PsyX_GTE.cpp | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src_rebuild/Game/C/motion_c.c b/src_rebuild/Game/C/motion_c.c index 64840ca0..2474c662 100644 --- a/src_rebuild/Game/C/motion_c.c +++ b/src_rebuild/Game/C/motion_c.c @@ -611,8 +611,8 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP if (!bDoingShadow) // [A] Psy-X is currently incorrectly offsets the offscreen PGXP geometry. We don't need it anyway. { PGXPVData vdata1, vdata2; - PGXP_GetCacheData(&vdata1, PGXP_LOOKUP_VALUE(v1[0].sh, v1[1].sh), 0); - PGXP_GetCacheData(&vdata2, PGXP_LOOKUP_VALUE(v2[0].sh, v2[1].sh), 0); + PGXP_GetCacheData(&vdata1, PGXP_LOOKUP_VALUE(v1[0], v1[1]), 0); + PGXP_GetCacheData(&vdata2, PGXP_LOOKUP_VALUE(v2[0], v2[1]), 0); { float len; @@ -664,25 +664,25 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP } } - PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0.sh, prims->y0.sh), + PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0, prims->y0), vdata1.px + (FIXEDH(sn) - dx1) * 0.01f, vdata1.py + (FIXEDH(cs) + dy1) * 0.01f, vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy }; - PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1.sh, prims->y1.sh), + PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1, prims->y1), vdata1.px - (FIXEDH(sn) - dx1) * 0.01f, vdata1.py - (FIXEDH(cs) - dy1) * 0.01f, vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy }; - PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2.sh, prims->y2.sh), + PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2, prims->y2), vdata2.px + (FIXEDH(sn) + dx2) * 0.01f, vdata2.py + (FIXEDH(cs) - dy2) * 0.01f, vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy }; - PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3.sh, prims->y3.sh), + PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3, prims->y3), vdata2.px - (FIXEDH(sn) + dx2) * 0.01f, vdata2.py - (FIXEDH(cs) + dy2) * 0.01f, vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy }; diff --git a/src_rebuild/PsyX/include/PsyX/common/pgxp_defs.h b/src_rebuild/PsyX/include/PsyX/common/pgxp_defs.h index 4ed4dec9..91dd4910 100644 --- a/src_rebuild/PsyX/include/PsyX/common/pgxp_defs.h +++ b/src_rebuild/PsyX/include/PsyX/common/pgxp_defs.h @@ -5,7 +5,7 @@ #include "PsyX/common/half_float.h" // Helpful macro -#define PGXP_LOOKUP_VALUE(x, y) (x | (y << 16)) +#define PGXP_LOOKUP_VALUE(x, y) (*(u_short*)&(x) | (*(u_short*)&(y) << 16)) //------------------------------------- diff --git a/src_rebuild/PsyX/include/psx/inline_c.h b/src_rebuild/PsyX/include/psx/inline_c.h index 7fc5a7e5..c0f57b13 100644 --- a/src_rebuild/PsyX/include/psx/inline_c.h +++ b/src_rebuild/PsyX/include/psx/inline_c.h @@ -589,7 +589,7 @@ extern int doCOP2(int op); #define gte_stsxy0( r0 ) \ { *(uint*)((char*)r0) = MFC2(12);} -#endif +#endif // USE_PGXP // swc2 8 #define gte_stdp( r0 ) \ diff --git a/src_rebuild/PsyX/src/gpu/PsyX_GPU.cpp b/src_rebuild/PsyX/src/gpu/PsyX_GPU.cpp index 3b256ab3..df55b0f8 100644 --- a/src_rebuild/PsyX/src/gpu/PsyX_GPU.cpp +++ b/src_rebuild/PsyX/src/gpu/PsyX_GPU.cpp @@ -165,7 +165,8 @@ void MakeLineArray(GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx) inline void ApplyVertexPGXP(GrVertex* v, VERTTYPE* p, float ofsX, float ofsY, ushort gteidx) { #ifdef USE_PGXP - uint lookup = PGXP_LOOKUP_VALUE(p[0].sh, p[1].sh); + uint lookup = PGXP_LOOKUP_VALUE(p[0], p[1]); + PGXPVData vd; if (g_pgxpTextureCorrection && PGXP_GetCacheData(&vd, lookup, gteidx)) { diff --git a/src_rebuild/PsyX/src/gte/PsyX_GTE.cpp b/src_rebuild/PsyX/src/gte/PsyX_GTE.cpp index 5d2958e7..93299d1d 100644 --- a/src_rebuild/PsyX/src/gte/PsyX_GTE.cpp +++ b/src_rebuild/PsyX/src/gte/PsyX_GTE.cpp @@ -385,8 +385,8 @@ int GTE_RotTransPers(int idx, int lm) g_FP_SXYZ0 = g_FP_SXYZ1; g_FP_SXYZ1 = g_FP_SXYZ2; + // calculate projected values for cache PGXPVector3D temp; - temp.px = (double(C2_OFX) + double(float(C2_IR1) * float(h_over_sz3))) / float(1 << 16); temp.py = (double(C2_OFY) + double(float(C2_IR2) * float(h_over_sz3))) / float(1 << 16); temp.pz = float(max(C2_SZ3, C2_H / 2)) / float(1 << 16); @@ -401,7 +401,7 @@ int GTE_RotTransPers(int idx, int lm) // do not perform perspective multiplication so it stays in object space // perspective is performed exclusively in shader PGXPVData vdata; - vdata.lookup = PGXP_LOOKUP_VALUE(temp.x.sh, temp.y.sh); // hash short values + vdata.lookup = PGXP_LOOKUP_VALUE(temp.x, temp.y); // hash short values // FIXME: actually we scaling here entire geometry, is that correct? vdata.px = fMAC1 * one_by_v * g_pgxpZScale + g_pgxpZOffset;