AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC2.cs
2024-06-28 18:08:25 +08:00

34 lines
1.1 KiB
C#

namespace AxibugEmuOnline.Client.UNES.Mapper
{
[MapperDef(Id = 9, Description = "Mike Tyson's Punch-Out!!")]
public class MMC2 : MMC4
{
public MMC2(Emulator emulator) : base(emulator)
{
}
public override void InitializeMemoryMap(CPU cpu)
{
base.InitializeMemoryMap(cpu);
cpu.MapReadHandler(0x8000, 0xBFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
cpu.MapReadHandler(0xA000, 0xFFFF, address => _prgROM[_prgROM.Length - 0x4000 - 0x2000 + (address - 0xA000)]);
cpu.MapWriteHandler(0xA000, 0xAFFF, (address, val) => _prgBankOffset = (val & 0xF) * 0x2000);
}
protected override void GetLatch(uint address, out uint latch, out bool? on)
{
base.GetLatch(address, out latch, out on);
// For MMC2, only 0xFD8 and 0xFE8 trigger the latch,
// not the whole range like in MMC4
if (latch == 0 && (address & 0x3) != 0)
{
on = null;
}
}
}
}