feat: add character generator using orao ROM
This commit is contained in:
parent
32795a402c
commit
9bc59ba6c0
1 changed files with 22 additions and 0 deletions
22
orao/chargen.py
Normal file
22
orao/chargen.py
Normal file
|
@ -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])
|
Loading…
Reference in a new issue