Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
{ MOUSE.PAS                                Copyright (c) Ales Kucik }
{ Unit pro praci s mysi.                                            }
{                                                                   }
{ Datum:29.11.2002                             http://www.trsek.com }
 
unit mouse;
interface
var ExMouse:boolean;
 
procedure CursorEnable;
procedure CursorDisable;
procedure ReadState(var button,horiz,vert:word);
procedure SetCo_or(horiz,vert:word);
procedure GetPress(button:word; var state,number,horiz,vert:word);
procedure GetRelease(button:word; var state,number,horiz,vert:word);
procedure HorizRange(maximum,minimum:word);
procedure VertRange(maximum,minimum:word);
procedure SensiMouse(horiz,vert:word);
procedure RealState(button:word; var state,number,horiz,vert:word);
function ExistMouse:boolean;
 
 
implementation
procedure CursorEnable; assembler;
asm
   push   ax
   mov    ax, $1
   int    $33
   pop    ax
end;
 
procedure CursorDisable; assembler;
asm
   push   ax
   mov    ax, $2
   int    $33
   pop    ax
end;
 
procedure ReadState(var button,horiz,vert:word);
var b,c,d:word;
begin
  asm
     mov    ax, $3
     int    $33
     mov    b, bx
     mov    c, cx
     mov    d, dx
  end;
  button:=b;
  horiz:=c;
  vert:=d;
end;
 
procedure SetCo_or(horiz,vert:word); assembler;
asm
   mov    ax, $4
   mov    cx, horiz
   mov    dx, vert
   int    $33
end;
 
procedure GetPress(button:word; var state,number,horiz,vert:word);
var a,b,c,d:word;
begin
  asm
     mov  ax, $5
     mov  bx, button
     int  $33
     mov  a, ax
     mov  b, bx
     mov  c, cx
     mov  d, dx
  end;
  state:=a;
  number:=b;
  horiz:=c;
  vert:=d;
end;
 
procedure GetRelease(button:word; var state,number,horiz,vert:word);
var a,b,c,d:word;
begin
  asm
     mov  ax, $6
     mov  bx, button
     int  $33
     mov  a, ax
     mov  b, bx
     mov  c, cx
     mov  d, dx
  end;
  state:=a;
  number:=b;
  horiz:=c;
  vert:=d;
end;
 
procedure HorizRange(maximum,minimum:word); assembler;
asm
   mov   ax, $7
   mov   cx, minimum
   mov   dx, maximum
   int   $33
end;
 
procedure VertRange(maximum,minimum:word); assembler;
asm
   mov   ax, $8
   mov   cx, minimum
   mov   dx, maximum
   int   $33
end;
 
procedure SensiMouse(horiz,vert:word); assembler;
asm
   mov   ax, $F
   mov   cx, horiz
   mov   dx, vert
   int   $33
end;
 
procedure RealState;
var a,b,c,d:word;
begin
  asm
     mov  ax, $5
     mov  bx, button
     int  $33
     mov  a, ax
     mov  b, bx
     mov  c, cx
     mov  d, dx
  end;
  state:=a;
  number:=b;
  horiz:=(c+8)div 8;
  vert:=(d+8)div 8;
end;
 
 
function ExistMouse:boolean;
var a:word;
begin
  asm
     mov   ax, $0
     int   $33
     mov   a, ax
  end;
  if a=0 then ExistMouse:=false
  else ExistMouse:=true;
end;
 
begin
  ExMouse:=ExistMouse;
end.