Classic Computer Magazine Archive ANTIC VOL. 6, NO. 4 / AUGUST 1987

Atari Animation: Lesson 3

Animation Editor and LinkBAS

by Robin Alan Sherer

Two vital programming tools that will be used throughout this intermediate BASIC series are presented here. Animation Editor is a professional-quality character set editor that includes powerful image-moving features. This BASIC program works on 8-bit Atari computers with a minimum of 32K memory and a disk drive. LinkBAS is a short BASIC subroutine that converts machine language code into ATASCII string variables for use in your BASIC programs. It runs on all 8-bit Atari computers with a disk drive.

Last month we promised you some powerful software tools that would greatly simplify your creation and use of redefined characters—the basis of Atari Animation.

So before going on to add more details to our haunted house animation sequence next month, we need to introduce two stand-alone utilities that will be used often in upcoming lessons.

The main program is the Animation Editor, a full-featured character set editor. In many ways, Animation Editor is similar to UltraFont (Antic, August 1986). However, because Animation Editor was specifically written as a tool for helping you make Atari images move, it also offers the following two unusual features

  • ANIMATION: Select a sequence of redefined characters—such as the #$% sequence we modified into the little robot last month—and alternate these characters in the same spot on the screen at various speeds.
  • BUILD: Construct composite characters by combining four stacked character shapes into one larger unit.
Our second animation tool this month is LinkBAS, a useful short routine that converts assembly language object code into data variables for use in your BASIC programs.

ANIMATION EDITOR

To obtain your own Animation Editor, type in Listing 1, CHAREDIT.BAS, check it with TYPO II and SAVE a copy before you RUN it.

Antic Disk owners will find a faster machine language version of this program on the monthly disk. Use option L from the DOS menu to load CHAREDIT.EXE.

The type-in version and the Antic Disk version of Animation Editor look alike, use the same commands, and do the same work. The only difference is the faster operating speed of machine language. You can make CHAREDIT.EXE load automatically or run by copying it to a separate disk with DOS 2 or 2.5 and renaming it AUTORUN.SYS.

When you RUN Animation Editor, you will see that the main screen is divided up into five major work areas- Editing Grid, Character Image Display, Menu, Character Set Display, and User Input Prompts.

EDITING GRID

Each of the 64 rectangles in the Editing Grid display represents a bit, and each horizontal row of bits represents a byte. This is the main work area for editing, animating, or building composite characters.

CHARACTER IMAGE

Whenever you edit a character, the Character Image boxes show you what it will look like in three different graphics modes.

The first box shows the character in Graphics 0—the mode in which the character editor runs. To the right is Graphics 1 (double-height characters) and below is Graphics 2 (double-width and double-height). For clarity each character is a different color, but the colors have no other significance.

MENU

The Menu is a list of the Animation Editor's major function commands. Type the first letter of a function to select it. (For example, type L for the [L]OAD function. The command would be indicated in the text as [L].) When a function is selected, it is highlighted in blue. NOTE: Do NOT press [RETURN] after selecting your function.

CHARACTER SET DISPLAY

The entire character set is seen in the Character Set display. When you want to GET or PUT a character, the cursor jumps here to find it. NOTE: You may edit only 126 of the 128 characters in the character set. You can't edit the [BACKSPACE] or [DELETE] delete characters because they're specially modified and colored for the Editing Grid. Their color comes from artifacting.

I/O BOX

The I/O Box on the bottom left of the screen displays error messages and other information. For example, here is where you'll type the filename of the character set (font) to be LOADed or SAVEd.

KEYBOARD COMMANDS

The CURSOR mode on top of the menu is highlighted in blue whenever you're working in the Editing Grid. Six functions are available in this mode:

1. Move Cursor: Use the [ARROW] keys to position the cursor within the Editing Grid. Do NOT press [CONTROL] or [SHIFT].

2. Write Cursor: Use this function to draw and erase within the Editing Grid. If the cursor is on a blank square, pressing [CONTROL] and any [ARROW] key will fill-in that square. If the cursor is already on a filled-in square, pressing [CONTROL] and any [ARROW] key will erase that square. NOTE: This function will also move the cursor in the direction of the [ARROW] key you pressed.)

