ANTIC VOL. 6, NO. 4 / AUGUST 1987 / PAGE 17
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
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.
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.
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.
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.
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.
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.
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.
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.)
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.
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.
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.
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
Listing 2 LINKBAS.BAS
On disk CHAREDIT.EXE
On disk LINKBAS.EXE