eobish
diff src/dos/mouse.c @ 7:6a350c554e46
started DOS port
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 19 Jan 2015 15:49:14 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/dos/mouse.c Mon Jan 19 15:49:14 2015 +0200 1.3 @@ -0,0 +1,93 @@ 1.4 +#include "mouse.h" 1.5 +#include "inttypes.h" 1.6 + 1.7 +#define INTR 0x33 1.8 + 1.9 +#define QUERY 0 1.10 +#define SHOW 1 1.11 +#define HIDE 2 1.12 +#define READ 3 1.13 +#define WRITE 4 1.14 +#define PIXRATE 0xf 1.15 + 1.16 +#define XLIM 7 1.17 +#define YLIM 8 1.18 + 1.19 +int have_mouse(void) 1.20 +{ 1.21 + uint16_t res = 0; 1.22 + _asm { 1.23 + mov eax, QUERY 1.24 + int INTR 1.25 + mov res, ax 1.26 + } 1.27 + return res; 1.28 +} 1.29 + 1.30 +void show_mouse(int show) 1.31 +{ 1.32 + uint16_t cmd = show ? SHOW : HIDE; 1.33 + _asm { 1.34 + mov ax, cmd 1.35 + int INTR 1.36 + } 1.37 +} 1.38 + 1.39 +int read_mouse(int *xp, int *yp) 1.40 +{ 1.41 + uint16_t x, y, state; 1.42 + _asm { 1.43 + mov eax, READ 1.44 + int INTR 1.45 + mov state, bx 1.46 + mov x, cx 1.47 + mov y, dx 1.48 + } 1.49 + 1.50 + if(xp) *xp = x; 1.51 + if(yp) *yp = y; 1.52 + return state; 1.53 +} 1.54 + 1.55 +void set_mouse(int x, int y) 1.56 +{ 1.57 + _asm { 1.58 + mov eax, WRITE 1.59 + mov ecx, x 1.60 + mov edx, 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 eax, XLIM 1.69 + mov ecx, xmin 1.70 + mov edx, xmax 1.71 + int INTR 1.72 + mov eax, YLIM 1.73 + mov ecx, ymin 1.74 + mov edx, ymax 1.75 + int INTR 1.76 + } 1.77 +} 1.78 + 1.79 +void set_mouse_rate(int xrate, int yrate) 1.80 +{ 1.81 + _asm { 1.82 + mov ax, PIXRATE 1.83 + mov ecx, xrate 1.84 + mov edx, yrate 1.85 + int INTR 1.86 + } 1.87 +} 1.88 + 1.89 +void set_mouse_mode(enum mouse_mode mode) 1.90 +{ 1.91 + if(mode == MOUSE_GFX) { 1.92 + set_mouse_rate(1, 1); 1.93 + } else { 1.94 + set_mouse_rate(8, 16); 1.95 + } 1.96 +}