#include <stdio.h>
#include "TLIGHTPE.H"
TLightPen* LightPen;
void far interrupt InternalClickHandler(...)
{

//	int x=10,y=15;
//	printf("%3d-%3d",x,y++);
//	if(LightPen.ClickHandler != NULL)
//		LightPen.ClickHandler(x,y);
}
TLightPen::TLightPen()
{
//	LightPen = this;
	//Add the source to install the correct lightpen driver
	//Init the mouse
	rRegs.x.ax = MouseInit;
	int86(MouseInterrupt,&rRegs,&rRegs);
	//If ax = 0 -> Mouse is not installed (Lightpen driver or mouse driver not installed);

	//Show the cursor
	rRegs.x.ax = MouseShowCursor;
	int86(MouseInterrupt,&rRegs,&rRegs);
	//Lightpen emulation on
	rRegs.x.ax = MouseLightPenEmulationOn;
	int86(MouseInterrupt,&rRegs,&rRegs);
}
TLightPen::~TLightPen()
{
	//Hide the cursor
	rRegs.x.ax = MouseHideCursor;
	int86(MouseInterrupt,&rRegs,&rRegs);
}
void TLightPen::SetReleaseHandler(Handler  hHandler)
{
//	ClickHandler = hHandler;
//   setvect(0x33,InternalClickHandler);
	rRegs.x.ax = 12;//0x12;
	rRegs.x.cx = 0x04;
	rRegs.x.dx = FP_OFF(InternalClickHandler);
	sRegs.es   = FP_SEG(InternalClickHandler);
	int86x(0x33,&rRegs,&rRegs,&sRegs);
}

