Classic Computer Magazine Archive COMPUTE! ISSUE 48 / MAY 1984 / PAGE 10

Sprite Data Problems

I am a Commodore 64 owner and I have a question about sprites. I understand how to create a sprite and move it around the screen. I also know how to move more than one sprite, if the data for them is the same. My problem occurs when I have more than one set of data. I can't seem to get both sprites on the screen at the same time. The Programmer's Reference Guide doesn't have an example with two sets of data. I would appreciate it if you would help me out.

Seth Hausman

Jim Butterfield replies:

I can think of two possible problems with your sprites:

1. You may have forgotten to link each sprite to its drawing in memory. With normal memory mapping, sprite 0 needs to have its drawing number (usually 11, 13, 14, or 15) placed into memory address 2040, sprite 1 into 2041, and so on up to sprite 7 into address 2047. If you use drawing number 11, the drawing of the sprite should be in addresses 704–766 decimal; for number 13, addresses 832–894; for number 14, addresses 896–958; and for 15, 960–1022.

2. Many sprite register addresses control all eight sprites at the same time. To turn sprite 0 on, you would POKE 53269,1; to turn sprite 1 on, you would POKE 53269,2; to turn them both on, you would add 1 and 2 and POKE 53269,3. The following table shows the bit values for each sprite:

Sprite 0–1

Thus, to turn on sprites 0, 2, and 4, we add 1+4+16 and POKE 53269,21.

Be sure that you keep the difference between a sprite number and a drawing number clear in your mind. Several sprites can use one drawing (or "definition"); or a single sprite can be switched from one drawing to another as it moves its arms, legs, tentacles, or whatever.