home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
-
- MOUH_INT.C (FOR HERCULES)
-
- Demonstrates the most commonly used function calls in
- programming the Microsoft mouse driver. This was written
- in Microsoft C 5.1 using the small model. All the calls
- made to the driver are made using int86x.
-
- Before running this program, the Hercules graphics support
- utility must be loaded. Run either MSHERC.COM (included with
- C 5.1) or QBHERC.COM (included with QuickBASIC 4.0).
-
- Written by David Tryon
- Microsoft Product Support
- 6/15/88
-
- To build, type: cl /AS mouh_int.c
-
- NOTE: Program assumes mouse and mouse driver are installed.
- *******************************************************************/
-
- #include <graph.h>
- #include <dos.h>
- #define MOUSE 0x33
-
- union REGS inregs, outregs;
- struct SREGS segregs;
-
- main ()
- {
- void chkdrv (); /* Checks if driver installed */
-
- char far *video_mode = (char far *) 0x00000449;
- unsigned short cursor [32]; /* Array to Contain Cursor */
-
- chkdrv (); /* Exit if no driver loaded */
-
- *video_mode = 6; /* Tell BIOS it's in Graphics mode */
-
- /* Function 0: Reset Mouse */
- inregs.x.ax = 0;
- int86x (MOUSE, &inregs, &outregs, &segregs);
-
- /* Define screen mask */
-
- cursor [0] = 0xE1FF;
- cursor [1] = 0xE1FF;
- cursor [2] = 0xE1FF;
- cursor [3] = 0xE1FF;
- cursor [4] = 0xE1FF;
- cursor [5] = 0xE000;
- cursor [6] = 0xE000;
- cursor [7] = 0xE000;
- cursor [8] = 0x0000;
- cursor [9] = 0x0000;
- cursor [10] = 0x0000;
- cursor [11] = 0x0000;
- cursor [12] = 0x0000;
- cursor [13] = 0x0000;
- cursor [14] = 0x0000;
- cursor [15] = 0x0000;
-
- /* Define cursor mask */
-
- cursor [16] = 0x1E00;
- cursor [17] = 0x1200;
- cursor [18] = 0x1200;
- cursor [19] = 0x1200;
- cursor [20] = 0x1200;
- cursor [21] = 0x13FF;
- cursor [22] = 0x1249;
- cursor [23] = 0x1249;
- cursor [24] = 0xF249;
- cursor [25] = 0x9001;
- cursor [26] = 0x9001;
- cursor [27] = 0x9001;
- cursor [28] = 0x8001;
- cursor [29] = 0x8001;
- cursor [30] = 0x8001;
- cursor [31] = 0xFFFF;
-
- /* Function 9: Set Graphics Cursor Block */
- inregs.x.ax = 9;
- inregs.x.bx = 5;
- inregs.x.cx = 0;
- inregs.x.dx = (unsigned short) cursor;
- segread(&segregs);
- segregs.es = segregs.ds; /* ES:DX => Cursor Array */
- int86x ( MOUSE, &inregs, &outregs, &segregs);
- segread(&segregs);
-
- /* Function 7: Set Horizontal Limits */
- inregs.x.ax = 7;
- inregs.x.cx = 100;
- inregs.x.dx = 620;
- int86x ( MOUSE, &inregs, &outregs, &segregs);
-
- /* Function 8: Set Vertical Limits */
- inregs.x.ax = 8;
- inregs.x.cx = 50;
- inregs.x.dx = 300;
- int86x ( MOUSE, &inregs, &outregs, &segregs);
-
- _setvideomode (_HERCMONO);
-
- /* Draw box showing mouse limits */
- _moveto (100, 50);
- _lineto (620, 50);
- _lineto (620,300);
- _lineto (100,300);
- _lineto (100, 50);
-
- /* Function 1: Show Cursor */
- inregs.x.ax = 1;
- int86x (MOUSE, &inregs, &outregs, &segregs);
-
- do
- {
- inregs.x.ax = 3;
- int86x ( MOUSE, &inregs, &outregs, &segregs);
- _settextposition (1,1);
- printf ("%d \t%d ", outregs.x.cx,outregs.x.dx);
- } while (!outregs.x.bx); /* Loop until button pressed */
-
- /* Function 2: Hide Cursor */
- inregs.x.ax = 2;
- int86x ( MOUSE, &inregs, &outregs, &segregs);
-
- *video_mode = 7;
-
- _setvideomode (_DEFAULTMODE);
- }
-
- void chkdrv ()
- {
- unsigned long address;
- unsigned char first_byte;
-
- inregs.x.ax = 0x3533; /* Get Interrupt Vector for 0x33 */
- intdosx ( &inregs, &outregs, &segregs);
- address = (((long) segregs.es) << 16) + (long) outregs.x.bx ;
- first_byte = (unsigned char) * (long far *) address;
-
- /* Be sure vector isn't 0 and first instruction isn't iret */
- if ((address == 0L) || (first_byte == 0xCF))
- {
- printf ("\nThe Mouse Driver must be installed to use this program");
- exit ();
- }
- }
-