take it further

This commit is contained in:
Arisotura 2022-01-07 11:42:44 +01:00
parent 95f0e30dcb
commit f577b45eb9
10 changed files with 116 additions and 81 deletions

View File

@ -38,7 +38,6 @@ add_library(core STATIC
NDSCart.cpp
Platform.h
ROMList.h
ROMSource.h
FreeBIOS.h
RTC.cpp
Savestate.cpp

View File

@ -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)

View File

@ -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?

View File

@ -30,6 +30,8 @@ public:
void Reset();
void DoSavestate(Savestate* file);
void SendCMD(u8 cmd, u32 param);
void SendACMD(u8 cmd, u32 param);

View File

@ -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))

View File

@ -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);

View File

@ -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)

View File

@ -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/.
*/

View File

@ -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 <string>
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

View File

@ -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);