From b4839314448aba0f89a5b8b1aeb2653c486efad0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 30 Aug 2023 17:39:41 +1000 Subject: [PATCH] System: Allow overriding BIOS in boot parameters --- src/core/system.cpp | 9 +++++---- src/core/system.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 9385e534a..97ce95532 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -103,7 +103,7 @@ static bool ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_ static void StallCPU(TickCount ticks); -static bool LoadBIOS(); +static bool LoadBIOS(const std::string& override_bios_path); static void InternalReset(); static void ClearRunningGame(); static void DestroySystem(); @@ -1359,7 +1359,7 @@ bool System::BootSystem(SystemBootParameters parameters) #endif // Load BIOS image. - if (!LoadBIOS()) + if (!LoadBIOS(parameters.override_bios)) { s_state = State::Shutdown; ClearRunningGame(); @@ -2140,9 +2140,10 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di return !sw.HasError(); } -bool System::LoadBIOS() +bool System::LoadBIOS(const std::string& override_bios_path) { - std::optional bios_image(BIOS::GetBIOSImage(s_region)); + std::optional bios_image( + override_bios_path.empty() ? BIOS::GetBIOSImage(s_region) : FileSystem::ReadBinaryFile(override_bios_path.c_str())); if (!bios_image.has_value()) { Host::ReportFormattedErrorAsync("Error", TRANSLATE("System", "Failed to load %s BIOS."), diff --git a/src/core/system.h b/src/core/system.h index e1488b365..06185ce33 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -43,6 +43,7 @@ struct SystemBootParameters std::string filename; std::string save_state; std::string override_exe; + std::string override_bios; std::optional override_fast_boot; std::optional override_fullscreen; std::optional override_start_paused;