3. Home Cursor: Press [H] to move the cursor to its "home" position; the upper left corner of the Editing Grid. [CONTROL] [H] moves the cursor to the lower right corner.

4. Shift Grid: [SHIFT] [ARROW] slides the character in the editing grid one row in the direction of the [ARROW] key.

5. Byte Values On/Off: To see the byte value of each row in the editing grid, press [N]. To turn off these values, press [CONTROL] [N].

6. Cursor On/Off: The cursor must be visible before you can edit a character. Sometimes, though, it may distract you from properly seeing the pattern you've created. When this happens, press the [SPACEBAR] to turn the cursor off. Press it again (or press an [ARROW] key) to turn it on again.

SAMPLE CHARACTERS

Before we proceed, let's get a character set that we can experiment with. Here is a short routine which will copy a character set to a disk file called "D:DEMO.FNT"

31900 OPEN #1,8,0,"D:DEMO.FNT"
31910 CSET= PEEK(756) * 256
31920 FOR BYTE=0 TO 1023
31930 PUT #1,PEEK(CSET+ BYTE)
31940 NEXT BYTE
31950 CLOSE #1

RUN the current Haunted House listing (July's HAUNT02.LST as merged with HAUNT0l.BAS from the June issue) to redefine your character set. As soon as you see the little robot on the screen, press the [BREAK] key, type the above routine, and then type GOTO 31900. In a moment, you'll have a DEMO character set that you can use with this month's editor.

LOAD and SAVE

Use these functions to LOAD and SAVE character set files to your disk.

Press [L] to LOAD a character set and [S] to SAVE one. Then, type the name of the file to be LOADed or SAVEd.

With both LOAD and SAVE, you don't need to enter a filename extender, because the default is .FNT. Exit by pressing [RETURN] before entering a filename.

Press [G] and [RETURN] to GET a character from the Character Set display area and move it onto the Editing Grid. The [ARROW] keys position the cursor over the character you want to edit. Both the character and your cursor will move to the Editing Grid.

Once on the grid, you may edit the character by using the [ARROW] key commands described above.

Press [P] to move the character from the Editing Grid and PUT it into the Character Set. This is the reverse of the GET command With this command, you may edit a character and PUT it anywhere in the character set.

You can also PUT copies of a single character into several spots. For example, if you are creating several similar versions of a character and only a small part of each character needs to be redrawn, PUT several copies of the basic character into the Character Set. Finally, edit each copy, adding the parts which are different.

Press [C] to CLEAR the editing grid, setting all bits to "off." This function only erases the character in the editing grid. It does not affect any other characters.

Press [R] to RESTORE the character in the editing grid to its original Atari shape. It does not affect any other characters. This function is only active when you are GETting or PUTting a character.

Press [I] to INITIALIZE the character editor. This function restores ALL of the characters to their original Atari shape.

ANIMATE

Press [A] to Animate a moving sequence of characters in both the Editing Grid and the Character Image display. The Animate function will ask you for the characters to be animated.

Enter the characters to be animated and press [RETURN] to start the sequence. Press [S]low or [F]ast to control the speed of the animation. Press [Q]uit to stop the routine.

If you LOAD the DEMO character set described above, and Animate the [#], [$] and [%] characters, you'll see last month's little robot stomping around.

BUILD

A composite character looks like a large character, but is actually made of several combined standard-size characters (such as last month's larger robot).

Press [B] to Build a composite character, then enter the four characters to be used. Fill some of these characters with blanks to create smaller composite characters.

The characters you enter will appear in the Graphics 2 Character Image Display box.

Press [Q] to [Quit] the program. The program will ask you if you're sure you want to exit. Any response other than [Y] returns you to the program.

USING CHARACTER SETS

File I/O: The following routine loads your character set into RAM:

2000 OPEN #1,4,0,"D:FILENAME.FNT"
2010 FOR 1=0 TO 1023
2020 GET #1,BYTE
2030 POKE CA+I,BYTE
2040 NEXT I
2050 CLOSE #1

File I/O takes some time and can be annoying if you have more than one character set to load. Also, extra I/O and support files can cause even more delays.

The main advantage of the above File I/O routine is memory conservation, but if your program is reaching your Atari's memory limits, it might be wise to store the character sets in a separate file. In this case, you may want to use a speedy USR function to load your character set. (See this issue's Haiku Master, lines 200-220 for an example of this technique.)

RESIDENT CODE

Resident code means that the character set is contained within your program, either in DATA statements or string variables. This example shows a character set in DATA statements:

2000 RESTORE 7000
2010 FOR I=0 TO 1023
2020 READ BYTE
2030 POKE CA+I,BYTE
2040 NEXT

7000 DATA 0,0,112,134,34,2,2,0,0,65,65
7010 DATA (another 1013 numbers)

One major disadvantage to the resident code technique is that DATA statements consume a lot of memory. You are using a three-byte number like 112 instead of a lowercase p with the same ATASCII value of 112. If you used string variables to hold the data, it would look like this:

2000 DIM CS$(1024)
2010 CS$(1,100)="BEGINNING OF 1024 ATASCII CHARACTERS REPRESENTING"
2011 CS$(101, 200)="BYTE VALUES"
2012 ...
2013 ...
2014 CS$(1000,1024)="END OF 1024 ATASCII CHARACTERS"
2020 FOR COUNT=0 TO 1023
2030 BYTE=ASC(CS$(COUNT+1,COUNT+1))
2040 POKE CA+COUNT,BYTE
2050 NEXT COUNT

This is more practical in terms of memory conservation, but it's still slow. It also requires some method to interpret the byte values into ATASCII characters. That method is contained in our second utility, LinkBAS.

LINKBAS

LinkBAS is a "quick and dirty" utility that translates assembly language object code into ATASCII character strings. Add these to your own BASIC programs to replace clumsy READ/DATA initializations, conserve memory and improve program speed.

When RUN, LinkBAS reads a binary file (such as a character set or an assembly language object file) and writes a corresponding BASIC file which you may ENTER into your own BASIC programs.

Type in Listing 2, LINKBAS.BAS, check it with TYPO II and SAVE a copy. When you RUN it, the first prompt you'll see is for a destination filename.

After LinkBAS creates your BASIC file, it will use this filename to store it on your disk. The default filename is TEMP.LST which you can choose simply by pressing [RETURN].

Your DESTINATION file (the BASIC program that LinkBAS creates) may begin at any line number. At the next prompt, enter a starting line number for this program. Each successive line number will be incremented by 10. The default line number is 2000.

Make sure that the number you choose is larger than the highest line number in your BASIC program.

At the SOURCE/VARIABLE <@> prompt, enter the name of your SOURCE file. You don't need to type the "D:" device identifier.

Your filename should be followed by a slash [/], along with the name of the string variable that LinkBAS uses to store the data in the destination file. You don't need to put a [$] after the variable name.

If you want your destination file written to the same disk as your source file, add a [@] to your response.

EXAMPLES

Legal               Illegal
DEMO.FNT/CHAR$      DEMO.FNT
DEMO.FNT/CHAR$@     DEMO.FNT@
To end LinkBAS, just press [RETURN] at the SOURCE/VARIABLE <@> prompt, and you'll be returned to BASIC.

RECOMMENDED BOOKS

Your Atari Computer by Lon Poole. Osborne/McGraw-Hill, 2600 Tenth Street, Berkeley, CA 94710. (415) 548-2805. $17.95, 474 pages.

Mapping the Atari by Ian Chadwick. Compute! Publications, Inc. (ABC), 825 Seventh Avenue, New York, NY 10019. (212) 887-5928. $16.95, 272 pages.

Robin Sherer is the co-author of four Atari programming books. He currently lives in the Seattle area.

Listing 1  CHAREDIT.BAS Download

Listing 2  LINKBAS.BAS Download

On disk  CHAREDIT.EXE Download

On disk  LINKBAS.EXE Download