home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / MOUSE4.C < prev    next >
C/C++ Source or Header  |  1992-07-03  |  3KB  |  167 lines

  1. /*
  2. ** some mouse routines
  3. ** by Uwe E. Schirm, May/June 1992
  4. ** placed in public domain
  5. */
  6.  
  7. #include <dos.h>
  8.  
  9. static union REGS r;
  10. static struct SREGS s;
  11.  
  12. /*
  13. ** initialize mouse
  14. */
  15.  
  16. int m_init()
  17. {
  18.       r.x.ax = 0;
  19.       int86(0x33, &r, &r);
  20.       return(r.x.ax);
  21. }
  22.  
  23. /*
  24. ** show mouse cursor
  25. */
  26.  
  27. void m_show()
  28. {
  29.       r.x.ax = 1;
  30.       int86(0x33, &r, &r);
  31. }
  32.  
  33. /*
  34. ** hide mouse cursor
  35. */
  36.  
  37. void m_hide()
  38. {
  39.       r.x.ax = 2;
  40.       int86(0x33, &r, &r);
  41. }
  42.  
  43. /*
  44. ** read mouse position and button status
  45. */
  46.  
  47. void m_read(int *row, int *col, int *but)
  48. {
  49.       r.x.ax = 3;
  50.       int86(0x33, &r, &r);
  51.       *but = r.x.bx;
  52.       *col = r.x.cx;
  53.       *row = r.x.dx;
  54. }
  55.  
  56. /*
  57. ** set mouse to row/column
  58. */
  59.  
  60. void m_pos(int row, int col)
  61. {
  62.       r.x.ax = 4;
  63.       r.x.cx = col;
  64.       r.x.dx = row;
  65.       int86(0x33, &r, &r);
  66. }
  67.  
  68. /*
  69. ** read where and with which button mouse was pressed
  70. */
  71.  
  72. int m_press(int *row, int *col, int but)
  73. {
  74.       r.x.ax = 5;
  75.       r.x.bx = but;
  76.       int86(0x33, &r, &r);
  77.       *col = r.x.cx;
  78.       *row = r.x.dx;
  79.       return(r.x.ax);
  80. }
  81.  
  82. /*
  83. ** read where and with which button mouse was released
  84. */
  85.  
  86. int m_rel(int *row, int *col, int but)
  87. {
  88.       r.x.ax = 6;
  89.       r.x.bx = but;
  90.       int86(0x33, &r, &r);
  91.       *col = r.x.cx;
  92.       *row = r.x.dx;
  93.       return(r.x.ax);
  94. }
  95.  
  96. /*
  97. ** define horizontal range for mouse
  98. */
  99.  
  100. void m_col(int min, int max)
  101. {
  102.       r.x.ax = 7;
  103.       r.x.cx = min;
  104.       r.x.dx = max;
  105.       int86(0x33, &r, &r);
  106. }
  107.  
  108. /*
  109. ** define vertical range for mouse
  110. */
  111.  
  112. void m_row(int min, int max)
  113. {
  114.       r.x.ax = 8;
  115.       r.x.cx = min;
  116.       r.x.dx = max;
  117.       int86(0x33, &r, &r);
  118. }
  119.  
  120. /*
  121. ** show self defined cursor, works only in graphic mode
  122. */
  123.  
  124. void m_show_g()
  125. {
  126.       static unsigned int glove[] = {
  127.             0xf3ff, 0xe1ff, 0xe1ff, 0xe1ff, 0xe1ff, 0xe049, 0xe000, 0x8000,
  128.             0x0000, 0x0000, 0x07fc, 0x07f8, 0x9ff9, 0x8ff1, 0xc003, 0xe007,
  129.             0x0c00, 0x1200, 0x1200, 0x1200, 0x1200, 0x13b6, 0x1249, 0x7249,
  130.             0x9249, 0x9001, 0x9001, 0x8001, 0x4002, 0x4002, 0x2004, 0x1ff8 };
  131.  
  132.       /* first 16 = screenmask, last 16 = cursormask */
  133.  
  134.       segread(&sr);
  135.       sr.es = sr.ds;
  136.       regs.x.ax = 9;
  137.       regs.x.bx = 4;           /* start hotspot */
  138.       regs.x.cx = 0;           /* end hotspot   */
  139.       regs.x.dx = (unsigned) glove;
  140.       int86x(0x33, &r, &r, &s);
  141. }
  142.  
  143. /*
  144. ** set cursor type, works only in text mode
  145. */
  146.  
  147. void m_show_t(int type, unsigned smask, unsigned cmask)
  148. {
  149.       r.x.ax = 10;
  150.       r.x.bx = type;
  151.       r.x.cx = smask;
  152.       r.x.dx = cmask;
  153.       int86(0x33, &r, &r);
  154. }
  155.  
  156. /*
  157. ** read the motion counts
  158. */
  159.  
  160. void m_count(int *row, int *col)
  161. {
  162.       r.x.ax = 0b;
  163.       int86(0x33, &r, &r);
  164.       *col = r.x.cx;
  165.       *row = r.x.dx;
  166. }
  167.