home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBII / ECO_MOU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-03-08  |  7.9 KB  |  256 lines

  1. (*
  2.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  3.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  4.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  5.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  6.     ▓▓▓▓▓▓▓▓·──                                              ──·▓▓▓▓▓▓▓▓▓▓▓
  7.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  8.     ▓▓▓▓▓▓▓▓   Unit was conceived, designed and written         ░░▓▓▓▓▓▓▓▓▓
  9.     ▓▓▓▓▓▓▓▓   by Floor A.C. Naaijkens for                      ░░▓▓▓▓▓▓▓▓▓
  10.     ▓▓▓▓▓▓▓▓   UltiHouse Software / The ECO Group.              ░░▓▓▓▓▓▓▓▓▓
  11.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  12.     ▓▓▓▓▓▓▓▓   (C) MCMXCII by EUROCON PANATIONAL CORPORATION.   ░░▓▓▓▓▓▓▓▓▓
  13.     ▓▓▓▓▓▓▓▓   All Rights Reserved for The ECO Group.           ░░▓▓▓▓▓▓▓▓▓
  14.     ▓▓▓▓▓▓▓▓                                                    ░░▓▓▓▓▓▓▓▓▓
  15.     ▓▓▓▓▓▓▓▓│                                                  │░░▓▓▓▓▓▓▓▓▓
  16.     ▓▓▓▓▓▓▓▓·──                                              ──·░░▓▓▓▓▓▓▓▓▓
  17.     ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
  18.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  19.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  20.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  21. *)
  22. {$O+,F+}
  23. unit eco_mou;
  24. interface
  25.  
  26. uses
  27.   dos
  28.  
  29.   ;                        { for interrupts and registers }
  30.  
  31.  
  32. const
  33.   mdd = $33;                { interrupt for mouse device driver }
  34.   hardware = 1;                                  { cursor types }
  35.   software = 0;
  36.   left     = 0;                                 { mouse buttons }
  37.   right    = 1;
  38.   middle   = 2;
  39.  
  40. type
  41.   resetrec = record        { initialized by mouse function 0 }
  42.     exists   : boolean;           { true if mouse is present }
  43.     nbuttons : integer;                 { # buttons on mouse }
  44.   end;
  45.  
  46.   locrec = record    { initialized by mouse fcns 3, 5, and 6 }
  47.     buttonstatus,    { bits 0-2 on if corresp button is down }
  48.     opcount,               { # times button has been clicked }
  49.                              { opcount not returned by fcn 3 }
  50.     column,                                       { position }
  51.     row      : integer;
  52.   end;
  53.  
  54.   moverec = record             { initialized by mouse fcn 11 }
  55.     hcount,                        { net horizontal movement }
  56.     vcount : integer;                { net vertical movement }
  57.   end;
  58.  
  59. var  reg : registers;
  60.  
  61. { these are the microsoft mouse functions }
  62. {$f+}
  63. procedure mreset (var mouse : resetrec);       { function  0 }
  64. procedure mshow;                               { function  1 }
  65. procedure mhide;                               { function  2 }
  66. procedure mpos (var mouse : locrec);           { function  3 }
  67. procedure mmoveto (col, row : integer);        { function  4 }
  68. procedure mpressed (button : integer;
  69.                     var mouse : locrec);       { function  5 }
  70. procedure mreleased (button : integer;
  71.                     var mouse : locrec);       { function  6 }
  72. procedure mcolrange (min, max : integer);      { function  7 }
  73. procedure mrowrange (min, max : integer);      { function  8 }
  74. procedure mgraphcursor (hhot, vhot : integer;
  75.                    maskseg, maskofs : word);   { function  9 }
  76. procedure mtextcursor (ctype, p1, p2 : word);  { function 10 }
  77. procedure mmotion (var moved : moverec);       { function 11 }
  78. procedure minsttask (mask,
  79.                      taskseg, taskofs : word); { function 12 }
  80. procedure mlpenon;                             { function 13 }
  81. procedure mlpenoff;                            { function 14 }
  82. procedure mratio (horiz, vert : integer);      { function 15 }
  83. {$f-}
  84. { ---------------------------------------------------------- }
  85.  
  86.  
  87.  
  88.  
  89. implementation
  90.  
  91.  
  92.  
  93.  
  94.  
  95. function lower (n1, n2 : integer) : integer;  { local to unit}
  96. begin
  97.   if n1 < n2 then lower := n1
  98.   else lower := n2;
  99. end;
  100.  
  101. function upper (n1, n2 : integer) : integer; { local to unit }
  102. begin
  103.   if n1 > n2 then upper := n1
  104.   else upper := n2;
  105. end;
  106. { --------------------------- }
  107. procedure mreset;        { resets mouse to default condition }
  108. begin
  109.   reg.ax := 0;
  110.   intr (mdd, reg);
  111.   if reg.ax <> 0 then
  112.     mouse.exists := true
  113.   else
  114.     mouse.exists := false;
  115.   mouse.nbuttons := reg.bx;
  116. end;
  117. { --------------------------- }
  118. procedure mshow;                 { make mouse cursor visible }
  119. begin
  120.   reg.ax := 1;
  121.   intr (mdd, reg);
  122. end;
  123. { --------------------------- }
  124. procedure mhide;               { make mouse cursor invisible }
  125. begin
  126.   reg.ax := 2;
  127.   intr (mdd, reg);
  128. end;
  129. { --------------------------- }
  130. procedure mpos;              { get mouse status and position }
  131. begin
  132.   reg.ax := 3;
  133.   intr (mdd, reg);
  134.   mouse.buttonstatus := reg.bx;
  135.   mouse.column := reg.cx;
  136.   mouse.row := reg.dx;
  137. end;
  138. { --------------------------- }
  139. procedure mmoveto;       { move mouse cursor to new location }
  140. begin
  141.   reg.ax := 4;
  142.   reg.cx := col;
  143.   reg.dx := row;
  144.   intr (mdd, reg);
  145. end;
  146. { --------------------------- }
  147. procedure mpressed;  { get pressed info about a given button }
  148. begin
  149.   reg.ax := 5;
  150.   reg.bx := button;
  151.   intr (mdd, reg);
  152.   mouse.buttonstatus := reg.ax;
  153.   mouse.opcount := reg.bx;
  154.   mouse.column := reg.cx;
  155.   mouse.row := reg.dx;
  156. end;
  157. { --------------------------- }
  158. procedure mreleased;      { get released into about a button }
  159. begin
  160.   reg.ax := 6;
  161.   reg.bx := button;
  162.   intr (mdd, reg);
  163.   mouse.buttonstatus := reg.ax;
  164.   mouse.opcount := reg.bx;
  165.   mouse.column := reg.cx;
  166.   mouse.row := reg.dx;
  167. end;
  168. { --------------------------- }
  169. procedure mcolrange;            { set column range for mouse }
  170. begin
  171.   reg.ax := 7;
  172.   reg.cx := lower (min, max);
  173.   reg.dx := upper (min, max);
  174.   intr (mdd, reg);
  175. end;
  176. { --------------------------- }
  177. procedure mrowrange;               { set row range for mouse }
  178. begin
  179.   reg.ax := 8;
  180.   reg.cx := lower (min, max);
  181.   reg.dx := upper (min, max);
  182.   intr (mdd, reg);
  183. end;
  184. { --------------------------- }
  185. procedure mgraphcursor;          { set mouse graphics cursor }
  186. begin
  187.   reg.ax := 9;
  188.   reg.bx := hhot;
  189.   reg.cx := vhot;
  190.   reg.dx := maskofs;
  191.   reg.es := maskseg;
  192.   intr (mdd, reg);
  193. end;
  194. { --------------------------- }
  195. procedure mtextcursor;               { set mouse text cursor }
  196.  
  197.    { notes:                                            }
  198.    { type 0 is the software cursor. when specified, p1 }
  199.    {   and p2 are the screen and cursor masks.         }
  200.    { type 1 is the hardware cursor. when specified, p1 }
  201.    {   and p2 are the start and stop scan lines, i.e.  }
  202.    {   the cursor shape.                               }
  203.  
  204. begin
  205.   reg.ax := 10;
  206.   reg.bx := ctype;
  207.   reg.cx := p1;
  208.   reg.dx := p2;
  209.   intr (mdd, reg);
  210. end;
  211. { --------------------------- }
  212. procedure mmotion;   { net movement of mouse since last call }
  213.                              { expressed in mickeys (1/100") }
  214. begin
  215.   reg.ax := 11;
  216.   intr (mdd, reg);
  217.   moved.hcount := reg.cx;
  218.   moved.vcount := reg.dx;
  219. end;
  220. { --------------------------- }
  221. procedure minsttask;             { install user-defined task }
  222. begin
  223.   reg.ax := 12;
  224.   reg.cx := mask;
  225.   reg.dx := taskofs;
  226.   reg.es := taskseg;
  227.   intr (mdd, reg);
  228. end;
  229. { --------------------------- }
  230. procedure mlpenon;   { turn on light pen emulation (default) }
  231. begin
  232.   reg.ax := 14;
  233.   intr (mdd, reg);
  234. end;
  235. { --------------------------- }
  236. procedure mlpenoff;           { turn off light pen emulation }
  237. begin
  238.   reg.ax := 15;
  239.   intr (mdd, reg);
  240. end;
  241. { --------------------------- }
  242. procedure mratio;                { set mickey to pixel ratio }
  243.  
  244.    { notes:                                       }
  245.    { ratios are r/8.                              }
  246.    { default is 16 for vertical, 8 for horizontal }
  247.  
  248. begin
  249.   reg.ax := 15;
  250.   reg.cx := horiz;
  251.   reg.dx := vert;
  252. end;
  253. { --------------------------- }
  254.  
  255. end.
  256.