This commit is contained in:
StapleButter 2018-10-18 02:45:38 +02:00
parent a2cc7087f7
commit 7bf62918cd
3 changed files with 69 additions and 3 deletions

View File

@ -511,7 +511,7 @@ bool DoSavestate(Savestate* file)
NDSCart::DoSavestate(file);
GPU::DoSavestate(file);
// SPU
SPU::DoSavestate(file);
// SPI
// RTC
// wifi

View File

@ -24,8 +24,6 @@
// SPU TODO
// * loop mode 3, what does it do?
// * the FIFO, whatever it is. GBAtek mentions it but gives no details.
// * consider mixing every sample instead of every 16?
namespace SPU
@ -121,6 +119,21 @@ void Stop()
memset(OutputBuffer, 0, 2*OutputBufferSize*2);
}
void DoSavestate(Savestate* file)
{
file->Section("SPU.");
file->Var16(&Cnt);
file->Var8(&MasterVolume);
file->Var16(&Bias);
for (int i = 0; i < 16; i++)
Channels[i]->DoSavestate(file);
Capture[0]->DoSavestate(file);
Capture[1]->DoSavestate(file);
}
void SetBias(u16 bias)
{
@ -154,6 +167,36 @@ void Channel::Reset()
FIFOLevel = 0;
}
void Channel::DoSavestate(Savestate* file)
{
file->Var32(&Cnt);
file->Var32(&SrcAddr);
file->Var16(&TimerReload);
file->Var32(&LoopPos);
file->Var32(&Length);
file->Var8(&Volume);
file->Var8(&VolumeShift);
file->Var8(&Pan);
file->Var32(&Timer);
file->Var32((u32*)&Pos);
file->Var16((u16*)&CurSample);
file->Var16(&NoiseVal);
file->Var32((u32*)&ADPCMVal);
file->Var32((u32*)&ADPCMIndex);
file->Var32((u32*)&ADPCMValLoop);
file->Var32((u32*)&ADPCMIndexLoop);
file->Var8(&ADPCMCurByte);
file->Var32(&FIFOReadPos);
file->Var32(&FIFOWritePos);
file->Var32(&FIFOReadOffset);
file->Var32(&FIFOLevel);
file->VarArray(FIFO, 8*4);
}
void Channel::FIFO_BufferData()
{
u32 totallen = LoopPos + Length;
@ -439,6 +482,23 @@ void CaptureUnit::Reset()
FIFOLevel = 0;
}
void CaptureUnit::DoSavestate(Savestate* file)
{
file->Var8(&Cnt);
file->Var32(&DstAddr);
file->Var16(&TimerReload);
file->Var32(&Length);
file->Var32(&Timer);
file->Var32((u32*)&Pos);
file->Var32(&FIFOReadPos);
file->Var32(&FIFOWritePos);
file->Var32(&FIFOWriteOffset);
file->Var32(&FIFOLevel);
file->VarArray(FIFO, 4*4);
}
void CaptureUnit::FIFO_FlushData()
{
for (u32 i = 0; i < 4; i++)

View File

@ -19,6 +19,8 @@
#ifndef SPU_H
#define SPU_H
#include "Savestate.h"
namespace SPU
{
@ -27,6 +29,8 @@ void DeInit();
void Reset();
void Stop();
void DoSavestate(Savestate* file);
void SetBias(u16 bias);
void Mix(u32 samples);
@ -46,6 +50,7 @@ public:
Channel(u32 num);
~Channel();
void Reset();
void DoSavestate(Savestate* file);
u32 Num;
@ -137,6 +142,7 @@ public:
CaptureUnit(u32 num);
~CaptureUnit();
void Reset();
void DoSavestate(Savestate* file);
u32 Num;