Problem converting 256 KB MMC-1 to 512 KB MMC-1

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

User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

I want to convert my current game from a MMC-1 with 256 KB to MMC-1 with 512 KB.
I did all the changes that I think are needed, but the game doesn't start anymore.

This is what I did:

I changed the fifth value in the NES header from 16 to 32:

Code: Select all

.segment "HEADER"
	.byte "NES", $1A
	.byte 32
	.byte 0
	.byte %00010010
I added new memory and segment entries in the config file.

Those are the corresponding original values:

Code: Select all

PRG_ROM_BANK_0:   type = ro, start = $8000, size = $4000, file = %O, fill = yes;
...
PRG_ROM_BANK_14:  type = ro, start = $8000, size = $4000, file = %O, fill = yes;
PRG_ROM_BANK_FIX: type = ro, start = $C000, size = $4000, file = %O, fill = yes;

Code: Select all

BANK_0_RESET:   load = PRG_ROM_BANK_0,   type = ro;
...
BANK_14_RESET:  load = PRG_ROM_BANK_14,  type = ro;
BANK_FIX_RESET: load = PRG_ROM_BANK_FIX, type = ro;

Code: Select all

BANK_0_VECTORS:   load = PRG_ROM_BANK_0,   type = ro, start = $BFFA;
...
BANK_14_VECTORS:  load = PRG_ROM_BANK_14,  type = ro, start = $BFFA;
BANK_FIX_VECTORS: load = PRG_ROM_BANK_FIX, type = ro, start = $FFFA;
Here, I put bank 15-30 between 14 and fix.

Same with the code itself.

Original versions:

Code: Select all

.segment "BANK_0_RESET"
	RESET_START
...
.segment "BANK_14_RESET"
	RESET_START
.segment "BANK_FIX_RESET"
Reset:
	RESET_START

Code: Select all

.segment "BANK_0_VECTORS"
	.addr Nmi, Reset, 0
...
.segment "BANK_14_VECTORS"
	.addr Nmi, Reset, 0
.segment "BANK_FIX_VECTORS"
	.addr Nmi, Reset, 0
I added bank 15-30 between bank 14 and bank fix.

By the way, RESET_START is a macro that contains this code:

Code: Select all

.macro RESET_START
	SEI
	CLD
	LDX #$40
	STX ApuFrameCounter
	LDX #$FF
	TXS
	STX $8000
.endmacro
All in all, the version with 16 banks works fine. But with 32 banks, it doesn't even start.

So, what else do I need to add, so that the code works?
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by rainwarrior »

The MMC1 mapper was only designed to do 256k normally. The 5th bit of the "PRG" register actually controls PRG-RAM enable, not PRG banking. The high bit of 512k PRG select was achieved by reusing a line from the CHR banking registers on some boards. It's a terribly overloaded situation, unfortunately. You might find emulators that won't even use the high bit like that without a CRC match.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

Well, there are two non-obscure, American MMC-1 cartridges with 512 KB PRG ROM: "Dragon Warrior III" and "IV".

So it looks like MMC-1 512 KB mappers were not only used by some unknown company in games that nobody remembers, but this mapper type actually exists inside the list of the popular, famous titles.

So, should I stick with MMC-1 and check how to change the code accordingly?
Or should I switch to MMC-3?
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by tokumaru »

DRW wrote:At least there are two non-obscure, American MMC-1 cartridges with 512 KB PRG ROM: "Dragon Warrior III" and "IV", so it's not like this was only used by some unknown company.
Yes, but it's still a hack. They repurposed a CHR address line to select between 2 256KB of a 512KB PRG chip, so the result is more like a multicart with 2 256KB MMC1 programs that can switch to each other.

If you stick to the MMC1, you have to design your program around that model. One solution is to use one of the 256KB halves mostly for graphics and audio, so you don't need to jump back and forth during game logic.
So, should I stick with MMC-1 and check how to change the code accordingly?
Or should I switch to MMC-3?
I'm not a big fan of the MMC1 anyway, so I think this would be a huge upgrade. In addition to the much improved memory mapping capabilities, you'll get a decent scanline counter that'll open a world of possibilities for raster effects.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

O.k., I'll switch to MMC-3 then.

Since my game is a top-down action adventure like "Zelda", raster effects aren't really necessary, but I can finally abolish sprite 0 for the nametable switch when a dialog box is open.

