Turtle

*P. Pinder * London



Driving a turtle is a little like giving someone road

directions - go so many yards, then turn right, go on

again, then turn left, and so on. That is not at all easy

to do in Basic, which lays out its screen like a map and

much prefers movement to be in the orienteering style of

"go from 094/453 to 122/474".

  Very few home computers have a built-in GO RIGHT, GO LEFT

instruction mode - the Enterprise is the only Basic I know

which has it - and so driving a turtle is not easy unless

you can afford to buy a separate Logo language package.

  This program can drive a screen turtle and, using a

suitable interface, it is also possible to drive a simple

two-motor floor buggy. The set-up I used was a Centronics

relay board from Cirkit plugged into a dK'tronics Centro-

nics printer interface. That allows a motor to be turned on

by the simple command LPRINT CHR$(1); and turned off again

by LPRINT CHR$(0); Other hardware add-ons might require an

OUT addr,x to switch something on and OUT addr,y to switch

it off.

  If you add your own motor-control code, remember the

format is MOTOR ON, DELAY, MOTOR OFF. As it stands, the

program moves a turtle over the screen. The commands to

drive a floor buggy should be patched in at lines 503, 553,

602 and 604 according to what piece of hardware is on the

back of your Spectrum.

  Spectrum Basic calculates angles in radians rather than

in degrees but apart from that complication, the code for

moving Right, Forward and Left is short and occupies three

short subroutines. A time delay is the fourth subroutine.



 Body Language



  The main body of the program - lines 100-410 - accepts

and processes the input commands. Those commands may be

given in the individual form of Ldd, Rdd or Fpp, where

dd=degrees and pp=pixels, or as a multiple input line such

as F5L90F50L5F44. The instructions will be obeyed one after

another in sequence. Entering a nought instead of a letter

will take you back to Basic.

  The advantage of this system is the ease with which

extra commands can be added to the program. Line 250 hold

the number of commands available - three in this case -

followed by the command letter and the line at which the

routine serving that command is to be found.