home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
- Turbo Mouse
- Version 2.1
- Turbo Pascal Interface to Microsoft Mouse
- (C) Copyright 1991, Andrew Verba, All Rights Reserved
-
-
-
-
-
-
-
-
-
-
-
-
-
- TABLE OF CONTENTS
-
- I. Introduction .................................. 2
- II. Included Files ................................ 2
- III. Function and Procedure Overview ............... 3
- IV. Function and Procedure Details ................ 5
-
-
- -2-
-
-
- Introduction
- ------------
- These routines are being distributed as an aid to the development of
- Turbo Pascal programs using the Microsoft mouse. The mouse comes with a
- program that is accessed via BASIC but it is not accessable from Turbo Pascal.
- The routines supplied by Microsoft are also cryptic. Who can understand a
- statement like:
- CALL MOUSE(M1%,M2%,M3%,M4%) ?????
- Hopefully the functions and procedures presented here are easier to understand
- and use, leading to faster development and simpler debugging than possible
- with the BASIC call function.
- The calls to the Turbo Mouse routines are more straight forward. For
- instance the BASIC code to see if the mouse hardware and driver are installed
- is:
- 10 DEF SEG=0
- 20 MSEG=256*PEEK(51*4+3)+PEEK(51*4+2)
- 30 MOUSE=256*PEEK(51*4+1)+PEEK(51*4+2)
- 40 IF MSEG OR (MOUSE-2) THEN 60
- 50 PRINT "Mouse not installed":END
- 60 DEF SEG=MSEG
- 70 M1%=0
- 80 CALL MOUSE(M1%,M2%,M3%,M4%)
- 90 IF NOT(M1%) THEN PRINT "Mouse not installed":END
-
- Not the clearest code. But with Turbo Mouse :
-
- if not mouse_installed
- writeln('Mouse not installed');
-
- It's hard to beat.
-
- 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!
-
- Included Files
- -------- -----
- There are two files making up Turbo Mouse version 2.1.
-
- TMOUSE.DOC This document.
-
- TMOUSE.PAS This file contains the functions and procedures making
- up Turbo Mouse. In order to use it you must include
- it before your programs code. Uses TMOUSE; is fine.
-
- TMOUSE.TPU This is the unit file already compiled.
-
-
-
- -3-
-
-
- Function and Procedure Overview
- -------- --- --------- --------
- Following is a listing of the functions and procedures followed by a brief
- description of each. Details on the routines and the variables involved can
- be found on page 5.
-
- Functions
- ---------
- function mouse_installed : boolean;
- Return true if mouse driver and hardware are installed. Reset mouse
- to default settings.
-
- function button_pressed(button : integer) : boolean;
- Return true if the button is being held down.
-
- function number_of_presses(button : integer) : integer;
- Return the number of times that the button has been pressed since
- the last time that this function was called.
-
- function number_of_releases(button : integer) : integer;
- Return the number of times that the button has been released since
- the last time that this function was called.
-
-
- Procedures
- ----------
- procedure show_cursor;
- Make the cursor visible.
-
- procedure hide_cursor;
- Make the cursor invisible.
-
- procedure get_cursor_position(var horizontal, vertical : integer);
- Get the position of the cursor on the screen.
-
- procedure set_cursor_position(horizontal, vertical : integer);
- Move the cursor to the specified position on the screen.
-
- procedure set_min_max_horiz(minimum, maximum : integer);
- Set the minimum and maximum horizontal positions of the cursor.
-
- procedure set_min_max_vert(minimum, maximum : integer);
- Set the minimum and maximum vertical positions of the cursor.
-
- procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
- var cursor : cursor_array);
- Pass a custom cursor to the mouse hardware.
-
- procedure read_counters(var horizontal, vertical : integer);
- Read the horizontal and vertical mickey count since the last call
- to this procedure.
-
- procedure user_subroutine(mask, subroutine_segment, subroutine_offset
- : integer);
- Allows a branch to the specified subroutine according to the
- conditions in the call mask.
-
-
-
- -4-
-
-
- Procedures (cont.)
- ----------
- procedure light_pen_on;
- Enables light pen emulation by the mouse.
-
- procedure light_pen_off;
- Disables light pen emulation by the mouse.
-
- procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
- Sets the sensitivity of the mouse. Number of rotations per 8
- pixels.
-
- procedure set_text_cursor(bottom_line, top_line : integer);
- Select the hardware text cursor and the scan lines used.
-
-
- -5-
-
-
- Function and Procedure Details
- -------- --- --------- -------
- The following is the full information on the functions and procedures in
- Turbo Mouse. It is not intended as a tutorial on Turbo Pascal. It is assumed
- that the user of these routines understands the difference between functions
- and procedures. There is only one user defined variable type. It is an array
- that is used to pass the graphics cursor to the mouse. It is a simple array
- of integers and it is defined at the beginning of MMOUSE.PAS.
- It is a good idea to read the section of the Microsoft mouse manual called
- "Mouse Interface and System Calls".
-
-
- Functions
- ---------
-
-
- function mouse_installed : boolean;
-
- Return true if mouse driver and hardware are installed. Reset mouse to
- default settings:
- centers cursor on the screen
- sets the graphics cursor to the arrow with a hotspot of -1, -1
- sets the text cursor as an inverting box
- clears the user defined call mask
- enables light pen emulation
- sets the rotation per pixel ratio: 8 to 8 for horizontal
- 16 to 8 for vertical
- sets the minimum and maximum cursor positions to the full screen :
- horizontal -> 0 to 639
- vertical -> 0 to 199
- Example :
- if not mouse_installed
- writeln('Mouse not installed');
-
-
-
- function button_pressed(button : integer) : boolean;
-
- Return true if the button is being held down. The variable "button" should
- be either 0 for the left button or 1 for the right button. If any other
- number is passed it is treated as a 1.
-
- Example :
- if button_pressed(0) then
- writeln('Why don't you let go of the left button')
-
-
-
- function number_of_presses(button : integer) : integer;
-
- Return the number of times that the button has been pressed since the last
- time that this function was called. Again button should be 0 for the left
- button and 1 for the right button.
-
- Example :
- writeln('Press the right button to plot a point');
- while number_of_presses(1) = 0 do ;
- plot(x, y, color);
-
-
- -6-
-
-
- function number_of_releases(button : integer) : integer;
-
- Return the number of times that the button has been released since the last
- time that this function was called. Button = 0 -> left button. Button = 1 ->
- right button.
-
- Example :
- writeln('The left button has been released ',number_of_releases(0),
- 'times.');
-
-
-
- Procedures
- ----------
- procedure show_cursor;
-
- Make the cursor visible. This procedure takes no parameters. It just
- turns the cursor on. Always turn the cursor off before modifying the portion
- of the screen containing the cursor. This will prevent the corruption
- of the display.
-
- Example :
- show_cursor;
-
-
-
- procedure hide_cursor;
-
- Make the cursor invisible. This procedure takes no parameters. It just
- turns the cursor off. Even though the cursor is off, it still tracks the
- movement of the mouse. Always turn the cursor off before modifying the
- portion of the screen containing the cursor. This will prevent the corruption
- of the display.
-
- Example :
- hide_cursor;
- plot(x, y, color);
- show_cursor;
-
-
-
- procedure get_cursor_position(var horizontal, vertical : integer);
-
- Get the position of the cursor on the screen. The cursor position is
- returned in the parameters horizontal and vertical. The position is always
- within the range of the minimum and maximum values set by the set_min_max
- procedures.
-
- Example :
- get_cursor_position(x, y);
- gotoxy(x, y);
- write('I hope this is where you wanted it.');
-
-
- -7-
-
-
- procedure set_cursor_position(horizontal, vertical : integer);
-
- Move the cursor to the specified position on the screen. The values of
- horizontal and vertical must be within the ranges specified by the set_min_max
- procedures.
-
- Example :
- set_cursor_position(25, 50);
-
-
-
- procedure set_min_max_horiz(minimum, maximum : integer);
-
- Set the minimum and maximum horizontal positions of the cursor. Motion of
- the cursor is restricted to the left and right limits set by minimum and
- maximum. If the cursor is outside of the limits when the call is made, it is
- moved to just inside the bounds.
-
- Example :
- set_min_max_horiz(0, 200); { restrict the action to the left side of
- the screen. }
-
-
-
- procedure set_min_max_vert(minimum, maximum : integer);
-
- Set the minimum and maximum vertical positions of the cursor. Motion of
- the cursor is restricted the the upper and lower limits set by minimum and
- maximum. Again if the cursor is outside of the limits at the time of the
- call, it will be moved just inside the limit.
-
- Example :
- set_min_max_vert(50, 150); { restrict motion to the middle of the
- screen. }
-
-
-
- procedure set_graphics_cursor(hot_spot_x, hot_spot_y : integer;
- var cursor : cursor_array);
-
- Pass a custom cursor to the mouse hardware. The hot spots are the active
- part of the cursor (the part that is actually pointing). They must be in the
- range of -16 to 16. The cursor array is an array[0..31] of integer containing
- both the screen mask and the cursor mask. The following example is an
- adaptation of the arrow pointer shown in the Microsoft mouse manual.
-
- Example :
- const
- cursor : cursor_array=($FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
- $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
- $8000,$E000,$F800,$FE00,$D800,$0C00,$0600,$0300,
- $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000);
- hot_spot_x : integer = 0;
- hot_spot_y : integer = 0;
- set_graphics_cursor(hot_spot_x, hot_spot_y, cursor);
-
-
- -8-
-
-
- procedure read_counters(var horizontal, vertical : integer);
-
- Read the horizontal and vertical mickey count since the last call to this
- procedure. A mickey is equivalent to about 1/100th of an inch. A positive
- horizontal value signifies motion to the right. A positive vertical value
- signifies motion towards the bottom of the screen. The count is set to zero
- by this call.
-
- Example :
- if horiz <> 0 then
- writeln('You have moved ', horiz / 100, 'inches to the right.')
- else
- writeln('You have moved ', horiz / 100, 'inches to the left.');
-
-
-
- procedure user_subroutine(mask, subroutine_segment, subroutine_offset
- : integer);
-
- Allows a branch to the specified subroutine according to the conditions in
- the call mask. The mask is an integer that defines the conditions that will
- cause a branch to the user defined subroutine. Only bits 0 through 4 are used
- and they are defined as follows:
- Bit Condition
- 0 cursor position is changed
- 1 left button is pressed
- 2 left button is released
- 3 right button is pressed
- 4 right button is released
- Set the corresponding bit or bits in the mask using an integer corresponding
- to the bit positions that you want to set to 1.
- Control can be passed to a procedure or function by using the CSEG function
- for the subroutine_segment and ofs(function_name) for the subroutine_offset.
- Control is passed back to the point where the interrupt occurred.
-
- Example :
- mask = 10; { turn on bits 1 and 3. Binary -> 01010 }
- user_subroutine(mask, cseg, ofs(button_hit));
-
-
-
- procedure light_pen_on;
-
- Enables light pen emulation by the mouse. The pen is down when both both
- buttons are down, and up when both are up. Now if only Turbo Pascal had light
- pen functions like BASIC does this would be useful. Maybe I'll figure
- something out for future versions. For now you are on your own. This is the
- default state after resetting the mouse.
-
-
-
- procedure light_pen_off;
-
- Disables light pen emulation by the mouse. See light_pen_on.
-
-
- -9-
-
-
- procedure set_pixel_ratio(horizontal_ratio, vertical_ratio : integer);
-
- Sets the sensitivity of the mouse. Number of mickeys per 8 pixels. A
- Mickey is about 1/100th of an inch of motion by the mouse. The defeault
- values are 8 mickeys horizontally per 8 pixels horizontally and 16 mickeys
- vertically for 8 pixels vertically.
-
- Example :
- set_pixel_ratio(1, 2); { The cursor will really fly with this setting }
-
-
-
- procedure set_text_cursor(bottom_line, top_line : integer);
-
- Select the hardware text cursor and the scan lines used. Bottom_line
- contains the line number of first scan line and top_line the upper line.
- Top_line should always be greater than or equal to bottom_line. On the CGA
- the line numbers range from 0 to 7 with 0 being the lowest line and 7 the
- uppermost. On the MDA the line numbers range from 0 to 11 in the same manner.
-
- Example :
- set_text_cursor(0, 4); { set a text cursor that is about one half the
- height of the character box. }
-