#include<dos.h>
/*reset mouse,ax=0,return if ax=0 means there is not mouse installed
-1 means there is mouse installed,and save the number of buttons in bx*/
void mouse_init(void)
{
union REGS r;
r.x.ax=0;
int86(0x33,&r,&r);
if(r.x.ax=0)
{
printf("There is NOT mouse installed!");
exit(-1);
}
printf("Mouse with %d buttons installed!",r.x.bx);
}
/*show mouse,ax=1
Attention:if you call this function for times
you should call mouse_hide() for times to hide mouse*/
void mouse_show(void)
{
union REGS r;
r.x.ax=1;
int86(0x33,&r,&r);
}
/*hide mouse,ax=2
Attention:as mouse_show()*/
void mouse_hide(void)
{
union REGS r;
r.x.ax=2;
int86(0x33,&r,&r);
}
/*get mouse state,ax=3*/
void mouse_getstate(int *x,int *y,int *button)
{
union REGS r;
r.x.ax=3;
int86(0x33,&r,&r);
*button=r.x.bx;/*if left button was pressed r.x.bx=0;
if right button was pressed r.x.bx=1;
if middle button was pressed r.x.bx=2;
*/
*x=r.x.cx; /*mouse current X postion*/
*y=r.x.dx; /*mouse current Y postion*/
}
/*set mouse postion,ax=4*/
void mouse_setpostion(int x,int y)
{
union REGS r;
r.x.ax=4;
r.x.cx=x;/*X postion*/
r.x.dx=y;/*Y postion*/
int86(0x33,&r,&r);
}
you can write other function like this
and the detailed information about the int 0x33 at http://www.asmcity.com/prog/p_info/Intwin.zip