Merge pull request #127 from retro-wertz/fix_rtps_rtpt
authornotaz <notasas@gmail.com>
Mon, 25 Mar 2019 21:48:57 +0000 (23:48 +0200)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2019 21:48:57 +0000 (23:48 +0200)
gte: backport fix for RTPS/RTPT

1  2 
libpcsxcore/gte.c

diff --combined libpcsxcore/gte.c
  
  #ifndef FLAGLESS
  
 -static inline s32 BOUNDS_(psxCP2Regs *regs, s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) {
 +static inline s64 BOUNDS_(psxCP2Regs *regs, s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) {
        if (n_value > n_max) {
                gteFLAG |= n_maxflag;
        } else if (n_value < n_min) {
@@@ -404,6 -404,7 +404,7 @@@ static u32 DIVIDE_(s16 n, u16 d) 
  
  void gteRTPS(psxCP2Regs *regs) {
        int quotient;
+       s64 tmp;
  
  #ifdef GTE_LOG
        GTE_LOG("GTE RTPS\n");
        gteSX2 = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
        gteSY2 = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
  
-       gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient));
-       gteIR0 = limH(gteMAC0 >> 12);
+       tmp = (s64)gteDQB + ((s64)gteDQA * quotient);
+       gteMAC0 = F(tmp);
+       gteIR0 = limH(tmp >> 12);
  }
  
  void gteRTPT(psxCP2Regs *regs) {
        int quotient;
        int v;
        s32 vx, vy, vz;
+       s64 tmp;
  
  #ifdef GTE_LOG
        GTE_LOG("GTE RTPT\n");
                fSX(v) = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
                fSY(v) = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
        }
-       gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient));
-       gteIR0 = limH(gteMAC0 >> 12);
+       tmp = (s64)gteDQB + ((s64)gteDQA * quotient);
+       gteMAC0 = F(tmp);
+       gteIR0 = limH(tmp >> 12);
  }
  
  void gteMVMVA(psxCP2Regs *regs) {