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

87 lines
1.7 KiB
C#
Raw Normal View History

using BizHawk.Common;
2013-11-14 13:15:41 +00:00
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
public sealed class Mapper231 : NES.NESBoardBase
{
/*
* Here are Disch's original notes:
========================
= Mapper 231 =
========================
Example Game:
--------------------------
20-in-1
Registers:
---------------------------
$8000-FFFF: A~[.... .... M.LP PPP.]
M = Mirroring (0=Vert, 1=Horz)
L = Low bit of PRG
P = High bits of PRG
PRG Setup:
---------------------------
Note that 'L' and 'P' bits make up the PRG reg, and the 'L' is the low bit.
$8000 $A000 $C000 $E000
+---------------+---------------+
| $8000 AND $1E | $8000 |
+---------------+---------------+
*/
2012-07-17 06:24:36 +00:00
public int prg_reg;
public int prg_bank_mask_16k;
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "MAPPER231":
break;
default:
return false;
}
prg_bank_mask_16k = Cart.prg_size / 16 - 1;
return true;
}
public override void SyncState(Serializer ser)
{
2012-07-17 06:24:36 +00:00
ser.Sync("prg_reg", ref prg_reg);
base.SyncState(ser);
}
public override void WritePRG(int addr, byte value)
{
if (addr.Bit(7))
{
SetMirrorType(EMirrorType.Horizontal);
}
else
{
SetMirrorType(EMirrorType.Vertical);
}
2012-07-17 06:24:36 +00:00
int prg_reg_P = (addr >> 1) & 0xF;
int prg_reg_L = (addr >> 5) & 1;
prg_reg = (prg_reg_P<<1) | prg_reg_L;
prg_reg &= prg_bank_mask_16k;
}
public override byte ReadPRG(int addr)
{
2013-02-24 20:17:12 +00:00
int bank = prg_reg;
return ROM[(bank << 14) + addr - 0x4000];
}
}
}