fix some internal settings infrastructure
This commit is contained in:
parent
5d743cdf88
commit
fb133da0c5
|
@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
|
|||
public void PutSettings(Gameboy.GambatteSettings s, Gameboy.GambatteSyncSettings ss)
|
||||
{
|
||||
this.s = s ?? Gameboy.GambatteSettings.GetDefaults();
|
||||
this.ss = ss ?? Gameboy.GambatteSyncSettings.GetDefaults();
|
||||
this.ss = ss ?? new Gameboy.GambatteSyncSettings();
|
||||
propertyGrid1.SelectedObject = this.ss;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DefaultsBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var s = TI83.TI83Settings.GetDefaults();
|
||||
var s = new TI83.TI83Settings();
|
||||
BackgroundPanel.BackColor = Color.FromArgb((int)s.BGColor);
|
||||
ForeGroundPanel.BackColor = Color.FromArgb((int)s.ForeColor);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ namespace BizHawk.Common
|
|||
|
||||
private static IDictionary<Type, DefaultValueSetter> DefaultValueSetters = new ConcurrentDictionary<Type, DefaultValueSetter>();
|
||||
|
||||
/// <summary>
|
||||
/// set all properties (not fields!) of obj with a DefaultValueAttribute to that value
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj">the obj to act on</param>
|
||||
public static void SetDefaultValues<T>(T obj)
|
||||
{
|
||||
DefaultValueSetter f;
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
|
||||
public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings)
|
||||
{
|
||||
PutSettings(Settings ?? TI83Settings.GetDefaults());
|
||||
PutSettings(Settings ?? new TI83Settings());
|
||||
|
||||
CoreComm = comm;
|
||||
cpu.ReadMemory = ReadMemory;
|
||||
|
@ -984,13 +984,8 @@ namespace BizHawk.Emulation.Cores.Calculators
|
|||
public uint BGColor = 0x889778;
|
||||
public uint ForeColor = 0x36412D;
|
||||
|
||||
public static TI83Settings GetDefaults()
|
||||
public TI83Settings()
|
||||
{
|
||||
return new TI83Settings
|
||||
{
|
||||
BGColor = 0x889778,
|
||||
ForeColor = 0x36412D
|
||||
};
|
||||
}
|
||||
|
||||
public TI83Settings Clone()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||
{
|
||||
|
@ -39,65 +40,82 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
public class A2600Settings
|
||||
{
|
||||
[JsonIgnore]
|
||||
private int _ntscTopLine = 24;
|
||||
private int _ntscTopLine;
|
||||
|
||||
[JsonIgnore]
|
||||
private int _ntscBottomLine = 248;
|
||||
private int _ntscBottomLine;
|
||||
|
||||
[JsonIgnore]
|
||||
private int _palTopLine = 24;
|
||||
private int _palTopLine;
|
||||
|
||||
[JsonIgnore]
|
||||
private int _palBottomLine = 296;
|
||||
private int _palBottomLine;
|
||||
|
||||
[Description("Sets whether or not the Background layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowBG { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Player 1 layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowPlayer1 { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Player 2 layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowPlayer2 { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Missle 1 layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowMissle1 { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Missle 2 layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowMissle2 { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Ball layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowBall { get; set; }
|
||||
|
||||
[Description("Sets whether or not the Playfield layer will be displayed")]
|
||||
[DefaultValue(true)]
|
||||
public bool ShowPlayfield { get; set; }
|
||||
|
||||
[Description("If true, PAL mode will show with SECAM (French) colors.")]
|
||||
[DefaultValue(false)]
|
||||
public bool SECAMColors { get; set; }
|
||||
|
||||
[Description("First line of the video image to display in NTSC mode.")]
|
||||
[DefaultValue(24)]
|
||||
public int NTSCTopLine
|
||||
{
|
||||
get { return this._ntscTopLine; }
|
||||
set { _ntscTopLine = Math.Min(64, Math.Max(value, 0)); }
|
||||
}
|
||||
|
||||
[Description("Last line of the video image to display in NTSC mode.")]
|
||||
[DefaultValue(248)]
|
||||
public int NTSCBottomLine
|
||||
{
|
||||
get { return _ntscBottomLine; }
|
||||
set { _ntscBottomLine = Math.Min(260, Math.Max(value, 192)); }
|
||||
}
|
||||
|
||||
[Description("First line of the video image to display in PAL mode.")]
|
||||
[DefaultValue(24)]
|
||||
public int PALTopLine
|
||||
{
|
||||
get { return this._palTopLine; }
|
||||
set { this._palTopLine = Math.Min(64, Math.Max(value, 0)); }
|
||||
}
|
||||
|
||||
[Description("Last line of the video image to display in PAL mode.")]
|
||||
[DefaultValue(296)]
|
||||
public int PALBottomLine
|
||||
{
|
||||
get { return this._palBottomLine; }
|
||||
set { this._palBottomLine = Math.Min(310, Math.Max(value, 192)); }
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "Black")]
|
||||
public Color BackgroundColor { get; set; }
|
||||
|
||||
public A2600Settings Clone()
|
||||
|
@ -105,35 +123,28 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
return (A2600Settings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static A2600Settings GetDefaults()
|
||||
public A2600Settings()
|
||||
{
|
||||
return new A2600Settings
|
||||
{
|
||||
ShowBG = true,
|
||||
ShowPlayer1 = true,
|
||||
ShowPlayer2 = true,
|
||||
ShowMissle1 = true,
|
||||
ShowMissle2 = true,
|
||||
ShowBall = true,
|
||||
ShowPlayfield = true,
|
||||
BackgroundColor = Color.Black,
|
||||
SECAMColors = false
|
||||
};
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class A2600SyncSettings
|
||||
{
|
||||
[Description("Set the TV Type switch on the console to B&W or Color")]
|
||||
[Description("Set the TV Type switch on the console to B&W or Color. This only affects the displayed image if the game supports it.")]
|
||||
[DefaultValue(false)]
|
||||
public bool BW { get; set; }
|
||||
|
||||
[Description("Set the Left Difficulty switch on the console")]
|
||||
[DefaultValue(true)]
|
||||
public bool LeftDifficulty { get; set; }
|
||||
|
||||
[Description("Set the Right Difficulty switch on the console")]
|
||||
[DefaultValue(true)]
|
||||
public bool RightDifficulty { get; set; }
|
||||
|
||||
[Description("Super Charger only, sets whether or not to skip the BIOS intro")]
|
||||
[Description("Skip the BIOS intro (Super Charger only)")]
|
||||
[DefaultValue(false)]
|
||||
public bool FastScBios { get; set; }
|
||||
|
||||
public A2600SyncSettings Clone()
|
||||
|
@ -141,14 +152,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
return (A2600SyncSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static A2600SyncSettings GetDefaults()
|
||||
public A2600SyncSettings()
|
||||
{
|
||||
return new A2600SyncSettings
|
||||
{
|
||||
BW = false,
|
||||
LeftDifficulty = true,
|
||||
RightDifficulty = true
|
||||
};
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
{
|
||||
Ram = new byte[128];
|
||||
CoreComm = comm;
|
||||
Settings = (A2600Settings)settings ?? A2600Settings.GetDefaults();
|
||||
SyncSettings = (A2600SyncSettings)syncSettings ?? A2600SyncSettings.GetDefaults();
|
||||
Settings = (A2600Settings)settings ?? new A2600Settings();
|
||||
SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings();
|
||||
|
||||
var domains = new List<MemoryDomain>
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
|
||||
using BizHawk.Common.BufferExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -112,18 +113,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
try
|
||||
{
|
||||
this.SyncSettings = (GambatteSyncSettings)SyncSettings ?? GambatteSyncSettings.GetDefaults();
|
||||
this._SyncSettings = (GambatteSyncSettings)SyncSettings ?? new GambatteSyncSettings();
|
||||
// copy over non-loadflag syncsettings now; they won't take effect if changed later
|
||||
zerotime = (uint)this.SyncSettings.RTCInitialTime;
|
||||
real_rtc_time = DeterministicEmulation ? false : this.SyncSettings.RealTimeRTC;
|
||||
zerotime = (uint)this._SyncSettings.RTCInitialTime;
|
||||
real_rtc_time = DeterministicEmulation ? false : this._SyncSettings.RealTimeRTC;
|
||||
|
||||
LibGambatte.LoadFlags flags = 0;
|
||||
|
||||
if (this.SyncSettings.ForceDMG)
|
||||
if (this._SyncSettings.ForceDMG)
|
||||
flags |= LibGambatte.LoadFlags.FORCE_DMG;
|
||||
if (this.SyncSettings.GBACGB)
|
||||
if (this._SyncSettings.GBACGB)
|
||||
flags |= LibGambatte.LoadFlags.GBA_CGB;
|
||||
if (this.SyncSettings.MulticartCompat)
|
||||
if (this._SyncSettings.MulticartCompat)
|
||||
flags |= LibGambatte.LoadFlags.MULTICART_COMPAT;
|
||||
|
||||
if (LibGambatte.gambatte_load(GambatteState, romdata, (uint)romdata.Length, GetCurrentTime(), flags) != 0)
|
||||
|
@ -971,18 +972,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
#region Settings
|
||||
|
||||
GambatteSettings Settings;
|
||||
GambatteSyncSettings SyncSettings;
|
||||
GambatteSettings _Settings;
|
||||
GambatteSyncSettings _SyncSettings;
|
||||
|
||||
public object GetSettings() { return Settings.Clone(); }
|
||||
public object GetSyncSettings() { return SyncSettings.Clone(); }
|
||||
public object GetSettings() { return _Settings.Clone(); }
|
||||
public object GetSyncSettings() { return _SyncSettings.Clone(); }
|
||||
public bool PutSettings(object o)
|
||||
{
|
||||
Settings = (GambatteSettings)o;
|
||||
_Settings = (GambatteSettings)o;
|
||||
if (IsCGBMode())
|
||||
SetCGBColors(Settings.CGBColors);
|
||||
SetCGBColors(_Settings.CGBColors);
|
||||
else
|
||||
ChangeDMGColors(Settings.GBPalette);
|
||||
ChangeDMGColors(_Settings.GBPalette);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -990,16 +991,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
{
|
||||
var s = (GambatteSyncSettings)o;
|
||||
bool ret;
|
||||
if (s.ForceDMG != SyncSettings.ForceDMG ||
|
||||
s.GBACGB != SyncSettings.GBACGB ||
|
||||
s.MulticartCompat != SyncSettings.MulticartCompat ||
|
||||
s.RealTimeRTC != SyncSettings.RealTimeRTC ||
|
||||
s.RTCInitialTime != SyncSettings.RTCInitialTime)
|
||||
if (s.ForceDMG != _SyncSettings.ForceDMG ||
|
||||
s.GBACGB != _SyncSettings.GBACGB ||
|
||||
s.MulticartCompat != _SyncSettings.MulticartCompat ||
|
||||
s.RealTimeRTC != _SyncSettings.RealTimeRTC ||
|
||||
s.RTCInitialTime != _SyncSettings.RTCInitialTime)
|
||||
ret = true;
|
||||
else
|
||||
ret = false;
|
||||
|
||||
SyncSettings = s;
|
||||
_SyncSettings = s;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1053,21 +1054,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
[JsonIgnore]
|
||||
int _RTCInitialTime;
|
||||
|
||||
public static GambatteSyncSettings GetDefaults()
|
||||
public GambatteSyncSettings()
|
||||
{
|
||||
return new GambatteSyncSettings
|
||||
{
|
||||
ForceDMG = false,
|
||||
GBACGB = false,
|
||||
MulticartCompat = false,
|
||||
RealTimeRTC = false,
|
||||
_RTCInitialTime = 0
|
||||
};
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
||||
public GambatteSyncSettings Clone()
|
||||
{
|
||||
// this does include anonymous backing fields for auto properties
|
||||
return (GambatteSyncSettings)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, object Settings, object SyncSettings, bool deterministic)
|
||||
{
|
||||
GambatteLinkSettings _Settings = (GambatteLinkSettings)Settings ?? GambatteLinkSettings.GetDefaults();
|
||||
GambatteLinkSyncSettings _SyncSettings = (GambatteLinkSyncSettings)SyncSettings ?? GambatteLinkSyncSettings.GetDefaults();
|
||||
GambatteLinkSyncSettings _SyncSettings = (GambatteLinkSyncSettings)SyncSettings ?? new GambatteLinkSyncSettings();
|
||||
|
||||
CoreComm = comm;
|
||||
L = new Gameboy(new CoreComm(comm.ShowMessage, comm.Notify), leftinfo, leftrom, _Settings.L, _SyncSettings.L, deterministic);
|
||||
|
@ -501,13 +501,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
public Gameboy.GambatteSyncSettings L;
|
||||
public Gameboy.GambatteSyncSettings R;
|
||||
|
||||
public static GambatteLinkSyncSettings GetDefaults()
|
||||
public GambatteLinkSyncSettings()
|
||||
{
|
||||
return new GambatteLinkSyncSettings
|
||||
{
|
||||
L = Gameboy.GambatteSyncSettings.GetDefaults(),
|
||||
R = Gameboy.GambatteSyncSettings.GetDefaults()
|
||||
};
|
||||
L = new Gameboy.GambatteSyncSettings();
|
||||
R = new Gameboy.GambatteSyncSettings();
|
||||
}
|
||||
|
||||
public GambatteLinkSyncSettings Clone()
|
||||
|
|
|
@ -707,7 +707,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
|
||||
#endregion
|
||||
|
||||
public SaturnSyncSettings SyncSettings;
|
||||
SaturnSyncSettings SyncSettings;
|
||||
|
||||
public object GetSettings() { return null; }
|
||||
public object GetSyncSettings() { return SyncSettings.Clone(); }
|
||||
|
@ -781,7 +781,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
}
|
||||
public SaturnSyncSettings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues<SaturnSyncSettings>(this);
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue