From f90c71412cd715e1a7293ecdb0237c96fbfe9bb8 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 14 Feb 2018 23:24:11 -0500 Subject: font support, inconsolata --- src/display_draw.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/display_draw.c (limited to 'src/display_draw.c') diff --git a/src/display_draw.c b/src/display_draw.c new file mode 100644 index 0000000..84a5443 --- /dev/null +++ b/src/display_draw.c @@ -0,0 +1,29 @@ +#include + +static unsigned int curx = 0; +static unsigned int cury = 0; + +extern const unsigned char inconsolata24[192 * 156 * 2 + 1]; + +void dsp_putchar(int c) +{ + unsigned int start = ((c - ' ') / 16 * 192 * 26 + (c % 16) * 12) * 2; + + dsp_set_addr(curx * 12, cury * 26, curx * 12 + 11, cury * 26 + 25); + // for each row + for (unsigned int i = 0; i < 26; i++) { + // for each column + for (int j = 12 * 2 - 1; j >= 0; j--) + dsp_write_data(inconsolata24[start + (i * 192 * 2) + j]); + } + + if (++curx == 26) + curx = 0, cury++; +} + +void dsp_puts(const char *s) +{ + unsigned int i = 0; + while (s[i]) + dsp_putchar(s[i++]); +} -- cgit v1.2.3