?? hardware.c
字號:
{ ulLines = ulDelta; } // calc the start out position ulOutPos = ulLastPos; // start to output upper left corner of window Home(OUTPUT_WINDOW); // while not end reached... ClrLines(wWindow[OUTPUT_WINDOW].y,ulLines); while(ulLines--) { SetForegroundColor(aBuffers[ulOutPos].usForegroundColor); SetBackgroundColor(aBuffers[ulOutPos].usBackgroundColor); Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulOutPos].buffer); ResetColor(); ulOutPos = (ulOutPos+1)%LINES_IN_BUFFER; } if(aBuffers[ulInPos].buffer[0]==':') { ClrLines(wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].cy-1,1); wWindow[OUTPUT_WINDOW].usCurY = wWindow[OUTPUT_WINDOW].cy-1; SetForegroundColor(aBuffers[ulInPos].usForegroundColor); SetBackgroundColor(aBuffers[ulInPos].usBackgroundColor); Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulInPos].buffer); ResetColor(); wWindow[OUTPUT_WINDOW].usCurX = strlen(aBuffers[ulInPos].buffer)+1; } //LEAVE_FUNC(); return TRUE;}//*************************************************************************// ResetColor()////*************************************************************************void ResetColor(void){ SetForegroundColor(COLOR_FOREGROUND); SetBackgroundColor(COLOR_BACKGROUND);}// OUTPUT handlers//*************************************************************************// PrintGraf()////*************************************************************************void PrintGraf(ULONG x,ULONG y,UCHAR c){ ohandlers.PrintGraf(x,y,c);}//*************************************************************************// Flush()//// Flush the stream of chars to PrintGraf()//*************************************************************************void Flush(void){ //ENTER_FUNC(); if(ohandlers.Flush) ohandlers.Flush(); //LEAVE_FUNC();}//*************************************************************************// 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(); for(i=0;p[i]!=0;i++) { if((UCHAR)p[i]>=0x20 && (UCHAR)p[i]<0x80) { PrintGraf(x+i,y,p[i]); } } Flush();// //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);}//*************************************************************************// ClrLines()//// clear a couple of lines//*************************************************************************void ClrLines(ULONG line,ULONG count){ if(ohandlers.ClrLines) { ohandlers.ClrLines(line,count); } else { ULONG i; for(i=0;i<count;i++) ClrLine(line + i); }}//*************************************************************************// 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){ ClrLines(wWindow[Window].y,wWindow[Window].cy); Home(Window);}//*************************************************************************// PrintCaption()////*************************************************************************void PrintCaption(void){ const char title[]=" PrivateICE system level debugger (LINUX) (c) 1998-2001 PrivateTOOLS "; ClrLines(0,1); PutChar((LPSTR)title, (GLOBAL_SCREEN_WIDTH-sizeof(title))/2, 0);}//*************************************************************************// PrintTemplate()//// print the screen template//*************************************************************************void PrintTemplate(void){ USHORT j; //ENTER_FUNC(); ResetColor(); for(j=0;j<4;j++) { ClrLines(wWindow[j].y,wWindow[j].cy); } SetForegroundColor(COLOR_TEXT); SetBackgroundColor(COLOR_CAPTION); PrintCaption(); ClrLines(wWindow[DATA_WINDOW].y-1,1); ClrLines(wWindow[SOURCE_WINDOW].y-1,1); ClrLines(wWindow[OUTPUT_WINDOW].y-1,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; ENTER_FUNC(); if(!bConsoleIsInitialized) { DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "console is not initialized!\n"); goto Quit; } if(Window > OUTPUT_WINDOW_UNBUFFERED) { DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "not a window!\n"); goto Quit; } // the OUTPUT_WINDOW is specially handled if(Window == OUTPUT_WINDOW) { DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "OUTPUT_WINDOW\n"); if(AddToRingBuffer(p)) { DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "checking ring buffer\n"); CheckRingBuffer(); } else { DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "outputting a line from ring buffer\n"); wWindow[OUTPUT_WINDOW].usCurX = 0; ClrLines(wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].usCurY,1); SetForegroundColor(aBuffers[ulInPos].usForegroundColor); SetBackgroundColor(aBuffers[ulInPos].usBackgroundColor); Print(OUTPUT_WINDOW_UNBUFFERED,aBuffers[ulInPos].buffer); ResetColor(); } } 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; } 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] = ' '; if(bOutput) PrintGraf(wWindow[Window].usCurX,wWindow[Window].y+wWindow[Window].usCurY,p[i]); wWindow[Window].usCurX++; } } // flush Flush(); }Quit: 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 memset((void*)&ohandlers,0,sizeof(ohandlers)); memset((void*)&ihandlers,0,sizeof(ihandlers)); DPRINT(PICE_DEBUG, DBT_HARDWARE, DBL_INFO, "TerminalMode = %d\n", eTerminalMode); 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) { // ohandlers.ClrLines is optional bResult = FALSE; } // check that inputhandlers were installed if( !ihandlers.GetKeyPolled || !ihandlers.FlushKeyboardQueue) { bResult = FALSE; } bConsoleIsInitialized = bResult; LEAVE_FUNC(); return bResult;}//*************************************************************************// ConsoleShutdown()//// exit terminal screen//*************************************************************************void ConsoleShutdown(void) { ENTER_FUNC(); 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 + -