NESHawk: Update Mapper 114

This commit is contained in:
alyosha-tas 2017-10-31 10:36:00 -04:00 committed by GitHub
parent dda86fce90
commit ec848f2c43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 67 additions and 64 deletions

View File

@ -1,60 +1,63 @@
using BizHawk.Common;
using BizHawk.Common;
using System;
namespace BizHawk.Emulation.Cores.Nintendo.NES
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// Mapper for Aladdin Super Game
public sealed class Mapper114 : MMC3Board_Base
{
private ByteBuffer EXPREGS = new ByteBuffer(2);
private byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 };
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
public sealed class Mapper114 : MMC3Board_Base
{
private ByteBuffer EXPREGS = new ByteBuffer(2);
private int prg_mask_16;
private byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 };
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "MAPPER114":
break;
default:
return false;
}
BaseSetup();
SetMirrorType(EMirrorType.Horizontal);
mmc3.MMC3Type = MMC3.EMMC3Type.MMC3A;
return true;
}
public override void Dispose()
{
EXPREGS.Dispose();
base.Dispose();
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("expregs", ref EXPREGS);
}
public override void WriteEXP(int addr, byte value)
break;
default:
return false;
}
BaseSetup();
SetMirrorType(EMirrorType.Horizontal);
mmc3.MMC3Type = MMC3.EMMC3Type.MMC3A;
prg_mask_16 = Cart.prg_size / 16 - 1;
return true;
}
public override void Dispose()
{
if ((addr & 0x7) == 0 && addr >= 0x1000)
{
EXPREGS[0] = value;
}
}
public override void WriteWRAM(int addr, byte value)
EXPREGS.Dispose();
base.Dispose();
}
public override void SyncState(Serializer ser)
{
if ((addr & 0x7) == 0)
{
EXPREGS[0] = value;
}
}
public override void WritePRG(int addr, byte value)
base.SyncState(ser);
ser.Sync("expregs", ref EXPREGS);
}
public override void WriteEXP(int addr, byte value)
{
if ((addr & 0x7) == 0 && addr >= 0x1000)
{
EXPREGS[0] = value;
}
}
public override void WriteWRAM(int addr, byte value)
{
if ((addr & 0x7) == 0)
{
EXPREGS[0] = value;
}
}
public override void WritePRG(int addr, byte value)
{
switch (addr & 0x6000)
{
@ -85,20 +88,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
base.WritePRG(0x6000, value);
}
break;
}
}
public override byte ReadPRG(int addr)
{
if ((EXPREGS[0] & 0x80) > 0)
}
}
public override byte ReadPRG(int addr)
{
if ((EXPREGS[0] & 0x80) > 0)
{
var bank = (EXPREGS[0] & 0x1F);
return ROM[(bank << 14) + (addr & 0x3FFF)];
}
else
var bank = EXPREGS[0] & 0x1F & prg_mask_16;
return ROM[(bank << 14) + (addr & 0x3FFF)];
}
else
{
return base.ReadPRG(addr);
}
}
}
return base.ReadPRG(addr);
}
}
}
}