From e08171fa243b7e5488713b63a7ae030f3b100490 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 3 Jan 2022 07:07:32 +0100 Subject: [PATCH 1/2] Config: Port remaining Core settings to new config system (partial). --- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 3 +- Source/Core/Core/BootManager.cpp | 58 ++----------------- Source/Core/Core/Config/MainSettings.cpp | 2 + Source/Core/Core/Config/MainSettings.h | 2 + .../Core/ConfigLoaders/GameConfigLoader.cpp | 3 + .../Core/ConfigLoaders/IsSettingSaveable.cpp | 17 ++++++ .../Core/ConfigLoaders/MovieConfigLoader.cpp | 4 ++ Source/Core/Core/ConfigManager.cpp | 52 +---------------- Source/Core/Core/ConfigManager.h | 22 ------- Source/Core/Core/Core.cpp | 2 +- Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp | 10 ++-- .../Core/Core/HW/EXI/EXI_DeviceEthernet.cpp | 16 ++--- Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp | 3 +- Source/Core/Core/HW/HW.cpp | 2 +- Source/Core/Core/HW/SystemTimers.cpp | 5 +- Source/Core/Core/Movie.cpp | 6 +- Source/Core/Core/NetPlayServer.cpp | 6 +- .../Interpreter/Interpreter_LoadStore.cpp | 6 +- .../Core/PowerPC/Jit64/Jit_FloatingPoint.cpp | 10 ++-- .../Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 4 +- .../JitArm64/JitArm64_FloatingPoint.cpp | 4 +- .../PowerPC/JitArm64/JitArm64_LoadStore.cpp | 2 +- .../Core/Core/PowerPC/JitCommon/JitBase.cpp | 12 +++- Source/Core/Core/PowerPC/JitCommon/JitBase.h | 5 ++ Source/Core/Core/PowerPC/PPCAnalyst.cpp | 10 ++-- Source/Core/Core/PowerPC/PPCAnalyst.h | 6 ++ Source/Core/DolphinQt/Debugger/JITWidget.cpp | 3 + Source/Core/DolphinQt/MenuBar.cpp | 2 +- .../Core/DolphinQt/Settings/AdvancedPane.cpp | 15 ++--- .../BroadbandAdapterSettingsDialog.cpp | 10 ++-- .../Core/DolphinQt/Settings/GameCubePane.cpp | 22 +++---- .../Core/DolphinQt/Settings/GeneralPane.cpp | 4 +- 32 files changed, 131 insertions(+), 197 deletions(-) diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 9e66a2458a..8903985453 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -16,6 +16,7 @@ #include "Core/Boot/Boot.h" #include "Core/CommonTitles.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HLE/HLE.h" @@ -301,7 +302,7 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type) model = gen.GetValue("MODEL"); bool region_matches = false; - if (SConfig::GetInstance().bOverrideRegionSettings) + if (Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS)) { region_matches = true; } diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index ee60c6a946..6e9c3d7f51 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -73,23 +73,14 @@ public: private: bool valid = false; bool bCPUThread = false; - bool bJITFollowBranch = false; bool bSyncGPUOnSkipIdleHack = false; - bool bFloatExceptions = false; - bool bDivideByZeroExceptions = false; - bool bFPRF = false; - bool bAccurateNaNs = false; bool bMMU = false; - bool bLowDCBZHack = false; bool bDisableICache = false; bool bSyncGPU = false; int iSyncGpuMaxDistance = 0; int iSyncGpuMinDistance = 0; float fSyncGpuOverclock = 0; bool bFastDiscSpeed = false; - bool bHLE_BS2 = false; - int iSelectedLanguage = 0; - PowerPC::CPUCore cpu_core = PowerPC::CPUCore::Interpreter; float m_EmulationSpeed = 0; std::string m_strGPUDeterminismMode; std::array iWiimoteSource{}; @@ -102,12 +93,7 @@ void ConfigCache::SaveConfig(const SConfig& config) valid = true; bCPUThread = config.bCPUThread; - bJITFollowBranch = config.bJITFollowBranch; bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; - bFloatExceptions = config.bFloatExceptions; - bDivideByZeroExceptions = config.bDivideByZeroExceptions; - bFPRF = config.bFPRF; - bAccurateNaNs = config.bAccurateNaNs; bDisableICache = config.bDisableICache; bMMU = config.bMMU; bSyncGPU = config.bSyncGPU; @@ -115,9 +101,6 @@ void ConfigCache::SaveConfig(const SConfig& config) iSyncGpuMinDistance = config.iSyncGpuMinDistance; fSyncGpuOverclock = config.fSyncGpuOverclock; bFastDiscSpeed = config.bFastDiscSpeed; - bHLE_BS2 = config.bHLE_BS2; - iSelectedLanguage = config.SelectedLanguage; - cpu_core = config.cpu_core; m_EmulationSpeed = config.m_EmulationSpeed; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; @@ -142,23 +125,14 @@ void ConfigCache::RestoreConfig(SConfig* config) valid = false; config->bCPUThread = bCPUThread; - config->bJITFollowBranch = bJITFollowBranch; config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack; - config->bFloatExceptions = bFloatExceptions; - config->bDivideByZeroExceptions = bDivideByZeroExceptions; - config->bFPRF = bFPRF; - config->bAccurateNaNs = bAccurateNaNs; config->bDisableICache = bDisableICache; config->bMMU = bMMU; - config->bLowDCBZHack = bLowDCBZHack; config->bSyncGPU = bSyncGPU; config->iSyncGpuMaxDistance = iSyncGpuMaxDistance; config->iSyncGpuMinDistance = iSyncGpuMinDistance; config->fSyncGpuOverclock = fSyncGpuOverclock; config->bFastDiscSpeed = bFastDiscSpeed; - config->bHLE_BS2 = bHLE_BS2; - config->SelectedLanguage = iSelectedLanguage; - config->cpu_core = cpu_core; // Only change these back if they were actually set by game ini, since they can be changed while a // game is running. @@ -235,22 +209,12 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls"); core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); - core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch); core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack, StartUp.bSyncGPUOnSkipIdleHack); - core_section->Get("FloatExceptions", &StartUp.bFloatExceptions, StartUp.bFloatExceptions); - core_section->Get("DivByZeroExceptions", &StartUp.bDivideByZeroExceptions, - StartUp.bDivideByZeroExceptions); - core_section->Get("FPRF", &StartUp.bFPRF, StartUp.bFPRF); - core_section->Get("AccurateNaNs", &StartUp.bAccurateNaNs, StartUp.bAccurateNaNs); core_section->Get("DisableICache", &StartUp.bDisableICache, StartUp.bDisableICache); core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU); - core_section->Get("LowDCBZHack", &StartUp.bLowDCBZHack, StartUp.bLowDCBZHack); core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); - core_section->Get("CPUCore", &StartUp.cpu_core, StartUp.cpu_core); - core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2); - core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage); if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed)) config_cache.bSetEmulationSpeed = true; @@ -302,12 +266,8 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) { // TODO: remove this once ConfigManager starts using OnionConfig. StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD); - StartUp.bJITFollowBranch = Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH); StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED); - StartUp.cpu_core = Config::Get(Config::MAIN_CPU_CORE); StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU); - if (!StartUp.bWii) - StartUp.SelectedLanguage = Config::Get(Config::MAIN_GC_LANGUAGE); for (int i = 0; i < 2; ++i) { if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii) @@ -330,30 +290,21 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings)); StartUp.bCPUThread = netplay_settings.m_CPUthread; StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave; - StartUp.cpu_core = netplay_settings.m_CPUcore; - StartUp.SelectedLanguage = netplay_settings.m_SelectedLanguage; - StartUp.bOverrideRegionSettings = netplay_settings.m_OverrideRegionSettings; StartUp.m_EXIDevice[0] = netplay_settings.m_EXIDevice[0]; StartUp.m_EXIDevice[1] = netplay_settings.m_EXIDevice[1]; StartUp.m_EXIDevice[2] = netplay_settings.m_EXIDevice[2]; config_cache.bSetEXIDevice[0] = true; config_cache.bSetEXIDevice[1] = true; config_cache.bSetEXIDevice[2] = true; - StartUp.bFPRF = netplay_settings.m_FPRF; - StartUp.bAccurateNaNs = netplay_settings.m_AccurateNaNs; StartUp.bDisableICache = netplay_settings.m_DisableICache; StartUp.bSyncGPUOnSkipIdleHack = netplay_settings.m_SyncOnSkipIdle; - StartUp.bFloatExceptions = netplay_settings.m_FloatExceptions; - StartUp.bDivideByZeroExceptions = netplay_settings.m_DivideByZeroExceptions; StartUp.bSyncGPU = netplay_settings.m_SyncGPU; StartUp.iSyncGpuMaxDistance = netplay_settings.m_SyncGpuMaxDistance; StartUp.iSyncGpuMinDistance = netplay_settings.m_SyncGpuMinDistance; StartUp.fSyncGpuOverclock = netplay_settings.m_SyncGpuOverclock; - StartUp.bJITFollowBranch = netplay_settings.m_JITFollowBranch; StartUp.bFastDiscSpeed = netplay_settings.m_FastDiscSpeed; StartUp.bMMU = netplay_settings.m_MMU; StartUp.bFastmem = netplay_settings.m_Fastmem; - StartUp.bHLE_BS2 = netplay_settings.m_SkipIPL; if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting) config_cache.bSetEmulationSpeed = true; } @@ -363,10 +314,11 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) } // Override out-of-region languages/countries to prevent games from crashing or behaving oddly - if (!StartUp.bOverrideRegionSettings) + if (!Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS)) { - StartUp.SelectedLanguage = - DiscIO::ToGameCubeLanguage(StartUp.GetLanguageAdjustedForRegion(false, StartUp.m_region)); + Config::SetCurrent( + Config::MAIN_GC_LANGUAGE, + DiscIO::ToGameCubeLanguage(StartUp.GetLanguageAdjustedForRegion(false, StartUp.m_region))); if (StartUp.bWii) { @@ -428,7 +380,7 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) } } - const bool load_ipl = !StartUp.bWii && !StartUp.bHLE_BS2 && + const bool load_ipl = !StartUp.bWii && !Config::Get(Config::MAIN_SKIP_IPL) && std::holds_alternative(boot->parameters); if (load_ipl) { diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 141d21ba71..ae7d3ce652 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -59,6 +59,8 @@ const Info MAIN_SLOT_B{{System::Main, "Core", "SlotB"}, ExpansionInterface: const Info MAIN_SERIAL_PORT_1{{System::Main, "Core", "SerialPort1"}, ExpansionInterface::EXIDEVICE_NONE}; const Info MAIN_BBA_MAC{{System::Main, "Core", "BBA_MAC"}, ""}; +const Info MAIN_BBA_XLINK_IP{{System::Main, "Core", "BBA_XLINK_IP"}, "127.0.0.1"}; +const Info MAIN_BBA_XLINK_CHAT_OSD{{System::Main, "Core", "BBA_XLINK_CHAT_OSD"}, true}; Info GetInfoForSIDevice(u32 channel) { diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 5874748feb..1424433647 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -63,6 +63,8 @@ extern const Info MAIN_SLOT_A; extern const Info MAIN_SLOT_B; extern const Info MAIN_SERIAL_PORT_1; extern const Info MAIN_BBA_MAC; +extern const Info MAIN_BBA_XLINK_IP; +extern const Info MAIN_BBA_XLINK_CHAT_OSD; Info GetInfoForSIDevice(u32 channel); Info GetInfoForAdapterRumble(u32 channel); Info GetInfoForSimulateKonga(u32 channel); diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 9c72f2a4ef..9012e7c9f9 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -24,6 +24,7 @@ #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Core/Config/MainSettings.h" #include "Core/Config/SYSCONFSettings.h" #include "Core/ConfigLoaders/IsSettingSaveable.h" @@ -72,6 +73,8 @@ static const INIToLocationMap& GetINIToLocationMap() {{"Core", "PAL60"}, {Config::SYSCONF_PAL60.GetLocation()}}, {{"Wii", "Widescreen"}, {Config::SYSCONF_WIDESCREEN.GetLocation()}}, {{"Wii", "Language"}, {Config::SYSCONF_LANGUAGE.GetLocation()}}, + {{"Core", "HLE_BS2"}, {Config::MAIN_SKIP_IPL.GetLocation()}}, + {{"Core", "GameCubeLanguage"}, {Config::MAIN_GC_LANGUAGE.GetLocation()}}, }; return ini_to_location; } diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 755de46418..a33d0448c4 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -72,6 +72,23 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_FALLBACK_REGION.GetLocation(), &Config::MAIN_REAL_WII_REMOTE_REPEAT_REPORTS.GetLocation(), &Config::MAIN_DSP_HLE.GetLocation(), + &Config::MAIN_CPU_CORE.GetLocation(), + &Config::MAIN_SKIP_IPL.GetLocation(), + &Config::MAIN_GC_LANGUAGE.GetLocation(), + &Config::MAIN_AGP_CART_A_PATH.GetLocation(), + &Config::MAIN_AGP_CART_B_PATH.GetLocation(), + &Config::MAIN_BBA_MAC.GetLocation(), + &Config::MAIN_BBA_XLINK_IP.GetLocation(), + &Config::MAIN_BBA_XLINK_CHAT_OSD.GetLocation(), + &Config::MAIN_OVERRIDE_REGION_SETTINGS.GetLocation(), + &Config::MAIN_CUSTOM_RTC_ENABLE.GetLocation(), + &Config::MAIN_CUSTOM_RTC_VALUE.GetLocation(), + &Config::MAIN_JIT_FOLLOW_BRANCH.GetLocation(), + &Config::MAIN_FLOAT_EXCEPTIONS.GetLocation(), + &Config::MAIN_DIVIDE_BY_ZERO_EXCEPTIONS.GetLocation(), + &Config::MAIN_LOW_DCBZ_HACK.GetLocation(), + &Config::MAIN_FPRF.GetLocation(), + &Config::MAIN_ACCURATE_NANS.GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp index 3b25dbfa9b..735e1e1eba 100644 --- a/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/MovieConfigLoader.cpp @@ -48,6 +48,8 @@ static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm) config_layer->Set(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, dtm->bSkipXFBCopyToRam); config_layer->Set(Config::SESSION_USE_FMA, dtm->bUseFMA); + + config_layer->Set(Config::MAIN_JIT_FOLLOW_BRANCH, dtm->bFollowBranch); } void SaveToDTM(Movie::DTMHeader* dtm) @@ -74,6 +76,8 @@ void SaveToDTM(Movie::DTMHeader* dtm) dtm->bUseFMA = Config::Get(Config::SESSION_USE_FMA); + dtm->bFollowBranch = Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH); + // Settings which only existed in old Dolphin versions dtm->bSkipIdle = true; dtm->bEFBCopyEnable = true; diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index b274922646..3bb3abb8b9 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -99,9 +99,7 @@ void SConfig::SaveCoreSettings(IniFile& ini) { IniFile::Section* core = ini.GetOrCreateSection("Core"); - core->Set("SkipIPL", bHLE_BS2); core->Set("TimingVariance", iTimingVariance); - core->Set("CPUCore", cpu_core); core->Set("Fastmem", bFastmem); core->Set("CPUThread", bCPUThread); core->Set("SyncOnSkipIdle", bSyncGPUOnSkipIdleHack); @@ -109,20 +107,9 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance); core->Set("SyncGpuMinDistance", iSyncGpuMinDistance); core->Set("SyncGpuOverclock", fSyncGpuOverclock); - core->Set("FloatExceptions", bFloatExceptions); - core->Set("DivByZeroExceptions", bDivideByZeroExceptions); - core->Set("FPRF", bFPRF); - core->Set("AccurateNaNs", bAccurateNaNs); - core->Set("SelectedLanguage", SelectedLanguage); - core->Set("OverrideRegionSettings", bOverrideRegionSettings); - core->Set("AgpCartAPath", m_strGbaCartA); - core->Set("AgpCartBPath", m_strGbaCartB); core->Set("SlotA", m_EXIDevice[0]); core->Set("SlotB", m_EXIDevice[1]); core->Set("SerialPort1", m_EXIDevice[2]); - core->Set("BBA_MAC", m_bba_mac); - core->Set("BBA_XLINK_IP", m_bba_xlink_ip); - core->Set("BBA_XLINK_CHAT_OSD", m_bba_xlink_chat_osd); for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i) { core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]); @@ -140,8 +127,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("EmulationSpeed", m_EmulationSpeed); core->Set("GPUDeterminismMode", m_strGPUDeterminismMode); core->Set("PerfMapDir", m_perfDir); - core->Set("EnableCustomRTC", bEnableCustomRTC); - core->Set("CustomRTCValue", m_customRTCValue); } void SConfig::LoadSettings() @@ -159,30 +144,13 @@ void SConfig::LoadCoreSettings(IniFile& ini) { IniFile::Section* core = ini.GetOrCreateSection("Core"); - core->Get("SkipIPL", &bHLE_BS2, true); -#ifdef _M_X86 - core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::JIT64); -#elif _M_ARM_64 - core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::JITARM64); -#else - core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::Interpreter); -#endif - core->Get("JITFollowBranch", &bJITFollowBranch, true); core->Get("Fastmem", &bFastmem, true); core->Get("TimingVariance", &iTimingVariance, 40); core->Get("CPUThread", &bCPUThread, true); core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true); - core->Get("SelectedLanguage", &SelectedLanguage, - DiscIO::ToGameCubeLanguage(Config::GetDefaultLanguage())); - core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false); - core->Get("AgpCartAPath", &m_strGbaCartA); - core->Get("AgpCartBPath", &m_strGbaCartB); core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER); core->Get("SlotB", (int*)&m_EXIDevice[1], ExpansionInterface::EXIDEVICE_NONE); core->Get("SerialPort1", (int*)&m_EXIDevice[2], ExpansionInterface::EXIDEVICE_NONE); - core->Get("BBA_MAC", &m_bba_mac); - core->Get("BBA_XLINK_IP", &m_bba_xlink_ip, "127.0.0.1"); - core->Get("BBA_XLINK_CHAT_OSD", &m_bba_xlink_chat_osd, true); for (size_t i = 0; i < std::size(m_SIDevice); ++i) { core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i], @@ -204,18 +172,10 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("SyncGpuMinDistance", &iSyncGpuMinDistance, -200000); core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f); core->Get("FastDiscSpeed", &bFastDiscSpeed, false); - core->Get("LowDCBZHack", &bLowDCBZHack, false); - core->Get("FloatExceptions", &bFloatExceptions, false); - core->Get("DivByZeroExceptions", &bDivideByZeroExceptions, false); - core->Get("FPRF", &bFPRF, false); - core->Get("AccurateNaNs", &bAccurateNaNs, false); core->Get("DisableICache", &bDisableICache, false); core->Get("EmulationSpeed", &m_EmulationSpeed, 1.0f); core->Get("GPUDeterminismMode", &m_strGPUDeterminismMode, "auto"); core->Get("PerfMapDir", &m_perfDir, ""); - core->Get("EnableCustomRTC", &bEnableCustomRTC, false); - // Default to seconds between 1.1.1970 and 1.1.2000 - core->Get("CustomRTCValue", &m_customRTCValue, 946684800); } void SConfig::ResetRunningGameMetadata() @@ -331,24 +291,16 @@ void SConfig::LoadDefaults() bAutomaticStart = false; bBootToPause = false; - cpu_core = PowerPC::DefaultCPUCore(); iTimingVariance = 40; bCPUThread = false; bSyncGPUOnSkipIdleHack = true; bRunCompareServer = false; bFastmem = true; - bFloatExceptions = false; - bDivideByZeroExceptions = false; - bFPRF = false; - bAccurateNaNs = false; bDisableICache = false; bMMU = false; - bLowDCBZHack = false; iBBDumpPort = -1; bSyncGPU = false; bFastDiscSpeed = false; - SelectedLanguage = 0; - bOverrideRegionSettings = false; bWii = false; ResetRunningGameMetadata(); @@ -539,7 +491,7 @@ DiscIO::Language SConfig::GetCurrentLanguage(bool wii) const if (wii) language = static_cast(Config::Get(Config::SYSCONF_LANGUAGE)); else - language = DiscIO::FromGameCubeLanguage(SConfig::GetInstance().SelectedLanguage); + language = DiscIO::FromGameCubeLanguage(Config::Get(Config::MAIN_GC_LANGUAGE)); // Get rid of invalid values (probably doesn't matter, but might as well do it) if (language > DiscIO::Language::Unknown || language < DiscIO::Language::Japanese) @@ -557,7 +509,7 @@ DiscIO::Language SConfig::GetLanguageAdjustedForRegion(bool wii, DiscIO::Region if (!wii && region == DiscIO::Region::NTSC_J && language == DiscIO::Language::English) return DiscIO::Language::Japanese; // English and Japanese both use the value 0 in GC SRAM - if (!bOverrideRegionSettings) + if (!Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS)) { if (region == DiscIO::Region::NTSC_J) return DiscIO::Language::Japanese; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 69758f6404..06e9a8c7f6 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -69,30 +69,21 @@ struct SConfig bool bAutomaticStart = false; bool bBootToPause = false; - PowerPC::CPUCore cpu_core; - - bool bJITFollowBranch; bool bJITNoBlockCache = false; bool bJITNoBlockLinking = false; bool bFastmem; - bool bFloatExceptions = false; - bool bDivideByZeroExceptions = false; - bool bFPRF = false; - bool bAccurateNaNs = false; bool bDisableICache = false; int iTimingVariance = 40; // in milli secounds bool bCPUThread = true; bool bSyncGPUOnSkipIdleHack = true; - bool bHLE_BS2 = true; bool bCopyWiiSaveNetplay = true; bool bRunCompareServer = false; bool bRunCompareClient = false; bool bMMU = false; - bool bLowDCBZHack = false; int iBBDumpPort = 0; bool bFastDiscSpeed = false; @@ -101,16 +92,9 @@ struct SConfig int iSyncGpuMinDistance; float fSyncGpuOverclock; - int SelectedLanguage = 0; - bool bOverrideRegionSettings = false; - bool bWii = false; bool m_is_mios = false; - // Custom RTC - bool bEnableCustomRTC; - u32 m_customRTCValue; - DiscIO::Region m_region; std::string m_strGPUDeterminismMode; @@ -162,15 +146,9 @@ struct SConfig static IniFile LoadLocalGameIni(const std::string& id, std::optional revision); static IniFile LoadGameIni(const std::string& id, std::optional revision); - std::string m_strGbaCartA; - std::string m_strGbaCartB; ExpansionInterface::TEXIDevices m_EXIDevice[3]; SerialInterface::SIDevices m_SIDevice[4]; - std::string m_bba_mac; - std::string m_bba_xlink_ip; - bool m_bba_xlink_chat_osd = true; - float m_EmulationSpeed; // Input settings diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index c56ba0b4ba..5d8d293017 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -636,7 +636,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi Fifo::Prepare(); // Setup our core, but can't use dynarec if we are compare server - if (core_parameter.cpu_core != PowerPC::CPUCore::Interpreter && + if (Config::Get(Config::MAIN_CPU_CORE) != PowerPC::CPUCore::Interpreter && (!core_parameter.bRunCompareServer || core_parameter.bRunCompareClient)) { PowerPC::SetMode(PowerPC::CoreMode::JIT); diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp index 061aae4260..c0a5f843a4 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp @@ -13,7 +13,7 @@ #include "Common/IOFile.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" namespace ExpansionInterface { @@ -35,8 +35,8 @@ CEXIAgp::~CEXIAgp() std::string filename; std::string ext; std::string gbapath; - SplitPath(m_slot == 0 ? SConfig::GetInstance().m_strGbaCartA : - SConfig::GetInstance().m_strGbaCartB, + SplitPath(m_slot == 0 ? Config::Get(Config::MAIN_AGP_CART_A_PATH) : + Config::Get(Config::MAIN_AGP_CART_B_PATH), &path, &filename, &ext); gbapath = path + filename; @@ -75,8 +75,8 @@ void CEXIAgp::LoadRom() std::string path; std::string filename; std::string ext; - SplitPath(m_slot == 0 ? SConfig::GetInstance().m_strGbaCartA : - SConfig::GetInstance().m_strGbaCartB, + SplitPath(m_slot == 0 ? Config::Get(Config::MAIN_AGP_CART_A_PATH) : + Config::Get(Config::MAIN_AGP_CART_B_PATH), &path, &filename, &ext); const std::string gbapath = path + filename; LoadFileToROM(gbapath + ext); diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp index 491b00cf44..0b20afad6e 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp @@ -13,7 +13,7 @@ #include "Common/Logging/Log.h" #include "Common/Network.h" #include "Common/StringUtil.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/CoreTiming.h" #include "Core/HW/EXI/EXI.h" #include "Core/HW/Memmap.h" @@ -28,7 +28,7 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type) { // Parse MAC address from config, and generate a new one if it doesn't // exist or can't be parsed. - std::string& mac_addr_setting = SConfig::GetInstance().m_bba_mac; + std::string mac_addr_setting = Config::Get(Config::MAIN_BBA_MAC); std::optional mac_addr = Common::StringToMacAddress(mac_addr_setting); std::transform(mac_addr_setting.begin(), mac_addr_setting.end(), mac_addr_setting.begin(), @@ -38,7 +38,8 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type) { mac_addr = Common::GenerateMacAddress(Common::MACConsumer::BBA); mac_addr_setting = Common::MacAddressToString(mac_addr.value()); - SConfig::GetInstance().SaveSettings(); + Config::SetBaseOrCurrent(Config::MAIN_BBA_MAC, mac_addr_setting); + Config::Save(); } switch (type) @@ -70,11 +71,12 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type) // m_client_mdentifier should be unique per connected emulator from the XLink kai client's // perspective so lets use "dolphin" - m_network_interface = std::make_unique( - this, SConfig::GetInstance().m_bba_xlink_ip, 34523, - "dolphin" + SConfig::GetInstance().m_bba_mac, SConfig::GetInstance().m_bba_xlink_chat_osd); + m_network_interface = + std::make_unique(this, Config::Get(Config::MAIN_BBA_XLINK_IP), 34523, + "dolphin" + Config::Get(Config::MAIN_BBA_MAC), + Config::Get(Config::MAIN_BBA_XLINK_CHAT_OSD)); INFO_LOG_FMT(SP1, "Created XLink Kai BBA network interface connection to {}:34523", - SConfig::GetInstance().m_bba_xlink_ip); + Config::Get(Config::MAIN_BBA_XLINK_IP)); break; } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp index 1d6b17bdf4..e55f880869 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp @@ -19,6 +19,7 @@ #include "Common/Swap.h" #include "Common/Timer.h" +#include "Core/Config/MainSettings.h" #include "Core/Config/SessionSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -133,7 +134,7 @@ CEXIIPL::CEXIIPL() // We Overwrite language selection here since it's possible on the GC to change the language as // you please - g_SRAM.settings.language = SConfig::GetInstance().SelectedLanguage; + g_SRAM.settings.language = Config::Get(Config::MAIN_GC_LANGUAGE); g_SRAM.settings.rtc_bias = 0; FixSRAMChecksums(); } diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index 828e1d2c71..b927e65d29 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -46,7 +46,7 @@ void Init() DSP::Init(Config::Get(Config::MAIN_DSP_HLE)); DVDInterface::Init(); GPFifo::Init(); - CPU::Init(SConfig::GetInstance().cpu_core); + CPU::Init(Config::Get(Config::MAIN_CPU_CORE)); SystemTimers::Init(); if (SConfig::GetInstance().bWii) diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index bba3a02316..62f10cdef1 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -52,6 +52,7 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule: #include "Common/Logging/Log.h" #include "Common/Thread.h" #include "Common/Timer.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -304,10 +305,10 @@ void Init() Common::Timer::IncreaseResolution(); // store and convert localtime at boot to timebase ticks - if (SConfig::GetInstance().bEnableCustomRTC) + if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)) { s_localtime_rtc_offset = - Common::Timer::GetLocalTimeSinceJan1970() - SConfig::GetInstance().m_customRTCValue; + Common::Timer::GetLocalTimeSinceJan1970() - Config::Get(Config::MAIN_CUSTOM_RTC_VALUE); } CoreTiming::SetFakeTBStartValue(static_cast(s_cpu_core_clock / TIMER_RATIO) * diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 609dd0e0c2..70d32ffb14 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -535,9 +535,9 @@ bool BeginRecordingInput(const ControllerTypeArray& controllers, s_bNetPlay = true; s_recordingStartTime = ExpansionInterface::CEXIIPL::NetPlay_GetEmulatedTime(); } - else if (SConfig::GetInstance().bEnableCustomRTC) + else if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)) { - s_recordingStartTime = SConfig::GetInstance().m_customRTCValue; + s_recordingStartTime = Config::Get(Config::MAIN_CUSTOM_RTC_VALUE); } else { @@ -904,7 +904,6 @@ void ReadHeader() { s_bSaveConfig = true; Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&tmpHeader)); - SConfig::GetInstance().bJITFollowBranch = tmpHeader.bFollowBranch; s_bClearSave = tmpHeader.bClearSave; s_memcards = tmpHeader.memcards; s_bongos = tmpHeader.bongos; @@ -1348,7 +1347,6 @@ void SaveRecording(const std::string& filename) header.filetype[3] = 0x1A; strncpy(header.gameID.data(), SConfig::GetInstance().GetGameID().c_str(), 6); header.bWii = SConfig::GetInstance().bWii; - header.bFollowBranch = SConfig::GetInstance().bJITFollowBranch; header.controllers = 0; header.GBAControllers = 0; for (int i = 0; i < 4; ++i) diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index e25f881be8..ee1ed43cde 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -2028,10 +2028,8 @@ void NetPlayServer::CheckSyncAndStartGame() u64 NetPlayServer::GetInitialNetPlayRTC() const { - const auto& config = SConfig::GetInstance(); - - if (config.bEnableCustomRTC) - return config.m_customRTCValue; + if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)) + return Config::Get(Config::MAIN_CUSTOM_RTC_VALUE); return Common::Timer::GetLocalTimeSinceJan1970(); } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index 80103648a0..88f9f9997c 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -9,6 +9,7 @@ #include "Common/MsgHandler.h" #include "Common/Swap.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/PowerPC/Interpreter/ExceptionUtils.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" @@ -504,8 +505,11 @@ void Interpreter::dcbz(UGeckoInstruction inst) } // Hack to stop dcbz/dcbi over low MEM1 trashing memory. - if (SConfig::GetInstance().bLowDCBZHack && (dcbz_addr < 0x80008000) && (dcbz_addr >= 0x80000000)) + if ((dcbz_addr < 0x80008000) && (dcbz_addr >= 0x80000000) && + Config::Get(Config::MAIN_LOW_DCBZ_HACK)) + { return; + } // TODO: Implement some sort of L2 emulation. PowerPC::ClearCacheLine(dcbz_addr & (~31)); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index e3730082c8..40999cadcc 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -38,7 +38,7 @@ void Jit64::SetFPRFIfNeeded(const OpArg& input, bool single) // As far as we know, the games that use this flag only need FPRF for fmul and fmadd, but // FPRF is fast enough in JIT that we might as well just enable it for every float instruction // if the FPRF flag is set. - if (!SConfig::GetInstance().bFPRF || !js.op->wantsFPRF) + if (!m_fprf || !js.op->wantsFPRF) return; X64Reg xmm = XMM0; @@ -102,7 +102,7 @@ void Jit64::HandleNaNs(UGeckoInstruction inst, X64Reg xmm_out, X64Reg xmm, X64Re // Dragon Ball: Revenge of King Piccolo requires generated NaNs // to be positive, so we'll have to handle them manually. - if (!SConfig::GetInstance().bAccurateNaNs) + if (!m_accurate_nans) { if (xmm_out != xmm) MOVAPD(xmm_out, R(xmm)); @@ -230,7 +230,7 @@ void Jit64::fp_arith(UGeckoInstruction inst) packed = false; bool round_input = single && !js.op->fprIsSingle[inst.FC]; - bool preserve_inputs = SConfig::GetInstance().bAccurateNaNs; + bool preserve_inputs = m_accurate_nans; const auto fp_tri_op = [&](int op1, int op2, bool reversible, void (XEmitter::*avxOp)(X64Reg, X64Reg, const OpArg&), @@ -475,7 +475,7 @@ void Jit64::fmaddXX(UGeckoInstruction inst) if (negate) XORPD(result_xmm, MConst(packed ? psSignBits2 : psSignBits)); - if (SConfig::GetInstance().bAccurateNaNs && result_xmm == XMM0) + if (m_accurate_nans && result_xmm == XMM0) { // HandleNaNs needs to clobber XMM0 MOVAPD(Rd, R(result_xmm)); @@ -632,7 +632,7 @@ void Jit64::fmrx(UGeckoInstruction inst) void Jit64::FloatCompare(UGeckoInstruction inst, bool upper) { - bool fprf = SConfig::GetInstance().bFPRF && js.op->wantsFPRF; + bool fprf = m_fprf && js.op->wantsFPRF; // bool ordered = !!(inst.SUBOP10 & 32); int a = inst.FA; int b = inst.FB; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index cc042fd236..3bd24baa22 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -413,7 +413,7 @@ void Jit64::dcbz(UGeckoInstruction inst) } FixupBranch end_dcbz_hack; - if (SConfig::GetInstance().bLowDCBZHack) + if (m_low_dcbz_hack) { // HACK: Don't clear any memory in the [0x8000'0000, 0x8000'8000) region. CMP(32, R(RSCRATCH), Imm32(0x8000'8000)); @@ -454,7 +454,7 @@ void Jit64::dcbz(UGeckoInstruction inst) SetJumpTarget(end_far_code); } - if (SConfig::GetInstance().bLowDCBZHack) + if (m_low_dcbz_hack) SetJumpTarget(end_dcbz_hack); } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_FloatingPoint.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_FloatingPoint.cpp index 988550db0e..b4fbd1ca48 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_FloatingPoint.cpp @@ -20,7 +20,7 @@ using namespace Arm64Gen; void JitArm64::SetFPRFIfNeeded(bool single, ARM64Reg reg) { - if (!SConfig::GetInstance().bFPRF || !js.op->wantsFPRF) + if (!m_fprf || !js.op->wantsFPRF) return; gpr.Lock(ARM64Reg::W0, ARM64Reg::W1, ARM64Reg::W2, ARM64Reg::W3, ARM64Reg::W4, ARM64Reg::W30); @@ -374,7 +374,7 @@ void JitArm64::frspx(UGeckoInstruction inst) void JitArm64::FloatCompare(UGeckoInstruction inst, bool upper) { - const bool fprf = SConfig::GetInstance().bFPRF && js.op->wantsFPRF; + const bool fprf = m_fprf && js.op->wantsFPRF; const u32 a = inst.FA; const u32 b = inst.FB; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp index 61baecfdff..99253b18f3 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp @@ -764,7 +764,7 @@ void JitArm64::dcbz(UGeckoInstruction inst) { INSTRUCTION_START JITDISABLE(bJITLoadStoreOff); - FALLBACK_IF(SConfig::GetInstance().bLowDCBZHack); + FALLBACK_IF(m_low_dcbz_hack); int a = inst.RA, b = inst.RB; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp index dc17ad47e4..53d41868a5 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp @@ -49,7 +49,15 @@ void JitBase::RefreshConfig() bJITBranchOff = Config::Get(Config::MAIN_DEBUG_JIT_BRANCH_OFF); bJITRegisterCacheOff = Config::Get(Config::MAIN_DEBUG_JIT_REGISTER_CACHE_OFF); m_enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING); + m_enable_float_exceptions = Config::Get(Config::MAIN_FLOAT_EXCEPTIONS); + m_enable_div_by_zero_exceptions = Config::Get(Config::MAIN_DIVIDE_BY_ZERO_EXCEPTIONS); + m_low_dcbz_hack = Config::Get(Config::MAIN_LOW_DCBZ_HACK); + m_fprf = Config::Get(Config::MAIN_FPRF); + m_accurate_nans = Config::Get(Config::MAIN_ACCURATE_NANS); analyzer.SetDebuggingEnabled(m_enable_debugging); + analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH)); + analyzer.SetFloatExceptionsEnabled(m_enable_float_exceptions); + analyzer.SetDivByZeroExceptionsEnabled(m_enable_div_by_zero_exceptions); } bool JitBase::CanMergeNextInstructions(int count) const @@ -72,8 +80,8 @@ void JitBase::UpdateMemoryAndExceptionOptions() bool any_watchpoints = PowerPC::memchecks.HasAny(); jo.fastmem = SConfig::GetInstance().bFastmem && jo.fastmem_arena && (MSR.DR || !any_watchpoints); jo.memcheck = SConfig::GetInstance().bMMU || any_watchpoints; - jo.fp_exceptions = SConfig::GetInstance().bFloatExceptions; - jo.div_by_zero_exceptions = SConfig::GetInstance().bDivideByZeroExceptions; + jo.fp_exceptions = m_enable_float_exceptions; + jo.div_by_zero_exceptions = m_enable_div_by_zero_exceptions; } bool JitBase::ShouldHandleFPExceptionForInstruction(const PPCAnalyst::CodeOp* op) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index d13728eb28..ccda3fc12d 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -127,6 +127,11 @@ protected: bool bJITBranchOff = false; bool bJITRegisterCacheOff = false; bool m_enable_debugging = false; + bool m_enable_float_exceptions = false; + bool m_enable_div_by_zero_exceptions = false; + bool m_low_dcbz_hack = false; + bool m_fprf = false; + bool m_accurate_nans = false; void RefreshConfig(); diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 9b70f5434e..ca5eb103c8 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -556,10 +556,10 @@ void PPCAnalyzer::SetInstructionStats(CodeBlock* block, CodeOp* code, const Gekk code->outputFPRF = (opinfo->flags & FL_SET_FPRF) != 0; code->canEndBlock = (opinfo->flags & FL_ENDBLOCK) != 0; - code->canCauseException = - first_fpu_instruction || (opinfo->flags & (FL_LOADSTORE | FL_PROGRAMEXCEPTION)) != 0 || - (SConfig::GetInstance().bFloatExceptions && (opinfo->flags & FL_FLOAT_EXCEPTION)) || - (SConfig::GetInstance().bDivideByZeroExceptions && (opinfo->flags & FL_FLOAT_DIV)); + code->canCauseException = first_fpu_instruction || + (opinfo->flags & (FL_LOADSTORE | FL_PROGRAMEXCEPTION)) != 0 || + (m_enable_float_exceptions && (opinfo->flags & FL_FLOAT_EXCEPTION)) || + (m_enable_div_by_zero_exceptions && (opinfo->flags & FL_FLOAT_DIV)); code->wantsCA = (opinfo->flags & FL_READ_CA) != 0; code->outputCA = (opinfo->flags & FL_SET_CA) != 0; @@ -761,7 +761,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, u32 numFollows = 0; u32 num_inst = 0; - const bool enable_follow = SConfig::GetInstance().bJITFollowBranch; + const bool enable_follow = m_enable_branch_following; for (std::size_t i = 0; i < block_size; ++i) { diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.h b/Source/Core/Core/PowerPC/PPCAnalyst.h index da8cfb99c8..4ae41ccbae 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/PowerPC/PPCAnalyst.h @@ -216,6 +216,9 @@ public: void ClearOption(AnalystOption option) { m_options &= ~(option); } bool HasOption(AnalystOption option) const { return !!(m_options & option); } void SetDebuggingEnabled(bool enabled) { m_is_debugging_enabled = enabled; } + void SetBranchFollowingEnabled(bool enabled) { m_enable_branch_following = enabled; } + void SetFloatExceptionsEnabled(bool enabled) { m_enable_float_exceptions = enabled; } + void SetDivByZeroExceptionsEnabled(bool enabled) { m_enable_div_by_zero_exceptions = enabled; } u32 Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std::size_t block_size) const; private: @@ -238,6 +241,9 @@ private: u32 m_options = 0; bool m_is_debugging_enabled = false; + bool m_enable_branch_following = false; + bool m_enable_float_exceptions = false; + bool m_enable_div_by_zero_exceptions = false; }; void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db); diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.cpp b/Source/Core/DolphinQt/Debugger/JITWidget.cpp index e9c7c9fc0e..fdf426acfc 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/JITWidget.cpp @@ -157,6 +157,9 @@ void JITWidget::Update() PPCAnalyst::CodeBlock code_block; PPCAnalyst::PPCAnalyzer analyzer; analyzer.SetDebuggingEnabled(Config::Get(Config::MAIN_ENABLE_DEBUGGING)); + analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH)); + analyzer.SetFloatExceptionsEnabled(Config::Get(Config::MAIN_FLOAT_EXCEPTIONS)); + analyzer.SetDivByZeroExceptionsEnabled(Config::Get(Config::MAIN_DIVIDE_BY_ZERO_EXCEPTIONS)); analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE); analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_FOLLOW); diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index ea0c235601..c2d64f52f0 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -802,7 +802,7 @@ void MenuBar::AddJITMenu() m_jit_interpreter_core = m_jit->addAction(tr("Interpreter Core")); m_jit_interpreter_core->setCheckable(true); - m_jit_interpreter_core->setChecked(SConfig::GetInstance().cpu_core == + m_jit_interpreter_core->setChecked(Config::Get(Config::MAIN_CPU_CORE) == PowerPC::CPUCore::Interpreter); connect(m_jit_interpreter_core, &QAction::toggled, [](bool enabled) { diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index 78b1fcc3d7..28f6a75030 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -174,7 +174,6 @@ void AdvancedPane::ConnectLayout() { connect(m_cpu_emulation_engine_combobox, static_cast(&QComboBox::currentIndexChanged), [](int index) { - SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[index]; Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]); }); @@ -212,17 +211,18 @@ void AdvancedPane::ConnectLayout() Update(); }); - m_custom_rtc_checkbox->setChecked(SConfig::GetInstance().bEnableCustomRTC); + m_custom_rtc_checkbox->setChecked(Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)); connect(m_custom_rtc_checkbox, &QCheckBox::toggled, [this](bool enable_custom_rtc) { - SConfig::GetInstance().bEnableCustomRTC = enable_custom_rtc; + Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_ENABLE, enable_custom_rtc); Update(); }); QDateTime initial_date_time; - initial_date_time.setSecsSinceEpoch(SConfig::GetInstance().m_customRTCValue); + initial_date_time.setSecsSinceEpoch(Config::Get(Config::MAIN_CUSTOM_RTC_VALUE)); m_custom_rtc_datetime->setDateTime(initial_date_time); connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) { - SConfig::GetInstance().m_customRTCValue = static_cast(date_time.toSecsSinceEpoch()); + Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE, + static_cast(date_time.toSecsSinceEpoch())); Update(); }); } @@ -232,12 +232,13 @@ void AdvancedPane::Update() const bool running = Core::GetState() != Core::State::Uninitialized; const bool enable_cpu_clock_override_widgets = Config::Get(Config::MAIN_OVERCLOCK_ENABLE); const bool enable_ram_override_widgets = Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE); - const bool enable_custom_rtc_widgets = SConfig::GetInstance().bEnableCustomRTC && !running; + const bool enable_custom_rtc_widgets = Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE) && !running; const std::vector& available_cpu_cores = PowerPC::AvailableCPUCores(); + const auto cpu_core = Config::Get(Config::MAIN_CPU_CORE); for (size_t i = 0; i < available_cpu_cores.size(); ++i) { - if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core) + if (available_cpu_cores[i] == cpu_core) m_cpu_emulation_engine_combobox->setCurrentIndex(int(i)); } m_cpu_emulation_engine_combobox->setEnabled(!running); diff --git a/Source/Core/DolphinQt/Settings/BroadbandAdapterSettingsDialog.cpp b/Source/Core/DolphinQt/Settings/BroadbandAdapterSettingsDialog.cpp index c458acac74..0c3af49df1 100644 --- a/Source/Core/DolphinQt/Settings/BroadbandAdapterSettingsDialog.cpp +++ b/Source/Core/DolphinQt/Settings/BroadbandAdapterSettingsDialog.cpp @@ -13,7 +13,7 @@ #include #include "Common/StringUtil.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" BroadbandAdapterSettingsDialog::BroadbandAdapterSettingsDialog(QWidget* parent, Type bba_type) @@ -38,7 +38,7 @@ void BroadbandAdapterSettingsDialog::InitControls() // interface (physical) like a serial number. "MAC" should be kept in translations. address_label = new QLabel(tr("Enter new Broadband Adapter MAC address:")); address_placeholder = QString::fromStdString("aa:bb:cc:dd:ee:ff"); - current_address = QString::fromStdString(SConfig::GetInstance().m_bba_mac); + current_address = QString::fromStdString(Config::Get(Config::MAIN_BBA_MAC)); description = new QLabel(tr("For setup instructions, refer to this page.")); @@ -51,7 +51,7 @@ void BroadbandAdapterSettingsDialog::InitControls() case Type::XLinkKai: address_label = new QLabel(tr("Enter IP address of device running the XLink Kai Client:")); address_placeholder = QString::fromStdString("127.0.0.1"); - current_address = QString::fromStdString(SConfig::GetInstance().m_bba_xlink_ip); + current_address = QString::fromStdString(Config::Get(Config::MAIN_BBA_XLINK_IP)); description = new QLabel(tr("For setup instructions, refer to this page.")); @@ -100,11 +100,11 @@ void BroadbandAdapterSettingsDialog::SaveAddress() tr("The entered MAC address is invalid.")); return; } - SConfig::GetInstance().m_bba_mac = bba_new_address; + Config::SetBaseOrCurrent(Config::MAIN_BBA_MAC, bba_new_address); break; case Type::XLinkKai: - SConfig::GetInstance().m_bba_xlink_ip = bba_new_address; + Config::SetBaseOrCurrent(Config::MAIN_BBA_XLINK_IP, bba_new_address); break; } diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp index 8ec5126f2f..054802e72b 100644 --- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp +++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp @@ -349,9 +349,10 @@ void GameCubePane::OnConfigPressed(int slot) } else { - path_old = QFileInfo(QString::fromStdString(slot == 0 ? SConfig::GetInstance().m_strGbaCartA : - SConfig::GetInstance().m_strGbaCartB)) - .absoluteFilePath(); + path_old = + QFileInfo(QString::fromStdString(slot == 0 ? Config::Get(Config::MAIN_AGP_CART_A_PATH) : + Config::Get(Config::MAIN_AGP_CART_B_PATH))) + .absoluteFilePath(); } if (memcard) @@ -369,11 +370,11 @@ void GameCubePane::OnConfigPressed(int slot) { if (slot == SLOT_A_INDEX) { - SConfig::GetInstance().m_strGbaCartA = path_abs.toStdString(); + Config::SetBase(Config::MAIN_AGP_CART_A_PATH, path_abs.toStdString()); } else { - SConfig::GetInstance().m_strGbaCartB = path_abs.toStdString(); + Config::SetBase(Config::MAIN_AGP_CART_B_PATH, path_abs.toStdString()); } } @@ -432,11 +433,10 @@ void GameCubePane::BrowseGBASaves() void GameCubePane::LoadSettings() { - const SConfig& params = SConfig::GetInstance(); - // IPL Settings - m_skip_main_menu->setChecked(params.bHLE_BS2); - m_language_combo->setCurrentIndex(m_language_combo->findData(params.SelectedLanguage)); + m_skip_main_menu->setChecked(Config::Get(Config::MAIN_SKIP_IPL)); + m_language_combo->setCurrentIndex( + m_language_combo->findData(Config::Get(Config::MAIN_GC_LANGUAGE))); bool have_menu = false; @@ -478,12 +478,8 @@ void GameCubePane::SaveSettings() { Config::ConfigChangeCallbackGuard config_guard; - SConfig& params = SConfig::GetInstance(); - // IPL Settings - params.bHLE_BS2 = m_skip_main_menu->isChecked(); Config::SetBaseOrCurrent(Config::MAIN_SKIP_IPL, m_skip_main_menu->isChecked()); - params.SelectedLanguage = m_language_combo->currentData().toInt(); Config::SetBaseOrCurrent(Config::MAIN_GC_LANGUAGE, m_language_combo->currentData().toInt()); // Device Settings diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.cpp b/Source/Core/DolphinQt/Settings/GeneralPane.cpp index b94bc63fcd..d25efbf0ae 100644 --- a/Source/Core/DolphinQt/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt/Settings/GeneralPane.cpp @@ -254,7 +254,8 @@ void GeneralPane::LoadConfig() #endif m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled()); - m_checkbox_override_region_settings->setChecked(SConfig::GetInstance().bOverrideRegionSettings); + m_checkbox_override_region_settings->setChecked( + Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS)); m_checkbox_auto_disc_change->setChecked(Config::Get(Config::MAIN_AUTO_DISC_CHANGE)); #ifdef USE_DISCORD_PRESENCE m_checkbox_discord_presence->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE)); @@ -348,7 +349,6 @@ void GeneralPane::OnSaveConfig() settings.bCPUThread = m_checkbox_dualcore->isChecked(); Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked()); Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked()); - settings.bOverrideRegionSettings = m_checkbox_override_region_settings->isChecked(); Config::SetBaseOrCurrent(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_checkbox_override_region_settings->isChecked()); Config::SetBase(Config::MAIN_AUTO_DISC_CHANGE, m_checkbox_auto_disc_change->isChecked()); From 0bfffe409589c016e35c1728f3be6cad768deca4 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Wed, 5 Jan 2022 03:25:19 +0100 Subject: [PATCH 2/2] Config: Port GC Adapter settings to new config system. --- Source/Core/Core/Config/MainSettings.cpp | 20 ++++++++++++---- Source/Core/Core/Config/MainSettings.h | 4 ++-- .../Core/ConfigLoaders/IsSettingSaveable.cpp | 10 +++++++- Source/Core/Core/ConfigManager.cpp | 4 ---- Source/Core/Core/ConfigManager.h | 4 ---- Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp | 3 ++- .../Config/Mapping/GCPadWiiUConfigDialog.cpp | 9 +++---- Source/Core/InputCommon/GCAdapter.cpp | 24 ++++++++++++++++++- 8 files changed, 57 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index ae7d3ce652..1bafe2b837 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -69,14 +69,26 @@ Info GetInfoForSIDevice(u32 channel) SerialInterface::SIDEVICE_NONE)}; } -Info GetInfoForAdapterRumble(u32 channel) +const Info& GetInfoForAdapterRumble(int channel) { - return {{System::Main, "Core", fmt::format("AdapterRumble{}", channel)}, true}; + static const std::array, 4> infos{ + Info{{System::Main, "Core", "AdapterRumble0"}, true}, + Info{{System::Main, "Core", "AdapterRumble1"}, true}, + Info{{System::Main, "Core", "AdapterRumble2"}, true}, + Info{{System::Main, "Core", "AdapterRumble3"}, true}, + }; + return infos[channel]; } -Info GetInfoForSimulateKonga(u32 channel) +const Info& GetInfoForSimulateKonga(int channel) { - return {{System::Main, "Core", fmt::format("SimulateKonga{}", channel)}, false}; + static const std::array, 4> infos{ + Info{{System::Main, "Core", "SimulateKonga0"}, false}, + Info{{System::Main, "Core", "SimulateKonga1"}, false}, + Info{{System::Main, "Core", "SimulateKonga2"}, false}, + Info{{System::Main, "Core", "SimulateKonga3"}, false}, + }; + return infos[channel]; } const Info MAIN_WII_SD_CARD{{System::Main, "Core", "WiiSDCard"}, true}; diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 1424433647..28beff16d2 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -66,8 +66,8 @@ extern const Info MAIN_BBA_MAC; extern const Info MAIN_BBA_XLINK_IP; extern const Info MAIN_BBA_XLINK_CHAT_OSD; Info GetInfoForSIDevice(u32 channel); -Info GetInfoForAdapterRumble(u32 channel); -Info GetInfoForSimulateKonga(u32 channel); +const Info& GetInfoForAdapterRumble(int channel); +const Info& GetInfoForSimulateKonga(int channel); extern const Info MAIN_WII_SD_CARD; extern const Info MAIN_WII_KEYBOARD; extern const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index a33d0448c4..a41ef76b09 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -48,7 +48,7 @@ bool IsSettingSaveable(const Config::Location& config_location) } } - static constexpr auto s_setting_saveable = { + static const auto s_setting_saveable = { // Main.Core &Config::MAIN_DEFAULT_ISO.GetLocation(), @@ -89,6 +89,14 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::MAIN_LOW_DCBZ_HACK.GetLocation(), &Config::MAIN_FPRF.GetLocation(), &Config::MAIN_ACCURATE_NANS.GetLocation(), + &Config::GetInfoForAdapterRumble(0).GetLocation(), + &Config::GetInfoForAdapterRumble(1).GetLocation(), + &Config::GetInfoForAdapterRumble(2).GetLocation(), + &Config::GetInfoForAdapterRumble(3).GetLocation(), + &Config::GetInfoForSimulateKonga(0).GetLocation(), + &Config::GetInfoForSimulateKonga(1).GetLocation(), + &Config::GetInfoForSimulateKonga(2).GetLocation(), + &Config::GetInfoForSimulateKonga(3).GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 3bb3abb8b9..2f936c006b 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -113,8 +113,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i) { core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]); - core->Set(fmt::format("AdapterRumble{}", i), m_AdapterRumble[i]); - core->Set(fmt::format("SimulateKonga{}", i), m_AdapterKonga[i]); } core->Set("WiiSDCard", m_WiiSDCard); core->Set("WiiKeyboard", m_WiiKeyboard); @@ -155,8 +153,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) { core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i], (i == 0) ? SerialInterface::SIDEVICE_GC_CONTROLLER : SerialInterface::SIDEVICE_NONE); - core->Get(fmt::format("AdapterRumble{}", i), &m_AdapterRumble[i], true); - core->Get(fmt::format("SimulateKonga{}", i), &m_AdapterKonga[i], false); } core->Get("WiiSDCard", &m_WiiSDCard, true); core->Get("WiiKeyboard", &m_WiiKeyboard, false); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 06e9a8c7f6..1f334076d7 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -151,10 +151,6 @@ struct SConfig float m_EmulationSpeed; - // Input settings - bool m_AdapterRumble[4]; - bool m_AdapterKonga[4]; - SConfig(const SConfig&) = delete; SConfig& operator=(const SConfig&) = delete; SConfig(SConfig&&) = delete; diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp index a3f24824fb..4ce82787bd 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp @@ -7,6 +7,7 @@ #include "Common/CommonTypes.h" #include "Common/Swap.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/GCPad.h" @@ -24,7 +25,7 @@ CSIDevice_GCAdapter::CSIDevice_GCAdapter(SIDevices device, int device_number) // get the correct pad number that should rumble locally when using netplay const int pad_num = NetPlay_InGamePadToLocalPad(m_device_number); if (pad_num < 4) - m_simulate_konga = SConfig::GetInstance().m_AdapterKonga[pad_num]; + m_simulate_konga = Config::Get(Config::GetInfoForSimulateKonga(pad_num)); } GCPadStatus CSIDevice_GCAdapter::GetPadStatus() diff --git a/Source/Core/DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.cpp b/Source/Core/DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.cpp index 2f25ea450a..af9231abd1 100644 --- a/Source/Core/DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.cpp @@ -8,6 +8,7 @@ #include #include +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "DolphinQt/QtUtils/QueueOnObject.h" @@ -86,12 +87,12 @@ void GCPadWiiUConfigDialog::UpdateAdapterStatus() void GCPadWiiUConfigDialog::LoadSettings() { - m_rumble->setChecked(SConfig::GetInstance().m_AdapterRumble[m_port]); - m_simulate_bongos->setChecked(SConfig::GetInstance().m_AdapterKonga[m_port]); + m_rumble->setChecked(Config::Get(Config::GetInfoForAdapterRumble(m_port))); + m_simulate_bongos->setChecked(Config::Get(Config::GetInfoForSimulateKonga(m_port))); } void GCPadWiiUConfigDialog::SaveSettings() { - SConfig::GetInstance().m_AdapterRumble[m_port] = m_rumble->isChecked(); - SConfig::GetInstance().m_AdapterKonga[m_port] = m_simulate_bongos->isChecked(); + Config::SetBaseOrCurrent(Config::GetInfoForAdapterRumble(m_port), m_rumble->isChecked()); + Config::SetBaseOrCurrent(Config::GetInfoForSimulateKonga(m_port), m_simulate_bongos->isChecked()); } diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index bf8ec87b3b..26984ca4dc 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -2,14 +2,17 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include +#include #include "Common/Event.h" #include "Common/Flag.h" #include "Common/Logging/Log.h" #include "Common/ScopeGuard.h" #include "Common/Thread.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -79,6 +82,9 @@ static u8 s_endpoint_out = 0; static u64 s_last_init = 0; +static std::optional s_config_callback_id = std::nullopt; +static std::array s_config_rumble_enabled{}; + static void Read() { int payload_size = 0; @@ -196,6 +202,12 @@ void SetAdapterCallback(std::function func) s_detect_callback = func; } +static void RefreshConfig() +{ + for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i) + s_config_rumble_enabled[i] = Config::Get(Config::GetInfoForAdapterRumble(i)); +} + void Init() { if (s_handle != nullptr) @@ -211,6 +223,10 @@ void Init() s_status = NO_ADAPTER_DETECTED; + if (!s_config_callback_id) + s_config_callback_id = Config::AddConfigChangedCallback(RefreshConfig); + RefreshConfig(); + if (UseAdapter()) StartScanThread(); } @@ -382,6 +398,12 @@ void Shutdown() Reset(); s_status = NO_ADAPTER_DETECTED; + + if (s_config_callback_id) + { + Config::RemoveConfigChangedCallback(*s_config_callback_id); + s_config_callback_id = std::nullopt; + } } static void Reset() @@ -557,7 +579,7 @@ static void ResetRumbleLockNeeded() void Output(int chan, u8 rumble_command) { - if (s_handle == nullptr || !UseAdapter() || !SConfig::GetInstance().m_AdapterRumble[chan]) + if (s_handle == nullptr || !UseAdapter() || !s_config_rumble_enabled[chan]) return; // Skip over rumble commands if it has not changed or the controller is wireless