DECLARE SUB FADE (ty%, tx%, text$)
'QBASIC Mouse demo                             
'Author : Dan Maxwell               
'Here is the routine that will add MOUSE functions to
'your QBasic 1.0 that comes with MS-DOS 5.0    
'(Works with Qbasic 1.1 too. - Adam)



DECLARE SUB PAUSE ()
DECLARE SUB MouseStatus (lb%, rb%, xMouse%, yMouse%)
DECLARE SUB MouseRange (x1%, y1%, x2%, y2%)
DECLARE SUB MousePut (x%, y%)
DECLARE SUB MouseHide ()
DECLARE SUB MouseDriver (ax%, bx%, cx%, dx%)
DECLARE SUB MouseShow ()
DECLARE FUNCTION MouseInit% ()
SCREEN 0
DIM SHARED Mouse$
Mouse$ = SPACE$(57)
FOR I% = 1 TO 57
  READ A$
  H$ = CHR$(VAL("&H" + A$))
  MID$(Mouse$, I%, 1) = H$
NEXT I%
DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F
DATA 8B,5E,06,89,17,5D,CA,08,00                
CLS
ms% = MouseInit%
IF NOT ms% THEN
  PRINT "Mouse not found"
  END
END IF
SCREEN 12
100 LOCATE 2, 1: PRINT "ΙΝΝΝΝΝΝΝ»"
PRINT "Ί CLEAR Ί"
PRINT "ΘΝΝΝΝΝΝΝΌ"
MouseShow
10 MouseStatus lb%, rb%, x2%, y2%
IF lb% = -1 THEN GOTO 20
GOTO 10
20 MouseStatus lb%, rb%, x%, y%
FOR I = 6 TO 64
IF x% = I THEN GOTO 3
NEXT I
32 MouseStatus lb%, rb%, x1%, y1%
IF rb% = -1 THEN GOTO 40
GOTO 32
3 FOR V = 21 TO 51
IF y% = V THEN GOTO 30
NEXT V
GOTO 10
30 CLS
GOTO 100
40 r% = x2% - x1%
IF r% < 0 THEN LET r% = r% - (r% * 2)
SLEEP 1
CIRCLE (x2%, y2%), r%
GOTO 100

DEFINT A-Z
SUB FADE (ty, tx, text$)
ScrollDelay = 5
    LOCATE ty, tx: COLOR 15: PRINT text$
    FOR n = 1 TO (ScrollDelay * 5000): NEXT
    LOCATE ty, tx: COLOR 7: PRINT text$
    FOR n = 1 TO (ScrollDelay * 5000): NEXT
    LOCATE ty, tx: COLOR 8: PRINT text$
    FOR n = 1 TO (ScrollDelay * 5000): NEXT

END SUB

DEFSNG A-Z
SUB MouseDriver (ax%, bx%, cx%, dx%)
  DEF SEG = VARSEG(Mouse$)
  Mouse% = SADD(Mouse$)
  CALL Absolute(ax%, bx%, cx%, dx%, Mouse%)
END SUB

SUB MouseHide
 ax% = 2
 MouseDriver ax%, 0, 0, 0
END SUB

FUNCTION MouseInit%
  ax% = 0
  MouseDriver ax%, 0, 0, 0
  MouseInit% = ax%
END FUNCTION

SUB MousePut (x%, y%)
  ax% = 4
  cx% = x%
  dx% = y%
  MouseDriver ax%, 0, cx%, dx%
END SUB

SUB MouseRange (x1%, y1%, x2%, y2%)
  ax% = 7
  cx% = x1%
  dx% = x2%
  MouseDriver ax%, 0, cx%, dx%
  ax% = 8
  cx% = y1%
  dx% = y2%
  MouseDriver ax%, 0, cx%, dx%
END SUB

SUB MouseShow
  ax% = 1
  MouseDriver ax%, 0, 0, 0
END SUB

SUB MouseStatus (lb%, rb%, xMouse%, yMouse%)
  ax% = 3
  MouseDriver ax%, bx%, cx%, dx%
  lb% = ((bx% AND 1) <> 0)
  rb% = ((bx% AND 2) <> 0)
  xMouse% = cx%
  yMouse% = dx%
END SUB

SUB PAUSE
  'This sub used for demo, not needed for mouse calls
  PRINT "Press any key to continue..."
  G$ = INPUT$(1)
  PRINT
END SUB

