home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB34.ZIP / KBMTEST.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1986-02-07  |  1.6 KB  |  33 lines

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