-
Notifications
You must be signed in to change notification settings - Fork 4
/
uhw_vt.pas
53 lines (44 loc) · 1.09 KB
/
uhw_vt.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
{ virtual terminal device for b4 }
unit uhw_vt;
interface
uses uhw, kvm, kbd;
type
TB4KVMTerm = class (TB4Device)
procedure invoke(op : char); override;
end;
implementation
uses ub4;
{$IFDEF TURBO}
function xmax : byte;
begin
xmax := lo( kvm.windmax ) - lo( kvm.windmin )
end;
function ymax : byte;
begin
ymax := hi( kvm.windmax ) - hi( kvm.windmin )
end;
procedure goxy( x, y : byte );
begin
kvm.gotoxy( x+1, y+1 )
end;
{$ENDIF}
procedure getc;
begin dput(value(kbd.readkey));
{ we have 32 bits & only need 16. we can store extended keys in one cell }
if tos = 0 then begin zap(dpop); dput(value(kbd.readkey) shl 8) end
end;
procedure TB4KVMTerm.invoke(op : char);
begin
case op of
'g' : begin dswp; kvm.gotoxy(dpop mod (xMax+1), dpop mod (yMax+1)) end;
'a' : kvm.textattr := dpop;
'e' : if tos in [$00..$ff] then write(chr(dpop)) else write('[',dpop,']');
'r' : getc;
'k' : if keypressed then dput(-1) else dput(0);
's' : kvm.clrscr;
'l' : kvm.clreol;
'c' : begin dput(kvm.wherex); dput(kvm.wherey) end;
end
end;
begin
end.