Classic Computer Magazine Archive COMPUTE! ISSUE 32 / JANUARY 1983 / PAGE 134

High Resolution Turtle Graphics

Connecting The Strobe Pen Plotter To Apple Turtle PILOT

David D. Thornburg, Associate Editor

There comes a time when most users of turtle graphics wish they could get higher resolution pictures than those shown on the display screen. The easiest way to accomplish this is to connect the computer to a graphic pen plotter. Pen plotters have been available for many years, but it is only recently that their cost has dropped to the point that they are affordable to home computer users.

Of the various low-price plotters, the Strobe Model 100 has a price of under $800 (including Apple interface card and software), and has a resolution of 0.002 inches in both axes. It uses inexpensive fine-point pens from the corner drugstore, and plots on plain 8½ × 11 paper. With special pens, it can also plot directly onto plastic sheets for overhead transparencies.

While Strobe provides several application packages for various business and other graphic applications, the plotter can also be interfaced to any program written in Applesoft BASIC. In order to use the plotter with your own programs, you must first load the printer driver program (supplied). Since this program resides just above memory location 35071 and is executed with the Applesoft CALL command, I have not found a way to use this plotter directly from Logo. Anyone who has solved this problem is invited to write about it!

Modify PILOT

Devout turtlers need not feel depressed, however, since the Turtle PILOT language by Alan Poole (published in the September 1982 issue of COMPUTE!) is written in Applesoft.

This language system consists of two programs — an editor for creating PILOT listings, and a translator that converts the PILOT program to Applesoft and appends the necessary BASIC utilities needed to make everything work properly. To interface the plotter to the language, one needs only to modify two subroutines and add one new subroutine to the translator program. To keep these programs clear, I will show only the changes that are to be made in the program published in Poole's original article. If you used different line numbers in your version, in order to see where you should put them you will have to compare these changes with the original listing.

The modifications to the translator perform three tasks:

  1. We must load the plotter driver routine and initialize the system. Since the routine starting at line 50000 is used at the beginning of every translated program, this is where we will add these tasks.
  2. We must add plotter commands after the screen drawing commands so that our plotted image will appear at the same time it is being drawn on the screen. The screen drawing routine begins at line 55000, so this is where we will make these changes.
  3. Finally, we need to add a routine that scales the plot commands for the paper size and plotter resolution, sets the pen in the up or down position as appropriate, and ships this assemblage of data to the plotter for execution. We will create this routine starting at line 56000.

Because all the changes are in that portion of the translator appended to each translated program, only one tiny change needs to be made in the PILOT programs themselves. As implemented, the command G:GOTO x,y will only be executed when the next G:DRAW command is given. If you are moving the turtle to a new loction X,Y with the pen up, you can execute this on the plotter with the sequence:

G:PEN UP;GOTO X,Y;DRAW 0;PEN DOWN

The function of the DRAW 0 command is to force the plotter to carry this motion out before setting the pen down.

Except for the small inconvenience of adding the extra DRAW 0 commands after each GOTO, any of your existing PILOT turtle graphics programs will run on the plotter as soon as they have been re-translated. I recommend using the original translator for making sure the picture fits on the screen and otherwise does what you want. Once this is done, you can use the modified translator (called, for example, TRANSPLOT) to generate the BASIC program that will both draw pictures on the display and plot them on the plotter at the same time.

To try out the plotter, I entered the following PILOT program:

*SQUIRALG : CREAL
C : A = 0
* LABEL
G : DRAW A
G : TURN 91
C : A = A + 1
J(A < 100) : * LABEL
E : 

When this was translated and run, I was able to get a beautiful squiral pattern that was devoid of the jaggies one gets with a raster display screen.

As you create pictures of your own, you will want to change pen colors every so often in the middle of a drawing. An easy way to do this is to use the following procedure when you want to change colors:

* QUERY
T : CHANGE PEN AND PRESS RETURN
A :
E :

This will stop the execution of the program while you change pens. When you are ready to start plotting again, just press RETURN.

The following figures are but a small indication of the pleasures that await those of you who want to increase the resolution of your turtle graphics.

The changes to be made in the Translator program of Apple Turtle PILOT include:

  1. Set up procedure:
    50000 PRINT CHR$(4) ; "BLOAD PLOT1.8"
    50002 HIMEM : 35071
    50004 CALL 35081
    50006 DIM Q$(25), QS(31)
    50008 QP = 1 : QX = 0 : QY = 0 : GOSUB 56000 : QP = 0
    
  2. Modify drawing routine:
    55004 GOSUB 56000
    55045 IF QP = 1 THEN GOSUB 56000
    55060 HPLOT TO QX + 139.0005, -QY + 80.0005: GOSUB 56000
    55070 RETURN
    
  3. Add plotter routine:
    56000 XI = 20 * (QX + 137.5) : YI = 20 * (QY + 106.25) : P % = QP + 2
    56010 IF XI < 0 THEN XI = XI + 65536
    56020 IX% = XI/256
    56030 POKE 35085, IX%
    56040 IX% = XI - IX% * 256
    56050 POKE 35084, IX%
    56060 IF YI < 0 THEN YI = YI + 65536
    56070 IY % = YI/256
    56080 POKE 35087, IY%
    56090 IY% = YI - IY% * 256
    56100 POKE 35086, IY%
    56110 IF P% < 0 THEN P% = P% + 255
    56120 POKE 35088, P%
    56130 CALL 35072
    56140 RETURN
    

Note: If you are extremely picky about plotting accuracy, add the line:

56005 XI = XI * 1.0007506 : YI = YI * 1.0198781

Any disk that contains programs generated with Transplot also needs to have a copy of the Strobe program Plot1.8. To copy this program to your disk, place any Strobe disk in your Apple and enter:

BLOAD PLOT1.8

Next, insert your program disk and enter:

BSAVE PLOT1.8, A$8900, L$6E0