Make MiniWatchDetails derive from MiniWatch
This commit is contained in:
parent
70f7238d96
commit
3b1ce44fb5
|
@ -14,10 +14,10 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
bool IsValid(MemoryDomain domain);
|
||||
}
|
||||
|
||||
internal sealed class MiniByteWatch : IMiniWatch
|
||||
internal class MiniByteWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; }
|
||||
private byte _previous;
|
||||
private protected byte _previous;
|
||||
|
||||
public MiniByteWatch(MemoryDomain domain, long addr)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
return IsValid(Address, domain);
|
||||
}
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public virtual void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = GetByte(Address, domain);
|
||||
}
|
||||
|
@ -53,10 +53,10 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
}
|
||||
}
|
||||
|
||||
internal sealed class MiniWordWatch : IMiniWatch
|
||||
internal class MiniWordWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; }
|
||||
private ushort _previous;
|
||||
private protected ushort _previous;
|
||||
|
||||
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
|
||||
public uint Previous => _previous;
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public virtual void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = GetUshort(Address, domain, bigEndian);
|
||||
}
|
||||
|
@ -92,10 +92,10 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
}
|
||||
}
|
||||
|
||||
internal sealed class MiniDWordWatch : IMiniWatch
|
||||
internal class MiniDWordWatch : IMiniWatch
|
||||
{
|
||||
public long Address { get; }
|
||||
private uint _previous;
|
||||
private protected uint _previous;
|
||||
|
||||
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
|
||||
public uint Previous => _previous;
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public virtual void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = GetUint(Address, domain, bigEndian);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common.RamSearchEngine
|
||||
namespace BizHawk.Client.Common.RamSearchEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="IMiniWatch" /> but with added details
|
||||
|
@ -10,174 +10,126 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
|||
internal interface IMiniWatchDetails : IMiniWatch
|
||||
{
|
||||
int ChangeCount { get; }
|
||||
|
||||
void ClearChangeCount();
|
||||
void Update(PreviousType type, MemoryDomain domain, bool bigEndian);
|
||||
}
|
||||
|
||||
internal sealed class MiniByteWatchDetailed : IMiniWatchDetails
|
||||
internal sealed class MiniByteWatchDetailed : MiniByteWatch, IMiniWatchDetails
|
||||
{
|
||||
public long Address { get; }
|
||||
private byte _current;
|
||||
|
||||
private byte _previous;
|
||||
private byte _prevFrame;
|
||||
|
||||
public MiniByteWatchDetailed(MemoryDomain domain, long addr)
|
||||
public MiniByteWatchDetailed(MemoryDomain domain, long addr) : base(domain, addr)
|
||||
{
|
||||
Address = addr;
|
||||
SetPreviousToCurrent(domain, false);
|
||||
}
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = _prevFrame = MiniByteWatch.GetByte(Address, domain);
|
||||
_previous = _current = GetByte(Address, domain);
|
||||
}
|
||||
|
||||
public uint Previous => _previous;
|
||||
|
||||
public int ChangeCount { get; private set; }
|
||||
|
||||
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
var value = MiniByteWatch.GetByte(Address, domain);
|
||||
|
||||
if (value != _prevFrame)
|
||||
var newValue = GetByte(Address, domain);
|
||||
if (newValue != _current)
|
||||
{
|
||||
ChangeCount++;
|
||||
if (type is PreviousType.LastChange)
|
||||
{
|
||||
_previous = _current;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
if (type is PreviousType.LastFrame)
|
||||
{
|
||||
case PreviousType.Original:
|
||||
case PreviousType.LastSearch:
|
||||
break;
|
||||
case PreviousType.LastFrame:
|
||||
_previous = _prevFrame;
|
||||
break;
|
||||
case PreviousType.LastChange:
|
||||
if (_prevFrame != value)
|
||||
{
|
||||
_previous = _prevFrame;
|
||||
}
|
||||
|
||||
break;
|
||||
_previous = _current;
|
||||
}
|
||||
|
||||
_prevFrame = value;
|
||||
_current = newValue;
|
||||
}
|
||||
|
||||
public void ClearChangeCount() => ChangeCount = 0;
|
||||
|
||||
public bool IsValid(MemoryDomain domain) => MiniByteWatch.IsValid(Address, domain);
|
||||
}
|
||||
|
||||
internal sealed class MiniWordWatchDetailed : IMiniWatchDetails
|
||||
internal sealed class MiniWordWatchDetailed : MiniWordWatch, IMiniWatchDetails
|
||||
{
|
||||
public long Address { get; }
|
||||
private ushort _current;
|
||||
|
||||
private ushort _previous;
|
||||
private ushort _prevFrame;
|
||||
|
||||
public MiniWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
|
||||
public MiniWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian) : base(domain, addr, bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
SetPreviousToCurrent(domain, bigEndian);
|
||||
}
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = _prevFrame = MiniWordWatch.GetUshort(Address, domain, bigEndian);
|
||||
_previous = _current = GetUshort(Address, domain, bigEndian);
|
||||
}
|
||||
|
||||
public uint Previous => _previous;
|
||||
public uint Current => _current;
|
||||
|
||||
public int ChangeCount { get; private set; }
|
||||
|
||||
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
var value = MiniWordWatch.GetUshort(Address, domain, bigEndian);
|
||||
if (value != _prevFrame)
|
||||
var newValue = GetUshort(Address, domain, bigEndian);
|
||||
if (newValue != _current)
|
||||
{
|
||||
ChangeCount++;
|
||||
if (type is PreviousType.LastChange)
|
||||
{
|
||||
_previous = _current;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
if (type is PreviousType.LastFrame)
|
||||
{
|
||||
case PreviousType.Original:
|
||||
case PreviousType.LastSearch:
|
||||
break;
|
||||
case PreviousType.LastFrame:
|
||||
_previous = _prevFrame;
|
||||
break;
|
||||
case PreviousType.LastChange:
|
||||
if (_prevFrame != value)
|
||||
{
|
||||
_previous = _prevFrame;
|
||||
}
|
||||
|
||||
break;
|
||||
_previous = _current;
|
||||
}
|
||||
|
||||
_prevFrame = value;
|
||||
_current = newValue;
|
||||
}
|
||||
|
||||
public void ClearChangeCount() => ChangeCount = 0;
|
||||
|
||||
public bool IsValid(MemoryDomain domain) => MiniWordWatch.IsValid(Address, domain);
|
||||
}
|
||||
|
||||
internal sealed class MiniDWordWatchDetailed : IMiniWatchDetails
|
||||
internal sealed class MiniDWordWatchDetailed : MiniDWordWatch, IMiniWatchDetails
|
||||
{
|
||||
public long Address { get; }
|
||||
private uint _current;
|
||||
|
||||
private uint _previous;
|
||||
private uint _prevFrame;
|
||||
|
||||
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
|
||||
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian) : base(domain, addr, bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
SetPreviousToCurrent(domain, bigEndian);
|
||||
}
|
||||
|
||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
_previous = _prevFrame = MiniDWordWatch.GetUint(Address, domain, bigEndian);
|
||||
_previous = _current = GetUint(Address, domain, bigEndian);
|
||||
}
|
||||
|
||||
public uint Previous => _previous;
|
||||
|
||||
public int ChangeCount { get; private set; }
|
||||
|
||||
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||
{
|
||||
var value = MiniDWordWatch.GetUint(Address, domain, bigEndian);
|
||||
if (value != _prevFrame)
|
||||
var newValue = GetUint(Address, domain, bigEndian);
|
||||
if (newValue != _current)
|
||||
{
|
||||
ChangeCount++;
|
||||
if (type is PreviousType.LastChange)
|
||||
{
|
||||
_previous = _current;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
if (type is PreviousType.LastFrame)
|
||||
{
|
||||
case PreviousType.Original:
|
||||
case PreviousType.LastSearch:
|
||||
break;
|
||||
case PreviousType.LastFrame:
|
||||
_previous = _prevFrame;
|
||||
break;
|
||||
case PreviousType.LastChange:
|
||||
if (_prevFrame != value)
|
||||
{
|
||||
_previous = _prevFrame;
|
||||
}
|
||||
|
||||
break;
|
||||
_previous = _current;
|
||||
}
|
||||
|
||||
_prevFrame = value;
|
||||
_current = newValue;
|
||||
}
|
||||
|
||||
public void ClearChangeCount() => ChangeCount = 0;
|
||||
|
||||
public bool IsValid(MemoryDomain domain) => MiniDWordWatch.IsValid(Address, domain);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue