eMage - Tutorial to Track Mouse Events in DOS using Interrupts - Part 1


Links
Home
Open Bitmaps with Turbo-C++
Mouse Events Tutorial - 1
Mouse Events Tutorial - 2
Mouse Events Tutorial - 3
Algorithms
Feedback

Support writeKA
writeKA Language Tools

First uploaded on 08-Mar-2003.
Standardised html and moved to new domain on 04-Mar-2006.



Next

Mouse Events Tutorial - Page 1/3
Mouse events are tracked by using the Software Interrupt 0x33. Here '0x' means that the number is hexadecimal. I assume you know what an interrupt is. If you don't, well, just think of it as a kind of direct function call to the system. In the following section you'll see code to perform various operations regarding the mouse. For all of these we issue the 0x33 interrupt, however we change the value in register AX to perform different operations. The other registers may be used to hold other values which may be needed by the call. The interrupt call is made using the int86() function.

This function is defined in dos.h. The unions inreg and outreg hold valus of the registers before and after the call has been made. They are of type union REGS. Union REGS is also defined in dos.h. You can get further information on union REGS and int86() in the Turbo C++ help files.

It should be noted that all the functions below have been implemented for the graphics environment and have not been tested for text mode. First of all we have to initialize the mouse. This is done by the following function. As you can see, we set the value of register AX as 0x0. This tells the system that when the 0x33 interrupt is called, it should initialize the mouse - basically get it ready for the other functions.


The following function makes the mouse pointer visible by setting register AX as 0x1.


The next function hides the mouse pointer by setting register AX as 0x2. It is extremely important that you hide the mouse pointer while outputting to the screen. Not doing so can corrupt the display or cause other unwanted effects.


Next