PILOT YOUR ATARI
Redefine Characters
Cursive letters are one possiblity
By Kathy and Phil Bergh
Exciting rumors are leaking fast from silvery silicon gulch. LOGO has been publicly shown and is now scheduled for release in the Fall. Atari has completed designing Super PILOT and has been using it in its Computer Camps. The specs sound great, four turtles, all visible, all graphic modes--and much, much more! Although Atari hasn't yet decided to release Super PILOT for the general public, we're hopeful. ANTIC will run full reviews on both languages as soon as possible.
ANTIC's monthly schedule gives us twice as much space for PILOT. Luckily, we've found a pair of accomplished programmers to share the work of producing creative, useful PILOT programs each month. With this column we welcome Phil and Kathy Bergh as authors. Kathy is a teacher in Washington state. Together, they wrote the only PILOT program yet accepted by APX. I think you'll enjoy their work as much as I do. --Ken Harms
We have often wished that ATARI had used a traditional division sign instead of the slash for math computations. Perhaps you would like to have animations on the screen with text. Could your program use French accent marks, German umlauts, or even a whole foreign alphabet? Well, PILOT can give you all of these and more, if you design your own customized characters. We will provide you with an overview of character design and show you how to redesign any characters you wish. This article's first program changes the capital "L" to cursive form. The second program creates a steam locomotive in place of six graphics characters and animates it. After these, let your imagination run wild!
ATARI's character set is in Read Only Memory (ROM) and, as the name implies, you cannot change it. You can, however, copy it into Random Access Memory (RAM), change any characters you like, and tell the computer to use your new set instead of the one in ROM. This article designs and uses characters in Graphics Mode 0 (text mode).
Each character in the set can be visualized as an eight by eight grid of light bulbs, each of which can be either "on" or "off." Each row of the grid is remembered by the computer as one memory byte, so eight bytes are needed to represent the whole grid (one character). The first step in redesigning the set is to color in boxes on small lined graph paper. The colored boxes represent the lighted bulbs. Figure 1 shows our custom letter, a cursive "L" on paper.
Figure 1
The boxes are binary (they are either on or off), but PILOT needs them in decimal notation. The conversion is easy. The numbers across the top of the chart show the decimal value of each column. For the decimal value of each row, add the column values of the filled-in boxes. In the top row, the 4, 2, and 1 column are filled in, so the value of the first byte is 7. Add across each row until you have the value of all rows, These will be the values of the eight bytes making up your custom character.
An even easier way to do this is to use one of the many BASIC utility programs which design characters. They show exactly what the character will look like with screen artifacting and other considerations. Some give the byte value as part of the screen display. Just write the values down.
Next, find the end of the program in the computer's memory so we can put the new character above it. In Program 1, Line 70 C:omputes a value of #Z which is the memory location where the program ends (@wordl76) divided by the number of bytes in one K (1024) plus three more K. PILOT stores the end of program in RAM space in the two bytes at address 176. We are used to seeing @B for "at byte", but in this case it takes two bytes to remember the end of the program, so the "B" is left out and PILOT gets those two bytes and automatically converts them to a two-byte address.
The Operating System requires that the new character set start at a 1K boundary in memory. The #Z variable will point to a boundary because when we divide by 1024, PILOT ignores the remainder, leaving us at the whole number of a 1K boundary. We then add an arbitrary 3K to insure that we are in clear space. At least 1K must be allowed. Using 3K allows room for program expansion. Line 80 multiplies the K value by 1024 to get the address of the first byte of our custom character set.
This new character set address is saved as #Z, #W, and #A (lines 80, 90 and 100). Variables #Z and #W will be used and incremented while #A will be used to reset values.
PILOT looks at the value stored in byte 756 to find the first memory page of the character set that the computer is going to use. In line 110, the pointer to the ROM character set is multiplied by 256 to convert that page value to a byte address (there are 256 bytes in a page), and it is saved as #Y.
And now the magic line! The C:ompute in line 120 puts the address we selected for the custom character set into address 756. From now on, PILOT will look at our new memory space rather than the ROM characters whenever it needs to display a character. Now it's up to us to give it a new set to display.
Although we could design an entirely new set of 255 characters, it's much easier to copy ATARI's regular set and then change just those we need to change. *MOVEIT in lines 140 through 190, copies each of the ROM characters into "our" RAM space. Even if you don't use all of them, all possible characters (even control graphics and inverse video) must be moved. The loop counter (#X) is set to zero (line 130), the contents of the first byte of the original set (@B#Y) is C:omputed into the new byte address (@B#Z), and #Y, #Z, and #X are each incremented by one. If all 1024 bytes have not been moved, the J:ump at line 190 loops back to copy another value.
Now that the whole set is in RAM, we need to find the character in the set that is to be changed. There is a chart entitled Internal Character Set on page 55 of the ATARI BASIC Reference Manual that shows the order of characters within the ROM character set. Multiplying the value of any character by eight gives the offset of the character into the table, in bytes. Adding this value to the address of the beginning of the new character set (#W) gives the first byte of the character to change (line 200). The Internal Character Set value of capital "L" is 44.
Lines 210 through 350 C:ompute the value we calculated for each row of the cursive "L" in Figure 1 into the spot where "L" was in RAM. The byte address is then incremented, and the next value inserted until all eight values are changed.
Usually, a program would tell the computer to use the new character set after moving the set and inserting the custom characters. We did this in line 120 before the set was moved to give an interesting effect of the letters appearing on the screen as they are moved. Once the program is RUN, the new set is in memory, and the "popping letters" effect is lost.
Since PILOT restores the original ROM address to byte 756 after GR:QUIT,LOAD,RESET, and the first WRITE:S in a series, your program must provide a C:ompute XB756 after each occurrence of these commands to remind the computer that we are using a set of our own.
The TRAIN program works just like Program 1 except that the characters [CTRL]-A,S,D,F,G, and H are designed to resemble a train. T:yping and retyping further along on the same line, chugs the train across the screen. Note that before each character is changed, the new address pointer must be reset (line 360, etc.) To see the train move again without rerunning the program, enter J:*GO.
After typing in the programs and working out a character of your own, you will begin to see what fun this powerful tool for custom character sets can be. Even better, you don't need to understand it to make it work! To change one character you need only change the Internal Character Set number in line 200 to match the character to be replaced and change the values in lines 210, 230, 250, 270, 290, 310, 330, and 350 to your numbers! You might try making flatcars and boxcars for the train. Other possibilities: Greek, cursive, Japanese and German fonts. Once your imagination is in gear, anything can happen!
We hope you find much fun and many uses for custom character sets.
Listing 1: CAPITAL.PLT Download / ViewListing 2: TRAIN.PLT Download / View