#define MOUSE_INT               0x33

struct mouse_inp
{
	int x, y;
	int lx, ly;
	int sx, sy;
	int button;
};

mouse_inp mouse;

void ScanMouse 		(int *x,int *y,int *buttons);
void SenseMouse		(int x,int y);
void ShowMouse 		(void);
void FeelMouse 		(int *x,int *y);
void HideMouse 		(void);
void WaitMouse 		(void);
int  GetButton          (void);

int GetButton   (void)
 {
   int a,b,c;
   ScanMouse(&a,&b,&c);
   return(c);
 }

  void WaitMouse (void)
    {
    int x,y,b;
    b=0;
    while(!(b>0))
    { ScanMouse(&x,&y,&b); if (kbhit()) { break; } }

    }

void HideMouse (void)
		{
		// this function decrements the inrternal show.mouse
		// counter. When it's equal to -1, the mouse is
		// hidden.
		//union REGS inregs,outregs;
		//inregs.x.ax = 0x02;
		//// subfunction 2: decrement the show flag
		//int86(MOUSE_INT,&inregs,&outregs);
		}

void ScanMouse(int *x,int *y,int *buttons)
{
	*x = mouse.x;
	*y = mouse.y;
	*buttons = mouse.button;

  /*union REGS inregs,outregs;

  inregs.x.ax = 0x03;
  int86(MOUSE_INT,&inregs,&outregs);
		*x       = outregs.x.cx;
		*y       = outregs.x.dx;
		*buttons = outregs.x.bx;*/
 }

void SenseMouse(int x,int y)
		{
		/*union REGS inregs,outregs;*/
		// this function sets the overall "sensitivity" of
		// the mouse. Each axis can have a sensitivity of
		// from 1-100, so the caller should put 1-100 in both
		// x and y before calling. Also "buttons" is used to
		// send in the double speed value, which also ranges
		// from 1-100.

		/*inregs.x.bx = x;
		inregs.x.cx = y;

		inregs.x.ax = 0x1A;*/
		// subfunction 26: set sensitivity
		/*int86(MOUSE_INT,&inregs,&outregs);*/

			mouse.sx = x;
			mouse.sy = y;
		}

	 void ShowMouse(void)
		{
	 /*union REGS inregs,outregs;

		inregs.x.ax = 0x01;
		int86(MOUSE_INT,&inregs,&outregs);*/
		}



	 void FeelMouse (int *x,int *y)
		{
///	      union REGS inregs,outregs;
		// this function gets the relative mouse motions from
		// the last call and puts them in the variable x,y.
//		inregs.x.ax = 0x0B;
		// subfunction 11: get relative motion
//		int86(MOUSE_INT,&inregs,&outregs);

		// extract the info and send it back to caller by
		// using pointers.
//		*x       = outregs.x.cx;
//		*y       = outregs.x.dx;
			*x = mouse.lx - mouse.x;
			*y = mouse.ly - mouse.y;
		}