?? m6845vgapep.c
字號:
/******************************************************************************* vgaDelLeftChar - delete the character to the left side of the cursor** RETURNS: N/A*/LOCAL void vgaDelLeftChar ( FAST VGA_CON_DEV * pVgaConDv /* pointer to the vga descriptor */ ) { FAST UINT16 erase; /* erase character with attributes */ erase = (pVgaConDv->defAttrib << 8) + ' ' ; if (pVgaConDv->autoWrap || pVgaConDv->ncol > 0) { pVgaConDv->col--; pVgaConDv->curChrPos -= CHR; } *(UINT16 *)pVgaConDv->curChrPos = erase; }/******************************************************************************* vgaCarriageReturn - do a carriage return on the monitor** RETURNS: N/A*/LOCAL void vgaCarriageReturn ( FAST VGA_CON_DEV * pVgaConDv /* pointer to the vga descriptor */ ) { pVgaConDv->curChrPos -= pVgaConDv->col * CHR; pVgaConDv->col = 0; }/******************************************************************************* vgaBackSpace - do a back space on the monitor** RETURNS: N/A*/LOCAL void vgaBackSpace ( FAST VGA_CON_DEV * pVgaConDv /* pointer to the vga descriptor */ ) { if (pVgaConDv->autoWrap || pVgaConDv->ncol > 0) { pVgaConDv->col--; pVgaConDv->curChrPos -= CHR; } if (pVgaConDv->col < 0) { pVgaConDv->col = pVgaConDv->ncol - 1; pVgaConDv->row--; pVgaConDv->scrollCheck = TRUE; } }/******************************************************************************* vgaTab - do a tab on the monitor** RETURNS: N/A*/LOCAL void vgaTab ( FAST VGA_CON_DEV * pVgaConDv /* pointer to the vga descriptor */ ) { int ix; for (ix = pVgaConDv->col + 1; ix < 80; ix++) { if (pVgaConDv->tab_stop [ix]) { pVgaConDv->col = ix; break; } } if (pVgaConDv->autoWrap && ix >= 80) { pVgaConDv->col = 0; pVgaConDv->row++; pVgaConDv->scrollCheck = TRUE; } pVgaConDv->curChrPos = ( pVgaConDv->memBase + pVgaConDv->row * pVgaConDv->ncol * CHR + pVgaConDv->col * CHR) ; }/******************************************************************************** vgaLineFeed - do a line feed on the monitor** RETURNS: N/A*/LOCAL void vgaLineFeed ( FAST VGA_CON_DEV * pVgaConDv /* pointer to the vga descriptor */ ) { pVgaConDv->curChrPos += pVgaConDv->ncol * CHR; pVgaConDv->row++; pVgaConDv->scrollCheck = TRUE; }/******************************************************************************** vgaCursorPos - Put the cursor at a specified location** RETURNS: N/A*/LOCAL void vgaCursorPos ( FAST UINT16 pos /* position of the cursor */ ) { sysOutByte ((int) CTRL_SEL_REG, 0x0e); sysOutByte ((int) CTRL_VAL_REG, (pos >> 8) & 0xff); sysOutByte ((int) CTRL_SEL_REG, 0x0f); sysOutByte ((int) CTRL_VAL_REG, pos & 0xff); return; }/******************************************************************************** vgaCursorOn - switch the cursor on** RETURNS: N/A*/LOCAL void vgaCursorOn (void) { sysOutByte ((int) CTRL_SEL_REG, 0x0a); sysOutByte ((int) CTRL_VAL_REG, curSt & ~0x20); sysOutByte ((int) CTRL_SEL_REG, 0x0b); sysOutByte ((int) CTRL_VAL_REG, curEd); return; }/******************************************************************************** vgacursoroff - swith the cursor off** RETURNS: N/A*/LOCAL void vgaCursorOff (void) { sysOutByte ((int) CTRL_SEL_REG, 0x0a); sysOutByte ((int) CTRL_VAL_REG, 0x20); sysOutByte ((int) CTRL_SEL_REG, 0x0b); sysOutByte ((int) CTRL_VAL_REG, 0x00); return; }/********************************************************************************* vgaWriteString - Write Character string to VGA Display* * This function does the write to the vga routine. This routine is provided as* transmitter startup routine when tyDevInit is called.** RETURNS: number of bytes written to the screen** NOMANUAL*/int vgaWriteString ( FAST PC_CON_DEV * pPcCoDv /* pointer to the console descriptor */ ) { int dummy; UCHAR ch; FAST int nBytes; FAST UCHAR atr; FAST RING_ID ringId = pPcCoDv->tyDev.wrtBuf; FAST VGA_CON_DEV * pVgaConDv = pPcCoDv->vs; pPcCoDv->tyDev.wrtState.busy = TRUE; atr = pVgaConDv->curAttrib; nBytes = 0; /* check if we need to output XON/XOFF for the read side */ if (pPcCoDv->tyDev.wrtState.xoff || pPcCoDv->tyDev.wrtState.flushingWrtBuf) { pPcCoDv->tyDev.wrtState.busy = FALSE; return nBytes; } while (RNG_ELEM_GET (ringId,&ch,dummy) != 0) { nBytes++; /* increment the number of bytes */ /* If character is normal and printable */ if ( (pVgaConDv->escFlags == ESC_NORMAL) && (pVgaConDv->charSet [ch] != 0)) { *(UINT16 *)pVgaConDv->curChrPos = (atr << 8) + pVgaConDv->charSet [ch]; if (pVgaConDv->col == pVgaConDv->ncol - 1) { if (pVgaConDv->autoWrap) { vgaCarriageReturn (pVgaConDv); /* time to wrap */ vgaLineFeed (pVgaConDv); goto VGA_CHECK; /* go do the wrap check */ } } else { pVgaConDv->col++; pVgaConDv->curChrPos += CHR; continue; } } switch (ch) { case 0x07: /* BEL */ vgaConBeep (FALSE); continue; case 0x08: /* Back Space */ vgaBackSpace (pVgaConDv); continue; case '\t': /* TAB code */ vgaTab (pVgaConDv); continue; case '\n': /* LF code */ if ((pPcCoDv->tyDev.options & OPT_CRMOD) == OPT_CRMOD) vgaCarriageReturn (pVgaConDv); vgaLineFeed (pVgaConDv); goto VGA_CHECK; case 0x0b: /* VT code */ vgaLineFeed (pVgaConDv); goto VGA_CHECK; case 0x0c: /* Clear Screen code */ vgaClear (pVgaConDv, 2, ' '); continue; case 0x0d: /* CR code */ vgaCarriageReturn (pVgaConDv); continue;#ifdef INCLUDE_ANSI_ESC_SEQUENCE case 0x1b: /* escape character */ pVgaConDv->escFlags = ESC_ESC; continue; case 0x9b: /* escape brace */ pVgaConDv->escFlags = ESC_BRACE; continue;#endif /* INCLUDE_ANSI_ESC_SEQUENCE */ case 0x0e: /* set the character set to VT100 graphics */ pVgaConDv->charSet = vgaCharTable [GRAPHICS_VT100_SET]; continue; case 0x0f: /* set the character set to normal text set */ pVgaConDv->charSet = vgaCharTable [TEXT_SET]; continue; case 0x7f: /* special character for del */ vgaDelLeftChar (pVgaConDv); continue; }#ifdef INCLUDE_ANSI_ESC_SEQUENCE switch (pVgaConDv->escFlags) { int ix; /* to hold temp data */ case ESC_ESC: pVgaConDv->escFlags = ESC_NORMAL; switch (ch) { case '[': /* escape brace */ pVgaConDv->escFlags = ESC_BRACE; continue; case 'E': /* cr lf */ vgaCarriageReturn (pVgaConDv); vgaLineFeed (pVgaConDv); goto VGA_CHECK; case 'M': /* cursor up */ pVgaConDv->row --; vgaPutCursor (pVgaConDv); continue; case 'D': /* generate a linefeed */ vgaLineFeed (pVgaConDv); goto VGA_CHECK; case 'H': /* give tab */ vgaTab (pVgaConDv); continue; case 'Z': /* get device attribute */ vgaEscResponse (pPcCoDv,2); continue; case '7': /* save current attributes */ vgaSaveCurAttrib (pVgaConDv); continue; case '8': /* restore current attributes */ vgaRestAttrib (pVgaConDv); continue; case '(': /* set character set to text */ pVgaConDv->escFlags = ESC_SET_TEXT; continue; case ')': /* set character set to grapics set */ pVgaConDv->escFlags = ESC_SET_GPRAHICS; continue; case '#': /* goto ESC_HASH state */ pVgaConDv->escFlags = ESC_HASH; continue; case 'c': /* reset display */ pPcCoDv->ks->kbdHook (0); vgaStatInit (); vgaClear (pVgaConDv, 2, ' '); vgaCursorOn (); continue; case '>': /* set numeric mode */ pPcCoDv->ks->kbdFlags |= NUM; pPcCoDv->ks->kbdHook (1); continue; case '=': /* set non numeric mode */ pPcCoDv->ks->kbdFlags &= ~NUM; pPcCoDv->ks->kbdHook (1); continue; } continue; case ESC_BRACE: /* Got ESC [ */ for (ix = 0; ix < NPARS; ix++) pVgaConDv->escPara [ix] = 0; pVgaConDv->escParaCount = 0; pVgaConDv->escFlags = ESC_GET_PARAMS; if ( ch == '[') { pVgaConDv->escFlags = ESC_FUNC_KEY; continue; } /* if received ? in the escape sequence */ if ( (pVgaConDv->escQuestion = (ch == '?')) ) continue; case ESC_GET_PARAMS: /* get parameters */ if ( (ch == ';') && (pVgaConDv->escParaCount < NPARS -1)) { pVgaConDv->escParaCount++; continue; } else if (ch >= '0' && ch <= '9') { pVgaConDv->escPara[pVgaConDv->escParaCount] *= 10; pVgaConDv->escPara[pVgaConDv->escParaCount] += ch -'0'; continue; } else pVgaConDv->escFlags = ESC_GOT_PARAMS; case ESC_GOT_PARAMS: pVgaConDv->escFlags = ESC_NORMAL; switch (ch) { case 'h': /* set vga modes ESC [ n h */ vgaSetMode (pPcCoDv, TRUE); continue; case 'l': /* reset vga mode ESC [ n l */ vgaSetMode (pPcCoDv, FALSE); continue; case 'n': if (!pVgaConDv->escQuestion) { if (pVgaConDv->escPara [0] == 5) { /* status report */ vgaEscResponse (pPcCoDv,1); } else if ( pVgaConDv->escPara [0] == 6) { /* cursor position report */ vgaEscResponse (pPcCoDv,0); } continue; } } if (pVgaConDv->escQuestion) { pVgaConDv->escQuestion = FALSE; continue; } switch (ch) { case 'G': /* ESC [ n G :move cursor by columns */ if (pVgaConDv->escPara [0] > 0) pVgaConDv->escPara [0]--; pVgaConDv->col = pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'A': /* ESC [ n A :cursor move up */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->row -= pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'B': /* ESC [ n B :cursor move down */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->row += pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'C': /* ESC [ n C :cursor move right */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->col += pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'D': /* ESC [ n D :cursor move left */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->col -= pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'E': /* ESC [ n E :cursor move by n rows */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->row += pVgaConDv->escPara [0]; pVgaConDv->col = 0; vgaPutCursor (pVgaConDv); continue; case 'F': /* ESC [ n F :move cursor laterally */ if (pVgaConDv->escPara [0] == 0) pVgaConDv->escPara [0]++; pVgaConDv->row -= pVgaConDv->escPara [0]; pVgaConDv->col = 0; vgaPutCursor (pVgaConDv); continue; case 'd': /* ESC [ n d :move cursor vertically */ if (pVgaConDv->escPara [0] > 0) pVgaConDv->escPara [0]--; pVgaConDv->row = pVgaConDv->escPara [0]; vgaPutCursor (pVgaConDv); continue; case 'H': /* ESC [ n;n H :position the cursor */ case 'f': /* ESC [ n;n f :position the cursor */ if (pVgaConDv->escPara [0] > 0) pVgaConDv->escPara [0]--; if (pVgaConDv->escPara [1] > 0) pVgaConDv->escPara [1]--; pVgaConDv->row = pVgaConDv->escPara [0]; pVgaConDv->col = pVgaConDv->escPara [1]; vgaPutCursor (pVgaConDv); continue; case 'J': /* ESC [ n J :clear display */ vgaClear (pVgaConDv, pVgaConDv->escPara [0], ' '); continue; case 'K': /* ESC [ n K :clear Line */ vgaClearLine (pVgaConDv); continue; case 'L': /* ESC [ n L :insert Lines */ vgaInsertLine (pVgaConDv); continue; case 'M': /* ESC [ n M :delete lines */ vgaDelLines (pVgaConDv); continue; case 'P': /* ESC [ n P :delete on right side */ vgaDelRightChars (pVgaConDv, pVgaConDv->escPara [0]); continue; case 'c': /* ESC [ n c :get response from term */ if ( pVgaConDv->escPara [0] == 0 ) vgaEscResponse (pPcCoDv,2); continue; case 'g': /* ESC [ n g :give tabs */ if ( pVgaConDv->escPara [0] == 0 ) { vgaTab (pVgaConDv); } else if ( pVgaConDv->escPara [0] == 3) { pVgaConDv->tab_stop [0] = 0; pVgaConDv->tab_stop [1] = 0; pVgaConDv->tab_stop [2] = 0; pVgaConDv->tab_stop [3] = 0; pVgaConDv->tab_stop [4] = 0; } continue; case 'm': /* ESC [ m :set the attributes */ vgaSetAttrib (pVgaConDv); continue; case 'r': /* ESC [ n;n r : set scroll limits */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -