Classic Computer Magazine Archive ANTIC VOL. 6, NO. 6 / OCTOBER 1987

Page 6 Exchange

Graphics Impossible

Antic imports Britain's best

by Paul Lay

Here are two eye-popping demonstrations of graphics techniques often mistakenly considered impossible—mixed vertical display lists, and dual players on the same horizontal line. You can use these powerful subroutines in your own BASIC programs and MAC/65 assembly language source code is also included. These BASIC program work on all 8-bit Atari computers of any memory size, with disk or cassette.

Any experienced 8-bit Atari user has learned that these computers are incredibly versatile. But there are some things most users believe the Atari can't do. For example, if you're a graphics programmer, you probably know that display lists can be mixed horizontally by building a new display list. But just ask some experts if you can combine different graphics modes vertically across the screen and they'll say it can't be done.

The two programs presented here will show that the Atari is even more versatile than some experts think.

Both of our programs use Graphics 8 because it's one of the most consistent graphics modes as far as direct memory access time (DMA) is concerned.

(DMA refers to the way the ANTIC chip "steals" cycles from the 6502 chip in order to draw the display screen. When you turn off the ANTIC chip with POKE 559,0 DMA is disabled and your program will run 15 %-30% faster. However, your screen will be black.—ANTIC ED)

All Atari graphics modes are more DMA-consistent than text modes. In fact, every scan line uses the same amount of DMA time except the two LMS (Load Memory Scan) lines—the first of which is two machine cycles ahead of a normal scan line while the second is three cycles ahead. We must take account of these differences in our timing loop.

GRAPHDEM

Our first listing, GRAPHDEM.BAS, proves that you can mix Graphics 8 and 9 vertically and there's no reason you can't change the program to include Graphics 10 or 11. So type in Listing 1, GRAPHDEM.BAS, check it with TYPO II and SAVE a copy before you RUN it.

This program generates a screen consisting of a Graphics 8 vertical margin down the left side, with the rest in Graphics 9. The normal four-line horizontal Graphics 0 text window is also retained. With this arrangement you can draw graphs in 16 intensities, neatly labeled with 40-Scolumn text.

The mix is created by changing the value in PRIOR (a GTIA mode selector, 53275, $D01B) from 0 to 64. This is done at a particular point on every scan line. (If you have an older Atari, POKE 623,64 to see if your machine has the GTIA chip. If so, the screen will go black.—ANTIC ED) Every scan line will take up 32 pixels of Graphics 8, with the rest of the screen in Graphics 9. We can access these from BASIC by fooling the operating system into thinking we're in either Graphics 8 or 9 (subroutines GR8 and GR9) and then DRAWing TO the relevant section of the screen.

The source code for the display list interrupt (DLI) used is in Listing 2, GRAPHDLI.M65. You do not need to type in this listing in order to use the program. This source code is provided just for the information of machine language students.

By inreasing or decreasing the DELAY between changes to PRIOR, we can change the proportions in which the screen is split between the two modes. You can create graphs such as pie charts, etc., while graphics adventures could be drawn in Graphics 9 with text or status information down the side in Graphics 8. There are many other applications requiring such labels.

What about doing the same thing with the ANTIC chip by changing a single scan line between the ANTIC E and ANTIC F display mode? According to standard reference manuals—and my own unsuccessful experiments—it's not possible because ANTIC's Display List Instruction Register (IR) cannot be accessed directly by the programmer.

PLAYDEM

The classic guidebook De Re Atari says that no two sections of the player can be on the same horizontal line. Therefore two incarnations (copies) of the player cannot be on the same horizontal line. This is incorrect, as Listing 3 will show. Type in Listing 3, PLAYDEM.BAS, check it with TYPO II and SAVE a copy before you RUN it.

By using a very precise timing loop contained within a DLI, Listing 3 allows two incarnations of Player 0 to be present in separate halves of the screen. The first incarnation occupies horizontal positions 0-122, while the second occupies positions 123-255. If either incarnation is outside this range, it won't be visible.

Source code for the actual timing loop is in Listing 4, PLAYDEM.M65. You do not need to type in this listing in order to use the program. This source code is provided just for the information of machine language students.

The scan line timing waits until the first incarnation has been displayed before moving the players horizontally. This technique could be extended to all players quite easily by using NOPs (No OPeration) assembly language instructions which tell your Atari to do nothing for two machine cycles within the timing loop.

You could also change PMBASE (Player/Missile Base Address, 54279, $D407) as well, thus having completely independent incarnations of each player as long as they're within certain screen bounds.

To position these incarnations of Player 0, their horizontal positions should be stored in locations 203 and 204 respectively. The program also displays all other players and missiles to prove that there is no cheating.

This is obviously a very powerful technique, and it's feasible that in games such as Pac-Man we could generate all the ghosts from just one player.

Cover ShotAntic proudly commences an important new "program exchange" series. During coming months, we will regularly reprint outstanding programs which originally appeared in England's leading Atari Magazine, Page 6. This recent exchange agreement gives Atari users on both sides of the Atlantic a much larger base of fine programming to enjoy, because Page 6 will also be reprinting Antic's top programs for the British public.



Listing 1  GRAPHDEM.BAS Download

Listing 2  GRAPHDLI.M65 Download / View

Listing 3  PLAYDEM.BAS Download

Listing 4  PLAYDEM.M65 Download / View