summaryrefslogtreecommitdiff
path: root/src/kernel/dev/vgatxt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/dev/vgatxt.cpp')
-rw-r--r--src/kernel/dev/vgatxt.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/kernel/dev/vgatxt.cpp b/src/kernel/dev/vgatxt.cpp
new file mode 100644
index 0000000..75071fb
--- /dev/null
+++ b/src/kernel/dev/vgatxt.cpp
@@ -0,0 +1,50 @@
+#include "vgatxt.h"
+
+#include <core/sys.h>
+#include <mem/mem.h>
+
+static uint16_t *video_memory = (uint16_t*)((size_t)K_HIGHHALF_ADDR + 0xB8000);
+
+vgatxt *text_display;
+
+vgatxt::vgatxt(node *parent) : display(parent) {
+ // nothing to do, really
+}
+
+int vgatxt::text_w() {
+ return 80;
+}
+
+int vgatxt::text_h() {
+ return 25;
+}
+
+void vgatxt::text_setcsr(int l, int c, bool visible) {
+ uint16_t cursor_location = l * 80 + c;
+ if (!visible) cursor_location = 10000;
+ outb(0x3D4, 14); //Sending high cursor byte
+ outb(0x3D5, cursor_location >> 8);
+ outb(0x3D4, 15); //Sending high cursor byte
+ outb(0x3D5, cursor_location);
+}
+
+void vgatxt::text_put(int l, int c, int ch, uint8_t fgcolor, uint8_t bgcolor) {
+ if (ch >= 0x80) ch = '?';
+ video_memory[l * 80 + c] = (char)ch | ((bgcolor << 4 | fgcolor) << 8);
+}
+
+void vgatxt::text_scroll(int n, uint8_t fgcolor, uint8_t bgcolor) {
+ //TODO: optimize
+ for (int i = 0; i < n; i++) {
+
+ uint16_t blank = (((bgcolor << 4) | fgcolor) << 8) | 0x20;
+ int j;
+ for (j = 0; j < 80*24; j++) {
+ video_memory[j] = video_memory[j+80];
+ }
+ for (j = 80*24; j < 80*25; j++) {
+ video_memory[j] = blank;
+ }
+
+ }
+}