Provide some base implementations on `Watch`
This commit is contained in:
parent
9e454bda6d
commit
b2a0ad0857
|
@ -99,10 +99,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override string Diff => $"{_value - _previous:+#;-#;0}";
|
||||
|
||||
public override bool IsValid => Domain.Size == 0 || Address < Domain.Size;
|
||||
|
||||
public override uint MaxValue => byte.MaxValue;
|
||||
|
||||
public override int Value => GetByte();
|
||||
|
||||
public override string ValueString => FormatValue(GetByte());
|
||||
|
|
|
@ -100,10 +100,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override string Diff => $"{_value - (long)_previous:+#;-#;0}";
|
||||
|
||||
public override bool IsValid => Domain.Size == 0 || Address < (Domain.Size - 3);
|
||||
|
||||
public override uint MaxValue => uint.MaxValue;
|
||||
|
||||
public override int Value => (int)GetDWord();
|
||||
|
||||
public override string ValueString => FormatValue(GetDWord());
|
||||
|
|
|
@ -90,11 +90,6 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public override string Diff => "";
|
||||
|
||||
/// <summary>
|
||||
/// Ignore that stuff
|
||||
/// </summary>
|
||||
public override uint MaxValue => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ignore that stuff
|
||||
/// </summary>
|
||||
|
|
|
@ -502,7 +502,15 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Gets the maximum possible value
|
||||
/// </summary>
|
||||
public abstract uint MaxValue { get; }
|
||||
public uint MaxValue
|
||||
=> Size switch
|
||||
{
|
||||
WatchSize.Separator => 0,
|
||||
WatchSize.Byte => byte.MaxValue,
|
||||
WatchSize.Word => ushort.MaxValue,
|
||||
WatchSize.DWord => uint.MaxValue,
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current value
|
||||
|
@ -517,7 +525,8 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Returns true if the Watch is valid, false otherwise
|
||||
/// </summary>
|
||||
public abstract bool IsValid { get; }
|
||||
public virtual bool IsValid
|
||||
=> Domain.Size is 0 || Address <= Domain.Size - unchecked((long) Size);
|
||||
|
||||
/// <summary>
|
||||
/// Try to sets the value into the <see cref="MemoryDomain"/>
|
||||
|
|
|
@ -98,10 +98,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override string Diff => $"{_value - _previous:+#;-#;0}";
|
||||
|
||||
public override bool IsValid => Domain.Size == 0 || Address < (Domain.Size - 1);
|
||||
|
||||
public override uint MaxValue => ushort.MaxValue;
|
||||
|
||||
public override int Value => GetWord();
|
||||
|
||||
public override string ValueString => FormatValue(GetWord());
|
||||
|
|
Loading…
Reference in New Issue