X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fgte.c;h=3002a90b691d09478caaeaf642f727971fab2400;hp=72210d3491f74f2120937628ae6f13462faef2e7;hb=3ebefe711e0fb2fe941951b764ea5623436cf887;hpb=ef79bbde537d6b9c745a7d86cb9df1d04c35590d diff --git a/libpcsxcore/gte.c b/libpcsxcore/gte.c index 72210d34..3002a90b 100644 --- a/libpcsxcore/gte.c +++ b/libpcsxcore/gte.c @@ -211,7 +211,7 @@ static inline u32 limE(u32 result) { #define F(a) BOUNDS((a), 0x7fffffff, (1 << 31) | (1 << 16), -(s64)0x80000000, (1 << 31) | (1 << 15)) #define limG1(a) LIM((a), 0x3ff, -0x400, (1 << 31) | (1 << 14)) #define limG2(a) LIM((a), 0x3ff, -0x400, (1 << 31) | (1 << 13)) -#define limH(a) LIM((a), 0xfff, 0x000, (1 << 12)) +#define limH(a) LIM((a), 0x1000, 0x0000, (1 << 12)) #include "gte_divider.h" @@ -240,9 +240,6 @@ static inline u32 MFC2(int reg) { break; case 28: - case 30: - return 0; - case 29: psxRegs.CP2D.r[reg] = LIM(gteIR1 >> 7, 0x1f, 0, 0) | (LIM(gteIR2 >> 7, 0x1f, 0, 0) << 5) | @@ -289,8 +286,6 @@ static inline void MTC2(u32 value, int reg) { } break; - case 7: - case 29: case 31: return; @@ -348,6 +343,18 @@ void gteSWC2() { psxMemWrite32(_oB_, MFC2(_Rt_)); } +#if 0 +#define DIVIDE DIVIDE_ +static u32 DIVIDE_(s16 n, u16 d) { + if (n >= 0 && n < d * 2) { + s32 n_ = n; + return ((n_ << 16) + d / 2) / d; + //return (u32)((float)(n_ << 16) / (float)d + (float)0.5); + } + return 0xffffffff; +} +#endif + void gteRTPS() { int quotient; @@ -372,8 +379,8 @@ void gteRTPS() { 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)) >> 12); - gteIR0 = limH(gteMAC0); + gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient)); + gteIR0 = limH(gteMAC0 >> 12); } void gteRTPT() { @@ -402,8 +409,8 @@ void gteRTPT() { 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)) >> 12); - gteIR0 = limH(gteMAC0); + gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient)); + gteIR0 = limH(gteMAC0 >> 12); } void gteMVMVA() { @@ -473,9 +480,9 @@ void gteSQR() { gteMAC1 = A1((gteIR1 * gteIR1) >> shift); gteMAC2 = A2((gteIR2 * gteIR2) >> shift); gteMAC3 = A3((gteIR3 * gteIR3) >> shift); - gteIR1 = limB1(gteMAC1 >> shift, lm); - gteIR2 = limB2(gteMAC2 >> shift, lm); - gteIR3 = limB3(gteMAC3 >> shift, lm); + gteIR1 = limB1(gteMAC1, lm); + gteIR2 = limB2(gteMAC2, lm); + gteIR3 = limB3(gteMAC3, lm); } void gteNCCS() {