NesHawk - Mapper 204 implemented

This commit is contained in:
adelikat 2015-08-21 22:58:18 -04:00
parent f72875b584
commit 1916ba0042
2 changed files with 62 additions and 0 deletions

View File

@ -547,6 +547,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper201.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper202.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper203.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper204.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper218.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper222.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper225.cs" />

View File

@ -0,0 +1,61 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// 64-in-1
// http://wiki.nesdev.com/w/index.php/INES_Mapper_204
public class Mapper204 : NES.NESBoardBase
{
private int _reg1, _reg2;
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "MAPPER204":
break;
default:
return false;
}
return true;
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("reg1", ref _reg1);
ser.Sync("reg2", ref _reg2);
}
public override void WritePRG(int addr, byte value)
{
_reg1 = addr & 0x6;
_reg2 = _reg1 + ((_reg1 == 0x6) ? 0 : (addr & 1));
_reg1 = _reg1 + ((_reg1 == 0x6) ? 1 : (addr & 1));
SetMirrorType(addr.Bit(0) ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
public override byte ReadPRG(int addr)
{
if (addr < 0x4000)
{
return ROM[(_reg2 * 0x4000) + (addr & 0x3FFF)];
}
return ROM[(_reg1 * 0x4000) + (addr & 0x3FFF)];
}
public override byte ReadPPU(int addr)
{
if (addr < 0x2000)
{
return VROM[(_reg2 * 0x2000) + (addr & 0x1FFF)];
}
return base.ReadPPU(addr);
}
}
}