rrutherford

NextMatrix 1.02

Jun 5th, 2020
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 10 ; NextMatrix 1.02 © 2020 Rick Rutherford
  2. 20 RUN AT 3: CLEAR 49151:ver=1.02
  3. 30 ON ERROR PROC exit()
  4. 40 r6=% REG 6: REG 6,% REG 6&119
  5. 50 .nextver v: IF v < 2.06 THEN PRINT "NextBASIC v2.06+ required": PAUSE 0: REG 2,1
  6. 60:
  7. 70 PROC init():o=1
  8. 80 REPEAT
  9. 90 %c=a(o):c=%c:%n=p(c)
  10. 100 IF % SGN {n} > 0 THEN PROC dispcol()
  11. 110 p(c)=p(c)+1: IF p(c) > r THEN p(c)=-7
  12. 120 IF % SGN {n} < 0 THEN PROC fadecol()
  13. 130 IF %n=0 THEN PROC resetcol()
  14. 140 k$= INKEY$ : IF k$ <> "" THEN PROC processkey(k$)
  15. 150 o=o+1: IF o > ac THEN o=1
  16. 160 IF %z=20 THEN IF bg THEN PROC glitch(1)
  17. 170 IF bg THEN %z=%z+1
  18. 180 REPEAT UNTIL 0
  19. 190:
  20. 200 DEFPROC processkey(k$)
  21. 210 LOCAL k
  22. 220 IF k$ >= "3" AND k$ <= "7" THEN PROC columns( VAL k$)
  23. 230 IF k$="h" THEN %t=% NOT t: PROC columns(ac)
  24. 240 IF k$="0" OR k$="g" OR k$="k" OR k$="m" OR k$="n" OR k$="z" THEN PROC mode(k$) TO m$
  25. 250 IF k$="b" THEN bg= NOT bg: PROC togglebg()
  26. 260 IF k$="q" THEN PROC exit()
  27. 270 k= CODE k$: IF (k=7 OR k=12 OR k=13 OR k=32) AND hv=0 THEN PROC help(): ELSE hv=0
  28. 280 ENDPROC
  29. 290:
  30. 300 DEFPROC dispcol()
  31. 310 LOCAL %l,%p
  32. 320 cc=% RND f+q
  33. 330 PRINT INK %c-1*7+(n-1/4)+2; AT %n-1,%c+2; CHR$ e(o)
  34. 340 IF %n < r THEN PRINT INK %254; AT %n,%c+2; CHR$ cc
  35. 350 e(o)=cc
  36. 360 ENDPROC
  37. 370:
  38. 380 DEFPROC fadecol()
  39. 390 BANK %b COPY %( SGN {n}+7)*7+512,%7 TO %b,%c-1*7+257
  40. 400 LAYER PALETTE %0 BANK %b,%256
  41. 410 ENDPROC
  42. 420:
  43. 430 DEFPROC resetcol()
  44. 440 LAYER ERASE %(c+2)*8,0,8,%r*8
  45. 450 BANK %b COPY %7+1,%7 TO %b,%c-1*7+257
  46. 460 LAYER PALETTE %0 BANK %b,%256
  47. 470 a(o)=% RND m+1
  48. 480 IF % NOT t THEN PROC initp(c)
  49. 490 ENDPROC
  50. 500:
  51. 510 DEFPROC initp(g)
  52. 520 IF g=0 THEN FOR n=1 TO m: ELSE n=g
  53. 530 IF %t THEN p(n)=0: ELSE p(n)=% RND 14+1
  54. 540 IF g=0 THEN NEXT n
  55. 550 ENDPROC
  56. 560:
  57. 570 DEFPROC mode(m$)
  58. 580 cs=1: IF m$="z" OR m$="g" OR m$="0" THEN cs=0
  59. 590 IF m$="0" THEN %f=2:%q=48
  60. 600 IF m$="g" THEN %f=110:%q=33
  61. 610 IF m$="k" THEN %f=20:%q=68
  62. 620 IF m$="m" THEN %f=56:%q=32
  63. 630 IF m$="n" THEN %f=10:%q=88
  64. 640 IF m$="z" THEN %f=94:%q=33
  65. 650 PROC charset(cs) TO cs: IF bg THEN PROC renderbg()
  66. 660 ENDPROC =m$
  67. 670:
  68. 680 DEFPROC glitch(%n)
  69. 690 LAYER 1,3
  70. 700 PRINT INK % RND 2+1; AT %j,%k; SCREEN$ (j,k)
  71. 710 %z=0:%j=% RND 23:%k=% RND 31
  72. 720 j=%j:k=%k
  73. 730 IF %n THEN PRINT INK %7; AT %j,%k; SCREEN$ (j,k)
  74. 740 LAYER 2,1
  75. 750 ENDPROC
  76. 760:
  77. 770 DEFPROC defchars()
  78. 780 LOCAL %a,%o,%r:%r=%49408:%o=2609
  79. 790 FOR %a=%0 TO %528 STEP %2
  80. 800 DPOKE %r+a,% BANK b DPEEK (a+o)
  81. 810 NEXT %a
  82. 820 PROC charset(1) TO cs
  83. 830 ENDPROC
  84. 840:
  85. 850 DEFPROC charset(%n)
  86. 860 LOCAL %a:%a=23606
  87. 870 IF % NOT n THEN DPOKE %a,%o: ELSE DPOKE %a,%49152
  88. 880 LAYER 2,1: PRINT CHR$ 2
  89. 890 ENDPROC =%n
  90. 900:
  91. 910 DEFPROC togglebg()
  92. 920 IF bg THEN REG 98,128: PROC renderbg()
  93. 930 IF NOT bg THEN REG 98,0: LAYER 1,3: CLS : LAYER 2,1
  94. 940 ENDPROC
  95. 950:
  96. 960 DEFPROC renderbg()
  97. 970 CLS : PROC initp(0)
  98. 980 LAYER 1,3: CLS
  99. 990 LOCAL c,%e,%i,%j,%s,%w,cc
  100. 1000 c=15:d=1:x=0
  101. 1010 REPEAT
  102. 1020 x=x+1:c=c+(x*d):d=-d
  103. 1030 INK % RND 2+1
  104. 1040 %s=% RND 17+1:%e=%s+ RND 30+1
  105. 1050 FOR %j=%s TO %e
  106. 1060 %w=%j: IF %w > 23 THEN %w=%j-24
  107. 1070 cc=% RND f+q
  108. 1080 PRINT AT %w,c; CHR$ cc
  109. 1090 NEXT %j
  110. 1100 REPEAT UNTIL c=30
  111. 1110 LAYER 2,1
  112. 1120 ENDPROC
  113. 1130:
  114. 1140 DEFPROC scroll()
  115. 1150 LOCAL %c,%p,%v
  116. 1160 PROC refreshrate() TO %h
  117. 1170 REG 98,0: REG 97,0
  118. 1180 FOR %c=%562 TO %2608
  119. 1190 LET %v=% BANK b PEEK c
  120. 1200 IF %v=54 AND (p=129) AND (h <> 50) THEN %v=0
  121. 1210 REG 96,%v:%p=%v
  122. 1220 NEXT %c
  123. 1230 REG 97,0: REG 98,128
  124. 1240 ENDPROC
  125. 1250:
  126. 1260 DEFPROC refreshrate()
  127. 1270 LOCAL %h:%h=%( REG 5&4)*5/2+50
  128. 1280 ENDPROC =%h
  129. 1290:
  130. 1300 DEFPROC columns(%w)
  131. 1310 ac=%w
  132. 1320 DIM a(ac): DIM e(ac)
  133. 1330 FOR n=1 TO ac
  134. 1340 a(n)= % RND (m-1)+1
  135. 1350 e(n)=% RND f+q
  136. 1360 NEXT n
  137. 1370 PROC initp(0)
  138. 1380 LAYER 2: CLS
  139. 1390 ENDPROC
  140. 1400:
  141. 1410 DEFPROC init()
  142. 1430 BANK NEW %b: BANK %b ERASE
  143. 1440 LOAD "NextMatrix.dat" BANK %b
  144. 1450 LAYER CLEAR : PALETTE CLEAR
  145. 1460 LAYER 0: BORDER 0: PAPER 0: INK 7: CLS
  146. 1470 LAYER 1,3: PALETTE DIM 8: PALETTE FORMAT 255: REG 38,4
  147. 1480 FOR %i=%0 TO %7: LAYER PALETTE %0,%i,%i*8: NEXT %i
  148. 1490 LAYER 2,1: PALETTE DIM 8: BORDER 0: PAPER 227: CLS
  149. 1500 LAYER PALETTE %0 BANK %b,%256: INK 255
  150. 1510 PRINT INK 7; AT 9,8;"NextMatrix v"; STR$ ver
  151. 1520 PRINT CHR$ 30; CHR$ 6; INK 4; AT 11,8;"Next System 1.3.2+ required"
  152. 1530 PRINT INK 4; AT 13,7;"Press "; INK 7;"Space"; INK 4;" or "; INK 7;"Enter"; INK 4;" for menu": PRINT CHR$ 30; CHR$ 8;
  153. 1540 LAYER PALETTE %0 BANK %b,%256: INK 255
  154. 1550 %o=% DPEEK 23606: PROC defchars():m$="m"
  155. 1560 %m=%27:m=%m:%r=%24:r=%r:cs=1
  156. 1570 DIM p(m):%f=%56:%q=%32:%t=1:hv=0
  157. 1580 %j=0:j=0:%k=0:k=0:%z=0:bg=1
  158. 1590 PROC scroll(): PROC renderbg(): PROC columns(5)
  159. 1600 ENDPROC
  160. 1610:
  161. 1620 DEFPROC exit()
  162. 1630 REG 98,0: REG 38,0: REG 39,0: REG 6,r6
  163. 1640 PROC charset(0): BANK %b CLEAR
  164. 1650 LAYER CLEAR : PALETTE CLEAR : CLS
  165. 1660 GO TO %9999
  166. 1670 ENDPROC
  167. 1680:
  168. 1690 DEFPROC help()
  169. 1700 PROC glitch(0): CLS : PROC charset(0)
  170. 1710 LOCAL %h,%i,k,k$:%h=253:%i=255: INK %h
  171. 1720 PRINT AT 5,9;"NextMatrix "; STR$ ver
  172. 1730 PRINT INK 250; AT 6,5;"© 2020 Rick Rutherford"
  173. 1740 PRINT AT 8,4;"3-7"; INK %i; AT 8,8;"Active columns"
  174. 1750 PRINT AT 9,5;"h"; INK %i; AT 9,8;"Full/random height"
  175. 1760 PRINT AT 10,5;"b"; INK %i; AT 10,8;"Toggle background"
  176. 1770 PRINT AT 11,5;"q"; INK %i; AT 11,8;"Quit"
  177. 1780 PRINT AT 13,14;"Modes"
  178. 1790 PRINT AT 15,5;"m"; INK %i; AT 15,8;"Matrix"; INK %h; AT 15,16;"k"; INK %i; AT 15,19;"Katakana"
  179. 1800 PRINT AT 16,5;"0"; INK %i; AT 16,8;"Binary"; INK %h; AT 16,16;"n"; INK %i; AT 16,19;"Numbers"
  180. 1810 PRINT AT 17,5;"z"; INK %i; AT 17,8;"ZX"; INK %h; AT 17,16;"g"; INK %i; AT 17,19;"ZX w/gfx"
  181. 1820 REPEAT :k$= INKEY$ : REPEAT UNTIL k$ <> ""
  182. 1830 k= CODE k$: IF k=7 OR k=12 OR k=13 OR k=32 THEN hv=1: CLS : PROC charset(cs): ELSE CLS : PROC charset(cs): PROC processkey(k$)
  183. 1840 ENDPROC
RAW Paste Data