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

69 lines
1.3 KiB
C#
Raw Normal View History

using System;
2011-03-01 09:32:12 +00:00
using System.IO;
using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo
{
//generally mapper3
2011-03-01 09:32:12 +00:00
//Solomon's Key
//Arkanoid
//Arkista's Ring
//Bump 'n' Jump
//Cybernoid
public class CNROM : NES.NESBoardBase
{
2011-03-01 09:32:12 +00:00
//configuration
int prg_mask,chr_mask;
2011-03-01 09:32:12 +00:00
bool bus_conflict;
//state
int chr;
public override bool Configure(NES.EDetectionOrigin origin)
{
//configure
switch (Cart.board_type)
{
case "NES-CNROM": //adventure island
case "HVC-CNROM":
AssertPrg(16, 32); AssertChr(8,16,32);
break;
default:
return false;
}
prg_mask = (Cart.prg_size / 16) - 1;
chr_mask = (Cart.chr_size / 8) - 1;
SetMirrorType(Cart.pad_h, Cart.pad_v);
bus_conflict = true;
return true;
}
public override void WritePRG(int addr, byte value)
{
2011-02-28 10:48:18 +00:00
if (bus_conflict) value = HandleNormalPRGConflict(addr,value);
chr = value&chr_mask;
2011-02-28 10:16:07 +00:00
//Console.WriteLine("at {0}, set chr={1}", NES.ppu.ppur.status.sl, chr);
}
public override byte ReadPPU(int addr)
{
if (addr < 0x2000)
{
return VROM[addr + (chr<<13)];
}
else return base.ReadPPU(addr);
}
public override void SyncState(Serializer ser)
2011-03-01 09:32:12 +00:00
{
base.SyncState(ser);
ser.Sync("chr",ref chr);
2011-03-01 09:32:12 +00:00
}
}
}