nesdev.com
http://forums.nesdev.com/

MMC5: Questions about how CHR bankswitch works.
http://forums.nesdev.com/viewtopic.php?f=3&t=15559
Page 1 of 1

Author:  Fumarumota [ Sun Feb 19, 2017 8:17 pm ]
Post subject:  MMC5: Questions about how CHR bankswitch works.

Hi guys, It's been a while since my last post.

My teammate and I are continuing the work on our emulator, and this time, I'm in charge of implementing the MMC5...

I have some questions about how the CHR bank switching works in the MMC5, more specifically, when using 8x8 sprites and extended attributes simultaneously.

So far games like Castlevania III, Just Breed, Laser Invation and Metal Slader Glory look fine (I don't think they use 8x8 sprites / Ex Attr. at the same time).

After reading the wiki pages, I learned that graphics use the last set of bank registers (0x5120 - 0x5127 / 0x5128 / 0x512B) written to when sprites are 8x8. So far so good, now, when using extended attributes, how do bank switching behaves (8x16 it's working OK, Just Breed looks just fine)?

Right now I have implemented it as follows:

- When fetching AT bytes, six bits from the corresponding NT ex-ram address are used for the CHR lower bank number plus 2 upper bits from register 0x5130 to form an 8 bit value.
- CHR bank is switched in the first or second 4K of PPU CHR depending on what side of the CHR is the BG using.
- When ex ram mode changes to anything different than 1, BG goes back to "normal" CHR register use.
- When fetching sprites , always use "normal" CHR bank registers.

I'm using "Shin 4 Nin Uchi Mahjong - Yakuman Tengoku" to test, and I get the colors right but definitely not the right tiles switched in (graphics garbled as hell).

Anything I might be doing wrong?

Thanks a lot in advance.

Author:  DementedPurple [ Mon Feb 20, 2017 10:40 am ]
Post subject:  Re: MMC5: Questions about how CHR bankswitch works.

What bankswitch basically does is as follows:
An average MMC1 cart allows for a maximum of 4K of CHR-ROM. However, for some games that won't be enough, so they use bankswitch mappers. What they do is let you have more then 4K of CHR-ROM, but there is still only 4K that is visible to PPU. In CHR-ROMs, a single bank is 4K, the maximum the PPU can see, so a Bankswitch Mapper basically switches what bank is visible to the PPU. I hope that made sense, if it didn't, feel free to private message me.

Author:  Revenant [ Mon Feb 20, 2017 12:20 pm ]
Post subject:  Re: MMC5: Questions about how CHR bankswitch works.

DementedPurple wrote:
What bankswitch basically does is as follows:
An average MMC1 cart allows for a maximum of 4K of CHR-ROM. However, for some games that won't be enough, so they use bankswitch mappers. What they do is let you have more then 4K of CHR-ROM, but there is still only 4K that is visible to PPU. In CHR-ROMs, a single bank is 4K, the maximum the PPU can see, so a Bankswitch Mapper basically switches what bank is visible to the PPU. I hope that made sense, if it didn't, feel free to private message me.

I'm pretty sure the OP already knows what bank switching is...

Author:  rainwarrior [ Mon Feb 20, 2017 12:50 pm ]
Post subject:  Re: MMC5: Questions about how CHR bankswitch works.

If you need some reference, you might try looking at open source emulators, e.g.:

Nintendulator: https://www.qmtpro.com/~nes/nintendulator/mapsrc42.zip
Nestopia: https://github.com/rdanbrook/nestopia/blob/master/source/core/board/NstBoardMmc5.cpp
FCEUX: https://sourceforge.net/p/fceultra/code/HEAD/tree/fceu/trunk/src/boards/mmc5.cpp

MMC5 is the most complicated mapper, and I'm sure its wiki page could use improvement. If you figure out what you were confused about and you think the wiki could explain it better, you might revise the wiki page yourself to help, or at least report here what you learned.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/