font: add an expanded 8x8 font for 2bpp displays
authorAlan Cox <alan@linux.intel.com>
Tue, 7 Aug 2018 23:04:18 +0000 (00:04 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 7 Aug 2018 23:04:18 +0000 (00:04 +0100)
We'll need this for the SAM Coupe where we don't have a 1pp high res mode.
(We may want a 6bit to 12bit font in the end but for now keep it simple).

Kernel/Makefile
Kernel/font8x8.c
Kernel/tools/fontexpand.c [new file with mode: 0644]

index 8738105..fb71c9b 100644 (file)
@@ -58,7 +58,7 @@ CS5SRCS = syscall_exec$(BITS).c
 #
 C3SRCS = devsys.c mm.c swap.c usermem.c timer.c audio.c level2.c devinput.c
 CVIDEOSRCS = vt.c
-CFONTSRCS = font4x6.c font6x8.c font8x8.c
+CFONTSRCS = font4x6.c font6x8.c font8x8.c font8x8_exp2.c
 
 
 ASRCS =  lowlevel-$(CPU)$(BANKED)$(ASMEXT) usermem_std-$(CPU)$(BANKED)$(ASMEXT)
@@ -151,6 +151,9 @@ $(AOBJS): %$(BINEXT): %$(ASMEXT)
 version.c: tools/makeversion
        tools/makeversion $(VERSION) $(SUBVERSION) $(TARGET)
 
+font8x8_exp2.c: font8x8.c tools/fontexpand
+       tools/fontexpand <font8x8.c >font8x8_exp2.c
+
 tools/makeversion: tools/makeversion.c
 
 tools/filesizes: tools/filesizes.c
@@ -165,6 +168,8 @@ tools/makejv3: tools/makejv3.c
 
 tools/trslabel: tools/trslabel.c
 
+tools/fontexpand: tools/fontexpand.c
+
 font4x6.c: tools/make4x6
        tools/make4x6 >font4x6.c
 
index b769bc0..9f9b9ea 100644 (file)
@@ -1,4 +1,7 @@
+/* We may also be used by a build tool */
+#ifndef GENERATOR
 #include <config.h>
+#endif
 
 #ifdef CONFIG_FONT8X8
 
diff --git a/Kernel/tools/fontexpand.c b/Kernel/tools/fontexpand.c
new file mode 100644 (file)
index 0000000..fa3e56d
--- /dev/null
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdint.h>
+
+#define CONFIG_FONT8X8
+#define GENERATOR
+
+#include "../font8x8.c"
+
+uint16_t widen(uint8_t n)
+{
+    unsigned int i;
+    uint16_t r = 0;
+    /* We don't need performance so do the simple way */
+    for (i = 0; i < 8; i++) {
+        if (n & 0x80)
+            r |= 0x03;
+        n <<= 1;
+        r <<= 2;
+    }
+    return r;
+}
+
+char *boolstr(uint8_t n)
+{
+    static char buf[9];
+    unsigned int i;
+    for (i = 0; i < 8; i++) {
+        buf[i] = (n & 0x80) ? '1' : '0';
+        n <<= 1;
+    }
+    buf[8] = 0;
+    return buf;
+}
+        
+    
+int main(int argc, char *argv[])
+{
+    const uint8_t *p = fontdata_8x8;
+    unsigned int i;
+
+    puts("#include <config.h>\n#include <kernel.h>\n");
+    puts("#ifdef CONFIG_FONT_8X8_EXP2\n");
+    puts("/* Automatically generated do not edit */\n");
+    printf("const uint16_t fontdata_8x8_exp2[%d] = {\n", FONTDATAMAX);
+    for (i = 0; i < FONTDATAMAX; i++) {
+        if (!(i & 7))
+            printf("\t/* Character %u */\n", i >> 3);
+        printf("\t0x%04X,\t/* %s */\n", widen(*p), boolstr(*p));
+        if ((i & 7) == 7)
+            putchar('\n');
+        p++;
+    }
+    puts("/* End of font */\n};\n\n#endif");
+    return 0;
+}