Create ISettable<T,T2>/ISettable interfaces. This checkin has not been extensively tested.

This commit is contained in:
jlennox 2014-10-19 01:22:47 +00:00
parent 2401de6ba2
commit a64017366c
58 changed files with 876 additions and 641 deletions

View File

@ -306,7 +306,7 @@ namespace BizHawk.Client.Common
// Bsnes profiles have incompatible savestates so save the profile name // Bsnes profiles have incompatible savestates so save the profile name
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
name += "." + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile; name += "." + (Global.Emulator as LibsnesCore).GetSyncSettings().Profile;
} }
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive)

View File

@ -64,14 +64,14 @@ namespace BizHawk.Client.Common
{ {
try try
{ {
var debuggable = Global.Emulator as IDebuggable; var debuggable = Global.Emulator as IDebuggable;
if (debuggable == null) if (debuggable == null)
throw new NotImplementedException(); throw new NotImplementedException();
var registers = debuggable.GetCpuFlagsAndRegisters(); var registers = debuggable.GetCpuFlagsAndRegisters();
return registers.ContainsKey(name) return registers.ContainsKey(name)
? registers[name] ? registers[name]
: 0; : 0;
} }
catch (NotImplementedException) catch (NotImplementedException)
{ {
@ -93,11 +93,11 @@ namespace BizHawk.Client.Common
try try
{ {
var debuggable = Global.Emulator as IDebuggable; var debuggable = Global.Emulator as IDebuggable;
if (debuggable == null) if (debuggable == null)
throw new NotImplementedException(); throw new NotImplementedException();
foreach (var kvp in debuggable.GetCpuFlagsAndRegisters()) foreach (var kvp in debuggable.GetCpuFlagsAndRegisters())
{ {
table[kvp.Key] = kvp.Value; table[kvp.Key] = kvp.Value;
} }
@ -120,11 +120,11 @@ namespace BizHawk.Client.Common
{ {
try try
{ {
var debuggable = Global.Emulator as IDebuggable; var debuggable = Global.Emulator as IDebuggable;
if (debuggable == null) if (debuggable == null)
throw new NotImplementedException(); throw new NotImplementedException();
debuggable.SetCpuRegister(register, value); debuggable.SetCpuRegister(register, value);
} }
catch (NotImplementedException) catch (NotImplementedException)
{ {
@ -189,25 +189,28 @@ namespace BizHawk.Client.Common
{ {
// in the future, we could do something more arbitrary here. // in the future, we could do something more arbitrary here.
// but this isn't any worse than the old system // 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.DispSprites = (bool)luaParam[0];
s.DispBackground = (bool)luaParam[1]; s.DispBackground = (bool)luaParam[1];
Global.Emulator.PutSettings(s); nes.PutSettings(s);
} }
else if (Global.Emulator is QuickNES) 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 // this core doesn't support disabling BG
bool showsp = GetSetting(0, luaParam); bool showsp = GetSetting(0, luaParam);
if (showsp && s.NumSprites == 0) if (showsp && s.NumSprites == 0)
s.NumSprites = 8; s.NumSprites = 8;
else if (!showsp && s.NumSprites > 0) else if (!showsp && s.NumSprites > 0)
s.NumSprites = 0; s.NumSprites = 0;
Global.Emulator.PutSettings(s); quicknes.PutSettings(s);
} }
else if (Global.Emulator is PCEngine) 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.ShowOBJ1 = GetSetting(0, luaParam);
s.ShowBG1 = GetSetting(1, luaParam); s.ShowBG1 = GetSetting(1, luaParam);
if (luaParam.Length > 2) if (luaParam.Length > 2)
@ -216,22 +219,24 @@ namespace BizHawk.Client.Common
s.ShowBG2 = GetSetting(3, luaParam); s.ShowBG2 = GetSetting(3, luaParam);
} }
Global.Emulator.PutSettings(s); pce.PutSettings(s);
} }
else if (Global.Emulator is SMS) 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.DispOBJ = GetSetting(0, luaParam);
s.DispBG = GetSetting(1, luaParam); s.DispBG = GetSetting(1, luaParam);
Global.Emulator.PutSettings(s); sms.PutSettings(s);
} }
else if (Global.Emulator is WonderSwan) 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.EnableSprites = GetSetting(0, luaParam);
s.EnableFG = GetSetting(1, luaParam); s.EnableFG = GetSetting(1, luaParam);
s.EnableBG = GetSetting(2, luaParam); s.EnableBG = GetSetting(2, luaParam);
Global.Emulator.PutSettings(s); ws.PutSettings(s);
} }
} }

View File

@ -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( [LuaMethodAttributes(
"getallowmorethaneightsprites", "getallowmorethaneightsprites",
"Gets the NES setting 'Allow more than 8 sprites per scanline' value" "Gets the NES setting 'Allow more than 8 sprites per scanline' value"
)] )]
public static bool GetAllowMoreThanEightSprites() 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( [LuaMethodAttributes(
@ -68,17 +71,14 @@ namespace BizHawk.Client.Common
)] )]
public static int GetBottomScanline(bool pal = false) 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 pal
{ ? AsNES.GetSettings().PAL_BottomLine
return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_BottomLine; : AsNES.GetSettings().NTSC_BottomLine;
}
return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_BottomLine;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -87,12 +87,12 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetClipLeftAndRight() 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( [LuaMethodAttributes(
@ -101,12 +101,12 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetDisplayBackground() public static bool GetDisplayBackground()
{ {
if (Global.Config.NES_InQuickNES) if (AsQuickNES != null)
{ {
return true; return true;
} }
return ((NES.NESSettings)Global.Emulator.GetSettings()).DispBackground; return AsNES.GetSettings().DispBackground;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -115,12 +115,12 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetDisplaySprites() public static bool GetDisplaySprites()
{ {
if (Global.Config.NES_InQuickNES) if (AsQuickNES != null)
{ {
return true; return true;
} }
return ((NES.NESSettings)Global.Emulator.GetSettings()).DispSprites; return AsNES.GetSettings().DispSprites;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -129,17 +129,14 @@ namespace BizHawk.Client.Common
)] )]
public static int GetTopScanline(bool pal = false) 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 pal
{ ? AsNES.GetSettings().PAL_TopLine
return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_TopLine; : AsNES.GetSettings().NTSC_TopLine;
}
return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_TopLine;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -164,15 +161,15 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
var s = (NES.NESSettings)Global.Emulator.GetSettings(); var s = AsNES.GetSettings();
s.AllowMoreThanEightSprites = allow; s.AllowMoreThanEightSprites = allow;
Global.Emulator.PutSettings(s); AsNES.PutSettings(s);
} }
else if (Global.Emulator is QuickNES) else if (Global.Emulator is QuickNES)
{ {
var s = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); var s = AsQuickNES.GetSettings();
s.NumSprites = allow ? 64 : 8; 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) if (Global.Emulator is NES)
{ {
var s = (NES.NESSettings)Global.Emulator.GetSettings(); var s = AsNES.GetSettings();
s.ClipLeftAndRight = leftandright; s.ClipLeftAndRight = leftandright;
Global.Emulator.PutSettings(s); AsNES.PutSettings(s);
} }
else if (Global.Emulator is QuickNES) else if (Global.Emulator is QuickNES)
{ {
var s = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); var s = AsQuickNES.GetSettings();
s.ClipLeftAndRight = leftandright; s.ClipLeftAndRight = leftandright;
Global.Emulator.PutSettings(s); AsQuickNES.PutSettings(s);
} }
} }
@ -206,9 +202,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
var s = (NES.NESSettings)Global.Emulator.GetSettings(); var s = AsNES.GetSettings();
s.DispBackground = show; s.DispBackground = show;
Global.Emulator.PutSettings(s); AsNES.PutSettings(s);
} }
} }
@ -220,9 +216,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
var s = (NES.NESSettings)Global.Emulator.GetSettings(); var s = AsNES.GetSettings();
s.DispSprites = show; s.DispSprites = show;
Global.Emulator.PutSettings(s); AsNES.PutSettings(s);
} }
} }
@ -252,7 +248,7 @@ namespace BizHawk.Client.Common
bottom = 128; bottom = 128;
} }
var s = (NES.NESSettings)Global.Emulator.GetSettings(); var s = AsNES.GetSettings();
if (pal) if (pal)
{ {
@ -265,7 +261,7 @@ namespace BizHawk.Client.Common
s.NTSC_BottomLine = bottom; s.NTSC_BottomLine = bottom;
} }
Global.Emulator.PutSettings(s); AsNES.PutSettings(s);
} }
} }
} }

View File

@ -1,6 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using BizHawk.Emulation.Common;
using LuaInterface; using LuaInterface;
using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.SNES;
@ -17,13 +17,22 @@ namespace BizHawk.Client.Common
public override string Name { get { return "snes"; } } 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( [LuaMethodAttributes(
"getlayer_bg_1", "getlayer_bg_1",
"Returns whether the bg 1 layer is displayed" "Returns whether the bg 1 layer is displayed"
)] )]
public static bool GetLayerBg1() public static bool GetLayerBg1()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG1_1; return GetSettings().ShowBG1_1;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -32,7 +41,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerBg2() public static bool GetLayerBg2()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG2_1; return GetSettings().ShowBG2_1;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -41,7 +50,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerBg3() public static bool GetLayerBg3()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG3_1; return GetSettings().ShowBG3_1;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -50,7 +59,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerBg4() public static bool GetLayerBg4()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG4_1; return GetSettings().ShowBG4_1;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -59,7 +68,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerObj1() public static bool GetLayerObj1()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_0; return GetSettings().ShowOBJ_0;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -68,7 +77,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerObj2() public static bool GetLayerObj2()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_1; return GetSettings().ShowOBJ_1;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -77,7 +86,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerObj3() public static bool GetLayerObj3()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_2; return GetSettings().ShowOBJ_2;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -86,7 +95,7 @@ namespace BizHawk.Client.Common
)] )]
public static bool GetLayerObj4() public static bool GetLayerObj4()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_3; return GetSettings().ShowOBJ_3;
} }
[LuaMethodAttributes( [LuaMethodAttributes(
@ -97,9 +106,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowBG1_1 = s.ShowBG1_0 = value; 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) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowBG2_1 = s.ShowBG2_0 = value; 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) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowBG3_1 = s.ShowBG3_0 = value; 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) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowBG4_1 = s.ShowBG4_0 = value; 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) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowOBJ_0 = value; s.ShowOBJ_0 = value;
Global.Emulator.PutSettings(s); PutSettings(s);
} }
} }
@ -167,9 +176,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowOBJ_1 = value; s.ShowOBJ_1 = value;
Global.Emulator.PutSettings(s); PutSettings(s);
} }
} }
@ -181,9 +190,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowOBJ_2 = value; s.ShowOBJ_2 = value;
Global.Emulator.PutSettings(s); PutSettings(s);
} }
} }
@ -195,9 +204,9 @@ namespace BizHawk.Client.Common
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = GetSettings();
s.ShowOBJ_3 = value; s.ShowOBJ_3 = value;
Global.Emulator.PutSettings(s); PutSettings(s);
} }
} }
} }

