home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
- #include <stdlib.h>
- #include <stdio.h>
-
- #define MOUSE 0x33
- #define VIDEO 0x10
-
- #define HORIZONTAL_RESOLUTION_MIN 256
- #define HORIZONTAL_RESOLUTION_MAX 512
- #define VERTICAL_RESOLUTION_MIN 64
- #define VERTICAL_RESOLUTION_MAX 128
-
- void far MSFCN12 ();
-
- main ()
-
- {
- union REGS inregs, outregs;
- struct SREGS segregs;
- char far *lpMem;
- char cVideoMode;
-
- /* Do whatever is necessary to setup display hardware */
- lpMem = (char far *)0x00000449; /* Video BIOS mode add. */
- cVideoMode = *lpMem; /* Get old Video mode */
- /****************** Only Example Specific Code *******************/
- inregs.x.ax = 6;
- int86 (VIDEO, &inregs, &outregs);
- /*****************************************************************/
- /* Set Video BIOS mode byte to 6 for single step cursor increment */
- *lpMem = 6; /* Set for increment by 1 */
-
- /* Reset Driver to recognize single step mode and set defaults */
- inregs.x.ax = 0;
- int86 (MOUSE, &inregs, &outregs);
-
- /* Inform driver of horizontal resolution of display */
- inregs.x.ax = 7;
- inregs.x.cx = HORIZONTAL_RESOLUTION_MIN;
- inregs.x.dx = HORIZONTAL_RESOLUTION_MAX;
- int86 (MOUSE, &inregs, &outregs);
-
- /* Inform driver of vertical resolution of display */
- inregs.x.ax = 8;
- inregs.x.cx = VERTICAL_RESOLUTION_MIN;
- inregs.x.dx = VERTICAL_RESOLUTION_MAX;
- int86 (MOUSE, &inregs, &outregs);
-
- /* Enable Function 12 assembly routine which will display cursor */
- inregs.x.ax = 12;
- inregs.x.cx = 1; /* Call routine on cursor motion */
- inregs.x.dx = (long)MSFCN12 & 0xffff; /* Get offset */
- segregs.es = (long)MSFCN12 >> 16; /* Get segment */
- int86x (MOUSE, &inregs, &outregs, &segregs);
-
-
- /* Loop to display cursor position when left button is clicked */
- do {
- /* Check button status */
- inregs.x.ax = 3;
- int86 (MOUSE, &inregs, &outregs);
-
- /* If left button clicked, display position */
- if (outregs.x.bx & 1) {
- printf ("%d %d\n", outregs.x.cx, outregs.x.dx);
- /* Wait for left button release before continuing */
- do {
- int86 (MOUSE, &inregs, &outregs);
- } while (outregs.x.bx & 1);
- }
-
- } while (!(outregs.x.bx & 2)); /* Loop 'til right pressed */
-
-
- /* Restore mouse to defaults and disable Function 12 */
- inregs.x.ax = 0; /* Hide Mouse cursor */
- int86 (MOUSE, &inregs, &outregs);
-
- /* Clear screen and restore video mode */
- inregs.x.ax = cVideoMode;
- int86 (VIDEO, &inregs, &outregs);
-
- }