Classic Computer Magazine Archive COMPUTE! ISSUE 40 / SEPTEMBER 1983 / PAGE 166

VIC PILOT

Mark Haugan

Just type in this program and you've got a completely new language you can use with your VIC: Turtle PILOT. For many applications, this language is superior to the BASIC that comes with the computer. If you're interested in a new, easy way to produce startling graphics; or in fractals and recursion; or in introducing Turtle graphics to a youngster - it's all possible with this PILOT and its high-resolution graphics capabilities. You'll need at least an 8K RAM memory expander. The Super Expander is optional.



It is difficult to exaggerate the interest and excitement being generated by Turtle Graphics and the languages, Logo and PILOT, that support it. Home-computer users, educators, mathematicians, and, of course, kids are all fascinated with "The Turtle." You need look no further than David Thornburg's "Friends of the Turtle" column in each month's COMPUTE! to see evidence of this.
    However, if you are a VIC user, you may be feeling left out. Although the VIC has excellent graphics capabilities, no package of Turtle Graphics commands that fully exploit these capabilities seems to be available. The programs included with this article will provide VIC users with a PILOT interpreter and high-resolution Turtle Graphics. You must have at least 8K RAM expansion. If you also have a Super Expander, there is an extra program that will really speed things up.

The PILOT Interpreter
    The PILOT interpreter included here is an extension of the core PILOT interpreter written in BASIC by Michael Tinglof (COMPUTE!, December 1982). His PILOT provides commands for displaying written information on the screen and for accepting and testing responses from the keyboard. To this core I've added a set of Turtle Graphics commands which control the location, heading, and motion of an imaginary turtle that inhabits the graphic screen.
    The turtle can leave a trail as it moves around the screen. The trail forms the graphic design. The interpreter understands commands which control whether a trail is left along any particular portion of the turtle's path; its color, assuming a trail is left; and the colors of VIC's screen and border. Most people find the "Turtle" approach to graphics simpler than the "Cartesian" approach (turn on the pixel, or dot, at screen coordinate x,y) because they can imagine themselves in the place of the turtle and "walk through" a desired design as an aid to programming it.
    Two versions of the interpreter are provided. Program 1 will run on a VIC with 8K or more expansion RAM added. It provides a 160x176 pixel high-resolution graphics screen and roughly 2K bytes for PILOT programs. You can, of course, add memory as you like. This version of the interpreter plots the path of the turtle point-by-point in a fashion that will be familiar to anyone who has worked with VIC's high-resolution screen. The result is a nice, sharp graphic display, but the procedure is slow - it provides turtle graphics in every sense of the word.
    If you have the Super Expander cartridge in addition to at least 8K of expansion RAM, type in Program 1, but make the substitutions shown in Program 2. The machine language graphics routines of the Super Expander are used to overcome the speed problem of the other PILOT version. Typical Turtle Graphics programs now run in tens of seconds. Even when the turtle's path consists of an immense number of tiny steps and plotting may take a few minutes, the Super Expander version runs about twice as fast as the first. If you are planning to work with a young child with a short attention span, this extra speed could be very important. For that matter, anyone wanting to experiment extensively with Turtle Graphics would probably prefer a faster turtle.
    The Super Expander version provides a 160x160 pixel high-resolution graphics screen and with an 8K RAM cartridge you have, once again, roughly 2K bytes for PILOT programs.
    Toward the end of this article we'll discuss a few PILOT programs to demonstrate some of the capabilities of this interpreter. But first, let's talk about the turtle commands that the interpreter understands and, also, briefly review the operation of the editor and the PILOT commands, instructions, and variable conventions that are inherited from Michael Tinglof's interpreter.

The Editor
The PILOT editor is precisely like the BASIC editor. To enter a program line, type the line number, the PILOT statement, and hit RETURN. To correct an error, move the cursor to it, type the correction, and hit RETURN. Alternatively, you may simply reenter the entire program line. As in BASIC, the editor assumes that anything entered without a line number is a command.

The Commands
The editor understands the following commands:
  • LIST xx-yy - Lists the program lines between the specified line numbers. Either or both of the line numbers may be absent.
  • RUN - Executes the PILOT program in memory.
  • SAVE name - Saves the program in memory on cassette.
  • LOAD name - Loads the program from cassette.
  • NEW - Clears program memory.
  • BASIC - Exits the interpreter and returns to BASIC.
  • PLIST xx-yy - Same as the list command except that output is sent to the printer, device 4.
    Note that command names may be shortened, even to a single letter. For example,

    L 10-25 for LIST 10-25
    R          for RUN.

