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
12
extern
ULONG
VramText
;
13
extern
UCHAR
TextCols
;
14
extern
UCHAR
TextLines
;
15
16
/* GLOBALS ********************************************************************/
17
18
#define TEXT_CHAR_SIZE 2
19
20
static
USHORT
CursorPosition
= 0;
21
22
/* FUNCTIONS ******************************************************************/
23
24
VOID
25
Pc98ConsPutChar
(
int
Ch
)
26
{
27
/* If scrolling is needed */
28
if
(
CursorPosition
>=
TextCols
*
TextLines
)
29
{
30
RtlCopyMemory
((
PUSHORT
)
VramText
,
31
(
PUSHORT
)(
VramText
+
TextCols
*
TEXT_CHAR_SIZE
),
32
TextCols
*
TextLines
*
TEXT_CHAR_SIZE
);
33
34
CursorPosition
-=
TextCols
;
35
}
36
37
if
(
Ch
==
'\n'
)
38
{
39
if
(
CursorPosition
%
TextCols
!= 0)
40
CursorPosition
+=
TextCols
- (
CursorPosition
%
TextCols
);
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
59
*(
PUSHORT
)(
VramText
+
CursorPosition
*
TEXT_CHAR_SIZE
) =
Ch
;
60
++
CursorPosition
;
61
}
62
63
BOOLEAN
64
Pc98ConsKbHit
(
VOID
)
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
85
Pc98ConsGetCh
(
VOID
)
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
unsigned char BOOLEAN
Definition:
ProcessorBind.h:185
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
freeldr.h
void
Definition:
nsiface.idl:2307
TextLines
UCHAR TextLines
Definition:
pc98video.c:22
Pc98ConsKbHit
BOOLEAN Pc98ConsKbHit(VOID)
Definition:
pc98cons.c:64
VramText
ULONG VramText
Definition:
pc98video.c:40
TextCols
UCHAR TextCols
Definition:
pc98video.c:21
Pc98ConsPutChar
VOID Pc98ConsPutChar(int Ch)
Definition:
pc98cons.c:25
Pc98ConsGetCh
int Pc98ConsGetCh(VOID)
Definition:
pc98cons.c:85
TEXT_CHAR_SIZE
#define TEXT_CHAR_SIZE
Definition:
pc98cons.c:18
CursorPosition
static USHORT CursorPosition
Definition:
pc98cons.c:20
Int386
int __cdecl Int386(int ivec, REGS *in, REGS *out)
USHORT
unsigned short USHORT
Definition:
pedump.c:61
Ch
#define Ch(x, y, z)
Definition:
sha2.c:141
BYTEREGS::al
unsigned char al
Definition:
pcbios.h:131
BYTEREGS::ah
unsigned char ah
Definition:
pcbios.h:132
BYTEREGS::bh
unsigned char bh
Definition:
pcbios.h:135
PUSHORT
uint16_t * PUSHORT
Definition:
typedefs.h:56
RtlCopyMemory
#define RtlCopyMemory(Destination, Source, Length)
Definition:
typedefs.h:263
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
REGS
Definition:
pcbios.h:159
REGS::b
BYTEREGS b
Definition:
pcbios.h:163
UCHAR
unsigned char UCHAR
Definition:
xmlstorage.h:181
boot
freeldr
freeldr
arch
i386
pc98
pc98cons.c
Generated on Mon Feb 6 2023 06:02:20 for ReactOS by
1.9.6