Commodore 128 Programmer's Reference Manual page 276

Hide thumbs Also See for 128:
Table of Contents

Advertisement

266
COMMODORE 128
U
SPRITES:
MOVABLE OBJECT BLOCKS
U
A sprite is a movable bit-mapped object that you can define into a particular shape for
display on the screen. The sprite image can be as large as 24 pixels wide by 21 pixels
I j
tall. Each pixel corresponds to a bit in memory in the sprite storage range; therefore,
\j
each sprite requires 63 bytes of storage. The C128 has predefined storage locations for
sprite data in the range 3584 ($0E00) through 4095 ($0FFF).
.
The C128 graphics system has 8 sprites. Each sprite moves on its own indepen
dent plane. A sprite may move in front of or behind objects or other sprites on the
screen, depending on the specified priority. Standard bit-mapped sprites may be any one
of the sixteen available colors. Multi-color sprites may have three colors. The colors that
I J
are assigned to the pixels within the sprite depend on the bit patterns of the image. In
LJ
sprite storage memory, the on bits (1) enable the sprite pixels to display the color
selected by the sprite color register; the off bits (0) disable the corresponding sprite pixels,
i i
making them transparent and thus allowing the background color to pass through and be
M
displayed. Sprites also can be expanded to twice the normal size in both vertical and
horizontal directions.
Most of the commercially available graphics software packages for the Commo-
I j
dore 128 and C64 rely on sprites. For graphics programming applications, sprites offer
LJ
superior animation capabilities. Single sprites are useful for small moving objects.
However, you can adjoin and overlay several sprites to give greater detail to animated
I I
graphic images. For example, suppose you are writing a program that animates a person
|J
running on the screen. You can make the image of the person as a single sprite, but the
effect looks much more realistic if you allocate separate sprites for different parts of the
person's body. The arms can be one sprite, the body another, and the legs a third. Then,
| I
you can define two additional sprites: one as a second set of legs in a different position,
and the other as a second set of arms in a different position. Position the first set of
arms, the body and the first set of legs on the screen so that they are joined into a full
I I
body. By continually turning on and off the two different sets of arms and legs, the
LJ
image appears to be running. This process involves overlaying and adjoining sprites.
The explanation given here is a simplified algorithm, and the actual programming can be
j |
tricky. Sprite programming has been made easy with the new BASIC 7.0 sprite
M
commands.
The first part of this section explains the new BASIC sprite commands and
illustrates the procedure for overlaying and adjoining sprites. The second part
I j
explains the internal operations of sprites, including storage information, color assign-
LJ
ments, sprite expansion and addressing the sprite registers in machine language.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents