[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]

You can create sprites that have fifteen possible color choices (plus
transparent) instead of three (plus transparent), by "attaching" two
sprites. To create attached sprites, you must:

   *  Use two channels per sprite, creating two sprites of the same
      size and located at the same position.

   *  Set a bit called  ATTACH  in the  second sprite control word .

The fifteen colors are selected from the full range of  color registers 
available to sprites -- registers 17 through 31. The extra color choices
are possible because each pixel contains four bits instead of only two as
in the normal, unattached sprite. Each sprite in the attached pair
contributes two bits to the binary color selector number. For example, if
you are using sprite  DMA channels  0 and 1, the high and low order
 color descriptor words  for line 1 in both  data structures  are combined
into line 1 of the attached object.

Sprites can be attached in the following combinations:

                       Sprite 1 to sprite 0
                       Sprite 3 to sprite 2
                       Sprite 5 to sprite 4
                       Sprite 7 to sprite 6

Any or all of these attachments can be active during the same display
field. As an example, assume that you wish to have more colors in the
spaceship sprite and you are using sprite  DMA channels  0 and 1. There
are five colors plus transparent in this sprite.


                         0000154444510000
                         0001564444651000
                         0015676446765100
                         0001564444651000
                         0000154444510000


The first line in this sprite requires the four  data words  shown in
Table 4-4 to form the correct binary color selector numbers.


        Table 4-4:  Data Words  for First Line of Spaceship Sprite


                           Pixel Number
                           ------------

           15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0
   ----------------------------------------------------------------------
   Line 1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
   Line 2   0   0   0   0   0   1   1   1   1   1   1   0   0   0   0   0
   Line 3   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
   Line 4   0   0   0   0   1   1   0   0   0   0   1   1   0   0   0   0


The highest numbered sprite (number 1, in this example) contributes the
highest order bits (leftmost) in the binary number. The high order
 data word  in each sprite contributes the leftmost digit. Therefore, the
lines above are written to the sprite  data structures  as follows:

        Line 1    Sprite 1 high order word for sprite line 1
        Line 2    Sprite 1 low order word for sprite line 1
        Line 3    Sprite 0 high order word for sprite line 1
        Line 4    Sprite 0 low order word for sprite line 1

See  Figure 4-7  for the order these words are stored in memory. Remember
that this data is contained in two sprite structures.

The binary numbers 0 through 15 select registers 17 through 31 as shown in
Table 4-5.


          Table 4-5: Color Registers in Attached Sprites


            Decimal        Binary     Color Register
            Number         Number         Number
            -------        ------     --------------
               0            0000            16 *
               1            0001            17
               2            0010            18
               3            0011            19
               4            0100            20
               5            0101            21
               6            0110            22
               7            0111            23
               8            1000            24
               9            1001            25
              10            1010            26
              11            1011            27
              12            1100            28
              13            1101            29
              14            1110            30
              15            1111            31


              * Unused; yields transparent pixel.


Attachment is in effect only when the  ATTACH  bit, bit 7 in sprite
 control word 2 , is set to 1 in the  data structure  for the odd-numbered
sprite. So, in this example, you set bit 7 in sprite  control word 2  in
the  data structure  for sprite 1.

When the sprites are moved, the Copper list must keep them both at exactly
the same position relative to each other. If they are not kept together on
the screen, their pixels will change color. Each sprite will revert to
three colors plus transparent, but the colors may be different than if
they were ordinary, unattached sprites. The color selection for the lower
numbered sprite will be from color registers 17-19. The color selection
for the higher numbered sprite will be from color registers 20, 24, and 28.

The following  data structure  is for the six-color spaceship made with two
attached sprites.

SPRITE0:
        DC.W    $6D60,$7200     ;VSTART = 65, HSTART = 128
        DC.W    $0C30,$0000     ;First  color descriptor word 
        DC.W    $1818,$0420
        DC.W    $342C,$0E70
        DC.W    $1818,$0420
        DC.W    $0C30,$0000
        DC.W    $0000,$0000     ;End of sprite 0
SPRITE1:
        DC.W    $6D60,$7280     ;Same as sprite 0 except  attach  bit on
        DC.W    $07E0,$0000     ;First descriptor word for sprite 1
        DC.W    $0FF0,$0000
        DC.W    $1FF8,$0000
        DC.W    $0FF0,$0000
        DC.W    $07E0,$0000
        DC.W    $0000,$0000     ;End of sprite 1


[Back to Amiga Developer Docs]