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));
}
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;
}
}

View File

@ -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);
}
}

View File

@ -25,9 +25,7 @@
#include "platform.h"
#include <libmaxsi/string.h>
#include <libmaxsi/memory.h>
#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
}
}

View File

@ -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;
}