home *** CD-ROM | disk | FTP | other *** search
- 1 rem "knights basic" 2000.09.21
- 2 poke55,0:poke56,55:clr
- 3 gosub3002
- 4 gosub12:onq%goto4002
- 5 q%=3:gosub102:onq%goto4002,5,6,6,4
- 6 ono%(0,0)gosub12,160:onq%goto4002,5
- 7 gosub174:onq%goto4002,5,5,5,4
- 10 :
- 12 : rem input
- 14 :
- 16 pokevl+39,1:rem ready
- 18 sysml+9:i%=cr%:on1+(i%=0)goto22:sysml+60,"pehq":on1+(i%=0)goto22
- 20 ono%(0,0)goto18,26
- 22 ifi%<5thenoni%gosub502,522,574,590:onq%goto28,28:ono%(0,0)goto18,26
- 24 ifo%(0,0)thengosub144:ifb%=-1then18
- 26 ifq%=5then18
- 28 pokevl+39,7:rem busy
- 30 return
- 100 :
- 102 : rem next move
- 104 :
- 106 a%=-1:b%=-1
- 108 rem --- color
- 110 p%=1-p%:cy%=ys%+6:gosub128:a$=c$(p%):poke646,c%(6+p%):gosub136:poke646,c%(2)
- 112 rem --- move #
- 114 m%=m%+1:cy%=ys%+8:a$="[205]ove"+right$(" "+str$(m%),4):gosub136
- 116 rem --- ? moves
- 118 c%=g%(0)org%(1)
- 120 n%=0:fori=0to1:forj=0to1:n%=n%-((d%(b%(a%(p%,i),j))andc%)=0):next:next
- 122 ifn%=0thenq%=5:a$="[206]o [205]oves":gosub212
- 124 return
- 126 :
- 128 : rem clear status block line
- 130 :
- 132 l%=17:sysml+30,xs%,xs%+l%-1,cy%,cy%,160,c%(1):return
- 134 :
- 136 : rem update status block line
- 138 :
- 140 sysml+12,fnxc(xs%),cy%,a$:return
- 142 :
- 144 : rem check move
- 146 :
- 148 c%=i%-5
- 150 ifa%=-1thenf%=((g%(p%)andd%(c%))<>0):a%=a%+(a%-c%)*f%:on2+f%gosub204:goto156
- 152 ifc%=a%thenf%=0:gosub204:a%=-1:goto156:rem cancel
- 154 b%=c%+(c%-b%)*(fnb(c%)<>0or(b%(a%,0)<>c%andb%(a%,1)<>c%))
- 156 return
- 158 :
- 160 : rem a solution
- 162 :
- 164 c%=z%(m%-1)andz%(m%+1):a%=fnl2(z%(m%-1)-c%):b%=fnl2(z%(m%+1)-c%)
- 166 sysml+21,fnx(a%)+1,fny(a%)+1:sysml+24,o%(2,0):f%=-1:gosub204
- 168 sysml+21,fnx(b%)+1,fny(b%)+1:sysml+24,o%(2,0)
- 170 return
- 172 :
- 174 : rem display move results
- 176 :
- 178 n%=1+(a%(p%,0)=a%):gosub190:f%=0:gosub204
- 180 a%(p%,n%)=b%:g%(p%)=fng(g%(p%))
- 182 ifg%(0)=w%(0)andg%(1)=w%(1)thena$="[211]olved":gosub212:goto186
- 184 ifm%=o%(1,0)thena$="[206]ot [211]olved in"+str$(m%):gosub212
- 186 return
- 188 :
- 190 : rem position knight
- 192 :
- 194 i%=2+p%*2+n%:cx%=fnx(b%):cy%=fny(b%)
- 196 py%=cy%*8+52:px%=cx%*8+24:c%=0:ifpx%>255thenpx%=px%-256:c%=b%(i%)
- 198 pokevl+i%*2,px%:pokevl+i%*2+1,py%:pokevl+16,c%
- 200 return
- 202 :
- 204 : rem region "a" highlight on(f%=-1); off(f%=0)
- 206 :
- 208 c%=c%(8+(a%andd%(0))):c%=c%+(c%-c%(0))*f%:sysml+36,a%+5,255,c%:return
- 210 :
- 212 : rem game over
- 214 :
- 216 q%=5:poke646,c%(5):cy%=ys%+10:gosub136:poke646,c%(2)
- 218 return
- 500 :
- 502 : rem play new game
- 504 :
- 506 q%=2:gosub510:m%=0:p%=1:cy%=ys%+10:gosub128:return
- 508 :
- 510 : rem new board
- 512 :
- 514 a%(0,0)=1:a%(0,1)=3:a%(1,0)=5:a%(1,1)=7:g%(0)=w%(1):g%(1)=w%(0)
- 516 fori=0to1:p%=i:forj=0to1:n%=j:b%=a%(i,j):gosub190:next:next
- 518 return
- 520 :
- 522 : rem edit setup
- 524 :
- 526 gosub632
- 528 sysml+42,hs%:pokemv,ls%:pokemv+2,9
- 530 n%=0
- 532 sysml+9:ifcr%=0thensysml+60,"q":oni%+1goto532,564
- 534 ifcr%=9then564
- 536 ifcr%<7then548
- 538 i=cr%-7
- 540 w$=n$(i):sysml+156,p%(i,3)+128,p%(i,4),c%(1),c%(1),p%(i,2),0,"[145]",n$(i)
- 542 ifn$(i)=w$then532
- 544 n%=n%ord%(i+3)
- 546 n$(i)=w$:goto532
- 548 forj=0to2:i=2-j:f%=(cr%>=o%(i,1)):j=j+(j-2)*f%:next
- 550 ifo%(i,2)=cr%then532
- 552 n%=n%ord%(i)
- 554 i%=o%(i,2):gosub3540:i%=cr%:gosub3552:f%=cr%-o%(i,1):o%(i,2)=cr%
- 556 onigoto560,562
- 558 o%(i,0)=f%+1:goto532
- 560 o%(i,0)=999-983*f%:goto532
- 562 o%(i,0)=60+180*f%:goto532
- 564 sysml+39,hs%:gosub640
- 566 ifn%>0thengosub608
- 568 if(n%andd%(0))<>0thenfori=6to8step2:cy%=ys%+i:gosub128:next:gosub502:q%=5
- 570 return
- 572 :
- 574 : rem help
- 576 :
- 578 gosub632
- 580 sysml+42,hh%:pokemv,lh%:pokemv+2,6
- 582 sysml+210,1+128,38,3,18,c%(2),0,c%(4),c%(5),0,"",""
- 584 gosub640
- 586 return
- 588 :
- 590 : rem quit
- 592 :
- 594 gosub632
- 596 sysml+42,hq%:pokemv,lq%:pokemv+2,2
- 598 sysml+9:i%=cr%:ifi%=0thensysml+60,"ny":ifi%=0then598
- 600 ifi%=2thenq%=1:goto604
- 602 gosub640
- 604 return
- 606 :
- 608 : rem new setup
- 610 :
- 612 rem --- solution
- 614 if(n%andd%(0))=0then620
- 616 cy%=ys%+2:a$=n$(o%(0,0)-1):gosub128:gosub136
- 618 cy%=ys%+3:a$=t$(o%(0,0)-1):gosub128:gosub136
- 620 rem --- name(s)
- 622 fori=0to1:if(n%andd%(i+3))=0then626
- 624 ifi=o%(0,0)-1thency%=ys%+2:a$=n$(i):gosub128:gosub136
- 626 next
- 628 return
- 630 :
- 632 : rem stash game screen
- 634 :
- 636 pokevl+21,3:sysml+39,hg%:return
- 638 :
- 640 : rem restore game screen
- 642 :
- 644 sysml+42,hg%:pokemv,lg%:pokemv+2,14:pokevl+21,63:return
- 3000 :
- 3002 : rem initialize
- 3004 :
- 3006 x=0:dv=peek(186)
- 3008 rem --- dim
- 3010 dim a%,b%,c%,cc%,cr%,cx%,cy%,f%,h%,hg%,hh%,hr%,hs%,hq%
- 3012 dim i%,l%,l1%,l2%,lg%,lh%,ls%,lq%,m%,n%,p%,pp%,px%,py%,q%
- 3014 dim r1%,r2%,rg%,sc%,sl%,xb%,xs%,yb%,ys%
- 3016 dim cl,i,j,ml,mm,mv,vl,a$,f$,w$
- 3018 dim a%(1,1),b%(7,1),c%(9),d%(7),g%(1),o%(2,2),p%(1,4),w%(1),z%(17)
- 3020 dim c$(1),n$(1),t$(1)
- 3022 rem --- deffn
- 3024 def fnb(x)=((g%(0)org%(1))andd%(x))
- 3026 def fnl2(x)=log(x)/log(2)
- 3028 def fng(x)=x-d%(a%)+d%(b%)
- 3030 def fnx(x)=peek(hr%*256+(x+4)*4)+1
- 3032 def fny(x)=peek(hr%*256+(x+4)*4+2)+1
- 3034 def fnxc(x)=x+(l%-len(a$))/2
- 3036 rem --- sprites
- 3038 readf%,a$,h%,l%
- 3040 iff%thengosub3502
- 3042 rem --- font
- 3044 readf%,a$,h%,l%
- 3046 iff%thengosub3502
- 3048 rem --- mouse
- 3050 readf%,a$,h%,l%
- 3052 iff%thengosub3502
- 3054 ml=h%*256+l%
- 3056 mv=ml+309
- 3058 hr%=97:pokemv+1,hr%
- 3060 lg%=0:lh%=lg%+12*4:ls%=lh%+6*4:lq%=ls%+9*4:rem region low bytes
- 3062 hg%=224:hh%=232:hs%=240:hq%=248:rem stash pages
- 3064 n%=98:fori=42to49:n%=n%+1:pokemv+i,n%:next
- 3066 rem --- mouse mate
- 3068 readf%,a$,h%,l%
- 3070 iff%thengosub3502
- 3072 mm=h%*256+l%
- 3074 pokemm+9,0:rem disable stop
- 3076 rem --- curtain
- 3078 readf%,a$,h%,l%
- 3080 iff%thengosub3502
- 3082 cl=h%*256+l%
- 3084 rem --- help text
- 3086 readf%,a$,h%,l%
- 3088 i=h%*256+l%
- 3090 iff%thensysml+201,a$,dv,i
- 3092 sysml+204,i
- 3094 rem --- vic location
- 3096 vl=53248
- 3098 rem ---
- 3100 w%(0)=160:w%(1)=10
- 3102 c$(0)="[215]hite [203]night":c$(1)="[194]lack [203]night"
- 3104 t$(0)="([200]uman)":t$(1)="([195]omputer)"
- 3106 fori=0to7:forj=0to1:readb%(i,j):next:next
- 3108 fori=0to7:readd%(i):next
- 3110 fori=0to17:readz%(i):next
- 3112 fori=0to9:readc%(i):next
- 3114 rem --- screen off
- 3116 pokevl+17,11
- 3118 rem --- font
- 3120 pokevl+24,31
- 3122 rem --- setup screen
- 3124 pokemv,ls%:pokevl+32,c%(2):pokevl+33,c%(4)
- 3126 sysml+126,0,39,0,24,92,94,c%(2),c%(0):sysml+30,5,34,2,19,160,c%(0)
- 3128 poke646,c%(0):poke199,1
- 3130 readcy%,a$:sysml+27,cy%,a$
- 3132 fori=1to3:readcx%,cy%,a$:sysml+12,cx%,cy%,a$:next
- 3134 fori=1to6:i%=i:readcx%,cy%,l%,a$:gosub3524:next
- 3136 l%=16:fori=0to1:i%=7+i:readcx%,cy%,a$:gosub3524
- 3138 p%(i,2)=l%-1:p%(i,3)=cx%:p%(i,4)=cy%:n$(i)=a$:next
- 3140 l%=8:i%=9:readcx%,cy%,a$:gosub3510:gosub3540
- 3142 fori=0to2:reado%(i,0),o%(i,1),o%(i,2):i%=o%(i,2):gosub3548:next
- 3144 poke199,0
- 3146 sysml+39,hs%
- 3148 rem --- quit screen
- 3150 pokemv,lq%:pokevl+32,c%(2):pokevl+33,c%(4)
- 3152 sysml+126,0,39,0,24,92,94,c%(2),c%(0):sysml+30,10,29,6,15,160,c%(0)
- 3154 poke646,c%(0):poke199,1
- 3156 readcy%,a$:sysml+27,cy%,a$
- 3158 l%=7:fori=1to2:i%=i:readcx%,cy%,a$:gosub3510:gosub3540:next
- 3160 poke199,0
- 3162 sysml+39,hq%
- 3164 rem --- help screen
- 3166 pokemv,lh%:pokevl+32,c%(0):pokevl+33,c%(1)
- 3168 sysml+30,0,39,0,24,160,c%(0):sysml+30,0,39,2,19,160,c%(4)+16
- 3170 poke646,c%(0):poke199,1:readcy%,a$:sysml+27,cy%,a$:poke199,0
- 3172 sysml+228,1024+40*cy%+19,1024+40*cy%+27,0
- 3174 poke646,c%(3):l%=8:fori=1to4:i%=i:readcx%,cy%,a$:gosub3510:next
- 3176 sysml+39,hh%
- 3178 rem --- game screen
- 3180 pokemv,lg%:pokevl+32,c%(0):pokevl+33,c%(1)
- 3182 sysml+30,0,39,0,24,160,c%(0)
- 3184 xs%=23:ys%=1:sysml+30,xs%,xs%+16,ys%,ys%+11,160,c%(1)
- 3186 poke646,c%(2)
- 3188 sysml+12,4,23," [171][172][173][174][175][176][175][176][177][178][165][166][163][164][167][168][146] [161][162][163][164][165][166][167][168][169][170][171][172][173][174][146] "
- 3190 sysml+12,4,24," [179][180][181][182][183][184][183][184][185][186][179][180][177][178][181][182][146] [175][176][177][178][179][180][181][182][183][184][185][186][187][188][146] "
- 3192 poke646,c%(3):l%=8:fori=1to4:i%=i:readcx%,cy%,a$:gosub3510:next
- 3194 xb%=3:yb%=4:sysml+126,xb%-3,xb%+17,yb%-3,yb%+17,92,94,c%(2),c%(0)
- 3196 fori=0to7:readcx%,cy%:sysml+15,5+i,cx%,cx%+4,cy%,cy%+4:next
- 3198 fori=0to7:sysml+36,5+i,160,c%(8+(iandd%(0))):next
- 3200 poke646,c%(2):gosub502:q%=5:n%=31:gosub608
- 3202 sysml+39,hg%
- 3204 rem --- title screen
- 3206 pokevl+32,c%(0)
- 3208 pokevl+33,c%(1)
- 3210 sysml+126,0,39,0,24,92,94,c%(0),c%(2)
- 3212 sysml+30,3,36,5,13,160,c%(4)+16
- 3214 poke646,c%(3)
- 3216 sysml+12,4,6,"[171][172][173][174][175][176][175][176][177][178][165][166][163][164][167][168][146] [161][162][163][164][165][166][167][168][169][170][171][172][173][174][146]"
- 3218 sysml+12,4,7,"[179][180][181][182][183][184][183][184][185][186][179][180][177][178][181][182][146] [175][176][177][178][179][180][181][182][183][184][185][186][187][188][146]"
- 3220 poke646,c%(4)
- 3222 sysml+27,9,"by [204]ance [195]. [212]homas"
- 3224 sysml+27,11,"(c) 2000 [202][160]& [198] [208]ublishing, [201]nc."
- 3226 rem --- game
- 3228 syscl
- 3230 pokevl+17,27
- 3232 gosub3556
- 3234 syscl+6
- 3236 poke198,0:wait198,15:poke198,0
- 3238 syscl+9
- 3240 pokevl+17,11:sysml+42,hg%:pokevl+17,27
- 3242 gosub3556
- 3244 syscl+6
- 3246 syscl+3
- 3248 sysmm
- 3250 sysml
- 3252 sysml+6,55*256
- 3254 sysml+18,1,37,1,22
- 3256 gosub510
- 3258 poke2042,223:pokevl+41,c%(7)
- 3260 poke2043,223:pokevl+42,c%(7)
- 3262 poke2044,222:pokevl+43,c%(7)
- 3264 poke2045,222:pokevl+44,c%(7)
- 3266 pokevl+28,60:pokevl+37,c%(6):pokevl+38,4:pokevl+21,63
- 3268 poke646,c%(2)
- 3270 return
- 3272 :
- 3502 : rem bload file
- 3504 :
- 3506 sys57812a$,dv,0:poke780,0:poke781,l%:poke782,h%:sys65493:return
- 3508 :
- 3510 : rem command button
- 3512 :
- 3514 sysml+15,i%,cx%,cx%+l%-1,cy%,cy%+2
- 3516 sysml+30,cx%,cx%+l%-1,cy%,cy%+2,160,c%(1)
- 3518 sysml+12,fnxc(cx%),cy%+1,a$
- 3520 return
- 3522 :
- 3524 : rem setup region
- 3526 :
- 3528 sysml+15,i%,cx%,cx%+l%-1,cy%,cy%
- 3530 ifi%<7thensysml+12,fnxc(cx%),cy%,a$:goto3534
- 3532 sysml+12,cx%,cy%,a$
- 3534 gosub3540
- 3536 return
- 3538 :
- 3540 : rem region highlight off
- 3542 :
- 3544 sysml+36,i%,255,c%(1):return
- 3546 :
- 3548 : rem region highlight on
- 3550 :
- 3552 sysml+36,i%,255,c%(5):return
- 3554 :
- 3556 : rem pause
- 3558 :
- 3560 i=ti
- 3562 ifti>ithenifti-i<20then3562
- 3564 return
- 4000 :
- 4002 : rem *** exit
- 4004 :
- 4006 sysml+3
- 4008 pokevl+21,0
- 4010 sysmm+3
- 4012 poke646,11
- 4014 goto40000
- 9000 :
- 9002 : *** data
- 9004 :
- 9006 data 00,"spr.knights",55,128
- 9008 data 00,"f.knights",56,0
- 9010 data 00,"mouse2.1 7k 4000",64,0
- 9012 data 00,"mouse mate 6000",96,0
- 9014 data 00,"curtain 5c00",92,0
- 9016 data 00,"t.knights hlp",98,0
- 9018 rem ---
- 9020 data 3,5, 4,6, 5,7, 6,0, 7,1, 0,2, 1,3, 2,4
- 9022 data 1,2,4,8,16,32,64,128
- 9024 data 10,160,66,36,80,5,192,12,130,40,6,96,20,65,48,72,160,10
- 9026 rem --- colors
- 9028 data 12,15,11,6,0,2,1,0,2,10
- 9030 rem --- setup
- 9032 data 4,"[211]etup"
- 9034 data 8,7,"[211]olution [205]oves [208]ause"
- 9036 data 7,13,"[206]ame ([200]uman)"
- 9038 data 7,16,"[206]ame ([195]omputer)"
- 9040 data 7,8,10,"[200]uman",7,9,10,"[195]omputer"
- 9042 data 20,8,5,"999",20,9,5," 16"
- 9044 data 28,8,5,"2",28,9,5,"8"
- 9046 data 7,14,"[211]ir [216]",7,17,"[203]nees [195]alhoon"
- 9048 data 25,15,"[[209]]uit"
- 9050 data 1,1,1, 999,3,3, 60,5,5
- 9052 rem --- quit
- 9054 data 8,"[209]uit?"
- 9056 data 12,11,"[[206]]o ",21,11,"[[217]]es"
- 9058 rem --- help
- 9060 data 0,"[200]elp [204]ine #### of ####"
- 9062 data 1,21,"[[200][207][205][197]]",11,21,"[[213][208]]",21,21,"[[196][207][215][206]]",31,21,"[[209]]uit"
- 9064 rem --- game
- 9066 data 23,15,"[[208]]lay",23,19,"[[197]]dit",32,15,"[[200]]elp",32,19,"[[209]]uit"
- 9068 data 8,4, 13,4, 13,9, 13,14, 8,14, 3,14, 3,9, 3,4
- 9999 :
- 10000 a$="knights basic"
- 10010 dv=peek(186):open15,dv,15,"s0:"+a$:close15:savea$,dv:end
- 40000 fori=8to29:poke820+i,i:next:ifdv>8anddv<30thenpoke828,dv:poke820+dv,8
- 40010 a$="presenter":gosub40030:a$="hello connect":gosub40030
- 40020 print"[147]":poke53272,23:poke186,8:poke2048,0:poke44,8:poke43,1:end
- 40030 forj=8to29:i=peek(820+j):ifi=14thennext
- 40040 close2:open2,i,2:close2:ifstthen40060
- 40050 close15:open15,i,15,"r0:"+a$+"="+a$:input#15,er:close15:ifer=63then40070
- 40060 next:return
- 40070 a$="hello connect":q$=chr$(34):poke646,peek(53281):print"[147]":poke53272,23
- 40080 print"[147]p[207]2048,0:p[207]44,8:p[207]43,1:p[207]56,160:p[207]55,0:clr:l[207]"q$a$q$","i
- 40090 print"run:":poke631,13:poke632,13:poke198,2:end
-