From e098815c0f70900c22c781de691afda8ea02f9a1 Mon Sep 17 00:00:00 2001 From: Chris Anders Date: Thu, 24 Oct 2024 06:56:58 +0200 Subject: [PATCH] refactor: Cleanup --- src/MimaSim/MimaSim/MIMA/Font.cs | 124 +++++++++++++++---------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/MimaSim/MimaSim/MIMA/Font.cs b/src/MimaSim/MimaSim/MIMA/Font.cs index 1144489..184d7dc 100644 --- a/src/MimaSim/MimaSim/MIMA/Font.cs +++ b/src/MimaSim/MimaSim/MIMA/Font.cs @@ -6,219 +6,219 @@ namespace MimaSim.MIMA; public class Font { - Dictionary _characters = new(); + Dictionary _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() @@ -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); } } }