home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1989 November & December
/
rerun-1989-11-12.d64
/
wraparound
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
103 lines
10 rem---wraparound-t. brantner
20 printchr$(8)chr$(142)
30 fora=0to62:poke832+a,0:readz:poke896+a,z:next
40 fora=5to12:poke833+a*3,255:next:clr
50 sp$="":tt$="wraparound":bl$=" [170][157][157][157] [170][157][157][157][175][175][186]"
60 tc=646:v=53248:s1=54272:s2=s1+7:j2=56320:z=rnd(-ti)
70 gosub640:pokev+39,1:pokev+21,1:r=0:c=0
80 rem---move cursor
90 poke2040,13
100 pokev+1,84+r*24:pokev,23+le*8+c*24
110 ifpeek(203)=3then320
120 js=peek(j2):if(jsand16)=0thengosub620:goto190
130 js=jsand15:ifjs=14andrthenr=r-1
140 ifjs=13andr<nrthenr=r+1
150 ifjs=11andcthenc=c-1
160 ifjs=7andc<ncthenc=c+1
170 goto100
180 rem---shift puzzle
190 poke2040,14
200 ifpeek(203)=3then320
210 js=peek(j2):if(jsand16)=0thengosub620:goto90
220 js=jsand15:jd=-(js=14)-2*(js=7)-3*(js=13)-4*(js=11):ifjd=0then200
230 onjdgosub400,500,430,470
240 onjdgosub580,540,580,540
250 pokes2+4,128:pokes2+4,129
260 mn=mn+1:gosub800
270 ifsp$<>mp$then200
280 rem---puzzle solved
290 pokes1+4,17
300 fora=1to4:forz=12to0step-1:poke53280,z:pokes1+1,z*5:foraa=0toz*3:next
310 next:next:pokes1+4,16
320 pokev+21,0
330 cy=8+nr*3:cx=13:ifsp$=mp$thencx=5:gosub380:print"[158]puzzle solved...":cx=21
340 gosub380:print"[158]try another? ";:a$="yn":gosub930
350 ifan=1thenrun50
360 sys2048
370 rem---plot
380 poke214,cy-1:print:printtab(cx);:return
390 rem---shift up
400 z=peek(sp+c):fora=1tonr:pokesp+(a-1)*cn+c,peek(sp+a*cn+c):next
410 pokesp+nr*cn+c,z:return
420 rem---shift down
430 z=peek(sp+nr*cn+c)
440 fora=nr-1to0step-1:pokesp+(a+1)*cn+c,peek(sp+a*cn+c):next
450 pokesp+c,z:return
460 rem---shift left
470 z=peek(sp+r*cn):fora=1tonc:pokesp+r*cn+a-1,peek(sp+r*cn+a):next
480 pokesp+r*cn+nc,z:return
490 rem---shift right
500 z=peek(sp+r*cn+nc)
510 fora=nc-1to0step-1:pokesp+r*cn+a+1,peek(sp+r*cn+a):next
520 pokesp+r*cn,z:return
530 rem---print row
540 cy=4+r*3:cx=le:gosub380
550 fora=0tonc:poketc,peek(sp+r*cn+a):printbl$"[145][145]";:next
560 return
570 rem---print column
580 cy=4:cx=le+c*3:gosub380
590 fora=0tonr:poketc,peek(sp+a*cn+c):printbl$"[157][157][157]";:next
600 return
610 rem---beep
620 pokes1+1,30:pokes1+4,17:fora=1to200:next:pokes1+4,16:waitj2,16:return
630 rem---initialize
640 fora=s1tos1+23:pokea,0:next
650 pokes1+5,8:pokes1+6,240
660 pokes2+1,80:pokes2+5,2:pokes1+24,15
670 poke53280,0:poke53281,0:gosub890
680 poke214,3:print:printtab(10)"[154]number of rows ";
690 a$="3456":gosub930:nr=an+1
700 print:printtab(10)"[158]number of columns ";
710 gosub930:nc=an+1:cn=an+2
720 print:printtab(10)"how many colors? ";:a$="23456":gosub930:co=an+2
730 rem---screen
740 z=2:fora=1to(nr+1)*(nc+1):sp$=sp$+chr$(z):z=z+1:ifz>cothenz=2
750 next
760 a=peek(45)+256*peek(46):sp=peek(a+3)+256*peek(a+4)
770 gosub890:le=21:gosub830:mp$=sp$
780 le=16-nc*3:gosub830
790 cy=8+nr*3:cx=15:gosub380:print"[158]f7 to quit"
800 cy=2:cx=14:gosub380:print"[154]moves "right$("0000"+mid$(str$(mn),2),5)
810 return
820 rem---scramble pattern
830 fora=0tolen(sp$)-1
840 z=int(rnd(1)*len(sp$))
850 aa=peek(sp+a):pokesp+a,peek(sp+z):pokesp+z,aa
860 next
870 forr=0tonr:gosub540:next:return
880 rem---title
890 print"[147]"tab(10);
900 fora=1tolen(tt$):poketc,rnd(1)*6+2:printmid$(tt$,a,1)"[170]";:next
910 print:return
920 rem---joystick input
930 an=1:poketc,1
940 print" [157]";:fora=1to80:next:printmid$(a$,an,1)"[157]";:fora=1to80:next
950 js=peek(j2):if(jsand16)=0thenprint:gosub620:return
960 js=jsand15
970 ifjs=14andan>1thenan=an-1
980 ifjs=13andan<len(a$)thenan=an+1
990 goto940
1000 data0,24,0,0,60,0,0,126,0,0,24,0,0,24,0,0,24,0,16,24,8,48,0,12,127
1010 data0,254,127,0,254,48,0,12,16,24,8,0,24,0,0,24,0,0,24,0,0,126,0,0,60,0
1020 data0,24,0,0,0,0,0,0,0,0,0,0