#include // these includes are for gotoxy and #include // printf functions #include // delay(miliseconds); unsigned int MouseX, MouseY; unsigned char MouseL, MouseC, MouseR; int MouseInit() { int result; asm { mov ax,0x00 int 0x33 mov [result],ax } return(result); } void MouseShow() { asm { mov ax,0x01 int 0x33 } } void MouseHide() { asm { mov ax,0x02 int 0x33 } } void MouseRead() { // CX = X; DX = Y; BX = Buttons asm { mov ax,0x03 int 0x33 mov [MouseX],cx mov [MouseY],dx mov bh,bl and bh,00000001b and bl,00000010b mov [MouseL],bh sar bl,1 mov [MouseR],bl } } void MouseRange(int Xmin, int Ymin, int Xmax, int Ymax) { asm { mov ax,7 mov cx,[Xmin] mov dx,[Xmax] int 33h mov ax,8 mov cx,[Ymin] mov dx,[Ymax] int 33h } } void MousePut(int Xpos, int Ypos) { asm { mov ax,4 mov cx,[Xpos] mov dx,[Ypos] int 33h } } void ReadKey() { asm { mov ax,0x00 int 0x16 } } void CursorOff() { asm { mov ah,01 mov cx,2000h int 10h } } void main() { int x,y; clrscr(); CursorOff(); MouseInit(); MouseShow(); printf("Coloque o mouse na posicao 80, 80 para continuar"); for (;!((MouseX==80)&&(MouseY==80));) { MouseRead(); gotoxy(1,2); printf("X: %d Y: %d Left: %d Right: %d ",MouseX,MouseY,MouseL,MouseR); } clrscr(); printf("Agora seu espaco esta' limitado..."); printf("Pressione qualquer tecla para continuar..."); MouseRange(80,80,280,180); ReadKey(); clrscr(); MouseInit(); MouseShow(); printf("Agora nao mexa com o mouse, apenas pressione uma tecla e assista\n"); ReadKey(); for (;;) { MouseRead(); MouseShow(); if (MouseX<40) MouseX+=4; if (MouseX>40) MouseX-=4; if (MouseY<60) MouseY+=4; if (MouseY>60) MouseY-=4; MousePut(MouseX,MouseY); if ((MouseX==40) && (MouseY==60)) break; delay(100); } printf("Muito bem! Agora pressione qualquer tecla para sair"); ReadKey(); MouseHide(); }