home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MSMOUSE1.ZIP / EGA.ZIP / DISPLAY.ZIP / MOUSE12.C next >
Encoding:
C/C++ Source or Header  |  1989-02-10  |  3.0 KB  |  84 lines

  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. #define         MOUSE   0x33
  6. #define         VIDEO   0x10
  7.  
  8. #define         HORIZONTAL_RESOLUTION_MIN       256
  9. #define         HORIZONTAL_RESOLUTION_MAX       512
  10. #define         VERTICAL_RESOLUTION_MIN         64
  11. #define         VERTICAL_RESOLUTION_MAX         128
  12.  
  13. void far MSFCN12 ();
  14.  
  15. main ()
  16.  
  17. {
  18.         union REGS inregs, outregs;
  19.         struct SREGS segregs;
  20.         char far *lpMem;
  21.         char cVideoMode;
  22.  
  23.         /* Do whatever is necessary to setup display hardware */
  24.         lpMem = (char far *)0x00000449;         /* Video BIOS mode add. */
  25.         cVideoMode = *lpMem;                    /* Get old Video mode */
  26.         /****************** Only Example Specific Code *******************/
  27.         inregs.x.ax = 6;
  28.         int86 (VIDEO, &inregs, &outregs);
  29.         /*****************************************************************/
  30.         /* Set Video BIOS mode byte to 6 for single step cursor increment */
  31.         *lpMem = 6;                             /* Set for increment by 1 */
  32.  
  33.         /* Reset Driver to recognize single step mode and set defaults */
  34.         inregs.x.ax = 0;
  35.         int86 (MOUSE, &inregs, &outregs);
  36.  
  37.         /* Inform driver of horizontal resolution of display */
  38.         inregs.x.ax = 7;
  39.         inregs.x.cx = HORIZONTAL_RESOLUTION_MIN;
  40.         inregs.x.dx = HORIZONTAL_RESOLUTION_MAX;
  41.         int86 (MOUSE, &inregs, &outregs);
  42.  
  43.         /* Inform driver of vertical resolution of display */
  44.         inregs.x.ax = 8;
  45.         inregs.x.cx = VERTICAL_RESOLUTION_MIN;
  46.         inregs.x.dx = VERTICAL_RESOLUTION_MAX;
  47.         int86 (MOUSE, &inregs, &outregs);
  48.  
  49.         /* Enable Function 12 assembly routine which will display cursor */
  50.         inregs.x.ax = 12;
  51.         inregs.x.cx = 1;                /* Call routine on cursor motion */
  52.         inregs.x.dx = (long)MSFCN12 & 0xffff;  /* Get offset */
  53.         segregs.es =  (long)MSFCN12 >> 16;     /* Get segment */
  54.         int86x (MOUSE, &inregs, &outregs, &segregs);
  55.  
  56.  
  57.         /* Loop to display cursor position when left button is clicked */
  58.         do {
  59.                 /* Check button status */
  60.                 inregs.x.ax = 3;
  61.                 int86 (MOUSE, &inregs, &outregs);
  62.  
  63.                 /* If left button clicked, display position */
  64.                 if (outregs.x.bx & 1) {
  65.                    printf ("%d %d\n", outregs.x.cx, outregs.x.dx);
  66.                    /* Wait for left button release before continuing */
  67.                    do {
  68.                       int86 (MOUSE, &inregs, &outregs);
  69.                    } while (outregs.x.bx & 1);
  70.                 }
  71.  
  72.         } while (!(outregs.x.bx & 2));          /* Loop 'til right pressed */
  73.  
  74.  
  75.         /* Restore mouse to defaults and disable Function 12 */
  76.         inregs.x.ax = 0;                        /* Hide Mouse cursor */
  77.         int86 (MOUSE, &inregs, &outregs);
  78.  
  79.         /* Clear screen and restore video mode */
  80.         inregs.x.ax = cVideoMode;
  81.         int86 (VIDEO, &inregs, &outregs);
  82.  
  83. }
  84.