BufferedCGA refactoring
This commit is contained in:
@ -10,32 +10,32 @@
|
||||
// The buffer dimensions must match with the destination dimensions
|
||||
class ScrollbackBuffer {
|
||||
private:
|
||||
CGA::cga_line_t* buffer; // Circular buffer to store lines that left the screen
|
||||
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
|
||||
// generated before the scrollback buffer is initialized by accident
|
||||
// (but only if it's less than a page)
|
||||
unsigned int current_linenumber;
|
||||
|
||||
CGA::cga_line_t* get_current_line() const; // Translate linenumber to memory location
|
||||
void buffer_next_line(); // Moves the current_line one line forward
|
||||
unsigned int pos;
|
||||
|
||||
public:
|
||||
const unsigned int pageheight, // Number of lines per page
|
||||
pages, // Number of pages in buffer
|
||||
lines; // Total number of lines in buffer
|
||||
const unsigned int pages; // Number of pages in buffer
|
||||
const unsigned int rows; // Number of lines in buffer
|
||||
|
||||
ScrollbackBuffer(unsigned char width, unsigned char height, unsigned char pages)
|
||||
: current_linenumber(0), pageheight(height), pages(pages), lines(height * pages) {
|
||||
this->buffer = new CGA::cga_line_t[lines];
|
||||
ScrollbackBuffer(unsigned char rows, unsigned char pages)
|
||||
: pos(0), pages(pages), rows(rows * pages) {
|
||||
this->buffer = new CGA::cga_page_t[pages];
|
||||
this->pagebuffer = new CGA::cga_page_t;
|
||||
this->clear(); // Null out the buffer so no crap gets displayed
|
||||
}
|
||||
~ScrollbackBuffer() {
|
||||
delete[] this->buffer;
|
||||
delete this->pagebuffer;
|
||||
}
|
||||
|
||||
void line_to_buffer(CGA::cga_line_t* line);
|
||||
void copy_page_from_buffer(CGA::cga_line_t* destination, unsigned char page) const;
|
||||
void copy_page_from_pagebuffer(CGA::cga_page_t* destination) const;
|
||||
void copy_page_to_pagebuffer(CGA::cga_page_t* source);
|
||||
void put(CGA::cga_line_t* line);
|
||||
void get(CGA::cga_line_t* destination, unsigned char page) const;
|
||||
void copy_from_pagebuffer(CGA::cga_page_t* destination) const;
|
||||
void copy_to_pagebuffer(CGA::cga_page_t* source);
|
||||
void clear();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user