home *** CD-ROM | disk | FTP | other *** search
- /* The following C program illustrates initialization and interraction with
- the Mouse driver Function 12. Function 12 allows extensions to be made
- to the Mouse driver through the addition of a user defined subroutine.
- The Mouse driver will do a FAR call to the user defined subroutine
- during mouse hardware event processing contingent on the condition of
- of the event and the state of Function 12's interrupt enable mask.
-
- Although Function 12 is designed to add additional functionality
- directly to the Mouse driver, it is also desirable to have Function 12
- interract directly with high level languages. This program illustrates
- how to use Function 12 to alter the contents of a variable defined
- within a C program. This is accomplished by having the Function 12
- call an assembler routine which has been linked to this C main program.
- In this way the assembler routine will have direct access to the C
- programs variables contained within the DGROUP.
-
- The program initializes the mouse (Function 0), sets up the subroutine
- (Function 12), and displays the mouse cursor (Function 1). The program
- remains in a loop until the left button is pressed (Function 3). On
- exit from this loop, the value of 'cvar' is displayed. 'cvar' is
- incremented each time the right button is pressed. 'cvar' is initialized
- to a value of 2. On exit from the program, the cursor is hidden and
- Function 12 disabled (Function 0).
-
- NOTE: Compile in large model - msc /AL demo12.c
- */
-
- #include <stdio.h>
-
- void pascal mousel(); /* MOUSE.LIB definition. */
- void sub(); /* External sub. to inc. cvar */
-
- int m1, m2, m3, m4;
- int cvar = 2; /* C variable to be incremented */
-
- main ()
- {
- void (*subadd)(); /* Void subroutine pointer. */
- /* Must reside in DGROUP! */
-
- m1 = 0; /* Initialize mouse. */
- mousel (&m1, &m2, &m3, &m4);
-
- m1 = 12; /* Function 12 initialization */
- m3 = 8; /* Set mask to enable rt. but. */
- subadd = sub; /* Address of masm subroutine. */
- mousel (&m1, &m2, &m3, &subadd);
-
- m1 = 1; /* Display mouse cursor. */
- mousel (&m1, &m2, &m3, &m4);
-
- do { /* Loop 'til left button hit. */
- m1 = 3; /* Get mouse button status. */
- mousel (&m1, &m2, &m3, &m4);
- } while (!(m2 & 1)); /* Exit on left button press. */
-
- printf ("%x\n", cvar); /* cvar is initialized to 2 and */
- /* can only change via the */
- /* masm Fcn 12 subroutine. */
-
- m1 = 0; /* Cursor off, disable Fcn 12. */
- mousel (&m1, &m2, &m3, &m4);
- }