2013-11-04 00:36:15 +00:00
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
|
2013-11-14 13:15:41 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
2012-10-13 18:35:31 +00:00
|
|
|
|
{
|
|
|
|
|
// Creatom
|
|
|
|
|
// specs pulled from Nintendulator sources
|
2013-08-25 01:08:17 +00:00
|
|
|
|
public sealed class Mapper132 : NES.NESBoardBase
|
2012-10-13 18:35:31 +00:00
|
|
|
|
{
|
2016-09-13 11:50:07 +00:00
|
|
|
|
private ByteBuffer reg = new ByteBuffer(4);
|
|
|
|
|
|
2012-10-13 18:35:31 +00:00
|
|
|
|
//configuraton
|
|
|
|
|
int prg_mask, chr_mask;
|
|
|
|
|
//state
|
|
|
|
|
int prg, chr;
|
2016-09-11 15:16:49 +00:00
|
|
|
|
|
2016-09-15 17:22:20 +00:00
|
|
|
|
bool is172, is173;
|
2016-09-11 15:16:49 +00:00
|
|
|
|
|
2012-10-13 18:35:31 +00:00
|
|
|
|
public override bool Configure(NES.EDetectionOrigin origin)
|
|
|
|
|
{
|
|
|
|
|
switch (Cart.board_type)
|
|
|
|
|
{
|
|
|
|
|
case "MAPPER132":
|
2012-10-17 02:08:19 +00:00
|
|
|
|
case "UNIF_UNL-22211":
|
2012-10-13 18:35:31 +00:00
|
|
|
|
break;
|
2016-09-15 17:22:20 +00:00
|
|
|
|
case "MAPPER172":
|
|
|
|
|
is172 = true;
|
|
|
|
|
break;
|
2016-09-11 15:16:49 +00:00
|
|
|
|
case "MAPPER173":
|
|
|
|
|
is173 = true;
|
|
|
|
|
break;
|
2012-10-13 18:35:31 +00:00
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prg_mask = Cart.prg_size / 32 - 1;
|
|
|
|
|
chr_mask = Cart.chr_size / 8 - 1;
|
|
|
|
|
SetMirrorType(Cart.pad_h, Cart.pad_v);
|
2016-09-17 16:38:03 +00:00
|
|
|
|
//SetMirrorType(EMirrorType.Vertical);
|
2012-10-13 18:35:31 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 17:22:20 +00:00
|
|
|
|
public void sync(byte value)
|
2012-10-13 18:35:31 +00:00
|
|
|
|
{
|
2016-09-15 17:22:20 +00:00
|
|
|
|
prg=reg[2]>>2;
|
|
|
|
|
prg &= prg_mask;
|
2016-09-13 02:46:14 +00:00
|
|
|
|
|
2016-09-15 17:22:20 +00:00
|
|
|
|
if (is172)
|
|
|
|
|
{
|
2016-09-17 16:38:03 +00:00
|
|
|
|
chr = ((value ^ reg[2]) >> 3 & 2) | ((value ^ reg[2]) >> 5 & 1);
|
2016-09-15 17:22:20 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-09-13 02:46:14 +00:00
|
|
|
|
chr = (reg[2] & 0x3);
|
2016-09-15 17:22:20 +00:00
|
|
|
|
}
|
2016-09-13 02:46:14 +00:00
|
|
|
|
|
2016-09-15 17:22:20 +00:00
|
|
|
|
chr &= chr_mask;
|
2016-09-13 02:46:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WritePRG(int addr, byte value)
|
|
|
|
|
{
|
2016-09-15 17:22:20 +00:00
|
|
|
|
sync(value);
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WriteEXP(int addr, byte value)
|
|
|
|
|
{
|
2016-09-13 02:46:14 +00:00
|
|
|
|
if (addr <= 0x103 && addr >= 0x100)
|
2016-09-17 16:38:03 +00:00
|
|
|
|
reg[addr & 0x03] = value;
|
|
|
|
|
//reg[addr&0x03] = (byte)(value & 0x0f);
|
2016-09-13 02:46:14 +00:00
|
|
|
|
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte ReadEXP(int addr)
|
|
|
|
|
{
|
2016-09-13 02:46:14 +00:00
|
|
|
|
|
2016-09-17 16:38:03 +00:00
|
|
|
|
/*if ((addr & 0x100) != 0)
|
2016-09-13 02:46:14 +00:00
|
|
|
|
return (byte)((NES.DB & (is173 ? 0x01 : 0xf0)) | reg[2]);
|
2012-10-13 18:35:31 +00:00
|
|
|
|
else if ((addr & 0x1000) == 0)
|
|
|
|
|
return NES.DB;
|
|
|
|
|
else
|
|
|
|
|
return 0xff;
|
2016-09-17 16:38:03 +00:00
|
|
|
|
*/
|
|
|
|
|
if (addr==0x100)
|
|
|
|
|
return (byte)((reg[1] ^ reg[2]) | (0x40 | (is173 ? 0x01 : 0x00)));
|
|
|
|
|
else
|
|
|
|
|
return NES.DB;
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte ReadPRG(int addr)
|
|
|
|
|
{
|
2016-10-15 13:49:18 +00:00
|
|
|
|
// Xiao Ma Li (Ch) has 16k prg (mapped to both 0x8000 and 0xC000)
|
|
|
|
|
if (Cart.prg_size == 16)
|
|
|
|
|
{
|
|
|
|
|
return ROM[addr & 0x3FFF];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ROM[addr + ((prg & prg_mask) << 15)];
|
|
|
|
|
}
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte ReadPPU(int addr)
|
|
|
|
|
{
|
|
|
|
|
if (addr < 0x2000)
|
|
|
|
|
{
|
|
|
|
|
return VROM[addr + (chr << 13)];
|
|
|
|
|
}
|
2016-09-15 17:22:20 +00:00
|
|
|
|
|
|
|
|
|
return base.ReadPPU(addr);
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SyncState(Serializer ser)
|
|
|
|
|
{
|
|
|
|
|
base.SyncState(ser);
|
|
|
|
|
ser.Sync("chr", ref chr);
|
|
|
|
|
ser.Sync("prg", ref prg);
|
2016-09-15 17:22:20 +00:00
|
|
|
|
ser.Sync("is172", ref is172);
|
2016-09-11 15:16:49 +00:00
|
|
|
|
ser.Sync("is173", ref is173);
|
2016-09-13 11:50:07 +00:00
|
|
|
|
ser.Sync("reg", ref reg);
|
2012-10-13 18:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|