From 184262ca3e56b83737f058c24c400b687e8b6f78 Mon Sep 17 00:00:00 2001 From: Lawrence Kesteloot Date: Mon, 6 Aug 2018 00:25:27 -0700 Subject: [PATCH] Add examples. --- examples/circle.bas | 9 +++++++ examples/gr_fill_screen.bas | 7 +++++ examples/gr_speed_test.bas | 12 +++++++++ examples/stars.bas | 43 ++++++++++++++++++++++++++++++ examples/stars.py | 30 +++++++++++++++++++++ examples/text_fill_screen_for.bas | 7 +++++ examples/text_fill_screen_goto.bas | 8 ++++++ examples/too_many_loops.bas | 14 ++++++++++ 8 files changed, 130 insertions(+) create mode 100644 examples/circle.bas create mode 100644 examples/gr_fill_screen.bas create mode 100644 examples/gr_speed_test.bas create mode 100644 examples/stars.bas create mode 100644 examples/stars.py create mode 100644 examples/text_fill_screen_for.bas create mode 100644 examples/text_fill_screen_goto.bas create mode 100644 examples/too_many_loops.bas diff --git a/examples/circle.bas b/examples/circle.bas new file mode 100644 index 0000000..e3cf3ff --- /dev/null +++ b/examples/circle.bas @@ -0,0 +1,9 @@ +10 GR +15 COLOR=5 +20 Y = 0 +30 X = 0 +40 IF (20-X)*(20-X) + (20-Y)*(20-Y) < 100 THEN PLOT X, Y +50 X = X + 1 +60 IF X < 40 GOTO 40 +70 Y = Y + 1 +80 IF Y < 40 GOTO 30 diff --git a/examples/gr_fill_screen.bas b/examples/gr_fill_screen.bas new file mode 100644 index 0000000..6d98017 --- /dev/null +++ b/examples/gr_fill_screen.bas @@ -0,0 +1,7 @@ +10 GR +15 COLOR=5 +20 FOR Y = 0 TO 39 +30 FOR X = 0 TO 39 +40 PLOT X,Y +50 NEXT X +60 NEXT Y diff --git a/examples/gr_speed_test.bas b/examples/gr_speed_test.bas new file mode 100644 index 0000000..009fba4 --- /dev/null +++ b/examples/gr_speed_test.bas @@ -0,0 +1,12 @@ +10 GR +20 Y = 0 +25 C = 1 +30 X = 0 +40 COLOR=C +45 PLOT X, Y +50 X = X + 1 +55 C = C + 1 +56 IF C = 16 THEN C = 1 +60 IF X < 40 GOTO 40 +70 Y = Y + 1 +80 IF Y < 40 GOTO 30 diff --git a/examples/stars.bas b/examples/stars.bas new file mode 100644 index 0000000..d2f3899 --- /dev/null +++ b/examples/stars.bas @@ -0,0 +1,43 @@ +10 GR +20 TS = 40 +30 DIM DX(9),DY(9),C(9),X(9),Y(9) +1000 DX(0) = 14 +1005 DY(0) = 13 +1010 C(0) = 14 +1100 DX(1) = 18 +1105 DY(1) = 8 +1110 C(1) = 5 +1200 DX(2) = 7 +1205 DY(2) = -18 +1210 C(2) = 12 +1300 DX(3) = 9 +1305 DY(3) = 17 +1310 C(3) = 3 +1400 DX(4) = 19 +1405 DY(4) = 2 +1410 C(4) = 12 +1500 DX(5) = -19 +1505 DY(5) = 0 +1510 C(5) = 4 +1600 DX(6) = -2 +1605 DY(6) = 19 +1610 C(6) = 14 +1700 DX(7) = 0 +1705 DY(7) = -19 +1710 C(7) = 4 +1800 DX(8) = -18 +1805 DY(8) = -7 +1810 C(8) = 4 +1900 DX(9) = 14 +1905 DY(9) = 13 +1910 C(9) = 11 +2100 FOR T = 0 TO TS +2200 FOR I = 0 TO 9 +2210 OX = X(I) : OY = Y(I) +2220 X(I) = 20 + DX(I) * T / TS +2230 Y(I) = 20 + DY(I) * T / TS +2240 COLOR=0 : PLOT OX, OY +2250 COLOR=C(I) : PLOT X(I), Y(I) +2260 NEXT +2300 NEXT +2310 GOTO 2100 diff --git a/examples/stars.py b/examples/stars.py new file mode 100644 index 0000000..c6ebf33 --- /dev/null +++ b/examples/stars.py @@ -0,0 +1,30 @@ +import random +import math + +str = """%(init)d00 DX(%(which)d) = %(x)d +%(init)d05 DY(%(which)d) = %(y)d +%(init)d10 C(%(which)d) = %(c)d""" + +print "10 GR" +print "20 TS = 40" +print "30 DIM DX(9),DY(9),C(9),X(9),Y(9)" + +for i in range(0,10) : + angle = random.uniform(0,.999) + x = int(20 * math.cos(angle * 3.14159 * 2)) + y = int(20 * math.sin(angle * 3.14159 * 2)) + c = random.randrange(1,15) + print str % {'init' : 10 + i, 'x' : x, 'y' : y, 'c' : c, 'which' : i} + +print "2100 FOR T = 0 TO TS" + +print "2200 FOR I = 0 TO 9" +print "2210 OX = X(I) : OY = Y(I)" +print "2220 X(I) = 20 + DX(I) * T / TS" +print "2230 Y(I) = 20 + DY(I) * T / TS" +print "2240 COLOR=0 : PLOT OX, OY" +print "2250 COLOR=C(I) : PLOT X(I), Y(I)" +print "2260 NEXT" + +print "2300 NEXT" +print "2310 GOTO 2100" diff --git a/examples/text_fill_screen_for.bas b/examples/text_fill_screen_for.bas new file mode 100644 index 0000000..b01fde5 --- /dev/null +++ b/examples/text_fill_screen_for.bas @@ -0,0 +1,7 @@ +10 HOME +20 FOR CH=65+128 TO 69+128 +30 FOR AD = 1024 TO 2047 +40 POKE AD, CH +50 NEXT +60 NEXT + diff --git a/examples/text_fill_screen_goto.bas b/examples/text_fill_screen_goto.bas new file mode 100644 index 0000000..e06aa27 --- /dev/null +++ b/examples/text_fill_screen_goto.bas @@ -0,0 +1,8 @@ +10 HOME +20 CH = 65+128 +30 AD = 1024 +40 POKE AD,CH +50 AD = AD + 1 +60 IF AD < 2048 GOTO 40 +70 CH = CH + 1 +80 IF CH < 70+128 GOTO 30 diff --git a/examples/too_many_loops.bas b/examples/too_many_loops.bas new file mode 100644 index 0000000..56584ca --- /dev/null +++ b/examples/too_many_loops.bas @@ -0,0 +1,14 @@ +10 FOR A = 1 TO 10 +20 FOR B = 1 TO 10 +30 FOR C = 1 TO 10 +40 FOR D = 1 TO 10 +50 FOR E = 1 TO 10 +60 FOR F = 1 TO 10 +70 FOR G = 1 TO 10 +80 FOR H = 1 TO 10 +90 FOR I = 1 TO 10 +100 FOR J = 1 TO 10 + +110 FOR K = 1 TO 10 +120 FOR L = 1 TO 10 +130 FOR M = 1 TO 10