(NOOB) good MMC chip explanations/tutorials?

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

Vikrinox
Posts: 4
Joined: Fri May 07, 2021 5:03 am
Location: Köttbulls land

(NOOB) good MMC chip explanations/tutorials?

Post by Vikrinox »

Hi! Guy (relatively) new to nesdev.
Before i start, i just want to clarify that i am an utter dunce, And replies will most likely need to be unneccesarily clear for me to properly understand. This is because I want to be able to pass on whatever knowledge i learn. And often things need to be crystal clear for my mind to connect the dots and not just acknowledge what they are. My question is, How does the MMC chips actually work? (specifically the MMC3)

Ive not been able to find a proper beginner friendly tutorial with clear explanations. I get that this topic by nature kind of needs me to have a better understanding of the nes as a whole. And that its a concept thats harder to grasp and to properly understand. But i feel like theres a better way to explain all this than what ive found so far. And i still want to give this a shot because ive found that its "cartridge addatives" like this thats held me back from being confident enough to actually starting proper with nesdev as a whole.

From what i understand, the MMC3 is equipped with some bank switching options primarily for CHR roms and different goodies, but from reading article to article and going through the wiki i have not been able to find out how to properly "operate" it.

What im looking for is a simple explanation or some sort of beginner friendly tutorial, telling me some of the different memory/bank layouts and how i should change my header and so on to use these layouts, aswell as where i need to read/write to switch what banks and what values to use/look for when reading/writing. If people also care enough to tell me any extra quirks, bugs, etc. it'd be great.

All help is greatly appreciated.

Yours truly
local noob
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: (NOOB) good MMC chip explanations/tutorials?

Post by Pokun »

As you seem not to fully understand how the NES works I don't see much point in trying to look for MMC3 info just yet. Start with NROM until you learn how the NES and 6502 works. Nerdy Nights is the best tutorial for beginners, and it includes MMC1 explanation. Once you understand that much, it shouldn't be hard to learn about the MMC3 from the wiki.

The MMC3 is the most advanced of the most commonly used mappers, but it's really just a mapper that allows you to use larger PRG- and CHR-ROMs. Notably it has a scanline counter which allows you to do screen splits (raster effects) much easier than without it. It's fully possible to do raster effects with the sprite 0 collision detection flag with any cartridge type though, including NROM (SMB1 does just that). Nerdy Nights teaches that too.
Vikrinox
Posts: 4
Joined: Fri May 07, 2021 5:03 am
Location: Köttbulls land

Re: (NOOB) good MMC chip explanations/tutorials?

Post by Vikrinox »

Well, this was pretty much what i was looking for. Honestly suprised i haven't found this earlier. I really just wanted help with more cartridge specific hardware as ive pretty much done everything i felt was possible using NROM. a simple (if janky) audio engine and some ppu tricks i thought were interesting. (scrolling, changing palettes and attribute tables on the fly, etc.) But this was pretty much what i was looking for. Honestly suprised i haven't found this before as it actualy properly explain things instead of just jumping aimlessly from one thing to the next. I've followed atleast half a dosen tutorials and switched compilers twice already. Sorry for going the lazy route and taking something like this to a forum. I know theres gonna be alot of people like me in the future and probably has been in the past. Im not fond of knowing ive added to that pile of basically useless threads.

In any case, thank you!
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: (NOOB) good MMC chip explanations/tutorials?

Post by Pokun »

Nerdy Nights used to be a very popular tutorial, but since the forum it was posted on has died I guess it's harder to find now. Thankfully these mirrors of the original threads exists.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: (NOOB) good MMC chip explanations/tutorials?

Post by dougeff »

MMC3 basics

Assuming you want the 2nd to last bank fixed to $c000 and you don't want to invert A12 for CHR.

set PRG bank at $8000
lda #6
sta $8000
lda #bank
sta $8001

set PRG bank at $a000
lda #7
sta $8000
lda #bank
sta $8001

set CHR bank at $0000
lda #0
sta $8000
lda #bank
sta $8001

set CHR bank at $0800
lda #1
sta $8000
lda #bank
sta $8001

set CHR bank at $1000
lda #2
sta $8000
lda #bank
sta $8001

set CHR bank at $1400
lda #3
sta $8000
lda #bank
sta $8001

set CHR bank at $1800
lda #4
sta $8000
lda #bank
sta $8001

set CHR bank at $1c00
lda #5
sta $8000
lda #bank
sta $8001

set mirroring
lda#0 vertical or 1 horizontal
sta $a000

turn off scanline IRQ
sta $e000 (any value)

turn on scanline IRQ
(CLI)
(sprite and BG must use different tile sets)
lda #number of scanlines
sta $e000 ; disable mmc3 irq
sta $c000 ; set the irq counter reload value
sta $c001 ; reload the reload value
sta $e001 ; enable the mmc3 irq

remember to explicitly set all banks and mirroring and disable IRQ on Reset.

