home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MSMOUSE1.ZIP / HGC.ZIP / C.ZIP / MOUSEHGC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-10  |  1.8 KB  |  58 lines

  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. #define         MOUSE   0x33
  6. #define         VIDEO   0x10
  7.  
  8. void GMODE ();
  9. void TMODE ();
  10.  
  11. main ()
  12.  
  13. {
  14.         union REGS inregs, outregs;
  15.         struct SREGS segregs;
  16.         char far *lpMem;
  17.         char cVideoMode;
  18.  
  19.         /* Do whatever is necessary to setup display hardware */
  20.         lpMem = (char far *)0x00000449;         /* Video BIOS mode add. */
  21.         cVideoMode = *lpMem;                    /* Get old Video mode */
  22.         GMODE ();
  23.         /* Set Video BIOS mode byte to 6 for single step cursor increment */
  24.         *lpMem = 6;                             /* HGC Video Page 0 */
  25.  
  26.         /* Reset Driver to recognize single step mode and set defaults */
  27.         inregs.x.ax = 0;
  28.         int86 (MOUSE, &inregs, &outregs);
  29.  
  30.         inregs.x.ax = 1;
  31.         int86 (MOUSE, &inregs, &outregs);
  32.  
  33.         /* Loop to display cursor position when left button is clicked */
  34.         do {
  35.                 /* Check button status */
  36.                 inregs.x.ax = 3;
  37.                 int86 (MOUSE, &inregs, &outregs);
  38.  
  39.                 /* If left button clicked, display position */
  40.                 if (outregs.x.bx & 1) {
  41.                    printf ("%d %d\n", outregs.x.cx, outregs.x.dx);
  42.                    /* Wait for left button release before continuing */
  43.                    do {
  44.                       int86 (MOUSE, &inregs, &outregs);
  45.                    } while (outregs.x.bx & 1);
  46.                 }
  47.  
  48.         } while (!(outregs.x.bx & 2));          /* Loop 'til right pressed */
  49.  
  50.         /* Hide Mouse cursor */
  51.         inregs.x.ax = 2;
  52.         int86 (MOUSE, &inregs, &outregs);
  53.  
  54.         /* Clear screen and restore video mode */
  55.         TMODE ();
  56.         *lpMem = cVideoMode;
  57. }
  58.