INT 33H: Mouse Support
0000H Reset/Query driver presence 0013H Set max for speed doubling
0001H Display pointer 0014H Exchange event handlers
0002H Hide pointer 0015H Query status buffer size
0003H Query position & buttons 0016H Save mouse status
0004H Move pointer 0017H Restore mouse status
0005H Query button-pressed count 0018H Install mouse+key event handler
0006H Query button-released count 0019H Get addr of mou+key evt handler
0007H Set horizontal range 001aH Set mouse sensitivity
0008H Set vertical range 001bH Query mouse sensitivity
0009H Set graphics pointer shape 001cH Set mouse interrupt rate
000aH Set text pointer mask 001dH Set display page
000bH Query last motion distance 001eH Query active display page
000cH Set event handler 001fH Deactivate mouse driver
000dH Enable lightpen emulation 0020H Activate mouse driver
000eH Disable lightpen emulation 0021H Reset mouse driver
000fH Set pointer speed 0024H Query mouse type, IRQ#
0010H Set exclusion area
To access the mouse support: load the registers as described under each
function, set AX to the function number, and execute INT 33H.
In most text-mode applications, very few functions are actually needed.
In a graphics mode application, you had better stick to the Windows or
other GUI or TUI environment mouse support.
To determine if the mouse is present, use INT 33H 0000H. This resets the
mouse driver and, in general, all of the default settings are adequate.
Note that you can probably assume that the user knows how to install the
mouse (via executing MOUSE.COM or installing MOUSE.SYS in CONFIG.SYS).
You may poll for mouse activity via INT 33H 0003H or install an event
handler via INT 33H 000cH or INT 33H 0018H and take action whenever a
button gets pressed. A common technique is to have your event handler
simply set values into global variables which can be examined by any part
of your program at any time.
One thing to note is that all screen coordinates used by the driver are
specified as if the screen were in a "virtual graphics mode". For text-
mode applications, a character position is considered to be 8 points wide
and 8 points tall. Thus, to specify a screen (X,Y) of (10,11), pass the
value (80,88). Similarly, when the support indicates that the mouse is at
(632,80), then the pointer is actually on character (79,10). Just divide
each coordinate by 8 (or shift right 3 times).
█▌Mouse Droppings▐█
One tricky part of text-mode mouse programming relates to an effect I call
mouse droppings. When you perform direct writes to the video buffer (and
in doing so, overwrite the position of the mouse), the mouse support won't
know about any new character or attribute at the pointer position. When
the mouse is then moved, the driver will restore the old character and
attribute instead of the new one you have written.
To avoid this, you must use INT 33H 0002H (hide ptr) before writing
directly to the video RAM and use INT 33H 0001H (show ptr) afterward.
Note that if you stick to INT 10H video I/O, you won't have this problem,
since the mouse support intercepts such I/O calls and eliminates the
problem.
█▌TSR Programs▐█
When writing a TSR which uses the mouse, you must take care to avoid the
mouse-droppings problem, as well as related problems having to do with
interrupting an executing program.
When installing your TSR, call INT 33H 0015H and allocate a buffer of the
indicated size. When the TSR is popped up, you must use INT 33H 0016H to
save the state of the mouse, and use INT 33H 000cH, INT 33H 0014H, or
INT 33H 0018H to install your event handler. Upon exiting from your TSR,
you must use INT 33H 0017H to restore the mouse state for the interrupted
program.
█▌Versions▐█
The Microsoft Mouse is the industry standard and it is generally okay for
an application to assume that the mouse is 100% Microsoft compatible.
MS Mouse driver version 6.0 (circa 1983) supported only MouFns 0-17H and
1dH-1eH. Driver version 6.1 (circa 1984) supports all the functions
listed above, adding the ability to install a more flexible event handler
(check for Shift-, Ctrl-, or Alt- clicks), CRT page awareness, mouse
sensitivity control, and a way to disable the mouse driver.
Since all of these improvements have existed for several years (with
nothing new, to speak of), there should be no problem with using any of
the newer functions. However, a few non-Microsoft mouse devices do not
support the later fns. For best compatibility, you might try sticking
with fns 0000H-0017H.
See Also: API Service Index
INT 15H 84H (joystick support)
IRQs: Hardware Interrupts
DOS Functions
-♦-