home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / BAS.ZIP / QB12&20.BAS < prev    next >
Encoding:
BASIC Source File  |  1989-01-20  |  3.1 KB  |  93 lines

  1.   '***************************************************************
  2.   '*  QB12&20.BAS                                                *
  3.   '*                                                             *
  4.   '*  Demonstration of mouse functions 12 and 20.                *
  5.   '*                                                             *
  6.   '*  Load QB.QLB into memory with QuickBASIC...  QB /L QB.QLB   *
  7.   '***************************************************************
  8.  
  9.     DEFINT A-Z
  10.  
  11.     TYPE RegType
  12.         ax    AS INTEGER
  13.         bx    AS INTEGER
  14.         cx    AS INTEGER
  15.         dx    AS INTEGER
  16.         bp    AS INTEGER
  17.         si    AS INTEGER
  18.         di    AS INTEGER
  19.         flags AS INTEGER
  20.     END TYPE
  21.  
  22.     DECLARE SUB Interrupt (intnum%, iReg AS RegType, oReg AS RegType)
  23.  
  24.     DIM iReg AS RegType
  25.     DIM oReg AS RegType
  26.  
  27.     DIM msub%(5), msub2%(5)
  28.     COMMON msub%(), msub2%()
  29.  
  30. '   First instructions
  31.     CLS
  32.     PRINT "Test by pressing right mouse button."
  33.     PRINT "Then press Enter."
  34.  
  35.   ' Build interrupt driven subroutine for function 12 activation
  36.     msub%(0) = &H4B8            ' Subroutine is from this code:
  37.     msub%(1) = &HB900           '   MOV AX,4   ; Function 4, Set
  38.                                 '              ; Mouse Cursor Position
  39.     msub%(2) = &H0              '   MOV CX,0   ; Left edge of screen
  40.     msub%(3) = &HBA             '   MOV DX,0   ; Top edge of screen
  41.     msub%(4) = &HCD00           '   INT 33h    ; Mouse Interrupt
  42.     msub%(5) = &HCB33           '   RETF       ; Return to BASIC
  43.  
  44.   ' Build interrupt driven subroutine for function 20 activation
  45.     msub2%(0) = &H4B8           ' Subroutine is from this code:
  46.     msub2%(1) = &HB900          '   MOV AX,4   ; Function 4, Set
  47.                                 '              ; Mouse Cursor Position
  48.     msub2%(2) = &H140           '   MOV CX,320 ; Middle of screen
  49.     msub2%(3) = &H64BA          '   MOV DX,100 ; Middle of screen
  50.     msub2%(4) = &HCD00          '   INT 33h    ; Mouse Interrupt
  51.     msub2%(5) = &HCB33          '   RETF       ; Return to BASIC
  52.  
  53.   ' Mouse Reset and Status
  54.     iReg.ax = 0
  55.     Interrupt &H33, iReg, oReg
  56.  
  57.   ' Show Cursor
  58.     iReg.ax = 1
  59.     Interrupt &H33, iReg, oReg
  60.  
  61.   ' Set Interrupt Subroutine Call Mask and Address
  62.     iReg.ax = 12                ' Mouse Function 12
  63.     iReg.cx = 8                 ' Interrupt when right button pressed
  64.     iReg.dx = VARPTR(msub%(0))  ' Offset of msub1
  65.     Interrupt &H33, iReg, oReg
  66.  
  67.   ' Wait until any key is pressed
  68.     DO
  69.     LOOP WHILE INKEY$ = ""
  70.  
  71.   ' Next instructions
  72.     CLS
  73.     PRINT "Next, test by pressing and releasing left mouse button."
  74.     PRINT "Then press Enter."
  75.  
  76.   ' Swap Interrupt Subroutines
  77.     iReg.ax = 20                ' Mouse Function 20
  78.     iReg.bx = VARSEG(msub2%(0)) ' Segment of msub2
  79.     iReg.cx = 4                 ' Interrupt when left button released
  80.     iReg.dx = VARPTR(msub2%(0)) ' Offset of msub2
  81.     Interrupt &H33, iReg, oReg
  82.  
  83.   ' Wait until any key is pressed
  84.     DO
  85.     LOOP WHILE INKEY$ = ""
  86.  
  87.  
  88.   ' Reset mouse to deactivate the interrupt
  89.     iReg.ax = 0
  90.     Interrupt &H33, iReg, oReg
  91.  
  92.     END
  93.