29 changes: 0 additions & 29 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -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);
Expand All @@ -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()
Expand All @@ -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);
Expand All @@ -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()
Expand Down Expand Up @@ -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();
Expand Down
31 changes: 0 additions & 31 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -47,42 +47,20 @@ 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;

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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/Core.cpp
Expand Up @@ -348,7 +348,8 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
static_cast<void>(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
Expand Down Expand Up @@ -396,7 +397,7 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del

s_is_started = false;

if (_CoreParameter.bFastmem)
if (fastmem_enabled)
EMM::UninstallExceptionHandler();

if (GDBStub::IsActive())
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/CoreTiming.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/DolphinAnalytics.cpp
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/HW/DVD/DVDInterface.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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<u64>::min();
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/HW/SystemTimers.cpp
Expand Up @@ -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;

{
Expand All @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Core/HW/WiimoteEmu/Speaker.h
Expand Up @@ -29,6 +29,8 @@ class SpeakerLogic : public I2CSlave
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);
Expand Down Expand Up @@ -71,6 +73,8 @@ class SpeakerLogic : public I2CSlave
ADPCMState adpcm_state{};

ControllerEmu::SettingValue<double> m_speaker_pan_setting;

bool m_speaker_enabled = false;
};

} // namespace WiimoteEmu
16 changes: 14 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
Expand Up @@ -109,6 +109,7 @@ class Wiimote : public ControllerEmu::EmulatedController, public WiimoteCommon::
static constexpr u16 BUTTON_HOME = 0x8000;

explicit Wiimote(unsigned int index);
~Wiimote();

std::string GetName() const override;
void LoadDefaults(const ControllerInterface& ciface) override;
Expand Down Expand Up @@ -144,6 +145,8 @@ class Wiimote : public ControllerEmu::EmulatedController, public WiimoteCommon::
// This is the region exposed over bluetooth:
static constexpr int EEPROM_FREE_SIZE = 0x1700;

void RefreshConfig();

void StepDynamics();
void UpdateButtonsStatus();

Expand Down Expand Up @@ -297,5 +300,7 @@ class Wiimote : public ControllerEmu::EmulatedController, public WiimoteCommon::
PositionalState m_shake_state;

IMUCursorState m_imu_cursor_state;

size_t m_config_changed_callback_id;
};
} // namespace WiimoteEmu
26 changes: 20 additions & 6 deletions Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -142,7 +142,16 @@ void AddWiimoteToPool(std::unique_ptr<Wiimote> 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()
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
9 changes: 7 additions & 2 deletions Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
Expand Up @@ -51,7 +51,7 @@ class Wiimote : public WiimoteCommon::HIDWiimote
Wiimote(Wiimote&&) = delete;
Wiimote& operator=(Wiimote&&) = delete;

virtual ~Wiimote() {}
~Wiimote() override;
// This needs to be called in derived destructors!
void Shutdown();

Expand Down Expand Up @@ -125,6 +125,8 @@ class Wiimote : public WiimoteCommon::HIDWiimote

void ThreadFunc();

void RefreshConfig();

bool m_is_linked = false;

// We track the speaker state to convert unnecessary speaker data into rumble reports.
Expand All @@ -144,6 +146,10 @@ class Wiimote : public WiimoteCommon::HIDWiimote

Common::SPSCQueue<Report> m_read_reports;
Common::SPSCQueue<Report> m_write_reports;

bool m_speaker_enabled_in_dolphin_config = false;

size_t m_config_changed_callback_id;
};

class WiimoteScannerBackend
Expand Down Expand Up @@ -209,5 +215,4 @@ void InitAdapterClass();
void HandleWiimotesInControllerInterfaceSettingChange();
void PopulateDevices();
void ProcessWiimotePool();

} // namespace WiimoteReal
8 changes: 2 additions & 6 deletions Source/Core/Core/IOS/DolphinDevice.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
13 changes: 6 additions & 7 deletions Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/IOS/USB/USB_KBD.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -210,7 +210,7 @@ std::optional<IPCReply> USB_KBD::Write(const ReadWriteRequest& request)

std::optional<IPCReply> 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));
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/NetPlayClient.cpp
Expand Up @@ -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);
}
}

Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/PowerPC/Jit64/Jit.cpp
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/PowerPC/JitArm64/Jit.cpp
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/PowerPC/JitCommon/JitBase.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitCommon/JitBase.h
Expand Up @@ -132,6 +132,7 @@ class JitBase : public CPUCoreBase
bool m_low_dcbz_hack = false;
bool m_fprf = false;
bool m_accurate_nans = false;
bool m_fastmem_enabled = false;

void RefreshConfig();

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/JitCommon/JitCache.cpp
Expand Up @@ -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"
Expand All @@ -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();
}
Expand Down
21 changes: 18 additions & 3 deletions Source/Core/Core/PowerPC/PPCCache.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -87,6 +87,12 @@ constexpr std::array<u32, 128> 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);
Expand All @@ -99,14 +105,18 @@ 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();
}

void InstructionCache::Invalidate(u32 addr)
{
if (!HID0.ICE || SConfig::GetInstance().bDisableICache)
if (!HID0.ICE || m_disable_icache)
return;

// Invalidates the whole set
Expand All @@ -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;
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions Source/Core/Core/PowerPC/PPCCache.h
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <array>
#include <optional>

#include "Common/CommonTypes.h"

Expand All @@ -30,11 +31,16 @@ struct InstructionCache
std::array<u8, 1 << 21> lookup_table_ex{};
std::array<u8, 1 << 20> lookup_table_vmem{};

bool m_disable_icache = false;
std::optional<size_t> 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
15 changes: 9 additions & 6 deletions Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp
Expand Up @@ -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);
Expand All @@ -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());

Expand Down
14 changes: 7 additions & 7 deletions Source/Core/DolphinQt/HotkeyScheduler.cpp
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt/MenuBar.cpp
Expand Up @@ -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();
});

Expand Down
8 changes: 4 additions & 4 deletions Source/Core/DolphinQt/Settings.cpp
Expand Up @@ -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();
Expand All @@ -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);
}
}
5 changes: 3 additions & 2 deletions Source/Core/DolphinQt/Settings/GeneralPane.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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()));

Expand Down
9 changes: 5 additions & 4 deletions Source/Core/VideoCommon/Fifo.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/VideoConfig.cpp
Expand Up @@ -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"
Expand All @@ -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()
Expand Down