NESHawk - fix mapper 60, including dipswitches

This commit is contained in:
adelikat 2015-08-24 22:49:57 -04:00
parent 254263c1df
commit ba8860b1c5
1 changed files with 36 additions and 14 deletions

View File

@ -1,4 +1,5 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
@ -6,7 +7,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
// http://wiki.nesdev.com/w/index.php/INES_Mapper_060
int reg = 0;
private int _reg;
private bool IsPrg16Mode { get { return _reg.Bit(7); } }
[MapperProp]
public int Mapper60_DipSwitch;
private const int DipSwitchMask = 3;
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
@ -17,39 +25,53 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return false;
}
AutoMapperProps.Apply(this);
return true;
}
public override void SyncState(Serializer ser)
{
ser.Sync("reg", ref reg);
base.SyncState(ser);
ser.Sync("_reg", ref _reg);
}
public override void NESSoftReset()
public override void WritePRG(int addr, byte value)
{
if (reg >= 3)
{
reg = 0;
}
else
{
reg++;
}
_reg = addr;
int mirr = ((_reg & 8) >> 3) ^ 1;
SetMirrorType(mirr > 0 ? EMirrorType.Vertical : EMirrorType.Horizontal);
}
public override byte ReadPRG(int addr)
{
addr &= 0x3FFF;
return ROM[addr + (reg * 0x4000)];
if ((_reg & 0x100) > 0)
{
return (byte)(Mapper60_DipSwitch & DipSwitchMask);
}
if (IsPrg16Mode)
{
int bank = (_reg >> 4) & 7;
return ROM[(bank * 0x4000) + (addr & 0x3FFF)];
}
else
{
int bank = (_reg >> 5) & 3;
return ROM[(bank * 0x8000) + (addr & 0x7FFF)];
}
}
public override byte ReadPPU(int addr)
{
if (addr < 0x2000)
{
return VROM[(reg * 0x2000) + addr];
return VROM[((_reg & 7) * 0x2000) + (addr & 0x1FFF)];
}
return base.ReadPPU(addr);
}
}