diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cga.cc | 20 | ||||
-rw-r--r-- | drivers/cga.h | 5 |
2 files changed, 14 insertions, 11 deletions
diff --git a/drivers/cga.cc b/drivers/cga.cc index 6589cee..51b7221 100644 --- a/drivers/cga.cc +++ b/drivers/cga.cc @@ -21,31 +21,31 @@ constexpr uint8_t cursor_addr_l = 15; // 0xf * 1 1 | blink fast */ constexpr uint8_t cursor_hide = 0b00100000; -constexpr uint32_t address = 0xc03ff000; -CGA::CGA() { +void CGA::set_buffer(uint32_t address) { buffer = reinterpret_cast<Entry*>(address); + clear(); + enable_cursor(14, 15); + update_cursor(); +} - // clear buffer +void CGA::set_colour(Colour fg, Colour bg) { + colour_fg = fg; + colour_bg = bg; for (size_t y = 0; y < max_rows; y++) { for (size_t x = 0; x < max_columns; x++) { const size_t index = y * max_columns + x; - buffer[index].c = ' '; buffer[index].fg = colour_fg; buffer[index].bg = colour_bg; } } - - enable_cursor(14, 15); - update_cursor(); } -void CGA::set_colour(Colour fg, Colour bg) { - colour_fg = fg; - colour_bg = bg; +void CGA::clear() { for (size_t y = 0; y < max_rows; y++) { for (size_t x = 0; x < max_columns; x++) { const size_t index = y * max_columns + x; + buffer[index].c = ' '; buffer[index].fg = colour_fg; buffer[index].bg = colour_bg; } diff --git a/drivers/cga.h b/drivers/cga.h index f4dfb3c..ec207c4 100644 --- a/drivers/cga.h +++ b/drivers/cga.h @@ -35,10 +35,13 @@ public: CGA_COLOR_WHITE = 15, }; - CGA(); + CGA() = default; ~CGA() = default; + void set_buffer(uint32_t); + void set_colour(Colour fg, Colour bg); + void clear(); void enable_cursor(uint8_t start, uint8_t end); void disable_cursor(); |