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 »

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 6091 times
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

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

Post by DRW »

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":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
Memblers
Site Admin
Posts: 4044
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 »

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: 2284
Joined: Sat Mar 27, 2010 12:57 pm

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

Post by 3gengames »

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 »

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