-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmousedrv.pas
102 lines (76 loc) · 1.73 KB
/
mousedrv.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
UNIT MouseDrv;
INTERFACE
Uses Dos, Crt;
PROCEDURE Mouse(m1, m2, m3, m4: Integer);
PROCEDURE Mouse_reset;
FUNCTION Mouse_exists : Boolean;
PROCEDURE Mouse_show;
PROCEDURE Mouse_hide;
FUNCTION Mouse_down : Integer;
FUNCTION Mouse_up : Integer;
PROCEDURE Mouse_getpos(var mx, my : Integer);
PROCEDURE Mouse_setpos(mx, my : Integer);
IMPLEMENTATION
Var regs : Registers;
PROCEDURE Mouse(m1, m2, m3, m4: Integer);
BEGIN
regs.ax := m1;
regs.bx := m2;
regs.cx := m3;
regs.dx := m4;
intr($33, regs);
END;
PROCEDURE Mouse_reset;
BEGIN
Mouse(0, 0, 0, 0);
END;
FUNCTION Mouse_exists : Boolean;
Var
ms : Pointer;
msseg, msoff : Word;
ad : Byte;
BEGIN
msseg := MemW[$00:($33 * 4 + 2)];
msoff := MemW[$00:($33 * 4)];
ms := Ptr(msseg, msoff);
ad := Mem[msseg:msoff];
if ( (ms <> Nil) and (ad <> $CF)) then
Mouse_Exists := TRUE
else
Mouse_Exists := FALSE;
END;
PROCEDURE Mouse_show;
BEGIN
if ( Mouse_exists ) then
Mouse(1, 0, 0, 0);
END;
PROCEDURE Mouse_hide;
BEGIN
if ( Mouse_exists ) then
Mouse(2, 0, 0, 0);
END;
FUNCTION Mouse_down : Integer;
BEGIN
if ( Mouse_exists ) then
Mouse(3, 0, 0, 0);
Mouse_Down := (regs.bx and 3);
END;
FUNCTION Mouse_up : Integer;
BEGIN
if ( Mouse_exists ) then
Mouse(6, 0, 0, 0);
Mouse_Up := regs.bx ;
END;
PROCEDURE Mouse_getpos(var mx, my : Integer);
BEGIN
if ( Mouse_exists ) then
Mouse (3, 0, 0, 0);
mx := (regs.cx div 8) + 1;
my := (regs.dx div 8) + 1;
END;
PROCEDURE Mouse_setpos(mx, my : Integer);
BEGIN
if ( Mouse_exists ) then
Mouse(4, 0, (mx - 1) * 8, (my - 1) * 8);
END;
END. { of Unit }