[SOLVED] SMB Title Screen isn't rendering in a proper way

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
[SOLVED] SMB Title Screen isn't rendering in a proper way
by on (#236173)
Hi, everyone!

Okay, first of all, I apologize in advance if you have any problems with reading this post caused due to my english language skills.

Back to the topic... A few weeks ago I started a project of my own NES emulator. I already finished the CPU emulation and I'm currently working on a PPU emulation and screen display. However, when I test it, things seem to behave quite weird.
I'm going to describe my problem and show you a few examples.

The title screen in Super Mario Bros. 1 is not rendering in a proper way:
Image

Also there are those garbage tiles during demo play:
Image

But during a normal gameplay, everything displays properly:
Image

Battle City's title screen seems to suffer from a same problem:
Image

But the game is completely unplayable:
Image

In Mappy, when you walk on a flat floor, you suddenly fall through it and loses a life and in Pacman you can eat walls and escape the maze.

Another weird thing is when I tested my emulator with a Nestest, it passed all documented opcodes tests.
Image

But when I run any of Blargg's CPU opcode test ROMs, it failes and in result I get an unreadable garbage.

I double checked all the CPU code, opcodes execution, addresing modes, JMPs, JSR, NMI and couldn't manage to find any bug that would cause those kinds of glitches. ROMs are not corrupted in any way and the read buffer during the $2007 read is implemented correctly.
Also please, don't pay much attention to the incorrect color assignment and white dots, I haven't implemented tile coloring based on attribute tables yet and sprites are temporarily represented as dots.

Thank you in advance for any ideas and your help ^-^
Re: SMB Title Screen isn't rendering in a proper way & more
by on (#236178)
Hmm... Try checking $2007 reads, the 1-byte buffered stuff.
Another point is the PPU address. Look at writes to $2007 and how the address is handled there.
Re: SMB Title Screen isn't rendering in a proper way & more
by on (#236181)
Zepper wrote:
Try checking $2007 reads, the 1-byte buffered stuff.

Oh my goodness... for a whole time I was reading values from $2007 immediately, not through a 1 byte buffer delay!
I fixed that and now everything works like a charm! Oh me silly :\

Image

Thank you a lot, Zepper ^-^
Re: SMB Title Screen isn't rendering in a proper way & more
by on (#236184)
That's the first thing that comes to mind, but you did say that "the read buffer during the $2007 read is implemented correctly", so...
Re: SMB Title Screen isn't rendering in a proper way & more
by on (#236188)
Well, at first I was pretty sure it was, but it actually wasn't done the way it should be done.