X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fgte.c;h=16e0a89ca770f4e532b2d7f4dae9940f21ecfbb6;hp=ec173b568859b96052743c917575d28838cdb8b9;hb=777506907b6d2283e9a7fb51cdcad497b8989e24;hpb=7384197d8a5fd20a4d94f3517a6462f7fe86dd4c diff --git a/libpcsxcore/gte.c b/libpcsxcore/gte.c index ec173b56..16e0a89c 100644 --- a/libpcsxcore/gte.c +++ b/libpcsxcore/gte.c @@ -168,6 +168,8 @@ #define gteop (psxRegs.code & 0x1ffffff) +#ifndef FLAGLESS + static inline s64 BOUNDS(s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) { if (n_value > n_max) { gteFLAG |= n_maxflag; @@ -189,6 +191,35 @@ static inline s32 LIM(s32 value, s32 max, s32 min, u32 flag) { return ret; } +static inline u32 limE(u32 result) { + if (result > 0x1ffff) { + gteFLAG |= (1 << 31) | (1 << 17); + return 0x1ffff; + } + return result; +} + +#else + +#define BOUNDS(a, ...) (a) + +static inline s32 LIM(s32 value, s32 max, s32 min, u32 flag_unused) { + s32 ret = value; + if (value > max) + ret = max; + else if (value < min) + ret = min; + return ret; +} + +static inline u32 limE(u32 result) { + if (result > 0x1ffff) + return 0x1ffff; + return result; +} + +#endif + #define A1(a) BOUNDS((a), 0x7fffffff, (1 << 30), -(s64)0x80000000, (1 << 31) | (1 << 27)) #define A2(a) BOUNDS((a), 0x7fffffff, (1 << 29), -(s64)0x80000000, (1 << 31) | (1 << 26)) #define A3(a) BOUNDS((a), 0x7fffffff, (1 << 28), -(s64)0x80000000, (1 << 31) | (1 << 25)) @@ -200,14 +231,6 @@ static inline s32 LIM(s32 value, s32 max, s32 min, u32 flag) { #define limC3(a) LIM((a), 0x00ff, 0x0000, (1 << 19)) #define limD(a) LIM((a), 0xffff, 0x0000, (1 << 31) | (1 << 18)) -static inline u32 limE(u32 result) { - if (result > 0x1ffff) { - gteFLAG |= (1 << 31) | (1 << 17); - return 0x1ffff; - } - return 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)) @@ -215,6 +238,8 @@ static inline u32 limE(u32 result) { #include "gte_divider.h" +#ifndef FLAGLESS + static inline u32 MFC2(int reg) { switch (reg) { case 1: @@ -343,6 +368,9 @@ void gteSWC2() { psxMemWrite32(_oB_, MFC2(_Rt_)); } +#endif // FLAGLESS + +#if 0 #define DIVIDE DIVIDE_ static u32 DIVIDE_(s16 n, u16 d) { if (n >= 0 && n < d * 2) { @@ -352,6 +380,7 @@ static u32 DIVIDE_(s16 n, u16 d) { } return 0xffffffff; } +#endif void gteRTPS() { int quotient; @@ -377,8 +406,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() { @@ -407,8 +436,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() {