'===========================================================================
' Subject: TEXT MOUSE ROUTINES                Date: Unknown Date           
'  Author: Kurt Kuzba                         Code: QB, PDS                
'  Origin: FidoNet QUIK_BAS Echo            Packet: MOUSE.ABC
'===========================================================================
'Some of these functions/subs might require a little modification because
'they are set for text mode only. Please use these freely!
'***********************************************************************

' $INCLUDE: 'qb.bi'
DEFINT A-Z
DECLARE SUB Mouse (m1%, m2%, m3%, m4%)
DECLARE SUB MousePut (xmouse%, ymouse%)
DECLARE SUB MouseHide ()
DECLARE SUB MouseInches (horizontal%, vertical%)
DECLARE FUNCTION MouseInstall% ()
DECLARE SUB MouseLightPen (switch%)
DECLARE SUB MousePressLeft (leftcount%, xmouse%, ymouse%)
DECLARE SUB MousePressRight (rightcount%, xmouse%, ymouse%)
DECLARE SUB MouseRange (x1%, y1%, x2%, y2%)
DECLARE SUB MouseReleaseLeft (leftcount%, xmouse%, ymouse%)
DECLARE SUB MouseReleaseRight (rightcount%, xmouse%, ymouse%)
DECLARE SUB MouseWarp (threshhold%)
DECLARE SUB MouseShow ()
DECLARE SUB MouseSoftCursor (screenmask%, cursormask%)
DECLARE SUB MouseNow (leftbutton%, rightbutton%, xmouse%, ymouse%)

IF MouseInstall THEN MouseShow

SUB Mouse (m1%, m2%, m3%, m4%)
	   DIM InRegs AS RegTypeX, OutRegs AS RegTypeX
	   InRegs.ax = m1%
	   InRegs.bx = m2%
	   InRegs.cx = m3%
	   InRegs.dx = m4%
	   INTERRUPTX &H33, InRegs, OutRegs
	   m1% = OutRegs.ax
	   m2% = OutRegs.bx
	   m3% = OutRegs.cx
	   m4% = OutRegs.dx
END SUB

SUB MouseHide
	   Mouse 2, 0, 0, 0
END SUB

SUB MouseInches (horizontal%, vertical%)
	   IF horizontal% > 100 THEN horizontal% = 100
	   IF vertical% > 100 THEN vertical% = 100
	   h% = horizontal% * 5 \ 2
	   v% = vertical% * 8
	   Mouse 10, 0, h%, v%
END SUB

FUNCTION MouseInstall%
	   mflag% = 0
	   Mouse mflag%, 0, 0, 0
	   MouseInstall% = mflag%
END FUNCTION

SUB MouseLightPen (switch%)
	   IF switch% THEN
			 Mouse 13, 0, 0, 0
	   ELSE
			 Mouse 14, 0, 0, 0
	   END IF
END SUB

SUB MouseNow (leftbutton%, rightbutton%, xmouse%, ymouse%)
	   Mouse 3, m2%, xmouse%, ymouse%
	   leftbutton% = ((m2% AND 1) <> 0)
	   rightbutton% = ((m2% AND 2) <> 0)
END SUB

SUB MousePressLeft (leftcount%, xmouse%, ymouse%)
	   m1% = 5
	   leftcount% = 0
	   Mouse m1%, leftcount%, xmouse%, ymouse%
END SUB

SUB MousePressRight (rightcount%, xmouse%, ymouse%) STATIC
	   m1% = 5
	   rightcount% = 1
	   Mouse m1%, rightcount%, xmouse%, ymouse%
END SUB

SUB MousePut (xmouse%, ymouse%)
	   Mouse 4, 0, xmouse%, ymouse%
END SUB

SUB MouseRange (x1%, y1%, x2%, y2%)
	   Mouse 7, 0, x1%, x2%
	   Mouse 8, 0, y1%, y2%
END SUB

SUB MouseReleaseLeft (leftcount%, xmouse%, ymouse%)
	   m1% = 6
	   leftcount% = 0
	   Mouse m1%, leftcount%, xmouse%, ymouse%
END SUB

SUB MouseReleaseRight (rightcount%, xmouse%, ymouse%)
	   m1% = 6
	   rightmouse% = 1
	   Mouse m1%, rightcount%, xmouse%, ymouse%
END SUB

SUB MouseShow
	   Mouse 1, 0, 0, 0
END SUB

SUB MouseSoftCursor (screenmask%, cursormask%)
	   Mouse 10, 0, screenmask%, cursormask%
END SUB

SUB MouseWarp (threshold%)
	   Mouse 19, 0, 0, threshold%
END SUB

