home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / vifs / gmtc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-30  |  3.9 KB  |  185 lines

  1. /*
  2.  *    gmtc.c -- genious mouse C interface (Turbo C, small memory model)
  3.  *
  4.  *
  5.  *    2 oct 1988  Olle
  6.  */
  7.  
  8. #include <dos.h>
  9. /*#include <gmtc.h>  TEST */
  10. #include "gmtc.h"
  11.  
  12. #define gmc    geninterrupt( 0x33 )
  13.  
  14. /* genious mouse functions */
  15.  
  16. int gm_init( void )
  17. {
  18. /* init mouse driver, return number of buttons (2 or 3) or 0  (fail) */
  19. /* this also sets defaults: cursor hidden, arrow shaped graphic cursor,
  20.  * text cursor in reversed video, user defined call mask all zeros,
  21.  * light pen emulation enabled, vertical mickey/pixel ratio 16 to 8,
  22.  * horizontal mickey/pixel ratio 8 to 8, min/max cursor postion
  23.  * hor/vert 0..current display mode max */
  24.  
  25. _AX = 0;
  26. gmc;
  27. return (_AX ? _BX : 0);
  28. }
  29.  
  30. void gm_show( void )
  31. {
  32. /* show cursor */
  33. _AX = 1;
  34. gmc;
  35. }
  36.  
  37. void gm_hide( void )
  38. {
  39. /* hide cursor */
  40. _AX = 2;
  41. gmc;
  42. }
  43.  
  44. void gm_getpos( struct gm_status *stat )
  45. {
  46. /* get mouse cursor position */
  47. _AX = 3;
  48. gmc;
  49. stat -> gm_pbutton = _BX;    /* button status */
  50. stat -> gm_xpos  = _CX;    /* horizontal position */
  51. stat -> gm_ypos  = _DX;    /* vertical position */
  52. }
  53.  
  54. void gm_setpos( int col, int row )
  55. {
  56. /* set mouse cursor position */
  57. _AX = 4;
  58. _CX = col;
  59. _DX = row;
  60. gmc;
  61. }
  62.  
  63. void gm_press( int button, struct gm_status *stat  )
  64. {
  65. /* get button press information */
  66. _AX = 5;
  67. _BX = button;    /* 0 = left, 1 = middle, 2 = right */
  68. gmc;
  69. stat -> gm_pbutton = _AX;    /* button status */
  70. stat -> gm_count = _BX;        /* number of button presses */
  71. stat -> gm_xpos  = _CX;        /* horizontal position */
  72. stat -> gm_ypos  = _DX;        /* vertical position */
  73. }
  74.  
  75. void gm_release( int button, struct gm_status *stat )
  76. {
  77. /* get button release information */
  78. _AX = 6;
  79. _BX = button;    /* 0 = left, 1 = middle, 2 = right */
  80. gmc;
  81. stat -> gm_pbutton = _AX;    /* button status */
  82. stat -> gm_count = _BX;        /* number of button releases */
  83. stat -> gm_xpos  = _CX;        /* horizontal position */
  84. stat -> gm_ypos  = _DX;        /* vertical position */
  85. }
  86.  
  87. void gm_hlimit( int min, int max )
  88. {
  89. /* set cursor horizontal max and min */
  90. _AX = 7;
  91. _CX = min;
  92. _DX = max;
  93. gmc;
  94. }
  95.  
  96. void gm_vlimit( int min, int max )
  97. {
  98. /* set cursor vertical max and min */
  99. _AX = 8;
  100. _CX = min;
  101. _DX = max;
  102. gmc;
  103. }
  104.  
  105. void gm_defg( struct gm_gcurs *gcurs )
  106. {
  107. /* define graphics cursor */
  108. _ES = _DS;    /* segmemt for the limit array, for sure es is al ready == ds */
  109. _DX = (int) &gcurs -> gm_scmask; /* screen & cursor masks 16+16 words ds:dx? */
  110. _AX = 9;
  111. _BX = gcurs -> gm_hhot;        /* horizontal hot -16..16, upper left (0,0) */
  112. _CX = gcurs -> gm_vhot;        /* vertical hot spot */
  113. gmc;
  114. }
  115.  
  116. void gm_deft( int hard, int scstart, int scstop )
  117. {
  118. /* define text cursor */
  119. _AX = 10;
  120. _BX = hard;    /* hard/soft cursor */
  121. _CX = scstart;    /* scan line start/screen mask */
  122. _DX = scstop;    /* scan line stop/cursor mask */
  123. gmc;
  124. }
  125.  
  126. void gm_getmickey( struct gm_status *stat )
  127. {
  128. /* get mouse motion (mickey) counters */
  129. _AX = 11;
  130. gmc;
  131. stat -> gm_xpos  = _CX;    /* horizontal count */
  132. stat -> gm_ypos  = _DX;    /* vertical count */
  133. }
  134.  
  135. void gm_event( int mask, int (*func)() )
  136. {
  137. _ES = _CS;         /* code segment, this uses _AX so do it first */
  138. _AX = 12;
  139. _CX = mask;        /* call mask, bit 0: position, 1..3 press, 4..6 release */
  140. _DX = (int) func;    /* event handler */
  141. gmc;
  142. _ES = _DS;        /* restore (small memory model) */
  143. }
  144.  
  145. void gm_lpon( void )
  146. {
  147. /* light pen enulation on */
  148. _AX = 13;
  149. gmc;
  150. }
  151.  
  152. void gm_lpoff( void )
  153. {
  154. /* light pen enulation off */
  155. _AX = 14;
  156. gmc;
  157. }
  158.  
  159. void gm_setmpr( int hrat, int vrat )
  160. {
  161. /* set mickey/pixel ratio */
  162. _AX = 15;
  163. _CX = hrat;    /* horizontal */
  164. _DX = vrat;    /* vertical */
  165. gmc;
  166. }
  167.  
  168. void gm_chide( struct gm_chbox *box )
  169. {
  170. /* conditionally hide cursor */
  171. _ES = _DS;    /* segmemt for the limit array, for sure es is al ready == ds */
  172. _AX = 16;
  173. _DX = (int) box;    /* limits for hide: left, upper, right and lower */
  174. gmc;
  175. }
  176.  
  177. void gm_setspl( int limit )
  178. {
  179. /* set double speed limit */
  180. _AX = 17;
  181. _DX = limit;    /* speed limit in mickeys/second */
  182. gmc;
  183. }
  184.  
  185.