diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 66441ef72a..3d8a3c6ad4 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -42,7 +42,8 @@ False ..\output\dll\LuaInterface.dll - + + False ..\Newtonsoft.Json.dll diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index 8e88381e55..4cf7f8c938 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -96,10 +96,10 @@ namespace BizHawk.Client.Common target.CoreFileProvider = cfp; cfp.FirmwareManager = Global.FirmwareManager; - target.NES_BackdropColor = Global.Config.NESBackgroundColor; - target.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites; - target.NES_ShowBG = Global.Config.NESDispBackground; - target.NES_ShowOBJ = Global.Config.NESDispSprites; + //target.NES_BackdropColor = Global.Config.NESBackgroundColor; + //target.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites; + //target.NES_ShowBG = Global.Config.NESDispBackground; + //target.NES_ShowOBJ = Global.Config.NESDispSprites; target.PCE_ShowBG1 = Global.Config.PCEDispBG1; target.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1; target.PCE_ShowBG2 = Global.Config.PCEDispBG2; diff --git a/BizHawk.Client.Common/RecentFiles.cs b/BizHawk.Client.Common/RecentFiles.cs index 270ab116d8..cf598d39b6 100644 --- a/BizHawk.Client.Common/RecentFiles.cs +++ b/BizHawk.Client.Common/RecentFiles.cs @@ -4,10 +4,11 @@ using System.Linq; namespace BizHawk.Client.Common { + [Newtonsoft.Json.JsonObject] public class RecentFiles : IEnumerable { - private readonly int MAX_RECENT_FILES; //Maximum number of files - private readonly List recentlist; //List of recent files + public int MAX_RECENT_FILES { get; private set; } //Maximum number of files + public List recentlist { get; private set; } //List of recent files public bool AutoLoad = false; diff --git a/BizHawk.Client.Common/config/Binding.cs b/BizHawk.Client.Common/config/Binding.cs index 846a006ae1..833df5787b 100644 --- a/BizHawk.Client.Common/config/Binding.cs +++ b/BizHawk.Client.Common/config/Binding.cs @@ -13,6 +13,7 @@ namespace BizHawk.Client.Common public int Ordinal = 0; } + [Newtonsoft.Json.JsonObject] public class BindingCollection : IEnumerable { public List Bindings { get; private set; } diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index e8d1cf5edb..9ffa12ea03 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -308,6 +308,10 @@ namespace BizHawk.Client.Common public int GifWriterFrameskip = 3; public int GifWriterDelay = -1; + // emulation core settings + public Dictionary CoreSettings = new Dictionary(); + public Dictionary CoreSyncSettings = new Dictionary(); + // NESPPU Settings public bool AutoLoadNESPPU = false; public bool NESPPUSaveWindowPosition = true; @@ -331,17 +335,17 @@ namespace BizHawk.Client.Common public int NESNameTableRefreshRate = 4; // NES Graphics settings - public bool NESAllowMoreThanEightSprites = false; - public bool NESClipLeftAndRight = false; + //public bool NESAllowMoreThanEightSprites = false; + //public bool NESClipLeftAndRight = false; public bool NESAutoLoadPalette = true; - public bool NESDispBackground = true; - public bool NESDispSprites = true; - public int NESBackgroundColor = 0; + //public bool NESDispBackground = true; + //public bool NESDispSprites = true; + //public int NESBackgroundColor = 0; public string NESPaletteFile = ""; - public int NTSC_NESTopLine = 8; - public int NTSC_NESBottomLine = 231; - public int PAL_NESTopLine = 8; - public int PAL_NESBottomLine = 231; + //public int NTSC_NESTopLine = 8; + //public int NTSC_NESBottomLine = 231; + //public int PAL_NESTopLine = 8; + //public int PAL_NESBottomLine = 231; // gb gpu view settings public bool AutoLoadGBGPUView = false; diff --git a/BizHawk.Client.Common/config/ConfigService.cs b/BizHawk.Client.Common/config/ConfigService.cs index 65b7f100ee..12b9528bca 100644 --- a/BizHawk.Client.Common/config/ConfigService.cs +++ b/BizHawk.Client.Common/config/ConfigService.cs @@ -17,8 +17,13 @@ namespace BizHawk.Client.Common if (file.Exists) using (var reader = file.OpenText()) { - var s = new JsonSerializer {SuppressMissingMemberException = true, SuppressDuplicateMemberException = true}; - var r = new JsonReader(reader); + var s = new JsonSerializer + { + MissingMemberHandling = MissingMemberHandling.Ignore, + TypeNameHandling = TypeNameHandling.Auto + //SuppressDuplicateMemberException = true + }; + var r = new JsonTextReader(reader); config = (T)s.Deserialize(r, typeof(T)); } } @@ -30,6 +35,7 @@ namespace BizHawk.Client.Common //if (config == null) return new T(); //patch up arrays in the config with the minimum number of things + // TODO: do we still need this with the new json.net version? foreach(var fi in typeof(T).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)) if (fi.FieldType.IsArray) { @@ -56,8 +62,12 @@ namespace BizHawk.Client.Common var file = new FileInfo(filepath); using (var writer = file.CreateText()) { - var s = new JsonSerializer(); - var w = new JsonWriter(writer) { Formatting = Formatting.Indented }; + var s = new JsonSerializer + { + TypeNameHandling = TypeNameHandling.Auto + }; + + var w = new JsonTextWriter(writer) { Formatting = Formatting.Indented }; s.Serialize(w, config); } } diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 7dc6428721..76abf0be73 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -28,6 +28,7 @@ namespace BizHawk.Client.Common } } + [Newtonsoft.Json.JsonObject] public class PathEntryCollection : IEnumerable { public List Paths { get; private set; } @@ -259,6 +260,13 @@ namespace BizHawk.Client.Common new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "Base", Path= Path.Combine(".", "Saturn"), Ordinal = 0 }, + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "DEBUG", SystemDisplayName = "DEBUG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, }; } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 6e8702211f..35616da12c 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -49,8 +49,12 @@ namespace BizHawk.Client.Common { if (Global.Emulator is NES) { - Global.CoreComm.NES_ShowOBJ = Global.Config.NESDispSprites = (bool)lua_p[0]; - Global.CoreComm.NES_ShowBG = Global.Config.NESDispBackground = (bool)lua_p[1]; + // in the future, we could do something more arbitrary here. + // but this isn't any worse than the old system + NES.NESSettings s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.DispSprites = (bool)lua_p[0]; + s.DispBackground = (bool)lua_p[1]; + Global.Emulator.PutSettings(s); } else if (Global.Emulator is PCEngine) { diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs index 2c41a7bc72..77e22ce252 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs @@ -51,47 +51,51 @@ namespace BizHawk.Client.Common } } + // these methods are awkward. perhaps with the new core config system, one could + // automatically bring out all of the settings to a lua table, with names. that + // would be completely arbitrary and would remove the whole requirement for this mess + public static bool nes_getallowmorethaneightsprites() { - return Global.Config.NESAllowMoreThanEightSprites; + return ((NES.NESSettings)Global.Emulator.GetSettings()).AllowMoreThanEightSprites; } public static int nes_getbottomscanline(bool pal = false) { if (pal) { - return Global.Config.PAL_NESBottomLine; + return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_BottomLine; } else { - return Global.Config.NTSC_NESBottomLine; + return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_BottomLine; } } public static bool nes_getclipleftandright() { - return Global.Config.NESClipLeftAndRight; + return ((NES.NESSettings)Global.Emulator.GetSettings()).ClipLeftAndRight; } public static bool nes_getdispbackground() { - return Global.Config.NESDispBackground; + return ((NES.NESSettings)Global.Emulator.GetSettings()).DispBackground; } public static bool nes_getdispsprites() { - return Global.Config.NESDispSprites; + return ((NES.NESSettings)Global.Emulator.GetSettings()).DispSprites; } public static int nes_gettopscanline(bool pal = false) { if (pal) { - return Global.Config.PAL_NESTopLine; + return ((NES.NESSettings)Global.Emulator.GetSettings()).PAL_TopLine; } else { - return Global.Config.NTSC_NESTopLine; + return ((NES.NESSettings)Global.Emulator.GetSettings()).NTSC_TopLine; } } @@ -108,80 +112,83 @@ namespace BizHawk.Client.Common public static void nes_setallowmorethaneightsprites(bool allow) { - Global.Config.NESAllowMoreThanEightSprites = allow; if (Global.Emulator is NES) { - (Global.Emulator as NES).CoreComm.NES_UnlimitedSprites = allow; + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.AllowMoreThanEightSprites = allow; + Global.Emulator.PutSettings(s); } } public static void nes_setclipleftandright(bool leftandright) { - Global.Config.NESClipLeftAndRight = leftandright; if (Global.Emulator is NES) { - (Global.Emulator as NES).SetClipLeftAndRight(leftandright); + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.ClipLeftAndRight = leftandright; + Global.Emulator.PutSettings(s); } } + // these seem to duplicate emu.setrenderplanes??? public static void nes_setdispbackground(bool show) { - Global.Config.NESDispBackground = show; - CoreFileProvider.SyncCoreCommInputSignals(); + if (Global.Emulator is NES) + { + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.DispBackground = show; + Global.Emulator.PutSettings(s); + } } public static void nes_setdispsprites(bool show) { - Global.Config.NESDispSprites = show; - CoreFileProvider.SyncCoreCommInputSignals(); + if (Global.Emulator is NES) + { + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.DispSprites = show; + Global.Emulator.PutSettings(s); + } } public static void nes_setscanlines(object top, object bottom, bool pal = false) { - - int first = LuaInt(top); - int last = LuaInt(bottom); - if (first > 127) - { - first = 127; - } - else if (first < 0) - { - first = 0; - } - - if (last > 239) - { - last = 239; - } - else if (last < 128) - { - last = 128; - } - - if (pal) - { - Global.Config.PAL_NESTopLine = first; - Global.Config.PAL_NESBottomLine = last; - } - else - { - Global.Config.NTSC_NESTopLine = first; - Global.Config.NTSC_NESBottomLine = last; - } - if (Global.Emulator is NES) { + int first = LuaInt(top); + int last = LuaInt(bottom); + if (first > 127) + { + first = 127; + } + else if (first < 0) + { + first = 0; + } + + if (last > 239) + { + last = 239; + } + else if (last < 128) + { + last = 128; + } + + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + if (pal) { - (Global.Emulator as NES).PAL_FirstDrawLine = first; - (Global.Emulator as NES).PAL_LastDrawLine = last; + s.PAL_TopLine = first; + s.PAL_BottomLine = last; } else { - (Global.Emulator as NES).NTSC_FirstDrawLine = first; - (Global.Emulator as NES).NTSC_LastDrawLine = last; + s.NTSC_TopLine = first; + s.NTSC_BottomLine = last; } + + Global.Emulator.PutSettings(s); } } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 3394bb0d64..8e8b8f07e0 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -3176,8 +3176,8 @@ namespace BizHawk.Client.EmuHawk case DiscType.UnknownCDFS: case DiscType.UnknownFormat: default: // PCECD was bizhawk's first CD core, - // and during that time, all CDs were blindly sent to it - // so this prevents regressions + // and during that time, all CDs were blindly sent to it + // so this prevents regressions game.System = "PCECD"; break; } @@ -3432,14 +3432,8 @@ namespace BizHawk.Client.EmuHawk break; case "NES": { - var nes = new NES(nextComm, game, rom.FileData, Global.MovieSession.Movie.Header.BoardProperties) - { - NTSC_FirstDrawLine = Global.Config.NTSC_NESTopLine, - NTSC_LastDrawLine = Global.Config.NTSC_NESBottomLine, - PAL_FirstDrawLine = Global.Config.PAL_NESTopLine - }; - nes.NTSC_LastDrawLine = Global.Config.PAL_NESBottomLine; - nes.SetClipLeftAndRight(Global.Config.NESClipLeftAndRight); + var nes = new NES(nextComm, game, rom.FileData, Global.MovieSession.Movie.Header.BoardProperties); + nextEmulator = nes; if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 && HawkFile.ExistsAt(Global.Config.NESPaletteFile)) @@ -3572,6 +3566,15 @@ namespace BizHawk.Client.EmuHawk return false; } + // load core settings + { + string typename = nextEmulator.GetType().ToString(); + object settings = null; + Global.Config.CoreSettings.TryGetValue(typename, out settings); + if (settings != null) + nextEmulator.PutSettings(settings); + } + CloseGame(); Global.Emulator.Dispose(); Global.Emulator = nextEmulator; @@ -3775,6 +3778,18 @@ namespace BizHawk.Client.EmuHawk } StopAVI(); + + { + // save settings object + string typename = Global.Emulator.GetType().ToString(); + object settings = Global.Emulator.GetSettings(); + if (settings != null) + Global.Config.CoreSettings[typename] = settings; + object syncsettings = Global.Emulator.GetSyncSettings(); + if (syncsettings != null) + Global.Config.CoreSyncSettings[typename] = syncsettings; + } + Global.Emulator.Dispose(); Global.CoreComm = new CoreComm(ShowMessageCoreComm); CoreFileProvider.SyncCoreCommInputSignals(); diff --git a/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs index 96acd9a7ab..d67fc364ce 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs @@ -17,6 +17,7 @@ namespace BizHawk.Client.EmuHawk private HawkFile palette; private NES nes; + private NES.NESSettings settings; public NESGraphicsConfig() { @@ -26,23 +27,24 @@ namespace BizHawk.Client.EmuHawk private void NESGraphicsConfig_Load(object sender, EventArgs e) { nes = Global.Emulator as NES; + settings = (NES.NESSettings)nes.GetSettings(); LoadStuff(); } private void LoadStuff() { - NTSC_FirstLineNumeric.Value = Global.Config.NTSC_NESTopLine; - NTSC_LastLineNumeric.Value = Global.Config.NTSC_NESBottomLine; - PAL_FirstLineNumeric.Value = Global.Config.PAL_NESTopLine; - PAL_LastLineNumeric.Value = Global.Config.PAL_NESBottomLine; - AllowMoreSprites.Checked = Global.Config.NESAllowMoreThanEightSprites; - ClipLeftAndRightCheckBox.Checked = Global.Config.NESClipLeftAndRight; - AutoLoadPalette.Checked = Global.Config.NESAutoLoadPalette; + NTSC_FirstLineNumeric.Value = settings.NTSC_TopLine; + NTSC_LastLineNumeric.Value = settings.NTSC_BottomLine; + PAL_FirstLineNumeric.Value = settings.PAL_TopLine; + PAL_LastLineNumeric.Value = settings.PAL_BottomLine; + AllowMoreSprites.Checked = settings.AllowMoreThanEightSprites; + ClipLeftAndRightCheckBox.Checked = settings.ClipLeftAndRight; + AutoLoadPalette.Checked = settings.AutoLoadPalette; PalettePath.Text = Global.Config.NESPaletteFile; - DispSprites.Checked = Global.Config.NESDispSprites; - DispBackground.Checked = Global.Config.NESDispBackground; - BGColorDialog.Color = Color.FromArgb(unchecked(Global.Config.NESBackgroundColor | (int)0xFF000000)); - checkUseBackdropColor.Checked = (Global.Config.NESBackgroundColor & 0xFF000000) != 0; + DispSprites.Checked = settings.DispSprites; + DispBackground.Checked = settings.DispBackground; + BGColorDialog.Color = Color.FromArgb(unchecked(settings.BackgroundColor | (int)0xFF000000)); + checkUseBackdropColor.Checked = (settings.BackgroundColor & 0xFF000000) != 0; SetColorBox(); } @@ -87,29 +89,20 @@ namespace BizHawk.Client.EmuHawk GlobalWin.OSD.AddMessage("Standard Palette set"); } - Global.Config.NTSC_NESTopLine = (int)NTSC_FirstLineNumeric.Value; - nes.NTSC_FirstDrawLine = (int)NTSC_FirstLineNumeric.Value; - - Global.Config.NTSC_NESBottomLine = (int)NTSC_LastLineNumeric.Value; - nes.NTSC_LastDrawLine = (int)NTSC_LastLineNumeric.Value; - - Global.Config.PAL_NESTopLine = (int)PAL_FirstLineNumeric.Value; - nes.PAL_FirstDrawLine = (int)PAL_FirstLineNumeric.Value; - - Global.Config.PAL_NESBottomLine = (int)PAL_LastLineNumeric.Value; - nes.PAL_LastDrawLine = (int)PAL_LastLineNumeric.Value; - - Global.Config.NESAllowMoreThanEightSprites = AllowMoreSprites.Checked; - Global.Config.NESClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; - nes.SetClipLeftAndRight(ClipLeftAndRightCheckBox.Checked); - Global.Config.NESAutoLoadPalette = AutoLoadPalette.Checked; - Global.Config.NESDispSprites = DispSprites.Checked; - Global.Config.NESDispBackground = DispBackground.Checked; - Global.Config.NESBackgroundColor = BGColorDialog.Color.ToArgb(); + settings.NTSC_TopLine = (int)NTSC_FirstLineNumeric.Value; + settings.NTSC_BottomLine = (int)NTSC_LastLineNumeric.Value; + settings.PAL_TopLine = (int)PAL_FirstLineNumeric.Value; + settings.PAL_BottomLine = (int)PAL_LastLineNumeric.Value; + settings.AllowMoreThanEightSprites = AllowMoreSprites.Checked; + settings.ClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; + settings.AutoLoadPalette = AutoLoadPalette.Checked; + settings.DispSprites = DispSprites.Checked; + settings.DispBackground = DispBackground.Checked; + settings.BackgroundColor = BGColorDialog.Color.ToArgb(); if (!checkUseBackdropColor.Checked) - { - Global.Config.NESBackgroundColor &= 0x00FFFFFF; - } + settings.BackgroundColor &= 0x00FFFFFF; + + nes.PutSettings(settings); Close(); } @@ -152,19 +145,8 @@ namespace BizHawk.Client.EmuHawk private void RestoreDefaultsButton_Click(object sender, EventArgs e) { - NTSC_FirstLineNumeric.Value = 8; - NTSC_LastLineNumeric.Value = 231; - PAL_FirstLineNumeric.Value = 0; - PAL_LastLineNumeric.Value = 239; - AllowMoreSprites.Checked = false; - ClipLeftAndRightCheckBox.Checked = false; - AutoLoadPalette.Checked = true; - PalettePath.Text = ""; - DispSprites.Checked = true; - DispBackground.Checked = true; - BGColorDialog.Color = Color.FromArgb(unchecked(0 | (int)0xFF000000)); - checkUseBackdropColor.Checked = false; - SetColorBox(); + settings = new NES.NESSettings(); + LoadStuff(); } } } diff --git a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs index 87c638e4f7..8d515009d0 100644 --- a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs @@ -114,6 +114,10 @@ namespace BizHawk.Emulation.Common get; set; } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } public class NullSound : ISoundProvider diff --git a/BizHawk.Emulation.Common/Interfaces/CoreComms.cs b/BizHawk.Emulation.Common/Interfaces/CoreComms.cs index 9ef0b2ce72..f922c241d4 100644 --- a/BizHawk.Emulation.Common/Interfaces/CoreComms.cs +++ b/BizHawk.Emulation.Common/Interfaces/CoreComms.cs @@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Common { public class CoreComm { - public int NES_BackdropColor; - public bool NES_UnlimitedSprites = false; - public bool NES_ShowBG = true, NES_ShowOBJ = true; + //public int NES_BackdropColor; + //public bool NES_UnlimitedSprites = false; + //public bool NES_ShowBG = true, NES_ShowOBJ = true; public bool PCE_ShowBG1 = true, PCE_ShowOBJ1 = true, PCE_ShowBG2 = true, PCE_ShowOBJ2 = true; public bool SMS_ShowBG = true, SMS_ShowOBJ = true; public bool GG_ShowClippedRegions; diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index 688bd3c6a5..b5088e86ed 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -123,10 +123,6 @@ namespace BizHawk.Emulation.Common /// CoreComm CoreComm { get; } - - // this MUST BE the same as MemoryDomains[0], else DRAGONS - /// - ///The list of all avaialble memory domains /// A memory domain is a byte array that respresents a distinct part of the emulated system. /// By convention the Main Memory is the 1st domain in the list @@ -144,6 +140,31 @@ namespace BizHawk.Emulation.Common /// /// List> GetCpuFlagsAndRegisters(); + + // ====settings interface==== + + // in addition to these methods, it's expected that the constructor or Load() method + // will take a SyncSettings object to set the initial state of the core (and possibly a settings object?) + + /// + /// get the current core settings, excepting movie settings + /// + /// a json-serializable object + object GetSettings(); + + /// + /// get the current core settings that affect movie sync + /// + /// a json-serializable object + object GetSyncSettings(); + + /// + /// change the core settings, excepting movie settings + /// + /// an object of the same type as the return for GetSettings + /// true if a core reboot will be required to implement these + bool PutSettings(object o); + } public enum DisplayType { NTSC, PAL, DENDY } diff --git a/BizHawk.Emulation.Common/LibRetroEmulator.cs b/BizHawk.Emulation.Common/LibRetroEmulator.cs index d76424653f..8a7ebca8c1 100644 --- a/BizHawk.Emulation.Common/LibRetroEmulator.cs +++ b/BizHawk.Emulation.Common/LibRetroEmulator.cs @@ -548,5 +548,9 @@ namespace BizHawk.Emulation.Common public int BackgroundColor { get { return unchecked((int)0xff000000); } } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index acde0d55fe..4be72391f9 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -1036,5 +1036,10 @@ namespace BizHawk.Emulation.Cores.Calculators } */ } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } + } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 15d38251dd..9ae6d80605 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -171,5 +171,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 //domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func(disk.PeekRam), new Action(disk.PokeRam))); memoryDomains = new MemoryDomainList(domains); } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index a8f45ba8b1..8e65565c20 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -130,6 +130,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private readonly MemoryDomainList memoryDomains; public MemoryDomainList MemoryDomains { get { return memoryDomains; } } public void Dispose() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs index a9d7435a54..d87d76debc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs @@ -425,5 +425,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 } } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index b740993767..e3094130fb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -289,5 +289,9 @@ namespace BizHawk.Emulation.Cores.ColecoVision public ISyncSoundProvider SyncSoundProvider { get { return null; } } public bool StartAsyncSound() { return true; } public void EndAsyncSound() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 1b3c1d3919..af84559172 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -203,5 +203,9 @@ namespace BizHawk.Emulation.Cores.Intellivision public void Dispose() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index 0058d152b9..d8d3296605 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -553,5 +553,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index bf886b7521..8cb6d703e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -891,5 +891,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } #endregion + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index 9bb96c0a3d..c2905a11b9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -417,5 +417,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 0200f31088..f61ba3fc0c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -434,5 +434,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 InitMemoryDomains(); } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 41f1fcb756..352333d28d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -195,10 +195,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES class MyVideoProvider : IVideoProvider { - public int ntsc_top = 8; - public int ntsc_bottom = 231; - public int pal_top = 0; - public int pal_bottom = 239; + //public int ntsc_top = 8; + //public int ntsc_bottom = 231; + //public int pal_top = 0; + //public int pal_bottom = 239; public int left = 0; public int right = 255; @@ -220,18 +220,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int the_bottom; if (emu.DisplayType == DisplayType.NTSC) { - the_top = ntsc_top; - the_bottom = ntsc_bottom; + the_top = emu.Settings.NTSC_TopLine; + the_bottom = emu.Settings.NTSC_BottomLine; } else { - the_top = pal_top; - the_bottom = pal_bottom; + the_top = emu.Settings.PAL_TopLine; + the_bottom = emu.Settings.PAL_BottomLine; } int backdrop = 0; - if (emu.CoreComm != null) - backdrop = emu.CoreComm.NES_BackdropColor; + backdrop = emu.Settings.BackgroundColor; bool useBackdrop = (backdrop & 0xFF000000) != 0; //TODO - we could recalculate this on the fly (and invalidate/recalculate it when the palette is changed) @@ -258,58 +257,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (emu.DisplayType == DisplayType.NTSC) { - return ntsc_bottom - ntsc_top + 1; + return emu.Settings.NTSC_BottomLine - emu.Settings.NTSC_TopLine + 1; } else { - return pal_bottom - pal_top + 1; + return emu.Settings.PAL_BottomLine - emu.Settings.PAL_TopLine + 1; } } } } - public int NTSC_FirstDrawLine - { - get { return videoProvider.ntsc_top; } - set { videoProvider.ntsc_top = value; CoreComm.ScreenLogicalOffsetY = videoProvider.ntsc_top; } - } - - public int NTSC_LastDrawLine - { - get { return videoProvider.ntsc_bottom; } - set { videoProvider.ntsc_bottom = value; } - } - - public int PAL_FirstDrawLine - { - get { return videoProvider.pal_top; } - set { videoProvider.pal_top = value; CoreComm.ScreenLogicalOffsetY = videoProvider.pal_top; } - } - - public int PAL_LastDrawLine - { - get { return videoProvider.pal_bottom; } - set { videoProvider.pal_bottom = value; } - } - - public void SetClipLeftAndRight(bool clip) - { - if (clip) - { - videoProvider.left = 8; - videoProvider.right = 248; - } - else - { - videoProvider.left = 0; - videoProvider.right = 255; - } - - CoreComm.ScreenLogicalOffsetX = videoProvider.left; - videoProvider.FillFrameBuffer(); - } - MyVideoProvider videoProvider; public IVideoProvider VideoProvider { get { return videoProvider; } } public ISoundProvider SoundProvider { get { return magicSoundProvider; } } @@ -912,6 +870,48 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES }; } + + NESSettings Settings = new NESSettings(); + + public object GetSettings() { return Settings.Clone(); } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) + { + Settings = (NESSettings)o; + if (Settings.ClipLeftAndRight) + { + videoProvider.left = 8; + videoProvider.right = 248; + } + else + { + videoProvider.left = 0; + videoProvider.right = 255; + } + CoreComm.ScreenLogicalOffsetX = videoProvider.left; + CoreComm.ScreenLogicalOffsetY = DisplayType == DisplayType.NTSC ? Settings.NTSC_TopLine : Settings.PAL_TopLine; + return false; + } + + public class NESSettings + { + public bool AllowMoreThanEightSprites = false; + public bool ClipLeftAndRight = false; + public bool AutoLoadPalette = true; + public bool DispBackground = true; + public bool DispSprites = true; + public int BackgroundColor = 0; + + public int NTSC_TopLine = 8; + public int NTSC_BottomLine = 231; + public int PAL_TopLine = 0; + public int PAL_BottomLine = 239; + + public NESSettings Clone() + { + return (NESSettings)MemberwiseClone(); + } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index 169ea86a62..56d222caf0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES pixelcolor |= 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later } - if (!nes.CoreComm.NES_ShowBG) + if (!nes.Settings.DispBackground) pixelcolor = 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later //look for a sprite to be drawn @@ -255,7 +255,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Reg2002_objhit |= (oam->index == 0 && pixel != 0 && rasterpos < 255); //priority handling, if in front of BG: bool drawsprite = !(((oam->oam[2] & 0x20) != 0) && ((pixel & 3) != 0)); - if (drawsprite && nes.CoreComm.NES_ShowOBJ) + if (drawsprite && nes.Settings.DispSprites) { //bring in the palette bits and palettize spixel |= (oam->oam[2] & 3) << 2; @@ -296,7 +296,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (oamcount >= 8 && reg_2001.PPUON) { Reg2002_objoverflow = true; - if(!nes.CoreComm.NES_UnlimitedSprites) + if(!nes.Settings.AllowMoreThanEightSprites) break; } //just copy some bytes into the internal sprite buffer diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index e7f822a42d..116f1ae14b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -1045,5 +1045,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public void EndAsyncSound() { } #endregion audio stuff + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 55ab6266c6..74444a87f8 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -623,5 +623,9 @@ namespace BizHawk.Emulation.Cores.PCEngine if (disc != null) disc.Dispose(); } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index 0bf900c977..3edde3472c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -479,5 +479,9 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis public MemoryDomainList MemoryDomains { get { return memoryDomains; } } public void Dispose() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index bf977dff51..874ee2ae97 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -462,5 +462,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public MemoryDomainList MemoryDomains { get { return memoryDomains; } } public void Dispose() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 37bef201ad..89c07a5c06 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -139,8 +139,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn if (factor == 0) LibYabause.libyabause_glresize(width, height); } - - + + public void FrameAdvance(bool render, bool rendersound = true) { @@ -424,7 +424,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn } } } - + #endregion @@ -631,5 +631,9 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index f32b48acd4..f8b48487fe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -624,5 +624,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } #endregion + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index d089259955..6d249fdc4f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -211,5 +211,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSP public void DiscardSamples() { } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 3336f950b9..af6ef2dda6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -281,6 +281,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public int MaxVolume { get; set; } private List memoryDomains = new List(); public MemoryDomainList MemoryDomains { get; private set; } + + public object GetSettings() { return null; } + public object GetSyncSettings() { return null; } + public bool PutSettings(object o) { return false; } } } diff --git a/Newtonsoft.Json.dll b/Newtonsoft.Json.dll index 0985c864f6..0a159151ba 100644 Binary files a/Newtonsoft.Json.dll and b/Newtonsoft.Json.dll differ