diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 43b5a70297..79687ddff2 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -723,19 +723,9 @@ bool Load() void Save() { auto cfgpath = Platform::GetLocalFilePath(kConfigFile); -printf("save\n"); if (!Platform::CheckFileWritable(cfgpath)) return; - printf("zirz\n"); - /*RootTable["test"] = 4444; - RootTable["teste.derp"] = 5555; - RootTable["testa"]["fazil"] = 6666;*/ - //std::string derp = "sfsdf"; - //toml::serializer vorp(RootTable); - //toml::serializer zarp; - - //std::cout << RootTable; - printf("blarg\n"); + std::ofstream file; file.open(cfgpath, std::ofstream::out | std::ofstream::trunc); file << RootTable; diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 2a5cc9ba0a..5adf671f28 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -68,6 +68,20 @@ EmuInstance::EmuInstance(int inst) : instanceID(inst), globalCfg(Config::GetGlobalTable()), localCfg(Config::GetLocalTable(inst)) { + consoleType = globalCfg.GetInt("Emu.ConsoleType"); + + ndsSave = nullptr; + cartType = -1; + baseROMDir = ""; + baseROMName = ""; + baseAssetName = ""; + + gbaSave = nullptr; + gbaCartType = -1; + baseGBAROMDir = ""; + baseGBAROMName = ""; + baseGBAAssetName = ""; + cheatFile = nullptr; cheatsOn = localCfg.GetBool("EnableCheats"); @@ -506,7 +520,7 @@ std::string EmuInstance::getEffectiveFirmwareSavePath() { return kWifiSettingsPath; } - if (nds->ConsoleType == 1) + if (consoleType == 1) { return globalCfg.GetString("DSi.FirmwarePath"); } @@ -1016,7 +1030,7 @@ ARCodeFile* EmuInstance::getCheatFile() void EmuInstance::setBatteryLevels() { - if (nds->ConsoleType == 1) + if (consoleType == 1) { auto dsi = static_cast(nds); dsi->I2C.GetBPTWL()->SetBatteryLevel(localCfg.GetInt("DSi.Battery.Level")); @@ -1158,7 +1172,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB } - if ((!nds) || (consoletype != nds->ConsoleType)) + if ((!nds) || (consoletype != consoleType)) { NDS::Current = nullptr; if (nds) delete nds; @@ -1204,9 +1218,11 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB void EmuInstance::reset() { + consoleType = globalCfg.GetInt("Emu.ConsoleType"); + updateConsole(Keep {}, Keep {}); - if (nds->ConsoleType == 1) ejectGBACart(); + if (consoleType == 1) ejectGBACart(); nds->Reset(); setBatteryLevels(); @@ -1237,7 +1253,7 @@ void EmuInstance::reset() string newsave; if (globalCfg.GetBool("Emu.ExternalBIOSEnable")) { - if (nds->ConsoleType == 1) + if (consoleType == 1) newsave = globalCfg.GetString("DSi.FirmwarePath") + instanceFileSuffix(); else newsave = globalCfg.GetString("DS.FirmwarePath") + instanceFileSuffix(); @@ -1381,7 +1397,7 @@ pair, string> EmuInstance::generateDefaultFirmware() { // Construct the default firmware... string settingspath; - std::unique_ptr firmware = std::make_unique(nds->ConsoleType); + std::unique_ptr firmware = std::make_unique(consoleType); assert(firmware->Buffer() != nullptr); // Try to open the instanced Wi-fi settings, falling back to the regular Wi-fi settings if they don't exist. @@ -1412,7 +1428,7 @@ pair, string> EmuInstance::generateDefaultFirmware() Platform::Log(Platform::LogLevel::Warn, "Failed to read Wi-fi settings from \"%s\"; using defaults instead\n", wfcsettingspath.c_str()); firmware->GetAccessPoints() = { - Firmware::WifiAccessPoint(nds->ConsoleType), + Firmware::WifiAccessPoint(consoleType), Firmware::WifiAccessPoint(), Firmware::WifiAccessPoint(), }; @@ -1789,7 +1805,7 @@ QString EmuInstance::cartLabel() bool EmuInstance::loadGBAROM(QStringList filepath) { - if (nds->ConsoleType == 1) + if (consoleType == 1) { QMessageBox::critical(mainWindow, "melonDS", "The DSi doesn't have a GBA slot."); return false; @@ -1864,7 +1880,7 @@ bool EmuInstance::loadGBAROM(QStringList filepath) void EmuInstance::loadGBAAddon(int type) { - if (nds->ConsoleType == 1) return; + if (consoleType == 1) return; gbaSave = nullptr; @@ -1895,7 +1911,7 @@ bool EmuInstance::gbaCartInserted() QString EmuInstance::gbaCartLabel() { - if (nds->ConsoleType == 1) return "none (DSi)"; + if (consoleType == 1) return "none (DSi)"; switch (gbaCartType) { diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index fd4221a984..44bd75e125 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -78,6 +78,7 @@ class EmuInstance ~EmuInstance(); int getInstanceID() { return instanceID; } + int getConsoleType() { return consoleType; } EmuThread* getEmuThread() { return emuThread; } melonDS::NDS* getNDS() { return nds; } @@ -225,6 +226,7 @@ class EmuInstance Config::Table globalCfg; Config::Table localCfg; + int consoleType; melonDS::NDS* nds; int cartType;