home *** CD-ROM | disk | FTP | other *** search
/ Teach Yourself Game Programming in 21 Days / TYGAMES_R.ISO / source / day_07 / graph7m.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-16  |  3.4 KB  |  178 lines

  1.  
  2. // I N C L U D E S ///////////////////////////////////////////////////////////
  3.  
  4. #include <dos.h>
  5. #include <bios.h>
  6. #include <stdio.h>
  7. #include <math.h>
  8. #include <conio.h>
  9. #include "graph7m.h"
  10.  
  11. // F U N C T I O N S /////////////////////////////////////////////////////////
  12.  
  13. int Squeeze_Mouse(int command, int *x, int *y,int *buttons)
  14. {
  15. // mouse interface, we'll use _int86 instead of inline asm...Why? No real reason.
  16. // what function is caller requesting?
  17.  
  18. union _REGS inregs, outregs;
  19.  
  20. switch(command)
  21.       {
  22.  
  23.       case MOUSE_RESET:
  24.            {
  25.  
  26.            inregs.x.ax = 0x00; // subfunction 0: reset
  27.            _int86(MOUSE_INT, &inregs, &outregs);
  28.            *buttons = outregs.x.bx; // return number of buttons
  29.            return(outregs.x.ax);    // return overall success/failure
  30.  
  31.            } break;
  32.  
  33.       case MOUSE_SHOW:
  34.            {
  35.            // this function increments the internal show mouse counter.
  36.            // when it is equal to 0 then the mouse will be displayed.
  37.  
  38.            inregs.x.ax = 0x01; // subfunction 1: increment show flag
  39.            _int86(MOUSE_INT, &inregs, &outregs);
  40.  
  41.            return(1);
  42.  
  43.            } break;
  44.  
  45.       case MOUSE_HIDE:
  46.            {
  47.            // this function decrements the internal show mouse counter.
  48.            // when it is equal to -1 then the mouse will be hidden.
  49.  
  50.            inregs.x.ax = 0x02; // subfunction 2: decrement show flag
  51.            _int86(MOUSE_INT, &inregs, &outregs);
  52.  
  53.            return(1);
  54.  
  55.            } break;
  56.  
  57.       case MOUSE_BUTT_POS:
  58.            {
  59.            // this functions gets the buttons and returns the absolute mouse
  60.            // positions in the vars x,y, and buttons, respectively
  61.  
  62.            inregs.x.ax = 0x03; // subfunction 3: get position and buttons
  63.            _int86(MOUSE_INT, &inregs, &outregs);
  64.  
  65.            // extract the info and send back to caller via pointers
  66.            *x       = outregs.x.cx;
  67.            *y       = outregs.x.dx;
  68.            *buttons = outregs.x.bx;
  69.  
  70.            return(1);
  71.  
  72.            } break;
  73.  
  74.       case MOUSE_MOTION_REL:
  75.            {
  76.  
  77.            // this functions gets the relative mouse motions from the last
  78.            // call and puts them in the vars x,y respectively
  79.  
  80.            inregs.x.ax = 0x03; // subfunction 11: get relative motion
  81.            _int86(MOUSE_INT, &inregs, &outregs);
  82.  
  83.            // extract the info and send back to caller via pointers
  84.            *x       = outregs.x.cx;
  85.            *y       = outregs.x.dx;
  86.  
  87.            return(1);
  88.  
  89.            } break;
  90.  
  91.       case MOUSE_SET_SENSITIVITY:
  92.            {
  93.            // this function sets the overall "sensitivity" of the mouse.
  94.            // each axis can have a sensitivity from 1-100.  So the caller
  95.            // should put 1-100 in both "x" and "y" before calling/
  96.            // also "buttons" is used to send in the doublespeed value which
  97.            // ranges from 1-100 also.
  98.  
  99.            inregs.x.bx = *x;
  100.            inregs.x.cx = *y;
  101.            inregs.x.dx = *buttons;
  102.  
  103.            inregs.x.ax = 0x1A; // subfunction 26: set sensitivity
  104.            _int86(MOUSE_INT, &inregs, &outregs);
  105.  
  106.            return(1);
  107.  
  108.            } break;
  109.  
  110.       default:break;
  111.  
  112.       } // end switch
  113.  
  114. } // end Squeze_Mouse
  115.  
  116. //////////////////////////////////////////////////////////////////////////////
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.