ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

pccons.c
Go to the documentation of this file.
00001 /* $Id: pccons.c 53440 2011-08-25 09:44:21Z tkreuzer $
00002  *
00003  *  FreeLoader
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #include <freeldr.h>
00021 
00022 #define TEXTMODE_BUFFER      0xb8000
00023 #define TEXTMODE_BUFFER_SIZE 0x8000
00024 
00025 #define TEXT_COLS  80
00026 #define TEXT_LINES 25
00027 
00028 VOID
00029 PcConsPutChar(int Ch)
00030 {
00031   REGS Regs;
00032 
00033   /* If we are displaying a CR '\n' then do a LF also */
00034   if ('\n' == Ch)
00035     {
00036       /* Display the LF */
00037       PcConsPutChar('\r');
00038     }
00039 
00040   /* If we are displaying a TAB '\t' then display 8 spaces ' ' */
00041   if ('\t' == Ch)
00042     {
00043       /* Display the 8 spaces ' ' */
00044       PcConsPutChar(' ');
00045       PcConsPutChar(' ');
00046       PcConsPutChar(' ');
00047       PcConsPutChar(' ');
00048       PcConsPutChar(' ');
00049       PcConsPutChar(' ');
00050       PcConsPutChar(' ');
00051       PcConsPutChar(' ');
00052       return;
00053     }
00054 
00055   /* Int 10h AH=0Eh
00056    * VIDEO - TELETYPE OUTPUT
00057    *
00058    * AH = 0Eh
00059    * AL = character to write
00060    * BH = page number
00061    * BL = foreground color (graphics modes only)
00062    */
00063   Regs.b.ah = 0x0E;
00064   Regs.b.al = Ch;
00065   Regs.w.bx = 1;
00066   Int386(0x10, &Regs, &Regs);
00067 }
00068 
00069 BOOLEAN
00070 PcConsKbHit(VOID)
00071 {
00072   REGS Regs;
00073 
00074   /* Int 16h AH=01h
00075    * KEYBOARD - CHECK FOR KEYSTROKE
00076    *
00077    * AH = 01h
00078    * Return:
00079    * ZF set if no keystroke available
00080    * ZF clear if keystroke available
00081    * AH = BIOS scan code
00082    * AL = ASCII character
00083    */
00084   Regs.b.ah = 0x01;
00085   Int386(0x16, &Regs, &Regs);
00086 
00087   return 0 == (Regs.x.eflags & EFLAGS_ZF);
00088 }
00089 
00090 int
00091 PcConsGetCh(void)
00092 {
00093   REGS Regs;
00094   static BOOLEAN ExtendedKey = FALSE;
00095   static char ExtendedScanCode = 0;
00096 
00097   /* If the last time we were called an
00098    * extended key was pressed then return
00099    * that keys scan code. */
00100   if (ExtendedKey)
00101     {
00102       ExtendedKey = FALSE;
00103       return ExtendedScanCode;
00104     }
00105 
00106   /* Int 16h AH=00h
00107    * KEYBOARD - GET KEYSTROKE
00108    *
00109    * AH = 00h
00110    * Return:
00111    * AH = BIOS scan code
00112    * AL = ASCII character
00113    */
00114   Regs.b.ah = 0x00;
00115   Int386(0x16, &Regs, &Regs);
00116 
00117   /* Check for an extended keystroke */
00118   if (0 == Regs.b.al)
00119     {
00120       ExtendedKey = TRUE;
00121       ExtendedScanCode = Regs.b.ah;
00122     }
00123 
00124   /* Return keystroke */
00125   return Regs.b.al;
00126 }
00127 
00128 /* EOF */

Generated on Mon May 28 2012 04:18:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.