Odd sprite rendering during SMB

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Odd sprite rendering during SMB
by on (#214491)
Hello friends!

Like many before me I've been writing an emulator in my spare time for the last few months. Mostly for my own personal enjoyment and learning, and to help prepare me to better contribute to open source projects. I do have some fun graphical effects eventually planned out, but for now I consider it mostly writing a toy emulator.

I'm running into a problem with Super Mario Bros. Certain large sprites will have an odd line drawn in the middle of them. I've attached screenshots below. Notice the coin, the depleted question mark block, and the squished goomba. They all have a strange line appearing though them.

I was wondering if anyone had any insights as to what could potentially be causing this odd line.

A couple notes on the emulator:

1. Other than these lines (and a similar one with smashed turtles), no other obvious graphical artifacts are present in SMB or in any other NROM game I've tested. (Excitebike, Donkey Kong, Donkey Kong Jr.)
2. I have scrolling implemented correctly as laid out on the wiki.
3. Buffered reads, latched reads, and sprite zero detection are all emulated. (As far as I can tell at least).
4. I have no APU support added to speak of.
5. I do sprite evalution for the next scanline at PPU cycle 257. My sprite evaluation is fairly straightforward and simple.

Any ideas?

Thanks so much guys!
Re: Odd sprite rendering during SMB
by on (#214496)
The thing I see in common with all of the problem sprites in your example is that they are vertically flipped sprites.

So, my guess is you have an off by one error in whatever code draws your sprites upside down for that case. (Maybe the starting address for the CHR fetch is off by 1? e.g. +8 instead of +7?)

That block sprite and Mario seem shifted to the right by one pixel as well. (Are all your sprites shifted to the right?)
Re: Odd sprite rendering during SMB
by on (#214530)
You are a wizard rainwarrior! Off by one error in my vertical flip was exactly what was happening. I'm super impressed you were able to spot that so quickly!

Also sharp eye on the sprite pixel shift.

Both problem are officially solved. Now I can go onward to implementing some basic APU and mapper support.


Woot! Thank you so much! :)