The ability to redefine the character set is one of the more useful features of the Atari. In a previous article, "Character Generation on the Atari," (COMPUTE! #9) I explained the principles and techniques of customizing the character set. 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 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:
W: Write Data
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 the character displayed in 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 re-defined 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.
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 may 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 two 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.
The code of the main program is fairly straight forward. 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 (and any other 6502 function such as ROR) to be used on a binary level (see also "Make Your Atari a Bit Wiser," COMPUTE! #12, p. 74). (4) Implements a fast machine language memory save thanks to the 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! (INTRUDER ALERT! INTRUDER ALERT!) SuperFont makes your task easier, even fun!