home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
UpTime Volume 2 #5
/
utv2n5s1.d64
/
race.exe
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-28
|
6KB
|
234 lines
30 poke 45,peek(174):poke 46,peek(175)
31 poke 56,160:clr
32 dim p1$(8),p2$(15),p2(15),hi$(10),hi(10),p1(8)
33 open5,8,5,"hiscore,p,r"
34 fori=1to10:input#5,hi$(i):input#5,hi(i):nexti:close5
40 sa=16577:cl=16635
42 poke 53280,6:poke 53281,6:print"[147]"chr$(8)chr$(142)
45 sys sa:poke54296,4
50 poke 53272,21:poke866,1
60 poke 2040,236:poke 2041,234:poke2042,235
70 v=53248:poke v,160:pokev+1,54
80 pokev+2,129:pokev+4,191:pokev+3,220:pokev+5,220
83 pokev+16,0
85 pokev+28,0:pokev+39,1:poke v+40,3:pokev+41,3
90 pokev+23,1:pokev+29,7:pokev+21,7
94 print""tab(19)"by":a$="":p=1:poke198,0:de=0
95 print" music composed by greg gauthier."
96 b$=" 1 player"
100 print""tab(13)"f1:"b$a$
101 printtab(13)"f3: best times"
105 printtab(13)"f7: start"
110 printtab(13)"f8: quit to uptime"
115 getz$:ifz$="[133]"thenp=p+1:de=0:b$=" player":ifp=9thenp=0:a$=" "
116 ifz$="[133]"andp>1thenb$=b$+"s"
117 de=de+1:ifp=0thenb$=" practice"
118 ifp>0andz$="[133]"thenb$=str$(p)+b$
119 ifz$="[134]"thende=500
120 ifde=500then1200
122 if z$="[140]" then 700
125 ifz$<>"[136]"then100
130 rem start here
135 ifp=0then1700
140 poke828,p:p=int(p/2+.5)*2
150 fori=1to15:p2$(i)="":p2(i)=96000:nexti
155 poke53269,0
156 ifpeek(828)>1then160
157 print"[147]what computer level do you want (1-3)? ";
158 geta$:ifa$<"1"ora$>"3"then158
159 printa$:poke 857,val(a$)
160 fori=1topeek(828)
170 print"player #"i", enter your name."
180 poke198,0:n$=""
185 print":[164][157]";
190 geta$:ifa$=chr$(20)then240
200 ifa$=chr$(13)then260
205 if a$="[140]" then 700
210 ifa$<" "ora$>"z"then190
215 if a$=chr$(34) then 190
220 iflen(n$)=10then190
230 n$=n$+a$:printa$"[164][157]";:goto190
240 iflen(n$)=0then190
250 n$=left$(n$,len(n$)-1):print" [157][157][164][157]";:goto190
260 iflen(n$)=0then190
265 print" "
270 p1$(i)=n$:nexti
275 ifpeek(828)<>pthenp1$(p)="computer "+chr$(8)
280 fori=1top:p2$(i)=p1$(i):next:fori=1to15:p2(i)=101000:next
283 p1=peek(828)
285 fori=1to16:x1=int(rnd(1)*p1)+1:x2=int(rnd(1)*p1)+1
286 a$=p2$(x1):p2$(x1)=p2$(x2):p2$(x2)=a$:next
290 print"[147]"tab(15)"standings:"
291 poke53280,6:poke53281,6
295 d$=""
300 x=3:fori=1to8
305 printleft$(d$,x)p2$(i):ifp2$(i)<>""thenprint"[163][163][163][163][163][163][163][163][163][163]"
310 x=x+2:ifi/2=int(i/2)thenx=x+2
315 nexti
320 x=6:fori=9to12
324 printleft$(d$,x)tab(10)p2$(i)
325 if(p>2andi=10)or(p>4andi=11)orp>6ori=9thenprinttab(10)"[163][163][163][163][163][163][163][163][163][163]"
326 x=x+2:ifi/2=int(i/2)thenx=x+8
330 nexti
340 x=11:fori=13to14
345 printleft$(d$,x)tab(20)p2$(i)
350 if(p>2andi=13)orp>4thenprinttab(20)"[163][163][163][163][163][163][163][163][163][163]"
355 x=x+4 :nexti
360 ifp>4thenprintleft$(d$,13)tab(29)p2$(15):printtab(29)"[163][163][163][163][163][163][163][163][163][163]"
370 gosub900
380 rem choose next contestant
385 ifp2(1)>96000thenga=1:goto450
390 ifp2(3)>96000andp>2thenga=3:goto450
395 ifp2(5)>96000andp>4thenga=5:goto450
400 ifp2(7)>96000andp>6thenga=7:goto450
405 ifp2(9)>96000andp>2thenga=9:goto450
410 ifp2(11)>96000andp>6thenga=11:goto450
415 ifp2(13)>96000andp>5thenga=13:goto450
420 goto 1300
450 a$="next heat:"
451 poke53280,14:poke53281,14
452 ifp2(ga)=98000thena$=a$+"(rematch)"
453 print"[147]"tab(20-len(a$)/2)a$
454 a$=p2$(ga)+" vs "+p2$(ga+1)
455 print""tab(20-len(a$)/2)a$
456 if(peek(56320)and16)=0or(peek(56321)and16)=0then456
460 print"press your button "p2$(ga);
465 x1=0:x2=0
470 a=(peek(56321)and16):if(aand16)=0thenx1=1:print" blue car":goto490
475 ifp2$(ga+1)="computer "+chr$(8)then470
480 a=(peek(56320)and16):if(aand16)=0thenx1=0:print" red car":goto490
485 goto470
490 x2=1-x1:poke 856,2
495 p1=peek(828):ifp2$(ga+1)="computer "+chr$(8)thenpoke856,1:goto550
500 print"press your button "p2$(ga+1);
501 ifx2=1thenprint" blue car"
502 ifx2=0thenprint" red car"
505 a=(peek(56320+x2)and16):if(aand16)=16then505
550 rem start race
551 print"get ready"
552 fori=1to1500:next:sys cl
555 sys16384:sys49152:poke53280,12:poke53281,12
556 poke 53269,0:print"[147]"
557 poke53272,21
560 print""tab(16)"results:"
561 a1$="":a2$="":ifx2=0thena1$="":a2$=""
562 x1=(1-x1)*2:x2=(1-x2)*2
565 poke828,p1
570 t1=peek(850+x1)*1000+peek(849+x1)
571 ifpeek(842+x1/2)=3thent1=96000
575 t2=peek(850+x2)*1000+peek(849+x2)
576 ifpeek(842+x2/2)=3thent2=96000
580 printa1$p2$(ga)tab(12)":";
585 a=t1:gosub1000:p2(ga)=a
587 printa2$""p2$(ga+1)tab(12)":";
590 a=t2:gosub1000:p2(ga+1)=a
595 ift1=t2thenp2(ga)=98000:p2(ga+1)=98000:goto620
596 ifpeek(842)=3andpeek(843)=3thenp2(ga)=98000:p2(ga+1)=98000:goto620
600 rem put winner into proper place
605 x=9:ifga=3thenx=10
606 ifga=5thenx=11
607 ifga=7thenx=12
608 ifga=9thenx=13
609 ifga=11thenx=14
610 ifga=13thenx=15
611 ift1<t2thenp2$(x)=p2$(ga)
612 ift2<t1thenp2$(x)=p2$(ga+1)
613 ifpeek(828)=porp<3then620
619 ifp2$(ga+1)="computer "+chr$(8)thenp2$(x)=p2$(ga)
620 rem go back to chart
625 gosub900
630 goto290
700 clr:load"upt.reboot",8
899 end
900 if(peek(56320)and16)=0or(peek(56321)and16)=0then900
904 print""tab(8)"press button to continue"
905 if(peek(56320)and16)=16and(peek(56321)and16)=16then905
920 return
1000 rem given a, print out time
1005 b1=int(a/1000):b2=a-b1*1000
1010 ifb1=96thenprint"[158]out of race":goto1020
1015 b3=int(b1/16):b4=b1-b3*16:b5=int(b2/16):b6=b2-b5*16
1017 printchr$(b3+48)chr$(b4+48)"."chr$(b5+48)chr$(b6+48)
1020 return
1100 sys cl:forx=1to50:nextx
1103 poke856,0:poke857,2:sys16384:sys49152:poke53269,0:print"[147]":poke53281,12
1105 poke53280,12:goto40
1200 rem high score display
1205 print"[147]":poke53248+29,1
1206 poke53269,1:poke53249,54:poke53248,160:poke2040,236:poke53248+23,1
1210 poke53280,0:poke53281,0
1215 printtab(16)"[164][164][164][164][164][164][164][164]"
1220 printtab(8)"[164][175][185][162][184][183][163] all time [163][183][184][146][162][185][175][164]"
1225 fori=1to10:a$=str$(i)
1230 a$=""+right$(a$,2)+"."
1235 printtab(8)a$" [159]"hi$(i)tab(27)"[158]";
1240 a=hi(i):gosub1000
1245 nexti
1246 printtab(8)"[164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]"
1250 printtab(9)"[163][183][184][162][185][175][164] best [164][175][185][162][146][184][183][163]"
1251 printtab(3)"[152]press a key to return to the menu."
1255 poke198,0
1260 ifpeek(198)<>0then40
1270 de=de+1:ifde<1200then1260
1280 goto1100
1300 rem high score update
1301 print" "
1305 z=0:fori=1to15
1310 ifp2(i)<hi(10)thengosub1400:z=z+1
1315 nexti:ifzthengosub1450
1320 de=300:goto1500
1400 ifp2$(i)="computer "+chr$(8)thenz=z-1:return
1402 hi$(10)=p2$(i):hi(10)=p2(i)
1404 x=9
1405 ifhi(x)<=hi(x+1)thenreturn
1410 a=hi(x):hi(x)=hi(x+1):hi(x+1)=a:a$=hi$(x):hi$(x)=hi$(x+1):hi$(x+1)=a$
1415 x=x-1:ifx>0then1405
1420 return
1450 rem rewrite highscores
1455 print"[147]":sys cl:open15,8,15,"s0:hiscore":close15
1460 open5,8,5,"hiscore,p,w"
1465 fori=1to10:print#5,hi$(i):print#5,hi(i):nexti:close5
1466 open15,8,15:input#15,a,b$,c,d:close15:ifa=0thenreturn
1470 print"[147]disk error:"b$
1471 a=peek(56320)and16:b=peek(56321)and16:ifa=0orb=0then1471
1475 print"press either button to try again."
1476 a=peek(56320)and16:b=peek(56321)and16:ifa=16andb=16then1476
1480 goto1450
1500 rem display each player best time
1501 wi$=""
1505 fori=1top:p1(i)=96000:next
1510 fori=1to15:a$=p2$(i):forx=1top:ifa$<>p1$(x)thennextx:goto1520
1513 wi$=p2$(i)
1515 ifp2(i)<p1(x)thenp1(x)=p2(i)
1520 nexti
1525 print"[147]"tab(15)"best times"
1530 print""
1535 fori=1top
1540 ifp1$(i)="computer "+chr$(8)thengoto1560
1550 print""p1$(i)tab(11)":";:a=p1(i):gosub1000
1560 nexti
1562 ifwi$="computer "+chr$(8)thenwi$="computer"
1565 print"";:a$="winner:[158]"+wi$
1567 printtab(21-len(a$)/2)a$
1568 if(peek(56320)and16)=0or(peek(56321)and16)=0then1568
1570 print""tab(6)"press <return> to go to menu"
1575 print" press button to play with same names"
1580 poke198,0
1581 fori=1to15:p2$(i)="":next
1585 geta$:ifa$=chr$(13)then1200
1590 if(peek(56320)and16)=16and(peek(56321)and16)=16then1585
1595 goto280
1600 rem practice
1700 poke53280,6:poke53281,6