diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2018-02-14 23:24:11 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2018-02-14 23:24:11 -0500 |
commit | f90c71412cd715e1a7293ecdb0237c96fbfe9bb8 (patch) | |
tree | f1473a3dff0a8ec5ff3d0128d3e31bd58eea646b /src/display_draw.c | |
parent | 92d50d4d8368e616d4ead3153fae91cc913100a4 (diff) |
font support, inconsolata
Diffstat (limited to 'src/display_draw.c')
-rw-r--r-- | src/display_draw.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 <display.h> + +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++]); +} |