SMB Crash at End of Second NameTable

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
davecom
Posts: 39
Joined: Mon Jul 16, 2018 2:57 pm

Re: SMB Crash at End of Second NameTable

Post by davecom »

Right, name tables get written by $2007. I can see incorrect tiles being written there right before the crash.
User avatar
davecom
Posts: 39
Joined: Mon Jul 16, 2018 2:57 pm

Re: SMB Crash at End of Second NameTable

Post by davecom »

Okay I finished building my nametables debugger. You can find a "just before the crash" screenshot of both the game (small window) and the 4 nametables (big window) here:
Before the crash screenshot.
Before the crash screenshot.
Then you will find an "after the crash" screenshot here:
After the crash screenshot.
After the crash screenshot.
As you can see from the screenshots, the text and coin on the top actually appears to be okay in the nametables! The mystery deepens.

EDIT: Originally was failing a timing test ROM. I have since fixed that—I wasn't counting the +1 ticks for successful branches. Fixed. SMB still crashing.
User avatar
davecom
Posts: 39
Joined: Mon Jul 16, 2018 2:57 pm

Re: SMB Crash at End of Second NameTable

Post by davecom »

Okay I solved it!

As I suspected it did have to do with pulling from the wrong nametable address and it also was a one liner!

For nametable byte address fetch I was using:

Code: Select all

address = (0x2000 + NAME_TABLE_ADDRESS) | (V & 0x0FFF);
Where NAME_TABLE_ADDRESS was

Code: Select all

((((word)PPU_CONTROL1) & 0b00000011) * 0x400)
But I noticed in Fogleman's emulator that actually I just needed the simpler:

Code: Select all

address = 0x2000 | (V & 0x0FFF);
I guess V already encodes the specific nametable... okay SMB is working now. Thanks everyone.
Post Reply