How to partially render a sprite that is popping up slowly?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
charrli
Posts: 2
Joined: Mon May 23, 2016 10:41 pm

How to partially render a sprite that is popping up slowly?

Post by charrli » Mon May 23, 2016 10:53 pm

Hi everyone,

I'm working on an NES emulator, and the PPU I wrote looks good. However, I found one strange behavior when playing the Super Mario Bros. i found the mushroom, which is supposed to gradually appear on the screen, is actually drawn on the screen entire from the very beginning, and then the entire mushroom sprite moving up. I guess I miss something here for the emulation. Does anyone know what's wrong with this rendering? By the way, to handle the sprite priority, I'm actually drawing from the last sprite to the first sprite (sprite No.63 to Sprite No.0). Please help. Thanks!

Regards,
Charlie
Attachments
The mushroom is supposed to be rendered partially, only the part that is above the block is drawn.
The mushroom is supposed to be rendered partially, only the part that is above the block is drawn.
mushroom1.jpg (23.41 KiB) Viewed 5280 times

User avatar
DRW
Posts: 2047
Joined: Sat Sep 07, 2013 2:59 pm

Re: How to partially render a sprite that is popping up slow

Post by DRW » Mon May 23, 2016 11:02 pm

Every sprite has a "behind the background"/"in front of the background" flag:
http://wiki.nesdev.com/w/index.php/PPU_OAM#Byte_2

You need to handle this flag correctly, then the mushroom appears behind the block (since the block is a background object).
My game "City Trouble": www.denny-r-walter.de/city.htm

User avatar
Memblers
Site Admin
Posts: 3899
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: How to partially render a sprite that is popping up slow

Post by Memblers » Tue May 24, 2016 1:58 am

I don't think SMB uses this, but it's also possible to mask a high-priority sprite behind the background by putting a lower priority sprite, in a lower sprite number, on top of it. SMB3 and Castlevania are a couple games that use that. By priority in this case I mean the foreground/background flag that DRW mentioned.
http://wiki.nesdev.com/w/index.php/PPU_sprite_priority

3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Re: How to partially render a sprite that is popping up slow

Post by 3gengames » Tue May 24, 2016 12:42 pm

I'm pretty sure one of the Mario's actually does use tiles in front of the sprite to cover it, so just make sure your sprite rendering and background/foreground flags are set up correctly.

charrli
Posts: 2
Joined: Mon May 23, 2016 10:41 pm

Re: How to partially render a sprite that is popping up slow

Post by charrli » Tue May 24, 2016 4:17 pm

Thanks all! I guess you guys have pointed out the reason. Let me try the fix and back to you.

Post Reply