(omitted, SRAM settings)
Last edited by dougeff on Fri May 07, 2021 3:43 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Quietust
Posts: 1918
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: (NOOB) good MMC chip explanations/tutorials?

Post by Quietust »

dougeff wrote: Fri May 07, 2021 3:20 pm set CHR bank at $0000
lda #0
sta $8000
lda #bank
sta $8001

set CHR bank at $0800
lda #1
sta $8000
lda #bank
sta $8001

set CHR bank at $1a00
lda #5
sta $8000
lda #bank
sta $8001
Some minor corrections: when you're mapping CHR banks at $0000 and $0800, you need to double the number written to $8001 because you're actually providing a 1KB bank number and the MMC3 is discarding the least significant bit to change it into a 2KB bank number.

Additionally, the topmost bank is at $1C00, not $1A00.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: (NOOB) good MMC chip explanations/tutorials?

Post by dougeff »

edited to say 1c00
nesdoug.com -- blog/tutorial on programming for the NES
Vikrinox
Posts: 4
Joined: Fri May 07, 2021 5:03 am
Location: Köttbulls land

Re: (NOOB) good MMC chip explanations/tutorials?

Post by Vikrinox »

Well this was alot easier than i first thought. Thank you for your responses! Guess all the explanations ive been reading were just alot more intimidating than anything. However with this i want to ask a few things as i want to be sure im on the right track before i dive head first into actually trying to make any of this work and try to fix problems for the next week.

As i understand it, banks are kind of another way to divide data into "chunks" much like a segment or similar. WIth the big difference being that banks can be used to have different codes occupy the same address space. (although with only one set visible at a time of course)
So is it laid out like this?

Bank 0: has one set of data (PPU $0000-1FFF and CPU $8000-FFFF ? ) where i decide what parts are shown to the NES according the different sections
Bank 1: has another set of data for $0000-1FFF and $8000-FFFF where i decide what parts are shown to the NES according the different sections
Bank 2: has another set of data for $0000-1FFF and $8000-FFFF where i decide what parts are shown to the NES according the different sections
Bank ...
And then i can just kind of mix and match banks between sections a little however according to what i need at that time?

Also with this comes probably my dumbest question where its probably good to know i use ca65. if its even possible and if ive understood all this correctly How do declare "here starts bank 1 in my code" and the same for bank 2 and so on within my assembly code? I know linker files are a thing and all that but is that mandatory? Im gonna answer my own question and say they probably are. But if so how do i say "hey bank x should be a bank that does this and all that"

I feel like these should be very obvious things. And they most likely are but to me who is learning all of this for the first time it really isn't as such. I just really prefer knowing im right and shutting my mouth to being loud and ignorant with no insentive to change that. (i mean this is the whole reason im taking this to a forum and not just spending another day googling around and somewhat knowing what im doing)

In any case, Thanks to all future responses in advance.
User avatar
nia_prene
Posts: 17
Joined: Sat Dec 04, 2021 2:50 pm

Re: (NOOB) good MMC chip explanations/tutorials?

Post by nia_prene »

When I first started, I had these grandiose dreams of making massive games on the MMC3. I wanted animated backgrounds and huge detailed maps et.. What actually happened is I became frustrated trying to learn which mapper to use and how to use it before even mastering the NES architecture in its most primitive form. I bit off way more than I could chew. The reality is, with one lone coder, the practicality of making a huge MMC3 game is more or less out of reach, especially for "noobs." The best advice I can give you is make a super simple arcade-style game on the NROM. Make a bunch of them. Become a master. Don't worry about bank switching or advanced boards until you can make an NROM game in your sleep. By that time you will have no problem with the NESDEV documentation on the MMC3, and you can decide for yourself if it is worth programming for. Don't put the cart before the horse, or you will end up angry and quit before even completing a game. See a game all the way through, from conception to logic to graphics to sound to completion, even if it is just one level. Get in the groove. small projects are easier to complete.

I think you already have your answer, and to that effect I am sorry I am not answering your questions. I thought I would share my experience from when I was asking questions like this.
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: (NOOB) good MMC chip explanations/tutorials?

Post by puppydrum64 »

nia-prene wrote: Sat May 15, 2021 4:51 pm When I first started, I had these grandiose dreams of making massive games on the MMC3. I wanted animated backgrounds and huge detailed maps et.. What actually happened is I became frustrated trying to learn which mapper to use and how to use it before even mastering the NES architecture in its most primitive form. I bit off way more than I could chew. The reality is, with one lone coder, the practicality of making a huge MMC3 game is more or less out of reach, especially for "noobs." The best advice I can give you is make a super simple arcade-style game on the NROM. Make a bunch of them. Become a master. Don't worry about bank switching or advanced boards until you can make an NROM game in your sleep. By that time you will have no problem with the NESDEV documentation on the MMC3, and you can decide for yourself if it is worth programming for. Don't put the cart before the horse, or you will end up angry and quit before even completing a game. See a game all the way through, from conception to logic to graphics to sound to completion, even if it is just one level. Get in the groove. small projects are easier to complete.

