diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a45252c..24a79f71 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,7 +38,6 @@ add_library(core STATIC NDSCart.cpp Platform.h ROMList.h - ROMSource.h FreeBIOS.h RTC.cpp Savestate.cpp diff --git a/src/DSi.cpp b/src/DSi.cpp index 889d518a..2ac1032e 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -244,6 +244,8 @@ void DoSavestate(Savestate* file) DSi_Camera::DoSavestate(file); DSi_DSP::DoSavestate(file); DSi_I2C::DoSavestate(file); + SDMMC->DoSavestate(file); + SDIO->DoSavestate(file); } void DecryptModcryptArea(u32 offset, u32 size, u8* iv) diff --git a/src/DSi_NWifi.cpp b/src/DSi_NWifi.cpp index 57bd93c3..fde48ecf 100644 --- a/src/DSi_NWifi.cpp +++ b/src/DSi_NWifi.cpp @@ -223,6 +223,45 @@ void DSi_NWifi::Reset() NDS::CancelEvent(NDS::Event_DSi_NWifi); } +void DSi_NWifi::DoSavestate(Savestate* file) +{ + file->Section("NWFi"); + + for (int i = 0; i < 9; i++) + Mailbox[i].DoSavestate(file); + + file->Var8(&F0_IRQEnable); + file->Var8(&F0_IRQStatus); + + file->Var8(&F1_IRQEnable); + file->Var8(&F1_IRQEnable_CPU); + file->Var8(&F1_IRQEnable_Error); + file->Var8(&F1_IRQEnable_Counter); + file->Var8(&F1_IRQStatus); + file->Var8(&F1_IRQStatus_CPU); + file->Var8(&F1_IRQStatus_Error); + file->Var8(&F1_IRQStatus_Counter); + + file->Var32(&WindowData); + file->Var32(&WindowReadAddr); + file->Var32(&WindowWriteAddr); + + file->Var32(&ROMID); + file->Var32(&ChipID); + file->Var32(&HostIntAddr); + + file->VarArray(EEPROM, 0x400); + file->Var32(&EEPROMReady); + + file->Var32(&BootPhase); + + file->Var32(&ErrorMask); + file->Var32(&ScanTimer); + + file->Var64(&BeaconTimer); + file->Var32(&ConnectionStatus); +} + // CHECKME // can IRQ status bits be set when the corresponding IRQs are disabled in the enable register? diff --git a/src/DSi_NWifi.h b/src/DSi_NWifi.h index da6597d7..ef337fcd 100644 --- a/src/DSi_NWifi.h +++ b/src/DSi_NWifi.h @@ -30,6 +30,8 @@ public: void Reset(); + void DoSavestate(Savestate* file); + void SendCMD(u8 cmd, u32 param); void SendACMD(u8 cmd, u32 param); diff --git a/src/DSi_SD.cpp b/src/DSi_SD.cpp index 2b9ac77f..6c5979b0 100644 --- a/src/DSi_SD.cpp +++ b/src/DSi_SD.cpp @@ -51,8 +51,8 @@ DSi_SDHost::DSi_SDHost(u32 num) { Num = num; - Ports[0] = NULL; - Ports[1] = NULL; + Ports[0] = nullptr; + Ports[1] = nullptr; } DSi_SDHost::~DSi_SDHost() @@ -155,7 +155,41 @@ void DSi_SDHost::Reset() void DSi_SDHost::DoSavestate(Savestate* file) { - // TODO! + file->Section(Num ? "SDIO" : "SDMM"); + + file->Var16(&PortSelect); + file->Var16(&SoftReset); + file->Var16(&SDClock); + file->Var16(&SDOption); + + file->Var32(&IRQStatus); + file->Var32(&IRQMask); + + file->Var16(&CardIRQStatus); + file->Var16(&CardIRQMask); + file->Var16(&CardIRQCtl); + + file->Var16(&DataCtl); + file->Var16(&Data32IRQ); + file->Var32(&DataMode); + file->Var16(&BlockCount16); + file->Var16(&BlockCount32); + file->Var16(&BlockCountInternal); + file->Var16(&BlockLen16); + file->Var16(&BlockLen32); + file->Var16(&StopAction); + + file->Var16(&Command); + file->Var32(&Param); + file->VarArray(ResponseBuffer, 8); + + file->Var32(&CurFIFO); + DataFIFO[0].DoSavestate(file); + DataFIFO[1].DoSavestate(file); + DataFIFO32.DoSavestate(file); + + if (Ports[0]) Ports[0]->DoSavestate(file); + if (Ports[1]) Ports[1]->DoSavestate(file); } @@ -737,7 +771,7 @@ DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, std::string file { Internal = internal; File = Platform::OpenLocalFile(filename, "r+b"); - printf("BLAGFARTED: %s -> %p\n", filename.c_str(), File); + SD = nullptr; ReadOnly = false; @@ -793,6 +827,26 @@ void DSi_MMCStorage::Reset() RWCommand = 0; } +void DSi_MMCStorage::DoSavestate(Savestate* file) +{ + file->Section(Internal ? "NAND" : "SDCR"); + + file->VarArray(CID, 16); + file->VarArray(CSD, 16); + + file->Var32(&CSR); + file->Var32(&OCR); + file->Var32(&RCA); + file->VarArray(SCR, 8); + file->VarArray(SSR, 64); + + file->Var32(&BlockSize); + file->Var64(&RWAddress); + file->Var32(&RWCommand); + + // TODO: what about the file contents? +} + void DSi_MMCStorage::SendCMD(u8 cmd, u32 param) { if (CSR & (1<<5)) diff --git a/src/DSi_SD.h b/src/DSi_SD.h index 1927e695..2e63a631 100644 --- a/src/DSi_SD.h +++ b/src/DSi_SD.h @@ -109,6 +109,8 @@ public: virtual void Reset() = 0; + virtual void DoSavestate(Savestate* file) = 0; + virtual void SendCMD(u8 cmd, u32 param) = 0; virtual void ContinueTransfer() = 0; @@ -129,6 +131,8 @@ public: void Reset(); + void DoSavestate(Savestate* file); + void SetCID(u8* cid) { memcpy(CID, cid, 16); } void SendCMD(u8 cmd, u32 param); diff --git a/src/DSi_SPI_TSC.cpp b/src/DSi_SPI_TSC.cpp index 061feb1a..134d9def 100644 --- a/src/DSi_SPI_TSC.cpp +++ b/src/DSi_SPI_TSC.cpp @@ -71,14 +71,15 @@ void Reset() void DoSavestate(Savestate* file) { - /*file->Section("SPTi"); + file->Section("SPTi"); file->Var32(&DataPos); - file->Var8(&ControlByte); + file->Var8(&Index); + file->Var8(&Bank); file->Var8(&Data); - file->Var16(&ConvResult);*/ - // TODO!! + file->VarArray(Bank3Regs, 0x80); + file->Var8(&TSCMode); } void SetMode(u8 mode) diff --git a/src/ROMSource.cpp b/src/ROMSource.cpp deleted file mode 100644 index 26262e36..00000000 --- a/src/ROMSource.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - Copyright 2016-2021 Arisotura - - This file is part of melonDS. - - melonDS is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - melonDS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with melonDS. If not, see http://www.gnu.org/licenses/. -*/ diff --git a/src/ROMSource.h b/src/ROMSource.h deleted file mode 100644 index b815bc76..00000000 --- a/src/ROMSource.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2016-2021 Arisotura - - This file is part of melonDS. - - melonDS is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - melonDS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with melonDS. If not, see http://www.gnu.org/licenses/. -*/ - -#ifndef ROMSOURCE_H -#define ROMSOURCE_H - -#include - -class ROMSource -{ -public: - virtual ~ROMSource() = 0; - - virtual u32 ReadROMData(u64 offset, u32 len, void* data) = 0; - - virtual std::string GetSaveFilePath() = 0; - virtual std::string GetSavestatePath(int slot) = 0; - virtual std::string GetCheatFilePath() = 0; -}; - -#endif // ROMSOURCE_H diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 578b7ff0..6766928f 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -2804,27 +2804,14 @@ void MainWindow::onFullscreenToggled() void MainWindow::onEmuStart() { - // TODO: make savestates work in DSi mode!! - if (Config::ConsoleType == 1) + for (int i = 1; i < 9; i++) { - for (int i = 0; i < 9; i++) - { - actSaveState[i]->setEnabled(false); - actLoadState[i]->setEnabled(false); - } - actUndoStateLoad->setEnabled(false); - } - else - { - for (int i = 1; i < 9; i++) - { - actSaveState[i]->setEnabled(true); - actLoadState[i]->setEnabled(ROMManager::SavestateExists(i)); - } - actSaveState[0]->setEnabled(true); - actLoadState[0]->setEnabled(true); - actUndoStateLoad->setEnabled(false); + actSaveState[i]->setEnabled(true); + actLoadState[i]->setEnabled(ROMManager::SavestateExists(i)); } + actSaveState[0]->setEnabled(true); + actLoadState[0]->setEnabled(true); + actUndoStateLoad->setEnabled(false); actPause->setEnabled(true); actPause->setChecked(false);