aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-23 07:32:54 -0800
committerChristian Cunningham <cc@localhost>2021-12-23 07:32:54 -0800
commit9130122609599f14f30fd6d2b32d15865cc8dfe3 (patch)
tree6d099a03f9be4028b234c1d06cafd92446d629ea /src/graphics
parent5427e73f6437edd0c889a107ebb6adb4436d55da (diff)
Moving away from UART output
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/drawer.c39
-rw-r--r--src/graphics/drawer.h4
-rw-r--r--src/graphics/lfb.c4
3 files changed, 45 insertions, 2 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);
+}
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;
}