SPU: delay channel start until whenever it can actually start. fixes maxmod interpolated mode.

This commit is contained in:
Arisotura 2020-07-23 12:59:19 +02:00
parent 3827fa562f
commit 2f9a6b7c03
3 changed files with 12 additions and 2 deletions

View File

@ -160,6 +160,8 @@ void Channel::Reset()
else else
BusRead32 = NDS::ARM7Read32; BusRead32 = NDS::ARM7Read32;
KeyOn = false;
SetCnt(0); SetCnt(0);
SrcAddr = 0; SrcAddr = 0;
TimerReload = 0; TimerReload = 0;
@ -187,6 +189,7 @@ void Channel::DoSavestate(Savestate* file)
file->Var8(&VolumeShift); file->Var8(&VolumeShift);
file->Var8(&Pan); file->Var8(&Pan);
file->Var8((u8*)&KeyOn);
file->Var32(&Timer); file->Var32(&Timer);
file->Var32((u32*)&Pos); file->Var32((u32*)&Pos);
file->Var16((u16*)&CurSample); file->Var16((u16*)&CurSample);
@ -417,6 +420,12 @@ void Channel::Run(s32* buf, u32 samples)
{ {
if (!(Cnt & (1<<31))) return; if (!(Cnt & (1<<31))) return;
if (KeyOn)
{
Start();
KeyOn = false;
}
for (u32 s = 0; s < samples; s++) for (u32 s = 0; s < samples; s++)
{ {
Timer += 512; // 1 sample = 512 cycles at 16MHz Timer += 512; // 1 sample = 512 cycles at 16MHz

View File

@ -69,6 +69,7 @@ public:
u8 VolumeShift; u8 VolumeShift;
u8 Pan; u8 Pan;
bool KeyOn;
u32 Timer; u32 Timer;
s32 Pos; s32 Pos;
s16 CurSample; s16 CurSample;
@ -105,7 +106,7 @@ public:
if ((val & (1<<31)) && !(oldcnt & (1<<31))) if ((val & (1<<31)) && !(oldcnt & (1<<31)))
{ {
Start(); KeyOn = true;
} }
} }