nes: implement mapper249: mmc3 plus "security features"

San Shi Liu Ji,
Shui Hu Zhuan,
Myth Struggle,
Duo Bao Xiao Ying Hao - Guang Ming yu An Hei Chuan Shuo
This commit is contained in:
goyuken 2012-11-14 16:41:33 +00:00
parent 00c4db8eeb
commit 631212ca4f
2 changed files with 65 additions and 0 deletions

View File

@ -315,6 +315,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\Mapper197.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\Mapper205.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\Mapper245.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\Mapper249.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\Mapper250.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\MMC3.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\MMC3_family\NES-QJ.cs" />

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.Emulation.Consoles.Nintendo
{
public class Mapper249 : MMC3Board_Base
{
bool piratecrap = false;
// mmc3 with pirate crap bolt on
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "MAPPER249":
break;
default:
return false;
}
AssertPrg(256, 512);
AssertChr(256);
Cart.wram_size = 8;
BaseSetup();
return true;
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("piratecrap", ref piratecrap);
}
public override void WriteEXP(int addr, byte value)
{
piratecrap = value.Bit(1);
}
protected override int Get_CHRBank_1K(int addr)
{
int v = base.Get_CHRBank_1K(addr);
if (piratecrap)
v = v & 3 | v >> 1 & 4 | v >> 4 & 8 | v >> 2 & 0x10 | v << 3 & 0x20 | v << 2 & 0xC0;
return v;
}
protected override int Get_PRGBank_8K(int addr)
{
int v = base.Get_PRGBank_8K(addr);
if (piratecrap)
{
if (v < 0x20)
v = v & 1 | v >> 3 & 2 | v >> 1 & 4 | v << 2 & 8 | v << 2 & 0x10;
else
{
v -= 0x20;
v = v & 3 | v >> 1 & 4 | v >> 4 & 8 | v >> 2 & 0x10 | v << 3 & 0x20 | v << 2 & 0xC0;
}
}
return v;
}
}
}