-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINT33.PAS
329 lines (283 loc) · 7.18 KB
/
INT33.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
{
INT 33 - Mouse pointer Services
Built with info from https://stanislavs.org/helppc/int_33.html
This library was tested with CuteMouse v2.1 beta 4 driver by Nagy Daniel
which also provides a Wheel API
2022 LRT
}
unit
int33;
interface
const
C_MOUSE_LEFT = $0001;
C_MOUSE_RIGHT = $0002;
C_MOUSE_MIDDLE = $0004;
C_MOUSE_WHEEL = $FFFF;
type
{ used to query press or release information }
TButtonInfo = record
count: word; { number of presses/releases since last query }
x, y: word; { the mouse cursor x and y position }
status: word; { the current button status }
end;
{
used to set the mouse graphics cursor
screen cursor result
0 0 0 (black)
0 1 1 (white)
1 0 Bit not changed (transparent)
1 1 Bit inverted
}
PMouseCursor = ^TMouseCursor;
TMouseCursor = packed record
screenMask: array[0..15] of word; { screen mask / AND mask }
cursorMask: array[0..15] of word; { cursor mask / XOR mask }
hotX: word; { cursor hotspot X coordinate (-16 to 16) }
hotY: word; { cursor hotspot Y coordinate (-16 to 16) }
end;
{ *** int 33h services ************************************************** }
{ initializes the mouse driver }
procedure mouseReset;
{
increments the mouse visibility accumulator
(shows the cursor on screen if above zero)
}
procedure showMouseCursor;
{
decrements the mouse visibility accumulator
(hides the cursor on screen if below zero)
}
procedure hideMouseCursor;
{
returns the mouse cursor position and the status of its buttons
}
procedure getMouseStatus(var x, y:word; var status: word);
{
sets the position of the mouse cursor
}
procedure setMousePosition(x, y: word);
{
returns mouse button press information
}
procedure getPressInfo(button: word; var info:TButtonInfo);
{
returns mouse button release information
}
procedure getReleaseInfo(button: word; var info:TButtonInfo);
{
sets the minimum and maximum values for the mouse horizontal movement
}
procedure setHorizontalRange(min, max: word);
{
sets the minimum and maximum values for the mouse vertical movement
}
procedure setVerticalRange(min, max: word);
{
sets the graphics mouse cursor
}
procedure setGraphicsCursor(var cursor: TMouseCursor);
{
sets a software text cursor. front and back are the colors,
char is the character that represents the cursor
}
procedure setTextCursor(front, back: byte; character: char);
{
reads the mouse motion counters.
returns values in mickeys (a unit of measurement for mouse movement)
for both horizontal and vertical axes) as signed 16 bit integers
}
procedure getMotionCounters(var h, v: integer);
{
sets the ratio between physical cursor movement (mickeys) and
screen coordinate changes.
}
procedure setMickeysPer8Pixels(mx, my: word);
{
returns the number of buttons available
}
function getButtonCount: byte;
{
returns true if the mouse device is available for use
}
function isMouseAvailable: boolean;
{
returns true if a mouse wheel is present
}
function isWheelSupported: boolean;
{ *** useful functions ************************************************** }
{
returns true if the specified mouse button is pressed
}
function mouseButtonDown(button: word): boolean;
implementation
var
mButtonCount: byte;
procedure mouseReset;
var
driverInstalled: word;
buttonCount: word;
begin
asm
mov ax, 0
int 33h
mov driverInstalled, ax
mov buttonCount, bx
end;
if driverInstalled <> $FFFF then
mButtonCount := 0
else
mButtonCount := Lo(buttonCount);
end;
procedure showMouseCursor; assembler;
asm
mov ax, 1
int 33h
end;
procedure hideMouseCursor; assembler;
asm
mov ax, 2
int 33h
end;
procedure getMouseStatus(var x, y:word; var status: word);
var
px, py, s: word;
begin
asm
mov ax, 3
int 33h
mov px, cx
mov py, dx
mov s, bx
end;
x := px;
y := py;
status := s;
end;
function isMouseAvailable: boolean;
begin
isMouseAvailable := mButtonCount > 0;
end;
procedure setMousePosition(x, y: word);
begin
asm
mov ax, 4
mov cx, x
mov dx, y
int 33h
end;
end;
procedure getInfo(cmd: word; button: word; var info:TButtonInfo);
var
count, px, py, status: word;
begin
asm
mov ax, cmd
mov bx, button
int 33h
mov count, bx
mov px, cx
mov py, dx
mov status, ax
end;
info.count := count;
info.x := px;
info.y := py;
info.status := status;
end;
procedure getPressInfo(button: word; var info:TButtonInfo);
begin
GetInfo(5, button, info);
end;
procedure getReleaseInfo(button: word; var info:TButtonInfo);
begin
GetInfo(6, button, info);
end;
procedure setRange(cmd, min, max: word);
begin
asm
mov ax, cmd
mov cx, min
mov dx, max
int 33h
end;
end;
procedure setHorizontalRange(min, max: word);
begin
SetRange(7, min, max);
end;
procedure setVerticalRange(min, max: word);
begin
SetRange(8, min, max);
end;
procedure setGraphicsCursor(var cursor: TMouseCursor);
var x, y: word;
begin
x := cursor.hotX;
y := cursor.hotY;
asm
mov ax, 0009h
mov bx, x
mov cx, y
les dx, cursor
int 33h
end;
end;
procedure setTextCursor(front, back: byte; character: char);
var color: byte;
begin
color := (back shl 4) or front;
asm
mov ax, $0A
mov bx, $00 { software cursor }
mov cx, $00 { screen mask value }
mov dh, color { front and back colors }
mov dl, character { character to use }
int 33h
end;
end;
procedure getMotionCounters(var h, v: integer);
var hm, vm: word;
begin
asm
mov ax, 0Bh
int 33h
mov hm, cx
mov vm, dx
end;
h := hm;
v := vm;
end;
procedure setMickeysPer8Pixels(mx, my: word); assembler;
asm
mov ax, 0Fh
mov cx, mx { default mickeys per 8 pixels is 8 }
mov dx, my { default mickeys per 8 pixels is 16 }
int 33h
end;
function getButtonCount: byte;
begin
GetButtonCount := mButtonCount;
end;
function isWheelSupported: boolean;
var
signature: word;
capabilities: word;
begin
asm
mov ax, 11h
int 33h
mov signature, ax
mov capabilities, cx
end;
isWheelSupported := (signature = $574D) and ((capabilities and 1) = 1);
end;
function mouseButtonDown(button: word): boolean;
var
x, y, status: word;
begin
getMouseStatus(x, y, status);
mouseButtonDown := (status and button) <> 0;
end;
begin
mButtonCount := 0;
end.