Hi,
I am new to this forum.I was just trying to do a tic tac toe game using mouse,but i am facing some wierd problem.I was trying to do like this,on a left button click i should get "x",then on the next click i should get "o",but the combination is not right.Here is the code:

Code:
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<stdlib.h>

void init_mouse();
void show_mouse();
int lb_prs();
void get_coord(int *,int *);
void hidemouse();
int chk_coord(int *,int *);

int board_fill[3][3]={0,0,0,0,0,0,0,0,0};

int main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
int x1,y1,x2,y2,i,j,but1=0,but2=0,p,q,turn=0;
char ch;

choose_menu();
getch();
cleardevice();

x1=0;
y1=0;
x2=0;
y2=0;
i=0;
j=0;

cleardevice();

setlinestyle(0,3,3);
line(210,200,390,200);
line(210,260,390,260);
line(270,140,270,320);
line(330,140,330,320);

init_mouse();
show_mouse();

setcolor(3);

while(turn<9)
{

a:
x1=0;
y1=0;
i=0;

if(lb_prs())
	{
	get_coord(&x1,&y1);
	i=chk_coord(&x1,&y1);
	while(lb_prs());
	if(i==1)
		{
		hidemouse();
		settextstyle(0,0,3);
		outtextxy(x1,y1,"X");
		show_mouse();
		turn++;
		}
	else
		{
		outtextxy(0,0,"Wrong input..");
		goto a;
		}
}

b:
x1=0;
y1=0;
i=0;

if(lb_prs())
	{
	get_coord(&x1,&y1);
	i=chk_coord(&x1,&y1);
	while(lb_prs());
	if(i==1)
		{
		hidemouse();
		settextstyle(0,0,3);
		outtextxy(x1,y1,"O");
		show_mouse();
		turn++;
		}
	else
		{
		outtextxy(0,0,"Wrong input..");
		goto b;
		}
	}

}

getch();
closegraph();
return 0;
}


void init_mouse()
{
union REGS in,out;

in.x.ax=0;
int86(0x33,&in,&out);
if(out.x.ax==0)
	{
	printf("Mouse driver failed!!!!");
	exit(1);
	}
}


void show_mouse()
{
union REGS in,out;

in.x.ax=1;
int86(0x33,&in,&out);
}


int lb_prs()
{
union REGS in,out;
in.x.ax=3;

int86(0x33,&in,&out);
return (out.x.bx & 1);
}

void get_coord(int *x,int *y)
{
union REGS in,out;

in.x.ax=0;

in.x.ax=3;
int86(0x33,&in,&out);

*x=out.x.cx;
*y=out.x.dx;
}

void hidemouse()
{
union REGS in,out;

in.x.ax=2;
int86(0x33,&in,&out);
}

int chk_coord(int *x1,int *y1)
{
int i=0;
int x=0,y=0;


x=*x1;
y=*y1;

if((x>=210)&&(y>=140)&&(x<=270)&&(y<=200))
	{
	*x1=230;
	*y1=160;

if(board_fill[0][0]==0)
	{
	board_fill[0][0]=1;
	return 1;
	}
	}
if((x>=270)&&(y>=140)&&(x<=330)&&(y<=200))
	{
	*x1=290;
	*y1=160;

if(board_fill[0][1]==0)
	{
	board_fill[0][1]=1;
	return 1;
	}

	}
if((x>=330)&&(y>=140)&&(x<=390)&&(y<=200))
	{
	*x1=350;
	*y1=160;

if(board_fill[0][2]==0)
	{
	board_fill[0][2]=1;
	return 1;
	}

	}
if((x>=210)&&(y>=200)&&(x<=270)&&(y<=260))
	{
	*x1=230;
	*y1=220;
if(board_fill[1][0]==0)
	{
	board_fill[1][0]=1;
	return 1;
	}

	}
if((x>=270)&&(y>=200)&&(x<=330)&&(y<=260))
	{
	*x1=290;
	*y1=220;
if(board_fill[1][1]==0)
	{
	board_fill[1][1]=1;
	return 1;
	}

	}
if((x>=330)&&(y>=200)&&(x<=390)&&(y<=260))
	{
	*x1=350;
	*y1=220;
if(board_fill[1][2]==0)
	{
	board_fill[1][2]=1;
	return 1;
	}

	}

if((x>=210)&&(y>=260)&&(x<=270)&&(y<=320))
	{
	*x1=230;
	*y1=280;
if(board_fill[2][0]==0)
	{
	board_fill[2][0]=1;
	return 1;
	}
}
if((x>=270)&&(y>=260)&&(x<=330)&&(y<=320))
	{
	*x1=290;
	*y1=280;
if(board_fill[2][1]==0)
	{
	board_fill[2][1]=1;
	return 1;
	}

	}
if((x>=330)&&(y>=260)&&(x<=390)&&(y<=320))
	{
	*x1=350;
	*y1=280;
if(board_fill[2][2]==0)
	{
	board_fill[2][2]=1;
	return 1;
	}

	}

return 0;
}