Sprites per line limit

From NeoGeo Development Wiki
Revision as of 00:23, 5 April 2016 by Furrtek (talk | contribs) (Created page with "thumb|[[Twinkle Star Sprites often exceeds the limit because of the many particle effects.]] The sprite per line limit is a hardware-imposed limit c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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 consoles. 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 (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's GPU was designed to render no more than 1536 sprite pixels per line (96*16 pixels).

It is important to notice that even transparent pixels, and pixels removed by horizontal shrinking 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

For example, in the following sprite setup, there are four 1-tile high sprites next to each other at the exact same Y positions:

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 displays 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 ?