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 165 added 35 lines
The first three Kal() statements:
{{{
Graphics C24)
SetColor (1,0,14) : SetColor (2,0,0)
}}}
set up graphics mode 24, with white dots on a black background. The next group:
{{{
persistence = 2500
period = 10000
p.cnt = period
p.ax = 5221
p.bx = 64449
p.cx = 3
p.ay = 57669
p.bx = 64489
p.cy = 3
}}}
sets the initial values that control the pattern generation of Gen().You can change these to generate your own patterns. As stated above, ax, ay, bx, by, cx and cy are used to calculate the points to be plotted. The value for period determines how frequently the pattern will change. The value for persistence determines how much of the pattern will be on the screen at once.
You may be saying at this point, "Hold on there! If you don't erase any points, the screen will just turn white," and you would be right. That's the reason for:
{{{
MoveBlock(e, p, REC)
}}}
and why Gen() is passed a record argument. It turns out that, depending on the value of color, Gen() will either plot or erase points on the screen. The p record will be used for plotting, and the e record will be used for erasing. MoveBlock makes a copy of p (all the fields) in e, because when a record variable is referenced without a field, the address of the record is used. When a type name is referenced, the size in bytes of the type is used. Thus, MoveBlock is being called with the address of records e and p, and the size of the record. Initially both p and e will have the same values. Here is how p and e are used:
{{{
WHILE CH = 255 DO
color = 1 Gen(p)
color = 0 Gen(e)
OD
}}}
First, color is set to one (plot points) and Gen() is called with p as an argument (remember, this passes the address of p, a POINTER, to the Gen() procedure). Next, color is set to zero (erase points) and Gen() is called with e as an argument. Since both p and e start out the same, what happens is that Ge(p) draws some points on the screen and Gen(e) erases them. That keeps the screen from turning white.
The sequence will keep repeating as long as [CH] equals 255. [CH] was declared to be at address 764, the location that the OS stores the internal value for the last key pressed. It is set to 255 by the keyboard handler after a key is processed. Thus, as long as no key is depressed, [CH] will equal 255. As soon as a key is depressed, it will contain the code for the last key (will no longer equal 255) and the loop will terminate, causing: