BizHawk/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/AxROM.cs

103 lines
2.3 KiB
C#
Raw Normal View History

2011-02-28 09:39:24 +00:00
using System;
2011-03-01 09:32:12 +00:00
using System.IO;
2011-02-28 09:39:24 +00:00
using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo
2011-02-28 09:39:24 +00:00
{
//generally mapper7
public class AxROM : NES.NESBoardBase
{
2011-03-01 09:32:12 +00:00
//configuration
2011-02-28 09:39:24 +00:00
bool bus_conflict;
int vram_byte_mask;
2011-02-28 09:39:24 +00:00
int prg_mask;
2011-03-01 09:32:12 +00:00
//state
2011-02-28 09:39:24 +00:00
int prg;
public override bool Configure(NES.EDetectionOrigin origin)
2011-02-28 09:39:24 +00:00
{
//configure
switch (Cart.board_type)
2011-02-28 09:39:24 +00:00
{
case "MAPPER007":
bus_conflict = false;
break;
case "NES-ANROM": //marble madness
AssertPrg(128); AssertChr(0); AssertVram(8); AssertWram(0);
bus_conflict = false;
break;
case "NES-AN1ROM": //R.C. Pro-Am
AssertPrg(64); AssertChr(0); AssertVram(8); AssertWram(0);
bus_conflict = false;
break;
case "NES-AMROM": //time lord
AssertPrg(128); AssertChr(0); AssertVram(8); AssertWram(0);
bus_conflict = true;
break;
case "NES-AOROM": //battletoads
case "HVC-AOROM":
AssertPrg(128,256); AssertChr(0); AssertVram(8); AssertWram(0);
bus_conflict = true; //MAYBE. apparently it varies
break;
default:
return false;
2011-02-28 09:39:24 +00:00
}
prg_mask = (Cart.prg_size / 16) - 1;
vram_byte_mask = 8 * 1024 - 1; //these boards always have 8KB of VRAM
2011-03-02 03:05:28 +00:00
2011-02-28 10:16:07 +00:00
//it is necessary to write during initialization to set the mirroring
2011-02-28 09:39:24 +00:00
WritePRG(0, 0);
return true;
2011-02-28 09:39:24 +00:00
}
public override byte ReadPRG(int addr)
{
return ROM[addr + (prg << 14)];
2011-02-28 09:39:24 +00:00
}
public override void WritePRG(int addr, byte value)
{
if (ROM != null && bus_conflict) value = HandleNormalPRGConflict(addr,value);
2011-06-06 10:27:42 +00:00
int prg_bank = value & 7;
prg = (prg_bank * 2) & prg_mask;
2011-02-28 09:39:24 +00:00
if ((value & 0x10) == 0)
2011-04-18 22:35:40 +00:00
SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenA);
2011-02-28 09:39:24 +00:00
else
2011-04-18 22:35:40 +00:00
SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenB);
2011-02-28 09:39:24 +00:00
}
public override byte ReadPPU(int addr)
{
if (addr < 0x2000)
{
return VRAM[addr & vram_byte_mask];
2011-02-28 09:39:24 +00:00
}
else return base.ReadPPU(addr);
}
public override void WritePPU(int addr, byte value)
{
if (addr < 0x2000)
{
VRAM[addr & vram_byte_mask] = value;
2011-02-28 09:39:24 +00:00
}
else base.WritePPU(addr,value);
}
public override void SyncState(Serializer ser)
2011-03-01 09:32:12 +00:00
{
base.SyncState(ser);
ser.Sync("prg",ref prg);
2011-03-01 09:32:12 +00:00
}
2011-02-28 09:39:24 +00:00
}
}