MMC3 - Repro problems, works on the PowerPak and Emulators

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Vectrex2809
Posts: 97
Joined: Mon Jul 14, 2014 6:05 am
Location: Tokyo, Japan

MMC3 - Repro problems, works on the PowerPak and Emulators

Post by Vectrex2809 »

So I made a little MMC3 game (which works on all emulators and on the PowerPak and my friend is trying to make a repro of it. However he always gets a solid gray screen. So I wanted to make sure my MMC3 init code was okay or if it's just him. The game isn't too big (32K PRG / 64K CHR) since I use the MMC3 mostly for the bank sizes and the IRQs.

Here's my MMC3 init code as well as a few things that might help

Code: Select all


  .inesprg 2   ; 2x 16KB PRG code
  .ineschr 8   ; 4x  8KB CHR data
  .inesmap 4   ; mapper 4 = MMC3
  .inesmir 1   ; background mirroring

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BANKSWAP		= $8000
BANKDATA		= $8001
MIRROR			= $A000
RAMPROTECT		= $A001
IRQLATCH		        = $C000
IRQRELOAD		= $C001
IRQOFF			= $E000
IRQON			= $E001

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  LDA #%00000000
  STA BANKSWAP
  LDA #%00000000
  STA BANKDATA

  LDA #%00000001
  STA BANKSWAP
  LDA #%00000010
  STA BANKDATA

  LDX #$02
  LDY #$1C
.copyloop
  STX BANKSWAP
  STY BANKDATA
  INY
  INX
  CPX #$06
  BNE .copyloop

  LDA #$00
  STA RAMPROTECT
  STA MIRROR
Any idea of might've went wrong?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: MMC3 - Repro problems, works on the PowerPak and Emulato

Post by tepples »

Your init code has to be in $E000-$FFFF because the PRG bank registers' values are unspecified at power-on.

Do other similarly sized ROMs work when you try to make a repro?
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: MMC3 - Repro problems, works on the PowerPak and Emulato

Post by tokumaru »

The reset code, including the mapper configuration, must be at $e000-$ffff, which is always hardwired to the last bank. Also, it appears you're only selecting the CHR banks. You need to select which 8KB PRG banks go at $8000-$bfff before you can use them. It may be obvious which banks go there since you only have 32KB of PRG-ROM, but the mapper doesn't know that.
User avatar
Vectrex2809
Posts: 97
Joined: Mon Jul 14, 2014 6:05 am
Location: Tokyo, Japan

Re: MMC3 - Repro problems, works on the PowerPak and Emulato

Post by Vectrex2809 »

tepples wrote:Your init code has to be in $E000-$FFFF because the PRG bank registers' values are unspecified at power-on.

Do other similarly sized ROMs work when you try to make a repro?
Ah-ha! It's in the $C000-$DFFF range so that's why it doesn't work probably. I'll try putting it in the $E000-$FFFF range then.
Is this written in the wiki? I think that would be useful information to write in it if it isn't there.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: MMC3 - Repro problems, works on the PowerPak and Emulato

Post by tokumaru »

It's general knowledge that registers have unknown values on startup, meaning the MMC3 is in an unknown state on power up. The only MMC3 ROM slot hardwired to the same ROM bank in all configurations is $e000-$ffff. Some mappers don't even have any slots you can count on being mapped to a constant bank, so they need to have the reset code in all banks.

A warning about this is relevant to all mappers, not only the MMC3. You need to read the documentation of the mapper you're using to see if there are any slots guaranteed to point to a constant bank, in which case that's where the reset code must be, otherwise every bank has to include a little reset stub in the same position, so it's guaranteed to be mapped on power on.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: MMC3 - Repro problems, works on the PowerPak and Emulato

Post by Dwedit »

Also see: Cheetahmen 2 didn't have the reset stub, and occasionally boots up on the inaccessible levels.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply