Super Mario Bros title screen

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
ermular
Posts: 5
Joined: Thu Sep 27, 2012 4:44 pm

Super Mario Bros title screen

Post by ermular » Thu Sep 27, 2012 4:51 pm

Hi, when my emulator runs Super Mario Bros, the title screen draws in an odd way:

Image

The game itself runs just fine -- looks perfect and no glitches that I can see:

Image

I've been trying to solve this for a few hours with not much luck. It seems that the rendering of the title screen nametable is correct, but the big "SUPER MARIO BROS" tiles are not referenced in the nametable. Any ideas? Thanks in advance.

3gengames
Formerly 65024U
Posts: 2276
Joined: Sat Mar 27, 2010 12:57 pm

Re: Super Mario Bros title screen

Post by 3gengames » Thu Sep 27, 2012 4:54 pm

Dunno about why the sprite color is wrong, but SMB is elusive for storing the title screen data in the CHR-ROM, make sure $2007 reads work right is my best advice for now. :)

ermular
Posts: 5
Joined: Thu Sep 27, 2012 4:44 pm

Re: Super Mario Bros title screen

Post by ermular » Thu Sep 27, 2012 5:00 pm

Oh, nevermind the issue with the sprite palette. :) That's a separate bug that I'll deal with some other time.

User avatar
tokumaru
Posts: 11755
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Super Mario Bros title screen

Post by tokumaru » Thu Sep 27, 2012 5:40 pm

CHR-ROM reads are delayed by 1 read. When the program reads $2007, it gets the contents of a buffer, and the actual byte read from CHR-ROM goes into this buffer, so it can be read the next time. This is true for all of the PPU memory, except for the palette RAM, which returns values immediately. If you're not emulating this correctly, SMB will not succeed in reading the data it needs in order to draw the title screen.

ermular
Posts: 5
Joined: Thu Sep 27, 2012 4:44 pm

Re: Super Mario Bros title screen

Post by ermular » Thu Sep 27, 2012 5:46 pm

As far as I know, I am emulating that correctly. Here is my $2007 non-palette read:

Code: Select all

byte OldBuffer = VRAMBuffer;

if (VRAMAddress >= 0x2000)
{
	bool NameTableZero = (VRAMAddress & (int)_Mirroring) == 0;
	VRAMBuffer = PPUMemory[(NameTableZero ? 0 : 0x0400) + (VRAMAddress & 0x03FF)];
}
else
	VRAMBuffer = _ReadCHRByte(VRAMAddress);

return OldBuffer;
_Mirroring is 0x0400 in the case of SMB (vertical mirroring). PPUMemory is 0x2000 - 0x27FF, but zero-indexed. Is there anything that looks wrong here?

ermular
Posts: 5
Joined: Thu Sep 27, 2012 4:44 pm

Re: Super Mario Bros title screen

Post by ermular » Thu Sep 27, 2012 6:19 pm

Wow, I wasn't incrementing the VRAM pointer after reads, only after writes. I can't believe it took me hours to figure that out :) Incidentally, it helps my sprite palette issues, too!

Image

User avatar
Dwedit
Posts: 4329
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Super Mario Bros title screen

Post by Dwedit » Thu Sep 27, 2012 7:08 pm

That mushroom cursor isn't a sprite, so you never had any sprite palette issues to begin with :)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Super Mario Bros title screen

Post by Petruza » Sun May 08, 2016 2:35 pm

I had the same problem with the title screen and the green mushroom, but the causes were totally different.
Actually I hadn't implemented reading the CHR memory, because I assumed hardly any (CHR-ROM) game would do that. I haven't implemented CHR-RAM yet.
So SMB reads the CHR-ROM for some reason I won't investigate too much now, but that was the problem, the data was never making it to the latch and never read.
This post made me review my $2007 code and I found it, so thanks!

User avatar
Gilbert
Posts: 384
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: Super Mario Bros title screen

Post by Gilbert » Sun May 08, 2016 6:01 pm

SMB having to read CHR-ROM to display the title screen is actually a well-known issue of the game(see tokumaru and 3gengames' replies). It's because they ran out of space in the PRG area so part of the name table data of the title logo was stored in the CHR area.

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Super Mario Bros title screen

Post by Petruza » Mon May 09, 2016 7:34 am

Gilbert wrote:SMB having to read CHR-ROM to display the title screen is actually a well-known issue of the game(see tokumaru and 3gengames' replies). It's because they ran out of space in the PRG area so part of the name table data of the title logo was stored in the CHR area.
Yes, I just read it on the wiki article Tricky to emulate games after I solved it. Shame on me. And I remember reading it a couple of times before. The thing is I never cared for it because it was only an aesthetic problem that didn't crash or hurt gameplay, so I went on to more critical issues.

Post Reply