home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 5 / 005.d81 / p_p_s#10 < prev    next >
Text File  |  2022-08-26  |  3KB  |  154 lines

  1.   PEEKs, POKEs, and SYSes -- Part 10
  2.  
  3.          by Jimmy Weiler
  4.  
  5. ======================================
  6. Location:197        Hexadecimal: $00C5
  7. Official Label: LSTX         Type: RAM
  8. Useful BASIC commands: PEEK
  9.  
  10.  
  11. LSTX contains the number of the key
  12.  
  13. being pressed.  If no key is pressed,
  14.  
  15. LSTX contains 64.
  16.  
  17.   The keys are not numbered by ascii
  18.  
  19. value, or keyboard position.  Rather
  20.  
  21. they are numbered by PRIORITY.  What's
  22.  
  23. priority?  Simple:  the highest number
  24.  
  25. goes first.  If several keys are
  26.  
  27. pressed, the one with the highest
  28.  
  29. number is the one that gets into 197.
  30.  
  31. What's not so simple is  knowing which
  32.  
  33. keys have which numbers.
  34.  
  35.   That's why we're giving you this
  36.  
  37. chart:
  38.  
  39. --------------------------------------
  40. {CBM-G}                                    {CBM-N}
  41. {CBM-G} 0 = inst/del    33 = i             {CBM-N}
  42. {CBM-G} 1 = return      34 = j             {CBM-N}
  43. {CBM-G} 2 = _crsr       35 = 0             {CBM-N}
  44. {CBM-G} 3 = f7/f8       36 = m             {CBM-N}
  45. {CBM-G} 4 = f1/f2       37 = k             {CBM-N}
  46. {CBM-G} 5 = f3/f4       38 = o             {CBM-N}
  47. {CBM-G} 6 = f5/f6       39 = n             {CBM-N}
  48. {CBM-G} 7 = ^crsr       40 = +             {CBM-N}
  49. {CBM-G} 8 = 3           41 = p             {CBM-N}
  50. {CBM-G} 9 = w           42 = l             {CBM-N}
  51. {CBM-G}10 = a           43 = -             {CBM-N}
  52. {CBM-G}11 = 4           44 = . / >         {CBM-N}
  53. {CBM-G}12 = z           45 = : / [         {CBM-N}
  54. {CBM-G}13 = s           46 = @             {CBM-N}
  55. {CBM-G}14 = e           47 = , / <         {CBM-N}
  56. {CBM-G}15 = not used    48 = \             {CBM-N}
  57. {CBM-G}16 = 5           49 = *             {CBM-N}
  58. {CBM-G}17 = r           50 = ; / ]         {CBM-N}
  59. {CBM-G}18 = d           51 = clr / home    {CBM-N}
  60. {CBM-G}19 = 6           52 = not used      {CBM-N}
  61. {CBM-G}20 = c           53 = =             {CBM-N}
  62. {CBM-G}21 = f           54 = ^             {CBM-N}
  63. {CBM-G}22 = t           55 = /             {CBM-N}
  64. {CBM-G}23 = x           56 = 1             {CBM-N}
  65. {CBM-G}24 = 7           57 = _             {CBM-N}
  66. {CBM-G}25 = y           58 = not used      {CBM-N}
  67. {CBM-G}26 = g           59 = 2             {CBM-N}
  68. {CBM-G}27 = 8           60 = space         {CBM-N}
  69. {CBM-G}28 = b           61 = not used      {CBM-N}
  70. {CBM-G}29 = h           62 = q             {CBM-N}
  71. {CBM-G}30 = u           63 = run           {CBM-N}
  72. {CBM-G}31 = v           64 = no key pressed{CBM-N}
  73. {CBM-G}32 = 9                              {CBM-N}
  74. {CBM-G}                                    {CBM-N}
  75. --------------------------------------
  76.  
  77.   You can use location 197 as an
  78.  
  79. alternative to the get statement:
  80.  
  81. 10 x=peek(197):ifx<>39then10
  82. 20 poke198,0:k$="n"
  83.  
  84.  is much like
  85.  
  86. 10 get k$: if k$<>"N" and k$<>"n" and
  87.  k$<>"{CBM-N}" and k$<>chr$(14) then 10
  88.  
  89.  but only takes about 3/4 as much
  90.  memory.
  91.  
  92.  
  93. ======================================
  94. Location:198        Hexadecimal: $00C6
  95. Official Label: NDX          Type: RAM
  96. Useful BASIC commands: PEEK, POKE
  97.  
  98.  
  99. NDX tells how many characters are
  100.  
  101. presently in the type-ahead buffer
  102.  
  103. (also known as the keyboard buffer).
  104.  
  105. This is most useful in conjunction
  106.  
  107. with the BASIC 'GET' statement.
  108.  
  109.   After a page of instructions, you
  110.  
  111. will often want to wait for a key-
  112.  
  113. press so you use:
  114.  
  115. 1000 GET K$
  116.  
  117. But if a key has already been pressed
  118.  
  119. before the instructions were printed,
  120.  
  121. then there's already a character
  122.  
  123. waiting to be "GOT".  You want to
  124.  
  125. throw that character away and have
  126.  
  127. your GET get a fresh keypress.  That's
  128.  
  129. why you should use:
  130.  
  131. 1000 POKE 198,0: WAIT 198,1: GET K$
  132.  
  133.   This will clear the keyboard buffer
  134.  
  135. of any spurious keypresses, then
  136.  
  137. wait for any key (no, not shift, or
  138.  
  139. ctrl, or commodore) to be pressed,
  140.  
  141. then assign K$ to the character of the
  142.  
  143. key pressed.
  144.  
  145.   It takes a little more coding than
  146.  
  147. a simple GET K$, but the program won't
  148.  
  149. run on ahead of where you wanted it to
  150.  
  151. be.
  152.  
  153. --------------------------------------
  154.