diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 874b9d2151..00f1773e49 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -54,28 +54,28 @@ namespace BizHawk.Client.Common } // helper methods for the settings events - private object GetCoreSettings() - where T : IEmulator + private TSetting GetCoreSettings() + where TCore : IEmulator { - return GetCoreSettings(typeof(T)); + return (TSetting)GetCoreSettings(typeof(TCore), typeof(TSetting)); } - private object GetCoreSyncSettings() - where T : IEmulator + private TSync GetCoreSyncSettings() + where TCore : IEmulator { - return GetCoreSyncSettings(typeof(T)); + return (TSync)GetCoreSyncSettings(typeof(TCore), typeof(TSync)); } - private object GetCoreSettings(Type t) + private object GetCoreSettings(Type t, Type settingsType) { - var e = new SettingsLoadArgs(t); + var e = new SettingsLoadArgs(t, settingsType); OnLoadSettings?.Invoke(this, e); return e.Settings; } - private object GetCoreSyncSettings(Type t) + private object GetCoreSyncSettings(Type t, Type syncSettingsType) { - var e = new SettingsLoadArgs(t); + var e = new SettingsLoadArgs(t, syncSettingsType); OnLoadSyncSettings?.Invoke(this, e); return e.Settings; } @@ -125,9 +125,11 @@ namespace BizHawk.Client.Common { public object Settings { get; set; } public Type Core { get; } - public SettingsLoadArgs(Type t) + public Type SettingsType { get; } + public SettingsLoadArgs(Type t, Type s) { Core = t; + SettingsType = s; Settings = null; } } @@ -309,16 +311,16 @@ namespace BizHawk.Client.Common game, null, new[] { disc }, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); break; case "SAT": nextEmulator = new Saturnus( nextComm, game, new[] { disc }, - (NymaCore.NymaSettings)GetCoreSettings(), - (NymaCore.NymaSyncSettings)GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ); break; @@ -328,15 +330,15 @@ namespace BizHawk.Client.Common new List { disc }, new List { Path.GetFileNameWithoutExtension(path) }, null, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), DiscHashWarningText(game, discHash) ); break; case "PCFX": nextEmulator = new Tst(nextComm, game, new[] { disc }, - (NymaCore.NymaSettings)GetCoreSettings(), - (NymaCore.NymaSyncSettings)GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic); break; case "PCE": // TODO: this is clearly not used, its set to PCE by code above @@ -348,8 +350,8 @@ namespace BizHawk.Client.Common nextComm, game, disc, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ), // CoreNames.HyperNyma => new HyperNyma( // game, @@ -363,8 +365,8 @@ namespace BizHawk.Client.Common game, new[] { disc }, nextComm, - (NymaCore.NymaSettings) GetCoreSettings(), - (NymaCore.NymaSyncSettings) GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ) }; @@ -409,8 +411,8 @@ namespace BizHawk.Client.Common discs, discNames, null, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), swRomDetails.ToString() ); } @@ -477,7 +479,7 @@ namespace BizHawk.Client.Common var ti83 = new TI83( ti83BiosAsRom.GameInfo, ti83Bios, - GetCoreSettings() + GetCoreSettings() ); ti83.LinkPort.SendFileToCalc(File.OpenRead(path.SubstringBefore('|')), false); nextEmulator = ti83; @@ -503,8 +505,8 @@ namespace BizHawk.Client.Common isXml ? rom.FileData : null, Path.GetDirectoryName(path.SubstringBefore('|')), nextComm, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return; } @@ -545,8 +547,8 @@ namespace BizHawk.Client.Common null, null, nextComm, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return; } @@ -562,8 +564,8 @@ namespace BizHawk.Client.Common nextComm, new[] { rom.FileData }, rom.GameInfo, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return; case "ZXSpectrum": @@ -571,8 +573,8 @@ namespace BizHawk.Client.Common nextComm, new[] { rom.RomData }, new List { rom.GameInfo }, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ); return; @@ -580,9 +582,7 @@ namespace BizHawk.Client.Common nextEmulator = new ChannelF( nextComm, game, - rom.FileData, - GetCoreSettings(), - GetCoreSyncSettings() + rom.FileData ); return; case "AmstradCPC": @@ -590,8 +590,8 @@ namespace BizHawk.Client.Common nextComm, new[] { rom.RomData }, new List { rom.GameInfo }, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return; case "PSX": @@ -600,8 +600,8 @@ namespace BizHawk.Client.Common null, null, rom.FileData, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), "PSX etc." ); return; @@ -609,7 +609,7 @@ namespace BizHawk.Client.Common nextEmulator = new MAME( file.Directory, file.CanonicalName, - GetCoreSyncSettings(), + GetCoreSyncSettings(), out var gameName ); rom.GameInfo.Name = gameName; @@ -633,8 +633,8 @@ namespace BizHawk.Client.Common rom.RomData, rom.FileData, Deterministic, - GetCoreSettings(core.Type), - GetCoreSyncSettings(core.Type), + GetCoreSettings(core.Type, core.SettingsType), + GetCoreSyncSettings(core.Type, core.SyncSettingsType), rom.Extension ); } @@ -652,8 +652,8 @@ namespace BizHawk.Client.Common nextEmulator = new Octoshock( nextComm, psf, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); // total garbage, this @@ -688,8 +688,8 @@ namespace BizHawk.Client.Common leftBytes, right, rightBytes, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); // other stuff todo return true; @@ -702,8 +702,8 @@ namespace BizHawk.Client.Common leftBytes, right, rightBytes, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ); // other stuff todo @@ -724,8 +724,8 @@ namespace BizHawk.Client.Common centerBytes3x, right3x, rightBytes3x, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; case "GB4x": @@ -747,15 +747,15 @@ namespace BizHawk.Client.Common C_Bytes4x, D_4x, D_Bytes4x, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; case "AppleII": nextEmulator = new AppleII( nextComm, xmlGame.Assets.Select(a => a.Value), - (AppleII.Settings) GetCoreSettings() + (AppleII.Settings) GetCoreSettings() ); return true; case "C64": @@ -763,8 +763,8 @@ namespace BizHawk.Client.Common nextComm, xmlGame.Assets.Select(a => a.Value), GameInfo.NullInstance, - (C64.C64Settings) GetCoreSettings(), - (C64.C64SyncSettings) GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; case "ZXSpectrum": @@ -772,8 +772,8 @@ namespace BizHawk.Client.Common nextComm, xmlGame.Assets.Select(kvp => kvp.Value), xmlGame.Assets.Select(kvp => new GameInfo { Name = Path.GetFileNameWithoutExtension(kvp.Key) }).ToList(), - (ZXSpectrum.ZXSpectrumSettings) GetCoreSettings(), - (ZXSpectrum.ZXSpectrumSyncSettings) GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ); return true; @@ -782,8 +782,8 @@ namespace BizHawk.Client.Common nextComm, xmlGame.Assets.Select(kvp => kvp.Value), xmlGame.Assets.Select(kvp => new GameInfo { Name = Path.GetFileNameWithoutExtension(kvp.Key) }).ToList(), - (AmstradCPC.AmstradCPCSettings) GetCoreSettings(), - (AmstradCPC.AmstradCPCSyncSettings) GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; case "PSX": @@ -812,8 +812,8 @@ namespace BizHawk.Client.Common discs, discNames, null, - GetCoreSettings(), - GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), swRomDetails.ToString() ); return true; @@ -823,8 +823,8 @@ namespace BizHawk.Client.Common nextEmulator = new Saturnus( nextComm, game, saturnDiscs, - (NymaCore.NymaSettings)GetCoreSettings(), - (NymaCore.NymaSyncSettings)GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic ); return true; @@ -832,8 +832,8 @@ namespace BizHawk.Client.Common var pcfxDiscs = DiscsFromXml(xmlGame, "PCFX", DiscType.PCFX); if (pcfxDiscs.Count == 0) return false; nextEmulator = new Tst(nextComm, game, pcfxDiscs, - (NymaCore.NymaSettings)GetCoreSettings(), - (NymaCore.NymaSyncSettings)GetCoreSyncSettings(), + GetCoreSettings(), + GetCoreSyncSettings(), Deterministic); return true; case "GEN": @@ -845,8 +845,8 @@ namespace BizHawk.Client.Common game, romBytes, genDiscs, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; case "Game Gear": @@ -860,8 +860,8 @@ namespace BizHawk.Client.Common leftBytesGG, rightGG, rightBytesGG, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; } @@ -881,8 +881,8 @@ namespace BizHawk.Client.Common rom.FileData, Path.GetDirectoryName(path.SubstringBefore('|')), nextComm, - GetCoreSettings(), - GetCoreSyncSettings() + GetCoreSettings(), + GetCoreSyncSettings() ); return true; } diff --git a/src/BizHawk.Client.Common/config/ConfigExtensions.cs b/src/BizHawk.Client.Common/config/ConfigExtensions.cs index 17ba3477ac..e6b4e7e4d2 100644 --- a/src/BizHawk.Client.Common/config/ConfigExtensions.cs +++ b/src/BizHawk.Client.Common/config/ConfigExtensions.cs @@ -6,21 +6,15 @@ namespace BizHawk.Client.Common { public static class ConfigExtensions { - private class TypeNameEncapsulator - { - public object o; - } private static JToken Serialize(object o) { - var tne = new TypeNameEncapsulator { o = o }; - return JToken.FromObject(tne, ConfigService.Serializer)["o"]; + return JToken.FromObject(o, ConfigService.Serializer); } - private static object Deserialize(JToken j) + private static object Deserialize(JToken j, Type type) { - var jne = new JObject(new JProperty("o", j)); try { - return jne.ToObject(ConfigService.Serializer).o; + return j.ToObject(type, ConfigService.Serializer); } catch { @@ -35,22 +29,20 @@ namespace BizHawk.Client.Common /// /// /// null if no settings were saved, or there was an error deserializing - public static object GetCoreSettings(this Config config, Type coreType) + public static object GetCoreSettings(this Config config, Type coreType, Type settingsType) { config.CoreSettings.TryGetValue(coreType.ToString(), out var j); - return Deserialize(j); + return Deserialize(j, settingsType); } /// /// Returns the core settings for a core /// - /// - /// /// null if no settings were saved, or there was an error deserializing - public static object GetCoreSettings(this Config config) + public static TSetting GetCoreSettings(this Config config) where TCore : IEmulator { - return config.GetCoreSettings(typeof(TCore)); + return (TSetting)config.GetCoreSettings(typeof(TCore), typeof(TSetting)); } /// @@ -89,22 +81,20 @@ namespace BizHawk.Client.Common /// /// /// null if no settings were saved, or there was an error deserializing - public static object GetCoreSyncSettings(this Config config, Type coreType) + public static object GetCoreSyncSettings(this Config config, Type coreType, Type syncSettingsType) { config.CoreSyncSettings.TryGetValue(coreType.ToString(), out var j); - return Deserialize(j); + return Deserialize(j, syncSettingsType); } /// /// Returns the core syncsettings for a core /// - /// - /// /// null if no settings were saved, or there was an error deserializing - public static object GetCoreSyncSettings(this Config config) + public static TSync GetCoreSyncSettings(this Config config) where TCore : IEmulator { - return config.GetCoreSyncSettings(typeof(TCore)); + return (TSync)config.GetCoreSyncSettings(typeof(TCore), typeof(TSync)); } /// diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index c214d46796..29081796f4 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -2225,7 +2225,7 @@ namespace BizHawk.Client.EmuHawk } else { - e.Settings = Config.GetCoreSyncSettings(e.Core); + e.Settings = Config.GetCoreSyncSettings(e.Core, e.SettingsType); // Only show this nag if the core actually has sync settings, not all cores do if (e.Settings != null && !_suppressSyncSettingsWarning) @@ -2240,13 +2240,13 @@ namespace BizHawk.Client.EmuHawk } else { - e.Settings = Config.GetCoreSyncSettings(e.Core); + e.Settings = Config.GetCoreSyncSettings(e.Core, e.SettingsType); } } private void CoreSettings(object sender, RomLoader.SettingsLoadArgs e) { - e.Settings = Config.GetCoreSettings(e.Core); + e.Settings = Config.GetCoreSettings(e.Core, e.SettingsType); } /// diff --git a/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs index 331aebb2d1..bc3f85db9b 100644 --- a/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -57,9 +57,9 @@ namespace BizHawk.Client.EmuHawk } else { - _s = (N64Settings)_config.GetCoreSettings() + _s = _config.GetCoreSettings() ?? new N64Settings(); - _ss = (N64SyncSettings)_config.GetCoreSyncSettings() + _ss = _config.GetCoreSyncSettings() ?? new N64SyncSettings(); } diff --git a/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs b/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs index aae64b4fbf..f328456029 100644 --- a/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs @@ -233,7 +233,6 @@ namespace BizHawk.Client.EmuHawk where TSetting : class, new() where TEmulator : IEmulator { - // should we complain if we get a successful object from the config file, but it is the wrong type? object fromCore = null; var settable = new SettingsAdapter(_emulator); if (settable.HasSyncSettings) @@ -242,7 +241,7 @@ namespace BizHawk.Client.EmuHawk } return fromCore as TSetting - ?? _config.GetCoreSyncSettings() as TSetting + ?? _config.GetCoreSyncSettings() ?? new TSetting(); // guaranteed to give sensible defaults } diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index f7aba5113d..972e1f7c16 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME displayName: "Arcade")] public partial class MAME : IEmulator, IVideoProvider, ISoundProvider, ISettable, IStatable, IInputPollable { - public MAME(string dir, string file, object syncSettings, out string gamename) + public MAME(string dir, string file, MAME.SyncSettings syncSettings, out string gamename) { ServiceProvider = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs index 4a8f795746..8b1a32afc4 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Calculators public partial class TI83 : IEmulator, IVideoProvider, IDebuggable, IInputPollable, ISettable { [CoreConstructor("TI83")] - public TI83(GameInfo game, byte[] rom, object settings) + public TI83(GameInfo game, byte[] rom, TI83.TI83Settings settings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs index 32a59ad375..df7cc80efc 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs @@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC isReleased: false)] public partial class AmstradCPC : IRegionable, IDriveLight { - public AmstradCPC(CoreComm comm, IEnumerable files, List game, object settings, object syncSettings) + public AmstradCPC(CoreComm comm, IEnumerable files, List game, AmstradCPCSettings settings, AmstradCPCSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 792e468b48..9c52403f5d 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 isReleased: true)] public sealed partial class C64 : IEmulator, IRegionable, IBoardInfo, IRomInfo { - public C64(CoreComm comm, IEnumerable roms, GameInfo game, object settings, object syncSettings) + public C64(CoreComm comm, IEnumerable roms, GameInfo game, C64Settings settings, C64SyncSettings syncSettings) { PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings()); PutSettings((C64Settings)settings ?? new C64Settings()); diff --git a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs index c9c5a5aacf..e4f27f7063 100644 --- a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs +++ b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public partial class MSX : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IInputPollable, IRegionable, ISettable { [CoreConstructor("MSX")] - public MSX(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) + public MSX(CoreComm comm, GameInfo game, byte[] rom, MSX.MSXSettings settings, MSX.MSXSyncSettings syncSettings) { ServiceProvider = new BasicServiceProvider(this); Settings = (MSXSettings)settings ?? new MSXSettings(); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index e48b6fa737..de6f1e4c5c 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum isReleased: true)] public partial class ZXSpectrum : IRegionable, IDriveLight { - public ZXSpectrum(CoreComm comm, IEnumerable files, List game, object settings, object syncSettings, bool? deterministic) + public ZXSpectrum(CoreComm comm, IEnumerable files, List game, ZXSpectrumSettings settings, ZXSpectrumSyncSettings syncSettings, bool? deterministic) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index 822a92035e..8d176109e5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 IRegionable, ICreateGameDBEntries, ISettable { [CoreConstructor("A26")] - public Atari2600(GameInfo game, byte[] rom, object settings, object syncSettings) + public Atari2600(GameInfo game, byte[] rom, Atari2600.A2600Settings settings, Atari2600.A2600SyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index d2421767a0..0554e1cc10 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } [CoreConstructor("A78")] - public A7800Hawk(CoreComm comm, byte[] rom, object settings, object syncSettings) + public A7800Hawk(CoreComm comm, byte[] rom, A7800Hawk.A7800Settings settings, A7800Hawk.A7800SyncSettings syncSettings) { var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index d90e821754..6acb27a847 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -13,7 +13,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision public sealed partial class ColecoVision : IEmulator, IDebuggable, IInputPollable, ISettable { [CoreConstructor("Coleco")] - public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object syncSettings) + public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, + ColecoSettings settings, + ColecoSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs index 6172cc5fbf..6a0cb384df 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF [ServiceNotApplicable(new[] { typeof(IDriveLight) })] public partial class ChannelF { - public ChannelF(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) + public ChannelF(CoreComm comm, GameInfo game, byte[] rom) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs index ea3b65abdb..9c17d5bda2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs @@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public SerialPort serialport; [CoreConstructor("VEC")] - public VectrexHawk(CoreComm comm, byte[] rom, object settings, object syncSettings) + public VectrexHawk(CoreComm comm, byte[] rom, VectrexHawk.VectrexSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex ppu = new PPU(); serialport = new SerialPort(); - _settings = settings ?? new object(); + _settings = new object(); // TODO: wtf is this _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _controllerDeck = new VectrexHawkControllerDeck(_syncSettings.Port1, _syncSettings.Port2); @@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex ser.Register(audio); ServiceProvider = ser; - _settings = settings ?? new object(); + _settings = new object(); // TODO: wtf is this _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 354df1f947..58bca3315a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Intellivision IBoardInfo, IDebuggable, ISettable { [CoreConstructor("INTV")] - public Intellivision(CoreComm comm, byte[] rom, object settings, object syncSettings) + public Intellivision(CoreComm comm, byte[] rom, Intellivision.IntvSettings settings, Intellivision.IntvSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs index 0b1f604210..4e6ffde4af 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs @@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public bool is_G7400; [CoreConstructor("O2")] - public O2Hawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + public O2Hawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ O2Settings settings, O2SyncSettings syncSettings) { var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index 53d3fb24d6..457f5a20d6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -94,7 +94,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk private static byte[] GBA_override = { 0xFF, 0x00, 0xCD, 0x03, 0x35, 0xAA, 0x31, 0x90, 0x94, 0x00, 0x00, 0x00, 0x00 }; [CoreConstructor(new[] { "GB", "GBC" })] - public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBSettings settings, GBSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index babccb71c7..0ff40e4558 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink displayName: "Gameboy")] [ServiceNotApplicable(new[] { typeof(IDriveLight) })] public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, - ISettable + ISettable { // we want to create two GBHawk instances that we will run concurrently // maybe up to 4 eventually? @@ -30,7 +30,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink public bool do_frame_fill; //[CoreConstructor("GB", "GBC")] - public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) + public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ + GBHawkLink.GBLinkSettings settings, GBHawkLink.GBLinkSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs index bf9cfe2290..2d6c27482a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs @@ -30,7 +30,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x public bool do_frame_fill; //[CoreConstructor("GB", "GBC")] - public GBHawkLink3x(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_C, byte[] rom_C, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) + public GBHawkLink3x(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_C, byte[] rom_C, GameInfo game_R, byte[] rom_R, + /*string gameDbFn,*/ GBHawkLink3x.GBLink3xSettings settings, GBHawkLink3x.GBLink3xSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs index 799247f598..e8b426e4cc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs @@ -51,7 +51,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x public bool do_frame_fill; //[CoreConstructor("GB", "GBC")] - public GBHawkLink4x(CoreComm comm, GameInfo game_A, byte[] rom_A, GameInfo game_B, byte[] rom_B, GameInfo game_C, byte[] rom_C, GameInfo game_D, byte[] rom_D, /*string gameDbFn,*/ object settings, object syncSettings) + public GBHawkLink4x(CoreComm comm, GameInfo game_A, byte[] rom_A, GameInfo game_B, byte[] rom_B, GameInfo game_C, byte[] rom_C, GameInfo game_D, byte[] rom_D, /*string gameDbFn,*/ + GBHawkLink4x.GBLink4xSettings settings, GBHawkLink4x.GBLink4xSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 00763e84dc..61cd1c5346 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy IGameboyCommon, ICycleTiming, ILinkable { [CoreConstructor(new[] { "GB", "GBC" })] - public Gameboy(CoreComm comm, GameInfo game, byte[] file, object settings, object syncSettings, bool deterministic) + public Gameboy(CoreComm comm, GameInfo game, byte[] file, Gameboy.GambatteSettings settings, Gameboy.GambatteSyncSettings syncSettings, bool deterministic) { var ser = new BasicServiceProvider(this); ser.Register(new GBDisassembler()); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index f4dddb15a9..48d1e48a02 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -11,7 +11,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public partial class GambatteLink : IEmulator, IVideoProvider, ISoundProvider, IInputPollable, ISaveRam, IStatable, ILinkable, IBoardInfo, IRomInfo, IDebuggable, ISettable, ICodeDataLogger { - public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, object settings, object syncSettings, bool deterministic) + public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, + GambatteLink.GambatteLinkSettings settings, GambatteLink.GambatteLinkSyncSettings syncSettings, bool deterministic) { ServiceProvider = new BasicServiceProvider(this); GambatteLinkSettings linkSettings = (GambatteLinkSettings)settings ?? new GambatteLinkSettings(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 0fed3286f6..ebb2d5f82d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 /// Rom that should be loaded /// N64SyncSettings object [CoreConstructor("N64")] - public N64(GameInfo game, byte[] file, object settings, object syncSettings) + public N64(GameInfo game, byte[] file, N64Settings settings, N64SyncSettings syncSettings) { ServiceProvider = new BasicServiceProvider(this); InputCallbacks = new InputCallbackSystem(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index c9a28abdd8..289235a388 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -78,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS private static extern void FrameAdvance(uint buttons, byte touchX, byte touchY); [CoreConstructor("NDS")] - public MelonDS(byte[] file, CoreComm comm, object settings, object syncSettings) + public MelonDS(byte[] file, CoreComm comm, MelonSettings settings, MelonSyncSettings syncSettings) { _serviceProvider = new BasicServiceProvider(this); ControllerDefinition = new ControllerDefinition { Name = "NDS Controller" }; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 80b56fea45..36db961482 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES IBoardInfo, IRomInfo, ISettable, ICodeDataLogger { [CoreConstructor("NES")] - public NES(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) + public NES(CoreComm comm, GameInfo game, byte[] rom, NESSettings settings, NESSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 5119166544..e24dd86f21 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES } [CoreConstructor("NES")] - public QuickNES(byte[] file, object settings, object syncSettings) + public QuickNES(byte[] file, QuickNESSettings settings, QuickNESSyncSettings syncSettings) { FP = OSTailoredCode.IsUnixHost ? (IFPCtrl) new Unix_FPCtrl() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 9f45c879e2..e393adaf2a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -29,7 +29,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public unsafe partial class LibsnesCore : IEmulator, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ICodeDataLogger, IDebuggable, ISettable { - public LibsnesCore(GameInfo game, byte[] romData, byte[] xmlData, string baseRomPath, CoreComm comm, object settings, object syncSettings) + public LibsnesCore(GameInfo game, byte[] romData, byte[] xmlData, string baseRomPath, CoreComm comm, + LibsnesCore.SnesSettings settings, LibsnesCore.SnesSyncSettings syncSettings) { _baseRomPath = baseRomPath; var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs index 9e8b608ab8..b3a9b8f5b0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk ISettable, IDebuggable { [CoreConstructor(new[] { "GB", "GBC" })] - public SubGBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + public SubGBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBHawk.GBHawk.GBSettings settings, GBHawk.GBHawk.GBSyncSettings syncSettings) { var subGBSettings = (GBHawk.GBHawk.GBSettings)settings ?? new GBHawk.GBHawk.GBSettings(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs index 47cc65a251..ad48699185 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk ISettable { [CoreConstructor("NES")] - public SubNESHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + public SubNESHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ NES.NES.NESSettings settings, NES.NES.NESSyncSettings syncSettings) { var subNesSettings = (NES.NES.NESSettings)settings ?? new NES.NES.NESSettings(); var subNesSyncSettings = (NES.NES.NESSyncSettings)syncSettings ?? new NES.NES.NESSyncSettings(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 081e5fcdd1..e8b11bda46 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.PCEngine IPceGpuView { [CoreConstructor(new[] { "PCE", "SGX" })] - public PCEngine(GameInfo game, byte[] rom, object settings, object syncSettings) + public PCEngine(GameInfo game, byte[] rom, PCEngine.PCESettings settings, PCEngine.PCESyncSettings syncSettings) { switch (game.System) { @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.PCEngine int IVideoLogicalOffsets.ScreenY => Settings.TopLine; - public PCEngine(CoreComm comm, GameInfo game, Disc disc, object settings, object syncSettings) + public PCEngine(CoreComm comm, GameInfo game, Disc disc, PCESettings settings, PCESyncSettings syncSettings) { SystemId = "PCECD"; Type = NecSystemType.TurboCD; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs index 1848bda5c9..e808f38342 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink displayName: "Game Gear")] [ServiceNotApplicable(new[] { typeof(IDriveLight) })] public partial class GGHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, - ISettable + ISettable { // we want to create two GG instances that we will run concurrently public SMS L; @@ -25,7 +25,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink private bool do_r_next = false; - public GGHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) + public GGHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ + GGLinkSettings settings, GGLinkSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index 7812b079ee..bbbd37e66c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem IDebuggable, ISettable, ICodeDataLogger { [CoreConstructor(new[] { "SMS", "SG", "GG" })] - public SMS(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) + public SMS(CoreComm comm, GameInfo game, byte[] rom, SmsSettings settings, SmsSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs index 9ce7fb5ee7..a671ec7438 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs @@ -24,12 +24,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx IInputPollable, IDebuggable, IDriveLight, ICodeDataLogger, IDisassemblable { [CoreConstructor("GEN")] - public GPGX(CoreComm comm, GameInfo game, byte[] file, object settings, object syncSettings) + public GPGX(CoreComm comm, GameInfo game, byte[] file, GPGXSettings settings, GPGXSyncSettings syncSettings) : this(comm, game, file, null, settings, syncSettings) { } - public GPGX(CoreComm comm, GameInfo game, byte[] rom, IEnumerable cds, object settings, object syncSettings) + public GPGX(CoreComm comm, GameInfo game, byte[] rom, IEnumerable cds, GPGXSettings settings, GPGXSyncSettings syncSettings) { LoadCallback = new LibGPGX.load_archive_cb(load_archive); _inputCallback = new LibGPGX.input_cb(input_callback); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 76ae3ba85e..71c52069d9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX isReleased: true)] public unsafe partial class Octoshock : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IStatable, IDriveLight, ISettable, IRegionable, IInputPollable, IRomInfo { - public Octoshock(CoreComm comm, PSF psf, object settings, object syncSettings) + public Octoshock(CoreComm comm, PSF psf, Octoshock.Settings settings, Octoshock.SyncSettings syncSettings) { string romDetails = "It's a PSF, what do you want. Oh, tags maybe?"; Load(comm, null, null, null, settings, syncSettings, psf, romDetails); @@ -44,13 +44,13 @@ namespace BizHawk.Emulation.Cores.Sony.PSX //note: its annoying that we have to have a disc before constructing this. //might want to change that later. HOWEVER - we need to definitely have a region, at least - public Octoshock(CoreComm comm, List discs, List discNames, byte[] exe, object settings, object syncSettings, string romDetails) + public Octoshock(CoreComm comm, List discs, List discNames, byte[] exe, Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, string romDetails) { Load(comm, discs, discNames, exe, settings, syncSettings, null, romDetails); OctoshockDll.shock_PowerOn(psx); } - void Load(CoreComm comm, List discs, List discNames, byte[] exe, object settings, object syncSettings, PSF psf, string romDetails) + void Load(CoreComm comm, List discs, List discNames, byte[] exe, Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, PSF psf, string romDetails) { RomDetails = romDetails; ConnectTracer(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 1907e69dbd..84526eb571 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan IInputPollable, IDebuggable { [CoreConstructor("WSWAN")] - public WonderSwan(byte[] file, bool deterministic, object settings, object syncSettings) + public WonderSwan(byte[] file, bool deterministic, WonderSwan.Settings settings, WonderSwan.SyncSettings syncSettings) { ServiceProvider = new BasicServiceProvider(this); _settings = (Settings)settings ?? new Settings(); diff --git a/src/BizHawk.Emulation.Cores/CoreInventory.cs b/src/BizHawk.Emulation.Cores/CoreInventory.cs index db1e4a8562..26dbd7c42c 100644 --- a/src/BizHawk.Emulation.Cores/CoreInventory.cs +++ b/src/BizHawk.Emulation.Cores/CoreInventory.cs @@ -48,11 +48,18 @@ namespace BizHawk.Emulation.Cores { throw new InvalidOperationException($"Unexpected parameter name {p.Name} in constructor for {Type}"); } - - // disabling the type check here doesn't really hurt anything, because the Invoke call will still catch any forbidden casts - // it does allow us to write "MySettingsType settings" instead of "object settings" - // if (expectedType != p.ParameterType) - // throw new InvalidOperationException($"Unexpected type mismatch in parameter {p.Name} in constructor for {Type}"); + if (pName == "settings") + { + if (p.ParameterType == typeof(object)) + throw new InvalidOperationException($"Setting and SyncSetting constructor parameters for {type} must be annotated with the actual type"); + SettingsType = p.ParameterType; + } + else if (pName == "syncsettings") + { + if (p.ParameterType == typeof(object)) + throw new InvalidOperationException($"Setting and SyncSetting constructor parameters for {type} must be annotated with the actual type"); + SyncSettingsType = p.ParameterType; + } _paramMap.Add(pName, i); } } @@ -60,6 +67,8 @@ namespace BizHawk.Emulation.Cores public string Name { get; } public Type Type { get; } public ConstructorInfo CTor { get; } + public Type SettingsType { get; } = typeof(object); + public Type SyncSettingsType { get; } = typeof(object); private void Bp(object[] parameters, string name, object value) {