home *** CD-ROM | disk | FTP | other *** search
- 1 rem "petals.bas" 2003.07.14
- 2 poke55,0:poke56,56:clr:gosub3002
- 10 rem --- play new game
- 12 q=0:p=1:n=13:cc%=47:fora=0to12:x=x%(a,1):gosub620:a%(a,0)=-1:next
- 14 rem --- next move
- 16 o=p:p=1-p:m=2:cc%=102:x=y%(o,1):gosub620:cc%=230:x=y%(p,1):gosub620
- 18 rem --- input
- 20 sysml+9:ifcr%>0theni%=cr%:goto28
- 22 ifl2%thenonp%(p)goto36
- 24 ifr2%theni=1-p:gosub614:i=p:gosub614:goto30
- 26 sysml+60,"qp12":ifi%=0then30
- 28 oni%goto40000,10,34,34
- 30 onqgoto20:onp%(p)goto20
- 32 gosub302:goto50
- 34 i=i%-3:gosub614:goto20
- 36 rem --- human
- 38 ifsc%=32then20
- 40 ifsc%=13thenonmgoto14,20
- 42 ifm=1thenifa=sc%then14
- 44 ifnota%(sc%,0)then20
- 46 ifm=1thenifa%(a,1)<>sc%anda%(a,2)<>sc%then20
- 48 a=sc%:gosub608:ifmthenifa%(a%(a,1),0)ora%(a%(a,2),0)then20
- 50 rem --- results
- 52 ifnthen14
- 54 q=1:goto18:rem win
- 300 :
- 302 : rem computer :
- 304 ifm=1then464:human move
- 306 ifn=13theni%=13*rnd(0):a=i%:i%=2*rnd(0):m=i%+1:goto458:1st move
- 308 rem --- find groups
- 310 i=0:j=-1:k=0
- 312 ifa%(i,0)=jthen318
- 314 ifj=0thenb%(0,0)=i:b%(0,2)=0:goto322:1st occupied petal
- 316 j=0
- 318 i=a%(i,2)
- 320 goto312
- 322 ifa%(i,0)thenb%(k,1)=i:b%(k,2)=b%(k,2)+1:goto334
- 324 k=k+1
- 326 i=a%(i,2)
- 328 ifi=b%(0,0)then340:found
- 330 ifa%(i,0)thenb%(k,0)=i:b%(k,2)=0:goto322
- 332 goto326
- 334 i=a%(i,2)
- 336 ifi=b%(0,0)then340:found
- 338 goto322
- 340 rem --- one group
- 342 ifk=1thenh=0:m=2-(nand1):goto440
- 344 rem ---
- 346 i=k-1:h=i:j=i
- 348 i=i-1
- 350 ifb%(i,2)>b%(h,2)thenh=i
- 352 ifb%(i,2)<b%(j,2)thenj=i
- 354 ifi>0then348
- 356 m=1:rem if loss take 1 from largest
- 358 if(kand1)=1then400
- 360 rem --- two,four or six groups
- 362 ifb%(h,2)=b%(j,2)then440:loss
- 364 ifk=6then398
- 366 l=b%(h,2)-b%(j,2)
- 368 ifl>2then398
- 370 ifk=2then396
- 372 i=k:l1%=0:l2%=0:r1%=0:r2%=0
- 374 i=i-1
- 376 ifb%(i,2)=b%(h,2)thenl1%=l1%+1:goto386
- 378 ifb%(i,2)=b%(j,2)thenl2%=l2%+1:goto386
- 380 ifr1%=0theni%=i:r1%=b%(i,2):goto386
- 382 ifb%(i,2)=r1%thenr1%=r1%+1:goto386
- 384 r2%=b%(i,2)
- 386 ifi>0then374
- 388 ifl1%=2andl2%=2then440:loss
- 390 ifr1%=1andr2%=1then440:loss
- 392 ifl1%=2andl2%=1thenh=i%:l=1:goto396
- 394 ifl1%=1andl2%=2thenl=1
- 396 a=b%(h,0):m=l:goto458
- 398 m=1+(b%(h,2)and1):goto440
- 400 rem --- three or five groups
- 402 ifb%(h,2)=1thenm=1:goto440:all 1
- 404 ifb%(h,2)=2thenifb%(j,2)=2thenm=2:goto440:all 2
- 406 ifb%(h,2)=b%(j,2)then440:loss
- 408 i=k:l1%=0:l2%=0:i%=-1
- 410 i=i-1
- 412 ifb%(i,2)=b%(h,2)thenl1%=l1%+1:goto418
- 414 ifb%(i,2)=b%(j,2)thenl2%=l2%+1:goto418
- 416 i%=i:rem only for 3 groups
- 418 ifi>0then410
- 420 ifk=5then436
- 422 ifl1%=1then428
- 424 ifb%(j,2)>2then440:loss
- 426 h=j:goto438:l1%=2, l2%=1
- 428 ifi%=-1then438
- 430 l=b%(h,2)-b%(j,2)-b%(i%,2)
- 432 ifl=1orl=2thena=a%(b%(h,0),2):m=l:goto458
- 434 goto440:loss
- 436 ifl1%=2andl2%=3thenh=j:rem b%(h,2)=1
- 438 m=2-(b%(h,2)and1)
- 440 rem --- 1st petal
- 442 i%=(b%(h,2)-1)/2
- 444 oni%goto448,450,452,454,456
- 446 a=b%(h,0):goto458
- 448 a=a%(b%(h,0),2):goto458
- 450 a=a%(a%(b%(h,0),2),2):goto458
- 452 a=a%(a%(a%(b%(h,0),2),2),2):goto458
- 454 a=a%(a%(a%(a%(b%(h,0),2),2),2),2):goto458
- 456 a=a%(a%(a%(a%(a%(b%(h,0),2),2),2),2),2)
- 458 rem --- move
- 460 gosub602
- 462 ifm=1thena=a%(a,2):gosub602
- 464 return
- 600 :
- 602 : rem move pointer :
- 604 sysml+24,15:sysml+21,x%(a,0),y%(a,0):sysml+24,30:gosub608:return
- 606 :
- 608 : rem clear marker :
- 610 cc%=255:x=x%(a,1):gosub620:a%(a,0)=0:m=m-1:n=n-1:return
- 612 :
- 614 : rem toggle player :
- 616 p%(i)=1-p%(i):pokesp+2+i,i%(p%(i)):pokev+41+i,i%(p%(i)+2):return
- 618 :
- 620 : rem paint 2x2 block :
- 622 pokex,cc%:pokex+1,cc%:pokex+40,cc%:pokex+41,cc%
- 624 return
- 3000 :
- 3002 : rem init :
- 3006 dim cc%,cr%,cx%,cy%,i%,l1%,l2%,pp%,px%,py%,r1%,r2%,rg%,sc%
- 3010 dim a,d,gs,h,i,j,k,l,m,ml,mm,mv,n,o,p,pb,pc,sc,sp,q,v,x
- 3020 dim a%(12,2),b%(5,2),i%(3),p%(1),x%(12,1),y%(12,1)
- 3038 v=53248:d=peek(186):ifd<8thend=8
- 3040 deffnpx(x)=x*sin(a)+160.5
- 3042 deffnpy(x)=x*cos(a)+100.5
- 3100 rem --- font
- 3102 gosub3502
- 3104 rem --- player sprites i%(0+p) - ptr; i%(2+p) - color
- 3106 gosub3502:i%(0)=1:i%(1)=2:i%(2)=6:i%(3)=10
- 3108 rem --- grafscripter
- 3110 gosub3502:gs=x:sc=39936:pb=96:pc=92
- 3112 rem --- mouse
- 3114 gosub3502:ml=x:mv=x+156:pokemv+1,203
- 3116 gosub3502:mm=x:pokemm+9,0
- 3118 poke53280,6:poke53281,6:poke53282,15:rem colors
- 3196 rem --- colors
- 3198 poke53280,6:poke53281,6:poke53282,15
- 3200 rem --- x%() & y%() are pixel x,y
- 3202 sysgs,pb,pc:rem open
- 3204 sysgs+3,5:rem mode
- 3206 poke53265,11
- 3208 a=0:i=2*(NULL)/13
- 3210 forj=0to12:a=a+i
- 3212 x%(j,0)=fnpx(32):y%(j,0)=fnpy(24):x%(j,1)=fnpx(120):y%(j,1)=fnpy(90)
- 3214 next
- 3216 i=1:cc%=1:gosub3514
- 3218 sysgs+27,160,100,cc%:rem fill
- 3220 i=0:cc%=0:gosub3514
- 3222 sysgs+27,160,100,cc%
- 3224 forj=0to12
- 3226 sysgs+6,x%(j,0),y%(j,0),cc%:rem plot
- 3228 sysgs+9,x%(j,1),y%(j,1),cc%:rem line
- 3230 next
- 3232 rem ---
- 3234 syssc,pb,pc,56
- 3236 syssc+3,"[154]"
- 3238 syssc+6,17,0,"[181][182][183][184][185][186]"
- 3240 syssc+3,"[158]"
- 3242 f$="[187][187][187][187][187][187][187][187]"
- 3244 syssc+6,18,10,left$(f$,4):syssc+6,17,11,left$(f$,6)
- 3246 syssc+6,17,12,left$(f$,6)
- 3248 syssc+6,17,13,left$(f$,6):syssc+6,18,14,left$(f$,4)
- 3250 rem ---
- 3254 rem x%(,0) & y%(,0) are char x,y for markers
- 3255 rem x%(,1) is color memory address for markers (address < 32768)
- 3256 rem y%(0,1) is color memory address for p0 move (address < 32768)
- 3257 rem y%(1,1) is color memory address for p1 move (address < 32768)
- 3258 rem screen codes @ 1024 mark petals (0-12), center(13) & n/a(32)
- 3259 sysml+30,0,39,0,24,32,14:rem n/a
- 3260 syssc+3,"[155][151]"
- 3262 l=8
- 3264 fori=1to4
- 3266 readcx%,cy%,f$
- 3268 gosub3524
- 3270 next
- 3271 syssc+3,"[155]"
- 3272 l=2:f$="[188][189][190][191]"
- 3274 fori=0to12
- 3276 readx%(i,0),y%(i,0)
- 3278 cx%=x%(i,0):cy%=y%(i,0):gosub3530
- 3280 x%(i,1)=pc*256+cy%*40+cx%
- 3282 next
- 3283 syssc+3,""
- 3284 l=2:f$="[177][178][179][180]":cx%=35:cy%=4
- 3286 fori=0to1
- 3288 cx%=38-cx%
- 3290 gosub3530
- 3292 y%(i,1)=pc*256+cy%*40+cx%
- 3294 next
- 3384 fori=0to12
- 3386 readpp%:x=1024+pp%
- 3388 readi%:ifi%>-1thenx=x+i%:pokex,i:goto3388
- 3390 next
- 3392 i=13
- 3394 sysml+30,18,21,10,14,i,14
- 3396 sysml+30,17,17,11,13,i,14:sysml+30,22,22,11,13,i,14
- 3400 rem --- spr ptr @ colormappg*256+1016
- 3402 sysml+6,64*256
- 3404 sp=pc*256+1016:pokesp,0:pokesp+1,0
- 3406 pokev+37,2:pokev+38,9:pokev+28,12
- 3408 pokev+4,60:pokev+5,53:pokev+6,60:pokev+7,53:pokev+16,8
- 3410 p%(0)=0:p%(1)=1:fori=0to1:gosub614:next
- 3416 fori=0to12:reada%(i,1),a%(i,2):next
- 3418 sysmm:sysml:sysml+18,0,38,0,22:pokev+21,15
- 3420 poke53265,59
- 3422 return
- 3500 :
- 3502 : rem bload :
- 3506 readl,h,f$:x=l+h*256
- 3508 rem sys57812f$,d,0:poke780,0:poke781,l:poke782,h:sys65493
- 3510 return
- 3512 :
- 3514 : rem circle :
- 3516 sysgs+6,x%(12,i),y%(12,i),cc%
- 3518 forj=0to12:sysgs+9,x%(j,i),y%(j,i),cc%:next
- 3520 return
- 3522 :
- 3524 : rem region :
- 3526 gosub3530:sysml+15,i,cx%,cx%+l-1,cy%,cy%+i%:return
- 3528 :
- 3530 : rem print block :
- 3532 i%=len(f$)/l-1:forh=0toi%:syssc+6,cx%,cy%+h,mid$(f$,h*l+1,l):next:return
- 9000 :
- 9002 data 000, 056, f.petals
- 9004 data 064, 064, spr.petals
- 9006 data 000, 144, grafscripter
- 9008 data 000, 192, mouse2.1 jr c000
- 9010 data 000, 202, mouse mate ca00
- 9101 data 32,22," [[209]]uit "
- 9102 data 0,22," [[208]]lay "
- 9103 data 0, 0," [1] "
- 9104 data 32, 0," [2] "
- 9106 data 26,18, 30,15, 31,10, 28,07, 24,04, 19,03, 14,04, 10,07
- 9114 data 07,10, 08,15, 12,18, 16,20, 22,20
- 9206 data 623,0,41,1,39,1,1,1,38,1,1,1,1,37,1,1,1,37,1,1,-1
- 9207 data 585,0,1,1,1,1,1,1,1,1,34,1,1,1,1,1,37,1,1,1,39,-1
- 9208 data 393,0,36,1,1,1,1,33,1,1,1,1,1,1,1,32,1,1,1,1,1,1,1,1,-1
- 9209 data 229,0,39,1,1,37,1,1,1,1,35,1,1,1,1,1,34,1,1,1,36,-1
- 9210 data 144,0,1,1,37,1,1,1,1,1,35,1,1,1,37,1,1,37,1,1,38,1,39,-1
- 9211 data 97,0,1,1,1,1,1,36,1,1,1,37,1,1,1,37,1,1,1,38,1,39,1,39,1,-1
- 9212 data 133,0,1,1,36,1,1,1,1,1,37,1,1,1,38,1,1,39,1,1,39,1,40,-1
- 9213 data 210,0,39,1,1,37,1,1,1,1,36,1,1,1,1,1,38,1,1,1,41,-1
- 9214 data 366,0,40,1,1,1,1,36,1,1,1,1,1,1,1,33,1,1,1,1,1,1,1,1,-1
- 9215 data 566,0,1,1,1,1,1,1,1,1,33,1,1,1,1,1,35,1,1,1,38,-1
- 9216 data 616,0,38,1,37,1,1,1,35,1,1,1,1,36,1,1,1,38,1,1,-1
- 9217 data 658,0,1,38,1,1,38,1,1,37,1,1,1,36,1,1,1,1,36,1,1,1,1,37,1,1,1,-1
- 9218 data 660,0,1,39,1,1,38,1,1,38,1,1,1,37,1,1,1,1,36,1,1,1,1,36,1,1,1,-1
- 9300 data 12,1, 0,2, 1,3, 2,4, 3,5, 4,6, 5,7, 6,8, 7,9, 8,10, 9,11, 10,12, 11,0
- 9999 :
- 10000 d=8:f$="0:petals.bas":open15,d,15,"s"+f$:close15:savef$,d:end
- 40000 pokev+21,0:print"[147]";:sysgs+3,4:sysml+3:sysmm+3:poke53280,14:poke646,14
- 40004 fori=8to29:poke820+i,i:next:ifd>8andd<30thenpoke828,d:poke820+d,8
- 40010 f$="presenter":gosub40030:f$="hello connect":gosub40030
- 40020 poke186,8:poke2048,0:poke44,8:poke43,1:poke56,160:poke55,0:clr:new
- 40030 forj=8to29:i=peek(820+j):ifi=14thennext
- 40040 close2:open2,i,2:close2:ifstthen40060
- 40050 close15:open15,i,15,"r0:"+f$+"="+f$:input#15,er:close15:ifer=63then40070
- 40060 next:return
- 40070 f$="hello connect":q$=chr$(34):poke646,peek(53281)
- 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$f$q$","i
- 40090 print"run:":poke631,13:poke632,13:poke198,2:end
-