From 79f12de480dd6dc66690bda2aee2c7464f08beba Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 15 Jun 2025 01:42:24 +0200 Subject: [PATCH] multi-instance: load firmware from correct instance-specific file (load from original file if not found) --- src/frontend/qt_sdl/EmuInstance.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index deed0f2a..f89359fb 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -1013,28 +1013,35 @@ std::optional EmuInstance::loadFirmware(int type) noexcept return generateFirmware(type); } } - //const string& firmwarepath = type == 1 ? Config::DSiFirmwarePath : Config::FirmwarePath; + string firmwarepath; if (type == 1) firmwarepath = globalCfg.GetString("DSi.FirmwarePath"); else firmwarepath = globalCfg.GetString("DS.FirmwarePath"); - Log(Debug, "SPI firmware: loading from file %s\n", firmwarepath.c_str()); + string fwpath_inst = firmwarepath + instanceFileSuffix(); - FileHandle* file = OpenLocalFile(firmwarepath, Read); + Log(Debug, "Loading firmware from file %s\n", fwpath_inst.c_str()); + FileHandle* file = OpenLocalFile(fwpath_inst, Read); if (!file) { - Log(Error, "SPI firmware: couldn't open firmware file!\n"); - return std::nullopt; + Log(Debug, "Loading firmware from file %s\n", firmwarepath.c_str()); + file = OpenLocalFile(firmwarepath, Read); + if (!file) + { + Log(Error, "Couldn't open firmware file!\n"); + return std::nullopt; + } } + Firmware firmware(file); CloseFile(file); if (!firmware.Buffer()) { - Log(Error, "SPI firmware: couldn't read firmware file!\n"); + Log(Error, "Couldn't read firmware file!\n"); return std::nullopt; }