Skip to content

PPU: no 8-sprite-per-scanline limit or sprite overflow flag #604

@bfirsh

Description

@bfirsh

Summary

The PPU renders all 64 sprites on every scanline. Real hardware only evaluates 8 sprites per scanline — additional sprites are hidden (with the overflow flag set in $2002 bit 5).

Impact

Missing sprite limit

Games that rely on sprite flickering look wrong. Many action games deliberately rotate sprite priority each frame so that flickering makes all sprites visible. Without the limit, there's no flicker and all sprites render simultaneously, which can look correct but also produces visual differences.

Missing overflow flag

The sprite overflow flag ($2002 bit 5) is never set. Games or demos that poll this flag will hang or behave incorrectly.

Implementation notes

Sprite evaluation should:

  1. Walk OAM to find sprites on the current scanline (secondary OAM evaluation)
  2. Stop after finding 8 sprites
  3. Set the overflow flag if more than 8 are found
  4. Only render the first 8 found sprites

The sprite overflow bug (incorrect evaluation after finding 8 sprites) should also be considered for accuracy.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    accuracyHardware accuracy improvementbugcomponent: ppuPPU / graphics (ppu/)difficulty: mediumModerate change requiring understanding of one subsystempriority: highSignificantly wrong behavior affecting many games

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions