From 9bc59ba6c018bcce9c7854d7ed2c6e31730f5a50 Mon Sep 17 00:00:00 2001 From: shokre Date: Thu, 16 Sep 2021 16:27:06 +0200 Subject: [PATCH] feat: add character generator using orao ROM --- orao/chargen.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 orao/chargen.py diff --git a/orao/chargen.py b/orao/chargen.py new file mode 100644 index 0000000..9e10401 --- /dev/null +++ b/orao/chargen.py @@ -0,0 +1,22 @@ + +chars = None + +def chargen_init(char_data): + global chars + chars = char_data + + +def chargen_draw_char(surf, px, py, ch): + char_loc = (ord(ch) - 32) * 8 + for y in range(8): + c = chars[char_loc + y] + for x in range(8): + if (c >> x) & 1: + surf.set_at((px + x, py + y), (0, 255, 0)) + else: + surf.set_at((px + x, py + y), (0, 0, 0)) + + +def chargen_draw_str(surf, px, py, str): + for x in range(len(str)): + chargen_draw_char(surf, px + x * 8, py, str[x])