MIRRORED DISPLAY LISTS
Fast, unusual graphics in half the memory!by DAVID PLOTKIN
Throw splashy kaleidoscopic patterns all over your screen. Learn how to use mirrored display lists-a powerful graphics programming technique that easily produces distinctive effects without tying up a great deal of memory. The short BASIC demonstration program works on all Atari 8-bit computers of any memory size, with disk or cassette.
They say you can't teach an old dog new tricks, but there still seems to be no limit to the tricks you can teach your Atari. This article demonstrates 'an interesting screen modification that can lend an unusual and impressive look to your programs with relatively little effort. REFLECTION DISPLAYS
Inside your Atari is a custom microchip called ANTIC that controls the computer's video output (Yes, that's where the name of your favorite magazine came from.) Among the things that ANTIC does is set up the screen display and track which memory locations hold the required data for display.
This chip gets its instructions from a program called the display list, which is written into RAM by the 6502 microprocessor every time a GR. command is made.
If you modify a display list so that the bottom half of the screen 'reflects' the top half, then anything drawn on the top half also appears upside-down on the bottom half. One good use for this effect would be to depict stars emerging from the center of the screen and moving toward the edges for a three-dimensional effect.
Your program only needs to be concerned with drawing and moving the stars in the top half of the screen, since those on the bottom are their mirror image. This gives you fast-moving effects because you're only manipulating half the normal amount of data to create graphics.
And since you're using the same memory area for both halves of the screen, you save half of the normal memory requirement for a graphics mode. In Graphics 8, that's about 4,000 bytes-a substantial amount!
HOW IT WORKS
Type in Listing 1, checking it with TYPO II. SAVE a copy before you RUN it. Antic disk subscribers will find the program under the filename REFLECT. BAS.
The best way to understand how to use the reflection technique is to roll up your sleeves and get to work. In line 1000, we find the highest available memory address, then step back 4K for the screen YSTART), and another 1/2K for the display list (DLS). Line 1010 puts the address of the display list into the location that tells BASIC where the top of usable memory is.
Then we start POKEing a display list into memory. If you're familiar with display lists, you'll note that it looks like a Graphics 8 setup, but with only half the normal number of scan lines-96. Next, we calculate the address of the middle of the screen by multiplying the number of lines (96) by bytes per line (40) and adding this to YSTART.
Lines 1040 to 1060 contain the secret of our trick with the display list. In each display list instruction for the bottom half of the screen, the LMB (Load Memory Scan) option is set, telling the computer to treat the next two bytes as the address from which to display data for that line.
This address, which we must POKE in for each line of the bottom half of the display, starts at the middle of the screen (as computed in line 1025), and is decreased by one line (40 bytes) for each remaining line of the display list. Therefore, the bottom line of the screen displays data from the same address (the same data, in other words) as the first line of the screen, and the bottom half of the screen mirrors the top. Lastly, line 1070 ends the display list by inserting a JMP instruction (65) and telling the computer where the beginning of the list is. Line 1080 tells the computer to use the new display list by putting its address in memory locations 560 and 561. The remaining lines create pictures to demonstrate the mirrored screen.
Dave Plotkin of Walnut Creek, California is a regular contributor to Antic in both BASIC and ACTION!
Listing: REFLECT.BAS Download