New Ram Search - some progress
This commit is contained in:
parent
3857c27f93
commit
657d858b99
|
@ -326,8 +326,6 @@ namespace BizHawk.MultiClient
|
|||
AutoloadDialogMenuItem.Checked = Global.Config.RecentSearches.AutoLoad;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void AutoloadDialogMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.RecentSearches.AutoLoad ^= true;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
class RamSearchEngine
|
||||
{
|
||||
private WatchList _watchList;
|
||||
private List<MiniWatch> _watchList = new List<MiniWatch>();
|
||||
private Settings _settings;
|
||||
|
||||
#region Constructors
|
||||
|
@ -24,12 +24,28 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void Start()
|
||||
{
|
||||
_watchList = new WatchList(_settings.Domain);
|
||||
|
||||
//TODO: other byte sizes, mis-aligned
|
||||
for (int i = 0; i < _settings.Domain.Size; i++)
|
||||
_watchList.Clear();
|
||||
switch (_settings.Size)
|
||||
{
|
||||
_watchList.Add(Watch.GenerateWatch(_settings.Domain, i, _settings.Size, _settings.Mode == Settings.SearchMode.Detailed));
|
||||
default:
|
||||
case Watch.WatchSize.Byte:
|
||||
for (int i = 0; i < _settings.Domain.Size; i++)
|
||||
{
|
||||
_watchList.Add(new MiniByteWatch(_settings.Domain, i));
|
||||
}
|
||||
break;
|
||||
case Watch.WatchSize.Word:
|
||||
for (int i = 0; i < _settings.Domain.Size; i += (_settings.CheckMisAligned ? 1 : 2))
|
||||
{
|
||||
_watchList.Add(new MiniWordWatch(_settings.Domain, i, _settings.BigEndian));
|
||||
}
|
||||
break;
|
||||
case Watch.WatchSize.DWord:
|
||||
for (int i = 0; i < _settings.Domain.Size; i += (_settings.CheckMisAligned ? 1 : 4))
|
||||
{
|
||||
_watchList.Add(new MiniDWordWatch(_settings.Domain, i, _settings.BigEndian));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +56,15 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
get
|
||||
{
|
||||
return _watchList[index];
|
||||
//TODO: must set prev value, change count, and display type!
|
||||
return Watch.GenerateWatch(
|
||||
_settings.Domain,
|
||||
_watchList[index].Address,
|
||||
_settings.Size,
|
||||
_settings.Type,
|
||||
_settings.BigEndian,
|
||||
_watchList[index].Value,
|
||||
_watchList[index].Value /*TODO*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +86,23 @@ namespace BizHawk.MultiClient
|
|||
//TODO
|
||||
}
|
||||
|
||||
public void SetType(Watch.DisplayType type)
|
||||
{
|
||||
if (Watch.AvailableTypes(_settings.Size).Contains(type))
|
||||
{
|
||||
_settings.Type = type;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEndian(bool bigendian)
|
||||
{
|
||||
_settings.BigEndian = bigendian;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparisons
|
||||
|
@ -96,6 +137,85 @@ namespace BizHawk.MultiClient
|
|||
#endregion
|
||||
|
||||
#region Classes
|
||||
private interface MiniWatch
|
||||
{
|
||||
int Address { get; }
|
||||
int Value { get; }
|
||||
}
|
||||
|
||||
private class MiniByteWatch : MiniWatch
|
||||
{
|
||||
public int Address { get; private set; }
|
||||
private byte val;
|
||||
|
||||
public MiniByteWatch(MemoryDomain domain, int addr)
|
||||
{
|
||||
Address = addr;
|
||||
val = domain.PeekByte(addr);
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get { return val; }
|
||||
}
|
||||
}
|
||||
|
||||
private class MiniWordWatch : MiniWatch
|
||||
{
|
||||
public int Address { get; private set; }
|
||||
private ushort val;
|
||||
|
||||
public MiniWordWatch(MemoryDomain domain, int addr, bool bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
if (bigEndian)
|
||||
{
|
||||
val = (ushort)((domain.PeekByte(addr) << 8) | (domain.PeekByte(addr + 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (ushort)((domain.PeekByte(addr)) | (domain.PeekByte(addr + 1) << 8));
|
||||
}
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get { return val; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MiniDWordWatch : MiniWatch
|
||||
{
|
||||
public int Address { get; private set; }
|
||||
private uint val;
|
||||
|
||||
public MiniDWordWatch(MemoryDomain domain, int addr, bool bigEndian)
|
||||
{
|
||||
Address = addr;
|
||||
|
||||
if (bigEndian)
|
||||
{
|
||||
val = (uint)((domain.PeekByte(addr) << 24)
|
||||
| (domain.PeekByte(addr + 1) << 16)
|
||||
| (domain.PeekByte(addr + 2) << 8)
|
||||
| (domain.PeekByte(addr + 3) << 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (uint)((domain.PeekByte(addr) << 0)
|
||||
| (domain.PeekByte(addr + 1) << 8)
|
||||
| (domain.PeekByte(addr + 2) << 16)
|
||||
| (domain.PeekByte(addr + 3) << 24));
|
||||
}
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get { return (int) val; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Settings
|
||||
{
|
||||
/*Require restart*/
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public static DisplayType StringToDisplayType(string name)
|
||||
{
|
||||
switch(name)
|
||||
switch (name)
|
||||
{
|
||||
default:
|
||||
return (DisplayType) Enum.Parse(typeof(DisplayType), name);
|
||||
return (DisplayType)Enum.Parse(typeof(DisplayType), name);
|
||||
case "Fixed Point 12.4":
|
||||
return DisplayType.FixedPoint_12_4;
|
||||
case "Fixed Point 20.12":
|
||||
|
@ -44,14 +44,14 @@ namespace BizHawk.MultiClient
|
|||
public abstract int? Value { get; }
|
||||
public abstract string ValueString { get; }
|
||||
public abstract WatchSize Size { get; }
|
||||
|
||||
|
||||
public abstract int? Previous { get; }
|
||||
public abstract string PreviousStr { get; }
|
||||
public abstract void ResetPrevious();
|
||||
|
||||
public abstract bool Poke(string value);
|
||||
|
||||
public virtual DisplayType Type { get { return _type; } set { _type = value; } }
|
||||
public virtual DisplayType Type { get { return _type; } set { _type = value; } }
|
||||
public virtual bool BigEndian { get { return _bigEndian; } set { _bigEndian = value; } }
|
||||
|
||||
public MemoryDomain Domain { get { return _domain; } }
|
||||
|
@ -272,6 +272,22 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, bool bigendian, int prev, int changecount)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
default:
|
||||
case WatchSize.Separator:
|
||||
return new SeparatorWatch();
|
||||
case WatchSize.Byte:
|
||||
return new DetailedByteWatch(domain, address, type, bigendian, (byte)prev, changecount);
|
||||
case WatchSize.Word:
|
||||
return new DetailedWordWatch(domain, address, type, bigendian, (ushort)prev, changecount);
|
||||
case WatchSize.DWord:
|
||||
return new DetailedDWordWatch(domain, address, type, bigendian, (uint)prev, changecount);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DisplayType> AvailableTypes(WatchSize size)
|
||||
{
|
||||
switch (size)
|
||||
|
@ -548,6 +564,15 @@ namespace BizHawk.MultiClient
|
|||
_value = GetByte();
|
||||
}
|
||||
|
||||
public DetailedByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount)
|
||||
: this(domain, address)
|
||||
{
|
||||
_previous = prev;
|
||||
ChangeCount = changeCount;
|
||||
_type = type;
|
||||
_bigEndian = bigEndian;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Notes + ": " + ValueString;
|
||||
|
@ -559,19 +584,19 @@ namespace BizHawk.MultiClient
|
|||
public string Diff
|
||||
{
|
||||
get
|
||||
{
|
||||
string diff = String.Empty;
|
||||
int diffVal = _value - _previous;
|
||||
if (diffVal > 0)
|
||||
{
|
||||
diff = "+";
|
||||
}
|
||||
else if (diffVal < 0)
|
||||
{
|
||||
diff = "-";
|
||||
}
|
||||
return diff + FormatValue((byte)(_previous - _value));
|
||||
}
|
||||
{
|
||||
string diff = String.Empty;
|
||||
int diffVal = _value - _previous;
|
||||
if (diffVal > 0)
|
||||
{
|
||||
diff = "+";
|
||||
}
|
||||
else if (diffVal < 0)
|
||||
{
|
||||
diff = "-";
|
||||
}
|
||||
return diff + FormatValue((byte)(_previous - _value));
|
||||
}
|
||||
}
|
||||
|
||||
public string Notes { get; set; }
|
||||
|
@ -759,6 +784,15 @@ namespace BizHawk.MultiClient
|
|||
_value = GetWord();
|
||||
}
|
||||
|
||||
public DetailedWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount)
|
||||
: this(domain, address)
|
||||
{
|
||||
_previous = prev;
|
||||
ChangeCount = changeCount;
|
||||
_type = type;
|
||||
_bigEndian = bigEndian;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Notes + ": " + ValueString;
|
||||
|
@ -960,6 +994,15 @@ namespace BizHawk.MultiClient
|
|||
_value = GetDWord();
|
||||
}
|
||||
|
||||
public DetailedDWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount)
|
||||
: this(domain, address)
|
||||
{
|
||||
_previous = prev;
|
||||
ChangeCount = changeCount;
|
||||
_type = type;
|
||||
_bigEndian = bigEndian;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Notes + ": " + ValueString;
|
||||
|
|
Loading…
Reference in New Issue