The ability to redefine characters is a very powerful feature of the Atari. This discussion explains how it is done.
Atari computers are among the few that possess a very powerful feature--the ability to redefine the character set. The character setis the group of 255 alphanumeric characters that can appear on the screen. It comprises the upper- and lowercase alphabet, the numbers, special symbols, and punctuation. Also included in the Atari character set are 29 "control graphics" characters. When the CTRL key is held down and a letter of the alphabet is typed, the corresponding graphics symbol is displayed. These symbols are much like those found on the PET/CBM. Unlike the PET, however, the Atari can redefine any of these characters. This allows custom graphics, user-defined special symbols (like pi, theta, or foreign language alphabets), and logos.
There is no built-in command to perform the changes; it has to be done the hard way with PEEK and POKE. These are commands to look at and modify memory, respectively. First of all, you must understand how the Atari stores and displays these characters. It is beneficial if you know how to work with binary numbers, but it is not a prerequisite.
Start out by designing your characters. Fill in the blocks on an 8x8 grid; each block will represent a pixel (picture element, or screen dot). Observe the A in Figure 1. Notice the heavy vertical lines. A television screen will display horizontal lines brighter than vertical lines, so it is necessary to have two vertical lines in order for it to be clearly visible (this also prevents "artifacting"). Therefore, the pi in Figure 2 may be hard to see unless enlarged in mode 1 or 2.
After you have designed your characters, you have to convert them to the numbers that a computer loves. Each row in your grid represents a binary byte.A filled-in block represents a 1 and a blank block means 0. Hence, the top row of the A is 00011000 or 24 decimal. Now write the bytes for each row. If you do not work with binary numbers, you can convert each line in the following manner:
1. Notice the numbers above each column. They are the powers of two.
2. If a block is filled in, take a number above it and add it to a "Sum." Sum up all the blocks in the row (for example, the fourth line of the pi would be 128 + 32 + 4 = 164).
3. Do this for all eight rows.
Figure 1. Character A
Figure 2. Character Pi
Next, assemble the numbers into DATA statements. The numbers for pi would then look like this:
1000 DATA 0,1,126,164,36,36,36,36
Finally, you have your numbers. Now all you have to do is replace the numbers of the character you want to redefine with your numbers. Unfortunately, this table is stored in Read Only Memory (ROM), so it cannot be altered. The solution is to copy this table into Random Access Memory (RAM), which can be changed, and then tell the computer where you have moved the characters.
First, we have to find a safe place in RAM to hold the character set table. One solution is to place the character set at the top of memory. We can use memory location 106, which holds the number of the topmost page (a "page" is 256 bytes) of memory. On a 32K machine, this is usually 128 (128*256 = 32768 = 32*1024). We would need to store our character set four pages beneath this limit, since we need 1024 bytes, and 4*256 = 1024.
However, there is a complication. The operating system has also decided to use the top of memory to store information needed to display the video screen. All we need to do is store our character set a little further back in memory, behind the screen. Here's the tricky part. Exactly how much we need to "step back" depends on which graphics screen is used, since different modes use varying amounts of memory (from 272 bytes in GRAPHICS 3, to nearly 8,000 bytes in GRAPHICS 8). Just remember to step back far enough to get past the screen, and make the "step size" a multiple of four.
So to find the place to store a character set with graphics modes 0,1,2,3,4 and 5, step back four pages to get past the screen then step back four more to hold your character set, for a total of eight. GRAPHICS 6 would require 12, GRAPHICS 7 would require 20, and you would need to step back a whopping 36 pages to fit your character set beneath a GRAPHICS 8 display.
A sample program to redefine the character set (assuming you've set up your DATA statements) might start out like this:
10 CHBAS=57344 20 CHSET=(PEEK(106)-8)*256 30 FOR I=0 TO 1023 40 POKE CHSET+I,PEEK(CHBAS+I) 50 NEXT I
These lines transfer the ROM-based character set to RAM, where they can be modified. The transfer (in BASIC) takes a long time to execute, about 15 seconds. You don't need to copy the character set if you want to redefine the entire character set, or don't need any characters from the default character set. And unless you go into a higher graphics mode that might wipe out the character set, you don't need to execute these lines more than once. The data will still be there, even when you RUN the program again.
The next line:
60 POKE 756,CHSET/256
tells ANTIC (the Atari's video microprocessor) where you have placed your character set. This location normally contains 224 (224*256 = 57344, which is the address in ROM of the default character set).
Now that the table is in RAM, we can find the place in it for the new numbers. Look up the character you want to replace (Table 9.6-Internal Character Set, in the Atari BASIC Reference Manual).Note that this number is notthe ATASCII value of the character. Include this number preceding your eight bytes in the DATA statements. For our pi:
1000 DATA 32,0,1,126,164,36,36,36,36
The 32 is the internal code for the @ symbol. Anytime you press the @ key, you may be surprised to see pi.
A few more lines, and the program is finished:
70 READ NCHR: REM NUMBER OF CHARACTERS TO BE CUSTOMIZED 80 FOR I=1 TO NCHAR 90 READ RPLC: REM INTERNAL VALUE OF CHARACTER TO BE REPLACED 100 FOR J=0 TO 7 110 READ A 120 POKE CHSET+8*RPLC+J,A 130 NEXT J 140 NEXT I 150 REM LINE 170 IS OPTIONAL 160 REM IT JUST DISPLAYS ALL THE CHARACTERS 170 FOR I=0 TO 255:PRINT CHR$(27);CHR$(I);:NEXT I 180 END 998 REM NUMBER OF CHARACTERS 999 DATA 1
A few program notes:
1. You can use multiple statements per line; delete REMs if you like.
2. This program should be appropriately renumbered, and RETURN added if you want to use it as a subroutine.
3. This is not the only way to customize the character set. See the other articles in this book for more ideas.
The complete program (less DATA statements) and a utility program that lets you look at characters wrap up this article. Study them, puzzle them out, and have fun with Atari's custom characters!
Program 1. Redefining CharactersDownload P052L1.BAS (Saved BASIC)
Download / View P052L1.LST (Listed BASIC)
Program 2. View CharactersDownload P052L2.BAS (Saved BASIC)
Download / View P052L2.LST (Listed BASIC)
Return to Table of Contents | Previous Section | Next Section