View File

@ -95,7 +95,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
movie.EmulatorVersion = VersionInfo.GetEmuVersion(); movie.EmulatorVersion = VersionInfo.GetEmuVersion();
movie.SystemID = Global.Emulator.SystemId; movie.SystemID = Global.Emulator.SystemId;
movie.SyncSettingsJson = ConfigService.SaveWithType(Global.Emulator.GetSyncSettings()); var settable = Global.Emulator as ISettable<object, object>;
if (settable == null)
throw new NotImplementedException("ISettable");
movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
if (Global.Game != null) if (Global.Game != null)
{ {

View File

@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk.CoreExtensions
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
str += " (" + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile + ")"; str += " (" + (((LibsnesCore)Global.Emulator).GetSyncSettings()).Profile + ")";
} }
return str; return str;

View File

@ -412,7 +412,8 @@ namespace BizHawk.Client.EmuHawk
} }
else if (Global.Emulator is LibsnesCore) 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") if (ss.Profile == "Performance")
{ {
var box = new MsgBox( var box = new MsgBox(
@ -431,7 +432,7 @@ namespace BizHawk.Client.EmuHawk
if (result == DialogResult.Yes) if (result == DialogResult.Yes)
{ {
ss.Profile = "Compatibility"; ss.Profile = "Compatibility";
Global.Emulator.PutSyncSettings(ss); snes.PutSyncSettings(ss);
} }
else if (result == DialogResult.Cancel) else if (result == DialogResult.Cancel)
{ {
@ -1300,7 +1301,7 @@ namespace BizHawk.Client.EmuHawk
private void PCESubMenu_DropDownOpened(object sender, EventArgs e) 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; PceControllerSettingsMenuItem.Enabled = !Global.MovieSession.Movie.IsActive;
@ -1344,21 +1345,21 @@ namespace BizHawk.Client.EmuHawk
private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e)
{ {
var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); var s = ((PCEngine)Global.Emulator).GetSettings();
s.SpriteLimit ^= true; s.SpriteLimit ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e) private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e)
{ {
var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); var s = ((PCEngine)Global.Emulator).GetSettings();
s.EqualizeVolume ^= true; s.EqualizeVolume ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e) private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e)
{ {
var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); var s = ((PCEngine)Global.Emulator).GetSettings();
s.ArcadeCardRewindHack ^= true; s.ArcadeCardRewindHack ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
@ -1369,8 +1370,8 @@ namespace BizHawk.Client.EmuHawk
private void SMSSubMenu_DropDownOpened(object sender, EventArgs e) private void SMSSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((SMS)Global.Emulator).GetSyncSettings();
SMSregionExportToolStripMenuItem.Checked = ss.ConsoleRegion == "Export"; SMSregionExportToolStripMenuItem.Checked = ss.ConsoleRegion == "Export";
SMSregionJapanToolStripMenuItem.Checked = ss.ConsoleRegion == "Japan"; SMSregionJapanToolStripMenuItem.Checked = ss.ConsoleRegion == "Japan";
SMSregionAutoToolStripMenuItem.Checked = ss.ConsoleRegion == "Auto"; SMSregionAutoToolStripMenuItem.Checked = ss.ConsoleRegion == "Auto";
@ -1408,98 +1409,98 @@ namespace BizHawk.Client.EmuHawk
private void SMS_RegionExport_Click(object sender, EventArgs e) 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"; ss.ConsoleRegion = "Export";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_RegionJapan_Click(object sender, EventArgs e) 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"; ss.ConsoleRegion = "Japan";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_RegionAuto_Click(object sender, EventArgs e) 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"; ss.ConsoleRegion = "Auto";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_DisplayNTSC_Click(object sender, EventArgs e) 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"; ss.DisplayType = "NTSC";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_DisplayPAL_Click(object sender, EventArgs e) 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"; ss.DisplayType = "PAL";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_DisplayAuto_Click(object sender, EventArgs e) 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"; ss.DisplayType = "Auto";
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMS_BIOS_Click(object sender, EventArgs e) 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; ss.UseBIOS ^= true;
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMSEnableFMChipMenuItem_Click(object sender, EventArgs e) private void SMSEnableFMChipMenuItem_Click(object sender, EventArgs e)
{ {
var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((SMS)Global.Emulator).GetSyncSettings();
ss.EnableFM ^= true; ss.EnableFM ^= true;
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMSOverclockMenuItem_Click(object sender, EventArgs e) private void SMSOverclockMenuItem_Click(object sender, EventArgs e)
{ {
var ss = (SMS.SMSSyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((SMS)Global.Emulator).GetSyncSettings();
ss.AllowOverlock ^= true; ss.AllowOverlock ^= true;
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
private void SMSForceStereoMenuItem_Click(object sender, EventArgs e) private void SMSForceStereoMenuItem_Click(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.ForceStereoSeparation ^= true; s.ForceStereoSeparation ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void SMSSpriteLimitMenuItem_Click(object sender, EventArgs e) private void SMSSpriteLimitMenuItem_Click(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.SpriteLimit ^= true; s.SpriteLimit ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void SMSFix3DDisplayMenuItem_Click(object sender, EventArgs e) private void SMSFix3DDisplayMenuItem_Click(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.Fix3D ^= true; s.Fix3D ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void ShowClippedRegionsMenuItem_Click(object sender, EventArgs e) private void ShowClippedRegionsMenuItem_Click(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.ShowClippedRegions ^= true; s.ShowClippedRegions ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
private void HighlightActiveDisplayRegionMenuItem_Click(object sender, EventArgs e) private void HighlightActiveDisplayRegionMenuItem_Click(object sender, EventArgs e)
{ {
var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.HighlightActiveDisplayRegion ^= true; s.HighlightActiveDisplayRegion ^= true;
PutCoreSettings(s); PutCoreSettings(s);
} }
@ -1617,21 +1618,21 @@ namespace BizHawk.Client.EmuHawk
private void GBForceDMGMenuItem_Click(object sender, EventArgs e) private void GBForceDMGMenuItem_Click(object sender, EventArgs e)
{ {
var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); var s = ((Gameboy)Global.Emulator).GetSyncSettings();
s.ForceDMG ^= true; s.ForceDMG ^= true;
PutCoreSyncSettings(s); PutCoreSyncSettings(s);
} }
private void GBAInCGBModeMenuItem_Click(object sender, EventArgs e) private void GBAInCGBModeMenuItem_Click(object sender, EventArgs e)
{ {
var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); var s = ((Gameboy)Global.Emulator).GetSyncSettings();
s.GBACGB ^= true; s.GBACGB ^= true;
PutCoreSyncSettings(s); PutCoreSyncSettings(s);
} }
private void GBMulticartCompatibilityMenuItem_Click(object sender, EventArgs e) private void GBMulticartCompatibilityMenuItem_Click(object sender, EventArgs e)
{ {
var s = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); var s = ((Gameboy)Global.Emulator).GetSyncSettings();
s.MulticartCompat ^= true; s.MulticartCompat ^= true;
PutCoreSyncSettings(s); PutCoreSyncSettings(s);
} }
@ -1691,7 +1692,7 @@ namespace BizHawk.Client.EmuHawk
private void SNESDisplayMenuItem_DropDownOpened(object sender, EventArgs e) 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; SnesBg1MenuItem.Checked = s.ShowBG1_1;
SnesBg2MenuItem.Checked = s.ShowBG2_1; SnesBg2MenuItem.Checked = s.ShowBG2_1;
@ -1781,13 +1782,13 @@ namespace BizHawk.Client.EmuHawk
private void ColecoSubMenu_DropDownOpened(object sender, EventArgs e) 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; ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro;
} }
private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e) private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e)
{ {
var ss = (ColecoVision.ColecoSyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((ColecoVision)Global.Emulator).GetSyncSettings();
ss.SkipBiosIntro ^= true; ss.SkipBiosIntro ^= true;
PutCoreSyncSettings(ss); PutCoreSyncSettings(ss);
} }
@ -1805,7 +1806,7 @@ namespace BizHawk.Client.EmuHawk
N64CircularAnalogRangeMenuItem.Checked = Global.Config.N64UseCircularAnalogConstraint; N64CircularAnalogRangeMenuItem.Checked = Global.Config.N64UseCircularAnalogConstraint;
var s = (N64Settings)Global.Emulator.GetSettings(); var s = ((N64)Global.Emulator).GetSettings();
MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag; MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag;
//var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); //var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings();
@ -1854,16 +1855,18 @@ namespace BizHawk.Client.EmuHawk
private void MupenStyleLagMenuItem_Click(object sender, EventArgs e) 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; s.UseMupenStyleLag ^= true;
Global.Emulator.PutSettings(s); n64.PutSettings(s);
} }
private void N64ExpansionSlotMenuItem_Click(object sender, EventArgs e) 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; ss.DisableExpansionSlot ^= true;
Global.Emulator.PutSyncSettings(ss); n64.PutSyncSettings(ss);
FlagNeedsReboot(); FlagNeedsReboot();
} }

View File

@ -507,8 +507,8 @@ namespace BizHawk.Client.EmuHawk
Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons);
} }
// autohold/autofire must not be affected by the following inputs // autohold/autofire must not be affected by the following inputs
Global.ActiveController.Overrides(Global.LuaAndAdaptor); Global.ActiveController.Overrides(Global.LuaAndAdaptor);
if (GlobalWin.Tools.Has<LuaConsole>()) if (GlobalWin.Tools.Has<LuaConsole>())
{ {
@ -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) public void SNES_ToggleBG1(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowBG1_1 = s.ShowBG1_0 = setto.Value; s.ShowBG1_1 = s.ShowBG1_0 = setto.Value;
@ -1080,13 +1082,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowBG1_1 = s.ShowBG1_0 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowBG1_1 ? "BG 1 Layer On" : "BG 1 Layer Off");
} }
public void SNES_ToggleBG2(bool? setto = null) public void SNES_ToggleBG2(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowBG2_1 = s.ShowBG2_0 = setto.Value; s.ShowBG2_1 = s.ShowBG2_0 = setto.Value;
@ -1096,13 +1098,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowBG2_1 = s.ShowBG2_0 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowBG2_1 ? "BG 2 Layer On" : "BG 2 Layer Off");
} }
public void SNES_ToggleBG3(bool? setto = null) public void SNES_ToggleBG3(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowBG3_1 = s.ShowBG3_0 = setto.Value; s.ShowBG3_1 = s.ShowBG3_0 = setto.Value;
@ -1112,13 +1114,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowBG3_1 = s.ShowBG3_0 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowBG3_1 ? "BG 3 Layer On" : "BG 3 Layer Off");
} }
public void SNES_ToggleBG4(bool? setto = null) public void SNES_ToggleBG4(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowBG4_1 = s.ShowBG4_0 = setto.Value; s.ShowBG4_1 = s.ShowBG4_0 = setto.Value;
@ -1128,13 +1130,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowBG4_1 = s.ShowBG4_0 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowBG4_1 ? "BG 4 Layer On" : "BG 4 Layer Off");
} }
public void SNES_ToggleObj1(bool? setto = null) public void SNES_ToggleObj1(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowOBJ_0 = setto.Value; s.ShowOBJ_0 = setto.Value;
@ -1144,13 +1146,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowOBJ_0 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowOBJ_0 ? "OBJ 1 Layer On" : "OBJ 1 Layer Off");
} }
public void SNES_ToggleObj2(bool? setto = null) public void SNES_ToggleObj2(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowOBJ_1 = setto.Value; s.ShowOBJ_1 = setto.Value;
@ -1159,13 +1161,13 @@ namespace BizHawk.Client.EmuHawk
{ {
s.ShowOBJ_1 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowOBJ_1 ? "OBJ 2 Layer On" : "OBJ 2 Layer Off");
} }
public void SNES_ToggleOBJ3(bool? setto = null) public void SNES_ToggleOBJ3(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowOBJ_2 = setto.Value; s.ShowOBJ_2 = setto.Value;
@ -1175,13 +1177,13 @@ namespace BizHawk.Client.EmuHawk
s.ShowOBJ_2 ^= true; 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"); GlobalWin.OSD.AddMessage(s.ShowOBJ_2 ? "OBJ 3 Layer On" : "OBJ 3 Layer Off");
} }
public void SNES_ToggleOBJ4(bool? setto = null) public void SNES_ToggleOBJ4(bool? setto = null)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = AsSNES.GetSettings();
if (setto.HasValue) if (setto.HasValue)
{ {
s.ShowOBJ_3 = setto.Value; s.ShowOBJ_3 = setto.Value;
@ -1191,7 +1193,7 @@ namespace BizHawk.Client.EmuHawk
s.ShowOBJ_3 ^= true; 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"); 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() private void HandlePlatformMenus()
{ {
var system = string.Empty; var system = string.Empty;
if (!Global.Game.IsNullInstance) if (!Global.Game.IsNullInstance)
{ {
//New Code //New Code
//We use SystemID as that has the system we are playing on. //We use SystemID as that has the system we are playing on.
system = Global.Emulator.SystemId; system = Global.Emulator.SystemId;
//Old Code below. //Old Code below.
//system = Global.Game.System; //system = Global.Game.System;
} }
TI83SubMenu.Visible = false; TI83SubMenu.Visible = false;
NESSubMenu.Visible = false; NESSubMenu.Visible = false;
PCESubMenu.Visible = false; PCESubMenu.Visible = false;
SMSSubMenu.Visible = false; SMSSubMenu.Visible = false;
GBSubMenu.Visible = false; GBSubMenu.Visible = false;
GBASubMenu.Visible = false; GBASubMenu.Visible = false;
AtariSubMenu.Visible = false; AtariSubMenu.Visible = false;
SNESSubMenu.Visible = false; SNESSubMenu.Visible = false;
ColecoSubMenu.Visible = false; ColecoSubMenu.Visible = false;
N64SubMenu.Visible = false; N64SubMenu.Visible = false;
SaturnSubMenu.Visible = false; SaturnSubMenu.Visible = false;
DGBSubMenu.Visible = false; DGBSubMenu.Visible = false;
GenesisSubMenu.Visible = false; GenesisSubMenu.Visible = false;
wonderSwanToolStripMenuItem.Visible = false; wonderSwanToolStripMenuItem.Visible = false;
switch (system) switch (system)
{ {
case "GEN": case "GEN":
GenesisSubMenu.Visible = true; GenesisSubMenu.Visible = true;
break; break;
case "TI83": case "TI83":
TI83SubMenu.Visible = true; TI83SubMenu.Visible = true;
break; break;
case "NES": case "NES":
NESSubMenu.Visible = true; NESSubMenu.Visible = true;
break; break;
case "PCE": case "PCE":
case "PCECD": case "PCECD":
case "SGX": case "SGX":
PCESubMenu.Visible = true; PCESubMenu.Visible = true;
break; break;
case "SMS": case "SMS":
SMSSubMenu.Text = "&SMS"; SMSSubMenu.Text = "&SMS";
SMSSubMenu.Visible = true; SMSSubMenu.Visible = true;
break; break;
case "SG": case "SG":
SMSSubMenu.Text = "&SG"; SMSSubMenu.Text = "&SG";
SMSSubMenu.Visible = true; SMSSubMenu.Visible = true;
break; break;
case "GG": case "GG":
SMSSubMenu.Text = "&GG"; SMSSubMenu.Text = "&GG";
SMSSubMenu.Visible = true; SMSSubMenu.Visible = true;
break; break;
case "GB": case "GB":
case "GBC": case "GBC":
GBSubMenu.Visible = true; GBSubMenu.Visible = true;
break; break;
case "GBA": case "GBA":
GBASubMenu.Visible = true; GBASubMenu.Visible = true;
break; break;
case "A26": case "A26":
AtariSubMenu.Visible = true; AtariSubMenu.Visible = true;
break; break;
case "SNES": case "SNES":
case "SGB": case "SGB":
// TODO: fix SNES9x here // TODO: fix SNES9x here
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
if ((Global.Emulator as LibsnesCore).IsSGB) if ((Global.Emulator as LibsnesCore).IsSGB)
{ {
SNESSubMenu.Text = "&SGB"; SNESSubMenu.Text = "&SGB";
} }
else else
{ {
SNESSubMenu.Text = "&SNES"; SNESSubMenu.Text = "&SNES";
} }
SNESSubMenu.Visible = true; SNESSubMenu.Visible = true;
} }
else else
{ {
SNESSubMenu.Visible = false; SNESSubMenu.Visible = false;
} }
break; break;
case "Coleco": case "Coleco":
ColecoSubMenu.Visible = true; ColecoSubMenu.Visible = true;
break; break;
case "N64": case "N64":
N64SubMenu.Visible = true; N64SubMenu.Visible = true;
break; break;
case "SAT": case "SAT":
SaturnSubMenu.Visible = true; SaturnSubMenu.Visible = true;
break; break;
case "DGB": case "DGB":
DGBSubMenu.Visible = true; DGBSubMenu.Visible = true;
break; break;
case "WSWAN": case "WSWAN":
wonderSwanToolStripMenuItem.Visible = true; wonderSwanToolStripMenuItem.Visible = true;
break; break;
} }
} }
private static void InitControls() private static void InitControls()
{ {
@ -1724,9 +1726,9 @@ namespace BizHawk.Client.EmuHawk
} }
var sfd = new SaveFileDialog(); var sfd = new SaveFileDialog();
sfd.AddExtension = true; sfd.AddExtension = true;
sfd.DefaultExt = "State"; sfd.DefaultExt = "State";
sfd.Filter = "Save States (*.State)|*.State|All Files|*.*"; sfd.Filter = "Save States (*.State)|*.State|All Files|*.*";
var path = PathManager.GetSaveStatePath(Global.Game); var path = PathManager.GetSaveStatePath(Global.Game);
sfd.InitialDirectory = path; sfd.InitialDirectory = path;
sfd.FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State"; sfd.FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State";
@ -1923,7 +1925,8 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public void PutCoreSettings(object o) public void PutCoreSettings(object o)
{ {
if (Global.Emulator.PutSettings(o)) var settable = Global.Emulator as ISettable;
if (settable != null && settable.PutSettings(o))
{ {
FlagNeedsReboot(); FlagNeedsReboot();
} }
@ -1934,11 +1937,12 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public void PutCoreSyncSettings(object o) public void PutCoreSyncSettings(object o)
{ {
var settable = Global.Emulator as ISettable;
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive)
{ {
GlobalWin.OSD.AddMessage("Attempt to change sync-relevant settings while recording BLOCKED."); 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(); FlagNeedsReboot();
} }
@ -3182,7 +3186,7 @@ namespace BizHawk.Client.EmuHawk
// the new settings objects // the new settings objects
CommitCoreSettingsToConfig(); // adelikat: I Think by reordering things, this isn't necessary anymore CommitCoreSettingsToConfig(); // adelikat: I Think by reordering things, this isn't necessary anymore
CloseGame(); CloseGame();
var nextComm = CreateCoreComm(); var nextComm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(nextComm); CoreFileProvider.SyncCoreCommInputSignals(nextComm);
var result = loader.LoadRom(path, nextComm); var result = loader.LoadRom(path, nextComm);
@ -3289,7 +3293,7 @@ namespace BizHawk.Client.EmuHawk
} }
else 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 // TODO: put all these in a single method or something
HandlePlatformMenus(); HandlePlatformMenus();
_stateSlots.Clear(); _stateSlots.Clear();
@ -3344,19 +3348,23 @@ namespace BizHawk.Client.EmuHawk
{ {
// save settings object // save settings object
var t = Global.Emulator.GetType(); 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 // don't trample config with loaded-from-movie settings
if (!Global.MovieSession.Movie.IsActive) 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?? // whats the difference between these two methods??
// its very tricky. rename to be more clear or combine them. // its very tricky. rename to be more clear or combine them.
// This gets called whenever a core related thing is changed. // This gets called whenever a core related thing is changed.
// Like reboot core. // Like reboot core.
private void CloseGame(bool clearSram = false) private void CloseGame(bool clearSram = false)
{ {
if (clearSram) if (clearSram)
@ -3392,8 +3400,8 @@ namespace BizHawk.Client.EmuHawk
public void CloseRom(bool clearSram = false) public void CloseRom(bool clearSram = false)
{ {
//This gets called after Close Game gets called. //This gets called after Close Game gets called.
//Tested with NESHawk and SMB3 (U) //Tested with NESHawk and SMB3 (U)
if (GlobalWin.Tools.AskSave()) if (GlobalWin.Tools.AskSave())
{ {
CloseGame(clearSram); CloseGame(clearSram);
@ -3447,48 +3455,48 @@ namespace BizHawk.Client.EmuHawk
#endregion #endregion
#region Tool Control API #region Tool Control API
// TODO: move me // TODO: move me
public IControlMainform master { get; private set; } public IControlMainform master { get; private set; }
public void RelinquishControl(IControlMainform master) public void RelinquishControl(IControlMainform master)
{ {
this.master = master; this.master = master;
} }
private void ToggleReadOnly() private void ToggleReadOnly()
{ {
if (IsSlave && master.WantsToControlReadOnly) if (IsSlave && master.WantsToControlReadOnly)
{ {
master.ToggleReadOnly(); master.ToggleReadOnly();
} }
else else
{ {
if (Global.MovieSession.Movie.IsActive) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.ReadOnly ^= true; Global.MovieSession.ReadOnly ^= true;
GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode"); GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode");
} }
else else
{ {
GlobalWin.OSD.AddMessage("No movie active"); GlobalWin.OSD.AddMessage("No movie active");
} }
} }
} }
public void StopMovie(bool saveChanges = true) public void StopMovie(bool saveChanges = true)
{ {
if (IsSlave && master.WantsToControlStopMovie) if (IsSlave && master.WantsToControlStopMovie)
{ {
master.StopMovie(); master.StopMovie();
} }
else else
{ {
Global.MovieSession.StopMovie(saveChanges); Global.MovieSession.StopMovie(saveChanges);
SetMainformMovieInfo(); SetMainformMovieInfo();
UpdateStatusSlots(); UpdateStatusSlots();
} }
} }
private bool IsSlave private bool IsSlave
{ {
@ -3503,7 +3511,7 @@ namespace BizHawk.Client.EmuHawk
private void GBAcoresettingsToolStripMenuItem1_Click(object sender, EventArgs e) private void GBAcoresettingsToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
GenericCoreConfig.DoDialog(this, "Gameboy Advance Settings"); GenericCoreConfig.DoDialog(this, "Gameboy Advance Settings");
} }
private void CaptureRewind(bool suppressCaptureRewind) private void CaptureRewind(bool suppressCaptureRewind)
@ -3542,11 +3550,11 @@ namespace BizHawk.Client.EmuHawk
return isRewinding; return isRewinding;
} }
#endregion #endregion
private void LinkConnectStatusBarButton_Click(object sender, EventArgs e) private void LinkConnectStatusBarButton_Click(object sender, EventArgs e)
{ {
// TODO: it would be cool if clicking this toggled the state // TODO: it would be cool if clicking this toggled the state
} }
} }
} }

