BizHawk/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs

84 lines
1.8 KiB
C#
Raw Normal View History

using BizHawk.Common;
2013-11-14 13:15:41 +00:00
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//AKA half of mapper 034 (the other half is AVE_NINA_001 which is entirely different..)
public sealed class BxROM : NES.NESBoardBase
{
//configuration
int prg_bank_mask_32k;
2017-05-26 22:24:21 +00:00
int chr_bank_mask_8k;
//state
int prg_bank_32k;
2017-05-26 22:24:21 +00:00
int chr_bank_8k;
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("prg_bank_32k", ref prg_bank_32k);
2017-05-26 22:24:21 +00:00
ser.Sync("chr_bank_8k", ref chr_bank_8k);
}
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
2014-01-23 23:32:53 +00:00
case "AVE-NINA-07": // wally bear and the gang
// it's not the NINA_001 but something entirely different; actually a colordreams with VRAM
// this actually works
2017-05-26 22:24:21 +00:00
AssertPrg(32,128); AssertChr(0,16); AssertWram(0); AssertVram(0,8);
2014-01-23 23:32:53 +00:00
break;
case "IREM-BNROM": //Mashou (J).nes
case "NES-BNROM": //Deadly Towers (U)
2017-06-08 01:35:18 +00:00
AssertPrg(128,256); AssertChr(0); AssertWram(0,8); AssertVram(8);
break;
default:
return false;
}
prg_bank_mask_32k = Cart.prg_size / 32 - 1;
2017-05-26 22:24:21 +00:00
chr_bank_mask_8k = Cart.chr_size / 8 - 1;
SetMirrorType(Cart.pad_h, Cart.pad_v);
return true;
}
public override byte ReadPRG(int addr)
{
addr |= (prg_bank_32k << 15);
return ROM[addr];
}
public override void WritePRG(int addr, byte value)
{
value = HandleNormalPRGConflict(addr, value);
prg_bank_32k = value & prg_bank_mask_32k;
2017-05-26 22:24:21 +00:00
chr_bank_8k = ((value >> 4) & 0xF) & chr_bank_mask_8k;
}
public override byte ReadPPU(int addr)
{
if (addr<0x2000)
{
if (VRAM != null)
{
2017-06-10 00:43:02 +00:00
return VRAM[addr];
2017-05-26 22:24:21 +00:00
}
else
{
return VROM[addr | (chr_bank_8k << 13)];
}
}
else
{
return base.ReadPPU(addr);
}
}
}
2017-06-08 01:35:18 +00:00
}