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