Closed Molorius closed 6 years ago
I will review and test it. The commit message should start with the system name "[NES]".
Looks good. I can take the patch as-is and add bitmasks to the map10_write (0x0f and 0x1f masks) later or you can include them in this pull request. Let me know which is preferred.
[edit] BTW, the pull request topic doesn't matter. Its the actual commit message in the pull request that should start with "[NES]".
I don't see where the bitmasks need to be applied, but feel free to add them.
My mistake, the commit message is now properly edited.
For future reference, this how I think it should be based on: https://wiki.nesdev.com/w/index.php/MMC4
/* Used when tile $FD/$FE is accessed */
static void mmc10_latchfunc(uint32 address, uint8 value)
{
if (0xFD == value || 0xFE == value)
{
if (!address)
{
latch[0] = value;
mmc_bankvrom(4, 0x0000, regs[value == 0xfd ? 0 : 1]);
}
else
{
latch[1] = value;
mmc_bankvrom(4, 0x1000, regs[value == 0xfd ? 2 : 3]);
}
}
}
/* mapper 10: MMC4 */
/* MMC4: Fire Emblem */
static void map10_write(uint32 address, uint8 value)
{
switch ((address & 0xF000) >> 12)
{
case 0xA:
mmc_bankrom(16, 0x8000, value & 0x0f);
break;
case 0xB:
regs[0] = value & 0x1f;
//if (0xFD == latch[0])
mmc_bankvrom(4, 0x0000, regs[0]);
break;
case 0xC:
regs[1] = value & 0x1f;
//if (0xFE == latch[0])
mmc_bankvrom(4, 0x0000, regs[1]);
break;
case 0xD:
regs[2] = value & 0x1f;
//if (0xFD == latch[1])
mmc_bankvrom(4, 0x1000, regs[2]);
break;
case 0xE:
regs[3] = value & 0x1f;
//if (0xFE == latch[1])
mmc_bankvrom(4, 0x1000, regs[3]);
break;
case 0xF:
if (value & 1)
ppu_mirror(0, 0, 1, 1); /* horizontal */
else
ppu_mirror(0, 1, 0, 1); /* vertical */
break;
default:
break;
}
}
There are only 3 games using this mapper: http://bootgod.dyndns.org:7777/search.php?ines=10
I will just include the patch as-is and others can refer back to this info.
Tested on an English patched "Fire Emblem (J).nes". I didn't test this very much, but there are no visible problems in the first area of the game.