ReactOS 0.4.15-dev-5667-ged97270
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
12extern ULONG VramText;
13extern UCHAR TextCols;
14extern UCHAR TextLines;
15
16/* GLOBALS ********************************************************************/
17
18#define TEXT_CHAR_SIZE 2
19
21
22/* FUNCTIONS ******************************************************************/
23
24VOID
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
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
84int
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}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UCHAR TextLines
Definition: pc98video.c:22
BOOLEAN Pc98ConsKbHit(VOID)
Definition: pc98cons.c:64
ULONG VramText
Definition: pc98video.c:40
UCHAR TextCols
Definition: pc98video.c:21
VOID Pc98ConsPutChar(int Ch)
Definition: pc98cons.c:25
int Pc98ConsGetCh(VOID)
Definition: pc98cons.c:85
#define TEXT_CHAR_SIZE
Definition: pc98cons.c:18
static USHORT CursorPosition
Definition: pc98cons.c:20
int __cdecl Int386(int ivec, REGS *in, REGS *out)
unsigned short USHORT
Definition: pedump.c:61
#define Ch(x, y, z)
Definition: sha2.c:141
unsigned char al
Definition: pcbios.h:131
unsigned char ah
Definition: pcbios.h:132
unsigned char bh
Definition: pcbios.h:135
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
Definition: pcbios.h:159
BYTEREGS b
Definition: pcbios.h:163
unsigned char UCHAR
Definition: xmlstorage.h:181