Memory Mappers

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Memory Mappers

Post by WedNESday » Tue Jul 22, 2008 9:33 am

1. If say game X writes the value $12 to the $8000-$FFFF region to change PRG/CHR banks, then should this number be ANDed with the PRG/CHR byte in the header? (i.e. (Value & (PRG - 1)) * $4000). I ask this because it would seem this way since most mappers like UxROM ignore the upper bits on a write.

2. What's the deal with MMC1 mirroring? Is the following correct? (Using the lower two bits of the first register) (based on the wiki)

Code: Select all

00 - Normal Mirroring - Horizontal Mirroring
01 - Normal Mirroring - Vertical Mirroring
10 - One Screen Mirroring - Name/Attribute Table 0
11 - One Screen Mirroring - Name/Attribute Table 1

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

Post by Dwedit » Tue Jul 22, 2008 10:44 am

The way emulators handle roms which don't have sizes with powers of two is inconsistent.
One thing that is consistent though, is that sizes are padded to the next power of 2. So if a game has 14 pages, it will be treated as if it has 16 pages.
Games with CHR pages missing are common. For example, one dump of Zelda 2 omits the blank CHR pages at the end. It's still treated as if it has 16 CHR pages, even though the file says 14 pages.
As for what to put in the expanded area, some emulators just repeat the last page, and others fill it with FF's.
If PRG pages are missing, then things go bad. Some emulators like VirtuaNES repeat the last 16k page to pad it to a power of 2, while others make it FF filled, so most games won't boot.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
Bregalad
Posts: 8008
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Memory Mappers

Post by Bregalad » Tue Jul 22, 2008 11:25 am

2. What's the deal with MMC1 mirroring? Is the following correct? (Using the lower two bits of the first register) (based on the wiki)

Code: Select all

00 - Normal Mirroring - Horizontal Mirroring
01 - Normal Mirroring - Vertical Mirroring
10 - One Screen Mirroring - Name/Attribute Table 0
11 - One Screen Mirroring - Name/Attribute Table 1
If you exchange all '0' and '1' in what you wrote it should become correct.[/quote]
Useless, lumbering half-wits don't scare us.

tepples
Posts: 22233
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Tue Jul 22, 2008 11:38 am

Dwedit wrote:Games with CHR pages missing are common. For example, one dump of Zelda 2 omits the blank CHR pages at the end. It's still treated as if it has 16 CHR pages, even though the file says 14 pages.
IIRC, there are widespread roms of Tetris 2, Smash TV, and several CNROM games with "trimmed" CHR.
As for what to put in the expanded area, some emulators just repeat the last page, and others fill it with FF's.
If PRG pages are missing, then things go bad. Some emulators like VirtuaNES repeat the last 16k page to pad it to a power of 2, while others make it FF filled, so most games won't boot.
If I were developing an emulator, I would take VirtuaNES's approach for PRG and FF-pad CHR. At least this would preserve the "last bank" semantics of U*ROM, S*ROM, T*ROM, and most other PRG mappers that have a fixed bank.

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Re: Memory Mappers

Post by WedNESday » Tue Jul 22, 2008 11:59 am

Bregalad wrote:
2. What's the deal with MMC1 mirroring? Is the following correct? (Using the lower two bits of the first register) (based on the wiki)

Code: Select all

00 - Normal Mirroring - Horizontal Mirroring
01 - Normal Mirroring - Vertical Mirroring
10 - One Screen Mirroring - Name/Attribute Table 0
11 - One Screen Mirroring - Name/Attribute Table 1
If you exchange all '0' and '1' in what you wrote it should become correct.
[/quote]

Just the column on the left? Or including the name table 1's and 0's on the right?

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Tue Jul 22, 2008 12:40 pm

I have the Space Shuttle game with the title screen scrambled. I wonder if it's because of mirroring...?

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Post by WedNESday » Tue Jul 22, 2008 2:17 pm

Fx3 wrote:I have the Space Shuttle game with the title screen scrambled. I wonder if it's because of mirroring...?
Probably just another NASA budget cut. It's scrambled for me too. Let's work this one out together.

Edit #1: The Space Shuttle game doesn't use One Screen Mirroring (at least for the messed up title screen).

Edit #2: Nintendulator runs the game just fine, Nestopia gives you the music ok, but just a blank white screen and nothing else.

User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap » Wed Jul 23, 2008 3:13 am

"Space Shuttle Project (U) [!].nes" runs ok here, even in Nestopia, bad dump maybe? or you're talking about a different game?
Just the column on the left? Or including the name table 1's and 0's on the right?

Code: Select all

00 - One Screen Mirroring - Name/Attribute Table 0
01 - One Screen Mirroring - Name/Attribute Table 1
10 - Normal Mirroring - Vertical Mirroring
11 - Normal Mirroring - Horizontal Mirroring

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Post by WedNESday » Wed Jul 23, 2008 3:34 am

hap wrote:"Space Shuttle Project (U) [!].nes" runs ok here, even in Nestopia, bad dump maybe? or you're talking about a different game?
Just the column on the left? Or including the name table 1's and 0's on the right?

Code: Select all

00 - One Screen Mirroring - Name/Attribute Table 0
01 - One Screen Mirroring - Name/Attribute Table 1
10 - Normal Mirroring - Vertical Mirroring
11 - Normal Mirroring - Horizontal Mirroring
Same game and thats what Nestopia gives me. Never mind, that's what i use for my mirroring, but games like Zelda 1 when moving to the left screen or right screen just have a screen full of 0's until the scrolling has stopped. Now I think that it isn't mirroring causing that but something else.

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Wed Jul 23, 2008 10:57 am

I have no clue, here's the image anyways...
-removed, l4m33-
Last edited by Zepper on Wed Jul 23, 2008 7:35 pm, edited 1 time in total.

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg » Wed Jul 23, 2008 12:33 pm

Fx3 wrote:I have no clue, here's the image anyways...[/img]
Post the CRC-32 of the file (perhaps of just the PRG data, skipping the iNES header). Also, try to post screenshots in 256x240 (using PNG or GIF format).

User avatar
kode54
Posts: 67
Joined: Mon Jun 06, 2005 12:47 pm
Contact:

Post by kode54 » Wed Jul 23, 2008 1:01 pm

CRC32: 2220E14A

Entry from Nestopia's database:

Code: Select all

    <game>
        <cartridge system="NES-NTSC" dump="ok" crc="2220E14A" sha1="EE36B29BDB4BD81043DC2B7BD273665F8CED6DA9">
            <board type="NES-SGROM" mapper="1">
                <prg size="256k" />
                <vram size="8k" />
                <chip type="MMC1B2" />
            </board>
        </cartridge>
    </game>

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Post by WedNESday » Wed Jul 23, 2008 2:02 pm

Here is WedNESday's:

Image

So we have the same problem. I sincerely don't think that its down to mirroring though because I think that I've got that all worked out now. I have not yet implemented IRQ's because I've not got around to doing any sound work, but I doubt that it's that.

bunnyboy
Posts: 449
Joined: Thu Oct 27, 2005 1:44 pm
Location: CA
Contact:

Post by bunnyboy » Wed Jul 23, 2008 5:13 pm

Part way down the screen its switching which pattern table is used for the background. Those emulators aren't getting that switch so the bottom half is using the same tile set as the top half. Its doing that on scanline ~119 (likely sprite 0 hit) by changing the $C000 MMC1 register to select a 4KB chr bank at $1000. MMC1 has no IRQ so that is not the problem.

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Wed Jul 23, 2008 7:34 pm

How so? This game uses CHR RAM.

Post Reply