home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ICONMN.ZIP / IMOUSE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-04-11  |  5.0 KB  |  209 lines

  1. (* IMOUSE.PAS  a minimal set of mouse procedures and functions -
  2.       for icon programs
  3.       require EGA or medium VGA graphics *)
  4.  
  5. unit imouse;
  6.  
  7. interface
  8.  
  9. uses dos;
  10.  
  11. function initmouse : boolean;
  12. { initialize mouse software and hardware }
  13.  
  14. procedure showmouse;
  15. { show mouse cursor }
  16.  
  17. procedure hidemouse;
  18. { hide mouse cursor }
  19.  
  20. function mouseposition(var mousex,mousey : word) : word;
  21. { return mouse position and button status }
  22. { X and Y values scaled for 640 x 350 EGA mode }
  23.  
  24. procedure setmouseposition(mousex, mousey: word);
  25. { sets mouse position  }
  26. { X and Y values scaled for 640 x 350 EGA mode }
  27.  
  28. procedure setmousexy(x1,y1,x2,y2: word);
  29. { sets min/max values for horizontal/vertical  }
  30. { X and Y values scaled for 640 x 350 EGA mode }
  31.  
  32. procedure cursorshape(shape: byte);
  33. { sets the graphics cursor shape }
  34.  
  35.  
  36. function mousepress(button: word;
  37.                      var count, lastx, lasty: word): word;
  38. { gets button press information  }
  39. { X and Y values scaled for 640 x 350 EGA mode }
  40.  
  41. function mouserelease(button: word;
  42.                        var count, lastx, lasty: word): word;
  43. { gets button release information  }
  44. { X and Y values scaled for 640 x 350 EGA mode }
  45.  
  46. procedure restoremouseega;
  47. { restores min/max values for EGA screen }
  48.  
  49.  
  50. implementation
  51.  
  52. type
  53.   mouse_cursor_type = record
  54.                         cursform : array [0..31] of word;
  55.                         hsx, hsy : word; end;
  56. const
  57.    point: mouse_cursor_type = ( cursform :
  58.        ($9fff,$fff,$87ff,$c3ff,$e1f9,$f0f0,$f061,$e021,
  59.     $c001,$c001,$8001,$8000,$c000,$e000,$f001,$fc03,
  60.     $6000,$9000,$4800,$2400,$1206,$909,$c92,$1252,
  61.     $2922,$2482,$5242,$4901,$2401,$1001,$c02,$3fc);
  62.           hsx : 0;
  63.           hsy : 0);
  64.  
  65.    arrow: mouse_cursor_type = (cursform : (
  66.     $3fff,$1fff,$fff,$7ff,$3ff,$1ff,$ff,$7f,
  67.     $3f,$1f,$f,$7,$1847,$387f,$fc3f,$fe7f,
  68.     $0,$4000,$6000,$7000,$7800,$7c00,$7e00,$7f00,
  69.     $7f80,$7fc0,$7fe0,$6730,$4300,$300,$180,$0);
  70.          hsx : 1;
  71.          hsy : 0);
  72.  
  73.    finger: mouse_cursor_type = (cursform : (
  74.     $ffff,$f3ff,$e1ff,$e1ff,$e1ff,$e1ff,$e007,$e000,
  75.     $8000,$0,$0,$0,$0,$0,$8001,$c003,
  76.     $0,$c00,$1200,$1200,$1200,$13b0,$124e,$1249,
  77.     $7249,$9249,$9001,$8001,$8001,$8001,$4002,$3ffc);
  78.           hsx : 5;
  79.           hsy : 0);
  80.  
  81. var mouse_reg : registers;
  82.  
  83. function initmouse : boolean;
  84. { initialize mouse software and hardware }
  85. var mousetest : boolean;
  86. begin
  87.   with mouse_reg do
  88.     ax := 0;
  89.   intr($33,mouse_reg);
  90.   mousetest:= boolean(mouse_reg.ax);
  91.   if mousetest then restoremouseega;
  92.   initmouse:=mousetest;
  93. end;
  94.  
  95. procedure showmouse;
  96. { show mouse cursor }
  97. begin
  98.   mouse_reg.ax := 1;
  99.   intr($33,mouse_reg);
  100. end;
  101.  
  102. procedure hidemouse;
  103. { hide mouse cursor }
  104. begin
  105.   mouse_reg.ax := 2;
  106.   intr($33,mouse_reg);
  107. end;
  108.  
  109. function mouseposition(var mousex,mousey : word) : word;
  110. { return mouse position and button status }
  111. { X and Y values scaled for 640 x 350 EGA mode }
  112. begin
  113.   mouse_reg.ax := 3;
  114.   intr($33,mouse_reg);
  115.   with mouse_reg do begin
  116.     mouseX := cx;
  117.     mouseY := dx;
  118.     mousePosition := bx;
  119.   end;
  120. end;
  121.  
  122. procedure setmouseposition(mousex, mousey: word);
  123. { sets mouse position  }
  124. { X and Y values scaled for 640 x 350 EGA mode }
  125. begin
  126.   mouse_reg.ax:=4;
  127.   mouse_reg.cx:=mousex;
  128.   mouse_reg.dx:=mousey;
  129.   intr($33,mouse_reg);
  130. end;
  131.  
  132. procedure setmousexy(x1,y1,x2,y2: word);
  133. { sets min/max values for horizontal/vertical  }
  134. { X and Y values scaled for 640 x 350 EGA mode }
  135. begin
  136.   mouse_reg.ax:=7;
  137.   mouse_reg.cx:=x1;
  138.   mouse_reg.dx:=x2;
  139.   intr($33,mouse_reg);
  140.   mouse_reg.ax:=8;
  141.   mouse_reg.cx:=y1;
  142.   mouse_reg.dx:=y2;
  143.   intr($33,mouse_reg);
  144. end;
  145.  
  146. procedure cursorshape(shape: byte);
  147. { sets the graphics cursor shape }
  148. var  m : mouse_cursor_type;
  149. begin
  150.   case shape of
  151.     1 : m:=arrow;
  152.     2 : m:=point;
  153.     3 : m:=finger;
  154.        end;
  155.  with mouse_reg do
  156.   begin
  157.     ax := 9;
  158.     bx := m.hsx;
  159.     cx := m.hsy;
  160.     es := Seg(m.cursform);
  161.     dx := Ofs(m.cursform);
  162.     intr($33, mouse_reg);
  163.   end;
  164. end;
  165.  
  166. function mousepress(button: word;
  167.                      var count, lastx, lasty: word): word;
  168. { gets button press information  }
  169. { X and Y values scaled for 640 x 350 EGA mode }
  170. begin
  171.   mouse_reg.ax:=5;
  172.   mouse_reg.bx:=button;
  173.   intr($33,mouse_reg);;
  174.   mousepress:=mouse_reg.ax;
  175.   count:=mouse_reg.bx;
  176.   lastx:=mouse_reg.cx;
  177.   lasty:=mouse_reg.dx;
  178. end;
  179.  
  180. function mouserelease(button: word;
  181.                        var count, lastx, lasty: word): word;
  182. { gets button release information  }
  183. { X and Y values scaled for 640 x 350 EGA mode }
  184. begin
  185.   mouse_reg.ax:=6;
  186.   mouse_reg.bx:=button;
  187.   intr($33,mouse_reg);;
  188.   mouserelease:=mouse_reg.ax;
  189.   count:=mouse_reg.bx;
  190.   lastx := mouse_reg.cx;
  191.   lasty := mouse_reg.dx;
  192. end;
  193.  
  194. procedure restoremouseega;
  195. { restores min/max values for EGA screen }
  196. begin
  197.   mouse_reg.ax:=7;
  198.   mouse_reg.cx:=0;
  199.   mouse_reg.dx:=639;
  200.   intr($33,mouse_reg);
  201.   mouse_reg.ax:=8;
  202.   mouse_reg.cx:=0;
  203.   mouse_reg.dx:=349;
  204.   intr($33,mouse_reg);
  205. end;
  206.  
  207.  
  208.  
  209. end.