This commit is contained in:
StapleButter 2018-10-18 02:31:01 +02:00
parent 148f4032f1
commit a2cc7087f7
7 changed files with 192 additions and 6 deletions

View File

@ -47,7 +47,7 @@ public:
} }
void Savestate(Savestate* file) void DoSavestate(Savestate* file)
{ {
file->Var32(&NumOccupied); file->Var32(&NumOccupied);
file->Var32(&ReadPos); file->Var32(&ReadPos);

View File

@ -158,7 +158,54 @@ void Stop()
void DoSavestate(Savestate* file) 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);
} }

View File

@ -138,6 +138,64 @@ void GPU2D::Reset()
OBJExtPalStatus = 0; 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) void GPU2D::SetFramebuffer(u32* buf)
{ {
Framebuffer = buf; Framebuffer = buf;

View File

@ -27,6 +27,8 @@ public:
void Reset(); void Reset();
void DoSavestate(Savestate* file);
void SetFramebuffer(u32* buf); void SetFramebuffer(u32* buf);
u8 Read8(u32 addr); u8 Read8(u32 addr);

View File

@ -45,7 +45,7 @@
// the added bias affects interpolation. // the added bias affects interpolation.
// //
// depth buffer: // 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 // W-buffering mode: val = W
// //
// formula for clear depth: (GBAtek is wrong there) // formula for clear depth: (GBAtek is wrong there)
@ -351,6 +351,80 @@ void Reset()
SoftRenderer::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) void MatrixLoadIdentity(s32* m)

View File

@ -20,6 +20,7 @@
#define GPU3D_H #define GPU3D_H
#include <array> #include <array>
#include "Savestate.h"
namespace GPU3D namespace GPU3D
{ {
@ -85,6 +86,8 @@ bool Init();
void DeInit(); void DeInit();
void Reset(); void Reset();
void DoSavestate(Savestate* file);
void ExecuteCommand(); void ExecuteCommand();
void Run(s32 cycles); void Run(s32 cycles);

View File

@ -474,8 +474,8 @@ bool DoSavestate(Savestate* file)
file->Var16(&IPCSync7); file->Var16(&IPCSync7);
file->Var16(&IPCFIFOCnt9); file->Var16(&IPCFIFOCnt9);
file->Var16(&IPCFIFOCnt7); file->Var16(&IPCFIFOCnt7);
IPCFIFO9->Savestate(file); IPCFIFO9->DoSavestate(file);
IPCFIFO7->Savestate(file); IPCFIFO7->DoSavestate(file);
file->Var16(&DivCnt); file->Var16(&DivCnt);
file->Var16(&SqrtCnt); file->Var16(&SqrtCnt);
@ -510,11 +510,13 @@ bool DoSavestate(Savestate* file)
CP15::DoSavestate(file); CP15::DoSavestate(file);
NDSCart::DoSavestate(file); NDSCart::DoSavestate(file);
// GPU GPU::DoSavestate(file);
// SPU // SPU
// SPI // SPI
// RTC // RTC
// wifi // wifi
return true;
} }
bool LoadROM(const char* path, bool direct) bool LoadROM(const char* path, bool direct)