home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 4
/
004.d81
/
fireflies
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
9KB
|
333 lines
1 rem fireflies
2 rem c64 version 1.1 6/21/84
3 rem copyright (c) 1984 by dan tobias
4 gosub41000:rem instructions
5 printchr$(142):rem upper case mode
6 poke53280,0:poke53281,0:print""
7 print"[147]":input"today's date (mm/dd/yy)";sd$
8 gosub6000
9 js=0
10 print:input"(j)oystick or (k)eyboard";i$:ifi$="j"ori$="[202]"thenjs=-1
12 fora=54272to54296:pokea,0:next:poke54296,8:poke54277,0:poke54278,240
13 poke54282,3:poke54284,0:poke54285,240
20 dimx%(30),y%(30),l%(30),tl%(30)
25 gosub4000
30 goto75
40 rem position
45 printleft$("",v)spc(h-1);:return
75 gosub30000
80 rem ng
82 print"[147] fireflies - by dan tobias - c64 v1.1"
87 print:print" hit any key to start. ";
88 geti$:ifi$=""then88
89 print"[147]"
90 sn=0:jn=8:of=0:sc=0
94 poke53248,255:poke53249,128
95 poke53269,peek(53269)or1
100 rem ns
101 i=0:poke54283,64
102 kb=0:sn=sn+1
103 ko=0
105 x=20:y=10:ifof<30thenof=of+5
106 tl=120+(of*6)
107 nf=of:n2=nf:nl=nf
110 fora=1tonf
120 x%(a)=int(rnd(0)*38)+2:y%(a)=int(rnd(0)*19)+2
130 l%(a)=-int(rnd(0)*2):tl%(a)=int(rnd(0)*3)
150 next
155 kx%=(rnd(0)*50)-5:ky%=-10:kl%=rnd(0)*2:ifrnd(0)<.5thenky%=35
157 kt%=rnd(0)*3
160 print"[147]":gosub5000
161 v=22:h=1:gosub40:print"score:"sc;:h=20:gosub40:print"hi score:";hs(0,1)
163 v=23:h=1:gosub40:print"fireflies on screen:"n2;
164 printtab(24);"time left:"tl:print"fireflies left: "n2;tab(24);"screen #:"sn
165 poke54275,8:fori=1to8:poke54273,t%(i,0):poke54272,t%(i,1):poke54276,65
166 forj=1tot%(i,2):next:poke54276,64:next
167 gosub1000
170 fora=1tonf
171 ko=ko+1
172 poke54279,rnd(0)*256
173 lc=l%(a):tl%(a)=tl%(a)+1:iftl%(a)>2thentl%(a)=0:lc=notlc
174 xc=1:yc=1:ifrnd(0)<.5thenxc=-1
175 ifrnd(0)<.5thenyc=-1
176 f%=0
177 ifx%(a)<2orx%(a)>39ory%(a)<2ory%(a)>20thenf%=-1:goto200
190 h=x%(a):v=y%(a):gosub40:print" "
200 x%(a)=x%(a)+xc:y%(a)=y%(a)+yc:l%(a)=lc
210 ifx%(a)<2orx%(a)>39ory%(a)<2ory%(a)>20thenn2=n2+(notf%):goto300
215 iff%<>0thenn2=n2+1
220 ifnotl%(a)then300
230 h=x%(a):v=y%(a):gosub40:print"[158]."
300 rem
302 v=23:h=21:gosub40:printn2"[157] ":v=24:h=21:gosub40:printnl"[157] "
303 ifn2=0thena=999:next:goto900
305 gosub500
307 ifko/5=int(ko/5)thengosub312
310 next:gosub800
311 goto170
312 rem
315 kb=0
320 xc=sgn(x-kx%):yc=sgn(y-ky%):lc=kl%:kt%=kt%+1:ifkt%>2thenlc=notlc:kt%=0
330 ifkx%<2orkx%>39orky%<2orky%>20then360
340 h=kx%:v=ky%:gosub40:print" "
360 kx%=kx%+xc:ky%=ky%+yc:kl%=lc
370 ifkx%<2orkx%>39orky%<2orky%>20thenpoke54283,64:goto400
372 poke54280,6:poke54279,rnd(0)*256:poke54283,65
375 ifkl%=0then400
380 h=kx%:v=ky%:gosub40:print"[209]"
390 kb=1
400 ifkx%<xorkx%>x+2orky%<yorky%>y+1thenreturn
410 h=kx%:v=ky%:gosub40:print"[209]"
415 x$="the killer bug got you!"
430 goto9000:rem pop?
500 rem
508 ox=x:oy=y
509 ifjs<>0then3000
510 geti$
512 ifi$=""theni$=j$
515 j$=""
516 ifi$=""then2000
517 ifi$=" "theni=0:goto600
520 ifi$="j"thenx=x-1:j$=i$:ifx<1thenx=1
530 ifi$="k"thenx=x+1:j$=i$:ifx>38thenx=38
540 ifi$="i"theny=y-1:j$=i$:ify<1theny=1
550 ifi$="m"theny=y+1:j$=i$:ify>19theny=19
553 tl=tl-1:v=23:h=35:gosub40:printtl"[157] "
556 iftl<=0thenx$="time has run out!":goto9000
570 ifx=oxandy=oythenreturn
580 gosub1000
590 return
600 rem c
610 forb=1tonf
620 xb=x%(b):yb=y%(b)
630 ifxb<xorxb>x+2oryb<yoryb>y+1then670
640 sc=sc+10:nl=nl-1:n2=n2-1
641 v=23:h=21:gosub40:printn2"[157] ":v=24:h=21:gosub40:printnl"[157] ":v=22:h=7
642 gosub40:printsc"[157] ":h=xb:v=yb:gosub40:print"[158]."
645 poke54275,8:poke54273,22:poke54272,21:poke54276,65:fora=1to50:next
646 poke54276,64
647 gosub40:print" "
650 x%(b)=-16384:y%(b)=-16384
670 nextb
680 ifkx%<xorkx%>x+2orky%<yorky%>y+1thenreturn
685 h=kx%:v=ky%:gosub40:print"[209]"
690 poke54275,8:poke54273,24:poke54272,1:poke54276,65:fora=1to80:next
695 poke54276,64
700 sc=sc+500
705 v=22:h=7:gosub40:printsc"[157] "
710 h=kx%:v=ky%:gosub40:print" "
715 kb=0:kx%=-16384:ky%=-16384
720 return
800 rem
810 a=1
820 ifx%(a)<-10000then850
830 a=a+1:ifa<=nfthen820
840 return
850 ifa=nfthennf=nf-1:return
860 forb=a+1tonf:x%(b-1)=x%(b):y%(b-1)=y%(b):l%(b-1)=l%(b)
870 tl%(b-1)=tl%(b):next
880 nf=nf-1:goto830
900 rem done with board
910 ifnl=0thensc=sc+100
920 sc=sc+50+tl
930 goto100
1000 rem draw jar
1010 xx=x*8+16
1020 hx=int(xx/256):lx=xx-256*hx
1030 poke53248,lx:poke53264,hx
1040 poke53249,y*8+42
1050 return
2000 geti$:ifi$=""then2000
2010 goto500
3000 rem joystick
3010 jv=peek(56321)
3020 fr=jvand16:jv=15-(jvand15)
3030 iffr<>16then600
3040 ifjvand1theny=y-1:ify<1theny=1
3050 ifjvand2theny=y+1:ify>19theny=19
3060 ifjvand4thenx=x-1:ifx<1thenx=1
3070 ifjvand8thenx=x+1:ifx>38thenx=38
3080 goto553
3090 data18,209,200,15,210,100,12,143,100,18,209,300,16,195,100
3095 data15,210,200,14,24,200,12,143,400
4000 rem read in sprites
4010 fori=896to959:readj:pokei,j:next
4020 poke2040,14:poke53287,4
4025 poke832,0:rem make sure menu sprites are reloaded
4030 return
4100 data16,0,8,16,0,8,16,0,8,32,0,4,64,0,2,128,0,1
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
4120 data128,0,1,128,0,1,128,0,1,128,0,1,128,0,1,64,0,2,63,255,250
4130 data0
5000 rem draw screen
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]";
5020 fori=2to20:print"[194] [194]";:next
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]"
5040 return
6000 rem set up tune
6005 dimt%(8,2)
6010 fori=1to8:readt%(i,0),t%(i,1),t%(i,2):next
6020 return
9000 rem end
9002 print"[147]"
9005 poke54283,64:poke53269,peek(53269)and254
9006 print:printtab(20-len(x$)/2)x$
9007 print:print" g a m e o v e r"
9008 print:print" final score:"sc
9010 gosub31000
9015 print:print"p=play again, q=quit, h=high scores"
9100 rem
9110 geti$:ifi$=""then9110
9120 ifi$="q"then33000:rem pop?
9130 ifi$="p"then80:rem pop?
9140 ifi$="h"then32000
9150 goto9100
30000 rem h
30020 open15,8,15:open5,8,5,"ff.hi-scores"
30025 input#15,a$,b$,c$,d$:ifval(a$)>0then30100
30030 fora=1to10
30040 input#5,hs(0,a):input#5,sn$(0,a):input#5,sd$(0,a)
30050 next
30060 close5:close15:return
30100 rem
30110 close5:close15
30120 return
31000 rem u
31005 xx=0
31010 fora=0to1
31020 b=1
31030 ifsc>hs(a,b)thengosub31500:goto31100
31040 b=b+1:ifb<11then31030
31100 next:return
31500 rem
31503 ifxx=1then31540
31506 ifa=0thenxx=1
31510 print:print"your score is in the top ten!"
31520 print:print"enter your name. (limit 16 characters)"
31530 print:inputsn$
31532 iflen(sn$)>16thensn$=left$(sn$,16)
31540 ifb=10thenhs(a,b)=sc:sn$(a,b)=sn$:sd$(a,b)=sd$:return
31550 forc=9tobstep-1
31560 hs(a,c+1)=hs(a,c):sn$(a,c+1)=sn$(a,c):sd$(a,c+1)=sd$(a,c)
31570 next:hs(a,b)=sc:sn$(a,b)=sn$:sd$(a,b)=sd$:return
32000 rem disp hi scores
32010 print"[147]"
32030 print:print:print"high scores for current run:":print
32050 fora=1to10
32055 ifhs(1,a)=0thenprint:goto32070
32060 printa;tab(4);hs(1,a);tab(15);sn$(1,a);tab(32);sd$(1,a)
32070 next
32075 print:print"hit any key to continue."
32077 geti$:ifi$=""then32077
32080 print"[147]":print:print"all-time high scores for this disk:"
32085 print
32090 fora=1to10
32095 ifhs(0,a)=0thenprint:goto32120
32100 printa;tab(4);hs(0,a);tab(15);sn$(0,a);tab(32);sd$(0,a)
32120 next
32125 print
32127 geti$
32130 print"p=play, q=quit, h=high scores"
32140 geti$:ifi$=""then32140
32150 ifi$="p"then80
32160 ifi$="q"then33000
32170 ifi$="h"then32000
32180 goto32140
33000 remx
33005 print"[147]":print"saving high scores to disk."
33020 open15,8,15,"s0:ff.hi-scores":open5,8,5,"ff.hi-scores,s,w"
33030 fora=1to10:print#5,hs(0,a):print#5,chr$(34)sn$(0,a)
33032 print#5,chr$(34)sd$(0,a):next
33035 close5:close15
33045 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
33050 poke631,13:poke632,13:poke198,2
39999 end
40000 nf=25
40005 n2=25
40010 fora=1to5:x%(a)=a:y%(a)=1:next
40020 fora=6to10:x%(a)=a-5:y%(a)=2:next
40030 fora=11to15:x%(a)=a-10:y%(a)=3:next
40040 fora=16to20:x%(a)=a-15:y%(a)=4:next
40050 fora=21to25:x%(a)=a-20:y%(a)=5: