5748180 [rkeene@sledge /home/rkeene/devel/archive/quickbasic]$ cat -n mouse7.bas
   1: DECLARE SUB Sleepa (T)
   2: DECLARE SUB Lightup (sm!, x%, y%)
   3: 'QBASIC Mouse demo                                 
   4: 'Author : Dan Maxwell                   
   5: 'Here is the routine that will add MOUSE functions to
   6: 'your QBasic 1.0 that comes with MS-DOS 5.0        
   7: '(Works with Qbasic 1.1 too. - Adam)
   8: 
   9: 
  10: 
  11: DECLARE SUB Pause ()
  12: DECLARE SUB MouseStatus (lb%, rb%, xMouse%, yMouse%)
  13: DECLARE SUB MouseRange (x1%, y1%, x2%, y2%)
  14: DECLARE SUB MousePut (x%, y%)
  15: DECLARE SUB MouseHide ()
  16: DECLARE SUB MouseDriver (ax%, bx%, cx%, dx%)
  17: DECLARE SUB MouseShow ()
  18: DECLARE FUNCTION MouseInit% ()
  19: 
  20: DIM SHARED Mouse$
  21: Mouse$ = SPACE$(57)
  22: FOR I% = 1 TO 57
  23:   READ A$
  24:   H$ = CHR$(VAL("&H" + A$))
  25:   MID$(Mouse$, I%, 1) = H$
  26: NEXT I%
  27: DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
  28: DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
  29: DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F
  30: DATA 8B,5E,06,89,17,5D,CA,08,00                    
  31: CLS
  32: ms% = MouseInit%
  33: IF NOT ms% THEN
  34:   PRINT "Mouse not found"
  35:   END
  36: END IF
  37: SCREEN 0
  38: MouseShow
  39: 1 MouseStatus lb%, rb%, y%, x%
  40: LOCATE 1, 1: PRINT x%; y%; lb%; rb%; x% / 7.5; y% / 7.8; "                "
  41: I$ = INKEY$
  42: IF I$ = CHR$(27) GOTO 222
  43: IF lb% = -1 GOTO 1111
  44: IF rb% = -1 GOTO 1111
  45: GOTO 1
  46: 1111 Lightup 0, x% / 7.5, y% / 7.8
  47: IF I$ = "" GOTO 222
  48: GOTO 1
  49: 222
  50: 
  51: SUB Lightup (sm, x%, y%)
  52: LOCATE x%, y%: PRINT "°": Sleepa .2
  53: LOCATE x%, y%: PRINT "±": Sleepa .2
  54: LOCATE x%, y%: PRINT "²": Sleepa .2
  55: LOCATE x%, y%: PRINT "Û": Sleepa .2
  56: END SUB
  57: 
  58: SUB MouseDriver (ax%, bx%, cx%, dx%)
  59:   DEF SEG = VARSEG(Mouse$)
  60:   Mouse% = SADD(Mouse$)
  61:   CALL Absolute(ax%, bx%, cx%, dx%, Mouse%)
  62: END SUB
  63: 
  64: SUB MouseHide
  65:  ax% = 2
  66:  MouseDriver ax%, 0, 0, 0
  67: END SUB
  68: 
  69: FUNCTION MouseInit%
  70:   ax% = 0
  71:   MouseDriver ax%, 0, 0, 0
  72:   MouseInit% = ax%
  73: END FUNCTION
  74: 
  75: SUB MousePut (x%, y%)
  76:   ax% = 4
  77:   cx% = x%
  78:   dx% = y%
  79:   MouseDriver ax%, 0, cx%, dx%
  80: END SUB
  81: 
  82: SUB MouseRange (x1%, y1%, x2%, y2%)
  83:   ax% = 7
  84:   cx% = x1%
  85:   dx% = x2%
  86:   MouseDriver ax%, 0, cx%, dx%
  87:   ax% = 8
  88:   cx% = y1%
  89:   dx% = y2%
  90:   MouseDriver ax%, 0, cx%, dx%
  91: END SUB
  92: 
  93: SUB MouseShow
  94:   ax% = 1
  95:   MouseDriver ax%, 0, 0, 0
  96: END SUB
  97: 
  98: SUB MouseStatus (lb%, rb%, xMouse%, yMouse%)
  99:   ax% = 3
 100:   MouseDriver ax%, bx%, cx%, dx%
 101:   lb% = ((bx% AND 1) <> 0)
 102:   rb% = ((bx% AND 2) <> 0)
 103:   xMouse% = cx%
 104:   yMouse% = dx%
 105: END SUB
 106: 
 107: SUB Pause
 108:   'This sub used for demo, not needed for mouse calls
 109:   PRINT "Press any key to continue..."
 110:   G$ = INPUT$(1)
 111:   PRINT
 112: END SUB
 113: 
 114: SUB Sleepa (T)
 115: A = TIMER + T
 116: 9 B = TIMER
 117: IF B > A THEN GOTO 10 ELSE GOTO 9
 118: 10 END SUB
 119: 
5748181 [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:27