ReactOS  0.4.15-dev-1397-g19779b3
pc98cons.c
Go to the documentation of this file.
1 /*
2  * PROJECT: FreeLoader
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Console routines for NEC PC-98 series
5  * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
6  */
7 
8 /* INCLUDES *******************************************************************/
9 
10 #include <freeldr.h>
11 
12 extern ULONG VramText;
13 extern UCHAR TextCols;
14 extern UCHAR TextLines;
15 
16 /* GLOBALS ********************************************************************/
17 
18 #define TEXT_CHAR_SIZE 2
19 
21 
22 /* FUNCTIONS ******************************************************************/
23 
24 VOID
26 {
27  /* If scrolling is needed */
29  {
33 
35  }
36 
37  if (Ch == '\n')
38  {
39  if (CursorPosition % TextCols != 0)
41 
42  return;
43  }
44 
45  if (Ch == '\t')
46  {
47  Pc98ConsPutChar(' ');
48  Pc98ConsPutChar(' ');
49  Pc98ConsPutChar(' ');
50  Pc98ConsPutChar(' ');
51  Pc98ConsPutChar(' ');
52  Pc98ConsPutChar(' ');
53  Pc98ConsPutChar(' ');
54  Pc98ConsPutChar(' ');
55 
56  return;
57  }
58 
61 }
62 
63 BOOLEAN
65 {
66  REGS Regs;
67 
68  /* Int 18h AH=01h
69  * KEYBOARD - CHECK FOR KEYSTROKE
70  *
71  * Return:
72  * BH - status
73  * 00h - if no keystroke available
74  * 01h - if keystroke available
75  * AH - BIOS scan code
76  * AL - ASCII character
77  */
78  Regs.b.ah = 0x01;
79  Int386(0x18, &Regs, &Regs);
80 
81  return Regs.b.bh == 1;
82 }
83 
84 int
86 {
87  static BOOLEAN ExtendedKey = FALSE;
88  static UCHAR ExtendedScanCode = 0;
89  REGS Regs;
90 
91  /*
92  * If the last time we were called an
93  * extended key was pressed then return
94  * that keys scan code.
95  */
96  if (ExtendedKey)
97  {
98  ExtendedKey = FALSE;
99 
100  return ExtendedScanCode;
101  }
102 
103  /* Int 18h AH=00h
104  * KEYBOARD - GET KEYSTROKE
105  *
106  * Return:
107  * AH - BIOS scan code
108  * AL - ASCII character
109  */
110  Regs.b.ah = 0x00;
111  Int386(0x18, &Regs, &Regs);
112 
113  /* Check for an extended keystroke */
114  if (Regs.b.al == 0)
115  {
116  ExtendedKey = TRUE;
117  ExtendedScanCode = Regs.b.ah;
118  }
119 
120  /* Return keystroke */
121  return Regs.b.al;
122 }
BOOLEAN Pc98ConsKbHit(VOID)
Definition: pc98cons.c:64
#define TRUE
Definition: types.h:120
unsigned char ah
Definition: pcbios.h:126
#define Ch(x, y, z)
Definition: sha2.c:141
ULONG VramText
Definition: pc98video.c:40
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
UCHAR TextLines
Definition: pc98video.c:22
int Pc98ConsGetCh(VOID)
Definition: pc98cons.c:85
unsigned char UCHAR
Definition: xmlstorage.h:181
BYTEREGS b
Definition: pcbios.h:157
unsigned char al
Definition: pcbios.h:125
VOID Pc98ConsPutChar(int Ch)
Definition: pc98cons.c:25
UCHAR TextCols
Definition: pc98video.c:21
unsigned char bh
Definition: pcbios.h:129
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
Definition: pcbios.h:152
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define TEXT_CHAR_SIZE
Definition: pc98cons.c:18
static USHORT CursorPosition
Definition: pc98cons.c:20
unsigned short * PUSHORT
Definition: retypes.h:2