home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 60
/
060.d81
/
digithunt.bas
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
15KB
|
429 lines
10 rem@ s1024
20 rem@ 02
30 rem@ r=cs
40 clr:dim a(9,9),x(9),y(9),pt(9),rx(81),ry(81),rn(9),cn(9),bn(9),rc(9),cc(9)
50 dim bc(9),rp(9),cp(9),bp(9),nr(9),nc(9),nb(9),lv(9),uv(9),kv(9),vv(9),c(7)
60 dim rf(7),m1$(3),m2$(3),bt$(9,2)
70 data255,0,56,69,130,69,56,0,224,144,144,144,224,128,64,63
80 data255,16,144,16,16,16,144,16,16,16,16,16,32,64,128,0
90 fori=832to894:pokei,0:next
100 fori=832to877step3:readj:pokei,j:next
110 fori=833to878step3:readj:pokei,j:next
120 poke53287,0:poke53248,50:poke53249,194:poke53264,1:poke2040,13:poke53269,1
130 deffnx(y)=int(log(y)/log(2))+1
140 sl$="":cl$=" "
150 bs$="[157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157]":cs=55386:ts=1114:
160 cl$="[155]"+sl$+cl$+bs$+cl$+bs$
170 cl$=cl$+"[144] [155][145][145][145]"
180 c(1)=11:c(2)=12:c(3)=15:c(4)=1:c(5)=15:c(6)=12
190 poke53280,0:poke53281,0:db$="[157][157][157][157][157][157][157][157]"
200 bo$="[159][213][192][192][192][192][192][192][201]"+db$+"[221] [221]"+db$+"[202][192][192][192][192][192][192][203]"+db$+"[144] [145][157] [157][145] [157]"
210 bo$=bo$+"[157][157][157][157][157][157][157][159]":open15,8,15,"i0:"
220 open2,8,2,"best times,p,r"
230 input#15,a$,a$:ifa$<>"ok"thenclose2:goto250
240 fori=1to9:input#2,bt$(i,1),bt$(i,0),bt$(i,2):next:close2:goto270
250 fori=1to9:bt$(i,1)="006000":bt$(i,0)="---------":bt$(i,2)="5"
260 next:gosub3940:run
270 close15:poke53272,21:print"[147][158] d i g i t h u n t "
280 gosub3690:print"[155]"spc(3)" level time name errors[151][184]"
290 printspc(4)"[184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][155]"
300 jj$=" ":fori=1to9:a$=bt$(i,1):ifi=skthenpoke199,1
310 printspc(6)i"[157]. ";:ifval(mid$(a$,3,2))<10thenprint" ";
320 printval(mid$(a$,3,2))"[157]:"mid$(a$,5,2)jj$bt$(i,0)jj$;
330 ifval(bt$(i,2))<10thenprint" ";
340 printbt$(i,2)" ":next:ifskthen4050
350 poke214,13:print:print"[158] setting up..."
360 gosub1830
370 gosub1550:forj=1to3:fori=1to3:x(i+j*3-3)=r(j)*3-3:next:next
380 gosub1550:forj=1to3:fori=1to3:y(i+j*3-3)=r(j)*3-3:next:next
390 fori=0to6step3:gosub1550:forj=1to3:x(i+j)=x(i+j)+r(j):next:gosub1550
400 forj=1to3:y(i+j)=y(i+j)+r(j):next:next
410 poke214,13:print:print" setting up..."
420 forx=1to9:fory=1to9:readq:a(x(x),y(y))=-z(q):next:next
430 data1,5,9,8,4,6,7,2,3,8,6,3,1,2,7,5,4,9,7,2,4,3,9,5,8,6,1
440 data2,1,8,5,3,9,6,7,4,4,9,5,7,6,2,3,1,8,6,3,7,4,1,8,2,9,5
450 data5,8,2,9,7,4,1,3,6,3,4,6,2,8,1,9,5,7,9,7,1,6,5,3,4,8,2
460 poke198,0:i=1
470 poke214,13:print:print"[159]skill level (1-9) or clr to clear times"
480 geta$:ifti<10then510
490 poke55869,c(i):poke55871,c(i)
500 poke55877,c(i):poke55878,c(i):poke55879,c(i):i=i+1:ti$="000000":ifi>6theni=1
510 sk=val(a$):if(sk>9orsk<1)anda$<>"[147]"anda$<>""then480
520 ifa$="[147]"ora$=""then3990
530 ti$="160000":goto280
540 poke53272,21:poke53280,11:poke53281,11:poke53269,0
550 x$="[144][221][155][166][158][221][155][166][158][221][155][166][144][221][155][166][158][221][155][166][158][221][155][166][144][221][155][166][158][221][155][166][158][221][155][166][144][221]"
560 y$=" [144][171][158][192][219][192][219][192][144][219][158][192][219][192][219][192][144][219][158][192][219][192][219][192][144][179]"
570 z$=" [144][171][192][219][192][219][192][219][192][219][192][219][192][219][192][219][192][219][192][179]"
580 print"[147][155] d i g i t h u n t [144][146][175]"
590 print"[144][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175]"
600 print" a b c d e f g h i"
610 print"[144] [176][192][178][192][178][192][178][192][178][192][178][192][178][192][178][192][178][192][174]"
620 print" r";x$:printy$
630 print" s";x$:printy$
640 print" t";x$:printz$
650 print" u";x$:printy$
660 print" v";x$:printy$
670 print" w";x$:printz$
680 print" x";x$:printy$
690 print" y";x$:printy$
700 print" z";x$:print" [144][173][192][177][192][177][192][177][192][177][192][177][192][177][192][177][192][177][192][189]"
710 printcl$;"[155] one moment..."
720 print" i'm thinking of a good puzzle..."
730 poke1983,160:poke2023,160:poke56255,0:poke56295,0
740 poke214,12:print:print"[144]best time":print""bo$;:a$=bt$(sk,1)
750 print"[159]"val(mid$(a$,3,2))"[157]:"mid$(a$,5,2)
760 poke214,12:print:printtab(32)"[144]errors"
770 printtab(31)bo$
780 print"[144]";:ifbt$(sk,0)="---------"thenprint"[151]";
790 printbt$(sk,0):print"[144]limit"
800 print""val(mid$(tb$,3,2))"[157]:"mid$(tb$,5,2)
810 gosub1950:rem ifsk=10thenfori=1to9:forii=1to9:a(i,ii)=abs(a(i,ii)):next:next
820 printcl$;"[155] i've got it!"
830 gosub1750:x1=5:y1=5
840 gosub1290
850 :
860 rem main loop
870 :
880 ifnu<1thengosub3880:printcl$" you win with only"sc"errors";:goto1480
890 ifval(ti$)>10000thenprint""bo$""spc(31)bo$:ti$="000000"
900 print"[144][146]timeaccuracy"
910 pokecs+2*x1+80*y1,1
920 gosub3860
930 gosub3580:ifa(x1,y1)>0thenifa$>"0"anda$<="9"thentr%=tr%+1
940 rem ifa$="?"ora$="/"thensc=sc+1:xm=1:gosub3640:tr%=tr%+1
950 ifti$>tb$thengosub3970
960 a=asc(a$):x2=x1:y2=y1:rempoke1983,160:poke2023,160:poke56255,0:poke56295,0
970 ifa>=65anda<=73thenx2=a-64:goto1320
980 ifa>=82anda<=90theny2=a-81:goto1320
990 ifa=133thengosub2280:goto840
1000 ifa=134thengosub2650:goto840
1010 ifa=135thengosub2550:goto840
1020 ifa=136then2860
1030 ifa=47anda(x1,y1)>0thenff%=1:gosub1680:sc=sc+2:gosub3860:goto880
1040 ifa=63thengosub1790:sc=sc+2:ff%=1:gosub3860:goto880
1050 ifa=17theny2=y1+1:goto1320
1060 ifa=29thenx2=x1+1:goto1320
1070 ifa=145theny2=y1-1:goto1320
1080 ifa=157thenx2=x1-1:goto1320
1090 ifa=81then1370
1100 ifa<49ora>57then880
1110 a=a-48:ifa(x1,y1)<0then880
1120 ifa(x1,y1)=athengosub1680:goto880
1130 x2=x1:y2=y1:sc=sc+1:gosub3860
1140 if(rn(y1)andpt(a))=0then1170
1150 j=1:fori=1to9:ifa(i,y1)=-athenx2=i
1160 next:i=y1:gosub2820:goto1240
1170 if(cn(x1)andpt(a))=0then1200
1180 j=2:fori=1to9:ifa(x1,i)=-atheny2=i
1190 next:i=x1:gosub2820:goto1240
1200 b=kv(x1)+uv(y1):if(bn(b)andpt(a))=0then1230
1210 fori=vv(b)+1tovv(b)+3:forj=uv(b)+1touv(b)+3:ifa(i,j)=-athenx2=i:y2=j
1220 nextj,i:j=3:i=b:gosub2820:goto1240
1230 m1$(1)=">>> i have a different digit there":x2=0:goto1250
1240 m1$(1)=">>> "+b$+c$+" already has a"+str$(a)
1250 printcl$;m1$(1):ifx2>0thenpokecs+2*x2+80*y2,0
1260 gosub 3580
1270 ifx2>0thenpokecs+2*x2+80*y2,15
1280 gosub1290:goto960
1290 printcl$;" q:quit ?:reveal rnd /:reveal this"
1300 print" f1:print f3:load f5:save f7:hint";:return
1310 rem move cursor, check bounds
1320 pokecs+2*x1+80*y1,15:x1=x2:y1=y2:ifx1<1thenx1=9
1330 ifx1>9thenx1=1
1340 ify1<1theny1=9
1350 ify1>9theny1=1
1360 goto880
1370 printcl$;"quit? f1:yes f3:show grid f7:no"
1380 geta$:ifa$=""then1380
1390 ifa$="y"thena$="[133]"
1400 ifa$="n"thena$="[136]"
1410 ifa$=chr$(136)then840
1420 ifa$=chr$(133)then1470
1430 ifa$<>chr$(134)then1380
1440 fory=1to9:forx=1to9:pokets+2*x+80*y,48+a(x,y)
1450 ifa(x,y)<0thenpokets+2*x+80*y,48-a(x,y)
1460 nextx,y
1470 printcl$;"[145]";
1480 ifsc=1then print"[157] "
1490 print
1500 pokecs+2*x1+80*y1,15:printspc(13)"play again? (y/n)"
1510 geta$:ifa$<>"y"anda$<>"n"then1510
1520 ifa$="n"then3640
1530 run
1540 rem compute permutation of 3
1550 r(1)=1:r(2)=2:r(3)=3
1560 r=int(rnd(ti)*2)+2:s=r(1):r(1)=r(r):r(r)=s
1570 r=int(rnd(ti)*2)*2+1:s=r(2):r(2)=r(r):r(r)=s
1580 r=int(rnd(ti)*2)+1:s=r(3):r(3)=r(r):r(r)=s
1590 return
1600 rem remove square at (x,y)
1610 n=-a(x,y):a(x,y)=n:nu=nu+1:pt=pt(n):b=kv(x)+uv(y):bs=lv(x)+vv(y)
1620 rn(y)=rn(y)-pt:cn(x)=cn(x)-pt:bn(b)=bn(b)-pt
1630 rc(