This page (revision-22) was last changed on 03-Feb-2023 15:21 by Gromit 

This page was created on 14-Mar-2010 18:17 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
22 03-Feb-2023 15:21 23 KB Gromit to previous
21 01-Feb-2011 12:53 23 KB Gromit to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 120 added 45 lines
The IF statement:
{{{
IF x0 <= y0 AND y0 < 96 THEN FI
}}}
determines if any points are to be plotted. The check for y0 < 96 assures that the points won't overlap
when we calculate x1 and y1:
{{{
x1 = 191 - x0
y1 = 191 - y0
}}}
The value of 191 was chosen since it is the maximum y-value you can plot in graphics mode 24.
The Plot calls following these two statements display all eight combinations of x0, y0, x1, and y1. The +64 in each call centers the display on the screen, since there are 128 more points in the X direction than there are in the Y direction.
If you're curious about how this plotting algorithm works, choose your own values for x0 and y0 (21 and 55, for example). Calculate x1 and y1 from the formula above (170,136). Finally, calculate all of the points that will be plotted (don't add in the 64; it makes things easier to see). Our example would yield coordinates' of (21,55), (21,136), (55,21), (55,170), (170,55), (170,136), (136,21) and (136,170). If you plot these on a piece of graph paper with 0,0 in the upper left corner and 191,191 in the lower right, you' ll see that they are symmetric about the center.
The only part of Gen() not explained yet is:
{{{
r.cnt == -1
IF r.cnt = 0 THEN
.
.
FI
}}}
The first statement decrements the cnt field of r, and the IF statement body is executed when cnt reaches
zero. The statements:
{{{
r.bx = (r.bx + r.cx) ! r.cx
r.by = (r.by + r.cy) ! r.cy
}}}
calculate new values for bx and by, which cause the ax and ay calculations to change in the future as well.
The line:
{{{
r.cnt = period
}}}
resets cnt so that it can count down to zero again. Finally,
{{{
ATRACT = 0
}}}
keeps the screen from going into attract mode. Note that [[ATRACT]] was declared to be at location 77. This is the memory location used by the OS to determine if attract mode is on or off.
A look at Kal(). Now you understand (I hope) how the Gen() procedure works. So let's look at Kal() and see how it uses Gen().