Technology sprites - Part 4: Format of sprites with a mask.

ZX Forum #04
             MASKS


   As for masks, then there
would be difficult to entitle this
article, "These different masks,
because at the front all the masks
easy and standardized.

   For a start let us look at what exactly is a mask.
Look at the sprites from 3D games
BATMAN; you can see that
before the image of the man
is a figure,
which instead shows a man of his silhouette. Why does he need?
It's simple - when printing
sprite on the screen straight copy (LD A, (data); LD (screen), 
A or otherwise), we eliminate the background that was behind 
sprite, resulting in the sprite around the ugly form of 
emptiness, that spoils the overall impression of the game. Here 
zdesto and comes to the fore mask. The central processor has a 
in its arsenal, a logical command as AND. What happens to the 
screen, if the mask imposed on the screen with this Team:



      Screen 11111111 bytes

      byte mask 11100111

                  -------
      result 11100111


   As you see, you can see the space turned off pixels. Someone 
has probably already guessed: indeed, if we impose on the 
screen mask before you print yourself

sprite on the screen will turn an empty space - the size of a 
sprite. If we now print on the screen

sprite no direct copying, but
combine screen and sprite for OR,
then the sprite will fit into the purified
mask window and the background, which is located next to the 
sprite, not will be spoiled.


   How to create a mask. Once your sprite is ready, he
must create a mask, and make it very simple. Creation
Masks can be divided into 3 phases:

   First, we invert the sprite is drawn on (off included bits 
and include shutdown), the second stage - to erase all inside 
the silhouette, and finally, the third stage - we are expanding 
the internal space of the mask by 1 pixel. It is necessary to 
sprite when printing is not merged with background, and 
separated from it by a strip of one-pixel. 

   Well, the mask seems to be everything.
Let me just say that the memory mask
stored in the same form in which is stored corresponding
sprite.