home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MMOUSE.ZIP / MMOUSE.PAS
Encoding:
Pascal/Delphi Source File  |  1986-07-09  |  5.7 KB  |  246 lines

  1.  
  2.  
  3. { Microsoft Mouse function access routines }
  4. { (C) 1986 John Vedral, Vedco Computer }
  5.  
  6. { Full commercial version available for a small $5.00 donation from:
  7.  
  8.        Vedco Computer
  9.        128 Terbell Pky.
  10.        River Vale, NJ 07675
  11.  
  12.   Includes all mouse functions and full documentation as well as programming
  13.     examples. }
  14.  
  15.  
  16.  
  17.  
  18. function mouse_installed : boolean;
  19.  
  20. { return true if the mouse driver and hardware are installed.  Also
  21.   resets mouse to default settings. }
  22.  
  23.   type registers = record
  24.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  25.                    end; { record registers }
  26.  
  27.   var regs : registers;
  28.  
  29.   begin
  30.     regs.ax := 0;  { invoke mouse function 0 }
  31.  
  32.     intr($33, regs);
  33.  
  34.     if regs.ax = 0 then
  35.       mouse_installed := false
  36.     else
  37.       mouse_installed := true;
  38.   end; { function mouse_installed }
  39.  
  40.  
  41.  
  42. function button_press(button : integer) : boolean;
  43.  
  44. { returns true if button has been pressed.  Button = 0 for left button and 1
  45.   for right button }
  46.  
  47.   type registers  =  record
  48.                        ax, bx, cx, dx, bp, di, si, ds, es, flags  :  integer
  49.                      end;
  50.  
  51.   var regs  :  registers;
  52.  
  53.   begin
  54.     regs.ax := 5; { invoke mouse function 5 }
  55.     regs.bx := button;
  56.  
  57.     intr($33, regs);
  58.  
  59.     button_press := (regs.bx > 0);
  60.   end; { function button_pressed }
  61.  
  62.  
  63.  
  64. procedure show_cursor;
  65.  
  66. { makes the cursor visible }
  67.  
  68.   type registers = record
  69.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  70.                    end; { record registers }
  71.  
  72.   var regs : registers;
  73.  
  74.   begin
  75.     regs.ax := 1;   { invoke mouse function 1 }
  76.  
  77.     intr($33, regs);
  78.   end; { procedure show_cursor }
  79.  
  80.  
  81.  
  82. procedure hide_cursor;
  83.  
  84. { makes cursor invisible }
  85.  
  86.   type registers = record
  87.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  88.                    end; { record registers }
  89.  
  90.   var regs : registers;
  91.  
  92.   begin
  93.     regs.ax := 2;  { invoke mouse function 2 }
  94.  
  95.     intr($33, regs)
  96.   end; { procedure hide_cursor }
  97.  
  98.  
  99.  
  100. procedure get_cursor_position(var horizontal, vertical : integer);
  101.  
  102. { get the position of the cursor on the screen }
  103.  
  104.   type registers = record
  105.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  106.                    end; { record registers }
  107.  
  108.   var regs : registers;
  109.  
  110.   begin
  111.     regs.ax := 3;  { invoke mouse function 3 }
  112.  
  113.     intr($33, regs);
  114.  
  115.     horizontal := regs.cx;
  116.     vertical := regs.dx;
  117.   end; { procedure get_cursor_position }
  118.  
  119.  
  120.  
  121. procedure set_cursor_position(horizontal, vertical : integer);
  122.  
  123. { move the cursor to the specified position }
  124.  
  125.   type registers = record
  126.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  127.                    end; { record registers }
  128.  
  129.   var regs : registers;
  130.  
  131.   begin
  132.     regs.ax := 4; { invoke mouse function 4 }
  133.     regs.cx := horizontal;
  134.     regs.dx := vertical;
  135.  
  136.     intr($33, regs);
  137.   end; { procedure set_cursor_position }
  138.  
  139.  
  140.  
  141. procedure set_min_max_horiz(minimum, maximum : integer);
  142.  
  143. { set the minimum and maximum horizontal position of the cursor }
  144.  
  145.   type registers = record
  146.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  147.                    end; { record registers }
  148.  
  149.   var regs : registers;
  150.  
  151.   begin
  152.     regs.ax := 7;
  153.     regs.cx := minimum;
  154.     regs.dx := maximum;
  155.  
  156.     intr($33, regs);
  157.   end; { procedure set_min_max_horiz }
  158.  
  159.  
  160.  
  161. procedure set_min_max_vert(minimum, maximum : integer);
  162.  
  163. { set the minimum and maximum vertical position of the cursor }
  164.  
  165.   type registers = record
  166.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  167.                    end; { record registers }
  168.  
  169.   var regs : registers;
  170.  
  171.   begin
  172.     regs.ax := 8;
  173.     regs.cx := minimum;
  174.     regs.dx := maximum;
  175.  
  176.     intr($33, regs);
  177.   end; { procedure set_min_max_vert }
  178.  
  179.  
  180.  
  181. procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
  182.                               var cursor : cursor_array);
  183.  
  184. { Pass a custom cursor to the mouse hardware. Cursor information contained
  185.   in type cursor_array = array[0..31] of integer.  See examples in manual.
  186.   Concatenate the two arrays shown in the manual into one array. }
  187.  
  188.   type registers = record
  189.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  190.                    end; { record registers }
  191.  
  192.   var regs : registers;
  193.  
  194.   begin
  195.     regs.ax := 9;
  196.     regs.bx := hot_spot_x;
  197.     regs.cx := hot_spot_y;
  198.     regs.dx := ofs(cursor[0]);
  199.     regs.es := seg(cursor[0]);
  200.  
  201.     intr($33, regs);
  202.   end; { procedure set_graphics_cursor }
  203.  
  204.  
  205.  
  206. procedure read_counters(var horizontal, vertical : integer);
  207.  
  208. { read the the horizontal and vertical mickey count since the last call to
  209.   this procedure }
  210.  
  211.   type registers = record
  212.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  213.                    end; { record registers }
  214.  
  215.   var regs : registers;
  216.  
  217.   begin
  218.     regs.ax := 11;
  219.  
  220.     intr($33, regs);
  221.  
  222.     horizontal := regs.cx;
  223.     vertical := regs.dx;
  224.   end; { procedure read_counters }
  225.  
  226.  
  227.  
  228. procedure user_subroutine(mask, subroutine_segment, subroutine_offset : integer);
  229.  
  230. { allows a branch to the specified subroutine according to the conditions
  231.   specified in the call mask.  See the Microsoft mouse manual for details }
  232.  
  233.   type registers = record
  234.                      ax, bx, cx, dx, bp, di, si, ds, es, flags : integer
  235.                    end; { record registers }
  236.  
  237.   var regs : registers;
  238.  
  239.   begin
  240.     regs.ax := 12;
  241.     regs.cx := mask;
  242.     regs.es := subroutine_segment;
  243.     regs.dx := subroutine_offset;
  244.  
  245.     intr($33, regs);
  246.   end; { procedure user_subroutine }