VGA now sort-of works under serial-connections.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-05 21:44:14 +01:00
parent 9e5b9e3767
commit 2c728fc1f1
4 changed files with 18 additions and 51 deletions

View File

@ -44,15 +44,14 @@ namespace Sortix
UART::Write(InitMessage, Maxsi::String::Length(InitMessage)); UART::Write(InitMessage, Maxsi::String::Length(InitMessage));
} }
size_t numvgaframes = 0;
bool isEsc; bool isEsc;
bool isEscDepress; bool isEscDepress;
int sigpending; int sigpending;
const bool ECHO_TO_VGA = true;
void Init() void Init()
{ {
numvgaframes = 0;
Reset(); Reset();
isEsc = isEscDepress = false; isEsc = isEscDepress = false;
@ -118,51 +117,17 @@ namespace Sortix
} }
Keyboard::QueueKeystroke(c); 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::RenderVGA((const uint16_t*) 0xB8000);
{
UART::WriteChar('\e');
UART::WriteChar('[');
UART::WriteChar('l');
}
}
void OnVGAFrameDeleted()
{
if ( --numvgaframes == 0 )
{
Reset();
UART::WriteChar('\e');
UART::WriteChar('[');
UART::WriteChar('h');
}
} }
size_t Print(void* /*user*/, const char* string, size_t stringlen) size_t Print(void* /*user*/, const char* string, size_t stringlen)
{ {
if ( numvgaframes ) if ( ECHO_TO_VGA ) { VGATerminal::Print(NULL, string, stringlen); }
{ UART::Write(string, stringlen);
VGATerminal::Print(NULL, string, stringlen);
#ifdef PLATFORM_SERIAL
UART::RenderVGA((const uint16_t*) 0xB8000);
#endif
}
else
{
UART::Write(string, stringlen);
}
return stringlen; return stringlen;
} }
} }

View File

@ -32,8 +32,7 @@ namespace Sortix
void Init(); void Init();
void Reset(); void Reset();
void OnTick(); void OnTick();
void OnVGAFrameCreated(); void OnVGAModified();
void OnVGAFrameDeleted();
size_t Print(void* user, const char* string, size_t stringlen); size_t Print(void* user, const char* string, size_t stringlen);
} }
} }

View File

@ -25,9 +25,7 @@
#include "platform.h" #include "platform.h"
#include <libmaxsi/string.h> #include <libmaxsi/string.h>
#include <libmaxsi/memory.h> #include <libmaxsi/memory.h>
#ifdef PLATFORM_SERIAL
#include "vga.h" #include "vga.h"
#endif
#include "uart.h" #include "uart.h"
using namespace Maxsi; using namespace Maxsi;
@ -68,11 +66,9 @@ namespace Sortix
const nat BASE_BAUD = 1843200/16; const nat BASE_BAUD = 1843200/16;
const nat BOTH_EMPTY = LSR_TEMT | LSR_THRE; const nat BOTH_EMPTY = LSR_TEMT | LSR_THRE;
#ifdef SORTIX_VGA_H
const unsigned FrameWidth = 80; const unsigned FrameWidth = 80;
const unsigned FrameHeight = 25; const unsigned FrameHeight = 25;
uint16_t VGALastFrame[FrameWidth * FrameHeight]; uint16_t VGALastFrame[FrameWidth * FrameHeight];
#endif
nat ProbeBaud(nat Port) nat ProbeBaud(nat Port)
{ {
@ -103,9 +99,7 @@ namespace Sortix
void Init() void Init()
{ {
#ifdef SORTIX_VGA_H
InvalidateVGA(); InvalidateVGA();
#endif
#ifdef JSSORTIX #ifdef JSSORTIX
// This crashes the JS VM, so don't do it. // This crashes the JS VM, so don't do it.
@ -208,7 +202,6 @@ namespace Sortix
WriteChar(Num % 10); WriteChar(Num % 10);
} }
#ifdef SORTIX_VGA_H
// Change from VGA color to another color system. // 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 }; 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
} }
} }

View File

@ -70,6 +70,14 @@ namespace Sortix
DevVGA::~DevVGA() 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) ssize_t DevVGA::Read(byte* dest, size_t count)
@ -87,6 +95,9 @@ namespace Sortix
Maxsi::Memory::Copy(VGA::VGA + offset, src, count); Maxsi::Memory::Copy(VGA::VGA + offset, src, count);
offset = (offset + count) % VGA::VGA_SIZE; offset = (offset + count) % VGA::VGA_SIZE;
VGA::SetCursor(VGA::WIDTH, VGA::HEIGHT-1); VGA::SetCursor(VGA::WIDTH, VGA::HEIGHT-1);
#ifdef PLATFORM_SERIAL
SerialTerminal::OnVGAModified();
#endif
return count; return count;
} }