You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
(SPECTRUM GRAPHICS!<br />
Spirogram<br />
Moving in circles can produce some<br />
interesting results as Simon Palmer<br />
demonstrates. lli&,86j I3T BlS r13<br />
I12e,88» 137 •-IS r-id<br />
Almost everybody will have<br />
played with a Spirograph at<br />
some time. It is a set of toothed<br />
wheels, like gears which produce<br />
intricate patterns. One of<br />
the gears is pinned to a piece of<br />
paper, while the other is pushed<br />
around it by a pen which pokes<br />
through onto the paper. The patterns<br />
which are produced de<br />
pend on the sizes the gears, and<br />
the position of the pen hole in<br />
the moving gear. These effects<br />
are reproduced on a Spectrum<br />
computer by this program.<br />
The format for a call to the<br />
machine code program is RAN<br />
DOMIZE USR 65274: REM<br />
a,b,f,m,r where a and b are the<br />
coordinates of the centre of the<br />
pattern on the screen, f and m<br />
are integers which are the radii<br />
of the fixed and moving gears,<br />
and r is the distance of the pen<br />
hole from the centre of the moving<br />
gear.<br />
The program is based almost<br />
entirely on the Spectrum Basic<br />
interpreter's calculator (called<br />
by a RST 00281. This is controlled<br />
by a string of literals immediately<br />
following the call<br />
which describe what needs to<br />
be done, adding multiplying and<br />
so on. Particular use has been<br />
made of the number fetching<br />
r IX<br />
Stack Map<br />
and storing facilities which are<br />
normally used for the<br />
calculator's memory area to<br />
manipulate numbers on the<br />
calculator stack (a plan of which<br />
is given in figure 1).<br />
Functions<br />
The functions of the different<br />
sections of program are:<br />
FEF A - FF40 get the<br />
arguments from the REM statement<br />
which must immediately<br />
follow a USR call to this program,<br />
and put them on the<br />
calculator stack after the six<br />
dummy values at the bottom to<br />
replace the calculator's memory<br />
area, of at any time an error is<br />
detected a jump is made to<br />
1C8A which stops the BASIC<br />
program and produces an error<br />
report.<br />
FF41 FF54 calculates the hcf<br />
of f and m.<br />
FF55 - FF74 calculates the<br />
size of angular incrementsAG<br />
and the total number of them in a<br />
complete pattern.<br />
FF75 FF8A sets the initial<br />
set-mem get-mem contents<br />
CO EO calcO<br />
CI El calc 1<br />
C2 E2 calc2<br />
C3 E3 calc3<br />
C4 E4 caic4<br />
C5 E5 calc 5<br />
C6 E6 a<br />
CI E7 b<br />
C8 E8 1<br />
C9 E9 m<br />
CA EA r<br />
CB EB t<br />
CC EC AG<br />
CD ED cose<br />
CE EE SIN e<br />
CF EF cos AO<br />
DO FO sin AG<br />
D7 F1 cose<br />
D2 F2 SIN e<br />
D3 F3 cos Ae<br />
D4 F4 sin Ae<br />
D5 F5 X<br />
D6 F6 V<br />
< , 6 6 )<br />
I 8 8 )<br />
values of COS©, SIN©, COS0,<br />
SIN0(COS & SIN denote (f i m)<br />
cos0& (f + m) sind, and COS0&<br />
SINfiklenote r cos0and r sin0) and<br />
calculates cosAft, sinA0, cosA<br />
#and sinAtT.<br />
FF8B FF9D increments6 (by<br />
changing COSOand SIN6I.<br />
FF9E FFAF increments 0 (by<br />
changing COSffand SIN0I.<br />
FFBO - FFBB calculates the plot<br />
position (x,y).<br />
m l B r 1 8<br />
no - I S r - 1<br />
FFBC FFE2 checks to see<br />
whether lx,y) is on the screen, if<br />
so it is PLOTted by a USR call to<br />
22DC.<br />
FFE3 - FFF2 decrements the<br />
step count, if this is not zero and<br />
there is no keyboard break, then<br />
the loop is executed again.<br />
FFF3 - FFFE resets the<br />
calculators memory area and<br />
clears the stack.<br />
FFFF returns to BASIC.<br />
10 REM SPIROGRAM<br />
20 CLEAR 65273<br />
30 LET P=1+PEEK 23730+256*PEEK<br />
23731<br />
40 GO SUB 1000<br />
50 INPUT •(-ja;",";b;•><br />
m";m;• r";r<br />
60 RANDOMIZE USR P: REM a,b,-Ff<br />
m, r<br />
70 GO TO 50<br />
1000 REM poke SpiroGram<br />
1010 LET d=p<br />
1020 DEF FN d(dS)=(dt