fix bufferedcga bug where buffer was used before init
This commit is contained in:
@ -10,12 +10,16 @@ void BufferedCGA::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BufferedCGA::displaypage() {
|
void BufferedCGA::displaypage() {
|
||||||
if (this->current_page == 0) {
|
if (this->initialized) {
|
||||||
// Use pagebuffer
|
if (this->current_page == 0) {
|
||||||
this->scrollback_buffer->copy_page_from_pagebuffer((cga_page_t*)CGA_START);
|
// Use pagebuffer
|
||||||
|
this->scrollback_buffer->copy_page_from_pagebuffer((cga_page_t*)CGA_START);
|
||||||
|
} else {
|
||||||
|
// Use scrollback
|
||||||
|
this->scrollback_buffer->copy_page_from_buffer((cga_line_t*)CGA_START, this->current_page - 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use scrollback
|
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||||
this->scrollback_buffer->copy_page_from_buffer((cga_line_t*)CGA_START, this->current_page - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,25 +55,33 @@ void BufferedCGA::clear() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int BufferedCGA::scroll_page_backward() {
|
void BufferedCGA::scroll_page_backward() {
|
||||||
// If this is the first scrollback we have to save the current screen content
|
if (this->initialized) {
|
||||||
if (this->current_page == 0) {
|
|
||||||
this->scrollback_buffer->copy_page_to_pagebuffer((cga_page_t*)CGA_START);
|
|
||||||
}
|
|
||||||
|
|
||||||
// current_page can be equal to scrollback_buffer->pages
|
// If this is the first scrollback we have to save the current screen content
|
||||||
// as we have a separate pagebuffer for the current screen content
|
if (this->current_page == 0) {
|
||||||
if (this->current_page < this->scrollback_buffer->pages) {
|
this->scrollback_buffer->copy_page_to_pagebuffer((cga_page_t*)CGA_START);
|
||||||
this->current_page = this->current_page + 1;
|
}
|
||||||
|
|
||||||
|
// current_page can be equal to scrollback_buffer->pages
|
||||||
|
// as we have a separate pagebuffer for the current screen content
|
||||||
|
if (this->current_page < this->scrollback_buffer->pages) {
|
||||||
|
this->current_page = this->current_page + 1;
|
||||||
|
}
|
||||||
|
this->displaypage();
|
||||||
|
} else {
|
||||||
|
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||||
}
|
}
|
||||||
this->displaypage();
|
|
||||||
return this->current_page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int BufferedCGA::scroll_page_forward() {
|
void BufferedCGA::scroll_page_forward() {
|
||||||
if (this->current_page > 0) {
|
if (this->initialized) {
|
||||||
this->current_page = this->current_page - 1;
|
|
||||||
|
if (this->current_page > 0) {
|
||||||
|
this->current_page = this->current_page - 1;
|
||||||
|
}
|
||||||
|
this->displaypage();
|
||||||
|
} else {
|
||||||
|
this->print("ScrollbackBuffer not initialized\n\n", 34);
|
||||||
}
|
}
|
||||||
this->displaypage();
|
|
||||||
return this->current_page;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
BufferedCGA() : CGA(), initialized(false), current_page(0) {};
|
BufferedCGA() : CGA(), initialized(false), current_page(0) {};
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user