Classic Computer Magazine Archive BEST OF ANTIC VOLUME 1

Scrolling


The strongest features of the ATARI relative to game programming are the 12 Graphics Modes (high resolution 320 x 192); two direct memory access (DMA) video channels (sort of a simplified multiprocessing system); display-list controlled, memory-mapped graphics; redefinable character sets; hooks for vertical blank interrupts and scan line interrupts; and, of course, four channels of sound.

The ATARI maps its memory to video via an LSI chip called ANTIC. This chip is a dedicated processor with its own instruction set. These instructions make up what is called a display list. The display list controls the Graphics Mode which will be displayed on the screen. Recall that there are 12 modes, each specifying memory use, resolution and color. The display list tells ANTIC what part ofthe 6502 memory space to display, what mode to display, whether an interrupt should be generated, and whether horizontal and/or vertical scrolling should be enabled. It is this last feature which will be demonstrated here.

There are two methods which can be used to scroll the image. The first is direct and easy to comprehend. The display list has, as part of its instructions, a feature called Load Memory Scan (LMS). This operator is three bytes long. The last two bytes are the address (lo byte/hi byte, 6502 style) of the start of display memory. As a result, the entire address space is available for display under program control. This gives the observer a "window" into memory. Scrolling windows are created by simply changing the two address bytes of the LMS. In other words, it is not data being moved through memory, but a window moving across the data residing in memory which causes the image to scroll.

Listing 1 should give a good idea of "coarse" vertical scrolling. I call it coarse because the image moves a full character width at a time. Lines 170 and 180 are really doing all the dirty work. The new display address is being inserted into the display list at this point after appropriate incrementing or decrementing of the address bytes. I've chosen to vertically scroll the entire image but it is an easy matter to set up a scrolling window within a background display. In fact, Listing 2 does just that, only in the horizontal direction.

I've also mixed two modes on the screen. The only complication here is the need to have more than one LMS instruction. The second LMS restores the pointer to memory prior to the horizontal intrusion. There is nothing to stop you from placing an LMS instruction on every mode line; each could be scrolling in independent directions.

Listing 3 is meant to demonstrate the second scrolling method, smooth or fine scrolling. This is accomplished with the help of hardware scrolling registers, one for horizontal and another for vertical direction. When the appropriate bits are set in a display list instruction, the values in each of these registers control the number of scan lines vertically or color clocks horizontally that each line will be displaced. The limitation here is the amount of fine scrolling allowed. A line can be moved eight full color-clocks horizontally and 16 scan lines vertically. When this amount is scrolled, the LMS address bytes must be incremented or decremented and the whole process must be started again. In this way smooth scrolling can be maintained.

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

Listing 1: SCROLL1.BAS Download
Listing 2: SCROLL2.BAS Download
Listing 3: SCROLL3.BAS Download