Sprite Viewer and questions

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
cpow
NESICIDE developer
Posts: 1089
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Sprite Viewer and questions

Post by cpow » Wed Oct 28, 2009 7:04 pm

I implemented an OAM viewer and noticed right away that games do weird stuff with sprites. As an example, I recorded it during the intro of SMB1. I am curious why the sprites flicker. I know why the Mario sprites flicker...because he actually flickers when he gets bigger or smaller. However, I wasn't expecting the other sprites to do so. Another example, Zelda seems to move sprites around.

SMB1 (8MB AVI)
Zelda (2MB AVI)

Anyone have any decent explanation for why this is done?

Nessie
Posts: 134
Joined: Mon Sep 20, 2004 11:13 am
Location: Sweden
Contact:

Post by Nessie » Wed Oct 28, 2009 7:33 pm

Looks like "OAM cycling", it's a workaround for the 8 sprites per scanline limit. The NES will only display the first 8 sprites found on a scanline. If you've got 12 sprites on a single scanline you move objects around in sprite ram so that they will take turns being among the 8 first sprites.

If letters represent sprites on a single scanline:

; sprites A - H will be visible
A B C D E F G H I J K L M N O

; sprites E - L will be visible
E F G H I J K L M N O A B C D

This of course causes flickering if a scanline has more than 8 objects. That's why some emulators have the "no sprite limit" option - this option will also draw the remaining sprites that would have been invisible on a real NES and reduce flicker.

Of course, that first part of SMB does not have 8 sprites on a single line, but think of when you've got a bunch of goombas in front of you and shoot a fireball - the goombas will start flickering until one of them dies and jumps off the screen. Without OAM cycling, one of the goombas (or the fireball) wouldn't have been visible at all.

User avatar
tokumaru
Posts: 11469
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Sprite Viewer and questions

Post by tokumaru » Wed Oct 28, 2009 8:36 pm

NESICIDE wrote:Anyone have any decent explanation for why this is done?
Contrary to what programming guides for newbies might have people believe, games don't usually hardcode game objects to OAM positions. This is because different objects of different sizes can be active at any given time, and because some randomness is desirable for sprite cycling.

Post Reply