Odd sprite rendering during SMB

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Posts: 7
Joined: Fri Mar 02, 2018 12:22 am

Odd sprite rendering during SMB

Post by drewying » Fri Mar 02, 2018 12:38 am

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!

User avatar
Posts: 8006
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada

Re: Odd sprite rendering during SMB

Post by rainwarrior » Fri Mar 02, 2018 1:29 am

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?)

Posts: 7
Joined: Fri Mar 02, 2018 12:22 am

Re: Odd sprite rendering during SMB

Post by drewying » Fri Mar 02, 2018 8:20 pm

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! :)

Post Reply