Skip to content

Commit

Permalink
refactor: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Oct 24, 2024
1 parent f9d8438 commit e098815
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions src/MimaSim/MimaSim/MIMA/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,219 +6,219 @@ namespace MimaSim.MIMA;

public class Font
{
Dictionary<char, bool[]> _characters = new();
Dictionary<char, (bool[] pixels, int width)> _characters = new();

public bool[] this[char key] => _characters[key];
public (bool[] pixels, int width) this[char key] => _characters[key];

public Font()
{
_characters.Add('a', [
_characters.Add('a', ([
false, true, true, true, false, // Zeile 1: .###.
false, false, false, false, true, // Zeile 2: ....#
false, true, true, true, true, // Zeile 3: .####
true, false, false, false, true, // Zeile 4: #...#
false, true, true, true, false // Zeile 5: .###.
]);
], 5));

_characters.Add('b', [
_characters.Add('b', ([
true, false, false, false, false, // Zeile 1: #..
true, false, false, false, false, // Zeile 2: #....
true, true, true, true, false, // Zeile 3: ####.
true, false, false, false, true, // Zeile 4: #...#
true, true, true, true, false // Zeile 5: ####.
]);
], 5));

_characters.Add('c', [
_characters.Add('c', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, false, // Zeile 2: #....
true, false, false, false, false, // Zeile 3: #....
true, false, false, false, false, // Zeile 4: #....
false, true, true, true, false // Zeile 5: .###.
]);
], 5));

_characters.Add('d', [
_characters.Add('d', ([
false, false, true, true, false, // Zeile 1: ..##.
false, true, false, false, true, // Zeile 2: .#..#
false, true, false, false, true, // Zeile 3: .#..#
false, true, false, false, true, // Zeile 4: .#..#
false, false, true, true, false // Zeile 5: ..##.
]);
], 5));

_characters.Add('e', [
_characters.Add('e', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, true, // Zeile 2: #...#
true, true, true, true, false, // Zeile 3: ####.
true, false, false, false, false, // Zeile 4: #....
false, true, true, true, false // Zeile 5: .###.
]);
], 5));

_characters.Add('f', [
_characters.Add('f', ([
false, true, true, true, true, // Zeile 1: .####
true, false, false, false, false, // Zeile 2: #....
true, true, true, false, false, // Zeile 3: ###..
true, false, false, false, false, // Zeile 4: #....
true, false, false, false, false // Zeile 5: #....
]);
], 5));

_characters.Add('g', [
_characters.Add('g', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, true, // Zeile 2: #...#
true, false, false, false, true, // Zeile 3: #...#
false, true, true, true, true, // Zeile 4: .####
false, false, false, false, true // Zeile 5: ....#
]);
], 5));

_characters.Add('h', [
_characters.Add('h', ([
true, false, false, false, false, // Zeile 1: #....
true, false, false, false, false, // Zeile 2: #....
true, true, true, true, false, // Zeile 3: ####.
true, false, false, false, true, // Zeile 4: #...#
true, false, false, false, true // Zeile 5: #...#
]);
], 5));

_characters.Add('i', [
false, false, true, false, false, // Zeile 1: ..#..
false, false, true, false, false, // Zeile 2: ..#..
false, false, true, false, false, // Zeile 3: ..#..
false, false, true, false, false, // Zeile 4: ..#..
false, false, true, false, false // Zeile 5: ..#..
]);
_characters.Add('i', ([
false, true, false, // Zeile 1: .#.
false, true, false, // Zeile 2: .#.
false, true, false, // Zeile 3: .#.
false, true, false, // Zeile 4: .#.
false, true, false // Zeile 5: .#.
], 3));

_characters.Add('j', [
_characters.Add('j', ([
false, false, false, true, false, // Zeile 1: ...#.
false, false, false, true, false, // Zeile 2: ...#.
false, false, false, true, false, // Zeile 3: ...#.
true, false, false, true, false, // Zeile 4: #..#.
false, true, true, false, false // Zeile 5: .##..
]);
], 5));

_characters.Add('k', [
_characters.Add('k', ([
true, false, false, false, true, // Zeile 1: #...#
true, false, false, true, false, // Zeile 2: #..#.
true, true, true, false, false, // Zeile 3: ###..
true, false, false, true, false, // Zeile 4: #..#.
true, false, false, false, true // Zeile 5: #...#
]);
], 5));

_characters.Add('l', [
_characters.Add('l', ([
true, false, false, false, false, // Zeile 1: #....
true, false, false, false, false, // Zeile 2: #....
true, false, false, false, false, // Zeile 3: #....
true, false, false, false, false, // Zeile 4: #....
true, true, true, true, false // Zeile 5: ####.
]);
], 5));

_characters.Add('m', [
_characters.Add('m', ([
true, true, false, true, true, // Zeile 1: ##.##
true, false, true, false, true, // Zeile 2: #.#.#
true, false, false, false, true, // Zeile 3: #...#
true, false, false, false, true, // Zeile 4: #...#
true, false, false, false, true // Zeile 5: #...#
]);
], 5));

