It is currently Sun Dec 17, 2017 12:52 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Sep 27, 2012 4:51 pm 
Offline

Joined: Thu Sep 27, 2012 4:44 pm
Posts: 5
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.


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 4:54 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
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. :)


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 5:00 pm 
Offline

Joined: Thu Sep 27, 2012 4:44 pm
Posts: 5
Oh, nevermind the issue with the sprite palette. :) That's a separate bug that I'll deal with some other time.


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 5:40 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10169
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 5:46 pm 
Offline

Joined: Thu Sep 27, 2012 4:44 pm
Posts: 5
As far as I know, I am emulating that correctly. Here is my $2007 non-palette read:

Code:
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?


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 6:19 pm 
Offline

Joined: Thu Sep 27, 2012 4:44 pm
Posts: 5
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


Top
 Profile  
 
PostPosted: Thu Sep 27, 2012 7:08 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
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!


Top
 Profile  
 
PostPosted: Sun May 08, 2016 2:35 pm 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 311
Location: Argentina
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!


Top
 Profile  
 
PostPosted: Sun May 08, 2016 6:01 pm 
Offline
User avatar

Joined: Sun Dec 12, 2010 10:27 pm
Posts: 298
Location: Hong Kong
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.


Top
 Profile  
 
PostPosted: Mon May 09, 2016 7:34 am 
Offline
User avatar

Joined: Mon Dec 22, 2008 10:45 pm
Posts: 311
Location: Argentina
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: sdm and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group