📄 serial.c
字号:
void SetBackgroundColorSerial(ECOLORS col)
{
eBackgroundColor = col;
}
//*************************************************************************
// PrintGrafSerial()
//
//*************************************************************************
void PrintGrafSerial(ULONG x,ULONG y,UCHAR c)
{
// put this into memory
pScreenBufferSerial[y*GLOBAL_SCREEN_WIDTH + x] = c;
// put this into cache
if(ulFlushBufferPos == 0)
{
g_x = x;
g_y = y;
}
flush_buffer[ulFlushBufferPos++] = c;
}
//*************************************************************************
// FlushSerial()
//
//*************************************************************************
void FlushSerial(void)
{
PSERIAL_DATA_PACKET_PRINT pPrint;
PSERIAL_PACKET p;
pPrint = (PSERIAL_DATA_PACKET_PRINT)packet;
pPrint->type = PACKET_TYPE_PRINT;
pPrint->x = g_x;
pPrint->y = g_y;
pPrint->fgcol = eForegroundColor;
pPrint->bkcol = eBackgroundColor;
flush_buffer[ulFlushBufferPos++] = 0;
PICE_strcpy(pPrint->string,flush_buffer);
ulFlushBufferPos = 0;
p = AssemblePacket((PUCHAR)pPrint,sizeof(SERIAL_DATA_PACKET_PRINT)+PICE_strlen(flush_buffer));
SendPacket(p);
}
//*************************************************************************
// ShowCursorSerial()
//
// show hardware cursor
//*************************************************************************
void ShowCursorSerial(void)
{
PSERIAL_DATA_PACKET_CURSOR pCursor;
PSERIAL_PACKET p;
ENTER_FUNC();
bCursorEnabled = TRUE;
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
pCursor->type = PACKET_TYPE_CURSOR;
pCursor->state = (UCHAR)TRUE;
pCursor->x = (UCHAR)wWindow[OUTPUT_WINDOW].usCurX;
pCursor->y = (UCHAR)wWindow[OUTPUT_WINDOW].usCurY;
p = AssemblePacket((PUCHAR)pCursor,sizeof(SERIAL_DATA_PACKET_CURSOR));
SendPacket(p);
LEAVE_FUNC();
}
//*************************************************************************
// HideCursorSerial()
//
// hide hardware cursor
//*************************************************************************
void HideCursorSerial(void)
{
PSERIAL_DATA_PACKET_CURSOR pCursor;
PSERIAL_PACKET p;
ENTER_FUNC();
bCursorEnabled = FALSE;
pCursor = (PSERIAL_DATA_PACKET_CURSOR)packet;
pCursor->type = PACKET_TYPE_CURSOR;
pCursor->state = (UCHAR)TRUE;
p = AssemblePacket((PUCHAR)pCursor,sizeof(SERIAL_DATA_PACKET_CURSOR));
SendPacket(p);
LEAVE_FUNC();
}
//*************************************************************************
// CopyLineToSerial()
//
// copy a line from src to dest
//*************************************************************************
void CopyLineToSerial(USHORT dest,USHORT src)
{
NOT_IMPLEMENTED();
}
//*************************************************************************
// InvertLineSerial()
//
// invert a line on the screen
//*************************************************************************
void InvertLineSerial(ULONG line)
{
PSERIAL_DATA_PACKET_INVERTLINE pInvertLine;
PSERIAL_PACKET p;
pInvertLine = (PSERIAL_DATA_PACKET_INVERTLINE)packet;
pInvertLine->type = PACKET_TYPE_INVERTLINE;
pInvertLine->line = line;
p = AssemblePacket((PUCHAR)pInvertLine,sizeof(SERIAL_DATA_PACKET_INVERTLINE));
SendPacket(p);
}
//*************************************************************************
// HatchLineSerial()
//
// hatches a line on the screen
//*************************************************************************
void HatchLineSerial(ULONG line)
{
NOT_IMPLEMENTED();
}
//*************************************************************************
// ClrLineSerial()
//
// clear a line on the screen
//*************************************************************************
void ClrLineSerial(ULONG line)
{
PSERIAL_DATA_PACKET_CLRLINE pClrLine;
PSERIAL_PACKET p;
pClrLine = (PSERIAL_DATA_PACKET_CLRLINE)packet;
pClrLine->type = PACKET_TYPE_CLRLINE;
pClrLine->fgcol = eForegroundColor;
pClrLine->bkcol = eBackgroundColor;
pClrLine->line = line;
p = AssemblePacket((PUCHAR)pClrLine,sizeof(SERIAL_DATA_PACKET_CLRLINE));
SendPacket(p);
}
//*************************************************************************
// PrintLogoSerial()
//
//*************************************************************************
void PrintLogoSerial(BOOLEAN bShow)
{
NOT_IMPLEMENTED();
}
//*************************************************************************
// PrintCursorSerial()
//
// emulate a blinking cursor block
//*************************************************************************
void PrintCursorSerial(BOOLEAN bForce)
{
NOT_IMPLEMENTED();
}
//*************************************************************************
// SaveGraphicsStateSerial()
//
//*************************************************************************
void SaveGraphicsStateSerial(void)
{
// not implemented
}
//*************************************************************************
// RestoreGraphicsStateSerial()
//
//*************************************************************************
void RestoreGraphicsStateSerial(void)
{
// not implemented
}
// INPUT handlers
//*************************************************************************
// GetKeyPolledSerial()
//
//*************************************************************************
UCHAR GetKeyPolledSerial(void)
{
UCHAR ucResult;
PSERIAL_DATA_PACKET_POLL pPoll;
PSERIAL_PACKET p;
pPoll = (PSERIAL_DATA_PACKET_POLL)packet;
pPoll->type = PACKET_TYPE_POLL;
pPoll->major_version = PICE_MAJOR_VERSION;
pPoll->minor_version = PICE_MINOR_VERSION;
pPoll->build_number = PICE_BUILD;
p = AssemblePacket((PUCHAR)pPoll,sizeof(SERIAL_DATA_PACKET_POLL));
SendPacket(p);
ucResult = ucLastKeyRead;
ucLastKeyRead = 0;
return ucResult;
}
//*************************************************************************
// FlushKeyboardQueueSerial()
//
//*************************************************************************
void FlushKeyboardQueueSerial(void)
{
// not implemented
}
//*************************************************************************
// Connect()
//
//*************************************************************************
BOOLEAN Connect(USHORT xSize,USHORT ySize)
{
PSERIAL_DATA_PACKET_CONNECT pConnect;
PSERIAL_PACKET p;
pConnect = (PSERIAL_DATA_PACKET_CONNECT)packet;
pConnect->type = PACKET_TYPE_CONNECT;
pConnect->xsize = xSize;
pConnect->ysize = ySize;
p = AssemblePacket((PUCHAR)pConnect,sizeof(SERIAL_DATA_PACKET_CONNECT));
return SendPacketTimeout(p);
}
//*************************************************************************
// ConsoleInitSerial()
//
// init terminal screen
//*************************************************************************
BOOLEAN ConsoleInitSerial(void)
{
BOOLEAN bResult = FALSE;
ENTER_FUNC();
ohandlers.CopyLineTo = CopyLineToSerial;
ohandlers.PrintGraf = PrintGrafSerial;
ohandlers.Flush = FlushSerial;
ohandlers.ClrLine = ClrLineSerial;
ohandlers.InvertLine = InvertLineSerial;
ohandlers.HatchLine = HatchLineSerial;
ohandlers.PrintLogo = PrintLogoSerial;
ohandlers.PrintCursor = PrintCursorSerial;
ohandlers.SaveGraphicsState = SaveGraphicsStateSerial;
ohandlers.RestoreGraphicsState = RestoreGraphicsStateSerial;
ohandlers.ShowCursor = ShowCursorSerial;
ohandlers.HideCursor = HideCursorSerial;
ohandlers.SetForegroundColor = SetForegroundColorSerial;
ohandlers.SetBackgroundColor = SetBackgroundColorSerial;
ihandlers.GetKeyPolled = GetKeyPolledSerial;
ihandlers.FlushKeyboardQueue = FlushKeyboardQueueSerial;
SetWindowGeometry(wWindowSerial);
GLOBAL_SCREEN_WIDTH = 80;
GLOBAL_SCREEN_HEIGHT = 60;
pScreenBufferSerial = PICE_malloc(FRAMEBUFFER_SIZE, NONPAGEDPOOL);
if(pScreenBufferSerial)
{
bResult = TRUE;
EmptyRingBuffer();
SetupSerial(1,115200);
// connect to terminal, if none's there, we give up
bResult = Connect(GLOBAL_SCREEN_WIDTH,GLOBAL_SCREEN_HEIGHT);
if(bResult)
{
GetKeyPolledSerial();
}
}
LEAVE_FUNC();
return bResult;
}
//*************************************************************************
// ConsoleShutdownSerial()
//
// exit terminal screen
//*************************************************************************
void ConsoleShutdownSerial(void)
{
ENTER_FUNC();
Connect(80,25);
FlushSerialBuffer();
if(pScreenBufferSerial)
PICE_free(pScreenBufferSerial);
LEAVE_FUNC();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -