Implement the Ghostbusters63in1 unif board, sort of. Using mapper properties it can play both 22-in-1 carts and the 20-in-1 that are in the rom, but not actually the 63-in-1

This commit is contained in:
adelikat 2016-09-14 09:08:21 -04:00
parent c6a319763f
commit a9675d4a8f
2 changed files with 70 additions and 0 deletions

View File

@ -733,6 +733,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-A65AS.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-BS-5.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-D1038.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-Ghostbusters63in1.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-GS-2004.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-GS-2013.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\UNIF\UNIF_BMC-T-262.cs" />

View File

@ -0,0 +1,69 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// Adapted from FCEUX src
public sealed class UNIF_BMC_Ghostbusters63in1 : NES.NESBoardBase
{
private ByteBuffer reg = new ByteBuffer(2);
private readonly int[] banks = new [] { 0, 0, 524288, 1048576 };
private int bank;
[MapperProp]
public int Ghostbusters63in1_chip;
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "UNIF_BMC-Ghostbusters63in1":
break;
default:
return false;
}
AutoMapperProps.Apply(this);
return true;
}
public override void SyncState(Serializer ser)
{
ser.Sync("reg", ref reg);
ser.Sync("bank", ref bank);
ser.Sync("bank", ref Ghostbusters63in1_chip);
base.SyncState(ser);
}
public override void WritePRG(int addr, byte value)
{
reg[addr & 1] = value;
//bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1);
SetMirrorType(reg[0].Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
public override byte ReadPRG(int addr)
{
//if (bank == 1)
//{
// return NES.DB;
//}
if (reg[0].Bit(5))
{
var offset = (Ghostbusters63in1_chip % 3) * (1024 * 512);
int b = (reg[0] & 0x1F);
return ROM[offset + (b << 14) + (addr & 0x3FFF)];
}
else
{
var offset = (Ghostbusters63in1_chip % 3) * (1024 * 512);
int b = ((reg[0] >> 1) & 0x0F);
return ROM[offset + (b << 15) + addr];
}
}
}
}