From a64017366c4cd64ea711c73c3479728609d50798 Mon Sep 17 00:00:00 2001 From: jlennox Date: Sun, 19 Oct 2014 01:22:47 +0000 Subject: [PATCH] Create ISettable/ISettable interfaces. This checkin has not been extensively tested. --- BizHawk.Client.Common/PathManager.cs | 2 +- .../lua/EmuLuaLibrary.Emu.cs | 55 +-- .../lua/EmuLuaLibrary.NES.cs | 78 ++-- .../lua/EmuLuaLibrary.SNES.cs | 59 +-- .../conversions/MovieConversionExtensions.cs | 6 +- .../Extensions/CoreExtensions.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.Events.cs | 69 ++-- BizHawk.Client.EmuHawk/MainForm.cs | 342 +++++++++--------- .../config/GB/CGBColorChooserForm.cs | 7 +- .../config/GB/ColorChooserForm.cs | 5 +- BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs | 7 +- BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs | 9 +- .../config/GenericCoreConfig.cs | 18 +- .../config/N64/N64ControllersSetup.cs | 7 +- .../config/N64/N64VideoPluginconfig.cs | 4 +- .../config/N64/NewN64PluginSettings.cs | 4 +- .../config/NES/NESSoundConfig.cs | 16 +- .../config/NES/NESSyncSettingsForm.cs | 2 +- .../config/NES/NesControllerSettings.cs | 2 +- .../config/NES/QuickNesConfig.cs | 2 +- .../config/PCE/PCEControllerConfig.cs | 4 +- .../config/PCE/PCEGraphicsConfig.cs | 7 +- .../config/ProfileConfig.cs | 6 +- .../config/SMS/SMSGraphicsConfig.cs | 4 +- .../config/SNES/SNESOptions.cs | 4 +- .../config/TI83/TI83PaletteConfig.cs | 7 +- .../tools/SNES/SNESGraphicsDebugger.cs | 9 +- .../tools/VirtualPads/schema/N64Schema.cs | 2 +- .../tools/VirtualPads/schema/NesSchema.cs | 2 +- .../Base Implementations/NullEmulator.cs | 5 - .../Interfaces/IEmulator.cs | 51 +-- BizHawk.Emulation.Cores/Calculator/TI83.cs | 19 +- .../Computers/Commodore64/C64.Core.cs | 2 +- .../Computers/Commodore64/C64.cs | 7 +- .../Consoles/Atari/2600/Atari2600.Settings.cs | 40 +- .../Consoles/Atari/2600/Atari2600.cs | 2 +- .../Consoles/Atari/7800/Atari7800.cs | 7 +- .../Consoles/Atari/lynx/Lynx.cs | 25 -- .../Consoles/Coleco/ColecoVision.cs | 21 +- .../Consoles/Intellivision/Intellivision.cs | 5 - .../Consoles/Nintendo/GBA/Meteor.cs | 7 +- .../Consoles/Nintendo/GBA/VBANext.cs | 32 +- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 40 +- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 45 ++- .../Consoles/Nintendo/N64/N64.cs | 35 +- .../Consoles/Nintendo/NES/NES.cs | 40 +- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 35 +- .../Consoles/Nintendo/SNES/LibsnesCore.cs | 41 ++- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 24 -- .../Consoles/PC Engine/PCEngine.cs | 43 ++- .../Consoles/Sega/Genesis/Genesis.cs | 15 +- .../Consoles/Sega/SMS/SMS.cs | 109 +++--- .../Consoles/Sega/Saturn/Yabause.cs | 32 +- .../Consoles/Sega/gpgx/GPGX.cs | 41 ++- .../Consoles/Sony/PSP/PSP.cs | 5 - .../Consoles/Sony/PSX/Octoshock.cs | 5 - .../Consoles/WonderSwan/WonderSwan.cs | 38 +- BizHawk.Emulation.Cores/LibRetroEmulator.cs | 5 - 58 files changed, 876 insertions(+), 641 deletions(-) diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index 366c04a3fe..5a6cb39545 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -306,7 +306,7 @@ namespace BizHawk.Client.Common // Bsnes profiles have incompatible savestates so save the profile name if (Global.Emulator is LibsnesCore) { - name += "." + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile; + name += "." + (Global.Emulator as LibsnesCore).GetSyncSettings().Profile; } if (Global.MovieSession.Movie.IsActive) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 734612d822..a1f8b73725 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -64,14 +64,14 @@ namespace BizHawk.Client.Common { try { - var debuggable = Global.Emulator as IDebuggable; - if (debuggable == null) - throw new NotImplementedException(); + var debuggable = Global.Emulator as IDebuggable; + if (debuggable == null) + throw new NotImplementedException(); - var registers = debuggable.GetCpuFlagsAndRegisters(); - return registers.ContainsKey(name) - ? registers[name] - : 0; + var registers = debuggable.GetCpuFlagsAndRegisters(); + return registers.ContainsKey(name) + ? registers[name] + : 0; } catch (NotImplementedException) { @@ -93,11 +93,11 @@ namespace BizHawk.Client.Common try { - var debuggable = Global.Emulator as IDebuggable; - if (debuggable == null) - throw new NotImplementedException(); + var debuggable = Global.Emulator as IDebuggable; + if (debuggable == null) + throw new NotImplementedException(); - foreach (var kvp in debuggable.GetCpuFlagsAndRegisters()) + foreach (var kvp in debuggable.GetCpuFlagsAndRegisters()) { table[kvp.Key] = kvp.Value; } @@ -120,11 +120,11 @@ namespace BizHawk.Client.Common { try { - var debuggable = Global.Emulator as IDebuggable; - if (debuggable == null) - throw new NotImplementedException(); + var debuggable = Global.Emulator as IDebuggable; + if (debuggable == null) + throw new NotImplementedException(); - debuggable.SetCpuRegister(register, value); + debuggable.SetCpuRegister(register, value); } catch (NotImplementedException) { @@ -189,25 +189,28 @@ namespace BizHawk.Client.Common { // in the future, we could do something more arbitrary here. // but this isn't any worse than the old system - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var nes = Global.Emulator as NES; + var s = nes.GetSettings(); s.DispSprites = (bool)luaParam[0]; s.DispBackground = (bool)luaParam[1]; - Global.Emulator.PutSettings(s); + nes.PutSettings(s); } else if (Global.Emulator is QuickNES) { - var s = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); + var quicknes = Global.Emulator as QuickNES; + var s = quicknes.GetSettings(); // this core doesn't support disabling BG bool showsp = GetSetting(0, luaParam); if (showsp && s.NumSprites == 0) s.NumSprites = 8; else if (!showsp && s.NumSprites > 0) s.NumSprites = 0; - Global.Emulator.PutSettings(s); + quicknes.PutSettings(s); } else if (Global.Emulator is PCEngine) { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var pce = Global.Emulator as PCEngine; + var s = pce.GetSettings(); s.ShowOBJ1 = GetSetting(0, luaParam); s.ShowBG1 = GetSetting(1, luaParam); if (luaParam.Length > 2) @@ -216,22 +219,24 @@ namespace BizHawk.Client.Common s.ShowBG2 = GetSetting(3, luaParam); } - Global.Emulator.PutSettings(s); + pce.PutSettings(s); } else if (Global.Emulator is SMS) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var sms = Global.Emulator as SMS; + var s = sms.GetSettings(); s.DispOBJ = GetSetting(0, luaParam); s.DispBG = GetSetting(1, luaParam); - Global.Emulator.PutSettings(s); + sms.PutSettings(s); } else if (Global.Emulator is WonderSwan) { - var s = (WonderSwan.Settings)Global.Emulator.GetSettings(); + var ws = Global.Emulator as WonderSwan; + var s = ws.GetSettings(); s.EnableSprites = GetSetting(0, luaParam); s.EnableFG = GetSetting(1, luaParam); s.EnableBG = GetSetting(2, luaParam); - Global.Emulator.PutSettings(s); + ws.PutSettings(s); } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs index 6f4cd43b7a..9af571ed53 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs @@ -48,18 +48,21 @@ namespace BizHawk.Client.Common } } + private static QuickNES AsQuickNES { get { return Global.Emulator as QuickNES; } } + private static NES AsNES { get { return Global.Emulator as NES; } } + [LuaMethodAttributes( "getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value" )] public static bool GetAllowMoreThanEightSprites() { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { - return ((QuickNES.QuickNESSettings)Global.Emulator.GetSettings()).NumSprites != 8; + return AsQuickNES.GetSettings().NumSprites != 8; } - return ((NES.NESSettings)Global.Emulator.GetSettings()).AllowMoreThanEightSprites; + return AsNES.GetSettings().AllowMoreThanEightSprites; } [LuaMethodAttributes( @@ -68,17 +71,14 @@ namespace BizHawk.Client.Common )] public static int GetBottomScanline(bool pal = false) { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { - return ((QuickNES.QuickNESSettings)Global.Emulator.GetSettings()).ClipTopAndBottom ? 231 : 239; + return AsQuickNES.GetSettings().ClipTopAndBottom ? 231 : 239; } - if (pal) - { - return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_BottomLine; - } - - return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_BottomLine; + return pal + ? AsNES.GetSettings().PAL_BottomLine + : AsNES.GetSettings().NTSC_BottomLine; } [LuaMethodAttributes( @@ -87,12 +87,12 @@ namespace BizHawk.Client.Common )] public static bool GetClipLeftAndRight() { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { - return ((QuickNES.QuickNESSettings)Global.Emulator.GetSettings()).ClipLeftAndRight; + return AsQuickNES.GetSettings().ClipLeftAndRight; } - return ((NES.NESSettings)Global.Emulator.GetSettings()).ClipLeftAndRight; + return AsNES.GetSettings().ClipLeftAndRight; } [LuaMethodAttributes( @@ -101,12 +101,12 @@ namespace BizHawk.Client.Common )] public static bool GetDisplayBackground() { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { return true; } - return ((NES.NESSettings)Global.Emulator.GetSettings()).DispBackground; + return AsNES.GetSettings().DispBackground; } [LuaMethodAttributes( @@ -115,12 +115,12 @@ namespace BizHawk.Client.Common )] public static bool GetDisplaySprites() { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { return true; } - return ((NES.NESSettings)Global.Emulator.GetSettings()).DispSprites; + return AsNES.GetSettings().DispSprites; } [LuaMethodAttributes( @@ -129,17 +129,14 @@ namespace BizHawk.Client.Common )] public static int GetTopScanline(bool pal = false) { - if (Global.Config.NES_InQuickNES) + if (AsQuickNES != null) { - return ((QuickNES.QuickNESSettings)Global.Emulator.GetSettings()).ClipTopAndBottom ? 8 : 0; + return AsQuickNES.GetSettings().ClipTopAndBottom ? 8 : 0; } - if (pal) - { - return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_TopLine; - } - - return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_TopLine; + return pal + ? AsNES.GetSettings().PAL_TopLine + : AsNES.GetSettings().NTSC_TopLine; } [LuaMethodAttributes( @@ -164,15 +161,15 @@ namespace BizHawk.Client.Common { if (Global.Emulator is NES) { - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var s = AsNES.GetSettings(); s.AllowMoreThanEightSprites = allow; - Global.Emulator.PutSettings(s); + AsNES.PutSettings(s); } else if (Global.Emulator is QuickNES) { - var s = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); + var s = AsQuickNES.GetSettings(); s.NumSprites = allow ? 64 : 8; - Global.Emulator.PutSettings(s); + AsQuickNES.PutSettings(s); } } @@ -185,16 +182,15 @@ namespace BizHawk.Client.Common { if (Global.Emulator is NES) { - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var s = AsNES.GetSettings(); s.ClipLeftAndRight = leftandright; - Global.Emulator.PutSettings(s); + AsNES.PutSettings(s); } else if (Global.Emulator is QuickNES) { - var s = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); + var s = AsQuickNES.GetSettings(); s.ClipLeftAndRight = leftandright; - Global.Emulator.PutSettings(s); - + AsQuickNES.PutSettings(s); } } @@ -206,9 +202,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is NES) { - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var s = AsNES.GetSettings(); s.DispBackground = show; - Global.Emulator.PutSettings(s); + AsNES.PutSettings(s); } } @@ -220,9 +216,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is NES) { - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var s = AsNES.GetSettings(); s.DispSprites = show; - Global.Emulator.PutSettings(s); + AsNES.PutSettings(s); } } @@ -252,7 +248,7 @@ namespace BizHawk.Client.Common bottom = 128; } - var s = (NES.NESSettings)Global.Emulator.GetSettings(); + var s = AsNES.GetSettings(); if (pal) { @@ -265,7 +261,7 @@ namespace BizHawk.Client.Common s.NTSC_BottomLine = bottom; } - Global.Emulator.PutSettings(s); + AsNES.PutSettings(s); } } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs index 9f8b8205f2..a05c25c124 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs @@ -1,6 +1,6 @@ using System; using System.ComponentModel; - +using BizHawk.Emulation.Common; using LuaInterface; using BizHawk.Emulation.Cores.Nintendo.SNES; @@ -17,13 +17,22 @@ namespace BizHawk.Client.Common public override string Name { get { return "snes"; } } + private static LibsnesCore.SnesSettings GetSettings() + { + return ((LibsnesCore)Global.Emulator).GetSettings(); + } + + private static void PutSettings(LibsnesCore.SnesSettings settings) { + ((LibsnesCore)Global.Emulator).PutSettings(settings); + } + [LuaMethodAttributes( "getlayer_bg_1", "Returns whether the bg 1 layer is displayed" )] public static bool GetLayerBg1() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG1_1; + return GetSettings().ShowBG1_1; } [LuaMethodAttributes( @@ -32,7 +41,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerBg2() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG2_1; + return GetSettings().ShowBG2_1; } [LuaMethodAttributes( @@ -41,7 +50,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerBg3() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG3_1; + return GetSettings().ShowBG3_1; } [LuaMethodAttributes( @@ -50,7 +59,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerBg4() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG4_1; + return GetSettings().ShowBG4_1; } [LuaMethodAttributes( @@ -59,7 +68,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerObj1() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_0; + return GetSettings().ShowOBJ_0; } [LuaMethodAttributes( @@ -68,7 +77,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerObj2() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_1; + return GetSettings().ShowOBJ_1; } [LuaMethodAttributes( @@ -77,7 +86,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerObj3() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_2; + return GetSettings().ShowOBJ_2; } [LuaMethodAttributes( @@ -86,7 +95,7 @@ namespace BizHawk.Client.Common )] public static bool GetLayerObj4() { - return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_3; + return GetSettings().ShowOBJ_3; } [LuaMethodAttributes( @@ -97,9 +106,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowBG1_1 = s.ShowBG1_0 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -111,9 +120,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowBG2_1 = s.ShowBG2_0 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -125,9 +134,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowBG3_1 = s.ShowBG3_0 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -139,9 +148,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowBG4_1 = s.ShowBG4_0 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -153,9 +162,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowOBJ_0 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -167,9 +176,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowOBJ_1 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -181,9 +190,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowOBJ_2 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } @@ -195,9 +204,9 @@ namespace BizHawk.Client.Common { if (Global.Emulator is LibsnesCore) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = GetSettings(); s.ShowOBJ_3 = value; - Global.Emulator.PutSettings(s); + PutSettings(s); } } } diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index f6e5739246..84fb3440a3 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -95,7 +95,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions movie.EmulatorVersion = VersionInfo.GetEmuVersion(); movie.SystemID = Global.Emulator.SystemId; - movie.SyncSettingsJson = ConfigService.SaveWithType(Global.Emulator.GetSyncSettings()); + var settable = Global.Emulator as ISettable; + if (settable == null) + throw new NotImplementedException("ISettable"); + + movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings()); if (Global.Game != null) { diff --git a/BizHawk.Client.EmuHawk/Extensions/CoreExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/CoreExtensions.cs index 3b88af5018..4feda50c61 100644 --- a/BizHawk.Client.EmuHawk/Extensions/CoreExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/CoreExtensions.cs @@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk.CoreExtensions if (Global.Emulator is LibsnesCore) { - str += " (" + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile + ")"; + str += " (" + (((LibsnesCore)Global.Emulator).GetSyncSettings()).Profile + ")"; } return str; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index a0d04c1110..18fcf2f37f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -412,7 +412,8 @@ namespace BizHawk.Client.EmuHawk } else if (Global.Emulator is LibsnesCore) { - var ss = (LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings(); + var snes = (LibsnesCore)Global.Emulator; + var ss = snes.GetSyncSettings(); if (ss.Profile == "Performance") { var box = new MsgBox( @@ -431,7 +432,7 @@ namespace BizHawk.Client.EmuHawk if (result == DialogResult.Yes) { ss.Profile = "Compatibility"; - Global.Emulator.PutSyncSettings(ss); + snes.PutSyncSettings(ss); } else if (result == DialogResult.Cancel) { @@ -1300,7 +1301,7 @@ namespace BizHawk.Client.EmuHawk private void PCESubMenu_DropDownOpened(object sender, EventArgs e) { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var s = ((PCEngine)Global.Emulator).GetSettings(); PceControllerSettingsMenuItem.Enabled = !Global.MovieSession.Movie.IsActive; @@ -1344,21 +1345,21 @@ namespace BizHawk.Client.EmuHawk private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var s = ((PCEngine)Global.Emulator).GetSettings(); s.SpriteLimit ^= true; PutCoreSettings(s); } private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e) { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var s = ((PCEngine)Global.Emulator).GetSettings(); s.EqualizeVolume ^= true; PutCoreSettings(s); } private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e) { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var s = ((PCEngine)Global.Emulator).GetSettings(); s.ArcadeCardRewindHack ^= true; PutCoreSettings(s); } @@ -1369,8 +1370,8 @@ namespace BizHawk.Client.EmuHawk private void SMSSubMenu_DropDownOpened(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); SMSregionExportToolStripMenuItem.Checked = ss.ConsoleRegion == "Export"; SMSregionJapanToolStripMenuItem.Checked = ss.ConsoleRegion == "Japan"; SMSregionAutoToolStripMenuItem.Checked = ss.ConsoleRegion == "Auto"; @@ -1408,98 +1409,98 @@ namespace BizHawk.Client.EmuHawk private void SMS_RegionExport_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.ConsoleRegion = "Export"; PutCoreSyncSettings(ss); } private void SMS_RegionJapan_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.ConsoleRegion = "Japan"; PutCoreSyncSettings(ss); } private void SMS_RegionAuto_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.ConsoleRegion = "Auto"; PutCoreSyncSettings(ss); } private void SMS_DisplayNTSC_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.DisplayType = "NTSC"; PutCoreSyncSettings(ss); } private void SMS_DisplayPAL_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.DisplayType = "PAL"; PutCoreSyncSettings(ss); } private void SMS_DisplayAuto_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.DisplayType = "Auto"; PutCoreSyncSettings(ss); } private void SMS_BIOS_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.UseBIOS ^= true; PutCoreSyncSettings(ss); } private void SMSEnableFMChipMenuItem_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.EnableFM ^= true; PutCoreSyncSettings(ss); } private void SMSOverclockMenuItem_Click(object sender, EventArgs e) { - var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((SMS)Global.Emulator).GetSyncSettings(); ss.AllowOverlock ^= true; PutCoreSyncSettings(ss); } private void SMSForceStereoMenuItem_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.ForceStereoSeparation ^= true; PutCoreSettings(s); } private void SMSSpriteLimitMenuItem_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.SpriteLimit ^= true; PutCoreSettings(s); } private void SMSFix3DDisplayMenuItem_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.Fix3D ^= true; PutCoreSettings(s); } private void ShowClippedRegionsMenuItem_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.ShowClippedRegions ^= true; PutCoreSettings(s); } private void HighlightActiveDisplayRegionMenuItem_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.HighlightActiveDisplayRegion ^= true; PutCoreSettings(s); } @@ -1617,21 +1618,21 @@ namespace BizHawk.Client.EmuHawk private void GBForceDMGMenuItem_Click(object sender, EventArgs e) { - var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); + var s = ((Gameboy)Global.Emulator).GetSyncSettings(); s.ForceDMG ^= true; PutCoreSyncSettings(s); } private void GBAInCGBModeMenuItem_Click(object sender, EventArgs e) { - var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); + var s = ((Gameboy)Global.Emulator).GetSyncSettings(); s.GBACGB ^= true; PutCoreSyncSettings(s); } private void GBMulticartCompatibilityMenuItem_Click(object sender, EventArgs e) { - var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); + var s = ((Gameboy)Global.Emulator).GetSyncSettings(); s.MulticartCompat ^= true; PutCoreSyncSettings(s); } @@ -1691,7 +1692,7 @@ namespace BizHawk.Client.EmuHawk private void SNESDisplayMenuItem_DropDownOpened(object sender, EventArgs e) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = ((LibsnesCore)Global.Emulator).GetSettings(); SnesBg1MenuItem.Checked = s.ShowBG1_1; SnesBg2MenuItem.Checked = s.ShowBG2_1; @@ -1781,13 +1782,13 @@ namespace BizHawk.Client.EmuHawk private void ColecoSubMenu_DropDownOpened(object sender, EventArgs e) { - var ss = (ColecoVision.ColecoSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((ColecoVision)Global.Emulator).GetSyncSettings(); ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro; } private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e) { - var ss = (ColecoVision.ColecoSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((ColecoVision)Global.Emulator).GetSyncSettings(); ss.SkipBiosIntro ^= true; PutCoreSyncSettings(ss); } @@ -1805,7 +1806,7 @@ namespace BizHawk.Client.EmuHawk N64CircularAnalogRangeMenuItem.Checked = Global.Config.N64UseCircularAnalogConstraint; - var s = (N64Settings)Global.Emulator.GetSettings(); + var s = ((N64)Global.Emulator).GetSettings(); MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag; //var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); @@ -1854,16 +1855,18 @@ namespace BizHawk.Client.EmuHawk private void MupenStyleLagMenuItem_Click(object sender, EventArgs e) { - var s = (N64Settings)Global.Emulator.GetSettings(); + var n64 = (N64)Global.Emulator; + var s = n64.GetSettings(); s.UseMupenStyleLag ^= true; - Global.Emulator.PutSettings(s); + n64.PutSettings(s); } private void N64ExpansionSlotMenuItem_Click(object sender, EventArgs e) { - var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + var n64 = (N64)Global.Emulator; + var ss = n64.GetSyncSettings(); ss.DisableExpansionSlot ^= true; - Global.Emulator.PutSyncSettings(ss); + n64.PutSyncSettings(ss); FlagNeedsReboot(); } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 1f8de6d771..a7d6a8f23a 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -507,8 +507,8 @@ namespace BizHawk.Client.EmuHawk Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); } - // autohold/autofire must not be affected by the following inputs - Global.ActiveController.Overrides(Global.LuaAndAdaptor); + // autohold/autofire must not be affected by the following inputs + Global.ActiveController.Overrides(Global.LuaAndAdaptor); if (GlobalWin.Tools.Has()) { @@ -1068,9 +1068,11 @@ namespace BizHawk.Client.EmuHawk } } + private static LibsnesCore AsSNES { get { return Global.Emulator as LibsnesCore; } } + public void SNES_ToggleBG1(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowBG1_1 = s.ShowBG1_0 = setto.Value; @@ -1080,13 +1082,13 @@ namespace BizHawk.Client.EmuHawk s.ShowBG1_1 = s.ShowBG1_0 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowBG1_1 ? "BG 1 Layer On" : "BG 1 Layer Off"); } public void SNES_ToggleBG2(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowBG2_1 = s.ShowBG2_0 = setto.Value; @@ -1096,13 +1098,13 @@ namespace BizHawk.Client.EmuHawk s.ShowBG2_1 = s.ShowBG2_0 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowBG2_1 ? "BG 2 Layer On" : "BG 2 Layer Off"); } public void SNES_ToggleBG3(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowBG3_1 = s.ShowBG3_0 = setto.Value; @@ -1112,13 +1114,13 @@ namespace BizHawk.Client.EmuHawk s.ShowBG3_1 = s.ShowBG3_0 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowBG3_1 ? "BG 3 Layer On" : "BG 3 Layer Off"); } public void SNES_ToggleBG4(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowBG4_1 = s.ShowBG4_0 = setto.Value; @@ -1128,13 +1130,13 @@ namespace BizHawk.Client.EmuHawk s.ShowBG4_1 = s.ShowBG4_0 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowBG4_1 ? "BG 4 Layer On" : "BG 4 Layer Off"); } public void SNES_ToggleObj1(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowOBJ_0 = setto.Value; @@ -1144,13 +1146,13 @@ namespace BizHawk.Client.EmuHawk s.ShowOBJ_0 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowOBJ_0 ? "OBJ 1 Layer On" : "OBJ 1 Layer Off"); } public void SNES_ToggleObj2(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowOBJ_1 = setto.Value; @@ -1159,13 +1161,13 @@ namespace BizHawk.Client.EmuHawk { s.ShowOBJ_1 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowOBJ_1 ? "OBJ 2 Layer On" : "OBJ 2 Layer Off"); } public void SNES_ToggleOBJ3(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowOBJ_2 = setto.Value; @@ -1175,13 +1177,13 @@ namespace BizHawk.Client.EmuHawk s.ShowOBJ_2 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowOBJ_2 ? "OBJ 3 Layer On" : "OBJ 3 Layer Off"); } public void SNES_ToggleOBJ4(bool? setto = null) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = AsSNES.GetSettings(); if (setto.HasValue) { s.ShowOBJ_3 = setto.Value; @@ -1191,7 +1193,7 @@ namespace BizHawk.Client.EmuHawk s.ShowOBJ_3 ^= true; } - Global.Emulator.PutSettings(s); + AsSNES.PutSettings(s); GlobalWin.OSD.AddMessage(s.ShowOBJ_3 ? "OBJ 4 Layer On" : "OBJ 4 Layer Off"); } @@ -1484,108 +1486,108 @@ namespace BizHawk.Client.EmuHawk } private void HandlePlatformMenus() - { - var system = string.Empty; - if (!Global.Game.IsNullInstance) - { - //New Code + { + var system = string.Empty; + if (!Global.Game.IsNullInstance) + { + //New Code //We use SystemID as that has the system we are playing on. - system = Global.Emulator.SystemId; - //Old Code below. - //system = Global.Game.System; + system = Global.Emulator.SystemId; + //Old Code below. + //system = Global.Game.System; - } + } - TI83SubMenu.Visible = false; - NESSubMenu.Visible = false; - PCESubMenu.Visible = false; - SMSSubMenu.Visible = false; - GBSubMenu.Visible = false; - GBASubMenu.Visible = false; - AtariSubMenu.Visible = false; - SNESSubMenu.Visible = false; - ColecoSubMenu.Visible = false; - N64SubMenu.Visible = false; - SaturnSubMenu.Visible = false; - DGBSubMenu.Visible = false; - GenesisSubMenu.Visible = false; - wonderSwanToolStripMenuItem.Visible = false; + TI83SubMenu.Visible = false; + NESSubMenu.Visible = false; + PCESubMenu.Visible = false; + SMSSubMenu.Visible = false; + GBSubMenu.Visible = false; + GBASubMenu.Visible = false; + AtariSubMenu.Visible = false; + SNESSubMenu.Visible = false; + ColecoSubMenu.Visible = false; + N64SubMenu.Visible = false; + SaturnSubMenu.Visible = false; + DGBSubMenu.Visible = false; + GenesisSubMenu.Visible = false; + wonderSwanToolStripMenuItem.Visible = false; - switch (system) - { - case "GEN": - GenesisSubMenu.Visible = true; - break; - case "TI83": - TI83SubMenu.Visible = true; - break; - case "NES": - NESSubMenu.Visible = true; - break; - case "PCE": - case "PCECD": - case "SGX": - PCESubMenu.Visible = true; - break; - case "SMS": - SMSSubMenu.Text = "&SMS"; - SMSSubMenu.Visible = true; - break; - case "SG": - SMSSubMenu.Text = "&SG"; - SMSSubMenu.Visible = true; - break; - case "GG": - SMSSubMenu.Text = "&GG"; - SMSSubMenu.Visible = true; - break; - case "GB": - case "GBC": - GBSubMenu.Visible = true; - break; - case "GBA": - GBASubMenu.Visible = true; - break; - case "A26": - AtariSubMenu.Visible = true; - break; - case "SNES": - case "SGB": - // TODO: fix SNES9x here - if (Global.Emulator is LibsnesCore) - { - if ((Global.Emulator as LibsnesCore).IsSGB) - { - SNESSubMenu.Text = "&SGB"; - } - else - { - SNESSubMenu.Text = "&SNES"; - } - SNESSubMenu.Visible = true; - } - else - { - SNESSubMenu.Visible = false; - } - break; - case "Coleco": - ColecoSubMenu.Visible = true; - break; - case "N64": - N64SubMenu.Visible = true; - break; - case "SAT": - SaturnSubMenu.Visible = true; - break; - case "DGB": - DGBSubMenu.Visible = true; - break; - case "WSWAN": - wonderSwanToolStripMenuItem.Visible = true; - break; - } - } + switch (system) + { + case "GEN": + GenesisSubMenu.Visible = true; + break; + case "TI83": + TI83SubMenu.Visible = true; + break; + case "NES": + NESSubMenu.Visible = true; + break; + case "PCE": + case "PCECD": + case "SGX": + PCESubMenu.Visible = true; + break; + case "SMS": + SMSSubMenu.Text = "&SMS"; + SMSSubMenu.Visible = true; + break; + case "SG": + SMSSubMenu.Text = "&SG"; + SMSSubMenu.Visible = true; + break; + case "GG": + SMSSubMenu.Text = "&GG"; + SMSSubMenu.Visible = true; + break; + case "GB": + case "GBC": + GBSubMenu.Visible = true; + break; + case "GBA": + GBASubMenu.Visible = true; + break; + case "A26": + AtariSubMenu.Visible = true; + break; + case "SNES": + case "SGB": + // TODO: fix SNES9x here + if (Global.Emulator is LibsnesCore) + { + if ((Global.Emulator as LibsnesCore).IsSGB) + { + SNESSubMenu.Text = "&SGB"; + } + else + { + SNESSubMenu.Text = "&SNES"; + } + SNESSubMenu.Visible = true; + } + else + { + SNESSubMenu.Visible = false; + } + break; + case "Coleco": + ColecoSubMenu.Visible = true; + break; + case "N64": + N64SubMenu.Visible = true; + break; + case "SAT": + SaturnSubMenu.Visible = true; + break; + case "DGB": + DGBSubMenu.Visible = true; + break; + case "WSWAN": + wonderSwanToolStripMenuItem.Visible = true; + break; + } + } private static void InitControls() { @@ -1724,9 +1726,9 @@ namespace BizHawk.Client.EmuHawk } var sfd = new SaveFileDialog(); - sfd.AddExtension = true; - sfd.DefaultExt = "State"; - sfd.Filter = "Save States (*.State)|*.State|All Files|*.*"; + sfd.AddExtension = true; + sfd.DefaultExt = "State"; + sfd.Filter = "Save States (*.State)|*.State|All Files|*.*"; var path = PathManager.GetSaveStatePath(Global.Game); sfd.InitialDirectory = path; sfd.FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State"; @@ -1923,7 +1925,8 @@ namespace BizHawk.Client.EmuHawk /// public void PutCoreSettings(object o) { - if (Global.Emulator.PutSettings(o)) + var settable = Global.Emulator as ISettable; + if (settable != null && settable.PutSettings(o)) { FlagNeedsReboot(); } @@ -1934,11 +1937,12 @@ namespace BizHawk.Client.EmuHawk /// public void PutCoreSyncSettings(object o) { + var settable = Global.Emulator as ISettable; if (Global.MovieSession.Movie.IsActive) { GlobalWin.OSD.AddMessage("Attempt to change sync-relevant settings while recording BLOCKED."); } - else if (Global.Emulator.PutSyncSettings(o)) + else if (settable != null && settable.PutSyncSettings(o)) { FlagNeedsReboot(); } @@ -3182,7 +3186,7 @@ namespace BizHawk.Client.EmuHawk // the new settings objects CommitCoreSettingsToConfig(); // adelikat: I Think by reordering things, this isn't necessary anymore CloseGame(); - + var nextComm = CreateCoreComm(); CoreFileProvider.SyncCoreCommInputSignals(nextComm); var result = loader.LoadRom(path, nextComm); @@ -3289,7 +3293,7 @@ namespace BizHawk.Client.EmuHawk } else { - //This shows up if there's a problem + //This shows up if there's a problem // TODO: put all these in a single method or something HandlePlatformMenus(); _stateSlots.Clear(); @@ -3344,19 +3348,23 @@ namespace BizHawk.Client.EmuHawk { // save settings object var t = Global.Emulator.GetType(); - Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t); + var settable = Global.Emulator as ISettable; + if (settable == null) + return; + + Global.Config.PutCoreSettings(settable.GetSettings(), t); // don't trample config with loaded-from-movie settings if (!Global.MovieSession.Movie.IsActive) { - Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t); + Global.Config.PutCoreSyncSettings(settable.GetSyncSettings(), t); } } // whats the difference between these two methods?? // its very tricky. rename to be more clear or combine them. - // This gets called whenever a core related thing is changed. - // Like reboot core. + // This gets called whenever a core related thing is changed. + // Like reboot core. private void CloseGame(bool clearSram = false) { if (clearSram) @@ -3392,8 +3400,8 @@ namespace BizHawk.Client.EmuHawk public void CloseRom(bool clearSram = false) { - //This gets called after Close Game gets called. - //Tested with NESHawk and SMB3 (U) + //This gets called after Close Game gets called. + //Tested with NESHawk and SMB3 (U) if (GlobalWin.Tools.AskSave()) { CloseGame(clearSram); @@ -3447,48 +3455,48 @@ namespace BizHawk.Client.EmuHawk #endregion - #region Tool Control API + #region Tool Control API - // TODO: move me - public IControlMainform master { get; private set; } + // TODO: move me + public IControlMainform master { get; private set; } public void RelinquishControl(IControlMainform master) { this.master = master; } - private void ToggleReadOnly() - { - if (IsSlave && master.WantsToControlReadOnly) - { - master.ToggleReadOnly(); - } - else - { - if (Global.MovieSession.Movie.IsActive) - { - Global.MovieSession.ReadOnly ^= true; - GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode"); - } - else - { - GlobalWin.OSD.AddMessage("No movie active"); - } - } - } + private void ToggleReadOnly() + { + if (IsSlave && master.WantsToControlReadOnly) + { + master.ToggleReadOnly(); + } + else + { + if (Global.MovieSession.Movie.IsActive) + { + Global.MovieSession.ReadOnly ^= true; + GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode"); + } + else + { + GlobalWin.OSD.AddMessage("No movie active"); + } + } + } - public void StopMovie(bool saveChanges = true) - { - if (IsSlave && master.WantsToControlStopMovie) - { - master.StopMovie(); - } - else - { - Global.MovieSession.StopMovie(saveChanges); - SetMainformMovieInfo(); - UpdateStatusSlots(); - } - } + public void StopMovie(bool saveChanges = true) + { + if (IsSlave && master.WantsToControlStopMovie) + { + master.StopMovie(); + } + else + { + Global.MovieSession.StopMovie(saveChanges); + SetMainformMovieInfo(); + UpdateStatusSlots(); + } + } private bool IsSlave { @@ -3503,7 +3511,7 @@ namespace BizHawk.Client.EmuHawk private void GBAcoresettingsToolStripMenuItem1_Click(object sender, EventArgs e) { GenericCoreConfig.DoDialog(this, "Gameboy Advance Settings"); - } + } private void CaptureRewind(bool suppressCaptureRewind) @@ -3542,11 +3550,11 @@ namespace BizHawk.Client.EmuHawk return isRewinding; } - #endregion + #endregion private void LinkConnectStatusBarButton_Click(object sender, EventArgs e) { // TODO: it would be cool if clicking this toggled the state } - } + } } diff --git a/BizHawk.Client.EmuHawk/config/GB/CGBColorChooserForm.cs b/BizHawk.Client.EmuHawk/config/GB/CGBColorChooserForm.cs index 0b3cbf08df..06668a3f40 100644 --- a/BizHawk.Client.EmuHawk/config/GB/CGBColorChooserForm.cs +++ b/BizHawk.Client.EmuHawk/config/GB/CGBColorChooserForm.cs @@ -91,14 +91,15 @@ namespace BizHawk.Client.EmuHawk { using (var dlg = new CGBColorChooserForm()) { - dlg.LoadType((Gameboy.GambatteSettings)Global.Emulator.GetSettings()); + var gb = Global.Emulator as Gameboy; + dlg.LoadType(gb.GetSettings()); var result = dlg.ShowDialog(parent); if (result == DialogResult.OK) { - var s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); + var s = gb.GetSettings(); s.CGBColors = dlg.type; - Global.Emulator.PutSettings(s); + gb.PutSettings(s); } } } diff --git a/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs b/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs index 273d0766e2..7b9857b798 100644 --- a/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs +++ b/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs @@ -232,8 +232,9 @@ namespace BizHawk.Client.EmuHawk { using (var dlg = new ColorChooserForm()) { + var gb = Global.Emulator as Gameboy; if (fromemu) - s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); + s = gb.GetSettings(); dlg.SetAllColors(s.GBPalette); var result = dlg.ShowDialog(parent); @@ -245,7 +246,7 @@ namespace BizHawk.Client.EmuHawk s.GBPalette = colorints; if (fromemu) - Global.Emulator.PutSettings(s); + gb.PutSettings(s); } } } diff --git a/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs b/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs index 828d1dc5b4..c32ce2b570 100644 --- a/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs +++ b/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs @@ -47,8 +47,9 @@ namespace BizHawk.Client.EmuHawk.config.GB public static void DoDGBPrefsDialog(IWin32Window owner) { - var s = (GambatteLink.GambatteLinkSettings)Global.Emulator.GetSettings(); - var ss = (GambatteLink.GambatteLinkSyncSettings)Global.Emulator.GetSyncSettings(); + var gambatte = (GambatteLink)Global.Emulator; + var s = gambatte.GetSettings(); + var ss = gambatte.GetSyncSettings(); using (var dlg = new DGBPrefs()) { @@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk.config.GB if (dlg.ShowDialog(owner) == DialogResult.OK) { dlg.GetSettings(out s, out ss); - Global.Emulator.PutSettings(s); + gambatte.PutSettings(s); if (dlg.SyncSettingsChanged) GlobalWin.MainForm.PutCoreSyncSettings(ss); } diff --git a/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs b/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs index faf956fc60..3da575d03a 100644 --- a/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs +++ b/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs @@ -20,17 +20,18 @@ namespace BizHawk.Client.EmuHawk.config.GB public static void DoGBPrefsDialog(IWin32Window owner) { - var s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); - var ss = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); + var gb = ((Gameboy)Global.Emulator); + var s = gb.GetSettings(); + var ss = gb.GetSyncSettings(); using (var dlg = new GBPrefs()) { dlg.gbPrefControl1.PutSettings(s, ss); - dlg.gbPrefControl1.ColorGameBoy = ((Gameboy)Global.Emulator).IsCGBMode(); + dlg.gbPrefControl1.ColorGameBoy = gb.IsCGBMode(); if (dlg.ShowDialog(owner) == DialogResult.OK) { dlg.gbPrefControl1.GetSettings(out s, out ss); - Global.Emulator.PutSettings(s); + gb.PutSettings(s); if (dlg.gbPrefControl1.SyncSettingsChanged) GlobalWin.MainForm.PutCoreSyncSettings(ss); } diff --git a/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs index 2228cb7df5..674f9e96b2 100644 --- a/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs +++ b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs @@ -8,6 +8,7 @@ using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Client.EmuHawk; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -21,8 +22,13 @@ namespace BizHawk.Client.EmuHawk { InitializeComponent(); - s = Global.Emulator.GetSettings(); - ss = Global.Emulator.GetSyncSettings(); + var settable = Global.Emulator as ISettable; + + if (settable != null) + { + s = settable.GetSettings(); + ss = settable.GetSyncSettings(); + } if (s != null) propertyGrid1.SelectedObject = s; @@ -39,8 +45,12 @@ namespace BizHawk.Client.EmuHawk private void button1_Click(object sender, EventArgs e) { - if (s != null) - Global.Emulator.PutSettings(s); + var settable = Global.Emulator as ISettable; + if (s != null && settable != null) + { + settable.PutSettings(s); + } + if (ss != null && syncsettingschanged) GlobalWin.MainForm.PutCoreSyncSettings(ss); diff --git a/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs b/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs index 29d1706193..1998964f45 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs @@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk private void N64ControllersSetup_Load(object sender, EventArgs e) { - var n64Settings = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + var n64Settings = ((N64)Global.Emulator).GetSyncSettings(); ControllerSettingControls .ForEach(c => @@ -45,7 +45,8 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - var n64Settings = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + var n64 = (N64)Global.Emulator; + var n64Settings = n64.GetSyncSettings(); ControllerSettingControls .ForEach(c => @@ -54,7 +55,7 @@ namespace BizHawk.Client.EmuHawk n64Settings.Controllers[c.ControllerNumber - 1].PakType = c.PakType; }); - Global.Emulator.PutSyncSettings(n64Settings); + n64.PutSyncSettings(n64Settings); DialogResult = DialogResult.OK; Close(); diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs index 5bed5e07f9..053ff76534 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is N64) { - return (N64SyncSettings)Global.Emulator.GetSyncSettings(); + return ((N64)Global.Emulator).GetSyncSettings(); } else { @@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is N64) { - return (N64Settings)Global.Emulator.GetSettings(); + return ((N64)Global.Emulator).GetSettings(); } else { diff --git a/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs b/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs index e7bd8bec8c..5a9a455ee1 100644 --- a/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs +++ b/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs @@ -85,7 +85,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is N64) { - return (N64SyncSettings)Global.Emulator.GetSyncSettings(); + return ((N64)Global.Emulator).GetSyncSettings(); } return (N64SyncSettings)Global.Config.GetCoreSyncSettings() @@ -96,7 +96,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is N64) { - return (N64Settings)Global.Emulator.GetSettings(); + return ((N64)Global.Emulator).GetSettings(); } return (N64Settings)Global.Config.GetCoreSettings() diff --git a/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs b/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs index ba6805a7c4..f98d334e03 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESSoundConfig.cs @@ -34,6 +34,8 @@ namespace BizHawk.Client.EmuHawk } } + private static NES AsNES { get { return Global.Emulator as NES; } } + public NESSoundConfig() { InitializeComponent(); @@ -48,7 +50,7 @@ namespace BizHawk.Client.EmuHawk private void NESSoundConfig_Load(object sender, EventArgs e) { - _oldSettings = (NES.NESSettings)Global.Emulator.GetSettings(); + _oldSettings = AsNES.GetSettings(); _settings = _oldSettings.Clone(); trackBar1.Value = _settings.Square1; @@ -66,7 +68,7 @@ namespace BizHawk.Client.EmuHawk private void Cancel_Click(object sender, EventArgs e) { // restore previous value - Global.Emulator.PutSettings(_oldSettings); + AsNES.PutSettings(_oldSettings); Close(); } @@ -74,35 +76,35 @@ namespace BizHawk.Client.EmuHawk { label6.Text = trackBar1.Value.ToString(); _settings.Square1 = trackBar1.Value; - Global.Emulator.PutSettings(_settings); + AsNES.PutSettings(_settings); } private void trackBar2_ValueChanged(object sender, EventArgs e) { label7.Text = trackBar2.Value.ToString(); _settings.Square2 = trackBar2.Value; - Global.Emulator.PutSettings(_settings); + AsNES.PutSettings(_settings); } private void trackBar3_ValueChanged(object sender, EventArgs e) { label8.Text = trackBar3.Value.ToString(); _settings.Triangle = trackBar3.Value; - Global.Emulator.PutSettings(_settings); + AsNES.PutSettings(_settings); } private void trackBar4_ValueChanged(object sender, EventArgs e) { label9.Text = trackBar4.Value.ToString(); _settings.Noise = trackBar4.Value; - Global.Emulator.PutSettings(_settings); + AsNES.PutSettings(_settings); } private void trackBar5_ValueChanged(object sender, EventArgs e) { label10.Text = trackBar5.Value.ToString(); _settings.DMC = trackBar5.Value; - Global.Emulator.PutSettings(_settings); + AsNES.PutSettings(_settings); } } } diff --git a/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs b/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs index 7e7e8fee16..d1c44add32 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk public NESSyncSettingsForm() { InitializeComponent(); - SyncSettings = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); + SyncSettings = ((NES)Global.Emulator).GetSyncSettings(); DTDB = new DataTableDictionaryBind(SyncSettings.BoardProperties); dataGridView1.DataSource = DTDB.Table; diff --git a/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs b/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs index 3d615f548d..c6d641bbeb 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk public NesControllerSettings() { InitializeComponent(); - SyncSettings = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); + SyncSettings = ((NES)Global.Emulator).GetSyncSettings(); // TODO: use combobox extension and add descriptions to enum values comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray()); diff --git a/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs b/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs index 75e65cd190..5d0dd438c0 100644 --- a/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs +++ b/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk private void QuickNesConfig_Load(object sender, EventArgs e) { - Settings = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); + Settings = ((QuickNES)Global.Emulator).GetSettings(); propertyGrid1.SelectedObject = Settings; SetPaletteImage(); } diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs index 71c66ac051..fb375c66dc 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk private void PCEControllerConfig_Load(object sender, EventArgs e) { - var pceSettings = (PCEngine.PCESyncSettings)Global.Emulator.GetSyncSettings(); + var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); for (int i = 0; i < 5; i++) { Controls.Add(new Label @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - var pceSettings = (PCEngine.PCESyncSettings)Global.Emulator.GetSyncSettings(); + var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); Controls .OfType() diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs index bf393a4699..80c499b9ce 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs @@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk private void PCEGraphicsConfig_Load(object sender, EventArgs e) { - PCEngine.PCESettings s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + PCEngine.PCESettings s = ((PCEngine)Global.Emulator).GetSettings(); DispOBJ1.Checked = s.ShowOBJ1; DispBG1.Checked = s.ShowBG1; @@ -25,12 +25,13 @@ namespace BizHawk.Client.EmuHawk private void OK_Click(object sender, EventArgs e) { - PCEngine.PCESettings s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + var pce = (PCEngine)Global.Emulator; + PCEngine.PCESettings s = pce.GetSettings(); s.ShowOBJ1 = DispOBJ1.Checked; s.ShowBG1 = DispBG1.Checked; s.ShowOBJ2 = DispOBJ2.Checked; s.ShowBG2 = DispBG2.Checked; - Global.Emulator.PutSettings(s); + pce.PutSettings(s); Close(); } } diff --git a/BizHawk.Client.EmuHawk/config/ProfileConfig.cs b/BizHawk.Client.EmuHawk/config/ProfileConfig.cs index aee054d25a..fd435d88ba 100644 --- a/BizHawk.Client.EmuHawk/config/ProfileConfig.cs +++ b/BizHawk.Client.EmuHawk/config/ProfileConfig.cs @@ -355,7 +355,7 @@ namespace BizHawk.Client.EmuHawk where TEmulator : IEmulator { // should we complain if we get a successful object from the config file, but it is the wrong type? - return Global.Emulator.GetSyncSettings() as TSetting + return ((ISettable)Global.Emulator).GetSyncSettings() as TSetting ?? Global.Config.GetCoreSyncSettings() as TSetting ?? new TSetting(); // guaranteed to give sensible defaults } @@ -365,7 +365,7 @@ namespace BizHawk.Client.EmuHawk where TEmulator : IEmulator { // should we complain if we get a successful object from the config file, but it is the wrong type? - return Global.Emulator.GetSettings() as TSetting + return ((ISettable)Global.Emulator).GetSettings() as TSetting ?? Global.Config.GetCoreSettings() as TSetting ?? new TSetting(); // guaranteed to give sensible defaults } @@ -375,7 +375,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is TEmulator) { - Global.Emulator.PutSettings(o); + ((ISettable)Global.Emulator).PutSettings(o); } else { diff --git a/BizHawk.Client.EmuHawk/config/SMS/SMSGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/SMS/SMSGraphicsConfig.cs index d57e7d715c..36d942d3bb 100644 --- a/BizHawk.Client.EmuHawk/config/SMS/SMSGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/SMS/SMSGraphicsConfig.cs @@ -16,14 +16,14 @@ namespace BizHawk.Client.EmuHawk private void SMSGraphicsConfig_Load(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); DispOBJ.Checked = s.DispOBJ; DispBG.Checked = s.DispBG; } private void OK_Click(object sender, EventArgs e) { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + var s = ((SMS)Global.Emulator).GetSettings(); s.DispOBJ = DispOBJ.Checked; s.DispBG = DispBG.Checked; GlobalWin.MainForm.PutCoreSettings(s); diff --git a/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs b/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs index 131ed23a16..4377e2a537 100644 --- a/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs +++ b/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs @@ -59,8 +59,8 @@ namespace BizHawk.Client.EmuHawk public static void DoSettingsDialog(IWin32Window owner) { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); - var ss = (LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings(); + var s = ((LibsnesCore)Global.Emulator).GetSettings(); + var ss = ((LibsnesCore)Global.Emulator).GetSyncSettings(); var dlg = new SNESOptions { UseRingBuffer = s.UseRingBuffer, diff --git a/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs b/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs index 2423c38c6e..f87429cca3 100644 --- a/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs +++ b/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs @@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk private void TI83PaletteConfig_Load(object sender, EventArgs e) { - var s = (TI83.TI83Settings)Global.Emulator.GetSettings(); + var s = ((TI83)Global.Emulator).GetSettings(); // Alpha hack because Winform is lame with colors BackgroundPanel.BackColor = Color.FromArgb(255, Color.FromArgb((int)s.BGColor)); @@ -30,11 +30,12 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - var s = (TI83.TI83Settings)Global.Emulator.GetSettings(); + var ti83 = (TI83)Global.Emulator; + var s = ti83.GetSettings(); s.BGColor = (uint)BackgroundPanel.BackColor.ToArgb(); s.ForeColor = (uint)ForeGroundPanel.BackColor.ToArgb(); - Global.Emulator.PutSettings(s); + ti83.PutSettings(s); DialogResult = DialogResult.OK; Close(); diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index fc76acfb76..72de8eb797 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -1350,7 +1350,7 @@ namespace BizHawk.Client.EmuHawk if (suppression) return; var pal = (SnesColors.ColorType)comboPalette.SelectedValue; Console.WriteLine("set {0}", pal); - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = ((LibsnesCore)Global.Emulator).GetSettings(); s.Palette = pal.ToString(); if (currentSnesCore != null) { @@ -1364,7 +1364,7 @@ namespace BizHawk.Client.EmuHawk void RefreshBGENCheckStatesFromConfig() { - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var s = ((LibsnesCore)Global.Emulator).GetSettings(); checkEN0_BG1.Checked = s.ShowBG1_0; checkEN0_BG2.Checked = s.ShowBG2_0; checkEN0_BG3.Checked = s.ShowBG3_0; @@ -1382,7 +1382,8 @@ namespace BizHawk.Client.EmuHawk private void checkEN_CheckedChanged(object sender, EventArgs e) { if(suppression) return; - var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); + var snes = ((LibsnesCore)Global.Emulator); + var s = snes.GetSettings(); if (sender == checkEN0_BG1) s.ShowBG1_0 = checkEN0_BG1.Checked; if (sender == checkEN0_BG2) s.ShowBG2_0 = checkEN0_BG2.Checked; if (sender == checkEN0_BG3) s.ShowBG3_0 = checkEN0_BG3.Checked; @@ -1414,7 +1415,7 @@ namespace BizHawk.Client.EmuHawk RefreshBGENCheckStatesFromConfig(); suppression = false; } - Global.Emulator.PutSettings(s); + snes.PutSettings(s); } private void lblEnPrio0_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs index 1c861de3e7..5bb42469b4 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs @@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk { public IEnumerable GetPadSchemas() { - var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((N64)Global.Emulator).GetSyncSettings(); for (var i = 0; i < 4; i++) { if (ss.Controllers[i].IsConnected) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs index 197eb4dd36..e14c86a5dd 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is NES) { - var ss = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); + var ss = ((NES)Global.Emulator).GetSyncSettings(); var core = (Global.Emulator as NES); var isFds = core.BoardName == "FDS"; if (ss.Controls.Famicom) diff --git a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs index d7113d596d..4732d63dfd 100644 --- a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs @@ -118,11 +118,6 @@ namespace BizHawk.Emulation.Common get; set; } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } public class NullSound : ISoundProvider diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index e5d547e285..ccc8235fe4 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -126,9 +126,34 @@ namespace BizHawk.Emulation.Common /// the corecomm module in use by this core. /// CoreComm CoreComm { get; } + } - // ====settings interface==== + public interface IDebuggable : IEmulator + { + /// + /// Returns a list of Cpu registers and their current state + /// + /// + Dictionary GetCpuFlagsAndRegisters(); + /// + /// Sets a given Cpu register to the given value + /// + /// + /// + void SetCpuRegister(string register, int value); + } + + public interface ISettable : IEmulator + { + object GetSettings(); + object GetSyncSettings(); + bool PutSettings(object o); + bool PutSyncSettings(object o); + } + + public interface ISettable : ISettable + { // in addition to these methods, it's expected that the constructor or Load() method // will take a Settings and SyncSettings object to set the initial state of the core // (if those are null, default settings are to be used) @@ -139,7 +164,7 @@ namespace BizHawk.Emulation.Common /// (unless the object is later passed to PutSettings) /// /// a json-serializable object - object GetSettings(); + new TSettings GetSettings(); /// /// get the current core settings that affect movie sync. these go in movie 2.0 files, so don't make the JSON too extravagant, please @@ -148,14 +173,14 @@ namespace BizHawk.Emulation.Common /// (unless the object is later passed to PutSyncSettings) /// /// a json-serializable object - object GetSyncSettings(); + new TSync GetSyncSettings(); /// /// change the core settings, excepting movie settings /// /// an object of the same type as the return for GetSettings /// true if a core reboot will be required to make the changes effective - bool PutSettings(object o); + new bool PutSettings(TSettings o); /// /// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING @@ -163,24 +188,8 @@ namespace BizHawk.Emulation.Common /// /// an object of the same type as the return for GetSyncSettings /// true if a core reboot will be required to make the changes effective - bool PutSyncSettings(object o); + new bool PutSyncSettings(TSync o); } - public interface IDebuggable : IEmulator - { - /// - /// Returns a list of Cpu registers and their current state - /// - /// - Dictionary GetCpuFlagsAndRegisters(); - - /// - /// Sets a given Cpu register to the given value - /// - /// - /// - void SetCpuRegister(string register, int value); - } - public enum DisplayType { NTSC, PAL, DENDY } } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index e5c02d7a37..e322c92a3a 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Calculators isPorted: false, isReleased: true )] - public class TI83 : IEmulator, IMemoryDomains, IDebuggable + public class TI83 : IEmulator, IMemoryDomains, IDebuggable, ISettable { //hardware private readonly Z80A cpu = new Z80A(); @@ -350,7 +350,7 @@ namespace BizHawk.Emulation.Cores.Calculators [CoreConstructor("TI83")] public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings) { - PutSettings(Settings ?? new TI83Settings()); + PutSettings((TI83Settings)Settings ?? new TI83Settings()); CoreComm = comm; cpu.ReadMemory = ReadMemory; @@ -997,14 +997,23 @@ namespace BizHawk.Emulation.Cores.Calculators TI83Settings Settings; - public object GetSettings() { return Settings.Clone(); } + public TI83Settings GetSettings() { return Settings.Clone(); } - public bool PutSettings(object o) + public bool PutSettings(TI83Settings o) { - Settings = (TI83Settings)o; + Settings = o; return false; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) { + return PutSettings((TI83Settings)o); + } + public object GetSyncSettings() { return null; } public bool PutSyncSettings(object o) { return false; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs index 49987dd83e..23358a238e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Core.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 PAL } - sealed public partial class C64 : IEmulator, IDebuggable + sealed public partial class C64 : IEmulator, IDebuggable { private Motherboard board; private bool loadPrg; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 14b777ec5e..f4ede6208b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { board.inputRead = false; board.PollInput(); - board.cpu.LagCycles = 0; + board.cpu.LagCycles = 0; for (int count = 0; count < cyclesPerFrame; count++) { @@ -201,10 +201,5 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 //domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func(disk.PeekRam), new Action(disk.PokeRam))); memoryDomains = new MemoryDomainList(domains); } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Settings.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Settings.cs index 80bd428092..afacfd402e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Settings.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Settings.cs @@ -1,42 +1,62 @@ using System; using System.ComponentModel; using System.Drawing; +using BizHawk.Emulation.Common; using Newtonsoft.Json; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.Atari2600 { - public partial class Atari2600 + public partial class Atari2600 : ISettable { - public object GetSettings() + public A2600Settings GetSettings() { return Settings.Clone(); } - public object GetSyncSettings() + public A2600SyncSettings GetSyncSettings() { return SyncSettings.Clone(); } - public bool PutSettings(object o) + public bool PutSettings(A2600Settings o) { - A2600Settings newSettings = (A2600Settings)o; - if (Settings == null || Settings.SECAMColors != newSettings.SECAMColors) + if (Settings == null || Settings.SECAMColors != o.SECAMColors) { if (_tia != null) - _tia.SetSECAM(newSettings.SECAMColors); + _tia.SetSECAM(o.SECAMColors); } - Settings = newSettings; + Settings = o; return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(A2600SyncSettings o) { - SyncSettings = (A2600SyncSettings)o; + SyncSettings = o; return false; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((A2600Settings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((A2600SyncSettings)o); + } + public class A2600Settings { [JsonIgnore] diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index fae4511dae..9923bd90a3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 isPorted: false, isReleased: true )] - public partial class Atari2600 : IEmulator, IMemoryDomains, IDebuggable + public partial class Atari2600 : IEmulator, IMemoryDomains, IDebuggable { private readonly GameInfo _game; private bool _islag = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs index 5da7405be6..47c6095961 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 portedVersion: "v1.5", portedUrl: "http://emu7800.sourceforge.net/" )] - public partial class Atari7800 : IEmulator, IMemoryDomains, IDebuggable + public partial class Atari7800 : IEmulator, IMemoryDomains, IDebuggable { // TODO: // some things don't work when you try to plug in a 2600 game @@ -457,10 +457,5 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 } } #endregion - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index 0bb03edc2f..b915d14f2a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -366,30 +366,5 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } #endregion - - #region Settings - - public object GetSettings() - { - return null; - } - - public object GetSyncSettings() - { - return null; - } - - public bool PutSettings(object o) - { - return false; - } - - public bool PutSyncSettings(object o) - { - return false; - } - - #endregion - } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 4ab4ebb300..7269111594 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision isPorted: false, isReleased: true )] - public sealed partial class ColecoVision : IEmulator, IMemoryDomains, IDebuggable + public sealed partial class ColecoVision : IEmulator, IMemoryDomains, IDebuggable, ISettable { // ROM public byte[] RomData; @@ -239,16 +239,25 @@ namespace BizHawk.Emulation.Cores.ColecoVision public void EndAsyncSound() { } public object GetSettings() { return null; } - public object GetSyncSettings() { return SyncSettings.Clone(); } + public ColecoSyncSettings GetSyncSettings() { return SyncSettings.Clone(); } public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(ColecoSyncSettings o) { - var n = (ColecoSyncSettings)o; - bool ret = n.SkipBiosIntro != SyncSettings.SkipBiosIntro; - SyncSettings = n; + bool ret = o.SkipBiosIntro != SyncSettings.SkipBiosIntro; + SyncSettings = o; return ret; } + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSettings((ColecoSyncSettings)o); + } + ColecoSyncSettings SyncSettings; public class ColecoSyncSettings diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 31348ff31f..73246918f4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -205,10 +205,5 @@ namespace BizHawk.Emulation.Cores.Intellivision public void Dispose() { } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index 8ecf38d6de..f5af0c9210 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA isPorted: true, isReleased: false )] - public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, IDebuggable + public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, IDebuggable { public Dictionary GetCpuFlagsAndRegisters() { @@ -544,10 +544,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA } #endregion - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index e7bfe8b897..c3b25af937 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -14,7 +14,8 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBA { [CoreAttributes("VBA-Next", "many authors", true, true, "cd508312a29ed8c29dacac1b11c2dce56c338a54", "https://github.com/libretro/vba-next")] - public class VBANext : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, IDebuggable + public class VBANext : IEmulator, IVideoProvider, ISyncSoundProvider, + IGBAGPUViewable, IMemoryDomains, IDebuggable, ISettable { IntPtr Core; @@ -399,7 +400,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA return null; } - public object GetSyncSettings() + public SyncSettings GetSyncSettings() { return _SyncSettings.Clone(); } @@ -412,14 +413,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(SyncSettings o) { - var s = (SyncSettings)o; - bool ret = SyncSettings.NeedsReboot(s, _SyncSettings); - _SyncSettings = s; + bool ret = SyncSettings.NeedsReboot(o, _SyncSettings); + _SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings(o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((SyncSettings)o); + } + public class SyncSettings { [DisplayName("Skip BIOS")] diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 1eb654d8e0..e2ea3de0e3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -22,7 +22,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy portedVersion: "SVN 344", portedUrl: "http://gambatte.sourceforge.net/" )] - public class Gameboy : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable + public class Gameboy : IEmulator, IVideoProvider, ISyncSoundProvider, + IMemoryDomains, IDebuggable, ISettable { #region ALL SAVESTATEABLE STATE GOES HERE @@ -163,7 +164,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy throw new InvalidOperationException("gambatte_load() returned non-zero (is this not a gb or gbc rom?)"); // set real default colors (before anyone mucks with them at all) - PutSettings(Settings ?? new GambatteSettings()); + PutSettings((GambatteSettings)Settings ?? new GambatteSettings()); InitSound(); @@ -986,11 +987,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy GambatteSettings _Settings; GambatteSyncSettings _SyncSettings; - public object GetSettings() { return _Settings.Clone(); } - public object GetSyncSettings() { return _SyncSettings.Clone(); } - public bool PutSettings(object o) + public GambatteSettings GetSettings() { return _Settings.Clone(); } + public GambatteSyncSettings GetSyncSettings() { return _SyncSettings.Clone(); } + public bool PutSettings(GambatteSettings o) { - _Settings = (GambatteSettings)o; + _Settings = o; if (IsCGBMode()) SetCGBColors(_Settings.CGBColors); else @@ -998,14 +999,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(GambatteSyncSettings o) { - var s = (GambatteSyncSettings)o; - bool ret = GambatteSyncSettings.NeedsReboot(_SyncSettings, s); - _SyncSettings = s; + bool ret = GambatteSyncSettings.NeedsReboot(_SyncSettings, o); + _SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((GambatteSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((GambatteSyncSettings)o); + } + public class GambatteSettings { private static readonly int[] DefaultPalette = new[] diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index b9fd176f48..ca6445ee98 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy isPorted: true, isReleased: true )] - public class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider, IDebuggable + public class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider, + IDebuggable, ISettable { bool disposed = false; @@ -516,31 +517,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy #region settings - public object GetSettings() + public GambatteLinkSettings GetSettings() { return new GambatteLinkSettings ( - (Gameboy.GambatteSettings)L.GetSettings(), - (Gameboy.GambatteSettings)R.GetSettings() + L.GetSettings(), + R.GetSettings() ); } - public object GetSyncSettings() + public GambatteLinkSyncSettings GetSyncSettings() { return new GambatteLinkSyncSettings ( - (Gameboy.GambatteSyncSettings)L.GetSyncSettings(), - (Gameboy.GambatteSyncSettings)R.GetSyncSettings() + L.GetSyncSettings(), + R.GetSyncSettings() ); } - public bool PutSettings(object o) + public bool PutSettings(GambatteLinkSettings o) { - var s = (GambatteLinkSettings)o; - return L.PutSettings(s.L) || R.PutSettings(s.R); + return L.PutSettings(o.L) || R.PutSettings(o.R); } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(GambatteLinkSyncSettings o) { - var s = (GambatteLinkSyncSettings)o; - return L.PutSyncSettings(s.L) || R.PutSyncSettings(s.R); + return L.PutSyncSettings(o.L) || R.PutSyncSettings(o.R); + } + + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((GambatteLinkSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((GambatteLinkSyncSettings)o); } public class GambatteLinkSettings diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index e2e849b5e5..8ee0a0e4bd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 portedVersion: "2.0", portedUrl: "https://code.google.com/p/mupen64plus/" )] - public partial class N64 : IEmulator, IMemoryDomains, IDebuggable + public partial class N64 : IEmulator, IMemoryDomains, IDebuggable, + ISettable { private readonly N64Input _inputProvider; private readonly N64VideoProvider _videoProvider; @@ -481,29 +482,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 #region Settings - public object GetSettings() + public N64Settings GetSettings() { return _settings.Clone(); } - public object GetSyncSettings() + public N64SyncSettings GetSyncSettings() { return _syncSettings.Clone(); } - public bool PutSettings(object o) + public bool PutSettings(N64Settings o) { - _settings = (N64Settings)o; + _settings = o; return true; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(N64SyncSettings o) { - _syncSettings = (N64SyncSettings)o; + _syncSettings = o; SetControllerButtons(); return true; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((N64Settings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((N64SyncSettings)o); + } + private void SetControllerButtons() { ControllerDefinition.BoolButtons.Clear(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 0925c8ba3e..5fa1d60583 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES isPorted: false, isReleased: true )] - public partial class NES : IEmulator, IMemoryDomains, IDebuggable + public partial class NES : IEmulator, IMemoryDomains, IDebuggable, + ISettable { static readonly bool USE_DATABASE = true; public RomStatus RomStatus; @@ -46,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES CoreComm.UsesDriveLed = true; (board as FDS).SetDriveLightCallback((val) => CoreComm.DriveLED = val); } - PutSettings(Settings ?? new NESSettings()); + PutSettings((NESSettings)Settings ?? new NESSettings()); } private NES() @@ -931,11 +932,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES NESSettings Settings = new NESSettings(); NESSyncSettings SyncSettings = new NESSyncSettings(); - public object GetSettings() { return Settings.Clone(); } - public object GetSyncSettings() { return SyncSettings.Clone(); } - public bool PutSettings(object o) + public NESSettings GetSettings() { return Settings.Clone(); } + public NESSyncSettings GetSyncSettings() { return SyncSettings.Clone(); } + public bool PutSettings(NESSettings o) { - Settings = (NESSettings)o; + Settings = o; if (Settings.ClipLeftAndRight) { videoProvider.left = 8; @@ -959,14 +960,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(NESSyncSettings o) { - var n = (NESSyncSettings)o; - bool ret = NESSyncSettings.NeedsReboot(SyncSettings, n); - SyncSettings = n; + bool ret = NESSyncSettings.NeedsReboot(SyncSettings, o); + SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((NESSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((NESSyncSettings)o); + } + public class NESSettings { public bool AllowMoreThanEightSprites = false; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 76d3d46d85..f494982c5f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -21,7 +21,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES portedVersion: "0.7.0", portedUrl: "https://github.com/kode54/QuickNES" )] - public class QuickNES : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable + public class QuickNES : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, + IDebuggable, ISettable { #region FPU precision @@ -84,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES BoardName = mappername; CoreComm.VsyncNum = 39375000; CoreComm.VsyncDen = 655171; - PutSettings(Settings ?? new QuickNESSettings()); + PutSettings((QuickNESSettings)Settings ?? new QuickNESSettings()); ComputeBootGod(); } @@ -502,30 +503,50 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES } } - public object GetSettings() + public QuickNESSettings GetSettings() { return _Settings.Clone(); } - public object GetSyncSettings() + public QuickNESSyncSettings GetSyncSettings() { return new QuickNESSyncSettings(); } - public bool PutSettings(object o) + public bool PutSettings(QuickNESSettings o) { - _Settings = (QuickNESSettings)o; + _Settings = o; LibQuickNES.qn_set_sprite_limit(Context, _Settings.NumSprites); RecalculateCrops(); CalculatePalette(); return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(QuickNESSyncSettings o) { return false; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((QuickNESSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((QuickNESSyncSettings)o); + } + #endregion public void Dispose() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 7a0e914b71..ba1656e24c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -66,7 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES portedVersion: "v87", portedUrl: "http://byuu.org/" )] - public unsafe class LibsnesCore : IEmulator, IVideoProvider, IMemoryDomains, IDebuggable + public unsafe class LibsnesCore : IEmulator, IVideoProvider, IMemoryDomains, + IDebuggable, ISettable { public bool IsSGB { get; private set; } @@ -1183,25 +1184,43 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES SnesSettings Settings; SnesSyncSettings SyncSettings; - public object GetSettings() { return Settings.Clone(); } - public object GetSyncSettings() { return SyncSettings.Clone(); } - public bool PutSettings(object o) + public SnesSettings GetSettings() { return Settings.Clone(); } + public SnesSyncSettings GetSyncSettings() { return SyncSettings.Clone(); } + public bool PutSettings(SnesSettings o) { - SnesSettings n = (SnesSettings)o; - bool refreshneeded = n.Palette != Settings.Palette; - Settings = n; + bool refreshneeded = o.Palette != Settings.Palette; + Settings = o; if (refreshneeded) RefreshPalette(); return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(SnesSyncSettings o) { - SnesSyncSettings n = (SnesSyncSettings)o; - bool ret = n.Profile != SyncSettings.Profile; - SyncSettings = n; + bool ret = o.Profile != SyncSettings.Profile; + SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((SnesSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((SnesSyncSettings)o); + } + public class SnesSettings { public bool ShowBG1_0 = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index 7f73e91588..b584552a2f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -126,30 +126,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X #endregion - #region settings - - public object GetSettings() - { - return null; - } - - public object GetSyncSettings() - { - return null; - } - - public bool PutSettings(object o) - { - return false; - } - - public bool PutSyncSettings(object o) - { - return false; - } - - #endregion - #region IVideoProvider private int[] _vbuff = new int[512 * 480]; diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 85161c731b..33722a5046 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -22,7 +22,8 @@ namespace BizHawk.Emulation.Cores.PCEngine isPorted: false, isReleased: true )] - public sealed partial class PCEngine : IEmulator, IMemoryDomains, IDebuggable + public sealed partial class PCEngine : IEmulator, IMemoryDomains, + IDebuggable, ISettable { // ROM public byte[] RomData; @@ -567,31 +568,49 @@ namespace BizHawk.Emulation.Cores.PCEngine public PCESettings _settings; private PCESyncSettings _syncSettings; - public object GetSettings() { return _settings.Clone(); } - public object GetSyncSettings() { return _syncSettings.Clone(); } - public bool PutSettings(object o) + public PCESettings GetSettings() { return _settings.Clone(); } + public PCESyncSettings GetSyncSettings() { return _syncSettings.Clone(); } + public bool PutSettings(PCESettings o) { - PCESettings n = (PCESettings)o; bool ret; - if (n.ArcadeCardRewindHack != _settings.ArcadeCardRewindHack || - n.EqualizeVolume != _settings.EqualizeVolume) + if (o.ArcadeCardRewindHack != _settings.ArcadeCardRewindHack || + o.EqualizeVolume != _settings.EqualizeVolume) ret = true; else ret = false; - _settings = n; + _settings = o; return ret; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(PCESyncSettings o) { - var newsyncsettings = (PCESyncSettings)o; - bool ret = PCESyncSettings.NeedsReboot(newsyncsettings, _syncSettings); - _syncSettings = newsyncsettings; + bool ret = PCESyncSettings.NeedsReboot(o, _syncSettings); + _syncSettings = o; // SetControllerButtons(); // not safe to change the controller during emulation, so instead make it a reboot event return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((PCESettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((PCESyncSettings)o); + } + public class PCESettings { public bool ShowBG1 = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index 859e6af159..f3ead0e4e3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis isPorted: false, isReleased: false )] - public sealed partial class Genesis : IEmulator, IMemoryDomains, IDebuggable + public sealed partial class Genesis : IEmulator, IMemoryDomains, IDebuggable { private int _lagcount = 0; private bool lagged = true; @@ -138,8 +138,8 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis Musashi.Reset(); VDP.GetPC = () => Musashi.PC; #else - MainCPU.Reset(); - VDP.GetPC = () => MainCPU.PC; + MainCPU.Reset(); + VDP.GetPC = () => MainCPU.PC; #endif InitializeCartHardware(game); } @@ -224,7 +224,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis #if MUSASHI Musashi.Execute(cycles); #else - MainCPU.ExecuteCycles(cycles); + MainCPU.ExecuteCycles(cycles); #endif } @@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis #if MUSASHI Musashi.SetIRQ(irq); #else - MainCPU.Interrupt = irq; + MainCPU.Interrupt = irq; #endif } @@ -491,10 +491,5 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis public MemoryDomainList MemoryDomains { get { return memoryDomains; } } public void Dispose() { } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index e7cd539e51..6944df0566 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -27,7 +27,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem isPorted: false, isReleased: true )] - public sealed partial class SMS : IEmulator, IMemoryDomains, IDebuggable + public sealed partial class SMS : IEmulator, IMemoryDomains, + IDebuggable, ISettable { // Constants public const int BankSize = 16384; @@ -101,14 +102,14 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem IsGameGear = game.System == "GG"; IsSG1000 = game.System == "SG"; - RomData = rom; - CoreComm.CpuTraceAvailable = true; - - if (RomData.Length % BankSize != 0) - Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); - RomBanks = (byte)(RomData.Length / BankSize); + RomData = rom; + CoreComm.CpuTraceAvailable = true; + + if (RomData.Length % BankSize != 0) + Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); + RomBanks = (byte)(RomData.Length / BankSize); - DisplayType = DetermineDisplayType(SyncSettings.DisplayType, game.Region); + DisplayType = DetermineDisplayType(SyncSettings.DisplayType, game.Region); if (game["PAL"] && DisplayType != DisplayType.PAL) { DisplayType = DisplayType.PAL; @@ -128,26 +129,26 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem CoreComm.Notify("Region was forced to Japan for game compatibility."); } - if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear) - HasYM2413 = true; + if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear) + HasYM2413 = true; - if (Controller == null) - Controller = NullController.GetNullController(); + if (Controller == null) + Controller = NullController.GetNullController(); - Cpu = new Z80A(); - Cpu.RegisterSP = 0xDFF0; - Cpu.ReadHardware = ReadPort; - Cpu.WriteHardware = WritePort; + Cpu = new Z80A(); + Cpu.RegisterSP = 0xDFF0; + Cpu.ReadHardware = ReadPort; + Cpu.WriteHardware = WritePort; - Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); - PSG = new SN76489(); - YM2413 = new YM2413(); - SoundMixer = new SoundMixer(YM2413, PSG); - if (HasYM2413 && game["WhenFMDisablePSG"]) - SoundMixer.DisableSource(PSG); - ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG; + Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); + PSG = new SN76489(); + YM2413 = new YM2413(); + SoundMixer = new SoundMixer(YM2413, PSG); + if (HasYM2413 && game["WhenFMDisablePSG"]) + SoundMixer.DisableSource(PSG); + ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG; - SystemRam = new byte[0x2000]; + SystemRam = new byte[0x2000]; if (game["CMMapper"]) InitCodeMastersMapper(); @@ -166,20 +167,20 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem else InitSegaMapper(); - if (Settings.ForceStereoSeparation && !IsGameGear) - { - if (game["StereoByte"]) - { - ForceStereoByte = byte.Parse(game.OptionValue("StereoByte")); - } + if (Settings.ForceStereoSeparation && !IsGameGear) + { + if (game["StereoByte"]) + { + ForceStereoByte = byte.Parse(game.OptionValue("StereoByte")); + } PSG.StereoPanning = ForceStereoByte; - } + } - if (SyncSettings.AllowOverlock && game["OverclockSafe"]) - Vdp.IPeriod = 512; + if (SyncSettings.AllowOverlock && game["OverclockSafe"]) + Vdp.IPeriod = 512; - if (Settings.SpriteLimit) - Vdp.SpriteLimit = true; + if (Settings.SpriteLimit) + Vdp.SpriteLimit = true; if (game["3D"]) IsGame3D = true; @@ -593,23 +594,41 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public void Dispose() { } - public object GetSettings() { return Settings.Clone(); } - public object GetSyncSettings() { return SyncSettings.Clone(); } - public bool PutSettings(object o) + public SMSSettings GetSettings() { return Settings.Clone(); } + public SMSSyncSettings GetSyncSettings() { return SyncSettings.Clone(); } + public bool PutSettings(SMSSettings o) { - SMSSettings n = (SMSSettings)o; - bool ret = SMSSettings.RebootNeeded(Settings, n); - Settings = n; + bool ret = SMSSettings.RebootNeeded(Settings, o); + Settings = o; return ret; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(SMSSyncSettings o) { - SMSSyncSettings n = (SMSSyncSettings)o; - bool ret = SMSSyncSettings.RebootNeeded(SyncSettings, n); - SyncSettings = n; + bool ret = SMSSyncSettings.RebootNeeded(SyncSettings, o); + SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((SMSSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((SMSSyncSettings)o); + } + public SMSSettings Settings; public SMSSyncSettings SyncSettings; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 7bf3a6352e..7bf0bd607a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -23,7 +23,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn portedVersion: "9.12", portedUrl: "http://yabause.org" )] - public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains + public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, + ISettable { public static ControllerDefinition SaturnController = new ControllerDefinition { @@ -707,14 +708,13 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn SaturnSyncSettings SyncSettings; public object GetSettings() { return null; } - public object GetSyncSettings() { return SyncSettings.Clone(); } + public SaturnSyncSettings GetSyncSettings() { return SyncSettings.Clone(); } public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(SaturnSyncSettings o) { - var n = (SaturnSyncSettings)o; - bool ret = SaturnSyncSettings.NeedsReboot(SyncSettings, n); + bool ret = SaturnSyncSettings.NeedsReboot(SyncSettings, o); - SyncSettings = n; + SyncSettings = o; if (GLMode && SyncSettings.UseGL) if (SyncSettings.DispFree) @@ -724,6 +724,26 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((object)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((SaturnSyncSettings)o); + } + public class SaturnSyncSettings { [DisplayName("Open GL Mode")] diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index eb4d351572..d23a7ebc65 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -24,7 +24,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx portedVersion: "r874", portedUrl: "https://code.google.com/p/genplus-gx/" )] - public class GPGX : IEmulator, ISyncSoundProvider, IVideoProvider, IMemoryDomains, IDebuggable + public class GPGX : IEmulator, ISyncSoundProvider, IVideoProvider, IMemoryDomains, + IDebuggable, ISettable { static GPGX AttachedCore = null; @@ -163,7 +164,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx if (CD != null) CoreComm.UsesDriveLed = true; - PutSettings(Settings ?? new GPGXSettings()); + PutSettings((GPGXSettings)Settings ?? new GPGXSettings()); InitMemCallbacks(); KillMemCallbacks(); @@ -786,23 +787,41 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx GPGXSyncSettings _SyncSettings; GPGXSettings _Settings; - public object GetSettings() { return _Settings.Clone(); } - public object GetSyncSettings() { return _SyncSettings.Clone(); } - public bool PutSettings(object o) + public GPGXSettings GetSettings() { return _Settings.Clone(); } + public GPGXSyncSettings GetSyncSettings() { return _SyncSettings.Clone(); } + public bool PutSettings(GPGXSettings o) { - _Settings = (GPGXSettings)o; + _Settings = o; LibGPGX.gpgx_set_draw_mask(_Settings.GetDrawMask()); return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(GPGXSyncSettings o) { - bool ret; - var n = (GPGXSyncSettings)o; - ret = GPGXSyncSettings.NeedsReboot(_SyncSettings, n); - _SyncSettings = n; + bool ret = GPGXSyncSettings.NeedsReboot(_SyncSettings, o); + _SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((GPGXSettings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((GPGXSyncSettings)o); + } + public class GPGXSettings { [DisplayName("Background Layer A")] diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index e8c5b9b6b9..50eab89939 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -213,10 +213,5 @@ namespace BizHawk.Emulation.Cores.Sony.PSP public void DiscardSamples() { } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index c3babbb126..6f9fc7986f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -283,10 +283,5 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public int MaxVolume { get; set; } private List memoryDomains = new List(); public MemoryDomainList MemoryDomains { get; private set; } - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 49e37027c1..920842140b 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -12,7 +12,8 @@ using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.WonderSwan { [CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.34.1", "http://mednafen.sourceforge.net/")] - public class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable + public class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, + IDebuggable, ISettable { #region Controller @@ -496,32 +497,51 @@ namespace BizHawk.Emulation.Cores.WonderSwan } } - public object GetSettings() + public Settings GetSettings() { return _Settings.Clone(); } - public object GetSyncSettings() + public SyncSettings GetSyncSettings() { return _SyncSettings.Clone(); } - public bool PutSettings(object o) + public bool PutSettings(Settings o) { - _Settings = (Settings)o; + _Settings = o; var native = _Settings.GetNativeSettings(); BizSwan.bizswan_putsettings(Core, ref native); return false; } - public bool PutSyncSettings(object o) + public bool PutSyncSettings(SyncSettings o) { - var newsettings = (SyncSettings)o; - bool ret = SyncSettings.NeedsReboot(newsettings, _SyncSettings); - _SyncSettings = newsettings; + bool ret = SyncSettings.NeedsReboot(o, _SyncSettings); + _SyncSettings = o; return ret; } + object ISettable.GetSettings() + { + return GetSettings(); + } + + bool ISettable.PutSettings(object o) + { + return PutSettings((Settings)o); + } + + object ISettable.GetSyncSettings() + { + return GetSyncSettings(); + } + + bool ISettable.PutSyncSettings(object o) + { + return PutSyncSettings((SyncSettings)o); + } + #endregion #region IVideoProvider diff --git a/BizHawk.Emulation.Cores/LibRetroEmulator.cs b/BizHawk.Emulation.Cores/LibRetroEmulator.cs index eb688d05a2..59550f7b80 100644 --- a/BizHawk.Emulation.Cores/LibRetroEmulator.cs +++ b/BizHawk.Emulation.Cores/LibRetroEmulator.cs @@ -562,10 +562,5 @@ namespace BizHawk.Emulation.Cores public int BackgroundColor { get { return unchecked((int)0xff000000); } } #endregion - - public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } - public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } } }