From 216c2ff3aefc9e0295ed9b1486935d65f6c13f55 Mon Sep 17 00:00:00 2001 From: iCatButler Date: Mon, 2 May 2016 15:01:27 +0100 Subject: Fix bugs from previous Fix stray triangles - Switch to full floating point RTPS/RTPT - Clamp w values to near plane Fix texture corruption in 1.78, copy 2.4 Tweak - Remove matrix replacement - Add W component to vertices - Wrap glVertex3fv calls - Use counter to call glVertex4fv for PGXP vertices only --- libpcsxcore/gte.c | 16 ++++++++-------- libpcsxcore/pgxp_gte.c | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/gte.c b/libpcsxcore/gte.c index 2d02032a..abe3c205 100755 --- a/libpcsxcore/gte.c +++ b/libpcsxcore/gte.c @@ -497,11 +497,11 @@ int docop2(int op) { SX2 = Lm_G1(F((s64) OFX + ((s64) IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)) >> 16); SY2 = Lm_G2(F((s64) OFY + ((s64) IR2 * h_over_sz3)) >> 16); - PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), - Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), - SZ3, SXY2); + //PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), + // Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), + // SZ3, SXY2); - //PGXP_RTPS(0, SXY2); + PGXP_RTPS(0, SXY2); MAC0 = F((s64) DQB + ((s64) DQA * h_over_sz3)); IR0 = Lm_H(m_mac0, 1); @@ -889,11 +889,11 @@ int docop2(int op) { SX2 = Lm_G1(F((s64) OFX + ((s64) IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)) >> 16); SY2 = Lm_G2(F((s64) OFY + ((s64) IR2 * h_over_sz3)) >> 16); - PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), - Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), - SZ3, SXY2); + //PGXP_pushSXYZ2s(Lm_G1_ia((s64)OFX + (s64)(IR1 * h_over_sz3) * (Config.Widescreen ? 0.75 : 1)), + // Lm_G2_ia((s64)OFY + (s64)(IR2 * h_over_sz3)), + // SZ3, SXY2); - //PGXP_RTPS(v, SXY2); + PGXP_RTPS(v, SXY2); } MAC0 = F((s64) DQB + ((s64) DQA * h_over_sz3)); diff --git a/libpcsxcore/pgxp_gte.c b/libpcsxcore/pgxp_gte.c index d5341dc6..5d681d85 100644 --- a/libpcsxcore/pgxp_gte.c +++ b/libpcsxcore/pgxp_gte.c @@ -306,8 +306,8 @@ void PGXP_RTPS(u32 _n, u32 _v) float MAC2 = TRY + (R21 * VX(_n)) + (R22 * VY(_n)) + (R23 * VZ(_n)); float MAC3 = TRZ + (R31 * VX(_n)) + (R32 * VY(_n)) + (R33 * VZ(_n)); - float SZ3 = MAC3; float H = psxRegs.CP2C.p[26].sw.l; + float SZ3 = max(MAC3, H); float h_over_sz3 = H / SZ3; // Offsets with 16-bit shift @@ -333,26 +333,26 @@ int PGXP_NLCIP_valid() float PGXP_NCLIP() { -// float nclip = ((SX0 * SY1) + (SX1 * SY2) + (SX2 * SY0) - (SX0 * SY2) - (SX1 * SY0) - (SX2 * SY1)); + float nclip = ((SX0 * SY1) + (SX1 * SY2) + (SX2 * SY0) - (SX0 * SY2) - (SX1 * SY0) - (SX2 * SY1)); // ensure fractional values are not incorrectly rounded to 0 - //if ((fabs(nclip) < 1.0f) && (nclip != 0)) - // nclip += (nclip < 0.f ? -1 : 1); + if ((fabs(nclip) < 1.0f) && (nclip != 0)) + nclip += (nclip < 0.f ? -1 : 1); - float AX = SX1 - SX0; - float AY = SY1 - SY0; + //float AX = SX1 - SX0; + //float AY = SY1 - SY0; - float BX = SX2 - SX0; - float BY = SY2 - SY0; + //float BX = SX2 - SX0; + //float BY = SY2 - SY0; - // normalise A and B - float mA = sqrt((AX*AX) + (AY*AY)); - float mB = sqrt((BX*BX) + (BY*BY)); + //// normalise A and B + //float mA = sqrt((AX*AX) + (AY*AY)); + //float mB = sqrt((BX*BX) + (BY*BY)); - // calculate AxB to get Z component of C - float CZ = ((AX * BY) - (AY * BX)) * (1 << 12); + //// calculate AxB to get Z component of C + //float CZ = ((AX * BY) - (AY * BX)) * (1 << 12); - return CZ;// nclip; + return nclip; } static precise_value PGXP_MFC2_int(u32 reg) -- cgit v1.2.3