1

fix bufferedcga bug where buffer was used before init

This commit is contained in:
churl
2022-05-10 00:20:25 +02:00
parent 15515269a1
commit b860c82d87
2 changed files with 37 additions and 25 deletions

View File

@ -10,6 +10,7 @@ void BufferedCGA::init() {
} }
void BufferedCGA::displaypage() { void BufferedCGA::displaypage() {
if (this->initialized) {
if (this->current_page == 0) { if (this->current_page == 0) {
// Use pagebuffer // Use pagebuffer
this->scrollback_buffer->copy_page_from_pagebuffer((cga_page_t*)CGA_START); this->scrollback_buffer->copy_page_from_pagebuffer((cga_page_t*)CGA_START);
@ -17,6 +18,9 @@ void BufferedCGA::displaypage() {
// Use scrollback // Use scrollback
this->scrollback_buffer->copy_page_from_buffer((cga_line_t*)CGA_START, this->current_page - 1); this->scrollback_buffer->copy_page_from_buffer((cga_line_t*)CGA_START, this->current_page - 1);
} }
} else {
this->print("ScrollbackBuffer not initialized\n\n", 34);
}
} }
void BufferedCGA::print(char* string, int n, unsigned char attrib) { void BufferedCGA::print(char* string, int n, unsigned char attrib) {
@ -51,7 +55,9 @@ void BufferedCGA::clear() {
} }
} }
unsigned int BufferedCGA::scroll_page_backward() { void BufferedCGA::scroll_page_backward() {
if (this->initialized) {
// If this is the first scrollback we have to save the current screen content // If this is the first scrollback we have to save the current screen content
if (this->current_page == 0) { if (this->current_page == 0) {
this->scrollback_buffer->copy_page_to_pagebuffer((cga_page_t*)CGA_START); this->scrollback_buffer->copy_page_to_pagebuffer((cga_page_t*)CGA_START);
@ -63,13 +69,19 @@ unsigned int BufferedCGA::scroll_page_backward() {
this->current_page = this->current_page + 1; this->current_page = this->current_page + 1;
} }
this->displaypage(); this->displaypage();
return this->current_page; } else {
this->print("ScrollbackBuffer not initialized\n\n", 34);
}
} }
unsigned int BufferedCGA::scroll_page_forward() { void BufferedCGA::scroll_page_forward() {
if (this->initialized) {
if (this->current_page > 0) { if (this->current_page > 0) {
this->current_page = this->current_page - 1; this->current_page = this->current_page - 1;
} }
this->displaypage(); this->displaypage();
return this->current_page; } else {
this->print("ScrollbackBuffer not initialized\n\n", 34);
}
} }

View File

@ -21,8 +21,8 @@ public:
void init(); // Scrollback needs to be initialized after memorymanagement void init(); // Scrollback needs to be initialized after memorymanagement
unsigned char current_page; // The page that is displayed unsigned char current_page; // The page that is displayed
unsigned int scroll_page_backward(); // Scroll up the page history void scroll_page_backward(); // Scroll up the page history
unsigned int scroll_page_forward(); // Scroll down the page history (to the current page) void scroll_page_forward(); // Scroll down the page history (to the current page)
void print(char* string, int n, unsigned char attrib = STD_ATTR) override; void print(char* string, int n, unsigned char attrib = STD_ATTR) override;
void scrollup() override; void scrollup() override;