Hello,
I have been trying lately to make a simple 2 player TicTacToe program in TurboC++ using the graphics library ! I want to implement the program using mouse.
I have written the getmpos() function to get the mouse position on clicking ! However,the mouse gets polled only for the first time,and for the rest of the times the previous input is taken. Hence I am experirncing a problem. Please help me !
(Note:The TicTacToe logic is incomplete.)

Code:
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include<iostream.h>

class TTT
{
	int board[3][3];
	int origx,origy,player1,player2,move;
	public:
	void init();
	void initboard();
	int win();
	void drawsym(int,int,int);
	void drawcross(int,int);
	void drawnought(int,int);
	void setmouse();
	void getmpos(int*,int*);
	void getblock(int*,int*);
	void play();
};

void TTT::init()
{
   clrscr();
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "C:\\tc\\bgi");
   for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
		board[i][j]=0;
   move=0;
}

void TTT::initboard()
{
	int midx=getmaxx()/2;
	int midy=getmaxy()/2;
	origx=midx-180;origy=midy-180;
	/*Draw 4 lines for board*/
	line(midx-180,midy-60,midx+180,midy-60);
	line(midx-180,midy+60,midx+180,midy+60);
	line(midx-60,midy-180,midx-60,midy+180);
	line(midx+60,midy-180,midx+60,midy+180);
	/*board[0][0]='X';
	if(board[0][0]=='X')
	{
		drawcross(1,1);
	}
	drawnought(0,0);*/
};

void TTT::drawcross(int m,int n)
{
	line(origx+m*120+10,origy+n*120+10,origx+m*120+110,origy+n*120+110);
	line(origx+m*120+110,origy+n*120+10,origx+m*120+10,origy+n*120+110);
}

void TTT::drawnought(int m,int n)
{
	circle(origx+m*120+60,origy+n*120+60,50);
}

void TTT::drawsym(int sym,int m,int n)
{
	if(sym==1)
		drawcross(m,n);
	else if(sym==2)
		drawnought(m,n);

}

int TTT::win()
{
	if((board[0][0]==1 && board[0][1]==1 && board[0][2]==1)||
	   (board[0][0]==1 && board[1][1]==1 && board[2][2]==1)||
	   (board[0][0]==1 && board[1][0]==1 && board[2][0]==1)||
	   (board[0][1]==1 && board[1][1]==1 && board[2][1]==1)||
	   (board[0][2]==1 && board[1][2]==1 && board[2][2]==1)||
	   (board[0][2]==1 && board[1][1]==1 && board[2][0]==1)||
	   (board[1][0]==1 && board[1][1]==1 && board[1][2]==1)||
	   (board[2][0]==1 && board[2][1]==1 && board[2][2]==1))
		return 1;                      //Computer Wins
	if((board[0][0]==2 && board[0][1]==2 && board[0][2]==2)||
	   (board[0][0]==2 && board[1][1]==2 && board[2][2]==2)||
	   (board[0][0]==2 && board[1][0]==2 && board[2][0]==2)||
	   (board[0][1]==2 && board[1][1]==2 && board[2][1]==2)||
	   (board[0][2]==2 && board[1][2]==2 && board[2][2]==2)||
	   (board[0][2]==2 && board[1][1]==2 && board[2][0]==2)||
	   (board[1][0]==2 && board[1][1]==2 && board[1][2]==2)||
	   (board[2][0]==2 && board[2][1]==2 && board[2][2]==2))
		return 2;                     //Player Wins
	else
	{
		int flag=1;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				if(board[i][j]!=0)
					flag=0;
		if(flag==1)
			return 0;			//Still Playing
		return 3;				//Draw
	}
}

void TTT::setmouse()
{
	asm mov ax,0
	asm int 0x33
	asm mov ax,1
	asm int 0x33
}

void TTT::getmpos(int *x,int *y)
{
	int a=*x,b=*y;
	asm xor bx,bx
	asm xor cx,cx
	asm xor dx,dx
	asm xor ax,ax
	asm mov ax,2
	asm int 0x33
	asm mov ax,1
	asm int 0x33
lp:	asm mov ax,3
	asm int 0x33
	asm and bx,1
	asm cmp bx,1
	asm jnz lp
	asm mov a,cx
	asm mov b,dx
	cout<<"X = "<<a<<" Y = "<<b;
	*x=a;*y=b;
}

void TTT::getblock(int *m,int *n)
{
	int x,y;
	getmpos(&x,&y);
	if(x>origx && x< origx+120 && y>origy && y<origy+120)
	{
		*m=0;*n=0;
	}
	else if(x>origx+120 && x<origx+240 && y>origy && y<origy+120)
	{
		*m=0;*n=1;
	}
	else if(x>origx+240 && x< origx+360 && y>origy && y<origy+120)
	{
		*m=0;*n=2;
	}
	else if(x>origx && x< origx+120 && y>origy+120 && y<origy+240)
	{
		*m=1;*n=0;
	}
	else if(x>origx+120 && x< origx+240 && y>origy+120 && y<origy+240)
	{
		*m=1;*n=1;
	}
	else if(x>origx+240 && x< origx+360 && y>origy+120 && y<origy+240)
	{
		*m=1;*n=2;
	}

}


void TTT::play()
{
	int m,n;
	init();
	initboard();
	setmouse();
	player1=1;
	player2=2;
	int players;
	while(move<9)
	{
		if(move%2==0)
			players=player1;
		else
			players=player2;
		getblock(&m,&n);
		drawsym(players,n,m);
		board[m][n]=players;
		if(win()==2 || win()==1)
			break;
		move++;
	}

}

int main(void)
{
   TTT game;
   game.play();
   getch();
   closegraph();
   return 0;
}