Doing The Impossible

by Paul Lay


Issue 21

May/Jun 86

Next Article >>

<< Prev Article



We all know that the Atari is an incredibly versatile machine but there are some tasks that most people believe it cannot do. I would like to take a couple of these 'impossible' tasks and prove that the Atari is even more versatile than you thought.

Everyone should know that display lists can be mixed horizontally by building a new display list but ask many experts if you can combine different graphics modes vertically across the screen and they will say it can't be done. The program GRAPHDEM here proves that it is possible to mix Graphics 8 and 9 in this way and there is no reason why you cannot amend it to include graphics 10 or 11.


Both programs presented here use a graphics 8 screen as it is one of the most consistent graphics modes as far as DMA is concerned. In fact every scan line uses the same amount of DMA with the exception of the two lms scan lines. The first Ims scan line is two machine cycles ahead of a normal scan line while the second is three cycles ahead. We have to take account of the differences in our timing loop. All graphics modes are, in fact, more consistent than text modes.


This program generates a screen consisting of a margin of Graphics 8 down the left hand side of the screen with the rest of the screen in Graphics 9. To add further variety, the normal 4 line Graphics 0 text window is retained. One use of this arrangement is the ability to draw graphs in 16 intensities neatly labelled with 40 column text.

The technique is performed by changing the GTIA selection in PRIOR ($D01B) at a particular point during every scan line. We end up with every scan line comprising 32 pixels of Graphics 8 followed by the rest of the screen in Graphics 9. We can access these from Basic by fooling the OS into thinking that we are in either Graphics 8 or 9 (subroutines GR8 and GR9) and then drawing to the relevant section of the screen.

The DLI used is provided in source form with this article and obviously by increasing or decreasing the delay between changes to PRIOR we may increase or decrease the proportions in which the screen is split between the two modes. Obvious other applications are graphs such as pie charts and so on whilst graphic adventures could be drawn in Graphics 9 with text or status information down the side in Graphics 8. There are many other applications where labelling is required.

One immediate question which arises is is whether it would be possible to do the same with ANTIC, that is, on a single scan line, change between ANTIC #E and ANTIC #F display mode. Unfortunately it doesn't look like this is possible as according to the Hardware Manuals, ANTIC's Display List Instruction Register (IR) cannot be directly accessed by the programmer.


For the second example I would like to quote from De Re Atari, page 5-8 under the section Applications of Display List Interrupts. "Of course, no two sections of the player can be on the same horizontal line, so two incarnations of the player cannot be on the same horizontal line."

This statement is completely incorrect and is disproved by the program PLAYDEM. By using a very precise timing loop, the program allows two incarnations of player 0 to be present in separate halves of the screen. The first incarnation can take horizontal positions 0 to 122, while the second incarnation can take horizontal positions 123 to 255. If either incarnation is outside of this range it will not be visible.

The timing loop is contained within a DLI and the source listing is provided. The timing involved every scan line requires waiting until the first incarnation has been displayed before altering the player's horizontal position. Obviously this technique could quite easily be extended to all of the players (by using NOPs within the timing loop). It would also be possible to change PMBASE as well and thus have completely independent incarnations of each player as long as they are within certain screen bounds.

To position these incarnations of player 0, the horizontal position for the first incarnation should be stored in location 203 and the horizontal position for the second in 204. In the program I have also displayed all the other players and missiles and the playfield to prove that there is no cheating!!

This is, obviously, a very powerful technique and it is feasible that in a game such as PAC-MAN we could generate all the ghosts from merely one player.

GraphDem DLI source code

1000 *=$0600
1010 PHA
1020 TXA
1030 PHA
1040 TYA
1050 PHA
1060 LDA #$00
1070 LDY #$40
1080 LDX #$A0 ; loop over 160 scans
1090 LOOP
1100 STA $D40A
1110 STA $D01B ; disable GTIA
1120 CPX #$A0
1130 BEQ SKIP1 ; first lms ?
1140 NOP
1150 SKIP1
1160 CPX #$42 ; second lms ?
1170 BEQ SKIP2
1180 STA $CB ; three cycle delay !
1190 SKIP2
1200 STA $CB ; three cycle delay !
1210 NOP
1220 NOP
1230 NOP
1240 NOP
1250 STY $D01B ; enable GTIA #9
1260 DEX
1280 STA $D40A
1290 STA $D01B ; disable GTIA
1300 PLA
1310 TAY
1320 PLA
1330 TAX
1340 PLA
1350 RTI

PlayDem DLI source code

1000 *=$0600
1010 PHA
1020 TXA
1030 PHA
1040 LDX #$C0 ; loop over 192 scans
1050 LOOP
1060 LDA $CB ; first position
1070 STA $D40A
1080 STA $D000
1090 CPX #$C0 ; first lms ?
1100 BEQ SKIP1
1110 NOP
1120 SKIP1
1130 CPX #$62 ; second lms ?
1140 BEQ SKIP2
1150 LDA $CC ; three cycle delay !
1160 SKIP2
1170 LDA $CC ; second position
1180 NOP
1190 NOP
1200 NOP
1210 NOP
1220 NOP
1230 STA $D000
1240 DEX
1260 PLA
1270 TAX
1280 PLA
1290 RTI