Player Missile Graphics .. an introduction

by Les Ellingham

 

Issue 8

Mar/Apr 84

Next Article >>

<< Prev Article

 

 

 

If you are a newcomer to the Atari you may not even know that Player Missile Graphics exist for Atari seem to want to keep it a secret. There is no mention in the manuals and using Player Missile Graphics is not as easy as some of Atari's other features. You may know what Player Missile Graphics are but don't know how to use them or you may even be completely in the dark. Either way read on for an introduction to the marvellous world of Players and Missiles. Before we begin let me say that this is merely an introduction and if you find that you already know the subject well why not write a program and article as a follow on to help other users?

Player Missile Graphics are relatively easy to set up and use in simple terms but begin to get more complicated when you require FAST movement or when vertical movement is needed. The purpose of this article is to introduce Player Missile Graphics and we will therefore leave vertical movement and the like for a future article. I have said that Player Missile Graphics are relatively easy but there are a number of steps to learn and it is best to go through these stage by stage. The various steps do not necessarily need to be approached in the same order but it is best to adopt a consistent approach to help you to remember the procedure for other programs. Some of the stages give you options but all are required to set up Player Missile Graphics. Here are the various steps.

1. Design your Players
2. Reserve RAM for PMG
3. Set the Graphics mode for the playfield
4. Tell ANTIC where to find PMG
5. Clear out PMG area
6. Set up initial parameters 

        a) Resolution

        b) Width

        c) Horizontal & vertical positions 

        d) Colours
7. Place players/missiles in memory
8. Set priority
9. Activate PMG

Once all of the above steps have been accomplished you will have your players and missiles on screen and then only two more things are required - movement and collision detection.

Normally tutorials on Player Missile Graphics take you through these stages and put a single player on screen leaving you to guess what to do next. I have written a simple game to demonstrate not only the setting up of Players and Missiles but also showing priority and collisions and giving you the opportunity of expanding the game using your new found knowledge. You can even play the game - in a limited form - as it stands! Quickshot is the name of the game and if you look at the listing, lines 1000 - 1200 contain the routine that sets up Player Missile Graphics and should be referred to as we go along. Let's start.

DESIGN THE PLAYERS

Designing players is virtually the same as redefining characters except that although the image is eight bits wide the height can be up to 128 bytes in double-line resolution and 256 bytes in single-line resolution. There is not room in this article to go over bit-mapped images but the article on Character Redefinition in Issue 3 will provide the necessary background as will Memories in Issue 6. The first task then is with pencil and graph paper or a character design utility. Sketch out your player images and convert them to DATA. The DATA for your image is put into the program starting from the top of the image. We are using two players and the DATA is in lines 1080 and 1085.

RESERVE RAM FOR PLAYERS

Player Missile Graphics require their own area of RAM which must not be interfered with by other parts of the program. The easiest way to provide such an area of protected memory is to lower RAMTOP which Basic recognises as the upper limit of available memory. Location 106 holds the top of memory in pages - 256 bytes - and we can POKE a lower number in here to fool Basic into thinking that there is less memory available. Double-line resolution Player Missile Graphics requires 1024 bytes - 4 pages - and so in line 1000 we lower RAMTOP by first PEEKing the current value, then subtracting 4 and finally POKEing the new value into 106. Basic now thinks that memory ends 4 pages lower than it actually does and we can use the area above the new RAMTOP without interference.

SET GRAPHICS MODE

In line 1010 we make a graphics call for the mode we require as a background so that ANTIC the chip that handles the Graphics display - can set up a Display list below the new RAMT0P. By lowering RAMTOP we have in effect 'hidden' the old display list

TELL ANTIC WHERE TO FIND PMG

ANTIC needs to know where we have put our Player Missiles and we tell it by using location 54279 which is known as PMBASE. The figure to use is the page number at the beginning of Player Missile Graphics. We have used the variable TOP to define the new RAMTOP and this is where our Player Missile Graphics area starts. In line 1020 we therefore POKE 54279,TOP. We also need to know the actual memory location later on and this is calculated in this line by multiplying the number of pages (TOP) by 256.

CLEAR OUT PMG MEMORY


The memory we have reserved is probably full of unwanted data which might affect the images we are going to place there so, in line 1030, we clear this by POKEing zeroes in each memory location. Remember we are using 4 pages - 1024 bytes and we must therefore POKE in 1024 zeroes from the beginning of player memory which we calculated in line 1020 as PMMEM.

SET UP INITIAL PARAMETERS

So far the steps taken have been mandatory but we now come to a point where we can choose the form our players and missiles take. When you have typed in the listing, I suggest that you experiment by changing the values in lines 1040 - 1070 to see the various effects possible.

