home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 4 / 004.d81 / fireflies (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  9KB  |  333 lines

  1. 1 rem fireflies
  2. 2 rem c64 version 1.1 6/21/84
  3. 3 rem copyright (c) 1984 by dan tobias
  4. 4 gosub41000:rem instructions
  5. 5 printchr$(142):rem upper case mode
  6. 6 poke53280,0:poke53281,0:print""
  7. 7 print"[147]":input"today's date (mm/dd/yy)";sd$
  8. 8 gosub6000
  9. 9 js=0
  10. 10 print:input"(j)oystick or (k)eyboard";i$:ifi$="j"ori$="[202]"thenjs=-1
  11. 12 fora=54272to54296:pokea,0:next:poke54296,8:poke54277,0:poke54278,240
  12. 13 poke54282,3:poke54284,0:poke54285,240
  13. 20 dimx%(30),y%(30),l%(30),tl%(30)
  14. 25 gosub4000
  15. 30 goto75
  16. 40 rem position
  17. 45 printleft$("",v)spc(h-1);:return
  18. 75 gosub30000
  19. 80 rem ng
  20. 82 print"[147] fireflies - by dan tobias - c64 v1.1"
  21. 87 print:print"         hit any key to start. ";
  22. 88 geti$:ifi$=""then88
  23. 89 print"[147]"
  24. 90 sn=0:jn=8:of=0:sc=0
  25. 94 poke53248,255:poke53249,128
  26. 95 poke53269,peek(53269)or1
  27. 100 rem ns
  28. 101 i=0:poke54283,64
  29. 102 kb=0:sn=sn+1
  30. 103 ko=0
  31. 105 x=20:y=10:ifof<30thenof=of+5
  32. 106 tl=120+(of*6)
  33. 107 nf=of:n2=nf:nl=nf
  34. 110 fora=1tonf
  35. 120 x%(a)=int(rnd(0)*38)+2:y%(a)=int(rnd(0)*19)+2
  36. 130 l%(a)=-int(rnd(0)*2):tl%(a)=int(rnd(0)*3)
  37. 150 next
  38. 155 kx%=(rnd(0)*50)-5:ky%=-10:kl%=rnd(0)*2:ifrnd(0)<.5thenky%=35
  39. 157 kt%=rnd(0)*3
  40. 160 print"[147]":gosub5000
  41. 161 v=22:h=1:gosub40:print"score:"sc;:h=20:gosub40:print"hi score:";hs(0,1)
  42. 163 v=23:h=1:gosub40:print"fireflies on screen:"n2;
  43. 164 printtab(24);"time left:"tl:print"fireflies left:     "n2;tab(24);"screen #:"sn
  44. 165 poke54275,8:fori=1to8:poke54273,t%(i,0):poke54272,t%(i,1):poke54276,65
  45. 166 forj=1tot%(i,2):next:poke54276,64:next
  46. 167 gosub1000
  47. 170 fora=1tonf
  48. 171 ko=ko+1
  49. 172 poke54279,rnd(0)*256
  50. 173 lc=l%(a):tl%(a)=tl%(a)+1:iftl%(a)>2thentl%(a)=0:lc=notlc
  51. 174 xc=1:yc=1:ifrnd(0)<.5thenxc=-1
  52. 175 ifrnd(0)<.5thenyc=-1
  53. 176 f%=0
  54. 177 ifx%(a)<2orx%(a)>39ory%(a)<2ory%(a)>20thenf%=-1:goto200
  55. 190 h=x%(a):v=y%(a):gosub40:print" "
  56. 200 x%(a)=x%(a)+xc:y%(a)=y%(a)+yc:l%(a)=lc
  57. 210 ifx%(a)<2orx%(a)>39ory%(a)<2ory%(a)>20thenn2=n2+(notf%):goto300
  58. 215 iff%<>0thenn2=n2+1
  59. 220 ifnotl%(a)then300
  60. 230 h=x%(a):v=y%(a):gosub40:print"[158]."
  61. 300 rem
  62. 302 v=23:h=21:gosub40:printn2"[157] ":v=24:h=21:gosub40:printnl"[157] "
  63. 303 ifn2=0thena=999:next:goto900
  64. 305 gosub500
  65. 307 ifko/5=int(ko/5)thengosub312
  66. 310 next:gosub800
  67. 311 goto170
  68. 312 rem
  69. 315 kb=0
  70. 320 xc=sgn(x-kx%):yc=sgn(y-ky%):lc=kl%:kt%=kt%+1:ifkt%>2thenlc=notlc:kt%=0
  71. 330 ifkx%<2orkx%>39orky%<2orky%>20then360
  72. 340 h=kx%:v=ky%:gosub40:print" "
  73. 360 kx%=kx%+xc:ky%=ky%+yc:kl%=lc
  74. 370 ifkx%<2orkx%>39orky%<2orky%>20thenpoke54283,64:goto400
  75. 372 poke54280,6:poke54279,rnd(0)*256:poke54283,65
  76. 375 ifkl%=0then400
  77. 380 h=kx%:v=ky%:gosub40:print"[209]"
  78. 390 kb=1
  79. 400 ifkx%<xorkx%>x+2orky%<yorky%>y+1thenreturn
  80. 410 h=kx%:v=ky%:gosub40:print"[209]"
  81. 415 x$="the killer bug got you!"
  82. 430 goto9000:rem pop?
  83. 500 rem
  84. 508 ox=x:oy=y
  85. 509 ifjs<>0then3000
  86. 510 geti$
  87. 512 ifi$=""theni$=j$
  88. 515 j$=""
  89. 516 ifi$=""then2000
  90. 517 ifi$=" "theni=0:goto600
  91. 520 ifi$="j"thenx=x-1:j$=i$:ifx<1thenx=1
  92. 530 ifi$="k"thenx=x+1:j$=i$:ifx>38thenx=38
  93. 540 ifi$="i"theny=y-1:j$=i$:ify<1theny=1
  94. 550 ifi$="m"theny=y+1:j$=i$:ify>19theny=19
  95. 553 tl=tl-1:v=23:h=35:gosub40:printtl"[157] "
  96. 556 iftl<=0thenx$="time has run out!":goto9000
  97. 570 ifx=oxandy=oythenreturn
  98. 580 gosub1000
  99. 590 return
  100. 600 rem c
  101. 610 forb=1tonf
  102. 620 xb=x%(b):yb=y%(b)
  103. 630 ifxb<xorxb>x+2oryb<yoryb>y+1then670
  104. 640 sc=sc+10:nl=nl-1:n2=n2-1
  105. 641 v=23:h=21:gosub40:printn2"[157] ":v=24:h=21:gosub40:printnl"[157] ":v=22:h=7
  106. 642 gosub40:printsc"[157] ":h=xb:v=yb:gosub40:print"[158]."
  107. 645 poke54275,8:poke54273,22:poke54272,21:poke54276,65:fora=1to50:next
  108. 646 poke54276,64
  109. 647 gosub40:print" "
  110. 650 x%(b)=-16384:y%(b)=-16384
  111. 670 nextb
  112. 680 ifkx%<xorkx%>x+2orky%<yorky%>y+1thenreturn
  113. 685 h=kx%:v=ky%:gosub40:print"[209]"
  114. 690 poke54275,8:poke54273,24:poke54272,1:poke54276,65:fora=1to80:next
  115. 695 poke54276,64
  116. 700 sc=sc+500
  117. 705 v=22:h=7:gosub40:printsc"[157] "
  118. 710 h=kx%:v=ky%:gosub40:print" "
  119. 715 kb=0:kx%=-16384:ky%=-16384
  120. 720 return
  121. 800 rem
  122. 810 a=1
  123. 820 ifx%(a)<-10000then850
  124. 830 a=a+1:ifa<=nfthen820
  125. 840 return
  126. 850 ifa=nfthennf=nf-1:return
  127. 860 forb=a+1tonf:x%(b-1)=x%(b):y%(b-1)=y%(b):l%(b-1)=l%(b)
  128. 870 tl%(b-1)=tl%(b):next
  129. 880 nf=nf-1:goto830
  130. 900 rem done with board
  131. 910 ifnl=0thensc=sc+100
  132. 920 sc=sc+50+tl
  133. 930 goto100
  134. 1000 rem draw jar
  135. 1010 xx=x*8+16
  136. 1020 hx=int(xx/256):lx=xx-256*hx
  137. 1030 poke53248,lx:poke53264,hx
  138. 1040 poke53249,y*8+42
  139. 1050 return
  140. 2000 geti$:ifi$=""then2000
  141. 2010 goto500
  142. 3000 rem joystick
  143. 3010 jv=peek(56321)
  144. 3020 fr=jvand16:jv=15-(jvand15)
  145. 3030 iffr<>16then600
  146. 3040 ifjvand1theny=y-1:ify<1theny=1
  147. 3050 ifjvand2theny=y+1:ify>19theny=19
  148. 3060 ifjvand4thenx=x-1:ifx<1thenx=1
  149. 3070 ifjvand8thenx=x+1:ifx>38thenx=38
  150. 3080 goto553
  151. 3090 data18,209,200,15,210,100,12,143,100,18,209,300,16,195,100
  152. 3095 data15,210,200,14,24,200,12,143,400
  153. 4000 rem read in sprites
  154. 4010 fori=896to959:readj:pokei,j:next
  155. 4020 poke2040,14:poke53287,4
  156. 4025 poke832,0:rem make sure menu sprites are reloaded
  157. 4030 return
  158. 4100 data16,0,8,16,0,8,16,0,8,32,0,4,64,0,2,128,0,1
  159. 4110 data128,0,1,128,0,1,128,0,1,128,0,1,128,0,1,128,0,1,128,0,1,128,0,1
  160. 4120 data128,0,1,128,0,1,128,0,1,128,0,1,128,0,1,64,0,2,63,255,250
  161. 4130 data0
  162. 5000 rem draw screen
  163. 5010 print"[159][213][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][201]";
  164. 5020 fori=2to20:print"[194]                                      [194]";:next
  165. 5030 print"[202][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][203]"
  166. 5040 return
  167. 6000 rem set up tune
  168. 6005 dimt%(8,2)
  169. 6010 fori=1to8:readt%(i,0),t%(i,1),t%(i,2):next
  170. 6020 return
  171. 9000 rem end
  172. 9002 print"[147]"
  173. 9005 poke54283,64:poke53269,peek(53269)and254
  174. 9006 print:printtab(20-len(x$)/2)x$
  175. 9007 print:print"           g a m e   o v e r"
  176. 9008 print:print"            final score:"sc
  177. 9010 gosub31000
  178. 9015 print:print"p=play again, q=quit, h=high scores"
  179. 9100 rem
  180. 9110 geti$:ifi$=""then9110
  181. 9120 ifi$="q"then33000:rem pop?
  182. 9130 ifi$="p"then80:rem pop?
  183. 9140 ifi$="h"then32000
  184. 9150 goto9100
  185. 30000 rem h
  186. 30020 open15,8,15:open5,8,5,"ff.hi-scores"
  187. 30025 input#15,a$,b$,c$,d$:ifval(a$)>0then30100
  188. 30030 fora=1to10
  189. 30040 input#5,hs(0,a):input#5,sn$(0,a):input#5,sd$(0,a)
  190. 30050 next
  191. 30060 close5:close15:return
  192. 30100 rem
  193. 30110 close5:close15
  194. 30120 return
  195. 31000 rem u
  196. 31005 xx=0
  197. 31010 fora=0to1
  198. 31020 b=1
  199. 31030 ifsc>hs(a,b)thengosub31500:goto31100
  200. 31040 b=b+1:ifb<11then31030
  201. 31100 next:return
  202. 31500 rem
  203. 31503 ifxx=1then31540
  204. 31506 ifa=0thenxx=1
  205. 31510 print:print"your score is in the top ten!"
  206. 31520 print:print"enter your name.  (limit 16 characters)"
  207. 31530 print:inputsn$
  208. 31532 iflen(sn$)>16thensn$=left$(sn$,16)
  209. 31540 ifb=10thenhs(a,b)=sc:sn$(a,b)=sn$:sd$(a,b)=sd$:return
  210. 31550 forc=9tobstep-1
  211. 31560 hs(a,c+1)=hs(a,c):sn$(a,c+1)=sn$(a,c):sd$(a,c+1)=sd$(a,c)
  212. 31570 next:hs(a,b)=sc:sn$(a,b)=sn$:sd$(a,b)=sd$:return
  213. 32000 rem disp hi scores
  214. 32010 print"[147]"
  215. 32030 print:print:print"high scores for current run:":print
  216. 32050 fora=1to10
  217. 32055 ifhs(1,a)=0thenprint:goto32070
  218. 32060 printa;tab(4);hs(1,a);tab(15);sn$(1,a);tab(32);sd$(1,a)
  219. 32070 next
  220. 32075 print:print"hit any key to continue."
  221. 32077 geti$:ifi$=""then32077
  222. 32080 print"[147]":print:print"all-time high scores for this disk:"
  223. 32085 print
  224. 32090 fora=1to10
  225. 32095 ifhs(0,a)=0thenprint:goto32120
  226. 32100 printa;tab(4);hs(0,a);tab(15);sn$(0,a);tab(32);sd$(0,a)
  227. 32120 next
  228. 32125 print
  229. 32127 geti$
  230. 32130 print"p=play, q=quit, h=high scores"
  231. 32140 geti$:ifi$=""then32140
  232. 32150 ifi$="p"then80
  233. 32160 ifi$="q"then33000
  234. 32170 ifi$="h"then32000
  235. 32180 goto32140
  236. 33000 remx
  237. 33005 print"[147]":print"saving high scores to disk."
  238. 33020 open15,8,15,"s0:ff.hi-scores":open5,8,5,"ff.hi-scores,s,w"
  239. 33030 fora=1to10:print#5,hs(0,a):print#5,chr$(34)sn$(0,a)
  240. 33032 print#5,chr$(34)sd$(0,a):next
  241. 33035 close5:close15
  242. 33045 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  243. 33050 poke631,13:poke632,13:poke198,2
  244. 39999 end
  245. 40000 nf=25
  246. 40005 n2=25
  247. 40010 fora=1to5:x%(a)=a:y%(a)=1:next
  248. 40020 fora=6to10:x%(a)=a-5:y%(a)=2:next
  249. 40030 fora=11to15:x%(a)=a-10:y%(a)=3:next
  250. 40040 fora=16to20:x%(a)=a-15:y%(a)=4:next
  251. 40050 fora=21to25:x%(a)=a-20:y%(a)=5: