2011-02-28 09:13:27 +00:00
|
|
|
using System;
|
2013-11-04 00:36:15 +00:00
|
|
|
using BizHawk.Common;
|
2011-02-28 09:13:27 +00:00
|
|
|
|
2013-11-14 13:15:41 +00:00
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
2011-02-28 09:13:27 +00:00
|
|
|
{
|
2011-06-13 09:55:25 +00:00
|
|
|
//generally mapper 3
|
2011-02-28 09:13:27 +00:00
|
|
|
|
2011-03-01 09:32:12 +00:00
|
|
|
//Solomon's Key
|
|
|
|
//Arkanoid
|
|
|
|
//Arkista's Ring
|
|
|
|
//Bump 'n' Jump
|
|
|
|
//Cybernoid
|
|
|
|
|
2012-10-17 00:25:46 +00:00
|
|
|
[NES.INESBoardImplPriority]
|
2013-08-25 01:08:17 +00:00
|
|
|
public sealed class CNROM : NES.NESBoardBase
|
2011-02-28 09:13:27 +00:00
|
|
|
{
|
2011-03-01 09:32:12 +00:00
|
|
|
//configuration
|
2014-01-11 02:59:39 +00:00
|
|
|
int prg_byte_mask, chr_mask;
|
|
|
|
bool copyprotection = false;
|
2011-03-01 09:32:12 +00:00
|
|
|
bool bus_conflict;
|
2016-11-02 16:13:26 +00:00
|
|
|
bool seicross;
|
2011-03-01 09:32:12 +00:00
|
|
|
|
|
|
|
//state
|
|
|
|
int chr;
|
2014-01-11 02:59:39 +00:00
|
|
|
bool chr_enabled = true;
|
2011-03-01 09:32:12 +00:00
|
|
|
|
2011-03-20 02:12:10 +00:00
|
|
|
public override bool Configure(NES.EDetectionOrigin origin)
|
2011-02-28 09:13:27 +00:00
|
|
|
{
|
2011-03-07 10:41:46 +00:00
|
|
|
//configure
|
2011-03-08 07:25:35 +00:00
|
|
|
switch (Cart.board_type)
|
2011-03-07 10:41:46 +00:00
|
|
|
{
|
2013-02-19 02:52:32 +00:00
|
|
|
case "MAPPER185":
|
2014-01-11 02:59:39 +00:00
|
|
|
case "HVC-CNROM+SECURITY":
|
2016-10-15 12:58:11 +00:00
|
|
|
case "HVC-CNROM-256K-01":
|
2014-01-11 02:59:39 +00:00
|
|
|
copyprotection = true;
|
|
|
|
bus_conflict = true;
|
|
|
|
AssertPrg(16, 32); AssertChr(8);
|
|
|
|
break;
|
2012-03-22 06:20:10 +00:00
|
|
|
case "MAPPER003":
|
2012-06-24 17:39:12 +00:00
|
|
|
//we assume no bus conflicts for generic unknown cases.
|
|
|
|
//this was done originally to support Colorful Dragon (Unl) (Sachen) which bugs out if bus conflicts are emulated
|
|
|
|
//Games which behave otherwise will force us to start entering these in the game DB
|
|
|
|
//Licensed titles below are more likely to have used the same original discrete logic design and so suffer from the conflicts
|
|
|
|
bus_conflict = false;
|
2014-01-11 02:59:39 +00:00
|
|
|
AssertPrg(8, 16, 32);
|
2012-03-22 06:20:10 +00:00
|
|
|
break;
|
2014-01-11 02:59:39 +00:00
|
|
|
|
2011-03-08 07:25:35 +00:00
|
|
|
case "NES-CNROM": //adventure island
|
2012-10-17 02:08:19 +00:00
|
|
|
case "UNIF_NES-CNROM": // some of these should be bus_conflict = false because UNIF is bad
|
2011-03-07 10:41:46 +00:00
|
|
|
case "HVC-CNROM":
|
2014-01-15 17:00:02 +00:00
|
|
|
case "TAITO-CNROM":
|
|
|
|
case "BANDAI-CNROM":
|
2014-01-23 23:08:56 +00:00
|
|
|
case "BANDAI-74*161/32": // untested
|
2012-06-24 17:39:12 +00:00
|
|
|
bus_conflict = true;
|
2014-01-11 02:59:39 +00:00
|
|
|
AssertPrg(16, 32);
|
2011-03-07 10:41:46 +00:00
|
|
|
break;
|
2011-11-13 09:18:14 +00:00
|
|
|
case "KONAMI-CNROM": //gradius (J)
|
2012-06-24 17:39:12 +00:00
|
|
|
bus_conflict = true;
|
2011-11-13 09:18:14 +00:00
|
|
|
AssertPrg(32); AssertChr(32);
|
|
|
|
break;
|
2012-03-10 13:40:36 +00:00
|
|
|
case "AVE-74*161":
|
2012-06-24 17:39:12 +00:00
|
|
|
bus_conflict = true;
|
2012-03-10 13:40:36 +00:00
|
|
|
AssertPrg(32); AssertChr(64);
|
|
|
|
break;
|
2014-01-23 23:08:56 +00:00
|
|
|
case "NTDEC-N715062": // untested
|
|
|
|
case "NTDEC-N715061": // untested
|
|
|
|
bus_conflict = true;
|
|
|
|
AssertPrg(16, 32); AssertChr(8, 16, 32);
|
|
|
|
break;
|
|
|
|
|
2014-01-24 03:05:41 +00:00
|
|
|
case "BANDAI-PT-554": // untested
|
|
|
|
// as seen on nescartdb, this board clearly has one of those audio sample chips on it,
|
|
|
|
// but we don't implement that
|
|
|
|
AssertPrg(32); AssertChr(32);
|
|
|
|
bus_conflict = true;
|
|
|
|
break;
|
|
|
|
|
2014-01-23 23:08:56 +00:00
|
|
|
case "NAMCOT-CNROM+WRAM": // untested
|
|
|
|
AssertPrg(32); AssertChr(32); AssertWram(2);
|
|
|
|
break;
|
2011-03-07 10:41:46 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-01 16:58:01 +00:00
|
|
|
if (Cart.pcb == "9011-N02") // othello
|
2011-09-25 03:28:35 +00:00
|
|
|
copyprotection = true;
|
2014-01-11 02:59:39 +00:00
|
|
|
prg_byte_mask = Cart.prg_size * 1024 - 1;
|
2011-03-08 07:25:35 +00:00
|
|
|
chr_mask = (Cart.chr_size / 8) - 1;
|
|
|
|
SetMirrorType(Cart.pad_h, Cart.pad_v);
|
2011-03-07 10:41:46 +00:00
|
|
|
|
2016-11-02 16:13:26 +00:00
|
|
|
if (Cart.sha1 == "sha1:4C9C05FAD6F6F33A92A27C2EDC1E7DE12D7F216D")
|
|
|
|
seicross = true;
|
|
|
|
|
2011-03-07 10:41:46 +00:00
|
|
|
return true;
|
2011-02-28 09:13:27 +00:00
|
|
|
}
|
2014-01-11 02:59:39 +00:00
|
|
|
|
2011-02-28 09:13:27 +00:00
|
|
|
public override void WritePRG(int addr, byte value)
|
|
|
|
{
|
2014-01-11 02:59:39 +00:00
|
|
|
if (bus_conflict)
|
|
|
|
value = HandleNormalPRGConflict(addr, value);
|
|
|
|
|
|
|
|
chr = value & chr_mask;
|
2011-09-25 03:28:35 +00:00
|
|
|
|
|
|
|
if (copyprotection)
|
|
|
|
{
|
2016-11-02 16:13:26 +00:00
|
|
|
if (seicross)
|
2011-09-25 03:28:35 +00:00
|
|
|
{
|
2016-11-02 16:13:26 +00:00
|
|
|
if (value != 0x21)
|
|
|
|
{
|
|
|
|
chr_enabled = true;
|
|
|
|
Console.WriteLine("chr enabled");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chr_enabled = false;
|
|
|
|
Console.WriteLine("chr disabled");
|
|
|
|
}
|
2011-09-25 03:28:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-02 16:13:26 +00:00
|
|
|
if ((value & 0x0F) > 0 && (value != 0x13))
|
|
|
|
{
|
|
|
|
chr_enabled = true;
|
|
|
|
Console.WriteLine("chr enabled");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chr_enabled = false;
|
|
|
|
Console.WriteLine("chr disabled");
|
|
|
|
}
|
2011-09-25 03:28:35 +00:00
|
|
|
}
|
2016-11-02 16:13:26 +00:00
|
|
|
|
2011-09-25 03:28:35 +00:00
|
|
|
}
|
2011-02-28 09:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override byte ReadPPU(int addr)
|
|
|
|
{
|
2011-09-25 03:28:35 +00:00
|
|
|
if (chr_enabled == false)
|
|
|
|
{
|
|
|
|
return 0x12;
|
|
|
|
}
|
2011-02-28 09:13:27 +00:00
|
|
|
if (addr < 0x2000)
|
|
|
|
{
|
2014-01-11 02:59:39 +00:00
|
|
|
return VROM[addr + (chr << 13)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return base.ReadPPU(addr);
|
2011-02-28 09:13:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 22:51:53 +00:00
|
|
|
public override void SyncState(Serializer ser)
|
2011-03-01 09:32:12 +00:00
|
|
|
{
|
2011-04-17 22:51:53 +00:00
|
|
|
base.SyncState(ser);
|
2014-01-11 02:59:39 +00:00
|
|
|
ser.Sync("chr", ref chr);
|
2016-11-02 16:13:26 +00:00
|
|
|
ser.Sync("seicross", ref seicross);
|
2014-01-11 02:59:39 +00:00
|
|
|
ser.Sync("chr_enabled", ref chr_enabled);
|
2011-03-01 09:32:12 +00:00
|
|
|
}
|
2011-02-28 09:13:27 +00:00
|
|
|
|
2013-02-19 02:52:32 +00:00
|
|
|
public override byte ReadPRG(int addr)
|
|
|
|
{
|
2014-01-11 02:59:39 +00:00
|
|
|
return ROM[addr & prg_byte_mask];
|
2013-02-19 02:52:32 +00:00
|
|
|
}
|
2011-02-28 09:13:27 +00:00
|
|
|
}
|
2014-01-11 02:59:39 +00:00
|
|
|
}
|