ANTIC'S MODE 3
A special character mode
By KARL WIEGERSSYNOPSIS
Here's how to modify Atari's text mode to display video lowercase
letters with real descenders (g, j, p, and y), and subscripts. The
programs run on all Atari computers. Please note: the ANTIC referred
to in this article is Atari's LSI chip, not your favorite magazine.
Newer readers now know where our name came from. Antic Disk Subscribers:
Run "D:HIDDEN.BAS"
With the implementation of the new Operating
System in the XL series of Atari computers, all of Atari's graphics and
text modes but one are readily available to the user from BASIC.
This is ANTIC Mode 3, a text mode that's similar to Graphics 0, but that
allows special modifications to the character set.
A few of the concepts and terms used in this article may
be unfamiliar to you. The display list is a set of instructions used by
the ANTIC chip, the special graphics processor that constructs the screen
display. See "Display Lists Simplified" (Antic, February/March 1983)
for a detailed explanation of display lists and how they work.
A scan line is a single horizontal line traced by the
electron beam on your television screen. Every 30th of a second,
525 scan lines are produced, forming a single screen image.
A mode line in Atari terminology is a group of scan lines
(from 1 to 16, depending on the graphics mode) used as a unit by the display
list. For instance, in Graphics 0, eight scan lines make up one mode
line. See the Graphics Chart ("Unlocking the 56 Graphics Modes")
in this issue for the number of scan lines required by different text and
graphics modes.
Character graphics refers to the method normally used
by the Atari Operating System to display alphanumeric characters on the
screen. Read "Character Graphics" (Antic, February 1984) for further
information.
Each character is composed of dots (pixels) in an 8-by-8
matrix. The dot pattern for each character is stored in eight consecutive
bytes in ROM. The 128 characters that are the Atari character set
occupy (128 x 8) 1024 bytes.
Here's a short program that will print out the Internal
Character set (the ATASCII set).
The order in which the set is printed is the same order
in which the computer's Read Only Memory stores the set.
10 PRINT "NUMBER",,"CHARACTER"
20 FOR I=0 TO 63:PRINT
I,,CHR$(I+32):NEXT I
30 FOR I=64 TO 90:PRINT
I,,CHR$(I-64):NEXT I
35 FOR I=91 TO 95:PRINT
I,,CHR$(27);CHR$(I-64):NEXT I
40 FOR I=96 To 124: PRINT
I,,CHR$(I):NEXT I
50 FOR I=125 TO 127:PRINT
I,,CHR$(27);CHR$(I):NEXT I
In ANTIC 3, each mode line is ten scan lines high. Each character is still represented by eight bytes, and two scan lines normally appear as blanks below the character. Second, the last 32 characters in the set (lower case letters plus six special important characters) are displayed differently from the rest. The first two bytes of these 32 characters are displayed at the bottom of the character, and the two blank lines appear at the top. This allows us to redefine some of these characters to have lower-case descenders (the "tails" of letters, g, j, p, q, y extend two dots below the bottom of other letters).
STEP BY STEP
First, modify the display list. Each mode line of ANTIC 3 has
ten scan lines. Our ANTIC 3 screen will have 20 lines of text on
the screen. The program in Listing 1 sets up the ANTIC 3 display
list.
When you RUN Listing 1, the screen will flash and a rectangular
cursor will appear. The Operating System is set up for ANTIC 2, so
it tries to display 24 lines. Since we've set up our new display
list to show 30 lines, the bottom four lines of the display are invisible.
Press [RESET] to return to the normal display before rerunning the program.
Type some letters. Capital letters, numbers and
graphic symbols look fine. Now type some lowercase letters.
All the tall lowercase letters (b, d, f, h, i, j, k, 1, t) are cut off;
the tops of the letters are displayed as dots at the bottom of the letters.
Here's why:
Figure 1A shows the dot pattern for a normal uppercase
'Y' in ANTIC Mode 2. Figure 1B shows the 'Y' in ANTIC 3. The two extra
scan lines appear as blank lines below the character. Figure 2A shows
the pattern for a lowercase 't', and 2B shows its ANTIC 3 representation.
Note that dots in the top two rows of the normal character have been moved
to the bottom of the character in ANTIC 3. This happens with all characters
with ATASCII codes between 96 and 127.
We can't use the standard character set in ANTIC 3 because
of this. One possible solution is to redraw each character one line
lower within its 8-by-10 matrix. The entire set must be copied into
RAM first.
Figure 3 illustrates the necessary steps. Shift
the eight bytes in the character down by one, and move the last byte to
the top of the character. When ANTIC 3 displays the character, it
displays the first two bytes last, so the vertically shifted characters
will look fine. Listing 2 contains a machine-language subroutine
that transfers the character set to RAM and performs the modification quickly.
Merge Listing 2 with Listing 1 to combine the ANTIC 3 display list with
the shifted characters.
Here's how to merge the two listings:
1. LOAD or type in Listing 1 and LIST it to disk or cassette.
2. Verify with TYPO.
2. LOAD or type in Listing 2.
3. Use the ENTER command to load (and merge) Listing 1.
4. Use SAVE to store the combined program.
5. If you don't see 'READY' after running the combined program, press
[RESET] and RUN again.
We're now ready to redefine some characters to give the
lowercase descenders mentioned earlier. We can repair the comma and
the semicolon at the same time.
Make a less squashed-looking 'y' by changing it to the
dot pattern in figures 4A and 4B. This illustrates lowercase descenders;
ANTIC 3 gives such characters a more pleasing appearance than does the
usual text mode.
Listing 3 gives descenders to all the appropriate characters,
and repairs the comma and semicolon. Merge this with the program
from Listings 1 and 2. You now have a complete, working text display for
ANTIC Mode 3.
A USEFUL APPLICATION
If we wish to write chemical or mathematical formulae, we need to use
symbols as subscripts. Let's use ANTIC 3's special display features
to create some subscript number characters,
The ATASCII character set has six rarely used characters
whose codes are: 96 ([CTRL][.]; 123 ([CTRL][;]; 124 ([SHIFT][=]); 125;
126; and 127. In this example, we'll replace character 96 with the
dot pattern for a subscript '2', 123 with subscript '3', and 124 with subscript
'4' (Figures 5A and 5B). Type in Listing 4 and merge with your evolving
program. Press [RESET], and RUN the program. Now, whenever
you press [CTRL][-], you should get a subscript '2', and so on. Try
writing the chemical formula for potassium phosphate with these keystrokes:
[K] [CTRL][;] [P] [O] [SHIFT][=] See if you can type other
formulae, like silver carbonate, AG2CO3; sodium acetate, NaC2H3O2; aluminum
sulfate, Al2(SO4)3. This may be the first chemistry you've seen coming
out of your Atari computer, but it's just one application of ANTIC Mode
3. (If you come up with any other interesting uses for this mode, send
then to Antic. If they're good, we'll publish them.)
As always, this is just a start. ANTIC 3 can be
used for super/subscripts, footnotes, and vowel markings for foreign languages.
Special character sets can be printed out using screen dump programs.
Karl E. Wiegers, Ph.D., is a research chemist for Eastman Kodak and an Atari hobbyist. He writes for a number of computer publications.
Listing: HIDDEN.BAS Download
Listing: HIDDEN1.LST Download / View
Listing: HIDDEN2.LST Download / View
Listing: HIDDEN3.LST Download / View
Listing: HIDDEN4.LST Download / View
Listing 1
30 GRAPHICS 0
40 REM Turn off TV display
50 POKE 559,0
60 REM Find start of display list
70 DL=PEEK(560)+256*PEEK(561)
80 REM Modify display list to ANTIC mo
de 3
90 POKE DL+3,67
109 FOR I=6 TO 24:POKE DL+I,3:NEXT I
110 POKE DL+25,65
120 POKE DL+26,PEEK(DL+30)
130 POKE DL+27,PEEK(DL+31)
400 REM Turn on TV display
410 POKE 559,34
Listing 2
10 REM Reserve 4 pages of RAM for char
acter set
20 MEM=PEEK(106)-4:POKE 106,MEM-1:RAMS
TART=256*MEM
140 REM Load ML routine
150 FOR I=1 TO 35:READ A:POKE 1535+I,A
:NEXT I
160 DATA 104,160,255,162,7,177,203,72,
136,177,203,200,145,205
170 DATA 136,202,208,246,104,145,205,1
36,192
180 DATA 255,208,233,198,206,198,204,1
98,207,208,223,96
190 REM Initialize work variables for
character set Transfer to RAM
200 POKE 203,0:POKE 204,227
210 POKE 205,0:POKE 206,MEM+3:POKE 207
,4
220 REM Call ML routine to move charac
ter set
230 A=USR(1536)
380 REM Turn on new character set
390 POKE 756,MEM
Listing 3
240 FOR J=1 TO 7:READ OFFSET:OFFSET=OF
FSET*8
250 FOR I=0 TO 7:READ A:POKE RAMSTART+
I+OFFSET,A:NEXT I:NEXT J
260 REM comma,semicolon,g,j,p,q,y
280 DATA 12,0,0,0,0,0,24,24,48
290 DATA 27,0,0,24,24,0,24,24,48
300 DATA 103,102,60,0,62,102,102,62,6
310 DATA 106,6,60,6,0,31,6,6,6
320 DATA 112,96,240,0,124,102,102,124,
96
330 DATA 113,6,15,0,62,102,102,62,6
340 DATA 121,24,48,0,102,102,102,62,12
Listing 4
240 FOR J=l TO 10:READ OFFSET:OFFSET=O
FFET*8
270 REM CTRL-.,CTHL-;,Shift-=
350 DATA 96,48,126,0,0,60,102,12,24
360 DATA 123,102,60,0,0,126,12,24,12
370 DATA 124,126,12,0,0,12,28,60,108