Here is a preliminary mouse unit I wrote(attachment 1). The
comments should be self explanitory, but if you need any help, or have
any problems using it email me and I will give you more detailted
documentation.
Also I have a question. How do I change the graphics cursor. I
know from Mr Kenedy's informative post that its function 9 from int 33,
but how do I actually define it's shape. Which registers do I use, or do
I uses registers? Please help? Thanx!
[
WIZMOUSE.PAS 5K ]
unit wizmouse;
interface
type
mcortype = record
left,right,center : boolean;
x,y : integer;
end;
procedure initmouse(var stat : boolean; var buttons : integer);
procedure gettxt(var mouse : mcortype; mode : integer);
procedure getgr(var mouse : mcortype);
function mousex : integer;
function mousey : integer;
function mousebut : integer;
procedure showcursor;
procedure hidecursor;
implementation
{----------------------------------------------------------------------------}
function mousex : integer;
{Post - calls the mouse driver and returns the x coordinate of the
cursor in pixels}
var
tmpint : integer;
begin
asm
mov ax,3;
int $33;
mov tmpint,cx;
end;
mousex := tmpint;
end;
{----------------------------------------------------------------------------}
function mousey : integer;
{Post - calls the mouse driver and returns the y coordinate of the
cursor in pixels}
var
tmpint : integer;
begin
asm
mov ax,3;
int $33;
mov tmpint,dx;
end;
mousey := tmpint;
end;
{----------------------------------------------------------------------------}
function mousebut : integer;
{Post - calls the mouse driver and returns the button code(1 - left 2
- right 4 - middle) of the button(s) currently pressed}
var
tmpint : integer;
begin
asm
mov ax,3;
int $33;
mov tmpint,bx;
end;
mousebut := tmpint;
end;
{----------------------------------------------------------------------------}
procedure gettxt (var mouse : mcortype;mode : integer);
{Pre - mode in (40,80). This works for both text modes
(co40,co80)
Post - In mouse the x,y coordinates in text pixles and the status of
the left, right, and middle buttons}
var
butcde : integer;
begin
mouse.left := false;
mouse.right := false;
mouse.left := false;
mouse.x := mousex div (640 div mode);
mouse.y := mousey div 8;
butcde:=mousebut;
with mouse do
case mousebut of
1,3,5,7 : left := true;
2,6,3, 7: right := true;
4..7: center := true;
end;
end;
{----------------------------------------------------------------------------}
procedure getgr ( var mouse : mcortype);
{Post - in mouse returns the xy coordinte in graphic pixels and
the status of the left, right, and middle buttons}
var
butcde : integer;
begin
with mouse do
begin
x := mousex;
y := mousey;
butcde := mousebut;
case butcde of
1,3,5,7 : left := true;
2,3,6,7 : right := true;
4..7 : center := true;
end;
end;
end;
{----------------------------------------------------------------------------}
procedure showcursor;
{Post - the graphical cursor is showed on the screen}
begin
asm
mov ax,1
int $33
end;
end;
{----------------------------------------------------------------------------}
procedure hidecursor;
{Post - the graphical cursor display is turned off}
begin
asm
mov ax,2
int $33
end;
end;
{----------------------------------------------------------------------------}
procedure initmouse (var stat : boolean; var buttons: integer);
{Post - if the mouse is correctly initilized stat will be true,
otherwise stat is false, buttons contains the number of buttons the
has currently avaliable}
var
statwrd,tmpbut : integer;
begin
asm
mov ax,0
int $33
mov statwrd,ax
mov tmpbut,bx
end;
case statwrd of
0 : stat :=true;
-1: stat :=false;
end;
buttons := tmpbut;
end;
{============================================================================}
end.