Inline ToHexString extension where param numdigits is constant

This commit is contained in:
YoshiRulz 2019-04-04 01:18:32 +10:00 committed by James Groom
parent a6c1e69630
commit 3fa0f71a24
7 changed files with 8 additions and 18 deletions

View File

@ -190,7 +190,7 @@ namespace BizHawk.Client.Common
case DisplayType.Signed:
return ((sbyte)val).ToString();
case DisplayType.Hex:
return val.ToHexString(2);
return $"{val:X2}";
case DisplayType.Binary:
return Convert.ToString(val, 2).PadLeft(8, '0').Insert(4, " ");
}

View File

@ -215,7 +215,7 @@ namespace BizHawk.Client.Common
case DisplayType.Signed:
return ((int)val).ToString();
case DisplayType.Hex:
return val.ToHexString(8);
return $"{val:X8}";
case DisplayType.FixedPoint_20_12:
return $"{(int)val / 4096.0:0.######}";
case DisplayType.FixedPoint_16_16:

View File

@ -202,7 +202,7 @@ namespace BizHawk.Client.Common
case DisplayType.Signed:
return ((short)val).ToString();
case DisplayType.Hex:
return val.ToHexString(4);
return $"{val:X4}";
case DisplayType.FixedPoint_12_4:
return $"{val / 16.0:F4}";
case DisplayType.Binary:

View File

@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
var sb = new StringBuilder();
foreach (var b in _syncSettings.InitialWRamStatePattern)
{
sb.Append(b.ToHexString(2));
sb.Append($"{b:X2}");
}
RamPatternOverrideBox.Text = sb.ToString();

View File

@ -130,8 +130,8 @@ namespace BizHawk.Client.EmuHawk
string FormatVramAddress(int address)
{
int excess = address & 1023;
if (excess != 0) return $"@{address.ToHexString(4)}";
else return $"@{address.ToHexString(4)} ({address / 1024}K)";
if (excess != 0) return $"@{address:X4}";
else return $"@{address:X4} ({address / 1024}K)";
}
public void NewUpdate(ToolFormUpdateType type) { }
@ -786,7 +786,7 @@ namespace BizHawk.Client.EmuHawk
addr *= 2;
addr &= 0xFFFF;
txtMapEntryTileAddr.Text = $"@{addr.ToHexString(4)}";
txtMapEntryTileAddr.Text = $"@{addr:X4}";
}
void UpdateColorDetails()

View File

@ -15,16 +15,6 @@ namespace BizHawk.Common.NumberExtensions
return string.Format($"{{0:X{numdigits}}}", n);
}
public static string ToHexString(this byte n, int numdigits)
{
return string.Format($"{{0:X{numdigits}}}", n);
}
public static string ToHexString(this ushort n, int numdigits)
{
return string.Format($"{{0:X{numdigits}}}", n);
}
public static string ToHexString(this long n, int numdigits)
{
return string.Format($"{{0:X{numdigits}}}", n);

View File

@ -747,7 +747,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
for (ushort i = 0; i < bytes_read; i++)
{
byte_code += ReadMemory((ushort)(RegPC + i)).ToHexString(2);
byte_code += $"{ReadMemory((ushort)(RegPC + i)):X2}";
if (i < (bytes_read - 1))
{
byte_code += " ";