Mouse Programming Reference =========================== Function Overview ----------------- 0 - Mouse Installed Flag and Reset 1 - Show Cursor 2 - Hide Cursor 3 - Get Mouse Position and Button Status 4 - Set Mouse Cursor Position 5 - Get Button Press Information 6 - Get Button Release Information 7 - Set Minimum and Maximum Horizontal Position 8 - Set Minimum and Maximum Vertical Position 9 - Set Graphics Cursor Block 10 - Set Text Cursor 11 - Read Mouse Motion Counters 12 - Set User-Defined Subroutine Input Mask 13 - Light Pen Emulation Mode On 14 - Light Pen Emulation Mode Off 15 - Set Mickey/Pixel Ratio 16 - Conditional Off 19 - Set Double Speed Threshold Given: SUB MouseDriver m1%, m2%, m3%, m4% Function 0: Mouse Installed Flag and Reset ------------------------------------------ Input: m1% = 0 Output: m1% = mouse status m2% = number of buttons mouse status is 0 (false) if the mouse hardware and software are not installed, and is -1 (true) if the hardware and software are installed. Function 1: Show Cursor ----------------------- Input: m1% = 1 Increments the internal cursor flag and, if the flag is 0, displays the cursor on the screen. The cursor tracks the motion of the mouse, changing position as the mouse changes position. Function 2: Hide Cursor ----------------------- Input: m1% = 2 Removes the cursor from the screen and decrements the internal cursor flag. The cursor, even though hidden, still tracks the motion of the mouse, changing position as the mouse changes position. Use this function before modifying any portion of the screen containing the cursor. This prevents the cursor from possibly affection the data written to the screen. Function 3: Get Mouse Position and Button Status ------------------------------------------------ Input: m1% = 3 Output: m2% = button status m3% = cursor position (horizontal) m4% = cursor position (vertical) Returns the state of the left and right buttons and the horizontal and vertical positions of the cursor. The button status is a single integer value. Bits 0 and 1 represent the left and right buttons, respectively. A bit is 1 if a button is down, and 0 if up. Note: In 320xwhatever screen resolutions the horizontal values will still range between 0 and 640, so you must divide by 2 to get the actual pixel location. Function 4: Set Mouse Cursor Position ------------------------------------- Input: m1% = 4 m2% = (horizontal) new cursor position m3% = (vertical) new cursor position Sets the cursor to the specified horizontal and vertical screen positions. The new values must be in the horizontal and vertical ranges of the virtual screen. If the screen is not in high resolution mode, the values are rounded to the nearest horizontal or vertical values permitted for the current screen mode. Function 5: Get Button Press Information ---------------------------------------- Input: m1% = 5 m2% = button Output: m1% = button status m2% = count of button presses m3% = cursor (horizontal) at last press m4% = cursor (vertical) at last press Returns current button status, a count of button presses since that last call to this function, and the horizontal and vertical position of the cursor at the last press of the button. The parameter m2% specifies which button is checked. If set to 0, the left button is checked. If 1, the right button is checked. The count of button presses is always in the range 0 to 32767; overflow is not detected. The count is set to 0 after the call. Function 6: Get Button Release Information ------------------------------------------ Input: m1% = 6 m2% = button Output: m1% = button status m2% = count of button releases m3% = cursor (horizontal) at last release m4% = cursor (vertical) at last release Returns current button status, a count of button releases since the last call to this function, and the horizontal and vertical position of the cursor at the last release of the button. Function 7: Set Minimum and Maximum Horizontal Position ------------------------------------------------------- Input: m1% = 7 m3% = minimum position m4% = maximum position Sets the minimum and maximum horizontal cursor positions on the screen. Subsequent cursor motion is restricted to the specified area. The minimum and maximum values are defined by the virtual screen. If the minimum value is greater than the maximum, the two values are swapped. Function 8: Set minimum and Maximum Vertical Position ----------------------------------------------------- Input: m1% = 8 m3% = minimum position m4% = maximum position Function 9: Set Graphics Cursor Block ------------------------------------- Input: m1% = 9 m2% = cursor hot spot (horizontal) m3% = cursor hot spot (vertical) m4% = pointer to screen and cursor masks Defines the shape, color, and center of the cursor when in graphics modes. To pass the screen mask and cursor mask in BASIC, assign their values to an integer array and use the first element of the array as the fourth parameter in the call. Note: This function is poorly documented, so you may not be able to get it to work using just the information in this file. Example: 'Create array DIM CURSOR(0 TO 15, 0 TO 1) 'Define the screen mask CURSOR( 0,0)=&HE1FF 'Binary 1110000111111111 CURSOR( 1,0)=&HE1FF 'Binary 1110000111111111 CURSOR( 2,0)=&HE1FF 'Binary 1110000111111111 CURSOR( 3,0)=&HE1FF 'Binary 1110000111111111 CURSOR( 4,0)=&HE1FF 'Binary 1110000111111111 CURSOR( 5,0)=&HE000 'Binary 1110000000000000 CURSOR( 6,0)=&HE000 'Binary 1110000000000000 CURSOR( 7,0)=&HE000 'Binary 1110000000000000 CURSOR( 8,0)=&H0000 'Binary 0000000000000000 CURSOR( 9,0)=&H0000 'Binary 0000000000000000 CURSOR(10,0)=&H0000 'Binary 0000000000000000 CURSOR(11,0)=&H0000 'Binary 0000000000000000 CURSOR(12,0)=&H0000 'Binary 0000000000000000 CURSOR(13,0)=&H0000 'Binary 0000000000000000 CURSOR(14,0)=&H0000 'Binary 0000000000000000 CURSOR(15,0)=&H0000 'Binary 0000000000000000 'Define the cursor mask CURSOR( 0,0)=&H1E00 'Binary 0001111000000000 CURSOR( 1,0)=&H1200 'Binary 0001001000000000 CURSOR( 2,0)=&H1200 'Binary 0001001000000000 CURSOR( 3,0)=&H1200 'Binary 0001001000000000 CURSOR( 4,0)=&H1200 'Binary 0001001000000000 CURSOR( 5,0)=&H13FF 'Binary 0001001111111111 CURSOR( 6,0)=&H1249 'Binary 0001001001001001 CURSOR( 7,0)=&H1249 'Binary 0001001001001001 CURSOR( 8,0)=&HF249 'Binary 1111001001001001 CURSOR( 9,0)=&H9001 'Binary 1001000000000001 CURSOR(10,0)=&H9001 'Binary 1001000000000001 CURSOR(11,0)=&H9001 'Binary 1001000000000001 CURSOR(12,0)=&H8001 'Binary 1000000000000001 CURSOR(13,0)=&H8001 'Binary 1000000000000001 CURSOR(14,0)=&H8001 'Binary 1000000000000001 CURSOR(15,0)=&HFFFF 'Binary 1111111111111111 Function 10: Set Text Cursor ---------------------------- Input: m1% = 10 m2% = cursor select m3% = screen mask value/scan line start m4% = cursor mask value/scan line stop Selects the software of hardware text cursor. If the software text cursor is selected, this function defines the character attributes of the cursor when in text mode. If the hardware text cursor is selected, this function defines the first and last scan lines to be shown on the screen. The value of the parameter m2% selects the cursor type. If the value is 0, the software text cursor is selected. If the value is 1, the hardware text cursor is selected. Function 11: Read Mouse Motion Counters --------------------------------------- Input: m1% = 11 Output: m3% = count (horizontal) m4% = count (vertical) Returns the horizontal and vertical mickey count since the last call to this function. The mickey count is the distance in 1/100 inch increments that the mouse has moved. The mickey count is always within the range -32768 to 32767. A positive horizontal count specifies a motion to the right. A positive vertical count specifies a motion to the bottom of the screen. Overflow is ignored. The mickey count is set to 0 after the call is completed. Function 12: Set User-Defined Subroutine Input Mask --------------------------------------------------- Input: m1% = 12 m3% = call mask m4% = address offset to subroutine Sets the call mask and subroutine address for the mouse software interrupts. The mouse software interrupts automatically, stops execution of your program and calls the specified subroutine whenever one of more of the conditions defined by the call mask occur. On completion of the subroutine, your program will continue execution at the point of interruption. The call mask, a single integer value, defines which conditions will cause an interrupt. Each bit in the call mask corresponds to a specific condition as shown here: Mask bit Condition -------- --------- 0 cursor position changes 1 left button pressed 2 left button released 3 right button pressed 4 right button released 5-15 not used (1984 driver, newer drivers may make use of these bits) To enable an interrupt for a given condition, set the corresponding call mask bit to 1 and pass the mask as parameter m3%. To disable a condition, set the corresponding bit to 0 and pass the mask. All conditions are automatically disabled by Function 0. When the mouse software makes a call to the subroutine, it loads the following information into the CPU registers: Register Information -------- ----------- AX condition mask (similar to call mask except a bit is set only if the condition has occurred) BX button state CX cursor position (horizontal) DX cursor position (vertical) Function 13: Light Pen Emulation Mode On ----------------------------------------- Input: m1% = 13 Enables the light pen emulation by the mouse. When the mouse emulates the light pen, calls to the PEN function, described in the BASIC manual, will return the cursor position at the last "pen down." "Pen down" and "Pen off the screen" are controlled by the mouse buttons. The pen is down when both buttons are down. The pen os off the screen when both buttons are up. Function 14: Light Pen Emulation Mode Off ----------------------------------------- Input: m1% = 14 Disables the light pen emulation. Function 15: Set mickey/pixel ratio ----------------------------------- Input: m1% = 15 m2% = mickey/pixel ratio (horizontal) m3% = mickey/pixel ratio (vertical) Sets the mickey to pixel ratio for mouse motion. The horizontal and vertical ratios specify a number of mickeys per 8 pixels. The values must be in the range 1 to 32767. Function 16: Conditional Off ---------------------------- Note: The manual only gives assembly instructions. Input: AX = 16 CX = upper x screen coordinate value DX = upper y screen coordinate value SI = lower x screen coordinate value DI = lower y screen coordinate value Function 16 defines a region on the screen for updating. If the mouse pointer is in or moves into the defined region, Function 16 hides the mouse cursor while the region is being updated. After calling Function 16, a subsequent call to Function 1 (show cursor) is needed to show the cursor again. Function 19: Set Double Speed Threshold --------------------------------------- Input: m1% = 19 m4% = Threshold speed in mickeys/second Function 19 sets the threshold speed for doubling the cursor's motion on the screen. Using Function 19 will make it easier to point at images widely separate on the screen. Parameter m4% defines the threshold speed of the mouse. If no value is given, a preset value of 64 mickeys per second is assigned. If the mouse movement speed exceeds the value in m4%, cursor motion double in speed. The threshold speed is set until Function 19 is called again. The speed doubling feature is not turned off in the same sense as a switch is turned off. It can be disables by setting the value of m4% to a speed sufficiently higher that the mouse can obtain (10000 for example) and then calling Function 19.