From 0bfd019dc06ef9cf66d657400c21a889a22efa80 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sat, 15 Sep 2018 02:47:34 +0200 Subject: [PATCH] start implementing actual shito (also looks like the test bench in libui_sdl/main.cpp snuck in with the copyright update. shit) --- src/ARM.cpp | 21 +++++++++++++++++++++ src/ARM.h | 2 ++ src/CP15.cpp | 19 +++++++++++++++++++ src/CP15.h | 2 ++ src/NDS.cpp | 16 ++++++++++++++++ src/NDS.h | 3 +++ 6 files changed, 63 insertions(+) diff --git a/src/ARM.cpp b/src/ARM.cpp index dee40f29..fbf4be2b 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -161,6 +161,27 @@ void ARM::Reset() JumpTo(ExceptionBase); } +void ARM::Savestate(Savestate* file) +{ + file->Section(Num ? "ARM7" : "ARM9"); + + file->Var32(&(u32)Cycles); + file->Var32(&(u32)CyclesToRun); + file->Var32(&Halted); + + file->VarArray(R, 16*sizeof(u32)); + file->Var32(&CPSR); + file->VarArray(R_FIQ, 8*sizeof(u32)); + file->VarArray(R_SVC, 3*sizeof(u32)); + file->VarArray(R_ABT, 3*sizeof(u32)); + file->VarArray(R_IRQ, 3*sizeof(u32)); + file->VarArray(R_UND, 3*sizeof(u32)); + file->Var32(&CurInstr); + file->VarArray(NextInstr, 2*sizeof(u32)); + + file->Var32(&ExceptionBase); +} + void ARM::JumpTo(u32 addr, bool restorecpsr) { if (restorecpsr) diff --git a/src/ARM.h b/src/ARM.h index be583625..85ddfc04 100644 --- a/src/ARM.h +++ b/src/ARM.h @@ -38,6 +38,8 @@ public: void Reset(); + void Savestate(Savestate* file); + void JumpTo(u32 addr, bool restorecpsr = false); void RestoreCPSR(); diff --git a/src/CP15.cpp b/src/CP15.cpp index 8bf68fb8..97414db0 100644 --- a/src/CP15.cpp +++ b/src/CP15.cpp @@ -57,6 +57,25 @@ void Reset() DTCMSize = 0; } +void Savestate(Savestate* file) +{ + file->Section("CP15"); + + file->Var32(&Control); + + file->Var32(&DTCMSetting); + file->Var32(&ITCMSetting); + + if (!file->Saving) + { + UpdateDTCMSetting(); + UpdateITCMSetting(); + } + + file->VarArray(ITCM, 0x8000); + file->VarArray(DTCM, 0x4000); +} + void UpdateDTCMSetting() { diff --git a/src/CP15.h b/src/CP15.h index b448bf2a..2e7f5f01 100644 --- a/src/CP15.h +++ b/src/CP15.h @@ -24,6 +24,8 @@ namespace CP15 void Reset(); +void Savestate(Savestate* file); + void UpdateDTCMSetting(); void UpdateITCMSetting(); diff --git a/src/NDS.cpp b/src/NDS.cpp index bf5e0ef8..909e8c25 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -356,6 +356,22 @@ void Stop() SPU::Stop(); } +void Savestate(Savestate* file) +{ + // NDS shito + + ARM9->Savestate(file); + ARM7->Savestate(file); + CP15::Savestate(file); + + // NDSCart + // GPU + // SPU + // SPI + // RTC + // wifi +} + bool LoadROM(const char* path, bool direct) { if (NDSCart::LoadROM(path, direct)) diff --git a/src/NDS.h b/src/NDS.h index 68f37e91..9887323f 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -19,6 +19,7 @@ #ifndef NDS_H #define NDS_H +#include "Savestate.h" #include "types.h" namespace NDS @@ -108,6 +109,8 @@ void DeInit(); void Reset(); void Stop(); +void Savestate(Savestate* file); + bool LoadROM(const char* path, bool direct); void LoadBIOS(); void SetupDirectBoot();