Classic Computer Magazine Archive ANTIC VOL. 2, NO. 3 / JUNE 1983

Up and Down

Vertical movement for player/missiles

by Chris Nicotra

Player/Missile graphics are among the most powerful capabilities of the ATARI computer. Using the computer's horizontal-position registerj simple players can be quickly moved across the screen. This means you can write impressive, arcade-style games even in BASIC.

Many articles describe how the amateur programmer can use this tool. Most of these also mention the problem of slow vertical motion. Since the only way to move the player up or down from BASIC is to shift the player image using PEEKs and POKEs, the vertical motion of a player is considerably slower than the horizontal motion.

One solution is an Assembly Language routine to shift the player tables vertically one position at a time. Unfortunately, this does not come close to equalling the horizontal-motion capabilities of Player/Missile graphics. This article gives you a simple Assembly Language routine that will make vertical motion as simple and fast as horizontal motion, and shows you how to use it from BASIC.

You will need to know the fundamentals of P/M graphics from other sources to benefit from this article. Since the purpose here is to show you a tool for game writing, I will touch only briefly on the meaning of the P/M registers.


Once the Player/Missile routine is installed, it becomes part of the vertical-blank service routine. Then, every 60th of a second, the computer will erase each of the players and missiles from the screen and re-draw them in their new vertical position. This entire process is transparent to you, the programmer. Your only task is changing the vertical- and horizontal-position registers; and the players and missiles will move around the screen.


First, load the Player/Missile routine into memory. This is done by calling the "load" subroutine, beginning at line 8000, as follows:

GOSUB 8000

Second, define each player's image. To do this, POKE the desired image into the player-image table. The following table shows the address to store each player's image:


  0    1571-1580
  1    1581-1590
  2    1591-1600
  3    1601-1610

These images are laid out in memory the same way the players are in the Player/Missile table. For example, if you want player zero to look like this:

*      * = 129 decimal 
*      * = 129 decimal 
*  **  * = 153 decimal 
******** = 255 decimal 
******** = 255 decimal 
*  **  * = 153 decimal
*      * = 129 decimal 
*      * = 129 decimal

you could use the following code to set-up the image:

POKE 1571,129
POKE 1572,129
POKE 1573,153
POKE 1574,255
POKE 1575,255
POKE 1576,153
POKE 1577,129
POKE 1578,129

Next, POKE this size of the player image into the playersize table. The following is a table of player-size locations:


  0      1611
  1      1612
  2      1613
  3      1614

Since the player used in our example contained eight bytes in the image table, POKE 7 (one less than the number of bytes) into the player-size table for player number zero.

POKE 1611,7

Next, select the Graphics Mode to be used in the program. Finally, activate the Player/Missile routine by calling the Player/Missile initialization routine, beginning at Line 9000, as follows:

GOSUB 9000

At this point, the system has a set of vertical-position registers. The location of these registers is shown in this table:



  0     1536 
  1     1537 
  2     1538 
  3     1539


  0     1540
  1     1541
  2     1542
  3     1543


Whenever the Graphics Mode in BASIC changes, so does the size of the display buffer. As a result, the pointers to the player and missile tables must be changed. Unfortunately, while the pointers are being changed, the Player/Missile routine is trying to use them. In other words, the Player/Missile routine could grab a half-changed address from the pointer table and start putting the player's image in the wrong part of memory. This could be disastrous. The Player/Missile routine should be turned off to prevent this conflict by POKEing a 1 into location 1562. The Graphics Mode can then be changed and the Player/Missile routine can be re-initialized by the initialization routine. The following instructions might be used to safely change the Graphics Mode in a program:

POKE 1562,1
GOSUB 9000

Listing 1 demonstrates these routines. In this program, the joystick moves the player, and a missile is shot by pressing the trigger on the joystick.

Listing 2 contains the Assembly Language listing of the Player / Missile routine