diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 8724851a77..89c66d855e 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -294,7 +294,7 @@ namespace BizHawk.Client.Common break; case "SAT": { - var saturn = new Yabause(nextComm, disc, Global.Config.SaturnUseGL); + var saturn = new Yabause(nextComm, disc, GetCoreSyncSettings()); nextEmulator = saturn; } break; diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 7295c48553..6f5bdab3b3 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -409,13 +409,6 @@ namespace BizHawk.Client.Common public bool SNES_ShowOBJ3 = true; public bool SNES_ShowOBJ4 = true; - // SATURN GRAPHICS SETTINGS - public bool SaturnUseGL = false; - public int SaturnDispFactor = 1; - public bool SaturnDispFree = false; - public int SaturnGLW = 640; - public int SaturnGLH = 480; - // PCE BG Viewer settings public bool PCEBGViewerSaveWIndowPosition = true; public bool PCEBGViewerAutoload = false; @@ -423,14 +416,6 @@ namespace BizHawk.Client.Common public int PCEBGViewerWndy = -1; public int PCEBGViewerRefreshRate = 16; - // Coleco Settings - //public bool ColecoSkipBiosIntro = false; - - //GB Debugger settings - public bool AutoloadGBDebugger = false; - public bool GBDebuggerSaveWindowPosition = true; - public bool GameBoySkipBIOS = true; - #region Cheats Dialog public bool Cheats_ValuesAsHex = true; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 7fae791f99..e8d7ceaaaa 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1637,11 +1637,7 @@ namespace BizHawk.Client.EmuHawk { using (var dlg = new SaturnPrefs()) { - var result = dlg.ShowDialog(this); - if (result == DialogResult.OK) - { - SaturnSetPrefs(); - } + dlg.ShowDialog(this); } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index eb09e5b6c6..33cfc1b712 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1376,32 +1376,7 @@ namespace BizHawk.Client.EmuHawk } } - private void SaturnSetPrefs(Yabause e = null) - { - if (e == null) - { - e = Global.Emulator as Yabause; - } - if (Global.Config.SaturnUseGL != e.GLMode) - { - // theoretically possible; not coded. meh. - FlagNeedsReboot(); - return; - } - - if (e.GLMode && Global.Config.SaturnUseGL) - { - if (Global.Config.SaturnDispFree) - { - e.SetGLRes(0, Global.Config.SaturnGLW, Global.Config.SaturnGLH); - } - else - { - e.SetGLRes(Global.Config.SaturnDispFactor, 0, 0); - } - } - } private void HandlePlatformMenus() { @@ -2891,11 +2866,7 @@ namespace BizHawk.Client.EmuHawk if (result) { - if (loader.LoadedEmulator is Yabause) - { - SaturnSetPrefs(loader.LoadedEmulator as Yabause); - } - else if (loader.LoadedEmulator is TI83) + if (loader.LoadedEmulator is TI83) { if (Global.Config.TI83autoloadKeyPad) { diff --git a/BizHawk.Client.EmuHawk/config/Saturn/SaturnPrefs.cs b/BizHawk.Client.EmuHawk/config/Saturn/SaturnPrefs.cs index c12d2fa27d..b67780fbe0 100644 --- a/BizHawk.Client.EmuHawk/config/Saturn/SaturnPrefs.cs +++ b/BizHawk.Client.EmuHawk/config/Saturn/SaturnPrefs.cs @@ -8,6 +8,7 @@ using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Cores.Sega.Saturn; namespace BizHawk.Client.EmuHawk { @@ -18,13 +19,15 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); try { - radioButtonGL.Checked = Global.Config.SaturnUseGL; - radioButtonSoft.Checked = !Global.Config.SaturnUseGL; - radioButtonFree.Checked = Global.Config.SaturnDispFree; - radioButtonFactor.Checked = !Global.Config.SaturnDispFree; - numericUpDownFactor.Value = Global.Config.SaturnDispFactor; - numericUpDown1.Value = Global.Config.SaturnGLW; - numericUpDown2.Value = Global.Config.SaturnGLH; + var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings(); + + radioButtonGL.Checked = ss.UseGL; + radioButtonSoft.Checked = !ss.UseGL; + radioButtonFree.Checked = ss.DispFree; + radioButtonFactor.Checked = !ss.DispFree; + numericUpDownFactor.Value = ss.DispFactor; + numericUpDown1.Value = ss.GLW; + numericUpDown2.Value = ss.GLH; } catch (ArgumentOutOfRangeException) { @@ -44,11 +47,13 @@ namespace BizHawk.Client.EmuHawk private void buttonOK_Click(object sender, EventArgs e) { - Global.Config.SaturnUseGL = radioButtonGL.Checked; - Global.Config.SaturnDispFree = radioButtonFree.Checked; - Global.Config.SaturnDispFactor = (int)numericUpDownFactor.Value; - Global.Config.SaturnGLW = (int)numericUpDown1.Value; - Global.Config.SaturnGLH = (int)numericUpDown2.Value; + var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings(); + ss.UseGL = radioButtonGL.Checked; + ss.DispFree = radioButtonFree.Checked; + ss.DispFactor = (int)numericUpDownFactor.Value; + ss.GLW = (int)numericUpDown1.Value; + ss.GLH = (int)numericUpDown2.Value; + GlobalWin.MainForm.PutCoreSyncSettings(ss); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 9010e3608c..b1be151dce 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -41,21 +41,26 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn LibYabause.InputCallback InputCallbackH; - public Yabause(CoreComm CoreComm, DiscSystem.Disc CD, bool GL) + public Yabause(CoreComm CoreComm, DiscSystem.Disc CD, object SyncSettings) { byte[] bios = CoreComm.CoreFileProvider.GetFirmware("SAT", "J", true, "Saturn BIOS is required."); CoreComm.RomStatusDetails = string.Format("Disk partial hash:{0}", CD.GetHash()); this.CoreComm = CoreComm; this.CD = CD; + + this.SyncSettings = (SaturnSyncSettings)SyncSettings ?? new SaturnSyncSettings(); + ResetCounters(); - Init(bios, GL); + Init(bios); InputCallbackH = new LibYabause.InputCallback(() => CoreComm.InputCallback.Call()); LibYabause.libyabause_setinputcallback(InputCallbackH); } - void Init(byte[] bios, bool GL = false) + void Init(byte[] bios) { + bool GL = SyncSettings.UseGL; + if (AttachedCore != null) { AttachedCore.Dispose(); @@ -92,6 +97,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn InitMemoryDomains(); GLMode = GL; + // if in GL mode, this will trigger the initial GL resize + PutSyncSettings(this.SyncSettings); } public ControllerDefinition ControllerDefinition @@ -632,9 +639,42 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn #endregion + SaturnSyncSettings SyncSettings; + public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } + public object GetSyncSettings() { return SyncSettings.Clone(); } public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } + public bool PutSyncSettings(object o) + { + var n = (SaturnSyncSettings)o; + bool ret = SaturnSyncSettings.NeedsReboot(SyncSettings, n); + + SyncSettings = n; + + if (GLMode && SyncSettings.UseGL) + if (SyncSettings.DispFree) + SetGLRes(0, SyncSettings.GLW, SyncSettings.GLH); + else + SetGLRes(SyncSettings.DispFactor, 0, 0); + return ret; + } + + public class SaturnSyncSettings + { + public bool UseGL = false; + public int DispFactor = 1; + public bool DispFree = false; + public int GLW = 640; + public int GLH = 480; + + public static bool NeedsReboot(SaturnSyncSettings x, SaturnSyncSettings y) + { + return x.UseGL != y.UseGL; + } + public SaturnSyncSettings Clone() + { + return (SaturnSyncSettings)MemberwiseClone(); + } + } } }