2

h_rule.jpg

Designing
Player Images



In this chapter you'll learn how to design an original graphic image that you can animate using Atari's special PMG features. We'll call this image a "player" to distinguish it from other graphic objects that may appear on the screen. Specifically, when you finish this chapter, you'll be able to:

  1. Lay out a player image on graph paper.
  2. Figure out the binary data required in memory to create a player.
  3. Calculate the decimal numbers needed to create a player image.
  4. Sketch out the player images that would be created by various kinds of data in memory.
  5. Explain what distinguishes player-missile (PM) memory from ordinary memory.

Let's begin by taking a look at the way graphic images are stored in memory.

HOW IMAGES ARE STORED

As you probably know, your Atari has several different graphics modes. In this discussion, I will be referring to graphics modes 3 through 8. These modes are for displaying pictures rather than words or letters.

An important graphics term is pixel, short for "picture cell." (Think of "pic.-cell.") A pixel is the smallest picture element possible. The size of a pixel depends on the graphics mode you are in. This next illustration shows the approximate size of a pixel in graphics mode 3.

ch2_p1.gif

If you'd like to see what a pixel actually looks like in different modes, trying running this program:

10 GRAPHICS 5:? "WHAT GRAPHICS MODE WOULD YOU LIKE? ...
   (ENTER A NUMBER BETWEEN 3 AND 8)" 
20 INPUT GM:IF GM<3 OR GM>8 THEN 10 
30 GRAPHICS GM 
40 COLOR 3 
50 PLOT 30,18 
60 ? "THIS IS A PIXEL IN GRAPHICS MODE";GM
70 FOR PAUSE=1 TO 1000:NEXT PAUSE 
80 GOTO 10

As you may know, all data in random access memory (RAM) is stored in consecutive memory locations called bits. (Eight consecutive bits are called a byte.) Each bit contains either a one or a zero.

A certain part of RAM is used to hold data that will be used to display screen images. Let's call that screen RAM. If a bit in screen RAM is set to one, then the corresponding screen pixel will light up. If a bit is a zero, then the pixel will be turned off.

ch2_p2.gif

ANSWER

 

A   (Remember that each bit set to one causes the corresponding screen pixel to be illuminated.)

 

ONE- AND TWO-DIMENSIONAL IMAGES

Notice that image "A" above is not yet really a two-dimensional image. It has a horizontal dimension, but no vertical dimension. Actually, it is just a stubby line. Let's make it into a two-dimensional image by turning on some pixels directly beneath it on lines two and three.

ch2_p3.gif

Now we have a two-dimensional image. It has height and width. In Ordinary RAM it would be hard to display this image. We would have to do a lot of calculating to figure out which bits in RAM to set to one. Why? Well, RAM is linear; it consists of a series of bytes laid end to end. It is one-dimensional.

ch2_p4.gif

On the other hand, screen images are two-dimensional. They have a horizontal and a vertical dimension. Fortunately, the Atari engineers simplified

ch2_p5.gif

all this. They arranged for the second byte in PM memory to be displayed directly under the image of the first byte. Similarly, the third byte is displayed directly under the image of the second byte, and so on. This way the data for an image can be stored in consecutive bytes in RAM as illustrated here:

ch2_p6.gif

Of course, before you put any data into those consecutive bytes, you need to know exactly what image you want to create. So let's go over the procedure for designing a player image.

DESIGNING A PLAYER IMAGE

First, lay out a grid that is 8 columns wide with as many rows as you like up to 128. For example, you might start with a grid that has 8 columns and 11 rows, like this:

ch2_p7.gif

Next, make an image by shading in selected squares on the grid. (Actually, each square on your grid represents a pixel on the display screen.) Here's an example:

ch2_p8.gif
ANSWER

 

Just one.

 

LIGHTING UP PIXELS

The next step is to figure out which bits in memory to set to one so the proper pixels are turned on. This is really quite simple. All we do is convert each row in our grid to a number.

To do that we look at each square in our grid. If the square is shaded in, we write down a "one." If the square is not shaded, we write down a zero. For example, we would convert the first row of our player like this:

ch2_p9.gif

This number--00011100--is called a binary number. Notice that it is composed of just ones and zeros. As you may know, a binary 00011100 is not at all the same as eleven thousand, one hundred (11,100). I'll explain this shortly if you don't understand binary numbers. For now, just remember that we are translating each row of our player into a binary number.

ch2_p10.gif

ANSWER

 

00011100 (row 2)
00001000 (row 3)

 

ch2_p11.gif

ANSWER

 

a.    00011100
b.    00011100
c.    00001000
d.    00011100
e.    00111010
f.    01011001
g.    00011000
h.    00101000
i.    01001100
j.    01000100
k.    01000100

 

Now we have all of the binary numbers needed for our player image. But before we can put these values into Atari's memory, we need to convert them into decimal numbers. That's because BASIC was designed for inputing decimal numbers, not binary ones.

If you already know what decimal and binary numbers are and how to convert from binary to decimal, you can skip ahead to "Converting the Image to Decimal Numbers." Otherwise, read on and I'll explain.

Decimal numbers are the kind used by most normal people (You know what I mean--people who aren't assembly language programmers). The word part "dec" means "ten". For example, a decade is a period of ten years. The decimal number system contains ten different number symbols, which are:

0,  1,  2,  3,  4,  5,  6,  7,  8,  9

Similarly, the word part "bi" means "two." For example, bimonthly means "every two months." Binoculars are field glasses designed for use by two eyes. The binary number system uses only two kinds of number symbols: 1's and 0's.

Let's look at some binary numbers. To keep things simple, we'll start out with small binary numbers and put each number symbol in a box.

ch2_p12.gif
ch2_p13.gif

ANSWER

 

2 (2+0=2)

 

Now let's try a binary number with three number symbols. Again, we'll put each symbol in a box. This time, above each box, we'll show what the box is worth in decimal if it has a "1" in it.

ch2_p14.gif

So this binary "111" represents a decimal 7 since 4 + 2 + 1 = 7.

ch2_p15.gif
ANSWER

 

6 (4+2) 3 (2+1), 2

 

a. 101    _____________
b. 010    _____________
c. 001    _____________
d. 111    _____________

ANSWER

 

a. 5   b. 2   c. 1   d. 7

 

Now let's look at an eight-position binary number. We'll put the digits in boxes again to help you visualize the number.

ch2_p16.gif

This binary number is equal to 255 since:

128+64+32+16+8+4+2+1=255
ch2_p17.gif

ANSWER

 

253 (It is just two less than the previous example. Notice we now have a "0" in the "2 box" instead of a "1."

 

ch2_p18.gif

ANSWER

 

20

 

ch2_p19.gif

ANSWER

 

40 (32+8=40)

 

CONVERTING THE IMAGE TO DECIMAL NUMBERS

Now you're ready to convert your own player image to decimal numbers. Before you do that, however, you may wish to practice on some examples.

  00111100 (4+8+1632)
00011100 (16+8+4)
00001000 (8)
00011100
00111010
01011001
00011000
00101000
01001100
01000100
01000100
  a. 60
b. 28
c. 8
d. __________
e. __________
f. __________
g. __________
h. __________
i. __________
j. __________
k. __________


ANSWER

 
  1. 28
  2. 28
  3. 8
  4. 28
  5. 58
  6. 89
  7. 24
  8. 40
  9. 76
  10. 68
  11. 68
 

If you'd like more practice in calculating decimal numbers, you may wish to try this next one. Otherwise, on to the next chapter. I can't wait to show you a new, little-known method for allocating PM memory!

MORE PRACTICE

ch2_p20.gif
ANSWER

 
  1. 60 (32+16+8+4)
  2. 124 (64 more than the previous row)
  3. 116 (124-8)
  4. 127 (3 more than row 2)
  5. 124 (same as row 2)
  6. 112 (12 less than row 5)
  7. 124 (same as row 2)
  8. 96 (64+32)
 

Congratulations. You can now design your own player image and calculate the decimal numbers needed for it. Next, you learn how to reserve memory for your player-missile image data.


Return to Table of Contents | Previous Chapter | Next Chapter