Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatsunea/4c73a46c8036d2ed0c3e21729fc20a99 to your computer and use it in GitHub Desktop.
Save hatsunea/4c73a46c8036d2ed0c3e21729fc20a99 to your computer and use it in GitHub Desktop.
const int Width = 45;
const int Height = 113;
const int BufferSize = 5085;
const int DigitsWidth = Width + 5;
const int DigitsSize = 4;
internal Color BackgroundColor { get; set; } = Color.Black;
internal Color ForegroundColor { get; set; } = Color.Green;
private ushort[] Buffer = new ushort[BufferSize];
private int Offset = 0;
internal void Display4digits(int x, int y, int value)
{
if (Buffer.Length < DigitsWidth * Height * DigitsSize)
{
Buffer = new ushort[DigitsWidth * Height * DigitsSize];
}
Offset = 0;
for (var i = DigitsSize; i > 0; i--)
{
CreateSprinte(Digit(value, i));
Offset += DigitsWidth * Height;
}
Screen.Write((ushort)(135 - Height - y), (ushort)x, Height, (ushort)(DigitsWidth * DigitsSize), Buffer);
}
private int Digit(int n, int d)
{
return (int)(n / (long)Math.Pow(10, d - 1) % 10);
}
internal void Display(int x, int y, int value)
{
if (Buffer.Length != BufferSize)
{
Buffer = new ushort[BufferSize];
}
Offset = 0;
CreateSprinte(value);
Screen.Write((ushort)(135 - Height - y), (ushort)x, Height, Width, Buffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment