LOGOSPIN
TABLE OF CONTENTS
What is LOGOSPIN? . . . . . . . . . . . . . . . 1
System requirements . . . . . . . . . . . . . . 2
How to Install LOGOSPIN . . . . . . . . . . . . 2
A Quick Introduction for the Impatient. . . . . 3
How to Run the Demo . . . . . . . . . . . . . . 4
The LOGOSPIN Screen . . . . . . . . . . . . . . 5
Entering LOGOSPIN Commands. . . . . . . . . . . 5
The LOGOSPIN Commands . . . . . . . . . . . . . 6
BACK (BK) . . . . . . . . . . . . . . . . . 6
CLEARSCREEN (CS). . . . . . . . . . . . . . 6
EDIT. . . . . . . . . . . . . . . . . . . . 7
FORWARD (FD). . . . . . . . . . . . . . . . 7
FREEZE. . . . . . . . . . . . . . . . . . . 7
HIDETURTLE (HT) . . . . . . . . . . . . . . 7
LEFT (LT) . . . . . . . . . . . . . . . . . 8
LOAD. . . . . . . . . . . . . . . . . . . . 8
MAKE. . . . . . . . . . . . . . . . . . . . 8
PENDOWN (PD). . . . . . . . . . . . . . . . 8
PENUP (PU). . . . . . . . . . . . . . . . . 9
POTS and PONS . . . . . . . . . . . . . . . 9
QUIT. . . . . . . . . . . . . . . . . . . . 9
REPEAT (RPT). . . . . . . . . . . . . . . . 9
RIGHT (RT). . . . . . . . . . . . . . . . . 10
SAVE. . . . . . . . . . . . . . . . . . . . 10
SETBG . . . . . . . . . . . . . . . . . . . 10
SETCOLOR (SC) . . . . . . . . . . . . . . . 10
SETHEADING (SH) . . . . . . . . . . . . . . 11
SETX (SX) . . . . . . . . . . . . . . . . . 11
SETXY and SETPOS (SXY). . . . . . . . . . . 11
SETY (SY) . . . . . . . . . . . . . . . . . 12
SHOWTURTLE (ST) . . . . . . . . . . . . . . 12
SPIN. . . . . . . . . . . . . . . . . . . . 12
THAW. . . . . . . . . . . . . . . . . . . . 12
WAIT. . . . . . . . . . . . . . . . . . . . 13
The LOGOSPIN Colors . . . . . . . . . . . . . . 13
LOGOSPIN Variables and Expressions. . . . . . . 14
The LOGOSPIN Editor . . . . . . . . . . . . . . 16
How to Create a LOGOSPIN function . . . . . . . 16
An interesting function . . . . . . . . . . . . 19
Artifacts . . . . . . . . . . . . . . . . . . . 20
Technical Stuff for the Techies . . . . . . . . 21
Demo file program list. . . . . . . . . . . . . 23
Registering LOGOSPIN. . . . . . . . . . . . . . 24
Registration Form . . . . . . . . . . . . . . . 25
What is LOGOSPIN?
LOGOSPIN is based upon the turtle graphics portion of LOGO, an
interactive programming language for children. Most of the
features of LOGO are present but in addition, LOGOSPIN adds a
dynamic animation capability. LOGO draws pictures on the
computer screen, LOGOSPIN draws and then moves them about to
create spectacular animation.
With LOGO as with LOGOSPIN, you are encouraged to think of what
is seen on the screen as a turtle which draws figures as it moves
about leaving tracks. Commands such as "forward", "back",
"right", and "left" are given to the turtle to move it about. As
the turtle responds to these commands, the screen shows the
"turtle tracks" made in the form of line segments which form a
picture.
Several such commands make a complex picture of many lines.
These commands may be preserved for redrawing the picture with a
single command, the name chosen. For example, to draw a square,
there are four equal sides and four corners requiring a turn
(left or right turn). The commands to perform this function
might contain four "forward" and "right" commands. This set of
commands might be named "square". When the command "square" is
issued, the square is drawn. It is not necessary to enter all
eight commands again. Subsequently, an even more complex figure
consisting of several squares can be drawn with a new command
which calls upon "square".
LOGOSPIN provides the basic turtle commands such as forward,
back, left and right. In addition you can add your own commands
to that command set in creating colorful animated squares,
triangles, ferris wheels, or any moving figure consisting of many
line segments.
The unique feature of LOGOSPIN is the "spin" command which tells
a line to take on a spinning characteristic. This command causes
motion. Combining spin with the traditional turtle commands
provides for an infinite variety of animated drawings.
Very young children can create programs in the LOGO language.
Just as LOGO has provided uncounted hours of fun for children,
LOGOSPIN brings an animated feature to LOGO for a new fun
learning experience.
In summary, LOGOSPIN is an animated version of LOGO with only a
few commands, so it is easy to learn. Very simple little
programs can make spectacular animated drawings. Have fun
creating your own LOGOSPIN drawings.
Page 1
System Requirements
LOGOSPIN will run on any MS DOS machine (IBM compatible) with an
enhanced graphics display (EGA) or higher (VGA) and a color
monitor. The faster the processor, the more complex the
animation can become. It is strongly suggested that a processor
speed of at least 16MHz be used. 20Mhz or higher is recommended.
A printer is not required.
LOGOSPIN was developed on a 25MHz 386 based MS DOS system. Such
computing power is not required but desirable.
How to Install LOGOSPIN
A machine satisfying the requirements to run LOGOSPIN, no doubt
has a hard disk storage system. A hard disk is not required.
Simply slip the LOGOSPIN disk into the A: drive and begin having
fun right away. The only requirement in running LOGOSPIN is that
the file named DEMO be on the default directory. If that "DOS
talk" didn't make sense, that's all right too, just follow
directions.
Get the C:> prompt. This may be the way your machine starts any
way but if it isn't, exit from the menu system or shell to get
it. Place the LOGOSPIN disk into the A: drive. Then type:
md \LOGOSPIN <enter>
cd \LOGOSPIN <enter>
copy a:*.* <enter>
That's all there is to it. The first line makes a directory on
the C: drive called LOGOSPIN. The second line changes the
default directory to the LOGOSPIN directory. The third line
simply copies the distributed files to that directory.
To run the program from the C:> prompt, simply type:
cd \LOGOSPIN <enter>
ls <enter>
The first line changes the default directory to \LOGOSPIN. The
second line runs the program.
For the DOS initiated, the file DEMO is required for the title
screen and to run the demonstration and must be on the default
directory.
Page 2
A Quick Introduction for the Impatient
After viewing the title screen, press any key to get going. The
screen is blank except for the cursor in the lower left hand
corner. It means that LOGOSPIN is ready to accept commands. The
following exercise will introduce a few of the LOGOSPIN commands.
Type the following script exactly as it appears here. The symbol
<enter> means press the big enter key. In case of a typing
mistake, simply enter the back space key to erase the error. If
the enter key was pressed after a typing mistake, a message might
appear saying that LOGOSPIN did not understand what it is being
asked to do.
Type: Comment:(do not enter this)
showturtle <enter> An arrowhead, the turtle.
forward 100 <enter> A straight line pointing up.
spin 5 <enter> It is rotating clockwise at a rate of 5
spin 1 <enter> It is rotating slower.
right 90 <enter> Turtle is pointing in the new direction.
forward 75 <enter> A new line at right angles to the first.
spin 2 <enter> It is spinning faster than the first.
setcolor red <enter> Establish new color for drawing.
forward 40 <enter> New red line, same direction as second.
spin -3 <enter> Spinning in counter clockwise direction.
clearscreen <enter> Clear screen to start your own figure.
The point of this exercise is to show how interactive LOGOSPIN
actually is. Type a command like forward, right, setcolor, spin
or clearscreen and immediately see the result. You also saw how
easy it is to create multiple lines of different colors, lengths
and animation rates. Typed commands and the figure both appear
on the screen. Only the last three commands are displayed so
that the actual animation gets most of the screen.
You will soon get the hang of it. There are not many interesting
figures you can make with commands typed directly from the
keyboard. Twisting and turning multiple lines are not enough.
You will soon tire of that. Later on, you will learn how to
create programs or scripts consisting of many commands. Then you
can create figures like the ferris wheel. Experiment with the
command line though to get familiar with LOGOSPIN capabilities.
Try this to get two spinning squares:
Type:
repeat 4 forward 100 spin 3 right 90 <enter>
setcolor red <enter>
repeat 4 forward 50 spin 2 right 90 <enter>
Type quit <enter> to end your LOGOSPIN session.
Page 3
How to Run the Demo
Several interesting LOGOSPIN programs are stored on the file
named DEMO on the distribution disk. Watching them run will give
you some idea of the things that you can do by using your
imagination.
LOGOSPIN is a user supported program. See page 22 for details on
how to register. The registered version allows saving and
loading functions from the disk for later use. Version 1.0 can
only load the file DEMO and can not save procedures. It is fully
functional except for save and load.
To load and run the demonstration,
Type: Comment: (do not enter this)
load demo <enter> Loads the demo from disk file DEMO.
demo <enter> Runs the program named "demo".
The demo presents a 6 minute show. Press <Ctrl-C> if you wish to
interrupt the demo and exit to DOS. To repeat it 10 times for a
one hour show. Enter:
repeat 10 demo <enter>
The "demo" program calls programs on the demo file. Later, you
will learn how to examine each of these programs and to alter
them to suit your own fancy. For now though, just enjoy the
diverse ways that spinning lines can be put together to yield
fascinating forms. Imagination is the only limitation to what
can be done with LOGOSPIN.
For example with the demo programs loaded, try this:
cs ferris 100 <enter>
repeat 6 freeze wait 60 thaw wait 60 <enter>
Most of the demo programs are derived from more complex figures.
They have been trimmed to accommodate slower machines. Even so,
if your machine "locks up" or the screen "flickers" while running
the demo, do not despair, similar but less complex figures can
still be produced. With a 25MHz 386, as many as 120 lines of
modest length can be spinning at once. Scale it down for your
own computer speed with less complex yet fascinating animated
figures.
If the figure begins to jerk, that is an indication that drawing
so many lines is becoming difficult for your processor.
The programs contained on the demo file are listed on page 22.
Change them in any way to suit your own needs.
Page 4
The LOGOSPIN Screen
LOGOSPIN uses the EGA/VGA 640 X 350 graphics mode. Lines
consist of a number of those "dots". The coordinate system is
set up so that screen coordinate (320,175) serves as the origin.
Think of the center of the screen as having coordinate (0,0).
Any line with x coordinate between -320 and 320 and y coordinate
between -175 and 175 is displayed on screen. Positive x is to
the right, positive y is up.
Some lines twist and turn in such a way that they may exceed
screen limits. They may partially or completely disappear.
Occasionally, the line which goes off screen to the right will
reappear at the left and conversely. Lines going off screen at
the top and bottom do not reappear elsewhere.
Some versions of LOGO produce "wrap around". When a line goes
off screen anywhere, it reappears at the opposite edge. This was
considered as an option for LOGOSPIN. However, the decision not
to wrap off screen lines was based upon the time required to
perform the wrap test. If such a test were made, the maximum
number of animated lines would have been significantly reduced.
Angles are measured from the vertical position like a map or a
compass. North, or up is 0 degrees while south, or down is 180
degrees. East - to the right is 90 degrees, west - to the left
is 270 degrees.
At starting position, the turtle is located at (0,0) or the
center of the screen and it's heading is 0 or pointing toward the
top of the screen. The turtle may be commanded to alter it's
heading or its position.
Entering LOGOSPIN Commands
LOGOSPIN commands are free form. A command is entered followed
by one or more spaces followed by the value when one is required.
For example the forward command requires a value to specify the
distance the turtle should travel. Enter forward followed by one
or more blank spaces followed by a number or expression. Any
number of commands may be entered on one line. For example to
draw a red line 100 units long and spinning at a rate of 2,
enter:
setcolor red forward 100 spin 2 <enter>
Commands may be entered in capital or lower case letters. For
example forward, FORWARD, or even FoRwArD are the same.
Page 5
The LOGOSPIN Commands
The following paragraphs describe the individual LOGOSPIN
commands. Some of the commands have a short form. The short
form is an abbreviation of the longer form. For example, the
command "clearscreen" has a short form "cs" which is much easier
to enter and does the same thing. The short forms are listed
with the long form command description.
Some commands require a number to specify the value that is to be
used like spin 3. Spin tells LOGOSPIN to spin the line and 3
tells how fast. When the command requires a number, <expression>
will follow it. This means that the value can be specified
arithmetically. For example forward 35 + 6 * (2 + 3) could be
used to specify forward 65. In addition to integer values, the
expression can contain variables. For example forward x + y.
The command and expression will be followed by <enter> meaning
that the command is to be typed and then the key with the word
"enter" on it is to be pressed. Some keyboards do not actually
spell out the word but rather have a funny looking left pointing
arrow. Use that key for <enter>.
BACK (BK)
The current heading points to the way the turtle is heading.
When the back command is entered, the turtle travels in the
opposite direction or backward from the pointing direction. The
value specified by the expression tells the turtle the distance
to travel backward.
Form: Example:
back <expression> <enter> back 100 <enter>
bk <expression> <enter> bk (x + 3) * 5 <enter>
CLEARSCREEN (CS)
To start over with a clean screen, enter the clearscreen command.
In addition to clearing the screen, the current spin value,
heading and color are reset to their original default values.
Spin rate is set to zero, heading is zero or to the top of the
screen, the color value is set to white (15), and the background
color is set to black. All displayed lines are erased.
Form: Example:
clearscreen <enter> clearscreen <enter>
cs <enter> cs <enter>
Page 6
EDIT
The edit command is used in the creation of programs. The name
of the program must follow the edit command. See the later
sections on the editor and creating programs. To return to the
LOGOSPIN graphics screen, press the escape key.
Form: Example:
edit <name> <enter> edit square <enter>
FORWARD (FD)
The forward command causes the turtle to move in the direction of
the current heading value. In the case of a spinning line, the
current heading value is constantly changing. The expression
tells the turtle the distance to travel.
Form: Example:
forward <expression> <enter> forward 2 * x + 10 <enter>
fd <expression> <enter> fd 87 <enter>
FREEZE
The freeze command causes the spinning to stop. Movement can be
locked indefinitely. Lines are displayed but they do not move.
There will be no animation until a thaw command is entered.
Form: Example:
freeze <enter> freeze <enter>
HIDETURTLE (HT)
The turtle may be displayed on the screen to show the current
direction. It takes the form of an arrow pointing in the
direction of forward turtle travel. The turtle is "turned on" by
the showturtle command. Once it appears on the screen, it will
remain until turned off by the hideturtle command.
Form: Example:
hideturtle <enter> hideturtle <enter>
ht <enter> ht <enter>
Page 7
LEFT (LT)
The turtle will proceed in the current direction until commanded
to turn. The left command tells the turtle that it must change
its current direction to the left. The value specifies the angle
to turn in degrees.
Form: Example:
left <expression> <enter> left 90
lt <expression> <enter> lt (angle + 30) * 2
LOAD
The load command is honored only on the registered version of
LOGOSPIN. It retrieves a set of functions already saved to a
disk. If any function has the same name as one already defined,
it is overwritten. Load takes the disk file name as its
argument. It must be eight characters or less in length with no
extension. The file must reside on the current directory.
For the non registered version, load will work only for the file
named demo. Do not change this file.
Form: Example:
load <file name> <enter> load demo <enter>
MAKE
This command is used to set a variable to a value. In many
programming languages, a replace statement containing the "="
sign is used. See the section of LOGOSPIN variables and
expressions for a more complete discussion.
Form: Example:
make <variable> <expression> <enter> make x 30
PENDOWN (PD)
Pendown is used to reverse the command "penup". Normally, the
pen is down. Turtle motion occurs but no line is drawn if the
pen is in the penup state. Spinning takes place with either a
penup or pendown. Actually, the drawing is done with the color
black when the pen is up. Black does not show on the screen.
Form: Example:
pendown <enter> pendown <enter>
pd <enter> pd <enter>
Page 8
PENUP (PU)
Penup is used to allow motion but not to draw. It actually draws
with the color black which is transparent for any background
color. Penup can be reversed with the pendown command.
Form: Example:
penup <enter> penup <enter>
pu <enter> pu <enter>
POTS and PONS
Pots is short for print out titles and pons for print out names.
The pots command prints all program titles on screen with their
variable argument list. Pons prints the variable names and
values. If the list of titles or names is so long that they
scroll off screen, they may be viewed by using the up arrowor
down arrow keys to scroll through the list. To return to the
graphics screen, press the <escape> key.
Form: Example:
pots <enter> pots <enter>
pons <enter> pons <enter>
QUIT
The quit command exits and returns the DOS prompt. Functions
will not be saved. LOGOSPIN will also exit at any time when
<Ctrl-C> is pressed. (Hold down the Ctrl key and press C.)
Form: Example:
quit <enter> quit <enter>
REPEAT (RPT)
A set of commands can be repeated several times by using the
repeat command. For example to draw a square's four sides and
angles, four forwards and four turn commands must be entered.
Repeat saves you from all that. Just enter:
repeat 4 forward 80 right 90 <enter>
Repeat encompasses all commands to the end of the command line or
to the end of procedure in the case of programs.
Form: Example:
repeat <expression> <enter> repeat x <enter>
rpt <expression> <enter> rpt 4 <enter>
Page 9
RIGHT (RT)
The right command tells the turtle to change the direction in
which to draw the next line. It changes the current heading.
The value specifies the amount of change in degrees. The turn
direction is to the right.
Form: Example:
right <expression> <enter> right x + 45 <enter>
rt <expression> <enter> rt 180 <enter>
SAVE
The save command will save all of the current procedures to a
disk file for later replay. Save does not work on the Version
1.0 distribution disk, only for the registered version. The file
name following the save command must be 8 or fewer alpha
characters with no extension. It is not a path name so does not
recognize the drive, path or extension. The file is saved on the
current directory.
Form: Example:
save <file name> <enter> save myprogs <enter>
SETBG
To change from the black background and have the figures appear
on some other color, use the setbg command. It sets the
background to the color specified in the expression. The color
can be any number from 0 to 15. Any other number is taken modulo
15. See page 13 for the names of colors used to set the
background.
Form: Example:
segbg <expression> <enter> setbg lightmagenta <enter>
SETCOLOR (SC)
Lines drawn with the forward or the back command, are drawn in
the current color. Current color is white unless otherwise
specified by the setcolor command. See page 13 for the names of
colors used to set the current drawing color. They range in
value from 0 to 15. Any other number is taken modulo 15. The
color must be specified before the line is drawn. Once drawn,
the line color may not be changed.
Form: Example:
setcolor <expression> <enter> setcolor lightcyan <enter>
sc <expression> <enter> sc 12 <enter>
Page 10
SETHEADING (SH)
Before any line may be drawn, LOGOSPIN determines what color, and
direction to use in drawing it. The direction is zero if no
lines have been drawn and no heading has been specified. The
direction will normally be taken from the last line drawn unless
a change of position has been made. The current direction of the
last line drawn is modified by the last right or left command to
specify the current direction. Setheading however, will change
that and specify the direction of the next line drawn. The value
is in degrees.
Form: Example:
setheading <expression> <enter> setheading 60 * x <enter>
sh <expression> <enter> sh 90 <enter>
SETX (SX)
To draw at a position on the screen and start over at another
position, use the set position commands. Setx sets the current
drawing position x coordinate to the value specified and sets the
y coordinate to 0.
Form: Example:
setx <expression> <enter> setx 40 <enter>
sx <expression> <enter> sx pos - 10 <enter>
SETXY and SETPOS (SXY)
Setxy is much like setx in that it is a position command.
Drawing will subsequently start at the coordinate specified.
Notice that two arguments are required. This takes some
explanation. The expression evaluator gets confused by the use
of negative values. For example setxy 30 -10 is ambiguous to the
expression evaluator. It takes the two values and performs the
subtraction to get 20 and then looks for a second value which is
not there and issues an error message. This can be fixed by
enclosing the second value in parentheses like this:
setxy 30 (-10). Only multiple expressions beginning with the
negative sign will confuse the expression evaluator. Feel free
to enter such things as setxy 30 30 or even setxy -30 30.
Form: Example:
setxy <expression> <expression> <enter> setxy x+2 y+5 <enter>
sxy <expression> <expression> <enter> sxy 20 (-20) <enter>
setpos <expression> <expression> <enter> setpos t s-5 <enter>
Page 11
SETY (SY)
Sety is another of the position commands. It changes the current
drawing position to the location specified. The new x coordinate
will be 0 and the y coordinate will be the value of the
expression.
Form: Example:
sety <expression> <enter> sety 100 <enter>
sy <expression> <enter> sy s+100 <enter>
SHOWTURTLE (ST)
The turtle becomes visible with the show turtle command. It is
an arrowhead pointing in the current direction. It is used to
show the direction of the next line.
Form: Example:
showturtle <enter> showturtle <enter>
st <enter> st <enter>
SPIN
The spin command is what sets LOGOSPIN apart from other versions
of the LOGO language. It animates line drawings. The spin
command sets the spin speed for the next line to be drawn.
However, it also sets the spin speed for the last line drawn if
the last command was a forward or a back command. This will take
some explanation.
Enter: Comment:
forward 50 spin 3 <enter> The line spins at a rate of 3.
forward 50 rt 90 spin 2 <enter> The line spins at old rate.
Next line will spin at 2 rate.
Form: Example:
spin <expression> <enter> spin 4-x <enter>
THAW
When the freeze command has been entered and the screen animation
has stopped, the thaw command allows it to start again. If
animation is not frozen, thaw has no effect.
Form: Example:
thaw <enter> thaw <enter>
Page 12
WAIT
When LOGOSPIN encounters a wait command, it stops drawing lines
and waits for the specified time before continuing. The wait
command may be used with the freeze and thaw commands to freeze
the screen for a period of time and then continue action. There
are approximately 18 counts per second. For example wait 36 will
discontinue any further action for about 2 seconds. Animated
motion continues during the waiting period.
Form: Example:
wait <expression> <enter> wait 36 <enter>
Wait, in conjunction with freeze and thaw can temporarily stop
and start animation. For example, try this:
forward 80 spin 2 repeat 4 freeze wait 45 thaw wait 45 <enter>
The LOGOSPIN Colors
The expression used in the setcolor or setbg command specifies
one of sixteen colors. The 16 pre defined color variables and
their corresponding values are:
black is 0
blue is 1
green is 2
cyan is 3
red is 4
magenta is 5
brown is 6
lightgray is 7
darkgray is 8
lightblue is 9
lightgreen is 10
lightcyan is 11
lightred is 12
lightmagenta is 13
yellow is 14
white is 15
There are two ways to set color to red:
sc red <enter>
sc 4 <enter>
Any other value such as 17, is taken modulo 16 for a value of 1.
LOGOSPIN divides by 16 and uses the remainder.
Page 13
LOGOSPIN Variables and Expressions
A LOGOSPIN variable is created by the make command. To name and
specify the value of a variable, type make followed by the
variable name followed by the value. For example, make side 75
<enter> creates a variable named side and assigns it value of 75.
Subsequently, make side 85 <enter> will assign the value 85 to
side, the variable created with the first make command.
LOGOSPIN variables can contain up to 15 characters in their names
and have a value between -32767 and 32767. LOGOSPIN stores as
many as 50 global variables. All variables are integers with no
fraction or decimal.
The value of a variable and its name is stored into the global
variable array. Function parameter variables, described in a
later section, are local variables. There may be any number of
local variables. Functions may access a global variable at any
time. Only the function called may access a local variable. If
this is confusing, don't worry about it just use them at your
convenience.
A variable name must begin with an alphabetic character followed
by alphanumeric characters (alphabetics or numbers). Capitals or
lower case letters may be used. The name may consist of from one
to fifteen characters. For variable names longer than fifteen
characters, only the first fifteen are used. A LOGOSPIN command
can not be used as a variable name.
Legal variable names: Illegal variable names:
x 1x
ABCdefghijklmno right_side
x23 forward
Once a variable has been defined, it may subsequently be used in
expressions. For example:
Enter: Comment: (do not enter)
make len 80 <enter> assign 80 to the variable named len
forward len <enter> draw a line with length value 80
make len len + 20 <enter> assign 100 to the variable named len
Notice that len can be used in an expression only if it has been
defined. Without the first command, the second and third
commands would be ambiguous and LOGOSPIN would tell you that.
Remember the rule: A variable must be defined prior to its use in
any expression.
All constants are integers. Although 7 divided by 2 is 3 1/2,
LOGOSPIN gives 3 for the result. Division discards the
remainder.
Page 14
LOGOSPIN Variables and Expressions - Continued
To examine the current value of variables, use the pons command.
The pons command displays all of the variable names and their
values including the names of the sixteen colors. LOGOSPIN has
defined the colors so that their names rather than their numbers
may be used. For example, write setcolor red rather than the
equivalent command setcolor 4. The variable red has been
assigned the value 4.
An expression contains constants, variables and arithmetic
combinations of constants and variables. The arithmetic
operations are:
Symbol: Meaning:
+ addition
- subtraction or negation
* multiplication
/ division (integer portion only)
% modulo operator (the remainder after division)
^ exponentiation (first to the second power)
Expressions are evaluated left to right with ^ taking priority
over *,/, and %, which take priority over + and -. Parentheses
may be used to over ride the order of operations or to remove any
doubt about the order of the operations. The following examples
will explain this:
Expression: Value:
2 + 3 * 4 14
(2 + 3) * 4 20
2 * 3 + 4 10
5 + 4 * 3 ^ 2 41
3 + 5 % 2 4
(3 + 5) % 2 0
Variables can be used freely in expressions.
Enter: Comment: ( do not enter)
make side 17 <enter> Assign 17 to variable side
make x side + 1 <enter) Assign 18 to the variable x
sc x % 15 + 1 set color to 4
make s side / 2 Assign 8 to variable s
Page 15
The LOGOSPIN Editor
The LOGOSPIN editor can be used to create functions. Each
function must begin with its name and the last line must be
"end". You will find more about creating functions in the next
section.
Start the editor by entering the command:
Enter: Example:
edit <function name> <enter> edit square <enter>
The names of functions follow the same rule used for naming
variables. Start with alphabetic, followed by 14 or fewer
alphanumerics.
The editor is a full screen line editor. The function appears on
the screen as it is being entered. Long functions may scroll off
of the screen but most are very short and will be fully visible.
Enter commands just as command lines are entered. The <enter>
key will place the cursor on the next line. The position where
the next character is to be entered is indicated by the cursor.
The cursor moves in response to the arrow keys. Page down and
page up keys position the cursor a full screen away from its
current position.
The back space key erases the character to the immediate left.
The delete key deletes the character at the current cursor
position.
The editor is limited to a total of 100 lines of text. Line
length is limited to the 80 column screen limits.
How to Create a LOGOSPIN function
A LOGOSPIN function consists of a set of LOGOSPIN commands. Each
function is given a name when it is created. The function can be
regarded as a new command that has been added to those provided
originally by LOGOSPIN.
Let's illustrate this concept by example. Suppose that you want
LOGOSPIN to draw a square with side 80. If the command "square"
is entered, LOGOSPIN responds with the message "I don't know how
to square". So LOGOSPIN must be taught how to draw a square.
Enter:
edit square <enter>
Page 16
How to Create a LOGOSPIN function - Continued
The edit command changes the screen to text mode. The cursor is
located immediately following the word "square" on the first
line. The second line contains the word "end". Press the
<enter> key to enter the first command. The square can be drawn
with four sides and four turns. Work with the editor so that the
screen looks like this:
square
forward 80 right 90
forward 80 right 90
forward 80 right 90
forward 80 right 90
end
Press the escape key to return to the graphics screen.
Enter: Comment: (do not enter)
square A square.
cs clear the screen
spin 1 set the spin rate
square spinning square with rate 1
spin 2 set new rate
square spinning square with rate 2
spin 3 set new rate
square spinning square with rate 3
Three squares are spinning at different rates. To get them
coordinated:
Enter:
cs spin 1 square spin 2 square spin 3 square <enter>
See how they start together and then come back together. A new
command has been added to the list of commands LOGOSPIN
understands. The new command can now be used just as forward,
spin, or any of the other basic LOGOSPIN commands. Try creating
your own functions named triangle, pentagon, and hexagon to add
even more commands to the list.
Page 17
How to Create a LOGOSPIN function - Continued
Squares of different size than 80 might be desired. Another
square function, newsquare could be produced. Then to get a
square of another size, yet another function. Take heart, there
is an easier way. It is possible to produce a function to draw a
square of any length. Enter the editor again by typing edit
square <enter>. Then change the old square function to look like
this:
square side
forward side right 90
forward side right 90
forward side right 90
forward side right 90
end
Now the square command requires an expression specifying the size
of the side.
Enter: Comment: (do not enter)
cs start with clear screen
sc lightblue set the color to use
spin 2 set the spin rate
square 100 a spinning blue square
spin 1 new spin rate
square 75 a smaller slower square
spin 0 new spin rate
square 25 + 25 smaller square, not spinning
Functions can contain any LOGOSPIN command including newly
created ones. Let's create a new function that calls the square
function. Type edit squares <enter> and make squares look like
this:
squares size
sc red spin 1 square size
sc green spin 2 square size
sc lightcyan spin 3 square size
sc yellow spin 4 square size
end
Press the escape key to return to the graphics screen and enter:
squares 100
Four squares of different colors and spin rates appear.
Functions can use other functions as commands.
Page 18
How to Create a LOGOSPIN function - Continued
Notice that foursquares gets the value size, and passes it on to
the square function. Type cs <enter> to clear the screen and
then pons <enter> to see the value of the variables. Surprise!
Side and size are not listed. Functions use local rather than
global variables. They are not saved in the global variable
list, but are created upon entry into the procedure and destroyed
upon leaving the procedure. Press <escape> to return to the
graphics screen.
Make sure that the function has as its last line the word "end".
If not, LOGOSPIN will replace the last line with the word "end".
Type pots <enter> to see a list containing the two function names
with their arguments. Press <escape> to return to the graphics
screen.
You can learn a lot about functions by examining those on the
distribution disk. Look at the file DEMO as you would any ASCII
file with a text editor or list program. Be careful though, if
the file is changed, LOGOSPIN will not be able to read it. To
change any of the programs in the demo, load them as described on
page 4 and then edit them in any way you like.
In summary, LOGOSPIN functions extend the language. Define new
commands of your own to extend the LOGOSPIN language to suit your
own needs. Have fun.
An interesting function
Enter the editor by typing twister <enter> and create the
following function:
twister t1 t2
repeat 12
forward 40 spin 1 wait t1
forward 40 spin -1 wait t2
end
Terminate the editor by pressing the <esc> key. Several diverse
interesting figures can be obtained from the twister function.
For example try:
twister 15 30 <enter> twister 30 45 <enter>
twister 15 45 <enter> twister 30 75 <enter>
twister 15 60 <enter> twister 45 75 <enter>
twister 15 75 <enter> twister 45 120 <enter>
twister 15 90 <enter>
Page 19
Artifacts
At times, you may see something that does not quite fit your
intuition. The screen plays optical tricks on us. This section
describes some of these strange things.
The motion is not really motion at all but rather several
successive "still" frames. The still frames are refreshed at a
rate of about 18 times per second. This is sort of an optical
trick similar to motion pictures. Contrast this rate with a
motion picture which shows about 30 still frames per second. The
slower refresh of still frames causes a less smooth motion than a
motion picture. LOGOSPIN completely erases each line, calculates
its new position and then redraws it at this still frame rate.
Lines with slower spin rates appear to move smoother than those
with faster spin rates.
Line drawing is done as an "exclusive or" (XOR) write. That
means that when the line is drawn on top of its last position, it
is effectively erased. For example:
Enter:
forward 100 back 50 <enter>
Two lines are drawn. The last line partially covers the first.
The "exclusive or" write performs the erasure. However, the
screen refresh rate is different than the redraw rate causing the
erased line to appear dim but still visible.
Other surprises come from the wrap around phenomenon. In
designing LOGOSPIN, a decision was made to draw the screen lines
as rapidly as absolutely possible since they had to be drawn
twice 18 times per second. Lines drawn off screen, disappear and
in some cases it reappear in unexpected places. LOGOSPIN does
not check for off screen writes. Screen writes are made
regardless of the violation of x and y coordinate values. Since
the writes are direct screen memory writes, they go somewhere and
sometimes that is in strange and unexpected places.
Lastly, there is the wagon wheel phenomenon. In some old western
movies, the wagon wheel appears to be moving backwards until it
slows and then suddenly it appears to move forward. Again this
is an optical trick played on us by the 30 frames per second
refresh rate. In its simplest form the same effect can be
obtained by drawing a line and giving it a spin rate of 359. It
is actually spinning at a 359 rate but appears to the eye to be
spinning with a -1 rate.
Page 20
Technical Stuff for the Techies
This section is intended for those interested in the technical
stuff. If you don't understand it that's OK, I may not have
explained it that well. Have fun with LOGOSPIN anyway.
LOGOSPIN is written in Turbo C++ but does not use the object
oriented feature of the compiler. Some day, I will get the hang
of object oriented programming. For this project, I just didn't
take the time. Frequent use is made of the in line assembler.
The line drawing function is assembled with the Turbo assembler
provided with C++ Professional. The line drawing efficiency
using Bresenham's algorithm was very important to get as many
lines moving as possible. It was carefully coded with speed
being the most important design criterion.
The lines are drawn in an interrupt service routine. It tails
off of the system timer at the 18.2 system rate. A more frequent
interrupt could be set up but as it turns out, the 18.2 rate
gives a fairly smooth appearance and at the same time draws about
80 to 100 lines before getting too much flicker. As a compromise
between complexity of the drawing and smoothness of the motion,
it appears that 18.2 is not a bad selection after all. Some
folks will not have the hot machine necessary to draw as many as
100 lines but still they have as much capability as possible.
The interrupt service routine works from a display list, an array
of structures each containing the current state of the line - the
end points, spin rate, color, heading, etc. When the interrupt
occurs, the display list is scanned so as to draw the entire list
in the "exclusive or" mode. Then it is scanned the second time
to update the headings and positions and to draw the lines in
their new positions. The redraw is what gives the illusion of
motion.
LOGOSPIN does not always "close" a figure properly. After
drawing several lines, numerical round off can cause error to
accumulate. This could have been avoided by higher precision
methods but the time trade off did not seem to be worth it.
The display list is constructed in response to commands entered
on the command line or extracted from functions. LOGOSPIN is an
interpreter. It scans its input, either the command line or the
function and tokenizes it. The tokenized list is passed to the
command interpretation module which is really a rather large
switch statement, one position for each command. Each position
performs its function of setting variables or drawing lines.
Since both the interrupt service routine and the command
interpreter alter the display list, conflicts are avoided by
disabling interrupts in the command interpreter.
Page 21
Tecnical Stuff for the Techies - Continued
Recursive descent is employed in the expression evaluator. It
evaluates the expression from tokenized input and returns the
integer value. Future improvements probably will expand the
evaluator to include comparison operators.
The sine and cosines required to draw the lines in the proper
directions are obtained through table look up. They are stored
as integers and only integer arithmetic is used. Their product
with the line length is truncated to integer length. Figure
closure could be improved by carring both the integer and
fractional part of the product but in the interest of speed, only
the integer portion is carried on.
Function calls are performed by recursive calls to the function
evaluator including passing the arguments as automatic variables.
This allows for recursive functions but at this time, they are
not permitted since there is no provision for the
if...then...else construct. Future versions will include that
feature.
Page 22
Demo file program list
First level functions call second level functions whose names are
indented.
Program name and arguments: Example:
demo demo
twist twist
tree size number tree 30 5
triframe size rate triframe 60 4
ferris radius ferris 100
ferriscar carsize ferriscar 20
blast size blast 90
blastleg size blastleg 90
stars size stars 60
jumpingjacks size jumpingjacks 75
waves nlines size waves 25 75
wipers length wipers 100
drillteam ntimes drillteam 12
outblast size rate1 rate2 outblast 90 1 2
oleg size rate1 rate2 oleg 90 1 2
four size rate four 50 3
squarespin size rate squarespin 90 1 2
boom size boom 30
trianglespin size trianglespin 30
spider size rate spider 45 2
leg size rate leg 45 2
segment size rate segment 45 2
kaleid size kaleid 60
ksp size ksp 60
twosheets size twosheets 120
obthree firstrate secondrate thirdrate obthree 1 2 3
obthreeleg firstrate secondrate thirdrate obthreeleg 1 2 3
wave nlines length wave 30 100
threesaws threesaws
sawblade sawblade
box size spin1 spin2 box 50 1 2
fish nlines length fish 15 110
squareandstar squareandstar
ssstar ssstar
sssquare sssquare
wave2 nlines length wave2 22 80
twins twins
build size build 150
split split
gears gears
gear color startangle nteeth center length rate
gear 4 10 12 0 60 4
Page 23
Registering LOGOSPIN
LOGOSPIN is a user supported program. User supported programs
are freely distributed through various bulletin boards, shareware
distributors, and networks of friends. You are encouraged to
copy user supported programs and to give them to any one who is
interested. The user supported or shareware concept allows you
to try before you buy.
If you find the program interesting and useful, it may be
registered with the author. Registration has several benefits.
In the case of LOGOSPIN, you will get the registered version
which will load and save functions. In addition, you are placed
on the user data base and will receive information on any updates
or upgrades. Some additional interesting functions are included
in the registered version. LOGOSPINPIN is in the formative
stages and will undergo several upgrades. Registered users will
be informed of these important enhancements.
To register the program, make a copy and fill out the form found
on the next page. Inform the author about what you like and
dislike about LOGOSPIN when you register it. Report bugs. Tell
me what you think would improve its usefulness. Send a copy of
one your clever functions. Perhaps it can be included in future
releases. Most of all, I hope you have as much fun using
LOGOSPIN as I had in producing it.
Page 24
LOGOSPIN REGISTRATION FORM
Yes, I want to register LOGOSPIN and receive the registered
version. I have enclosed $25 as a donation in support of quality
shareware programs.
Name ________________________________________________________
Organization ________________________________________________
Street_______________________________________________________
City, State, Zip_____________________________________________
Check one: 5 1/4" disk [ ] 3 1/2" disk [ ]
Your Comments Please:____________________________________________
_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
Enclose your check for $25. U.S. Dollars.
Mail your check and this completed form to:
Sidney D. Nolte
13858 Peyton Drive
Dallas, Texas 75240