psx|spu2x|gsdx: shift negative value is undefined in C standard

Instead does the negation after the shift

v2: assert shift <= 15 in clamp_mix
This commit is contained in:
Gregory Hainaut 2017-04-23 19:08:29 +02:00
parent 9d99889703
commit dc00af8829
3 changed files with 8 additions and 7 deletions

View File

@ -468,9 +468,9 @@ __inline double limG2(double x) {
return (x);
}
__inline s32 F12limA1S(s64 x) { _LIMX(-32768 << 12, 32767 << 12, 24); }
__inline s32 F12limA2S(s64 x) { _LIMX(-32768 << 12, 32767 << 12, 23); }
__inline s32 F12limA3S(s64 x) { _LIMX(-32768 << 12, 32767 << 12, 22); }
__inline s32 F12limA1S(s64 x) { _LIMX(-(32768 << 12), 32767 << 12, 24); }
__inline s32 F12limA2S(s64 x) { _LIMX(-(32768 << 12), 32767 << 12, 23); }
__inline s32 F12limA3S(s64 x) { _LIMX(-(32768 << 12), 32767 << 12, 22); }
__inline s32 F12limA1U(s64 x) { _LIMX(0, 32767 << 12, 24); }
__inline s32 F12limA2U(s64 x) { _LIMX(0, 32767 << 12, 23); }
__inline s32 F12limA3U(s64 x) { _LIMX(0, 32767 << 12, 22); }

View File

@ -1140,7 +1140,7 @@ bool GSRendererSW::GetScanlineGlobalData(SharedData* data)
else
{
gd.mxl = GSVector4((float)mxl);
gd.l = GSVector4((float)(-0x10000 << context->TEX1.L));
gd.l = GSVector4((float)(-(0x10000 << context->TEX1.L)));
gd.k = GSVector4((float)k);
}

View File

@ -53,7 +53,8 @@ static __forceinline s32 MulShr32(s32 srcval, s32 mulval)
__forceinline s32 clamp_mix(s32 x, u8 bitshift)
{
return GetClamped(x, -0x8000 << bitshift, 0x7fff << bitshift);
assert(bitshift <= 15);
return GetClamped(x, -(0x8000 << bitshift), 0x7fff << bitshift);
}
#if _MSC_VER
@ -72,8 +73,8 @@ __forceinline
// modules or sound drivers could (will :p) overshoot with that. So giving it a small safety.
return StereoOut32(
GetClamped(sample.Left, -0x7f00 << bitshift, 0x7f00 << bitshift),
GetClamped(sample.Right, -0x7f00 << bitshift, 0x7f00 << bitshift));
GetClamped(sample.Left, -(0x7f00 << bitshift), 0x7f00 << bitshift),
GetClamped(sample.Right, -(0x7f00 << bitshift), 0x7f00 << bitshift));
}
static void __forceinline XA_decode_block(s16 *buffer, const s16 *block, s32 &prev1, s32 &prev2)