unit maus;

interface

uses dos;

procedure mouseinit;
procedure mouseshow;
procedure mousehide;
procedure mousestatus;
procedure getmousestatus;
procedure setmouse(a,b:integer);
procedure mouserange(anfx,anfy,endx,endy:integer);
function  mousein(x1,y1,x2,y2:integer):boolean;
procedure handmouse;


var mouse                                       :registers;
    mousex,mousey,button                        :integer;
    maskseg,maskofs,hot_spot_hor,hot_spot_ver   :integer;
    cursor                                      :array[0..31] of word;

implementation

procedure handmouse;

begin
  cursor[ 0]:=$e1ff;
  cursor[ 1]:=$e1ff;
  cursor[ 2]:=$e1ff;
  cursor[ 3]:=$e1ff;
  cursor[ 4]:=$e1ff;
  cursor[ 5]:=$e000;
  cursor[ 6]:=$e000;
  cursor[ 7]:=$e000;
  cursor[ 8]:=$0000;
  cursor[ 9]:=$0000;
  cursor[10]:=$0000;
  cursor[11]:=$0000;
  cursor[12]:=$0000;
  cursor[13]:=$0000;
  cursor[14]:=$0000;
  cursor[15]:=$0000;
  cursor[16]:=$1e00;
  cursor[17]:=$1200;
  cursor[18]:=$1200;
  cursor[19]:=$1200;
  cursor[20]:=$1200;
  cursor[21]:=$13ff;
  cursor[22]:=$1249;
  cursor[23]:=$1249;
  cursor[24]:=$f249;
  cursor[25]:=$9001;
  cursor[26]:=$9001;
  cursor[27]:=$9001;
  cursor[28]:=$8001;
  cursor[29]:=$8001;
  cursor[30]:=$8001;
  cursor[31]:=$ffff;
  maskseg:=seg(cursor);
  maskofs:=ofs(cursor);
  hot_spot_hor:=5;
  hot_spot_ver:=0;
  mouse.ax:=9;
  mouse.bx:=hot_spot_hor;
  mouse.cx:=hot_spot_ver;
  mouse.dx:=maskofs;
  mouse.es:=maskseg;
  intr($33,mouse);
end;

procedure mouseinit;

begin
  mouse.ax:=0;
  intr($33,mouse);
end;

procedure mouseshow;

begin
  mouse.ax:=1;
  intr($33,mouse);
end;

procedure mousehide;

begin
  mouse.ax:=2;
  intr($33,mouse);
end;

procedure mousestatus;

begin
  mouse.ax:=3;
  intr($33,mouse);
end;

procedure getmousestatus;

begin
  if mouse.ax=3 then begin
    intr($33,mouse);
    mousex:=mouse.cx;
    mousey:=mouse.dx;
    button:=mouse.bx;
  end;
end;

procedure setmouse(a,b:integer);

begin
  mouse.ax:=4;
  intr($33,mouse);
  mouse.cx:=a;
  mouse.dx:=b;
  intr($33,mouse);
end;

procedure mouserange(anfx,anfy,endx,endy:integer);

begin
  mouse.ax:=7;
  intr($33,mouse);
  mouse.cx:=anfx;
  mouse.dx:=endx;
  intr($33,mouse);
  mouse.ax:=8;
  intr($33,mouse);
  mouse.cx:=anfy;
  mouse.dx:=endy;
  intr($33,mouse);
end;

function mousein(x1,y1,x2,y2:integer):boolean;

begin
  if (mousex>=x1) and (mousex<=x2) and (mousey>=y1) and (mousey<=y2) then
  mousein:=true;
end;

end.