Created
October 31, 2025 07:50
-
-
Save philpem/4598c83c6dd5330c427c7ac2bd8fbd5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # | |
| # Deinterleave BSB font ROM from Maskromtool output | |
| # | |
| import os, sys | |
| def die(x): | |
| print(x) | |
| sys.exit(1) | |
| with open("bits.txt", "rt") as f: | |
| lines = f.readlines() | |
| ncols = None | |
| nrows = 0 | |
| barr = bytearray() | |
| # number of pixels horizontally | |
| xpixels = 8 | |
| # number of lanes per bank (128 characters / 16 xinterleave = 8) | |
| yinterleave = 8 | |
| for yo in range(8): | |
| for xo in reversed(range(16)): | |
| nrows += 1 | |
| for line in [lines[i].strip() for i in range(yo, len(lines), yinterleave)]: | |
| if ncols is None: | |
| ncols = len(line) | |
| xinterleave = ncols // xpixels | |
| if ncols % xpixels != 0: | |
| die(f"Line length {ncols} is not a multiple of {xpixels} bits") | |
| print(f"{ncols} bits per row, {xinterleave} addr-lsbs per interleaved lane") | |
| else: | |
| if ncols != len(line): | |
| die(f"Line length inconsistent on line {nrows}") | |
| bstr = line[xo:len(line):xinterleave] | |
| bstr = bstr[::-1] | |
| print(bstr.replace('0',' ').replace('1','X')) | |
| barr.append(int(bstr, 2)) | |
| print() | |
| print(f"Processed {nrows} characters") | |
| with open("rom.data", "wb") as f: | |
| f.write(barr) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference character set.
