unit mouse;
interface
function Init_mouse:boolean;
procedure mouseON;
procedure mouseOFF;
procedure get_TMXY(var mx,my,tlacilka:word);
procedure get_MXY(var mx,my,tlacilka:word);
procedure set_MXY(mx,my :word);
function Mouse_pressed:boolean;
function Mouse_left_pressed(var mx,my:word):boolean;
{zjisti if bylo macknuto leve tl. ,kde bylo xy}
function Mouse_right_pressed(var mx,my:word):boolean;
function Mouse_middle_pressed(var mx,my:word):boolean;
procedure Mouse_array(mx1,my1,mx2,my2:word);
implementation
function Init_mouse:boolean;assembler;
asm
xor ax,ax
int 33h
cmp ax,0
jz @konec
mov ax,1 {funkci init_mouse := 1 ... true, 0by bylo false}
@konec:
end;
procedure mouseON;assembler;
asm
mov ax,1
int 33h
end;
procedure mouseOFF;assembler;
asm
mov ax,2
int 33h
end;
procedure get_MXY(var mx,my,tlacilka:word);assembler;
asm
mov ax,3
int 33h
mov [ds:di],bx
mov [ds:di-2],dx
mov [ds:di-4],cx
{bx ..tlacitka,cx... x,dx... y}
{ mov mx,ax
}
end;
procedure get_TMXY(var mx,my,tlacilka:word);assembler;
asm
mov ax,3
int 33h
mov [ds:di],bx
SHR dx,4
mov [ds:di-4],dx
shr cx,3
mov [ds:di-2],cx
{bx ..tlacitka,cx... x,dx... y}
{ mov mx,ax
}
end;
procedure set_MXY(mx,my :word);assembler;
asm
mov ax,4
mov cx,mx
mov dx,my
int 33h
end;
function Mouse_pressed:boolean;assembler;
asm
mov ax,5
mov bx,0 {leve tlacitko}
int 33h
cmp ax,0
jnz @stisknuto
mov ax,5
mov bx,1 {prave tlacitko}
int 33h
cmp ax,0
jnz @stisknuto
mov ax,5
mov bx,2 {prostredni tlacitko}
int 33h
cmp ax,0
jnz @stisknuto
xor ax,ax
@stisknuto:
end;
function Mouse_left_pressed(var mx,my:word):boolean;assembler;
asm
mov ax,5
mov bx,0 {leve tlacitko}
int 33h
cmp ax,1
jz @dale
xor ax,ax
jmp @urychlit {nemusi zapsat do pameti}
@dale:
mov [ds:di],dx
mov [ds:di-2],cx
@urychlit:
end;
function Mouse_right_pressed(var mx,my:word):boolean;
assembler;
asm
mov ax,5
mov bx,1 {prave tlacitko}
int 33h
cmp ax,2
jz @dale
xor ax,ax
jmp @urychlit {nemusi zapsat do pameti}
@dale:
mov [ds:di],dx
mov [ds:di-2],cx
@urychlit:
end;
function Mouse_middle_pressed(var mx,my:word):boolean;assembler;
asm
mov ax,5
mov bx,3 {leve tlacitko}
int 33h
cmp ax,3
jz @dale
xor ax,ax
jmp @urychlit {nemusi zapsat do pameti}
@dale:
mov [ds:di],dx
mov [ds:di-2],cx
@urychlit:
end;
procedure Mouse_array(mx1,my1,mx2,my2:word);assembler;
asm
mov ax,7
mov cx,mx1
mov dx,mx2
shl cx,3
shl dx,3
int 33h
mov ax,8
mov cx,my1
mov dx,my2
shl cx,4
shl dx,4
int 33h
end;
end.