On the NES, I've gathered that it's considered best practice not to hardcode a particular game object's starting position in the display list. For example, don't always draw the main character using sprites 1-8, enemy 1 using sprites 9-14, enemy 2 using sprites 15-20, etc. Instead, NES games are supposed to reassign slots every frame, especially if there's a possibility that more than eight will be displayed on the same scanline. This also allows the game to make enemies intentionally Z-fight if they overlap.
But in the Game Boy community (gbdev.gg8.se and the related Discord server), it's common to hardcode OAM indices for actors or at least not shuffle them from frame to frame, and I'm trying to understand why they do that. The Game Boy sprite system differs from that of the NES as follows:
On the Game Boy, with more relative overdraw and less control of sprite-to-sprite priority, would it be less of a bad practice to statically allocate OAM space? Does random access to OAM even during horizontal blanking have anything to do with it by reducing the need to always use OAM DMA?
Relationship to other topic: This one also includes the random access instead of DMA as an additional factor.
But in the Game Boy community (gbdev.gg8.se and the related Discord server), it's common to hardcode OAM indices for actors or at least not shuffle them from frame to frame, and I'm trying to understand why they do that. The Game Boy sprite system differs from that of the NES as follows:
- There is enough secondary OAM to draw 10 8-pixel-wide sprites per 160-pixel scanline. Thus sprites can cover nearly half of the screen's width rather than one-fourth like on the NES.
- The PPU determines which sprites to draw by finding the 10 lowest-numbered sprites in OAM whose Y range overlaps each scanline, just as the NES PPU does. But then according to Pan Docs, the monochrome Game Boy sorts these frontmost 10 sprites by their X coordinate before displaying them. Sprites to the left are drawn in front, with position in OAM only breaking ties.
- The memory controller responsible for OAM isn't a rushed, buggy mess. This means OAM can be randomly accessed at $FE00-$FE9F during blanking periods.
- Horizontal blanking on the Game Boy is much longer than on the NES. OAM on the Game Boy can be accessed not only during vertical blanking but also during most of horizontal blanking.
On the Game Boy, with more relative overdraw and less control of sprite-to-sprite priority, would it be less of a bad practice to statically allocate OAM space? Does random access to OAM even during horizontal blanking have anything to do with it by reducing the need to always use OAM DMA?
Relationship to other topic: This one also includes the random access instead of DMA as an additional factor.