From: Alan Cox Date: Tue, 7 Aug 2018 23:04:18 +0000 (+0100) Subject: font: add an expanded 8x8 font for 2bpp displays X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=aa285e691704ee43f8acf6e9ca45fbbfda210a7b;p=FUZIX.git font: add an expanded 8x8 font for 2bpp displays 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). --- diff --git a/Kernel/Makefile b/Kernel/Makefile index 87381058..fb71c9ba 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -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_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 diff --git a/Kernel/font8x8.c b/Kernel/font8x8.c index b769bc06..9f9b9ea9 100644 --- a/Kernel/font8x8.c +++ b/Kernel/font8x8.c @@ -1,4 +1,7 @@ +/* We may also be used by a build tool */ +#ifndef GENERATOR #include +#endif #ifdef CONFIG_FONT8X8 diff --git a/Kernel/tools/fontexpand.c b/Kernel/tools/fontexpand.c new file mode 100644 index 00000000..fa3e56d8 --- /dev/null +++ b/Kernel/tools/fontexpand.c @@ -0,0 +1,55 @@ +#include +#include + +#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 \n#include \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; +}