The video processor can display up to sixteen sprites in any given frame. These sprites can have arbitrary dimensions, and can also be scaled.
Some sprites are initially reserved by the system:
- Sprite 14: reserved for the mouse pointer
- Sprite 15: reserved for the text cursor
Sprites are configured using ports 0x1D—0x26, but must first be selected using port 0x1C in order to read or write sprite configuration data.
Selects the desired sprite (0 - 15).
If set, the selected sprite is visible. If not set, the selected sprite is hidden and not rendered.
Determines the layer over which to draw the sprite. Sprites are always drawn above the indicated layer.
Determines the page from which to load the sprite's tile data. This is then mapped against sprite's tile page (0X1F) and used to render the sprite. Sprite are always tile-based in nature; there is no unique pixel addressing mode for sprites.
Within a given 16K page, this is used to select the actual sprite data. An index addresses 64 bytes of memory, although with color data, a sprite is usually larger than 64 bytes.
Indicates the scale of the sprite.
0: normal scale1: double scale2: 4x scale3: 8x scale
Indicates the source tile material for the sprite.
Indicates the height of the sprite, in tiles. Ranges from 0 to 15 tiles high.
Indicates the width of the sprite, in tiles. Ranges from 0 to 15 tiles wide.
Indicates the sprite's background color. If 0x00, the sprite will be transparent.
Indicates the sprite's foreground color. Any 0xFF pixels in the sprite will render with this color.
Determines the sprite's horizontal position. Combined, ports 0x23 and 0x24 form a sixteen-bit word (with 0x23 as the high eight bits) allowing a sprite to be positioned anywhere on the screen. The position is signed, meaning that negative values can be specified to ensure that a sprite is off screen (to the left).
Note that the horizontal sprite position of 0 does not indicate the left-most visible pixel column on the screen. Instead 0 is typically behind the screen border. For small sprites, this means it's easy to go "off screen" without having to go negative.
The screen border is typically 64 pixels wide. To display a sprite at the first visible horizontal pozition, set the X position to 64. Similarly, the last visible X position is 575.
Determines the sprite's vertical position. Like the X position, these two ports combine to form a sixteen-bit word (with 0x25 as the high byte). This allows the sprite to be positioned anywhere on the screen. The position is signed, meaning that negative values can be specified to ensure that a sprite is off screen (above the top).
A vertical position of 0 does not indicate the top-most visible pixel row on the screen. Instead this is typically behind the screen border. The screen border is typically 48 pixels high. To display a sprite at the first visible position, set the Y position to 48. Similarly the last visible Y position is 431.
Sprite collisions are tracked with ports 0x29 and 0x2A. Each bit (with 0x29 being the high bits) represents a single sprite. If the bit is set, the sprite collided with something (although the system doesn't track what). If unset, the sprite hasn't collided with anything.
- TODO: Implement this!