diff --git a/c_os/devices/CGA.cc b/c_os/devices/CGA.cc index b3d3985..894e7c3 100755 --- a/c_os/devices/CGA.cc +++ b/c_os/devices/CGA.cc @@ -17,6 +17,10 @@ const IOport CGA::index_port(0x3d4); const IOport CGA::data_port(0x3d5); +bse::span CGA::SCREEN{reinterpret_cast(0xb8000U)}; +bse::span CGA::SCREEN_ROWS{reinterpret_cast(0xb8000U)}; +CGA::cga_page_t* CGA::SCREEN_PAGE {reinterpret_cast(0xb8000U)}; + /***************************************************************************** * Methode: CGA::setpos * *---------------------------------------------------------------------------* @@ -82,7 +86,7 @@ void CGA::show(unsigned int x, unsigned int y, char character, unsigned char att return; } - cga_char_t* pos = reinterpret_cast(CGA_START) + x + y * COLUMNS; + cga_char_t* pos= SCREEN[x + y * COLUMNS]; pos->cga_char = character; pos->cga_attribute = attrib; } @@ -165,12 +169,10 @@ void CGA::scrollup() const { /* Hier muss Code eingefuegt werden */ // Move up - bse::memcpy(reinterpret_cast(CGA_START), - reinterpret_cast(CGA_START) + 1, - ROWS - 1); + bse::memcpy(SCREEN_ROWS[0], SCREEN_ROWS[1], ROWS - 1); // Clear last line - bse::zero(reinterpret_cast(CGA_START) + ROWS - 1); + bse::zero(SCREEN_ROWS[ROWS - 1]); } /***************************************************************************** @@ -182,7 +184,7 @@ void CGA::clear() { /* Hier muess Code eingefuegt werden */ - bse::zero(reinterpret_cast(CGA_START)); + bse::zero(SCREEN_PAGE); setpos(0, 0); } diff --git a/c_os/devices/CGA.h b/c_os/devices/CGA.h index e6430fa..fc92797 100755 --- a/c_os/devices/CGA.h +++ b/c_os/devices/CGA.h @@ -16,6 +16,7 @@ #include "kernel/IOport.h" #include "user/lib/Array.h" +#include "user/lib/Span.h" #include "user/lib/String.h" class CGA { @@ -34,8 +35,6 @@ public: // virtual ~CGA() = default; - static const unsigned int CGA_START = 0xb8000U; - // Konstanten fuer die moeglichen Farben im Attribut-Byte. typedef enum { BLACK, @@ -78,6 +77,10 @@ public: bse::array cga_page; }; + static bse::span SCREEN; + static bse::span SCREEN_ROWS; + static cga_page_t* SCREEN_PAGE; // No span because can't address anything in [0, 1] + // Setzen des Cursors in Spalte x und Zeile y. static void setpos(unsigned int x, unsigned int y);