Classic Computer Magazine Archive ANTIC VOL. 2, NO. 7 / OCTOBER 1983

PILOT YOUR ATARI

LONESOME PILOT

by KEN HARMS

Sitting beside a calm, blue lake in Idaho's Sawtooth mountains, I recently proved a philosophical statement by my friend, Anonymous: "A computer is a multi-purpose tool, not an all-purpose tool." Out here, the best turtle graphic program is a poor substitute for a rod, reel and a well-chosen fly. So, while the nine-inch rainbows fry, here are a few lines concerning letters to the author and short but delightful programs illustrating character graphic animation under PILOT.

ANTIC and its authors attempt to answer readers' questions either directly or through the I/O Board. Unfortunately, many letters are nearly unanswerable for reasons which maybe illustrated by replying to a recent letter.

"In your article on Holiday Trees, you stateed that you can get the big letters in the R:emark commands by placing a Control N right after the colon. I've tried this and it makes absolutely no difference in the looks of the print. What am I doing wrong?"

Answer: I was trying to explain how to get the Epson printer to print R:emarks lines in expanded mode. A similar special character can be used with the Atari and other printers; see your printer handbook. These characters have no effect on the listing displayed on the screen. No special characters will turn on the large screen letters (Graphics Mode 2). To answer this question I assumed the writer was listing to the screen. If he had included a description of his printer, I could have answered more helpfully.

"Your Sounder article (Volume 2, Issue 6) included a section on special effects that has puzzled me for some time. In the bouncing-ball section, absolutely nothing happens even though I have checked and rechecked the typing. I hear the sound effects, but there is no bouncing ball. I strongly suspect lines 590 and 690, followed by 570 and 670. What should I do on these lines.,"

Several people reported this problem, most probably a result of the way we used to list programs. The Epson printer I use (like the Atari printers) does not print most control characters. The 590 and 690 lines are good guesses for the problem. The key sequence should be a T:ype [CTRI] [.] followed by a space and a remark bracket. The period in one remark didn't print, leaving some confused. Lines 570 and 670 print blanks to erase the ball before the next line prints it again higher (or lower) on the screen. Be sure to include both the space and a remark bracket or PILOT will assume it's a null line and do nothing.

If all else fails on a graphic screen, a good rule of thumb is to clear the screen and start over. One way to do this is to insert a line with T:ype [ESC] [CTRL] [CLEAR]. If that doesn't work, try a GR:QUIT followed by a Q@B572 = 1 to turn off the cursor. In this program I'd insert the lines right after line 510, the start of the program.

"Also in the Sounder article, you lost me in the Jackhammer module, especially in lines 1220 to 1330, plus line 1340. The R:emarks were somewhat confusing as what came out on the screen looked like anything but a Jackhammer. I need some help interpreting these lines."

Again, ANTIC's new listing conventions, with full display of all characters, has solved this for future programs. In this case, however, the reader is subtly reporting an error in the remark statement intended to clarify a set of non-printing graphic characters. For all of you struggling with this, lines 1250 through 1270 are listed as "same as 1180." Once they were. But I renumbered the program and forgot to change the remark. They should be "same as 1240." Sorry folks!

Although these debugging problems were relatively simple (if I got them right!), most problems can be really difficult to diagnose from a few sentences. It really helps if you send along a disk or cassette with a copy of non-functioning programs and return postage, as well as a description of the problem and your hardware configuration. Be sure to keep your original copy! I can then see exactly what the computer sees and try to fix it.

And a final comment from our reader:

"I'm often struck by the exotic memory locations you use with poiter variables. Where do you come up with these locations and the various functions? Do you have a PILOT memory map? If you do, how do I obtain one? I'm always impressed by the way you can come up with just the right address to solve the tricky little problems. I never can, and believe me, it's frustrating.

The secret of finding just the right address to solve a tricky problem is writing articles only when the search for an address was successful. The number of programs which haven't been written because the right address just can't be located are many. For example, an address for all errors (we have one for I/O errors to disk) or a simple way to detennine the length of a variable are attractive but elusive.

Although there is no good memory map for PILOT that I know of, you miight find the following three resources helpful. The BASIC Reference Manual by Atari includes many of the most useful addresses. The Memory Map by Educational Software, Inc., is the most complete O.S. map I've seen. "Mapping the ATARI" by Ian Chadwick, is the most complete I haven't seen. Since PILOT, like BASIC, works with Atari's excellent Operating System, most of the addresses work withh PILOT. But don't expect locations such as variable addresses to work in a different language -- these are definitely language-dependent. In a word - experiment.

The last resource is the PILOT External Specification, available free from Atari's Customer Service group. The 'External Spec,' is an internal document (not typeset, etc.) designed for the experienced programmer. It packs lots of information into its draft-form pages, but you'll need some ingenuity to put these hints into use in your applications.

Now to this month's program. Locomotive is a simple program combining character graphics and advanced sound effects to animate an old-fashioned steam locomotive. "Character graphics" describes pictures created by stringing together characters in Atari's 256 character font. The program uses a *STARTUP module to get initial values for variables in #M and #R which control the left margin and the row number on which locomotive will print. Later, simply increasing this number and computing it into address 82 changes the left margin to move the locomotive across the screen one space at a time. That's the basic principle behind animating character graphics -- print the characters, erase them, and reprint them in a different location. You could use the POS:ition command, but since the locomotive is five lines high, five P: commands would be needed, changing the margin is simpler. To eliminate erasing, each line of characters in the locomotive includes a blank at either end. This automatically erases the last character when the string is reprinted.

The program uses #R to change location 84 to set the line number on which to print the pattern. Simply changing positions 82 and 84 and printing either *TRAIN or *TRAIN- RIGHT moves the locomotive back and forth down the screen.

The *WHISTLE and *LOCO2 moduales use special sound registers to control both a multi-voiced toot and the complete puff-puff of the locomotive. Simply, each of the four voices in PILOT is controlled by two registers -- a frequency address and a control address. PILOT looks at values in the frequency register to figure out the pitch (frequency) and the control register to determine the distortion plus loudness values for each voice. See the BASIC Reference Manual or "Sounder" in ANTIC Oct.-Nov. 1982, for more information.

The WIHISTLE module sounds each of three voices at different frequencies and at distortion 160 (clear tones) but with loudness values of 8 and 10. It turns them off by setting the loudness values to 0 (lines 2110 to 2130). The same technique gives the puffs. The variable #L sets up the maximum loudness (15 times 100) and then loops *LOCO1 and *LOCO2 first sound the loud puff and then loop through to rapidly decrease the loudness. The loop proceeds slowly at first while the train is starting up and goes faster and faster as the train speeds up. This increasing speed is accomplished by increasing the "step value" (variable #X) after each puff. See lines 1060 through 1100.

Well, it's back to the campfire for these fish. Upcoming programs include a way to merge programs under program control and continuing coverage of Logo.

Ken Harms is Contributing Editorfor PILOT and Logo, who programs for the sheer joy of computing. Readers interested in contributing to our coverage of either of these languages are invited to write him care of ANTIC.

Listing: LOCO.PLT Download / View