# HG changeset patch # User Paul Boddie # Date 1540923713 -3600 # Node ID e5fd5d81a72a3322407efd3fe712f1d80d2d9ad1 # Parent d103800bffdadfb6294e20d9983f16adbe8b3d03 Added a bitmap font, a conversion tool, and library code to blit characters. diff -r d103800bffda -r e5fd5d81a72a data/font.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/font.S Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,1424 @@ +.globl fontchars +.globl fonttable +.globl fontbase +.globl fontlimit + +.section .flash, "a" + +fontbase: +.word 33 + +fontchars: +/* 33 */ +.byte 2 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b00 +.byte 0b10 +.byte 0b00 +.byte 0b00 + +/* 34 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1010 +.byte 0b1010 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 + +/* 35 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b010100 +.byte 0b010100 +.byte 0b111110 +.byte 0b010100 +.byte 0b111110 +.byte 0b010100 +.byte 0b010100 +.byte 0b000000 +.byte 0b000000 + +/* 36 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b001000 +.byte 0b011110 +.byte 0b101000 +.byte 0b011100 +.byte 0b001010 +.byte 0b111100 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 37 */ +.byte 7 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0100000 +.byte 0b1010010 +.byte 0b0100100 +.byte 0b0001000 +.byte 0b0010000 +.byte 0b0100100 +.byte 0b1001010 +.byte 0b0000100 +.byte 0b0000000 + +/* 38 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b010000 +.byte 0b101000 +.byte 0b101000 +.byte 0b010000 +.byte 0b101010 +.byte 0b100100 +.byte 0b011010 +.byte 0b000000 +.byte 0b000000 + +/* 39 */ +.byte 2 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10 +.byte 0b10 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 + +/* 40 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b0110 +.byte 0b0000 + +/* 41 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1100 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b1100 +.byte 0b0000 + +/* 42 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b001000 +.byte 0b001000 +.byte 0b101010 +.byte 0b011100 +.byte 0b101010 +.byte 0b001000 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 43 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b000000 +.byte 0b001000 +.byte 0b001000 +.byte 0b111110 +.byte 0b001000 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 + +/* 44 */ +.byte 3 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b010 +.byte 0b010 +.byte 0b100 +.byte 0b000 + +/* 45 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b11110 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 + +/* 46 */ +.byte 2 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b10 +.byte 0b00 +.byte 0b00 + +/* 47 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00010 +.byte 0b00010 +.byte 0b00100 +.byte 0b00100 +.byte 0b01000 +.byte 0b01000 +.byte 0b10000 +.byte 0b10000 +.byte 0b00000 + +/* 48 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 49 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0100 +.byte 0b1100 +.byte 0b0100 +.byte 0b0100 +.byte 0b0100 +.byte 0b0100 +.byte 0b1110 +.byte 0b0000 +.byte 0b0000 + +/* 50 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b00010 +.byte 0b00100 +.byte 0b01000 +.byte 0b10000 +.byte 0b11110 +.byte 0b00000 +.byte 0b00000 + +/* 51 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b00010 +.byte 0b01100 +.byte 0b00010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 52 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00010 +.byte 0b00110 +.byte 0b01010 +.byte 0b10010 +.byte 0b11110 +.byte 0b00010 +.byte 0b00010 +.byte 0b00000 +.byte 0b00000 + +/* 53 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11110 +.byte 0b10000 +.byte 0b10000 +.byte 0b11100 +.byte 0b00010 +.byte 0b00010 +.byte 0b11100 +.byte 0b00000 +.byte 0b00000 + +/* 54 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10000 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 55 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b0010 +.byte 0b0010 +.byte 0b0100 +.byte 0b0100 +.byte 0b1000 +.byte 0b1000 +.byte 0b0000 +.byte 0b0000 + +/* 56 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 57 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b01110 +.byte 0b00010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 58 */ +.byte 2 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00 +.byte 0b00 +.byte 0b00 +.byte 0b10 +.byte 0b00 +.byte 0b10 +.byte 0b00 +.byte 0b00 +.byte 0b00 + +/* 59 */ +.byte 3 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b010 +.byte 0b000 +.byte 0b010 +.byte 0b010 +.byte 0b100 +.byte 0b000 + +/* 60 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0000 +.byte 0b0010 +.byte 0b0100 +.byte 0b1000 +.byte 0b0100 +.byte 0b0010 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 + +/* 61 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0000 +.byte 0b0000 +.byte 0b1110 +.byte 0b0000 +.byte 0b1110 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 + +/* 62 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0000 +.byte 0b1000 +.byte 0b0100 +.byte 0b0010 +.byte 0b0100 +.byte 0b1000 +.byte 0b0000 +.byte 0b0000 +.byte 0b0000 + +/* 63 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b00010 +.byte 0b00100 +.byte 0b00100 +.byte 0b00000 +.byte 0b00100 +.byte 0b00000 +.byte 0b00000 + +/* 64 */ +.byte 7 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0000000 +.byte 0b0011100 +.byte 0b0100010 +.byte 0b1001110 +.byte 0b1010010 +.byte 0b1001100 +.byte 0b0100000 +.byte 0b0011110 +.byte 0b0000000 + +/* 65 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11110 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 66 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b00000 +.byte 0b00000 + +/* 67 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10000 +.byte 0b10000 +.byte 0b10000 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 68 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b00000 +.byte 0b00000 + +/* 69 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1110 +.byte 0b0000 +.byte 0b0000 + +/* 70 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b0000 +.byte 0b0000 + +/* 71 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10000 +.byte 0b10110 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 72 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b11110 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 73 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b0100 +.byte 0b0100 +.byte 0b0100 +.byte 0b0100 +.byte 0b0100 +.byte 0b1110 +.byte 0b0000 +.byte 0b0000 + +/* 74 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01110 +.byte 0b00100 +.byte 0b00100 +.byte 0b00100 +.byte 0b00100 +.byte 0b00100 +.byte 0b11000 +.byte 0b00000 +.byte 0b00000 + +/* 75 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10010 +.byte 0b10100 +.byte 0b11000 +.byte 0b11000 +.byte 0b10100 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 76 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1110 +.byte 0b0000 +.byte 0b0000 + +/* 77 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b110110 +.byte 0b101010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b000000 +.byte 0b000000 + +/* 78 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b110010 +.byte 0b101010 +.byte 0b100110 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b000000 +.byte 0b000000 + +/* 79 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b011100 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b011100 +.byte 0b000000 +.byte 0b000000 + +/* 80 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b10000 +.byte 0b10000 +.byte 0b10000 +.byte 0b00000 +.byte 0b00000 + +/* 81 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b011100 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b101010 +.byte 0b100100 +.byte 0b011010 +.byte 0b000000 +.byte 0b000000 + +/* 82 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 83 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01100 +.byte 0b10010 +.byte 0b10000 +.byte 0b01100 +.byte 0b00010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 84 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b111110 +.byte 0b001000 +.byte 0b001000 +.byte 0b001000 +.byte 0b001000 +.byte 0b001000 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 85 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 86 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b010100 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 87 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b101010 +.byte 0b101010 +.byte 0b101010 +.byte 0b010100 +.byte 0b000000 +.byte 0b000000 + +/* 88 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b100010 +.byte 0b010100 +.byte 0b001000 +.byte 0b010100 +.byte 0b100010 +.byte 0b100010 +.byte 0b000000 +.byte 0b000000 + +/* 89 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b010100 +.byte 0b001000 +.byte 0b001000 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 90 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11110 +.byte 0b00010 +.byte 0b00100 +.byte 0b01000 +.byte 0b10000 +.byte 0b10000 +.byte 0b11110 +.byte 0b00000 +.byte 0b00000 + +/* 91 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1000 +.byte 0b1110 +.byte 0b0000 + +/* 92 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10000 +.byte 0b10000 +.byte 0b01000 +.byte 0b01000 +.byte 0b00100 +.byte 0b00100 +.byte 0b00010 +.byte 0b00010 +.byte 0b00000 + +/* 93 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b1110 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b1110 +.byte 0b0000 + +/* 94 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b001000 +.byte 0b010100 +.byte 0b100010 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 + +/* 95 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b00000 +.byte 0b11110 +.byte 0b00000 + +/* 96 */ +.byte 3 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100 +.byte 0b010 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 +.byte 0b000 + +/* 97 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01100 +.byte 0b00010 +.byte 0b01110 +.byte 0b10010 +.byte 0b01110 +.byte 0b00000 +.byte 0b00000 + +/* 98 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10000 +.byte 0b10000 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b00000 +.byte 0b00000 + +/* 99 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01110 +.byte 0b10000 +.byte 0b10000 +.byte 0b10000 +.byte 0b01110 +.byte 0b00000 +.byte 0b00000 + +/* 100 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00010 +.byte 0b00010 +.byte 0b01110 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01110 +.byte 0b00000 +.byte 0b00000 + +/* 101 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01100 +.byte 0b10010 +.byte 0b11110 +.byte 0b10000 +.byte 0b01110 +.byte 0b00000 +.byte 0b00000 + +/* 102 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00110 +.byte 0b01000 +.byte 0b11110 +.byte 0b01000 +.byte 0b01000 +.byte 0b01000 +.byte 0b01000 +.byte 0b00000 +.byte 0b00000 + +/* 103 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01110 +.byte 0b10010 +.byte 0b10010 +.byte 0b01110 +.byte 0b00010 +.byte 0b11100 +.byte 0b00000 + +/* 104 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10000 +.byte 0b10000 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 105 */ +.byte 2 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10 +.byte 0b00 +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b10 +.byte 0b00 +.byte 0b00 + +/* 106 */ +.byte 4 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b0010 +.byte 0b0000 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b0010 +.byte 0b1100 +.byte 0b0000 + +/* 107 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b10000 +.byte 0b10000 +.byte 0b10010 +.byte 0b10100 +.byte 0b11000 +.byte 0b10100 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 108 */ +.byte 3 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b100 +.byte 0b100 +.byte 0b100 +.byte 0b100 +.byte 0b100 +.byte 0b100 +.byte 0b010 +.byte 0b000 +.byte 0b000 + +/* 109 */ +.byte 8 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000000 +.byte 0b00000000 +.byte 0b01101100 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b00000000 +.byte 0b00000000 + +/* 110 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b00000 +.byte 0b00000 + +/* 111 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01100 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 112 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b11100 +.byte 0b10010 +.byte 0b10010 +.byte 0b11100 +.byte 0b10000 +.byte 0b10000 +.byte 0b00000 + +/* 113 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01110 +.byte 0b10010 +.byte 0b10010 +.byte 0b01110 +.byte 0b00010 +.byte 0b00010 +.byte 0b00000 + +/* 114 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b10110 +.byte 0b11000 +.byte 0b10000 +.byte 0b10000 +.byte 0b10000 +.byte 0b00000 +.byte 0b00000 + +/* 115 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b01110 +.byte 0b10000 +.byte 0b01100 +.byte 0b00010 +.byte 0b11100 +.byte 0b00000 +.byte 0b00000 + +/* 116 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b01000 +.byte 0b01000 +.byte 0b11110 +.byte 0b01000 +.byte 0b01000 +.byte 0b01000 +.byte 0b00110 +.byte 0b00000 +.byte 0b00000 + +/* 117 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01100 +.byte 0b00000 +.byte 0b00000 + +/* 118 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b000000 +.byte 0b000000 +.byte 0b100010 +.byte 0b100010 +.byte 0b100010 +.byte 0b010100 +.byte 0b001000 +.byte 0b000000 +.byte 0b000000 + +/* 119 */ +.byte 8 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000000 +.byte 0b00000000 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b10010010 +.byte 0b01101100 +.byte 0b00000000 +.byte 0b00000000 + +/* 120 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b000000 +.byte 0b000000 +.byte 0b100010 +.byte 0b010100 +.byte 0b001000 +.byte 0b010100 +.byte 0b100010 +.byte 0b000000 +.byte 0b000000 + +/* 121 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b10010 +.byte 0b10010 +.byte 0b10010 +.byte 0b01110 +.byte 0b00010 +.byte 0b11100 +.byte 0b00000 + +/* 122 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00000 +.byte 0b00000 +.byte 0b11110 +.byte 0b00100 +.byte 0b01000 +.byte 0b10000 +.byte 0b11110 +.byte 0b00000 +.byte 0b00000 + +/* 123 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b00110 +.byte 0b01000 +.byte 0b01000 +.byte 0b11000 +.byte 0b11000 +.byte 0b01000 +.byte 0b01000 +.byte 0b00110 +.byte 0b00000 + +/* 124 */ +.byte 3 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b010 +.byte 0b000 + +/* 125 */ +.byte 5 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b11000 +.byte 0b00100 +.byte 0b00100 +.byte 0b00110 +.byte 0b00110 +.byte 0b00100 +.byte 0b00100 +.byte 0b11000 +.byte 0b00000 + +/* 126 */ +.byte 6 /* width in pixels */ +.byte 9 /* height in pixels */ + +.byte 0b010000 +.byte 0b101010 +.byte 0b000100 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 +.byte 0b000000 + +fontlimit: +.word 127 +fonttable: +.word 0 +.word 11 +.word 22 +.word 33 +.word 44 +.word 55 +.word 66 +.word 77 +.word 88 +.word 99 +.word 110 +.word 121 +.word 132 +.word 143 +.word 154 +.word 165 +.word 176 +.word 187 +.word 198 +.word 209 +.word 220 +.word 231 +.word 242 +.word 253 +.word 264 +.word 275 +.word 286 +.word 297 +.word 308 +.word 319 +.word 330 +.word 341 +.word 352 +.word 363 +.word 374 +.word 385 +.word 396 +.word 407 +.word 418 +.word 429 +.word 440 +.word 451 +.word 462 +.word 473 +.word 484 +.word 495 +.word 506 +.word 517 +.word 528 +.word 539 +.word 550 +.word 561 +.word 572 +.word 583 +.word 594 +.word 605 +.word 616 +.word 627 +.word 638 +.word 649 +.word 660 +.word 671 +.word 682 +.word 693 +.word 704 +.word 715 +.word 726 +.word 737 +.word 748 +.word 759 +.word 770 +.word 781 +.word 792 +.word 803 +.word 814 +.word 825 +.word 836 +.word 847 +.word 858 +.word 869 +.word 880 +.word 891 +.word 902 +.word 913 +.word 924 +.word 935 +.word 946 +.word 957 +.word 968 +.word 979 +.word 990 +.word 1001 +.word 1012 +.word 1023 diff -r d103800bffda -r e5fd5d81a72a data/font.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/font.txt Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,59 @@ +#- #-#- -#-#-- --#--- -#----- -#---- #- -##- ##-- --#--- ------ --- ----- -- ---#- +#- #-#- -#-#-- -####- #-#--#- #-#--- #- #--- --#- --#--- --#--- --- ----- -- ---#- +#- ---- #####- #-#--- -#--#-- #-#--- -- #--- --#- #-#-#- --#--- --- ----- -- --#-- +#- ---- -#-#-- -###-- ---#--- -#---- -- #--- --#- -###-- #####- --- ####- -- --#-- +#- ---- #####- --#-#- --#---- #-#-#- -- #--- --#- #-#-#- --#--- --- ----- -- -#--- +-- ---- -#-#-- ####-- -#--#-- #--#-- -- #--- --#- --#--- --#--- -#- ----- -- -#--- +#- ---- -#-#-- --#--- #--#-#- -##-#- -- #--- --#- --#--- ------ -#- ----- #- #---- +-- ---- ------ ------ ----#-- ------ -- -##- ##-- ------ ------ #-- ----- -- #---- +-- ---- ------ ------ ------- ------ -- ---- ---- ------ ------ --- ----- -- ----- + +-##-- -#-- -##-- -##-- ---#- ####- -##-- ###- -##-- -##-- -- --- ---- ---- ---- -##-- ------- +#--#- ##-- #--#- #--#- --##- #---- #--#- --#- #--#- #--#- -- --- --#- ---- #--- #--#- --###-- +#--#- -#-- ---#- ---#- -#-#- #---- #---- --#- #--#- #--#- -- --- -#-- ###- -#-- ---#- -#---#- +#--#- -#-- --#-- -##-- #--#- ###-- ###-- -#-- -##-- -###- #- -#- #--- ---- --#- --#-- #--###- +#--#- -#-- -#--- ---#- ####- ---#- #--#- -#-- #--#- ---#- -- --- -#-- ###- -#-- --#-- #-#--#- +#--#- -#-- #---- #--#- ---#- ---#- #--#- #--- #--#- #--#- #- -#- --#- ---- #--- ----- #--##-- +-##-- ###- ####- -##-- ---#- ###-- -##-- #--- -##-- -##-- -- -#- ---- ---- ---- --#-- -#----- +----- ---- ----- ----- ----- ----- ----- ---- ----- ----- -- #-- ---- ---- ---- ----- --####- +----- ---- ----- ----- ----- ----- ----- ---- ----- ----- -- --- ---- ---- ---- ----- ------- + +-##-- ###-- -##-- ###-- ###- ###- -##-- #--#- ###- -###- #--#- #--- #---#- #---#- -###-- ###-- -###-- ###-- -##-- #####- #--#- #---#- #---#- #---#- #---#- +#--#- #--#- #--#- #--#- #--- #--- #--#- #--#- -#-- --#-- #-#-- #--- ##-##- ##--#- #---#- #--#- #---#- #--#- #--#- --#--- #--#- #---#- #---#- #---#- #---#- +#--#- #--#- #---- #--#- #--- #--- #---- #--#- -#-- --#-- ##--- #--- #-#-#- #-#-#- #---#- #--#- #---#- #--#- #---- --#--- #--#- #---#- #---#- -#-#-- #---#- +####- ###-- #---- #--#- ###- ###- #-##- ####- -#-- --#-- ##--- #--- #---#- #--##- #---#- ###-- #---#- ###-- -##-- --#--- #--#- #---#- #-#-#- --#--- -#-#-- +#--#- #--#- #---- #--#- #--- #--- #--#- #--#- -#-- --#-- #-#-- #--- #---#- #---#- #---#- #---- #-#-#- #--#- ---#- --#--- #--#- #---#- #-#-#- -#-#-- --#--- +#--#- #--#- #--#- #--#- #--- #--- #--#- #--#- -#-- --#-- #--#- #--- #---#- #---#- #---#- #---- #--#-- #--#- #--#- --#--- #--#- -#-#-- #-#-#- #---#- --#--- +#--#- ###-- -##-- ###-- ###- #--- -##-- #--#- ###- ##--- #--#- ###- #---#- #---#- -###-- #---- -##-#- #--#- -##-- --#--- -##-- --#--- -#-#-- #---#- --#--- +----- ----- ----- ----- ---- ---- ----- ----- ---- ----- ----- ---- ------ ------ ------ ----- ------ ----- ----- ------ ----- ------ ------ ------ ------ +----- ----- ----- ----- ---- ---- ----- ----- ---- ----- ----- ---- ------ ------ ------ ----- ------ ----- ----- ------ ----- ------ ------ ------ ------ + +####- ###- #---- ###- --#--- ----- #-- +---#- #--- #---- --#- -#-#-- ----- -#- +--#-- #--- -#--- --#- #---#- ----- --- +-#--- #--- -#--- --#- ------ ----- --- +#---- #--- --#-- --#- ------ ----- --- +#---- #--- --#-- --#- ------ ----- --- +####- #--- ---#- --#- ------ ----- --- +----- ###- ---#- ###- ------ ####- --- +----- ---- ----- ---- ------ ----- --- + +----- #---- ----- ---#- ----- --##- ----- #---- #- --#- #---- #-- -------- ----- ----- ----- ----- ----- ----- -#--- ----- ------ -------- ------ ----- ----- +----- #---- ----- ---#- ----- -#--- ----- #---- -- ---- #---- #-- -------- ----- ----- ----- ----- ----- ----- -#--- ----- ------ -------- ------ ----- ----- +-##-- ###-- -###- -###- -##-- ####- -###- ###-- #- --#- #--#- #-- -##-##-- ###-- -##-- ###-- -###- #-##- -###- ####- #--#- #---#- #--#--#- #---#- #--#- ####- +---#- #--#- #---- #--#- #--#- -#--- #--#- #--#- #- --#- #-#-- #-- #--#--#- #--#- #--#- #--#- #--#- ##--- #---- -#--- #--#- #---#- #--#--#- -#-#-- #--#- --#-- +-###- #--#- #---- #--#- ####- -#--- #--#- #--#- #- --#- ##--- #-- #--#--#- #--#- #--#- #--#- #--#- #---- -##-- -#--- #--#- #---#- #--#--#- --#--- #--#- -#--- +#--#- #--#- #---- #--#- #---- -#--- -###- #--#- #- --#- #-#-- #-- #--#--#- #--#- #--#- ###-- -###- #---- ---#- -#--- #--#- -#-#-- #--#--#- -#-#-- -###- #---- +-###- ###-- -###- -###- -###- -#--- ---#- #--#- #- --#- #--#- -#- #--#--#- #--#- -##-- #---- ---#- #---- ###-- --##- -##-- --#--- -##-##-- #---#- ---#- ####- +----- ----- ----- ----- ----- ----- ###-- ----- -- ##-- ----- --- -------- ----- ----- #---- ---#- ----- ----- ----- ----- ------ -------- ------ ###-- ----- +----- ----- ----- ----- ----- ----- ----- ----- -- ---- ----- --- -------- ----- ----- ----- ----- ----- ----- ----- ----- ------ -------- ------ ----- ----- + +--##- -#- ##--- -#---- +-#--- -#- --#-- #-#-#- +-#--- -#- --#-- ---#-- +##--- -#- --##- ------ +##--- -#- --##- ------ +-#--- -#- --#-- ------ +-#--- -#- --#-- ------ +--##- -#- ##--- ------ +----- --- ----- ------ diff -r d103800bffda -r e5fd5d81a72a examples/vga-dual/Makefile --- a/examples/vga-dual/Makefile Tue Oct 30 18:22:22 2018 +0100 +++ b/examples/vga-dual/Makefile Tue Oct 30 19:21:53 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S font.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o font.o # Application-specific adjustments. # See: examples/vga/Makefile diff -r d103800bffda -r e5fd5d81a72a examples/vga-dual/font.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-dual/font.S Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,1 @@ +../../data/font.S \ No newline at end of file diff -r d103800bffda -r e5fd5d81a72a examples/vga-pmp/Makefile --- a/examples/vga-pmp/Makefile Tue Oct 30 18:22:22 2018 +0100 +++ b/examples/vga-pmp/Makefile Tue Oct 30 19:21:53 2018 +0100 @@ -27,10 +27,11 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S font.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o font.o # Application-specific adjustments. +# See: examples/vga/Makefile CFLAGS += -DPARALLEL_MODE -I../vga diff -r d103800bffda -r e5fd5d81a72a examples/vga-pmp/font.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-pmp/font.S Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,1 @@ +../../data/font.S \ No newline at end of file diff -r d103800bffda -r e5fd5d81a72a examples/vga-timer/Makefile --- a/examples/vga-timer/Makefile Tue Oct 30 18:22:22 2018 +0100 +++ b/examples/vga-timer/Makefile Tue Oct 30 19:21:53 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S font.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o font.o # Application-specific adjustments. # See: examples/vga/Makefile diff -r d103800bffda -r e5fd5d81a72a examples/vga-timer/font.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga-timer/font.S Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,1 @@ +../../data/font.S \ No newline at end of file diff -r d103800bffda -r e5fd5d81a72a examples/vga/Makefile --- a/examples/vga/Makefile Tue Oct 30 18:22:22 2018 +0100 +++ b/examples/vga/Makefile Tue Oct 30 19:21:53 2018 +0100 @@ -27,8 +27,8 @@ # Ordering of objects is important and cannot be left to replacement rules. -SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S -OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o +SRC = $(START_SRC) main.c $(COMMON_SRC) $(DISPLAY_SRC) screendata.S sprite.S font.S +OBJ = $(START_OBJ) main.o $(COMMON_OBJ) $(DISPLAY_OBJ) screendata.o sprite.o font.o # Application-specific adjustments. diff -r d103800bffda -r e5fd5d81a72a examples/vga/font.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/vga/font.S Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,1 @@ +../../data/font.S \ No newline at end of file diff -r d103800bffda -r e5fd5d81a72a examples/vga/main.c --- a/examples/vga/main.c Tue Oct 30 18:22:22 2018 +0100 +++ b/examples/vga/main.c Tue Oct 30 19:21:53 2018 +0100 @@ -24,11 +24,12 @@ /* Specific functionality. */ -#include "main.h" #include "devconfig.h" -#include "vga.h" #include "display.h" #include "display_config.h" +#include "font.h" +#include "main.h" +#include "vga.h" #include "vga_display.h" @@ -63,13 +64,19 @@ -/* Bundled image data. */ +/* Bundled image and font data. */ extern uint8_t screendata[]; extern uint32_t screendata_width, screendata_height; extern uint8_t sprite[]; extern uint32_t sprite_width, sprite_height; +extern uint8_t fontchars[]; +extern uint32_t fonttable[]; +extern uint32_t fontbase, fontlimit; + +static font_config_t font_config; + /* Busy wait. */ @@ -125,6 +132,30 @@ } } +/* Fill the screen with characters. */ + +static void write_chars(void) +{ + int x = 0, y = 0; + char c; + + font_config.chars = (char_definition_t *) fontchars; + font_config.table = fonttable; + font_config.base = fontbase; + font_config.limit = fontlimit; + + while (y < display_config.line_count) + for (c = (char) font_config.base; c < (char) font_config.limit; c++) + { + x = write_char(&display_config, &font_config, c, x, y, 0xff); + + if (x > display_config.line_length) + { + x = 0; y += 9; + } + } +} + /* Main program. */ @@ -174,6 +205,10 @@ copy_display(&display_config, screendata, screendata_width, screendata_height, (LINE_LENGTH - screendata_width) / 2, (LINE_COUNT - screendata_height) / 2, -1, 1); + /* Write a sequence of characters. */ + + write_chars(); + /* Move a sprite around on the screen with a delay between each movement. */ animate(1 << 24); diff -r d103800bffda -r e5fd5d81a72a include/font.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/font.h Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,57 @@ +/* + * Common font-related functions. + * + * Copyright (C) 2018 Paul Boddie + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __FONT_H__ +#define __FONT_H__ + +#include + + + +/* Character definition structure. */ + +typedef struct +{ + uint8_t width; + uint8_t height; + uint8_t data[]; + +} char_definition_t; + +/* Font configuration type. */ + +typedef struct +{ + char_definition_t *chars; + uint32_t *table; + uint32_t base; + uint32_t limit; + +} font_config_t; + + + +/* Access functions. */ + +char_definition_t *get_char_definition(font_config_t *cfg, char c); + +int write_char(display_config_t *cfg, font_config_t *fcfg, char c, + int x, int y, uint8_t colour); + +#endif /* __FONT_H__ */ diff -r d103800bffda -r e5fd5d81a72a lib/font.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/font.c Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,71 @@ +/* + * Common font-related functions. + * + * Copyright (C) 2018 Paul Boddie + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "display.h" +#include "font.h" + + + +/* Return the character definition for the given character. */ + +char_definition_t *get_char_definition(font_config_t *fcfg, char c) +{ + /* Obtain the offset from the table and combine it with the character + definitions base address. */ + + if ((c >= fcfg->base) && (c < fcfg->limit)) + return (char_definition_t *) ((uint8_t *) fcfg->chars + fcfg->table[c - fcfg->base]); + else + return NULL; +} + +/* Write a character to the screen, returning the next character position. */ + +int write_char(display_config_t *cfg, font_config_t *fcfg, char c, + int x, int y, uint8_t colour) +{ + int sy, dx, dy; + char_definition_t *chardef = get_char_definition(fcfg, c); + uint8_t *imagerow = chardef->data, + *displayline = cfg->framebuffer + y * cfg->line_length, + bitmap, mask; + + /* Space is a special case. */ + + if (c == ' ') + return x + 3; + + for (sy = 0, dy = y; (sy < chardef->height) && (dy < cfg->line_count); sy++, dy++) + { + bitmap = *imagerow; + + for (dx = x, mask = 1 << (chardef->width - 1); (mask) && (dx < cfg->line_length); dx++, mask >>= 1) + { + if (bitmap & mask) + displayline[get_position(cfg, dx)] = colour; + } + + imagerow += 1; + displayline += cfg->line_length; + } + + return x + chardef->width; +} diff -r d103800bffda -r e5fd5d81a72a mk/common.mk --- a/mk/common.mk Tue Oct 30 18:22:22 2018 +0100 +++ b/mk/common.mk Tue Oct 30 19:21:53 2018 +0100 @@ -51,8 +51,8 @@ COMMON_SRC = $(LIBDIR)/payload.c $(LIBDIR)/init.c $(LIBDIR)/debug.c $(LIBDIR)/cpu.S COMMON_OBJ = $(LIBDIR)/payload.o $(LIBDIR)/init.o $(LIBDIR)/debug.o $(LIBDIR)/cpu.o -DISPLAY_SRC = $(LIBDIR)/display.c $(LIBDIR)/vga_display.c -DISPLAY_OBJ = $(LIBDIR)/display.o $(LIBDIR)/vga_display.o +DISPLAY_SRC = $(LIBDIR)/display.c $(LIBDIR)/vga_display.c $(LIBDIR)/font.c +DISPLAY_OBJ = $(LIBDIR)/display.o $(LIBDIR)/vga_display.o $(LIBDIR)/font.o # Common linker script. diff -r d103800bffda -r e5fd5d81a72a tools/makefont.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/makefont.py Tue Oct 30 19:21:53 2018 +0100 @@ -0,0 +1,177 @@ +#!/usr/bin/env python + +""" +Convert simple font bitmaps to GNU assembler data. + +Copyright (C) 2018 Paul Boddie + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +""" + +import sys + +class MissingRow(Exception): + + "Indicate a missing row in a character definition." + + def __init__(self, lineno): + self.lineno = lineno + + def __repr__(self): + return "MissingRow(%r)" % self.lineno + + + +def get_character_row(f, lineno=0): + + "Return a row of characters from 'f', employing 'lineno' for reference." + + line = f.readline().strip() + rows = [] + + while line: + row = line.split() + if rows and len(row) != len(rows[-1]): + raise MissingRow, lineno + + rows.append(row) + lineno += 1 + line = f.readline().strip() + + chars = [] + + if rows: + for i in range(0, len(rows[0])): + char = [] + for row in rows: + char.append(row[i]) + chars.append(char) + + return chars + + + +def convert(infile, outfile, base=33): + + "Convert textual data in 'infile' to assembler data in 'outfile'." + + f_in = open(infile) + f_out = open(outfile, "w") + try: + print >>f_out, """\ +.globl fontchars +.globl fonttable +.globl fontbase +.globl fontlimit + +.section .flash, "a" + +fontbase: +.word %d + +fontchars:""" % base + + lineno = 1 + offset = 0 + offsets = [] + point = base + + # Get each row of characters. + + chars = get_character_row(f_in, lineno) + + while chars: + lineno += len(chars[0]) + 1 + + # Write each character definition. + + for point, char in enumerate(chars, point): + offsets.append(offset) + offset += write_character(f_out, point, char) + + point += 1 + + # Get the next row. + + chars = get_character_row(f_in, lineno) + + # Write the limit of characters. + + print >>f_out, """\ +fontlimit: +.word %d""" % point + + # Write the offset table. + + print >>f_out, """\ +fonttable:""" + + for offset in offsets: + print >>f_out, ".word %d" % offset + + finally: + f_in.close() + f_out.close() + + + +def write_character(f, point, char): + + "Write to 'f' for the given 'point' the indicated 'char' definition." + + # Write a comment and pixel width information. + + print >>f, """\ +/* %d */ +.byte %d /* width in pixels */ +.byte %d /* height in pixels */ +""" % (point, len(char[0]), len(char)) + + # Write the pixel rows to a sequence of bytes. + + for row in char: + print >>f, ".byte 0b%s" % row.replace("-", "0").replace("#", "1") + + print >>f + + # Return the size of the definition as the number of rows plus the width + # and height bytes. + + return len(char) + 2 + + + +# Main program. + +if __name__ == "__main__": + + # Obtain filenames. + + try: + infile, outfile = sys.argv[1:3] + except ValueError: + print >>sys.stderr, """\ +Usage: %s +""" + sys.exit(1) + + # Perform the conversion. + + try: + convert(infile, outfile) + except MissingRow, exc: + print >>sys.stderr, """\ +Missing character information at line %d in file %s. +""" % (exc.lineno, infile) + +# vim: tabstop=4 expandtab shiftwidth=4