WIP. lay base for EmuInstance.
This commit is contained in:
parent
f93937e88b
commit
faa6cfec48
|
@ -56,6 +56,8 @@ set(SOURCES_QT_SDL
|
|||
|
||||
CLI.h
|
||||
CLI.cpp
|
||||
EmuInstance.cpp
|
||||
EmuInstance.h
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
|
|
@ -74,42 +74,6 @@ int MaxFPS;
|
|||
bool AudioSync;
|
||||
bool ShowOSD;
|
||||
|
||||
int ConsoleType;
|
||||
bool DirectBoot;
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
bool JIT_Enable = false;
|
||||
int JIT_MaxBlockSize = 32;
|
||||
bool JIT_BranchOptimisations = true;
|
||||
bool JIT_LiteralOptimisations = true;
|
||||
bool JIT_FastMemory = true;
|
||||
#endif
|
||||
|
||||
bool ExternalBIOSEnable;
|
||||
|
||||
std::string BIOS9Path;
|
||||
std::string BIOS7Path;
|
||||
std::string FirmwarePath;
|
||||
|
||||
std::string DSiBIOS9Path;
|
||||
std::string DSiBIOS7Path;
|
||||
std::string DSiFirmwarePath;
|
||||
std::string DSiNANDPath;
|
||||
|
||||
bool DLDIEnable;
|
||||
std::string DLDISDPath;
|
||||
int DLDISize;
|
||||
bool DLDIReadOnly;
|
||||
bool DLDIFolderSync;
|
||||
std::string DLDIFolderPath;
|
||||
|
||||
bool DSiSDEnable;
|
||||
std::string DSiSDPath;
|
||||
int DSiSDSize;
|
||||
bool DSiSDReadOnly;
|
||||
bool DSiSDFolderSync;
|
||||
std::string DSiSDFolderPath;
|
||||
|
||||
bool FirmwareOverrideSettings;
|
||||
std::string FirmwareUsername;
|
||||
int FirmwareLanguage;
|
||||
|
@ -137,7 +101,6 @@ std::string MicDevice;
|
|||
std::string MicWavPath;
|
||||
|
||||
std::string LastROMFolder;
|
||||
std::string LastBIOSFolder;
|
||||
|
||||
std::string RecentROMList[10];
|
||||
|
||||
|
@ -159,16 +122,6 @@ bool DSBatteryLevelOkay;
|
|||
int DSiBatteryLevel;
|
||||
bool DSiBatteryCharging;
|
||||
|
||||
bool DSiFullBIOSBoot;
|
||||
|
||||
#ifdef GDBSTUB_ENABLED
|
||||
bool GdbEnabled;
|
||||
int GdbPortARM7;
|
||||
int GdbPortARM9;
|
||||
bool GdbARM7BreakOnStartup;
|
||||
bool GdbARM9BreakOnStartup;
|
||||
#endif
|
||||
|
||||
CameraConfig Camera[2];
|
||||
|
||||
|
||||
|
@ -773,6 +726,11 @@ void Array::SetString(const int id, const std::string& val)
|
|||
}
|
||||
|
||||
|
||||
Table::Table() : Data()
|
||||
{
|
||||
PathPrefix = "";
|
||||
}
|
||||
|
||||
Table::Table(toml::value& data, std::string path) : Data(data)
|
||||
{
|
||||
if (path.empty())
|
||||
|
@ -781,6 +739,12 @@ Table::Table(toml::value& data, std::string path) : Data(data)
|
|||
PathPrefix = path + ".";
|
||||
}
|
||||
|
||||
Table Table::operator=(Table b)
|
||||
{
|
||||
Data = b.Data;
|
||||
PathPrefix = b.PathPrefix;
|
||||
}
|
||||
|
||||
Array Table::GetArray(const std::string& path)
|
||||
{
|
||||
toml::value& arr = ResolvePath(path);
|
||||
|
|
|
@ -138,9 +138,12 @@ private:
|
|||
class Table
|
||||
{
|
||||
public:
|
||||
Table();
|
||||
Table(toml::value& data, std::string path);
|
||||
~Table() {}
|
||||
|
||||
Table operator=(Table b);
|
||||
|
||||
Array GetArray(const std::string& path);
|
||||
Table GetTable(const std::string& path);
|
||||
|
||||
|
@ -212,42 +215,6 @@ extern int MaxFPS;
|
|||
extern bool AudioSync;
|
||||
extern bool ShowOSD;
|
||||
|
||||
extern int ConsoleType;
|
||||
extern bool DirectBoot;
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
extern bool JIT_Enable;
|
||||
extern int JIT_MaxBlockSize;
|
||||
extern bool JIT_BranchOptimisations;
|
||||
extern bool JIT_LiteralOptimisations;
|
||||
extern bool JIT_FastMemory;
|
||||
#endif
|
||||
|
||||
extern bool ExternalBIOSEnable;
|
||||
|
||||
extern std::string BIOS9Path;
|
||||
extern std::string BIOS7Path;
|
||||
extern std::string FirmwarePath;
|
||||
|
||||
extern std::string DSiBIOS9Path;
|
||||
extern std::string DSiBIOS7Path;
|
||||
extern std::string DSiFirmwarePath;
|
||||
extern std::string DSiNANDPath;
|
||||
|
||||
extern bool DLDIEnable;
|
||||
extern std::string DLDISDPath;
|
||||
extern int DLDISize;
|
||||
extern bool DLDIReadOnly;
|
||||
extern bool DLDIFolderSync;
|
||||
extern std::string DLDIFolderPath;
|
||||
|
||||
extern bool DSiSDEnable;
|
||||
extern std::string DSiSDPath;
|
||||
extern int DSiSDSize;
|
||||
extern bool DSiSDReadOnly;
|
||||
extern bool DSiSDFolderSync;
|
||||
extern std::string DSiSDFolderPath;
|
||||
|
||||
extern bool FirmwareOverrideSettings;
|
||||
extern std::string FirmwareUsername;
|
||||
extern int FirmwareLanguage;
|
||||
|
@ -275,7 +242,6 @@ extern std::string MicDevice;
|
|||
extern std::string MicWavPath;
|
||||
|
||||
extern std::string LastROMFolder;
|
||||
extern std::string LastBIOSFolder;
|
||||
|
||||
extern std::string RecentROMList[10];
|
||||
|
||||
|
@ -296,16 +262,8 @@ extern bool DSBatteryLevelOkay;
|
|||
extern int DSiBatteryLevel;
|
||||
extern bool DSiBatteryCharging;
|
||||
|
||||
extern bool DSiFullBIOSBoot;
|
||||
|
||||
extern CameraConfig Camera[2];
|
||||
|
||||
extern bool GdbEnabled;
|
||||
extern int GdbPortARM7;
|
||||
extern int GdbPortARM9;
|
||||
extern bool GdbARM7BreakOnStartup;
|
||||
extern bool GdbARM9BreakOnStartup;
|
||||
|
||||
|
||||
bool Load();
|
||||
void Save();
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
/*
|
||||
Copyright 2016-2023 melonDS team
|
||||
|
||||
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/.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <fstream>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <zstd.h>
|
||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||
#include "ArchiveUtil.h"
|
||||
#endif
|
||||
#include "EmuInstance.h"
|
||||
#include "Config.h"
|
||||
#include "Platform.h"
|
||||
|
||||
#include "NDS.h"
|
||||
#include "DSi.h"
|
||||
#include "SPI.h"
|
||||
#include "RTC.h"
|
||||
#include "DSi_I2C.h"
|
||||
#include "FreeBIOS.h"
|
||||
#include "main.h"
|
||||
|
||||
using std::make_unique;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
using std::tie;
|
||||
using std::unique_ptr;
|
||||
using std::wstring_convert;
|
||||
using namespace melonDS;
|
||||
using namespace melonDS::Platform;
|
||||
|
||||
|
||||
MainWindow* topWindow = nullptr;
|
||||
|
||||
|
||||
EmuInstance::EmuInstance(int inst)
|
||||
{
|
||||
instanceID = inst;
|
||||
|
||||
globalCfg = Config::GetGlobalTable();
|
||||
localCfg = Config::GetLocalTable(inst);
|
||||
|
||||
emuThread = new EmuThread();
|
||||
|
||||
numWindows = 0;
|
||||
mainWindow = nullptr;
|
||||
for (int i = 0; i < kMaxWindows; i++)
|
||||
windowList[i] = nullptr;
|
||||
|
||||
if (inst == 0) topWindow = nullptr;
|
||||
createWindow();
|
||||
|
||||
emuThread->start();
|
||||
emuThread->emuPause();
|
||||
}
|
||||
|
||||
EmuInstance::~EmuInstance()
|
||||
{
|
||||
// TODO window cleanup and shit?
|
||||
|
||||
emuThread->emuStop();
|
||||
emuThread->wait();
|
||||
delete emuThread;
|
||||
}
|
||||
|
||||
|
||||
void EmuInstance::createWindow()
|
||||
{
|
||||
if (numWindows >= kMaxWindows)
|
||||
{
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
|
||||
int id = -1;
|
||||
for (int i = 0; i < kMaxWindows; i++)
|
||||
{
|
||||
if (windowList[i]) continue;
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (id == -1)
|
||||
return;
|
||||
|
||||
MainWindow* win = new MainWindow(topWindow);
|
||||
if (!topWindow) topWindow = win;
|
||||
if (!mainWindow) mainWindow = win;
|
||||
windowList[id] = win;
|
||||
numWindows++;
|
||||
|
||||
emuThread->attachWindow(win);
|
||||
}
|
||||
|
||||
|
||||
int EmuInstance::lastSep(const std::string& path)
|
||||
{
|
||||
int i = path.length() - 1;
|
||||
while (i >= 0)
|
||||
{
|
||||
if (path[i] == '/' || path[i] == '\\')
|
||||
return i;
|
||||
|
||||
i--;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
string EmuInstance::getAssetPath(bool gba, const string& configpath, const string& ext, const string& file = "")
|
||||
{
|
||||
string result;
|
||||
|
||||
if (configpath.empty())
|
||||
result = gba ? baseGBAROMDir : baseROMDir;
|
||||
else
|
||||
result = configpath;
|
||||
|
||||
// cut off trailing slashes
|
||||
for (;;)
|
||||
{
|
||||
int i = result.length() - 1;
|
||||
if (i < 0) break;
|
||||
if (result[i] == '/' || result[i] == '\\')
|
||||
result.resize(i);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (!result.empty())
|
||||
result += '/';
|
||||
|
||||
if (file.empty())
|
||||
{
|
||||
std::string& baseName = gba ? baseGBAAssetName : baseAssetName;
|
||||
if (baseName.empty())
|
||||
result += "firmware";
|
||||
else
|
||||
result += baseName;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += file;
|
||||
}
|
||||
|
||||
result += ext;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString EmuInstance::verifyDSBIOS()
|
||||
{
|
||||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
f = Platform::OpenLocalFile(globalCfg.GetString("DS.BIOS9Path"), FileMode::Read);
|
||||
if (!f) return "DS ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len != 0x1000)
|
||||
{
|
||||
CloseFile(f);
|
||||
return "DS ARM9 BIOS is not a valid BIOS dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
f = Platform::OpenLocalFile(globalCfg.GetString("DS.BIOS7Path"), FileMode::Read);
|
||||
if (!f) return "DS ARM7 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len != 0x4000)
|
||||
{
|
||||
CloseFile(f);
|
||||
return "DS ARM7 BIOS is not a valid BIOS dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString EmuInstance::verifyDSiBIOS()
|
||||
{
|
||||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
// TODO: check the first 32 bytes
|
||||
|
||||
f = Platform::OpenLocalFile(globalCfg.GetString("DSi.BIOS9Path"), FileMode::Read);
|
||||
if (!f) return "DSi ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len != 0x10000)
|
||||
{
|
||||
CloseFile(f);
|
||||
return "DSi ARM9 BIOS is not a valid BIOS dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
f = Platform::OpenLocalFile(globalCfg.GetString("DSi.BIOS7Path"), FileMode::Read);
|
||||
if (!f) return "DSi ARM7 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len != 0x10000)
|
||||
{
|
||||
CloseFile(f);
|
||||
return "DSi ARM7 BIOS is not a valid BIOS dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString EmuInstance::verifyDSFirmware()
|
||||
{
|
||||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
std::string fwpath = globalCfg.GetString("DS.FirmwarePath");
|
||||
|
||||
f = Platform::OpenLocalFile(fwpath, FileMode::Read);
|
||||
if (!f) return "DS firmware was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(fwpath))
|
||||
return "DS firmware is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len == 0x20000)
|
||||
{
|
||||
// 128KB firmware, not bootable
|
||||
CloseFile(f);
|
||||
// TODO report it somehow? detect in core?
|
||||
return "";
|
||||
}
|
||||
else if (len != 0x40000 && len != 0x80000)
|
||||
{
|
||||
CloseFile(f);
|
||||
return "DS firmware is not a valid firmware dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString EmuInstance::verifyDSiFirmware()
|
||||
{
|
||||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
std::string fwpath = globalCfg.GetString("DSi.FirmwarePath");
|
||||
|
||||
f = Platform::OpenLocalFile(fwpath, FileMode::Read);
|
||||
if (!f) return "DSi firmware was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(fwpath))
|
||||
return "DSi firmware is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
len = FileLength(f);
|
||||
if (len != 0x20000)
|
||||
{
|
||||
// not 128KB
|
||||
// TODO: check whether those work
|
||||
CloseFile(f);
|
||||
return "DSi firmware is not a valid firmware dump.";
|
||||
}
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString EmuInstance::verifyDSiNAND()
|
||||
{
|
||||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
std::string nandpath = globalCfg.GetString("DSi.NANDPath");
|
||||
|
||||
f = Platform::OpenLocalFile(nandpath, FileMode::ReadWriteExisting);
|
||||
if (!f) return "DSi NAND was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(nandpath))
|
||||
return "DSi NAND is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
// TODO: some basic checks
|
||||
// check that it has the nocash footer, and all
|
||||
|
||||
CloseFile(f);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString EmuInstance::verifySetup()
|
||||
{
|
||||
QString res;
|
||||
|
||||
bool extbios = globalCfg.GetBool("Emu.ExternalBIOSEnable");
|
||||
int console = globalCfg.GetInt("Emu.ConsoleType");
|
||||
|
||||
if (extbios)
|
||||
{
|
||||
res = verifyDSBIOS();
|
||||
if (!res.isEmpty()) return res;
|
||||
}
|
||||
|
||||
if (console == 1)
|
||||
{
|
||||
res = verifyDSiBIOS();
|
||||
if (!res.isEmpty()) return res;
|
||||
|
||||
if (extbios)
|
||||
{
|
||||
res = verifyDSiFirmware();
|
||||
if (!res.isEmpty()) return res;
|
||||
}
|
||||
|
||||
res = verifyDSiNAND();
|
||||
if (!res.isEmpty()) return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (extbios)
|
||||
{
|
||||
res = verifyDSFirmware();
|
||||
if (!res.isEmpty()) return res;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright 2016-2023 melonDS team
|
||||
|
||||
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 EMUINSTANCE_H
|
||||
#define EMUINSTANCE_H
|
||||
|
||||
#include "EmuThread.h"
|
||||
#include "Window.h"
|
||||
#include "Config.h"
|
||||
|
||||
const int kMaxWindows = 16;
|
||||
|
||||
class EmuInstance
|
||||
{
|
||||
public:
|
||||
EmuInstance(int inst);
|
||||
~EmuInstance();
|
||||
|
||||
void createWindow();
|
||||
|
||||
// return: empty string = setup OK, non-empty = error message
|
||||
QString verifySetup();
|
||||
|
||||
private:
|
||||
static int lastSep(const std::string& path);
|
||||
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);
|
||||
|
||||
QString verifyDSBIOS();
|
||||
QString verifyDSiBIOS();
|
||||
QString verifyDSFirmware();
|
||||
QString verifyDSiFirmware();
|
||||
QString verifyDSiNAND();
|
||||
|
||||
int instanceID;
|
||||
|
||||
EmuThread* emuThread;
|
||||
|
||||
MainWindow* mainWindow;
|
||||
MainWindow* windowList[kMaxWindows];
|
||||
int numWindows;
|
||||
|
||||
Config::Table globalCfg;
|
||||
Config::Table localCfg;
|
||||
|
||||
int cartType;
|
||||
std::string baseROMDir;
|
||||
std::string baseROMName;
|
||||
std::string baseAssetName;
|
||||
|
||||
int gbaCartType;
|
||||
std::string baseGBAROMDir;
|
||||
std::string baseGBAROMName;
|
||||
std::string baseGBAAssetName;
|
||||
};
|
||||
|
||||
#endif //EMUINSTANCE_H
|
|
@ -38,7 +38,7 @@ extern bool RunningSomething;
|
|||
|
||||
bool EmuSettingsDialog::needsReset = false;
|
||||
|
||||
inline void updateLastBIOSFolder(QString& filename)
|
||||
inline void EmuSettingsDialog::updateLastBIOSFolder(QString& filename)
|
||||
{
|
||||
int pos = filename.lastIndexOf("/");
|
||||
if (pos == -1)
|
||||
|
@ -47,9 +47,11 @@ inline void updateLastBIOSFolder(QString& filename)
|
|||
}
|
||||
|
||||
QString path_dir = filename.left(pos);
|
||||
QString path_file = filename.mid(pos+1);
|
||||
//QString path_file = filename.mid(pos+1);
|
||||
|
||||
Config::LastBIOSFolder = path_dir.toStdString();
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
cfg.SetQString("LastBIOSFolder", path_dir);
|
||||
lastBIOSFolder = path_dir;
|
||||
}
|
||||
|
||||
EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::EmuSettingsDialog)
|
||||
|
@ -60,6 +62,8 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
|
|||
Config::Table cfg = Config::GetGlobalTable();
|
||||
Config::Table instcfg = Config::GetLocalTable(Platform::InstanceID());
|
||||
|
||||
lastBIOSFolder = cfg.GetQString("LastBIOSFolder");
|
||||
|
||||
ui->chkExternalBIOS->setChecked(cfg.GetBool("Emu.ExternalBIOSEnable"));
|
||||
ui->txtBIOS9Path->setText(cfg.GetQString("DS.BIOS9Path"));
|
||||
ui->txtBIOS7Path->setText(cfg.GetQString("DS.BIOS7Path"));
|
||||
|
@ -310,7 +314,7 @@ void EmuSettingsDialog::on_btnBIOS9Browse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DS-mode ARM9 BIOS...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"BIOS files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -324,7 +328,7 @@ void EmuSettingsDialog::on_btnBIOS7Browse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DS-mode ARM7 BIOS...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"BIOS files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -338,7 +342,7 @@ void EmuSettingsDialog::on_btnFirmwareBrowse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DS-mode firmware...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"Firmware files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -358,7 +362,7 @@ void EmuSettingsDialog::on_btnDSiBIOS9Browse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DSi-mode ARM9 BIOS...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"BIOS files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -372,7 +376,7 @@ void EmuSettingsDialog::on_btnDSiBIOS7Browse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DSi-mode ARM7 BIOS...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"BIOS files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -400,7 +404,7 @@ void EmuSettingsDialog::on_btnDLDISDBrowse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DLDI SD image...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"Image files (*.bin *.rom *.img *.dmg);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -427,7 +431,7 @@ void EmuSettingsDialog::on_btnDLDIFolderBrowse_clicked()
|
|||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
"Select DLDI SD folder...",
|
||||
QString::fromStdString(Config::LastBIOSFolder));
|
||||
lastBIOSFolder);
|
||||
|
||||
if (dir.isEmpty()) return;
|
||||
|
||||
|
@ -438,7 +442,7 @@ void EmuSettingsDialog::on_btnDSiFirmwareBrowse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DSi DS-mode firmware...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"Firmware files (*.bin *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -459,7 +463,7 @@ void EmuSettingsDialog::on_btnDSiNANDBrowse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DSi NAND...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"NAND files (*.bin *.mmc *.rom);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -494,7 +498,7 @@ void EmuSettingsDialog::on_btnDSiSDBrowse_clicked()
|
|||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
"Select DSi SD image...",
|
||||
QString::fromStdString(Config::LastBIOSFolder),
|
||||
lastBIOSFolder,
|
||||
"Image files (*.bin *.rom *.img *.sd *.dmg);;Any file (*.*)");
|
||||
|
||||
if (file.isEmpty()) return;
|
||||
|
@ -521,7 +525,7 @@ void EmuSettingsDialog::on_btnDSiSDFolderBrowse_clicked()
|
|||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
"Select DSi SD folder...",
|
||||
QString::fromStdString(Config::LastBIOSFolder));
|
||||
lastBIOSFolder);
|
||||
|
||||
if (dir.isEmpty()) return;
|
||||
|
||||
|
|
|
@ -81,8 +81,10 @@ private slots:
|
|||
|
||||
private:
|
||||
void verifyFirmware();
|
||||
void updateLastBIOSFolder(QString& filename);
|
||||
|
||||
Ui::EmuSettingsDialog* ui;
|
||||
QString lastBIOSFolder;
|
||||
};
|
||||
|
||||
#endif // EMUSETTINGSDIALOG_H
|
||||
|
|
|
@ -80,7 +80,7 @@ std::string PreviousSaveFile = "";
|
|||
ARCodeFile* CheatFile = nullptr;
|
||||
bool CheatsOn = false;
|
||||
|
||||
|
||||
#if 0
|
||||
int LastSep(const std::string& path)
|
||||
{
|
||||
int i = path.length() - 1;
|
||||
|
@ -142,7 +142,9 @@ QString VerifyDSBIOS()
|
|||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
f = Platform::OpenLocalFile(Config::BIOS9Path, FileMode::Read);
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
|
||||
f = Platform::OpenLocalFile(cfg.GetString("DS.BIOS9Path"), FileMode::Read);
|
||||
if (!f) return "DS ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -154,7 +156,7 @@ QString VerifyDSBIOS()
|
|||
|
||||
CloseFile(f);
|
||||
|
||||
f = Platform::OpenLocalFile(Config::BIOS7Path, FileMode::Read);
|
||||
f = Platform::OpenLocalFile(cfg.GetString("DS.BIOS7Path"), FileMode::Read);
|
||||
if (!f) return "DS ARM7 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -174,9 +176,11 @@ QString VerifyDSiBIOS()
|
|||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
|
||||
// TODO: check the first 32 bytes
|
||||
|
||||
f = Platform::OpenLocalFile(Config::DSiBIOS9Path, FileMode::Read);
|
||||
f = Platform::OpenLocalFile(cfg.GetString("DSi.BIOS9Path"), FileMode::Read);
|
||||
if (!f) return "DSi ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -188,7 +192,7 @@ QString VerifyDSiBIOS()
|
|||
|
||||
CloseFile(f);
|
||||
|
||||
f = Platform::OpenLocalFile(Config::DSiBIOS7Path, FileMode::Read);
|
||||
f = Platform::OpenLocalFile(cfg.GetString("DSi.BIOS7Path"), FileMode::Read);
|
||||
if (!f) return "DSi ARM7 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -208,10 +212,13 @@ QString VerifyDSFirmware()
|
|||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
f = Platform::OpenLocalFile(Config::FirmwarePath, FileMode::Read);
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
std::string fwpath = cfg.GetString("DS.FirmwarePath");
|
||||
|
||||
f = Platform::OpenLocalFile(fwpath, FileMode::Read);
|
||||
if (!f) return "DS firmware was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(Config::FirmwarePath))
|
||||
if (!Platform::CheckFileWritable(fwpath))
|
||||
return "DS firmware is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -238,10 +245,13 @@ QString VerifyDSiFirmware()
|
|||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
f = Platform::OpenLocalFile(Config::DSiFirmwarePath, FileMode::Read);
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
std::string fwpath = cfg.GetString("DSi.FirmwarePath");
|
||||
|
||||
f = Platform::OpenLocalFile(fwpath, FileMode::Read);
|
||||
if (!f) return "DSi firmware was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(Config::FirmwarePath))
|
||||
if (!Platform::CheckFileWritable(fwpath))
|
||||
return "DSi firmware is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
len = FileLength(f);
|
||||
|
@ -263,10 +273,13 @@ QString VerifyDSiNAND()
|
|||
FileHandle* f;
|
||||
long len;
|
||||
|
||||
f = Platform::OpenLocalFile(Config::DSiNANDPath, FileMode::ReadWriteExisting);
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
std::string nandpath = cfg.GetString("DSi.NANDPath");
|
||||
|
||||
f = Platform::OpenLocalFile(nandpath, FileMode::ReadWriteExisting);
|
||||
if (!f) return "DSi NAND was not found or could not be accessed. Check your emu settings.";
|
||||
|
||||
if (!Platform::CheckFileWritable(Config::FirmwarePath))
|
||||
if (!Platform::CheckFileWritable(nandpath))
|
||||
return "DSi NAND is unable to be written to.\nPlease check file/folder write permissions.";
|
||||
|
||||
// TODO: some basic checks
|
||||
|
@ -312,7 +325,7 @@ QString VerifySetup()
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif
|
||||
std::string GetEffectiveFirmwareSavePath(EmuThread* thread)
|
||||
{
|
||||
if (!Config::ExternalBIOSEnable)
|
||||
|
|
|
@ -140,7 +140,9 @@ bool TitleManagerDialog::openNAND()
|
|||
{
|
||||
nand = nullptr;
|
||||
|
||||
FileHandle* bios7i = Platform::OpenLocalFile(Config::DSiBIOS7Path, FileMode::Read);
|
||||
Config::Table cfg = Config::GetGlobalTable();
|
||||
|
||||
FileHandle* bios7i = Platform::OpenLocalFile(cfg.GetString("DSi.BIOS7Path"), FileMode::Read);
|
||||
if (!bios7i)
|
||||
return false;
|
||||
|
||||
|
@ -149,7 +151,7 @@ bool TitleManagerDialog::openNAND()
|
|||
FileRead(es_keyY, 16, 1, bios7i);
|
||||
CloseFile(bios7i);
|
||||
|
||||
FileHandle* nandfile = Platform::OpenLocalFile(Config::DSiNANDPath, FileMode::ReadWriteExisting);
|
||||
FileHandle* nandfile = Platform::OpenLocalFile(cfg.GetString("DSi.NANDPath"), FileMode::ReadWriteExisting);
|
||||
if (!nandfile)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -202,21 +202,24 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
{
|
||||
test_num = test++;
|
||||
#ifndef _WIN32
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, signalFd))
|
||||
if (!parent)
|
||||
{
|
||||
qFatal("Couldn't create socketpair");
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, signalFd))
|
||||
{
|
||||
qFatal("Couldn't create socketpair");
|
||||
}
|
||||
|
||||
signalSn = new QSocketNotifier(signalFd[1], QSocketNotifier::Read, this);
|
||||
connect(signalSn, SIGNAL(activated(int)), this, SLOT(onQuit()));
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_handler = signalHandler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_flags |= SA_RESTART;
|
||||
sigaction(SIGINT, &sa, 0);
|
||||
}
|
||||
|
||||
signalSn = new QSocketNotifier(signalFd[1], QSocketNotifier::Read, this);
|
||||
connect(signalSn, SIGNAL(activated(int)), this, SLOT(onQuit()));
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_handler = signalHandler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_flags |= SA_RESTART;
|
||||
sigaction(SIGINT, &sa, 0);
|
||||
#endif
|
||||
|
||||
oldW = Config::WindowWidth;
|
||||
|
|
|
@ -340,7 +340,6 @@ int main(int argc, char** argv)
|
|||
if (!Config::Load()) QMessageBox::critical(NULL, "melonDS", "Unable to write to config.\nPlease check the write permissions of the folder you placed melonDS in.");
|
||||
|
||||
#define SANITIZE(var, min, max) { var = std::clamp(var, min, max); }
|
||||
SANITIZE(Config::ConsoleType, 0, 1);
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
SANITIZE(Config::_3DRenderer, 0, 1); // 0 is the software renderer, 1 is the OpenGL renderer
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue