Classic Computer Magazine Archive BEST OF ANTIC VOLUME 1

ANTIC Disassembler and Raster Scan Graphics

Recall that the display list is the set of instructions used to control an LSI chip called ANTIC. ANTIC, a dumb microprocessor, functions as a graphics controller. Its principal duties are to specify the location in memory to be displayed, the mode of display (12 Graphics Modes with differing resolutions to choose from), horizontal/vertical scroll enable and display list instruction interrupt enable.

Included here is an ANTIC disassembler. This program requires you to enter a BASIC Graphics Mode numbered 0-11, and will then locate the associated display list and decode the instructions. Note that this program prints the ANTIC display modes numbered 2 - 15. Use the program and the ANTIC/BASIC correspondences will become apparent. (See Listing 1.) Also described are basic raster scan graphics (ATARI style), and then a quick lesson in the use of display list interrupts.

The normal NTSC raster television is made up of 625 interlaced scan lines. These scan lines are the horizontal lines appearing in the picture tube phosphor when energized by the electron beam as it sweeps left to right, top to bottom, across your screen. Interlacing occurs in normal television to eliminate flicker. It simply means that all even scan line rows are "painted" in one frame, and all odd lines in the next. The frame refresh rate is 60 Hz.

Each ATARI frame image contains 262 scan lines with no interlacing. Every frame is the duplicate of the prior one unless there is program intervention. The image is repainted 60 times per second, and the electron beam is turned off at the end of every scan line. At that time it is returned to the left edge of the screen to start the next line trace. This is called horizontal blank time.

The beam is also turned off after every frame so that it may return to the top left corner of the screen. This is called vertical blank time. These two time periods are very important to the would-be animator. It is crucial to understand how much time is available and how to enter code so that it will be executed at the appropriate moment.

The 6502 microchip in the ATARI cycles at 1.79 megahertz, almost twice as fast as the normal 6502. This cycle rate was chosen so that two color-clock widths on a scan line equal one machine cycle. There are 228 color-clocks on every scan line, and the maximum displayable width of any scan line is 176 color-clocks, called "wide playfield" in the ATARI literature. The maximum resolution is 1/2 color-clock, and therefore ATARI can display up to 352 picture elements (pixels) horizontally. The maximum vertical resolution, in scan line units is 240. Effectively, ATARI has a high-resolution mode of 352 x 240.

It's important to realize that there are physical limitations to this size display. Depending on your televisions's adjustment, some of the displayed image may appear on the curved edge of the picture tube. This overlap is called overscan. While overscan is not important in normal television viewing, it is crucial if what your word processor is printing you can't see.

Atari, in its Operating System (OS), used a more conservative screen size of 320 (160 clocks) horizontally by 192 scan lines vertically. This width screen is called "normal playfield" in the documentation. In this way Atari defeated normal overscan and assured us of seeing an entire image. There is a narrow playfield width as well, 256 pixels (128 clocks wide). These dimensions and timing are important since what is not used at display time is left over and available at interrupt time. (See Table 1 for timing.)

It is relatively simple to change between screen widths. Location $22F controls playfield width. Called SDMCTL in the documentation, it is initialized to 34. Writing a 35 will change the screen dimension to wide, and writing 33 will reduce the screen to narrow. SDMCTL is the OS shadow for a hardware register in the ANTIC chip at $D400, called DMACTL.

Since many of these hardware locations are write only, the OS keeps copies, called shadows, in RAM. Shadow registers update the associated hardware at vertical-blank-interrupt time. Remember to use the shadows to effect a permanent change to the entire frame. The exception occurs when using a display list interrupt. These interrupts can occur, under programmer control, on any scan line of every frame. To effect an immediate change at scan line interrupt, you must write directly to the hardware register.

To use the display list interrupt (DLI), a number of things must be accomplished. First, write the DLI service routine. The important thing to remember here is to save and restore any registers needed by the routine. Then find a free place in memory for this routine. (As you know, ATARI has reserved Page Six, decimal 1536-1791, just for users.) Next, update the vector at $200 and $201 to point to start of the routine. Now change the appropriate display list instruction to cause an interrupt (accomplished by turning on bit 7 of the instruction). Finally, enable DLIs by setting bit 7 of hardware register $D40E, called NMIEN (Non-Maskable Interrupt Enable). See Listing 2 for a simple example.

Also remember to set the interrupt in the mode line prior to the location where you would have the changes occur. Then write to a location call WSYNC $D40A. This will cause any changes to be delayed to the start of the next scan line and, therefore, allow a smoothly synchronized transition.

DLIs can be used for everything from putting many colors on the screen, to changing among a number of character sets, to moving Player/Missiles around. To get the most from your ATARI, experiment with this concept.

by James Capparell

Table 1: Timing
1.79 MHZ machine cycle
262 scan lines per frame
228 color clocks per scan line
60 frames per second refresh rate
1.79/60 = 29868 machine cycles per frame
29868/262 = 114 machine cycles per scan line
228/114 = 2 color clocks per machine cycle

Vertical Blank Time
262 scan Ines - 192 displayed scan line = 70
70 x 114 cycles/line = 7980 cycles available*

Horizontal Blank Time
Wide Playfield
228 clocks - 192 clocks = 36 clocks
36/2 = 18 machine cycles
Normal Playfield
228 clocks - 160 machine cycles = 68 clocks
68/2 = 34 machine cycles
Narrow Playfield
228 clocks - 128 clocks = 100 clocks
100/2 = 50 machine cycles

*AII graphics are cycle-stealing direct Memory Access (DMA). Depending on graphics mode and memory refresh, this value will be less.

"ANTIC Dissassembler," by James Caparell, is reprinted with permission from MICRO Magazine, Issue No. 43, P.O. Box 6502, Amherst, NH 03031.