The Master System and Game Gear can draw up to 64 simultaneous sprites.

A maximum of 8 sprites can be displayed per line, any subsequent sprites will not be drawn on that line.

Sprite size

Sprites can be either 8x8 or 8x16 pixels in size. This mode is determined by bit 1 of VDP Register 1. When using 8x16 mode, the sprite tiles will need to be stored sequentially, starting at even indexes which are a multiple of 2. For example, if the sprite's tile index is set to 14, the top 8x8 of the sprite will use tile 14, and the bottom 8x8 will use tile 15. Setting the sprite's tile index to 15 will ignore the lowest bit and start with tile index 14 instead.

Sprite scaling

Sprites can be scaled, where each pixel is doubled in size. This mode is determined by bit 0 of VDP Register 1.
This feature works as expected on the SMS 2 and Game Gear, but does not work properly for all 8 sprites on a line on the SMS 1 and is not supported by the Megadrive VDP.

Sprite Attribute Table

Each sprite is defined in the sprite attribute table (SAT), a 256-byte table located in VRAM, typically at $3f00-$3fff. The SAT has the following layout:


    00: yyyyyyyyyyyyyyyy
    10: yyyyyyyyyyyyyyyy
    20: yyyyyyyyyyyyyyyy
    30: yyyyyyyyyyyyyyyy
    40: ????????????????
    50: ????????????????
    60: ????????????????
    70: ????????????????
    80: xnxnxnxnxnxnxnxn
    90: xnxnxnxnxnxnxnxn
    A0: xnxnxnxnxnxnxnxn
    B0: xnxnxnxnxnxnxnxn
    C0: xnxnxnxnxnxnxnxn
    D0: xnxnxnxnxnxnxnxn
    E0: xnxnxnxnxnxnxnxn
    F0: xnxnxnxnxnxnxnxn

If the Y coordinate is set to $D0, then the sprite in question and all remaining sprites of the 64 available will not be drawn. This only works in the 192-line display mode, in the 224 and 240-line modes a Y coordinate of $D0 has no special meaning.

Sprites that are partially off-screen when the X coordinate is greater than 248 do not wrap around to the other side of the screen. If bit 3 of register $00 is set, the X coordinate is treated as being minus eight. Sprites that are partially displayed on the left edge of the screen do not wrap, either.

The pattern index selects one of 256 patterns to use. Bit 2 of register #6 acts like a global bit 8 in addition to this value, allowing sprite patterns to be taken from the first 256 or last 256 of the 512 available patterns.

When bit 1 of register #1 is set, bit 0 of the pattern index is ignored. The pattern index selects the pattern to be used for the top of the 8x16 sprite, and the same pattern index plus one is used for the bottom half of the sprite.

When bit 0 of register #1 is set, sprite pixels are zoomed to double their size. 8x8 sprites are 16x16, 8x16 sprites become 16x32. There is a bug in how the original SMS VDP processes zoomed sprites compared to the SMS 2 and GG VDP; it will only allow the first four sprites of the eight shown on a scanline to be zoomed horizontally and vertically, and the remaining four will be zoomed vertically. The SMS 2 and GG allow all eight sprites to be zoomed in both directions.

Table parsing

On each scanline, the VDP parses the SAT to find which sprites will be displayed on the next line. It goes through each Y coordinate and checks the position along with the sprite height (controlled by bit 1 of register #1) to see if the sprite falls on the next line. If it does, the sprite is added to an internal 8-entry buffer.

The VDP stops parsing sprites under the following conditions:

If all eight buffer entries have been used and there are more sprites that fall on the same line, bit 6 of the status flags is set, indicating a sprite overflow condition occurred. The bit remains set until the control port is read. Note that this is regardless of the sprite X coordinate or pattern data, so eight transparent sprites that were off-screen would count towards a sprite overflow.

On the next scanline, the VDP uses the X coordinate as a counter that is decremented each time the H counter is incremented. When the counter expires, the bitplanes for the current line of the sprite are shifted out one bit at a time to form a 4-bit pixel.

The inter-sprite priority is defined by the order of the sprites in the internal buffer. An opaque pixel from a lower-entry sprite is displayed over any opaque pixel from a higher-entry sprite.

For example: Out of the eight possible sprites, 5 are used. Sprites 1,2,3 have transparent pixels. Sprites 4 and 5 have opaque pixels. Only the pixel from sprite 4 will be shown since it comes before sprite 5.

In the situation where any two sprites from any of the eight positions have opaque pixels that overlap, the VDP will set bit 6 of the status flags indicating a sprite collision has occurred. This bit remains set until the status flags are read.

The resulting sprite pixel is printed over any low priority background tile. Or, for high priority background tiles, only where there is a transparent pixel.

Sprites that are off-screen on the Game gear contribute to the 8 sprite limit.




Return to top
0.048s