CIRCLES

by Chris Pile

from Your Sinclair #33 (September 1988)

[files CIRCLES.*]



Of all the shapes in the universe, of all the forms in the cosmos, do

you know which is the hardest to draw on the humble old Speccy? No, not

a rhombicosidodecahedron, nor a double helix, but a ... circle! It's so

complex that even the venerated Speccy ROM takes ages to draw one. But

here comes Chris Pile with a circle routine that is 20 times faster than

Basic.



Techno Bilge



For all you bilgo mathematicians out there, here's how it works:

(x^2+y^2)-r^2 for a 45 degree axis in seven points of x-y horizontal

symmetry. Understand? I thought you might.



Method



Despite the complexity of the actual code, it is contrastingly simple to

use. Type in or load the hex loader, and then enter the 320 bytes of

code into address 63000. After you've done that, save it to tape with

SAVE "name" CODE 63000,320.



Circulating



Halo, halo, halo. What's all this then? Just a dab of light humour there

to stir a groan from your chests. Right, now you have the code in

memory, type RANDOMIZE USR 63267. This sub-routine initialises the root

and plot tables which, in English, means it builds up the data for the

circle. You only need to do this once - every time you load the program!



[The routine at 63267 requires a sequence of 8 bytes holding the values]

[of each set bit at $FF00 (65280). This data was omitted from the      ]

[magazine listing, so the routine didn't work as printed. The extra    ]

[line 15 in the Basic listing corrects this. Thanks to "Woody" for     ]

[explaining the required correction.                               JimG]



To draw a circle use the following variables:

POKE 63002, x co-ord of centre

POKE 63004, y co-ord of centre

POKE 63006, radius



Then once you've done that, it's a case of typing RANDOMIZE USR 63000 to

see your circle on screen. The program is totally crash proof (cross my

fingers), and will not explode in a splurge of flashing squares should

your circle stray off the edge of the screen.



To see how really zippo and fast it is, type in the short demo program.

Get circulating!