I think you already have your answer, and to that effect I am sorry I am not answering your questions. I thought I would share my experience from when I was asking questions like this.
Or rather, put the cart ahead of the Nintendo 8-)
User avatar
nia_prene
Posts: 17
Joined: Sat Dec 04, 2021 2:50 pm

Re: (NOOB) good MMC chip explanations/tutorials?

Post by nia_prene »

puppydrum64 wrote: Sun May 16, 2021 12:02 am Or rather, put the cart ahead of the Nintendo 8-)
lmao
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: (NOOB) good MMC chip explanations/tutorials?

Post by puppydrum64 »

nia-prene wrote: Sun May 16, 2021 12:59 pm
puppydrum64 wrote: Sun May 16, 2021 12:02 am Or rather, put the cart ahead of the Nintendo 8-)
lmao
I'll admit I'm guilty of this myself, I got my start with NES Maker (which uses mapper 30 which is pretty complex) and was later intrigued by the Konami VRC6's enhanced music capabilities. So I've been having to learn firsthand just how difficult complex mappers can be to work with.
User avatar
nia_prene
Posts: 17
Joined: Sat Dec 04, 2021 2:50 pm

Re: (NOOB) good MMC chip explanations/tutorials?

Post by nia_prene »

puppydrum64 wrote: Sun May 16, 2021 7:24 pm
nia-prene wrote: Sun May 16, 2021 12:59 pm
puppydrum64 wrote: Sun May 16, 2021 12:02 am Or rather, put the cart ahead of the Nintendo 8-)
lmao
I'll admit I'm guilty of this myself, I got my start with NES Maker (which uses mapper 30 which is pretty complex) and was later intrigued by the Konami VRC6's enhanced music capabilities. So I've been having to learn firsthand just how difficult complex mappers can be to work with.
Oh I am guilty of this too. My initial project was going to be this vast open world JRPG experience. After struggling with half baked ideas for a year (and wasting hundreds of hours), I am actually pretty far on my new project, a simple game that uses only 2 buttons, left and right.

It is easy to forget that it took teams of people working overtime to make games on these boards. Pretty big scope for one bedroom coder. I think most homebrew projects can find their home on an nrom cart, and any scaling back on the project scope will actually be to the benefit of the programmer. It is better to outgrow the nrom board after years of development than to jump into a more difficult mapper at the onset. If we get to the point where we are becoming limited by the nrom board, then we can select a mapper that allows for more complex programs based on need.
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: (NOOB) good MMC chip explanations/tutorials?

Post by puppydrum64 »

nia-prene wrote: Mon May 17, 2021 4:18 pm
puppydrum64 wrote: Sun May 16, 2021 7:24 pm
nia-prene wrote: Sun May 16, 2021 12:59 pm

lmao
I'll admit I'm guilty of this myself, I got my start with NES Maker (which uses mapper 30 which is pretty complex) and was later intrigued by the Konami VRC6's enhanced music capabilities. So I've been having to learn firsthand just how difficult complex mappers can be to work with.
Oh I am guilty of this too. My initial project was going to be this vast open world JRPG experience. After struggling with half baked ideas for a year (and wasting hundreds of hours), I am actually pretty far on my new project, a simple game that uses only 2 buttons, left and right.

It is easy to forget that it took teams of people working overtime to make games on these boards. Pretty big scope for one bedroom coder. I think most homebrew projects can find their home on an nrom cart, and any scaling back on the project scope will actually be to the benefit of the programmer. It is better to outgrow the nrom board after years of development than to jump into a more difficult mapper at the onset. If we get to the point where we are becoming limited by the nrom board, then we can select a mapper that allows for more complex programs based on need.
There are just a lot of things that NROM can't do and that's always going to make me feel like my game is "outdated." Even when developing on NESMaker, which uses a really complex mapper chip, I couldn't help but feel that my spaceship game was barely better than the Action 52 spaceship games. Luckily those complicated mappers don't force you to use the maximum cartridge space, once you get the hang of how they operate you can just stick to the basics and add a little flair with some faux parallax scrolling here and there. I'm testing that feature out right now and it seems to work well
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: (NOOB) good MMC chip explanations/tutorials?

Post by lidnariq »

puppydrum64 wrote: Mon May 17, 2021 7:04 pm There are just a lot of things that NROM can't do and that's always going to make me feel like my game is "outdated."
You're selling both yourself and the simple mappers short with that sentiment: the majority of games for the NES and Famicom use things barely any better (NROM, UNROM, ANROM, MMC1), at most relying on CHR RAM for fancy effects. Thinking that you have to have fancy nametable mirroring or sophisticated CHR banking to make a compelling game is foolhardy, and an instance of Perfect being the enemy of the Good Enough.
Even when developing on NESMaker, which uses a really complex mapper chip,
NESmaker targets an oversize version of UNROM. It's really nothing fancy. The only significant difference is that now you literally cannot buy mask ROMs for cheaper than Flash, so UNROM512 can support self-programming.
Post Reply