From 9130122609599f14f30fd6d2b32d15865cc8dfe3 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Thu, 23 Dec 2021 07:32:54 -0800 Subject: Moving away from UART output --- src/graphics/drawer.c | 39 +++++++++++++++++++++++++++++++++++++++ src/graphics/drawer.h | 4 ++++ src/graphics/lfb.c | 4 ++-- 3 files changed, 45 insertions(+), 2 deletions(-) (limited to 'src/graphics') 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); +} diff --git a/src/graphics/drawer.h b/src/graphics/drawer.h index 63b5194..04f8f23 100644 --- a/src/graphics/drawer.h +++ b/src/graphics/drawer.h @@ -8,10 +8,14 @@ struct Drawer { static struct Drawer g_Drawer; +void write_cchar(struct Drawer* d, char s, unsigned int c); +void write_char(struct Drawer* d, char s); void write_cstring(struct Drawer* d, char* s, unsigned int c); void write_string(struct Drawer* d, char* s); void write_chex32(struct Drawer* d, unsigned long val, unsigned int c); void write_hex32(struct Drawer* d, unsigned long val); +void write_c10(struct Drawer* d, unsigned long val, unsigned int c); +void write_10(struct Drawer* d, unsigned long val); void set_drawer(struct Drawer* d, unsigned int x, unsigned int y); #endif diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c index de241d8..5e307f4 100644 --- a/src/graphics/lfb.c +++ b/src/graphics/lfb.c @@ -100,7 +100,7 @@ void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsign for(y=0; y<8; y++) { for(x=0; x<8; x++) { if((1 << (7-x)) & glyphs_byte[y+8*(ltr)]) { - *((unsigned int*)ptr) = isrgb ? c : (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16);; + *((unsigned int*)ptr) = isrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c; } else { *((unsigned int*)ptr) = 0x000000; } @@ -118,7 +118,7 @@ void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsi for(y=0; y<8; y++) { for(x=0; x<8; x++) { if((1 << (7-x)) & glyphs[y+8*(ltr)]) { - *((unsigned int*)ptr) = isrgb ? c : (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16);; + *((unsigned int*)ptr) = isrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c; } else { *((unsigned int*)ptr) = 0x000000; } -- cgit v1.2.1