aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ARM.cpp21
-rw-r--r--src/ARM.h2
-rw-r--r--src/CP15.cpp19
-rw-r--r--src/CP15.h2
-rw-r--r--src/NDS.cpp16
-rw-r--r--src/NDS.h3
6 files changed, 63 insertions, 0 deletions
diff --git a/src/ARM.cpp b/src/ARM.cpp
index dee40f2..fbf4be2 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 be58362..85ddfc0 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 8bf68fb..97414db 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 b448bf2..2e7f5f0 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 bf5e0ef..909e8c2 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 68f37e9..9887323 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();