diff --git a/src/Platform.h b/src/Platform.h index 04be94d4..ce98ef29 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -79,18 +79,6 @@ enum StopReason { */ void SignalStop(StopReason reason); -/** - * @returns The ID of the running melonDS instance if running in local multiplayer mode, - * or 0 if not. - */ -int InstanceID(); - -/** - * @returns A suffix that should be appended to all instance-specific paths - * if running in local multiplayer mode, - * or the empty string if not. - */ -std::string InstanceFileSuffix(); /** * Denotes how a file will be opened and accessed. diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 79bfa25c..f0e8c64c 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -108,6 +108,15 @@ EmuInstance::~EmuInstance() } +std::string EmuInstance::instanceFileSuffix() +{ + if (instanceID == 0) return ""; + + char suffix[16] = {0}; + snprintf(suffix, 15, ".%d", instanceID+1); + return suffix; +} + void EmuInstance::createWindow() { if (numWindows >= kMaxWindows) @@ -557,7 +566,7 @@ bool EmuInstance::loadState(const std::string& filename) std::string savefile = filename.substr(lastSep(filename)+1); savefile = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav", savefile); - savefile += Platform::InstanceFileSuffix(); + savefile += instanceFileSuffix(); ndsSave->SetPath(savefile, true); } @@ -608,7 +617,7 @@ bool EmuInstance::saveState(const std::string& filename) { std::string savefile = filename.substr(lastSep(filename)+1); savefile = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav", savefile); - savefile += Platform::InstanceFileSuffix(); + savefile += instanceFileSuffix(); ndsSave->SetPath(savefile, false); } @@ -1170,7 +1179,7 @@ void EmuInstance::reset() { std::string oldsave = ndsSave->GetPath(); std::string newsave = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav"); - newsave += Platform::InstanceFileSuffix(); + newsave += instanceFileSuffix(); if (oldsave != newsave) ndsSave->SetPath(newsave, false); } @@ -1179,7 +1188,7 @@ void EmuInstance::reset() { std::string oldsave = gbaSave->GetPath(); std::string newsave = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav"); - newsave += Platform::InstanceFileSuffix(); + newsave += instanceFileSuffix(); if (oldsave != newsave) gbaSave->SetPath(newsave, false); } @@ -1192,13 +1201,13 @@ void EmuInstance::reset() if (globalCfg.GetBool("Emu.ExternalBIOSEnable")) { if (nds->ConsoleType == 1) - newsave = globalCfg.GetString("DSi.FirmwarePath") + Platform::InstanceFileSuffix(); + newsave = globalCfg.GetString("DSi.FirmwarePath") + instanceFileSuffix(); else - newsave = globalCfg.GetString("DS.FirmwarePath") + Platform::InstanceFileSuffix(); + newsave = globalCfg.GetString("DS.FirmwarePath") + instanceFileSuffix(); } else { - newsave = kWifiSettingsPath + Platform::InstanceFileSuffix(); + newsave = kWifiSettingsPath + instanceFileSuffix(); } if (oldsave != newsave) @@ -1341,7 +1350,7 @@ pair, string> EmuInstance::generateDefaultFirmware() // Try to open the instanced Wi-fi settings, falling back to the regular Wi-fi settings if they don't exist. // We don't need to save the whole firmware, just the part that may actually change. std::string wfcsettingspath = kWifiSettingsPath; - settingspath = wfcsettingspath + Platform::InstanceFileSuffix(); + settingspath = wfcsettingspath + instanceFileSuffix(); FileHandle* f = Platform::OpenLocalFile(settingspath, FileMode::Read); if (!f) { @@ -1493,13 +1502,12 @@ void EmuInstance::customizeFirmware(Firmware& firmware, bool overridesettings) n } } - int inst = Platform::InstanceID(); - if (inst > 0) + if (instanceID > 0) { rep = true; - mac[3] += inst; - mac[4] += inst*0x44; - mac[5] += inst*0x10; + mac[3] += instanceID; + mac[4] += instanceID*0x44; + mac[5] += instanceID*0x10; } if (rep) @@ -1630,7 +1638,7 @@ bool EmuInstance::loadROM(QStringList filepath, bool reset) std::string savname = getAssetPath(false, globalCfg.GetString("SaveFilePath"), ".sav"); std::string origsav = savname; - savname += Platform::InstanceFileSuffix(); + savname += instanceFileSuffix(); FileHandle* sav = Platform::OpenFile(savname, FileMode::Read); if (!sav) @@ -1772,7 +1780,7 @@ bool EmuInstance::loadGBAROM(QStringList filepath) std::string savname = getAssetPath(true, globalCfg.GetString("SaveFilePath"), ".sav"); std::string origsav = savname; - savname += Platform::InstanceFileSuffix(); + savname += instanceFileSuffix(); FileHandle* sav = Platform::OpenFile(savname, FileMode::Read); if (!sav) diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index 87f4226d..c0d5dca6 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -84,6 +84,8 @@ public: Config::Table& getGlobalConfig() { return globalCfg; } Config::Table& getLocalConfig() { return localCfg; } + std::string instanceFileSuffix(); + void createWindow(); void osdAddMessage(unsigned int color, const char* fmt, ...); diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index b36ed7d3..b27087b3 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -420,7 +420,7 @@ void EmuThread::run() if (winUpdateFreq < 1) winUpdateFreq = 1; - int inst = Platform::InstanceID(); + int inst = emuInstance->instanceID; if (inst == 0) sprintf(melontitle, "[%d/%.0f] melonDS " MELONDS_VERSION, fps, fpstarget); else @@ -439,7 +439,7 @@ void EmuThread::run() EmuStatus = EmuRunning; - int inst = Platform::InstanceID(); + int inst = emuInstance->instanceID; if (inst == 0) sprintf(melontitle, "melonDS " MELONDS_VERSION); else @@ -483,7 +483,6 @@ void EmuThread::run() EmuStatus = emuStatus_Exit; NDS::Current = nullptr; - // nds is out of scope, so unique_ptr cleans it up for us } void EmuThread::changeWindowTitle(char* title) diff --git a/src/frontend/qt_sdl/PathSettingsDialog.cpp b/src/frontend/qt_sdl/PathSettingsDialog.cpp index 38222fe9..f1561082 100644 --- a/src/frontend/qt_sdl/PathSettingsDialog.cpp +++ b/src/frontend/qt_sdl/PathSettingsDialog.cpp @@ -53,7 +53,7 @@ PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne ui->txtSavestatePath->setText(cfg.GetQString("SavestatePath")); ui->txtCheatFilePath->setText(cfg.GetQString("CheatFilePath")); - int inst = Platform::InstanceID(); + int inst = emuInstance->getInstanceID(); if (inst > 0) ui->lblInstanceNum->setText(QString("Configuring paths for instance %1").arg(inst+1)); else diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index a0aa751f..aa09dd7e 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -204,21 +204,6 @@ void SignalStop(StopReason reason) } -int InstanceID() -{ - return IPCInstanceID; -} - -std::string InstanceFileSuffix() -{ - int inst = IPCInstanceID; - if (inst == 0) return ""; - - char suffix[16] = {0}; - snprintf(suffix, 15, ".%d", inst+1); - return suffix; -} - static QIODevice::OpenMode GetQMode(FileMode mode) { QIODevice::OpenMode qmode = QIODevice::OpenModeFlag::NotOpen; diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp index b1b2096a..e28bd9ec 100644 --- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp +++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp @@ -89,7 +89,7 @@ PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent), } - int inst = Platform::InstanceID(); + int inst = emuInstance->getInstanceID(); if (inst > 0) ui->lblInstanceNum->setText(QString("Setting battery levels for instance %1").arg(inst+1)); else diff --git a/src/frontend/qt_sdl/Screen.cpp b/src/frontend/qt_sdl/Screen.cpp index 78bdd91a..5721d2b3 100644 --- a/src/frontend/qt_sdl/Screen.cpp +++ b/src/frontend/qt_sdl/Screen.cpp @@ -16,20 +16,13 @@ with melonDS. If not, see http://www.gnu.org/licenses/. */ -#include -#include -#include #include #include -#include -#include -#include #include #include #include -#include #ifndef _WIN32 #ifndef APPLE #include @@ -57,12 +50,6 @@ using namespace melonDS; -// TEMP -extern bool RunningSomething; - -extern int videoRenderer; -extern bool videoSettingsDirty; - const u32 kOSDMargin = 6; diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 9c32639b..53ebd983 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -232,8 +232,6 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : setAcceptDrops(true); setFocusPolicy(Qt::ClickFocus); - //int inst = Platform::InstanceID(); - QMenuBar* menubar = new QMenuBar(); { QMenu* menu = menubar->addMenu("File");