From 0c920f175f0cfe96ad7ee0788a2e158f619a41aa Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 26 Jan 2016 20:22:43 -0500 Subject: [PATCH 1/2] BootManager: Simplify SaveConfig Also std::array-ifies C-array members of ConfigCache --- Source/Core/Core/BootManager.cpp | 63 +++++++++++++++++++------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index d2e3819651..7a14626d00 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -20,6 +20,8 @@ // Includes // ---------------- +#include +#include #include #include @@ -52,20 +54,40 @@ public: // restore values to the configuration from the cache void RestoreConfig(SConfig* config); - // these store if the relevant setting should be reset back later (true) or if it should be left alone on restore (false) - bool bSetEmulationSpeed, bSetEXIDevice[MAX_EXI_CHANNELS], bSetVolume, bSetPads[MAX_SI_CHANNELS], bSetWiimoteSource[MAX_BBMOTES], bSetFrameSkip; + // These store if the relevant setting should be reset back later (true) or if it should be left alone on restore (false) + bool bSetEmulationSpeed; + bool bSetVolume; + bool bSetFrameSkip; + std::array bSetWiimoteSource; + std::array bSetPads; + std::array bSetEXIDevice; private: - bool valid, bCPUThread, bSkipIdle, bSyncGPUOnSkipIdleHack, bFPRF, bAccurateNaNs, bMMU, bDCBZOFF, m_EnableJIT, - bSyncGPU, bFastDiscSpeed, bDSPHLE, bHLE_BS2, bProgressive, bPAL60; + bool valid; + bool bCPUThread; + bool bSkipIdle; + bool bSyncGPUOnSkipIdleHack; + bool bFPRF; + bool bAccurateNaNs; + bool bMMU; + bool bDCBZOFF; + bool m_EnableJIT; + bool bSyncGPU; + bool bFastDiscSpeed; + bool bDSPHLE; + bool bHLE_BS2; + bool bProgressive; + bool bPAL60; int iSelectedLanguage; - int iCPUCore, Volume; - int iWiimoteSource[MAX_BBMOTES]; - SIDevices Pads[MAX_SI_CHANNELS]; + int iCPUCore; + int Volume; + std::array iWiimoteSource; + std::array Pads; + std::array m_EXIDevice; unsigned int frameSkip; float m_EmulationSpeed; - TEXIDevices m_EXIDevice[MAX_EXI_CHANNELS]; - std::string strBackend, sBackend; + std::string strBackend; + std::string sBackend; std::string m_strGPUDeterminismMode; }; @@ -91,33 +113,22 @@ void ConfigCache::SaveConfig(const SConfig& config) iCPUCore = config.iCPUCore; Volume = config.m_Volume; - for (unsigned int i = 0; i < MAX_BBMOTES; ++i) - { - iWiimoteSource[i] = g_wiimote_sources[i]; - } - - for (unsigned int i = 0; i < MAX_SI_CHANNELS; ++i) - { - Pads[i] = config.m_SIDevice[i]; - } + std::copy(std::begin(g_wiimote_sources), std::end(g_wiimote_sources), std::begin(iWiimoteSource)); + 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)); m_EmulationSpeed = config.m_EmulationSpeed; frameSkip = config.m_FrameSkip; - for (unsigned int i = 0; i < MAX_EXI_CHANNELS; ++i) - { - m_EXIDevice[i] = config.m_EXIDevice[i]; - } - strBackend = config.m_strVideoBackend; sBackend = config.sBackend; m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; bSetEmulationSpeed = false; - std::fill_n(bSetEXIDevice, (int)MAX_EXI_CHANNELS, false); bSetVolume = false; - std::fill_n(bSetPads, (int)MAX_SI_CHANNELS, false); - std::fill_n(bSetWiimoteSource, (int)MAX_BBMOTES, false); + bSetWiimoteSource.fill(false); + bSetPads.fill(false); + bSetEXIDevice.fill(false); bSetFrameSkip = false; } From d7d067390022bf18078676cad866a7f9e56f45d2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 26 Jan 2016 20:37:44 -0500 Subject: [PATCH 2/2] BootManager: Vertically align where sensible to do so --- Source/Core/Core/BootManager.cpp | 119 +++++++++++++++---------------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 7a14626d00..e70c0f45bb 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -81,55 +81,53 @@ private: int iSelectedLanguage; int iCPUCore; int Volume; - std::array iWiimoteSource; - std::array Pads; - std::array m_EXIDevice; unsigned int frameSkip; float m_EmulationSpeed; std::string strBackend; std::string sBackend; std::string m_strGPUDeterminismMode; + std::array iWiimoteSource; + std::array Pads; + std::array m_EXIDevice; }; void ConfigCache::SaveConfig(const SConfig& config) { valid = true; - bCPUThread = config.bCPUThread; - bSkipIdle = config.bSkipIdle; - bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; - bFPRF = config.bFPRF; - bAccurateNaNs = config.bAccurateNaNs; - bMMU = config.bMMU; - bDCBZOFF = config.bDCBZOFF; - m_EnableJIT = config.m_DSPEnableJIT; - bSyncGPU = config.bSyncGPU; - bFastDiscSpeed = config.bFastDiscSpeed; - bDSPHLE = config.bDSPHLE; - bHLE_BS2 = config.bHLE_BS2; - bProgressive = config.bProgressive; - bPAL60 = config.bPAL60; - iSelectedLanguage = config.SelectedLanguage; - iCPUCore = config.iCPUCore; - Volume = config.m_Volume; + bCPUThread = config.bCPUThread; + bSkipIdle = config.bSkipIdle; + bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; + bFPRF = config.bFPRF; + bAccurateNaNs = config.bAccurateNaNs; + bMMU = config.bMMU; + bDCBZOFF = config.bDCBZOFF; + m_EnableJIT = config.m_DSPEnableJIT; + bSyncGPU = config.bSyncGPU; + bFastDiscSpeed = config.bFastDiscSpeed; + bDSPHLE = config.bDSPHLE; + bHLE_BS2 = config.bHLE_BS2; + bProgressive = config.bProgressive; + bPAL60 = config.bPAL60; + iSelectedLanguage = config.SelectedLanguage; + iCPUCore = config.iCPUCore; + Volume = config.m_Volume; + m_EmulationSpeed = config.m_EmulationSpeed; + frameSkip = config.m_FrameSkip; + strBackend = config.m_strVideoBackend; + sBackend = config.sBackend; + m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; std::copy(std::begin(g_wiimote_sources), std::end(g_wiimote_sources), std::begin(iWiimoteSource)); 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)); - m_EmulationSpeed = config.m_EmulationSpeed; - frameSkip = config.m_FrameSkip; - - strBackend = config.m_strVideoBackend; - sBackend = config.sBackend; - m_strGPUDeterminismMode = config.m_strGPUDeterminismMode; - bSetEmulationSpeed = false; bSetVolume = false; + bSetFrameSkip = false; bSetWiimoteSource.fill(false); bSetPads.fill(false); bSetEXIDevice.fill(false); - bSetFrameSkip = false; } void ConfigCache::RestoreConfig(SConfig* config) @@ -139,24 +137,25 @@ void ConfigCache::RestoreConfig(SConfig* config) valid = false; - config->bCPUThread = bCPUThread; - config->bSkipIdle = bSkipIdle; + config->bCPUThread = bCPUThread; + config->bSkipIdle = bSkipIdle; config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack; - config->bFPRF = bFPRF; - config->bAccurateNaNs = bAccurateNaNs; - config->bMMU = bMMU; - config->bDCBZOFF = bDCBZOFF; - config->m_DSPEnableJIT = m_EnableJIT; - config->bSyncGPU = bSyncGPU; - config->bFastDiscSpeed = bFastDiscSpeed; - config->bDSPHLE = bDSPHLE; - config->bHLE_BS2 = bHLE_BS2; - config->bProgressive = bProgressive; + config->bFPRF = bFPRF; + config->bAccurateNaNs = bAccurateNaNs; + config->bMMU = bMMU; + config->bDCBZOFF = bDCBZOFF; + config->m_DSPEnableJIT = m_EnableJIT; + config->bSyncGPU = bSyncGPU; + config->bFastDiscSpeed = bFastDiscSpeed; + config->bDSPHLE = bDSPHLE; + config->bHLE_BS2 = bHLE_BS2; + config->bProgressive = bProgressive; + config->bPAL60 = bPAL60; + config->SelectedLanguage = iSelectedLanguage; + config->iCPUCore = iCPUCore; + config->m_SYSCONF->SetData("IPL.PGS", bProgressive); - config->bPAL60 = bPAL60; config->m_SYSCONF->SetData("IPL.E60", bPAL60); - config->SelectedLanguage = iSelectedLanguage; - config->iCPUCore = iCPUCore; // Only change these back if they were actually set by game ini, since they can be changed while a game is running. if (bSetVolume) @@ -319,14 +318,14 @@ bool BootCore(const std::string& _rFilename) // Movie settings if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { - StartUp.bCPUThread = Movie::IsDualCore(); - StartUp.bSkipIdle = Movie::IsSkipIdle(); - StartUp.bDSPHLE = Movie::IsDSPHLE(); - StartUp.bProgressive = Movie::IsProgressive(); - StartUp.bPAL60 = Movie::IsPAL60(); + StartUp.bCPUThread = Movie::IsDualCore(); + StartUp.bSkipIdle = Movie::IsSkipIdle(); + StartUp.bDSPHLE = Movie::IsDSPHLE(); + StartUp.bProgressive = Movie::IsProgressive(); + StartUp.bPAL60 = Movie::IsPAL60(); StartUp.bFastDiscSpeed = Movie::IsFastDiscSpeed(); - StartUp.iCPUCore = Movie::GetCPUMode(); - StartUp.bSyncGPU = Movie::IsSyncGPU(); + StartUp.iCPUCore = Movie::GetCPUMode(); + StartUp.bSyncGPU = Movie::IsSyncGPU(); for (int i = 0; i < 2; ++i) { if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii) @@ -339,17 +338,17 @@ bool BootCore(const std::string& _rFilename) if (NetPlay::IsNetPlayRunning()) { - StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread; - StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; - StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard; - StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore; - StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage; - StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage; - StartUp.bProgressive = g_NetPlaySettings.m_ProgressiveScan; - StartUp.bPAL60 = g_NetPlaySettings.m_PAL60; + StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread; + StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; + StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard; + StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore; + StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage; + StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage; + StartUp.bProgressive = g_NetPlaySettings.m_ProgressiveScan; + StartUp.bPAL60 = g_NetPlaySettings.m_PAL60; SConfig::GetInstance().m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT; - SConfig::GetInstance().m_OCEnable = g_NetPlaySettings.m_OCEnable; - SConfig::GetInstance().m_OCFactor = g_NetPlaySettings.m_OCFactor; + SConfig::GetInstance().m_OCEnable = g_NetPlaySettings.m_OCEnable; + SConfig::GetInstance().m_OCFactor = g_NetPlaySettings.m_OCFactor; SConfig::GetInstance().m_EXIDevice[0] = g_NetPlaySettings.m_EXIDevice[0]; SConfig::GetInstance().m_EXIDevice[1] = g_NetPlaySettings.m_EXIDevice[1]; config_cache.bSetEXIDevice[0] = true;