home *** CD-ROM | disk | FTP | other *** search
- '***************************************************************
- '* QB12&20.BAS *
- '* *
- '* Demonstration of mouse functions 12 and 20. *
- '* *
- '* Load QB.QLB into memory with QuickBASIC... QB /L QB.QLB *
- '***************************************************************
-
- DEFINT A-Z
-
- TYPE RegType
- ax AS INTEGER
- bx AS INTEGER
- cx AS INTEGER
- dx AS INTEGER
- bp AS INTEGER
- si AS INTEGER
- di AS INTEGER
- flags AS INTEGER
- END TYPE
-
- DECLARE SUB Interrupt (intnum%, iReg AS RegType, oReg AS RegType)
-
- DIM iReg AS RegType
- DIM oReg AS RegType
-
- DIM msub%(5), msub2%(5)
- COMMON msub%(), msub2%()
-
- ' First instructions
- CLS
- PRINT "Test by pressing right mouse button."
- PRINT "Then press Enter."
-
- ' Build interrupt driven subroutine for function 12 activation
- msub%(0) = &H4B8 ' Subroutine is from this code:
- msub%(1) = &HB900 ' MOV AX,4 ; Function 4, Set
- ' ; Mouse Cursor Position
- msub%(2) = &H0 ' MOV CX,0 ; Left edge of screen
- msub%(3) = &HBA ' MOV DX,0 ; Top edge of screen
- msub%(4) = &HCD00 ' INT 33h ; Mouse Interrupt
- msub%(5) = &HCB33 ' RETF ; Return to BASIC
-
- ' Build interrupt driven subroutine for function 20 activation
- msub2%(0) = &H4B8 ' Subroutine is from this code:
- msub2%(1) = &HB900 ' MOV AX,4 ; Function 4, Set
- ' ; Mouse Cursor Position
- msub2%(2) = &H140 ' MOV CX,320 ; Middle of screen
- msub2%(3) = &H64BA ' MOV DX,100 ; Middle of screen
- msub2%(4) = &HCD00 ' INT 33h ; Mouse Interrupt
- msub2%(5) = &HCB33 ' RETF ; Return to BASIC
-
- ' Mouse Reset and Status
- iReg.ax = 0
- Interrupt &H33, iReg, oReg
-
- ' Show Cursor
- iReg.ax = 1
- Interrupt &H33, iReg, oReg
-
- ' Set Interrupt Subroutine Call Mask and Address
- iReg.ax = 12 ' Mouse Function 12
- iReg.cx = 8 ' Interrupt when right button pressed
- iReg.dx = VARPTR(msub%(0)) ' Offset of msub1
- Interrupt &H33, iReg, oReg
-
- ' Wait until any key is pressed
- DO
- LOOP WHILE INKEY$ = ""
-
- ' Next instructions
- CLS
- PRINT "Next, test by pressing and releasing left mouse button."
- PRINT "Then press Enter."
-
- ' Swap Interrupt Subroutines
- iReg.ax = 20 ' Mouse Function 20
- iReg.bx = VARSEG(msub2%(0)) ' Segment of msub2
- iReg.cx = 4 ' Interrupt when left button released
- iReg.dx = VARPTR(msub2%(0)) ' Offset of msub2
- Interrupt &H33, iReg, oReg
-
- ' Wait until any key is pressed
- DO
- LOOP WHILE INKEY$ = ""
-
-
- ' Reset mouse to deactivate the interrupt
- iReg.ax = 0
- Interrupt &H33, iReg, oReg
-
- END
-