-
Notifications
You must be signed in to change notification settings - Fork 1
/
circles.bas
96 lines (95 loc) · 1.53 KB
/
circles.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
10 REM Circles
20 REM
30 COLOR 7, 4
40 CLS
50 A = 56
60 B = 22
70 R = 20
80 GOSUB 1000
90 A = 25
100 B = 32
110 R = 19
120 GOSUB 1000
130 A = 18
140 B = 18
150 R = 15
160 GOSUB 1000
180 LOCATE 5, 14
190 COLOR 7, 6
200 PRINT " T i n y B A S I C ";
210 LOCATE 19, 46
220 COLOR 7, 5
230 PRINT " f o r C u r s e s ";
240 END
1000 REM SUBROUTINE draw a circle, center (A, B), radius R
1050 F = 1 - R
1060 D = 1
1070 E = -2 * R
1080 X = 0
1090 Y = R
1100 M = A
1110 N = B + R
1120 GOSUB 2000
1130 M = A
1140 N = B - R
1150 GOSUB 2000
1160 M = A + R
1170 N = B
1180 GOSUB 2000
1190 M = A - R
1200 N = B
1210 GOSUB 2000
1230 REM DO
1250 IF F < 0 GOTO 1290
1260 Y = Y - 1
1270 E = E + 2
1280 F = F + E
1290 REM END IF
1300 X = X + 1
1310 D = D + 2
1320 F = F + D
1330 M = A + X
1340 N = B + Y
1350 GOSUB 2000
1360 M = A - X
1370 N = B + Y
1380 GOSUB 2000
1390 M = A + X
1400 N = B - Y
1410 GOSUB 2000
1420 M = A - X
1430 N = B - Y
1440 GOSUB 2000
1450 M = A + Y
1460 N = B + X
1470 GOSUB 2000
1480 M = A - Y
1490 N = B + X
1500 GOSUB 2000
1510 M = A + Y
1520 N = B - X
1530 GOSUB 2000
1540 M = A - Y
1550 N = B - X
1560 GOSUB 2000
1570 IF X < Y GOTO 1230
1590 REM LOOP
1600 RETURN
1610 REM
2000 REM SUBROUTINE draw a pixel at (M, N)
2010 LOCATE 25 - N / 2, M
2020 P = N - N / 2 * 2
2030 INCHAR C
2040 IF P = 1 GOSUB 2200
2050 IF P = 0 GOSUB 2400
2060 RETURN
2070 REM
2200 REM SUBROUTINE print upper pixel
2210 IF C < 219 OUT 223
2220 IF C = 220 OUT 219
2230 RETURN
2240 REM
2400 REM SUBROUTINE print lower pixel
2410 IF C < 219 OUT 220
2420 IF C = 223 OUT 219
2430 RETURN