diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-10 22:53:50 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-10 22:53:50 +0200 |
commit | 6f54758123abe9f137922df1e8d7e33835e9a9f2 (patch) | |
tree | e21b553a826c7ae67cc4b41ffde921e39ed4022b /src/vga.cc | |
parent | Add some compiler warnings (diff) | |
download | kernel.cpp-6f54758123abe9f137922df1e8d7e33835e9a9f2.tar.xz |
Update VGA cursor position on printk
Diffstat (limited to 'src/vga.cc')
-rw-r--r-- | src/vga.cc | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -15,6 +15,9 @@ VGA::VGA(vga_color fg, vga_color bg, uint32_t address) : color_fg(fg), color_bg( buffer[index].bg = color_bg; } } + + enable_cursor(14, 15); + update_cursor(); } void VGA::set_color(vga_color fg, vga_color bg) { @@ -29,6 +32,27 @@ void VGA::set_color(vga_color fg, vga_color bg) { } } +void VGA::enable_cursor(uint8_t start, uint8_t end) { + p_3d4.write(0x0a); + p_3d5.write((p_3d5.read() & 0xc0) | start); + + p_3d4.write(0x0b); + p_3d5.write((p_3d5.read() & 0xe0) | end); +} +void VGA::disable_cursor() { + p_3d4.write(0x0a); + p_3d5.write(0x20); +} +void VGA::update_cursor() { + const uint16_t pos = row * max_columns + column; + + p_3d4.write(0x0f); + p_3d5.write(static_cast<uint8_t>(pos & 0xff)); + + p_3d4.write(0x0e); + p_3d5.write(static_cast<uint8_t>((pos >> 8) & 0xff)); +} + void VGA::write(char c) { switch (c) { case '\n': |