SPU: VolumeSlide: disregard phase when exp + decr

This commit is contained in:
Ziemas 2024-01-20 09:34:06 +01:00 committed by Connor McLaughlin
parent e3ca5833d0
commit 01849565aa
1 changed files with 16 additions and 2 deletions

View File

@ -144,11 +144,20 @@ void V_VolumeSlide::Update()
} }
} }
counter_inc = std::max<u32>(1, counter_inc); // Allow counter_inc to be zero only in when all bits
// of the rate field are set
if (Step != 3 && Shift != 0x1f)
{
counter_inc = std::max<u32>(1, counter_inc);
}
Counter += counter_inc; Counter += counter_inc;
// If negative phase "increase" to -0x8000 or "decrease" towards 0 // If negative phase "increase" to -0x8000 or "decrease" towards 0
level_inc = Phase ? -level_inc : level_inc; // Unless in Exp + Decr modes
if (!(Exp && Decr))
{
level_inc = Phase ? -level_inc : level_inc;
}
if (Counter >= 0x8000) if (Counter >= 0x8000)
{ {
@ -162,6 +171,11 @@ void V_VolumeSlide::Update()
{ {
s32 low = Phase ? INT16_MIN : 0; s32 low = Phase ? INT16_MIN : 0;
s32 high = Phase ? 0 : INT16_MAX; s32 high = Phase ? 0 : INT16_MAX;
if (Exp)
{
low = 0;
high = INT16_MAX;
}
Value = std::clamp<s32>(Value + level_inc, low, high); Value = std::clamp<s32>(Value + level_inc, low, high);
} }
} }