5748146 [rkeene@sledge /home/rkeene/devel/archive/quickbasic]$ cat -n mouse.bas
   1: DECLARE SUB Lightup (sm!, X%, Y%)
   2: DECLARE SUB Pause ()
   3: DECLARE SUB MouseStatus (Lb%, Rb%, xMouse%, yMouse%)
   4: DECLARE SUB MouseRange (x1%, y1%, x2%, y2%)
   5: DECLARE SUB MousePut (X%, Y%)
   6: DECLARE SUB MouseHide ()
   7: DECLARE SUB MouseDriver (ax%, bx%, cx%, dx%)
   8: DECLARE SUB MouseShow ()
   9: DECLARE FUNCTION MouseInit% ()
  10: DIM SHARED Mouse$
  11: Mouse$ = SPACE$(57)
  12: FOR I% = 1 TO 57
  13:   READ A$
  14:   H$ = CHR$(VAL("&H" + A$))
  15:   MID$(Mouse$, I%, 1) = H$
  16: NEXT I%
  17: DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
  18: DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
  19: DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F
  20: DATA 8B,5E,06,89,17,5D,CA,08,00                   
  21: CLS
  22: ms% = MouseInit%
  23: IF NOT ms% THEN
  24:   PRINT "Mouse not found"
  25:   END
  26: END IF
  27: SCREEN 12
  28: MouseShow
  29: FOR q = 1 TO 30
  30: LOCATE q, 1: PRINT LTRIM$(RTRIM$(STR$(q)));
  31: NEXT q
  32: 1 MouseStatus Lb%, Rb%, Y%, X%
  33: LOCATE 1, 1: PRINT Lb%, Rb%, Y%, X%; INT(X% / 16) + 1; INT(Y% / 8) + 1
  34: GOTO 1
  35: 
  36: SUB Lightup (sm, X%, Y%)
  37: AAA = 176
  38: IF sm = 0 GOTO ZERO
  39: IF sm = 12 GOTO TW
  40: TW:
  41: LOCATE X% / 15, Y% / 8: PRINT CHR$(AAA)
  42: AAA = AAA + 1
  43: IF AAA > 179 THEN A = 219
  44: IF AAA = 220 GOTO 2222
  45: GOTO TW
  46: ZERO:
  47: LOCATE X% / 7.5, Y% / 7.8: PRINT CHR$(AAA)
  48: AAA = AAA + 1
  49: IF AAA > 179 THEN A = 219
  50: IF AAA = 220 GOTO 2222
  51: GOTO ZERO
  52: 2222 END SUB
  53: 
  54: SUB MouseDriver (ax%, bx%, cx%, dx%)
  55:   DEF SEG = VARSEG(Mouse$)
  56:   Mouse% = SADD(Mouse$)
  57:   CALL Absolute(ax%, bx%, cx%, dx%, Mouse%)
  58: END SUB
  59: 
  60: SUB MouseHide
  61:  ax% = 2
  62:  MouseDriver ax%, 0, 0, 0
  63: END SUB
  64: 
  65: FUNCTION MouseInit%
  66:   ax% = 0
  67:   MouseDriver ax%, 0, 0, 0
  68:   MouseInit% = ax%
  69: END FUNCTION
  70: 
  71: SUB MousePut (X%, Y%)
  72:   ax% = 4
  73:   cx% = X%
  74:   dx% = Y%
  75:   MouseDriver ax%, 0, cx%, dx%
  76: END SUB
  77: 
  78: SUB MouseRange (x1%, y1%, x2%, y2%)
  79:   ax% = 7
  80:   cx% = x1%
  81:   dx% = x2%
  82:   MouseDriver ax%, 0, cx%, dx%
  83:   ax% = 8
  84:   cx% = y1%
  85:   dx% = y2%
  86:   MouseDriver ax%, 0, cx%, dx%
  87: END SUB
  88: 
  89: SUB MouseShow
  90:   ax% = 1
  91:   MouseDriver ax%, 0, 0, 0
  92: END SUB
  93: 
  94: SUB MouseStatus (Lb%, Rb%, xMouse%, yMouse%)
  95:   ax% = 3
  96:   MouseDriver ax%, bx%, cx%, dx%
  97:   Lb% = ((bx% AND 1) <> 0)
  98:   Rb% = ((bx% AND 2) <> 0)
  99:   xMouse% = cx%
 100:   yMouse% = dx%
 101: END SUB
 102: 
 103: SUB Pause
 104:   'This sub used for demo, not needed for mouse calls
 105:   PRINT "Press any key to continue..."
 106:   G$ = INPUT$(1)
 107:   PRINT
 108: END SUB
 109: 
5748147 [rkeene@sledge /home/rkeene/devel/archive/quickbasic]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2000-05-09 21:05:14