mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-10 01:59:02 +00:00
Boot: Clean up the boot code
* Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
This commit is contained in:
parent
4d2fb9b9ba
commit
22992ae41e
18 changed files with 468 additions and 440 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/Config/Config.h"
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/NetPlayConfigLoader.h"
|
||||
|
@ -222,23 +223,23 @@ static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode)
|
|||
}
|
||||
|
||||
// Boot the ISO or file
|
||||
bool BootCore(const std::string& filename, SConfig::EBootBS2 type)
|
||||
bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
{
|
||||
if (!boot)
|
||||
return false;
|
||||
|
||||
SConfig& StartUp = SConfig::GetInstance();
|
||||
|
||||
StartUp.m_BootType = SConfig::BOOT_ISO;
|
||||
StartUp.m_strFilename = filename;
|
||||
StartUp.bRunCompareClient = false;
|
||||
StartUp.bRunCompareServer = false;
|
||||
|
||||
config_cache.SaveConfig(StartUp);
|
||||
|
||||
// If for example the ISO file is bad we return here
|
||||
if (!StartUp.AutoSetup(type))
|
||||
if (!StartUp.SetPathsAndGameMetadata(*boot))
|
||||
return false;
|
||||
|
||||
// Load game specific settings
|
||||
if (type == SConfig::BOOT_DEFAULT)
|
||||
if (!std::holds_alternative<BootParameters::IPL>(boot->parameters))
|
||||
{
|
||||
std::string game_id = SConfig::GetInstance().GetGameID();
|
||||
u16 revision = SConfig::GetInstance().GetRevision();
|
||||
|
@ -400,15 +401,14 @@ bool BootCore(const std::string& filename, SConfig::EBootBS2 type)
|
|||
if (StartUp.bWii)
|
||||
StartUp.SaveSettingsToSysconf();
|
||||
|
||||
// Run the game
|
||||
// Init the core
|
||||
if (!Core::Init())
|
||||
const bool load_ipl = !StartUp.bWii && !StartUp.bHLE_BS2 &&
|
||||
std::holds_alternative<BootParameters::Disc>(boot->parameters);
|
||||
if (load_ipl)
|
||||
{
|
||||
PanicAlertT("Couldn't init the core.\nCheck your configuration.");
|
||||
return false;
|
||||
return Core::Init(std::make_unique<BootParameters>(BootParameters::IPL{
|
||||
StartUp.m_region, std::move(std::get<BootParameters::Disc>(boot->parameters))}));
|
||||
}
|
||||
|
||||
return true;
|
||||
return Core::Init(std::move(boot));
|
||||
}
|
||||
|
||||
void Stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue