summaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-05-06 17:12:31 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-05-06 17:12:31 +0100
commitca61b53f6c99e49de4620395bc8dbe5b71c9e2db (patch)
treeff573393e15c8eb343d499c637c4bc846419024e /libpcsxcore
parent4b706847d4ffbaa72b2d2a39130f71b0d2a401b6 (diff)
downloadpcsxr-ca61b53f6c99e49de4620395bc8dbe5b71c9e2db.tar.gz
More fixes for persective correct build
- Switch back to fixed point GTE - Only clamp w to h/2 after divide - Fix vertex function for multi-pass (was overwriting vertexon first pass)
Diffstat (limited to 'libpcsxcore')
-rwxr-xr-xlibpcsxcore/gte.c25
-rw-r--r--libpcsxcore/pgxp_gte.c31
2 files changed, 43 insertions, 13 deletions
diff --git a/libpcsxcore/gte.c b/libpcsxcore/gte.c
index abe3c205..2938d170 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)),
+ max(SZ3, H/2), SXY2);
- PGXP_RTPS(0, SXY2);
+ //PGXP_RTPS(0, SXY2);
MAC0 = F((s64) DQB + ((s64) DQA * h_over_sz3));
IR0 = Lm_H(m_mac0, 1);
@@ -888,12 +888,19 @@ int docop2(int op) {
SXY1 = SXY2;
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_RTPS(v, SXY2);
+ //float tempMx = MAC1;
+ //float tempx = IR1;
+ //float temphow = (float)h_over_sz3 / (float)(1 << 16);
+
+ //float tempMz = MAC3;
+ //float tempZ = SZ3;
+ //
+ 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)),
+ max(SZ3, H/2), 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 3ee5db22..3844e6be 100644
--- a/libpcsxcore/pgxp_gte.c
+++ b/libpcsxcore/pgxp_gte.c
@@ -306,19 +306,42 @@ 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 IR1 = max(min(MAC1, 0x7fff), -0x8000);
+ float IR2 = max(min(MAC2, 0x7fff), -0x8000);
+ float IR3 = max(min(MAC3, 0x7fff), -0x8000);
+
float H = psxRegs.CP2C.p[26].sw.l; // Near plane
float F = 0xFFFF; // Far plane?
- float SZ3 = max(MAC3, H); // Clamp SZ3 to near plane because we have no clipping (no proper Z)
+ float SZ3 = max(min(MAC3, 0xffff), 0x0000); // Clamp SZ3 to near plane because we have no clipping (no proper Z)
// float h_over_sz3 = H / SZ3;
// Offsets with 16-bit shift
float OFX = (float)psxRegs.CP2C.p[24].sd / (float)(1 << 16);
float OFY = (float)psxRegs.CP2C.p[25].sd / (float)(1 << 16);
+ float h_over_w = min(H / SZ3, (float)0x1ffff / (float)0xffff);
+ h_over_w = (SZ3 == 0) ? ((float)0x1ffff / (float)0xffff) : h_over_w;
+
// PSX Screen space X,Y,W components
- float sx = OFX + (MAC1 * (H / SZ3)) * (Config.Widescreen ? 0.75 : 1);
- float sy = OFY + (MAC2 * (H / SZ3));
- float sw = SZ3;
+ float sx = OFX + (IR1 * h_over_w) * (Config.Widescreen ? 0.75 : 1);
+ float sy = OFY + (IR2 * h_over_w);
+ float sw = SZ3;// max(SZ3, 0.1);
+
+ sx = max(min(sx, 1024.f), -1024.f);
+ sy = max(min(sy, 1024.f), -1024.f);
+
+ //float sx2 = SX2;
+ //float sy2 = SY2;
+ //float sz2 = SXY2.z;
+
+ //float ftolerance = 5.f;
+
+ //if ((fabs(sx - sx2) > ftolerance) ||
+ // (fabs(sy - sy2) > ftolerance) ||
+ // (fabs(sw - sz2) > ftolerance))
+ //{
+ // float r = 5;
+ //}
PGXP_pushSXYZ2f(sx , sy , sw, _v);