2 * Copyright (c) 1992, 1993, 1996
3 * Berkeley Software Design, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Berkeley Software
18 * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * BSDI int33.c,v 2.2 1996/04/08 19:32:54 bostic Exp
32 * $FreeBSD: src/usr.bin/doscmd/mouse.c,v 1.3.2.1 2002/04/25 11:04:51 tg Exp $
33 * $DragonFly: src/usr.bin/doscmd/mouse.c,v 1.2 2003/06/17 04:29:26 dillon Exp $
40 u_char
*mouse_area
= 0;
49 int33(regcontext_t
*REGS
)
56 R_FLAGS
|= PSL_C
; /* We don't support a mouse */
60 printf("Mouse: %02x\n", R_AX
);
62 case 0x00: /* Reset Mouse */
63 printf("Installing mouse driver\n");
64 R_AX
= 0xffff; /* Mouse installed */
65 R_BX
= 2; /* Number of mouse buttons */
66 memset(&mouse_status
, 0, sizeof(mouse_status
));
67 mouse_status
.installed
= 1;
68 mouse_status
.hardcursor
= 1;
69 mouse_status
.end
= 16;
70 mouse_status
.hmickey
= 8;
71 mouse_status
.vmickey
= 16;
72 mouse_status
.doubling
= 100;
73 mouse_status
.init
= -1;
74 mouse_status
.range
.w
= 8 * 80;
75 mouse_status
.range
.h
= 16 * 25;
78 case 0x01: /* Display Mouse Cursor */
79 if ((mouse_status
.init
+= 1) == 0) {
80 mouse_status
.show
= 1;
84 case 0x02: /* Hide Mouse Cursor */
85 if (mouse_status
.init
== 0)
86 mouse_status
.show
= 0;
87 mouse_status
.init
-= 1;
90 case 0x03: /* Get cursor position/button status */
92 R_CX
= mouse_status
.x
;
93 R_DX
= mouse_status
.y
;
94 R_BX
= mouse_status
.buttons
;
97 case 0x04: /* Move mouse cursor */
98 /* mouse_move(GET16(sc->sc_ecx), GET16(sc->sc_edx)); */
101 case 0x05: /* Determine number of times mouse button was active */
106 R_BX
= mouse_status
.downs
[i
];
107 mouse_status
.downs
[i
] = 0;
108 R_AX
= mouse_status
.buttons
;
109 R_CX
= mouse_status
.x
; /* Not quite right */
110 R_DX
= mouse_status
.y
; /* Not quite right */
113 case 0x06: /* Determine number of times mouse button was relsd */
118 R_BX
= mouse_status
.ups
[i
];
119 mouse_status
.ups
[i
] = 0;
120 R_AX
= mouse_status
.buttons
;
121 R_CX
= mouse_status
.x
; /* Not quite right */
122 R_DX
= mouse_status
.y
; /* Not quite right */
125 case 0x07: /* Set min/max horizontal cursor position */
126 mouse_status
.range
.x
= R_CX
;
127 mouse_status
.range
.w
= R_DX
- R_CX
;
130 case 0x08: /* Set min/max vertical cursor position */
131 mouse_status
.range
.y
= R_CX
;
132 mouse_status
.range
.h
= R_DX
- R_CX
;
134 case 0x09: /* Set graphics cursor block */
135 /* BX,CX is hot spot, ES:DX is data. */
138 case 0x0a: /* Set Text Cursor */
139 mouse_status
.hardcursor
= R_BX
? 1 : 0;
140 mouse_status
.start
= R_CX
;
141 mouse_status
.end
= R_CX
; /* XXX is this right ? */
144 case 0x0b: /* Read Mouse Motion Counters */
146 R_CX
= mouse_status
.x
- mouse_status
.lastx
;
147 R_DX
= mouse_status
.y
- mouse_status
.lasty
;
150 case 0x0c: /* Set event handler */
151 mouse_status
.mask
= R_CX
;
152 mouse_status
.handler
= MAKEVEC(R_ES
, R_DX
);
155 case 0x0d: /* Enable light pen */
156 case 0x0e: /* Disable light pen */
159 case 0x0f: /* Set cursor speed */
160 mouse_status
.hmickey
= R_CX
;
161 mouse_status
.vmickey
= R_DX
;
164 case 0x10: /* Exclusive area */
165 mouse_status
.exclude
.x
= R_CX
;
166 mouse_status
.exclude
.y
= R_DX
;
167 mouse_status
.exclude
.w
= R_SI
- R_CX
;
168 mouse_status
.exclude
.h
= R_DI
- R_DX
;
171 case 0x13: /* Set maximum for mouse speed doubling */
173 case 0x14: /* Exchange event handlers */
174 mask
= mouse_status
.mask
;
175 vec
= mouse_status
.handler
;
177 mouse_status
.mask
= R_CX
;
178 mouse_status
.handler
= MAKEVEC(R_ES
, R_DX
);
180 PUTVEC(R_ES
, R_DX
, vec
);
183 case 0x15: /* Determine mouse status buffer size */
184 R_BX
= sizeof(mouse_status
);
187 case 0x16: /* Store mouse buffer */
188 memcpy((char *)MAKEPTR(R_ES
, R_DX
), &mouse_status
,
189 sizeof(mouse_status
));
192 case 0x17: /* Restore mouse buffer */
193 memcpy(&mouse_status
, (char *)MAKEPTR(R_ES
, R_DX
),
194 sizeof(mouse_status
));
197 case 0x18: /* Install alternate handler */
199 if ((R_CX
& 0xe0) == 0x00 ||
200 mask
== mouse_status
.altmask
[0] ||
201 mask
== mouse_status
.altmask
[1] ||
202 mask
== mouse_status
.altmask
[2] ||
203 (mouse_status
.altmask
[i
= 0] &&
204 mouse_status
.altmask
[i
= 1] &&
205 mouse_status
.altmask
[i
= 2])) {
209 mouse_status
.altmask
[i
] = R_CX
;
210 mouse_status
.althandler
[i
] = MAKEVEC(R_ES
, R_DX
);
213 case 0x19: /* Determine address of alternate event handler */
215 if (mask
== mouse_status
.altmask
[0])
216 vec
= mouse_status
.althandler
[0];
217 else if (mask
== mouse_status
.altmask
[1])
218 vec
= mouse_status
.althandler
[1];
219 else if (mask
== mouse_status
.altmask
[2])
220 vec
= mouse_status
.althandler
[2];
223 PUTVEC(R_ES
, R_DX
, vec
);
226 case 0x1a: /* set mouse sensitivity */
227 mouse_status
.hmickey
= R_BX
;
228 mouse_status
.vmickey
= R_CX
;
229 mouse_status
.doubling
= R_DX
;
232 case 0x1b: /* get mouse sensitivity */
233 R_BX
= mouse_status
.hmickey
;
234 R_CX
= mouse_status
.vmickey
;
235 R_DX
= mouse_status
.doubling
;
238 case 0x1c: /* set mouse hardware rate */
239 case 0x1d: /* set display page */
242 case 0x1e: /* get display page */
243 R_BX
= 0; /* Always on display page 0 */
246 case 0x1f: /* Disable mouse driver */
247 if (mouse_status
.installed
) {
248 PUTVEC(R_ES
, R_DX
, mouse_status
.handler
);
249 mouse_status
.installed
= 0;
255 case 0x20: /* Enable mouse driver */
256 mouse_status
.installed
= 1;
259 case 0x21: /* Reset mouse driver */
260 if (mouse_status
.installed
) {
261 mouse_status
.show
= 0;
262 mouse_status
.handler
= 0;
263 mouse_status
.mask
= 0;
264 mouse_status
.cursor
= 0;
270 case 0x22: /* Specified language for mouse messages */
273 case 0x23: /* Get language number */
274 R_BX
= 0; /* Always return english */
277 case 0x24: /* Get mouse type */
278 R_CX
= 0x0400; /* PS/2 style mouse */
279 R_BX
= 0x0600 + 24; /* Version 6.24 */
293 vec
= insert_softint_trampoline();
295 register_callback(vec
, int33
, "int 33");