Turtle Graphics Interpreter for the Commodore 64 by Irwin Tillman
From COMPUTE!'s Gazette Magazine and Disk October 1984 (Issue 16 Vol. 2, No. 10)

This version of Logo is written almost entirely in BASIC. It is possible to alter, improve, and expand the program. It is quite slow and runs considerably better on an emulator in high-speed or warp mode. It could also be adapted to take advantage of the Commodore 128's powerful drawing commands. The article
includes instructions for adapting this program to work with a tape drive. This version of Logo is in NOWRAP mode, also known as FENCEd mode, which prevents the turtle from leaving the screen. Instead the turtle will trail along the edge of the screen. Also, as computers of the 80's used TVs and monitor
that did not have square pixels, drawing squares and circles would be stretched. In line 50 of "TURTLE GRAPHIC 1" you will see the variable CR=.74. CR "crunches" the scaling on the Y axis, creating correctly proportioned squares and circles on most TVs and monitors. However, on emulators, it reverses the effect, enlongating the shapes. Changing this value to 1 should solve the problem.

The included Work Disk has several examples. Examine their code to see how they work.

Command / Short Form / Examples with Inputs
Explanation or Notes

--------
Turtle Commands and Primitives:

FORWARD	FD	FORWARD 50

RIGHT		RT	RIGHT 90

LEFT		LT	LEFT 90

REPEAT	RP	REPEAT 4 [FD 50 RT 90]

PENUP		PU	-
stops turtle from drawing

PENDOWN	PD	-
starts turtle drawing (default)

PENERASE	PE	-
turtle erases lines and dots if PENDOWN

PENDRAW	PW	-
turtle draws if PENDOWN (returns to current PENCOLOR) (default)

PENCOLOR	PC	PENCOLOR 0
				0 = black
				1 = white
				2 = red
				3 = cyan
				4 = purple
				5 = green
				6 = blue
				7 = yellow
				8 = orange
				9 = brown
				10 = light red
				11 = dark gray (gray 1)
				12 = medium gray (gray 2)
				13 = light green
				14 = light blue
				15 = light gray (gray 3)
pencolor changes the color of the entire picture, thereby avoiding Commodore color conflicts (where one color bleeds into another)

BACKGROUNDCOLOR	BC	BACKGROUNDCOLOR 0
				see color list above

TURTLECOLOR		TC	TURTLECOLOR 0
				see color list above

SHOWTURTLE		ST	-
(default)

HIDETURTLE		HT	-

CLEARSCREEN		CS	-
sets turtle position to 0,0 heading 0 (HOME) & clears graphics
screen

HOME			-	-
sets PENUP mode, sends turtle to position 0,0 heading 0, then
returns to whichever mode turtle was in before

CLEAN			-	-
clears graphics screen but does not send turtle HOME

SETHEADING		SETH	SETHEADING 0
				SETHEADING -90
sets turtle's heading

SETPOSITION		SETP	SETPOSITION 0 0
				SETPOSITION -50 -50
sets PENUP mode, sets turtle's X and Y coordinates, then
returns to whichever mode turtle was in before

PRINTHEADING	-	-
prints turtle's heading

PRINTPOSITION	-	-
prints turtle's X and Y coordinates

QUIT			-	-
quits TGI but does not reset computer or erase program or
procedures in memory. CONT will continue from where you were.
RUN will clear memory and restart TGI for another user.

-----------
Editing Commands:

DEFINE	-	DEFINE PROCEDURENAME
enters input mode, displaying procedure name folled by a
question mark and a space, allowing two lines of procedure to
be input; 80 characters less the length of procedure name and
less the question mark and space following it. Interestingly,
it allows redefining of preset commands and primitives

ERASE		-	ERASE PROCEDURENAME
clears memory of specific procedures

ERASEALL	-	-
clears memory of all procedures

NAMES		-	-
lists names of all procedures in memory, will overrun text area

PRINTPROCEDURE	PPROC	PRINTPROCEDURE PROCEDURENAME
lists the contents of specific procedure, will overrun text
area

RENAME	-	RENAME OLDPROCNAME NEWPROCNAME
renames a procedure

-----------
File Commands:
It is recommend not to use quotes.

LOAD		-	LOAD FILENAME
			LOAD "FILENAME
			LOAD "FILENAME"
reads in a set of procedures from a file on disk, quotes MUST
be consistent; if SAVEd with single or double quotes, can only
be LOADed with single or double quotes

SAVE		-	SAVE FILENAME
			SAVE "FILENAME
			SAVE "FILENAME"
saves a set of procedures in a file on disk, quotes MUST be
consistent; if SAVEd with single or double quotes, can only be
LOADed or SCRATCHed with single or double quotes

SCRATCH		-	SCRATCH FILENAME
			SCRATCH "FILENAME
			SCRATCH "FILENAME"
erases a file on disk, quotes MUST be consistent; if SAVEd with
single or double quotes, can only be SCRATCHed with single or
double quotes

------------
Key Commands:

CLR/HOME	clears the text portion of the screen and homes the cursor (regardless of whether the SHIFT key is pressed)

f1 		changes the border color

f3		changes the text-background color

CRSR keys	trying to move from the text window into the hires screen will be treated as a CLR/HOME

------------
Note: CTRL-G on most Logo's will break the turtle out of a loop. In Turtle Graphics Interpreter, this option doesn't exist. However it can be replicated by pressing RUN/STOP and typing GOTO 150. This will not clear the memory and all your procedures will still exist. If you hit RUN/STOP and RESTORE, type GOTO 120 to bring back the drawing screen (the screen will be CLEANed, and the turtle will not be HOMEd.) Again, your procedures will be intact. It is recommended that you save your procedures and restart the program, as it can become unstable.
