-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyBoard5.01.c
67 lines (60 loc) · 967 Bytes
/
KeyBoard5.01.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Keyboard routines for the version 5.01 terminals
*
* KbdInit - call ONCE at beginning.
* KbdFlush - flushes queues.
* KbdReset - call ONCE at end.
* KbdGetc - call to get next character.
*
* Copyright (c) 1987 Robert L. Brown. All Rights Reserved. This code
* is public domain.
*
*/
#define GINFLAG ((char *)0x100032)
extern int acktoz80(), (*g_kbdgin)();
int (*ginsave)();
char Queue[100], *Qend, *Qhead, *Qtail;
int KbdInt();
KbdInit()
{
ginsave = g_kbdgin;
g_kbdgin = KbdInt;
*GINFLAG = 1;
}
KbdReset()
{
g_kbdgin = ginsave;
*GINFLAG = 0;
}
KbdFlush()
{
Qhead = Qtail = Queue;
Qend = &Queue[sizeof Queue];
}
KbdInt()
{
char *next;
int c;
c = dummy();
next = Qtail+1;
if(next>=Qend)
next = Queue;
if (next!=Qhead) {
*Qtail = c;
Qtail = next;
}
g_kbdgin = KbdInt;
*GINFLAG = 1;
acktoz80();
}
dummy(){}
KbdGetc()
{
int c;
if(Qhead==Qtail)
return -1;
c = *Qhead++;
if(Qhead>=Qend)
Qhead = Queue;
return (int)c;
}