dos3d
diff src/mouse.c @ 0:f04884489bad
dos3d initial import
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 21 Nov 2011 06:14:01 +0200 |
parents | |
children | 00d84ab1ef26 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/mouse.c Mon Nov 21 06:14:01 2011 +0200 1.3 @@ -0,0 +1,74 @@ 1.4 +#include "mouse.h" 1.5 + 1.6 +#define INTR 0x33 1.7 + 1.8 +#define QUERY 0 1.9 +#define SHOW 1 1.10 +#define HIDE 2 1.11 +#define READ 3 1.12 +#define WRITE 4 1.13 + 1.14 +#define XLIM 7 1.15 +#define YLIM 8 1.16 + 1.17 +int have_mouse(void) 1.18 +{ 1.19 + int res; 1.20 + asm { 1.21 + mov ax, QUERY 1.22 + int INTR 1.23 + mov res, ax 1.24 + } 1.25 + return res; 1.26 +} 1.27 + 1.28 +void show_mouse(int show) 1.29 +{ 1.30 + int cmd = show ? SHOW : HIDE; 1.31 + asm { 1.32 + mov ax, cmd 1.33 + int INTR 1.34 + } 1.35 +} 1.36 + 1.37 +int read_mouse(int *xp, int *yp) 1.38 +{ 1.39 + int x, y, bn; 1.40 + 1.41 + asm { 1.42 + mov ax, READ 1.43 + int INTR 1.44 + mov bn, bx 1.45 + mov x, cx 1.46 + mov y, dx 1.47 + /* XXX some sort of div by 8 in the original code ? */ 1.48 + } 1.49 + 1.50 + if(xp) *xp = x; 1.51 + if(yp) *yp = y; 1.52 + return bn; 1.53 +} 1.54 + 1.55 +void set_mouse(int x, int y) 1.56 +{ 1.57 + asm { 1.58 + mov ax, WRITE 1.59 + mov cx, x 1.60 + mov dx, y 1.61 + int INTR 1.62 + } 1.63 +} 1.64 + 1.65 +void set_mouse_limits(int xmin, int ymin, int xmax, int ymax) 1.66 +{ 1.67 + asm { 1.68 + mov ax, XLIM 1.69 + mov cx, xmin 1.70 + mov dx, xmax 1.71 + int INTR 1.72 + mov ax, YLIM 1.73 + mov cx, ymin 1.74 + mov dx, ymax 1.75 + int INTR 1.76 + } 1.77 +}