Graphics Simplified


Staffan Sandberg

You've seen the wonderful things the Atari can do with player/missile graphics, but until now you've either had to settle for slow-moving wobbles or learn machine language. Here is an overlay method which is simple to use and results in extremely fast animation of up to five players.

In the overlay method we will design overlays, or patterns that we can place on the screen. We can create as many patterns as we want and use them as often as we want. Each overlay is eight dots wide and anything from one to 128 dots high. The overlay allows specified dots to be lit up on the screen. When we want an object to appear to be moving, we place one of the overlays on the screen by specifying its X and Y coordinates. We then give it new X and Y coordinates, and it appears to move. This process is very fast, so the object appears to move quite quickly. These overlays are totally separate from player/missile graphics. It is the combination of the overlays and player/missile graphics that allows us the freedom of movement of the overlay method. To use overlays, just follow these steps:

Step 1: Decide how many players you wish to use and set aside enough memory to hold them. That is, what is the maximum number of objects you want on the screen at one time? You can have up to five. We must give each one a name and set aside 128 spaces for it because each player is potentially 128 dots high. We do this by DIMensioning the space:

10 DIM PM1$(128),PM2*(128),PM3$(128)

The DIMensioning must be the first thing the computer sees when it is turned on, so before you start programming, turn off the computer and turn it back on. This is necessary because as the computer constructs a variable table, the variables are stored in the order that they are entered. The variable table is not cleared by typing NEW. We want these variables at the beginning of the table so we can find them easily later. If they are not the first thing that the computer sees, the method will not work.

Step 2: Design the overlays or patterns that you wish to use. Remember, you can create as many overlays as you wish. They are stored in strings (ALIEN$, SHIP$, etc.), so you must give each overlay a name and DIMension its size. When deciding the size of each overlay, keep the following questions in mind:

You don't need to worry about the width of the overlay. But you must decide how many dots high you wish to make an overlay. It can be up to 128 dots in height (an average spaceship might be six dots high). If you are going to be moving your players down the screen, you must leave blank spaces to cover up the old overlay, and you must take into account the speed at which your player will move. The speed is measured in Dots Per Move (DPM). If your players will be moving at a top speed of three DPM up and down the screen, then you need to leave three spaces above and three spaces below. To help decide the size to be DIMensioned for each overlay, use the formula:

SIZE = height of overlay + DPM up + DPM down

SHIP$ and ALIEN$ Examples

In our example we will have one ship which we'll call SHIP$, with a height of six moving up and down at the speed of five DPM, and another ship which we'll call ALIEN$, with a height of eight moving neither up nor down.

20 SIZE1=l6:SIZE2=8 

We also want a blank overlay that we use to erase the player from the screen quickly. We'll call this overlay CLEAR$. It should be 128 dots high so that it can erase anything on the 128 dot high player.

40 DIM CLEAR$(128)

Now you must create the overlays line by line. Each line or row is made up of dots or "boxes." Each box is numbered from right to left 1, 2, 4, 8, 16, 32, 64, and 128.

128 64 32 16 8 4 2 1

To create the overlays, you must decide which boxes you want filled or lit up on the screen. You then add the value of each filled box for each row (see Figures 1 and 2).

Figure 1. The Ship

Figure 2. The Alien


Now that you have the totals for each row, you must put them in the string that you have DIMensioned for them. This is done in a short loop such as the one below.

90 DATA 0,0,0,0,0
100 DATA 16,56,56,124,108,68
110 DATA 0,0,0,0,0
160 DATA 60,126,219,126,36,36,66,129

You need a loop for each overlay that you have.

You also need to create the blank overlay, CLEAR$, by entering 128 blank lines into CLEAR$.

170 FOR ROWS=1 TO 128

Step 3: Tell the computer that you are going to be using player/missile graphics with overlay method by entering the following lines, substituting a value for NUMBEROFPLAYERS.

200 A=4*(INT(PEEK(742)/4)-1)
210 POKE 54279,A
220 VSA=256*PEEK(135)+PEEK(134)
230 BOA=256*PEEK(141)+PEEK(140)
240 PM=256*A+512
260 ADD=2
330 NEXT T

If you are going to have five players on the screen at one time, you must change line 240 from PM = 256* A + 512 to PM = 256* A + 384. This tells the computer to let us use the fourth missile as a player.

Step 4: Now we are ready to add the initial specifications, such as color, size, and shape to the players. First, line 340 places the blank overlay on each player, clearing out any stray data.


Next we set the player/missile graphics to double-line resolution and turn on the P/M graphics (a 3 enables them and a 0 disables them).

350 POKE 559,46:POKE 53277,3

To set the colors of the players, we must POKE the color register for each player with the proper color number. The registers go from 704 (for Player 0) through 707 (for Player 3). The fifth player takes on a combination of the colors of the other four. The colors that I have chosen are: COLR1 is yellow, COLR2 is white, and COLR3 is pink:

360 COLR1=25:COLR2=11:COLR3=74
370 POKE 704,COLR1:POKE 705,COLR2:POKE 706,COLR3

The size of the players is automatically set to normal. If you want to change the size, POKE 0 for normal, 1 for double, and 3 for quadruple size into the size register for the corresponding player. These registers go from 53256 (for Player 0) through 53259 (for Player 3).

POKE 53256,1 would make Player 0 double size.

Now we can place the player on the screen. First, we give the player an X (horizontal) value and POKE it into the horizontal position register for each player. The registers go from 53248 (for Player 0) through 53251 (for Player 3). The horizontal positions that show up on the screen range from about 50 to 200 (depending on your TV). Numbers lower than 50 and greater than 200 are to the right and left of the screen.

380 X1=125:X2=75:X3=175
390 POKE 53248,X1:POKE 53249,X2:POKE 53250,X3

Now we must give our player a Y (vertical) value and an overlay. The format is PM$ (Y value) = overlay.

400 Y1=125:Y2=25:Y3=25
410 PM1*(Y1)-SHIP$:PM2$(Y2)=ALIENS$:PM3$(Y3)-ALIEN$

To move the player around the screen, change the X and/or the Y value and repeat steps 390 and 410. Be sure not to change the X value more than the maximum DPM that you decided earlier. If you do, you will leave parts of the overlay on the screen.

Program 1. Player/Missile Graphics Example 1

Download P107L1.BAS (Saved BASIC)
Download / View P107L1.LST (Listed BASIC)

Program 2. Player/Missile Graphics Example 2

Download P107L2.BAS (Saved BASIC)
Download / View P107L2.LST (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section