diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 7d1049f76e..b9bb5cffe2 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -641,6 +641,7 @@ + Code diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs index 7d8d814c02..fa420c059c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs @@ -2,12 +2,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { + // Tetris Fily 6-in-1 (GS-2004) (U) [!] public class UNIF_BMC_GS_2004 : NES.NESBoardBase { private int _reg = 0xFF; private int _prgMask32k; - private int _wramPage; + private int _wramOffset; public override bool Configure(NES.EDetectionOrigin origin) { @@ -23,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES _prgMask32k = (Cart.prg_size - 8) / 32 - 1; // Last 8k of Prg goes into 6000-7FFF - _wramPage = ((Cart.prg_size - 8) / 32) * 0x8000; + _wramOffset = ((Cart.prg_size - 8) / 32) * 0x8000; SetMirrorType(EMirrorType.Vertical); @@ -50,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadWRAM(int addr) { - return ROM[_wramPage + (addr & 0x1FFF)]; + return ROM[_wramOffset + (addr & 0x1FFF)]; } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs new file mode 100644 index 0000000000..e39ad1cbab --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs @@ -0,0 +1,67 @@ +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Tetris Family 12-in-1 (GS-2013) [U][!] + // This cart is 2 ROMs in 1 + // Pretty much the UNIF_BMC-GS_2004 board, with more Rom tacked on + public class UNIF_BMC_GS_2013 : NES.NESBoardBase + { + private int _reg = 0xFF; + private bool _isRom2 = true; + + private int _prgMaskRom1 = 7; + private int _prgMaskRom2 = 1; + + private int _wramPage = 0x3E000; + private int _rom2Offset = 0x40000; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_BMC-GS-2013": + break; + default: + return false; + } + + SetMirrorType(EMirrorType.Vertical); + + return true; + } + + public override void NESSoftReset() + { + _reg = 0xFF; + _isRom2 = true; + base.NESSoftReset(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("reg", ref _reg); + ser.Sync("_isRom2", ref _isRom2); + + } + + public override void WritePRG(int addr, byte value) + { + _isRom2 = value.Bit(3); + _reg = value; + } + + public override byte ReadWRAM(int addr) + { + return ROM[_wramPage + (addr & 0x1FFF)]; + } + + public override byte ReadPRG(int addr) + { + int bank = _reg & (_isRom2 ? _prgMaskRom2 : _prgMaskRom1); + return ROM[(bank * 0x8000) + (addr & 0x7FFF) + (_isRom2 ? _rom2Offset : 0)]; + } + } +}