From 0b7facea328516edd88152f5f267d18f65ea3d8f Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Tue, 14 Jan 2014 21:30:21 +0100 Subject: [PATCH] Implement clear --- kernel/include/vesa.hpp | 3 +++ kernel/src/vesa.cpp | 20 ++++++++++++++++++-- kernel/src/vesa_console.cpp | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/include/vesa.hpp b/kernel/include/vesa.hpp index 24643050..bdb6c0a0 100644 --- a/kernel/include/vesa.hpp +++ b/kernel/include/vesa.hpp @@ -114,6 +114,9 @@ void draw_hline(size_t x, size_t y, size_t w, uint32_t color); void draw_vline(size_t x, size_t y, size_t h, uint32_t color); void draw_vline(size_t x, size_t y, size_t h, uint8_t r, uint8_t g, uint8_t b); +void draw_rect(size_t x, size_t y, size_t w, size_t h, uint32_t color); +void draw_rect(size_t x, size_t y, size_t w, size_t h, uint8_t r, uint8_t g, uint8_t b); + void draw_char(size_t x, size_t y, char c, uint32_t color); void draw_char(size_t x, size_t y, char c, uint8_t r, uint8_t g, uint8_t b); diff --git a/kernel/src/vesa.cpp b/kernel/src/vesa.cpp index 50dfce0a..84a8c3d3 100644 --- a/kernel/src/vesa.cpp +++ b/kernel/src/vesa.cpp @@ -108,7 +108,7 @@ void vesa::draw_vline(size_t x, size_t y, size_t h, uint32_t color){ } void vesa::draw_vline(size_t x, size_t y, size_t h, uint8_t r, uint8_t g, uint8_t b){ - return draw_vline(x, y, h, make_color(r, g, b)); + draw_vline(x, y, h, make_color(r, g, b)); } void vesa::draw_char(size_t x, size_t y, char c, uint32_t color){ @@ -130,5 +130,21 @@ void vesa::draw_char(size_t x, size_t y, char c, uint32_t color){ } void vesa::draw_char(size_t x, size_t y, char c, uint8_t r, uint8_t g, uint8_t b){ - return draw_char(x, y, c, make_color(r, g, b)); + draw_char(x, y, c, make_color(r, g, b)); +} + +void vesa::draw_rect(size_t x, size_t y, size_t w, size_t h, uint32_t color){ + auto where = x + y * y_shift; + + for(size_t j = 0; j < h; ++j){ + for(size_t i = 0; i < w; ++i){ + screen[where + i] = color; + } + + where += y_shift; + } +} + +void vesa::draw_rect(size_t x, size_t y, size_t w, size_t h, uint8_t r, uint8_t g, uint8_t b){ + draw_rect(x, y, w, h, make_color(r, g, b)); } diff --git a/kernel/src/vesa_console.cpp b/kernel/src/vesa_console.cpp index a49cad43..f7b6010d 100644 --- a/kernel/src/vesa_console.cpp +++ b/kernel/src/vesa_console.cpp @@ -45,7 +45,7 @@ size_t vesa_console::columns(){ } void vesa_console::clear(){ - + vesa::draw_rect(LEFT, TOP, _columns * 8, _lines* 16, 0, 0, 0); } void vesa_console::scroll_up(){