Masking Sprites
A sprite is the name given to any object that can move around the screen. More powerful home computers had hardware sprites and did not suffer from attribute clashes. Spectrum games, on the other hand, tended to be mostly monochrome, and it was up to the developer to draw sprites on the screen.
Sprites in early games would tend to merge in with the backgrounds; Jet Pac and Manic Miner are good examples of games that used this approach.
Later games looked a lot slicker; the sprites would be drawn but would not merge into the background. How was this achieved?
Boolean algebra, my friends, was the solution.
The following diagram of a 16×16 sprite image of a bubble will explain:
The sprite and mask data is stored in memory with a “0” where the white bits are and a “1” where the dark grey bits are.
The sprite data is what the player actually sees; a picture of a bubble. The mask data is the clever bit; this is the area of screen you wish to clear before drawing your sprite. So, first AND the mask data onto the screen, then OR the sprite data and you get the result.
Note that the mask data is a pixel wider all round than the sprite; this is to give the sprite a clear border; you will see this used to great effect in many games.
Whilst this was time consuming; both for the artist to draw the masks and the computer to do double the work for each sprite, the final result was well worth the effort.
Different programmers had different ways of storing the sprite data. I think I interleaved each sprite and mask data sprite, though I could be wrong.