1

Buffered CGA refactor finish

This commit is contained in:
churl
2022-05-20 16:15:43 +02:00
parent 80cbe0900d
commit 5e2196c898
5 changed files with 29 additions and 36 deletions

View File

@ -7,15 +7,12 @@
// NOTE: I added this file
// The buffer dimensions must match with the destination dimensions
class ScrollbackBuffer {
private:
CGA::cga_page_t* buffer; // Circular buffer to store lines that left the screen
CGA::cga_page_t* pagebuffer; // Contains the current page separately from the scrollback.
// I thought this was easier since it also captures the little output
// generated before the scrollback buffer is initialized by accident
// (but only if it's less than a page)
unsigned int pos;
CGA::cga_page_t* buffer; // Circular buffer to store lines that left the screen
unsigned int pos; // Buffer write position
ScrollbackBuffer(const ScrollbackBuffer&) = delete;
public:
const unsigned int pages; // Number of pages in buffer
@ -23,19 +20,15 @@ public:
ScrollbackBuffer(unsigned char rows, unsigned char pages)
: pos(0), pages(pages), rows(rows * pages) {
this->buffer = new CGA::cga_page_t[pages]; // Allocate with new because it's quite large,
this->pagebuffer = new CGA::cga_page_t; // also I wanted to use the new memory manager.
this->clear(); // Null out the buffer so no crap gets displayed.
this->buffer = new CGA::cga_page_t[pages]; // Allocate with new because it's quite large
this->clear(); // Null out the buffer so no crap gets displayed
}
~ScrollbackBuffer() {
delete[] this->buffer;
delete this->pagebuffer;
}
void put(CGA::cga_line_t* line);
void get(CGA::cga_line_t* destination, unsigned char page) const;
void save_screen(CGA::cga_page_t* destination) const; // Do not lose video memory when scrolling
void restore_screen(CGA::cga_page_t* source);
void clear();
};