home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 229 / 229.d81 / t.buildaboot < prev    next >
Text File  |  2022-08-26  |  7KB  |  263 lines

  1. u
  2.              BUILD A BOOT
  3.            by Dave Moorman
  4.  
  5.     As you may have already read in
  6. "Sprites Are Fun," the VIC II video
  7. chip -- while marvelous in every way
  8. -- only "sees" 16K of memory at a
  9. time. Everything Video must be within
  10. that 16K -- Text Screen, Bitmap
  11. Screen, Font, and Sprites. (Color
  12. memory and default fonts are not
  13. normally a problem.)
  14.  
  15.     If you want to use just 1 to 3
  16. sprites, you are in luck. Sprite
  17. Images 13, 14, and 15 are located in
  18. the cassette buffer (832 - 1023) and
  19. are handy. But if you want more sprite
  20. images, you must make a place for
  21. them.
  22.  
  23.     One method is to move the screen
  24. to a different Video Bank. This is
  25. particularly appropriate when working
  26. with a bitmap screen, since space in
  27. V-Bank 0 is extremely limited. But I
  28. have found that the text screen can be
  29. a great graphics palette for games.
  30. And the default screen at 1024 works
  31. as well as anywhere.
  32.  
  33.     The only problem then is that
  34. V-Bank 0 is [full]. System data uses
  35. locations 0 - 827. Locations 828 -
  36. 1023 is the cassette buffer, as
  37. already mentioned. 1024 - 2047 is the
  38. default screen memory. And BASIC
  39. memory begins at 2048 and continues
  40. beyond the top of V-Bank 0.
  41.  
  42.     Now, one can certainly lower the
  43. Top of BASIC memory, usually to Page
  44. 56. This is fine for very small BASIC
  45. programs -- and does give 2K for video
  46. data (a font or 32 sprites). But I
  47. happen to be greedy! I [need] more
  48. memory. I want 128 sprites [and] a
  49. custom font!
  50.  
  51.     For greedy people like me, the
  52. only answer is to move the Bottom of
  53. BASIC up to Page 64 -- completely
  54. removing BASIC memory from V-Bank 0.
  55. We even have a 4K chunk of memory
  56. (beginning at Page 16) which cannot be
  57. used for sprites or custom fonts (this
  58. being where the VIC II sees the
  59. default fonts) but is great for ML
  60. code and data.
  61.  
  62.     So, lets get to work. The very
  63. first step is to create a work disk or
  64. disk image. Copy "JOYSPRITE 1000" and
  65. "JOY.SPR" to your work disk.
  66.  
  67.     I begin every program by writing
  68. the "scratch and save" routine. This
  69. way, [every] program can be saved by
  70. exactly the same GOTO command.
  71.  
  72.   10000 D=PEEK(186):OPEN1,D,15,"IO"
  73.   :CLOSE1:N$="PROGNAME
  74.   10001 OPEN1,D,15,"S0:"+N$:CLOSE1
  75.   :SAVEN$,D:END
  76.  
  77.  First off, D is set to the current
  78. device number. Then an "I0" is sent to
  79. the drive to make sure it is ready to
  80. receive data. N$ holds the name of the
  81. program. (Notice this is at the end of
  82. the program line -- for easy editing
  83. -- and you don't even need the closing
  84. quotes!) The next line Scratches the
  85. program file and saves it.
  86.  
  87.     Not only is this easy to do [once]
  88. per program, every save on every
  89. program is the same. In immediate
  90. mode, type and <ENTER>:
  91.  
  92.  GOTO10000
  93.  
  94.  You will get so used to typing
  95. GOTO10000 to save your work, you won't
  96. have to think about it.
  97.  
  98. (If you have not LOADed the program
  99. from the disk, or you are unsure which
  100. disk drive was last used, type and
  101. <ENTER>:
  102.  
  103.  POKE186,8
  104.  
  105.  before doing the GOSUB10000.
  106.  
  107.     So, do it -- save the program!
  108.  
  109.     Now, change the program name to
  110. "B.PROGNAME". This will create a
  111. second program -- your Boot. (At the
  112. LOADSTAR Tower, we always prefix the
  113. file to be LOADed and RUN with "B.".)
  114. Once you make the change, do the
  115. GOTO10000.
  116.  
  117.     The boot will have to LOAD and RUN
  118. the main program. So we begin with
  119. finding out which device we are using:
  120.  
  121.  10 D=PEEK(186):IF D<8 THEN D=8
  122.  20 A$="PROGNAME"
  123.  
  124.     The next step is called "using the
  125. dynamic keyboard." The C-64 has a
  126. 10-character keyboard buffer (631-640)
  127. which captures and queues keystrokes.
  128. The number of keystrokes is in
  129. location 198. With the dynamic
  130. keyboard technique, we trick the
  131. computer into thinking that characters
  132. have been typed.
  133.  
  134.     First, we place the LOAD and RUN
  135. commands in the right places on the
  136. screen:
  137.  
  138.  30 PRINT"<CLR><DN><DN><DN>A$,D"
  139.  40 PRINT"<DN><DN><DN><DN>RUN<HM>"
  140.  
  141.  The bracketed (or highlighted)
  142. letters are keypresses:
  143.  
  144.     <CLR> Clear Screen
  145.     <DN>  Down Cursor
  146.     <HM>   Home
  147.  
  148.  (You may want to first turn the
  149. screen background black and make the
  150. characters black -- to hide the
  151. prestadigitalization! But for now, you
  152. can see what is going on.)
  153.  
  154.     Once this is done, we can BLOAD
  155. any files we will need -- which do not
  156. interfere with our Boot program. We
  157. will use "JOYSPRITE 1000" which will
  158. reside at Page 16.
  159.  
  160.  50 SYS57812"JOYSPRITE16.ML",D,0
  161.  51 POKE780,0:POKE781,0
  162.  52 POKE782,16:SYS65493
  163.  
  164.     You will want to memorize this
  165. code! Location 780 is the .A register,
  166. 781 is .X, and 782 is .Y. We POKE 0
  167. into 780 to tell the routine that this
  168. is a LOAD, not a VERIFY. The LOW/HIGH
  169. bytes of the LOAD address go into
  170. 781/782. This is why I think of memory
  171. in Pages -- 256 pages of 256 bytes
  172. each. The Page number is the HIGH byte
  173. of the address -- and goes into 782.
  174.  
  175.  60 SYS57812"JOY.SPR",D,0
  176.  61 POKE780,0:POKE781,0
  177.  62 POKE782,32:SYS65493
  178.  
  179.     This is the file of sprites
  180. included in this issue that you copied
  181. to your work disk -- didn't you?
  182.  
  183.     We can also have a custom font
  184. with this program, but it will be put
  185. at Page 8 -- which is where BASIC
  186. still is. So as not to mess up the
  187. Boot, we will wait until the Main
  188. program to BLOAD the font.
  189.  
  190.     Now it is time to do the magic,
  191. moving up the Bottom of BASIC. It is
  192. really very simple:
  193.  
  194.  70 Q=32:POKE44,Q:POKEQ*256,0
  195.  
  196.     Simple, right? I use Q to hold the
  197. Bottom of BASIC Page number so I don't
  198. have to remember it twice. I am lazy
  199. [and] greedy!
  200.  
  201.     From this point on in your
  202. program, you do [not] want to use any
  203. form of jump -- GOTO, GOSUB, IF-THEN.
  204. You have put the Bottom of BASIC
  205. "above" your program, and the
  206. interpreter will be quite confused
  207. with any jumping up or down. Sort of
  208. like Grandma around little kids.
  209.  
  210.     We have only one thing left to do
  211. -- enable that dynamic keyboard stuff
  212. we printed in lines 20-40. We have set
  213. up the screen so the LOAD and RUN
  214. commands are in just the right places,
  215. and the cursor will wind up on top of
  216. the LOAD command. Now we need a couple
  217. of <RETURN>s.
  218.  
  219.  80 POKE198,2
  220.  81 POKE631,13:POKE632,13
  221.  90 END
  222.  
  223.  [Before] you RUN this, do the
  224. GOTO10000! This program will self-
  225. destruct when RUN, and the Secretary
  226. will disavow all knowledge of it.
  227.  
  228.     Once you save the program, go
  229. ahead and RUN it. You will see the
  230. dynamic keyboard do its thing. When
  231. the READY prompt appears, type and
  232. <RETURN>:
  233.  
  234.  LIST
  235.  
  236.  There is your Main program, good old
  237. "PROGNAME". You can now write, edit,
  238. scratch and save PROGNAME all you
  239. want. The ML code and data are all in
  240. memory, ready to go.
  241.  
  242.     Of course, when you want to use or
  243. edit your program at another time,
  244. LOAD and RUN "B.PROGNAME". In fact, I
  245. often add this line at the top of my
  246. Main program:
  247.  
  248.  1 IF PEEK(44)<>64 THEN STOP
  249.  
  250.  All this does is check to see that
  251. the Boot has been used to LOAD and RUN
  252. the program -- which is a great idea.
  253.  
  254.     Of course, you won't want to use
  255. the name "PROGNAME" -- you are
  256. certainly more creative than that! But
  257. now you have a shell ready to try out
  258. all the bells and whistles of
  259. JoySprite. See you in the Docs.
  260.  
  261.  DMM
  262.  
  263.  
  264.