home *** CD-ROM | disk | FTP | other *** search
-
- #include <dos.h> /* for REGS struct definitions */
-
- #define MOLPTR (MOUSEPTR) 0 /* A TRUE NULL MOUSE POINTER */
- #define NULPTR (char *) 0 /* null pointer */
- #define MO_LEFT 0 /* Mouse left button used by mo_wait */
- #define MO_RIGHT 1 /* Mouse right button used by mo_wait */
- #define MO_HDW 1 /* Mouse hardware */
- #define MO_SFT 0 /* Mouse software */
-
- typedef struct mcb /* Mouse control block structure */
- {
- int exists, /* TRUE if MOUSE exists */
- nbuts, /* number of buttons */
- bstat, /* button status */
- nclik, /* number of clicks */
- col, /* position - column */
- row, /* position - row */
- hmove, /* net horizontal movement */
- vmove; /* net vertical movement */
- char *handle; /* my own id */
- } MOUSE, *MOUSEPTR;
-
-
-
- #define MOCAL int86 (0x33, &crp, &rrp)
- #define MOCALX int86x(0x33, &crp, &rrp, &srp)
-
- static MOUSE mm; /* mouse control block */
- static MOUSEPTR m = &mm; /* our mouse (static) */
- static union REGS crp, rrp; /* common hdw registers */
- static struct SREGS srp; /* common segment registers */
-
-
-
- /*
- ************
- * mo_reset * +
- ************
- */
-
- MOUSEPTR mo_reset() /* mouse reset (initialize) */
- {
- crp.x.ax = 0; /* function 0 - reset */
- MOCAL; /* do the int */
- m->exists = rrp.x.ax; /* to exist or not to exist!! */
- m->nbuts = rrp.x.bx; /* number of buttons */
- if(m->exists) { /* do I exist ? */
- m->handle = (char*)m; /* set pointer to myself */
- return(m);
- }
- else {
- m->handle = NULPTR; /* set handle to ozone */
- return(MOLPTR); /* return null MOUSEPTR */
- }
- }
-
-
- /*
- **********
- * mo_pos * +
- **********
- */
-
- void mo_pos(m) /* get position and button status */
- MOUSEPTR m;
- {
- if(m != (MOUSEPTR)m->handle) /* always perform the standard */
- ; /* safety check */
- crp.x.ax = 3; /* function 3 - get position */
- MOCAL; /* fetch location */
- m->bstat = rrp.x.bx; /* button status */
- m->row = rrp.x.dx; /* vertical (row) location */
- m->col = rrp.x.cx; /* horizontal (col) location */
- }
-
-
- /*
- ***********
- * mo_clim * +
- ***********
- */
-
- void mo_clim(m,cmin,cmax) /* set min/max col limits (range) */
- MOUSEPTR m;
- int cmin, cmax;
- {
- if(m != (MOUSEPTR)m->handle) /* always perform the standard */
- ; /* safety check */
- crp.x.ax = 7; /* function 7 - col range */
- crp.x.cx = cmin; /* lower limit */
- crp.x.dx = cmax; /* upper limit */
- MOCAL;
- }
-
- /*
- ***********
- * mo_rlim * +
- ***********
- */
-
- void mo_rlim(m,rmin,rmax) /* set min/max row limits (range) */
- MOUSEPTR m;
- int rmin, rmax;
- {
- if(m != (MOUSEPTR)m->handle) /* always perform the standard */
- ; /* safety check */
- crp.x.ax = 8; /* function 8 - row range */
- crp.x.cx = rmin; /* lower limit */
- crp.x.dx = rmax; /* upper limit */
- MOCAL;
- }
-
-
- /* End */
-