Merge pull request #1504 from TASVideos/semicolonFormat

[Untested] Use format strings with the semicolon section separator
This commit is contained in:
adelikat 2019-03-27 19:38:16 -05:00 committed by GitHub
commit 165880b444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 54 deletions

View File

@ -200,24 +200,7 @@ namespace BizHawk.Client.Common
/// Get a string representation of difference
/// between current value and the previous one
/// </summary>
public override string Diff
{
get
{
string diff = "";
int diffVal = _value - _previous;
if (diffVal > 0)
{
diff = "+";
}
else if (diffVal < 0)
{
diff = "-";
}
return $"{diff}{((byte)Math.Abs(diffVal))}";
}
}
public override string Diff => $"{_value - (short)_previous:+#;-#;0}";
/// <summary>
/// Get the maximum possible value

View File

@ -231,7 +231,7 @@ namespace BizHawk.Client.Common
/// Get a string representation of difference
/// between current value and the previous one
/// </summary>
public override string Diff => (_previous - _value).ToString();
public override string Diff => $"{_value - (long)_previous:+#;-#;0}";
/// <summary>
/// Get the maximum possible value

View File

@ -214,24 +214,7 @@ namespace BizHawk.Client.Common
/// Get a string representation of difference
/// between current value and the previous one
/// </summary>
public override string Diff
{
get
{
string diff = "";
int diffVal = _value - _previous;
if (diffVal > 0)
{
diff = "+";
}
else if (diffVal < 0)
{
diff = "-";
}
return $"{diff}{((ushort)Math.Abs(diffVal))}";
}
}
public override string Diff => $"{_value - (int)_previous:+#;-#;0}";
/// <summary>
/// Get the maximum possible value

View File

@ -12,28 +12,15 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
//d immediately succeeds the opcode
//n immediate succeeds the opcode and the displacement (if present)
//nn immediately succeeds the opcode and the displacement (if present)
if (format.IndexOf("nn") != -1)
{
byte B = read(addr++);
byte C = read(addr++);
format = format.Replace("nn", string.Format("{0:X4}h", B + C * 256));
}
if (format.IndexOf("n") != -1)
{
byte B = read(addr++);
format = format.Replace("n", string.Format("{0:X2}h", B));
}
if (format.IndexOf("nn") != -1) format = format.Replace("nn", $"{read(addr++) + (read(addr++) << 8):X4}h"); // LSB is read first
if (format.IndexOf("n") != -1) format = format.Replace("n", $"{read(addr++):X2}h");
if (format.IndexOf("+d") != -1) format = format.Replace("+d", "d");
if (format.IndexOf("d") != -1)
{
byte B = read(addr++);
bool neg = ((B & 0x80) != 0);
char sign = neg ? '-' : '+';
int val = neg ? 256 - B : B;
format = format.Replace("d", string.Format("{0}{1:X2}h", sign, val));
var b = unchecked ((sbyte) read(addr++));
format = format.Replace("d", $"{(b < 0 ? '-' : '+')}{(b < 0 ? -b : b):X2}h");
}
return format;