16K Cassette/24K Disk

by Tom Hudson

Hidden deep inside the ATARI 400/800 computer systems are several capabilities that ATARI apparently chose to keep a deep, dark secret. Playermissile graphics, an incredibly powerful graphics tool, are barely hinted at in most ATARI documentation. Optimized Systems Software's BASIC A+ was a step in the right direction as far as P/M graphics are concerned, allowing easy manipulation in BASIC.

Unknown to many ATARI users, the 400/800 computers actually have 14 graphics modes (17 if you count GTIA), not just the nine BASIC modes 0 - 8. These additional modes are available in the hardware, but the Operating System (OS) doesn't support them directly. Shown below is a table of the ANTIC (hardware) modes and their corresponding BASIC modes.


02    0     40 X 24, 2 COLOR, TEXT
03    -     40 X 19, 2 COLOR, TEXT
04    -     40 X 24, 4 COLOR, TEXT
05    -     40 X 12, 4 COLOR, TEXT
06    1     20 X 24, 5 COLOR, TEXT
07    2     20 X 12, 5 COLOR, TEXT
08    3     40 X 24, 4 COLOR, GRAPHIC
09    4     80 X 48, 2 COLOR, GRAPHIC
10    5     80 X 48, 4 COLOR, GRAPHIC
11    6    160 X 96, 2 COLOR, GRAPHIC
12    -    160 X192, 2 COLOR, GRAPHIC
13    7    160 X 96, 4 COLOR, GRAPHIC
14    -    160 X192, 4 COLOR, GRAPHIC
15    8    320 X192, 2 COLOR, GRAPHIC

ANTIC mode 3 is a nifty text mode similar to GRAPHICS 0 which will allow true descenders on lower-case letters. ANTIC 4 and 5 are very powerful text modes allowing 5 colors WITHIN EACH CHARACTER! Mode 4 was used for ATARI's adaptation of PAC-MAN, for the maze and bonus nuggets. ANTIC 12, which we call GRAPHICS 6+, is identical to BASIC GRAPHICS 6, but each plotted block (or pixel) is only one scan line tall, giving a higher resolution display of 160 by 192.

The mode this article is concerned with is ANTIC 14, or GRAPHICS 7+. It is identical to GRAPHICS 7, but has a resolution of 160 by 192. Using this mode will allow the generation of high-resolution displays in four colors. The best example of this mode is Datasoft's graphics package, "Micropainter." This article will present a machine language subroutine which will allow you to use GRAPHICS 7+ from BASIC. It also has some nice enhancements which make plotting and drawing much faster.

The "Plot" Thickens

Listing 1 is the BASIC code necessary to use GRAPHICS 7+. As written, it will run a continuous demonstration, plotting rectangles in 3 colors at random points on the screen. Type this listing into your computer and SAVE it before running it.

After SAVEing the program, RUN it. If the listing was entered correctly, you will see rectangles plotted continuously on your screen. The program has some error-checking that will catch some errors in the DATA. A "CALC DATA ERROR" indicates an error in the plot calculator data in lines 460-500. A "MAIN DATA ERROR" indicates an error in the main routine data in lines 540-680.

Listings 2 and 3 are the machine-language source listings of the handler, for those interested in the assembler side of the routine.

Once you have an operating copy of the GRAPHICS 7+ handler, you are ready to use it in your own programs.

Inside The Program

As noted earlier, the program presented here will plot random rectangles on your screen. The code that performs this function is in lines 230-420. Lines 50-220 and 440-680 MUST be left as is (of course, you can delete the REMarks if you wish).

Line 50 - READs the DATA in lines 460-500 and places it in the user memory. This DATA, the machine-language form of listing #2, actually performs the calculations needed to PLOT in GRAPHICS 7+.

Lines 110-115 - READs the DATA in lines 540680 and places it in the string variable G7P$. This DATA is the machine-language form of listing #3, and handles GRAPHICS 7+ initialization, PLOTting and DRAWing. Note that a simple checksum routine is used to check for DATA errors.

Line 170 - This line sets entry points into the machine-language program located in G7P$. INIT is the address of the initialization routine, PL is the address of the PLOT routine, and DR is the address of the DRAWTO routine.

Line 220 - This line initializes the GRAPHICS 7+ screen. First, the user must set up a GRAPHICS 8 screen, either a full-screen or split-screen mode. In this case, we want a full-screen GRAPHICS 7+ screen so we use GRAPHICS 8+16. Using only GRAPHICS 8 will allow the use of a text window at the bottom of the screen. We use a GRAPHICS 8 call because it reserves the same amount of memory that GRAPHICS 7+ needs. Next, we do a USR call to the INIT routine to actually set up the GRAPHICS 7+ screen. It's that simple!

Line 230 - This line sets COLOR 0 to red.

Line 280 - This line randomizes the X and Y coordinates of the rectangle's upper-left corner. It also sets a random COLOR of 1, 2, or 3. We don't allow the color value to be zero, as this would be the same color as the background, and wouldn't show up.

Line 330 - This line PLOTs the first point of a rectangle. It does the same thing as the BASIC statement:

PLOT 10+X,10+Y

One interesting function incorporated into the GRAPHICS 7+ handler is the ability to plot multiple points with one PLOT statement. For example, examine the following BASIC statements:

PLOT X+2,Y+2

These four commands could be done in GRAPHICS 7+ with ONE command, as shown below:


Using one command for such multiple PLOTs can speed up program execution and makes life a little easier when keying in programs. just remember to always give the routine an EVEN number of arguments (X and Y coordinates). If the GRAPHICS 7+ handler receives an odd number of arguments, it will not plot, but will simply return to BASIC. If the X or Y values exceed the screen limits (X = 0-159, Y = 0-191), the PLOT will be ignored.

To summarize, whenever a PLOT is desired in GRAPHICS 7+, use the command:


where X and Y are the coordinates of the pixel to be PLOTed.

Line 380 - This line DRAWs the four sides of the rectangle. As with the GRAPHICS 7+ PLOT handler, the DRAW handler will accept multiple DRAWTOs! As you can see, we can draw a rectangle in GRAPHICS 7+ with only TWO commands, where normally FIVE BASIC commands would be necessary. This line is the same as the four BASIC commands:

DRAWTO 10+X,10+Y

This multiple-argument DRAWTO capability can be very powerful, allowing many lines to be drawn with one statement.

Whenever a DRAWTO is desired with GRAPHICS 7+, use the command:


where X and Y are the corrdinates of the pixel a line is to be drawn to. This line will originate from the last point plotted by the GRAPHICS 7+ routine.

Line 420 - This line simply transfers control back to line 280, where the plotting of another rectangle begins.

Using Graphics 7+ In Your Own Programs

You can easily create programs that use GRAPHICS 7+. Simply remove lines 230-420 and place your program code after line 220. You may change the "GRAPHICS 8+16" command in line 220 if a split-screen graphics mode is desired.

I think you will find that GRAPHICS 7+ is a happy medium between the somewhat "chunky" GRAPHICS 7 and the one-color hi-res GRAPHICS 8. Its added resolution in the Y-axis brings it close to mode 8, and the four-color capability gives spectacular displays.

Interestingly enough, the new ATARI 1200XL computer supports ANTIC modes 4, 5, 12 (or 6+) and 14 (or 7+)! Therefore, this program is unnecessary for those future 1200XL owners. Of course, any program written with this GRAPHICS 7+ handler will work on a 1200XL, without modification.

Whichever ATARI computer you own, the GRAPHICS 7+ handler will let those hidden graphics capabilities shine through.