diff --git a/sortix/serialterminal.cpp b/sortix/serialterminal.cpp index f02a5a6b..d8615171 100644 --- a/sortix/serialterminal.cpp +++ b/sortix/serialterminal.cpp @@ -44,15 +44,14 @@ namespace Sortix UART::Write(InitMessage, Maxsi::String::Length(InitMessage)); } - size_t numvgaframes = 0; - bool isEsc; bool isEscDepress; int sigpending; + const bool ECHO_TO_VGA = true; + void Init() { - numvgaframes = 0; Reset(); isEsc = isEscDepress = false; @@ -118,51 +117,17 @@ namespace Sortix } Keyboard::QueueKeystroke(c); } - -#ifdef PLATFORM_SERIAL - // TODO: But this hack may be worse. - if ( numvgaframes ) - { - UART::RenderVGA((const uint16_t*) 0xB8000); - } -#endif } - void OnVGAFrameCreated() + void OnVGAModified() { - if ( numvgaframes++ == 0 ) - { - UART::WriteChar('\e'); - UART::WriteChar('['); - UART::WriteChar('l'); - } - } - - void OnVGAFrameDeleted() - { - if ( --numvgaframes == 0 ) - { - Reset(); - UART::WriteChar('\e'); - UART::WriteChar('['); - UART::WriteChar('h'); - } + UART::RenderVGA((const uint16_t*) 0xB8000); } size_t Print(void* /*user*/, const char* string, size_t stringlen) { - if ( numvgaframes ) - { - VGATerminal::Print(NULL, string, stringlen); -#ifdef PLATFORM_SERIAL - UART::RenderVGA((const uint16_t*) 0xB8000); -#endif - } - else - { - UART::Write(string, stringlen); - } - + if ( ECHO_TO_VGA ) { VGATerminal::Print(NULL, string, stringlen); } + UART::Write(string, stringlen); return stringlen; } } diff --git a/sortix/serialterminal.h b/sortix/serialterminal.h index 84aa8e09..7e47968c 100644 --- a/sortix/serialterminal.h +++ b/sortix/serialterminal.h @@ -32,8 +32,7 @@ namespace Sortix void Init(); void Reset(); void OnTick(); - void OnVGAFrameCreated(); - void OnVGAFrameDeleted(); + void OnVGAModified(); size_t Print(void* user, const char* string, size_t stringlen); } } diff --git a/sortix/uart.cpp b/sortix/uart.cpp index 37ff10ab..b367947f 100644 --- a/sortix/uart.cpp +++ b/sortix/uart.cpp @@ -25,9 +25,7 @@ #include "platform.h" #include #include -#ifdef PLATFORM_SERIAL #include "vga.h" -#endif #include "uart.h" using namespace Maxsi; @@ -68,11 +66,9 @@ namespace Sortix const nat BASE_BAUD = 1843200/16; const nat BOTH_EMPTY = LSR_TEMT | LSR_THRE; -#ifdef SORTIX_VGA_H const unsigned FrameWidth = 80; const unsigned FrameHeight = 25; uint16_t VGALastFrame[FrameWidth * FrameHeight]; -#endif nat ProbeBaud(nat Port) { @@ -103,9 +99,7 @@ namespace Sortix void Init() { -#ifdef SORTIX_VGA_H InvalidateVGA(); -#endif #ifdef JSSORTIX // This crashes the JS VM, so don't do it. @@ -208,7 +202,6 @@ namespace Sortix WriteChar(Num % 10); } -#ifdef SORTIX_VGA_H // Change from VGA color to another color system. nat ConversionTable[16] = { 0, 4, 2, 6, 1, 5, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7 }; @@ -327,6 +320,5 @@ namespace Sortix } } } -#endif } } diff --git a/sortix/vga.cpp b/sortix/vga.cpp index 37147088..c1d13275 100644 --- a/sortix/vga.cpp +++ b/sortix/vga.cpp @@ -70,6 +70,14 @@ namespace Sortix DevVGA::~DevVGA() { +#ifdef PLATFORM_SERIAL + // TODO: HACK: This is a hack that is unrelated to this file. + // This is a hack to make the cursor a proper color after the vga buffer + // has been radically modified. The best solution would be for the VGA + // to ANSI Escape Codes converter to keep track of colors and restoring + // them, but this will do for now. + Log::PrintF("\e[m"); +#endif } ssize_t DevVGA::Read(byte* dest, size_t count) @@ -87,6 +95,9 @@ namespace Sortix Maxsi::Memory::Copy(VGA::VGA + offset, src, count); offset = (offset + count) % VGA::VGA_SIZE; VGA::SetCursor(VGA::WIDTH, VGA::HEIGHT-1); +#ifdef PLATFORM_SERIAL + SerialTerminal::OnVGAModified(); +#endif return count; }