This commit is contained in:
Arisotura 2024-05-19 21:34:20 +02:00
parent cde47f56c5
commit 21de51bb3f
2 changed files with 18 additions and 9 deletions

View File

@ -128,9 +128,12 @@ private:
std::string baseGBAROMName;
std::string baseGBAAssetName;
// HACK
public:
std::unique_ptr<SaveManager> ndsSave;
std::unique_ptr<SaveManager> gbaSave;
std::unique_ptr<SaveManager> firmwareSave;
private:
std::unique_ptr<melonDS::Savestate> backupState;
bool savestateLoaded;

View File

@ -29,14 +29,14 @@
#include <QThread>
#include <QSemaphore>
#include <QMutex>
#include <QOpenGLContext>
//#include <QOpenGLContext>
#include <QSharedMemory>
#include <QTemporaryFile>
#include <SDL_loadso.h>
#include "Platform.h"
#include "Config.h"
#include "ROMManager.h"
#include "main.h"
#include "CameraManager.h"
#include "LAN_Socket.h"
#include "LAN_PCap.h"
@ -52,6 +52,9 @@ std::string EmuDirectory;
extern CameraManager* camManager[2];
// REMOVE ME
extern EmuInstance* testinst;
void emuStop();
// TEMP
@ -520,25 +523,28 @@ void Sleep(u64 usecs)
void WriteNDSSave(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen)
{
if (ROMManager::NDSSave)
ROMManager::NDSSave->RequestFlush(savedata, savelen, writeoffset, writelen);
EmuInstance* inst = testinst;
if (inst->ndsSave)
inst->ndsSave->RequestFlush(savedata, savelen, writeoffset, writelen);
}
void WriteGBASave(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen)
{
if (ROMManager::GBASave)
ROMManager::GBASave->RequestFlush(savedata, savelen, writeoffset, writelen);
EmuInstance* inst = testinst;
if (inst->gbaSave)
inst->gbaSave->RequestFlush(savedata, savelen, writeoffset, writelen);
}
void WriteFirmware(const Firmware& firmware, u32 writeoffset, u32 writelen)
{
if (!ROMManager::FirmwareSave)
EmuInstance* inst = testinst;
if (!inst->firmwareSave)
return;
if (firmware.GetHeader().Identifier != GENERATED_FIRMWARE_IDENTIFIER)
{ // If this is not the default built-in firmware...
// ...then write the whole thing back.
ROMManager::FirmwareSave->RequestFlush(firmware.Buffer(), firmware.Length(), writeoffset, writelen);
inst->firmwareSave->RequestFlush(firmware.Buffer(), firmware.Length(), writeoffset, writelen);
}
else
{
@ -555,7 +561,7 @@ void WriteFirmware(const Firmware& firmware, u32 writeoffset, u32 writelen)
{ // If we're writing to the access points...
const u8* buffer = firmware.GetExtendedAccessPointPosition();
u32 length = sizeof(firmware.GetExtendedAccessPoints()) + sizeof(firmware.GetAccessPoints());
ROMManager::FirmwareSave->RequestFlush(buffer, length, writeoffset - eapstart, writelen);
inst->firmwareSave->RequestFlush(buffer, length, writeoffset - eapstart, writelen);
}
}