RESOLUTION: We have a choice between single line resolution and double-line resolution. In single-line resolution each byte of the player image takes up one TV scan line whilst in double-line resolution two scan lines are used giving a taller but less detailed image. For double-line resolution, location 559 should be POKEd with 46 as we have done in line 1040 and the number to use for single-line resolution is 62. If you wish to use single-line resolution, you require 2048 bytes of player memory and the initial steps of reserving RAM will have to be amended accordingly.

WIDTH: Players may be normal, double or quadruple width. Registers 53256-53259 hold the values for players 0-3. POKE with 0 or 2 for normal width, 1 for double width or 3 for quadruple width. Normal width will do us so we POKE in the appropriate value in line 1045.

HORIZONTAL & VERTICAL POSITIONS: In lines 1050 & 1055 we set variables for the initial positions in which we wish our images to appear. Any number between 0 and 255 may be used but only the middle range will appear on the screen. P0Y and P1Y hold the vertical positions of our players and P0X and P1X hold the horizontal positions. The precise positions that are visible may vary slightly on different TV sets so you are encouraged to experiment here with different values. In line 1055, M0Y, M1Y, M0X and M1X are the vertical and horizontal positions of the missiles associated with each player. Locations 53252-53255 control the horizontal position of the missiles and these are POKEd in in line 1065. There are no registers for vertical positions and so we must leave this for later.

COLOUR: Each player can be a different colour and locations 704-707 are POKEd wth a number representing the colour required. The number is derived from the normal SETCOLOR statement and is the HUE*16+LUMINENCE. As we are only using two players we use only locations 704 and 705 in line 1070.

PLACE PLAYERS/ MISSILES IN MEMORY

We now come to the point where we actually place our images into the area we have reserved. This is also the point where we define the vertical positions of our players and missiles. The Player Missile area is subdivided into six separate areas which are used - or not - for each image. Figure 1 shows the division of this area. 

 

 

Figure 1 - layout of Player Missile Graphics area

 

To place Player 0 in memory we first insert the DATA representing the player shape in line 1080 and then in line 1090 we READ this DATA and POKE it into the area allowed for Player 0. This is 512 bytes up from the start of the Player-Missile area (PMMEM) and we can place the image at any position from 512 to 639 which is the upper limit for Player 0. So, line 1090 READs the DATA and POKEs it, byte by byte, into the Player 0 area (PMMEM+512) at the vertical position required (P0Y). This procedure is repeated for Player 1 with the DATA in line 1085 and insertion of the player in line 1095. Missiles are placed similarly in the area beginning at PMMEM+384 but the procedure for defining missiles is different. Each missile can be only one or two bits wide as all four missiles are packed into one byte. 

 

The value 15 used is the binary number to turn on the first four bits representing the missiles for Players 0 and 1. Figure 2 gives more details of turning on the various missiles.

 

 

Figure 2 - DATA for missiles. Add together numbers for missiles required. Note each missile can be either 1 or 2 bits wide.

SET PRIORITY


Players can appear in front of or behind other players or background objects. Location 623 controls this priority and in line 1110 we set priority with the number 1 to start with as this can be changed as the program is run. When you run the program you may press any key and the contents of this location will change and be displayed enabling you to see the different priorities available.

ACTIVATE PMG

Finally the big moment! Despite all the work so far no players or missiles will appear on the screen until you enable Player Missile Graphics. All you do is POKE 53277 with 3 and - provided you have got the above steps right - presto! You should have Players and Missiles.

There is much, much more to Player Missile Graphics and this article has merely served as an introduction to get you started and whet your appetite. In future issues we will cover vertical
movement and give a machine code routine for moving all four players. In the meantime experiment and have fun.


Further references

GTIA TUTORIAL - PAGE 6 Issue 2 for POKEing values to colour registers.

CHARACTER REDEFINITION - PAGE 6 Issue 3 for a guide to defining characters which also holds good for players.

MEMORIES - PAGE 6 Issue 6 for an explanation of binary values.

MAPPING THE ATARI by lan Chadwick (COMPUTE! PUBLICATIONS) for full details of EVERY location used in Player Missile Graphics.


QUICKSHOT


The game is deliberately simple to enable you to follow the routines easily. The only new area introduced is collision detection. Locations 53256-53259 may be PEEKed to determine if a missile has hit a player. The value returned depends on which player has been hit and you can then send the program to a routine to determine the outcome of that 'collision'. Lines 160 and 185 do this. You can also use locations 53248-53251 for missile to playfield collisions, locations 53252-53255 for player to playfield collisions and 53260-53263 for player to player collisions.

Want to play the game? You are the white cowboy and when the bell sounds you must outdraw your opponent. You can move your player right and left and fire with the trigger. Use the keyboard to set different priorities and watch how your player can move in front of or behind other objects. There are no score routines and no control of the second player, it's up to you to add these yourself. Study the listing carefully and you should be able to figure out how to move the second player and find out where to put scoring routines.

 

AtariLister - requires Java

top