Animation on SPECTRUM - Sprites and masks...
SPRIES AND MASKS
So, let's say y us yes
background (Fig. 1), and sprite (Fig. 2). B
as an example we took them from
BATMAN program, which is
is a brilliant example of three-dimensional
no animation, bypassed
almost all are eight-bit
computers - ENTERPRISE, COMMO-
DORE 64, ATARI, SCHNEIDER, SPEC-
TRUM 48/128 and others.
If we just forward
sprite on the screen, we get this
such a picture (Fig. 3). Main
part of the forwarding program
the sprite on the screen may look like
something like this:
LD A,(DE) ;in DE - address in
memory
LD (HL),A; in HL - address on
screen
To prevent the sprite window from closing
Ralo background, you can only turn on
those bits that match c
background bits, then we get
such a picture (Fig. 4). That is,
now the background shows through
sprite. Forwarding program every
How many bytes of sprite may look like
do it like this:
LD A,(DE)
AND (HL)
LD(HL),A
Thus, we need
maybe not everything will shine through
sprite window, but not the place
occupied by a BATMAN figurine. Here
This is where a mask comes in handy
(Fig. 5), repeating the contour of the volume
project that should not npocbe-
chivat. First through logical
“And” (AND) is applied to the background
mask, then apply the same
in the same place sprite and in
As a result, we get the following picture:
nku (Fig. 6)
Of course it's not the only one
a way to overlay a sprite on a background,
there can be a lot of options -
go, with this example we only want to
decided to demonstrate his own
principle
B next chapter we
let's look at ways to move
sprite vertically pixel by pixel
and horizontally.
to be continued.
___ ___
Share your thoughts about the article