aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/NDS.cpp2
-rw-r--r--src/SPU.cpp64
-rw-r--r--src/SPU.h6
3 files changed, 69 insertions, 3 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index 27356b2..1a1714a 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -511,7 +511,7 @@ bool DoSavestate(Savestate* file)
NDSCart::DoSavestate(file);
GPU::DoSavestate(file);
- // SPU
+ SPU::DoSavestate(file);
// SPI
// RTC
// wifi
diff --git a/src/SPU.cpp b/src/SPU.cpp
index 5a0eaa5..034e1aa 100644
--- a/src/SPU.cpp
+++ b/src/SPU.cpp
@@ -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++)
diff --git a/src/SPU.h b/src/SPU.h
index 94011bd..d340a72 100644
--- a/src/SPU.h
+++ b/src/SPU.h
@@ -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;