PILOT Instructions
PILOT statements, with the exception of labels, consist of an instruction name, an optional conditioner, a colon, and an object. The object is simply everything that follows the colon and is optional with some instructions.
    The interpreter understands the following PILOT instructions:
    T: The TYPE instruction prints everything in the object on the screen. This may be text or variables. For example,

10 T:ANGLE=#A

prints "ANGLE = xx" where xx is the value for the numerical variable #A. Note that no carriage return will be printed if a T: instruction is ended with a ";".
    A: The ACCEPT instruction inputs a response from the user. The user must hit RETURN to complete a response. The object of an A: instruction may be a numerical or string variable, but no object is necessary. The user's response will be assigned as the variable's value if an object is given. It will be assigned to a buffer that can be used by the MATCH instruction when no object is present.

15 A:
20 A:$V

    M: The MATCH instruction checks to see if certain strings are present in the contents of the Accept buffer or in a string variable. If so, the Y-conditioner flag is set. If not, the N flag is set. For example,

15 M:12,TWELVE,XII,1100,$OC

sets the Y flag if any of these representations of twelve is present in the Accept buffer, while

20 M:$L,SUPERIOR,MICHIGAN,HURON,ERIE,ONTARIO

sets the Y flag if the string variable $L contains any one of these Great Lakes names.
    I: The IF instruction is a nonstandard instruction implemented by Michael Tinglof to allow mathematical testing to set the Y and N flags. It can check to see if a given variable is greater than, less than, or equal to a given value or a second variable. The Y flag is set if the expression in the object of the instruction is true. Otherwise, the N flag is set. Only =, <, and > can be used in expressions. Sample instructions are

30 I:#N=9
35 I:#N<#L

    J: and U: The JUMP and USE instructions are the analogues of BASIC's GOTO and GOSUB statements. However, either labels or line num bers may be used in PILOT to specify where in a program these instructions are to transfer control.

35 J:5
20 U:*SHIFT

    E: The END instruction is the analogue of BASIC's RETURN statement. It transfers control to the program line following the last U: instruction executed by PILOT.
    C: The COMPUTE instruction performs simple four-function calculations in linear order (no parentheses). The object of this instruction must be an equation specifying the value of a numerical variable. The expression on the righthand side of the equation is evaluated and the value of the variable is set to the result.

15 C:#N=#G*10/#T+15

Note that if #R is encountered in the expression, its value will be set to a random number between 0 and 1.
    R: The REMARK instruction is not executed. Its object may be any desired program documentation.
    H: The HOME instruction clears the text screen and returns the cursor to home.
    G: The GRAPHICS instruction takes as its object any of the turtle commands discussed below. For example,

12 G:DRAW 50

    END This instruction stops execution of a PILOT program and returns control to the editor. It may not be abbreviated and is the only in struction that cannot be modified by a Y or N conditioner.

100 END

    Conditioners: PILOT instructions can be modified by the addition of a Y or N conditioner. For example,

50 TY:VERY GOOD $N.
60 JN:*START

Y-conditioned instructions will be executed only if the Y flag is set. Similarly, N-conditioned instructions will be executed only if the N flag is set. Remember that these flags are set by MATCH and IF instructions.
    Labels: These are designated by beginning a line with *. For example,
.
.
10 *LOOP START
25 JY:*LOOP START
.
.

PILOT Variables
The interpreter recognizes both string and numerical variables. String variable names consist of a $ followed by a single letter. Numerical variables are integer variables. Their names consist of a # followed by a single letter.

Turtle Commands
Each of the commands described here must be preceded by a G: instruction. Command names may be abbreviated, even to a single letter, although, as we'll see, other parts of commands such as color names may not be shortened.
    CLEAR - This command sets and clears the VIC's high-resolution screen. It initializes the color of the screen to white, the border to blue, and the color of the turtle's trail to black. The CLEAR command also initializes the turtle's heading to zero degrees, north, and its location to center screen, X and Y coordinates (0,0). The CLEAR command must be the first in any graphics routine.
G: CLEAR
GY:C

    TURN - The TURN command is followed by a number or a numeric variable. The number or the value of the variable is the number of degrees added to the turtle's current heading. A positive value turns the turtle clockwise.
G:TURN -270
G:T #A

    TURNTO - This command sets the turtle's heading to the specified angle. The word TURN in TURNTO may be abbreviated, but TO must be included at the end of any abbreviation of TURNTO. For example,