Also, my graphics artist can then do animated backgrounds.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by tepples »

rainwarrior wrote:The MMC1 mapper was only designed to do 256k normally. The 5th bit of the "PRG" register actually controls PRG-RAM enable, not PRG banking. The high bit of 512k PRG select was achieved by reusing a line from the CHR banking registers on some boards. It's a terribly overloaded situation, unfortunately.
I don't see what you mean by "overloaded" in this case. In all MMC1 boards with 4 Mbit PRG ROM, A18 on the program is connected to the mapper's CHR A16 output.
rainwarrior wrote:You might find emulators that won't even use the high bit like that without a CRC match.
Anyone know which emulators these might be, so that I can file a bug should Holy Mapperel fail?

Again, the biggest reason to stick with MMC1 is if your cart manufacturer charges more for the larger CPLD that can hold an MMC3. Have you received quotes from manufacturers?

Animated backgrounds don't technically need MMC3, as you can stuff tiles into CHR RAM during idle vblank time. The Curse of Possum Hollow does this because only 16 tiles of each background can be animated (in 2 groups of 8, one group per vblank).
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by tokumaru »

DRW wrote:O.k., I'll switch to MMC-3 then.
If that doesn't cause any supply or cost issues, I think that's a great decision.
Since my game is a top-down action adventure like "Zelda", raster effects aren't really necessary, but I can finally abolish sprite 0 for the nametable switch when a dialog box is open.
Some may associate "raster effects" with "parallax effects", but dialog boxes and status bars are also considered raster effects. Maybe you'll think of something else to do in-game.
Also, my graphics artist can then do animated backgrounds.
Those are always pretty cool.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by Bregalad »

User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by rainwarrior »

tepples wrote:I don't see what you mean by "overloaded" in this case.
I mean the textbook definition of "overloaded" in a programming context.
tepples wrote:
rainwarrior wrote:You might find emulators that won't even use the high bit like that without a CRC match.
Anyone know which emulators these might be, so that I can file a bug should Holy Mapperel fail?
I haven't tested it, but this comment in FCEUX's source is suggestive.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

Do you remember when I told you that you have a habit of trying to put me down? This is another one of those examples.

Do you seriously expect me to find a single post within a larger thread that is called "More MMC1 CHR bankswitching woes" when I have a question about increasing the number of PRG ROM banks of an MMC-1 ROM?

Yeah, sounds doable. I always read every post in every thread on this forum. How could I not stumble upon this information buried in a thread about CHR-related issues? :roll:
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by tepples »

rainwarrior wrote:
tepples wrote:
rainwarrior wrote:You might find emulators that won't even use the high bit like that without a CRC match.
Anyone know which emulators these might be, so that I can file a bug should Holy Mapperel fail?
I haven't tested it, but this comment in FCEUX's source is suggestive.
Based on my reading of that code, it still figures offs_16banks correctly, though artifacts from using 4K mode with different values for bit 4 might not be emulated. I just tested a Holy Mapperel SUROM build in FCEUX and confirmed that it worked. I think the comment was just describing misuse of the WRAM disable bit as an extra PRG bank bit.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by Bregalad »

I originally didn't intend to answer, as I don't necessarly like getting political, but as it seems from DRW's signature he's selling games I can't refrain from commenting. We the forum users help everyone for free, and you are probably making profit from this help, but you still complain and act relatively aggressively. This behavior is not inclining people to help you. Now I can already forsee you aggressively defend your cause and so on, but I just won't care; I'm just pointing things out, I don't care about being right or wrong or anything, and I don't like getting political anymore.
DRW wrote: Do you remember when I told you that you have a habit of trying to put me down? This is another one of those examples.
I don't know why you're taking it personally, but I don't normally behave differently towads different forum users. I would have said the exact same with anyone else. If you are taking this as a personal attack or anything you're probably paranoid, since this is neither personal nor an attack. I simply wrote a helpful post about extensions of MMC1 less than a month ago, I'm linking to it (and other people discussing the subject) rather than typing everything down again. How's that bad in any way ? Sometimes if I clearly remember a discussion having already taken place I could even link to post from 10 years ago too. There's no point in discussing the same thing over and over again if a clear explanation is already there for free.

