forked from MarkHofmann11/WWIVEdit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CURSORS.PAS
124 lines (111 loc) · 2.43 KB
/
CURSORS.PAS
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
UNIT Cursors;
{$DEFINE CAN_OVERLAY}
{$I WEGLOBAL.PAS}
INTERFACE
TYPE
CursorStates = (On, Off, FullBlock, BottomHalf, TopHalf, UnderScore);
PROCEDURE Cursor(State:CursorStates);
PROCEDURE PushCursor;
PROCEDURE PopCursor;
IMPLEMENTATION
USES DOS;
CONST
Init: Boolean = FALSE;
TYPE
CsrStackPtr = ^CsrStack;
CsrStack = RECORD
state : word;
next : CsrStackPtr;
END;
VAR
CSR_START,CSR_END:byte;
CSR_BOTTOM : byte;
CursorStack:CsrStackPtr;
PROCEDURE InitCursor;
VAR r:Registers;
BEGIN
WITH r DO
BEGIN
ah:=3;
intr($10,r);
CSR_START:=ch;
CSR_END:=cl;
CSR_BOTTOM:=cl;
END;
CursorStack:=NIL;
Init:=TRUE;
END;
PROCEDURE PushCursor;
VAR r:Registers;
temp:CsrStackPtr;
BEGIN
IF NOT Init THEN InitCursor;
r.ah:=3;
intr($10,r);
new(temp);
temp^.next:=CursorStack;
temp^.state:=r.cx;
CursorStack:=temp;
END;
PROCEDURE PopCursor;
VAR r:Registers;
temp:CsrStackPtr;
BEGIN
r.ah:=1;
r.cx:=CursorStack^.state;
intr($10,r);
temp:=CursorStack;
CursorStack:=CursorStack^.next;
dispose(temp);
END;
PROCEDURE Cursor(State:CursorStates);
VAR r:Registers;
BEGIN
IF NOT Init THEN InitCursor;
CASE State OF
On : BEGIN
r.ah:=1;
r.ch:=CSR_START;
r.cl:=CSR_END;
intr($10,r)
END;
Off : BEGIN
r.ah:=1;
r.ch:=32;
intr($10,r)
END;
FullBlock : BEGIN
r.ah:=1;
r.ch:=0;
r.cl:=CSR_BOTTOM;
CSR_START:=r.ch;
CSR_END:=r.cl;
intr($10,r)
END;
Underscore: BEGIN
r.ah:=1;
r.ch:=CSR_BOTTOM-1;
r.cl:=CSR_BOTTOM;
CSR_START:=r.ch;
CSR_END:=r.cl;
intr($10,r)
END;
TopHalf : BEGIN
r.ah:=1;
r.ch:=0;
r.cl:=CSR_BOTTOM DIV 2;
CSR_START:=r.ch;
CSR_END:=r.cl;
intr($10,r)
END;
BottomHalf: BEGIN
r.ah:=1;
r.ch:=(CSR_BOTTOM+1) DIV 2;
r.cl:=CSR_BOTTOM;
CSR_START:=r.ch;
CSR_END:=r.cl;
intr($10,r)
END;
END;
END;
END.