diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index 6888d9520b..f6bebb60cc 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -35,11 +35,15 @@ Mixer::Mixer(unsigned int BackendSampleRate) m_surround_decoder(BackendSampleRate, DPL2QualityToFrameBlockSize(Config::Get(Config::MAIN_DPL2_QUALITY))) { + m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); + INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized"); } Mixer::~Mixer() { + Config::RemoveConfigChangedCallback(m_config_changed_callback_id); } void Mixer::DoState(PointerWrap& p) @@ -53,7 +57,8 @@ void Mixer::DoState(PointerWrap& p) // Executed from sound stream thread unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples, - bool consider_framelimit) + bool consider_framelimit, float emulationspeed, + int timing_variance) { unsigned int currentSample = 0; @@ -71,13 +76,12 @@ unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples, // advance indexR with sample position // remember fractional offset - float emulationspeed = SConfig::GetInstance().m_EmulationSpeed; float aid_sample_rate = static_cast(m_input_sample_rate); if (consider_framelimit && emulationspeed > 0.0f) { float numLeft = static_cast(((indexW - indexR) & INDEX_MASK) / 2); - u32 low_waterwark = m_input_sample_rate * SConfig::GetInstance().iTimingVariance / 1000; + u32 low_waterwark = m_input_sample_rate * timing_variance / 1000; low_waterwark = std::min(low_waterwark, MAX_SAMPLES / 2); m_numLeftI = (numLeft + m_numLeftI * (CONTROL_AVG - 1)) / CONTROL_AVG; @@ -154,18 +158,26 @@ unsigned int Mixer::Mix(short* samples, unsigned int num_samples) memset(samples, 0, num_samples * 2 * sizeof(short)); - if (Config::Get(Config::MAIN_AUDIO_STRETCH)) + const float emulation_speed = m_config_emulation_speed; + const int timing_variance = m_config_timing_variance; + if (m_config_audio_stretch) { unsigned int available_samples = std::min(m_dma_mixer.AvailableSamples(), m_streaming_mixer.AvailableSamples()); m_scratch_buffer.fill(0); - m_dma_mixer.Mix(m_scratch_buffer.data(), available_samples, false); - m_streaming_mixer.Mix(m_scratch_buffer.data(), available_samples, false); - m_wiimote_speaker_mixer.Mix(m_scratch_buffer.data(), available_samples, false); + m_dma_mixer.Mix(m_scratch_buffer.data(), available_samples, false, emulation_speed, + timing_variance); + m_streaming_mixer.Mix(m_scratch_buffer.data(), available_samples, false, emulation_speed, + timing_variance); + m_wiimote_speaker_mixer.Mix(m_scratch_buffer.data(), available_samples, false, emulation_speed, + timing_variance); for (auto& mixer : m_gba_mixers) - mixer.Mix(m_scratch_buffer.data(), available_samples, false); + { + mixer.Mix(m_scratch_buffer.data(), available_samples, false, emulation_speed, + timing_variance); + } if (!m_is_stretching) { @@ -177,11 +189,11 @@ unsigned int Mixer::Mix(short* samples, unsigned int num_samples) } else { - m_dma_mixer.Mix(samples, num_samples, true); - m_streaming_mixer.Mix(samples, num_samples, true); - m_wiimote_speaker_mixer.Mix(samples, num_samples, true); + m_dma_mixer.Mix(samples, num_samples, true, emulation_speed, timing_variance); + m_streaming_mixer.Mix(samples, num_samples, true, emulation_speed, timing_variance); + m_wiimote_speaker_mixer.Mix(samples, num_samples, true, emulation_speed, timing_variance); for (auto& mixer : m_gba_mixers) - mixer.Mix(samples, num_samples, true); + mixer.Mix(samples, num_samples, true, emulation_speed, timing_variance); m_is_stretching = false; } @@ -385,6 +397,13 @@ void Mixer::StopLogDSPAudio() } } +void Mixer::RefreshConfig() +{ + m_config_emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED); + m_config_timing_variance = Config::Get(Config::MAIN_TIMING_VARIANCE); + m_config_audio_stretch = Config::Get(Config::MAIN_AUDIO_STRETCH); +} + void Mixer::MixerFifo::DoState(PointerWrap& p) { p.Do(m_input_sample_rate); diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index b47f7b204c..0cf25810fb 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -69,7 +69,8 @@ private: } void DoState(PointerWrap& p); void PushSamples(const short* samples, unsigned int num_samples); - unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true); + unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit, + float emulationspeed, int timing_variance); void SetInputSampleRate(unsigned int rate); unsigned int GetInputSampleRate() const; void SetVolume(unsigned int lvolume, unsigned int rvolume); @@ -89,6 +90,8 @@ private: u32 m_frac = 0; }; + void RefreshConfig(); + MixerFifo m_dma_mixer{this, 32000, false}; MixerFifo m_streaming_mixer{this, 48000, false}; MixerFifo m_wiimote_speaker_mixer{this, 3000, true}; @@ -109,4 +112,10 @@ private: // Current rate of emulation (1.0 = 100% speed) std::atomic m_speed{0.0f}; + + float m_config_emulation_speed; + int m_config_timing_variance; + bool m_config_audio_stretch; + + size_t m_config_changed_callback_id; }; diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index acc46a7f16..5f72002545 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -64,7 +64,6 @@ public: // These store if the relevant setting should be reset back later (true) or if it should be left // alone on restore (false) - bool bSetEmulationSpeed = false; bool bSetVolume = false; std::array bSetWiimoteSource{}; std::array bSetPads{}; @@ -73,16 +72,11 @@ public: private: bool valid = false; bool bCPUThread = false; - bool bSyncGPUOnSkipIdleHack = false; bool bMMU = false; - bool bDisableICache = false; bool bSyncGPU = false; int iSyncGpuMaxDistance = 0; int iSyncGpuMinDistance = 0; float fSyncGpuOverclock = 0; - bool bFastDiscSpeed = false; - float m_EmulationSpeed = 0; - std::string m_strGPUDeterminismMode; std::array iWiimoteSource{}; std::array Pads{}; std::array m_EXIDevice{}; @@ -93,16 +87,11 @@ void ConfigCache::SaveConfig(const SConfig& config) valid = true; bCPUThread = config.bCPUThread; - bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; - bDisableICache = config.bDisableICache; bMMU = config.bMMU; bSyncGPU = config.bSyncGPU; iSyncGpuMaxDistance = config.iSyncGpuMaxDistance; iSyncGpuMinDistance = config.iSyncGpuMinDistance; fSyncGpuOverclock = config.fSyncGpuOverclock; - bFastDiscSpeed = config.bFastDiscSpeed; - m_EmulationSpeed = config.m_EmulationSpeed; - m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; for (int i = 0; i != MAX_BBMOTES; ++i) iWiimoteSource[i] = WiimoteCommon::GetSource(i); @@ -110,7 +99,6 @@ void ConfigCache::SaveConfig(const SConfig& config) std::copy(std::begin(config.m_SIDevice), std::end(config.m_SIDevice), std::begin(Pads)); std::copy(std::begin(config.m_EXIDevice), std::end(config.m_EXIDevice), std::begin(m_EXIDevice)); - bSetEmulationSpeed = false; bSetVolume = false; bSetWiimoteSource.fill(false); bSetPads.fill(false); @@ -125,14 +113,11 @@ void ConfigCache::RestoreConfig(SConfig* config) valid = false; config->bCPUThread = bCPUThread; - config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack; - config->bDisableICache = bDisableICache; config->bMMU = bMMU; config->bSyncGPU = bSyncGPU; config->iSyncGpuMaxDistance = iSyncGpuMaxDistance; config->iSyncGpuMinDistance = iSyncGpuMinDistance; config->fSyncGpuOverclock = fSyncGpuOverclock; - config->bFastDiscSpeed = bFastDiscSpeed; // Only change these back if they were actually set by game ini, since they can be changed while a // game is running. @@ -151,38 +136,15 @@ void ConfigCache::RestoreConfig(SConfig* config) config->m_SIDevice[i] = Pads[i]; } - if (bSetEmulationSpeed) - config->m_EmulationSpeed = m_EmulationSpeed; - for (unsigned int i = 0; i < ExpansionInterface::MAX_EXI_CHANNELS; ++i) { if (bSetEXIDevice[i]) config->m_EXIDevice[i] = m_EXIDevice[i]; } - - config->m_strGPUDeterminismMode = m_strGPUDeterminismMode; } static ConfigCache config_cache; -void SetEmulationSpeedReset(bool value) -{ - config_cache.bSetEmulationSpeed = value; -} - -static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode) -{ - if (mode == "auto") - return GPUDeterminismMode::Auto; - if (mode == "none") - return GPUDeterminismMode::Disabled; - if (mode == "fake-completion") - return GPUDeterminismMode::FakeCompletion; - - NOTICE_LOG_FMT(BOOT, "Unknown GPU determinism mode {}", mode); - return GPUDeterminismMode::Auto; -} - // Boot the ISO or file bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) { @@ -206,17 +168,8 @@ 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("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack, - StartUp.bSyncGPUOnSkipIdleHack); - core_section->Get("DisableICache", &StartUp.bDisableICache, StartUp.bDisableICache); core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU); core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU); - core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed); - if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed)) - config_cache.bSetEmulationSpeed = true; - - core_section->Get("GPUDeterminismMode", &StartUp.m_strGPUDeterminismMode, - StartUp.m_strGPUDeterminismMode); for (unsigned int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i) { @@ -256,14 +209,11 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) } } - StartUp.m_GPUDeterminismMode = ParseGPUDeterminismMode(StartUp.m_strGPUDeterminismMode); - // Movie settings if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { // TODO: remove this once ConfigManager starts using OnionConfig. StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD); - StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED); StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU); for (int i = 0; i < 2; ++i) { @@ -293,17 +243,11 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) config_cache.bSetEXIDevice[0] = true; config_cache.bSetEXIDevice[1] = true; config_cache.bSetEXIDevice[2] = true; - StartUp.bDisableICache = netplay_settings.m_DisableICache; - StartUp.bSyncGPUOnSkipIdleHack = netplay_settings.m_SyncOnSkipIdle; 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.bFastDiscSpeed = netplay_settings.m_FastDiscSpeed; StartUp.bMMU = netplay_settings.m_MMU; - StartUp.bFastmem = netplay_settings.m_Fastmem; - if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting) - config_cache.bSetEmulationSpeed = true; } else { @@ -355,7 +299,7 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) // Disable loading time emulation for Riivolution-patched games until we have proper emulation. if (!boot->riivolution_patches.empty()) - StartUp.bFastDiscSpeed = true; + Config::SetCurrent(Config::MAIN_FAST_DISC_SPEED, true); Core::UpdateWantDeterminism(/*initial*/ true); diff --git a/Source/Core/Core/BootManager.h b/Source/Core/Core/BootManager.h index cdc790322e..10474c5f3f 100644 --- a/Source/Core/Core/BootManager.h +++ b/Source/Core/Core/BootManager.h @@ -11,7 +11,6 @@ struct WindowSystemInfo; namespace BootManager { bool BootCore(std::unique_ptr parameters, const WindowSystemInfo& wsi); -void SetEmulationSpeedReset(bool value); // Synchronise Dolphin's configuration with the SYSCONF (which may have changed during emulation), // and restore settings that were overriden by per-game INIs or for some other reason. diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 4e17de9868..7f8c132c58 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -10,6 +10,7 @@ #include "AudioCommon/AudioCommon.h" #include "Common/CommonPaths.h" #include "Common/Config/Config.h" +#include "Common/Logging/Log.h" #include "Common/MathUtil.h" #include "Common/StringUtil.h" #include "Common/Version.h" @@ -96,6 +97,8 @@ const Info MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false} const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING{ {System::Main, "Core", "WiimoteContinuousScanning"}, false}; const Info MAIN_WIIMOTE_ENABLE_SPEAKER{{System::Main, "Core", "WiimoteEnableSpeaker"}, false}; +const Info MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE{ + {System::Main, "Core", "WiimoteControllerInterface"}, false}; const Info MAIN_MMU{{System::Main, "Core", "MMU"}, false}; const Info MAIN_BB_DUMP_PORT{{System::Main, "Core", "BBDumpPort"}, -1}; const Info MAIN_SYNC_GPU{{System::Main, "Core", "SyncGPU"}, false}; @@ -118,8 +121,24 @@ const Info MAIN_MEM1_SIZE{{System::Main, "Core", "MEM1Size"}, Memory::MEM1_ const Info MAIN_MEM2_SIZE{{System::Main, "Core", "MEM2Size"}, Memory::MEM2_SIZE_RETAIL}; const Info MAIN_GFX_BACKEND{{System::Main, "Core", "GFXBackend"}, VideoBackendBase::GetDefaultBackendName()}; + const Info MAIN_GPU_DETERMINISM_MODE{{System::Main, "Core", "GPUDeterminismMode"}, "auto"}; + +GPUDeterminismMode GetGPUDeterminismMode() +{ + auto mode = Config::Get(Config::MAIN_GPU_DETERMINISM_MODE); + if (mode == "auto") + return GPUDeterminismMode::Auto; + if (mode == "none") + return GPUDeterminismMode::Disabled; + if (mode == "fake-completion") + return GPUDeterminismMode::FakeCompletion; + + NOTICE_LOG_FMT(CORE, "Unknown GPU determinism mode {}", mode); + return GPUDeterminismMode::Auto; +} + const Info MAIN_PERF_MAP_DIR{{System::Main, "Core", "PerfMapDir"}, ""}; const Info MAIN_CUSTOM_RTC_ENABLE{{System::Main, "Core", "EnableCustomRTC"}, false}; // Default to seconds between 1.1.1970 and 1.1.2000 diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 910b7e8ee0..0e5b0fdbe9 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -72,6 +72,7 @@ extern const Info MAIN_WII_SD_CARD; extern const Info MAIN_WII_KEYBOARD; extern const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING; extern const Info MAIN_WIIMOTE_ENABLE_SPEAKER; +extern const Info MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE; extern const Info MAIN_MMU; extern const Info MAIN_BB_DUMP_PORT; extern const Info MAIN_SYNC_GPU; @@ -93,7 +94,18 @@ extern const Info MAIN_MEM1_SIZE; extern const Info MAIN_MEM2_SIZE; // Should really be part of System::GFX, but again, we're stuck with past mistakes. extern const Info MAIN_GFX_BACKEND; + +enum class GPUDeterminismMode +{ + Auto, + Disabled, + // This is currently the only mode. There will probably be at least + // one more at some point. + FakeCompletion, +}; extern const Info MAIN_GPU_DETERMINISM_MODE; +GPUDeterminismMode GetGPUDeterminismMode(); + extern const Info MAIN_PERF_MAP_DIR; extern const Info MAIN_CUSTOM_RTC_ENABLE; extern const Info MAIN_CUSTOM_RTC_VALUE; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index a41ef76b09..9859fb977d 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -97,6 +97,19 @@ bool IsSettingSaveable(const Config::Location& config_location) &Config::GetInfoForSimulateKonga(1).GetLocation(), &Config::GetInfoForSimulateKonga(2).GetLocation(), &Config::GetInfoForSimulateKonga(3).GetLocation(), + &Config::MAIN_EMULATION_SPEED.GetLocation(), + &Config::MAIN_PERF_MAP_DIR.GetLocation(), + &Config::MAIN_GPU_DETERMINISM_MODE.GetLocation(), + &Config::MAIN_DISABLE_ICACHE.GetLocation(), + &Config::MAIN_FAST_DISC_SPEED.GetLocation(), + &Config::MAIN_SYNC_ON_SKIP_IDLE.GetLocation(), + &Config::MAIN_FASTMEM.GetLocation(), + &Config::MAIN_TIMING_VARIANCE.GetLocation(), + &Config::MAIN_WII_SD_CARD.GetLocation(), + &Config::MAIN_WII_KEYBOARD.GetLocation(), + &Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING.GetLocation(), + &Config::MAIN_WIIMOTE_ENABLE_SPEAKER.GetLocation(), + &Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE.GetLocation(), // UI.General diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index c4b9cb079c..cdd691f259 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -99,10 +99,7 @@ void SConfig::SaveCoreSettings(IniFile& ini) { IniFile::Section* core = ini.GetOrCreateSection("Core"); - core->Set("TimingVariance", iTimingVariance); - core->Set("Fastmem", bFastmem); core->Set("CPUThread", bCPUThread); - core->Set("SyncOnSkipIdle", bSyncGPUOnSkipIdleHack); core->Set("SyncGPU", bSyncGPU); core->Set("SyncGpuMaxDistance", iSyncGpuMaxDistance); core->Set("SyncGpuMinDistance", iSyncGpuMinDistance); @@ -114,15 +111,7 @@ void SConfig::SaveCoreSettings(IniFile& ini) { core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]); } - core->Set("WiiSDCard", m_WiiSDCard); - core->Set("WiiKeyboard", m_WiiKeyboard); - core->Set("WiimoteContinuousScanning", m_WiimoteContinuousScanning); - core->Set("WiimoteEnableSpeaker", m_WiimoteEnableSpeaker); - core->Set("WiimoteControllerInterface", connect_wiimotes_for_ciface); core->Set("MMU", bMMU); - core->Set("EmulationSpeed", m_EmulationSpeed); - core->Set("GPUDeterminismMode", m_strGPUDeterminismMode); - core->Set("PerfMapDir", m_perfDir); } void SConfig::LoadSettings() @@ -140,10 +129,7 @@ void SConfig::LoadCoreSettings(IniFile& ini) { IniFile::Section* core = ini.GetOrCreateSection("Core"); - core->Get("Fastmem", &bFastmem, true); - core->Get("TimingVariance", &iTimingVariance, 40); core->Get("CPUThread", &bCPUThread, true); - core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true); 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); @@ -152,22 +138,12 @@ 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("WiiSDCard", &m_WiiSDCard, true); - core->Get("WiiKeyboard", &m_WiiKeyboard, false); - core->Get("WiimoteContinuousScanning", &m_WiimoteContinuousScanning, false); - core->Get("WiimoteEnableSpeaker", &m_WiimoteEnableSpeaker, false); - core->Get("WiimoteControllerInterface", &connect_wiimotes_for_ciface, false); core->Get("MMU", &bMMU, bMMU); core->Get("BBDumpPort", &iBBDumpPort, -1); core->Get("SyncGPU", &bSyncGPU, false); core->Get("SyncGpuMaxDistance", &iSyncGpuMaxDistance, 200000); core->Get("SyncGpuMinDistance", &iSyncGpuMinDistance, -200000); core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f); - core->Get("FastDiscSpeed", &bFastDiscSpeed, false); - core->Get("DisableICache", &bDisableICache, false); - core->Get("EmulationSpeed", &m_EmulationSpeed, 1.0f); - core->Get("GPUDeterminismMode", &m_strGPUDeterminismMode, "auto"); - core->Get("PerfMapDir", &m_perfDir, ""); } void SConfig::ResetRunningGameMetadata() @@ -283,15 +259,10 @@ void SConfig::LoadDefaults() bAutomaticStart = false; bBootToPause = false; - iTimingVariance = 40; bCPUThread = false; - bSyncGPUOnSkipIdleHack = true; - bFastmem = true; - bDisableICache = false; bMMU = false; iBBDumpPort = -1; bSyncGPU = false; - bFastDiscSpeed = false; bWii = false; ResetRunningGameMetadata(); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 46804f3172..51dfc2b85e 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -47,24 +47,8 @@ enum SIDevices : int; struct BootParameters; -enum class GPUDeterminismMode -{ - Auto, - Disabled, - // This is currently the only mode. There will probably be at least - // one more at some point. - FakeCompletion, -}; - struct SConfig { - // Wii Devices - bool m_WiiSDCard; - bool m_WiiKeyboard; - bool m_WiimoteContinuousScanning; - bool m_WiimoteEnableSpeaker; - bool connect_wiimotes_for_ciface; - // Settings bool bAutomaticStart = false; bool bBootToPause = false; @@ -72,17 +56,11 @@ struct SConfig bool bJITNoBlockCache = false; bool bJITNoBlockLinking = false; - bool bFastmem; - bool bDisableICache = false; - - int iTimingVariance = 40; // in milli secounds bool bCPUThread = true; - bool bSyncGPUOnSkipIdleHack = true; bool bCopyWiiSaveNetplay = true; bool bMMU = false; int iBBDumpPort = 0; - bool bFastDiscSpeed = false; bool bSyncGPU = false; int iSyncGpuMaxDistance; @@ -94,17 +72,10 @@ struct SConfig DiscIO::Region m_region; - std::string m_strGPUDeterminismMode; - - // set based on the string version - GPUDeterminismMode m_GPUDeterminismMode; - // files std::string m_strBootROM; std::string m_strSRAM; - std::string m_perfDir; - std::string m_debugger_game_id; // TODO: remove this as soon as the ticket view hack in IOS/ES/Views is dropped. bool m_disc_booted_from_game_list = false; @@ -146,8 +117,6 @@ struct SConfig ExpansionInterface::TEXIDevices m_EXIDevice[3]; SerialInterface::SIDevices m_SIDevice[4]; - float m_EmulationSpeed; - SConfig(const SConfig&) = delete; SConfig& operator=(const SConfig&) = delete; SConfig(SConfig&&) = delete; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index a5ae7784b6..df575b431f 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -348,7 +348,8 @@ static void CpuThread(const std::optional& savestate_path, bool del static_cast(IDCache::GetEnvForThread()); #endif - if (_CoreParameter.bFastmem) + const bool fastmem_enabled = Config::Get(Config::MAIN_FASTMEM); + if (fastmem_enabled) EMM::InstallExceptionHandler(); // Let's run under memory watch #ifdef USE_MEMORYWATCHER @@ -396,7 +397,7 @@ static void CpuThread(const std::optional& savestate_path, bool del s_is_started = false; - if (_CoreParameter.bFastmem) + if (fastmem_enabled) EMM::UninstallExceptionHandler(); if (GDBStub::IsActive()) diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index f850c726d6..e90d367c5e 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -17,7 +17,6 @@ #include "Common/SPSCQueue.h" #include "Core/Config/MainSettings.h" -#include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/PowerPC/PowerPC.h" @@ -81,6 +80,7 @@ static EventType* s_ev_lost = nullptr; static size_t s_registered_config_callback_id; static float s_config_OC_factor; static float s_config_OC_inv_factor; +static bool s_config_sync_on_skip_idle; static void EmptyTimedCallback(u64 userdata, s64 cyclesLate) { @@ -161,6 +161,7 @@ void RefreshConfig() s_config_OC_factor = Config::Get(Config::MAIN_OVERCLOCK_ENABLE) ? Config::Get(Config::MAIN_OVERCLOCK) : 1.0f; s_config_OC_inv_factor = 1.0f / s_config_OC_factor; + s_config_sync_on_skip_idle = Config::Get(Config::MAIN_SYNC_ON_SKIP_IDLE); } void DoState(PointerWrap& p) @@ -388,7 +389,7 @@ void AdjustEventQueueTimes(u32 new_ppc_clock, u32 old_ppc_clock) void Idle() { - if (SConfig::GetInstance().bSyncGPUOnSkipIdleHack) + if (s_config_sync_on_skip_idle) { // When the FIFO is processing data we must not advance because in this way // the VI will be desynchronized. So, We are waiting until the FIFO finish and diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index 6ef1109cb4..93ed3888dd 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -360,7 +360,7 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("cfg-dsp-jit", Config::Get(Config::MAIN_DSP_JIT)); builder.AddData("cfg-dsp-thread", Config::Get(Config::MAIN_DSP_THREAD)); builder.AddData("cfg-cpu-thread", SConfig::GetInstance().bCPUThread); - builder.AddData("cfg-fastmem", SConfig::GetInstance().bFastmem); + builder.AddData("cfg-fastmem", Config::Get(Config::MAIN_FASTMEM)); builder.AddData("cfg-syncgpu", SConfig::GetInstance().bSyncGPU); builder.AddData("cfg-audio-backend", Config::Get(Config::MAIN_AUDIO_BACKEND)); builder.AddData("cfg-oc-enable", Config::Get(Config::MAIN_OVERCLOCK_ENABLE)); diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index 0cbc27e205..338a3b009c 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -19,7 +19,6 @@ #include "Common/Logging/Log.h" #include "Core/Config/MainSettings.h" -#include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/DolphinAnalytics.h" #include "Core/HW/AudioInterface.h" @@ -1382,7 +1381,7 @@ static void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& parti dvd_offset = Common::AlignDown(dvd_offset, DVD_ECC_BLOCK_SIZE); const u64 first_block = dvd_offset; - if (SConfig::GetInstance().bFastDiscSpeed) + if (Config::Get(Config::MAIN_FAST_DISC_SPEED)) { // The SUDTR setting makes us act as if all reads are buffered buffer_start = std::numeric_limits::min(); diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 62f10cdef1..5f063a093e 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -173,8 +173,8 @@ void ThrottleCallback(u64 last_time, s64 cyclesLate) u64 time = Common::Timer::GetTimeUs(); s64 diff = last_time - time; - const SConfig& config = SConfig::GetInstance(); - bool frame_limiter = config.m_EmulationSpeed > 0.0f && !Core::GetIsThrottlerTempDisabled(); + const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED); + bool frame_limiter = emulation_speed > 0.0f && !Core::GetIsThrottlerTempDisabled(); u32 next_event = GetTicksPerSecond() / 1000; { @@ -186,9 +186,9 @@ void ThrottleCallback(u64 last_time, s64 cyclesLate) if (frame_limiter) { - if (config.m_EmulationSpeed != 1.0f) - next_event = u32(next_event * config.m_EmulationSpeed); - const s64 max_fallback = config.iTimingVariance * 1000; + if (emulation_speed != 1.0f) + next_event = u32(next_event * emulation_speed); + const s64 max_fallback = Config::Get(Config::MAIN_TIMING_VARIANCE) * 1000; if (std::abs(diff) > max_fallback) { DEBUG_LOG_FMT(COMMON, "system too {}, {} ms skipped", diff < 0 ? "slow" : "fast", diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index 62aad0bc62..e09c991419 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -73,7 +73,7 @@ void stopdamnwav() void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan) { // TODO: should we still process samples for the decoder state? - if (!SConfig::GetInstance().m_WiimoteEnableSpeaker) + if (!m_speaker_enabled) return; if (reg_data.sample_rate == 0 || length == 0) @@ -186,6 +186,11 @@ void SpeakerLogic::DoState(PointerWrap& p) p.Do(reg_data); } +void SpeakerLogic::SetSpeakerEnabled(bool enabled) +{ + m_speaker_enabled = enabled; +} + int SpeakerLogic::BusRead(u8 slave_addr, u8 addr, int count, u8* data_out) { if (I2C_ADDR != slave_addr) diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.h b/Source/Core/Core/HW/WiimoteEmu/Speaker.h index d2004df459..9a6a652bb1 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.h +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.h @@ -29,6 +29,8 @@ public: void Reset(); void DoState(PointerWrap& p); + void SetSpeakerEnabled(bool enabled); + private: // Pan is -1.0 to +1.0 void SpeakerData(const u8* data, int length, float speaker_pan); @@ -71,6 +73,8 @@ private: ADPCMState adpcm_state{}; ControllerEmu::SettingValue m_speaker_pan_setting; + + bool m_speaker_enabled = false; }; } // namespace WiimoteEmu diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 4ccf02fc17..b266464021 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -17,8 +17,7 @@ #include "Common/MathUtil.h" #include "Common/MsgHandler.h" -#include "Core/Config/SYSCONFSettings.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/HW/Wiimote.h" #include "Core/Movie.h" @@ -297,6 +296,14 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index) m_hotkeys->AddInput(_trans("Upright Hold"), false); Reset(); + + m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); +} + +Wiimote::~Wiimote() +{ + Config::RemoveConfigChangedCallback(m_config_changed_callback_id); } std::string Wiimote::GetName() const @@ -726,6 +733,11 @@ void Wiimote::SetRumble(bool on) m_rumble->controls.front()->control_ref->State(on); } +void Wiimote::RefreshConfig() +{ + m_speaker_logic.SetSpeakerEnabled(Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER)); +} + void Wiimote::StepDynamics() { EmulateSwing(&m_swing_state, m_swing, 1.f / ::Wiimote::UPDATE_FREQ); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h index 8107111099..31448c6e3c 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h @@ -109,6 +109,7 @@ public: static constexpr u16 BUTTON_HOME = 0x8000; explicit Wiimote(unsigned int index); + ~Wiimote(); std::string GetName() const override; void LoadDefaults(const ControllerInterface& ciface) override; @@ -144,6 +145,8 @@ private: // This is the region exposed over bluetooth: static constexpr int EEPROM_FREE_SIZE = 0x1700; + void RefreshConfig(); + void StepDynamics(); void UpdateButtonsStatus(); @@ -297,5 +300,7 @@ private: PositionalState m_shake_state; IMUCursorState m_imu_cursor_state; + + size_t m_config_changed_callback_id; }; } // namespace WiimoteEmu diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 06ae8e790a..1c57dff7ef 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -111,7 +111,7 @@ void ProcessWiimotePool() for (u32 index = 0; index != MAX_WIIMOTES; ++index) TryToFillWiimoteSlot(index); - if (SConfig::GetInstance().connect_wiimotes_for_ciface) + if (Config::Get(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE)) { for (auto& entry : s_wiimote_pool) ciface::WiimoteController::AddDevice(std::move(entry.wiimote)); @@ -142,7 +142,16 @@ void AddWiimoteToPool(std::unique_ptr wiimote) s_wiimote_pool.emplace_back(WiimotePoolEntry{std::move(wiimote)}); } -Wiimote::Wiimote() = default; +Wiimote::Wiimote() +{ + m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); +} + +Wiimote::~Wiimote() +{ + Config::RemoveConfigChangedCallback(m_config_changed_callback_id); +} void Wiimote::Shutdown() { @@ -263,7 +272,7 @@ void Wiimote::InterruptDataOutput(const u8* data, const u32 size) } } else if (rpt[1] == u8(OutputReportID::SpeakerData) && - (!SConfig::GetInstance().m_WiimoteEnableSpeaker || !m_speaker_enable || m_speaker_mute)) + (!m_speaker_enabled_in_dolphin_config || !m_speaker_enable || m_speaker_mute)) { rpt.resize(3); // Translate undesired speaker data reports into rumble reports. @@ -677,7 +686,7 @@ void WiimoteScanner::ThreadFunc() continue; // If we don't want Wiimotes in ControllerInterface, we may not need them at all. - if (!SConfig::GetInstance().connect_wiimotes_for_ciface) + if (!Config::Get(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE)) { // We don't want any remotes in passthrough mode or running in GC mode. const bool core_running = Core::GetState() != Core::State::Uninitialized; @@ -804,6 +813,11 @@ void Wiimote::ThreadFunc() DisconnectInternal(); } +void Wiimote::RefreshConfig() +{ + m_speaker_enabled_in_dolphin_config = Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER); +} + int Wiimote::GetIndex() const { return m_index; @@ -843,7 +857,7 @@ void Initialize(::Wiimote::InitializeMode init_mode) s_wiimote_scanner.StartThread(); } - if (SConfig::GetInstance().m_WiimoteContinuousScanning) + if (Config::Get(Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING)) s_wiimote_scanner.SetScanMode(WiimoteScanMode::CONTINUOUSLY_SCAN); else s_wiimote_scanner.SetScanMode(WiimoteScanMode::DO_NOT_SCAN); @@ -957,7 +971,7 @@ static void HandleWiimoteDisconnect(int index) // This is called from the GUI thread void Refresh() { - if (!SConfig::GetInstance().m_WiimoteContinuousScanning) + if (!Config::Get(Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING)) s_wiimote_scanner.SetScanMode(WiimoteScanMode::SCAN_ONCE); } diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h index 18b927962c..34573a0609 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h @@ -51,7 +51,7 @@ public: Wiimote(Wiimote&&) = delete; Wiimote& operator=(Wiimote&&) = delete; - virtual ~Wiimote() {} + ~Wiimote() override; // This needs to be called in derived destructors! void Shutdown(); @@ -125,6 +125,8 @@ private: void ThreadFunc(); + void RefreshConfig(); + bool m_is_linked = false; // We track the speaker state to convert unnecessary speaker data into rumble reports. @@ -144,6 +146,10 @@ private: Common::SPSCQueue m_read_reports; Common::SPSCQueue m_write_reports; + + bool m_speaker_enabled_in_dolphin_config = false; + + size_t m_config_changed_callback_id; }; class WiimoteScannerBackend @@ -209,5 +215,4 @@ void InitAdapterClass(); void HandleWiimotesInControllerInterfaceSettingChange(); void PopulateDevices(); void ProcessWiimotePool(); - } // namespace WiimoteReal diff --git a/Source/Core/Core/IOS/DolphinDevice.cpp b/Source/Core/Core/IOS/DolphinDevice.cpp index 699cacfd42..3c533f9ab0 100644 --- a/Source/Core/Core/IOS/DolphinDevice.cpp +++ b/Source/Core/Core/IOS/DolphinDevice.cpp @@ -14,9 +14,7 @@ #include "Common/SettingsHandler.h" #include "Common/Timer.h" #include "Common/Version.h" -#include "Core/BootManager.h" #include "Core/Config/MainSettings.h" -#include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" @@ -103,8 +101,7 @@ IPCReply GetSpeedLimit(const IOCtlVRequest& request) return IPCReply(IPC_EINVAL); } - const SConfig& config = SConfig::GetInstance(); - const u32 speed_percent = config.m_EmulationSpeed * 100; + const u32 speed_percent = Config::Get(Config::MAIN_EMULATION_SPEED) * 100; Memory::Write_U32(speed_percent, request.io_vectors[0].address); return IPCReply(IPC_SUCCESS); @@ -124,8 +121,7 @@ IPCReply SetSpeedLimit(const IOCtlVRequest& request) } const float speed = float(Memory::Read_U32(request.in_vectors[0].address)) / 100.0f; - SConfig::GetInstance().m_EmulationSpeed = speed; - BootManager::SetEmulationSpeedReset(true); + Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed); return IPCReply(IPC_SUCCESS); } diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index 3355996ff9..c6dcab44e5 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -16,7 +16,6 @@ #include "Common/SDCardUtil.h" #include "Core/Config/MainSettings.h" #include "Core/Config/SessionSettings.h" -#include "Core/ConfigManager.h" #include "Core/HW/Memmap.h" #include "Core/IOS/IOS.h" #include "Core/IOS/VersionInfo.h" @@ -49,10 +48,10 @@ void SDIOSlot0Device::EventNotify() { if (!m_event) return; - // Accessing SConfig variables like this isn't really threadsafe, - // but this is how it's done all over the place... - if ((SConfig::GetInstance().m_WiiSDCard && m_event->type == EVENT_INSERT) || - (!SConfig::GetInstance().m_WiiSDCard && m_event->type == EVENT_REMOVE)) + + const bool sd_card_inserted = Config::Get(Config::MAIN_WII_SD_CARD); + if ((sd_card_inserted && m_event->type == EVENT_INSERT) || + (!sd_card_inserted && m_event->type == EVENT_REMOVE)) { m_ios.EnqueueIPCReply(m_event->request, m_event->type); m_event.reset(); @@ -440,8 +439,8 @@ IPCReply SDIOSlot0Device::GetStatus(const IOCtlRequest& request) // Evaluate whether a card is currently inserted (config value). // Make sure we don't modify m_status so we don't lose track of whether the card is SDHC. - const u32 status = - SConfig::GetInstance().m_WiiSDCard ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST; + const bool sd_card_inserted = Config::Get(Config::MAIN_WII_SD_CARD); + const u32 status = sd_card_inserted ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST; INFO_LOG_FMT(IOS_SD, "IOCTL_GETSTATUS. Replying that {} card is {}{}", (status & CARD_SDHC) ? "SDHC" : "SD", diff --git a/Source/Core/Core/IOS/USB/USB_KBD.cpp b/Source/Core/Core/IOS/USB/USB_KBD.cpp index c6cd20a24a..5f18f50dfb 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.cpp +++ b/Source/Core/Core/IOS/USB/USB_KBD.cpp @@ -10,7 +10,7 @@ #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" // Local core functions #include "Core/HW/Memmap.h" #include "InputCommon/ControlReference/ControlReference.h" // For background input check @@ -210,7 +210,7 @@ std::optional USB_KBD::Write(const ReadWriteRequest& request) std::optional USB_KBD::IOCtl(const IOCtlRequest& request) { - if (SConfig::GetInstance().m_WiiKeyboard && !Core::WantsDeterminism() && + if (Config::Get(Config::MAIN_WII_KEYBOARD) && !Core::WantsDeterminism() && ControlReference::GetInputGate() && !m_message_queue.empty()) { Memory::CopyToEmu(request.buffer_out, &m_message_queue.front(), sizeof(MessageData)); @@ -231,7 +231,7 @@ bool USB_KBD::IsKeyPressed(int key) const void USB_KBD::Update() { - if (!SConfig::GetInstance().m_WiiKeyboard || Core::WantsDeterminism() || !m_is_active) + if (!Config::Get(Config::MAIN_WII_KEYBOARD) || Core::WantsDeterminism() || !m_is_active) return; u8 modifiers = 0x00; diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 6dad22e5ba..4e40ec7f3b 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -2033,13 +2033,13 @@ bool NetPlayClient::GetNetPads(const int pad_nb, const bool batching, GCPadStatu if (time_diff.count() >= 1.0 || !buffer_over_target) { // run fast if the buffer is overfilled, otherwise run normal speed - SConfig::GetInstance().m_EmulationSpeed = buffer_over_target ? 0.0f : 1.0f; + Config::SetCurrent(Config::MAIN_EMULATION_SPEED, buffer_over_target ? 0.0f : 1.0f); } } else { // Set normal speed when we're the host, otherwise it can get stuck at unlimited - SConfig::GetInstance().m_EmulationSpeed = 1.0f; + Config::SetCurrent(Config::MAIN_EMULATION_SPEED, 1.0f); } } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 84e2970d27..fc77921ece 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -332,7 +332,7 @@ void Jit64::Init() { EnableBlockLink(); - jo.fastmem_arena = SConfig::GetInstance().bFastmem && Memory::InitFastmemArena(); + jo.fastmem_arena = m_fastmem_enabled && Memory::InitFastmemArena(); jo.optimizeGatherPipe = true; jo.accurateSinglePrecision = true; UpdateMemoryAndExceptionOptions(); @@ -355,8 +355,7 @@ void Jit64::Init() // BLR optimization has the same consequences as block linking, as well as // depending on the fault handler to be safe in the event of excessive BL. - m_enable_blr_optimization = - jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging; + m_enable_blr_optimization = jo.enableBlocklink && m_fastmem_enabled && !m_enable_debugging; m_cleanup_after_stackfault = false; m_stack = nullptr; diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index da44109464..c701f160c6 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -52,7 +52,7 @@ void JitArm64::Init() AllocCodeSpace(CODE_SIZE + child_code_size); AddChildCodeSpace(&m_far_code, child_code_size); - jo.fastmem_arena = SConfig::GetInstance().bFastmem && Memory::InitFastmemArena(); + jo.fastmem_arena = m_fastmem_enabled && Memory::InitFastmemArena(); jo.enableBlocklink = true; jo.optimizeGatherPipe = true; UpdateMemoryAndExceptionOptions(); @@ -67,8 +67,7 @@ void JitArm64::Init() analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE); analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_FOLLOW); - m_enable_blr_optimization = - jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging; + m_enable_blr_optimization = jo.enableBlocklink && m_fastmem_enabled && !m_enable_debugging; m_cleanup_after_stackfault = false; AllocStack(); diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp index 53d41868a5..5dfe40cfd4 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.cpp @@ -54,6 +54,7 @@ void JitBase::RefreshConfig() 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); + m_fastmem_enabled = Config::Get(Config::MAIN_FASTMEM); analyzer.SetDebuggingEnabled(m_enable_debugging); analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH)); analyzer.SetFloatExceptionsEnabled(m_enable_float_exceptions); @@ -78,7 +79,7 @@ bool JitBase::CanMergeNextInstructions(int count) const void JitBase::UpdateMemoryAndExceptionOptions() { bool any_watchpoints = PowerPC::memchecks.HasAny(); - jo.fastmem = SConfig::GetInstance().bFastmem && jo.fastmem_arena && (MSR.DR || !any_watchpoints); + jo.fastmem = m_fastmem_enabled && jo.fastmem_arena && (MSR.DR || !any_watchpoints); jo.memcheck = SConfig::GetInstance().bMMU || any_watchpoints; jo.fp_exceptions = m_enable_float_exceptions; jo.div_by_zero_exceptions = m_enable_div_by_zero_exceptions; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index ccda3fc12d..d9e7ae8e94 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -132,6 +132,7 @@ protected: bool m_low_dcbz_hack = false; bool m_fprf = false; bool m_accurate_nans = false; + bool m_fastmem_enabled = false; void RefreshConfig(); diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index b25e3fba90..de55900846 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -13,7 +13,7 @@ #include "Common/CommonTypes.h" #include "Common/JitRegister.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/MMU.h" @@ -40,7 +40,7 @@ JitBaseBlockCache::~JitBaseBlockCache() = default; void JitBaseBlockCache::Init() { - JitRegister::Init(SConfig::GetInstance().m_perfDir); + JitRegister::Init(Config::Get(Config::MAIN_PERF_MAP_DIR)); Clear(); } diff --git a/Source/Core/Core/PowerPC/PPCCache.cpp b/Source/Core/Core/PowerPC/PPCCache.cpp index 181764dc3b..9207ea5f72 100644 --- a/Source/Core/Core/PowerPC/PPCCache.cpp +++ b/Source/Core/Core/PowerPC/PPCCache.cpp @@ -7,7 +7,7 @@ #include "Common/ChunkFile.h" #include "Common/Swap.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/DolphinAnalytics.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/JitInterface.h" @@ -87,6 +87,12 @@ constexpr std::array s_way_from_plru = [] { }(); } // Anonymous namespace +InstructionCache::~InstructionCache() +{ + if (m_config_callback_id) + Config::RemoveConfigChangedCallback(*m_config_callback_id); +} + void InstructionCache::Reset() { valid.fill(0); @@ -99,6 +105,10 @@ void InstructionCache::Reset() void InstructionCache::Init() { + if (!m_config_callback_id) + m_config_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); + RefreshConfig(); + data.fill({}); tags.fill({}); Reset(); @@ -106,7 +116,7 @@ void InstructionCache::Init() void InstructionCache::Invalidate(u32 addr) { - if (!HID0.ICE || SConfig::GetInstance().bDisableICache) + if (!HID0.ICE || m_disable_icache) return; // Invalidates the whole set @@ -129,7 +139,7 @@ void InstructionCache::Invalidate(u32 addr) u32 InstructionCache::ReadInstruction(u32 addr) { - if (!HID0.ICE || SConfig::GetInstance().bDisableICache) // instruction cache is disabled + if (!HID0.ICE || m_disable_icache) // instruction cache is disabled return Memory::Read_U32(addr); u32 set = (addr >> 5) & 0x7f; u32 tag = addr >> 12; @@ -202,4 +212,9 @@ void InstructionCache::DoState(PointerWrap& p) p.DoArray(lookup_table_ex); p.DoArray(lookup_table_vmem); } + +void InstructionCache::RefreshConfig() +{ + m_disable_icache = Config::Get(Config::MAIN_DISABLE_ICACHE); +} } // namespace PowerPC diff --git a/Source/Core/Core/PowerPC/PPCCache.h b/Source/Core/Core/PowerPC/PPCCache.h index fdc23ba546..431bc10c41 100644 --- a/Source/Core/Core/PowerPC/PPCCache.h +++ b/Source/Core/Core/PowerPC/PPCCache.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" @@ -30,11 +31,16 @@ struct InstructionCache std::array lookup_table_ex{}; std::array lookup_table_vmem{}; + bool m_disable_icache = false; + std::optional m_config_callback_id = std::nullopt; + InstructionCache() = default; + ~InstructionCache(); u32 ReadInstruction(u32 addr); void Invalidate(u32 addr); void Init(); void Reset(); void DoState(PointerWrap& p); + void RefreshConfig(); }; } // namespace PowerPC diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index 70a65f5752..e5616da4bf 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -305,9 +305,9 @@ void WiimoteControllersWidget::LoadSettings() } m_wiimote_real_balance_board->setChecked(WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) == WiimoteSource::Real); - m_wiimote_speaker_data->setChecked(SConfig::GetInstance().m_WiimoteEnableSpeaker); - m_wiimote_ciface->setChecked(SConfig::GetInstance().connect_wiimotes_for_ciface); - m_wiimote_continuous_scanning->setChecked(SConfig::GetInstance().m_WiimoteContinuousScanning); + m_wiimote_speaker_data->setChecked(Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER)); + m_wiimote_ciface->setChecked(Config::Get(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE)); + m_wiimote_continuous_scanning->setChecked(Config::Get(Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING)); if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) m_wiimote_passthrough->setChecked(true); @@ -319,9 +319,12 @@ void WiimoteControllersWidget::LoadSettings() void WiimoteControllersWidget::SaveSettings() { - SConfig::GetInstance().m_WiimoteEnableSpeaker = m_wiimote_speaker_data->isChecked(); - SConfig::GetInstance().connect_wiimotes_for_ciface = m_wiimote_ciface->isChecked(); - SConfig::GetInstance().m_WiimoteContinuousScanning = m_wiimote_continuous_scanning->isChecked(); + Config::SetBaseOrCurrent(Config::MAIN_WIIMOTE_ENABLE_SPEAKER, + m_wiimote_speaker_data->isChecked()); + Config::SetBaseOrCurrent(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE, + m_wiimote_ciface->isChecked()); + Config::SetBaseOrCurrent(Config::MAIN_WIIMOTE_CONTINUOUS_SCANNING, + m_wiimote_continuous_scanning->isChecked()); Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED, m_wiimote_passthrough->isChecked()); diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index 4fa3031e63..c3d2aadcb7 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -459,26 +459,26 @@ void HotkeyScheduler::Run() Core::SetIsThrottlerTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true)); auto ShowEmulationSpeed = []() { + const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED); OSD::AddMessage( - SConfig::GetInstance().m_EmulationSpeed <= 0 ? + emulation_speed <= 0 ? "Speed Limit: Unlimited" : - StringFromFormat("Speed Limit: %li%%", - std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f))); + StringFromFormat("Speed Limit: %li%%", std::lround(emulation_speed * 100.f))); }; if (IsHotkey(HK_DECREASE_EMULATION_SPEED)) { - auto speed = SConfig::GetInstance().m_EmulationSpeed - 0.1; + auto speed = Config::Get(Config::MAIN_EMULATION_SPEED) - 0.1; speed = (speed <= 0 || (speed >= 0.95 && speed <= 1.05)) ? 1.0 : speed; - SConfig::GetInstance().m_EmulationSpeed = speed; + Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed); ShowEmulationSpeed(); } if (IsHotkey(HK_INCREASE_EMULATION_SPEED)) { - auto speed = SConfig::GetInstance().m_EmulationSpeed + 0.1; + auto speed = Config::Get(Config::MAIN_EMULATION_SPEED) + 0.1; speed = (speed >= 0.95 && speed <= 1.05) ? 1.0 : speed; - SConfig::GetInstance().m_EmulationSpeed = speed; + Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed); ShowEmulationSpeed(); } diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index c2d64f52f0..0c08dd3390 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -829,9 +829,9 @@ void MenuBar::AddJITMenu() m_jit_disable_fastmem = m_jit->addAction(tr("Disable Fastmem")); m_jit_disable_fastmem->setCheckable(true); - m_jit_disable_fastmem->setChecked(!SConfig::GetInstance().bFastmem); + m_jit_disable_fastmem->setChecked(!Config::Get(Config::MAIN_FASTMEM)); connect(m_jit_disable_fastmem, &QAction::toggled, [this](bool enabled) { - SConfig::GetInstance().bFastmem = !enabled; + Config::SetBaseOrCurrent(Config::MAIN_FASTMEM, !enabled); ClearCache(); }); diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index 44bcd581b1..d22dcc6e25 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -696,14 +696,14 @@ void Settings::SetBatchModeEnabled(bool batch) bool Settings::IsSDCardInserted() const { - return SConfig::GetInstance().m_WiiSDCard; + return Config::Get(Config::MAIN_WII_SD_CARD); } void Settings::SetSDCardInserted(bool inserted) { if (IsSDCardInserted() != inserted) { - SConfig::GetInstance().m_WiiSDCard = inserted; + Config::SetBaseOrCurrent(Config::MAIN_WII_SD_CARD, inserted); emit SDCardInsertionChanged(inserted); auto* ios = IOS::HLE::GetIOS(); @@ -714,14 +714,14 @@ void Settings::SetSDCardInserted(bool inserted) bool Settings::IsUSBKeyboardConnected() const { - return SConfig::GetInstance().m_WiiKeyboard; + return Config::Get(Config::MAIN_WII_KEYBOARD); } void Settings::SetUSBKeyboardConnected(bool connected) { if (IsUSBKeyboardConnected() != connected) { - SConfig::GetInstance().m_WiiKeyboard = connected; + Config::SetBaseOrCurrent(Config::MAIN_WII_KEYBOARD, connected); emit USBKeyboardConnectionChanged(connected); } } diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.cpp b/Source/Core/DolphinQt/Settings/GeneralPane.cpp index d25efbf0ae..05ea785484 100644 --- a/Source/Core/DolphinQt/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt/Settings/GeneralPane.cpp @@ -260,7 +260,7 @@ void GeneralPane::LoadConfig() #ifdef USE_DISCORD_PRESENCE m_checkbox_discord_presence->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE)); #endif - int selection = qRound(SConfig::GetInstance().m_EmulationSpeed * 10); + int selection = qRound(Config::Get(Config::MAIN_EMULATION_SPEED) * 10); if (selection < m_combobox_speedlimit->count()) m_combobox_speedlimit->setCurrentIndex(selection); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); @@ -353,7 +353,8 @@ void GeneralPane::OnSaveConfig() m_checkbox_override_region_settings->isChecked()); Config::SetBase(Config::MAIN_AUTO_DISC_CHANGE, m_checkbox_auto_disc_change->isChecked()); Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked()); - settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f; + Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, + m_combobox_speedlimit->currentIndex() * 0.1f); Settings::Instance().SetFallbackRegion( UpdateFallbackRegionFromIndex(m_combobox_fallback_region->currentIndex())); diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index f96c71b550..33dd94817d 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -14,6 +14,7 @@ #include "Common/MemoryUtil.h" #include "Common/MsgHandler.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" #include "Core/HW/Memmap.h" @@ -509,15 +510,15 @@ void UpdateWantDeterminism(bool want) // it should be safe to change this. const SConfig& param = SConfig::GetInstance(); bool gpu_thread = false; - switch (param.m_GPUDeterminismMode) + switch (Config::GetGPUDeterminismMode()) { - case GPUDeterminismMode::Auto: + case Config::GPUDeterminismMode::Auto: gpu_thread = want; break; - case GPUDeterminismMode::Disabled: + case Config::GPUDeterminismMode::Disabled: gpu_thread = false; break; - case GPUDeterminismMode::FakeCompletion: + case Config::GPUDeterminismMode::FakeCompletion: gpu_thread = true; break; } diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index a835625691..c8f79b0e66 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -9,7 +9,7 @@ #include "Common/CommonTypes.h" #include "Common/StringUtil.h" #include "Core/Config/GraphicsSettings.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/Movie.h" #include "VideoCommon/DriverDetails.h" @@ -24,7 +24,7 @@ static bool IsVSyncActive(bool enabled) { // Vsync is disabled when the throttler is disabled by the tab key. return enabled && !Core::GetIsThrottlerTempDisabled() && - SConfig::GetInstance().m_EmulationSpeed == 1.0; + Config::Get(Config::MAIN_EMULATION_SPEED) == 1.0; } void UpdateActiveConfig()