G:TURNTO 90
G:TTO #A

    DRAW - The DRAW command moves the turtle the specified distance along its current heading. The turtle will leave a trail if its pen is down (see the PEN command below). When using the Super Expander version, program execution will cease and you will receive a warning message if you attempt to DRAW off screen. With the other version, the turtle will proceed off screen. You will receive a message informing you that the turtle left the screen at some point during program execution when you return to text mode.
G:DRAW 50
G:D #L

    GO - The GO command moves the turtle the specified distance along its current heading without leaving a trail. The command is equivalent to DRAW with PEN UP.
GN:GO 45
G:G #D

    GOTO - This command moves the turtle to the specified screen coordinates without changing its heading. The X and Y coordinates are separated by a comma in the GOTO statement. The range of X coordinates on the screen is -106.65 to 108, and the range of Y coordinates is =87 to 88. When using the Super Expander interpreter, the Y coordinates are -79 to 80.
G:GOTO #X,#Y
G:GTO -15,35

    PEN - The PEN command controls the color of the turtle's trail on the screen. With the VIC, it is possible to use several pen colors on a single graphics display. Allowed color names are BLACK, WHITE, RED, CYAN, PURPLE, GREEN, BLUE, and YELLOW. If the PEN command is followed by the word ERASE, the pen color is set to the screens current color. The PEN command may also be followed by the words UP and DOWN. PEN UP causes DRAW commands to move the turtle without leaving a trail. PEN DOWN returns the pen to normal. Note that color names and the other pen control words may not be abbreviated.
G:PEN GREEN
G:P DOWN

SCREEN - This command changes the color of the graphics screen without clearing it. The same colors are available as for the PEN command.
G:SCREEN RED
G:S CYAN

    BORDER - This command controls the color of VIC's screen border. Once again, the colors already mentioned are available.
G:BORDER YELLOW
G:B RED

    QUIT - The QUIT command returns the text screen. When this command is encountered, the graphics screen will be held until you enter Q from the keyboard. This lets you control the amount of time you spend admiring your turtle handiwork.
    In general, QUIT must be the final command of a graphics routine. The only exception occurs when the turtle is sent along an infinite path (it may loop back on itself). In this case a QUIT command would never be reached, and you exit graphics mode by hitting
G:QUIT
GY:Q

    One structure that occurs frequently in Turtle Graphics programs is a sequence of DRAW and TURN commands. This is done to draw polygons of various types. The interpreter understands one compound command that performs this task easily.

G:xx(DRAW yy;TURN zz)

xx must be an integer. yy and zz may be integers or integer variables as for single DRAW and TURN commands. For example,
G:9(D 50;T 160)
G:5(DRAW #L;TURN 72)

Program Operation
All of VIC's internal memory is required to produce the high-resolution screen for Turtle Graphics. For this reason, the start of BASIC must be moved to location 8192, the beginning of BLK1 of expansion RAM, before loading and running either version of the interpreter. This is accomplished by typing in this direct statement before doing anything else:

POKE 44,32:POKE 642,32:POKE 8192,0:NEW

The interpreter takes up about 5K of RAM memory, and 1K is required for system initialization. So, with 4K allocated to screen and programmable character memory, you can see why there is only 2K left for PILOT programs on an 8K-expanded VIC. Note that the maximum allowable number of PILOT program lines is contained in the variable M in line 6 of the interpreter. This number may be changed.
    To stop any PILOT program, you simply hit the @ key. If you are in graphics mode, the text screen will automatically return. Note that the @is accepted only when execution of the current PILOT program line has been completed. If this line should be, for example, a long turtle loop like

G:180(D 1;T 2)

there will be a noticeable delay before the program halts.
    If for any reason the program returns to BASIC, you may reenter the interpreter without losing the current PILOT program by typing GOTO 11 and hitting RETURN. This means that you may hit RUN/STOP and RESTORE to regain control if the interpreter "locks up " (if, for example, you forget a G:QUIT statement and get stuck with the graphics display on screen). You then type GOTO 11 and hit RETURN to resume work on your program.

    When loading PILOT programs (if the NEW command has not been given) the current program and the new one are merged. If you wish to operate the interpreter with disk rather than cassette storage, the following program changes are required:

41 OPEN1,8,2,R$+",S,W":PRINT"SAVING "R$
45 OPEN1,8,2,R$+",S,R":PRINT"LOADING "R$

In addition, to save a program on drive 0 the syntax of the SAVE command must be altered to

    SAVE 0:name

    The following error codes may be generated when a PILOT program is run:

    1. Illegal variable name
    2. Unknown label
    3. Stack overflow (too many USES)
    4. Stack empty (an E: without a USE)
    5. Bad format
    6. Division by zero
    7. Numerical variable out of range (magnitude greater than 32767)
    8: CLEAR not the first graphic command

    Finally, it should be remarked that the PILOT interpreter is not as indifferent about spaces scattered through program lines as the BASIC interpreter is. The PILOT interpreter will remove spaces before a line number or a command and will remove extra spaces between line numbers and instruction names. However, extra spaces elsewhere in a program line may confuse the interpreter. Also, spaces as shown in the sample commands are necessary. For example, there must be a space between DRAW and #L in

50 G:DRAW #L

Sample Turtle Graphics Programs
The three sample programs here serve to demonstrate the graphics capabilities of this PILOT interpreter. There's a little something for everyone: a typical turtle pattern made of shifted and rotated squares, a picture for the kids, and a recursive binary tree program for the mathematically minded. Although no abbreviations are used in Program 3 (to make it easy to follow), they are included in the other two programs to demonstrate their use.
    "Pretty Pattern" (Program 3) draws a picture that is typical of turtle designs made up of simple polygons. In this case the polygons are squares, and they are shifted and rotated relative to each other to form the design. A star is formed by the overlapping squares at the center of the pattern. After drawing six squares, the turtle returns to its initial location and heading. The program is written so that the turtle loops around its six-square path again and again, forever. As a result, no G:QUIT and END statements are needed. Exit the program by hitting the 0) key. It only takes about 20 seconds for the "fast" (Super Expander) turtle to make its way around the design.
    Program 4, "Teddy Bear," is fun for children. Fairly rough circles are used in the design to reduce the time for drawing to 90 seconds with the "fast" turtle. When the program reaches the G:QUIT statement in line 29, execution will halt until you hit the "Q" key. Note that it is quite easy to turn this bear into a rabbit by designing ears made using two quarter circles for each ear.
    Finally, for those of you who are interested in recursion, Program 5, "Recursive Tree," draws a simple binary tree. The way in which the tree is drawn by the procedure *BRANCH is of particular interest. This procedure calls itself repeatedly. To understand how this is done using only global variables, it is helpful to study the listing and to run the program. When you run it, select final branch level 1, then level 2, and so on to see the order in which the branches are drawn. The VIC's screen resolution produces nice pictures of the tree up to level 5 and even level 6.

Further Suggestions
My goal while developing this PILOT interpreter was to make Turtle Graphics available on a VIC with only 8K bytes of expansion RAM added. I have "crunched" the program to achieve this goal (the few REMs scattered through the listings are to keep the line numbers of the two versions of the interpreter aligned), but there are a few features I simply could not squeeze in. If you have more memory and the inclination, you might want to extend the program.
    I regret not being able to include the capability for mixing text and graphics on the high-resolution screen. This means that you really cannot run a program like VISITURT ("Friends of the Turtle," COMPUTE!, April 1982) which makes the turtle interactive. The necessary prompts cannot be written onto the graphics screen.
    This is unfortunate because an interactive turtle would be very nice for children to work with. It would, however, be fairly simple to add a mixed text-graphics mode, if you have access to the Super Expander command CHAR. Other possible additional features include adding a SOUND command like the one in Atari PILOT or the ability to use VIC's multicolor mode.

Program 1: PILOT Interpreter

0 GOTO4
1 I$=""
2 SYS820:IFPEEK(0)=13THENRETURN
3 I$=I$+CHR$(PEEK(0)):GOTO2
4 POKE36866,150:POKE36869,240:POKE648,30
5 FORJ=217TO228:POKEJ,158:NEXT:FORJ=229T
  O250:POKEJ,159:NEXT
6 CLR:M=200:DIMS%(9),N%(26),S$(26),L$(M)
  ,C$(17),G$(7),B$(10)
7 PRINT"(CLR}(BLK) **** PILOT V2.1 ****"
  :FORX=820TO825:READZ:POKEX,Z:NEXT:FORX
  =0TO17
8 READC$(X):NEXT:FORX=OT07:READG$(X):NEX
  T:FORX=OT010:READB$(X):NEXT:DATA32,207
  ,255,133
9 DATA0,96,LIST,RUN,SAVE,LOAD,NEW,BASIC,
  PLIST,T,J,E,U,M,C,A,I,H,R,G,CLEAR,QUIT
  ,TURN
10 DATADRAW,GO,PEN,SCREEN,BORDER,BLACK,W
   HITE,RED,CYAN,PURPLE,GREEN,BLUE,YELLO
   W,ERASE,UP
11 PRINT"(DOWN}PILOT.":DATADOWN
12 GOSUB1:PRINT:IFASC(I$)=32ANDLEN(I$)=1
   THEN12
13 IFLEFT$(I$,1)=" "THENI$=MID$(I$,2):GO
   TO13
14 L=VAL(I$):IFL<>0THEN23
15 L=1:H=M:R$="":FORX=ITOLEN(I$):IFMID$(
   I$,X,1)<>" "THENNEXT:GOTO21
16 R$=MID$(I$,X+1):I$=LEFT$(I$,X-1)
17 L=VAL(R$):H=L:FORX=ITOLEN(R$):IFMID$(
   R$,X,1)<>"-"THENNEXT:GOTO19
18 L=VAL(LEFT$(R$,X-1)):H=VAL(MID$(R$,X+
   1))
19 IFL=0THENL=1
20 IFH=0THENH=M
21 FORX=0TO6:IFI$<>LEFT$(C$(X),LEN(I$))T
   HENNEXT:PRINT"UNKNOWN COMMAND.":GOTO1
   1
22 ONX+IGOTO32,51,41,45,49,50,31
23 IFL>MTHENPRINT"LINE NUMBER OUT OF RAN
   GE.":GOTO11
24 X=LEN(STR$(L)):X$=MID$(I$,X):IFX$=""T
   HENL$(L)="":GOTO12
25 IFLEFT$(X$,1)=" "THENX$=MID$(X$,2):GO
   TO25
26 X=3:IFMID$(X$,2,1)<>":"THENX=4:IFMID$
   (X$,3,1)<>":"THENL$(L)=X$:GOTO12
27 FORZ=7TO17:IFLEFT$(X$,1)<>C$(Z)THENNE
   XT:PRINT"ILLEGAL COMMAND.":GOTO11
28 IFMID$(X$,2,1)="Y"THENZ=Z+13
29 IFMID$(X$,2,1)="N"THENZ=Z+26
30 L$(L)=CHR$(Z-6)+MID$(X$,X):GOTO12
31 OPEN1,4:GOTO33
32 OPEN1,3
33 FORX=LTOH:IFL$(X)=""THEN39
34 X$=":":Z=ASC(L$(X)):IFZ>40THENX$=LEFT
   $(L$(X),1):GOTO38
35 IFZ>26THENZ=Z-26:X$="N"+X$
36 IFZ>13THENZ=Z-13:X$="Y"+X$
37 X$=C$(Z+6)+X$
38 PRINT#1,X;X$;MID$(L$(X),2)
39 GETX$:IFX$<>""THENCLOSE1:GOTO11
40 NEXT:CLOSEI:GOTO11
41 OPEN1,1,1,R$:PRINT"SAVING "R$
42 FORX=ITOM:IFL$(X)=""THEN44
43 PRINT#1,X;CHR$(13)CHR$(34)L$(X)CHR$(3
   4)CHR$(13);
44 NEXTX:CLOSE1:GOTO11
45 OPEN1,1,0,R$:PRINT"LOADING "R$
46 INPUT#1,X:IFSTTHEN48
47 INPUT#1,L$(X):IFST=0THEN46
48 CLOSEI:GOTO11
49 GOTO6
50 PRINT"(DOWN)EXITING TO BASIC....":END
51 L=0:FORX=1TO26:N%(X)=O:S$(X)="":NEXT:
   P=0:F%=0
52 L=L+1:IFL=>MORL$(L)="END"THEN11
53 GETX$:IFX$="@"ANDCQ%=0THEN11
54 IFX$="@"ANDCQ%=1THENGOSUB127:GOTO11
55 IFL$(L)=""THEN52
56 X=ASC(L$(L)):IFX>40THEN52
57 IFX>26THENX=X-26:IFF%=1THEN52
58 IFX>13THENX=X-13:IFF%=0THEN52
59 C$=MID$(L$(L),2)
60 ONXGOTO62,73,76,71,78,85,101,106,115,
   52,116
61 PRINT"ERROR #"E"IN LINE"L:GOTO11
62 Z=0:IFRIGHT$(C$,1)=";"THENZ=1:C$=LEFT
   $(C$,LEN(C$)-1)
63 FORX=ITOLEN(C$):X$=MID$(C$,X,1):IFX$=
   "#"THEN67
64 IFX$="$"THEN68
65 PRINTX$;:NEXT:IFZ=OTHENPRINT
66 GOTO52
67 GOSUB69:X$=STR$(N%(Y)):GOTO65
68 GOSUB69:X$=S$(Y):GOTO65
69 X=X+1:Y=ASC(MID$(C$,X,1))-64:IFY<1ORY
   >26THENE=1:GOTO61
70 RETURN
71 IFP>8THENE=3:GOTO61
72 P=P+1:S%(P)=L
73 IFVAL(C$)<>OTHENL=VAL(C$)-1:GOTO52
74 FORX=ITOM:IFC$<>L$(X)THENNEXT:E=2:GOT
   O61
75 L=X:GOTO52
76 IFP=OTHENE=4:GOTO61
77 L=S%(P):P=P-1:GOTO52
78 X=1:C$=C$+",":X$=AC$:IFLEFT$(C$,1)="$
   "THENGOSUB83
79 FORZ=XTOLEN(C$):IFMID$(C$,Z,1)<>","TH
   ENNEXT
80 Z$=MID$(C$,X,Z-X):FORY=ITOLEN(X$):IFM
   ID$(X$,Y,LEN(Z$))=Z$THENF%=1:GOTO52
81 NEXT:IFZ<LEN(C$)THENX=Z+1:GOTO79
82 F%=0:GOTO52
83 Y=ASC(MID$(C$,2))-64:IFY<1ORY>26THENE
   =1:GOTO61
84 X$=S$(Y):X=4:RETURN
85 A=3:Z=0:X$="":IFLEFT$(C$,1)<>"#"ORMID
   $(C$,3,1)<>"="THENE=5:GOTO61
86 Y=1:X$=MID$(C$,A,1):A=A+1:IFMID$(C$,A
   ,1)="-"THENA=A+1:Y=-1
87 IFMID$(C$,A,1)<>"#"THENY=Y*VAL(MID$(C
   $,A)):A=A+LEN(STR$(Y))-1:GOTO91
88 X=ASC(MID$(C$,A+1))-64:IFX<1ORX>26THE
   NE=1:GOTO61
89 IFX=18THENY=Y*RND(1):GOTO91
90 Y=Y*N%(X):A=A+2
91 IFX$="="THENZ=Y
92 IFX$="-"THENZ=Z-Y
93 IFX$="+"THENZ=Z+Y
94 IFX$="/"ANDY=0THENE=6:GOTO61
95 IFX$="*"THENZ=Z*Y
96 IFX$="/"THENZ=Z/Y
97 IFA<=LEN(C$)THEN86
98 X=ASC(MID$(C$,2))-64:IFX<1ORX>26THENE
   =1:GOTO61
99 IFZ>327670RZ<-32767THENE=7:GOTO61
100 N%(X)=Z:GOTO52
101 IFC$=""THENGOSUB1:AC$=I$:PRINT:GOTO5
    2
102 X=ASC(MID$(C$,2))-64:IFX<1ORX>26THEN
    E=1:GOTO61
103 GOSUB1:Z=VAL(I$):PRINT:IFLEFT$(C$,1)
    ="#"THENN%(X)=Z
104 IFLEFT$(C$,1)="$"THENS$(X)=I$
105 GOTO52
106 IFLEFT$(C$,l)<>"#"THENE=5:GOTO61
107 X=ASC(MID$(C$,2))-64:IFX<IORX>26THEN
    E=1:GOTO61
108 A=N%(X):X$=MID$(C$,3,1):IFMID$(C$,4,
    1)<>"#"THENX=VAL(MID$(C$,4)):GOTO111
109 X=ASC(MID$(C$,5))-64:IFX<1ORX>26THEN
    E=1:GOTO61
110 X=N%(X)
111 F%=0:IFX$="<"ANDA<XTHENF%=1
112 IFX$=">"ANDA>XTHENF%=1
113 IFX$="="ANDA=XTHENF$=1
114 GOTO52
115 PRINT"(CLR)";:GOTO52
116 Y=0:FORZ=ITOLEN(C$):IFMID$(C$,Z,1)<>
    " "THENNEXT:GOTO121
117 R$=MID$(C$,Z+1):C$=LEFT$(C$,Z-1):IFR
    IGHT$(C$,2)="TO"THENY=1:C$=LEFT$(C$,
    LEN(C$)-2)
