aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/drawer.c37
-rw-r--r--src/graphics/drawer.h4
-rw-r--r--src/graphics/font.bin.h (renamed from src/graphics/font.h.bin)0
-rw-r--r--src/graphics/glyphs.h3
-rw-r--r--src/graphics/glyphs.old2
-rw-r--r--src/graphics/homer.h1
-rw-r--r--src/graphics/lfb.c59
-rw-r--r--src/graphics/lfb.h16
8 files changed, 80 insertions, 42 deletions
diff --git a/src/graphics/drawer.c b/src/graphics/drawer.c
index be7b0ac..35a16a6 100644
--- a/src/graphics/drawer.c
+++ b/src/graphics/drawer.c
@@ -1,10 +1,11 @@
-#include "../graphics/lfb.h"
#include "../graphics/drawer.h"
+#include "../graphics/lfb.h"
#define GRAPHICS_DRAWER_C
struct Drawer g_Drawer = {.x = 0, .y = 0};
-void write_cchar(struct Drawer* d, char s, unsigned int c) {
+void write_cchar(struct Drawer* d, char s, unsigned int c)
+{
d->x %= GG_MAX_X;
d->y %= GG_MAX_Y;
if (s == 0x0A) {
@@ -20,11 +21,13 @@ void write_cchar(struct Drawer* d, char s, unsigned int c) {
// CHECK Y EVENTUALLY
}
-void write_char(struct Drawer* d, char s) {
+void write_char(struct Drawer* d, char s)
+{
write_cchar(d, s, 0xFFFFFF);
}
-void write_cstring(struct Drawer* d, char* s, unsigned int c) {
+void write_cstring(struct Drawer* d, char* s, unsigned int c)
+{
d->x %= GG_MAX_X;
d->y %= GG_MAX_Y;
unsigned int idx = 0;
@@ -44,16 +47,13 @@ void write_cstring(struct Drawer* d, char* s, unsigned int c) {
}
}
-void write_string(struct Drawer* d, char* s) {
+void write_string(struct Drawer* d, char* s)
+{
write_cstring(d, s, 0xFFFFFF);
}
-void set_drawer(struct Drawer* d, unsigned int x, unsigned int y) {
- d->x = x % GG_MAX_X;
- d->y = y % GG_MAX_Y;
-}
-
-void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) {
+void write_chex32(struct Drawer* d, unsigned long val, unsigned int c)
+{
draw_chex32(d->x, d->y, val, c);
d->x += 8;
if (d->x >= GG_MAX_X) {
@@ -62,11 +62,13 @@ void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) {
}
}
-void write_hex32(struct Drawer* d, unsigned long val) {
+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) {
+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;
@@ -81,6 +83,13 @@ void write_c10(struct Drawer* d, unsigned long val, unsigned int c) {
write_cstring(d, s, c);
}
-void write_10(struct Drawer* d, unsigned long val) {
+void write_10(struct Drawer* d, unsigned long val)
+{
write_c10(d, val, 0xFFFFFF);
}
+
+void set_drawer(struct Drawer* d, unsigned int x, unsigned int y)
+{
+ d->x = x % GG_MAX_X;
+ d->y = y % GG_MAX_Y;
+}
diff --git a/src/graphics/drawer.h b/src/graphics/drawer.h
index 1ad89c5..6d97163 100644
--- a/src/graphics/drawer.h
+++ b/src/graphics/drawer.h
@@ -12,12 +12,16 @@ extern 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/font.h.bin b/src/graphics/font.bin.h
index f883cda..f883cda 100644
--- a/src/graphics/font.h.bin
+++ b/src/graphics/font.bin.h
diff --git a/src/graphics/glyphs.h b/src/graphics/glyphs.h
index 668508e..1a9319d 100644
--- a/src/graphics/glyphs.h
+++ b/src/graphics/glyphs.h
@@ -1,7 +1,6 @@
#ifndef GRAPHICS_GLYPHS_H
#define GRAPHICS_GLYPHS_H
-//extern char* glyphs;
-#include "font.h.bin"
+#include "font.bin.h"
#endif
diff --git a/src/graphics/glyphs.old b/src/graphics/glyphs.old
index 6377747..0a831f9 100644
--- a/src/graphics/glyphs.old
+++ b/src/graphics/glyphs.old
@@ -1,4 +1,3 @@
-
const char glyphs[] = {
0b10000001,
0b00111000,
@@ -1298,4 +1297,3 @@ const char glyphs_byte[] = {
0b01000000,
0b00000000,
};
-
diff --git a/src/graphics/homer.h b/src/graphics/homer.h
index 97b4edb..459bc3d 100644
--- a/src/graphics/homer.h
+++ b/src/graphics/homer.h
@@ -11,6 +11,7 @@ pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2)); \
pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33))); \
data += 4; \
}
+
static char *homer_data =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c
index 6aa6012..54bc71c 100644
--- a/src/graphics/lfb.c
+++ b/src/graphics/lfb.c
@@ -1,8 +1,8 @@
#include "../drivers/uart.h"
+#include "../graphics/glyphs.h"
+#include "../graphics/homer.h"
#include "../graphics/lfb.h"
#include "../graphics/mbox.h"
-#include "../graphics/homer.h"
-#include "../graphics/glyphs.h"
#define GRAPHICS_LFB_C
unsigned int width, height, pitch, isrgb; /* dimensions and channel order */
@@ -11,7 +11,7 @@ unsigned char *lfb; /* raw frame buffer address */
/**
* Set screen resolution to 1024x768
*/
-void lfb_init()
+void lfb_init(void)
{
mbox[0] = 35*4;
mbox[1] = MBOX_REQUEST;
@@ -71,11 +71,23 @@ void lfb_init()
}
}
+void clear_screen(void)
+{
+ unsigned char *ptr=lfb;
+ for(unsigned int y = 0; y < height; y++) {
+ for(unsigned int x = 0; x < width; x++) {
+ *(unsigned int*)ptr = 0x000000;
+ ptr += 4;
+ }
+ }
+}
+
/**
* Show a picture
*/
-void lfb_showpicture()
+void lfb_showpicture(void)
{
+ clear_screen();
unsigned int x,y;
unsigned char *ptr=lfb;
char *data=homer_data, pixel[4];
@@ -93,7 +105,8 @@ void lfb_showpicture()
}
}
-void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c) {
+void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c)
+{
unsigned int x, y;
unsigned char* ptr = lfb;
ptr += (pitch*ly*GLYPH_Y+lx*4*GLYPH_X);
@@ -114,7 +127,13 @@ void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsign
}
}
-void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c) {
+void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter)
+{
+ draw_cbyte(lx, ly, letter, 0xFFFFFF);
+}
+
+void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c)
+{
unsigned int x, y;
unsigned char* ptr = lfb;
ptr += (pitch*ly*GLYPH_Y+lx*4*GLYPH_X);
@@ -132,7 +151,13 @@ void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsi
}
}
-void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c) {
+void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter)
+{
+ draw_cletter(lx, ly, letter, 0xFFFFFF);
+}
+
+void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c)
+{
unsigned int x = lx % GG_MAX_X, y = ly % GG_MAX_Y;
unsigned int idx = 0;
while(s[idx] != 0) {
@@ -145,7 +170,13 @@ void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c) {
}
}
-void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c) {
+void draw_string(unsigned int lx, unsigned int ly, char* s)
+{
+ draw_cstring(lx, ly, s, 0xFFFFFF);
+}
+
+void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c)
+{
unsigned int x = lx % GG_MAX_X, y = ly % GG_MAX_Y;
for(unsigned int i = 0; i < GLYPH_X; i++) {
draw_cbyte(x++, y, 0xF & (val >> ((GLYPH_X-1)-i)*4), c);
@@ -157,15 +188,7 @@ void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned i
}
}
-void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter) {
- draw_cbyte(lx, ly, letter, 0xFFFFFF);
-}
-void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter) {
- draw_cletter(lx, ly, letter, 0xFFFFFF);
-}
-void draw_string(unsigned int lx, unsigned int ly, char* s){
- draw_cstring(lx, ly, s, 0xFFFFFF);
-}
-void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val) {
+void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val)
+{
draw_chex32(lx, ly, val, 0xFFFFFF);
}
diff --git a/src/graphics/lfb.h b/src/graphics/lfb.h
index 37914ac..a4eef2e 100644
--- a/src/graphics/lfb.h
+++ b/src/graphics/lfb.h
@@ -8,17 +8,21 @@
extern unsigned int width, height, pitch, isrgb; /* dimensions and channel order */
#endif
-void lfb_init();
-void lfb_showpicture();
+void lfb_init(void);
+void lfb_showpicture(void);
-void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
-void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
-void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c);
-void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c);
+void clear_screen(void);
+void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter);
+
+void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter);
+
+void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c);
void draw_string(unsigned int lx, unsigned int ly, char* s);
+
+void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c);
void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val);
#endif