experimental/refinement_font.py

Download file

Release 2026-11-04-r2 · SHA256 de93701ae364d3eb4324e7c26b3172e6700c6ed6b5e4fb90bde91ccd59fd3d85 · Click a line number for a direct link.

1"""One menu-only ± tile, without changing any native font/resource allocation.23The native text format treats high-bit bytes as positioning commands. ASCII '~'4is an otherwise blank internal token. A guarded native character lookup selects5the one scratch tile only for that token in the small-font path; every original6character and font resource stays byte-identical.7"""8ORIGINAL = 0xBE26A9GLYPH = 0x25A0001011def install(data, patch, with_cosmetic_ui=False):12    glyph = bytearray(data[ORIGINAL + 10:ORIGINAL + 42])13    foreground = {(3, 1), (3, 2), (3, 4)}14    foreground.update((x, y) for y in (3, 6) for x in range(1, 6))15    shadow = {(x + 1, y + 1) for x, y in foreground if x < 7 and y < 7} - foreground16    for colour, pixels in ((4, shadow), (1, foreground)):17        for x, y in pixels:18            offset = 4 * y + x // 219            shift = 0 if x & 1 else 420            glyph[offset] = (glyph[offset] & ~(15 << shift)) | (colour << shift)21    patch(GLYPH, b'\xff' * 32, glyph)22    patch(0x11C38, bytes.fromhex('3032000408380003c2f8'), bytes.fromhex('4eb9002580144e714e71'))2324    if with_cosmetic_ui:25        # The native ASCII$ tile is a copyright-like glyph, not a dollar sign.26        # A modal-owned scratch glyph avoids changing that native font globally.27        rows=['00011000','00111110','01111000','00111100','00011110','01111100','00011000','00000000']28        foreground={(x,y)for y,row in enumerate(rows)for x,c in enumerate(row)if c=='1'}29        shadow={(x+1,y+1)for x,y in foreground if x<7 and y<7}-foreground30        dollar=bytearray(data[0xAAC52+10:0xAAC52+42])31        for colour,pixels in[(4,shadow),(1,foreground)]:32            for x,y in pixels:33                at=4*y+x//2;shift=0 if x&1 else 4;dollar[at]=(dollar[at]&~(15<<shift))|(colour<<shift)34        patch(GLYPH+32,b'\xff'*32,dollar)35