Question

I'm new to programming the mouse in C, so can someone please expalin me this basic code?

#include <dos.h>  
union REGS in, out;

void detect_mouse ()
{
    in.x.ax = 0;
    int86 (0X33,&in,&out);   //invoke interrupt
    if (out.x.ax == 0)
        printf ("\nMouse Failed To Initialize");
    else
        printf ("\nMouse was Succesfully Initialized");
}

int main ()
{
    detect_mouse ();
    getch ();
}
Was it helpful?

Solution

This would be code for old, plain MS DOS which would query if the mouse driver (mouse.com/mouse.sys) is loaded or not.

To talk to mouse.sys, you had to fill some processor registers with specific contents, execute interrupt 0x33, then check the processor registers for return values. That's what the function does. You can find a list of most possible register contents and functions here: http://www.delorie.com/djgpp/doc/rbinter/ix/33/00.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top