home *** CD-ROM | disk | FTP | other *** search
- unit tmouse;
-
- { TURBO MOUSE V2.10 12/01/91
- If you are a programmer and find this type of software
- helpful, time-saving, as well as cutting redundancy
- in your code; donate. Send 2 dollars with your name
- and address to:
- Andrew Verba
- 1001 Eagle Rd.
- Wayne, PA, 19087
- You will recieve an account at Software Inc BBS. This BBS
- is full of reliable, expandable code that you can use and
- incorporate in almost any of your projects.
- And help fight overpriced commercial software, use shareware
- instead!
- }
-
- interface
- type cursor_array = array[0..31] of integer;
-
- procedure set_text_cursor(bottom_line, top_line : integer);
- function number_of_releases(button : integer) : integer;
- function number_of_presses(button : integer) : integer;
- procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
- procedure light_pen_off;
- procedure light_pen_on;
- procedure user_subroutine(mask, subroutine_segment, subroutine_offset :
- integer);
- procedure read_counters(var horizontal, vertical : integer);
- procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
- var cursor : cursor_array);
- procedure set_min_max_vert(minimum, maximum : integer);
- procedure set_min_max_horiz(minimum, maximum : integer);
- procedure set_cursor_position(horizontal, vertical : integer);
- procedure get_cursor_position(var horizontal, vertical : integer);
- procedure hide_cursor;
- procedure show_cursor;
-
- implementation
-
- uses dos,crt,graph;
-
- function mouse_installed : boolean;
-
- { return true if the mouse driver and hardware are installed. Also
- resets mouse to default settings. }
-
- var regs : registers;
-
- begin
- regs.ax := 0; { invoke mouse function 0 }
- intr($33,regs);
-
- if regs.ax = 0 then
- mouse_installed := false
- else
- mouse_installed := true;
- end; { function mouse_installed }
-
-
-
- function button_pressed(button : integer) : boolean;
-
- { returns true if button is down. Button = 0 for left button and 1
- for right button }
-
- var regs : registers;
-
- begin
- regs.ax := 3; { invoke mouse function 3 }
-
- intr($33, regs);
-
- if button = 0 then
- button_pressed := (regs.bx and 1) <> 0
- else
- button_pressed := (regs.bx and 2) <> 0;
- end; { function button_pressed }
-
-
-
- procedure show_cursor;
-
- { makes the cursor visible }
-
- var regs : registers;
-
- begin
- regs.ax := 1; { invoke mouse function 1 }
-
- intr($33, regs);
- end; { procedure show_cursor }
-
-
-
- procedure hide_cursor;
-
- { makes cursor invisible }
-
- var regs : registers;
-
- begin
- regs.ax := 2; { invoke mouse function 2 }
-
- intr($33, regs)
- end; { procedure hide_cursor }
-
-
-
- procedure get_cursor_position(var horizontal, vertical : integer);
-
- { get the position of the cursor on the screen }
-
- var regs : registers;
-
- begin
- regs.ax := 3; { invoke mouse function 3 }
-
- intr($33, regs);
-
- horizontal := regs.cx;
- vertical := regs.dx;
- end; { procedure get_cursor_position }
-
-
-
- procedure set_cursor_position(horizontal, vertical : integer);
-
- { move the cursor to the specified position }
-
- var regs : registers;
-
- begin
- regs.ax := 4; { invoke mouse function 4 }
- regs.cx := horizontal;
- regs.dx := vertical;
-
- intr($33, regs);
- end; { procedure set_cursor_position }
-
-
-
- procedure set_min_max_horiz(minimum, maximum : integer);
-
- { set the minimum and maximum horizontal position of the cursor }
-
- var regs : registers;
-
- begin
- regs.ax := 7;
- regs.cx := minimum;
- regs.dx := maximum;
-
- intr($33, regs);
- end; { procedure set_min_max_horiz }
-
-
-
- procedure set_min_max_vert(minimum, maximum : integer);
-
- { set the minimum and maximum vertical position of the cursor }
-
- var regs : registers;
-
- begin
- regs.ax := 8;
- regs.cx := minimum;
- regs.dx := maximum;
-
- intr($33, regs);
- end; { procedure set_min_max_vert }
-
-
-
- procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
- var cursor : cursor_array);
-
- { Pass a custom cursor to the mouse hardware. Cursor information contained
- in type cursor_array = array[0..31] of integer. See examples in Microsoft
- mouse manual. Concatenate the two arrays shown in the manual into one
- array. }
-
- var regs : registers;
-
- begin
- regs.ax := 9;
- regs.bx := hot_spot_x;
- regs.cx := hot_spot_y;
- regs.dx := ofs(cursor[0]);
- regs.es := seg(cursor[0]);
-
- intr($33, regs);
- end; { procedure set_graphics_cursor }
-
-
-
- procedure read_counters(var horizontal, vertical : integer);
-
- { read the the horizontal and vertical mickey count since the last call to
- this procedure }
-
- var regs : registers;
-
- begin
- regs.ax := 11;
-
- intr($33, regs);
-
- horizontal := regs.cx;
- vertical := regs.dx;
- end; { procedure read_counters }
-
-
-
- procedure user_subroutine(mask, subroutine_segment, subroutine_offset : integer);
-
- { allows a branch to the specified subroutine according to the conditions
- specified in the call mask. See the Microsoft mouse manual for details }
-
- var regs : registers;
-
- begin
- regs.ax := 12;
- regs.cx := mask;
- regs.es := subroutine_segment;
- regs.dx := subroutine_offset;
-
- intr($33, regs);
- end; { procedure user_subroutine }
-
-
-
- procedure light_pen_on;
-
- { enables light pen emulation by the mouse. }
-
- var regs : registers;
-
- begin
- regs.ax := 13; { invoke mouse function 13 }
-
- intr($33, regs);
- end; { procedure light_pen_on }
-
-
-
- procedure light_pen_off;
-
- { disables light pen emulation by the mouse. }
-
- var regs : registers;
-
- begin
- regs.ax := 14; { invoke mouse function 14 }
-
- intr($33, regs);
- end; { procedure light_pen_off }
-
-
-
- procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
-
- { Sets the sensitivity of the mouse. The values entered for the ratios
- determine the number of mickeys per eight pixels.
- for example: horizontal_ratio = 8, vertical_ratio = 16 -> 8 mickeys for 8
- pixels horizontally and 16 mickeys for 8 pixels vertically. }
-
-
- var regs : registers;
-
- begin
- regs.ax := 15; { invoke mouse function 15 }
- regs.cx := horizontal_ratio;
- regs.dx := vertical_ratio;
-
- intr($33, regs);
- end; { procedure set_pixel_ratio }
-
-
-
- function number_of_presses(button : integer) : integer;
-
- { returns number of times the button has been pressed since the last call
- to this function. Button = 0 for left button and 1 for right button }
-
-
- var regs : registers;
-
- begin
- regs.ax := 5; { invoke mouse function 5 }
- regs.bx := button;
-
- intr($33, regs);
-
- number_of_presses := regs.bx;
- end; { function number_of_presses }
-
-
-
- function number_of_releases(button : integer) : integer;
-
- { returns number of times the button has been released since the last call
- to this function. Button = 0 for left button and 1 for right button }
-
- var regs : registers;
-
- begin
- regs.ax := 6; { invoke mouse function 6 }
- regs.bx := button;
-
- intr($33, regs);
-
- number_of_releases := regs.bx;
- end; { function number_of_releases }
-
-
-
- procedure set_text_cursor(bottom_line, top_line : integer);
-
- { select the text cursor and the scan lines used. On the CGA the cursor
- can be up to 8 scan lines high, numbered 0-7. On the MDA, 0-11. }
-
- var regs : registers;
-
- begin
- regs.ax := 10; { invoke mouse function 10 }
- regs.bx := 1;
- regs.cx := bottom_line;
- regs.dx := top_line;
-
- intr($33, regs);
- end; { function use_hardware_cursor }
- end.