saturn to new settings system

This commit is contained in:
goyuken 2013-12-27 03:02:28 +00:00
parent f122105b42
commit e3165459d8
6 changed files with 65 additions and 68 deletions

View File

@ -294,7 +294,7 @@ namespace BizHawk.Client.Common
break; break;
case "SAT": case "SAT":
{ {
var saturn = new Yabause(nextComm, disc, Global.Config.SaturnUseGL); var saturn = new Yabause(nextComm, disc, GetCoreSyncSettings<Yabause>());
nextEmulator = saturn; nextEmulator = saturn;
} }
break; break;

View File

@ -409,13 +409,6 @@ namespace BizHawk.Client.Common
public bool SNES_ShowOBJ3 = true; public bool SNES_ShowOBJ3 = true;
public bool SNES_ShowOBJ4 = 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 // PCE BG Viewer settings
public bool PCEBGViewerSaveWIndowPosition = true; public bool PCEBGViewerSaveWIndowPosition = true;
public bool PCEBGViewerAutoload = false; public bool PCEBGViewerAutoload = false;
@ -423,14 +416,6 @@ namespace BizHawk.Client.Common
public int PCEBGViewerWndy = -1; public int PCEBGViewerWndy = -1;
public int PCEBGViewerRefreshRate = 16; 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 #region Cheats Dialog
public bool Cheats_ValuesAsHex = true; public bool Cheats_ValuesAsHex = true;

View File

@ -1637,11 +1637,7 @@ namespace BizHawk.Client.EmuHawk
{ {
using (var dlg = new SaturnPrefs()) using (var dlg = new SaturnPrefs())
{ {
var result = dlg.ShowDialog(this); dlg.ShowDialog(this);
if (result == DialogResult.OK)
{
SaturnSetPrefs();
}
} }
} }

View File

@ -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() private void HandlePlatformMenus()
{ {
@ -2891,11 +2866,7 @@ namespace BizHawk.Client.EmuHawk
if (result) if (result)
{ {
if (loader.LoadedEmulator is Yabause) if (loader.LoadedEmulator is TI83)
{
SaturnSetPrefs(loader.LoadedEmulator as Yabause);
}
else if (loader.LoadedEmulator is TI83)
{ {
if (Global.Config.TI83autoloadKeyPad) if (Global.Config.TI83autoloadKeyPad)
{ {

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.Emulation.Cores.Sega.Saturn;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -18,13 +19,15 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
try try
{ {
radioButtonGL.Checked = Global.Config.SaturnUseGL; var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings();
radioButtonSoft.Checked = !Global.Config.SaturnUseGL;
radioButtonFree.Checked = Global.Config.SaturnDispFree; radioButtonGL.Checked = ss.UseGL;
radioButtonFactor.Checked = !Global.Config.SaturnDispFree; radioButtonSoft.Checked = !ss.UseGL;
numericUpDownFactor.Value = Global.Config.SaturnDispFactor; radioButtonFree.Checked = ss.DispFree;
numericUpDown1.Value = Global.Config.SaturnGLW; radioButtonFactor.Checked = !ss.DispFree;
numericUpDown2.Value = Global.Config.SaturnGLH; numericUpDownFactor.Value = ss.DispFactor;
numericUpDown1.Value = ss.GLW;
numericUpDown2.Value = ss.GLH;
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
@ -44,11 +47,13 @@ namespace BizHawk.Client.EmuHawk
private void buttonOK_Click(object sender, EventArgs e) private void buttonOK_Click(object sender, EventArgs e)
{ {
Global.Config.SaturnUseGL = radioButtonGL.Checked; var ss = (Yabause.SaturnSyncSettings)Global.Emulator.GetSyncSettings();
Global.Config.SaturnDispFree = radioButtonFree.Checked; ss.UseGL = radioButtonGL.Checked;
Global.Config.SaturnDispFactor = (int)numericUpDownFactor.Value; ss.DispFree = radioButtonFree.Checked;
Global.Config.SaturnGLW = (int)numericUpDown1.Value; ss.DispFactor = (int)numericUpDownFactor.Value;
Global.Config.SaturnGLH = (int)numericUpDown2.Value; ss.GLW = (int)numericUpDown1.Value;
ss.GLH = (int)numericUpDown2.Value;
GlobalWin.MainForm.PutCoreSyncSettings(ss);
} }
} }
} }

View File

@ -41,21 +41,26 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
LibYabause.InputCallback InputCallbackH; 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."); byte[] bios = CoreComm.CoreFileProvider.GetFirmware("SAT", "J", true, "Saturn BIOS is required.");
CoreComm.RomStatusDetails = string.Format("Disk partial hash:{0}", CD.GetHash()); CoreComm.RomStatusDetails = string.Format("Disk partial hash:{0}", CD.GetHash());
this.CoreComm = CoreComm; this.CoreComm = CoreComm;
this.CD = CD; this.CD = CD;
this.SyncSettings = (SaturnSyncSettings)SyncSettings ?? new SaturnSyncSettings();
ResetCounters(); ResetCounters();
Init(bios, GL); Init(bios);
InputCallbackH = new LibYabause.InputCallback(() => CoreComm.InputCallback.Call()); InputCallbackH = new LibYabause.InputCallback(() => CoreComm.InputCallback.Call());
LibYabause.libyabause_setinputcallback(InputCallbackH); LibYabause.libyabause_setinputcallback(InputCallbackH);
} }
void Init(byte[] bios, bool GL = false) void Init(byte[] bios)
{ {
bool GL = SyncSettings.UseGL;
if (AttachedCore != null) if (AttachedCore != null)
{ {
AttachedCore.Dispose(); AttachedCore.Dispose();
@ -92,6 +97,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
InitMemoryDomains(); InitMemoryDomains();
GLMode = GL; GLMode = GL;
// if in GL mode, this will trigger the initial GL resize
PutSyncSettings(this.SyncSettings);
} }
public ControllerDefinition ControllerDefinition public ControllerDefinition ControllerDefinition
@ -632,9 +639,42 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
#endregion #endregion
SaturnSyncSettings SyncSettings;
public object GetSettings() { return null; } 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 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();
}
}
} }
} }