rayzor

view src/mouse.c @ 17:79609d482762

the renderer renders, also fixed an unnoticed matrix conversion problem between scenegraph and min3d
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 14 Apr 2014 07:34:45 +0300
parents a826bf0fb169
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
11 #define PIXRATE 0xf
13 #define XLIM 7
14 #define YLIM 8
16 int have_mouse(void)
17 {
18 uint16_t res = 0;
19 _asm {
20 mov eax, QUERY
21 int INTR
22 mov res, ax
23 }
24 return res;
25 }
27 void show_mouse(int show)
28 {
29 uint16_t cmd = show ? SHOW : HIDE;
30 _asm {
31 mov ax, cmd
32 int INTR
33 }
34 }
36 int read_mouse(int *xp, int *yp)
37 {
38 uint16_t x, y, state;
39 _asm {
40 mov eax, READ
41 int INTR
42 mov state, bx
43 mov x, cx
44 mov y, dx
45 }
47 if(xp) *xp = x;
48 if(yp) *yp = y;
49 return state;
50 }
52 void set_mouse(int x, int y)
53 {
54 _asm {
55 mov eax, WRITE
56 mov ecx, x
57 mov edx, y
58 int INTR
59 }
60 }
62 void set_mouse_limits(int xmin, int ymin, int xmax, int ymax)
63 {
64 _asm {
65 mov eax, XLIM
66 mov ecx, xmin
67 mov edx, xmax
68 int INTR
69 mov eax, YLIM
70 mov ecx, ymin
71 mov edx, ymax
72 int INTR
73 }
74 }
76 void set_mouse_rate(int xrate, int yrate)
77 {
78 _asm {
79 mov ax, PIXRATE
80 mov ecx, xrate
81 mov edx, yrate
82 int INTR
83 }
84 }
86 void set_mouse_mode(enum mouse_mode mode)
87 {
88 if(mode == MOUSE_GFX) {
89 set_mouse_rate(1, 1);
90 } else {
91 set_mouse_rate(8, 16);
92 }
93 }