home *** CD-ROM | disk | FTP | other *** search
- (* IMOUSE.PAS a minimal set of mouse procedures and functions -
- for icon programs
- require EGA or medium VGA graphics *)
-
- unit imouse;
-
- interface
-
- uses dos;
-
- function initmouse : boolean;
- { initialize mouse software and hardware }
-
- procedure showmouse;
- { show mouse cursor }
-
- procedure hidemouse;
- { hide mouse cursor }
-
- function mouseposition(var mousex,mousey : word) : word;
- { return mouse position and button status }
- { X and Y values scaled for 640 x 350 EGA mode }
-
- procedure setmouseposition(mousex, mousey: word);
- { sets mouse position }
- { X and Y values scaled for 640 x 350 EGA mode }
-
- procedure setmousexy(x1,y1,x2,y2: word);
- { sets min/max values for horizontal/vertical }
- { X and Y values scaled for 640 x 350 EGA mode }
-
- procedure cursorshape(shape: byte);
- { sets the graphics cursor shape }
-
-
- function mousepress(button: word;
- var count, lastx, lasty: word): word;
- { gets button press information }
- { X and Y values scaled for 640 x 350 EGA mode }
-
- function mouserelease(button: word;
- var count, lastx, lasty: word): word;
- { gets button release information }
- { X and Y values scaled for 640 x 350 EGA mode }
-
- procedure restoremouseega;
- { restores min/max values for EGA screen }
-
-
- implementation
-
- type
- mouse_cursor_type = record
- cursform : array [0..31] of word;
- hsx, hsy : word; end;
- const
- point: mouse_cursor_type = ( cursform :
- ($9fff,$fff,$87ff,$c3ff,$e1f9,$f0f0,$f061,$e021,
- $c001,$c001,$8001,$8000,$c000,$e000,$f001,$fc03,
- $6000,$9000,$4800,$2400,$1206,$909,$c92,$1252,
- $2922,$2482,$5242,$4901,$2401,$1001,$c02,$3fc);
- hsx : 0;
- hsy : 0);
-
- arrow: mouse_cursor_type = (cursform : (
- $3fff,$1fff,$fff,$7ff,$3ff,$1ff,$ff,$7f,
- $3f,$1f,$f,$7,$1847,$387f,$fc3f,$fe7f,
- $0,$4000,$6000,$7000,$7800,$7c00,$7e00,$7f00,
- $7f80,$7fc0,$7fe0,$6730,$4300,$300,$180,$0);
- hsx : 1;
- hsy : 0);
-
- finger: mouse_cursor_type = (cursform : (
- $ffff,$f3ff,$e1ff,$e1ff,$e1ff,$e1ff,$e007,$e000,
- $8000,$0,$0,$0,$0,$0,$8001,$c003,
- $0,$c00,$1200,$1200,$1200,$13b0,$124e,$1249,
- $7249,$9249,$9001,$8001,$8001,$8001,$4002,$3ffc);
- hsx : 5;
- hsy : 0);
-
- var mouse_reg : registers;
-
- function initmouse : boolean;
- { initialize mouse software and hardware }
- var mousetest : boolean;
- begin
- with mouse_reg do
- ax := 0;
- intr($33,mouse_reg);
- mousetest:= boolean(mouse_reg.ax);
- if mousetest then restoremouseega;
- initmouse:=mousetest;
- end;
-
- procedure showmouse;
- { show mouse cursor }
- begin
- mouse_reg.ax := 1;
- intr($33,mouse_reg);
- end;
-
- procedure hidemouse;
- { hide mouse cursor }
- begin
- mouse_reg.ax := 2;
- intr($33,mouse_reg);
- end;
-
- function mouseposition(var mousex,mousey : word) : word;
- { return mouse position and button status }
- { X and Y values scaled for 640 x 350 EGA mode }
- begin
- mouse_reg.ax := 3;
- intr($33,mouse_reg);
- with mouse_reg do begin
- mouseX := cx;
- mouseY := dx;
- mousePosition := bx;
- end;
- end;
-
- procedure setmouseposition(mousex, mousey: word);
- { sets mouse position }
- { X and Y values scaled for 640 x 350 EGA mode }
- begin
- mouse_reg.ax:=4;
- mouse_reg.cx:=mousex;
- mouse_reg.dx:=mousey;
- intr($33,mouse_reg);
- end;
-
- procedure setmousexy(x1,y1,x2,y2: word);
- { sets min/max values for horizontal/vertical }
- { X and Y values scaled for 640 x 350 EGA mode }
- begin
- mouse_reg.ax:=7;
- mouse_reg.cx:=x1;
- mouse_reg.dx:=x2;
- intr($33,mouse_reg);
- mouse_reg.ax:=8;
- mouse_reg.cx:=y1;
- mouse_reg.dx:=y2;
- intr($33,mouse_reg);
- end;
-
- procedure cursorshape(shape: byte);
- { sets the graphics cursor shape }
- var m : mouse_cursor_type;
- begin
- case shape of
- 1 : m:=arrow;
- 2 : m:=point;
- 3 : m:=finger;
- end;
- with mouse_reg do
- begin
- ax := 9;
- bx := m.hsx;
- cx := m.hsy;
- es := Seg(m.cursform);
- dx := Ofs(m.cursform);
- intr($33, mouse_reg);
- end;
- end;
-
- function mousepress(button: word;
- var count, lastx, lasty: word): word;
- { gets button press information }
- { X and Y values scaled for 640 x 350 EGA mode }
- begin
- mouse_reg.ax:=5;
- mouse_reg.bx:=button;
- intr($33,mouse_reg);;
- mousepress:=mouse_reg.ax;
- count:=mouse_reg.bx;
- lastx:=mouse_reg.cx;
- lasty:=mouse_reg.dx;
- end;
-
- function mouserelease(button: word;
- var count, lastx, lasty: word): word;
- { gets button release information }
- { X and Y values scaled for 640 x 350 EGA mode }
- begin
- mouse_reg.ax:=6;
- mouse_reg.bx:=button;
- intr($33,mouse_reg);;
- mouserelease:=mouse_reg.ax;
- count:=mouse_reg.bx;
- lastx := mouse_reg.cx;
- lasty := mouse_reg.dx;
- end;
-
- procedure restoremouseega;
- { restores min/max values for EGA screen }
- begin
- mouse_reg.ax:=7;
- mouse_reg.cx:=0;
- mouse_reg.dx:=639;
- intr($33,mouse_reg);
- mouse_reg.ax:=8;
- mouse_reg.cx:=0;
- mouse_reg.dx:=349;
- intr($33,mouse_reg);
- end;
-
-
-
- end.