SNES Sprites

The Super Nintendo draws sprites in hardware. Its picture processing unit keeps a dedicated object layer with up to 128 sprites, each placed, sized, coloured and flipped from a small table the program fills in. The PPU composites them over the background layers every frame, so movement costs the CPU almost nothing.

SNES Sprites

Overview

An SNES sprite is called an object, or OBJ. The PPU can show up to 128 objects on screen at once, each a small tile-based bitmap positioned anywhere on the 256×224 display. All 128 objects are described by object attribute memory, or OAM, a small private RAM inside the PPU. Each frame the program writes the objects it wants into OAM and the PPU draws them, with hardware flipping, priority and palette selection.

PropertyValue
Objects on screenUp to 128
SizesTwo, chosen from a global size set
Colour depth4bpp, 16 colours per object
Object palettes8 palettes of 16 colours
OAM size512 + 32 bytes
FlipsHorizontal and vertical, in hardware

Object sizes

Every object is one of two sizes, a small and a large. Which two are available is set once for the whole screen by a three-bit size field in the PPU object register, choosing one row from a fixed table of size pairs. Each object then picks small or large with a single bit in the high OAM table. Sizes range from 8×8 at the smallest up to 64×64 at the largest.

Size selectSmallLarge
08 × 816 × 16
18 × 832 × 32
28 × 864 × 64
316 × 1632 × 32
416 × 1664 × 64
532 × 3264 × 64
616 × 3232 × 64
716 × 3232 × 32

A large object is built from a block of tiles taken from object VRAM. Its top-left tile is the tile number in OAM; the tiles to its right and below follow in the tile map, so a 16×16 object uses a 2×2 group and a 32×32 object an 8×8 group.

The OAM table

OAM is 544 bytes in two parts. The main table is 512 bytes, four bytes per object for all 128 objects. Each four-byte entry holds the position, tile and attributes:

ByteContents
0X position, low 8 bits (0–255)
1Y position (0–255)
2Tile number, low 8 bits
3Attributes: flips, priority, palette, tile high bit

Byte 3 packs the per-object flags. The most significant bit is vertical flip, the next horizontal flip, then two bits of priority against the background, three bits of palette select, and the top bit of the tile number, giving a 9-bit tile index into object VRAM:

Bit76543210
MeaningV flipH flipPriorityPalette (0–7)Tile bit 8

The high OAM table

The second part of OAM is 32 bytes, two bits per object. It holds the ninth bit of each object's X position, so a sprite can reach the whole 512-wide coordinate range and slide off the left edge, plus the size bit that picks small or large for that object.

FieldBits per objectMeaning
X high bit1Bit 8 of the X position (sign, for off-screen left)
Size10 = small, 1 = large from the size set

Four objects share each byte of the high table, so all 128 objects fit in 32 bytes. Together the main and high tables give the full 512 + 32 = 544 bytes of OAM.

Colour and priority

Objects are always 4 bits per pixel, so each sprite draws from a 16-colour palette. Eight object palettes are available, selected by the three palette bits in the attribute byte, and they occupy the upper half of CGRAM, colours 128 to 255. Colour index 0 in every object palette is transparent, letting the background show through.

The two priority bits in the attribute byte set where an object sits against the four background layers. The PPU resolves object priority against background priority so sprites can appear in front of or behind chosen layers, which is how a character walks behind a foreground element.

Per-scanline limits

Although 128 objects can exist at once, the PPU has a fixed budget per scanline. On any one line it can begin at most 32 objects and fetch at most 34 tiles (8×8 slices) of object data. Objects beyond those limits on a line drop out, the classic sprite flicker or dropout when too many objects crowd one row. Spreading objects vertically, or using larger tiles, keeps them within the line budget.

LimitPer scanline
Objects32
Tiles (8×8 slices)34