Eudimorphodon
Veteran Member
On the slight chance anyone's interested here's a minimal program I threw together in Python3 using "Pillow" (an actually supported fork of the older Python Image Library, PIL to render a graphic dump of the contents of a byte-wide character generator ROM.
(I wrote this because I wanted to do some "comparative anatomy" of a few different machine's character sets for a project I've been working on, and I wanted to make sure I was getting the data straight from the horses' mouths. Tried it with several character ROMs from Tandy and Commodore machines and it works. Round "ROM_ROWS" to the next biggest byte, IE, say "16" for a 10 row font like the Model II.)
(I wrote this because I wanted to do some "comparative anatomy" of a few different machine's character sets for a project I've been working on, and I wanted to make sure I was getting the data straight from the horses' mouths. Tried it with several character ROMs from Tandy and Commodore machines and it works. Round "ROM_ROWS" to the next biggest byte, IE, say "16" for a 10 row font like the Model II.)
Code:
#!/usr/bin/env python
from PIL import Image, ImageDraw
image=Image.new("1",[256,256])
# TRS_80 Model I
fontfile = open("ROMS/trs80m1.chr", "rb").read()
ROM_ROWS=8
NUM_CHARS=128
OUTFILE="TRS-80_modelI_chars.png"
# TRS_80 Model III ; this ROM has twice as many characters
# fontfile = open("ROMS/trs80m3/8044316a.u36", "rb").read()
# ROM_ROWS=8
# NUM_CHARS=256
# OUTFILE="TRS80MODELIII_CHARS.PNG"
# Commodore PET, uses same settings as Model III
# fontfile = open("characters-2.901447-10.bin", "rb").read()
# ROM_ROWS=8
# NUM_CHARS=256
# OUTFILE="PETchars.png"
# Example for a 4-bit row font
#fontfile = open("ROMS/m2/8043316.u9", "rb").read()
#ROM_ROWS=16
#NUM_CHARS=128
#OUTFILE="TRS80MODELII_CHARS.PNG"
gridposx=0
gridposy=0
d=ImageDraw.Draw(image)
for fontchar in range (NUM_CHARS):
for y in range(ROM_ROWS):
for bitpos in range(8):
if (fontfile[(fontchar*ROM_ROWS)+y] >> bitpos & 1):
d.point([(gridposx+(7-bitpos)),(gridposy+y)],1)
gridposx=gridposx+8
if gridposx > 255:
gridposx=0
gridposy=gridposy+ROM_ROWS
image.show()
#image.save(OUTFILE)