Skip to content

Commit

Permalink
EC Monitor: add string representation of EC registers
Browse files Browse the repository at this point in the history
If you've used a hex editor before, the output will look very familiar
  • Loading branch information
Sparronator9999 committed Jan 26, 2025
1 parent f33fbbe commit 2670b98
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions YAMDCC.ECInspector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ private static void ServerMessage(object sender, PipeMessageEventArgs<ServiceRes
{
int lowBits = reg & 0x0F,
hiBits = (reg & 0xF0) >> 4;
Console.SetCursorPosition(6 + lowBits * 3, 4 + hiBits);

ConsoleColor original = Console.ForegroundColor;

// write hex value
Console.SetCursorPosition(6 + lowBits * 3, 4 + hiBits);

if (ECValues[reg].Value == value)
{
Expand All @@ -213,6 +213,20 @@ private static void ServerMessage(object sender, PipeMessageEventArgs<ServiceRes
Console.ForegroundColor = ConsoleColor.DarkGray;
}
Console.Write($"{value:X2}");

// write string representation
Console.SetCursorPosition(55 + lowBits, 4 + hiBits);
if (value is < 32 or > 126)
{
// unprintable non-extended ASCII char
Console.Write('.');
}
else
{
Console.Write((char)value);
}

// restore console colour and cursor position
Console.ForegroundColor = original;
Console.SetCursorPosition(0, 20);
}
Expand Down

0 comments on commit 2670b98

Please sign in to comment.