ReactOS 0.4.15-dev-8227-g32d615f
pccons.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <freeldr.h>
20
21#define TEXTMODE_BUFFER 0xb8000
22#define TEXTMODE_BUFFER_SIZE 0x8000
23
24#define TEXT_COLS 80
25#define TEXT_LINES 25
26
27VOID
29{
30 REGS Regs;
31
32 /* If we are displaying a CR '\n' then do a LF also */
33 if ('\n' == Ch)
34 {
35 /* Display the LF */
36 PcConsPutChar('\r');
37 }
38
39 /* If we are displaying a TAB '\t' then display 8 spaces ' ' */
40 if ('\t' == Ch)
41 {
42 /* Display the 8 spaces ' ' */
43 PcConsPutChar(' ');
44 PcConsPutChar(' ');
45 PcConsPutChar(' ');
46 PcConsPutChar(' ');
47 PcConsPutChar(' ');
48 PcConsPutChar(' ');
49 PcConsPutChar(' ');
50 PcConsPutChar(' ');
51 return;
52 }
53
54 /* Int 10h AH=0Eh
55 * VIDEO - TELETYPE OUTPUT
56 *
57 * AH = 0Eh
58 * AL = character to write
59 * BH = page number
60 * BL = foreground color (graphics modes only)
61 */
62 Regs.b.ah = 0x0E;
63 Regs.b.al = Ch;
64 Regs.w.bx = 1;
65 Int386(0x10, &Regs, &Regs);
66}
67
70{
71 REGS Regs;
72
73 /* Int 16h AH=01h
74 * KEYBOARD - CHECK FOR KEYSTROKE
75 *
76 * AH = 01h
77 * Return:
78 * ZF set if no keystroke available
79 * ZF clear if keystroke available
80 * AH = BIOS scan code
81 * AL = ASCII character
82 */
83 Regs.b.ah = 0x01;
84 Int386(0x16, &Regs, &Regs);
85
86 return 0 == (Regs.x.eflags & EFLAGS_ZF);
87}
88
89int
91{
92 REGS Regs;
93 static BOOLEAN ExtendedKey = FALSE;
94 static char ExtendedScanCode = 0;
95
96 /* If the last time we were called an
97 * extended key was pressed then return
98 * that keys scan code. */
99 if (ExtendedKey)
100 {
102 return ExtendedScanCode;
103 }
104
105 /* Int 16h AH=00h
106 * KEYBOARD - GET KEYSTROKE
107 *
108 * AH = 00h
109 * Return:
110 * AH = BIOS scan code
111 * AL = ASCII character
112 */
113 Regs.b.ah = 0x00;
114 Int386(0x16, &Regs, &Regs);
115
116 /* Check for an extended keystroke */
117 if (0 == Regs.b.al)
118 {
120 ExtendedScanCode = Regs.b.ah;
121 }
122
123 /* Return keystroke */
124 return Regs.b.al;
125}
126
127/* EOF */
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define EFLAGS_ZF
Definition: ketypes.h:185
int __cdecl Int386(int ivec, REGS *in, REGS *out)
VOID PcConsPutChar(int Ch)
Definition: pccons.c:28
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:69
int PcConsGetCh(void)
Definition: pccons.c:90
#define Ch(x, y, z)
Definition: sha2.c:141
unsigned char al
Definition: pcbios.h:131
unsigned char ah
Definition: pcbios.h:132
unsigned long eflags
Definition: pcbios.h:105
unsigned short bx
Definition: pcbios.h:112
static BOOLEAN ExtendedKey
Definition: ueficon.c:20
static char ExtendedScanCode
Definition: ueficon.c:21
Definition: pcbios.h:159
DWORDREGS x
Definition: pcbios.h:160
BYTEREGS b
Definition: pcbios.h:163
WORDREGS w
Definition: pcbios.h:162