aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/GPU.cpp5
-rw-r--r--src/GPU.h6
-rw-r--r--src/NDS.cpp95
-rw-r--r--src/NDS.h2
-rw-r--r--src/NDSCart.h4
-rw-r--r--src/SPI.h2
6 files changed, 110 insertions, 4 deletions
diff --git a/src/GPU.cpp b/src/GPU.cpp
index 2f1fbb4..c06ecfd 100644
--- a/src/GPU.cpp
+++ b/src/GPU.cpp
@@ -156,6 +156,11 @@ void Stop()
memset(Framebuffer, 0, 256*192*2*4);
}
+void DoSavestate(Savestate* file)
+{
+ //
+}
+
// VRAM mapping notes
//
diff --git a/src/GPU.h b/src/GPU.h
index 8611444..2ef33d9 100644
--- a/src/GPU.h
+++ b/src/GPU.h
@@ -72,6 +72,9 @@ void DeInit();
void Reset();
void Stop();
+void DoSavestate(Savestate* file);
+
+
void MapVRAM_AB(u32 bank, u8 cnt);
void MapVRAM_CD(u32 bank, u8 cnt);
void MapVRAM_E(u32 bank, u8 cnt);
@@ -389,6 +392,9 @@ void DisplaySwap(u32 val);
void StartFrame();
void FinishFrame(u32 lines);
void StartScanline(u32 line);
+void StartHBlank(u32 line);
+
+void DisplayFIFO(u32 x);
void SetDispStat(u32 cpu, u16 val);
diff --git a/src/NDS.cpp b/src/NDS.cpp
index b0bd392..8d3afbf 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -112,6 +112,10 @@ u16 RCnt;
bool Running;
+void DivDone(u32 param);
+void SqrtDone(u32 param);
+
+
bool Init()
{
ARM9 = new ARM(0);
@@ -356,7 +360,91 @@ void Stop()
SPU::Stop();
}
-void DoSavestate(Savestate* file)
+bool DoSavestate_Scheduler(Savestate* file)
+{
+ // this is a bit of a hack
+ // but uh, your local coder realized that the scheduler list contains function pointers
+ // and that storing those as-is is not a very good idea
+ // unless you want it to crash and burn
+
+ // this is the solution your local coder came up with.
+ // it's gross but I think it's the best solution for this problem.
+ // just remember to add here if you add more event callbacks, kay?
+ // atleast until we come up with something more elegant.
+
+ void (*eventfuncs[])(u32) =
+ {
+ GPU::StartScanline, GPU::StartHBlank, GPU::FinishFrame,
+ SPU::Mix,
+ Wifi::USTimer,
+
+ GPU::DisplayFIFO,
+ NDSCart::ROMPrepareData, NDSCart::ROMEndTransfer,
+ NDSCart::SPITransferDone,
+ SPI::TransferDone,
+ DivDone,
+ SqrtDone,
+
+ NULL
+ };
+
+ int len = Event_MAX;
+ if (file->Saving)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ SchedEvent* evt = &SchedList[i];
+
+ u32 funcid = -1;
+ for (int j = 0; eventfuncs[j]; j++)
+ {
+ if (evt->Func == eventfuncs[j])
+ {
+ funcid = j;
+ break;
+ }
+ }
+ if (funcid < 0)
+ {
+ printf("savestate: VERY BAD!!!!! FUNCTION POINTER FOR EVENT %d NOT IN HACKY LIST. CANNOT SAVE. SMACK STAPLEBUTTER.\n", i);
+ return false;
+ }
+
+ file->Var32(&funcid);
+ file->Var32((u32*)&evt->WaitCycles);
+ file->Var32(&evt->Param);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < len; i++)
+ {
+ SchedEvent* evt = &SchedList[i];
+
+ u32 funcid;
+ file->Var32(&funcid);
+
+ for (int j = 0; ; j++)
+ {
+ if (!eventfuncs[j])
+ {
+ printf("savestate: VERY BAD!!!!!! EVENT FUNCTION POINTER ID %d IS OUT OF RANGE. HAX?????\n", j);
+ return false;
+ }
+ if (j == funcid) break;
+ }
+
+ evt->Func = eventfuncs[funcid];
+
+ file->Var32((u32*)&evt->WaitCycles);
+ file->Var32(&evt->Param);
+ }
+ }
+
+ return true;
+}
+
+bool DoSavestate(Savestate* file)
{
file->Section("NDSG");
@@ -399,7 +487,8 @@ void DoSavestate(Savestate* file)
file->VarArray(DMA9Fill, 4*sizeof(u32));
- file->VarArray(SchedList, sizeof(SchedList));
+ //file->VarArray(SchedList, sizeof(SchedList));
+ if (!DoSavestate_Scheduler(file)) return false;
file->Var32(&SchedListMask);
file->Var32((u32*)&CurIterationCycles);
file->Var32((u32*)&ARM7Offset);
@@ -420,7 +509,7 @@ void DoSavestate(Savestate* file)
ARM7->DoSavestate(file);
CP15::DoSavestate(file);
- // NDSCart
+ NDSCart::DoSavestate(file);
// GPU
// SPU
// SPI
diff --git a/src/NDS.h b/src/NDS.h
index 27dc820..98e507e 100644
--- a/src/NDS.h
+++ b/src/NDS.h
@@ -109,7 +109,7 @@ void DeInit();
void Reset();
void Stop();
-void DoSavestate(Savestate* file);
+bool DoSavestate(Savestate* file);
bool LoadROM(const char* path, bool direct);
void LoadBIOS();
diff --git a/src/NDSCart.h b/src/NDSCart.h
index 75ded4a..e99e938 100644
--- a/src/NDSCart.h
+++ b/src/NDSCart.h
@@ -53,6 +53,10 @@ void WriteSPICnt(u16 val);
u8 ReadSPIData();
void WriteSPIData(u8 val);
+void ROMPrepareData(u32 param);
+void ROMEndTransfer(u32 param);
+void SPITransferDone(u32 param);
+
}
#endif
diff --git a/src/SPI.h b/src/SPI.h
index 05a610d..04e9471 100644
--- a/src/SPI.h
+++ b/src/SPI.h
@@ -52,6 +52,8 @@ void WriteCnt(u16 val);
u8 ReadData();
void WriteData(u8 val);
+void TransferDone(u32 param);
+
}
#endif