// SPDX-FileCopyrightText: NONE // // SPDX-License-Identifier: CC0-1.0 //! Apple II and II Plus character generator ROM 341-0036, as pixel data. //! //! Generated, and not to be edited by hand: it is a transcription of a chip. //! It came from the apple2chars project, whose `tools/gen_font.py` reads the //! ROM dump and writes this out; the dump itself came from the Apple II //! Documentation Project's mirror and is byte-identical to MAME's copy //! (CRC32 `64f415c6`). //! //! Uppercase only: 64 glyphs of 7 dots by 8 scan lines, holding `@ A-Z [ \ ] ^ _` //! then space, punctuation and digits. Same byte layout as apple2e.zig -- **bit 6 //! is the leftmost dot**, a **1 bit means lit**, bit 7 is always 0 -- but note //! the glyphs sit on scan lines 1..7 with the blank line at the *top*, where the //! //e moved them to lines 0..6 so that lowercase descenders could use the //! bottom line. //! //! This ROM only ever sees six bits of the screen code. A II or II Plus decides //! inverse and flashing from bits 6 and 7 outside the ROM, with an XOR gate on //! the shift register's output, so one bitmap serves all four quarters of the //! screen-code range: //! //! | Screen code | Displays | //! |-------------|-----------------------------| //! | `$00-$3F` | inverse | //! | `$40-$7F` | flashing | //! | `$80-$BF` | normal | //! | `$C0-$FF` | normal (repeat) | //! //! Use `glyph` rather than indexing `charset` directly and that masking is done //! for you. The dump is 2 KB: these 64 glyphs, then the same 64 again with a //! stray bit 7 set, then both of those a second time. //! //! The bytes are a normalised form and are not the ROM's own layout: see //! apple2e.zig for what the conversion is and why the chip needs one. /// Dots across one scan line of a character cell. pub const width = 7; /// Scan lines in a character cell. pub const height = 8; /// One character cell: 8 scan lines, topmost first. pub const Glyph = [height]u8; /// The 64 glyphs, indexed by the low six bits of a screen code. pub const charset: [64]Glyph = .{ .{ 0x00, 0x1C, 0x22, 0x2A, 0x2E, 0x2C, 0x20, 0x1E }, // $00 '@' ......./..###../.#...#./.#.#.#./.#.###./.#.##../.#...../..####. .{ 0x00, 0x08, 0x14, 0x22, 0x22, 0x3E, 0x22, 0x22 }, // $01 'A' ......./...#.../..#.#../.#...#./.#...#./.#####./.#...#./.#...#. .{ 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x22, 0x22, 0x3C }, // $02 'B' ......./.####../.#...#./.#...#./.####../.#...#./.#...#./.####.. .{ 0x00, 0x1C, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1C }, // $03 'C' ......./..###../.#...#./.#...../.#...../.#...../.#...#./..###.. .{ 0x00, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3C }, // $04 'D' ......./.####../.#...#./.#...#./.#...#./.#...#./.#...#./.####.. .{ 0x00, 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x3E }, // $05 'E' ......./.#####./.#...../.#...../.####../.#...../.#...../.#####. .{ 0x00, 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x20 }, // $06 'F' ......./.#####./.#...../.#...../.####../.#...../.#...../.#..... .{ 0x00, 0x1E, 0x20, 0x20, 0x20, 0x26, 0x22, 0x1E }, // $07 'G' ......./..####./.#...../.#...../.#...../.#..##./.#...#./..####. .{ 0x00, 0x22, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x22 }, // $08 'H' ......./.#...#./.#...#./.#...#./.#####./.#...#./.#...#./.#...#. .{ 0x00, 0x1C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C }, // $09 'I' ......./..###../...#.../...#.../...#.../...#.../...#.../..###.. .{ 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1C }, // $0A 'J' ......./.....#./.....#./.....#./.....#./.....#./.#...#./..###.. .{ 0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22 }, // $0B 'K' ......./.#...#./.#..#../.#.#.../.##..../.#.#.../.#..#../.#...#. .{ 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3E }, // $0C 'L' ......./.#...../.#...../.#...../.#...../.#...../.#...../.#####. .{ 0x00, 0x22, 0x36, 0x2A, 0x2A, 0x22, 0x22, 0x22 }, // $0D 'M' ......./.#...#./.##.##./.#.#.#./.#.#.#./.#...#./.#...#./.#...#. .{ 0x00, 0x22, 0x22, 0x32, 0x2A, 0x26, 0x22, 0x22 }, // $0E 'N' ......./.#...#./.#...#./.##..#./.#.#.#./.#..##./.#...#./.#...#. .{ 0x00, 0x1C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C }, // $0F 'O' ......./..###../.#...#./.#...#./.#...#./.#...#./.#...#./..###.. .{ 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x20, 0x20, 0x20 }, // $10 'P' ......./.####../.#...#./.#...#./.####../.#...../.#...../.#..... .{ 0x00, 0x1C, 0x22, 0x22, 0x22, 0x2A, 0x24, 0x1A }, // $11 'Q' ......./..###../.#...#./.#...#./.#...#./.#.#.#./.#..#../..##.#. .{ 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x28, 0x24, 0x22 }, // $12 'R' ......./.####../.#...#./.#...#./.####../.#.#.../.#..#../.#...#. .{ 0x00, 0x1C, 0x22, 0x20, 0x1C, 0x02, 0x22, 0x1C }, // $13 'S' ......./..###../.#...#./.#...../..###../.....#./.#...#./..###.. .{ 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, // $14 'T' ......./.#####./...#.../...#.../...#.../...#.../...#.../...#... .{ 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C }, // $15 'U' ......./.#...#./.#...#./.#...#./.#...#./.#...#./.#...#./..###.. .{ 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x14, 0x08 }, // $16 'V' ......./.#...#./.#...#./.#...#./.#...#./.#...#./..#.#../...#... .{ 0x00, 0x22, 0x22, 0x22, 0x2A, 0x2A, 0x36, 0x22 }, // $17 'W' ......./.#...#./.#...#./.#...#./.#.#.#./.#.#.#./.##.##./.#...#. .{ 0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22 }, // $18 'X' ......./.#...#./.#...#./..#.#../...#.../..#.#../.#...#./.#...#. .{ 0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08 }, // $19 'Y' ......./.#...#./.#...#./..#.#../...#.../...#.../...#.../...#... .{ 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3E }, // $1A 'Z' ......./.#####./.....#./....#../...#.../..#..../.#...../.#####. .{ 0x00, 0x3E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3E }, // $1B '[' ......./.#####./.##..../.##..../.##..../.##..../.##..../.#####. .{ 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00 }, // $1C '\' ......./......./.#...../..#..../...#.../....#../.....#./....... .{ 0x00, 0x3E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3E }, // $1D ']' ......./.#####./....##./....##./....##./....##./....##./.#####. .{ 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, 0x00 }, // $1E '^' ......./......./......./...#.../..#.#../.#...#./......./....... .{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E }, // $1F '_' ......./......./......./......./......./......./......./.#####. .{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // $20 space ......./......./......./......./......./......./......./....... .{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08 }, // $21 '!' ......./...#.../...#.../...#.../...#.../...#.../......./...#... .{ 0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00 }, // $22 '"' ......./..#.#../..#.#../..#.#../......./......./......./....... .{ 0x00, 0x14, 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x14 }, // $23 '#' ......./..#.#../..#.#../.#####./..#.#../.#####./..#.#../..#.#.. .{ 0x00, 0x08, 0x1E, 0x28, 0x1C, 0x0A, 0x3C, 0x08 }, // $24 '$' ......./...#.../..####./.#.#.../..###../...#.#./.####../...#... .{ 0x00, 0x30, 0x32, 0x04, 0x08, 0x10, 0x26, 0x06 }, // $25 '%' ......./.##..../.##..#./....#../...#.../..#..../.#..##./....##. .{ 0x00, 0x10, 0x28, 0x28, 0x10, 0x2A, 0x24, 0x1A }, // $26 '&' ......./..#..../.#.#.../.#.#.../..#..../.#.#.#./.#..#../..##.#. .{ 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, // $27 ''' ......./...#.../...#.../...#.../......./......./......./....... .{ 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08 }, // $28 '(' ......./...#.../..#..../.#...../.#...../.#...../..#..../...#... .{ 0x00, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08 }, // $29 ')' ......./...#.../....#../.....#./.....#./.....#./....#../...#... .{ 0x00, 0x08, 0x2A, 0x1C, 0x08, 0x1C, 0x2A, 0x08 }, // $2A '*' ......./...#.../.#.#.#./..###../...#.../..###../.#.#.#./...#... .{ 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00 }, // $2B '+' ......./......./...#.../...#.../.#####./...#.../...#.../....... .{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10 }, // $2C ',' ......./......./......./......./......./...#.../...#.../..#.... .{ 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00 }, // $2D '-' ......./......./......./......./.#####./......./......./....... .{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }, // $2E '.' ......./......./......./......./......./......./......./...#... .{ 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00 }, // $2F '/' ......./......./.....#./....#../...#.../..#..../.#...../....... .{ 0x00, 0x1C, 0x22, 0x26, 0x2A, 0x32, 0x22, 0x1C }, // $30 '0' ......./..###../.#...#./.#..##./.#.#.#./.##..#./.#...#./..###.. .{ 0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C }, // $31 '1' ......./...#.../..##.../...#.../...#.../...#.../...#.../..###.. .{ 0x00, 0x1C, 0x22, 0x02, 0x0C, 0x10, 0x20, 0x3E }, // $32 '2' ......./..###../.#...#./.....#./...##../..#..../.#...../.#####. .{ 0x00, 0x3E, 0x02, 0x04, 0x0C, 0x02, 0x22, 0x1C }, // $33 '3' ......./.#####./.....#./....#../...##../.....#./.#...#./..###.. .{ 0x00, 0x04, 0x0C, 0x14, 0x24, 0x3E, 0x04, 0x04 }, // $34 '4' ......./....#../...##../..#.#../.#..#../.#####./....#../....#.. .{ 0x00, 0x3E, 0x20, 0x3C, 0x02, 0x02, 0x22, 0x1C }, // $35 '5' ......./.#####./.#...../.####../.....#./.....#./.#...#./..###.. .{ 0x00, 0x0E, 0x10, 0x20, 0x3C, 0x22, 0x22, 0x1C }, // $36 '6' ......./...###./..#..../.#...../.####../.#...#./.#...#./..###.. .{ 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x10, 0x10 }, // $37 '7' ......./.#####./.....#./....#../...#.../..#..../..#..../..#.... .{ 0x00, 0x1C, 0x22, 0x22, 0x1C, 0x22, 0x22, 0x1C }, // $38 '8' ......./..###../.#...#./.#...#./..###../.#...#./.#...#./..###.. .{ 0x00, 0x1C, 0x22, 0x22, 0x1E, 0x02, 0x04, 0x38 }, // $39 '9' ......./..###../.#...#./.#...#./..####./.....#./....#../.###... .{ 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00 }, // $3A ':' ......./......./......./...#.../......./...#.../......./....... .{ 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x10 }, // $3B ';' ......./......./......./...#.../......./...#.../...#.../..#.... .{ 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04 }, // $3C '<' ......./....#../...#.../..#..../.#...../..#..../...#.../....#.. .{ 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00 }, // $3D '=' ......./......./......./.#####./......./.#####./......./....... .{ 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10 }, // $3E '>' ......./..#..../...#.../....#../.....#./....#../...#.../..#.... .{ 0x00, 0x1C, 0x22, 0x04, 0x08, 0x08, 0x00, 0x08 }, // $3F '?' ......./..###../.#...#./....#../...#.../...#.../......./...#... }; /// The glyph a screen code displays, ignoring inverse and flashing. pub fn glyph(screen_code: u8) Glyph { return charset[screen_code & 0x3F]; } /// Whether a screen code is drawn inverse on a II or II Plus. pub fn isInverse(screen_code: u8) bool { return screen_code < 0x40; } /// Whether a screen code flashes on a II or II Plus. Callers should invert its /// dots on alternate phases of the ~2 Hz flash clock. pub fn isFlashing(screen_code: u8) bool { return screen_code >= 0x40 and screen_code < 0x80; } /// Whether the dot at (`x`, `y`) of `glyph` is lit. `x` counts from the left. pub fn pixel(g: Glyph, x: u3, y: u3) bool { return (g[y] & (@as(u8, 0x40) >> x)) != 0; } /// Flip every dot in a cell: inverse video, and one phase of a flashing /// character. pub fn invert(g: Glyph) Glyph { var out: Glyph = undefined; for (g, 0..) |row, i| out[i] = ~row & 0x7F; return out; } const std = @import("std"); test "bit 7 is masked off and the top line is blank" { for (charset) |g| { for (g) |row| try std.testing.expect(row & 0x80 == 0); try std.testing.expectEqual(@as(u8, 0), g[0]); } } test "the four screen-code quarters share one bitmap" { for (0..0x40) |i| { const c: u8 = @intCast(i); try std.testing.expectEqual(charset[i], glyph(c)); try std.testing.expectEqual(charset[i], glyph(c + 0x40)); try std.testing.expectEqual(charset[i], glyph(c + 0x80)); try std.testing.expectEqual(charset[i], glyph(c + 0xC0)); } } test "capital A, one scan line below where the //e puts it" { try std.testing.expectEqual(Glyph{ 0b0000000, 0b0001000, 0b0010100, 0b0100010, 0b0100010, 0b0111110, 0b0100010, 0b0100010, }, glyph('A' | 0x80)); }