(guess) Merge `IMiniWatchDetails` and `IMiniWatch`
This commit is contained in:
parent
035fbea559
commit
fdabc5ed13
|
@ -7,36 +7,21 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
internal static class Extensions
|
internal static class Extensions
|
||||||
{
|
{
|
||||||
public static IEnumerable<IMiniWatch> ToBytes(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
public static IEnumerable<IMiniWatch> ToBytes(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
||||||
=> settings.IsDetailed()
|
=> addresses.ToDetailedBytes(settings.Domain);
|
||||||
? addresses.ToDetailedBytes(settings.Domain)
|
|
||||||
: addresses.ToBytes(settings.Domain);
|
|
||||||
|
|
||||||
public static IEnumerable<IMiniWatch> ToWords(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
public static IEnumerable<IMiniWatch> ToWords(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
||||||
=> settings.IsDetailed()
|
=> addresses.ToDetailedWords(settings.Domain, settings.BigEndian);
|
||||||
? addresses.ToDetailedWords(settings.Domain, settings.BigEndian)
|
|
||||||
: addresses.ToWords(settings.Domain, settings.BigEndian);
|
|
||||||
|
|
||||||
public static IEnumerable<IMiniWatch> ToDWords(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
public static IEnumerable<IMiniWatch> ToDWords(this IEnumerable<long> addresses, SearchEngineSettings settings)
|
||||||
=> settings.IsDetailed()
|
=> addresses.ToDetailedDWords(settings.Domain, settings.BigEndian);
|
||||||
? addresses.ToDetailedDWords(settings.Domain, settings.BigEndian)
|
|
||||||
: addresses.ToDWords(settings.Domain, settings.BigEndian);
|
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToBytes(this IEnumerable<long> addresses, MemoryDomain domain)
|
|
||||||
=> addresses.Select(a => new MiniByteWatch(domain, a));
|
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToDetailedBytes(this IEnumerable<long> addresses, MemoryDomain domain)
|
private static IEnumerable<IMiniWatch> ToDetailedBytes(this IEnumerable<long> addresses, MemoryDomain domain)
|
||||||
=> addresses.Select(a => new MiniByteWatchDetailed(domain, a));
|
=> addresses.Select(a => new MiniByteWatch(domain, a));
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
|
||||||
=> addresses.Select(a => new MiniWordWatch(domain, a, bigEndian));
|
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToDetailedWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
private static IEnumerable<IMiniWatch> ToDetailedWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
||||||
=> addresses.Select(a => new MiniWordWatchDetailed(domain, a, bigEndian));
|
=> addresses.Select(a => new MiniWordWatch(domain, a, bigEndian));
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToDWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
|
||||||
=> addresses.Select(a => new MiniDWordWatch(domain, a, bigEndian));
|
|
||||||
|
|
||||||
private static IEnumerable<IMiniWatch> ToDetailedDWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
private static IEnumerable<IMiniWatch> ToDetailedDWords(this IEnumerable<long> addresses, MemoryDomain domain, bool bigEndian)
|
||||||
=> addresses.Select(a => new MiniDWordWatchDetailed(domain, a, bigEndian));
|
=> addresses.Select(a => new MiniDWordWatch(domain, a, bigEndian));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,130 +4,172 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Ram address for watching in the <see cref="RamSearchEngine" />
|
/// Represents a Ram address for watching in the <see cref="RamSearchEngine" />
|
||||||
/// With the minimal details necessary for searching
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal interface IMiniWatch
|
internal interface IMiniWatch
|
||||||
{
|
{
|
||||||
long Address { get; }
|
long Address { get; }
|
||||||
long Previous { get; } // do not store sign extended variables in here.
|
long Previous { get; } // do not store sign extended variables in here.
|
||||||
void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian);
|
long Current { get; }
|
||||||
|
int ChangeCount { get; }
|
||||||
|
void ClearChangeCount();
|
||||||
|
void SetPreviousToCurrent();
|
||||||
bool IsValid(MemoryDomain domain);
|
bool IsValid(MemoryDomain domain);
|
||||||
|
void Update(PreviousType type, MemoryDomain domain, bool bigEndian);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class MiniByteWatch : IMiniWatch
|
internal sealed class MiniByteWatch : IMiniWatch
|
||||||
{
|
{
|
||||||
public long Address { get; }
|
public long Address { get; }
|
||||||
|
|
||||||
private byte _previous;
|
private byte _previous;
|
||||||
|
private byte _current;
|
||||||
|
|
||||||
public MiniByteWatch(MemoryDomain domain, long addr)
|
public MiniByteWatch(MemoryDomain domain, long addr)
|
||||||
{
|
{
|
||||||
Address = addr;
|
Address = addr;
|
||||||
_previous = GetByte(Address, domain);
|
_previous = _current = GetByte(domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPreviousToCurrent()
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Previous => _previous;
|
public long Previous => _previous;
|
||||||
|
public long Current => _current;
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain)
|
public int ChangeCount { get; private set; }
|
||||||
{
|
|
||||||
return IsValid(Address, domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||||
{
|
{
|
||||||
_previous = GetByte(Address, domain);
|
var newValue = GetByte(domain);
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsValid(long address, MemoryDomain domain)
|
if (newValue != _current)
|
||||||
{
|
|
||||||
return address < domain.Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte GetByte(long address, MemoryDomain domain)
|
|
||||||
{
|
|
||||||
if (!IsValid(address, domain))
|
|
||||||
{
|
{
|
||||||
return 0;
|
ChangeCount++;
|
||||||
|
if (type == PreviousType.LastChange)
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.PeekByte(address);
|
if (type == PreviousType.LastFrame)
|
||||||
|
_previous = _current;
|
||||||
|
|
||||||
|
_current = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearChangeCount() => ChangeCount = 0;
|
||||||
|
|
||||||
|
public bool IsValid(MemoryDomain domain) => Address < domain.Size;
|
||||||
|
|
||||||
|
public byte GetByte(MemoryDomain domain)
|
||||||
|
{
|
||||||
|
return IsValid(domain) ? domain.PeekByte(Address) : (byte)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class MiniWordWatch : IMiniWatch
|
internal sealed class MiniWordWatch : IMiniWatch
|
||||||
{
|
{
|
||||||
public long Address { get; }
|
public long Address { get; }
|
||||||
|
|
||||||
private ushort _previous;
|
private ushort _previous;
|
||||||
|
private ushort _current;
|
||||||
|
|
||||||
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||||
{
|
{
|
||||||
Address = addr;
|
Address = addr;
|
||||||
_previous = GetUshort(Address, domain, bigEndian);
|
_previous = _current = GetUshort(domain, bigEndian);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPreviousToCurrent()
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Previous => _previous;
|
public long Previous => _previous;
|
||||||
|
public long Current => _current;
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
public int ChangeCount { get; private set; }
|
||||||
{
|
|
||||||
_previous = GetUshort(Address, domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain)
|
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||||
{
|
{
|
||||||
return IsValid(Address, domain);
|
var newValue = GetUshort(domain, bigEndian);
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsValid(long address, MemoryDomain domain)
|
if (newValue != _current)
|
||||||
{
|
|
||||||
return address < (domain.Size - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ushort GetUshort(long address, MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
if (!IsValid(address, domain))
|
|
||||||
{
|
{
|
||||||
return 0;
|
ChangeCount++;
|
||||||
|
if (type == PreviousType.LastChange)
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.PeekUshort(address, bigEndian);
|
if (type == PreviousType.LastFrame)
|
||||||
|
_previous = _current;
|
||||||
|
|
||||||
|
_current = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearChangeCount() => ChangeCount = 0;
|
||||||
|
|
||||||
|
public bool IsValid(MemoryDomain domain) => Address < domain.Size - 1;
|
||||||
|
|
||||||
|
private ushort GetUshort(MemoryDomain domain, bool bigEndian)
|
||||||
|
{
|
||||||
|
return IsValid(domain) ? domain.PeekUshort(Address, bigEndian) : (ushort)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class MiniDWordWatch : IMiniWatch
|
internal sealed class MiniDWordWatch : IMiniWatch
|
||||||
{
|
{
|
||||||
public long Address { get; }
|
public long Address { get; }
|
||||||
|
|
||||||
private uint _previous;
|
private uint _previous;
|
||||||
|
private uint _current;
|
||||||
|
|
||||||
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
|
||||||
{
|
{
|
||||||
Address = addr;
|
Address = addr;
|
||||||
_previous = GetUint(Address, domain, bigEndian);
|
_previous = _current = GetUint(domain, bigEndian);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPreviousToCurrent()
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Previous => _previous;
|
public long Previous => _previous;
|
||||||
|
public long Current => _current;
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
public int ChangeCount { get; private set; }
|
||||||
{
|
|
||||||
_previous = GetUint(Address, domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain)
|
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
||||||
{
|
{
|
||||||
return IsValid(Address, domain);
|
var newValue = GetUint(domain, bigEndian);
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsValid(long address, MemoryDomain domain)
|
if (newValue != _current)
|
||||||
{
|
|
||||||
return address < (domain.Size - 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static uint GetUint(long address, MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
if (!IsValid(address, domain))
|
|
||||||
{
|
{
|
||||||
return 0;
|
ChangeCount++;
|
||||||
|
if (type == PreviousType.LastChange)
|
||||||
|
{
|
||||||
|
_previous = _current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.PeekUint(address, bigEndian);
|
if (type == PreviousType.LastFrame)
|
||||||
|
_previous = _current;
|
||||||
|
|
||||||
|
_current = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearChangeCount() => ChangeCount = 0;
|
||||||
|
|
||||||
|
public bool IsValid(MemoryDomain domain) => Address < domain.Size - 3;
|
||||||
|
|
||||||
|
private uint GetUint(MemoryDomain domain, bool bigEndian)
|
||||||
|
{
|
||||||
|
return IsValid(domain) ? domain.PeekUint(Address, bigEndian) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,183 +0,0 @@
|
||||||
using BizHawk.Emulation.Common;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common.RamSearchEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a <see cref="IMiniWatch" /> but with added details
|
|
||||||
/// to do change tracking. These types add more information but at a cost of
|
|
||||||
/// having to poll the ram address on every update
|
|
||||||
/// </summary>
|
|
||||||
internal interface IMiniWatchDetails : IMiniWatch
|
|
||||||
{
|
|
||||||
int ChangeCount { get; }
|
|
||||||
|
|
||||||
void ClearChangeCount();
|
|
||||||
void Update(PreviousType type, MemoryDomain domain, bool bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class MiniByteWatchDetailed : IMiniWatchDetails
|
|
||||||
{
|
|
||||||
public long Address { get; }
|
|
||||||
|
|
||||||
private byte _previous;
|
|
||||||
private byte _prevFrame;
|
|
||||||
|
|
||||||
public MiniByteWatchDetailed(MemoryDomain domain, long addr)
|
|
||||||
{
|
|
||||||
Address = addr;
|
|
||||||
SetPreviousToCurrent(domain, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame = MiniByteWatch.GetByte(Address, domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long 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)
|
|
||||||
{
|
|
||||||
ChangeCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case PreviousType.Original:
|
|
||||||
case PreviousType.LastSearch:
|
|
||||||
break;
|
|
||||||
case PreviousType.LastFrame:
|
|
||||||
_previous = _prevFrame;
|
|
||||||
break;
|
|
||||||
case PreviousType.LastChange:
|
|
||||||
if (_prevFrame != value)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_prevFrame = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearChangeCount() => ChangeCount = 0;
|
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain) => MiniByteWatch.IsValid(Address, domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class MiniWordWatchDetailed : IMiniWatchDetails
|
|
||||||
{
|
|
||||||
public long Address { get; }
|
|
||||||
|
|
||||||
private ushort _previous;
|
|
||||||
private ushort _prevFrame;
|
|
||||||
|
|
||||||
public MiniWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
|
|
||||||
{
|
|
||||||
Address = addr;
|
|
||||||
SetPreviousToCurrent(domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame = MiniWordWatch.GetUshort(Address, domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long Previous => _previous;
|
|
||||||
|
|
||||||
public int ChangeCount { get; private set; }
|
|
||||||
|
|
||||||
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
var value = MiniWordWatch.GetUshort(Address, domain, bigEndian);
|
|
||||||
if (value != Previous)
|
|
||||||
{
|
|
||||||
ChangeCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case PreviousType.Original:
|
|
||||||
case PreviousType.LastSearch:
|
|
||||||
break;
|
|
||||||
case PreviousType.LastFrame:
|
|
||||||
_previous = _prevFrame;
|
|
||||||
break;
|
|
||||||
case PreviousType.LastChange:
|
|
||||||
if (_prevFrame != value)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_prevFrame = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearChangeCount() => ChangeCount = 0;
|
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain) => MiniWordWatch.IsValid(Address, domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class MiniDWordWatchDetailed : IMiniWatchDetails
|
|
||||||
{
|
|
||||||
public long Address { get; }
|
|
||||||
|
|
||||||
private uint _previous;
|
|
||||||
private uint _prevFrame;
|
|
||||||
|
|
||||||
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
|
|
||||||
{
|
|
||||||
Address = addr;
|
|
||||||
SetPreviousToCurrent(domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame = MiniDWordWatch.GetUint(Address, domain, bigEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long Previous => (int)_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 != Previous)
|
|
||||||
{
|
|
||||||
ChangeCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case PreviousType.Original:
|
|
||||||
case PreviousType.LastSearch:
|
|
||||||
break;
|
|
||||||
case PreviousType.LastFrame:
|
|
||||||
_previous = _prevFrame;
|
|
||||||
break;
|
|
||||||
case PreviousType.LastChange:
|
|
||||||
if (_prevFrame != value)
|
|
||||||
{
|
|
||||||
_previous = _prevFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_prevFrame = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearChangeCount() => ChangeCount = 0;
|
|
||||||
|
|
||||||
public bool IsValid(MemoryDomain domain) => MiniDWordWatch.IsValid(Address, domain);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -64,46 +64,13 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case WatchSize.Byte:
|
case WatchSize.Byte:
|
||||||
if (_settings.IsDetailed())
|
for (var i = 0; i < _watchList.Length; i++) _watchList[i] = new MiniByteWatch(domain, i);
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++) _watchList[i] = new MiniByteWatchDetailed(domain, i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++) _watchList[i] = new MiniByteWatch(domain, i);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WatchSize.Word:
|
case WatchSize.Word:
|
||||||
if (_settings.IsDetailed())
|
for (var i = 0; i < _watchList.Length; i++) _watchList[i] = new MiniWordWatch(domain, i * stepSize, _settings.BigEndian);
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++)
|
|
||||||
{
|
|
||||||
_watchList[i] = new MiniWordWatchDetailed(domain, i * stepSize, _settings.BigEndian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++)
|
|
||||||
{
|
|
||||||
_watchList[i] = new MiniWordWatch(domain, i * stepSize, _settings.BigEndian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WatchSize.DWord:
|
case WatchSize.DWord:
|
||||||
if (_settings.IsDetailed())
|
for (var i = 0; i < _watchList.Length; i++) _watchList[i] = new MiniDWordWatch(domain, i * stepSize, _settings.BigEndian);
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++)
|
|
||||||
{
|
|
||||||
_watchList[i] = new MiniDWordWatchDetailed(domain, i * stepSize, _settings.BigEndian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _watchList.Length; i++)
|
|
||||||
{
|
|
||||||
_watchList[i] = new MiniDWordWatch(domain, i * stepSize, _settings.BigEndian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +88,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
_watchList[index].Previous,
|
_watchList[index].Previous,
|
||||||
_settings.IsDetailed() ? ((IMiniWatchDetails)_watchList[index]).ChangeCount : 0);
|
_settings.IsDetailed() ? _watchList[index].ChangeCount : 0);
|
||||||
|
|
||||||
public int DoSearch()
|
public int DoSearch()
|
||||||
{
|
{
|
||||||
|
@ -205,9 +172,8 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (!_settings.IsDetailed()) return;
|
|
||||||
using var @lock = _settings.Domain.EnterExit();
|
using var @lock = _settings.Domain.EnterExit();
|
||||||
foreach (IMiniWatchDetails watch in _watchList)
|
foreach (var watch in _watchList)
|
||||||
{
|
{
|
||||||
watch.Update(_settings.PreviousType, _settings.Domain, _settings.BigEndian);
|
watch.Update(_settings.PreviousType, _settings.Domain, _settings.BigEndian);
|
||||||
}
|
}
|
||||||
|
@ -235,8 +201,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
|
|
||||||
public void ClearChangeCounts()
|
public void ClearChangeCounts()
|
||||||
{
|
{
|
||||||
if (!_settings.IsDetailed()) return;
|
foreach (var watch in _watchList)
|
||||||
foreach (var watch in _watchList.Cast<IMiniWatchDetails>())
|
|
||||||
{
|
{
|
||||||
watch.ClearChangeCount();
|
watch.ClearChangeCount();
|
||||||
}
|
}
|
||||||
|
@ -302,12 +267,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
_watchList = _watchList.OrderBy(w => w.Previous, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.Previous, reverse).ToArray();
|
||||||
break;
|
break;
|
||||||
case WatchList.ChangesCol:
|
case WatchList.ChangesCol:
|
||||||
if (!_settings.IsDetailed()) break;
|
_watchList = _watchList.OrderBy(w => w.ChangeCount, reverse).ToArray();
|
||||||
_watchList = _watchList
|
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.OrderBy(w => w.ChangeCount, reverse)
|
|
||||||
.Cast<IMiniWatch>()
|
|
||||||
.ToArray();
|
|
||||||
break;
|
break;
|
||||||
case WatchList.Diff:
|
case WatchList.Diff:
|
||||||
_watchList = _watchList.OrderBy(w => GetValue(w.Address) - w.Previous, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => GetValue(w.Address) - w.Previous, reverse).ToArray();
|
||||||
|
@ -493,40 +453,25 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> CompareChanges(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> CompareChanges(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
if (!_settings.IsDetailed()) throw new InvalidCastException(); //TODO matches previous behaviour; was this intended to skip processing? --yoshi
|
|
||||||
if (CompareValue is not long compareValue) throw new InvalidCastException(); //TODO typo for IOE?
|
if (CompareValue is not long compareValue) throw new InvalidCastException(); //TODO typo for IOE?
|
||||||
switch (Operator)
|
switch (Operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount == compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount == compareValue);
|
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount != compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount != compareValue);
|
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount > compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount > compareValue);
|
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount >= compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount >= compareValue);
|
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount < compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount < compareValue);
|
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList
|
return watchList.Where(w => w.ChangeCount <= compareValue);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => w.ChangeCount <= compareValue);
|
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
return watchList
|
return watchList.Where(w => Math.Abs(w.ChangeCount - compareValue) == differentBy);
|
||||||
.Cast<IMiniWatchDetails>()
|
|
||||||
.Where(w => Math.Abs(w.ChangeCount - compareValue) == differentBy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1105,9 +1105,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Previous_LastChangeMenuItem.Checked = true;
|
Previous_LastChangeMenuItem.Checked = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviousFrameMenuItem.Enabled = _settings.IsDetailed();
|
|
||||||
Previous_LastChangeMenuItem.Enabled = _settings.IsDetailed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DetailedMenuItem_Click(object sender, EventArgs e)
|
private void DetailedMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -1169,8 +1166,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SearchSubMenu_DropDownOpened(object sender, EventArgs e)
|
private void SearchSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ClearChangeCountsMenuItem.Enabled = _settings.IsDetailed();
|
|
||||||
|
|
||||||
RemoveMenuItem.Enabled =
|
RemoveMenuItem.Enabled =
|
||||||
AddToRamWatchMenuItem.Enabled =
|
AddToRamWatchMenuItem.Enabled =
|
||||||
WatchListView.AnyRowsSelected;
|
WatchListView.AnyRowsSelected;
|
||||||
|
|
Loading…
Reference in New Issue