home *** CD-ROM | disk | FTP | other *** search
/ MegaDoom Adventures / PMWMEGADOOM.iso / doom / creators / deu521 / source / mouse.c < prev    next >
C/C++ Source or Header  |  1994-05-18  |  3KB  |  178 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.    struct SREGS sregs;
  32.  
  33.    regs.x.ax = 0x0000;
  34.    int86(MOUSE, ®s, ®s);
  35.    if (regs.x.ax == 0xffff)
  36.    {
  37.       UseMouse = TRUE; /* mouse */
  38. #ifdef CIRRUS_PATCH
  39.       /*
  40.          note from RQ:
  41.             This test is temporary and should be removed in DEU 5.3
  42.             We should create a better "fake cursor" by using the
  43.             mouse callback function.  Remember to remove the callback
  44.             when DEU exits...
  45.       */
  46.       if (CirrusCursor == TRUE)
  47.       {
  48.          regs.x.ax = 0x000C;
  49.          regs.x.cx = 0x0001;
  50.          regs.x.dx = FP_OFF( MouseCallBackFunction);
  51.          sregs.es  = FP_SEG( MouseCallBackFunction);
  52.          int86x( MOUSE, ®s, ®s, &sregs);
  53.       }
  54. #endif /* CIRRUS_PATCH */
  55.    }
  56.    else
  57.       UseMouse = FALSE; /* no mouse */
  58. }
  59.  
  60.  
  61.  
  62. /*
  63.    show the pointer
  64. */
  65.  
  66. void ShowMousePointer()
  67. {
  68.    union REGS regs;
  69.  
  70.    regs.x.ax = 0x0001;
  71.    int86(MOUSE, ®s, ®s);
  72. }
  73.  
  74.  
  75.  
  76. /*
  77.    hide the pointer
  78. */
  79.  
  80. void HideMousePointer()
  81. {
  82.    union REGS regs;
  83.  
  84.    regs.x.ax = 0x0002;
  85.    int86(MOUSE, ®s, ®s);
  86. }
  87.  
  88.  
  89.  
  90. /*
  91.    read pointer coordinates
  92. */
  93.  
  94. void GetMouseCoords(int *x, int *y, int *buttons)
  95. {
  96.    union REGS regs;
  97.  
  98.    regs.x.ax = 0x0003;
  99.    int86(MOUSE, ®s, ®s);
  100.    if (x != NULL)
  101.       *x = regs.x.cx;
  102.    if (y != NULL)
  103.       *y = regs.x.dx;
  104.    if (buttons)
  105.       *buttons = regs.x.bx;
  106. }
  107.  
  108.  
  109.  
  110. /*
  111.    change pointer coordinates
  112. */
  113.  
  114. void SetMouseCoords( int x, int y)
  115. {
  116.    union REGS regs;
  117.  
  118.    regs.x.ax = 0x0004;
  119.    regs.x.cx = (unsigned) x;
  120.    regs.x.dx = (unsigned) y;
  121.    int86(MOUSE, ®s, ®s);
  122. }
  123.  
  124.  
  125.  
  126. /*
  127.    set horizontal and vertical limits (constrain pointer in a box)
  128. */
  129.  
  130. void SetMouseLimits( int x0, int y0, int x1, int y1)
  131. {
  132.    union REGS regs;
  133.  
  134.    regs.x.ax = 0x0007;
  135.    regs.x.cx = (unsigned) x0;
  136.    regs.x.dx = (unsigned) x1;
  137.    int86(MOUSE, ®s, ®s);
  138.    regs.x.ax = 0x0008;
  139.    regs.x.cx = (unsigned) y0;
  140.    regs.x.dx = (unsigned) y1;
  141.    int86(MOUSE, ®s, ®s);
  142. }
  143.  
  144.  
  145.  
  146. /*
  147.    reset horizontal and vertical limits
  148. */
  149.  
  150. void ResetMouseLimits()
  151. {
  152.    union REGS regs;
  153.  
  154.    regs.x.ax = 0x0007;
  155.    regs.x.cx = (unsigned) 0;
  156.    regs.x.dx = (unsigned) ScrMaxX;
  157.    int86(MOUSE, ®s, ®s);
  158.    regs.x.ax = 0x0008;
  159.    regs.x.cx = (unsigned) 0;
  160.    regs.x.dx = (unsigned) ScrMaxY;
  161.    int86(MOUSE, ®s, ®s);
  162. }
  163.  
  164.  
  165. /*
  166.    mouse callback function
  167. */
  168.  
  169. void MouseCallBackFunction()
  170. {
  171. #ifdef CIRRUS_PATCH
  172.    if (CirrusCursor == TRUE)
  173.       SetHWCursorPos(_CX, _DX);
  174. #endif /* CIRRUS_PATCH */
  175. }
  176.  
  177. /* end of file */
  178.