Goto 10 RetroComputing: Atari and more

Share this post

Dragon and Snowflake Fractal Sweeps in BASIC

www.goto10retro.com

Dragon and Snowflake Fractal Sweeps in BASIC

Fun with fractals

Paul Lefebvre
Jul 29, 2022
5
1
Share this post

Dragon and Snowflake Fractal Sweeps in BASIC

www.goto10retro.com

In the September 1985 issue of Compute! magazine, there was an article called Apple Fractals. The article included three programs written in Apple II BASIC: The Dragon Sweep, Eight Thousand Dragons and The Snowflake Sweep.

I recently found a printout of the Dragon and Snowflake sweep programs that I had converted to Atari BASIC (apparently I never tried converting the Eight Thousand Dragons program).

Both of these draw pretty slowly in standard Atari BASIC (102m17s for Dragon Sweep, 12m12s for the Snowflake Sweep), but they can be sped up by doing the usual trick of turning off ANTIC screen updates after entering a value and then turning it back on when it has finished. Here are the changes for Dragon Sweep:

145 POKE 559,0:REM ANTIC off
245 POKE 559,34:REM ANTIC on

In addition, they both work fine in Turbo BASIC XL and BASIC XL/XE and run significantly faster with any of them.

Both sweeps run in high-resolution mode of 320x192 which only has one color. A fun modification would be to use one of the color modes, such as 160x192 (Graphics mode 15) and tweak the color value as it is drawing.

Dragon Sweep

Dragon Sweep

Atari BASIC source:

10 REM DRAGON SWEEP CONVERTED FROM THE APPLE TO THE ATARI BY P.LEFEBVRE
20 REM
40 REM 14 (MAX.) CYCLES
90 DIM SN(14)
100 GRAPHICS 0
110 PRINT "ENTER AN EVEN NO. OF CYCLES (2 TO 14)"
120 PRINT " OR ENTER A ZERO TO QUIT ";:INPUT NC
130 IF NC=0 THEN END
140 IF INT(NC/2)*2<>NC OR NC<2 OR NC>14 THEN 100
150 L=128:FOR C=2 TO NC STEP 2:L=L/2:NEXT C
160 X=77:Y=128:GRAPHICS 24:COLOR 1:PLOT X,Y
170 FOR C=0 TO NC:SN(C)=0:NEXT C
180 D=0:FOR C=1 TO NC:IF SN(C-1)=SN(C) THEN D=D-1:GOTO 200
190 D=D+1
200 IF D=-1 THEN D=7
210 IF D=8 THEN D=0
220 NEXT C
230 IF D=0 THEN X=X+L:GOTO 270
240 IF D=2 THEN Y=Y+L:GOTO 270
250 IF D=4 THEN X=X-L:GOTO 270
260 Y=Y-L
270 DRAWTO X,Y:SN(NC)=SN(NC)+1
280 FOR C=NC TO 1 STEP -1:IF SN(C)<>2 THEN 300
290 SN(C)=0:SN(C-1)=SN(C-1)+1:NEXT C
300 IF SN(0)=0 THEN 180
310 OPEN #1,4,0,"K":GET #1,K:CLOSE #1
320 GOTO 100

Snowflake Sweep

Atari BASIC Source:

10 REM SNOWFLAKE SWEEP
20 REM CONVERTED FROM THE APPLE TO THE ATARI BY PAUL LEFEBVRE
30 REM
50 DIM DX(11),DY(11),SD(6),RD(6),SN(4),LN(6):M=7/6
60 FOR N=0 TO 6:READ XX,YY:SD(N)=XX:RD(N)=YY:LN(N)=1/3:NEXT N:LN(2)=SQR(LN(1))
70 A=0:FOR D=6 TO 11:DX(D)=COS(A):DY(D)=SIN(A)
80 A=A+0.52359879:NEXT D
90 FOR D=0 TO 5:DX(D)=-DX(D+6):DY(D)=-DY(D+6):NEXT D
100 GRAPHICS 0
110 PRINT "ENTER THE NUMBER OF CYCLES ( 1 - 4 )"
120 PRINT " OR ENTER A ZERO TO QUIT ";:INPUT NC
130 IF NC=0 THEN END
140 IF NC>4 THEN 100
150 GRAPHICS 24:COLOR 1
160 X=235:Y=142:TL=162:PLOT X,Y
170 FOR C=0 TO NC:SN(C)=0:NEXT C
180 D=0:L=TL:NS=0:FOR C=1 TO NC:I=SN(C):L=L*LN(I):J=SN(C-1):NS=NS+SD(J):K=INT(NS/2)
185 IF K*2<>NS THEN D=D+12-RD(I):GOTO 200
190 D=D+RD(I)
200 IF D>11 THEN D=D-12
210 NEXT C
220 X=X+M*L*DX(D):Y=Y-L*DY(D):DRAWTO X,Y:SN(NC)=SN(NC)+1:FOR C=NC TO 1 STEP -1:IF SN(C)<>7 THEN 240
230 SN(C)=0:SN(C-1)=SN(C-1)+1:NEXT C
240 IF SN(0)=0 THEN 180
250 OPEN #1,4,0,"K":GET #1,K:CLOSE #1
260 GOTO 100
270 DATA 0,0,1,0,1,7,0,10,0,0,0,2,1,2

Goto 10 is a reader-supported publication. Become a paid subscriber to get access to a disk image with these two Atari BASIC programs on it, along with other articles and perks.

Be sure to check out the Goto 10 Archive with 40+ posts to enjoy!

1
Share this post

Dragon and Snowflake Fractal Sweeps in BASIC

www.goto10retro.com
Previous
Next
1 Comment
Alvaro
Jul 30, 2022

Drawing fractal is very interesting / Dibujar fractales es muy interesante

Expand full comment
Reply
TopNewCommunity

No posts

Ready for more?

© 2023 Paul Lefebvre
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing