Goto 10 RetroComputing: Atari and more

Share this post

Drawing a Spiral in GFA BASIC on the Atari ST

www.goto10retro.com

Drawing a Spiral in GFA BASIC on the Atari ST

BASIC on the Atari ST

Paul Lefebvre
Feb 3
3
Share this post

Drawing a Spiral in GFA BASIC on the Atari ST

www.goto10retro.com

Welcome back to the Goto 10 Free Friday post! This post is significant because it is the 100th post! In not quite a year, I’ve published regularly enough to hit 100 a bit earlier than expected. In these busy times, really appreciate you taking the time to read Goto 10.

white and black 10 signage
Photo by Marcel Eberle on Unsplash

Of course, if you’re a free subscriber you’ve only seen about half of the Goto 10 posts (and are missing out on perks). If you’d like even more Goto 10 content, with extra posts on Mondays, please consider becoming a paid subscriber. Thanks for reading!

Last year I showed how to draw a spiral in Atari BASIC, but I thought it would be neat to compare that to what the Atari ST could do with GFA BASIC.

This is the original Atari BASIC code:

10 GRAPHICS 15+16
20 C=1
30 TIME1=PEEK(20)+PEEK(19)*256+PEEK(18)*65536
40 X=80:Y=96:R=96
50 PLOT X,Y-R
60 TWOPI=3.14*2
70 SPIRALS=11
80 FOR A=0 TO SPIRALS*TWOPI STEP 0.01
90 NX=X+R/2*SIN(A)
100 NY=Y-R*COS(A)
110 DRAWTO NX,NY
120 R=R-0.01
130 IF LASTNX<X AND NX>X THEN C=C+1:IF C>3 THEN C=1
140 COLOR C
150 LASTNX=NX
160 NEXT A
170 TIME2=PEEK(20)+PEEK(19)*256+PEEK(18)*65536
180 DUR=(TIME2-TIME1)/60/60:REM MINUTES
190 GOTO 190

I used GFA BASIC 3.6 since that is the latest version available for the ST. The general concept will be the same in that we want to use trigonometry to draw a shrinking circle.

The Atari ST’s low-resolution mode is 320x200 in 16 colors, so this should look much better than the 8-bit version which ran in 160x92 with 4 colors.

It ought to be much faster as well!

Here is the GFA BASIC converted code:

 c=1
 x=160
 y=100
 r=100
 PLOT x,y-r
 twopi=3.14*2
 spirals=11
 FOR a=0 TO spirals*twopi STEP 0.01
   nx=x+r*SIN(a)
   ny=y-r*COS(a)
   DRAW  TO nx,ny
   r=r-0.01
   IF lastnx<x AND nx>x THEN
     c=c+1
   ENDIF
   COLOR c
   lastnx=nx
 NEXT a

The first thing to notice is that GFA BASIC does not use line numbers and its code is (automatically) indented.

I’m torn on line numbers. On the one hand, they totally scream BASIC! when you see them. On the other hand, they are really there because full-screen text editors were not a thing when BASIC was originally designed and also not a thing on the early low-memory personal computers. You needed the line numbers to indicate what bit of code you were editing. Plus, it worked well with GOTO.

But once computers had full-screen text editors, using a line-based editor is a royal pain.

Without line numbers you can still use GOTO by adding a label (usually text followed by a color, so “START:” for example.

Of course once more and more structure commands got added to BASIC, the need for GOTO mostly disappeared.

The math stuff is exactly the same. The drawing code is quite similar actually, with just DRAWTO becoming two words.

The above code took about 35 seconds to run on my 1040ST, which is a vast improvement over the 8-bit which took 21(!) minutes in Atari BASIC. Plus it does look better, as expected:

You are getting sleepy!

Update: A ready has informed me that the above GFA BASIC program also works unchanged on GFA BASIC for the Amiga.

Thanks for reading! Be sure to sign up for the FREE email newsletter to get new posts sent directly to your Inbox!

Reference:

Goto 10
Drawing a Spiral in BASIC
A while ago I came across this short snippet of BASIC code, originally written for QuickBASIC 4.5: CLS RANDOMIZE (TIMER) x = 320 y = 240 r = 100 c = 1 SCREEN 12 PSET (x, y - r), 0 FOR a = 0 TO 72 STEP .01 LINE -(x + r * SIN(a), y - r * COS(a)), c…
Read more
4 months ago · 5 likes · 5 comments · Paul Lefebvre
Share this post

Drawing a Spiral in GFA BASIC on the Atari ST

www.goto10retro.com
Previous
Next
Comments
TopNewCommunity

No posts

Ready for more?

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