From 233f66db5e1bbcc1d551e858c91217266c209c9c Mon Sep 17 00:00:00 2001 From: Pseudonym Date: Tue, 1 Nov 2016 11:09:08 +0000 Subject: [PATCH] Fixed effects area wrapping calculation, which was always buggy but this wasn't evident until additional addresses were precalculated. Not expected to improve compatibility. --- plugins/spu2-x/src/spu2sys.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/spu2-x/src/spu2sys.cpp b/plugins/spu2-x/src/spu2sys.cpp index a46cfface5..218e84faa7 100644 --- a/plugins/spu2-x/src/spu2sys.cpp +++ b/plugins/spu2-x/src/spu2sys.cpp @@ -229,17 +229,13 @@ s32 V_Core::EffectsBufferIndexer(s32 offset) const // already x4'd. It doesn't really make sense that we should x4 them again, and this // seems to work. (feedback-free in bios and DDS) --air - u32 pos = EffectsStartA + offset; - // Need to use modulus here, because games can and will drop the buffer size // without notice, and it leads to offsets several times past the end of the buffer. - if (pos > EffectsEndA) { - pos = EffectsStartA + (offset % EffectsBufferSize); - } else if (pos < EffectsStartA) { - pos = EffectsEndA + 1 - (offset % EffectsBufferSize); - } - return pos; + if ((u32)offset >= (u32)EffectsBufferSize) + return EffectsStartA + (offset % EffectsBufferSize) + (offset < 0 ? EffectsBufferSize : 0); + else + return EffectsStartA + offset; } void V_Core::UpdateEffectsBufferSize()