What is MMC5 "3-screen mirroring" good for? Answered inside.

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

AWJ
Posts: 433
Joined: Mon Nov 10, 2008 3:09 pm

What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by AWJ »

There seems to be a bit of confusion in the community as to what the practical uses are for the third nametable supported by MMC5 (in EXRAM mode 0). The example mirroring setups using 3 nametables on the wiki (both on the "Mirroring" page and the MMC5 page) are frankly of dubious practicality. There was also a thread on romhacking.net a while back asking whether it was possible on hardware and/or emulators to use four-screen mirroring with MMC5, the thread creator evidently being under the impression that this would be far more useful.

Don't think of "3-screen mirroring", think of "vertical mirroring and one-screen mirroring at the same time, with all the advantages of both". MMC5's third nametable allows you to have unlimited 4-way scrolling with a status bar, no visible attribute clashes on any edge of the screen, and no need for complex raster IRQ voodoo ala Crystalis.

Here's how you do it: You put your playfield on the two built-in nametables, configured with vertical mirroring (MMC5 $5105 = $44) In your IRQ handler, switch to one-screen mirroring with the EXRAM nametable ($5105 = $AA), where your status bar resides. It's as simple as one-screen mirroring, but without the need for fine-grained playfield updates and without the unavoidable attribute clashes. Because your playfield is vertically mirrored the horizontal scroll seam can be well offscreen, and the vertical scroll seam can be hidden behind the status bar.

Moreover, since you're only using a small part of the EXRAM nametable for your status bar, you can even use the rest of EXRAM as work RAM, just as long as you don't need it while the status bar is being rendered. For example, assuming your status bar is at the bottom of the screen, you can put your music engine variables in EXRAM. Just flip the EXRAM mode to 2 at the start of your NMI music update routine and flip it back to 0 at the end.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by Bregalad »

You're just stating the obvious in my opinion. Yes, the wiki mirroring/scrolling pages are awful, I did a poor attempt at reforming them to be a little less awful but Rainwarrior repeatedly refused my proposed reforms so I abandoned the matter.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by rainwarrior »

I liked and approved of some of what you proposed, and disagreed with some of it, but I guess my disagreement with part of it may have dulled your interest in the rest? :(

The discussion is here, though, and more eyes and voices on it would probably be fruitful:
http://wiki.nesdev.com/w/index.php/Talk ... lling_page
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by Bregalad »

rainwarrior wrote: The discussion is here, though, and more eyes and voices on it would probably be fruitful:
http://wiki.nesdev.com/w/index.php/Talk ... lling_page
I agree, the fact we were apparently the only two interested in the matter was not really motivating either of us to work hard on this.
but I guess my disagreement with part of it may have dulled your interest in the rest? :(
Partly yes, and the other part is that I was busy with more important things lately, and also the lack of general interest by other community members, so I stopped to care about the matter.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by Dwedit »

Castlevania 3 uses three screen mirroring for one level, when there's the rising water.
Yes, it could have been just as easily done on standard horizontal mirroring as well.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by Bregalad »

Dwedit wrote:Yes, it could have been just as easily done on standard horizontal mirroring as well.
At the price of very visible glitches on the screen's sides... At least they put the MMC5 extra functionality to some use when porting the game for the NES release, and I think they did a great job.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: What is MMC5 "3-screen mirroring" good for? Answered ins

Post by FrankenGraphics »

The rising water effect amazed me when the game was new. I couldn't even begin to comprehend how they did that.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by calima »

Apparently emulators have trouble with writing to 5105 while rendering is on. Trying to do exactly this, both fceux and mednafen display a differently broken image. I'm not on latest git versions though, maybe those are better.
edit: Nintendulator too. Bankswitches take effect, but the 5105 write does not. Yet if I change it with the PPU off, it does take effect in all three.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by lidnariq »

Looking in FCEUX's MMC5 source, I can't figure out how that could go wrong...?
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by NewRisingSun »

Could you post the ROM you are testing with?
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by calima »

Attached.
Attachments
mmc5.nes.gz
(3.9 KiB) Downloaded 132 times
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by calima »

Reference pics.
Attachments
mednafen.png
mednafen.png (480 Bytes) Viewed 5981 times
fceux.png
fceux.png (456 Bytes) Viewed 5981 times
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by NewRisingSun »

Thank you for the test ROM. I get a picture similar to your FCEUX reference picture in NintendulatorNRS. How is it supposed to look? It's not obvious to me what I should be getting.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by calima »

The A and B nametables contain a grass/forest scene in green and white respectively (bad programmer art, but just for testing). So everything below the HUD should have NT A contents since there isn't yet scrolling, and at that point the IRQ triggers the 5105 write from "exram nt only" to "vertical mirroring".

The fceux picture means the CHR bankswitch took effect, but the 5105 write did not; you're seeing the right CHR data but NT comes from exram, not NT A.

MMC5 is massive, and I don't have a hw test setup, so I'm not 100% sure the rom is correct. It's however very simple, aside from missing some reg writes not a lot of possibilities.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What is MMC5 "3-screen mirroring" good for? Answered inside.

Post by calima »

Sorry, my bug. During testing had moved the first 5105 write around, which directed the NTA/B writes to a wrong area. After fixing that, fceux displays a proper picture (mednafen is still broken).
Post Reply