This repository was archived by the owner on Oct 11, 2022. It is now read-only.
forked from nickelsworth/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0030.pas
More file actions
194 lines (171 loc) · 3.6 KB
/
Copy path0030.pas
File metadata and controls
194 lines (171 loc) · 3.6 KB
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
UNIT MOUSE;
{
Mouse
- by Bjarke Viksoe
One of the standard "hey, I can handle the mouse, too" units.
}
INTERFACE
function InitMouse : boolean;
{Initialize mouse to its default values for current screenmode.
Mouse is turned off.
Returns TRUE if mouse is present.}
function MouseDriverPresent : boolean;
{Returns TRUE if there were a mouse driver out there...}
procedure MouseOn;
{Turns mouse image on}
procedure MouseOff;
{Turns mouse image off}
procedure MouseInfo(VAR x,y : integer; VAR lb,rb : boolean);
{Get information about current x- and y-positions.
Also return info about current status of mouse buttons}
function LeftButton : boolean;
{Retuns TRUE if left mouse button is pressed}
function RightButton : boolean;
{Retuns TRUE if right mouse button is pressed}
procedure LastButtonPress(button : integer; VAR x,y : integer);
{Returns last x/y mouse pos when 'button' was pressed}
procedure LastButtonRelease(button : integer; VAR x,y : integer);
{Returns last x/y mouse pos when 'button' was released}
procedure SetMousePos(x,y : integer);
{Set mouse position on screen...}
procedure SetMouseWindow(x1,y1,x2,y2 : integer);
{Set mouse window limit}
procedure SetMouseImage(hotx,hoty : integer; Image : pointer);
{Change mouse pointer image.
"Hot?" ranges from -16 to 16
"Image" is 16 words of mask + 16 words of image}
procedure ReadMouseMotionCounters(VAR x,y : integer);
{Read mouse's motion counters}
procedure DefineMouseRatio(h,v : word);
{Change mouse Mickey/pixel ratio}
IMPLEMENTATION
function InitMouse : boolean; assembler;
asm
xor ax,ax
int $33
not ax
xor ax,1
and ax,1
end;
function MouseDriverPresent : boolean; assembler;
asm
mov ax,$21 {try to reset mouse}
int $33
cmp ax,-1
je @found
mov ax,$0 {not there. might be bad driver version... try setup mouse}
int $33
push ax
mov ax,$2 {quickly hide it again}
int $33
pop ax
@found:
inc ax
xor ax,1
end;
procedure MouseOn; assembler;
asm
mov ax,$0001
int $33
end;
procedure MouseOff; assembler;
asm
mov ax,$0002
int $33
end;
procedure MouseInfo(VAR x,y : integer; VAR lb,rb : boolean); assembler;
asm
mov ax,$0003
int $33
les si,x
mov [es:si],cx
les si,y
mov [es:si],dx
mov ax,bx
and al,1
les si,lb
mov [es:si],al
shr bl,1
and bl,1
les si,rb
mov [es:si],bl
end;
function LeftButton : boolean; assembler;
asm
mov ax,3
int $33
mov ax,bx
and ax,1
end;
function RightButton : boolean; assembler;
asm
mov ax,3
int $33
mov ax,bx
shr ax,1
and ax,1
end;
procedure LastButtonPress(button : integer; VAR x,y : integer); assembler;
asm
mov ax,5
mov bx,button
int $33
les di,x
mov [es:di],cx
les di,y
mov [es:di],dx
end;
procedure LastButtonRelease(button : integer; VAR x,y : integer); assembler;
asm
mov ax,6
mov bx,button
int $33
les di,x
mov [es:di],cx
les di,y
mov [es:di],dx
end;
procedure SetMousePos(x,y : integer); assembler;
asm
mov ax,$0004
mov cx,x
mov dx,y
int $33
end;
procedure SetMouseWindow(x1,y1,x2,y2 : integer); assembler;
asm
mov ax,$0007
mov cx,x1
mov dx,x2
int $33
mov ax,$0008
mov cx,y1
mov dx,y2
int $33
end;
procedure SetMouseImage(hotx,hoty : integer; Image : pointer); assembler;
asm
mov ax,$0009
mov bx,hotx
mov cx,hoty
les dx,Image
int $33
end;
procedure DefineMouseRatio(h,v : word); assembler;
asm
mov ax,$000F
mov cx,h
mov dx,v
int $33
end;
procedure ReadMouseMotionCounters(VAR x,y : integer); assembler;
asm
mov ax,$000B
int $33
les di,x
mov [es:di],cx
les di,y
mov [es:di],dx
end;
end.