Skip to content

Latest commit

 

History

History
179 lines (160 loc) · 3.65 KB

mmodem.pas

File metadata and controls

179 lines (160 loc) · 3.65 KB
 
Nov 18, 2000
Nov 18, 2000
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
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit mmodem;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
common,
tmpcom,
myio;
var
p:array[1..2] of integer;
ps:array[1..2] of astr;
procedure cwr(i:integer);
procedure wr(i:integer; c:char);
procedure wrs(i:integer; s:astr);
procedure outmodemstring1(s:astr);
procedure outmodemstring000(s:astr; showit:boolean);
procedure outmodemstring(s:astr);
procedure dophonehangup(showit:boolean);
procedure dophoneoffhook(showit:boolean);
implementation
procedure cwr(i:integer);
begin
tc(12);
ps[i]:=''; p[i]:=0;
case i of
1:begin
cwriteat(2,25,'Telegard:'+#3#14);
for i:=1 to 39 do write(' ');
gotoxy(11,25);
end;
2:begin
cwriteat(50,25,'Modem:'+#3#14);
for i:=1 to 14 do write(' ');
gotoxy(56,25);
end;
end;
end;
procedure wr(i:integer; c:char);
var j:integer;
begin
tc(14);
case i of
1:begin
if (p[i]>37) then begin
for j:=1 to 37 do ps[i][j]:=ps[i][j+1];
ps[i][0]:=chr(37); p[i]:=37;
end;
gotoxy(11,25); write(ps[i]);
end;
2:begin
if (p[i]>14) then begin
for j:=1 to 14 do ps[i][j]:=ps[i][j+1];
ps[i][0]:=chr(14); p[i]:=14;
end;
gotoxy(56,25); write(ps[i]);
end;
end;
ps[i]:=ps[i]+c; inc(p[i]);
write(c);
end;
procedure wrs(i:integer; s:astr);
var j:integer;
begin
for j:=1 to length(s) do wr(i,s[j]);
end;
procedure outmodemstring1(s:astr);
var i:integer;
begin
for i:=1 to length(s) do begin
com_tx(s[i]); wr(1,s[i]);
delay(2);
end;
if (s<>'') then com_tx(^M);
end;
procedure outmodemstring000(s:astr; showit:boolean);
var i:integer;
begin
for i:=1 to length(s) do
case s[i] of
'~':delay(500);
else
begin
com_tx(s[i]);
if (showit) then wr(1,s[i]);
delay(2);
end;
end;
com_tx(^M);
end;
procedure outmodemstring(s:astr);
begin
outmodemstring000(s,TRUE);
end;
procedure dophonehangup(showit:boolean);
var rl:real;
try,rcode:integer;
c:char;
procedure dely(r:real);
var r1:real;
begin
r1:=timer;
while abs(timer-r1)<r do;
end;
begin
if (spd<>'KB') then begin
if (showit) then begin
gotoxy(1,24); tc(12); clreol; write('Hanging up phone...');
cwr(1); cwr(2);
end;
try:=0;
while ((try<6) and (com_carrier) and (not keypressed)) do begin
term_ready(FALSE); dely(2.0); term_ready(TRUE);
if (showit) then begin cwr(1); cwr(2); end;
com_flush_rx;
outmodemstring000(modemr.hangup,showit);
rl:=timer;
while (c<>'0') and (abs(timer-rl)<2.0) do begin
c:=ccinkey1;
if (c<>#0) then
if (c in [#32..#255]) then
if (showit) then wr(2,c);
end;
inc(try);
end;
term_ready(TRUE);
if (keypressed) then c:=readkey;
end;
if (showit) then
if (exist('plogoff.bat')) then
shelldos(FALSE,'plogoff.bat',rcode);
end;
procedure dophoneoffhook(showit:boolean);
var rl1:real;
c:char;
done:boolean;
begin
if (showit) then begin
gotoxy(1,24); tc(12); clreol; write('Taking phone off hook...');
end;
delay(300); com_flush_rx;
if (showit) then begin cwr(1); cwr(2); end;
com_flush_rx; outmodemstring000(modemr.offhook,showit); com_flush_rx;
rl1:=timer; done:=FALSE; c:=#0;
repeat
c:=ccinkey1;
if (c<>#0) then begin
if (c=^M) then done:=TRUE;
if (c in [#32..#255]) then wr(2,c);
end;
until ((abs(timer-rl1)>1.0) or (done)) or (keypressed);
delay(50); com_flush_rx;
tc(11);
if (showit) then begin
gotoxy(1,24); clreol;
gotoxy(1,25); clreol;
end;
end;
end.