Skip to content

Commit

Permalink
Fixes, make sure that an error during reload is visible after the lau…
Browse files Browse the repository at this point in the history
…ncher starts.
  • Loading branch information
DirtyHairy committed Aug 23, 2024
1 parent 14d2b50 commit ee71908
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/debugger/gui/CartELFWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ void CartridgeELFWidget::saveArmImage(const FSNode& node)
const size_t sizeWritten = node.write(buffer, size);
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 (...) {
instance().frameBuffer().showTextMessage("Failed to export ARM executable image");
instance().frameBuffer().showTextMessage("Failed to export ARM executable image", MessagePosition::MiddleCenter, true);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/emucore/CartELF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ void CartridgeELF::parseAndLinkElf()
if (dump) dumpElf(myElfParser, cout);

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 {
myLinker->link(externalSymbols(SystemType::ntsc));
Expand Down
15 changes: 8 additions & 7 deletions src/emucore/EventHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1518,14 +1518,15 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return;

case Event::ReloadConsole:
if(pressed && !repeated && !myOSystem.reloadConsole(true))
exitEmulation(true);

return;

case Event::PreviousMultiCartRom:
if(pressed && !repeated&& !myOSystem.reloadConsole(true))
exitEmulation(true);
if(pressed && !repeated) {
const auto reloadError = myOSystem.reloadConsole(event == Event::ReloadConsole);

if (reloadError) {
exitEmulation(true);
myOSystem.frameBuffer().showTextMessage(reloadError.value(), MessagePosition::MiddleCenter, true);
}
}

return;

Expand Down
6 changes: 4 additions & 2 deletions src/emucore/OSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

return createConsole(myRomFile, myRomMD5, false) == EmptyString;
const string result = createConsole(myRomFile, myRomMD5, false);

return result == EmptyString ? std::nullopt : optional<string>(result);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion src/emucore/OSystem.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class OSystem
@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.
Expand Down

0 comments on commit ee71908

Please sign in to comment.