Implement mapper 221

This commit is contained in:
adelikat 2016-09-11 14:40:12 -04:00
parent 93148ebe9c
commit 907cd50b0d
2 changed files with 59 additions and 0 deletions

View File

@ -638,6 +638,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper213.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper214.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper218.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper221.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper222.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper225.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper226.cs" />

View File

@ -0,0 +1,58 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
public class Mapper221 : NES.NESBoardBase
{
IntBuffer regs = new IntBuffer(2);
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "MAPPER221":
case "UNIF_BMC-N625092":
break;
default:
return false;
}
return true;
}
public override void SyncState(Serializer ser)
{
ser.Sync("regs", ref regs);
base.SyncState(ser);
}
public override void WritePRG(int addr, byte value)
{
if (addr < 0x4000)
{
SetMirrorType(addr.Bit(0) ? EMirrorType.Horizontal : EMirrorType.Vertical);
regs[0] = addr >> 1 & 0xFF;
}
else
{
regs[1] = addr & 7;
}
}
public override byte ReadPRG(int addr)
{
int bank;
if (addr < 0x4000)
{
bank = (regs[0] >> 1 & 0x38) | ((regs[0].Bit(0)) ? ((regs[0] & 0x80) > 0) ? regs[1] : (regs[1] & 0x6) | 0x0 : regs[1]);
}
else
{
bank = (regs[0] >> 1 & 0x38) | ((regs[0].Bit(0) ? ((regs[0] & 0x80) > 0) ? 0x7 : (regs[1] & 0x6) | 0x1 : regs[1]));
}
return ROM[(bank << 14) + (addr & 0x3FFF)];
}
}
}