4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
5 |
|
#endif |
6 |
|
|
7 |
– |
/* |
8 |
– |
* Microsoft Mouse handling routines |
9 |
– |
*/ |
10 |
– |
|
11 |
– |
#include <stdio.h> |
12 |
– |
#include <dos.h> |
7 |
|
#include <i86.h> |
8 |
|
#include <graph.h> |
9 |
|
#include "driver.h" |
10 |
|
|
11 |
+ |
#define NULL 0 |
12 |
+ |
|
13 |
|
#define M_RIGHTBUTT 0x8 |
14 |
|
#define M_LEFTBUTT 0x2 |
15 |
|
#define M_MOTION 0x1 |
16 |
|
|
17 |
< |
static int ydispsize; |
17 |
> |
static int xdispsize, ydispsize; |
18 |
|
static int crad; |
19 |
|
#define right_button (mouse_event & M_RIGHTBUTT) |
20 |
|
#define left_button (mouse_event & M_LEFTBUTT) |
41 |
|
extern char *bmalloc(); |
42 |
|
static char *imp = NULL; |
43 |
|
static int curx = -1, cury = -1; |
44 |
+ |
#define xcmin (curx-crad<0 ? 0 : curx-crad) |
45 |
+ |
#define ycmin (cury-crad<0 ? 0 : cury-crad) |
46 |
+ |
#define xcmax (curx+crad>=xdispsize ? xdispsize-1 : curx+crad) |
47 |
+ |
#define ycmax (cury+crad>=ydispsize ? ydispsize-1 : cury+crad) |
48 |
|
|
49 |
|
if (imp == NULL && |
50 |
|
(imp = bmalloc(_imagesize(0,0,2*crad+1,2*crad+1))) == NULL) { |
52 |
|
quit(1); |
53 |
|
} |
54 |
|
if (curx >= 0 & cury >= 0) /* clear old cursor */ |
55 |
< |
_putimage(curx-crad, cury-crad, imp, _GPSET); |
55 |
> |
_putimage(xcmin, ycmin, imp, _GPSET); |
56 |
|
/* record new position */ |
57 |
|
curx = newx; cury = newy; |
58 |
|
if (curx < 0 | cury < 0) |
59 |
|
return; /* no cursor */ |
60 |
|
/* save under new cursor */ |
61 |
< |
_getimage(newx-crad,newy-crad,newx+crad,newy+crad, imp); |
61 |
> |
_getimage(xcmin, ycmin, xcmax, ycmax, imp); |
62 |
|
/* draw new cursor */ |
63 |
|
_setcolor(1); |
64 |
< |
_rectangle(_GFILLINTERIOR, newx-crad, newy-1, newx+crad, newy+1); |
65 |
< |
_rectangle(_GFILLINTERIOR, newx-1, newy-crad, newx+1, newy+crad); |
64 |
> |
_rectangle(_GFILLINTERIOR, xcmin, cury-1, xcmax, cury+1); |
65 |
> |
_rectangle(_GFILLINTERIOR, curx-1, ycmin, curx+1, ycmax); |
66 |
|
_setcolor(0); |
67 |
< |
_moveto(newx-crad+1, newy); |
68 |
< |
_lineto(newx+crad-1, newy); |
69 |
< |
_moveto(newx, newy-crad+1); |
70 |
< |
_lineto(newx, newy+crad-1); |
67 |
> |
_moveto(xcmin+1, cury); |
68 |
> |
_lineto(xcmax-1, cury); |
69 |
> |
_moveto(curx, ycmin+1); |
70 |
> |
_lineto(curx, ycmax-1); |
71 |
> |
#undef xcmin |
72 |
> |
#undef ycmin |
73 |
> |
#undef xcmax |
74 |
> |
#undef ycmax |
75 |
|
} |
76 |
|
|
77 |
|
|
151 |
|
|
152 |
|
/* get relevant parameters */ |
153 |
|
|
154 |
+ |
xdispsize = dp->xsiz; |
155 |
|
ydispsize = dp->ysiz; |
156 |
|
crad = dp->ysiz/40; |
157 |
|
|
158 |
+ |
/* set screen limits */ |
159 |
+ |
|
160 |
+ |
inregs.w.ax = 0x7; /* horizontal resolution */ |
161 |
+ |
inregs.w.cx = 0; |
162 |
+ |
inregs.w.dx = xdispsize-1; |
163 |
+ |
int386x( 0x33, &inregs, &outregs, &sregs ); |
164 |
+ |
inregs.w.ax = 0x8; /* vertical resolution */ |
165 |
+ |
inregs.w.cx = 0; |
166 |
+ |
inregs.w.dx = ydispsize-1; |
167 |
+ |
int386x( 0x33, &inregs, &outregs, &sregs ); |
168 |
+ |
|
169 |
|
/* install watcher */ |
170 |
|
|
171 |
|
inregs.w.ax = 0xC; |
177 |
|
|
178 |
|
dp->getcur = ms_getcur; |
179 |
|
} |
180 |
+ |
|
181 |
+ |
void |
182 |
+ |
ms_gcdone( dp ) |
183 |
+ |
struct driver *dp; |
184 |
+ |
{ |
185 |
+ |
union REGS inregs, outregs; |
186 |
+ |
|
187 |
+ |
if (dp->getcur != ms_getcur) |
188 |
+ |
return; /* not installed */ |
189 |
+ |
|
190 |
+ |
dp->getcur = NULL; |
191 |
+ |
|
192 |
+ |
/* uninstall watcher */ |
193 |
+ |
|
194 |
+ |
inregs.w.ax = 0; |
195 |
+ |
int386 (0x33, &inregs, &outregs); |
196 |
+ |
} |
197 |
+ |
|