NES: Fixed loading NES roms (+ improved behavior/error message display when this happens)

This commit is contained in:
Sour 2023-03-06 16:42:32 -05:00
parent 051dfadd76
commit a5fa24a32e
4 changed files with 18 additions and 2 deletions

View file

@ -53,7 +53,7 @@ void EmuSettings::Serialize(Serializer& s)
SV(_nes.DisableOamAddrBug); SV(_nes.DisablePaletteRead); SV(_nes.DisablePpu2004Reads);
SV(_nes.DisableGameGenieBusConflicts); SV(_nes.DisablePpuReset); SV(_nes.EnableOamDecay);
SV(_nes.EnablePpu2000ScrollGlitch); SV(_nes.EnablePpu2006ScrollGlitch); SV(_nes.EnablePpuOamRowCorruption);
SV(_nes.RestrictPpuAccessOnFirstFrame); SV(_nes.DisableGameGenieBusConflicts);
SV(_nes.RestrictPpuAccessOnFirstFrame);
SV(_nes.PpuExtraScanlinesAfterNmi); SV(_nes.PpuExtraScanlinesBeforeNmi);
SV(_nes.Region);
SV(_nes.LightDetectionRadius);

View file

@ -346,6 +346,20 @@ void Emulator::PowerCycle()
}
bool Emulator::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom, bool forPowerCycle)
{
try {
return InternalLoadRom(romFile, patchFile, stopRom, forPowerCycle);
} catch(std::exception& ex) {
_videoDecoder->StartThread();
_videoRenderer->StartThread();
MessageManager::DisplayMessage("Error", "UnexpectedError", ex.what());
Stop(false, true, false);
return false;
}
}
bool Emulator::InternalLoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom, bool forPowerCycle)
{
if(!romFile.IsValid()) {
MessageManager::DisplayMessage("Error", "CouldNotLoadFile", romFile.GetFileName());

View file

@ -131,7 +131,8 @@ private:
template<typename T> void TryLoadRom(VirtualFile& romFile, LoadRomResult& result, unique_ptr<IConsole>& console);
void InitConsole(unique_ptr<IConsole>& newConsole, ConsoleMemoryInfo originalConsoleMemory[], bool preserveRom);
bool InternalLoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom = true, bool forPowerCycle = false);
public:
Emulator();

View file

@ -73,6 +73,7 @@ std::unordered_map<string, string> MessageManager::_enResources = {
{ "SoundRecorderStarted", u8"Recording to: %1" },
{ "SoundRecorderStopped", u8"Recording saved to: %1" },
{ "TestFileSavedTo", u8"Test file saved to: %1" },
{ "UnexpectedError", u8"Unexpected error: %1" },
{ "UnsupportedMapper", u8"Unsupported mapper (%1), cannot load game." },
{ "VideoRecorderStarted", u8"Recording to: %1" },
{ "VideoRecorderStopped", u8"Recording saved to: %1" },