this is the small game using mouse device, I write it in turbo C++, it is a example about using asembler in Turbo C++, but when I write it in Visual C++ 6.0, It haves many error, I think it is a big difficult. Could you help me solve this problem, thank you very much:cheesy:
#include"stdio.h"
#include"dos.h"
#include"conio.h"
#include"stdlib.h"
#define INT_MOUSE 0x33
#define MOUSE_INIT 0x00
#define MOUSE_SHOW 0x01
#define MOUSE_GET_POSITION 0x03
#define MOUSE_Y_LIMIT 0x08
#define INT_VIDEO 0x10
#define CURSOR_SET 0X01
#define CURSOR_GET 0X03
#define BELL 7
#define PERIOD 25
unsigned long int tg_giay_100(void);
void main()
{
int mouse_status;
char ch;
unsigned long int t_bd,t_ht;
int cat_x,cat_y,mouse_x,mouse_y;
int raw_mouse_x,raw_mouse_y;
int cursor_size;
int old_mouse_x,old_mouse_y;
_AX=MOUSE_INIT;
geninterrupt(INT_MOUSE);
mouse_status=_AX;
if ( mouse_status!=-1 )
{
fprintf(stderr,"no mouse device\n");exit(1);
}
_AX=MOUSE_Y_LIMIT;_CX=5*8;_DX=25*8;
geninterrupt(INT_MOUSE);
clrscr();
puts(" press q to quit");
_AH=CURSOR_GET;
geninterrupt(INT_VIDEO);
cursor_size=_CX;
_AH=CURSOR_SET;
_CX=0x0f0f;
geninterrupt(INT_VIDEO);
old_mouse_x=old_mouse_y=-1;
cat_x=random(80)+1;cat_y=random(24)+1;
gotoxy(cat_x,cat_y);putch('C');
t_bd=tg_giay_100();
while ( 1 )
{
if ( kbhit() )
{
ch=getch();
if ( ch=='q' )
break;
else putch(BELL);
}
_AX=MOUSE_GET_POSITION;
geninterrupt(INT_MOUSE);
raw_mouse_x=_CX;raw_mouse_y=_DX;
mouse_x=raw_mouse_x/8+1;mouse_y=raw_mouse_y/8+1;
if ( (mouse_x!=old_mouse_x)||(mouse_y!=old_mouse_y) )
{
if ( old_mouse_x!=-1 )
{
gotoxy(old_mouse_x,old_mouse_y);
putch(' ');
}
gotoxy(mouse_x,mouse_y);putch('M');
old_mouse_x=mouse_x;
old_mouse_y=mouse_y;
}
if ( mouse_x==cat_x&&mouse_y==cat_y )
{
gotoxy(50,1);
cputs("quit");
break;
}
t_ht=tg_giay_100();
if ( t_ht-t_bd>PERIOD )
{
gotoxy(cat_x,cat_y);putch(' ');
cat_x=random(80)+1;
cat_y=random(21)+5;
gotoxy(cat_x,cat_y);putch('C');
t_bd=t_ht;
}
}
_AH=CURSOR_SET;
_CX=cursor_size;
geninterrupt(INT_VIDEO);
}
unsigned long int tg_giay_100(void)
{
static struct time ti;
unsigned long int t;
gettime(&ti);
t=((ti.ti_hour*60+ti.ti_min)*60+ti.ti_sec)*100+ti.ti_hund;
return t;
}