📄 hardware.c
字号:
{
if(ohandlers.Flush)
ohandlers.Flush();
}
//*************************************************************************
// EnableScroll()
//
//*************************************************************************
void EnableScroll(USHORT Window)
{
ENTER_FUNC();
wWindow[Window].bScrollDisabled=FALSE;
LEAVE_FUNC();
}
//*************************************************************************
// DisableScroll()
//
//*************************************************************************
void DisableScroll(USHORT Window)
{
ENTER_FUNC();
wWindow[Window].bScrollDisabled=TRUE;
LEAVE_FUNC();
}
//*************************************************************************
// ShowCursor()
//
// show hardware cursor
//*************************************************************************
void ShowCursor(void)
{
ohandlers.ShowCursor();
}
//*************************************************************************
// HideCursor()
//
// hide hardware cursor
//*************************************************************************
void HideCursor(void)
{
ohandlers.HideCursor();
}
//*************************************************************************
// SetForegroundColor()
//
// set foreground color
//*************************************************************************
void SetForegroundColor(ECOLORS c)
{
// ENTER_FUNC();
ohandlers.SetForegroundColor(c);
// LEAVE_FUNC();
}
//*************************************************************************
// SetBackgroundColor()
//
// set background color
//*************************************************************************
void SetBackgroundColor(ECOLORS c)
{
// ENTER_FUNC();
ohandlers.SetBackgroundColor(c);
// LEAVE_FUNC();
}
//*************************************************************************
// PutChar()
//
// put a zero terminated string at position (x,y)
//*************************************************************************
void PutChar(LPSTR p,ULONG x,ULONG y)
{
ULONG i;
// ENTER_FUNC();
Acquire_Output_Lock();
for(i=0;p[i]!=0;i++)
{
if((UCHAR)p[i]>=0x20 && (UCHAR)p[i]<0x80)
{
PrintGraf(x+i,y,p[i]);
}
}
Flush();
Release_Output_Lock();
// LEAVE_FUNC();
}
//*************************************************************************
// CopyLineTo()
//
// copy a line from src to dest
//*************************************************************************
void CopyLineTo(USHORT dest,USHORT src)
{
ohandlers.CopyLineTo(dest,src);
}
//*************************************************************************
// InvertLine()
//
// invert a line on the screen
//*************************************************************************
void InvertLine(ULONG line)
{
ohandlers.InvertLine(line);
}
//*************************************************************************
// HatchLine()
//
// hatches a line on the screen
//*************************************************************************
void HatchLine(ULONG line)
{
ohandlers.HatchLine(line);
}
//*************************************************************************
// ClrLine()
//
// clear a line on the screen
//*************************************************************************
void ClrLine(ULONG line)
{
ohandlers.ClrLine(line);
}
//*************************************************************************
// ScrollUp()
//
// Scroll a specific window up one line
//*************************************************************************
void ScrollUp(USHORT Window)
{
USHORT i;
return;
if(!wWindow[Window].bScrollDisabled)
{
for(i=1;i<wWindow[Window].cy;i++)
{
CopyLineTo((USHORT)(wWindow[Window].y+i-1),(USHORT)(wWindow[Window].y+i));
}
ClrLine((USHORT)(wWindow[Window].y+wWindow[Window].cy-1));
}
}
//*************************************************************************
// Home()
//
// cursor to home position
//*************************************************************************
void Home(USHORT Window)
{
wWindow[Window].usCurX=0;
wWindow[Window].usCurY=0;
}
//*************************************************************************
// Clear()
//
// clear a specific window
//*************************************************************************
void Clear(USHORT Window)
{
ULONG j;
for(j=0;j<wWindow[Window].cy;j++)
{
ClrLine(wWindow[Window].y+j);
}
Home(Window);
}
//*************************************************************************
// PrintCaption()
//
//*************************************************************************
void PrintCaption(void)
{
const char title[]=" PrivateICE system level debugger (REACTOS) ";
SetForegroundColor(COLOR_TEXT);
SetBackgroundColor(COLOR_CAPTION);
ClrLine(0);
PutChar((LPSTR)title,
(GLOBAL_SCREEN_WIDTH-sizeof(title))/2,
0);
ResetColor();
}
//*************************************************************************
// PrintTemplate()
//
// print the screen template
//*************************************************************************
void PrintTemplate(void)
{
USHORT i,j;
ENTER_FUNC();
ResetColor();
for(j=0;j<4;j++)
{
for(i=wWindow[j].y;i<(wWindow[j].y+wWindow[j].cy);i++)
{
ClrLine(i);
}
}
PrintCaption();
SetForegroundColor(COLOR_TEXT);
SetBackgroundColor(COLOR_CAPTION);
ClrLine(wWindow[DATA_WINDOW].y-1);
ClrLine(wWindow[SOURCE_WINDOW].y-1);
ClrLine(wWindow[OUTPUT_WINDOW].y-1);
ResetColor();
ShowRunningMsg();
PrintLogo(TRUE);
LEAVE_FUNC();
}
//*************************************************************************
// PrintLogo()
//
//*************************************************************************
void PrintLogo(BOOLEAN bShow)
{
ohandlers.PrintLogo(bShow);
}
//*************************************************************************
// PrintCursor()
//
// emulate a blinking cursor block
//*************************************************************************
void PrintCursor(BOOLEAN bForce)
{
ohandlers.PrintCursor(bForce);
}
//*************************************************************************
// Print()
//
//*************************************************************************
void Print(USHORT Window,LPSTR p)
{
ULONG i;
DPRINT((11,"%s",p));
//ENTER_FUNC();
if(!bConsoleIsInitialized)
{
DPRINT((0,"Print(): console is not initialized!\n"));
//LEAVE_FUNC();
return;
}
// the OUTPUT_WINDOW is specially handled
if(Window == OUTPUT_WINDOW)
{
DPRINT((0,"Print(): OUTPUT_WINDOW\n"));
if(AddToRingBuffer(p))
{
DPRINT((0,"Print(): checking ring buffer\n"));
CheckRingBuffer();
}
else
{
DPRINT((0,"Print(): outputting a line from ring buffer\n"));
wWindow[OUTPUT_WINDOW].usCurX = 0;
ClrLine(wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].usCurY);
Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulInPos]);
}
}
else
{
BOOLEAN bOutput = TRUE;
if(Window == OUTPUT_WINDOW_UNBUFFERED)
{
Window = OUTPUT_WINDOW;
}
for(i=0;p[i]!=0;i++)
{
if(wWindow[Window].usCurX > (GLOBAL_SCREEN_WIDTH-1))
bOutput = FALSE;
// newline
if(p[i]=='\n')
{
wWindow[Window].usCurX = 0;
wWindow[Window].usCurY++;
if(wWindow[Window].usCurY>=wWindow[Window].cy)
{
wWindow[Window].usCurY=wWindow[Window].cy-1;
ScrollUp(Window);
}
if(wWindow[Window].bScrollDisabled==TRUE)break;
}
// backspace
else if(p[i]=='\b')
{
if(wWindow[Window].usCurX>0)
{
wWindow[Window].usCurX--;
if(bOutput)
PrintGraf(wWindow[Window].usCurX,wWindow[Window].y+wWindow[Window].usCurY,0x20);
}
}
// TAB
else if(p[i]=='\t')
{
if((wWindow[Window].usCurX + 4) < (GLOBAL_SCREEN_WIDTH-1))
{
wWindow[Window].usCurX += 4;
}
}
else
{
if((UCHAR)p[i]<0x20 && (UCHAR)p[i]>0x7f)
p[i]=0x20;
if(bOutput)
PrintGraf(wWindow[Window].usCurX,wWindow[Window].y+wWindow[Window].usCurY,p[i]);
wWindow[Window].usCurX++;
}
}
// flush
Flush();
}
//LEAVE_FUNC();
}
//*************************************************************************
// SaveGraphicsState()
//
//*************************************************************************
void SaveGraphicsState(void)
{
ohandlers.SaveGraphicsState();
}
//*************************************************************************
// RestoreGraphicsState()
//
//*************************************************************************
void RestoreGraphicsState(void)
{
ohandlers.RestoreGraphicsState();
}
//*************************************************************************
// SetWindowGeometry()
//
//*************************************************************************
void SetWindowGeometry(PVOID pWindow)
{
PICE_memcpy(wWindow,pWindow,sizeof(wWindow));
}
// INPUT handlers
//*************************************************************************
// GetKeyPolled()
//
//*************************************************************************
UCHAR GetKeyPolled(void)
{
return ihandlers.GetKeyPolled();
}
//*************************************************************************
// FlushKeyboardQueue()
//
//*************************************************************************
void FlushKeyboardQueue(void)
{
ihandlers.FlushKeyboardQueue();
}
//*************************************************************************
// ConsoleInit()
//
// init terminal screen
//*************************************************************************
BOOLEAN ConsoleInit(void)
{
BOOLEAN bResult = FALSE;
ENTER_FUNC();
// preset ohandlers and ihandler to NULL
PICE_memset((void*)&ohandlers,0,sizeof(ohandlers));
PICE_memset((void*)&ihandlers,0,sizeof(ihandlers));
switch(eTerminalMode)
{
case TERMINAL_MODE_HERCULES_GRAPHICS:
bResult = ConsoleInitHercules();
break;
case TERMINAL_MODE_HERCULES_TEXT:
break;
case TERMINAL_MODE_VGA_TEXT:
bResult = ConsoleInitVga();
break;
case TERMINAL_MODE_SERIAL:
bResult = ConsoleInitSerial();
break;
case TERMINAL_MODE_NONE:
default:
// fail
break;
}
// check that outputhandlers have all been set
// ohandlers.Flush may be zero on return
if( !ohandlers.ClrLine ||
!ohandlers.CopyLineTo ||
!ohandlers.HatchLine ||
!ohandlers.HideCursor ||
!ohandlers.InvertLine ||
!ohandlers.PrintCursor ||
!ohandlers.PrintGraf ||
!ohandlers.PrintLogo ||
!ohandlers.RestoreGraphicsState ||
!ohandlers.SaveGraphicsState ||
!ohandlers.SetBackgroundColor ||
!ohandlers.SetForegroundColor ||
!ohandlers.ShowCursor)
{
bResult = FALSE;
}
// check that inputhandlers were installed
if( !ihandlers.GetKeyPolled ||
!ihandlers.FlushKeyboardQueue)
{
bResult = FALSE;
}
LEAVE_FUNC();
bConsoleIsInitialized = bResult;
return bResult;
}
//*************************************************************************
// ConsoleShutdown()
//
// exit terminal screen
//*************************************************************************
void ConsoleShutdown(void)
{
ENTER_FUNC();
// sleep for a few seconds
KeStallExecutionProcessor(1000*5000);
switch(eTerminalMode)
{
case TERMINAL_MODE_HERCULES_GRAPHICS:
ConsoleShutdownHercules();
break;
case TERMINAL_MODE_HERCULES_TEXT:
break;
case TERMINAL_MODE_VGA_TEXT:
ConsoleShutdownVga();
break;
case TERMINAL_MODE_SERIAL:
ConsoleShutdownSerial();
break;
case TERMINAL_MODE_NONE:
default:
// fail
break;
}
LEAVE_FUNC();
}
// EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -