56 changes: 2 additions & 54 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -99,35 +99,20 @@ 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);
core->Set("SyncGPU", bSyncGPU);
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]);
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);
Expand All @@ -140,8 +125,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()
Expand All @@ -159,36 +142,17 @@ 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],
(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);
Expand All @@ -204,18 +168,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()
Expand Down Expand Up @@ -331,24 +287,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();
Expand Down Expand Up @@ -539,7 +487,7 @@ DiscIO::Language SConfig::GetCurrentLanguage(bool wii) const
if (wii)
language = static_cast<DiscIO::Language>(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)
Expand All @@ -557,7 +505,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;
Expand Down
26 changes: 0 additions & 26 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -162,21 +146,11 @@ struct SConfig
static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision);
static IniFile LoadGameIni(const std::string& id, std::optional<u16> 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
bool m_AdapterRumble[4];
bool m_AdapterKonga[4];

SConfig(const SConfig&) = delete;
SConfig& operator=(const SConfig&) = delete;
SConfig(SConfig&&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Core.cpp
Expand Up @@ -636,7 +636,7 @@ static void EmuThread(std::unique_ptr<BootParameters> 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);
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp
Expand Up @@ -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
{
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
16 changes: 9 additions & 7 deletions Source/Core/Core/HW/EXI/EXI_DeviceEthernet.cpp
Expand Up @@ -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"
Expand All @@ -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<Common::MACAddress> mac_addr = Common::StringToMacAddress(mac_addr_setting);

std::transform(mac_addr_setting.begin(), mac_addr_setting.end(), mac_addr_setting.begin(),
Expand All @@ -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)
Expand Down Expand Up @@ -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<bba mac>"
m_network_interface = std::make_unique<XLinkNetworkInterface>(
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<XLinkNetworkInterface>(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;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/HW.cpp
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp
Expand Up @@ -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"
Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/HW/SystemTimers.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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<u64>(s_cpu_core_clock / TIMER_RATIO) *
Expand Down
6 changes: 2 additions & 4 deletions Source/Core/Core/Movie.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -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();
}
Expand Down
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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&),
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_FloatingPoint.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp
Expand Up @@ -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;

Expand Down
12 changes: 10 additions & 2 deletions Source/Core/Core/PowerPC/JitCommon/JitBase.cpp
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/PowerPC/JitCommon/JitBase.h
Expand Up @@ -127,6 +127,11 @@ class JitBase : public CPUCoreBase
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();

Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/PowerPC/PPCAnalyst.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Core/PowerPC/PPCAnalyst.h
Expand Up @@ -216,6 +216,9 @@ class PPCAnalyzer
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:
Expand All @@ -238,6 +241,9 @@ class PPCAnalyzer
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);
Expand Down
Expand Up @@ -8,6 +8,7 @@
#include <QLabel>
#include <QVBoxLayout>

#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"

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

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/MenuBar.cpp
Expand Up @@ -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) {
Expand Down
15 changes: 8 additions & 7 deletions Source/Core/DolphinQt/Settings/AdvancedPane.cpp
Expand Up @@ -174,7 +174,6 @@ void AdvancedPane::ConnectLayout()
{
connect(m_cpu_emulation_engine_combobox,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [](int index) {
SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[index];
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]);
});

Expand Down Expand Up @@ -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<u32>(date_time.toSecsSinceEpoch());
Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE,
static_cast<u32>(date_time.toSecsSinceEpoch()));
Update();
});
}
Expand All @@ -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<PowerPC::CPUCore>& 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);
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <QVBoxLayout>

#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)
Expand All @@ -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, <a "
"href=\"https://wiki.dolphin-emu.org/"
"index.php?title=Broadband_Adapter\">refer to this page</a>."));
Expand All @@ -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, <a "
"href=\"https://www.teamxlink.co.uk/wiki/Dolphin\">refer to this page</a>."));
Expand Down Expand Up @@ -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;
}

Expand Down
22 changes: 9 additions & 13 deletions Source/Core/DolphinQt/Settings/GameCubePane.cpp
Expand Up @@ -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)
Expand All @@ -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());
}
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt/Settings/GeneralPane.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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());
Expand Down
24 changes: 23 additions & 1 deletion Source/Core/InputCommon/GCAdapter.cpp
Expand Up @@ -2,14 +2,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include <algorithm>
#include <array>
#include <libusb.h>
#include <mutex>
#include <optional>

#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"
Expand Down Expand Up @@ -79,6 +82,9 @@ static u8 s_endpoint_out = 0;

static u64 s_last_init = 0;

static std::optional<size_t> s_config_callback_id = std::nullopt;
static std::array<bool, SerialInterface::MAX_SI_CHANNELS> s_config_rumble_enabled{};

static void Read()
{
int payload_size = 0;
Expand Down Expand Up @@ -196,6 +202,12 @@ void SetAdapterCallback(std::function<void()> 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)
Expand All @@ -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();
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down