Fixes, make sure that an error during reload is visible after the launcher starts.

This commit is contained in:
Christian Speckner 2024-08-23 22:43:18 +02:00
parent 14d2b50edd
commit ee7190851e
5 changed files with 17 additions and 13 deletions

View File

@ -88,10 +88,10 @@ void CartridgeELFWidget::saveArmImage(const FSNode& node)
const size_t sizeWritten = node.write(buffer, size); const size_t sizeWritten = node.write(buffer, size);
if (sizeWritten != size) throw runtime_error("failed to write arm image"); if (sizeWritten != size) throw runtime_error("failed to write arm image");
instance().frameBuffer().showTextMessage("Successfully exported ARM executable image"); instance().frameBuffer().showTextMessage("Successfully exported ARM executable image", MessagePosition::MiddleCenter, true);
} }
catch (...) { catch (...) {
instance().frameBuffer().showTextMessage("Failed to export ARM executable image"); instance().frameBuffer().showTextMessage("Failed to export ARM executable image", MessagePosition::MiddleCenter, true);
} }
} }

View File

@ -461,7 +461,8 @@ void CartridgeELF::parseAndLinkElf()
if (dump) dumpElf(myElfParser, cout); if (dump) dumpElf(myElfParser, cout);
myLinker = make_unique<ElfLinker>(ADDR_TEXT_BASE, ADDR_DATA_BASE, ADDR_RODATA_BASE, myElfParser); myLinker = make_unique<ElfLinker>(ADDR_TEXT_BASE, ADDR_DATA_BASE, ADDR_RODATA_BASE, myElfParser);
if (!mySettings.getBool("dev.thumb.trapfatal")) myLinker->setUndefinedSymbolDefault(0); if (!(mySettings.getBool("dev.settings") && mySettings.getBool("dev.thumb.trapfatal")))
myLinker->setUndefinedSymbolDefault(0);
try { try {
myLinker->link(externalSymbols(SystemType::ntsc)); myLinker->link(externalSymbols(SystemType::ntsc));

View File

@ -1518,14 +1518,15 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::ReloadConsole: case Event::ReloadConsole:
if(pressed && !repeated && !myOSystem.reloadConsole(true))
exitEmulation(true);
return;
case Event::PreviousMultiCartRom: case Event::PreviousMultiCartRom:
if(pressed && !repeated&& !myOSystem.reloadConsole(true)) if(pressed && !repeated) {
exitEmulation(true); const auto reloadError = myOSystem.reloadConsole(event == Event::ReloadConsole);
if (reloadError) {
exitEmulation(true);
myOSystem.frameBuffer().showTextMessage(reloadError.value(), MessagePosition::MiddleCenter, true);
}
}
return; return;

View File

@ -582,11 +582,13 @@ string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystem::reloadConsole(bool nextrom) optional<string> OSystem::reloadConsole(bool nextrom)
{ {
mySettings->setValue("romloadprev", !nextrom); mySettings->setValue("romloadprev", !nextrom);
return createConsole(myRomFile, myRomMD5, false) == EmptyString; const string result = createConsole(myRomFile, myRomMD5, false);
return result == EmptyString ? std::nullopt : optional<string>(result);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -377,7 +377,7 @@ class OSystem
@return True on successful creation, otherwise false @return True on successful creation, otherwise false
*/ */
bool reloadConsole(bool nextrom = true); optional<string> reloadConsole(bool nextrom = true);
/** /**
Creates a new ROM launcher, to select a new ROM to emulate. Creates a new ROM launcher, to select a new ROM to emulate.