Besides, you mentioned your game doesn't start but you didn't explain the efforts you made debugging with FCEU or Nintendulator in order to see where your game crashed, so not pointing to the reail problem.
Do you seriously expect me to find a single post within a larger thread that is called "More MMC1 CHR bankswitching woes" when I have a question about increasing the number of PRG ROM banks of an MMC-1 ROM?
Yes, I expect people to follow the forums, but I fully agree the thread title is irrelevant to the subject being discussed in this case; this happens regularly though and is unavoidable as discussions tends to derail.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

Bregalad wrote:We the forum users help everyone for free, and you are probably making profit from this help, but you still complain and act relatively aggressively.
I don't complain about people who help me. But I can complain about snarky comments that don't help me.

I'm grateful for rainwarrior's and tokumaru's help because they told me exactly what the issue is.
You, on the other hand, merely told me "Please research before asking." And your link merely repeated what has already been answered by the ther two guys, so I didn't even need this link in that moment anymore. Hence, your help in this situation was exactly zero.

My gratefulness always depends on the actual contents of the posts. Just because person A helped me doesn't mean that I have to be grateful towards person B, you know?
Bregalad wrote:There's no point in discussing the same thing over and over again if a clear explanation is already there for free.
Linking to another thread is fine. Complaining that the poster should have found it himself isn't, especially when it's not even obvious that this specific thread is about this specific topic.
Bregalad wrote:Besides, you mentioned your game doesn't start but you didn't explain the efforts you made debugging with FCEU or Nintendulator in order to see where your game crashed, so not pointing to the reail problem.
And that's a problem why exactly?
Sure, if someone does some obscure things in his code, then you can ask him what exactly he did. But I merely added more banks and someone immediately recognized that MMC1 simply doesn't support this number of banks, period.
So, what exactly are you even complaining about? That I didn't list all the things that I've done that wouldn't have made a difference anyway?

Again: My problem's answer lies not in any code bugs that I accidentally made, but in the simple fact that the mapper isn't built for that size.
The wiki page says 512 KB and you write five bits to the mapper, but the 512 KB only refers to some hacky workaround of which I never even knew that it can be a thing in the first place. So, my confusion after trying to add more banks and the game not working anymore wasn't something that was easily avoidable, but it was something that's easily answerable by anybody who knows a bit about the MMC1.
Bregalad wrote:
Do you seriously expect me to find a single post within a larger thread that is called "More MMC1 CHR bankswitching woes" when I have a question about increasing the number of PRG ROM banks of an MMC-1 ROM?
Yes, I expect people to follow the forums, but I fully agree the thread title is irrelevant to the subject being discussed in this case; this happens regularly though and is unavoidable as discussions tends to derail.
Oh, so you're not only expecting people to read every MMC1 thread because one of the 50 threads where this word appears might have this very answer. You expect people to read every thread because even a thread called "Scrolling issues" could have the desired MMC1 answer somewhere on page 17 of 25.
This premise is even more ridiculous.


And that's everything that I have to say about this.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by Bregalad »

Again: My problem's answer lies not in any code bugs that I accidentally made, but in the simple fact that the mapper isn't built for that size.
The wiki page says 512 KB and you write five bits to the mapper, but the 512 KB only refers to some hacky workaround of which I never even knew that it can be a thing in the first place
Oh I totally did not understand that, this changes everything. I assumed you knew about SUROM quirck but couldn't make it work and asked how. So I was definitely wrong from the beginning - my apologizes.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Problem converting 256 KB MMC-1 to 512 KB MMC-1

Post by DRW »

Well, I explained in detail what I tried, didn't I?
I want to convert my current game from a MMC-1 with 256 KB to MMC-1 with 512 KB.
[...]
This is what I did:
I changed the fifth value in the NES header from 16 to 32
[...]
I added new memory and segment entries in the config file.
[...]
Same with the code itself.
[...]
All in all, the version with 16 banks works fine. But with 32 banks, it doesn't even start.
This way, it was clear that I didn't know anything about any specific quirks and the unusual way to implement a 512 KB MMC1 ROM, but that I simply just tried to extend the game from 256 KB to 512 KB, in the same way that someone would extend a 128 KB MMC1 ROM to 256 KB.

Or, as you said it yourself:
Bregalad wrote:Please research before asking.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Post Reply