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

  1.        PEEK/POKE/SYS -- Part 3
  2.        ==== ==== ===    ==== =
  3. ======= Continued from Part 2 ========
  4.  
  5.    As an example of modifying BASIC,
  6.  
  7. copy BASIC to RAM as described in Part
  8.  
  9. 2.  Don't switch in the RAM BASIC yet.
  10.  
  11. Now do the following:
  12.  
  13.    READY.
  14.    POKE 41848, ASC("H")
  15.  
  16.    READY.
  17.    POKE 41849, ASC("O")
  18.  
  19.    READY.
  20.    POKE 41850, ASC("W")
  21.  
  22.    READY.
  23.    POKE 41853, ASC("!")
  24.  
  25.    READY.
  26.  
  27. Finally, switch in the RAM BASIC with
  28.  
  29. POKE 1, PEEK(1) AND 254.  The RAM BAS-
  30.  
  31. IC's "READY." prompt has been changed
  32.  
  33. to "HOWDY!"  Now re-enable the normal
  34.  
  35. ROM version of BASIC with POKE 1, PEEK
  36.  
  37. (1) AND 254 OR 1.  The prompt changes
  38.  
  39. back to "READY."
  40.  
  41.  
  42.    A more significant change can be
  43.  
  44. made by POKE 46991, 5.  This modifies
  45.  
  46. the RAM BASIC's ASC() function so that
  47.  
  48. instead of causing an ?ILLEGAL QUANTI-
  49.  
  50. TY ERROR if the argument evaluates to
  51.  
  52. a null (empty) string, it simply re-
  53.  
  54. turns a value of 0.  With this change
  55.  
  56. made, you no longer need to do an A =
  57.  
  58. ASC(A$ + CHR$(0)), just an A = ASC(A$)
  59.  
  60. to get the ASCII value of A$, no mat-
  61.  
  62. ter what value A$ is.  This is really
  63.  
  64. handy when reading files from disk or
  65.  
  66. tape, since the GET# statement changes
  67.  
  68. an incoming CHR$(0) to a null string!
  69.  
  70. Of course, a null string isn't really
  71.  
  72. an ASCII NUL (CHR$(0)) byte, and that
  73.  
  74. is why Commodore made the ASC function
  75.  
  76. the way it is, but sometimes getting
  77.  
  78. an ?ILLEGAL QUANTITY ERROR over a null
  79.  
  80. string can really wreck your day!
  81.  
  82.  
  83.    LORAM can also be used to allow o-
  84.  
  85. ther languages to exist without BASIC
  86.  
  87. just sitting there taking up space.
  88.  
  89.  
  90.    If the HIRAM bit is set to 0, the
  91.  
  92. Kernal ROM is replaced by RAM at $E000
  93.  
  94. -$FFFF.  Since BASIC needs the Kernal
  95.  
  96. to operate, it makes no sense to leave
  97.  
  98. the BASIC ROM on, so it is switched
  99.  
  100. out as well.  If both HIRAM and LORAM
  101.  
  102. are set to 0, then the 4K space at
  103.  
  104. $D000-$DFFF normally taken up by the
  105.  
  106. I/O chips is also replaced by RAM, re-
  107.  
  108. sulting in a true 64K RAM machine.  Of
  109.  
  110. course, without I/O chips, the compu-
  111.  
  112. ter is blind, deaf and (almost) dumb.
  113.  
  114. The most it can do is display text on
  115.  
  116. the screen, but it can't even specify
  117.  
  118. the color of the text!  (The text may
  119.  
  120. thus be invisible!)  So generally,
  121.  
  122. this RAM is used only for routines and
  123.  
  124. buffers that are used briefly and need
  125.  
  126. no I/O.  CHAREN has no effect on the
  127.  
  128. $D000-$DFFF space when the I/O chips
  129.  
  130. are de-activated in this manner.
  131.  
  132.  
  133.    LORAM and HIRAM can do other things
  134.  
  135. as well, if there is a device plugged
  136.  
  137. into the Expansion (Cartridge) slot.
  138.  
  139. Devices using this slot have access to
  140.  
  141. two other lines, called GAME and EXROM
  142.  
  143. which, in combination with LORAM and
  144.  
  145. HIRAM, allow 8 different memory con-
  146.  
  147. figurations of the 64.  See the sec-
  148.  
  149. tion 'Memory Management on the Commo-
  150.  
  151. dore 64' of Chapter 5, 'BASIC to Ma-
  152.  
  153. chine Language' , pages 260 - 267 of
  154.  
  155. the 'Commodore 64 Programmer's Refer-
  156.  
  157. ence Guide' for more information.
  158.  
  159. -------------<continued>--------------
  160.              <x to exit>
  161.