home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / WIN / DOS / MOUSE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-16  |  2.4 KB  |  148 lines

  1. /* ==( dos/mouse.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C  Copyright (C) 1989 - 1990 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   Bob   3-Oct-89                        */
  9. /* Modified  Geo  18-Apr-90  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *  18-Apr-90  Geo - Merged for physical/logical split
  17.  *   3-Oct-89  Bob - Written
  18. */
  19.  
  20. # include <stdio.h>
  21. # include <bench.h>
  22.  
  23. # ifdef MOUSE
  24.  
  25. # include "pregs.h"
  26.  
  27. /* Local access << extern in huge model */
  28. static char local_mouse = 0;
  29.  
  30. /*
  31.  * Initialize the mouse (if present)
  32.  * sets mouse_present accordingly
  33. */
  34. void mouse_init()
  35. {
  36. RegStorage;
  37.  
  38.     /*
  39.       * check memory position for int 0x33 here
  40.     */
  41.    Regs_ax = 0x21;
  42.  
  43.     Mouse();
  44.  
  45.    local_mouse = (char)Regs_ax;
  46.    mouse_num_buttons = Regs_bx;
  47.  
  48.     if (local_mouse == 0x21)
  49.         local_mouse = 0;
  50.  
  51.     mouse_present = local_mouse;
  52. }
  53.  
  54. /*
  55.  * Reset mouse (and get status)
  56. */
  57. void mouse_end()
  58. {
  59. RegStorage;
  60.  
  61.     if (!local_mouse)
  62.         return;
  63.  
  64.     mouse_cursor(OFF);
  65.    Regs_ax = 0x0;
  66.  
  67.     Mouse();
  68. }
  69.  
  70. /*
  71.  * Switch mouse cursor on or off
  72. */
  73. void mouse_cursor(on_off)
  74. int on_off;
  75. {
  76. RegStorage;
  77.  
  78.     if (!local_mouse)
  79.         return;
  80.  
  81.     /* Geo says what about (0 + 1) == off and (1 + 1) == on ? */
  82.    Regs_ax = on_off ? 1 : 2;
  83.  
  84.     Mouse();
  85. }
  86.  
  87. /*
  88.  * Get mouse position (and button status)
  89. */
  90. int mouse_position(x, y)
  91. unsigned int *x, *y;
  92. {
  93. RegStorage;
  94.  
  95.     if (!local_mouse)
  96.         return(0);
  97.  
  98.    Regs_ax = 3;
  99.  
  100.     Mouse();
  101.  
  102.    *x = Regs_cx;
  103.    *y = Regs_dx;
  104.    return(Regs_bx);
  105. }
  106.  
  107. /*
  108.  * Set mouse pointer position
  109. */
  110. void mouse_set_position(x, y)
  111. unsigned int x,y;
  112. {
  113. RegStorage;
  114.  
  115.     if (!local_mouse)
  116.         return;
  117.  
  118.    Regs_cx = (x - 1) * mouse_x_divisor;
  119.    Regs_dx = (y - 1) * mouse_y_divisor;
  120.    Regs_ax = 4;
  121.  
  122.     Mouse();
  123. }
  124.  
  125. /*
  126.  * Get button release information
  127. */
  128. void mouse_button_release(button, x , y)
  129. int button;
  130. unsigned int *x, *y;
  131. {
  132. RegStorage;
  133.  
  134.     if (!local_mouse)
  135.         return;
  136.  
  137.    Regs_bx = button;
  138.    Regs_ax = 6;
  139.  
  140.     Mouse();
  141.  
  142.    mouse_up_down = Regs_ax;
  143.    *x = Regs_cx;
  144.    *y = Regs_dx;
  145. }
  146.  
  147. # endif
  148.