MMC3 scroll not working

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
EnigmaOverdrive
Posts: 9
Joined: Sat Jul 09, 2016 10:16 am

MMC3 scroll not working

Post by EnigmaOverdrive »

I'm working on a project that uses the MMC3 mapper and some horizontal scrolling. As far as I can tell the mirroring is being set to horizontal in the config file and therefore the scrolling works when tested in emulators. But when I test it on a cartridge, the scrolling doesn't work and looks as though the mirroring isn't set properly. Any ideas as to why?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: MMC3 scroll not working

Post by tepples »

What value are you writing to $A000?
EnigmaOverdrive
Posts: 9
Joined: Sat Jul 09, 2016 10:16 am

Re: MMC3 scroll not working

Post by EnigmaOverdrive »

I'm not sure, my startup code has this in it:

Code: Select all

.segment "HEADER"

    .byte $4e,$45,$53,$1a
	.byte <NES_PRG_BANKS
	.byte <NES_CHR_BANKS
	.byte <NES_MIRRORING|(<NES_MAPPER<<4)
	.byte <NES_MAPPER&$f0
	.res 8,0
where NES_MIRRORING is set to 0
User avatar
Gilbert
Posts: 479
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: MMC3 scroll not working

Post by Gilbert »

Let me guess. Did you set it to horizontal mirroring for a horizontally scrolling game?

I know it's a bit confusing for some, but horizontal mirroring means that the two distinct name tables are arranged vertically, so that the same name table is repeated in the horizontal direction (hence, "mirroring").
Similarly, vertical mirroring means that the two distinct name tables are arranged horizontally, so that the same name table is repeated in the vertical direction.

In generally, you use horizontal mirroring for vertically scrolling scenes, and vertically mirroring for horizontally scrolling scenes.

I think people have started using terms like "vertical/horizontal arrangement of the name tables" to avoid confusions.
EnigmaOverdrive
Posts: 9
Joined: Sat Jul 09, 2016 10:16 am

Re: MMC3 scroll not working

Post by EnigmaOverdrive »

Hmm well with the NES_MIRRORING set to 0 it works correctly for the horizontal scrolling on emulators, but not if it's set to 1 (for vertical mirroring). On hardware it doesn't work regardless.
EnigmaOverdrive
Posts: 9
Joined: Sat Jul 09, 2016 10:16 am

Re: MMC3 scroll not working

Post by EnigmaOverdrive »

This is where that is set in the config file:

Code: Select all

SYMBOLS {

	__STACKSIZE__: type = weak, value = $0500; # 5 pages stack

	NES_MAPPER: type = weak, value = 4; 			# mapper number
	NES_PRG_BANKS: type = weak, value= 4; 			# number of 16K PRG banks, change to 2 for NROM256
	NES_CHR_BANKS: type = weak, value = 8; 			# number of 8K CHR banks
	NES_MIRRORING: type = weak, value = 0; 			# 0 horizontal, 1 vertical, 8 four screen
}
User avatar
freem
Posts: 168
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: MMC3 scroll not working

Post by freem »

The mirroring on MMC3 is mapper-controlled, meaning you have to set it in the actual program code. The "startup" code you posted earlier merely sets the value in the header of the .nes file, which the MMC3 hardware doesn't actually check or know about. (A flashcart typically needs it to know what mapper it's supposed to emulate.)
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: MMC3 scroll not working

Post by lidnariq »

An emulator's MMC3 should not use the mirroring value in the header. Only the older, marginally-compatible Namco 108 has fixed mirroring controlled by permanently connecting wires in the cartridge.

The MMC3 instead uses a register at memory address $A000 that allows the game to switch the layout whenever it wants.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: MMC3 scroll not working

Post by rainwarrior »

Gilbert wrote:Let me guess. Did you set it to horizontal mirroring for a horizontally scrolling game?

I know it's a bit confusing for some, but horizontal mirroring means that the two distinct name tables are arranged vertically, so that the same name table is repeated in the horizontal direction (hence, "mirroring").
Similarly, vertical mirroring means that the two distinct name tables are arranged horizontally, so that the same name table is repeated in the vertical direction.

In generally, you use horizontal mirroring for vertically scrolling scenes, and vertically mirroring for horizontally scrolling scenes.

I think people have started using terms like "vertical/horizontal arrangement of the name tables" to avoid confusions.
The original NES PCBs seemed to use H and V to label solder pads as "arrangement" rather than "mirroring" (i.e. Super Mario Bros. connects H, because it's a horizontal game). Since so many terms that we use come directly from the PCBs, I'm a bit surprised by this one too.

I might guess that it comes down from Marat Fayzullin's original iNES format specification, but I don't know if he took this terminology from a prior source.
EnigmaOverdrive
Posts: 9
Joined: Sat Jul 09, 2016 10:16 am

Re: MMC3 scroll not working

Post by EnigmaOverdrive »

So how should I go about setting the mirroring in the actual code itself? What value should I write to A000? It seems like it should be a 1 for horizontal scrolling, is that right?
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: MMC3 scroll not working

Post by koitsu »

EnigmaOverdrive wrote:So how should I go about setting the mirroring in the actual code itself? What value should I write to A000? It seems like it should be a 1 for horizontal scrolling, is that right?
Per the MMC3 wiki:

Using horizontal mirroring ("for vertically scrolling games"):

Code: Select all

lda #1
sta $a000
Using vertical mirroring ("for horizontally scrolling games"):

Code: Select all

lda #0
sta $a000
For the what the different mirroring terms mean, nametable-layout-wise, refer to the Mirroring document which includes visual diagrams.
User avatar
dougeff
Posts: 2875
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: MMC3 scroll not working

Post by dougeff »

I didn't know this either. I'm glad somebody brought it up.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: MMC3 scroll not working

Post by thefox »

lidnariq wrote:An emulator's MMC3 should not use the mirroring value in the header.
Yet they do, because there are mapper 206 ROMs floating around mislabeled as mapper 4.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
Myask
Posts: 965
Joined: Sat Jul 12, 2014 3:04 pm

Re: MMC3 scroll not working

Post by Myask »

Do we know the poweron/reset state(s) of the MMC3's mirroring control?

If not, is there a good reason not to use the header bit as an initial state?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: MMC3 scroll not working

Post by rainwarrior »

Reasons to randomize it:

1. Expose initialization bugs in homebrew testing.
2. Enable latent initialization bugs in commercial games to occur (if any exist).

Reasons not to:

1. Consistent behaviour.
2. Compatibility with mapper 206 with "improper" header.

If you want consistent behaviour, you need to initialize it to something. The header seems as good a source as any for that.
Post Reply