From eed77bd2970a00d1394ed027ceca5b646e4671ce Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 Jun 2020 18:31:46 +0200 Subject: Started rewrite --- src/userspace/libgui/draw.c | 22 ---------------- src/userspace/libgui/gui.h | 64 --------------------------------------------- src/userspace/libgui/init.c | 27 ------------------- src/userspace/libgui/util.c | 33 ----------------------- 4 files changed, 146 deletions(-) delete mode 100644 src/userspace/libgui/draw.c delete mode 100644 src/userspace/libgui/gui.h delete mode 100644 src/userspace/libgui/init.c delete mode 100644 src/userspace/libgui/util.c (limited to 'src/userspace/libgui') diff --git a/src/userspace/libgui/draw.c b/src/userspace/libgui/draw.c deleted file mode 100644 index 4576808..0000000 --- a/src/userspace/libgui/draw.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -void gui_draw_rectangle(int x1, int y1, int x2, int y2, const u32 color[3]) -{ - int pos1 = x1 * vbe_bpl + y1 * vbe_pitch; - char *draw = (char *)&fb[pos1]; - for (int i = 0; i <= y2 - y1; i++) { - for (int j = 0; j <= x2 - x1; j++) { - draw[vbe_bpl * j] = (char)color[2]; - draw[vbe_bpl * j + 1] = (char)color[1]; - draw[vbe_bpl * j + 2] = (char)color[0]; - } - draw += vbe_pitch; - } -} - -void gui_screen_clear() -{ - gui_draw_rectangle(0, 0, vbe_width - 1, vbe_height - 1, terminal_background); -} \ No newline at end of file diff --git a/src/userspace/libgui/gui.h b/src/userspace/libgui/gui.h deleted file mode 100644 index d210999..0000000 --- a/src/userspace/libgui/gui.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef MELVIX_GUI_H -#define MELVIX_GUI_H - -#include - -struct vbe_mode_info { - u16 attributes; - u16 pitch; - u16 width; - u16 height; - u8 bpp; - u8 memory_model; - u32 framebuffer; -}; - -struct font { - u16 font_32[758][32]; - u16 font_24[758][24]; - u8 font_16[758][16]; - u16 cursor[19]; -}; - -struct pointers { - struct vbe_mode_info *mode_info; - struct font *font; -}; - -u32 terminal_color[3]; -u32 terminal_background[3]; -enum gui_color { - gui_black = 0x1d1f24, - gui_red = 0xE06C75, - gui_green = 0x98C379, - gui_yellow = 0xE5C07B, - gui_blue = 0x61AFEF, - gui_magenta = 0xC678DD, - gui_cyan = 0x56B6C2, - gui_white = 0xABB2BF, - gui_dark_black = 0x3E4452, - gui_dark_red = 0xBE5046, - gui_dark_green = 0x98C379, - gui_dark_yellow = 0xD19A66, - gui_dark_blue = 0x61AFEF, - gui_dark_magenta = 0xC678DD, - gui_dark_cyan = 0x56B6C2, - gui_dark_white = 0x5C6370, -}; - -u8 *fb; -int vbe_width; -int vbe_height; -int vbe_pitch; -int vbe_bpl; - -struct pointers *pointers; - -void gui_init(); - -void gui_draw_rectangle(int x1, int y1, int x2, int y2, const u32 color[3]); -void gui_screen_clear(); - -void gui_convert_color(u32 *color_array, u32 color); - -#endif \ No newline at end of file diff --git a/src/userspace/libgui/init.c b/src/userspace/libgui/init.c deleted file mode 100644 index 2e5d9c5..0000000 --- a/src/userspace/libgui/init.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -struct pointers *pointers; - -u32 terminal_color[3] = { 0xab, 0xb2, 0xbf }; -u32 terminal_background[3] = { 0x1d, 0x1f, 0x24 }; - -void gui_init() -{ - // TODO: Implement framebuffer device - // pointers = syscall_pointers(); - - vbe_width = pointers->mode_info->width; - vbe_height = pointers->mode_info->height; - vbe_pitch = pointers->mode_info->pitch; - vbe_bpl = pointers->mode_info->bpp >> 3; - - // TODO: Why tf is the kheap magic stored in the first few bytes?! - fb = (pointers->mode_info->framebuffer << 16); - - /* gui_screen_clear(); */ - /* printf("%dx%dx%d\n", vbe_width, vbe_height, vbe_bpl << 3); */ - /* printf("0x%x\n", fb); */ -} \ No newline at end of file diff --git a/src/userspace/libgui/util.c b/src/userspace/libgui/util.c deleted file mode 100644 index f108822..0000000 --- a/src/userspace/libgui/util.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -void gui_convert_color(u32 *color_array, u32 color) -{ - u8 red = (u8)((color >> 16) & 255); - u8 green = (u8)((color >> 8) & 255); - u8 blue = (u8)(color & 255); - - if ((vbe_bpl << 3) == 8) { - u32 new_color = - ((red * 7 / 255) << 5) + ((green * 7 / 255) << 2) + (blue * 3 / 255); - color_array[0] = (new_color >> 16) & 255; - color_array[1] = (new_color >> 8) & 255; - color_array[2] = new_color & 255; - } else if ((vbe_bpl << 3) == 16) { - u32 new_color = - (((red & 0b11111000) << 8) + ((green & 0b11111100) << 3) + (blue >> 3)); - color_array[0] = (new_color >> 16) & 255; - color_array[1] = (new_color >> 8) & 255; - color_array[2] = new_color & 255; - } else if ((vbe_bpl << 3) == 24 || (vbe_bpl << 3) == 32) { - color_array[0] = red; - color_array[1] = green; - color_array[2] = blue; - } -} - -void gui_set_color(u32 color) -{ - gui_convert_color(terminal_color, color); - gui_convert_color(terminal_background, gui_black); -} \ No newline at end of file -- cgit v1.2.3