home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TMOUSE.ZIP / TMOUSE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-12-01  |  7.7 KB  |  334 lines

  1. unit tmouse;
  2.  
  3. {  TURBO MOUSE V2.10                                    12/01/91
  4.        If you are a programmer and find this type of software
  5.        helpful, time-saving, as well as cutting redundancy
  6.        in your code; donate. Send 2 dollars with your name
  7.        and address to:
  8.                 Andrew Verba
  9.                 1001 Eagle Rd.
  10.                 Wayne, PA, 19087
  11.        You will recieve an account at Software Inc BBS. This BBS
  12.        is full of reliable, expandable code that you can use and
  13.        incorporate in almost any of your projects.
  14.        And help fight overpriced commercial software, use shareware
  15.        instead!
  16. }
  17.  
  18. interface
  19. type cursor_array = array[0..31] of integer;
  20.  
  21.  procedure set_text_cursor(bottom_line, top_line : integer);
  22.  function number_of_releases(button : integer) : integer;
  23.  function number_of_presses(button : integer) : integer;
  24.  procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
  25.  procedure light_pen_off;
  26.  procedure light_pen_on;
  27.  procedure user_subroutine(mask, subroutine_segment, subroutine_offset :
  28.    integer);
  29.  procedure read_counters(var horizontal, vertical : integer);
  30.  procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
  31.                               var cursor : cursor_array);
  32.  procedure set_min_max_vert(minimum, maximum : integer);
  33.  procedure set_min_max_horiz(minimum, maximum : integer);
  34.  procedure set_cursor_position(horizontal, vertical : integer);
  35.  procedure get_cursor_position(var horizontal, vertical : integer);
  36.  procedure hide_cursor;
  37.  procedure show_cursor;
  38.  
  39. implementation
  40.  
  41. uses dos,crt,graph;
  42.  
  43. function mouse_installed : boolean;
  44.  
  45. { return true if the mouse driver and hardware are installed.  Also
  46.   resets mouse to default settings. }
  47.  
  48.   var regs : registers;
  49.  
  50.   begin
  51.     regs.ax := 0;  { invoke mouse function 0 }
  52.     intr($33,regs);
  53.  
  54.     if regs.ax = 0 then
  55.       mouse_installed := false
  56.     else
  57.       mouse_installed := true;
  58.   end; { function mouse_installed }
  59.  
  60.  
  61.  
  62. function button_pressed(button : integer) : boolean;
  63.  
  64. { returns true if button is down.  Button = 0 for left button and 1
  65.   for right button }
  66.  
  67.   var regs  :  registers;
  68.  
  69.   begin
  70.     regs.ax := 3; { invoke mouse function 3 }
  71.  
  72.     intr($33, regs);
  73.  
  74.     if button = 0 then
  75.       button_pressed := (regs.bx and 1) <> 0
  76.     else
  77.       button_pressed := (regs.bx and 2) <> 0;
  78.   end; { function button_pressed }
  79.  
  80.  
  81.  
  82. procedure show_cursor;
  83.  
  84. { makes the cursor visible }
  85.  
  86.   var regs : registers;
  87.  
  88.   begin
  89.     regs.ax := 1;   { invoke mouse function 1 }
  90.  
  91.     intr($33, regs);
  92.   end; { procedure show_cursor }
  93.  
  94.  
  95.  
  96. procedure hide_cursor;
  97.  
  98. { makes cursor invisible }
  99.  
  100.   var regs : registers;
  101.  
  102.   begin
  103.     regs.ax := 2;  { invoke mouse function 2 }
  104.  
  105.     intr($33, regs)
  106.   end; { procedure hide_cursor }
  107.  
  108.  
  109.  
  110. procedure get_cursor_position(var horizontal, vertical : integer);
  111.  
  112. { get the position of the cursor on the screen }
  113.  
  114.   var regs : registers;
  115.  
  116.   begin
  117.     regs.ax := 3;  { invoke mouse function 3 }
  118.  
  119.     intr($33, regs);
  120.  
  121.     horizontal := regs.cx;
  122.     vertical := regs.dx;
  123.   end; { procedure get_cursor_position }
  124.  
  125.  
  126.  
  127. procedure set_cursor_position(horizontal, vertical : integer);
  128.  
  129. { move the cursor to the specified position }
  130.  
  131.   var regs : registers;
  132.  
  133.   begin
  134.     regs.ax := 4; { invoke mouse function 4 }
  135.     regs.cx := horizontal;
  136.     regs.dx := vertical;
  137.  
  138.     intr($33, regs);
  139.   end; { procedure set_cursor_position }
  140.  
  141.  
  142.  
  143. procedure set_min_max_horiz(minimum, maximum : integer);
  144.  
  145. { set the minimum and maximum horizontal position of the cursor }
  146.  
  147.   var regs : registers;
  148.  
  149.   begin
  150.     regs.ax := 7;
  151.     regs.cx := minimum;
  152.     regs.dx := maximum;
  153.  
  154.     intr($33, regs);
  155.   end; { procedure set_min_max_horiz }
  156.  
  157.  
  158.  
  159. procedure set_min_max_vert(minimum, maximum : integer);
  160.  
  161. { set the minimum and maximum vertical position of the cursor }
  162.  
  163.   var regs : registers;
  164.  
  165.   begin
  166.     regs.ax := 8;
  167.     regs.cx := minimum;
  168.     regs.dx := maximum;
  169.  
  170.     intr($33, regs);
  171.   end; { procedure set_min_max_vert }
  172.  
  173.  
  174.  
  175. procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
  176.                               var cursor : cursor_array);
  177.  
  178. { Pass a custom cursor to the mouse hardware. Cursor information contained
  179.   in type cursor_array = array[0..31] of integer.  See examples in Microsoft
  180.   mouse manual.  Concatenate the two arrays shown in the manual into one
  181.   array. }
  182.  
  183.   var regs : registers;
  184.  
  185.   begin
  186.     regs.ax := 9;
  187.     regs.bx := hot_spot_x;
  188.     regs.cx := hot_spot_y;
  189.     regs.dx := ofs(cursor[0]);
  190.     regs.es := seg(cursor[0]);
  191.  
  192.     intr($33, regs);
  193.   end; { procedure set_graphics_cursor }
  194.  
  195.  
  196.  
  197. procedure read_counters(var horizontal, vertical : integer);
  198.  
  199. { read the the horizontal and vertical mickey count since the last call to
  200.   this procedure }
  201.  
  202.   var regs : registers;
  203.  
  204.   begin
  205.     regs.ax := 11;
  206.  
  207.     intr($33, regs);
  208.  
  209.     horizontal := regs.cx;
  210.     vertical := regs.dx;
  211.   end; { procedure read_counters }
  212.  
  213.  
  214.  
  215. procedure user_subroutine(mask, subroutine_segment, subroutine_offset : integer);
  216.  
  217. { allows a branch to the specified subroutine according to the conditions
  218.   specified in the call mask.  See the Microsoft mouse manual for details }
  219.  
  220.   var regs : registers;
  221.  
  222.   begin
  223.     regs.ax := 12;
  224.     regs.cx := mask;
  225.     regs.es := subroutine_segment;
  226.     regs.dx := subroutine_offset;
  227.  
  228.     intr($33, regs);
  229.   end; { procedure user_subroutine }
  230.  
  231.  
  232.  
  233. procedure light_pen_on;
  234.  
  235. { enables light pen emulation by the mouse. }
  236.  
  237.   var regs : registers;
  238.  
  239.   begin
  240.     regs.ax := 13;   { invoke mouse function 13 }
  241.  
  242.     intr($33, regs);
  243.   end; { procedure light_pen_on }
  244.  
  245.  
  246.  
  247. procedure light_pen_off;
  248.  
  249. { disables light pen emulation by the mouse. }
  250.  
  251.   var regs : registers;
  252.  
  253.   begin
  254.     regs.ax := 14;   { invoke mouse function 14 }
  255.  
  256.     intr($33, regs);
  257.   end; { procedure light_pen_off }
  258.  
  259.  
  260.  
  261. procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
  262.  
  263. { Sets the sensitivity of the mouse.  The values entered for the ratios
  264.   determine the number of mickeys per eight pixels.
  265.   for example: horizontal_ratio = 8, vertical_ratio = 16 -> 8 mickeys for 8
  266.       pixels horizontally and 16 mickeys for 8 pixels vertically. }
  267.  
  268.  
  269.   var regs : registers;
  270.  
  271.   begin
  272.     regs.ax := 15;   { invoke mouse function 15 }
  273.     regs.cx := horizontal_ratio;
  274.     regs.dx := vertical_ratio;
  275.  
  276.     intr($33, regs);
  277.   end; { procedure set_pixel_ratio }
  278.  
  279.  
  280.  
  281. function number_of_presses(button : integer) : integer;
  282.  
  283. { returns number of times the button has been pressed since the last call
  284.   to this function.  Button = 0 for left button and 1 for right button }
  285.  
  286.  
  287.   var regs  :  registers;
  288.  
  289.   begin
  290.     regs.ax := 5; { invoke mouse function 5 }
  291.     regs.bx := button;
  292.  
  293.     intr($33, regs);
  294.  
  295.     number_of_presses := regs.bx;
  296.   end; { function number_of_presses }
  297.  
  298.  
  299.  
  300. function number_of_releases(button : integer) : integer;
  301.  
  302. { returns number of times the button has been released since the last call
  303.   to this function.  Button = 0 for left button and 1 for right button }
  304.  
  305.   var regs  :  registers;
  306.  
  307.   begin
  308.     regs.ax := 6; { invoke mouse function 6 }
  309.     regs.bx := button;
  310.  
  311.     intr($33, regs);
  312.  
  313.     number_of_releases := regs.bx;
  314.   end; { function number_of_releases }
  315.  
  316.  
  317.  
  318. procedure set_text_cursor(bottom_line, top_line : integer);
  319.  
  320. { select the text cursor and the scan lines used.  On the CGA the cursor
  321.   can be up to 8 scan lines high, numbered 0-7.  On the MDA, 0-11. }
  322.  
  323.   var regs  :  registers;
  324.  
  325.   begin
  326.     regs.ax := 10; { invoke mouse function 10 }
  327.     regs.bx := 1;
  328.     regs.cx := bottom_line;
  329.     regs.dx := top_line;
  330.  
  331.     intr($33, regs);
  332.   end; { function use_hardware_cursor }
  333. end.
  334.