2011-02-28 10:16:07 +00:00
|
|
|
using System;
|
2011-03-01 09:32:12 +00:00
|
|
|
using System.IO;
|
2011-02-28 10:16:07 +00:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
2011-03-08 07:25:35 +00:00
|
|
|
namespace BizHawk.Emulation.Consoles.Nintendo
|
2011-02-28 10:16:07 +00:00
|
|
|
{
|
|
|
|
//mapper 11
|
|
|
|
|
2011-03-01 09:32:12 +00:00
|
|
|
//Crystal Mines
|
|
|
|
//Metal Fighter
|
|
|
|
|
2011-02-28 10:16:07 +00:00
|
|
|
public class Discrete_74x377 : NES.NESBoardBase
|
|
|
|
{
|
2011-03-01 09:32:12 +00:00
|
|
|
//configuration
|
2011-02-28 10:16:07 +00:00
|
|
|
int prg_mask, chr_mask;
|
|
|
|
bool bus_conflict = true;
|
|
|
|
|
2011-03-01 09:32:12 +00:00
|
|
|
//state
|
|
|
|
int prg, chr;
|
|
|
|
|
2011-03-20 02:12:10 +00:00
|
|
|
public override bool Configure(NES.EDetectionOrigin origin)
|
2011-02-28 10:16:07 +00:00
|
|
|
{
|
2011-03-08 07:25:35 +00:00
|
|
|
switch (Cart.board_type)
|
2011-03-07 10:41:46 +00:00
|
|
|
{
|
|
|
|
case "COLORDREAMS-74*377":
|
2011-03-08 07:25:35 +00:00
|
|
|
AssertPrg(32,64,128); AssertChr(16,32,64,128); AssertVram(0); AssertWram(0);
|
2011-03-07 10:41:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2011-02-28 10:16:07 +00:00
|
|
|
|
2011-03-08 07:25:35 +00:00
|
|
|
prg_mask = (Cart.prg_size/8/2)-1;
|
|
|
|
chr_mask = (Cart.chr_size / 8 - 1);
|
2011-02-28 10:16:07 +00:00
|
|
|
|
2011-03-07 10:41:46 +00:00
|
|
|
return true;
|
2011-02-28 10:16:07 +00:00
|
|
|
}
|
|
|
|
public override byte ReadPRG(int addr)
|
|
|
|
{
|
2011-03-07 10:41:46 +00:00
|
|
|
return ROM[addr + (prg<<15)];
|
2011-02-28 10:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override byte ReadPPU(int addr)
|
|
|
|
{
|
|
|
|
if (addr < 0x2000)
|
|
|
|
{
|
2011-03-07 10:41:46 +00:00
|
|
|
return VROM[addr + (chr << 13)];
|
2011-02-28 10:16:07 +00:00
|
|
|
}
|
|
|
|
else return base.ReadPPU(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void WritePRG(int addr, byte value)
|
|
|
|
{
|
|
|
|
if (bus_conflict)
|
|
|
|
{
|
|
|
|
byte old_value = value;
|
|
|
|
value &= ReadPRG(addr);
|
|
|
|
Debug.Assert(old_value == value, "Found a test case of Discrete_74x377 bus conflict. please report.");
|
|
|
|
}
|
|
|
|
|
|
|
|
prg = (value & 3) & prg_mask;
|
|
|
|
chr = (value >> 4) & chr_mask;
|
|
|
|
}
|
2011-03-01 09:32:12 +00:00
|
|
|
|
|
|
|
public override void SaveStateBinary(BinaryWriter bw)
|
|
|
|
{
|
|
|
|
base.SaveStateBinary(bw);
|
|
|
|
bw.Write(chr);
|
|
|
|
bw.Write(prg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void LoadStateBinary(BinaryReader br)
|
|
|
|
{
|
|
|
|
base.LoadStateBinary(br);
|
|
|
|
chr = br.ReadInt32();
|
|
|
|
prg = br.ReadInt32();
|
|
|
|
}
|
2011-02-28 10:16:07 +00:00
|
|
|
}
|
|
|
|
}
|