nuclear@1: /* TODO: try NOT using the v8086 interrupts to avoid the overhead */ nuclear@1: #include "mouse.h" nuclear@1: #include "inttypes.h" nuclear@1: #include "dpmi.h" nuclear@1: nuclear@1: #define INTR 0x33 nuclear@1: nuclear@1: #define QUERY 0 nuclear@1: #define SHOW 1 nuclear@1: #define HIDE 2 nuclear@1: #define READ 3 nuclear@1: #define WRITE 4 nuclear@1: nuclear@1: #define XLIM 7 nuclear@1: #define YLIM 8 nuclear@1: nuclear@1: int have_mouse(void) nuclear@1: { nuclear@1: struct dpmi_real_regs regs; nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: regs.eax = QUERY; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: return regs.eax & 0xffff; nuclear@1: } nuclear@1: nuclear@1: void show_mouse(int show) nuclear@1: { nuclear@1: struct dpmi_real_regs regs; nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: regs.eax = show ? SHOW : HIDE; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: } nuclear@1: nuclear@1: int read_mouse(int *xp, int *yp) nuclear@1: { nuclear@1: struct dpmi_real_regs regs; nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: nuclear@1: regs.eax = READ; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: nuclear@1: if(xp) *xp = regs.ecx & 0xffff; nuclear@1: if(yp) *yp = regs.edx & 0xffff; nuclear@1: return regs.ebx & 0xffff; nuclear@1: } nuclear@1: nuclear@1: void set_mouse(int x, int y) nuclear@1: { nuclear@1: struct dpmi_real_regs regs; nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: nuclear@1: regs.eax = WRITE; nuclear@1: regs.ecx = x; nuclear@1: regs.edx = y; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: } nuclear@1: nuclear@1: void set_mouse_limits(int xmin, int ymin, int xmax, int ymax) nuclear@1: { nuclear@1: struct dpmi_real_regs regs; nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: regs.eax = XLIM; nuclear@1: regs.ecx = xmin; nuclear@1: regs.edx = xmax; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: nuclear@1: memset(®s, 0, sizeof regs); nuclear@1: regs.eax = YLIM; nuclear@1: regs.ecx = ymin; nuclear@1: regs.edx = ymax; nuclear@1: dpmi_real_int(INTR, ®s); nuclear@1: }