home *** CD-ROM | disk | FTP | other *** search
- 100 '***********************************************************
- 110 '* BATEST.BAS *
- 120 '* *
- 130 '* Demonstrates use of the Microsoft Mouse from BASICA *
- 140 '***********************************************************
- 150 '
- 160 ' Clear the display
- 170 CLS
- 180 '
- 190 ' Determine mouse interrupt address
- 200 DEF SEG = 0
- 210 MOUSEG = 256 * PEEK(207) + PEEK(206)
- 220 MOUSE = 256 * PEEK(205) + PEEK(204) + 2
- 230 DEF SEG = MOUSEG
- 232 IF (MOUSEG OR (MOUSE - 2)) AND PEEK(MOUSE - 2) <> 207 THEN GOTO 260
- 234 PRINT "Mouse driver not found" : END
- 240 '
- 250 ' Display instructions for user
- 260 PRINT "BATEST - Mouse demonstration using interpreted BASIC"
- 270 PRINT
- 280 PRINT "Use mouse to highlight a menu item."
- 290 PRINT "Press either button to make selection. "
- 300 '
- 310 ' Reset mouse, and verify it's existence
- 320 M1%= 0
- 330 CALL MOUSE(M1%, M2%, M3%, M4%)
- 340 '
- 350 ' Quit if mouse wasn't found
- 360 IF M1%= 0 THEN PRINT "Error: Mouse not found ": END
- 370 '
- 380 ' Initialize menu pointer to first choice
- 390 MENUPTR% = 1
- 400 '
- 410 ' Initialize count of accumulated vertical mouse motion
- 420 MOTION% = 0
- 430 '
- 440 ' Set flag to cause the menu to be updated first time through
- 450 WFLAG% = 1
- 460 '
- 470 ' Main loop starts here
- 480 WHILE 1
- 490 '
- 500 ' Update the menu only when necessary
- 510 WHILE WFLAG% = 1
- 520 WFLAG% = 0
- 530 '
- 540 ' Print first line of the menu, highlighted if selected
- 550 IF MENUPTR% = 1 THEN COLOR 0,7 ELSE COLOR 7,0
- 560 LOCATE 10, 29
- 570 PRINT " 1. First menu choice "
- 580 '
- 590 ' Print second line of the menu, highlighted if selected
- 600 IF MENUPTR% = 2 THEN COLOR 0,7 ELSE COLOR 7,0
- 610 LOCATE 11, 29
- 620 PRINT " 2. Second choice "
- 630 '
- 640 ' Print third line of the menu, highlighted if selected
- 650 IF MENUPTR% = 3 THEN COLOR 0,7 ELSE COLOR 7,0
- 660 LOCATE 12, 29
- 670 PRINT " 3. Third choice "
- 680 '
- 690 ' Make sure highlighting isn't left on
- 700 COLOR 7, 0
- 710 '
- 720 ' End of the menu updating
- 730 WEND
- 740 '
- 750 ' Accumulate vertical mouse motion counts
- 760 M1%= 11
- 770 CALL MOUSE(M1%, M2%, M3%, M4%)
- 780 MOTION% = MOTION% + M4%
- 790 '
- 800 ' Move up the menu if enough mouse motion
- 810 IF MOTION% > -17 THEN GOTO 880
- 820 MOTION% = 0
- 830 IF MENUPTR% <= 1 THEN GOTO 880
- 840 MENUPTR% = MENUPTR% - 1
- 850 WFLAG%= 1
- 860 '
- 870 ' Move down the menu if enough mouse motion
- 880 IF MOTION% < 17 THEN GOTO 950
- 890 MOTION% = 0
- 900 IF MENUPTR% >= 3 THEN GOTO 950
- 910 MENUPTR% = MENUPTR% + 1
- 920 WFLAG% = 1
- 930 '
- 940 ' Check if left button has been pressed
- 950 M1%= 5
- 960 M2%= 0
- 970 CALL MOUSE(M1%, M2%, M3%, M4%)
- 980 IF M2% = 0 THEN GOTO 1030
- 990 PRINT "Left button was used to select choice", MENUPTR%
- 1000 END
- 1010 '
- 1020 ' Check if right button has been pressed
- 1030 M1%= 5
- 1040 M2%= 1
- 1050 CALL MOUSE(M1%, M2%, M3%, M4%)
- 1060 IF M2% = 0 THEN GOTO 1110
- 1070 PRINT "Right button was used to select choice", MENUPTR%
- 1080 END
- 1090 '
- 1100 ' Loop back until one of the buttons gets pressed
- 1110 WEND
-