Created
August 12, 2022 22:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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