more savestate crapo

This commit is contained in:
Arisotura 2022-01-07 11:08:47 +01:00
parent ad38838743
commit 95f0e30dcb
8 changed files with 74 additions and 9 deletions

View File

@ -82,6 +82,7 @@ u8 eMMC_CID[16];
void Set_SCFG_Clock9(u16 val);
void Set_SCFG_MC(u32 val);
bool Init()
@ -240,6 +241,9 @@ void DoSavestate(Savestate* file)
NDMAs[i]->DoSavestate(file);
DSi_AES::DoSavestate(file);
DSi_Camera::DoSavestate(file);
DSi_DSP::DoSavestate(file);
DSi_I2C::DoSavestate(file);
}
void DecryptModcryptArea(u32 offset, u32 size, u8* iv)

View File

@ -157,7 +157,7 @@ void Reset()
void DoSavestate(Savestate* file)
{
file->Section("AES.");
file->Section("AESi");
file->Var32(&Cnt);
@ -171,8 +171,8 @@ void DoSavestate(Savestate* file)
file->Var32(&OutputDMASize);
file->Var32(&AESMode);
InputFIFO->DoSavestate(file);
OutputFIFO->DoSavestate(file);
InputFIFO.DoSavestate(file);
OutputFIFO.DoSavestate(file);
file->VarArray(IV, 16);
@ -188,8 +188,8 @@ void DoSavestate(Savestate* file)
file->VarArray(OutputMAC, 16);
file->Bool32(&OutputMACDue);
file->VarArray(Ctx->RoundKey, AES_keyExpSize);
file->VarArray(Ctx->Iv, AES_BLOCKLEN);
file->VarArray(Ctx.RoundKey, AES_keyExpSize);
file->VarArray(Ctx.Iv, AES_BLOCKLEN);
}

View File

@ -70,6 +70,21 @@ void DSi_Camera::Reset()
NDS::ScheduleEvent(NDS::Event_DSi_CamIRQ, true, kIRQInterval, IRQ, 0);
}
void DSi_Camera::DoSavestate(Savestate* file)
{
file->Section("CAMi");
file->Var16(&ModuleCnt);
file->Var16(&Cnt);
file->VarArray(FrameBuffer, sizeof(FrameBuffer));
file->Var32(&TransferPos);
file->Var32(&FrameLength);
DSi_Camera0->DoCamSavestate(file);
DSi_Camera1->DoCamSavestate(file);
}
void DSi_Camera::IRQ(u32 param)
{
@ -150,7 +165,29 @@ DSi_Camera::DSi_Camera(u32 num)
DSi_Camera::~DSi_Camera()
{
//
}
void DSi_Camera::DoCamSavestate(Savestate* file)
{
char magic[5] = "CAMx";
magic[3] = '0' + Num;
file->Section(magic);
file->Var32(&DataPos);
file->Var32(&RegAddr);
file->Var16(&RegData);
file->Var16(&PLLDiv);
file->Var16(&PLLPDiv);
file->Var16(&PLLCnt);
file->Var16(&ClocksCnt);
file->Var16(&StandbyCnt);
file->Var16(&MiscCnt);
file->Var16(&MCUAddr);
// TODO: MCUData??
file->VarArray(MCURegs, 0x8000);
}
void DSi_Camera::ResetCam()

View File

@ -28,6 +28,8 @@ public:
static void DeInit();
static void Reset();
static void DoSavestate(Savestate* file);
static void IRQ(u32 param);
static void RequestFrame(u32 cam);
@ -36,6 +38,8 @@ public:
DSi_Camera(u32 num);
~DSi_Camera();
void DoCamSavestate(Savestate* file);
void ResetCam();
bool IsActivated();

View File

@ -587,6 +587,8 @@ void DoSavestate(Savestate* file)
file->Var16(&DSP_REP[1]);
file->Var16(&DSP_REP[2]);
file->Var8((u8*)&SCFG_RST);
// TODO: save the Teakra state!!!
}
}

View File

@ -41,8 +41,6 @@ bool Init();
void DeInit();
void Reset();
// TODO: needs to be called!
// however, no DSi savestate stuff seems to be actually implemented?!
void DoSavestate(Savestate* file);
void DSPCatchUpU32(u32 _);

View File

@ -72,6 +72,14 @@ void Reset()
Registers[0x81] = 0x64;
}
void DoSavestate(Savestate* file)
{
file->Section("I2BP");
file->VarArray(Registers, 0x100);
file->Var32(&CurPos);
}
u8 GetBootFlag() { return Registers[0x70]; }
void Start()
@ -169,6 +177,18 @@ void Reset()
DSi_Camera::Reset();
}
void DoSavestate(Savestate* file)
{
file->Section("I2Ci");
file->Var8(&Cnt);
file->Var8(&Data);
file->Var32(&Device);
DSi_BPTWL::DoSavestate(file);
// cameras are savestated from the DSi_Camera module
}
void WriteCnt(u8 val)
{
//printf("I2C: write CNT %02X, %08X\n", val, NDS::GetPC(1));

View File

@ -34,7 +34,7 @@ extern u8 Cnt;
bool Init();
void DeInit();
void Reset();
//void DoSavestate(Savestate* file);
void DoSavestate(Savestate* file);
void WriteCnt(u8 val);