diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 8bbfd4b996..8371edc70c 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -129,7 +129,7 @@ namespace BizHawk.Client.Common return false; } - public bool LoadRom(string path, CoreComm nextComm) + public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = false) // forceAccurateCore is currently just for Quicknes vs Neshawk but could be used for other situations { if (path == null) { @@ -339,7 +339,7 @@ namespace BizHawk.Client.Common nextEmulator = new TI83(nextComm, game, rom.RomData); break; case "NES": - if (!Global.Config.NES_InQuickNES) + if (!Global.Config.NES_InQuickNES || forceAccurateCore) { nextEmulator = new NES( nextComm, @@ -431,8 +431,21 @@ namespace BizHawk.Client.Common { string system = null; if (game != null) + { system = game.System; - ThrowLoadError("A core accepted the rom, but throw an exception while loading it:\n\n" + ex, system); + } + + // Specific hack here, as we get more cores of the same system, this isn't scalable + if (ex is LibQuickNES.UnsupportedMapperException) + { + LoadRom(path, nextComm, forceAccurateCore: true); + return true; + } + else + { + ThrowLoadError("A core accepted the rom, but throw an exception while loading it:\n\n" + ex, system); + } + return false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs index c518cb8081..9161a2c075 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs @@ -224,6 +224,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr qn_get_mapper(IntPtr e, ref int number); + public class UnsupportedMapperException : InvalidOperationException + { + public UnsupportedMapperException(string message) + : base(message) + { + + } + } + /// /// handle "string error" as returned by some quicknes functions /// @@ -233,7 +242,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES if (p == IntPtr.Zero) return; string s = Marshal.PtrToStringAnsi(p); - throw new InvalidOperationException("LibQuickNES error: " + s); + if (s == "Unsupported mapper") + { + throw new UnsupportedMapperException("Quicknes unsupported mapper"); + } + else + { + throw new InvalidOperationException("LibQuickNES error: " + s); + } } } }