home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1989 November & December / rerun-1989-11-12.d64 / wraparound (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  103 lines

  1. 10 rem---wraparound-t. brantner
  2. 20 printchr$(8)chr$(142)
  3. 30 fora=0to62:poke832+a,0:readz:poke896+a,z:next
  4. 40 fora=5to12:poke833+a*3,255:next:clr
  5. 50 sp$="":tt$="wraparound":bl$="  [170][157][157][157]  [170][157][157][157][175][175][186]"
  6. 60 tc=646:v=53248:s1=54272:s2=s1+7:j2=56320:z=rnd(-ti)
  7. 70 gosub640:pokev+39,1:pokev+21,1:r=0:c=0
  8. 80 rem---move cursor
  9. 90 poke2040,13
  10. 100 pokev+1,84+r*24:pokev,23+le*8+c*24
  11. 110 ifpeek(203)=3then320
  12. 120 js=peek(j2):if(jsand16)=0thengosub620:goto190
  13. 130 js=jsand15:ifjs=14andrthenr=r-1
  14. 140 ifjs=13andr<nrthenr=r+1
  15. 150 ifjs=11andcthenc=c-1
  16. 160 ifjs=7andc<ncthenc=c+1
  17. 170 goto100
  18. 180 rem---shift puzzle
  19. 190 poke2040,14
  20. 200 ifpeek(203)=3then320
  21. 210 js=peek(j2):if(jsand16)=0thengosub620:goto90
  22. 220 js=jsand15:jd=-(js=14)-2*(js=7)-3*(js=13)-4*(js=11):ifjd=0then200
  23. 230 onjdgosub400,500,430,470
  24. 240 onjdgosub580,540,580,540
  25. 250 pokes2+4,128:pokes2+4,129
  26. 260 mn=mn+1:gosub800
  27. 270 ifsp$<>mp$then200
  28. 280 rem---puzzle solved
  29. 290 pokes1+4,17
  30. 300 fora=1to4:forz=12to0step-1:poke53280,z:pokes1+1,z*5:foraa=0toz*3:next
  31. 310 next:next:pokes1+4,16
  32. 320 pokev+21,0
  33. 330 cy=8+nr*3:cx=13:ifsp$=mp$thencx=5:gosub380:print"[158]puzzle solved...":cx=21
  34. 340 gosub380:print"[158]try another? ";:a$="yn":gosub930
  35. 350 ifan=1thenrun50
  36. 360 sys2048
  37. 370 rem---plot
  38. 380 poke214,cy-1:print:printtab(cx);:return
  39. 390 rem---shift up
  40. 400 z=peek(sp+c):fora=1tonr:pokesp+(a-1)*cn+c,peek(sp+a*cn+c):next
  41. 410 pokesp+nr*cn+c,z:return
  42. 420 rem---shift down
  43. 430 z=peek(sp+nr*cn+c)
  44. 440 fora=nr-1to0step-1:pokesp+(a+1)*cn+c,peek(sp+a*cn+c):next
  45. 450 pokesp+c,z:return
  46. 460 rem---shift left
  47. 470 z=peek(sp+r*cn):fora=1tonc:pokesp+r*cn+a-1,peek(sp+r*cn+a):next
  48. 480 pokesp+r*cn+nc,z:return
  49. 490 rem---shift right
  50. 500 z=peek(sp+r*cn+nc)
  51. 510 fora=nc-1to0step-1:pokesp+r*cn+a+1,peek(sp+r*cn+a):next
  52. 520 pokesp+r*cn,z:return
  53. 530 rem---print row
  54. 540 cy=4+r*3:cx=le:gosub380
  55. 550 fora=0tonc:poketc,peek(sp+r*cn+a):printbl$"[145][145]";:next
  56. 560 return
  57. 570 rem---print column
  58. 580 cy=4:cx=le+c*3:gosub380
  59. 590 fora=0tonr:poketc,peek(sp+a*cn+c):printbl$"[157][157][157]";:next
  60. 600 return
  61. 610 rem---beep
  62. 620 pokes1+1,30:pokes1+4,17:fora=1to200:next:pokes1+4,16:waitj2,16:return
  63. 630 rem---initialize
  64. 640 fora=s1tos1+23:pokea,0:next
  65. 650 pokes1+5,8:pokes1+6,240
  66. 660 pokes2+1,80:pokes2+5,2:pokes1+24,15
  67. 670 poke53280,0:poke53281,0:gosub890
  68. 680 poke214,3:print:printtab(10)"[154]number of rows ";
  69. 690 a$="3456":gosub930:nr=an+1
  70. 700 print:printtab(10)"[158]number of columns ";
  71. 710 gosub930:nc=an+1:cn=an+2
  72. 720 print:printtab(10)"how many colors? ";:a$="23456":gosub930:co=an+2
  73. 730 rem---screen
  74. 740 z=2:fora=1to(nr+1)*(nc+1):sp$=sp$+chr$(z):z=z+1:ifz>cothenz=2
  75. 750 next
  76. 760 a=peek(45)+256*peek(46):sp=peek(a+3)+256*peek(a+4)
  77. 770 gosub890:le=21:gosub830:mp$=sp$
  78. 780 le=16-nc*3:gosub830
  79. 790 cy=8+nr*3:cx=15:gosub380:print"[158]f7 to quit"
  80. 800 cy=2:cx=14:gosub380:print"[154]moves  "right$("0000"+mid$(str$(mn),2),5)
  81. 810 return
  82. 820 rem---scramble pattern
  83. 830 fora=0tolen(sp$)-1
  84. 840 z=int(rnd(1)*len(sp$))
  85. 850 aa=peek(sp+a):pokesp+a,peek(sp+z):pokesp+z,aa
  86. 860 next
  87. 870 forr=0tonr:gosub540:next:return
  88. 880 rem---title
  89. 890 print"[147]"tab(10);
  90. 900 fora=1tolen(tt$):poketc,rnd(1)*6+2:printmid$(tt$,a,1)"[170]";:next
  91. 910 print:return
  92. 920 rem---joystick input
  93. 930 an=1:poketc,1
  94. 940 print" [157]";:fora=1to80:next:printmid$(a$,an,1)"[157]";:fora=1to80:next
  95. 950 js=peek(j2):if(jsand16)=0thenprint:gosub620:return
  96. 960 js=jsand15
  97. 970 ifjs=14andan>1thenan=an-1
  98. 980 ifjs=13andan<len(a$)thenan=an+1
  99. 990 goto940
  100. 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
  101. 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
  102. 1020 data0,24,0,0,0,0,0,0,0,0,0,0
  103.