118 FORZ=ITOLEN(R$):X$=MID$(R$,Z,1):IFX$
    <>","ANDX$<>","THENNEXT:GOTO121
119 IFX$=";"THEN130
120 X$=LEFT$(R$,Z-1):R$=MID$(R$,Z+1)
121 FORZ=OT07:IFC$<>LEFT$(G$(Z),LEN(C$))
    THENNEXT:GOTO126
122 IFCQ%=OANDZ<>OTHENE=8:GOTO61
123 IFZ=2ANDY=ITHEN167
124 IFZ=4ANDY=ITHEN168
125 ONZ+IGOTO139,142,145,147,157,158,163
    ,165
126 GOSUB127:PRINT"UNKNOWN GRAPHICS":PRT
    NT"COMMAND IN LINE ";L:GOTO11
127 CQ%=0:POKE36864,5:POKE36866,150:POKE
    36867,46:POKE36869,240:POKE36879,27
128 IFOS%=1THENPRINT"*PLOT WENT OFF SCRE
    EN"
129 PRINT"{CLR}(BLK}";:RETURN
130 D=VAL(C$):Y=LEN(STR$(D)):C$=MID$(C$,
    Y+1):IFD<=0THEN126
131 IFC$<>LEFT$(G$(3),LEN(C$))THEN126
132 FORZ=ITOLEN(R$):IFMID$(R$,Z,1)<>";"T
    HENNEXT:GOTO126
133 C$=LEFT$(R$,Z-1):X$=MID$(R$,Z+1)
134 FORZ=ITOLEN(X$):IFMID$(X$,Z,1)<>" "T
    HENNEXT:GOTO126
135 R$=MID$(X$,Z+1):X$=LEFT$(X$,Z-1):IFX
    $<>LEFT$(G$(2),LEN(X$))THEN126
136 X$=R$
137 R$=C$:GOTO147
138 R$=X$:GOTO145
139 CQ%=1:UD%=0:OS%=0:POKE36864,7:POKE36
    866,148:POKE36867,23
140 POKE36869,252:POKE36879,30:CO=0:SC=2
    :BC=6:AN=0:X0=0:Y0=0
141 FORI=0TO219:POKE7680+I,I:NEXT:FORI=4
    096TO7615:POKEI,0:NEXT:GOTO52
142 GETX$:IFX$7<>"Q"THEN142
143 REM
144 GOSUB127:GOTO52
145 GOSUB169:AN=AN+Z:D=D-1:IFD>0THEN137
146 D=0:GOTO52
147 GOSUB169:IFZ<OTHEN126
148 TH=(90-AN)*3.1415926/180
149 FORY=OTOZ:XG=XO+Y*COS(TH):YG=Y0+Y*SI
    N(TH):IFUD%=OTHENGOSUB152
150 NEXT:X0=XG:Y0=YG:IFD>OTHEN138
151 GOTO52
152 U=INT((XG+106.65)/1.35+.5):V=88-INT(
    YG+.5)
153 CH=INT(V/16)*20+INT(U/8):RO=(V/16-IN
    T(V/16))*16
154 IFCH<OORCH>2200RXG<-106.650RXG>108TH
    ENOS%=1:RETURN
155 BY=4096+16*CH+RO:BI=7-(U-INT(U/8)*8)
156 POKE38400+CH,CO:POKEBY,PEEK(BY)OR(21
    BI):RETURN
157 GOSUB169:TH=(90-AN)*3.14159265/180:X
    0=X0+Z*COS(TH):Y0=Y0+Z*SIN(TH):GOTO5
    2
158 FORZ=0T010:IFR$<>B$(Z)THENNEXT:GOTO1
    26
159 IFZ<8THENCO=Z:GOTO52
160 IFZ=8THENCO=SC-1:GOTO52
161 IFZ=9THENUD%=1:GOTO52
162 IFZ=10THENUD%=O:GOTO52
163 FORZ=0T07:IFR$<>B$(Z)THENNEXT:GOTO12
    6
164 SC=Z+1:POKE36879,SC*16+BC-8:GOTO52
165 FORZ=0TO7:IFR$<>B$(Z)THENNEXT:GOTO12
    6
166 BC=Z:POKE36879,SC*16+BC-8:GOTO52
167 GOSUB169:AN=Z:GOTO52
168 GOSUB169:Y0=Z:R$=X$:GOSUB169:X0=Z:GO
    TO52'
