/* --------------------------------- mouse.c -------------------------------- */ /* This is part of the flight simulator 'fly8'. * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au). */ /* Handler for the mouse as a pointing device. */ #include "fly.h" #include static int nbuttons = 2; static int FAR cal () { union REGS rg; /* cpu register for use of DOS calls */ rg.x.ax = 4; /* set mouse cursor position */ rg.x.cx = 100 << 3; /* middle col */ rg.x.dx = 100 << 3; /* middle row */ int86(0x33, &rg, &rg); return (0); } static int FAR init () { union REGS rg; /* cpu register for use of DOS calls */ struct SREGS segreg; /* cpu segment registers */ long miaddr; /* mouse interupt routine address */ /* check if the mouse drive exists first */ rg.x.ax = 0x3533; /* look at the interrupt 33 address */ int86x(0x21, &rg, &rg, &segreg); miaddr = (((long)segreg.es) << 16) + (long)rg.x.bx; if (miaddr == 0 || *(char FAR *)miaddr == 0xcf) return (1); /* check for mouse present */ rg.x.ax = 0; /* mouse status flag */ int86(0x33, &rg, &rg); /* check for the mouse interupt */ if (rg.x.ax == 0) return (2); #if 0 /* set mouse attributes */ rg.x.ax = 10; /* set text cursor */ rg.x.bx = 0; /* software text cursor please */ rg.x.cx = 0x77ff; /* screen mask */ rg.x.dx = 0x7700; /* cursor mask */ int86(0x33, &rg, &rg); #endif /* set number of columns for mouse */ rg.x.ax = 7; /* set min/max horizontal position */ rg.x.cx = 0; /* start at 0 */ rg.x.dx = 200 << 3; /* end at the end */ int86(0x33, &rg, &rg); /* set number of vertical rows for mouse */ rg.x.ax = 8; /* set min/max vertical position */ rg.x.cx = 0; /* start at 0 */ rg.x.dx = 200 << 3; /* end at the end */ int86(0x33, &rg, &rg); /* set mouse speed */ rg.x.ax = 15; rg.x.cx = 1; /* x speed */ rg.x.dx = 1; /* y speed */ int86(0x33, &rg, &rg); #if 0 /* turn the mouse cursor on */ rg.x.ax = 1; /* Show Cursor */ int86(0x33, &rg, &rg); /* turn the mouse cursor back off */ rg.x.ax = 2; /* Hide Cursor */ int86(0x33, &rg, &rg); #endif /* get it in the middle of the screen */ cal (p); return (0); } static int FAR read () { union REGS rg; char btn[3]; int reading; rg.x.ax = 3; /* Get button status and mouse position */ int86(0x33, &rg, &rg); reading = (rg.x.dx >> 3) - 100; /* x */ reading = (rg.x.cx >> 3) - 100; /* y */ btn[0] = T(rg.x.bx & 0x02); /* right button */ btn[1] = T(rg.x.bx & 0x01); /* left button */ return (0); }