aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FIFO.h2
-rw-r--r--src/GPU.cpp49
-rw-r--r--src/GPU2D.cpp58
-rw-r--r--src/GPU2D.h2
-rw-r--r--src/GPU3D.cpp76
-rw-r--r--src/GPU3D.h3
-rw-r--r--src/NDS.cpp8
7 files changed, 192 insertions, 6 deletions
diff --git a/src/FIFO.h b/src/FIFO.h
index fbb1bbf..7ce67e9 100644
--- a/src/FIFO.h
+++ b/src/FIFO.h
@@ -47,7 +47,7 @@ public:
}
- void Savestate(Savestate* file)
+ void DoSavestate(Savestate* file)
{
file->Var32(&NumOccupied);
file->Var32(&ReadPos);
diff --git a/src/GPU.cpp b/src/GPU.cpp
index c06ecfd..aba97a5 100644
--- a/src/GPU.cpp
+++ b/src/GPU.cpp
@@ -158,7 +158,54 @@ void Stop()
void DoSavestate(Savestate* file)
{
- //
+ file->Section("GPUG");
+
+ file->Var16(&VCount);
+ file->Var32(&NextVCount);
+ file->Var16(&TotalScanlines);
+
+ file->Var16(&DispStat[0]);
+ file->Var16(&DispStat[1]);
+ file->Var16(&VMatch[0]);
+ file->Var16(&VMatch[1]);
+
+ file->VarArray(Palette, 2*1024);
+ file->VarArray(OAM, 2*1024);
+
+ file->VarArray(VRAM_A, 128*1024);
+ file->VarArray(VRAM_B, 128*1024);
+ file->VarArray(VRAM_C, 128*1024);
+ file->VarArray(VRAM_D, 128*1024);
+ file->VarArray(VRAM_E, 64*1024);
+ file->VarArray(VRAM_F, 16*1024);
+ file->VarArray(VRAM_G, 16*1024);
+ file->VarArray(VRAM_H, 32*1024);
+ file->VarArray(VRAM_I, 16*1024);
+
+ file->VarArray(VRAMCNT, 9);
+ file->Var8(&VRAMSTAT);
+
+ file->Var32(&VRAMMap_LCDC);
+
+ file->VarArray(VRAMMap_ABG, sizeof(VRAMMap_ABG));
+ file->VarArray(VRAMMap_AOBJ, sizeof(VRAMMap_AOBJ));
+ file->VarArray(VRAMMap_BBG, sizeof(VRAMMap_BBG));
+ file->VarArray(VRAMMap_BOBJ, sizeof(VRAMMap_BOBJ));
+
+ file->VarArray(VRAMMap_ABGExtPal, sizeof(VRAMMap_ABGExtPal));
+ file->Var32(&VRAMMap_AOBJExtPal);
+ file->VarArray(VRAMMap_BBGExtPal, sizeof(VRAMMap_BBGExtPal));
+ file->Var32(&VRAMMap_BOBJExtPal);
+
+ file->VarArray(VRAMMap_Texture, sizeof(VRAMMap_Texture));
+ file->VarArray(VRAMMap_TexPal, sizeof(VRAMMap_TexPal));
+
+ file->Var32(&VRAMMap_ARM7[0]);
+ file->Var32(&VRAMMap_ARM7[1]);
+
+ GPU2D_A->DoSavestate(file);
+ GPU2D_B->DoSavestate(file);
+ GPU3D::DoSavestate(file);
}
diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp
index 3edfc44..078374b 100644
--- a/src/GPU2D.cpp
+++ b/src/GPU2D.cpp
@@ -138,6 +138,64 @@ void GPU2D::Reset()
OBJExtPalStatus = 0;
}
+void GPU2D::DoSavestate(Savestate* file)
+{
+ file->Section((char*)(Num ? "GP2B" : "GP2A"));
+
+ file->Var32(&DispCnt);
+ file->VarArray(BGCnt, 4*2);
+ file->VarArray(BGXPos, 4*2);
+ file->VarArray(BGYPos, 4*2);
+ file->VarArray(BGXRef, 2*4);
+ file->VarArray(BGYRef, 2*4);
+ file->VarArray(BGXRefInternal, 2*4);
+ file->VarArray(BGYRefInternal, 2*4);
+ file->VarArray(BGRotA, 2*2);
+ file->VarArray(BGRotB, 2*2);
+ file->VarArray(BGRotC, 2*2);
+ file->VarArray(BGRotD, 2*2);
+
+ file->VarArray(Win0Coords, 4);
+ file->VarArray(Win1Coords, 4);
+ file->VarArray(WinCnt, 4);
+
+ file->VarArray(BGMosaicSize, 2);
+ file->VarArray(OBJMosaicSize, 2);
+ file->Var8(&BGMosaicY);
+ file->Var8(&BGMosaicYMax);
+ file->Var8(&OBJMosaicY);
+ file->Var8(&OBJMosaicYMax);
+
+ file->Var16(&BlendCnt);
+ file->Var16(&BlendAlpha);
+ file->Var8(&EVA);
+ file->Var8(&EVB);
+ file->Var8(&EVY);
+
+ file->Var16(&MasterBrightness);
+
+ if (!Num)
+ {
+ file->VarArray(DispFIFO, 16*2);
+ file->Var32(&DispFIFOReadPtr);
+ file->Var32(&DispFIFOWritePtr);
+
+ file->VarArray(DispFIFOBuffer, 256*2);
+
+ file->Var32(&CaptureCnt);
+ }
+
+ if (!file->Saving)
+ {
+ // refresh those
+ BGExtPalStatus[0] = 0;
+ BGExtPalStatus[1] = 0;
+ BGExtPalStatus[2] = 0;
+ BGExtPalStatus[3] = 0;
+ OBJExtPalStatus = 0;
+ }
+}
+
void GPU2D::SetFramebuffer(u32* buf)
{
Framebuffer = buf;
diff --git a/src/GPU2D.h b/src/GPU2D.h
index 8eafc21..307ff33 100644
--- a/src/GPU2D.h
+++ b/src/GPU2D.h
@@ -27,6 +27,8 @@ public:
void Reset();
+ void DoSavestate(Savestate* file);
+
void SetFramebuffer(u32* buf);
u8 Read8(u32 addr);
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp
index 13c721c..1f3a64e 100644
--- a/src/GPU3D.cpp
+++ b/src/GPU3D.cpp
@@ -45,7 +45,7 @@
// the added bias affects interpolation.
//
// depth buffer:
-// Z-buffering mode: val = ((Z * 0x800 * 0x1000) / W) + 0x7FFEFF
+// Z-buffering mode: val = ((Z * 0x800 * 0x1000) / W) + 0x7FFEFF (nope, wrong. TODO update)
// W-buffering mode: val = W
//
// formula for clear depth: (GBAtek is wrong there)
@@ -351,6 +351,80 @@ void Reset()
SoftRenderer::Reset();
}
+void DoSavestate(Savestate* file)
+{
+ file->Section("GP3D");
+
+ CmdFIFO->DoSavestate(file);
+ CmdPIPE->DoSavestate(file);
+
+ file->Var32(&NumCommands);
+ file->Var32(&CurCommand);
+ file->Var32(&ParamCount);
+ file->Var32(&TotalParams);
+
+ file->Var32(&NumPushPopCommands);
+ file->Var32(&NumTestCommands);
+
+ file->Var32(&DispCnt);
+ file->Var8(&AlphaRef);
+
+ file->Var32(&GXStat);
+
+ file->VarArray(ExecParams, 32*4);
+ file->Var32(&ExecParamCount);
+ file->Var32((u32*)&CycleCount);
+
+ file->Var32(&MatrixMode);
+
+ file->VarArray(ProjMatrix, 16*4);
+ file->VarArray(PosMatrix, 16*4);
+ file->VarArray(VecMatrix, 16*4);
+ file->VarArray(TexMatrix, 16*4);
+
+ file->VarArray(ProjMatrixStack, 16*4);
+ file->VarArray(PosMatrixStack, 31*16*4);
+ file->VarArray(VecMatrixStack, 31*16*4);
+ file->VarArray(TexMatrixStack, 16*4);
+
+ file->Var32((u32*)&ProjMatrixStackPointer);
+ file->Var32((u32*)&PosMatrixStackPointer);
+ file->Var32((u32*)&TexMatrixStackPointer);
+
+ file->VarArray(Viewport, sizeof(Viewport));
+
+ file->VarArray(PosTestResult, 4*4);
+ file->VarArray(VecTestResult, 2*3);
+
+ file->Var32(&VertexNum);
+ file->Var32(&VertexNumInPoly);
+
+ file->Var32(&CurRAMBank);
+ file->Var32(&NumVertices);
+ file->Var32(&NumPolygons);
+ file->Var32(&NumOpaquePolygons);
+
+ file->Var32(&ClearAttr1);
+ file->Var32(&ClearAttr2);
+
+ file->Var32(&FlushRequest);
+ file->Var32(&FlushAttributes);
+
+ file->VarArray(VertexRAM, sizeof(Vertex)*6144*2);
+ file->VarArray(PolygonRAM, sizeof(Polygon)*2048*2);
+
+ // probably not worth storing the vblank-latched Renderxxxxxx variables
+
+ if (!file->Saving)
+ {
+ ClipMatrixDirty = true;
+ UpdateClipMatrix();
+
+ CurVertexRAM = &VertexRAM[CurRAMBank];
+ CurPolygonRAM = &PolygonRAM[CurRAMBank];
+ }
+}
+
void MatrixLoadIdentity(s32* m)
diff --git a/src/GPU3D.h b/src/GPU3D.h
index 0a299ef..c997a8f 100644
--- a/src/GPU3D.h
+++ b/src/GPU3D.h
@@ -20,6 +20,7 @@
#define GPU3D_H
#include <array>
+#include "Savestate.h"
namespace GPU3D
{
@@ -85,6 +86,8 @@ bool Init();
void DeInit();
void Reset();
+void DoSavestate(Savestate* file);
+
void ExecuteCommand();
void Run(s32 cycles);
diff --git a/src/NDS.cpp b/src/NDS.cpp
index 8d3afbf..27356b2 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -474,8 +474,8 @@ bool DoSavestate(Savestate* file)
file->Var16(&IPCSync7);
file->Var16(&IPCFIFOCnt9);
file->Var16(&IPCFIFOCnt7);
- IPCFIFO9->Savestate(file);
- IPCFIFO7->Savestate(file);
+ IPCFIFO9->DoSavestate(file);
+ IPCFIFO7->DoSavestate(file);
file->Var16(&DivCnt);
file->Var16(&SqrtCnt);
@@ -510,11 +510,13 @@ bool DoSavestate(Savestate* file)
CP15::DoSavestate(file);
NDSCart::DoSavestate(file);
- // GPU
+ GPU::DoSavestate(file);
// SPU
// SPI
// RTC
// wifi
+
+ return true;
}
bool LoadROM(const char* path, bool direct)