System: Allow overriding BIOS in boot parameters

This commit is contained in:
Stenzek 2023-08-30 17:39:41 +10:00
parent 15af10e82a
commit b483931444
2 changed files with 6 additions and 4 deletions

View file

@ -103,7 +103,7 @@ static bool ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_
static void StallCPU(TickCount ticks); static void StallCPU(TickCount ticks);
static bool LoadBIOS(); static bool LoadBIOS(const std::string& override_bios_path);
static void InternalReset(); static void InternalReset();
static void ClearRunningGame(); static void ClearRunningGame();
static void DestroySystem(); static void DestroySystem();
@ -1359,7 +1359,7 @@ bool System::BootSystem(SystemBootParameters parameters)
#endif #endif
// Load BIOS image. // Load BIOS image.
if (!LoadBIOS()) if (!LoadBIOS(parameters.override_bios))
{ {
s_state = State::Shutdown; s_state = State::Shutdown;
ClearRunningGame(); ClearRunningGame();
@ -2140,9 +2140,10 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
return !sw.HasError(); return !sw.HasError();
} }
bool System::LoadBIOS() bool System::LoadBIOS(const std::string& override_bios_path)
{ {
std::optional<BIOS::Image> bios_image(BIOS::GetBIOSImage(s_region)); std::optional<BIOS::Image> bios_image(
override_bios_path.empty() ? BIOS::GetBIOSImage(s_region) : FileSystem::ReadBinaryFile(override_bios_path.c_str()));
if (!bios_image.has_value()) if (!bios_image.has_value())
{ {
Host::ReportFormattedErrorAsync("Error", TRANSLATE("System", "Failed to load %s BIOS."), Host::ReportFormattedErrorAsync("Error", TRANSLATE("System", "Failed to load %s BIOS."),

View file

@ -43,6 +43,7 @@ struct SystemBootParameters
std::string filename; std::string filename;
std::string save_state; std::string save_state;
std::string override_exe; std::string override_exe;
std::string override_bios;
std::optional<bool> override_fast_boot; std::optional<bool> override_fast_boot;
std::optional<bool> override_fullscreen; std::optional<bool> override_fullscreen;
std::optional<bool> override_start_paused; std::optional<bool> override_start_paused;