diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 04de651e0a..57c0e69cbb 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -66,7 +66,7 @@ namespace BizHawk.Client.Common public List Discs { get; set; } = new List(); - public bool DeterministicEmulationRequested { get; set; } + public bool DeterministicEmulationRequested => _parent.Deterministic; public object FetchSettings(Type emulatorType, Type settingsType) => _parent.GetCoreSettings(emulatorType, settingsType); @@ -381,34 +381,21 @@ namespace BizHawk.Client.Common return MakeCore(clps); } - switch (game.System) + var cip = new CoreInventoryParameters(this) { - case "GEN": - nextEmulator = MakeCoreFromCds(game); - break; - case "SAT": - nextEmulator = MakeCoreFromCds(game); - break; - case "PSX": - nextEmulator = MakeCoreFromCds(game); - break; - case "PCFX": - nextEmulator = MakeCoreFromCds(game); - break; - case "PCE": // TODO: this is clearly not used, its set to PCE by code above - case "PCECD": - var core = _config.PreferredCores.TryGetValue("PCECD", out var preferredCore) ? preferredCore : CoreNames.PceHawk; - nextEmulator = core switch + Comm = nextComm, + Game = game, + Discs = { - CoreNames.PceHawk => MakeCoreFromCds(game), - CoreNames.HyperNyma => MakeCoreFromCds(game), - _ => MakeCoreFromCds(game), - }; - break; - default: - nextEmulator = null; - break; - } + new DiscAsset + { + DiscData = disc, + DiscType = new DiscIdentifier(disc).DetectDiscType(), + DiscName = Path.GetFileNameWithoutExtension(path) + } + }, + }; + nextEmulator = MakeCoreFromCoreInventory(cip); return true; } @@ -430,11 +417,11 @@ namespace BizHawk.Client.Common }; } - private IEmulator MakeCoreFromCoreInventory(string systemId, CoreInventoryParameters cip, string forcedCoreGameDb) + private IEmulator MakeCoreFromCoreInventory(CoreInventoryParameters cip) { - _config.PreferredCores.TryGetValue(systemId, out var preferredCore); - var forcedCore = ForcedCoreToCoreName(forcedCoreGameDb); - var cores = CoreInventory.Instance.GetCores(systemId) + _config.PreferredCores.TryGetValue(cip.Game.System, out var preferredCore); + var forcedCore = ForcedCoreToCoreName(cip.Game.ForcedCore); + var cores = CoreInventory.Instance.GetCores(cip.Game.System) .OrderBy(c => { if (c.Name == preferredCore) @@ -445,6 +432,8 @@ namespace BizHawk.Client.Common return (int)c.Priority; }) .ToList(); + if (cores.Count == 0) + throw new InvalidOperationException("No core was found to try on the game"); var exceptions = new List(); foreach (var core in cores) { @@ -457,7 +446,7 @@ namespace BizHawk.Client.Common exceptions.Add(e); } } - throw new AggregateException("No core could load the ROM", exceptions); + throw new AggregateException("No core could load the game", exceptions); } private void LoadOther(string path, CoreComm nextComm, HawkFile file, out IEmulator nextEmulator, out RomGame rom, out GameInfo game, out bool cancel) @@ -539,10 +528,8 @@ namespace BizHawk.Client.Common Game = game } }, - DeterministicEmulationRequested = Deterministic - }; - nextEmulator = MakeCoreFromCoreInventory(game.System, cip, game.ForcedCore); + nextEmulator = MakeCoreFromCoreInventory(cip); } private void LoadPSF(string path, CoreComm nextComm, HawkFile file, out IEmulator nextEmulator, out RomGame rom, out GameInfo game) diff --git a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/HyperNyma.cs b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/HyperNyma.cs index 26dfec084f..f1366d7c5b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/HyperNyma.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/HyperNyma.cs @@ -24,6 +24,7 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE { _hyperNyma = DoInit(game, rom, null, "hyper.wbx", extension, deterministic); } + [CoreConstructor("PCECD", Priority = CorePriority.Low)] public HyperNyma(CoreLoadParameters lp) : base(lp.Comm, "PCE", "PC Engine Controller", lp.Settings, lp.SyncSettings) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/TurboNyma.cs b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/TurboNyma.cs index 4d032bc96f..2920341d28 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/TurboNyma.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/TurboNyma.cs @@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE SettingOverrides["pce.disable_bram_hucard"].Default = "0"; _turboNyma = DoInit(game, rom, null, "turbo.wbx", extension, deterministic); } + [CoreConstructor("PCECD")] public TurboNyma(CoreLoadParameters lp) : base(lp.Comm, "PCE", "PC Engine Controller", lp.Settings, lp.SyncSettings) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs index 16187dd332..297e554694 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs @@ -17,6 +17,7 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX "https://mednafen.github.io/releases/", false, "PC-FX")] public class Tst : NymaCore { + [CoreConstructor("PCFX")] public Tst(CoreLoadParameters lp) : base(lp.Comm, "PCFX", "PC-FX Controller", lp.Settings, lp.SyncSettings) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index b6e8ba520a..a24e9ca4c0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -54,6 +54,7 @@ namespace BizHawk.Emulation.Cores.PCEngine int IVideoLogicalOffsets.ScreenY => Settings.TopLine; + [CoreConstructor("PCECD", Priority = CorePriority.Low)] public PCEngine(CoreLoadParameters lp) { SystemId = "PCECD"; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs index de6e65d756..7592f1b094 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs @@ -20,12 +20,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn public class Saturnus : NymaCore, IRegionable { [CoreConstructor("SAT")] - public Saturnus(CoreComm comm, NymaSettings settings, NymaSyncSettings syncSettings) - : base(comm, "SAT", "Saturn Controller", settings, syncSettings) - { - throw new InvalidOperationException("To load a Saturn game, please load the CUE file and not the BIN file."); - } - public Saturnus(CoreLoadParameters lp) : base(lp.Comm, "SAT", "Saturn Controller", lp.Settings, lp.SyncSettings) {