Memory Mappers

Memory Mappers
by on (#35130)
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:
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

by on (#35135)
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.
Re: Memory Mappers
by on (#35138)
Quote:
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:
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]

by on (#35140)
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.

Quote:
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.
Re: Memory Mappers
by on (#35143)
Bregalad wrote:
Quote:
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:
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?

by on (#35146)
I have the Space Shuttle game with the title screen scrambled. I wonder if it's because of mirroring...?

by on (#35158)
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.

by on (#35192)
"Space Shuttle Project (U) [!].nes" runs ok here, even in Nestopia, bad dump maybe? or you're talking about a different game?

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

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

by on (#35193)
hap wrote:
"Space Shuttle Project (U) [!].nes" runs ok here, even in Nestopia, bad dump maybe? or you're talking about a different game?

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

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

by on (#35202)
I have no clue, here's the image anyways...
-removed, l4m33-

by on (#35204)
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).

by on (#35206)
CRC32: 2220E14A

Entry from Nestopia's database:
Code:
    <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>

by on (#35207)
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.

by on (#35209)
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.

by on (#35218)
How so? This game uses CHR RAM.

by on (#35219)
There's no reason that CHR RAM can't be bankswitched mid-frame. CPROM anyone?

(Is it called CPROM because Videomation lets you draw CP?)

by on (#35220)
Yeah, but Videomation has its own 16K of VRAM, so that's ok.

by on (#35221)
As I understand it, the PPU address lines are still run through the mapper in S*ROM and T*ROM boards, even if only so that the mapper can control the mirroring.

by on (#35222)
My bad... ;)
Image

by on (#35228)
There's 8KB of CHR RAM, MMC1 can do CHR banking in 4KB chunks, so that 2 banks. RAM vs ROM doesn't make any difference for address lines.

by on (#35232)
Edit: Ok I understand everything now, I also understand that this game uses a board that the iNES 1.0 format cannot cater for. :x

So with the iNES 2.0 format, are board variants for mappers like MMC1 catered for?

by on (#35240)
bunnyboy wrote:
There's 8KB of CHR RAM, MMC1 can do CHR banking in 4KB chunks, so that 2 banks. RAM vs ROM doesn't make any difference for address lines.


Two banks... so I suppose the value C000 is ANDed with 1..?

by on (#35248)
Fx3 wrote:
bunnyboy wrote:
There's 8KB of CHR RAM, MMC1 can do CHR banking in 4KB chunks, so that 2 banks. RAM vs ROM doesn't make any difference for address lines.

Two banks... so I suppose the value C000 is ANDed with 1..?

Yes, on carts with 8 KiB of CHR (be it ROM or RAM), the bank number is in effect ANDed with 1.

by on (#49502)
- Raise from your grave... ^_^;; The wiki must be updated to bring this new info, of switchable CHR RAM. Currently, it says to ignore swaps when there's no CHR ROM:

Code:
There are some games that write to $A000-$DFFF, for emulator writers, this means if the game have 0 CHR count for it's size, ignore any CHR switching when the shift register gets copied over to the internal register on the 5th write.


http://wiki.nesdev.com/w/index.php/MMC1#Registers

by on (#49503)
Fx3 wrote:
- Raise from your grave... ^_^;; The wiki must be updated to bring this new info, of switchable CHR RAM. Currently, it says to ignore swaps when there's no CHR ROM:

Code:
There are some games that write to $A000-$DFFF, for emulator writers, this means if the game have 0 CHR count for it's size, ignore any CHR switching when the shift register gets copied over to the internal register on the 5th write.


http://wiki.nesdev.com/w/index.php/MMC1#Registers


Haha, sorry about that, I was the one who wrote that :X, when I was writing the emu and trying to get ff1 working, I noticed FF1 was writing values to switch CHR but I didn't know how to handle it, so I tried ignoring it and it worked. So I added it to the wiki thinking it might help people. This must be why my MMC1 code couldn't play some other games. Thanks for that! I fixed the wiki with the info above.