From eb909686f19073b324dee15366b957802dc095a7 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 14 Mar 2021 23:08:46 +0200 Subject: CGA: map and set buffer address in kernel main --- drivers/cga.cc | 20 ++++++++++---------- drivers/cga.h | 5 ++++- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'drivers') 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(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(); -- cgit v1.2.1