00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <dos.h>
00028
00029 #include "mouse.h"
00030
00031
00032
00033 #ifdef MOUSESOFT
00034 VOID (*_mfunc)(BOOL show, INT16 x, INT16 y);
00035 INT _omc;
00036 INT16 _omx, _omy;
00037 #endif
00038
00039
00040
00041
00042 BOOL mouse_open( VOID )
00043 {
00044 struct REGPACK preg;
00045 #ifdef MOUSESOFT
00046 _mfunc=0;
00047 _omc=1;
00048 #endif
00049 preg.r_ax = 0;
00050 intr(0x33,&preg);
00051 return (preg.r_ax==0);
00052 }
00053
00054
00055
00056 VOID mouse_close( VOID )
00057 {
00058 mouse_hide();
00059 }
00060
00061
00062
00063 PRIVATE VOID mouse_xshow( VOID )
00064 {
00065 struct REGPACK preg;
00066 preg.r_ax = 1;
00067 intr(0x33,&preg);
00068 }
00069
00070
00071
00072 PRIVATE VOID mouse_xhide( VOID )
00073 {
00074 struct REGPACK preg;
00075 preg.r_ax = 2;
00076 intr(0x33,&preg);
00077 }
00078
00079
00080
00081 PRIVATE UINT16 mouse_xget( INT16* x, INT16* y )
00082 {
00083 struct REGPACK preg;
00084 preg.r_ax = 3;
00085 intr(0x33,&preg);
00086 *x = preg.r_cx;
00087 *y = preg.r_dx;
00088 return preg.r_bx;
00089 }
00090
00091
00092
00093 VOID mouse_show( VOID )
00094 {
00095 #ifdef MOUSESOFT
00096 if (_mfunc) {
00097 if (!_omc) return;
00098 _omc--;
00099 if (!_omc) {
00100 mouse_xget(&_omx,&_omy);
00101 _mfunc(TRUE,_omx,_omy);
00102 }
00103 return;
00104 }
00105 #endif
00106
00107 mouse_xshow();
00108 }
00109
00110
00111
00112 VOID mouse_hide( VOID )
00113 {
00114 #ifdef MOUSESOFT
00115 if (_mfunc) {
00116 _omc++;
00117 if (_omc==1) _mfunc(FALSE,_omx,_omy);
00118 return;
00119 }
00120 #endif
00121
00122 mouse_xhide();
00123 }
00124
00125
00126
00127 VOID mouse_set_scale( INT16 xratio, INT16 yratio )
00128 {
00129 struct REGPACK preg;
00130 preg.r_ax = 15;
00131 preg.r_cx = xratio;
00132 preg.r_dx = yratio;
00133 intr(0x33,&preg);
00134 }
00135
00136
00137
00138 UINT16 mouse_get( INT16* x, INT16* y )
00139 {
00140 UINT16 c;
00141 c=mouse_xget(x,y);
00142
00143 #ifdef MOUSESOFT
00144 if (_mfunc&&(!_omc)&&((*x!=_omx)||(*y!=_omy))) {
00145 _mfunc(FALSE,_omx,_omy);
00146 _mfunc(TRUE,*x,*y);
00147 _omx=*x;
00148 _omy=*y;
00149 }
00150 #endif
00151
00152 return c;
00153 }
00154
00155
00156
00157 VOID mouse_set_xy( INT16 x, INT16 y )
00158 {
00159 struct REGPACK preg;
00160 preg.r_ax = 4;
00161 preg.r_cx = x;
00162 preg.r_dx = y;
00163 intr(0x33,&preg);
00164 }
00165
00166
00167
00168 VOID mouse_set_xrange( INT16 x0, INT16 x1 )
00169 {
00170 struct REGPACK preg;
00171 preg.r_ax = 7;
00172 preg.r_cx = x0;
00173 preg.r_dx = x1;
00174 intr(0x33,&preg);
00175 }
00176
00177
00178
00179 VOID mouse_set_yrange( INT16 y0, INT16 y1 )
00180 {
00181 struct REGPACK preg;
00182 preg.r_ax = 8;
00183 preg.r_cx = y0;
00184 preg.r_dx = y1;
00185 intr(0x33,&preg);
00186 }
00187
00188
00189
00190 VOID mouse_set_icon( mouse_cursor * mc )
00191 {
00192 struct REGPACK preg;
00193
00194 preg.r_ax = 9;
00195 preg.r_bx = mc->horz_hot_spot;
00196 preg.r_cx = mc->vert_hot_spot;
00197 preg.r_dx = FP_OFF(&(mc->mask));
00198 preg.r_es = FP_SEG(&(mc->mask));
00199 intr(0x33,&preg);
00200 }
00201
00202
00203
00204 VOID mouse_set_showfunc( VOID (*mfunc)(BOOL show, INT16 x, INT16 y) )
00205 {
00206 #ifdef MOUSESOFT
00207 if (_mfunc) { if (!_omc) _mfunc(FALSE,_omx,_omy); }
00208 else mouse_xhide();
00209
00210 _mfunc=mfunc;
00211 if (_mfunc) {
00212 if (!_omc) { mouse_xget(&_omx,&_omx); _mfunc(TRUE,_omx,_omy); }
00213 }
00214 else mouse_xshow();
00215 #endif
00216 }
00217
00218
00219
00220 VOID mouse_update(VOID)
00221 {
00222 #ifdef MOUSESOFT
00223 INT16 x, y;
00224 mouse_get(&x,&y);
00225 #endif
00226 }
00227
00228