-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathWEFOSSIL.PAS
195 lines (176 loc) · 2.87 KB
/
WEFOSSIL.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
UNIT WEFossil;
{$DEFINE CAN_OVERLAY}
{$I WEGLOBAL.PAS}
{ -- Fossil Driver unit for WWIVEdit 2.4
-- Provides a fossil driver interface for WWIVEdit 2.4
-- }
INTERFACE
PROCEDURE FossilTransmit(ch1:char);
FUNCTION FossilRecieve:char;
PROCEDURE FossilFlushComm;
FUNCTION FossilCharWaiting:BOOLEAN;
FUNCTION FossilCDetect:boolean;
PROCEDURE FossilInit(port:byte);
IMPLEMENTATION
USES DOS
{$IFDEF USE_EMS}
,WEMemory
{$ENDIF};
CONST
Fossil=$14;
VAR
thePort : word;
Status : word;
busy:boolean;
OldOutput : text;
CONST
Initialized : boolean = False;
PROCEDURE SetPort(port:byte);
VAR
r:registers;
BEGIN
thePort:=port-1;
IF port=0 THEN
theport:=$00ff;
r.ah:=4; r.dx:=theport; intr(FOSSIL,r);
IF r.ax<>$1954 THEN
BEGIN
writeln('Fossil Driver failed initialization.');
{$IFDEF USE_EMS}
MemCleanup;
{$ENDIF}
halt(1);
END;
END;
PROCEDURE CheckStatus;
VAR r:registers;
BEGIN
IF Initialized THEN
WITH r DO
BEGIN
ah:=3;
dx:=theport;
intr(FOSSIL,r);
status:=ax;
END;
END;
FUNCTION FossilCDetect:boolean;
VAR
i: integer;
carrier : boolean;
BEGIN
IF Initialized THEN
BEGIN
FossilCDetect:=TRUE;
IF theport=$00ff THEN Exit;
FOR i:=1 TO 100 DO
BEGIN
CheckStatus;
IF Status AND 128 > 0 THEN exit;
END;
FossilCDetect:=FALSE;
END
ELSE FossilCdetect:=TRUE;
END;
PROCEDURE FossilTransmit(ch1:char);
VAR
r:registers;
BEGIN
IF Initialized THEN
WITH r DO
BEGIN
ah:=$1;
al:=ord(ch1);
dx:=thePort;
intr(FOSSIL,r);
status:=ax;
END;
END;
FUNCTION FossilRecieve:char;
VAR
r:registers;
BEGIN
IF Initialized THEN
WITH r DO
BEGIN
ah:=2;
dx:=thePort;
intr(FOSSIL,r);
FossilRecieve:=chr(al);
END;
END;
FUNCTION FossilCharWaiting:BOOLEAN;
VAR
r:registers;
waiting:boolean;
BEGIN
IF Initialized THEN
WITH r DO
BEGIN
ah:=$0c;
dx:=theport;
intr(FOSSIL,r);
FossilCharWaiting:=not(ax=$ffff);
END
ELSE FossilCharWaiting:=FALSE;
END;
PROCEDURE FossilFlushComm;
VAR
r:registers;
BEGIN
IF Initialized THEN
WITH r DO
BEGIN
r.dx:=theport;
r.ah:=8;
intr(FOSSIL,r);
END;
END;
{$F+}
FUNCTION DoNothing(VAR f:TextRec):integer;
BEGIN
DoNothing :=0;
END;
FUNCTION OutCh(VAR f:TextRec):integer;
VAR
b:byte;
ch : char;
BEGIN
IF NOT FossilCdetect THEN
BEGIN
{$IFDEF USE_EMS}
MemCleanup;
{$ENDIF}
halt;
END;
IF NOT Busy THEN
BEGIN
Busy:=TRUE;
b:=0;
WHILE f.BufPos>0 DO
BEGIN
ch:=F.BufPtr^[b];
inc(b);
dec(F.BufPos);
FossilTransmit(ch);
write(OldOutput,ch);
END;
OutCh := 0;
Busy:=FALSE;
END;
END;
PROCEDURE FossilInit(port:byte);
BEGIN
SetPort(port);
busy:=false;
TextRec(OldOutput) := TextRec(OutPut);
WITH TextRec(Output) DO
BEGIN
Mode:=fmOutput;
InOutFunc := @OutCh;
FlushFunc := @OutCh;
UserData[1]:=0;
END;
Initialized:=True;
END;
END.