2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2011 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
// File description
|
|
|
|
// -------------
|
|
|
|
// Purpose of this file: Collect boot settings for Core::Init()
|
|
|
|
|
|
|
|
// Call sequence: This file has one of the first function called when a game is booted,
|
|
|
|
// the boot sequence in the code is:
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2011-03-03 04:35:03 +00:00
|
|
|
// DolphinWX: FrameTools.cpp StartGame
|
|
|
|
// Core BootManager.cpp BootCore
|
|
|
|
// Core.cpp Init Thread creation
|
2011-02-12 22:31:57 +00:00
|
|
|
// EmuThread Calls CBoot::BootUp
|
|
|
|
// Boot.cpp CBoot::BootUp()
|
|
|
|
// CBoot::EmulatedBS2_Wii() / GC() or Load_BS2()
|
|
|
|
|
2017-02-24 22:56:33 -05:00
|
|
|
#include "Core/BootManager.h"
|
|
|
|
|
2016-01-26 20:22:43 -05:00
|
|
|
#include <algorithm>
|
|
|
|
#include <array>
|
2011-02-12 22:31:57 +00:00
|
|
|
#include <string>
|
|
|
|
|
2019-10-20 07:35:11 -04:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2014-02-19 13:09:14 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2017-05-13 22:29:55 +01:00
|
|
|
#include "Common/Config/Config.h"
|
2016-01-17 16:54:31 -05:00
|
|
|
#include "Common/FileUtil.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/IniFile.h"
|
2016-10-07 21:57:07 +02:00
|
|
|
#include "Common/Logging/Log.h"
|
2016-12-23 21:53:36 +01:00
|
|
|
|
2017-05-27 15:43:40 +02:00
|
|
|
#include "Core/Boot/Boot.h"
|
2017-08-03 16:42:18 +08:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-08-01 22:37:42 +08:00
|
|
|
#include "Core/Config/SYSCONFSettings.h"
|
|
|
|
#include "Core/ConfigLoaders/BaseConfigLoader.h"
|
2017-05-13 22:29:55 +01:00
|
|
|
#include "Core/ConfigLoaders/NetPlayConfigLoader.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
2017-01-20 15:33:43 -05:00
|
|
|
#include "Core/HW/EXI/EXI.h"
|
2017-01-20 18:45:11 -05:00
|
|
|
#include "Core/HW/SI/SI.h"
|
2019-06-07 18:25:32 -04:00
|
|
|
#include "Core/HW/SI/SI_Device.h"
|
2015-06-14 13:59:41 +02:00
|
|
|
#include "Core/HW/Sram.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
|
|
|
#include "Core/Movie.h"
|
|
|
|
#include "Core/NetPlayProto.h"
|
2018-06-15 08:11:18 -04:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2020-03-16 13:02:35 +01:00
|
|
|
#include "Core/WiiRoot.h"
|
2016-12-23 21:53:36 +01:00
|
|
|
|
|
|
|
#include "DiscIO/Enums.h"
|
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2011-02-12 22:31:57 +00:00
|
|
|
|
|
|
|
namespace BootManager
|
|
|
|
{
|
|
|
|
// TODO this is an ugly hack which allows us to restore values trampled by per-game settings
|
|
|
|
// Apply fire liberally
|
|
|
|
struct ConfigCache
|
|
|
|
{
|
2015-06-17 14:07:58 +02:00
|
|
|
public:
|
|
|
|
// fill the cache with values from the configuration
|
|
|
|
void SaveConfig(const SConfig& config);
|
|
|
|
// restore values to the configuration from the cache
|
|
|
|
void RestoreConfig(SConfig* config);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-01-26 20:22:43 -05:00
|
|
|
// 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;
|
|
|
|
std::array<bool, MAX_BBMOTES> bSetWiimoteSource;
|
2017-03-16 01:51:27 -04:00
|
|
|
std::array<bool, SerialInterface::MAX_SI_CHANNELS> bSetPads;
|
2017-03-16 02:04:19 -04:00
|
|
|
std::array<bool, ExpansionInterface::MAX_EXI_CHANNELS> bSetEXIDevice;
|
2015-06-17 14:07:58 +02:00
|
|
|
|
|
|
|
private:
|
2016-01-26 20:22:43 -05:00
|
|
|
bool valid;
|
|
|
|
bool bCPUThread;
|
2018-07-19 18:10:37 -04:00
|
|
|
bool bJITFollowBranch;
|
2016-01-26 20:22:43 -05:00
|
|
|
bool bSyncGPUOnSkipIdleHack;
|
|
|
|
bool bFPRF;
|
|
|
|
bool bAccurateNaNs;
|
|
|
|
bool bMMU;
|
2017-01-26 04:57:03 -05:00
|
|
|
bool bLowDCBZHack;
|
2020-07-05 14:15:33 -07:00
|
|
|
bool bDisableICache;
|
2016-01-26 20:22:43 -05:00
|
|
|
bool m_EnableJIT;
|
|
|
|
bool bSyncGPU;
|
2018-07-19 18:10:37 -04:00
|
|
|
int iSyncGpuMaxDistance;
|
|
|
|
int iSyncGpuMinDistance;
|
|
|
|
float fSyncGpuOverclock;
|
2016-01-26 20:22:43 -05:00
|
|
|
bool bFastDiscSpeed;
|
|
|
|
bool bDSPHLE;
|
|
|
|
bool bHLE_BS2;
|
2015-06-08 20:25:48 +02:00
|
|
|
int iSelectedLanguage;
|
2018-06-15 08:11:18 -04:00
|
|
|
PowerPC::CPUCore cpu_core;
|
2016-01-26 20:22:43 -05:00
|
|
|
int Volume;
|
2015-12-16 00:10:47 +01:00
|
|
|
float m_EmulationSpeed;
|
2017-02-05 06:16:32 -05:00
|
|
|
float m_OCFactor;
|
|
|
|
bool m_OCEnable;
|
2018-12-17 18:20:47 -05:00
|
|
|
bool m_bt_passthrough_enabled;
|
2016-01-26 20:22:43 -05:00
|
|
|
std::string sBackend;
|
2014-09-06 17:43:43 -04:00
|
|
|
std::string m_strGPUDeterminismMode;
|
2019-11-12 18:50:16 -06:00
|
|
|
std::array<WiimoteSource, MAX_BBMOTES> iWiimoteSource;
|
2017-03-16 04:41:36 -04:00
|
|
|
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads;
|
2017-03-18 17:46:05 -04:00
|
|
|
std::array<ExpansionInterface::TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice;
|
2011-02-12 22:31:57 +00:00
|
|
|
};
|
2015-06-17 14:07:58 +02:00
|
|
|
|
|
|
|
void ConfigCache::SaveConfig(const SConfig& config)
|
|
|
|
{
|
|
|
|
valid = true;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-01-26 20:37:44 -05:00
|
|
|
bCPUThread = config.bCPUThread;
|
2018-07-19 18:10:37 -04:00
|
|
|
bJITFollowBranch = config.bJITFollowBranch;
|
2016-01-26 20:37:44 -05:00
|
|
|
bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack;
|
|
|
|
bFPRF = config.bFPRF;
|
|
|
|
bAccurateNaNs = config.bAccurateNaNs;
|
2020-07-05 14:15:33 -07:00
|
|
|
bDisableICache = config.bDisableICache;
|
2016-01-26 20:37:44 -05:00
|
|
|
bMMU = config.bMMU;
|
|
|
|
m_EnableJIT = config.m_DSPEnableJIT;
|
|
|
|
bSyncGPU = config.bSyncGPU;
|
2018-07-19 18:10:37 -04:00
|
|
|
iSyncGpuMaxDistance = config.iSyncGpuMaxDistance;
|
|
|
|
iSyncGpuMinDistance = config.iSyncGpuMinDistance;
|
|
|
|
fSyncGpuOverclock = config.fSyncGpuOverclock;
|
2016-01-26 20:37:44 -05:00
|
|
|
bFastDiscSpeed = config.bFastDiscSpeed;
|
|
|
|
bDSPHLE = config.bDSPHLE;
|
|
|
|
bHLE_BS2 = config.bHLE_BS2;
|
|
|
|
iSelectedLanguage = config.SelectedLanguage;
|
2018-06-15 08:11:18 -04:00
|
|
|
cpu_core = config.cpu_core;
|
2016-01-26 20:37:44 -05:00
|
|
|
Volume = config.m_Volume;
|
|
|
|
m_EmulationSpeed = config.m_EmulationSpeed;
|
|
|
|
sBackend = config.sBackend;
|
2015-06-17 14:07:58 +02:00
|
|
|
m_strGPUDeterminismMode = config.m_strGPUDeterminismMode;
|
2017-02-05 06:16:32 -05:00
|
|
|
m_OCFactor = config.m_OCFactor;
|
|
|
|
m_OCEnable = config.m_OCEnable;
|
2018-12-17 18:20:47 -05:00
|
|
|
m_bt_passthrough_enabled = config.m_bt_passthrough_enabled;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2019-11-12 18:50:16 -06:00
|
|
|
for (int i = 0; i != MAX_BBMOTES; ++i)
|
|
|
|
iWiimoteSource[i] = WiimoteCommon::GetSource(i);
|
|
|
|
|
2016-01-26 20:22:43 -05:00
|
|
|
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));
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-12-16 00:10:47 +01:00
|
|
|
bSetEmulationSpeed = false;
|
2015-06-17 14:07:58 +02:00
|
|
|
bSetVolume = false;
|
2016-01-26 20:22:43 -05:00
|
|
|
bSetWiimoteSource.fill(false);
|
|
|
|
bSetPads.fill(false);
|
|
|
|
bSetEXIDevice.fill(false);
|
2015-06-17 14:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigCache::RestoreConfig(SConfig* config)
|
|
|
|
{
|
|
|
|
if (!valid)
|
|
|
|
return;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-06-17 14:07:58 +02:00
|
|
|
valid = false;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-01-26 20:37:44 -05:00
|
|
|
config->bCPUThread = bCPUThread;
|
2018-07-19 18:10:37 -04:00
|
|
|
config->bJITFollowBranch = bJITFollowBranch;
|
2015-06-17 14:07:58 +02:00
|
|
|
config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack;
|
2016-01-26 20:37:44 -05:00
|
|
|
config->bFPRF = bFPRF;
|
|
|
|
config->bAccurateNaNs = bAccurateNaNs;
|
2020-07-05 14:15:33 -07:00
|
|
|
config->bDisableICache = bDisableICache;
|
2016-01-26 20:37:44 -05:00
|
|
|
config->bMMU = bMMU;
|
2017-01-26 04:57:03 -05:00
|
|
|
config->bLowDCBZHack = bLowDCBZHack;
|
2016-01-26 20:37:44 -05:00
|
|
|
config->m_DSPEnableJIT = m_EnableJIT;
|
|
|
|
config->bSyncGPU = bSyncGPU;
|
2018-07-19 18:10:37 -04:00
|
|
|
config->iSyncGpuMaxDistance = iSyncGpuMaxDistance;
|
|
|
|
config->iSyncGpuMinDistance = iSyncGpuMinDistance;
|
|
|
|
config->fSyncGpuOverclock = fSyncGpuOverclock;
|
2016-01-26 20:37:44 -05:00
|
|
|
config->bFastDiscSpeed = bFastDiscSpeed;
|
|
|
|
config->bDSPHLE = bDSPHLE;
|
|
|
|
config->bHLE_BS2 = bHLE_BS2;
|
|
|
|
config->SelectedLanguage = iSelectedLanguage;
|
2018-06-15 08:11:18 -04:00
|
|
|
config->cpu_core = cpu_core;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-06-17 14:07:58 +02:00
|
|
|
// Only change these back if they were actually set by game ini, since they can be changed while a
|
|
|
|
// game is running.
|
|
|
|
if (bSetVolume)
|
|
|
|
config->m_Volume = Volume;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-06-17 14:07:58 +02:00
|
|
|
if (config->bWii)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
|
|
|
|
{
|
|
|
|
if (bSetWiimoteSource[i])
|
2019-11-12 18:50:16 -06:00
|
|
|
WiimoteCommon::SetSource(i, iWiimoteSource[i]);
|
2015-06-17 14:07:58 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-03-16 01:51:27 -04:00
|
|
|
for (unsigned int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
2015-06-17 14:07:58 +02:00
|
|
|
{
|
|
|
|
if (bSetPads[i])
|
|
|
|
config->m_SIDevice[i] = Pads[i];
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-12-16 00:10:47 +01:00
|
|
|
if (bSetEmulationSpeed)
|
|
|
|
config->m_EmulationSpeed = m_EmulationSpeed;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-03-16 02:04:19 -04:00
|
|
|
for (unsigned int i = 0; i < ExpansionInterface::MAX_EXI_CHANNELS; ++i)
|
2015-06-17 14:07:58 +02:00
|
|
|
{
|
|
|
|
if (bSetEXIDevice[i])
|
|
|
|
config->m_EXIDevice[i] = m_EXIDevice[i];
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-06-17 14:07:58 +02:00
|
|
|
config->sBackend = sBackend;
|
|
|
|
config->m_strGPUDeterminismMode = m_strGPUDeterminismMode;
|
2017-02-05 06:16:32 -05:00
|
|
|
config->m_OCFactor = m_OCFactor;
|
|
|
|
config->m_OCEnable = m_OCEnable;
|
2018-12-17 18:20:47 -05:00
|
|
|
config->m_bt_passthrough_enabled = m_bt_passthrough_enabled;
|
2015-06-17 14:07:58 +02:00
|
|
|
}
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
static ConfigCache config_cache;
|
|
|
|
|
2019-11-01 23:30:30 +01:00
|
|
|
void SetEmulationSpeedReset(bool value)
|
|
|
|
{
|
|
|
|
config_cache.bSetEmulationSpeed = value;
|
|
|
|
}
|
|
|
|
|
2014-09-06 17:43:43 -04:00
|
|
|
static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode)
|
|
|
|
{
|
|
|
|
if (mode == "auto")
|
2018-06-15 14:25:16 -04:00
|
|
|
return GPUDeterminismMode::Auto;
|
2014-09-06 17:43:43 -04:00
|
|
|
if (mode == "none")
|
2018-06-15 14:25:16 -04:00
|
|
|
return GPUDeterminismMode::Disabled;
|
2014-09-06 17:43:43 -04:00
|
|
|
if (mode == "fake-completion")
|
2018-06-15 14:25:16 -04:00
|
|
|
return GPUDeterminismMode::FakeCompletion;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2020-11-18 06:01:15 -05:00
|
|
|
NOTICE_LOG_FMT(BOOT, "Unknown GPU determinism mode {}", mode);
|
2018-06-15 14:25:16 -04:00
|
|
|
return GPUDeterminismMode::Auto;
|
2014-09-06 17:43:43 -04:00
|
|
|
}
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// Boot the ISO or file
|
2018-10-03 23:03:22 +10:00
|
|
|
bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
2011-02-12 22:31:57 +00:00
|
|
|
{
|
2017-05-27 15:43:40 +02:00
|
|
|
if (!boot)
|
|
|
|
return false;
|
|
|
|
|
2015-06-12 13:56:53 +02:00
|
|
|
SConfig& StartUp = SConfig::GetInstance();
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
StartUp.bRunCompareClient = false;
|
|
|
|
StartUp.bRunCompareServer = false;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-06-17 14:07:58 +02:00
|
|
|
config_cache.SaveConfig(StartUp);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-05-27 15:43:40 +02:00
|
|
|
if (!StartUp.SetPathsAndGameMetadata(*boot))
|
2011-02-12 22:31:57 +00:00
|
|
|
return false;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// Load game specific settings
|
2017-05-27 15:43:40 +02:00
|
|
|
if (!std::holds_alternative<BootParameters::IPL>(boot->parameters))
|
2011-02-12 22:31:57 +00:00
|
|
|
{
|
2013-09-23 02:39:14 -04:00
|
|
|
IniFile game_ini = StartUp.LoadGameIni();
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// General settings
|
2014-06-16 01:12:43 -04:00
|
|
|
IniFile::Section* core_section = game_ini.GetOrCreateSection("Core");
|
|
|
|
IniFile::Section* dsp_section = game_ini.GetOrCreateSection("DSP");
|
|
|
|
IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls");
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2014-06-16 01:12:43 -04:00
|
|
|
core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
2018-07-08 21:26:34 +02:00
|
|
|
core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch);
|
2015-06-06 11:19:58 +02:00
|
|
|
core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack,
|
|
|
|
StartUp.bSyncGPUOnSkipIdleHack);
|
2014-10-21 04:56:35 -07:00
|
|
|
core_section->Get("FPRF", &StartUp.bFPRF, StartUp.bFPRF);
|
2015-06-07 14:38:09 +02:00
|
|
|
core_section->Get("AccurateNaNs", &StartUp.bAccurateNaNs, StartUp.bAccurateNaNs);
|
2020-07-05 14:15:33 -07:00
|
|
|
core_section->Get("DisableICache", &StartUp.bDisableICache, StartUp.bDisableICache);
|
2014-06-16 01:12:43 -04:00
|
|
|
core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU);
|
2017-01-26 04:57:03 -05:00
|
|
|
core_section->Get("LowDCBZHack", &StartUp.bLowDCBZHack, StartUp.bLowDCBZHack);
|
2014-06-16 01:12:43 -04:00
|
|
|
core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
|
|
|
|
core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
|
|
|
|
core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
|
2018-06-15 08:11:18 -04:00
|
|
|
core_section->Get("CPUCore", &StartUp.cpu_core, StartUp.cpu_core);
|
2014-06-16 01:12:43 -04:00
|
|
|
core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
2016-12-29 12:34:14 -06:00
|
|
|
core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage);
|
2017-01-22 16:40:26 +01:00
|
|
|
if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed))
|
2015-12-16 00:10:47 +01:00
|
|
|
config_cache.bSetEmulationSpeed = true;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-01-22 16:40:26 +01:00
|
|
|
if (dsp_section->Get("Volume", &StartUp.m_Volume, StartUp.m_Volume))
|
2014-01-02 16:36:06 -05:00
|
|
|
config_cache.bSetVolume = true;
|
2017-01-22 16:40:26 +01:00
|
|
|
dsp_section->Get("EnableJIT", &StartUp.m_DSPEnableJIT, StartUp.m_DSPEnableJIT);
|
|
|
|
dsp_section->Get("Backend", &StartUp.sBackend, StartUp.sBackend);
|
2014-09-06 17:43:43 -04:00
|
|
|
core_section->Get("GPUDeterminismMode", &StartUp.m_strGPUDeterminismMode,
|
|
|
|
StartUp.m_strGPUDeterminismMode);
|
2017-02-05 06:16:32 -05:00
|
|
|
core_section->Get("Overclock", &StartUp.m_OCFactor, StartUp.m_OCFactor);
|
|
|
|
core_section->Get("OverclockEnable", &StartUp.m_OCEnable, StartUp.m_OCEnable);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-03-16 01:51:27 -04:00
|
|
|
for (unsigned int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
2014-01-02 13:13:36 -05:00
|
|
|
{
|
|
|
|
int source;
|
2019-10-20 07:35:11 -04:00
|
|
|
controls_section->Get(fmt::format("PadType{}", i), &source, -1);
|
2017-03-16 04:41:36 -04:00
|
|
|
if (source >= SerialInterface::SIDEVICE_NONE && source < SerialInterface::SIDEVICE_COUNT)
|
2014-01-02 13:13:36 -05:00
|
|
|
{
|
2017-03-16 04:41:36 -04:00
|
|
|
StartUp.m_SIDevice[i] = static_cast<SerialInterface::SIDevices>(source);
|
2014-01-02 16:36:06 -05:00
|
|
|
config_cache.bSetPads[i] = true;
|
2014-01-02 13:13:36 -05:00
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
}
|
|
|
|
|
2011-02-12 22:31:57 +00:00
|
|
|
// Wii settings
|
|
|
|
if (StartUp.bWii)
|
|
|
|
{
|
2014-01-01 06:59:01 -05:00
|
|
|
int source;
|
|
|
|
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
|
|
|
{
|
2019-10-20 07:35:11 -04:00
|
|
|
controls_section->Get(fmt::format("WiimoteSource{}", i), &source, -1);
|
2019-11-12 18:50:16 -06:00
|
|
|
if (source != -1 && WiimoteCommon::GetSource(i) != WiimoteSource(source) &&
|
|
|
|
WiimoteSource(source) >= WiimoteSource::None &&
|
|
|
|
WiimoteSource(source) <= WiimoteSource::Real)
|
2014-01-01 06:59:01 -05:00
|
|
|
{
|
2014-01-02 16:36:06 -05:00
|
|
|
config_cache.bSetWiimoteSource[i] = true;
|
2019-11-12 18:50:16 -06:00
|
|
|
WiimoteCommon::SetSource(i, WiimoteSource(source));
|
2014-01-01 06:59:01 -05:00
|
|
|
}
|
|
|
|
}
|
2014-06-16 01:12:43 -04:00
|
|
|
controls_section->Get("WiimoteSourceBB", &source, -1);
|
2019-11-12 18:50:16 -06:00
|
|
|
if (source != -1 &&
|
|
|
|
WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) != WiimoteSource(source) &&
|
|
|
|
(WiimoteSource(source) == WiimoteSource::None ||
|
|
|
|
WiimoteSource(source) == WiimoteSource::Real))
|
2014-01-01 06:59:01 -05:00
|
|
|
{
|
2014-01-02 16:36:06 -05:00
|
|
|
config_cache.bSetWiimoteSource[WIIMOTE_BALANCE_BOARD] = true;
|
2019-11-12 18:50:16 -06:00
|
|
|
WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, WiimoteSource(source));
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
}
|
|
|
|
|
2014-11-05 19:36:12 -05:00
|
|
|
StartUp.m_GPUDeterminismMode = ParseGPUDeterminismMode(StartUp.m_strGPUDeterminismMode);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2014-01-02 13:13:36 -05:00
|
|
|
// Movie settings
|
2013-05-19 19:44:37 +02:00
|
|
|
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
|
|
|
{
|
2017-08-03 16:42:18 +08:00
|
|
|
// TODO: remove this once ConfigManager starts using OnionConfig.
|
|
|
|
StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD);
|
2018-07-19 18:10:37 -04:00
|
|
|
StartUp.bJITFollowBranch = Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH);
|
2017-08-03 16:42:18 +08:00
|
|
|
StartUp.bDSPHLE = Config::Get(Config::MAIN_DSP_HLE);
|
|
|
|
StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED);
|
2018-06-15 08:11:18 -04:00
|
|
|
StartUp.cpu_core = Config::Get(Config::MAIN_CPU_CORE);
|
2017-08-03 16:42:18 +08:00
|
|
|
StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
|
2016-08-09 16:58:18 -04:00
|
|
|
if (!StartUp.bWii)
|
2017-08-03 16:42:18 +08:00
|
|
|
StartUp.SelectedLanguage = Config::Get(Config::MAIN_GC_LANGUAGE);
|
2014-07-02 21:45:59 -04:00
|
|
|
for (int i = 0; i < 2; ++i)
|
2013-05-19 19:44:37 +02:00
|
|
|
{
|
2014-07-02 21:45:59 -04:00
|
|
|
if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii)
|
|
|
|
{
|
2019-10-20 07:35:11 -04:00
|
|
|
const auto raw_path =
|
|
|
|
File::GetUserPath(D_GCUSER_IDX) + fmt::format("Movie{}.raw", (i == 0) ? 'A' : 'B');
|
|
|
|
if (File::Exists(raw_path))
|
|
|
|
File::Delete(raw_path);
|
|
|
|
|
|
|
|
const auto movie_path = File::GetUserPath(D_GCUSER_IDX) + "Movie";
|
|
|
|
if (File::Exists(movie_path))
|
|
|
|
File::DeleteDirRecursively(movie_path);
|
2013-05-19 19:44:37 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
}
|
|
|
|
|
2013-08-05 04:56:30 -04:00
|
|
|
if (NetPlay::IsNetPlayRunning())
|
2013-07-19 18:48:27 -04:00
|
|
|
{
|
2018-07-09 15:52:31 -04:00
|
|
|
const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings();
|
2018-07-06 19:39:42 -04:00
|
|
|
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
|
|
|
|
StartUp.bCPUThread = netplay_settings.m_CPUthread;
|
|
|
|
StartUp.bDSPHLE = netplay_settings.m_DSPHLE;
|
|
|
|
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
|
|
|
|
StartUp.cpu_core = netplay_settings.m_CPUcore;
|
|
|
|
StartUp.SelectedLanguage = netplay_settings.m_SelectedLanguage;
|
2019-06-30 11:48:49 +02:00
|
|
|
StartUp.bOverrideRegionSettings = netplay_settings.m_OverrideRegionSettings;
|
2018-07-06 19:39:42 -04:00
|
|
|
StartUp.m_DSPEnableJIT = netplay_settings.m_DSPEnableJIT;
|
|
|
|
StartUp.m_OCEnable = netplay_settings.m_OCEnable;
|
|
|
|
StartUp.m_OCFactor = netplay_settings.m_OCFactor;
|
|
|
|
StartUp.m_EXIDevice[0] = netplay_settings.m_EXIDevice[0];
|
|
|
|
StartUp.m_EXIDevice[1] = netplay_settings.m_EXIDevice[1];
|
2019-04-01 09:14:28 -04:00
|
|
|
StartUp.m_EXIDevice[2] = netplay_settings.m_EXIDevice[2];
|
2014-01-02 16:36:06 -05:00
|
|
|
config_cache.bSetEXIDevice[0] = true;
|
|
|
|
config_cache.bSetEXIDevice[1] = true;
|
2019-04-01 09:14:28 -04:00
|
|
|
config_cache.bSetEXIDevice[2] = true;
|
2018-07-19 18:10:37 -04:00
|
|
|
StartUp.bFPRF = netplay_settings.m_FPRF;
|
|
|
|
StartUp.bAccurateNaNs = netplay_settings.m_AccurateNaNs;
|
2020-07-05 14:15:33 -07:00
|
|
|
StartUp.bDisableICache = netplay_settings.m_DisableICache;
|
2018-07-19 18:10:37 -04:00
|
|
|
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.bJITFollowBranch = netplay_settings.m_JITFollowBranch;
|
|
|
|
StartUp.bFastDiscSpeed = netplay_settings.m_FastDiscSpeed;
|
|
|
|
StartUp.bMMU = netplay_settings.m_MMU;
|
|
|
|
StartUp.bFastmem = netplay_settings.m_Fastmem;
|
|
|
|
StartUp.bHLE_BS2 = netplay_settings.m_SkipIPL;
|
2018-12-17 18:20:47 -05:00
|
|
|
StartUp.m_bt_passthrough_enabled = false;
|
NetPlay host input authority mode
Currently, each player buffers their own inputs and sends them to the
host. The host then relays those inputs to everyone else. Every player
waits on inputs from all players to be buffered before continuing. What
this means is all clients run in lockstep, and the total latency of
inputs cannot be lower than the sum of the 2 highest client ping times
in the game (in 3+ player sessions with people across the world, the
latency can be very high).
Host input authority mode changes it so players no longer buffer their
own inputs, and only send them to the host. The host stores only the
most recent input received from a player. The host then sends inputs
for all pads at the SI poll interval, similar to the existing code. If
a player sends inputs to slowly, their last received input is simply
sent again. If they send too quickly, inputs are dropped. This means
that the host has full control over what inputs are actually read by
the game, hence the name of the mode. Also, because the rate at which
inputs are received by SI is decoupled from the rate at which players
are sending inputs, clients are no longer dependent on each other. They
only care what the host is doing. This means that they can set their
buffer individually based on their latency to the host, rather than the
highest latency between any 2 players, allowing someone with lower ping
to the host to have less latency than someone else.
This is a catch to this: as a necessity of how the host's input sending
works, the host has 0 latency. There isn't a good way to fix this, as
input delay is now solely dependent on the real latency to the host's
server. Having differing latency between players would be considered
unfair for competitive play, but for casual play we don't really care.
For this reason though, combined with the potential for a few inputs to
be dropped on a bad connection, the old mode will remain and this new
mode is entirely optional.
2018-08-24 04:17:18 -04:00
|
|
|
if (netplay_settings.m_HostInputAuthority && !netplay_settings.m_IsHosting)
|
|
|
|
config_cache.bSetEmulationSpeed = true;
|
2013-07-19 18:48:27 -04:00
|
|
|
}
|
2015-06-14 13:59:41 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_SRAM_netplay_initialized = false;
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2019-06-30 12:44:38 +02:00
|
|
|
// Override out-of-region languages/countries to prevent games from crashing or behaving oddly
|
2019-06-30 11:48:49 +02:00
|
|
|
if (!StartUp.bOverrideRegionSettings)
|
2015-06-14 17:03:45 +02:00
|
|
|
{
|
2020-12-29 18:10:16 +01:00
|
|
|
StartUp.SelectedLanguage =
|
|
|
|
DiscIO::ToGameCubeLanguage(StartUp.GetLanguageAdjustedForRegion(false, StartUp.m_region));
|
2019-06-30 11:48:49 +02:00
|
|
|
|
|
|
|
if (StartUp.bWii)
|
|
|
|
{
|
|
|
|
const u32 wii_language =
|
|
|
|
static_cast<u32>(StartUp.GetLanguageAdjustedForRegion(true, StartUp.m_region));
|
2020-09-16 12:44:32 +02:00
|
|
|
if (wii_language != Config::Get(Config::SYSCONF_LANGUAGE))
|
|
|
|
Config::SetCurrent(Config::SYSCONF_LANGUAGE, wii_language);
|
2019-06-30 12:44:38 +02:00
|
|
|
|
|
|
|
const u8 country_code = static_cast<u8>(Config::Get(Config::SYSCONF_COUNTRY));
|
|
|
|
if (StartUp.m_region != DiscIO::SysConfCountryToRegion(country_code))
|
|
|
|
{
|
|
|
|
switch (StartUp.m_region)
|
|
|
|
{
|
|
|
|
case DiscIO::Region::NTSC_J:
|
|
|
|
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x01); // Japan
|
|
|
|
break;
|
|
|
|
case DiscIO::Region::NTSC_U:
|
|
|
|
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x31); // United States
|
|
|
|
break;
|
|
|
|
case DiscIO::Region::PAL:
|
|
|
|
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x6c); // Switzerland
|
|
|
|
break;
|
|
|
|
case DiscIO::Region::NTSC_K:
|
|
|
|
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x88); // South Korea
|
|
|
|
break;
|
2019-12-27 19:17:56 +01:00
|
|
|
case DiscIO::Region::Unknown:
|
|
|
|
break;
|
2019-06-30 12:44:38 +02:00
|
|
|
}
|
|
|
|
}
|
2019-06-30 11:48:49 +02:00
|
|
|
}
|
2015-06-14 17:03:45 +02:00
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-12-23 21:53:36 +01:00
|
|
|
// Some NTSC Wii games such as Doc Louis's Punch-Out!! and
|
|
|
|
// 1942 (Virtual Console) crash if the PAL60 option is enabled
|
2020-09-16 12:44:32 +02:00
|
|
|
if (StartUp.bWii && DiscIO::IsNTSC(StartUp.m_region) && Config::Get(Config::SYSCONF_PAL60))
|
2017-08-01 22:37:42 +08:00
|
|
|
Config::SetCurrent(Config::SYSCONF_PAL60, false);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2021-03-18 22:59:59 +01:00
|
|
|
Core::UpdateWantDeterminism(/*initial*/ true);
|
|
|
|
|
2016-09-25 13:45:07 +02:00
|
|
|
if (StartUp.bWii)
|
2020-03-16 13:02:35 +01:00
|
|
|
{
|
2021-03-18 22:59:59 +01:00
|
|
|
Core::InitializeWiiRoot(Core::WantsDeterminism());
|
2021-03-06 19:14:18 +01:00
|
|
|
|
|
|
|
// Ensure any new settings are written to the SYSCONF
|
2021-03-18 22:59:59 +01:00
|
|
|
if (!Core::WantsDeterminism())
|
2021-03-06 19:14:18 +01:00
|
|
|
{
|
|
|
|
Core::BackupWiiSettings();
|
|
|
|
ConfigLoaders::SaveToSYSCONF(Config::LayerType::Meta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ConfigLoaders::SaveToSYSCONF(Config::LayerType::Meta, [](const Config::Location& location) {
|
|
|
|
return Config::GetActiveLayerForConfig(location) >= Config::LayerType::Movie;
|
|
|
|
});
|
|
|
|
}
|
2020-03-16 13:02:35 +01:00
|
|
|
}
|
2016-09-25 13:45:07 +02:00
|
|
|
|
2017-05-27 15:43:40 +02:00
|
|
|
const bool load_ipl = !StartUp.bWii && !StartUp.bHLE_BS2 &&
|
|
|
|
std::holds_alternative<BootParameters::Disc>(boot->parameters);
|
|
|
|
if (load_ipl)
|
2011-02-12 22:31:57 +00:00
|
|
|
{
|
2018-10-03 23:03:22 +10:00
|
|
|
return Core::Init(
|
|
|
|
std::make_unique<BootParameters>(
|
|
|
|
BootParameters::IPL{StartUp.m_region,
|
|
|
|
std::move(std::get<BootParameters::Disc>(boot->parameters))},
|
|
|
|
boot->savestate_path),
|
|
|
|
wsi);
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
2018-10-03 23:03:22 +10:00
|
|
|
return Core::Init(std::move(boot), wsi);
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-01 22:37:42 +08:00
|
|
|
// SYSCONF can be modified during emulation by the user and internally, which makes it
|
|
|
|
// a bad idea to just always overwrite it with the settings from the base layer.
|
|
|
|
//
|
2017-11-19 17:15:50 -08:00
|
|
|
// Conversely, we also shouldn't just accept any changes to SYSCONF, as it may cause
|
2017-08-01 22:37:42 +08:00
|
|
|
// temporary settings (from Movie, Netplay, game INIs, etc.) to stick around.
|
|
|
|
//
|
2017-11-19 17:15:50 -08:00
|
|
|
// To avoid inconveniences in most cases, we accept changes that aren't being overriden by a
|
|
|
|
// non-base layer, and restore only the overriden settings.
|
2017-08-01 22:37:42 +08:00
|
|
|
static void RestoreSYSCONF()
|
|
|
|
{
|
|
|
|
// This layer contains the new SYSCONF settings (including any temporary settings).
|
2017-11-19 17:15:50 -08:00
|
|
|
Config::Layer temp_layer(Config::LayerType::Base);
|
|
|
|
// Use a separate loader so the temp layer doesn't automatically save
|
|
|
|
ConfigLoaders::GenerateBaseConfigLoader()->Load(&temp_layer);
|
|
|
|
|
2017-08-01 22:37:42 +08:00
|
|
|
for (const auto& setting : Config::SYSCONF_SETTINGS)
|
|
|
|
{
|
|
|
|
std::visit(
|
2020-09-20 19:11:20 +02:00
|
|
|
[&](auto* info) {
|
2017-08-01 22:37:42 +08:00
|
|
|
// If this setting was overridden, then we copy the base layer value back to the SYSCONF.
|
|
|
|
// Otherwise we leave the new value in the SYSCONF.
|
2020-09-20 19:11:20 +02:00
|
|
|
if (Config::GetActiveLayerForConfig(*info) == Config::LayerType::Base)
|
|
|
|
Config::SetBase(*info, temp_layer.Get(*info));
|
2017-08-01 22:37:42 +08:00
|
|
|
},
|
|
|
|
setting.config_info);
|
|
|
|
}
|
|
|
|
// Save the SYSCONF.
|
2017-11-19 17:15:50 -08:00
|
|
|
Config::GetLayer(Config::LayerType::Base)->Save();
|
2017-08-01 22:37:42 +08:00
|
|
|
}
|
|
|
|
|
2016-10-07 21:57:07 +02:00
|
|
|
void RestoreConfig()
|
|
|
|
{
|
2021-03-06 19:14:18 +01:00
|
|
|
Core::ShutdownWiiRoot();
|
|
|
|
|
|
|
|
if (!Core::WiiRootIsTemporary())
|
|
|
|
{
|
|
|
|
Core::RestoreWiiSettings(Core::RestoreReason::EmulationEnd);
|
|
|
|
RestoreSYSCONF();
|
|
|
|
}
|
|
|
|
|
2017-05-13 23:34:49 +01:00
|
|
|
Config::ClearCurrentRunLayer();
|
2017-05-13 22:29:55 +01:00
|
|
|
Config::RemoveLayer(Config::LayerType::Movie);
|
|
|
|
Config::RemoveLayer(Config::LayerType::Netplay);
|
|
|
|
Config::RemoveLayer(Config::LayerType::GlobalGame);
|
|
|
|
Config::RemoveLayer(Config::LayerType::LocalGame);
|
2017-03-09 09:47:43 +01:00
|
|
|
SConfig::GetInstance().ResetRunningGameMetadata();
|
2016-10-07 21:57:07 +02:00
|
|
|
config_cache.RestoreConfig(&SConfig::GetInstance());
|
2011-02-12 22:31:57 +00:00
|
|
|
}
|
|
|
|
|
2018-07-19 18:10:37 -04:00
|
|
|
} // namespace BootManager
|