home *** CD-ROM | disk | FTP | other *** search
- /*
- * m_init.c
- *
- * Public Domain (p) March 1990 By Rodney Loos
- * Syntax modified by S. Sampson
- */
-
- #define MAIN
-
- #include <dos.h>
- #include <alloc.h>
- #include "mouse.h"
-
- M_POS *__Mptr;
- Param *__Mpar;
-
- int m_init(void)
- {
- union REGS mreg;
- struct SREGS segs;
-
- /* User needs DOS 2 or higher to use these routines */
-
- if (_osmajor < 2)
- return(2);
-
- __Mpar = (Param *) malloc(sizeof(Param));
- __Mptr = (M_POS *) malloc(sizeof(M_POS));
-
- /* initialize variables to 0 */
-
- __Mpar->m1 = __Mpar->m2 = __Mpar->m3 = __Mpar->m4 = 0;
-
- /* status returned in __Mpar->m1, if 0 then not installed */
-
- if (_osmajor >= 3)
- mouse(__Mpar);
- else { /* it's version 2 */
- mreg.h.ah = 0x35; /* Function to get interrupt vector */
- mreg.h.al = 0x33; /* mouse interrupt number */
- intdosx(&mreg, &mreg, &segs);
-
- if (segs.es == 0 && mreg.x.bx == 0)
- __Mpar->m1 = 0; /* if vector points to 0000:0000,
- mouse not in */
- else
- mouse(__Mpar); /* initialize mouse */
- }
-
- return (__Mpar->m1);
- }
-
- void mouse(Param *mptr)
- {
- union REGS mousreg;
-
- mousreg.x.ax = mptr->m1;
- mousreg.x.bx = mptr->m2;
- mousreg.x.cx = mptr->m3;
- mousreg.x.dx = mptr->m4;
- int86(0x33, &mousreg, &mousreg); /* mouse interrupt */
-
- mptr->m1 = mousreg.x.ax;
- mptr->m2 = mousreg.x.bx;
- mptr->m3 = mousreg.x.cx;
- mptr->m4 = mousreg.x.dx;
- }