home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / GAMES_C / DEU50.ZIP / SOURCE.ZIP / MOUSE.C < prev    next >
C/C++ Source or Header  |  1994-03-27  |  2KB  |  147 lines

  1. /*
  2.    Mouse interface by Raphaël Quinet <quinet@montefiore.ulg.ac.be>
  3.  
  4.    You are allowed to use any parts of this code in another program, as
  5.    long as you give credits to the authors in the documentation and in
  6.    the program itself.  Read the file README.1ST for more information.
  7.  
  8.    This program comes with absolutely no warranty.
  9.  
  10.    MOUSE.C - Mouse driver routines.
  11. */
  12.  
  13. /* the includes */
  14. #include "deu.h"
  15. #include <dos.h>
  16.  
  17. /* mouse interrupt number */
  18. #define MOUSE 0x33
  19.  
  20. /* the global data */
  21. Bool UseMouse;            /* is there a mouse driver? */
  22.  
  23.  
  24. /*
  25.    initialize the mouse driver
  26. */
  27.  
  28. void CheckMouseDriver()
  29. {
  30.    union REGS regs;
  31.  
  32.    regs.x.ax = 0x0000;
  33.    int86(MOUSE, ®s, ®s);
  34.    if (regs.x.ax == 0xffff)
  35.       UseMouse = TRUE; /* mouse */
  36.    else
  37.       UseMouse = FALSE; /* no mouse */
  38. }
  39.  
  40.  
  41.  
  42. /*
  43.    show the pointer
  44. */
  45.  
  46. void ShowMousePointer()
  47. {
  48.    union REGS regs;
  49.  
  50.    regs.x.ax = 0x0001;
  51.    int86(MOUSE, ®s, ®s);
  52. }
  53.  
  54.  
  55.  
  56. /*
  57.    hide the pointer
  58. */
  59.  
  60. void HideMousePointer()
  61. {
  62.    union REGS regs;
  63.  
  64.    regs.x.ax = 0x0002;
  65.    int86(MOUSE, ®s, ®s);
  66. }
  67.  
  68.  
  69.  
  70. /*
  71.    read pointer coordinates
  72. */
  73.  
  74. void GetMouseCoords(int *x, int *y, int *buttons)
  75. {
  76.    union REGS regs;
  77.  
  78.    regs.x.ax = 0x0003;
  79.    int86(MOUSE, ®s, ®s);
  80.    if (x)
  81.       *x = regs.x.cx;
  82.    if (y)
  83.       *y = regs.x.dx;
  84.    if (buttons)
  85.       *buttons = regs.x.bx;
  86. }
  87.  
  88.  
  89.  
  90. /*
  91.    change pointer coordinates
  92. */
  93.  
  94. void SetMouseCoords( int x, int y)
  95. {
  96.    union REGS regs;
  97.  
  98.    regs.x.ax = 0x0004;
  99.    regs.x.cx = (unsigned) x;
  100.    regs.x.dx = (unsigned) y;
  101.    int86(MOUSE, ®s, ®s);
  102. }
  103.  
  104.  
  105.  
  106. /*
  107.    set horizontal and vertical limits (constrain pointer in a box)
  108. */
  109.  
  110. void SetMouseLimits( int x0, int y0, int x1, int y1)
  111. {
  112.    union REGS regs;
  113.  
  114.    regs.x.ax = 0x0007;
  115.    regs.x.cx = (unsigned) x0;
  116.    regs.x.dx = (unsigned) x1;
  117.    int86(MOUSE, ®s, ®s);
  118.    regs.x.ax = 0x0008;
  119.    regs.x.cx = (unsigned) y0;
  120.    regs.x.dx = (unsigned) y1;
  121.    int86(MOUSE, ®s, ®s);
  122. }
  123.  
  124.  
  125.  
  126. /*
  127.    reset horizontal and vertical limits
  128. */
  129.  
  130. void ResetMouseLimits()
  131. {
  132.    union REGS regs;
  133.  
  134.    regs.x.ax = 0x0007;
  135.    regs.x.cx = (unsigned) 0;
  136.    regs.x.dx = (unsigned) ScrMaxX;
  137.    int86(MOUSE, ®s, ®s);
  138.    regs.x.ax = 0x0008;
  139.    regs.x.cx = (unsigned) 0;
  140.    regs.x.dx = (unsigned) ScrMaxY;
  141.    int86(MOUSE, ®s, ®s);
  142. }
  143.  
  144.  
  145.  
  146. /* end of file */
  147.