169 Z=V1§L(R$):IFZ<>OORR$="0"THEN173
170 IFLEN(R$)<>20RLEFT$(R$,1)<>"#"THENE=
    1:GOSUB127:GOTO61
171 Y=ASC(RIGHT$(R$,1))-64:IFY<OORY>26TH
    ENE=1:GOSUB127:GOTO61
172 Z=N%(Y)
173 RETURN

Program 2: Changes For Super Expander
4 GRAPHICO:COLOR1,3,0,0
5 REM
127 CQ%=0:GRAPHIC4:COLOR1,3,0,0:SCNCLR:RE
     TURN
128 REM
129 REM
139 CQ%=1:UD%=0:OS%=0:GRAPHIC2:COLOR1,6,0
     ,0:SCNCLR:CO=0:SC=I:BC=6:AN=O:X0=0:,Y
     0=0:GOTO52
140 REM
141 REM
143 GOSUB127:IFOS%=1THEN11
144 GOTO52
147 GOSUB169
148 REM
149 REM
150 TH=(90-AN)*3.1415926/180:XG=X0+Z*COS(
     TH):YG=Y0+Z*SIN(TH):IFUD%=0THENGOSUB
     154
151 IFOS%=1THEN:CHAR18,0,"OFF SCREEN AT L
     INE{2 SPACES}"+STR$(L)+" : HIT Q":GO
     TO142
152 X0=XG:Y0=YG:IFD>0THEN138
153 GOTO52
154 IFY0<-790RYG<-790RY0>800RYG>80ORX0<-1
     06ORXG<-106ORX0>108ORXG>108THENOS%=l
     :RETURN
155 U0=1023*(X0+106.65)/(1.35*159):V0=102
     3*(80-Y0)/159:U=1023*(XG+106.65)/(1.
     35*159)
156 V=1023*(80-YG)/159:DRAW1,U0,V0TOU,V:R
     ETURN
159 IFZ<8THENCO=Z:REGIONZ:GOTO52
160 IFZ=8THENCO=SC:REGIONCO:GOTO52
164 SC=Z:COLORZ,BC,CO,0:GOTO52
166 BC=Z:COLORSC,Z,CO,0:GOTO52

Program 3: Pretty Pattern
1 *PRETTY PATTERN
2 G:CLEAR
3 G:SCREEN RED
4 GIGO 13
5 G:TURN 60
6 G:GO -17
7 U:*SHIFT SQUARE
8 J:7
10 *SHIFT SQUARE
11 G:GO 17
12 G:TURN 60
13 G:4(DRAW 60;TURN 90)
14 E:

Program 4: Teddy Bear
1 *TEDDY BEAR
2 G:C
3 G:TTO -90
4 I:#C=2
5 JY:*FACE
6 U:*1/3 BIG CIRCLE
7 U:*LOCATE FOOT/EAR
8 U:*FOOT/EAR
9 U:*LOCATE FOOT/EAR
10 U:*1/3 BIG CIRCLE
11 U:*LOCATE FOOT/EAR
12 U:*FOOT/EAR
13 U:*LOCATE FOOT/EAR
14 U:*1/3 BIG CIRCLE
15 G:T 180
16 C:#C=#C+l
17 J:4
18 *FACE
19 G:GTO 7,30
20 G:TTO 0
21 U:*EYE
22 G:GTO -7,30
23 G:T 180
24 U:*EYE
25 G:GTO 0,22
26 G:4(D 1;T 90)
27 G:GTO 12,20
28 G:10(D 4;T 18)
29 G:Q
30 END
35 *1/3 BIG CIRCLE
36 G:15(D 4;T 8)
37 E:
40 *FOOT/EAR
41 G:20(D 4;T 18)
42 E:
45 *EYE
46 G:15(D 2;T 24)
47 E:
50 *LOCATE FOOT/EAR
51 G:T 90
52 G:G 6
53 G:T 90
54 E:

Program 5: Recursive Tree
1 *RECURSIVE TREE
2 H:
3 T:FINAL BRANCH LEVEL ?
4 A:#L
5 G:C
6 C:#B=64
7 G:G -64
8 U:*BRANCH
9 G:Q
10 END
15 *BRANCH
16 I: #L=0
17 JY:30
18 G:D #B
19 C:#B=#B/2
20 C:#L=#L-1
21 G:T -45
22 U:*BRANCH
23 G:T 90
24 U:*BRANCH
25 G:T -45
26 C:#B=#B*2
27 C:#L=#L+1
28 C:#A=-#B
29 G:G #A
30 E: