(Any version) How To Change Your Game To Mapper 2

Bucket Mouse

Active member
NES games are Mapper 30. There are good and bad sides to this. The good is that Mapper 30 supports animated background tiles and Flash saving wherever possible. The bad is that Mapper 30 was developed by the hobby market and isn't supported by every emulator. Finding a browser emulator that will play a Mapper 30 game, for example, is pretty hard. Also, the Flash saving isn't supported everywhere either. It's designed for physical carts that use Flash memory, and doesn't work properly on some emulators or the Everdrive.

But there is a way to convert your game to a more common mapper: Mapper 2. This conversion will ensure 100% compatibility with anything that can play an NES game. You will lose the benefits of Mapper 30 though (no Flash saving, no animated background tiles....the tiles will simply not move).

I'm making this topic because I found out recently a Mapper 2 conversion has two steps, and most people aren't aware of the second one. The first step is to load the game ROM in Mesen, open the Debugger, and pick the "Tools" menu inside there. Select "Edit iNES Header" and simply change "30" to "2," then hit Save As.

The Mapper 2 conversion works on most emulators by just doing this, but Step 2 is kind of an important step. If an improperly converted Mapper 2 game is played on an original NES, it could create something called a "bus conflict" when switching banks. It's not a good thing:
Bus conflict - NESdev Wiki

To prevent this possiblity, the script that switches banks must be revised a bit. Look in your Subroutines folder for doBankswitchY.asm. It looks like this:

Code:
    doBankswitchY:
    STA currentBank
bankswitchNoSave:
    AND #%00011111
    ORA chrRamBank
    STA $c000
    
    RTS

Get rid of that and replace it with this:

Code:
    doBankswitchY:
    bankswitchNoSave:
    STA currentBank
    TXA
    PHA
    
    LDA currentBank
    TAX
    STA bankBytes,x
    
    PLA
    TAX
    RTS
    
    bankBytes:
  .db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F

Now your ROM is 100% Mapper 2 compatible, and will cause no issues with a real NES (or with FCEUX, which also locks up). This change is also compatible with Mapper 30.
 

SciNEStist

Well-known member
A very concise and clear bit of useful info. Thank you for sharing this! Anyone not using animated tiles or flash saving should bookmark this in order to get as many systems and emulators working as possible with their games.
 

wallmasterr

Active member
Very handy.
thanks
I did wonder weather someone would make a how to on this. il need to test this out on flea. would be great to do a run on mapper 2 boards so it runs everywhere and for all emulators.
Could also mabie finaly get flea on retron 5 through the patch method.

help lol
Iv not touched scripts in ages im on 4.1.5 where is that "doBankswitchY.asm" my windows indexing is playing up and showing no results
 
Last edited:

Bucket Mouse

Active member
Very handy.
thanks
I did wonder weather someone would make a how to on this. il need to test this out on flea. would be great to do a run on mapper 2 boards so it runs everywhere and for all emulators.
Could also mabie finaly get flea on retron 5 through the patch method.

help lol
Iv not touched scripts in ages im on 4.1.5 where is that "doBankswitchY.asm" my windows indexing is playing up and showing no results
On 4.1, the script is simply called "BankSwitch.asm" and it's in the System folder. It is identical otherwise.
 

wallmasterr

Active member
Thanks , found it.
But now im getting loads of unknown label errors and NESmaker cant find the game.nes file

I have tried with
doBankswitchY:
and
BankswitchY:
and
BankSwitch:
at the top and they all error.
Any ideas?

oh wait i changed it to and the errors went away but it just shows a black screen in nesmaker emulator and green on mesen, i also tried swapping over the header

bankswitchY:
bankswitchNoSave:
STA currentBank
TXA
PHA

LDA currentBank
TAX
STA bankBytes,x

PLA
TAX
RTS

bankBytes:
.db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F
 
Last edited:

Bucket Mouse

Active member
@wallmasterr Okay, there's one little extra thing: since 4.1 starts by shifting currentBank to Y instead of A, the replacement version has to do that too.

So the Version 4.1 script looks like this:

Code:
    bankswitchY:
    bankswitchNoSave:
    STY currentBank
    TXA
    PHA
  
    LDA currentBank
    TAX
    STA bankBytes,x
  
    PLA
    TAX
    RTS
  
    bankBytes:
  .db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F

I dug up an old game and my archived 4.1 files and got the game to boot in both Mapper 30 and 2 with this.
 

dale_coop

Moderator
Staff member
I think it's because of the size. NESmaker ROMs are technically too big for "standardized" mapper 2.
 
NES games are Mapper 30. There are good and bad sides to this. The good is that Mapper 30 supports animated background tiles and Flash saving wherever possible. The bad is that Mapper 30 was developed by the hobby market and isn't supported by every emulator. Finding a browser emulator that will play a Mapper 30 game, for example, is pretty hard. Also, the Flash saving isn't supported everywhere either. It's designed for physical carts that use Flash memory, and doesn't work properly on some emulators or the Everdrive.

But there is a way to convert your game to a more common mapper: Mapper 2. This conversion will ensure 100% compatibility with anything that can play an NES game. You will lose the benefits of Mapper 30 though (no Flash saving, no animated background tiles....the tiles will simply not move).

I'm making this topic because I found out recently a Mapper 2 conversion has two steps, and most people aren't aware of the second one. The first step is to load the game ROM in Mesen, open the Debugger, and pick the "Tools" menu inside there. Select "Edit iNES Header" and simply change "30" to "2," then hit Save As.

The Mapper 2 conversion works on most emulators by just doing this, but Step 2 is kind of an important step. If an improperly converted Mapper 2 game is played on an original NES, it could create something called a "bus conflict" when switching banks. It's not a good thing:
Bus conflict - NESdev Wiki

To prevent this possiblity, the script that switches banks must be revised a bit. Look in your Subroutines folder for doBankswitchY.asm. It looks like this:

Code:
    doBankswitchY:
    STA currentBank
bankswitchNoSave:
    AND #%00011111
    ORA chrRamBank
    STA $c000
   
    RTS

Get rid of that and replace it with this:

Code:
    doBankswitchY:
    bankswitchNoSave:
    STA currentBank
    TXA
    PHA
   
    LDA currentBank
    TAX
    STA bankBytes,x
   
    PLA
    TAX
    RTS
   
    bankBytes:
  .db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F

Now your ROM is 100% Mapper 2 compatible, and will cause no issues with a real NES (or with FCEUX, which also locks up). This change is also compatible with Mapper 30.
Very good! You are too good! In which folder do I add this?
 
Top Bottom