-
Notifications
You must be signed in to change notification settings - Fork 0
/
rainbow.bas
127 lines (127 loc) · 2.57 KB
/
rainbow.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
100 ' Pattern
110 ' Gilbert Francois Duivesteijn
120 '
130 R=RND(-TIME)
135 COLOR 1,15,15
140 SCREEN 2: CLS
150 CM=12
160 DIM CO(CM,2)
170 CO(0,0)=6
180 CO(0,1)=8
190 CO(1,0)=8
200 CO(1,1)=9
210 CO(2,0)=9 ' green
220 CO(2,1)=10
230 CO(3,0)=10 ' yellow
240 CO(3,1)=11
250 CO(4,0)=11 ' blue,cyan
260 CO(4,1)=3
270 CO(5,0)=3 ' red
280 CO(5,1)=12
290 CO(6,0)=12 ' green
300 CO(6,1)=2
301 CO(7,0)=2 ' magenta,blue
302 CO(7,1)=7
303 CO(8,0)=7 ' magenta,blue
304 CO(8,1)=5
305 CO(9,0)=5
306 CO(9,1)=4
307 CO(10,0)=4
308 CO(10,1)=13
309 CO(11,0)=13
310 CO(11,1)=6
315 RF=0 ' rnd fill threshold
319 ' Set block size here...
320 'BS=8 : GOSUB 380
330 BS=16: GOSUB 380
340 'BS=32: GOSUB 380
350 'BS=64: GOSUB 380
360 IF INKEY$="r" GOTO 310 ELSE 360
370 END
380 '
390 ' fill screen
400 '
410 BH=BS*.5 ' half block size
420 FOR I=0 TO 191\BS
430 FOR J=0 TO 191\BS
440 K=I*(192\BS)+J
450 A0=32+BS*I : B0=BS*J
460 A1=32+BS*(I+1)-1: B1=BS*(J+1)-1
470 IF BS=8 THEN GOSUB 510 ELSE IF RND(1) > RF THEN GOSUB 510
480 NEXT J
490 NEXT I
500 RETURN
510 '
520 ' Pattern selector
530 '
540 P=CINT(RND(1)*5)+1
545 'P=(K MOD 2) + 6
550 C0=K MOD CM
560 C1=INT(RND(1)*2)
570 C2=1-C1
580 C1=CO(C0,C1)
590 C2=CO(C0,C2)
600 IF P=1 THEN GOSUB 670
610 IF P=2 THEN GOSUB 730
620 IF P=3 THEN GOSUB 790
630 IF P=4 THEN GOSUB 880
640 IF P=5 THEN GOSUB 970
650 IF P=6 THEN GOSUB 1020
660 IF P=7 THEN GOSUB 1120
665 RETURN
670 '
680 ' Draw pattern 1
690 '
700 LINE(A0,B0)-(A1,B1),C1,BF
710 LINE(A0+BH,B0)-(A1,B1),C2,BF
720 RETURN
730 '
740 ' Draw pattern 2
750 '
760 LINE(A0,B0)-(A1,B1),C1,BF
770 LINE(A0,B0+BH)-(A1,B1),C2,BF
780 RETURN
790 '
800 ' Draw pattern 3
810 '
820 LINE(A0,B0)-(A1,B1),C1,BF
830 LINE(A0,B0)-(A1,B0),C2
840 LINE(A1,B0)-(A1,B1),C2
850 LINE(A1,B1)-(A0,B0),C2
860 PAINT(A1-1,B0+1),C2
870 RETURN
880 '
890 ' Draw pattern 4
900 '
910 LINE(A0,B0)-(A1,B1),C1,BF
920 LINE(A0,B0)-(A1,B0),C2
930 LINE(A1,B0)-(A0,B1),C2
940 LINE(A0,B1)-(A0,B0),C2
950 PAINT(A0+1,B0+1),C2
960 RETURN
970 '
980 ' Draw pattern 5
990 '
1000 LINE(A0,B0)-(A1,B1),C1,BF
1010 RETURN
1020 '
1030 ' Draw pattern 6
1040 '
1050 LINE(A0,B0)-(A1,B1),C1,BF
1060 CIRCLE(A0+BH,B0+BH),BH-2,C2
1070 PAINT(A0+BH,B0+BH),C2
1080 B4=.5*BH
1090 CIRCLE(A0+BH,B0+BH+B4-1),B4-2,C1
1100 PAINT(A0+BH,B0+BH+B4-1),C1
1110 RETURN
1120 '
1130 ' Draw pattern 7
1140 '
1150 LINE(A0,B0)-(A1,B1),C1,BF
1160 CIRCLE(A0+BH,B0+BH),BH-2,C2
1170 PAINT(A0+BH,B0+BH),C2
1180 B4=.5*BH
1190 CIRCLE(A0+BH,B0+BH-B4+1),B4-2,C1
1200 PAINT(A0+BH,B0+BH-B4+1),C1
1210 RETURN