home *** CD-ROM | disk | FTP | other *** search
/ The California Collection / TheCaliforniaCollection.cdr / his038 / qbints.lzh / MOUSE.BAS < prev    next >
Encoding:
BASIC Source File  |  1989-04-23  |  2.3 KB  |  93 lines

  1. 'Sun  Apr 23, 1989   2:19:17 pm     
  2. '**********************************************************************
  3. 'This set of routines carry out different MOUSE functions. 
  4. '**********************************************************************
  5. DECLARE SUB getbutton ()
  6. DECLARE SUB mousewindow (left, right, top, bottom)
  7. DECLARE SUB mouse (m1, m2, m3, m4)
  8. DECLARE SUB mouseon (value)
  9. DECLARE SUB movecursor ()
  10. DECLARE SUB waitforbutton (button)
  11. DECLARE FUNCTION mouseinstalled ()
  12.  
  13.  
  14. TYPE RegType
  15.      ax    AS INTEGER
  16.      bx    AS INTEGER
  17.      cx    AS INTEGER
  18.      dx    AS INTEGER
  19.      bp    AS INTEGER
  20.      si    AS INTEGER
  21.      di    AS INTEGER
  22.      flags AS INTEGER
  23. END TYPE
  24.  
  25. DIM SHARED inregs AS RegType, outregs AS RegType
  26. COMMON SHARED numbuttons, button, row, col, in$
  27.  
  28.  
  29.      IF mouseinstalled = 0 THEN mouseon 0 ELSE mouseon 1
  30.      CLS
  31.      CALL mousewindow(0, 640, 1, 200)
  32.      DO
  33.           waitforbutton 0
  34.           getbutton
  35.           LOCATE row, col
  36.           PRINT row; col
  37.     LOOP UNTIL button = 2
  38. END
  39.  
  40. SUB getbutton
  41.      DO
  42.           CALL mouse(3, button, x, y)
  43.           row = INT(y / 8) + 1: col = INT(x / 8) + 1
  44.           in$ = INKEY$
  45.      LOOP UNTIL button <> 0 OR in$ <> ""
  46. END SUB
  47.  
  48. SUB mouse (m1, m2, m3, m4)
  49. DIM InRegs AS regtype, OutRegs AS regtype
  50.      InRegs.ax = m1
  51.      InRegs.bx = m2
  52.      InRegs.cx = m3
  53.      InRegs.dx = m4
  54.      CALL INTERRUPT(51, InRegs, OutRegs)
  55.      m1 = OutRegs.ax
  56.      m2 = OutRegs.bx
  57.      m3 = OutRegs.cx
  58.      m4 = OutRegs.dx
  59. END SUB
  60.  
  61. FUNCTION mouseinstalled
  62.      m = 0                      ' reset function
  63.      CALL mouse(m, n, 0, 0)     ' returns M = 0 if no mouse installed
  64.      numbuttons = n
  65.      mouseinstalled = m
  66. END FUNCTION
  67.  
  68. SUB mouseon (value)
  69.      IF value = 0 THEN m = 2 ELSE m = 1
  70.      CALL mouse(m, 1, 0, 0)
  71. END SUB
  72.  
  73. SUB mousewindow (left, right, top, bottom)
  74.      CALL mouse(7, 0, left, right)
  75.      CALL mouse(8, 0, top, bottom)
  76. END SUB
  77.  
  78. SUB movecursor
  79.      waitforbutton (0)
  80.      CLS
  81.      LOCATE 4, 1
  82.      v = 24                       ' vertical position
  83.      FOR h = 1 TO 400
  84.           CALL mouse(4, x, h, v) ' position the cursor
  85.      NEXT
  86. END SUB
  87.  
  88. SUB waitforbutton (button)
  89.      DO
  90.           CALL mouse(3, b, x, y)
  91.      LOOP UNTIL b = button
  92. END SUB
  93.