Can I control the mouse using the BIOS?
Yes. You can communicate with mouse services by using interrupt 33 hex. Table XIV.13 lists the most
common mouse services available at interrupt 33
common mouse services available at interrupt 33
Mouse interrupt services.
-------------------------------------------------------------------------------------------------------------------
Number Description
Number Description
--------------------------------------------------------------------------------------------------------------------
0 Initialize Mouse; Hide If Currently Visible
1 Show Mouse
2 Hide Mouse
3 Get Mouse Position
4 Set Mouse Position
6 Check Whether Mouse Buttons Are Down
7 Set Horizontal Limits on Mouse
8 Set Vertical Limits on Mouse
9 Set Graphics Mode Mouse Shape
10 Set Text Mode Mouse Style
11 Get Mouse Delta Movement
0 Initialize Mouse; Hide If Currently Visible
1 Show Mouse
2 Hide Mouse
3 Get Mouse Position
4 Set Mouse Position
6 Check Whether Mouse Buttons Are Down
7 Set Horizontal Limits on Mouse
8 Set Vertical Limits on Mouse
9 Set Graphics Mode Mouse Shape
10 Set Text Mode Mouse Style
11 Get Mouse Delta Movement
--------------------------------------------------------------------------------------------------------------------
The following example code uses a few of the preceding mouse routines to manipulate a text mode mouse:
#include <stdlib.h>
#include <dos.h>
main()
#include <stdlib.h>
#include <dos.h>
main()
{
union REGS regs;
printf(“Initializing Mouse...”);
regs.x.ax = 0;
int86(0x33, ®s, ®s);
printf(“\nShowing Mouse...”);
regs.x.ax = 1;
int86(0x33, ®s, ®s);
printf(“\nMove mouse around. Press any key to quit...”);
getch();
printf(“\nHiding Mouse...”);
regs.x.ax = 2;
int86(0x33, ®s, ®s);
printf(“\nDone\n”);
}
union REGS regs;
printf(“Initializing Mouse...”);
regs.x.ax = 0;
int86(0x33, ®s, ®s);
printf(“\nShowing Mouse...”);
regs.x.ax = 1;
int86(0x33, ®s, ®s);
printf(“\nMove mouse around. Press any key to quit...”);
getch();
printf(“\nHiding Mouse...”);
regs.x.ax = 2;
int86(0x33, ®s, ®s);
printf(“\nDone\n”);
}
When you run this example, a flashing block cursor that you can move around will appear on-screen. Using function 3, you can query the mouse handler for the position of the mouse at any time. In fact, I wrote an entire set of mouse library routines using the functions in Table XIV.13 that are incorporated into many of my text mode DOS programs.
To access these functions, you must have a mouse driver loaded. Typically, this occurs in AUTOEXEC.BAT, where a DOS mouse driver is loaded. However, it is becoming common to have only a Windows mouse driver loaded at Windows runtime. In that case, you will have to be running in a DOS shell to access the mouse functions.
Cross Reference:
None.
No comments:
Post a Comment