changed a lot of small clang-tidy warnings
This commit is contained in:
@ -4,29 +4,29 @@
|
||||
// Can't initialize in constructor as memory management already needs working CGA for output
|
||||
// NOTE: This has to be called when memorymanagement is active
|
||||
void BufferedCGA::init(unsigned int pages) {
|
||||
this->scrollback_buffer = new ScrollbackBuffer(ROWS, pages); // No delete since it's only off when shutting the os down
|
||||
this->screen_buffer = new CGA::cga_page_t;
|
||||
this->scrollback_buffer = std::make_unique<ScrollbackBuffer>(ROWS, pages); // No delete since it's only off when shutting the os down
|
||||
this->screen_buffer = std::make_unique<CGA::cga_page_t>();
|
||||
|
||||
if (this->scrollback_buffer == NULL || this->screen_buffer == NULL) {
|
||||
if constexpr (DEBUG) kout << "Error initializing scrollback buffer" << endl;
|
||||
if constexpr (DEBUG) { kout << "Error initializing scrollback buffer" << endl; }
|
||||
return;
|
||||
}
|
||||
|
||||
this->initialized = true;
|
||||
if constexpr (DEBUG) kout << "Initialized scrollback buffer" << endl;
|
||||
if constexpr (DEBUG) { kout << "Initialized scrollback buffer" << endl; }
|
||||
}
|
||||
|
||||
void BufferedCGA::display_scrollback() {
|
||||
if (this->initialized) {
|
||||
if (this->scrollback == 0) {
|
||||
// Use pagebuffer
|
||||
mmem::memcpy<CGA::cga_page_t>((CGA::cga_page_t*)CGA_START, this->screen_buffer);
|
||||
mmem::memcpy<CGA::cga_page_t>((CGA::cga_page_t*)CGA_START, this->screen_buffer.get());
|
||||
} else {
|
||||
// Use scrollback
|
||||
this->scrollback_buffer->get((cga_line_t*)CGA_START, this->scrollback - 1);
|
||||
this->scrollback_buffer->get((CGA::cga_line_t*)CGA_START, this->scrollback - 1);
|
||||
}
|
||||
} else {
|
||||
if constexpr (DEBUG) kout << "ScrollbackBuffer not initialized" << endl;
|
||||
if constexpr (DEBUG) { kout << "ScrollbackBuffer not initialized" << endl; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,9 +43,9 @@ void BufferedCGA::print(char* string, int n, unsigned char attrib) {
|
||||
|
||||
void BufferedCGA::scrollup() {
|
||||
if (this->initialized) {
|
||||
this->scrollback_buffer->put((cga_line_t*)CGA_START);
|
||||
this->scrollback_buffer->put((CGA::cga_line_t*)CGA_START);
|
||||
} else {
|
||||
if constexpr (DEBUG) kout << "ScrollbackBuffer not initialized" << endl;
|
||||
if constexpr (DEBUG) { kout << "ScrollbackBuffer not initialized" << endl; }
|
||||
}
|
||||
|
||||
CGA::scrollup();
|
||||
@ -57,9 +57,9 @@ void BufferedCGA::clear() {
|
||||
|
||||
if (this->initialized) {
|
||||
this->scrollback_buffer->clear();
|
||||
mmem::zero<CGA::cga_page_t>(this->screen_buffer);
|
||||
mmem::zero<CGA::cga_page_t>(this->screen_buffer.get());
|
||||
} else {
|
||||
if constexpr (DEBUG) kout << "ScrollbackBuffer not initialized" << endl;
|
||||
if constexpr (DEBUG) { kout << "ScrollbackBuffer not initialized" << endl; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void BufferedCGA::scroll_page_backward() {
|
||||
|
||||
// If this is the first scrollback we have to save the current screen content
|
||||
if (this->scrollback == 0) {
|
||||
mmem::memcpy<CGA::cga_page_t>(this->screen_buffer, (CGA::cga_page_t*)CGA_START);
|
||||
mmem::memcpy<CGA::cga_page_t>(this->screen_buffer.get(), (CGA::cga_page_t*)CGA_START);
|
||||
}
|
||||
|
||||
// current_page can be equal to scrollback_buffer->pages
|
||||
@ -78,7 +78,7 @@ void BufferedCGA::scroll_page_backward() {
|
||||
}
|
||||
this->display_scrollback();
|
||||
} else {
|
||||
if constexpr (DEBUG) kout << "ScrollbackBuffer not initialized" << endl;
|
||||
if constexpr (DEBUG) { kout << "ScrollbackBuffer not initialized" << endl; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,6 +90,6 @@ void BufferedCGA::scroll_page_forward() {
|
||||
}
|
||||
this->display_scrollback();
|
||||
} else {
|
||||
if constexpr (DEBUG) kout << "ScrollbackBuffer not initialized" << endl;
|
||||
if constexpr (DEBUG) { kout << "ScrollbackBuffer not initialized" << endl; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "devices/CGA.h"
|
||||
#include "devices/Keyboard.h"
|
||||
#include "lib/ScrollbackBuffer.h"
|
||||
#include <memory>
|
||||
|
||||
// NOTE: I added this file, I don't know if it will be used till the end but right know it's nice to have
|
||||
|
||||
@ -12,20 +13,14 @@
|
||||
// have to replace print with unbuffered_print or something, which I don't like.
|
||||
class BufferedCGA : public CGA {
|
||||
private:
|
||||
ScrollbackBuffer* scrollback_buffer; // Contains previous pages
|
||||
CGA::cga_page_t* screen_buffer; // Contains the current page separately from the scrollback.
|
||||
bool initialized; // Don't do ScrollbackBuffer actions if not initialized
|
||||
std::unique_ptr<ScrollbackBuffer> scrollback_buffer; // Contains previous pages
|
||||
std::unique_ptr<CGA::cga_page_t> screen_buffer; // Contains the current page separately from the scrollback.
|
||||
bool initialized; // Don't do ScrollbackBuffer actions if not initialized
|
||||
|
||||
BufferedCGA(const BufferedCGA&) = delete;
|
||||
|
||||
public:
|
||||
BufferedCGA() : CGA(), initialized(false), scrollback(0) {};
|
||||
~BufferedCGA() {
|
||||
if (this->initialized) {
|
||||
delete this->scrollback_buffer;
|
||||
delete this->screen_buffer;
|
||||
}
|
||||
}
|
||||
BufferedCGA() : initialized(false), scrollback(0) {}
|
||||
|
||||
unsigned char scrollback; // The page that is displayed, public to enable page display
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ void CGA::setpos(int x, int y) {
|
||||
* *
|
||||
* Rückgabewerte: x und y *
|
||||
*****************************************************************************/
|
||||
void CGA::getpos(int& x, int& y) {
|
||||
void CGA::getpos(int& x, int& y) const {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
@ -78,7 +78,7 @@ void CGA::show(int x, int y, char character, unsigned char attrib) {
|
||||
return;
|
||||
}
|
||||
|
||||
cga_char_t* pos = (cga_char_t*)(CGA_START + 2 * (x + y * COLUMNS));
|
||||
cga_char_t* pos = (cga_char_t*)CGA_START + x + y * COLUMNS;
|
||||
pos->cga_char = character;
|
||||
pos->cga_attribute = attrib;
|
||||
}
|
||||
@ -101,7 +101,7 @@ void CGA::print(char* string, int n, unsigned char attrib) {
|
||||
int cursor_x, cursor_y; // Don't poll registers every stroke
|
||||
this->getpos(cursor_x, cursor_y);
|
||||
|
||||
for (unsigned short byte = 0; byte < n; ++byte) {
|
||||
for (int byte = 0; byte < n; ++byte) {
|
||||
char current = *(string + byte);
|
||||
if (current == '\n') {
|
||||
cursor_x = 0;
|
||||
@ -114,7 +114,9 @@ void CGA::print(char* string, int n, unsigned char attrib) {
|
||||
}
|
||||
|
||||
continue;
|
||||
} else if (current == '\0') {
|
||||
}
|
||||
|
||||
if (current == '\0') {
|
||||
// Don't need to run to end if null terminated
|
||||
break;
|
||||
}
|
||||
@ -185,7 +187,7 @@ unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
return blink << 7 // B0000000
|
||||
| (bg & 0x7) << 4 // 0HHH0000 (Hintergrund)
|
||||
| (fg & 0xF); // 0000VVVV (Vordergrund)
|
||||
return static_cast<int>(blink) << 7 // B0000000
|
||||
| (bg & 0x7) << 4 // 0HHH0000 (Hintergrund)
|
||||
| (fg & 0xF); // 0000VVVV (Vordergrund)
|
||||
}
|
||||
|
||||
@ -16,23 +16,23 @@
|
||||
|
||||
#include "kernel/IOport.h"
|
||||
#include "lib/MyStdLib.h"
|
||||
#include <variant>
|
||||
|
||||
class CGA {
|
||||
|
||||
private:
|
||||
IOport index_port; // Auswahl eines Register der Grafikkarte
|
||||
IOport data_port; // Lese-/Schreib-Zugriff auf Register der Grafikk.
|
||||
|
||||
// Copy Konstrutkor unterbinden
|
||||
CGA(const CGA& copy);
|
||||
CGA(const CGA& copy) = delete;
|
||||
|
||||
public:
|
||||
const char* CGA_START; // Startadresse des Buldschirmspeichers
|
||||
// NOTE: I change CGA_START to this const because I think the address should be constant and macro-like,
|
||||
// not the data at this address (we want that data to change).
|
||||
static const unsigned int CGA_START = 0xb8000U;
|
||||
|
||||
// Konstruktur mit Initialisierung der Ports
|
||||
CGA() : index_port(0x3d4), data_port(0x3d5) {
|
||||
CGA_START = (const char*)0xb8000;
|
||||
|
||||
// NOTE: I added this
|
||||
this->setpos(0, 0);
|
||||
}
|
||||
@ -67,7 +67,7 @@ public:
|
||||
// NOTE: I added this
|
||||
typedef struct {
|
||||
char cga_char;
|
||||
char cga_attribute;
|
||||
unsigned char cga_attribute;
|
||||
} cga_char_t;
|
||||
typedef struct {
|
||||
cga_char_t cga_line[COLUMNS];
|
||||
@ -80,7 +80,7 @@ public:
|
||||
void setpos(int x, int y);
|
||||
|
||||
// Abfragen der Cursorpostion
|
||||
void getpos(int& x, int& y);
|
||||
void getpos(int& x, int& y) const;
|
||||
|
||||
// Anzeige eines Zeichens mit Attribut an einer bestimmten Stelle
|
||||
void show(int x, int y, char character, unsigned char attrib = STD_ATTR);
|
||||
@ -96,7 +96,7 @@ public:
|
||||
virtual void clear();
|
||||
|
||||
// Hilfsfunktion zur Erzeugung eines Attribut-Bytes
|
||||
unsigned char attribute(CGA::color bg, CGA::color fg, bool blink);
|
||||
static unsigned char attribute(CGA::color bg, CGA::color fg, bool blink);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
* verwendet werden, um eine Ausgabe zu erzwingen. *
|
||||
*****************************************************************************/
|
||||
void CGA_Stream::flush() {
|
||||
print(buffer, pos, attribute(this->color_bg, this->color_fg, this->blink));
|
||||
print((char*)buffer, pos, attribute(this->color_bg, this->color_fg, this->blink));
|
||||
|
||||
// TODO: Should not be reset like this
|
||||
// Flushing resets attributes
|
||||
|
||||
@ -21,35 +21,28 @@
|
||||
// NOTE: I added this
|
||||
class fgc {
|
||||
public:
|
||||
fgc() : fg(CGA::LIGHT_GREY) {};
|
||||
fgc(CGA::color fg) : fg(fg) {};
|
||||
fgc() : fg(CGA::LIGHT_GREY) {}
|
||||
fgc(CGA::color fg) : fg(fg) {}
|
||||
CGA::color fg;
|
||||
};
|
||||
class bgc {
|
||||
public:
|
||||
bgc() : bg(CGA::BLACK) {};
|
||||
bgc(CGA::color bg) : bg(bg) {};
|
||||
bgc() : bg(CGA::BLACK) {}
|
||||
bgc(CGA::color bg) : bg(bg) {}
|
||||
CGA::color bg;
|
||||
};
|
||||
|
||||
// NOTE: I added this (changed this) to use BufferedCGA
|
||||
class CGA_Stream : public OutStream, public BufferedCGA {
|
||||
// class CGA_Stream : public OutStream, public CGA {
|
||||
|
||||
private:
|
||||
CGA_Stream(CGA_Stream& copy); // Verhindere Kopieren
|
||||
CGA_Stream(CGA_Stream& copy) = delete; // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
CGA::color color_fg;
|
||||
CGA::color color_bg;
|
||||
bool blink;
|
||||
|
||||
CGA_Stream() : OutStream(), BufferedCGA() {
|
||||
// CGA_Stream() : OutStream(), CGA() {
|
||||
color_fg = CGA::LIGHT_GREY;
|
||||
color_bg = CGA::BLACK;
|
||||
blink = false;
|
||||
|
||||
CGA_Stream() : color_fg(CGA::LIGHT_GREY), color_bg(CGA::BLACK), blink(false) {
|
||||
flush();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user