_characters.Add('n', [
_characters.Add('n', ([
true, true, true, false, false, // Zeile 1: ###..
true, false, false, true, false, // Zeile 2: #..#.
true, false, false, false, true, // Zeile 3: #...#
true, false, false, false, true, // Zeile 4: #...#
true, false, false, false, true // Zeile 5: #...#
]);
], 5));

_characters.Add('o', [
_characters.Add('o', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, true, // Zeile 2: #...#
true, false, false, false, true, // Zeile 3: #...#
true, false, false, false, true, // Zeile 4: #...#
false, true, true, true, false // Zeile 5: .###.
]);
], 5));

_characters.Add('p', [
_characters.Add('p', ([
true, true, true, true, false, // Zeile 1: ####.
true, false, false, false, true, // Zeile 2: #...#
true, true, true, true, false, // Zeile 3: ####.
true, false, false, false, false, // Zeile 4: #....
true, false, false, false, false // Zeile 5: #....
]);
], 5));

_characters.Add('q', [
_characters.Add('q', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, true, // Zeile 2: #...#
true, false, false, false, true, // Zeile 3: #...#
false, true, true, true, true, // Zeile 4: .####
false, false, false, false, true // Zeile 5: ....#
]);
], 5));

_characters.Add('r', [
_characters.Add('r', ([
true, true, true, false, false, // Zeile 1: ###..
true, false, false, true, false, // Zeile 2: #..#.
true, false, false, false, false, // Zeile 3: #....
true, false, false, false, false, // Zeile 4: #....
true, false, false, false, false // Zeile 5: #....
]);
], 5));

_characters.Add('s', [
_characters.Add('s', ([
false, true, true, true, false, // Zeile 1: .###.
true, false, false, false, false, // Zeile 2: #....
false, true, true, true, false, // Zeile 3: .###.
false, false, false, false, true, // Zeile 4: ....#
true, true, true, true, false // Zeile 5: ####.
]);
], 5));

_characters.Add('t', [
_characters.Add('t', ([
true, true, true, true, true, // Zeile 1: #####
false, false, true, false, false, // Zeile 2: ..#..
false, false, true, false, false, // Zeile 3: ..#..
false, false, true, false, false, // Zeile 4: ..#..
false, false, true, false, false // Zeile 5: ..#..
]);
], 5));

_characters.Add('u', [
_characters.Add('u', ([
true, false, false, false, true, // Zeile 1: #...#
true, false, false, false, true, // Zeile 2: #...#
true, false, false, false, true, // Zeile 3: #...#
true, false, false, false, true, // Zeile 4: #...#
false, true, true, true, false // Zeile 5: .###.
]);
], 5));

_characters.Add('v', [
_characters.Add('v', ([
true, false, false, false, true, // Zeile 1: #...#
true, false, false, false, true, // Zeile 2: #...#
false, true, false, true, false, // Zeile 3: .#.#.
false, true, false, true, false, // Zeile 4: .#.#.
false, false, true, false, false // Zeile 5: ..#..
]);
], 5));

_characters.Add('w', [
_characters.Add('w', ([
true, false, false, false, true, // Zeile 1: #...#
true, false, false, false, true, // Zeile 2: #...#
true, false, false, false, true, // Zeile 3: #...#
true, false, true, false, true, // Zeile 4: #.#.#
false, true, false, true, false // Zeile 5: .#.#.
]);
], 5));

_characters.Add('x', [
_characters.Add('x', ([
true, false, false, false, true, // Zeile 1: #...#
false, true, false, true, false, // Zeile 2: .#.#.
false, false, true, false, false, // Zeile 3: ..#..
false, true, false, true, false, // Zeile 4: .#.#.
true, false, false, false, true // Zeile 5: #...#
]);
], 5));

_characters.Add('y', [
_characters.Add('y', ([
true, false, false, false, true, // Zeile 1: #...#
false, true, false, true, false, // Zeile 2: .#.#.
false, false, true, false, false, // Zeile 3: ..#..
false, false, true, false, false, // Zeile 4: ..#..
false, true, true, false, false // Zeile 5: .##..
]);
], 5));

_characters.Add('z', [
_characters.Add('z', ([
true, true, true, true, true, // Zeile 1: #####
false, false, false, true, false, // Zeile 2: ...#.
false, false, true, false, false, // Zeile 3: ..#..
false, true, false, false, false, // Zeile 4: .#...
true, true, true, true, true // Zeile 5: #####
]);
], 5));
}

public void DrawChar()
Expand All @@ -227,19 +227,19 @@ public void DrawChar()
var yOffset = CPU.Instance.Display.DY.GetValueWithoutNotification();
var ch = (char)CPU.Instance.Display.DC.GetValueWithoutNotification();

if (!_characters.TryGetValue(ch, out var pixels))
if (!_characters.TryGetValue(ch, out var character))
{
throw new NotImplementedException($"unknown character {ch}");
}

var width = 5;
var (pixels, width) = character;
for (var y = 0; y < 5; y++)
{
for (var x = 0; x < width; x++)
{
if (pixels[y * width + x])
{
CPU.Instance.Display.SetPixel((short)(y + xOffset), (short)(x + yOffset), DisplayColor.Black);
CPU.Instance.Display.SetPixel((short)(y + yOffset), (short)(x + xOffset), DisplayColor.Black);
}
}
}
Expand Down

0 comments on commit e098815

Please sign in to comment.