Help with graphical artifacts with Mario Bros in PPU.

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
urbanspr1nter
Posts: 39
Joined: Thu Aug 16, 2012 7:55 pm

Help with graphical artifacts with Mario Bros in PPU.

Post by urbanspr1nter » Sat Jun 01, 2019 7:24 pm

Hello everyone! First of all, thanks to all the documentation on this site, forum help and nestech.txt that I have actually gotten my emulator rendering, with controller input support! However, i'm a bit stumped on this and was wondering if anyone has any expertise in guiding me on where to actually start looking for debugging.

My test ROM is Mario Bros. and the preview gameplay looks to be working fine, however after about 3 rounds of this, I begin seeing artifacts on the background. They look like this:

Image

Image

I was wondering if anyone has experienced this, and what would be a probable cause.

A hunch I have is that the background table address is being set improperly somehow at certain points in the game. Could it also be that I'm rendering at the wrong points?

LukasP
Posts: 15
Joined: Mon Mar 11, 2019 10:56 pm

Re: Help with graphical artifacts with Mario Bros in PPU.

Post by LukasP » Thu Jun 06, 2019 4:18 am

How did you imlement your PPU? Can you print out and compare with working emulator that you indeed get correct nametable indexes at those positions? How do other UNROM games look like in your emulator?
I've had similar issue with my first PPU iteration which was - render everything in one go each frame. The game may change and many will do the nametable base address mid frame so if you did the same then you need to record the register changes and replay them back when rendering.

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Help with graphical artifacts with Mario Bros in PPU.

Post by koitsu » Thu Jun 06, 2019 1:13 pm

Fairly certain Mario Bros does not do what's described in the above post. You can use a render-full-frame approach and Mario Bros will work just fine. I base this on anecdotal evidence (writing a NES emulator in the late 90s called VeNES that worked exactly this way, and Mario Bros was our primary test ROM, combined with looking at it in more detail in Mesen). Mario Bros is really pretty bare-bones and "simple" in the PPU work it's doing -- nothing fancy at all (unlike SMB).

The problem is very likely elsewhere. Said "hunch" is likely along the right lines. Impossible for me to tell you where though; your emulator = your code = only you know it. I could sit here and list off a billion "ideas" but zero are going to be helpful in narrowing it down.

P.S. -- Not sure how to interpret "after about 3 rounds of this", as screenshots depicted are exclusively phase 1 (round 1).

urbanspr1nter
Posts: 39
Joined: Thu Aug 16, 2012 7:55 pm

Re: Help with graphical artifacts with Mario Bros in PPU.

Post by urbanspr1nter » Sun Jun 09, 2019 10:09 am

Thanks for the responses. I actually ended up dumping the name table contents after a full frame and implemented a few debug features to take a few snapshots of the current console's state. I found that the name table bytes themselves were incorrect. Some junk bytes are being written to the PPU nametable. I don't know what the root cause is yet since I had found a few other CPU bugs along the way...

Even though I had passed the nestest rom, I found there were a few bugs in my CPU. After fixing them, a lot of other graphical glitches which I had not presented in this post started disappearing.

I think then all this coupled with an incorrect nametable at various points means that there is probably something wrong with my CPU. I will continue to debug. :)

I also meant by "3 rounds" meaning the intro screen transition from: Title Screen -> Autoplay -> Title Screen -> Autoplay, etc.

The graphical glitches don't seem to appear until after a few iterations of going from Title Screen -> Autoplay.

Post Reply