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