diff options
Diffstat (limited to 'src/SPU.cpp')
-rw-r--r-- | src/SPU.cpp | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/src/SPU.cpp b/src/SPU.cpp index 7f70e65..034e1aa 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -1,5 +1,5 @@ /* - Copyright 2016-2017 StapleButter + Copyright 2016-2019 StapleButter This file is part of melonDS. @@ -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++) |