diff --git a/src/DSi.cpp b/src/DSi.cpp index 2d559c26..ac4909de 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -168,6 +168,13 @@ void Reset() GPU::DispStat[1] |= (1<<6); } +void DoSavestate(Savestate* file) +{ + file->Section("DSIG"); + + // +} + void DecryptModcryptArea(u32 offset, u32 size, u8* iv) { AES_ctx ctx; diff --git a/src/DSi.h b/src/DSi.h index 2e6fda97..93f46eb1 100644 --- a/src/DSi.h +++ b/src/DSi.h @@ -57,6 +57,8 @@ bool Init(); void DeInit(); void Reset(); +void DoSavestate(Savestate* file); + void SetupDirectBoot(); void SoftReset(); diff --git a/src/DSi_DSP.h b/src/DSi_DSP.h index f5264b46..9f284874 100644 --- a/src/DSi_DSP.h +++ b/src/DSi_DSP.h @@ -45,6 +45,8 @@ void Reset(); // however, no DSi savestate stuff seems to be actually implemented?! void DoSavestate(Savestate* file); +void DSPCatchUpU32(u32 _); + // SCFG_RST bit0 bool IsRstReleased(); void SetRstLine(bool release); diff --git a/src/NDS.cpp b/src/NDS.cpp index 3e3536ec..0a094903 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -41,6 +41,9 @@ #include "DSi.h" #include "DSi_SPI_TSC.h" +#include "DSi_NWifi.h" +#include "DSi_Camera.h" +#include "DSi_DSP.h" namespace NDS @@ -199,7 +202,6 @@ bool Init() DMAs[6] = new DMA(1, 2); DMAs[7] = new DMA(1, 3); - //if (!NDSCart_SRAMManager::Init()) return false; if (!NDSCart::Init()) return false; if (!GBACart::Init()) return false; if (!GPU::Init()) return false; @@ -227,7 +229,6 @@ void DeInit() for (int i = 0; i < 8; i++) delete DMAs[i]; - //NDSCart_SRAMManager::DeInit(); NDSCart::DeInit(); GBACart::DeInit(); GPU::DeInit(); @@ -718,7 +719,14 @@ bool DoSavestate_Scheduler(Savestate* file) DivDone, SqrtDone, - NULL + DSi_SDHost::FinishRX, + DSi_SDHost::FinishTX, + DSi_NWifi::MSTimer, + DSi_Camera::IRQ, + DSi_Camera::Transfer, + DSi_DSP::DSPCatchUpU32, + + nullptr }; int len = Event_MAX; @@ -728,7 +736,7 @@ bool DoSavestate_Scheduler(Savestate* file) { SchedEvent* evt = &SchedList[i]; - u32 funcid = -1; + u32 funcid = 0xFFFFFFFF; if (evt->Func) { for (int j = 0; eventfuncs[j]; j++) @@ -775,7 +783,7 @@ bool DoSavestate_Scheduler(Savestate* file) evt->Func = eventfuncs[funcid]; } else - evt->Func = NULL; + evt->Func = nullptr; file->Var64(&evt->Timestamp); file->Var32(&evt->Param); @@ -789,13 +797,24 @@ bool DoSavestate(Savestate* file) { file->Section("NDSG"); - // TODO: - // * do something for bool's (sizeof=1) - // * do something for 'loading DSi-mode savestate in DS mode' and vice-versa - // * add IE2/IF2 there + if (file->Saving) + { + u32 console = ConsoleType; + file->Var32(&console); + } + else + { + u32 console; + file->Var32(&console); + if (console != ConsoleType) + { + file->Error = true; + return false; + } + } - file->VarArray(MainRAM, 0x400000); - file->VarArray(SharedWRAM, 0x8000); + file->VarArray(MainRAM, MainRAMMaxSize); + file->VarArray(SharedWRAM, SharedWRAMSize); file->VarArray(ARM7WRAM, ARM7WRAMSize); file->VarArray(ExMemCnt, 2*sizeof(u16)); @@ -807,6 +826,8 @@ bool DoSavestate(Savestate* file) file->VarArray(IME, 2*sizeof(u32)); file->VarArray(IE, 2*sizeof(u32)); file->VarArray(IF, 2*sizeof(u32)); + file->Var32(&IE2); + file->Var32(&IF2); file->Var8(&PostFlag9); file->Var8(&PostFlag7); @@ -893,6 +914,9 @@ bool DoSavestate(Savestate* file) RTC::DoSavestate(file); Wifi::DoSavestate(file); + if (ConsoleType == 1) + DSi::DoSavestate(file); + if (!file->Saving) { GPU::SetPowerCnt(PowerControl9); diff --git a/src/NDS.h b/src/NDS.h index e98c07e1..c3764d1f 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -50,8 +50,6 @@ enum Event_DSi_NWifi, Event_DSi_CamIRQ, Event_DSi_CamTransfer, - - Event_DSi_RAMSizeChange, Event_DSi_DSP, Event_MAX diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 194aef0e..351fe999 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -275,7 +275,7 @@ QString VerifySetup() std::string GetSavestateName(int slot) { std::string ext = ".ml"; - ext += ('0'+slot); + ext += (char)('0'+slot); return GetAssetPath(false, Config::SavestatePath, ext); }