deepstone
view src/mouse.c @ 29:5fa2983bfe61
watcom makefile changes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 22 Sep 2013 18:09:44 +0300 |
parents | f04884489bad |
children |
line source
1 #include "mouse.h"
2 #include "inttypes.h"
4 #define INTR 0x33
6 #define QUERY 0
7 #define SHOW 1
8 #define HIDE 2
9 #define READ 3
10 #define WRITE 4
12 #define XLIM 7
13 #define YLIM 8
15 int have_mouse(void)
16 {
17 int16_t res;
18 __asm {
19 mov ax, QUERY
20 int INTR
21 mov res, ax
22 }
23 return res;
24 }
26 void show_mouse(int show)
27 {
28 int16_t cmd = show ? SHOW : HIDE;
29 __asm {
30 mov ax, cmd
31 int INTR
32 }
33 }
35 int read_mouse(int *xp, int *yp)
36 {
37 int16_t x, y, bn;
39 __asm {
40 mov ax, READ
41 int INTR
42 mov bn, bx
43 mov x, cx
44 mov y, dx
45 /* XXX some sort of div by 8 in the original code ? */
46 }
48 if(xp) *xp = x;
49 if(yp) *yp = y;
50 return bn;
51 }
53 void set_mouse(int x, int y)
54 {
55 __asm {
56 mov ax, WRITE
57 mov ecx, x
58 mov edx, y
59 int INTR
60 }
61 }
63 void set_mouse_limits(int xmin, int ymin, int xmax, int ymax)
64 {
65 __asm {
66 mov ax, XLIM
67 mov ecx, xmin
68 mov edx, xmax
69 int INTR
70 mov ax, YLIM
71 mov ecx, ymin
72 mov edx, ymax
73 int INTR
74 }
75 }