rayzor
annotate 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 |
rev | line source |
---|---|
nuclear@1 | 1 #include "mouse.h" |
nuclear@1 | 2 #include "inttypes.h" |
nuclear@1 | 3 |
nuclear@1 | 4 #define INTR 0x33 |
nuclear@1 | 5 |
nuclear@1 | 6 #define QUERY 0 |
nuclear@1 | 7 #define SHOW 1 |
nuclear@1 | 8 #define HIDE 2 |
nuclear@1 | 9 #define READ 3 |
nuclear@1 | 10 #define WRITE 4 |
nuclear@7 | 11 #define PIXRATE 0xf |
nuclear@1 | 12 |
nuclear@1 | 13 #define XLIM 7 |
nuclear@1 | 14 #define YLIM 8 |
nuclear@1 | 15 |
nuclear@1 | 16 int have_mouse(void) |
nuclear@1 | 17 { |
nuclear@7 | 18 uint16_t res = 0; |
nuclear@7 | 19 _asm { |
nuclear@7 | 20 mov eax, QUERY |
nuclear@7 | 21 int INTR |
nuclear@7 | 22 mov res, ax |
nuclear@7 | 23 } |
nuclear@7 | 24 return res; |
nuclear@1 | 25 } |
nuclear@1 | 26 |
nuclear@1 | 27 void show_mouse(int show) |
nuclear@1 | 28 { |
nuclear@7 | 29 uint16_t cmd = show ? SHOW : HIDE; |
nuclear@7 | 30 _asm { |
nuclear@7 | 31 mov ax, cmd |
nuclear@7 | 32 int INTR |
nuclear@7 | 33 } |
nuclear@1 | 34 } |
nuclear@1 | 35 |
nuclear@1 | 36 int read_mouse(int *xp, int *yp) |
nuclear@1 | 37 { |
nuclear@7 | 38 uint16_t x, y, state; |
nuclear@7 | 39 _asm { |
nuclear@7 | 40 mov eax, READ |
nuclear@7 | 41 int INTR |
nuclear@7 | 42 mov state, bx |
nuclear@7 | 43 mov x, cx |
nuclear@7 | 44 mov y, dx |
nuclear@7 | 45 } |
nuclear@1 | 46 |
nuclear@7 | 47 if(xp) *xp = x; |
nuclear@7 | 48 if(yp) *yp = y; |
nuclear@7 | 49 return state; |
nuclear@1 | 50 } |
nuclear@1 | 51 |
nuclear@1 | 52 void set_mouse(int x, int y) |
nuclear@1 | 53 { |
nuclear@7 | 54 _asm { |
nuclear@7 | 55 mov eax, WRITE |
nuclear@7 | 56 mov ecx, x |
nuclear@7 | 57 mov edx, y |
nuclear@7 | 58 int INTR |
nuclear@7 | 59 } |
nuclear@1 | 60 } |
nuclear@1 | 61 |
nuclear@1 | 62 void set_mouse_limits(int xmin, int ymin, int xmax, int ymax) |
nuclear@1 | 63 { |
nuclear@7 | 64 _asm { |
nuclear@7 | 65 mov eax, XLIM |
nuclear@7 | 66 mov ecx, xmin |
nuclear@7 | 67 mov edx, xmax |
nuclear@7 | 68 int INTR |
nuclear@7 | 69 mov eax, YLIM |
nuclear@7 | 70 mov ecx, ymin |
nuclear@7 | 71 mov edx, ymax |
nuclear@7 | 72 int INTR |
nuclear@7 | 73 } |
nuclear@7 | 74 } |
nuclear@1 | 75 |
nuclear@7 | 76 void set_mouse_rate(int xrate, int yrate) |
nuclear@7 | 77 { |
nuclear@7 | 78 _asm { |
nuclear@7 | 79 mov ax, PIXRATE |
nuclear@7 | 80 mov ecx, xrate |
nuclear@7 | 81 mov edx, yrate |
nuclear@7 | 82 int INTR |
nuclear@7 | 83 } |
nuclear@1 | 84 } |
nuclear@7 | 85 |
nuclear@7 | 86 void set_mouse_mode(enum mouse_mode mode) |
nuclear@7 | 87 { |
nuclear@7 | 88 if(mode == MOUSE_GFX) { |
nuclear@7 | 89 set_mouse_rate(1, 1); |
nuclear@7 | 90 } else { |
nuclear@7 | 91 set_mouse_rate(8, 16); |
nuclear@7 | 92 } |
nuclear@7 | 93 } |