summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-11-11 10:10:27 +0100
committerAlexis211 <alexis211@gmail.com>2009-11-11 10:10:27 +0100
commit35bab823d752686709b62be75e8305cbd7549e90 (patch)
tree02de9cc4a89ed269ac62413c7f48f52bcb314477
parent7292b995d4f7bfea699e44ed335d7cc1616c1132 (diff)
downloadMelon-35bab823d752686709b62be75e8305cbd7549e90.tar.gz
Melon-35bab823d752686709b62be75e8305cbd7549e90.zip
More work
-rw-r--r--Source/Kernel/Devices/Display/Display.proto.h2
-rw-r--r--Source/Kernel/Devices/Display/GraphicDisplay.proto.cpp65
-rw-r--r--Source/Kernel/Devices/Display/GraphicDisplay.proto.h14
-rw-r--r--Source/Kernel/Devices/Display/VESADisplay.class.cpp43
-rw-r--r--Source/Kernel/Devices/Display/VESADisplay.class.h2
5 files changed, 103 insertions, 23 deletions
diff --git a/Source/Kernel/Devices/Display/Display.proto.h b/Source/Kernel/Devices/Display/Display.proto.h
index bccf013..8401e0b 100644
--- a/Source/Kernel/Devices/Display/Display.proto.h
+++ b/Source/Kernel/Devices/Display/Display.proto.h
@@ -7,8 +7,6 @@
namespace Disp { struct mode_t; }
-class VirtualTerminal;
-
class Display : public Device {
public:
virtual ~Display() {}
diff --git a/Source/Kernel/Devices/Display/GraphicDisplay.proto.cpp b/Source/Kernel/Devices/Display/GraphicDisplay.proto.cpp
index 5e2818f..3e1264e 100644
--- a/Source/Kernel/Devices/Display/GraphicDisplay.proto.cpp
+++ b/Source/Kernel/Devices/Display/GraphicDisplay.proto.cpp
@@ -4,24 +4,32 @@
u32int consoleColor[16] = {
0x00000000, // 0 == black
- 0x00000077, // 1 == dark blue
- 0x00007700, // 2 == dark green
- 0x00007777, // 3 == dark cyan
- 0x00770000, // 4 == dark red
- 0x00770077, // 5 == dark magenta
- 0x00777700, // 6 == dark orange
- 0x00777777, // 7 == light grey
- 0x00444444, // 8 == dark grey
- 0x000000FF, // 9 == bright blue
- 0x0000FF00, // A == bright green
- 0x0000FFFF, // B == bright cyan
- 0x00FF0000, // C == bright red
- 0x00FF00FF, // D == bright yellow
+ 0x000000AA, // 1 == dark blue
+ 0x0000AA00, // 2 == dark green
+ 0x0000AAAA, // 3 == dark cyan
+ 0x00AA0000, // 4 == dark red
+ 0x00AA00AA, // 5 == dark magenta
+ 0x00AA5500, // 6 == dark orange
+ 0x00999999, // 7 == light grey
+ 0x00555555, // 8 == dark grey
+ 0x005555FF, // 9 == bright blue
+ 0x0055FF55, // A == bright green
+ 0x0055FFFF, // B == bright cyan
+ 0x00FF5555, // C == bright red
+ 0x00FF55FF, // D == bright yellow
0x00FFFF00, // E == bright orange
0x00FFFFFF, // F == white
};
void GraphicDisplay::putChar(u16int line, u16int col, WChar c, u8int color) {
+ drawChar(line, col, c, color);
+ if (line == m_csrBuff.line and col == m_csrBuff.col) {
+ getCsrBuff();
+ drawCsr();
+ }
+}
+
+void GraphicDisplay::drawChar(u16int line, u16int col, WChar c, u8int color) {
u8int ch = c.toAscii();
if (ch == 0) return;
@@ -39,10 +47,35 @@ void GraphicDisplay::putChar(u16int line, u16int col, WChar c, u8int color) {
}
void GraphicDisplay::moveCursor(u16int line, u16int col) {
+ putCsrBuff();
+ m_csrBuff.line = line; m_csrBuff.col = col;
+ getCsrBuff();
+ drawCsr();
+}
+
+//************ CURSOR HANDLING
+void GraphicDisplay::getCsrBuff() {
+ if (m_csrBuff.col < 0 or m_csrBuff.line < 0) return;
+ for (int x = 0; x < C_FONT_WIDTH; x++) {
+ for (int y = 0; y < C_FONT_HEIGHT; y++) {
+ m_csrBuff.buff[x][y] = getPix((m_csrBuff.col * C_FONT_WIDTH) + x, (m_csrBuff.line * C_FONT_HEIGHT) + y);
+ }
+ }
+}
+
+void GraphicDisplay::putCsrBuff() {
+ if (m_csrBuff.col < 0 or m_csrBuff.line < 0) return;
+ for (int x = 0; x < C_FONT_WIDTH; x++) {
+ for (int y = 0; y < C_FONT_HEIGHT; y++) {
+ putPix((m_csrBuff.col * C_FONT_WIDTH) + x, (m_csrBuff.line * C_FONT_HEIGHT) + y, m_csrBuff.buff[x][y]);
+ }
+ }
+}
- //draw some cursor
+void GraphicDisplay::drawCsr() {
+ if (m_csrBuff.col < 0 or m_csrBuff.line < 0) return;
for (int x = 0; x < C_FONT_WIDTH; x++) {
- putPix((col * C_FONT_WIDTH) + x, (line * C_FONT_HEIGHT) + 14, 0x00FFFFFF);
- putPix((col * C_FONT_WIDTH) + x, (line * C_FONT_HEIGHT) + 15, 0x00000000);
+ putPix((m_csrBuff.col * C_FONT_WIDTH) + x, (m_csrBuff.line * C_FONT_HEIGHT) + 14, 0x00FFFFFF);
+ putPix((m_csrBuff.col * C_FONT_WIDTH) + x, (m_csrBuff.line * C_FONT_HEIGHT) + 15, 0x00000000);
}
}
diff --git a/Source/Kernel/Devices/Display/GraphicDisplay.proto.h b/Source/Kernel/Devices/Display/GraphicDisplay.proto.h
index 35bbdae..9608ada 100644
--- a/Source/Kernel/Devices/Display/GraphicDisplay.proto.h
+++ b/Source/Kernel/Devices/Display/GraphicDisplay.proto.h
@@ -10,8 +10,22 @@ extern u32int consoleColor[16];
#define C_FONT_HEIGHT 16
class GraphicDisplay : public Display {
+ struct {
+ int line, col;
+ u32int buff[C_FONT_WIDTH][C_FONT_HEIGHT];
+ } m_csrBuff;
+
+ //Cursor handling
+ void getCsrBuff();
+ void putCsrBuff();
+ void drawCsr();
+
public:
+ GraphicDisplay() { m_csrBuff.line = -1; m_csrBuff.col = -1; }
+
virtual void putChar(u16int line, u16int col, WChar c, u8int color);
+ virtual void drawChar(u16int line, u16int col, WChar c, u8int color);
+
virtual void moveCursor(u16int line, u16int col);
};
diff --git a/Source/Kernel/Devices/Display/VESADisplay.class.cpp b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
index 6e46273..4c3041a 100644
--- a/Source/Kernel/Devices/Display/VESADisplay.class.cpp
+++ b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
@@ -52,6 +52,7 @@ void VESADisplay::getModes(Vector<mode_t> &to) {
if ((mode.attributes & 0x90) != 0x90) continue;
if (mode.memory_model != 4 and mode.memory_model != 6) continue;
+ if (mode.bpp != 24) continue;
mode_t m; m.device = this;
m.textCols = mode.Xres / C_FONT_WIDTH; m.textRows = mode.Yres / C_FONT_HEIGHT;
m.identifier = modes[i];
@@ -94,24 +95,51 @@ void VESADisplay::putPix(u16int x, u16int y, u32int c) {
if (m_currMode.bpp == 24) {
*p.d = (*p.d & 0xFF000000) | c;
} else if (m_currMode.bpp == 15) {
-
+ u32int r = (c & 0x00FF0000 >> 16) * 32 / 256,
+ g = (c & 0x0000FF00 >> 8) * 32 / 256,
+ b = (c & 0x000000FF) * 32 / 256;
+ *p.w = (r << 10) | (g << 5) | b;
}
}
u32int VESADisplay::getPix(u16int x, u16int y) {
+ if (x >= m_currMode.Xres or y >= m_currMode.Yres) return 0;
u32int ret;
- u8int* a = memPos(x, y);
- ret = (a[2] << 16) | (a[1] << 8) | a[0];
+ union {
+ u8int* c;
+ u16int* w;
+ u32int* d;
+ } p = {memPos(x, y)};
+ if (m_currMode.bpp == 24) {
+ ret = *p.d & 0x00FFFFFF;
+ } else if (m_currMode.bpp == 15) {
+ u32int r = ((*p.w >> 10) & 0x1F) * 256 / 32,
+ g = ((*p.w >> 5) & 0x1F) * 256 / 32,
+ b = (*p.w & 0x1F) * 256 / 32;
+ return (r << 16) | (g << 8) | b;
+ }
return ret;
}
//Advanced functions
-void VESADisplay::putChar(u16int line, u16int col, WChar c, u8int color) {
+void VESADisplay::drawChar(u16int line, u16int col, WChar c, u8int color) {
u8int ch = c.toAscii();
if (ch == 0) return;
u16int sx = col * C_FONT_WIDTH, sy = line * C_FONT_HEIGHT;
u32int fgcolor = consoleColor[color & 0xF], bgcolor = consoleColor[(color >> 4) & 0xF];
+ if (m_pixWidth == 2) {
+ u32int r = (fgcolor & 0x00FF0000 >> 16) * 32 / 256,
+ g = (fgcolor & 0x0000FF00 >> 8) * 32 / 256,
+ b = (fgcolor & 0x000000FF) * 32 / 256;
+ fgcolor = (r << 10) | (g << 5) | b;
+ r = (bgcolor & 0x00FF0000 >> 16) * 32 / 256,
+ g = (bgcolor & 0x0000FF00 >> 8) * 32 / 256,
+ b = (bgcolor & 0x000000FF) * 32 / 256;
+ bgcolor = (r << 10) | (g << 5) | b;
+ }
+
+
int y = 0;
for (u8int* p = memPos(sx, sy); p < memPos(sx, sy + C_FONT_HEIGHT); p += m_currMode.pitch) {
union {
@@ -127,6 +155,13 @@ void VESADisplay::putChar(u16int line, u16int col, WChar c, u8int color) {
*pos.d = (*pos.d & 0xFF000000) | ((pixs & 1) != 0 ? fgcolor : bgcolor);
pixs = pixs >> 1;
}
+ } else if (m_pixWidth == 2) {
+ *pos.w = bgcolor;
+ for (int x = 0; x < 8; x++) {
+ pos.c -= m_pixWidth;
+ *pos.w = ((pixs & 1) != 0 ? fgcolor : bgcolor);
+ pixs = pixs >> 1;
+ }
}
y++;
}
diff --git a/Source/Kernel/Devices/Display/VESADisplay.class.h b/Source/Kernel/Devices/Display/VESADisplay.class.h
index 606c115..04c8e90 100644
--- a/Source/Kernel/Devices/Display/VESADisplay.class.h
+++ b/Source/Kernel/Devices/Display/VESADisplay.class.h
@@ -67,7 +67,7 @@ class VESADisplay : public GraphicDisplay {
u32int getPix(u16int x, u16int y);
//Advanced graphical functions, recoded for being optimized
- virtual void putChar(u16int line, u16int col, WChar c, u8int color);
+ virtual void drawChar(u16int line, u16int col, WChar c, u8int color);
};
#endif