| Zeile 12: | Zeile 12: | ||
void main() { | void main() { | ||
// Textausgabe | // Textausgabe | ||
| − | screen << "Willkommen im C++-TestKernel!"; | + | screen << color::blue << "Willkommen im C++-TestKernel!"; |
} | } | ||
</cpp> | </cpp> | ||
| Zeile 23: | Zeile 23: | ||
#ifndef VIDEO_H | #ifndef VIDEO_H | ||
#define VIDEO_H | #define VIDEO_H | ||
| + | |||
| + | namespace color | ||
| + | { | ||
| + | enum type | ||
| + | { | ||
| + | /* siehe [[Textausgabe]] */ | ||
| + | black = 0x00, | ||
| + | blue = 0x01, | ||
| + | green = 0x02, | ||
| + | cyan = 0x03, | ||
| + | red = 0x04, | ||
| + | magenta = 0x05, | ||
| + | brown = 0x06, | ||
| + | light_gray = 0x07, | ||
| + | dark_gray = 0x08, | ||
| + | light_blue = 0x09, | ||
| + | light_green = 0x0A, | ||
| + | light_cyan = 0x0B, | ||
| + | light_red = 0x0C, | ||
| + | light_magenta = 0x0D, | ||
| + | yellow = 0x0E, | ||
| + | white = 0x0F | ||
| + | }; | ||
| + | } | ||
class Video | class Video | ||
| Zeile 38: | Zeile 62: | ||
// Textausgabe | // Textausgabe | ||
Video& operator << (const char* s); | Video& operator << (const char* s); | ||
| + | |||
| + | // Vordergrund | ||
| + | Video& operator << (color::type color); | ||
// Ausgabe eines einzelnen Zeichens | // Ausgabe eines einzelnen Zeichens | ||
void put(char c); | void put(char c); | ||
| − | |||
| − | |||
| − | |||
private: | private: | ||
| Zeile 74: | Zeile 98: | ||
Video screen; | Video screen; | ||
| − | Video::Video() | + | Video::Video() |
| − | + | : pos(0), off(0), screen_color(0), videomem((unsigned short*) 0xb8000) | |
| − | + | { | |
| − | + | *this << color::light_gray; | |
| − | |||
| − | pos | ||
| − | |||
| − | |||
| − | |||
| − | |||
//Bildschirm leeren | //Bildschirm leeren | ||
| Zeile 107: | Zeile 125: | ||
put(*s++); | put(*s++); | ||
| + | return *this; | ||
| + | } | ||
| + | |||
| + | Video& Video::operator << (color::type color){ | ||
| + | screen_color = (color << 12) | (screen_color & 0x0F00); | ||
return *this; | return *this; | ||
} | } | ||
| Zeile 125: | Zeile 148: | ||
videomem[off + pos] = (unsigned char)c | screen_color; | videomem[off + pos] = (unsigned char)c | screen_color; | ||
pos++; | pos++; | ||
| − | |||
| − | |||
| − | |||
| − | |||
} | } | ||
</cpp> | </cpp> | ||