diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/graphics/vesa.c | 25 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.h | 2 | ||||
-rw-r--r-- | src/kernel/kernel.c | 2 |
3 files changed, 23 insertions, 6 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c index 1165d2e..9cfcd66 100644 --- a/src/kernel/graphics/vesa.c +++ b/src/kernel/graphics/vesa.c @@ -50,8 +50,6 @@ struct vbe_mode_info *vbe_set_mode(unsigned short mode) { struct vbe_mode_info *vbe_info = (struct vbe_mode_info *) 0xA0000; - terminal_write_number(vbe_info->width); - terminal_write_number(vbe_info->height); vbe_width = vbe_info->width; vbe_height = vbe_info->height; vbe_bpp = vbe_info->bpp / 8; @@ -137,7 +135,7 @@ void vesa_clear() { } void vesa_set_pixel(uint16_t x, uint16_t y, uint32_t color) { - unsigned pos = x * (vbe_bpp / 8) + y * vbe_pitch; + unsigned pos = x * (vbe_bpp) + y * vbe_pitch; fb[pos] = color & 255; fb[pos + 1] = (color >> 8) & 255; fb[pos + 2] = (color >> 16) & 255; @@ -157,13 +155,32 @@ void vesa_draw_char(char ch, int x, int y) { } } +void vesa_draw_rectangle(int x1, int y1, int x2, int y2, int color) { + int i, j; + char blue = color & 255; + char green = (color >> 8) & 255; + char red = (color >> 16) & 255; + int pos1 = x1 * vbe_bpp + y1 * vbe_pitch; + char *draw = &fb[pos1]; + for (i = 0; i <= y2 - y1; i++) { + for (j = 0; j <= x2 - x1; j++) { + draw[vbe_bpp * j] = blue; + draw[vbe_bpp * j + 1] = green; + draw[vbe_bpp * j + 2] = red; + } + draw += vbe_pitch; + } +} + void vesa_draw_string(char *data) { vesa_clear(); int i = 0; while (data[i] != '\0') { - vesa_draw_char(data[i], terminal_x + (10 * i), terminal_y); + vesa_draw_char(data[i], terminal_x, terminal_y); + terminal_x += 10; i++; } + // vesa_draw_rectangle(terminal_x, terminal_y, terminal_x + 10, terminal_y + 16, 0xffffff); } void vesa_set_color(uint32_t color) { diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h index 7b49e8b..9dbd96d 100644 --- a/src/kernel/graphics/vesa.h +++ b/src/kernel/graphics/vesa.h @@ -137,7 +137,7 @@ int vbe_width; int vbe_height; /** - * The bits per pixel of the current video mode + * The bits per pixel (pixel width) of the current video mode */ int vbe_bpp; diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 6c19e17..30a8e35 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -29,7 +29,7 @@ void kernel_main(void) { // info("Melvix loaded successfully!\n\n"); // info("Loading VESA..."); - vesa_draw_string("test"); + vesa_draw_string("This is a testing text!"); if (vesa_available) { write_serial("Loaded VESA!"); |