home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1986-02-07 | 1.6 KB | 33 lines |
- 1 ' ** KBMtest.bas by Dan Rollins
- 2 ' ** Illustrates how to use the KB Mouse bit flags in an application
- 4 ' ** KBM.COM must be executed before running this program
- 20 DEFINT A-Z
- 30 DEF SEG=0 : KEY.BITS=&H4F0 :CONT.FLAG=&H4F1 : INST.FLAG=&H4F2
- 40 IF PEEK(INST.FLAG)+PEEK(INST.FLAG+1)*256=&H1234 GOTO 60
- 50 BEEP : CLS : PRINT "KBM has not been installed!" : STOP
- 60 POKE CONT.FLAG,1 ' ** KB mouse keys will NOT be read as normal keystrokes
- 70 X=40 : Y=12
- 80 LOCATE ,,1,0,15 ' ** using a large cursor as kb mouse pointer
- 90 CLS : PRINT "Use arrow keys to move the cursor"
- 92 PRINT "[Home] [PgUp] and [-] are mouse 'buttons'"
- 94 PRINT "Press [CapsLock] to accelerate"
- 96 PRINT "Press [Esc] to exit the loop"
- 97 '**
- 98 '** this loop moves the cursor and senses the KBM buttons
- 100 LOCATE Y,X ' **move cursor to new position
- 110 K=PEEK(KEY.BITS) ' ** read the bits flags for the kb mouse
- 120 IF (K AND 1) THEN Y=Y-1 : IF (K AND 128) THEN Y=Y-1 '** up, CapsLock
- 130 IF (K AND 2) THEN X=X+1 : IF (K AND 128) THEN Y=Y-2 '** right, CapsLock
- 140 IF (K AND 4) THEN Y=Y+1 : IF (K AND 128) THEN Y=Y+2 '** down, CapsLock
- 150 IF (K AND 8) THEN X=X-1 : IF (K AND 128) THEN X=X-1 '** left, CapsLock
- 160 IF X>80 THEN X=1 ELSE IF X<1 THEN X=80 ' ** sense edge of screen
- 170 IF Y>24 THEN Y=1 ELSE IF Y<1 THEN Y=24
- 180 IF (K AND 16) THEN SOUND 200,0.03 '** button 1 = [Home]
- 190 IF (K AND 32) THEN SOUND 400,0.03 '** button 2 = [PgUp]
- 200 IF (K AND 64) THEN SOUND 600,0.03 '** button 3 = [-] (grey minus)
- 210 A$=INKEY$ : IF A$=CHR$(27) THEN 300 '** exit loop on [Esc]
- 220 GOTO 100
- 300 DEF SEG=0 : POKE CONT.FLAG,0 '** reset to normal key processing
- 310 LOCATE ,,,6,7 '** reset to normal cursor
- 320 END
-