SuperFont
Charles Brannon
The ability to redefine the character set is one of the more useful features of the Atari. Basically, it involves the plotting of a character on an eight by eight matrix and then converting each row into a binary number.
This process, however, is slow and tedious for the programmer. Fortunately, it is an obvious candidate for computerization. The computer could display a grid, let you set and clear points on it, and then do the binary-to-decimal conversion for you. It could also let you save and load completed fonts (character sets) from tape or disk.
Although "SuperFont" may lack some of the features of commercial products, it is quite powerful and versatile. SuperFont is written in BASIC, but what makes it special is that it has several machine language subroutines as well. One of these, thanks to a display list interrupt (DLI), enables the redefined character set to be displayed on the screen at the same time as the regular one. This permits you to see the effects of your changes without letting the command menu or prompts turn into starships.
SuperFont uses player/missile graphics for fast updates and a colorful grid. Since the special character window is set off in a different color than the rest of the screen (again via DLI's), you get eight different colors to delight the eye. The human interface is enhanced with the use of a joystick to plot points in the eight by eight grid.
SuperFont has 18 commands:
This menu is displayed on the screen along with a checkerboard plotting grid, the 128 characters of the character set, and the 128 characters of the alternate character set. Some commands require you to select a character. A cursor will be placed on each of the character sets. You can move the cursors around the sets simultaneously. When the cursor is on the desired character, press the fire button to indicate it. An explanation of each command follows:
Edit: The basic editing command. The selected character is copied into the grid, and a flashing cursor is homed into the grid. You move the cursor with the joystick. Pressing fire will set a point (if a point is clear) or reset (clear) a point (if a point is already set). You can draw lines by holding down the button while moving the joystick. Any changes are immediately visible in the character set and in the character displayed in the graphics mode one and two lines at the bottom of the screen. To completely redesign a character, use the Clear command, and then design the character from scratch.
Restore: This command will "fix" a character by copying the original bit pattern into it. Very useful if you have mangled a character or changed the wrong one.
Copy From: You select a character which is copied into the current character. The grid is updated, and you can further edit the character.
Copy To: The current character is copied to (replaces) the indicated character.
Switch: Exchanges the current character's bit pattern with the selected character.
Overlay: The selected character is overlaid upon the current character. This lets you combine two characters to form a new one.
Clear: Clears out the current character. For creating unique characters.
Invert: Turns the current character "upside down." For example, a redefined M could be inverted and copied to the W.
Save Font: Saves the alternate character set in compact form with a machine language routine. Answer "Filename?" with either C: or D:filespec. If you see an error message, press a key to return to the menu.
Load Font: Retrieves a character set from tape or disk. Answer the "Filename" prompt as you did in Save Font.
Cursor-up or SHIFT-DELETE: Similar to Delete Line in BASIC. The line of dots the cursor rests on is deleted; the following lines are pulled up to fill the gap.
Cursor-down or SHIFT-INSERT: Similar to Insert Line in BASIC. A blank line is inserted at the cursor position. The bottom line is lost.
Scroll Left: The bit pattern of the character is shifted to the left.
Scroll Right: The bit pattern of the character is shifted to the right.
Write Data: The internal code (0-127) of the current character is printed in reverse-field followed by the eight bytes (in decimal) of the character. If you want a printout of the entire character set, use the auxiliary program CHPRINT (Program 3). Pressing any menu selection key will erase the nine bytes.
Print Character: If you want a hardcopy printout of a character, or only want to define a few characters and have a printed record, this command comes in handy. Just have your printer on-line and press P to create a "picture" of the character (printed with X's). Beside each line of the character is the decimal value of the binary byte for that line. The number printed at the top is the internal character code for the character you redefined.
Graphics: Toggles the TEXT/GRAPHICS option of the graphics mode one and two lines to let you see each half of the character set.
Reverse: Puts the character in reverse field: all dots become blanks, and all blanks become dots. Reverse field versions of the characters are not normally stored in the character set, but you may want this for special graphics, such as reverse-field text in graphics modes one or two.
Quit: Exits program.
The commands offer flexibility in working with character sets, but there may be other functions you want to add. The program is modular in structure; just follow the branching IF statements after line 790 to 1370 and replace the 520 (IF K <> ASC("G") THEN 520) with a link to your additional command(s). You may also want to change the colors. Besides the SETCOLOR statements in line 170, change the zero in line 300 (POKE 1538,0) to COLOR (0-15)*16 + LUMINANCE (0-14). Similarly, you can play with the player/missile colors in line 360.
It is also possible to use the character set data on tape or disk directly. It is written as a series of 1024 bytes: the bytes of the character set--no more, no less. I have included three extra utility programs which access the character data. Program 2 simply loads the set into memory and changes CHBASE (756) to point to it. Program 3 produces a formatted hex or decimal dump of the character set. Both programs should have the "filespec" changed to the filename of your character set.
You can use Program 4, CHSET DATAMAKER, to create a "module" of lines that lets you add your character set to any program. After saving your character set to tape or disk, just RUN Program 4. It will ask you for the filename of the character set, the starting line number of the "module," and a filename for the module. (Just answer C: to the filename prompt for use with a cassette.)
CHSET DATAMAKER "writes" a subroutine replete with the appropriate PEEKs, loops, and DATA statements, to tape or disk. It optimizes space by writing DATA statements only for those characters you have changed, by comparing your character set to the ROM default character set. After it has finished, you can merge the lines it produced with any program using the ENTER command. You may need to make some minor adjustments to the code it produces. And in your main program, remember to use a POKE 756,CHSET/256 after every GRAPHICS statement, since a GRAPHICS statement resets the character pointer.
The code of the main program is fairly straightforward. It uses several machine language subroutines: (1) A Display List Interrupt handler to maintain the special character window. (2) Copies the ROM character table into the RAM CHSET table (avoids the 15-second delay in BASIC). (3) A LOGIC subroutine that permits AND, OR, EOR to be used on a binary level (see "Make Your Atari a Bit Wiser," COMPUTE!, May 1981, #12, p. 74). (4) Implements a fast machine language memory save, thanks to the Input/Output Control Block (IOCB) PUTREC and GETREC commands.
You can do a lot with this capability: custom fonts (Greek, "computeristic," script), graphics characters (special line drawing characters, spaceships, "invaders," bombs, tanks, planes, ships, even little people). SuperFont makes your task easier, even fun!
Download P067L1.BAS (Saved BASIC)
Download / View P067L1.LST (Listed BASIC)
Download P067L2.BAS (Saved BASIC)
Download / View P067L2.LST (Listed BASIC)
Download P067L3.BAS (Saved BASIC)
Download / View P067L3.LST (Listed BASIC)
Download P067L4.BAS (Saved BASIC)
Download / View P067L4.LST (Listed BASIC)
Return to Table of Contents | Previous Section | Next Section