home *** CD-ROM | disk | FTP | other *** search
- PBASMLIB Assembly Language Routines for PB3C
- Version 1.0
- Mouse Driver Interface Routines (MOUSE.ASM)
- (C) Copyright 1994 by Tim Gerchmez
- All Rights Reserved.
-
- This module contains routines that interface you to the mouse driver
- and allow you to add mouse control to your programs. You need to have
- a mouse driver loaded to use these routines (use MRESET to check for its
- presence), and the routines will be immediately accessible to your programs
- by including the statements $INCLUDE "PBASMLIB.INC" and $LINK "PBASMLIB.PBL"
- at the top of your programs.
-
- ================================================================================
- FUNCTION mattr%
-
- Returns the attribute at the mouse cursor position in text mode.
- This will vary depending on what attribute the mouse cursor
- is currently "on top of" (foreground/background colors), so can
- be used to test for certain attributes at different locations.
- To test for what's UNDER the mouse cursor, turn it off first with
- MHIDE. Make sure driver exists and is activated before calling.
-
- mattr%: Returns attribute value at mouse cursor y/x location
- (0-255).
-
- Example: print mattr%
-
- ================================================================================
- FUNCTION mchar$
-
- Returns the character at the mouse cursor's position in
- text mode. If the screen/cursor mask has been changed, turn
- the mouse cursor off first to find what's UNDER the mouse cursor.
- Make sure driver exists and is activated before calling.
-
- mchar$: Returns single ASCII character at mouse cursor's
- current y/x location on visible screen page.
-
- Example: a$ = mchar$
-
- ================================================================================
- SUB mcheck(lb%,rb%,mb%,y%,x%)
-
- Returns mouse buttons pressed and text coordinates
- of mouse cursor. To return graphics coordinates, use
- MGRAPHCHECK instead.
-
- lb%: Returns 1 if left button pressed, 0 if not
- rb%: Returns 1 if right button pressed, 0 if not
- mb%: Returns 1 if middle button pressed (Mouse Systems/
- Logitech mouse), or 0 if not
- y%: Returns y coordinate (row) of mouse cursor (1-25)
- x%: Returns x coordinate (column) of mouse cursor (1-80)
-
- Example: call mcheck(lb%,rb%,mb%,y%,x%)
-
- ================================================================================
- SUB mclear
-
- Resets the mouse driver, turning the mouse cursor off
- and resetting the internal SHOW/HIDE flag.
- Use when you get confused after multiple MSHOW/MHIDE
- commands, or to take the mouse out of strange modes.
- Does not change position of mouse cursor.
- A single MSHOW after an MCLEAR will show the mouse
- cursor at any time.
-
- Example: CALL mclear
-
- ================================================================================
- SUB mclearpen
-
- Turns mouse light-pen emulation mode OFF.
-
- Example: call mclearpen
-
- ================================================================================
- FUNCTION mcsrlin
-
- Similar to CSRLIN, but returns Y location of the mouse
- cursor instead of the normal screen cursor. Text mode only.
-
- Example: print mcsrlin
-
- ================================================================================
- SUB mdisable
-
- Disables the mouse driver. Use MENABLE to re-enable.
-
- Example: CALL mdisable
-
- ================================================================================
- SUB menable
-
- Enables the mouse driver after disabling with MDISABLE.
-
- Example: CALL menable
-
- ================================================================================
- SUB mgetaltroutine(mask%,sg??,ofs??)
-
- Attempts to find a user event handler defined by
- MSETALTROUTINE whose call mask matches mask%.
-
- mask%: Set to call mask to search for. Returns same
- call mask in mask% if found, or 0 in mask% if
- not found.
- sg??: Returns segment of user event handler, if found
- ofs??: Returns offset of user event handler, if found
-
- Example: mask%=1:mgetaltroutine mask%,sg??,ofs??
-
- ================================================================================
- SUB mgethotspot(counter%,hsy%,hsx%,tpe%)
-
- MS Mouse V7.02+ only - get mouse cursor hot spot
- row and column, internal mouse visibility flag, and
- mouse type.
-
- counter%: Returns internal mouse visibility flag
- hsy%: Returns cursor hot spot vertical row (Y)
- hsx%: Returns cursor hot spot horizontal column (X)
- tpe%: Returns mouse type (0=none, 1=bus, 2=serial,
- 3=InPort, 4=IBM, 5=Hewlett-Packard)
-
- Example: mgethotspot c%,y%,x%,t%
-
- ================================================================================
- FUNCTION mgetinfo(mv%,mn%,tpe%,intrpt%)
-
- MS Mouse V6.26+ only - returns information on mouse driver.
-
- mv%: Returns major version number (-1 if error) (the "8" in "8.1")
- mn%: Returns minor (revision) number (the "1" in "8.1"
- tpe%: Returns mouse type (1=bus, 2=serial, 3=InPort, 4=PS/2, 5=HP)
- intrpt%: Returns interrupt (0=PS/2, 2=IRQ2, 3=IRQ3,...,7=IRQ7)
-
- Example: mgetinfo mv%,mn%,tpe%,intrpt%
-
- ================================================================================
- SUB mgetmasks(smv??,cmv??,vmc%,hmc%)
-
- MS Mouse V7.01+ only - Get screen and cursor masks and
- horizontal/vertical mickey counts
-
- smv??: Returns screen mask value (or hardware scan line start
- if MS Mouse V7.02+)
- cmv??: Returns cursor mask value (or hardware scan line end
- if MS Mouse V7.02+)
- vmc%: Returns vertical mickeys moved since last call (Y)
- hmc%: Returns horizontal mickeys moved since last call (X)
-
- Example: call mgetmasks(s??,c??,v%,h%)
-
- ================================================================================
- SUB mgetmaxvirtual(mdf%,mvy%,mvx%)
-
- MS Mouse V6.26+ only - Gets maximum virtual coordinates
- (defined with MXRANGE/MYRANGE and related commands).
- To convert to text-mode values, divide by 8 and add 1.
-
- mdf%: Returns mouse-disabled flag
- mvy%: Returns maximum virtual Y coordinate
- mvx%: Returns maximum virtual X coordinate (current video mode)
-
- Example: mgetmaxvirtual mdf%,mvy%,mvx%
-
- ================================================================================
- SUB mgetpos(y%,x%)
-
- Gets the position of the mouse cursor on the screen in
- text mode. For graphics modes, use MGRAPHGETPOS instead.
- If button data is needed, use MCHECK instead
-
- y%: Returns y coordinate (row) of mouse cursor (1-25)
- x%: Returns x coordinate (column) of mouse cursor (1-80)
-
- Example: mgetpos y%,x%
-
- ================================================================================
- SUB mgetspeed(nh%,nv%,mps%)
-
- Gets the mouse driver's speed parameters.
-
- nh%: Returns number of mickeys per 8 pixels horizontally
- (see MSETSPEED)
- nv%: Returns number of mickeys per 8 pixels vertically
- (see MSETSPEED)
- mps%: Returns double-speed threshold in mickeys per second
- (see MSETDST)
-
- Example: CALL mgetspeed(nh%,nv%,mps%)
-
- ================================================================================
- SUB mgetvirtual(miny%,minx%,maxy%,maxx%)
-
- MS Mouse V7.05+ only - get mouse cursor virtual coordinates
- (set with MXRANGE/MYRANGE and related commands).
- To convert to text-mode values, divide by 8 and add 1.
-
- miny%: Returns virtual Y minimum value
- minx%: Returns virtual X minimum value
- maxy%: Returns virtual Y maximum value
- maxx%: Returns virtual X maximum value
-
- Example: mgetvirtual my%,mx%,xy%,xx%
- ================================================================================
- SUB mgraphbigdef(cw%,rw%,yh%,xh%,s$)
-
- Sets a large graphics cursor block for graphics modes
- (see MS mouse programmer's reference and MGRAPHDEFINE
- for info).
-
- cw%: Set to cursor width in words (0-255)
- rw%: Set to rows in cursor (0-255)
- yh%: Set to vertical "hot spot" (-16 to 16)
- xh%: Set to horizontal "hot spot" (-16 to 16)
- s$: Set to bit map of screen and cursor maps
-
- Example: mgraphbigdef cw%,rw%,yh%,xh%,s$
-
- ================================================================================
- SUB mgraphcheck(lb%,rb%,mb%,y%,x%)
-
- Returns mouse buttons pressed and graphics coordinates
- of mouse cursor. To find text coordinates instead, use
- MCHECK.
-
- lb%: Returns Left Button Status (1=pressed, 0=no)
- rb%: Returns Right Button Status (1=pressed, 0=no)
- mb%: Returns Middle Button Status (1=pressed, 0=no)
- y%: Returns y coordinate (row) of mouse cursor
- x%: Returns x coordinate (column) of mouse cursor
-
- Example: mgraphcheck lb%,rb%,mb%,y%,x%
-
- ================================================================================
- SUB mgraphdefine(yh%,xh%,bitmap$)
-
- Defines a shape for the graphics mouse cursor.
-
- yh%: Set to row of cursor hot spot (-16 to 16)
- xh%: Set to column of cursor hot spot (-16 to 16)
- bitmap$: Set to bitmap consisting of a 16-word screen
- mask and a 16-word cursor mask in string form
- (see MS mouse programmer's reference guide or
- other similar docs).
-
- Example: mgraphdefine yh%,xh%,bitmap$
-
- ================================================================================
- SUB mgraphgetpos(y%,x%)
-
-
- Gets the position of the mouse cursor on the screen in
- graphics modes. For text mode, use MGETPOS instead.
- If button data is needed, use MGRAPHCHECK instead
-
- y%: Returns y coordinate of mouse cursor
- x%: Returns x coordinate of mouse cursor
-
- Example: mgraphgetpos y%,x%
-
- ================================================================================
- SUB mgraphsetpos(y%,x%)
-
- Sets the position of the mouse cursor on the screen in
- graphics modes. For text mode, use MSETPOS instead.
-
- y%: Set to new y coordinate desired
- x%: Set to new x coordinate desired
-
- Example: mgraphsetpos 80,135
-
- ================================================================================
- SUB mhide
-
- Decrements the internal mouse cursor flag, hiding the mouse
- cursor if the flag goes below zero. Multiple calls to
- mhide will require multiple calls to MSHOW to show the cursor
- again. The mouse cursor is visible when the internal flag is
- zero or above, and invisible when the flag is below zero.
-
- Example: mhide [or] call mhide
-
- ================================================================================
- FUNCTION mlanguage
-
- Returns current language setting for international version
- of the mouse driver. U.S. version always returns 0.
- See MSETLANGUAGE for language values.
-
- Example: print mlanguage
-
- ================================================================================
- FUNCTION mleftbutton
-
- Returns 1 if left mouse button is pressed, 0 if not.
-
- Example: if mleftbutton=1 then print "Left Button Pressed"
-
- ================================================================================
- FUNCTION mlpresses
-
- Returns number of times left mouse button was pressed
- since this function was last called.
-
- Example: sleep 5:print mlpresses
-
- ================================================================================
- FUNCTION mlreleases
-
- Returns number of times left mouse button was released
- since this function was last called.
-
- Example: sleep 5:print mlreleases
-
- ================================================================================
- FUNCTION mmidbutton
-
- Returns 1 if middle mouse button pressed, 0 if not.
-
- Example: a% = mmidbutton
-
- ================================================================================
- FUNCTION mmpresses
-
- Returns number of times middle mouse button was pressed
- since this function was last called.
-
- Example: sleep 5:print mmpresses
-
- ================================================================================
- FUNCTION mmreleases
-
- Returns number of times middle mouse button was released
- since this function was last called.
-
- Example: sleep 5:print mmreleases
-
- ================================================================================
- SUB moffarea(uly%,ulx%,lry%,lrx%)
-
- Defines an area for screen updating in text mode. If the mouse
- cursor enters this area it will be turned off, and must be
- explicitly turned on again with MSHOW. For graphics modes,
- use MOFFGRAPHAREA.
-
- uly%: Set to upper left y position (1-25)
- ulx%: Set to upper left x position (1-80)
- lry%: Set to lower right y position (1-80)
- lrx%: Set to lower right x position (1-80)
-
- Example: moffarea 10,10,15,15 'Defines "turnoff" area
-
- ================================================================================
- SUB moffgrapharea(uly%,ulx%,lry%,lrx%)
-
- Defines an area for screen updating in graphics modes. If
- the mouse enters this area it will be turned off, and must
- be explicitly turned on again with MSHOW. For text modes,
- use MOFFAREA.
-
- uly%: Set to upper left y coordinate of update area
- ulx%: Set to upper left x coordinate of update area
- lry%: Set to lower right y coordinate of update area
- lrx%: Set to lower right x coordinate of update area
-
- Example: moffgrapharea 100,110,105,120
-
- ================================================================================
- FUNCTION mpage
-
- Returns the page the mouse cursor is currently displayed on.
-
- mpage: Returns page number
-
- Example: print mpage
-
- ================================================================================
- FUNCTION mpos(x%)
-
- Similar to POS(0), except returns X location of the mouse cursor
- instead of the normal screen cursor. Text mode only.
-
- x%: Set to dummy argument (normally 0)
-
- Example: print mpos(0)
-
- ================================================================================
- SUB mreadcounters(hmickeys%,vmickeys%)
-
- Returns number of horizontal and vertical mickeys
- mouse was moved since the last call to this routine.
- A mickey is the smallest increment the mouse can sense.
- Positive values indicate down/right movement.
-
- hmickeys%: Returns horizontal mickeys mouse was moved
- vmickeys%: Returns vertical mickeys mouse was moved
-
- Example: mreadcounters hm%,vm%
-
- ================================================================================
- SUB mreset(ins%,nb%)
-
- Resets the installed mouse driver (if any) and returns
- status and number of mouse buttons.
-
- ins%: Returns 0 if no mouse driver installed, or
- 1 if mouse driver is installed.
- nb%: Returns number of mouse buttons (if ins%<>0)
-
- Example: mreset ins%,nb%
- if ins%=1 then print "Mouse Installed"
-
- ================================================================================
- SUB mrestorestate(bf$)
-
- Restores the state of the mouse driver previously saved with
- MSAVESTATE.
-
- bf$: Set to buffer string retrieved with MSAVESTATE$
-
- Example: mrestorestate bf$
-
- ================================================================================
- FUNCTION mrightbutton
-
- Returns 1 if right mouse button pressed, 0 if not.
-
- Example: print mrightbutton
-
- ================================================================================
- FUNCTION mrpresses
-
- Returns number of times right mouse button was pressed
- since this function was last called.
-
- Example: sleep 5:print mrpresses
-
- ================================================================================
- FUNCTION mrreleases
-
- Returns number of times right mouse button was released
- since this function was last called.
-
- Example: sleep 5:print mrreleases
-
- ================================================================================
- FUNCTION msavestate$
-
- Saves the current state of the mouse driver (mouse position,
- type of cursor, etc etc). Use MRESTORESTATE to restore.
-
- msavestate$: Returns state buffer (save this string to
- use with MRESTORESTATE later). If insufficient
- memory available, will return "".
-
- Example: bf$ = msavestate$ 'if bf$<>"", state is saved.
-
- ================================================================================
- SUB msetaltroutine(mask%,sg??,ofs??)
-
- Sets a pointer to an alternate mouse-handler routine and
- defines a condition mask that will determine when the
- mouse driver calls that routine (see MSETROUTINE). Up to
- three handlers can be defined by separate calls to this
- routine. When the alternate routine is called, it's passed
- the same values given for MSETROUTINE. Note that the "bit
- mask" differs from the one given in MSETROUTINE:
-
- mask%: Set to condition mask for alternate routine:
- Bit 0: Call if mouse moves
- Bit 1: Call if left button pressed
- Bit 2: Call if left button released
- Bit 3: Call if right button pressed
- Bit 4: Call if right button released
- Bit 5: Call if shift key pressed during event
- Bit 6: Call if ctrl key pressed during event
- Bit 7: Call if alt key pressed during event.
- sg??: Set to segment of your mouse handler routine
- ofs??: Set to offset of your mouse handler routine
-
- Example: msetaltroutine 1,sg??,o??
-
- ================================================================================
- SUB msetdst(mps%)
-
- Sets a "double-speed threshold" for the mouse cursor in mickeys
- per second. If mouse moves faster than this, the cursor's on-
- screen motion is doubled.
-
- mps%: Set to mickeys per second threshold value (0=default 64)
-
- Example: msetdst 0 'Reset to default
-
- ================================================================================
- SUB msetlanguage(l%)
-
- Sets the international version of the mouse driver to
- display messages in a certain language. U.S. driver
- versions ignore this call.
-
- l%: Set to language desired:
- 0 = English
- 1 = French
- 2 = Dutch
- 3 = German
- 4 = Swedish
- 5 = Finnish
- 6 = Spanish
- 7 = Portuguese
- 8 = Italian
-
- Example: msetlanguage 0 'Set to English
-
- ================================================================================
- SUB msetpage(pg%)
-
- Sets the page the mouse cursor will be displayed on.
-
- pg%: Set to page number (in text modes, 0-3 CGA, 0-7 EGA/VGA)
-
- Example: msetpage 0
-
- ================================================================================
- SUB msetpen
-
- Turns mouse light-pen emulation mode ON.
-
- Example: call msetpen
-
- ================================================================================
- SUB msetpos(y%,x%)
-
- Sets the position of the mouse cursor on the screen in
- text mode. For graphics modes, use MGRAPHSETPOS instead.
-
- y%: Set to new y coordinate desired (1-25)
- x%: Set to new x coordinate desired (1-80)
-
- Example: msetpos 15,1
-
- ================================================================================
- SUB msetroutine(mask%,sg??,ofs??)
-
- Sets a pointer to your mouse-handler routine and defines
- a condition mask that will determine when the mouse driver
- will call your routine. The call made is far, and your
- routine should terminate with an RETF instruction. When
- your routine is called, it's passed the following values:
- AX=condition mask (same as call mask)
- BX=button state,CX=cursor column,DX=cursor row
- SI=horizontal mickey count,DI=vertical mickey count
-
- mask%: Set to condition mask:
- Bit 0: Call if mouse moves
- Bit 1: Call if left button pressed
- Bit 2: Call if left button released
- Bit 3: Call if right button pressed
- Bit 4: Call if right button released
- Bit 5: Call if middle button pressed
- Bit 6: Call if middle button released
- sg??: Set to segment of your mouse handler routine
- ofs??: Set to offset of your mouse handler routine
-
- Example: msetroutine m%,s??,o??
-
- ================================================================================
- SUB msetspeed(nh%,nv%)
-
- Sets the mickey to pixel ratio for the mouse driver.
- The larger the numbers, the slower the mouse cursor will
- move in relation to mouse movements (text and graphics)
-
- nh%: Set to number of mickeys per 8 pixels horizontally
- (defaults to 8)
- nv%: Set to number of mickeys per 8 pixels vertically
- (defaults to 16)
-
- Example: msetspeed 64,64 'Very slow mouse movements
- msetspeed 2,2 'Extremely fast mouse movements
-
- ================================================================================
- SUB mshow
-
- Increments the internal mouse cursor flag, showing the
- mouse if the flag is at zero. Multiple calls to mshow will
- require multiple calls to MHIDE to hide the cursor again. The
- mouse cursor is visible when the internal flag is zero or above,
- and invisible when the flag is below zero.
-
- Example: mshow [or] call mshow
-
- ================================================================================
- SUB mtextdefine(tpe%,a%,b%)
-
- Sets the text-mode mouse cursor to the hardware or
- software cursor, and defines start/end scan lines for
- the hardware cursor or screen/cursor masks for the software
- cursor. Default is software cursor (if this routine is
- not called).
-
- tpe%: Set to 0 for software cursor, or 1 for hardware cursor
- a%: Set to screen mask for software cursor, or start scan
- line for hardware cursor (according to setting of tpe%).
- b%: Set to cursor mask for software cursor, or end scan
- line for hardware cursor (according to setting of tpe%)
-
- Example: mtextdefine 1,1,7 'Set hardware block cursor
-
- ================================================================================
- SUB mxchgroutine(mask%,sg??,ofs??)
-
- Exchanges a new mouse-handler routine for the current one
- (see MSETROUTINE)
-
- mask%: Set to condition mask (see MSETROUTINE). Condition
- mask of old routine is returned in mask%.
- sg??: Set to segment of new handler. Segment of old handler
- is returned in sg??.
- ofs??: Set to offset of new handler. Offset of old handler
- is returned in ofs??.
-
- Example: mxchgroutine mask%,sg??,ofs??
-
- ================================================================================
- SUB mxgraphrange(min%,max%)
-
- Defines the minimum and maximum allowable screen range for
- the mouse cursor in graphics modes, thus defining a "border"
- area at the left and right of the screen that the mouse
- cursor cannot move into. For text mode, use MXRANGE.
-
- min%: Set to minimum x position
- max%: Set to maximum x position
-
- Example: mxgraphrange 50,100
-
- ================================================================================
- SUB mxrange(min%,max%)
-
- Defines the minimum and maximum allowable screen range
- for the mouse cursor in text mode, thus defining a "border"
- area at the left and right of the screen that the mouse cursor
- cannot move into. For graphics modes, use MXGRAPHRANGE
-
- min%: Set to minimum x position (column) (1-80)
- max%: Set to maximum x position (column) (1-80)
-
- Example: mxrange 5,75 ' Restricts mouse cursor to columns 5-75
-
- ================================================================================
- SUB mygraphrange(min%,max%)
-
- Defines the minimum and maximum allowable screen range for
- the mouse cursor in graphics modes, thus defining a "border"
- area at the top and bottom of the screen that the mouse
- cursor cannot move into. For text mode, use MYRANGE.
-
- min%: Set to minimum y position
- max%: Set to maximum y position
-
- Example: mygraphrange 10,50
-
- ================================================================================
- SUB myrange(min%,max%)
-
- Defines the minimum and maximum allowable screen range for the
- mouse cursor in text mode, thus defining a "border" area at the
- top and bottom of the screen that the mouse cursor cannot move
- into. For graphics modes, use MYGRAPHRANGE
-
- min%: Set to minimum y position (row) (1-25)
- max%: Set to maximum y position (row) (1-25)
-
- Example: myrange 3,22 'Restricts mouse cursor to rows 3-22
-
-