View File

@ -91,14 +91,15 @@ namespace BizHawk.Client.EmuHawk
{ {
using (var dlg = new CGBColorChooserForm()) 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); var result = dlg.ShowDialog(parent);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
var s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); var s = gb.GetSettings();
s.CGBColors = dlg.type; s.CGBColors = dlg.type;
Global.Emulator.PutSettings(s); gb.PutSettings(s);
} }
} }
} }

View File

@ -232,8 +232,9 @@ namespace BizHawk.Client.EmuHawk
{ {
using (var dlg = new ColorChooserForm()) using (var dlg = new ColorChooserForm())
{ {
var gb = Global.Emulator as Gameboy;
if (fromemu) if (fromemu)
s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); s = gb.GetSettings();
dlg.SetAllColors(s.GBPalette); dlg.SetAllColors(s.GBPalette);
var result = dlg.ShowDialog(parent); var result = dlg.ShowDialog(parent);
@ -245,7 +246,7 @@ namespace BizHawk.Client.EmuHawk
s.GBPalette = colorints; s.GBPalette = colorints;
if (fromemu) if (fromemu)
Global.Emulator.PutSettings(s); gb.PutSettings(s);
} }
} }
} }

View File

@ -47,8 +47,9 @@ namespace BizHawk.Client.EmuHawk.config.GB
public static void DoDGBPrefsDialog(IWin32Window owner) public static void DoDGBPrefsDialog(IWin32Window owner)
{ {
var s = (GambatteLink.GambatteLinkSettings)Global.Emulator.GetSettings(); var gambatte = (GambatteLink)Global.Emulator;
var ss = (GambatteLink.GambatteLinkSyncSettings)Global.Emulator.GetSyncSettings(); var s = gambatte.GetSettings();
var ss = gambatte.GetSyncSettings();
using (var dlg = new DGBPrefs()) using (var dlg = new DGBPrefs())
{ {
@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
if (dlg.ShowDialog(owner) == DialogResult.OK) if (dlg.ShowDialog(owner) == DialogResult.OK)
{ {
dlg.GetSettings(out s, out ss); dlg.GetSettings(out s, out ss);
Global.Emulator.PutSettings(s); gambatte.PutSettings(s);
if (dlg.SyncSettingsChanged) if (dlg.SyncSettingsChanged)
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);
} }

View File

@ -20,17 +20,18 @@ namespace BizHawk.Client.EmuHawk.config.GB
public static void DoGBPrefsDialog(IWin32Window owner) public static void DoGBPrefsDialog(IWin32Window owner)
{ {
var s = (Gameboy.GambatteSettings)Global.Emulator.GetSettings(); var gb = ((Gameboy)Global.Emulator);
var ss = (Gameboy.GambatteSyncSettings)Global.Emulator.GetSyncSettings(); var s = gb.GetSettings();
var ss = gb.GetSyncSettings();
using (var dlg = new GBPrefs()) using (var dlg = new GBPrefs())
{ {
dlg.gbPrefControl1.PutSettings(s, ss); dlg.gbPrefControl1.PutSettings(s, ss);
dlg.gbPrefControl1.ColorGameBoy = ((Gameboy)Global.Emulator).IsCGBMode(); dlg.gbPrefControl1.ColorGameBoy = gb.IsCGBMode();
if (dlg.ShowDialog(owner) == DialogResult.OK) if (dlg.ShowDialog(owner) == DialogResult.OK)
{ {
dlg.gbPrefControl1.GetSettings(out s, out ss); dlg.gbPrefControl1.GetSettings(out s, out ss);
Global.Emulator.PutSettings(s); gb.PutSettings(s);
if (dlg.gbPrefControl1.SyncSettingsChanged) if (dlg.gbPrefControl1.SyncSettingsChanged)
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);
} }

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk; using BizHawk.Client.EmuHawk;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -21,8 +22,13 @@ namespace BizHawk.Client.EmuHawk
{ {
InitializeComponent(); InitializeComponent();
s = Global.Emulator.GetSettings(); var settable = Global.Emulator as ISettable;
ss = Global.Emulator.GetSyncSettings();
if (settable != null)
{
s = settable.GetSettings();
ss = settable.GetSyncSettings();
}
if (s != null) if (s != null)
propertyGrid1.SelectedObject = s; propertyGrid1.SelectedObject = s;
@ -39,8 +45,12 @@ namespace BizHawk.Client.EmuHawk
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
if (s != null) var settable = Global.Emulator as ISettable;
Global.Emulator.PutSettings(s); if (s != null && settable != null)
{
settable.PutSettings(s);
}
if (ss != null && syncsettingschanged) if (ss != null && syncsettingschanged)
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);

View File

@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
private void N64ControllersSetup_Load(object sender, EventArgs e) private void N64ControllersSetup_Load(object sender, EventArgs e)
{ {
var n64Settings = (N64SyncSettings)Global.Emulator.GetSyncSettings(); var n64Settings = ((N64)Global.Emulator).GetSyncSettings();
ControllerSettingControls ControllerSettingControls
.ForEach(c => .ForEach(c =>
@ -45,7 +45,8 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var n64Settings = (N64SyncSettings)Global.Emulator.GetSyncSettings(); var n64 = (N64)Global.Emulator;
var n64Settings = n64.GetSyncSettings();
ControllerSettingControls ControllerSettingControls
.ForEach(c => .ForEach(c =>
@ -54,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
n64Settings.Controllers[c.ControllerNumber - 1].PakType = c.PakType; n64Settings.Controllers[c.ControllerNumber - 1].PakType = c.PakType;
}); });
Global.Emulator.PutSyncSettings(n64Settings); n64.PutSyncSettings(n64Settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();

View File

@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is N64) if (Global.Emulator is N64)
{ {
return (N64SyncSettings)Global.Emulator.GetSyncSettings(); return ((N64)Global.Emulator).GetSyncSettings();
} }
else else
{ {
@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is N64) if (Global.Emulator is N64)
{ {
return (N64Settings)Global.Emulator.GetSettings(); return ((N64)Global.Emulator).GetSettings();
} }
else else
{ {

View File

@ -85,7 +85,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is N64) if (Global.Emulator is N64)
{ {
return (N64SyncSettings)Global.Emulator.GetSyncSettings(); return ((N64)Global.Emulator).GetSyncSettings();
} }
return (N64SyncSettings)Global.Config.GetCoreSyncSettings<N64>() return (N64SyncSettings)Global.Config.GetCoreSyncSettings<N64>()
@ -96,7 +96,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is N64) if (Global.Emulator is N64)
{ {
return (N64Settings)Global.Emulator.GetSettings(); return ((N64)Global.Emulator).GetSettings();
} }
return (N64Settings)Global.Config.GetCoreSettings<N64>() return (N64Settings)Global.Config.GetCoreSettings<N64>()

View File

@ -34,6 +34,8 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private static NES AsNES { get { return Global.Emulator as NES; } }
public NESSoundConfig() public NESSoundConfig()
{ {
InitializeComponent(); InitializeComponent();
@ -48,7 +50,7 @@ namespace BizHawk.Client.EmuHawk
private void NESSoundConfig_Load(object sender, EventArgs e) private void NESSoundConfig_Load(object sender, EventArgs e)
{ {
_oldSettings = (NES.NESSettings)Global.Emulator.GetSettings(); _oldSettings = AsNES.GetSettings();
_settings = _oldSettings.Clone(); _settings = _oldSettings.Clone();
trackBar1.Value = _settings.Square1; trackBar1.Value = _settings.Square1;
@ -66,7 +68,7 @@ namespace BizHawk.Client.EmuHawk
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
// restore previous value // restore previous value
Global.Emulator.PutSettings(_oldSettings); AsNES.PutSettings(_oldSettings);
Close(); Close();
} }
@ -74,35 +76,35 @@ namespace BizHawk.Client.EmuHawk
{ {
label6.Text = trackBar1.Value.ToString(); label6.Text = trackBar1.Value.ToString();
_settings.Square1 = trackBar1.Value; _settings.Square1 = trackBar1.Value;
Global.Emulator.PutSettings(_settings); AsNES.PutSettings(_settings);
} }
private void trackBar2_ValueChanged(object sender, EventArgs e) private void trackBar2_ValueChanged(object sender, EventArgs e)
{ {
label7.Text = trackBar2.Value.ToString(); label7.Text = trackBar2.Value.ToString();
_settings.Square2 = trackBar2.Value; _settings.Square2 = trackBar2.Value;
Global.Emulator.PutSettings(_settings); AsNES.PutSettings(_settings);
} }
private void trackBar3_ValueChanged(object sender, EventArgs e) private void trackBar3_ValueChanged(object sender, EventArgs e)
{ {
label8.Text = trackBar3.Value.ToString(); label8.Text = trackBar3.Value.ToString();
_settings.Triangle = trackBar3.Value; _settings.Triangle = trackBar3.Value;
Global.Emulator.PutSettings(_settings); AsNES.PutSettings(_settings);
} }
private void trackBar4_ValueChanged(object sender, EventArgs e) private void trackBar4_ValueChanged(object sender, EventArgs e)
{ {
label9.Text = trackBar4.Value.ToString(); label9.Text = trackBar4.Value.ToString();
_settings.Noise = trackBar4.Value; _settings.Noise = trackBar4.Value;
Global.Emulator.PutSettings(_settings); AsNES.PutSettings(_settings);
} }
private void trackBar5_ValueChanged(object sender, EventArgs e) private void trackBar5_ValueChanged(object sender, EventArgs e)
{ {
label10.Text = trackBar5.Value.ToString(); label10.Text = trackBar5.Value.ToString();
_settings.DMC = trackBar5.Value; _settings.DMC = trackBar5.Value;
Global.Emulator.PutSettings(_settings); AsNES.PutSettings(_settings);
} }
} }
} }

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
public NESSyncSettingsForm() public NESSyncSettingsForm()
{ {
InitializeComponent(); InitializeComponent();
SyncSettings = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); SyncSettings = ((NES)Global.Emulator).GetSyncSettings();
DTDB = new DataTableDictionaryBind<string, string>(SyncSettings.BoardProperties); DTDB = new DataTableDictionaryBind<string, string>(SyncSettings.BoardProperties);
dataGridView1.DataSource = DTDB.Table; dataGridView1.DataSource = DTDB.Table;

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
public NesControllerSettings() public NesControllerSettings()
{ {
InitializeComponent(); InitializeComponent();
SyncSettings = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); SyncSettings = ((NES)Global.Emulator).GetSyncSettings();
// TODO: use combobox extension and add descriptions to enum values // TODO: use combobox extension and add descriptions to enum values
comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray()); comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray());

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
private void QuickNesConfig_Load(object sender, EventArgs e) private void QuickNesConfig_Load(object sender, EventArgs e)
{ {
Settings = (QuickNES.QuickNESSettings)Global.Emulator.GetSettings(); Settings = ((QuickNES)Global.Emulator).GetSettings();
propertyGrid1.SelectedObject = Settings; propertyGrid1.SelectedObject = Settings;
SetPaletteImage(); SetPaletteImage();
} }

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
private void PCEControllerConfig_Load(object sender, EventArgs e) 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++) for (int i = 0; i < 5; i++)
{ {
Controls.Add(new Label Controls.Add(new Label
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var pceSettings = (PCEngine.PCESyncSettings)Global.Emulator.GetSyncSettings(); var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings();
Controls Controls
.OfType<CheckBox>() .OfType<CheckBox>()

View File

@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
private void PCEGraphicsConfig_Load(object sender, EventArgs e) 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; DispOBJ1.Checked = s.ShowOBJ1;
DispBG1.Checked = s.ShowBG1; DispBG1.Checked = s.ShowBG1;
@ -25,12 +25,13 @@ namespace BizHawk.Client.EmuHawk
private void OK_Click(object sender, EventArgs e) 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.ShowOBJ1 = DispOBJ1.Checked;
s.ShowBG1 = DispBG1.Checked; s.ShowBG1 = DispBG1.Checked;
s.ShowOBJ2 = DispOBJ2.Checked; s.ShowOBJ2 = DispOBJ2.Checked;
s.ShowBG2 = DispBG2.Checked; s.ShowBG2 = DispBG2.Checked;
Global.Emulator.PutSettings(s); pce.PutSettings(s);
Close(); Close();
} }
} }

View File

@ -355,7 +355,7 @@ namespace BizHawk.Client.EmuHawk
where TEmulator : IEmulator where TEmulator : IEmulator
{ {
// should we complain if we get a successful object from the config file, but it is the wrong type? // 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<TEmulator>() as TSetting ?? Global.Config.GetCoreSyncSettings<TEmulator>() as TSetting
?? new TSetting(); // guaranteed to give sensible defaults ?? new TSetting(); // guaranteed to give sensible defaults
} }
@ -365,7 +365,7 @@ namespace BizHawk.Client.EmuHawk
where TEmulator : IEmulator where TEmulator : IEmulator
{ {
// should we complain if we get a successful object from the config file, but it is the wrong type? // 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<TEmulator>() as TSetting ?? Global.Config.GetCoreSettings<TEmulator>() as TSetting
?? new TSetting(); // guaranteed to give sensible defaults ?? new TSetting(); // guaranteed to give sensible defaults
} }
@ -375,7 +375,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is TEmulator) if (Global.Emulator is TEmulator)
{ {
Global.Emulator.PutSettings(o); ((ISettable)Global.Emulator).PutSettings(o);
} }
else else
{ {

View File

@ -16,14 +16,14 @@ namespace BizHawk.Client.EmuHawk
private void SMSGraphicsConfig_Load(object sender, EventArgs e) 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; DispOBJ.Checked = s.DispOBJ;
DispBG.Checked = s.DispBG; DispBG.Checked = s.DispBG;
} }
private void OK_Click(object sender, EventArgs e) 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.DispOBJ = DispOBJ.Checked;
s.DispBG = DispBG.Checked; s.DispBG = DispBG.Checked;
GlobalWin.MainForm.PutCoreSettings(s); GlobalWin.MainForm.PutCoreSettings(s);

View File

@ -59,8 +59,8 @@ namespace BizHawk.Client.EmuHawk
public static void DoSettingsDialog(IWin32Window owner) public static void DoSettingsDialog(IWin32Window owner)
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = ((LibsnesCore)Global.Emulator).GetSettings();
var ss = (LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((LibsnesCore)Global.Emulator).GetSyncSettings();
var dlg = new SNESOptions var dlg = new SNESOptions
{ {
UseRingBuffer = s.UseRingBuffer, UseRingBuffer = s.UseRingBuffer,

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
private void TI83PaletteConfig_Load(object sender, EventArgs e) 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 // Alpha hack because Winform is lame with colors
BackgroundPanel.BackColor = Color.FromArgb(255, Color.FromArgb((int)s.BGColor)); 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) 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.BGColor = (uint)BackgroundPanel.BackColor.ToArgb();
s.ForeColor = (uint)ForeGroundPanel.BackColor.ToArgb(); s.ForeColor = (uint)ForeGroundPanel.BackColor.ToArgb();
Global.Emulator.PutSettings(s); ti83.PutSettings(s);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();

View File

@ -1350,7 +1350,7 @@ namespace BizHawk.Client.EmuHawk
if (suppression) return; if (suppression) return;
var pal = (SnesColors.ColorType)comboPalette.SelectedValue; var pal = (SnesColors.ColorType)comboPalette.SelectedValue;
Console.WriteLine("set {0}", pal); Console.WriteLine("set {0}", pal);
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = ((LibsnesCore)Global.Emulator).GetSettings();
s.Palette = pal.ToString(); s.Palette = pal.ToString();
if (currentSnesCore != null) if (currentSnesCore != null)
{ {
@ -1364,7 +1364,7 @@ namespace BizHawk.Client.EmuHawk
void RefreshBGENCheckStatesFromConfig() void RefreshBGENCheckStatesFromConfig()
{ {
var s = (LibsnesCore.SnesSettings)Global.Emulator.GetSettings(); var s = ((LibsnesCore)Global.Emulator).GetSettings();
checkEN0_BG1.Checked = s.ShowBG1_0; checkEN0_BG1.Checked = s.ShowBG1_0;
checkEN0_BG2.Checked = s.ShowBG2_0; checkEN0_BG2.Checked = s.ShowBG2_0;
checkEN0_BG3.Checked = s.ShowBG3_0; checkEN0_BG3.Checked = s.ShowBG3_0;
@ -1382,7 +1382,8 @@ namespace BizHawk.Client.EmuHawk
private void checkEN_CheckedChanged(object sender, EventArgs e) private void checkEN_CheckedChanged(object sender, EventArgs e)
{ {
if(suppression) return; 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_BG1) s.ShowBG1_0 = checkEN0_BG1.Checked;
if (sender == checkEN0_BG2) s.ShowBG2_0 = checkEN0_BG2.Checked; if (sender == checkEN0_BG2) s.ShowBG2_0 = checkEN0_BG2.Checked;
if (sender == checkEN0_BG3) s.ShowBG3_0 = checkEN0_BG3.Checked; if (sender == checkEN0_BG3) s.ShowBG3_0 = checkEN0_BG3.Checked;
@ -1414,7 +1415,7 @@ namespace BizHawk.Client.EmuHawk
RefreshBGENCheckStatesFromConfig(); RefreshBGENCheckStatesFromConfig();
suppression = false; suppression = false;
} }
Global.Emulator.PutSettings(s); snes.PutSettings(s);
} }
private void lblEnPrio0_Click(object sender, EventArgs e) private void lblEnPrio0_Click(object sender, EventArgs e)

View File

@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public IEnumerable<PadSchema> GetPadSchemas() public IEnumerable<PadSchema> GetPadSchemas()
{ {
var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); var ss = ((N64)Global.Emulator).GetSyncSettings();
for (var i = 0; i < 4; i++) for (var i = 0; i < 4; i++)
{ {
if (ss.Controllers[i].IsConnected) if (ss.Controllers[i].IsConnected)

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator is NES) 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 core = (Global.Emulator as NES);
var isFds = core.BoardName == "FDS"; var isFds = core.BoardName == "FDS";
if (ss.Controls.Famicom) if (ss.Controls.Famicom)

View File

@ -118,11 +118,6 @@ namespace BizHawk.Emulation.Common
get; get;
set; 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 public class NullSound : ISoundProvider

View File

@ -126,9 +126,34 @@ namespace BizHawk.Emulation.Common
/// the corecomm module in use by this core. /// the corecomm module in use by this core.
/// </summary> /// </summary>
CoreComm CoreComm { get; } CoreComm CoreComm { get; }
}
// ====settings interface==== public interface IDebuggable : IEmulator
{
/// <summary>
/// Returns a list of Cpu registers and their current state
/// </summary>
/// <returns></returns>
Dictionary<string, int> GetCpuFlagsAndRegisters();
/// <summary>
/// Sets a given Cpu register to the given value
/// </summary>
/// <param name="register"></param>
/// <param name="value"></param>
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<TSettings, TSync> : ISettable
{
// in addition to these methods, it's expected that the constructor or Load() method // 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 // 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) // (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) /// (unless the object is later passed to PutSettings)
/// </summary> /// </summary>
/// <returns>a json-serializable object</returns> /// <returns>a json-serializable object</returns>
object GetSettings(); new TSettings GetSettings();
/// <summary> /// <summary>
/// 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 /// 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) /// (unless the object is later passed to PutSyncSettings)
/// </summary> /// </summary>
/// <returns>a json-serializable object</returns> /// <returns>a json-serializable object</returns>
object GetSyncSettings(); new TSync GetSyncSettings();
/// <summary> /// <summary>
/// change the core settings, excepting movie settings /// change the core settings, excepting movie settings
/// </summary> /// </summary>
/// <param name="o">an object of the same type as the return for GetSettings</param> /// <param name="o">an object of the same type as the return for GetSettings</param>
/// <returns>true if a core reboot will be required to make the changes effective</returns> /// <returns>true if a core reboot will be required to make the changes effective</returns>
bool PutSettings(object o); new bool PutSettings(TSettings o);
/// <summary> /// <summary>
/// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING /// changes the movie-sync relevant settings. THIS SHOULD NEVER BE CALLED WHILE RECORDING
@ -163,24 +188,8 @@ namespace BizHawk.Emulation.Common
/// </summary> /// </summary>
/// <param name="o">an object of the same type as the return for GetSyncSettings</param> /// <param name="o">an object of the same type as the return for GetSyncSettings</param>
/// <returns>true if a core reboot will be required to make the changes effective</returns> /// <returns>true if a core reboot will be required to make the changes effective</returns>
bool PutSyncSettings(object o); new bool PutSyncSettings(TSync o);
} }
public interface IDebuggable : IEmulator
{
/// <summary>
/// Returns a list of Cpu registers and their current state
/// </summary>
/// <returns></returns>
Dictionary<string, int> GetCpuFlagsAndRegisters();
/// <summary>
/// Sets a given Cpu register to the given value
/// </summary>
/// <param name="register"></param>
/// <param name="value"></param>
void SetCpuRegister(string register, int value);
}
public enum DisplayType { NTSC, PAL, DENDY } public enum DisplayType { NTSC, PAL, DENDY }
} }

View File

@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Calculators
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public class TI83 : IEmulator, IMemoryDomains, IDebuggable public class TI83 : IEmulator, IMemoryDomains, IDebuggable, ISettable<TI83.TI83Settings, object>
{ {
//hardware //hardware
private readonly Z80A cpu = new Z80A(); private readonly Z80A cpu = new Z80A();
@ -350,7 +350,7 @@ namespace BizHawk.Emulation.Cores.Calculators
[CoreConstructor("TI83")] [CoreConstructor("TI83")]
public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings) public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings)
{ {
PutSettings(Settings ?? new TI83Settings()); PutSettings((TI83Settings)Settings ?? new TI83Settings());
CoreComm = comm; CoreComm = comm;
cpu.ReadMemory = ReadMemory; cpu.ReadMemory = ReadMemory;
@ -997,14 +997,23 @@ namespace BizHawk.Emulation.Cores.Calculators
TI83Settings Settings; 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; return false;
} }
object ISettable.GetSettings()
{
return GetSettings();
}
bool ISettable.PutSettings(object o) {
return PutSettings((TI83Settings)o);
}
public object GetSyncSettings() { return null; } public object GetSyncSettings() { return null; }
public bool PutSyncSettings(object o) { return false; } public bool PutSyncSettings(object o) { return false; }

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
PAL PAL
} }
sealed public partial class C64 : IEmulator, IDebuggable sealed public partial class C64 : IEmulator, IDebuggable
{ {
private Motherboard board; private Motherboard board;
private bool loadPrg; private bool loadPrg;

View File

@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{ {
board.inputRead = false; board.inputRead = false;
board.PollInput(); board.PollInput();
board.cpu.LagCycles = 0; board.cpu.LagCycles = 0;
for (int count = 0; count < cyclesPerFrame; count++) 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<int, byte>(disk.PeekRam), new Action<int, byte>(disk.PokeRam))); //domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekRam), new Action<int, byte>(disk.PokeRam)));
memoryDomains = new MemoryDomainList(domains); 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; }
} }
} }

View File

@ -1,42 +1,62 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using BizHawk.Emulation.Common;
using Newtonsoft.Json; using Newtonsoft.Json;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600 namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
public partial class Atari2600 public partial class Atari2600 : ISettable<Atari2600.A2600Settings, Atari2600.A2600SyncSettings>
{ {
public object GetSettings() public A2600Settings GetSettings()
{ {
return Settings.Clone(); return Settings.Clone();
} }
public object GetSyncSettings() public A2600SyncSettings GetSyncSettings()
{ {
return SyncSettings.Clone(); return SyncSettings.Clone();
} }
public bool PutSettings(object o) public bool PutSettings(A2600Settings o)
{ {
A2600Settings newSettings = (A2600Settings)o; if (Settings == null || Settings.SECAMColors != o.SECAMColors)
if (Settings == null || Settings.SECAMColors != newSettings.SECAMColors)
{ {
if (_tia != null) if (_tia != null)
_tia.SetSECAM(newSettings.SECAMColors); _tia.SetSECAM(o.SECAMColors);
} }
Settings = newSettings; Settings = o;
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(A2600SyncSettings o)
{ {
SyncSettings = (A2600SyncSettings)o; SyncSettings = o;
return false; 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 public class A2600Settings
{ {
[JsonIgnore] [JsonIgnore]

View File

@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public partial class Atari2600 : IEmulator, IMemoryDomains, IDebuggable public partial class Atari2600 : IEmulator, IMemoryDomains, IDebuggable
{ {
private readonly GameInfo _game; private readonly GameInfo _game;
private bool _islag = true; private bool _islag = true;

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
portedVersion: "v1.5", portedVersion: "v1.5",
portedUrl: "http://emu7800.sourceforge.net/" portedUrl: "http://emu7800.sourceforge.net/"
)] )]
public partial class Atari7800 : IEmulator, IMemoryDomains, IDebuggable public partial class Atari7800 : IEmulator, IMemoryDomains, IDebuggable
{ {
// TODO: // TODO:
// some things don't work when you try to plug in a 2600 game // 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 #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; }
} }
} }

View File

@ -366,30 +366,5 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
} }
#endregion #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
} }
} }

View File

@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public sealed partial class ColecoVision : IEmulator, IMemoryDomains, IDebuggable public sealed partial class ColecoVision : IEmulator, IMemoryDomains, IDebuggable, ISettable<object, ColecoVision.ColecoSyncSettings>
{ {
// ROM // ROM
public byte[] RomData; public byte[] RomData;
@ -239,16 +239,25 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public void EndAsyncSound() { } public void EndAsyncSound() { }
public object GetSettings() { return null; } 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 PutSettings(object o) { return false; }
public bool PutSyncSettings(object o) public bool PutSyncSettings(ColecoSyncSettings o)
{ {
var n = (ColecoSyncSettings)o; bool ret = o.SkipBiosIntro != SyncSettings.SkipBiosIntro;
bool ret = n.SkipBiosIntro != SyncSettings.SkipBiosIntro; SyncSettings = o;
SyncSettings = n;
return ret; return ret;
} }
object ISettable.GetSyncSettings()
{
return GetSyncSettings();
}
bool ISettable.PutSyncSettings(object o)
{
return PutSettings((ColecoSyncSettings)o);
}
ColecoSyncSettings SyncSettings; ColecoSyncSettings SyncSettings;
public class ColecoSyncSettings public class ColecoSyncSettings

View File

@ -205,10 +205,5 @@ namespace BizHawk.Emulation.Cores.Intellivision
public void Dispose() 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; }
} }
} }

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
isPorted: true, isPorted: true,
isReleased: false isReleased: false
)] )]
public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, IDebuggable public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider, IGBAGPUViewable, IMemoryDomains, IDebuggable
{ {
public Dictionary<string, int> GetCpuFlagsAndRegisters() public Dictionary<string, int> GetCpuFlagsAndRegisters()
{ {
@ -544,10 +544,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
} }
#endregion #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; }
} }
} }

