diff options
author | Christian Cunningham <cc@localhost> | 2021-12-23 07:32:54 -0800 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2021-12-23 07:32:54 -0800 |
commit | 9130122609599f14f30fd6d2b32d15865cc8dfe3 (patch) | |
tree | 6d099a03f9be4028b234c1d06cafd92446d629ea /src/graphics/drawer.c | |
parent | 5427e73f6437edd0c889a107ebb6adb4436d55da (diff) |
Moving away from UART output
Diffstat (limited to 'src/graphics/drawer.c')
-rw-r--r-- | src/graphics/drawer.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/graphics/drawer.c b/src/graphics/drawer.c index a2c5d8e..742712a 100644 --- a/src/graphics/drawer.c +++ b/src/graphics/drawer.c @@ -3,6 +3,26 @@ static struct Drawer g_Drawer = {x: 0, y: 0}; +void write_cchar(struct Drawer* d, char s, unsigned int c) { + d->x %= GG_MAX_X; + d->y %= GG_MAX_Y; + if (s == 0x0A) { + d->y += 1; + d->x = 0; + } else { + draw_cletter(d->x++, d->y, s, c); + if (d->x > GG_MAX_X) { + d->y += 1; + d->x = 0; + } + } + // CHECK Y EVENTUALLY +} + +void write_char(struct Drawer* d, char s) { + write_cchar(d, s, 0xFFFFFF); +} + void write_cstring(struct Drawer* d, char* s, unsigned int c) { d->x %= GG_MAX_X; d->y %= GG_MAX_Y; @@ -44,3 +64,22 @@ void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) { void write_hex32(struct Drawer* d, unsigned long val) { write_chex32(d, val, 0xFFFFFF); } + +void write_c10(struct Drawer* d, unsigned long val, unsigned int c) { + static char out[] = "0000000000"; + char* s = (char*)out+10; + unsigned long tmp = val; + if(tmp == 0) + s--; + while (tmp != 0) { + s--; + unsigned char rem = tmp%10; + tmp /= 10; + *s = rem + 0x30; + } + write_cstring(d, s, c); +} + +void write_10(struct Drawer* d, unsigned long val) { + write_c10(d, val, 0xFFFFFF); +} |