Sprites per line limit

From NeoGeo Development Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Twinkle Star Sprites often exceeds the limit because of the many particle effects.

The sprite-per-line limit is a hardware imposed limit commonly found in old sprite-based videogame hardware. It is defined as a maximum number of sprites per raster (horizontal) video line.

This number is 96 on the NeoGeo.

If the limit is exceeded on a line, the next sprites (in VRAM order) which should be drawn on that particular line are simply skipped. Care must therefore be taken by developers to stay under the limit in order to avoid glitches.

Details

The limit comes from the fact that the NeoGeo GPU was designed to render no more than 1536 sprite pixels per line (96*16 pixels).

It is important to note that even transparent pixels, and pixels removed by horizontal shrinking also count as sprite pixels. The sprite's height value must be set appropriately to avoid "consuming" excess pixels in the lower part.

Even if a 5-tiles-wide chained sprite block is shrunk horizontally to 0 (resulting in a 5 pixels wide block on the display), it will still count as 5*16 = 80 pixels.

The GPU simply isn't smart enough to spend time writing only visible pixels.

Example

In the following sprite setup, there are four 1-tile high sprites next to each other at the exact same Y positions. They are set in VRAM from 0 to 3 from left to right:

If the NeoGeo allowed a maximum of 3 sprites per line, the black sprite would be completly masked off:

Let's say we move the blue sprite down a bit. Since the limit is on a per-line basis, the top of the black sprite shows but the rest is masked (magenta zone):

Then again, if the green sprite is moved up, we can clearly see that the black sprite gets masked only where all the sprites fall on the same lines:

The top is displayed because only red and green are on the lines. The bottom is displayed because only red and blue are on the lines.

Here's a sprite set to show graphics only 3 tiles high, but configured as 4 tiles high sprite, the magenta zone represents the wasted lines, which aren't visible but will count on the corresponding lines:

Setting the sprite's height to 3 instead of 4 can avoid masking of sprites falling on the previously wasted lines, in heavily animated scenes.

Emulation

MAME emulates the limit, but some other emulators might not. Which ones ?