It is currently Wed Oct 18, 2017 8:01 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Sprite 0 hit
PostPosted: Fri Jul 12, 2013 1:25 pm 
Offline

Joined: Thu Jul 04, 2013 11:32 am
Posts: 8
Making a NES emulator, here's where I'm at: http://imgur.com/O79p9sl

I'm trying to get sprites to display properly and I've discovered the hangup involves the sprite 0 hit flag. There are loops in the game I'm trying (super mario bros) that wait for VBLANK by cycling endlessly until the flag is set, then cleared. When should I be setting this flag? Is there a way to fake this operation, i.e. set the 0 hit flag at the first scanline? Sorry if my question is too game-specific.


Top
 Profile  
 
 Post subject: Re: Sprite 0 hit
PostPosted: Fri Jul 12, 2013 1:32 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19094
Location: NE Indiana, USA (NTSC)
Sprite zero hit turns off at line 261 (311 for PAL NES and Dendy) and turns on the moment a nontransparent pixel of sprite 0 is drawn overlapping a nontransparent pixel of the background (or vice versa; priority is disregarded). If the highest such overlap is at (64, 30), for example, then it'll turn on 64 dots (21 cycles) into line 30. To fake it for SMB1, set it on line 30.


Top
 Profile  
 
 Post subject: Re: Sprite 0 hit
PostPosted: Fri Jul 12, 2013 3:58 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
I assume you didn't add the $2007 read buffer (post-fetch), since the screen is scrambled. Do it and trust me - it'll look much better. ;)


Top
 Profile  
 
 Post subject: Re: Sprite 0 hit
PostPosted: Sat Jul 13, 2013 10:40 am 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2799
This early in your emulator you maybe shouldn't worry about accurately emulating Sprite hit Zero. As tepples suggests, just fake it by setting the flag around the scanline that the sprite appears. There are many other important things you'll want to get done before Sprite Hit Zero. Many games don't require sprite hit zero emulation. Emulating the flag can be tricky depending on how you emulate the CPU/PPU together and how you eumlate the PPU exactly.


Top
 Profile  
 
 Post subject: Re: Sprite 0 hit
PostPosted: Sat Jul 13, 2013 11:39 am 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
You might want to start with a different NROM game. Emulating SMB1 can be tricky.

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
 Post subject: Re: Sprite 0 hit
PostPosted: Mon Jul 15, 2013 10:28 pm 
Offline

Joined: Thu Jul 04, 2013 11:32 am
Posts: 8
@Tepples - Setting the flag at line 30 did the trick, for now
@zepper - yes! That fixed it the screen scrambling

I tested Mario, Excitebike, Donkey Kong Jr., and Donkey Kong, they all seemed pretty good in non-scrolling bits


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group