cga use span to address screen memory
This commit is contained in:
@ -17,6 +17,10 @@
|
||||
const IOport CGA::index_port(0x3d4);
|
||||
const IOport CGA::data_port(0x3d5);
|
||||
|
||||
bse::span<CGA::cga_char_t, CGA::ROWS * CGA::COLUMNS> CGA::SCREEN{reinterpret_cast<CGA::cga_char_t*>(0xb8000U)};
|
||||
bse::span<CGA::cga_line_t, CGA::ROWS> CGA::SCREEN_ROWS{reinterpret_cast<CGA::cga_line_t*>(0xb8000U)};
|
||||
CGA::cga_page_t* CGA::SCREEN_PAGE {reinterpret_cast<CGA::cga_page_t*>(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_char_t*>(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<cga_line_t>(reinterpret_cast<cga_line_t*>(CGA_START),
|
||||
reinterpret_cast<cga_line_t*>(CGA_START) + 1,
|
||||
ROWS - 1);
|
||||
bse::memcpy<cga_line_t>(SCREEN_ROWS[0], SCREEN_ROWS[1], ROWS - 1);
|
||||
|
||||
// Clear last line
|
||||
bse::zero<cga_line_t>(reinterpret_cast<cga_line_t*>(CGA_START) + ROWS - 1);
|
||||
bse::zero<cga_line_t>(SCREEN_ROWS[ROWS - 1]);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@ -182,7 +184,7 @@ void CGA::clear() {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
bse::zero<cga_page_t>(reinterpret_cast<cga_page_t*>(CGA_START));
|
||||
bse::zero<cga_page_t>(SCREEN_PAGE);
|
||||
setpos(0, 0);
|
||||
}
|
||||
|
||||
|
@ -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_line_t, ROWS> cga_page;
|
||||
};
|
||||
|
||||
static bse::span<cga_char_t, ROWS * COLUMNS> SCREEN;
|
||||
static bse::span<cga_line_t, ROWS> 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);
|
||||
|
||||
|
Reference in New Issue
Block a user