BufferedCGA refactoring
This commit is contained in:
@ -14,22 +14,10 @@ void ScrollbackBuffer::get(CGA::cga_line_t* destination, unsigned char page) con
|
||||
return;
|
||||
}
|
||||
|
||||
// We reverse the pagenumber so page 0 is always the current page
|
||||
// (The last written line is always before curent_line
|
||||
// so we need to take the last page if we want the newest lines)
|
||||
// We reverse the pagenumber so page 0 is always the newest page
|
||||
unsigned char rpage = this->pages - page - 1;
|
||||
|
||||
// Copy linewise because page may wrap around buffer borders
|
||||
|
||||
// Pageheight: 4, Pages: 2 | page = 0 => rpage = 2 - 0 - 1 = 1
|
||||
// LINE 0 | - line = 0 => wrapline = (5 + 1 * 4 + 0) % 8 = 1
|
||||
// LINE 1 | - [...]
|
||||
// LINE 2 | - line = 3 => wrapline = (5 + 1 * 4 + 3) % 8 = 4
|
||||
// LINE 3 |
|
||||
// LINE 4 | page = 1 => rpage = 2 - 1 - 1 = 0
|
||||
// LINE 5 - current_linenumber | - line = 0 => wrapline = (5 + 0 * 4 + 0) % 8 = 5
|
||||
// LINE 6 | - [...]
|
||||
// LINE 7 | - line = 3 => wrapline = (5 + 0 * 4 + 3) % 8 = 0
|
||||
unsigned int wrapline;
|
||||
for (unsigned int line = 0; line < (this->rows / this->pages); ++line) {
|
||||
wrapline = (this->pos + rpage * (this->rows / this->pages) + line) % this->rows;
|
||||
@ -37,11 +25,11 @@ void ScrollbackBuffer::get(CGA::cga_line_t* destination, unsigned char page) con
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollbackBuffer::copy_from_pagebuffer(CGA::cga_page_t* destination) const {
|
||||
void ScrollbackBuffer::save_screen(CGA::cga_page_t* destination) const {
|
||||
mmem::memcpy<CGA::cga_page_t>(destination, this->pagebuffer);
|
||||
}
|
||||
|
||||
void ScrollbackBuffer::copy_to_pagebuffer(CGA::cga_page_t* source) {
|
||||
void ScrollbackBuffer::restore_screen(CGA::cga_page_t* source) {
|
||||
mmem::memcpy<CGA::cga_page_t>(this->pagebuffer, source);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user