DECLARE SUB Lightup (sm!, X%, Y%)
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% ()
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
MouseShow
FOR q = 1 TO 30
LOCATE q, 1: PRINT LTRIM$(RTRIM$(STR$(q)));
NEXT q
1 MouseStatus Lb%, Rb%, Y%, X%
LOCATE 1, 1: PRINT Lb%, Rb%, Y%, X%; INT(X% / 16) + 1; INT(Y% / 8) + 1
GOTO 1

SUB Lightup (sm, X%, Y%)
AAA = 176
IF sm = 0 GOTO ZERO
IF sm = 12 GOTO TW
TW:
LOCATE X% / 15, Y% / 8: PRINT CHR$(AAA)
AAA = AAA + 1
IF AAA > 179 THEN A = 219
IF AAA = 220 GOTO 2222
GOTO TW
ZERO:
LOCATE X% / 7.5, Y% / 7.8: PRINT CHR$(AAA)
AAA = AAA + 1
IF AAA > 179 THEN A = 219
IF AAA = 220 GOTO 2222
GOTO ZERO
2222 END SUB

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

