ZX Spectrum Next Sprites¶
The Spectrum Next Wiki lists all the information, but the main points are
128 16x16 pixel sprites
Mirror, rotation and magnification of sprites
Sprites can be grouped together to make larger sprites
The sprite images are stored in their own 16k of memory in the FPGA
Think of the sprites as 128 slots in the Next that can each have a small 16x16 pixel image attached to it. The Next will then take care of moving and drawing those images. Each sprite has an X and Y position on the screen.
A “sprite pattern” is the name for the particular image that is assigned to a sprite. Each 16x16 sprite can have either 4bit or 8bit patterns assigned to it. There is a tradeoff between the number of sprite patterns and their colour depth. There’s only 16k of image memory available to store the sprite patterns, so maybe you have nicely coloured main sprites, but then low colour bullets.
Each sprite had attribute data associated with it. This is written to a register in the Next, one byte at a time (the Next internally keeps track of which attribute you’re uploading). Getting the attribute data into the Next is the main challenge, followed by getting graphics data into it correctly.
Fortunately, to save us a lot of effort someone else has written a simple API for the sprite library . It is slightly outdated, but works fine and comes conveniently as a library you can install into Z88DK.
We will be using this as a starting point for a sprite system that handles multiple sprites, of varying sizes that can load a sprite sheet from SD card.
- Loading Sprites
- Drawing Sprites
- Rotating Sprites
- Scaling Sprites
- Bigger sprites
- Managing Multiple Sprites