pce: make slstart, slend non-sync settings because the core supports it and the waterbox supports it
This commit is contained in:
parent
842a7df215
commit
2cc106de98
|
@ -56,6 +56,10 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
|
||||||
{ "nyma.rtcinitialtime", null },
|
{ "nyma.rtcinitialtime", null },
|
||||||
{ "nyma.rtcrealtime", null },
|
{ "nyma.rtcrealtime", null },
|
||||||
};
|
};
|
||||||
|
protected override ISet<string> NonSyncSettingNames { get; } = new HashSet<string>
|
||||||
|
{
|
||||||
|
"pce.slstart", "pce.slend",
|
||||||
|
};
|
||||||
|
|
||||||
protected override IDictionary<string, string> ButtonNameOverrides { get; } = new Dictionary<string, string>
|
protected override IDictionary<string, string> ButtonNameOverrides { get; } = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,9 +47,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
var s1 = SettingsInfo.Ports
|
var s1 = SettingsInfo.Ports
|
||||||
.Select((p, i) => new PortPropertyDescriptor(p, i))
|
.Select((p, i) => new PortPropertyDescriptor(p, i))
|
||||||
.Cast<PropertyDescriptor>();
|
.Cast<PropertyDescriptor>();
|
||||||
var s2 = SettingsInfo.Settings
|
var s2 = SettingsInfo.SyncSettings
|
||||||
.Where(s => !SettingsInfo.HiddenSettings.Contains(s.SettingsKey))
|
.Select(m => MednaPropertyDescriptor.Create(m, true));
|
||||||
.Select(m => MednaPropertyDescriptor.Create(m));
|
|
||||||
return new PropertyDescriptorCollection(s1.Concat(s2).ToArray());
|
return new PropertyDescriptorCollection(s1.Concat(s2).ToArray());
|
||||||
}
|
}
|
||||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
|
@ -67,8 +66,11 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
public override PropertyDescriptor GetDefaultProperty() => GetProperties()[0]; // "default" ??
|
public override PropertyDescriptor GetDefaultProperty() => GetProperties()[0]; // "default" ??
|
||||||
public override PropertyDescriptorCollection GetProperties()
|
public override PropertyDescriptorCollection GetProperties()
|
||||||
{
|
{
|
||||||
return new PropertyDescriptorCollection(
|
var s1 = SettingsInfo.LayerNames.Select(l => new LayerPropertyDescriptor(l))
|
||||||
SettingsInfo.LayerNames.Select(l => new LayerPropertyDescriptor(l)).ToArray());
|
.Cast<PropertyDescriptor>();
|
||||||
|
var s2 = SettingsInfo.Settings
|
||||||
|
.Select(m => MednaPropertyDescriptor.Create(m, true));
|
||||||
|
return new PropertyDescriptorCollection(s1.Concat(s2).ToArray());
|
||||||
}
|
}
|
||||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties();
|
||||||
}
|
}
|
||||||
|
@ -76,13 +78,15 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
public abstract class MednaPropertyDescriptor : PropertyDescriptor
|
public abstract class MednaPropertyDescriptor : PropertyDescriptor
|
||||||
{
|
{
|
||||||
public SettingT Setting { get; private set; }
|
public SettingT Setting { get; private set; }
|
||||||
public MednaPropertyDescriptor(SettingT setting)
|
private bool _isSyncSetting;
|
||||||
|
public MednaPropertyDescriptor(SettingT setting, bool isSyncSetting)
|
||||||
: base(setting.SettingsKey, new Attribute[0])
|
: base(setting.SettingsKey, new Attribute[0])
|
||||||
{
|
{
|
||||||
Setting = setting;
|
Setting = setting;
|
||||||
|
_isSyncSetting = isSyncSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Type ComponentType => typeof(NymaSyncSettings);
|
public override Type ComponentType => _isSyncSetting ? typeof(NymaSyncSettings) : typeof(NymaSettings);
|
||||||
public override bool IsReadOnly => false;
|
public override bool IsReadOnly => false;
|
||||||
// public override Type PropertyType => typeof(string);
|
// public override Type PropertyType => typeof(string);
|
||||||
public override bool CanResetValue(object component) => true;
|
public override bool CanResetValue(object component) => true;
|
||||||
|
@ -97,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
|
||||||
public override object GetValue(object component)
|
public override object GetValue(object component)
|
||||||
{
|
{
|
||||||
var ss = (NymaSyncSettings)component;
|
var ss = (INymaDictionarySettings)component;
|
||||||
if (!ss.MednafenValues.TryGetValue(Setting.SettingsKey, out var val))
|
if (!ss.MednafenValues.TryGetValue(Setting.SettingsKey, out var val))
|
||||||
val = Setting.DefaultValue;
|
val = Setting.DefaultValue;
|
||||||
var ret = ConvertFromString(val);
|
var ret = ConvertFromString(val);
|
||||||
|
@ -106,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
|
||||||
public override void ResetValue(object component)
|
public override void ResetValue(object component)
|
||||||
{
|
{
|
||||||
((NymaSyncSettings)component).MednafenValues.Remove(Setting.SettingsKey);
|
((INymaDictionarySettings)component).MednafenValues.Remove(Setting.SettingsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetValue(object component, object value)
|
public override void SetValue(object component, object value)
|
||||||
|
@ -117,30 +121,30 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
ResetValue(component);
|
ResetValue(component);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
((NymaSyncSettings)component).MednafenValues[Setting.SettingsKey] = s;
|
((INymaDictionarySettings)component).MednafenValues[Setting.SettingsKey] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldSerializeValue(object component)
|
public override bool ShouldSerializeValue(object component)
|
||||||
{
|
{
|
||||||
return ((NymaSyncSettings)component).MednafenValues.ContainsKey(Setting.SettingsKey);
|
return ((INymaDictionarySettings)component).MednafenValues.ContainsKey(Setting.SettingsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MednaPropertyDescriptor Create(SettingT s)
|
public static MednaPropertyDescriptor Create(SettingT s, bool isSyncSetting)
|
||||||
{
|
{
|
||||||
switch (s.Type)
|
switch (s.Type)
|
||||||
{
|
{
|
||||||
case SettingType.Int:
|
case SettingType.Int:
|
||||||
return new MednaLongDescriptor(s);
|
return new MednaLongDescriptor(s, isSyncSetting);
|
||||||
case SettingType.Uint:
|
case SettingType.Uint:
|
||||||
return new MednaUlongDescriptor(s);
|
return new MednaUlongDescriptor(s, isSyncSetting);
|
||||||
case SettingType.Bool:
|
case SettingType.Bool:
|
||||||
return new MednaBoolDescriptor(s);
|
return new MednaBoolDescriptor(s, isSyncSetting);
|
||||||
case SettingType.Float:
|
case SettingType.Float:
|
||||||
return new MednaDoubleDescriptor(s);
|
return new MednaDoubleDescriptor(s, isSyncSetting);
|
||||||
case SettingType.String:
|
case SettingType.String:
|
||||||
return new MednaStringDescriptor(s);
|
return new MednaStringDescriptor(s, isSyncSetting);
|
||||||
case SettingType.Enum:
|
case SettingType.Enum:
|
||||||
return new MednaEnumDescriptor(s);
|
return new MednaEnumDescriptor(s, isSyncSetting);
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException($"Unexpected SettingType {s.Type}");
|
throw new NotImplementedException($"Unexpected SettingType {s.Type}");
|
||||||
}
|
}
|
||||||
|
@ -149,7 +153,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
|
||||||
public class MednaEnumDescriptor : MednaPropertyDescriptor
|
public class MednaEnumDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaEnumDescriptor(SettingT s) : base(s) {}
|
public MednaEnumDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(string);
|
public override Type PropertyType => typeof(string);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +200,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
public class MednaStringDescriptor : MednaPropertyDescriptor
|
public class MednaStringDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaStringDescriptor(SettingT s) : base(s) {}
|
public MednaStringDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(string);
|
public override Type PropertyType => typeof(string);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +213,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
public class MednaBoolDescriptor : MednaPropertyDescriptor
|
public class MednaBoolDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaBoolDescriptor(SettingT s) : base(s) {}
|
public MednaBoolDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(bool);
|
public override Type PropertyType => typeof(bool);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +226,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
public class MednaLongDescriptor : MednaPropertyDescriptor
|
public class MednaLongDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaLongDescriptor(SettingT s) : base(s) {}
|
public MednaLongDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(long);
|
public override Type PropertyType => typeof(long);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +242,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
public class MednaUlongDescriptor : MednaPropertyDescriptor
|
public class MednaUlongDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaUlongDescriptor(SettingT s) : base(s) {}
|
public MednaUlongDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(ulong);
|
public override Type PropertyType => typeof(ulong);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
@ -265,7 +269,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
}
|
}
|
||||||
public class MednaDoubleDescriptor : MednaPropertyDescriptor
|
public class MednaDoubleDescriptor : MednaPropertyDescriptor
|
||||||
{
|
{
|
||||||
public MednaDoubleDescriptor(SettingT s) : base(s) {}
|
public MednaDoubleDescriptor(SettingT s, bool isSyncSetting) : base(s, isSyncSetting) {}
|
||||||
public override Type PropertyType => typeof(double);
|
public override Type PropertyType => typeof(double);
|
||||||
protected override object ConvertFromString(string s)
|
protected override object ConvertFromString(string s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,8 +7,6 @@ using System.Text;
|
||||||
using BizHawk.BizInvoke;
|
using BizHawk.BizInvoke;
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using FlatBuffers;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NymaTypes;
|
using NymaTypes;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Waterbox
|
namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
@ -20,6 +18,10 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
/// If the value is null, use the default value, otherwise override it.
|
/// If the value is null, use the default value, otherwise override it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual IDictionary<string, string> SettingsOverrides { get; } = new Dictionary<string, string>();
|
protected virtual IDictionary<string, string> SettingsOverrides { get; } = new Dictionary<string, string>();
|
||||||
|
/// <summary>
|
||||||
|
/// Add any settings here that your core is not sync sensitive to. Don't screw up and cause nondeterminism!
|
||||||
|
/// </summary>
|
||||||
|
protected virtual ISet<string> NonSyncSettingNames { get; } = new HashSet<string>();
|
||||||
public NymaSettingsInfo SettingsInfo { get; private set; }
|
public NymaSettingsInfo SettingsInfo { get; private set; }
|
||||||
private NymaSettings _settings;
|
private NymaSettings _settings;
|
||||||
private NymaSyncSettings _syncSettings;
|
private NymaSyncSettings _syncSettings;
|
||||||
|
@ -62,16 +64,26 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
: PutSettingsDirtyBits.RebootCore;
|
: PutSettingsDirtyBits.RebootCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NymaSettings
|
public interface INymaDictionarySettings
|
||||||
{
|
{
|
||||||
|
Dictionary<string, string> MednafenValues { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NymaSettings : INymaDictionarySettings
|
||||||
|
{
|
||||||
|
public Dictionary<string, string> MednafenValues { get; set; } = new Dictionary<string, string>();
|
||||||
public HashSet<string> DisabledLayers { get; set; } = new HashSet<string>();
|
public HashSet<string> DisabledLayers { get; set; } = new HashSet<string>();
|
||||||
public NymaSettings Clone()
|
public NymaSettings Clone()
|
||||||
{
|
{
|
||||||
return new NymaSettings { DisabledLayers = new HashSet<string>(DisabledLayers) };
|
return new NymaSettings
|
||||||
|
{
|
||||||
|
MednafenValues = new Dictionary<string, string>(MednafenValues),
|
||||||
|
DisabledLayers = new HashSet<string>(DisabledLayers),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NymaSyncSettings
|
public class NymaSyncSettings : INymaDictionarySettings
|
||||||
{
|
{
|
||||||
public Dictionary<string, string> MednafenValues { get; set; } = new Dictionary<string, string>();
|
public Dictionary<string, string> MednafenValues { get; set; } = new Dictionary<string, string>();
|
||||||
public Dictionary<int, string> PortDevices { get; set; } = new Dictionary<int, string>();
|
public Dictionary<int, string> PortDevices { get; set; } = new Dictionary<int, string>();
|
||||||
|
@ -100,20 +112,27 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
|
|
||||||
protected string SettingsQuery(string name)
|
protected string SettingsQuery(string name)
|
||||||
{
|
{
|
||||||
var forced = SettingsOverrides.TryGetValue(name, out var val);
|
if (SettingsOverrides.TryGetValue(name, out var val))
|
||||||
|
{
|
||||||
|
// use override
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// try to get actual value from settings
|
||||||
|
if (NonSyncSettingNames.Contains(name))
|
||||||
|
_settings.MednafenValues.TryGetValue(name, out val);
|
||||||
|
else
|
||||||
|
_syncSettings.MednafenValues.TryGetValue(name, out val);
|
||||||
|
}
|
||||||
|
// in either case, might need defaults
|
||||||
if (val == null)
|
if (val == null)
|
||||||
{
|
{
|
||||||
if (forced || !_syncSettingsActual.MednafenValues.TryGetValue(name, out val))
|
SettingsInfo.AllSettingsByKey.TryGetValue(name, out var info);
|
||||||
{
|
val = info?.DefaultValue;
|
||||||
if (SettingsInfo.SettingsByKey.TryGetValue(name, out var info))
|
}
|
||||||
{
|
if (val == null)
|
||||||
val = info.DefaultValue;
|
{
|
||||||
}
|
throw new InvalidOperationException($"Core asked for setting {name} which was not found in the defaults");
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Core asked for setting {name} which was not found in the defaults");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -133,11 +152,11 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the settings object has at least one settable value in it
|
/// If true, the settings object has at least one settable value in it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasSettings => SettingsInfo.LayerNames.Any();
|
public bool HasSettings => SettingsInfo.LayerNames.Count > 0|| SettingsInfo.Settings.Count > 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the syncSettings object has at least one settable value in it
|
/// If true, the syncSettings object has at least one settable value in it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasSyncSettings => SettingsInfo.Ports.Any() || SettingsInfo.Settings.Any();
|
public bool HasSyncSettings => SettingsInfo.Ports.Count > 0 || SettingsInfo.SyncSettings.Count > 0;
|
||||||
|
|
||||||
public class NymaSettingsInfo
|
public class NymaSettingsInfo
|
||||||
{
|
{
|
||||||
|
@ -162,8 +181,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Port> Ports { get; set; } = new List<Port>();
|
public List<Port> Ports { get; set; } = new List<Port>();
|
||||||
public List<SettingT> Settings { get; set; } = new List<SettingT>();
|
public List<SettingT> Settings { get; set; } = new List<SettingT>();
|
||||||
public Dictionary<string, SettingT> SettingsByKey { get; set; } = new Dictionary<string, SettingT>();
|
public List<SettingT> SyncSettings { get; set; } = new List<SettingT>();
|
||||||
public HashSet<string> HiddenSettings { get; set; } = new HashSet<string>();
|
public Dictionary<string, SettingT> AllSettingsByKey { get; set; } = new Dictionary<string, SettingT>();
|
||||||
}
|
}
|
||||||
private void InitSyncSettingsInfo(List<NPortInfoT> allPorts)
|
private void InitSyncSettingsInfo(List<NPortInfoT> allPorts)
|
||||||
{
|
{
|
||||||
|
@ -184,16 +203,20 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var setting in GetSettingsData())
|
foreach (var setting in GetSettingsData().Concat(ExtraSettings))
|
||||||
{
|
{
|
||||||
s.Settings.Add(setting);
|
s.AllSettingsByKey.Add(setting.SettingsKey, setting);
|
||||||
s.SettingsByKey.Add(setting.SettingsKey, setting);
|
if (!SettingsOverrides.ContainsKey(setting.SettingsKey))
|
||||||
}
|
{
|
||||||
s.HiddenSettings = new HashSet<string>(SettingsOverrides.Keys);
|
if (NonSyncSettingNames.Contains(setting.SettingsKey))
|
||||||
foreach (var ss in ExtraSettings)
|
{
|
||||||
{
|
s.Settings.Add(setting);
|
||||||
s.Settings.Add(ss);
|
}
|
||||||
s.SettingsByKey.Add(ss.SettingsKey, ss);
|
else
|
||||||
|
{
|
||||||
|
s.SyncSettings.Add(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SettingsInfo = s;
|
SettingsInfo = s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue