I can't use my PC these days so I use what I can to code, and it's TurboC++ 3 in Android device with dosbox. (If you are going to suggest another compiler, suggest one that works in Android and can make .exe files. Else please don't suggest Windows/Mac compilers).
I found a code for mouse usage in Electrosoft's site and added a call to put a pixel where the mouse is clicked. After adding it, the program exits saying I should use initgraph. But as you can see it's there, without the call to putpixel the code works fine.
I'm not experienced with interruptions or asm code so I can't touch the mouse parts. My idea is to use the mouse code as a starting step. Could you please tell me why it's not working?
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
union REGS in,out;
int callmouse()
{
in.x.ax=1;
int86(51,&in,&out);
return 1;
}
void mouseposi(int &xpos,int &ypos,int &click)
{
in.x.ax=3;
int86(51,&in,&out);
click=out.x.bx;
xpos=out.x.cx;
ypos=out.x.dx;
}
int mousehide()
{
in.x.ax=2;
int86(51,&in,&out);
return 1;
}
void setposi(int &xpos,int &ypos)
{
in.x.ax=4;
in.x.cx=xpos;
in.x.dx=ypos;
int86(51,&in,&out);
}
int main()
{
int x,y,cl,a,b;
clrscr();
int g=DETECT,m;
initgraph(&g,&m,"c:\tc\bgi");
a=100;
b=400;
setposi(a,b);
callmouse();
do
{
mouseposi(x,y,cl);
gotoxy(10,9);
printf("\n\tMouse Position is: %d,%d",x,y);
printf("\n\tClick: %d",cl);
printf("\n\tPress any key to hide the mouse");
//this if block breaks the code
if(cl==1)
{
putpixel(x,y,WHITE);
}
}while(!kbhit());
getch();
mousehide();
printf("\n\n\tPress any key to Exit");
getch();
return 0;
}