Rename BizHawk.Client.Common.DisplayType to WatchDisplayType

we have aonther type with that identifier, BizHawk.Emulation.Common.DisplayType
This commit is contained in:
YoshiRulz 2021-02-14 14:46:49 +10:00
parent 34cb598fe2
commit ba88712b2b
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
25 changed files with 261 additions and 261 deletions

View File

@ -43,7 +43,7 @@ namespace BizHawk.Client.Common.cheats
domain,
result.Address,
result.Size,
DisplayType.Hex,
WatchDisplayType.Hex,
domain.EndianType == MemoryDomain.Endian.Big,
description);
return result.Compare.HasValue

View File

@ -229,7 +229,7 @@ namespace BizHawk.Client.Common
if (emulator.HasRegions())
{
var region = emulator.AsRegionable().Region;
if (region == Emulation.Common.DisplayType.PAL)
if (region == DisplayType.PAL)
{
movie.HeaderEntries.Add(HeaderKeys.Pal, "1");
}

View File

@ -79,7 +79,7 @@ namespace BizHawk.Client.Common
public char SizeAsChar => _watch.SizeAsChar;
public DisplayType Type => _watch.Type;
public WatchDisplayType Type => _watch.Type;
public char TypeAsChar => _watch.TypeAsChar;
@ -267,7 +267,7 @@ namespace BizHawk.Client.Common
}
}
public void SetType(DisplayType type)
public void SetType(WatchDisplayType type)
{
if (_watch.IsDisplayTypeAvailable(type))
{

View File

@ -284,7 +284,7 @@ namespace BizHawk.Client.Common
// Set to hex for saving
var tempCheatType = cheat.Type;
cheat.SetType(DisplayType.Hex);
cheat.SetType(WatchDisplayType.Hex);
sb
.Append(cheat.AddressStr).Append('\t')
@ -349,7 +349,7 @@ namespace BizHawk.Client.Common
{
int? compare;
var size = WatchSize.Byte;
var type = DisplayType.Hex;
var type = WatchDisplayType.Hex;
var bigEndian = false;
var comparisonType = Cheat.CompareType.None;

View File

@ -205,7 +205,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
}
}
public void SetType(DisplayType type) => _settings.Type = type;
public void SetType(WatchDisplayType type) => _settings.Type = type;
public void SetEndian(bool bigEndian) => _settings.BigEndian = bigEndian;
@ -358,33 +358,33 @@ namespace BizHawk.Client.Common.RamSearchEngine
{
default:
case ComparisonOperator.Equal:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat().HawkFloatEquality(w.Previous.ToFloat()))
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) == SignExtendAsNeeded(w.Previous));
case ComparisonOperator.NotEqual:
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) != SignExtendAsNeeded(w.Previous));
case ComparisonOperator.GreaterThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() > w.Previous.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > SignExtendAsNeeded(w.Previous));
case ComparisonOperator.GreaterThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() >= w.Previous.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= SignExtendAsNeeded(w.Previous));
case ComparisonOperator.LessThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() < w.Previous.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < SignExtendAsNeeded(w.Previous));
case ComparisonOperator.LessThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() <= w.Previous.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= SignExtendAsNeeded(w.Previous));
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
var differentBy = DifferentBy.Value;
if (_settings.Type == DisplayType.Float)
if (_settings.Type == WatchDisplayType.Float)
{
return watchList.Where(w => (GetValue(w.Address).ToFloat() + differentBy).HawkFloatEquality(w.Previous.ToFloat())
|| (GetValue(w.Address).ToFloat() - differentBy).HawkFloatEquality(w.Previous.ToFloat()));
@ -414,28 +414,28 @@ namespace BizHawk.Client.Common.RamSearchEngine
{
default:
case ComparisonOperator.Equal:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat().HawkFloatEquality(compareValue.ToFloat()))
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) == SignExtendAsNeeded(compareValue));
case ComparisonOperator.NotEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => !GetValue(w.Address).ToFloat().HawkFloatEquality(compareValue.ToFloat()))
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) != SignExtendAsNeeded(compareValue));
case ComparisonOperator.GreaterThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() > compareValue.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > SignExtendAsNeeded(compareValue));
case ComparisonOperator.GreaterThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() >= compareValue.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= SignExtendAsNeeded(compareValue));
case ComparisonOperator.LessThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() < compareValue.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < SignExtendAsNeeded(compareValue));
case ComparisonOperator.LessThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() <= compareValue.ToFloat())
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= SignExtendAsNeeded(compareValue));
@ -443,7 +443,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
if (DifferentBy.HasValue)
{
var differentBy = DifferentBy.Value;
if (_settings.Type == DisplayType.Float)
if (_settings.Type == WatchDisplayType.Float)
{
return watchList.Where(w => (GetValue(w.Address).ToFloat() + differentBy).HawkFloatEquality(compareValue)
|| (GetValue(w.Address).ToFloat() - differentBy).HawkFloatEquality(compareValue));
@ -552,34 +552,34 @@ namespace BizHawk.Client.Common.RamSearchEngine
{
default:
case ComparisonOperator.Equal:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => (GetValue(w.Address).ToFloat() - w.Previous.ToFloat()).HawkFloatEquality(compareValue))
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) == compareValue);
case ComparisonOperator.NotEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => !(GetValue(w.Address).ToFloat() - w.Previous.ToFloat()).HawkFloatEquality(compareValue))
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) != compareValue);
case ComparisonOperator.GreaterThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() - w.Previous.ToFloat() > compareValue)
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) > compareValue);
case ComparisonOperator.GreaterThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() - w.Previous.ToFloat() >= compareValue)
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) >= compareValue);
case ComparisonOperator.LessThan:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() - w.Previous.ToFloat() < compareValue)
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) < compareValue);
case ComparisonOperator.LessThanEqual:
return _settings.Type == DisplayType.Float
return _settings.Type == WatchDisplayType.Float
? watchList.Where(w => GetValue(w.Address).ToFloat() - w.Previous.ToFloat() <= compareValue)
: watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) <= compareValue);
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
var differentBy = DifferentBy.Value;
if (_settings.Type == DisplayType.Float)
if (_settings.Type == WatchDisplayType.Float)
{
return watchList.Where(w => (GetValue(w.Address).ToFloat() - w.Previous.ToFloat() + differentBy).HawkFloatEquality(compareValue)
|| (GetValue(w.Address).ToFloat() - w.Previous.ToFloat() - differentBy).HawkFloatEquality(w.Previous));
@ -599,7 +599,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
private long SignExtendAsNeeded(long val)
{
if (_settings.Type != DisplayType.Signed)
if (_settings.Type != WatchDisplayType.Signed)
{
return val;
}

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
{
BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
Size = (WatchSize)memoryDomains.MainMemory.WordSize;
Type = DisplayType.Unsigned;
Type = WatchDisplayType.Unsigned;
Mode = memoryDomains.MainMemory.Size > 1024 * 1024
? SearchMode.Fast
: SearchMode.Detailed;
@ -26,7 +26,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
public bool CheckMisAligned { get; set; }
/*Can be changed mid-search*/
public DisplayType Type { get; set; }
public WatchDisplayType Type { get; set; }
public bool BigEndian { get; set; }
public PreviousType PreviousType { get; set; }
public bool UseUndoHistory { get; set; }

View File

@ -20,14 +20,14 @@ namespace BizHawk.Client.Common
/// </summary>
/// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param>
/// <param name="address">The address you want to track</param>
/// <param name="type">How you you want to display the value See <see cref="DisplayType"/></param>
/// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param>
/// <param name="bigEndian">Specify the endianess. true for big endian</param>
/// <param name="note">A custom note about the <see cref="Watch"/></param>
/// <param name="value">Current value</param>
/// <param name="previous">Previous value</param>
/// <param name="changeCount">How many times value has changed</param>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with <see cref="WatchSize.Byte"/></exception>
internal ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, byte value, byte previous, int changeCount)
/// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with <see cref="WatchSize.Byte"/></exception>
internal ByteWatch(MemoryDomain domain, long address, WatchDisplayType type, bool bigEndian, string note, byte value, byte previous, int changeCount)
: base(domain, address, WatchSize.Byte, type, bigEndian, note)
{
_value = value == 0 ? GetByte() : value;
@ -36,24 +36,24 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Gets an enumeration of <see cref="DisplayType"/> that are valid for a <see cref="ByteWatch"/>
/// Gets an enumeration of <see cref="WatchDisplayType"/> that are valid for a <see cref="ByteWatch"/>
/// </summary>
public static IEnumerable<DisplayType> ValidTypes
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return DisplayType.Unsigned;
yield return DisplayType.Signed;
yield return DisplayType.Hex;
yield return DisplayType.Binary;
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
}
}
/// <summary>
/// Get a list a <see cref="DisplayType"/> that can be used for this <see cref="ByteWatch"/>
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="ByteWatch"/>
/// </summary>
/// <returns>An enumeration that contains all valid <see cref="DisplayType"/></returns>
public override IEnumerable<DisplayType> AvailableTypes()
/// <returns>An enumeration that contains all valid <see cref="WatchDisplayType"/></returns>
public override IEnumerable<WatchDisplayType> AvailableTypes()
{
return ValidTypes;
}
@ -79,7 +79,7 @@ namespace BizHawk.Client.Common
byte val = 0;
switch (Type)
{
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
if (value.IsUnsigned())
{
val = (byte)int.Parse(value);
@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Signed:
case WatchDisplayType.Signed:
if (value.IsSigned())
{
val = (byte)(sbyte)int.Parse(value);
@ -101,7 +101,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
if (value.IsHex())
{
val = (byte)int.Parse(value, NumberStyles.HexNumber);
@ -112,7 +112,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
if (value.IsBinary())
{
val = (byte)Convert.ToInt32(value, 2);
@ -171,10 +171,10 @@ namespace BizHawk.Client.Common
return Type switch
{
_ when !IsValid => "-",
DisplayType.Unsigned => val.ToString(),
DisplayType.Signed => ((sbyte) val).ToString(),
DisplayType.Hex => $"{val:X2}",
DisplayType.Binary => Convert.ToString(val, 2).PadLeft(8, '0').Insert(4, " "),
WatchDisplayType.Unsigned => val.ToString(),
WatchDisplayType.Signed => ((sbyte) val).ToString(),
WatchDisplayType.Hex => $"{val:X2}",
WatchDisplayType.Binary => Convert.ToString(val, 2).PadLeft(8, '0').Insert(4, " "),
_ => val.ToString()
};
}

View File

@ -20,14 +20,14 @@ namespace BizHawk.Client.Common
/// </summary>
/// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param>
/// <param name="address">The address you want to track</param>
/// <param name="type">How you you want to display the value See <see cref="DisplayType"/></param>
/// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param>
/// <param name="bigEndian">Specify the endianess. true for big endian</param>
/// <param name="note">A custom note about the <see cref="Watch"/></param>
/// <param name="value">Current value</param>
/// <param name="previous">Previous value</param>
/// <param name="changeCount">How many times value has changed</param>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with <see cref="WatchSize.DWord"/></exception>
internal DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, uint value, uint previous, int changeCount)
/// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with <see cref="WatchSize.DWord"/></exception>
internal DWordWatch(MemoryDomain domain, long address, WatchDisplayType type, bool bigEndian, string note, uint value, uint previous, int changeCount)
: base(domain, address, WatchSize.DWord, type, bigEndian, note)
{
_value = value == 0 ? GetDWord() : value;
@ -36,27 +36,27 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Gets a list of <see cref="DisplayType"/> for a <see cref="DWordWatch"/>
/// Gets a list of <see cref="WatchDisplayType"/> for a <see cref="DWordWatch"/>
/// </summary>
public static IEnumerable<DisplayType> ValidTypes
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return DisplayType.Unsigned;
yield return DisplayType.Signed;
yield return DisplayType.Hex;
yield return DisplayType.Binary;
yield return DisplayType.FixedPoint_20_12;
yield return DisplayType.FixedPoint_16_16;
yield return DisplayType.Float;
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
yield return WatchDisplayType.FixedPoint_20_12;
yield return WatchDisplayType.FixedPoint_16_16;
yield return WatchDisplayType.Float;
}
}
/// <summary>
/// Get a list of <see cref="DisplayType"/> that can be used for a <see cref="DWordWatch"/>
/// Get a list of <see cref="WatchDisplayType"/> that can be used for a <see cref="DWordWatch"/>
/// </summary>
/// <returns>An enumeration that contains all valid <see cref="DisplayType"/></returns>
public override IEnumerable<DisplayType> AvailableTypes()
/// <returns>An enumeration that contains all valid <see cref="WatchDisplayType"/></returns>
public override IEnumerable<WatchDisplayType> AvailableTypes()
{
return ValidTypes;
}
@ -82,7 +82,7 @@ namespace BizHawk.Client.Common
uint val = 0;
switch (Type)
{
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
if (value.IsUnsigned())
{
val = (uint)int.Parse(value);
@ -93,7 +93,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Signed:
case WatchDisplayType.Signed:
if (value.IsSigned())
{
val = (uint)int.Parse(value);
@ -104,7 +104,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
if (value.IsHex())
{
val = (uint)int.Parse(value, NumberStyles.HexNumber);
@ -115,7 +115,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_20_12:
if (value.IsFixedPoint())
{
val = (uint)(int)(double.Parse(value) * 4096.0);
@ -126,7 +126,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_16_16:
if (value.IsFixedPoint())
{
val = (uint)(int)(double.Parse(value) * 65536.0);
@ -137,7 +137,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Float:
case WatchDisplayType.Float:
if (value.IsFloat())
{
var bytes = BitConverter.GetBytes(float.Parse(value));
@ -214,13 +214,13 @@ namespace BizHawk.Client.Common
return Type switch
{
_ when !IsValid => "-",
DisplayType.Unsigned => val.ToString(),
DisplayType.Signed => ((int)val).ToString(),
DisplayType.Hex => $"{val:X8}",
DisplayType.FixedPoint_20_12 => $"{(int)val / 4096.0:0.######}",
DisplayType.FixedPoint_16_16 => $"{(int)val / 65536.0:0.######}",
DisplayType.Float => FormatFloat(),
DisplayType.Binary => FormatBinary(),
WatchDisplayType.Unsigned => val.ToString(),
WatchDisplayType.Signed => ((int)val).ToString(),
WatchDisplayType.Hex => $"{val:X8}",
WatchDisplayType.FixedPoint_20_12 => $"{(int)val / 4096.0:0.######}",
WatchDisplayType.FixedPoint_16_16 => $"{(int)val / 65536.0:0.######}",
WatchDisplayType.Float => FormatFloat(),
WatchDisplayType.Binary => FormatBinary(),
_ => val.ToString()
};
}

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.Common
/// Initializes a new instance of the <see cref="SeparatorWatch"/> class.
/// </summary>
internal SeparatorWatch()
: base(null, 0, WatchSize.Separator, DisplayType.Separator, true, "")
: base(null, 0, WatchSize.Separator, WatchDisplayType.Separator, true, "")
{
}
@ -30,12 +30,12 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Get the appropriate DisplayType
/// Get the appropriate WatchDisplayType
/// </summary>
/// <returns>DisplayType.Separator nothing else</returns>
public override IEnumerable<DisplayType> AvailableTypes()
/// <returns>WatchDisplayType.Separator nothing else</returns>
public override IEnumerable<WatchDisplayType> AvailableTypes()
{
yield return DisplayType.Separator;
yield return WatchDisplayType.Separator;
}
/// <summary>

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
IComparable<Watch>
{
private MemoryDomain _domain;
private DisplayType _type;
private WatchDisplayType _type;
/// <summary>
/// Initializes a new instance of the <see cref="Watch"/> class
@ -29,11 +29,11 @@ namespace BizHawk.Client.Common
/// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param>
/// <param name="address">The address you want to track</param>
/// <param name="size">A <see cref="WatchSize"/> (byte, word, double word)</param>
/// <param name="type">How you you want to display the value See <see cref="DisplayType"/></param>
/// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param>
/// <param name="bigEndian">Specify the endianess. true for big endian</param>
/// <param name="note">A custom note about the <see cref="Watch"/></param>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with the <see cref="WatchSize"/></exception>
protected Watch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note)
/// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with the <see cref="WatchSize"/></exception>
protected Watch(MemoryDomain domain, long address, WatchSize size, WatchDisplayType type, bool bigEndian, string note)
{
if (IsDisplayTypeAvailable(type))
{
@ -46,7 +46,7 @@ namespace BizHawk.Client.Common
}
else
{
throw new ArgumentException($"{nameof(DisplayType)} {type} is invalid for this type of {nameof(Watch)}", nameof(type));
throw new ArgumentException($"{nameof(WatchDisplayType)} {type} is invalid for this type of {nameof(Watch)}", nameof(type));
}
}
@ -64,7 +64,7 @@ namespace BizHawk.Client.Common
/// <term>b,w or d</term>
/// <description>The <see cref="WatchSize"/>, byte, word or double word</description>
/// <term>s, u, h, b, 1, 2, 3, f</term>
/// <description>The <see cref="DisplayType"/> signed, unsigned,etc...</description>
/// <description>The <see cref="WatchDisplayType"/> signed, unsigned,etc...</description>
/// </item>
/// <item>
/// <term>0 or 1</term>
@ -99,7 +99,7 @@ namespace BizHawk.Client.Common
if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var address))
{
WatchSize size = SizeFromChar(parts[1][0]);
DisplayType type = DisplayTypeFromChar(parts[2][0]);
WatchDisplayType type = DisplayTypeFromChar(parts[2][0]);
bool bigEndian = parts[3] != "0";
MemoryDomain domain = domains[parts[4]];
string notes = parts[5].Trim('\r', '\n');
@ -130,7 +130,7 @@ namespace BizHawk.Client.Common
/// <param name="prev">Previous value</param>
/// <param name="changeCount">Number of changes occurs in current <see cref="Watch"/></param>
/// <returns>New <see cref="Watch"/> instance. True type is depending of size parameter</returns>
public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note = "", long value = 0, long prev = 0, int changeCount = 0)
public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, WatchDisplayType type, bool bigEndian, string note = "", long value = 0, long prev = 0, int changeCount = 0)
{
return size switch
{
@ -250,10 +250,10 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Gets a list a <see cref="DisplayType"/> that can be used for this <see cref="Watch"/>
/// Gets a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="Watch"/>
/// </summary>
/// <returns>An enumeration that contains all valid <see cref="DisplayType"/></returns>
public abstract IEnumerable<DisplayType> AvailableTypes();
/// <returns>An enumeration that contains all valid <see cref="WatchDisplayType"/></returns>
public abstract IEnumerable<WatchDisplayType> AvailableTypes();
/// <summary>
/// Resets the previous value; set it to the current one
@ -405,11 +405,11 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Determines if the specified <see cref="DisplayType"/> can be
/// Determines if the specified <see cref="WatchDisplayType"/> can be
/// used for the current <see cref="Watch"/>
/// </summary>
/// <param name="type"><see cref="DisplayType"/> you want to check</param>
public bool IsDisplayTypeAvailable(DisplayType type)
/// <param name="type"><see cref="WatchDisplayType"/> you want to check</param>
public bool IsDisplayTypeAvailable(WatchDisplayType type)
{
return AvailableTypes().Any(d => d == type);
}
@ -502,8 +502,8 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets or sets the way current <see cref="Watch"/> is displayed
/// </summary>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with the <see cref="WatchSize"/></exception>
public DisplayType Type
/// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with the <see cref="WatchSize"/></exception>
public WatchDisplayType Type
{
get => _type;
set
@ -514,7 +514,7 @@ namespace BizHawk.Client.Common
}
else
{
throw new ArgumentException($"DisplayType {value} is invalid for this type of Watch");
throw new ArgumentException($"WatchDisplayType {value} is invalid for this type of Watch");
}
}
}
@ -553,25 +553,25 @@ namespace BizHawk.Client.Common
public WatchSize Size { get; }
// TODO: Replace all the following stuff by implementing ISerializable
public static string DisplayTypeToString(DisplayType type)
public static string DisplayTypeToString(WatchDisplayType type)
{
return type switch
{
DisplayType.FixedPoint_12_4 => "Fixed Point 12.4",
DisplayType.FixedPoint_20_12 => "Fixed Point 20.12",
DisplayType.FixedPoint_16_16 => "Fixed Point 16.16",
WatchDisplayType.FixedPoint_12_4 => "Fixed Point 12.4",
WatchDisplayType.FixedPoint_20_12 => "Fixed Point 20.12",
WatchDisplayType.FixedPoint_16_16 => "Fixed Point 16.16",
_ => type.ToString()
};
}
public static DisplayType StringToDisplayType(string name)
public static WatchDisplayType StringToDisplayType(string name)
{
return name switch
{
"Fixed Point 12.4" => DisplayType.FixedPoint_12_4,
"Fixed Point 20.12" => DisplayType.FixedPoint_20_12,
"Fixed Point 16.16" => DisplayType.FixedPoint_16_16,
_ => (DisplayType) Enum.Parse(typeof(DisplayType), name)
"Fixed Point 12.4" => WatchDisplayType.FixedPoint_12_4,
"Fixed Point 20.12" => WatchDisplayType.FixedPoint_20_12,
"Fixed Point 16.16" => WatchDisplayType.FixedPoint_16_16,
_ => (WatchDisplayType) Enum.Parse(typeof(WatchDisplayType), name)
};
}
@ -608,34 +608,34 @@ namespace BizHawk.Client.Common
{
return Type switch
{
DisplayType.Separator => '_',
DisplayType.Unsigned => 'u',
DisplayType.Signed => 's',
DisplayType.Hex => 'h',
DisplayType.Binary => 'b',
DisplayType.FixedPoint_12_4 => '1',
DisplayType.FixedPoint_20_12 => '2',
DisplayType.FixedPoint_16_16 => '3',
DisplayType.Float => 'f',
WatchDisplayType.Separator => '_',
WatchDisplayType.Unsigned => 'u',
WatchDisplayType.Signed => 's',
WatchDisplayType.Hex => 'h',
WatchDisplayType.Binary => 'b',
WatchDisplayType.FixedPoint_12_4 => '1',
WatchDisplayType.FixedPoint_20_12 => '2',
WatchDisplayType.FixedPoint_16_16 => '3',
WatchDisplayType.Float => 'f',
_ => '_'
};
}
}
public static DisplayType DisplayTypeFromChar(char c)
public static WatchDisplayType DisplayTypeFromChar(char c)
{
return c switch
{
'_' => DisplayType.Separator,
'u' => DisplayType.Unsigned,
's' => DisplayType.Signed,
'h' => DisplayType.Hex,
'b' => DisplayType.Binary,
'1' => DisplayType.FixedPoint_12_4,
'2' => DisplayType.FixedPoint_20_12,
'3' => DisplayType.FixedPoint_16_16,
'f' => DisplayType.Float,
_ => DisplayType.Separator
'_' => WatchDisplayType.Separator,
'u' => WatchDisplayType.Unsigned,
's' => WatchDisplayType.Signed,
'h' => WatchDisplayType.Hex,
'b' => WatchDisplayType.Binary,
'1' => WatchDisplayType.FixedPoint_12_4,
'2' => WatchDisplayType.FixedPoint_20_12,
'3' => WatchDisplayType.FixedPoint_16_16,
'f' => WatchDisplayType.Float,
_ => WatchDisplayType.Separator
};
}
}

View File

@ -3,7 +3,7 @@
/// <summary>
/// This enum is used to specify how you want your <see cref="Watch"/> to be displayed
/// </summary>
public enum DisplayType
public enum WatchDisplayType
{
/// <summary>
/// Separator, only used by <see cref="SeparatorWatch"/>

View File

@ -29,7 +29,7 @@ namespace BizHawk.Client.Common
int xValue;
int yValue;
if (x.Type == DisplayType.Signed)
if (x.Type == WatchDisplayType.Signed)
{
int.TryParse(x.ValueString, out xValue);
}
@ -38,7 +38,7 @@ namespace BizHawk.Client.Common
xValue = x.Value;
}
if (y.Type == DisplayType.Signed)
if (y.Type == WatchDisplayType.Signed)
{
int.TryParse(y.ValueString, out yValue);
}

View File

@ -20,14 +20,14 @@ namespace BizHawk.Client.Common
/// </summary>
/// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param>
/// <param name="address">The address you want to track</param>
/// <param name="type">How you you want to display the value See <see cref="DisplayType"/></param>
/// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param>
/// <param name="bigEndian">Specify the endianess. true for big endian</param>
/// <param name="note">A custom note about the <see cref="Watch"/></param>
/// <param name="value">Current value</param>
/// <param name="previous">Previous value</param>
/// <param name="changeCount">How many times value has changed</param>
/// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with <see cref="WatchSize.Word"/></exception>
internal WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, ushort value, ushort previous, int changeCount)
/// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with <see cref="WatchSize.Word"/></exception>
internal WordWatch(MemoryDomain domain, long address, WatchDisplayType type, bool bigEndian, string note, ushort value, ushort previous, int changeCount)
: base(domain, address, WatchSize.Word, type, bigEndian, note)
{
_value = value == 0 ? GetWord() : value;
@ -36,25 +36,25 @@ namespace BizHawk.Client.Common
}
/// <summary>
/// Gets an Enumeration of <see cref="DisplayType"/>s that are valid for a <see cref="WordWatch"/>
/// Gets an Enumeration of <see cref="WatchDisplayType"/>s that are valid for a <see cref="WordWatch"/>
/// </summary>
public static IEnumerable<DisplayType> ValidTypes
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return DisplayType.Unsigned;
yield return DisplayType.Signed;
yield return DisplayType.Hex;
yield return DisplayType.Binary;
yield return DisplayType.FixedPoint_12_4;
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
yield return WatchDisplayType.FixedPoint_12_4;
}
}
/// <summary>
/// Get a list a <see cref="DisplayType"/> that can be used for this <see cref="WordWatch"/>
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="WordWatch"/>
/// </summary>
/// <returns>An enumeration that contains all valid <see cref="DisplayType"/></returns>
public override IEnumerable<DisplayType> AvailableTypes() => ValidTypes;
/// <returns>An enumeration that contains all valid <see cref="WatchDisplayType"/></returns>
public override IEnumerable<WatchDisplayType> AvailableTypes() => ValidTypes;
/// <summary>
/// Reset the previous value; set it to the current one
@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
ushort val = 0;
switch (Type)
{
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
if (value.IsUnsigned())
{
val = (ushort)int.Parse(value);
@ -88,7 +88,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Signed:
case WatchDisplayType.Signed:
if (value.IsSigned())
{
val = (ushort)(short)int.Parse(value);
@ -99,7 +99,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
if (value.IsHex())
{
val = (ushort)int.Parse(value, NumberStyles.HexNumber);
@ -110,7 +110,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
if (value.IsBinary())
{
val = (ushort)Convert.ToInt32(value, 2);
@ -121,7 +121,7 @@ namespace BizHawk.Client.Common
}
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
if (value.IsFixedPoint())
{
val = (ushort)(double.Parse(value) * 16.0);
@ -181,10 +181,10 @@ namespace BizHawk.Client.Common
return Type switch
{
_ when !IsValid => "-",
DisplayType.Unsigned => val.ToString(),
DisplayType.Signed => ((short) val).ToString(), DisplayType.Hex => $"{val:X4}",
DisplayType.FixedPoint_12_4 => $"{val / 16.0:F4}",
DisplayType.Binary => Convert
WatchDisplayType.Unsigned => val.ToString(),
WatchDisplayType.Signed => ((short) val).ToString(), WatchDisplayType.Hex => $"{val:X4}",
WatchDisplayType.FixedPoint_12_4 => $"{val / 16.0:F4}",
WatchDisplayType.Binary => Convert
.ToString(val, 2)
.PadLeft(16, '0')
.Insert(8, " ")

View File

@ -308,7 +308,7 @@
this.StopOnFrameTextBox.Nullable = true;
this.StopOnFrameTextBox.Size = new System.Drawing.Size(54, 20);
this.StopOnFrameTextBox.TabIndex = 58;
this.StopOnFrameTextBox.Type = BizHawk.Client.Common.DisplayType.Unsigned;
this.StopOnFrameTextBox.Type = BizHawk.Client.Common.WatchDisplayType.Unsigned;
this.StopOnFrameTextBox.TextChanged += new System.EventHandler(this.StopOnFrameTextBox_TextChanged_1);
//
// MovieCount

View File

@ -211,7 +211,7 @@
this.CompareBox.Nullable = true;
this.CompareBox.Size = new System.Drawing.Size(65, 31);
this.CompareBox.TabIndex = 15;
this.CompareBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.CompareBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged);
//
// ValueBox
@ -225,7 +225,7 @@
this.ValueBox.Size = new System.Drawing.Size(65, 31);
this.ValueBox.TabIndex = 12;
this.ValueBox.Text = "00";
this.ValueBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.ValueBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
//
// CompareTypeDropDown
//

View File

@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
ValueHexIndLabel.Text =
CompareHexIndLabel.Text =
_cheat.Type == DisplayType.Hex ? HexInd : "";
_cheat.Type == WatchDisplayType.Hex ? HexInd : "";
BigEndianCheckBox.Checked = _cheat.BigEndian ?? false;
@ -119,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
ValueBox.Type =
CompareBox.Type =
DisplayType.Hex;
WatchDisplayType.Hex;
ValueBox.ResetText();
CompareBox.ResetText();
@ -130,7 +130,7 @@ namespace BizHawk.Client.EmuHawk
BigEndianCheckBox.Checked = false;
SetTypeSelected(DisplayType.Hex);
SetTypeSelected(WatchDisplayType.Hex);
CheckFormState();
CompareBox.Text = ""; // TODO: A needed hack until WatchValueBox.ToRawInt() becomes nullable
@ -154,7 +154,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SetTypeSelected(DisplayType type)
private void SetTypeSelected(WatchDisplayType type)
{
foreach (var item in DisplayTypeDropDown.Items)
{
@ -185,21 +185,21 @@ namespace BizHawk.Client.EmuHawk
{
default:
case 0:
foreach (DisplayType t in ByteWatch.ValidTypes)
foreach (WatchDisplayType t in ByteWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}
break;
case 1:
foreach (DisplayType t in WordWatch.ValidTypes)
foreach (WatchDisplayType t in WordWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}
break;
case 2:
foreach (DisplayType t in DWordWatch.ValidTypes)
foreach (WatchDisplayType t in DWordWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}

View File

@ -788,11 +788,11 @@ namespace BizHawk.Client.EmuHawk
{
default:
case 1:
return Watch.GenerateWatch(_domain, address, WatchSize.Byte, Common.DisplayType.Hex, BigEndian);
return Watch.GenerateWatch(_domain, address, WatchSize.Byte, Common.WatchDisplayType.Hex, BigEndian);
case 2:
return Watch.GenerateWatch(_domain, address, WatchSize.Word, Common.DisplayType.Hex, BigEndian);
return Watch.GenerateWatch(_domain, address, WatchSize.Word, Common.WatchDisplayType.Hex, BigEndian);
case 4:
return Watch.GenerateWatch(_domain, address, WatchSize.DWord, Common.DisplayType.Hex, BigEndian);
return Watch.GenerateWatch(_domain, address, WatchSize.DWord, Common.WatchDisplayType.Hex, BigEndian);
}
}
@ -814,7 +814,7 @@ namespace BizHawk.Client.EmuHawk
_domain,
_highlightedAddress.Value,
WatchSize,
Common.DisplayType.Hex,
Common.WatchDisplayType.Hex,
BigEndian);
MainForm.CheatList.Add(new Cheat(
@ -831,7 +831,7 @@ namespace BizHawk.Client.EmuHawk
_domain,
address,
WatchSize,
Common.DisplayType.Hex,
Common.WatchDisplayType.Hex,
BigEndian);
cheats.Add(new Cheat(
@ -1670,7 +1670,7 @@ namespace BizHawk.Client.EmuHawk
_domain,
address,
(WatchSize)DataSize,
Common.DisplayType.Hex,
Common.WatchDisplayType.Hex,
BigEndian));
using var poke = new RamPoke(watches, MainForm.CheatList)

View File

@ -74,7 +74,7 @@
this.NumFramesBox.Size = new System.Drawing.Size(51, 20);
this.NumFramesBox.TabIndex = 3;
this.NumFramesBox.Text = "1";
this.NumFramesBox.Type = BizHawk.Client.Common.DisplayType.Unsigned;
this.NumFramesBox.Type = BizHawk.Client.Common.WatchDisplayType.Unsigned;
//
// FramesPrompt
//

View File

@ -98,7 +98,7 @@ namespace BizHawk.Client.EmuHawk
this.ValueBox.Size = new System.Drawing.Size(116, 20);
this.ValueBox.TabIndex = 10;
this.ValueBox.Text = "00";
this.ValueBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.ValueBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
//
// ValueHexLabel
//

View File

@ -67,7 +67,7 @@ namespace BizHawk.Client.EmuHawk
ValueBox.ByteSize = _watchList[0].Size;
ValueBox.Type = _watchList[0].Type;
ValueHexLabel.Text = _watchList[0].Type == DisplayType.Hex ? "0x" : "";
ValueHexLabel.Text = _watchList[0].Type == WatchDisplayType.Hex ? "0x" : "";
ValueBox.Text = _watchList[0].ValueString.Replace(" ", "");
DomainLabel.Text = _watchList[0].Domain.Name;
SizeLabel.Text = _watchList[0].Size.ToString();

View File

@ -603,7 +603,7 @@ namespace BizHawk.Client.EmuHawk
this.DifferenceBox.Nullable = false;
this.DifferenceBox.Size = new System.Drawing.Size(72, 20);
this.DifferenceBox.TabIndex = 45;
this.DifferenceBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.DifferenceBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
this.DifferenceBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged);
//
// DifferenceRadio
@ -659,7 +659,7 @@ namespace BizHawk.Client.EmuHawk
this.SpecificValueBox.Size = new System.Drawing.Size(72, 20);
this.SpecificValueBox.TabIndex = 15;
this.SpecificValueBox.Text = "00";
this.SpecificValueBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.SpecificValueBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
this.SpecificValueBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged);
//
// NumberOfChangesRadio
@ -878,7 +878,7 @@ namespace BizHawk.Client.EmuHawk
this.DifferentByBox.Nullable = false;
this.DifferentByBox.Size = new System.Drawing.Size(55, 20);
this.DifferentByBox.TabIndex = 85;
this.DifferentByBox.Type = BizHawk.Client.Common.DisplayType.Hex;
this.DifferentByBox.Type = BizHawk.Client.Common.WatchDisplayType.Hex;
this.DifferentByBox.TextChanged += new System.EventHandler(this.DifferentByBox_TextChanged);
//
// DifferentByRadio

View File

@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist]
public RamSearchSettings Settings { get; set; }
private void HardSetDisplayTypeDropDown(Common.DisplayType type)
private void HardSetDisplayTypeDropDown(Common.WatchDisplayType type)
{
foreach (var item in DisplayTypeDropdown.Items)
{
@ -152,8 +152,8 @@ namespace BizHawk.Client.EmuHawk
LoadConfigSettings();
SpecificValueBox.ByteSize = _settings.Size;
SpecificValueBox.Type = _settings.Type;
DifferentByBox.Type = Common.DisplayType.Unsigned;
DifferenceBox.Type = Common.DisplayType.Unsigned;
DifferentByBox.Type = Common.WatchDisplayType.Unsigned;
DifferenceBox.Type = Common.WatchDisplayType.Unsigned;
MessageLabel.Text = "";
SpecificAddressBox.MaxLength = (MemoryDomains.MainMemory.Size - 1).NumHexDigits();
@ -594,7 +594,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private void DoDisplayTypeClick(Common.DisplayType type)
private void DoDisplayTypeClick(Common.WatchDisplayType type)
{
if (_settings.Type != type)
{
@ -666,7 +666,7 @@ namespace BizHawk.Client.EmuHawk
if (!isTypeCompatible)
{
_settings.Type = Common.DisplayType.Unsigned;
_settings.Type = Common.WatchDisplayType.Unsigned;
}
_dropdownDontfire = true;
@ -689,7 +689,7 @@ namespace BizHawk.Client.EmuHawk
WatchSize.Byte => ByteWatch.ValidTypes,
WatchSize.Word => WordWatch.ValidTypes,
WatchSize.DWord => DWordWatch.ValidTypes,
_ => new List<Common.DisplayType>()
_ => new List<Common.WatchDisplayType>()
};
foreach (var type in types)
@ -1066,7 +1066,7 @@ namespace BizHawk.Client.EmuHawk
WatchSize.Byte => ByteWatch.ValidTypes,
WatchSize.Word => WordWatch.ValidTypes,
WatchSize.DWord => DWordWatch.ValidTypes,
_ => new List<Common.DisplayType>()
_ => new List<Common.WatchDisplayType>()
};
foreach (var type in types)

View File

@ -446,28 +446,28 @@ namespace BizHawk.Client.EmuHawk
string s = w.Size == WatchSize.Byte ? "1" : (w.Size == WatchSize.Word ? "2" : "4");
switch (w.Type)
{
case Common.DisplayType.Binary:
case Common.WatchDisplayType.Binary:
s += "b";
break;
case Common.DisplayType.FixedPoint_12_4:
case Common.WatchDisplayType.FixedPoint_12_4:
s += "F";
break;
case Common.DisplayType.FixedPoint_16_16:
case Common.WatchDisplayType.FixedPoint_16_16:
s += "F6";
break;
case Common.DisplayType.FixedPoint_20_12:
case Common.WatchDisplayType.FixedPoint_20_12:
s += "F2";
break;
case Common.DisplayType.Float:
case Common.WatchDisplayType.Float:
s += "f";
break;
case Common.DisplayType.Hex:
case Common.WatchDisplayType.Hex:
s += "h";
break;
case Common.DisplayType.Signed:
case Common.WatchDisplayType.Signed:
s += "s";
break;
case Common.DisplayType.Unsigned:
case Common.WatchDisplayType.Unsigned:
s += "u";
break;
}

View File

@ -143,19 +143,19 @@ namespace BizHawk.Client.EmuHawk
{
default:
case 0:
foreach (DisplayType t in ByteWatch.ValidTypes)
foreach (WatchDisplayType t in ByteWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}
break;
case 1:
foreach (DisplayType t in WordWatch.ValidTypes)
foreach (WatchDisplayType t in WordWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}
break;
case 2:
foreach (DisplayType t in DWordWatch.ValidTypes)
foreach (WatchDisplayType t in DWordWatch.ValidTypes)
{
DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t));
}

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
public class WatchValueBox : TextBox, INumberBox
{
private WatchSize _size = WatchSize.Byte;
private DisplayType _type = DisplayType.Hex;
private WatchDisplayType _type = WatchDisplayType.Hex;
public WatchValueBox()
{
@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
if (!isTypeCompatible)
{
_type = DisplayType.Unsigned;
_type = WatchDisplayType.Unsigned;
}
ResetText();
@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
}
}
public DisplayType Type
public WatchDisplayType Type
{
get => _type;
set
@ -110,20 +110,20 @@ namespace BizHawk.Client.EmuHawk
switch (Type)
{
default:
case DisplayType.Signed:
case DisplayType.Unsigned:
case WatchDisplayType.Signed:
case WatchDisplayType.Unsigned:
Text = "0";
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
Text = 0.ToHexString(MaxLength);
break;
case DisplayType.FixedPoint_12_4:
case DisplayType.FixedPoint_20_12:
case DisplayType.FixedPoint_16_16:
case DisplayType.Float:
case WatchDisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_16_16:
case WatchDisplayType.Float:
Text = "0.0";
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
Text = "0".PadLeft(((int)_size) * 8);
break;
}
@ -137,7 +137,7 @@ namespace BizHawk.Client.EmuHawk
default:
MaxLength = 8;
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
MaxLength = _size switch
{
WatchSize.Byte => 8,
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
_ => 8
};
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
MaxLength = _size switch
{
WatchSize.Byte => 2,
@ -154,7 +154,7 @@ namespace BizHawk.Client.EmuHawk
_ => 2
};
break;
case DisplayType.Signed:
case WatchDisplayType.Signed:
MaxLength = _size switch
{
WatchSize.Byte => 4,
@ -163,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
_ => 4
};
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
MaxLength = _size switch
{
WatchSize.Byte => 3,
@ -172,14 +172,14 @@ namespace BizHawk.Client.EmuHawk
_ => 3
};
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
MaxLength = 9;
break;
case DisplayType.Float:
case WatchDisplayType.Float:
MaxLength = 21;
break;
case DisplayType.FixedPoint_20_12:
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_16_16:
MaxLength = 64;
break;
}
@ -212,44 +212,44 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
default:
case DisplayType.Binary:
case WatchDisplayType.Binary:
if (!e.KeyChar.IsBinary())
{
e.Handled = true;
}
break;
case DisplayType.FixedPoint_12_4:
case DisplayType.FixedPoint_20_12:
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_16_16:
if (!e.KeyChar.IsFixedPoint())
{
e.Handled = true;
}
break;
case DisplayType.Float:
case WatchDisplayType.Float:
if (!e.KeyChar.IsFloat())
{
e.Handled = true;
}
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
if (!e.KeyChar.IsHex())
{
e.Handled = true;
}
break;
case DisplayType.Signed:
case WatchDisplayType.Signed:
if (!e.KeyChar.IsSigned())
{
e.Handled = true;
}
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
if (!e.KeyChar.IsUnsigned())
{
e.Handled = true;
@ -267,7 +267,7 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
default:
case DisplayType.Signed:
case WatchDisplayType.Signed:
int? val = ToRawInt() ?? 0;
if (val == MaxSignedInt)
{
@ -280,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
Text = val.ToString();
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
var uval = (uint)(ToRawInt() ?? 0);
if (uval == MaxUnsignedInt)
{
@ -293,7 +293,7 @@ namespace BizHawk.Client.EmuHawk
Text = uval.ToString();
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
var bVal = (uint)(ToRawInt() ?? 0);
if (bVal == MaxUnsignedInt)
{
@ -307,7 +307,7 @@ namespace BizHawk.Client.EmuHawk
var numBits = ((int)ByteSize) * 8;
Text = Convert.ToString(bVal, 2).PadLeft(numBits, '0');
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
var hexVal = (uint)(ToRawInt() ?? 0);
if (hexVal == MaxUnsignedInt)
{
@ -320,7 +320,7 @@ namespace BizHawk.Client.EmuHawk
Text = hexVal.ToHexString(MaxLength);
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
var f12val = double.Parse(text);
if (f12val > Max12_4 - _12_4_Unit)
{
@ -333,7 +333,7 @@ namespace BizHawk.Client.EmuHawk
Text = f12val.ToString();
break;
case DisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_20_12:
var f24val = double.Parse(text);
if (f24val >= Max20_12 - _20_12_Unit)
{
@ -346,7 +346,7 @@ namespace BizHawk.Client.EmuHawk
Text = f24val.ToString();
break;
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_16_16:
var f16val = double.Parse(text);
if (f16val >= Max16_16 - _16_16_Unit)
{
@ -359,7 +359,7 @@ namespace BizHawk.Client.EmuHawk
Text = f16val.ToString();
break;
case DisplayType.Float:
case WatchDisplayType.Float:
var dVal = double.Parse(text);
if (dVal > double.MaxValue - 1)
{
@ -379,7 +379,7 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
default:
case DisplayType.Signed:
case WatchDisplayType.Signed:
var val = ToRawInt();
if (!val.HasValue)
{
@ -396,7 +396,7 @@ namespace BizHawk.Client.EmuHawk
Text = val.ToString();
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
var uval = (uint)(ToRawInt() ?? 0);
if (uval == 0)
{
@ -409,7 +409,7 @@ namespace BizHawk.Client.EmuHawk
Text = uval.ToString();
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
var bVal = (uint)(ToRawInt() ?? 0);
if (bVal == 0)
{
@ -423,7 +423,7 @@ namespace BizHawk.Client.EmuHawk
var numBits = ((int)ByteSize) * 8;
Text = Convert.ToString(bVal, 2).PadLeft(numBits, '0');
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
var hexVal = (uint)(ToRawInt() ?? 0);
if (hexVal == 0)
{
@ -436,7 +436,7 @@ namespace BizHawk.Client.EmuHawk
Text = hexVal.ToHexString(MaxLength);
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
var f12val = double.Parse(text);
if (f12val < 0 + _12_4_Unit)
{
@ -449,7 +449,7 @@ namespace BizHawk.Client.EmuHawk
Text = f12val.ToString();
break;
case DisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_20_12:
var f24val = double.Parse(text);
if (f24val < 0 + _20_12_Unit)
{
@ -462,7 +462,7 @@ namespace BizHawk.Client.EmuHawk
Text = f24val.ToString();
break;
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_16_16:
var f16val = double.Parse(text);
if (f16val < 0 + _16_16_Unit)
{
@ -475,7 +475,7 @@ namespace BizHawk.Client.EmuHawk
Text = f16val.ToString();
break;
case DisplayType.Float:
case WatchDisplayType.Float:
var dval = double.Parse(text);
if (dval > double.MaxValue - 1)
{
@ -507,24 +507,24 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
case DisplayType.Signed:
case WatchDisplayType.Signed:
Text = Text.OnlySigned();
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
Text = Text.OnlyUnsigned();
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
Text = Text.OnlyBinary();
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
Text = Text.OnlyHex();
break;
case DisplayType.FixedPoint_12_4:
case DisplayType.FixedPoint_20_12:
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_16_16:
Text = Text.OnlyFixedPoint();
break;
case DisplayType.Float:
case WatchDisplayType.Float:
Text = Text.OnlyFloat();
break;
}
@ -546,56 +546,56 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
case DisplayType.Signed:
case WatchDisplayType.Signed:
if (Text.IsSigned())
{
return Text == "-" ? 0 : int.Parse(Text);
}
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
if (Text.IsUnsigned())
{
return (int)uint.Parse(Text);
}
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
if (Text.IsBinary())
{
return Convert.ToInt32(Text, 2);
}
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
if (Text.IsHex())
{
return int.Parse(Text, NumberStyles.HexNumber);
}
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
if (Text.IsFixedPoint())
{
return (int)(double.Parse(Text) * 16.0);
}
break;
case DisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_20_12:
if (Text.IsFixedPoint())
{
return (int)(double.Parse(Text) * 4096.0);
}
break;
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_16_16:
if (Text.IsFixedPoint())
{
return (int)(double.Parse(Text) * 65536.0);
}
break;
case DisplayType.Float:
case WatchDisplayType.Float:
if (Text.IsFloat())
{
if (Text == "-" || Text == ".")
@ -621,31 +621,31 @@ namespace BizHawk.Client.EmuHawk
switch (_type)
{
default:
case DisplayType.Signed:
case WatchDisplayType.Signed:
Text = val.ToString();
break;
case DisplayType.Unsigned:
case WatchDisplayType.Unsigned:
var uval = (uint)val.Value;
Text = uval.ToString();
break;
case DisplayType.Binary:
case WatchDisplayType.Binary:
var bVal = (uint)val.Value;
var numBits = ((int)ByteSize) * 8;
Text = Convert.ToString(bVal, 2).PadLeft(numBits, '0');
break;
case DisplayType.Hex:
case WatchDisplayType.Hex:
Text = val.Value.ToHexString(MaxLength);
break;
case DisplayType.FixedPoint_12_4:
case WatchDisplayType.FixedPoint_12_4:
Text = $"{val.Value / 16.0:F5}";
break;
case DisplayType.FixedPoint_20_12:
case WatchDisplayType.FixedPoint_20_12:
Text = $"{val.Value / 4096.0:F5}";
break;
case DisplayType.FixedPoint_16_16:
case WatchDisplayType.FixedPoint_16_16:
Text = $"{val.Value / 65536.0:F5}";
break;
case DisplayType.Float:
case WatchDisplayType.Float:
var bytes = BitConverter.GetBytes(val.Value);
float _float = BitConverter.ToSingle(bytes, 0);
Text = $"{_float:F6}";