View File

@ -14,7 +14,8 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBA namespace BizHawk.Emulation.Cores.Nintendo.GBA
{ {
[CoreAttributes("VBA-Next", "many authors", true, true, "cd508312a29ed8c29dacac1b11c2dce56c338a54", "https://github.com/libretro/vba-next")] [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<object, VBANext.SyncSettings>
{ {
IntPtr Core; IntPtr Core;
@ -399,7 +400,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
return null; return null;
} }
public object GetSyncSettings() public SyncSettings GetSyncSettings()
{ {
return _SyncSettings.Clone(); return _SyncSettings.Clone();
} }
@ -412,14 +413,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(SyncSettings o)
{ {
var s = (SyncSettings)o; bool ret = SyncSettings.NeedsReboot(o, _SyncSettings);
bool ret = SyncSettings.NeedsReboot(s, _SyncSettings); _SyncSettings = o;
_SyncSettings = s;
return ret; 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 public class SyncSettings
{ {
[DisplayName("Skip BIOS")] [DisplayName("Skip BIOS")]

View File

@ -22,7 +22,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
portedVersion: "SVN 344", portedVersion: "SVN 344",
portedUrl: "http://gambatte.sourceforge.net/" portedUrl: "http://gambatte.sourceforge.net/"
)] )]
public class Gameboy : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable public class Gameboy : IEmulator, IVideoProvider, ISyncSoundProvider,
IMemoryDomains, IDebuggable, ISettable<Gameboy.GambatteSettings, Gameboy.GambatteSyncSettings>
{ {
#region ALL SAVESTATEABLE STATE GOES HERE #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?)"); 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) // set real default colors (before anyone mucks with them at all)
PutSettings(Settings ?? new GambatteSettings()); PutSettings((GambatteSettings)Settings ?? new GambatteSettings());
InitSound(); InitSound();
@ -986,11 +987,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
GambatteSettings _Settings; GambatteSettings _Settings;
GambatteSyncSettings _SyncSettings; GambatteSyncSettings _SyncSettings;
public object GetSettings() { return _Settings.Clone(); } public GambatteSettings GetSettings() { return _Settings.Clone(); }
public object GetSyncSettings() { return _SyncSettings.Clone(); } public GambatteSyncSettings GetSyncSettings() { return _SyncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(GambatteSettings o)
{ {
_Settings = (GambatteSettings)o; _Settings = o;
if (IsCGBMode()) if (IsCGBMode())
SetCGBColors(_Settings.CGBColors); SetCGBColors(_Settings.CGBColors);
else else
@ -998,14 +999,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(GambatteSyncSettings o)
{ {
var s = (GambatteSyncSettings)o; bool ret = GambatteSyncSettings.NeedsReboot(_SyncSettings, o);
bool ret = GambatteSyncSettings.NeedsReboot(_SyncSettings, s); _SyncSettings = o;
_SyncSettings = s;
return ret; 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 public class GambatteSettings
{ {
private static readonly int[] DefaultPalette = new[] private static readonly int[] DefaultPalette = new[]

View File

@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
isPorted: true, isPorted: true,
isReleased: true isReleased: true
)] )]
public class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider, IDebuggable public class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider,
IDebuggable, ISettable<GambatteLink.GambatteLinkSettings, GambatteLink.GambatteLinkSyncSettings>
{ {
bool disposed = false; bool disposed = false;
@ -516,31 +517,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
#region settings #region settings
public object GetSettings() public GambatteLinkSettings GetSettings()
{ {
return new GambatteLinkSettings return new GambatteLinkSettings
( (
(Gameboy.GambatteSettings)L.GetSettings(), L.GetSettings(),
(Gameboy.GambatteSettings)R.GetSettings() R.GetSettings()
); );
} }
public object GetSyncSettings() public GambatteLinkSyncSettings GetSyncSettings()
{ {
return new GambatteLinkSyncSettings return new GambatteLinkSyncSettings
( (
(Gameboy.GambatteSyncSettings)L.GetSyncSettings(), L.GetSyncSettings(),
(Gameboy.GambatteSyncSettings)R.GetSyncSettings() R.GetSyncSettings()
); );
} }
public bool PutSettings(object o) public bool PutSettings(GambatteLinkSettings o)
{ {
var s = (GambatteLinkSettings)o; return L.PutSettings(o.L) || R.PutSettings(o.R);
return L.PutSettings(s.L) || R.PutSettings(s.R);
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(GambatteLinkSyncSettings o)
{ {
var s = (GambatteLinkSyncSettings)o; return L.PutSyncSettings(o.L) || R.PutSyncSettings(o.R);
return L.PutSyncSettings(s.L) || R.PutSyncSettings(s.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 public class GambatteLinkSettings

View File

@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
portedVersion: "2.0", portedVersion: "2.0",
portedUrl: "https://code.google.com/p/mupen64plus/" portedUrl: "https://code.google.com/p/mupen64plus/"
)] )]
public partial class N64 : IEmulator, IMemoryDomains, IDebuggable public partial class N64 : IEmulator, IMemoryDomains, IDebuggable,
ISettable<N64Settings, N64SyncSettings>
{ {
private readonly N64Input _inputProvider; private readonly N64Input _inputProvider;
private readonly N64VideoProvider _videoProvider; private readonly N64VideoProvider _videoProvider;
@ -481,29 +482,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
#region Settings #region Settings
public object GetSettings() public N64Settings GetSettings()
{ {
return _settings.Clone(); return _settings.Clone();
} }
public object GetSyncSettings() public N64SyncSettings GetSyncSettings()
{ {
return _syncSettings.Clone(); return _syncSettings.Clone();
} }
public bool PutSettings(object o) public bool PutSettings(N64Settings o)
{ {
_settings = (N64Settings)o; _settings = o;
return true; return true;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(N64SyncSettings o)
{ {
_syncSettings = (N64SyncSettings)o; _syncSettings = o;
SetControllerButtons(); SetControllerButtons();
return true; 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() private void SetControllerButtons()
{ {
ControllerDefinition.BoolButtons.Clear(); ControllerDefinition.BoolButtons.Clear();

View File

@ -17,7 +17,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public partial class NES : IEmulator, IMemoryDomains, IDebuggable public partial class NES : IEmulator, IMemoryDomains, IDebuggable,
ISettable<NES.NESSettings, NES.NESSyncSettings>
{ {
static readonly bool USE_DATABASE = true; static readonly bool USE_DATABASE = true;
public RomStatus RomStatus; public RomStatus RomStatus;
@ -46,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
CoreComm.UsesDriveLed = true; CoreComm.UsesDriveLed = true;
(board as FDS).SetDriveLightCallback((val) => CoreComm.DriveLED = val); (board as FDS).SetDriveLightCallback((val) => CoreComm.DriveLED = val);
} }
PutSettings(Settings ?? new NESSettings()); PutSettings((NESSettings)Settings ?? new NESSettings());
} }
private NES() private NES()
@ -931,11 +932,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
NESSettings Settings = new NESSettings(); NESSettings Settings = new NESSettings();
NESSyncSettings SyncSettings = new NESSyncSettings(); NESSyncSettings SyncSettings = new NESSyncSettings();
public object GetSettings() { return Settings.Clone(); } public NESSettings GetSettings() { return Settings.Clone(); }
public object GetSyncSettings() { return SyncSettings.Clone(); } public NESSyncSettings GetSyncSettings() { return SyncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(NESSettings o)
{ {
Settings = (NESSettings)o; Settings = o;
if (Settings.ClipLeftAndRight) if (Settings.ClipLeftAndRight)
{ {
videoProvider.left = 8; videoProvider.left = 8;
@ -959,14 +960,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(NESSyncSettings o)
{ {
var n = (NESSyncSettings)o; bool ret = NESSyncSettings.NeedsReboot(SyncSettings, o);
bool ret = NESSyncSettings.NeedsReboot(SyncSettings, n); SyncSettings = o;
SyncSettings = n;
return ret; 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 class NESSettings
{ {
public bool AllowMoreThanEightSprites = false; public bool AllowMoreThanEightSprites = false;

View File

@ -21,7 +21,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
portedVersion: "0.7.0", portedVersion: "0.7.0",
portedUrl: "https://github.com/kode54/QuickNES" portedUrl: "https://github.com/kode54/QuickNES"
)] )]
public class QuickNES : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable public class QuickNES : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains,
IDebuggable, ISettable<QuickNES.QuickNESSettings, QuickNES.QuickNESSyncSettings>
{ {
#region FPU precision #region FPU precision
@ -84,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
BoardName = mappername; BoardName = mappername;
CoreComm.VsyncNum = 39375000; CoreComm.VsyncNum = 39375000;
CoreComm.VsyncDen = 655171; CoreComm.VsyncDen = 655171;
PutSettings(Settings ?? new QuickNESSettings()); PutSettings((QuickNESSettings)Settings ?? new QuickNESSettings());
ComputeBootGod(); ComputeBootGod();
} }
@ -502,30 +503,50 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
} }
} }
public object GetSettings() public QuickNESSettings GetSettings()
{ {
return _Settings.Clone(); return _Settings.Clone();
} }
public object GetSyncSettings() public QuickNESSyncSettings GetSyncSettings()
{ {
return new QuickNESSyncSettings(); 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); LibQuickNES.qn_set_sprite_limit(Context, _Settings.NumSprites);
RecalculateCrops(); RecalculateCrops();
CalculatePalette(); CalculatePalette();
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(QuickNESSyncSettings o)
{ {
return false; 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 #endregion
public void Dispose() public void Dispose()

View File

@ -66,7 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
portedVersion: "v87", portedVersion: "v87",
portedUrl: "http://byuu.org/" portedUrl: "http://byuu.org/"
)] )]
public unsafe class LibsnesCore : IEmulator, IVideoProvider, IMemoryDomains, IDebuggable public unsafe class LibsnesCore : IEmulator, IVideoProvider, IMemoryDomains,
IDebuggable, ISettable<LibsnesCore.SnesSettings, LibsnesCore.SnesSyncSettings>
{ {
public bool IsSGB { get; private set; } public bool IsSGB { get; private set; }
@ -1183,25 +1184,43 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
SnesSettings Settings; SnesSettings Settings;
SnesSyncSettings SyncSettings; SnesSyncSettings SyncSettings;
public object GetSettings() { return Settings.Clone(); } public SnesSettings GetSettings() { return Settings.Clone(); }
public object GetSyncSettings() { return SyncSettings.Clone(); } public SnesSyncSettings GetSyncSettings() { return SyncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(SnesSettings o)
{ {
SnesSettings n = (SnesSettings)o; bool refreshneeded = o.Palette != Settings.Palette;
bool refreshneeded = n.Palette != Settings.Palette; Settings = o;
Settings = n;
if (refreshneeded) if (refreshneeded)
RefreshPalette(); RefreshPalette();
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(SnesSyncSettings o)
{ {
SnesSyncSettings n = (SnesSyncSettings)o; bool ret = o.Profile != SyncSettings.Profile;
bool ret = n.Profile != SyncSettings.Profile; SyncSettings = o;
SyncSettings = n;
return ret; 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 class SnesSettings
{ {
public bool ShowBG1_0 = true; public bool ShowBG1_0 = true;

View File

@ -126,30 +126,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
#endregion #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 #region IVideoProvider
private int[] _vbuff = new int[512 * 480]; private int[] _vbuff = new int[512 * 480];

View File

@ -22,7 +22,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public sealed partial class PCEngine : IEmulator, IMemoryDomains, IDebuggable public sealed partial class PCEngine : IEmulator, IMemoryDomains,
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>
{ {
// ROM // ROM
public byte[] RomData; public byte[] RomData;
@ -567,31 +568,49 @@ namespace BizHawk.Emulation.Cores.PCEngine
public PCESettings _settings; public PCESettings _settings;
private PCESyncSettings _syncSettings; private PCESyncSettings _syncSettings;
public object GetSettings() { return _settings.Clone(); } public PCESettings GetSettings() { return _settings.Clone(); }
public object GetSyncSettings() { return _syncSettings.Clone(); } public PCESyncSettings GetSyncSettings() { return _syncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(PCESettings o)
{ {
PCESettings n = (PCESettings)o;
bool ret; bool ret;
if (n.ArcadeCardRewindHack != _settings.ArcadeCardRewindHack || if (o.ArcadeCardRewindHack != _settings.ArcadeCardRewindHack ||
n.EqualizeVolume != _settings.EqualizeVolume) o.EqualizeVolume != _settings.EqualizeVolume)
ret = true; ret = true;
else else
ret = false; ret = false;
_settings = n; _settings = o;
return ret; return ret;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(PCESyncSettings o)
{ {
var newsyncsettings = (PCESyncSettings)o; bool ret = PCESyncSettings.NeedsReboot(o, _syncSettings);
bool ret = PCESyncSettings.NeedsReboot(newsyncsettings, _syncSettings); _syncSettings = o;
_syncSettings = newsyncsettings;
// SetControllerButtons(); // not safe to change the controller during emulation, so instead make it a reboot event // SetControllerButtons(); // not safe to change the controller during emulation, so instead make it a reboot event
return ret; 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 class PCESettings
{ {
public bool ShowBG1 = true; public bool ShowBG1 = true;

View File

@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
isPorted: false, isPorted: false,
isReleased: false isReleased: false
)] )]
public sealed partial class Genesis : IEmulator, IMemoryDomains, IDebuggable public sealed partial class Genesis : IEmulator, IMemoryDomains, IDebuggable
{ {
private int _lagcount = 0; private int _lagcount = 0;
private bool lagged = true; private bool lagged = true;
@ -138,8 +138,8 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
Musashi.Reset(); Musashi.Reset();
VDP.GetPC = () => Musashi.PC; VDP.GetPC = () => Musashi.PC;
#else #else
MainCPU.Reset(); MainCPU.Reset();
VDP.GetPC = () => MainCPU.PC; VDP.GetPC = () => MainCPU.PC;
#endif #endif
InitializeCartHardware(game); InitializeCartHardware(game);
} }
@ -224,7 +224,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
#if MUSASHI #if MUSASHI
Musashi.Execute(cycles); Musashi.Execute(cycles);
#else #else
MainCPU.ExecuteCycles(cycles); MainCPU.ExecuteCycles(cycles);
#endif #endif
} }
@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
#if MUSASHI #if MUSASHI
Musashi.SetIRQ(irq); Musashi.SetIRQ(irq);
#else #else
MainCPU.Interrupt = irq; MainCPU.Interrupt = irq;
#endif #endif
} }
@ -491,10 +491,5 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
public MemoryDomainList MemoryDomains { get { return memoryDomains; } } public MemoryDomainList MemoryDomains { get { return memoryDomains; } }
public void Dispose() { } 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; }
} }
} }

View File

@ -27,7 +27,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
isPorted: false, isPorted: false,
isReleased: true isReleased: true
)] )]
public sealed partial class SMS : IEmulator, IMemoryDomains, IDebuggable public sealed partial class SMS : IEmulator, IMemoryDomains,
IDebuggable, ISettable<SMS.SMSSettings, SMS.SMSSyncSettings>
{ {
// Constants // Constants
public const int BankSize = 16384; public const int BankSize = 16384;
@ -101,14 +102,14 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
IsGameGear = game.System == "GG"; IsGameGear = game.System == "GG";
IsSG1000 = game.System == "SG"; IsSG1000 = game.System == "SG";
RomData = rom; RomData = rom;
CoreComm.CpuTraceAvailable = true; CoreComm.CpuTraceAvailable = true;
if (RomData.Length % BankSize != 0) if (RomData.Length % BankSize != 0)
Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
RomBanks = (byte)(RomData.Length / BankSize); RomBanks = (byte)(RomData.Length / BankSize);
DisplayType = DetermineDisplayType(SyncSettings.DisplayType, game.Region); DisplayType = DetermineDisplayType(SyncSettings.DisplayType, game.Region);
if (game["PAL"] && DisplayType != DisplayType.PAL) if (game["PAL"] && DisplayType != DisplayType.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."); CoreComm.Notify("Region was forced to Japan for game compatibility.");
} }
if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear) if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear)
HasYM2413 = true; HasYM2413 = true;
if (Controller == null) if (Controller == null)
Controller = NullController.GetNullController(); Controller = NullController.GetNullController();
Cpu = new Z80A(); Cpu = new Z80A();
Cpu.RegisterSP = 0xDFF0; Cpu.RegisterSP = 0xDFF0;
Cpu.ReadHardware = ReadPort; Cpu.ReadHardware = ReadPort;
Cpu.WriteHardware = WritePort; Cpu.WriteHardware = WritePort;
Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType);
PSG = new SN76489(); PSG = new SN76489();
YM2413 = new YM2413(); YM2413 = new YM2413();
SoundMixer = new SoundMixer(YM2413, PSG); SoundMixer = new SoundMixer(YM2413, PSG);
if (HasYM2413 && game["WhenFMDisablePSG"]) if (HasYM2413 && game["WhenFMDisablePSG"])
SoundMixer.DisableSource(PSG); SoundMixer.DisableSource(PSG);
ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG; ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG;
SystemRam = new byte[0x2000]; SystemRam = new byte[0x2000];
if (game["CMMapper"]) if (game["CMMapper"])
InitCodeMastersMapper(); InitCodeMastersMapper();
@ -166,20 +167,20 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else else
InitSegaMapper(); InitSegaMapper();
if (Settings.ForceStereoSeparation && !IsGameGear) if (Settings.ForceStereoSeparation && !IsGameGear)
{ {
if (game["StereoByte"]) if (game["StereoByte"])
{ {
ForceStereoByte = byte.Parse(game.OptionValue("StereoByte")); ForceStereoByte = byte.Parse(game.OptionValue("StereoByte"));
} }
PSG.StereoPanning = ForceStereoByte; PSG.StereoPanning = ForceStereoByte;
} }
if (SyncSettings.AllowOverlock && game["OverclockSafe"]) if (SyncSettings.AllowOverlock && game["OverclockSafe"])
Vdp.IPeriod = 512; Vdp.IPeriod = 512;
if (Settings.SpriteLimit) if (Settings.SpriteLimit)
Vdp.SpriteLimit = true; Vdp.SpriteLimit = true;
if (game["3D"]) if (game["3D"])
IsGame3D = true; IsGame3D = true;
@ -593,23 +594,41 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public void Dispose() { } public void Dispose() { }
public object GetSettings() { return Settings.Clone(); } public SMSSettings GetSettings() { return Settings.Clone(); }
public object GetSyncSettings() { return SyncSettings.Clone(); } public SMSSyncSettings GetSyncSettings() { return SyncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(SMSSettings o)
{ {
SMSSettings n = (SMSSettings)o; bool ret = SMSSettings.RebootNeeded(Settings, o);
bool ret = SMSSettings.RebootNeeded(Settings, n); Settings = o;
Settings = n;
return ret; return ret;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(SMSSyncSettings o)
{ {
SMSSyncSettings n = (SMSSyncSettings)o; bool ret = SMSSyncSettings.RebootNeeded(SyncSettings, o);
bool ret = SMSSyncSettings.RebootNeeded(SyncSettings, n); SyncSettings = o;
SyncSettings = n;
return ret; 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 SMSSettings Settings;
public SMSSyncSettings SyncSettings; public SMSSyncSettings SyncSettings;

View File

@ -23,7 +23,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
portedVersion: "9.12", portedVersion: "9.12",
portedUrl: "http://yabause.org" portedUrl: "http://yabause.org"
)] )]
public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains,
ISettable<object, Yabause.SaturnSyncSettings>
{ {
public static ControllerDefinition SaturnController = new ControllerDefinition public static ControllerDefinition SaturnController = new ControllerDefinition
{ {
@ -707,14 +708,13 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
SaturnSyncSettings SyncSettings; SaturnSyncSettings SyncSettings;
public object GetSettings() { return null; } 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 PutSettings(object o) { return false; }
public bool PutSyncSettings(object o) public bool PutSyncSettings(SaturnSyncSettings o)
{ {
var n = (SaturnSyncSettings)o; bool ret = SaturnSyncSettings.NeedsReboot(SyncSettings, o);
bool ret = SaturnSyncSettings.NeedsReboot(SyncSettings, n);
SyncSettings = n; SyncSettings = o;
if (GLMode && SyncSettings.UseGL) if (GLMode && SyncSettings.UseGL)
if (SyncSettings.DispFree) if (SyncSettings.DispFree)
@ -724,6 +724,26 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
return ret; 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 public class SaturnSyncSettings
{ {
[DisplayName("Open GL Mode")] [DisplayName("Open GL Mode")]

View File

@ -24,7 +24,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
portedVersion: "r874", portedVersion: "r874",
portedUrl: "https://code.google.com/p/genplus-gx/" 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<GPGX.GPGXSettings, GPGX.GPGXSyncSettings>
{ {
static GPGX AttachedCore = null; static GPGX AttachedCore = null;
@ -163,7 +164,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
if (CD != null) if (CD != null)
CoreComm.UsesDriveLed = true; CoreComm.UsesDriveLed = true;
PutSettings(Settings ?? new GPGXSettings()); PutSettings((GPGXSettings)Settings ?? new GPGXSettings());
InitMemCallbacks(); InitMemCallbacks();
KillMemCallbacks(); KillMemCallbacks();
@ -786,23 +787,41 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
GPGXSyncSettings _SyncSettings; GPGXSyncSettings _SyncSettings;
GPGXSettings _Settings; GPGXSettings _Settings;
public object GetSettings() { return _Settings.Clone(); } public GPGXSettings GetSettings() { return _Settings.Clone(); }
public object GetSyncSettings() { return _SyncSettings.Clone(); } public GPGXSyncSettings GetSyncSettings() { return _SyncSettings.Clone(); }
public bool PutSettings(object o) public bool PutSettings(GPGXSettings o)
{ {
_Settings = (GPGXSettings)o; _Settings = o;
LibGPGX.gpgx_set_draw_mask(_Settings.GetDrawMask()); LibGPGX.gpgx_set_draw_mask(_Settings.GetDrawMask());
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(GPGXSyncSettings o)
{ {
bool ret; bool ret = GPGXSyncSettings.NeedsReboot(_SyncSettings, o);
var n = (GPGXSyncSettings)o; _SyncSettings = o;
ret = GPGXSyncSettings.NeedsReboot(_SyncSettings, n);
_SyncSettings = n;
return ret; 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 public class GPGXSettings
{ {
[DisplayName("Background Layer A")] [DisplayName("Background Layer A")]

View File

@ -213,10 +213,5 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
public void DiscardSamples() 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; }
} }
} }

View File

@ -283,10 +283,5 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
public int MaxVolume { get; set; } public int MaxVolume { get; set; }
private List<MemoryDomain> memoryDomains = new List<MemoryDomain>(); private List<MemoryDomain> memoryDomains = new List<MemoryDomain>();
public MemoryDomainList MemoryDomains { get; private set; } 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; }
} }
} }

View File

@ -12,7 +12,8 @@ using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.WonderSwan namespace BizHawk.Emulation.Cores.WonderSwan
{ {
[CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.34.1", "http://mednafen.sourceforge.net/")] [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<WonderSwan.Settings, WonderSwan.SyncSettings>
{ {
#region Controller #region Controller
@ -496,32 +497,51 @@ namespace BizHawk.Emulation.Cores.WonderSwan
} }
} }
public object GetSettings() public Settings GetSettings()
{ {
return _Settings.Clone(); return _Settings.Clone();
} }
public object GetSyncSettings() public SyncSettings GetSyncSettings()
{ {
return _SyncSettings.Clone(); return _SyncSettings.Clone();
} }
public bool PutSettings(object o) public bool PutSettings(Settings o)
{ {
_Settings = (Settings)o; _Settings = o;
var native = _Settings.GetNativeSettings(); var native = _Settings.GetNativeSettings();
BizSwan.bizswan_putsettings(Core, ref native); BizSwan.bizswan_putsettings(Core, ref native);
return false; return false;
} }
public bool PutSyncSettings(object o) public bool PutSyncSettings(SyncSettings o)
{ {
var newsettings = (SyncSettings)o; bool ret = SyncSettings.NeedsReboot(o, _SyncSettings);
bool ret = SyncSettings.NeedsReboot(newsettings, _SyncSettings); _SyncSettings = o;
_SyncSettings = newsettings;
return ret; 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 #endregion
#region IVideoProvider #region IVideoProvider

View File

@ -562,10 +562,5 @@ namespace BizHawk.Emulation.Cores
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }
#endregion #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; }
} }
} }