Question about SMB1 zero hit

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Question about SMB1 zero hit
by on (#137794)
Hello everyone,
My friend and I have been doing a lot of improvements in our NES emulator that someday we will share with all of you!

I have a question, when i started coding the sprite zero hit in order to run the SMB1 i just did something simple like trigger it at the very first pixel of the sprite 0, and it allowed to run SMB1.

Now that i finished this feature, i run the blarg's sprite 0 hit tests and now it passed! Now for example, bomberman is playable.
However, SMB1 is not working, and right now im pretty curious. I know that the tests are just tests, and the important part is running actual games, but im starting to think that maybe something else is broken, and thats why SMB is not running.

So... after a lot of introduction, SMB is not triggering the sprite 0 hit, and is froze at the first screen, do you guys know, how SMB uses sprite 0 hit?
What is the position of the bg tile that triggers the zero hit?
What chr number is?

idk, maybe im asking so detailed info, maybe someone who did it recently remembers something. but as i told you, im very curious about this, it seems like something is rotten in my code...
Any help will be a lot helpful!

Thanks in advance!
Re: Question about SMB1 zero hit
by on (#137796)
SMB1 has a coin in the status bar near the top of the background (tile $12E) and a sliver of the coin in sprite 0 (tile $0FF). When the sliver of the coin is drawn overlapping the coin, the sprite 0 flag is set.

But be cautioned that SMB1 uses "tricky" operations with $2006 to set the initial scroll position of the status bar. If the scroll position isn't correct at the top of the picture, sprite 0 will never hit and the game will freeze. To get the game working despite this, you can introduce a temporary inaccuracy: put in a hack to set the sprite 0 flag around a quarter of the way into line 30. If this hack gets SMB1 working without a status bar or with a flickering status bar, you need to make sure writes to $2000, $2005, and $2006 work exactly as described in "The skinny on NES scrolling".
Re: Question about SMB1 zero hit
by on (#137805)
Thank you tepples for your very fast and friendly reply.

The previous version of my zero hit "algorithm" was a hack, and that time the status bar was not flickering or anything.

Now that you mention, im using a predictive algorithm for triggering the zero hit.
I checked it, and it IS using the tiles that you mention. now that im looking at it, yes it is a coin and the lower part of the coin the tiles that it is using, and in fact it is drawing it exactly, but it seems my algorithm is a little bit off. And now i have an idea of how am i going to debug this.

Thank you very much!