diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs index 9d7693473e..4404117e2c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs @@ -26,6 +26,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs index 621068c2ff..b1ac0da1c2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs @@ -40,6 +40,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + public override void Dispose() + { + prg_regs.Dispose(); + low.Dispose(); + chr_regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs index 725980d3d1..e3ccbe97ca 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs @@ -59,6 +59,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void Dispose() { prg_banks_16k.Dispose(); + chr_banks_8k.Dispose(); base.Dispose(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs index ac75860c43..143525ba20 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs @@ -56,6 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void Dispose() { prg_banks_16k.Dispose(); + chr_banks_8k.Dispose(); base.Dispose(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs index c0b23fd82d..eabd01323f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs @@ -23,6 +23,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs index 21a255b551..4b6b35f13d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs @@ -24,6 +24,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + EXPREGS.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs index cb2da9c60e..f150e98789 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs @@ -23,6 +23,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs index e347098559..ab619862db 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs @@ -1,37 +1,43 @@ -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Nintendo.NES -{ - public sealed class Mapper199 : MMC3Board_Base - { - private ByteBuffer exRegs = new ByteBuffer(4); - - public override bool Configure(NES.EDetectionOrigin origin) - { - switch (Cart.board_type) - { - case "MAPPER199": - break; - default: - return false; - } - - exRegs[0] = (byte)(Cart.prg_size / 8 - 2); - exRegs[1] = (byte)(Cart.prg_size / 8 - 1); - exRegs[2] = 1; - exRegs[3] = 3; - - BaseSetup(); - mmc3.MirrorMask = 3; - return true; - } - - public override void SyncState(Serializer ser) - { - base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class Mapper199 : MMC3Board_Base + { + private ByteBuffer exRegs = new ByteBuffer(4); + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER199": + break; + default: + return false; + } + + exRegs[0] = (byte)(Cart.prg_size / 8 - 2); + exRegs[1] = (byte)(Cart.prg_size / 8 - 1); + exRegs[2] = 1; + exRegs[3] = 3; + + BaseSetup(); + mmc3.MirrorMask = 3; + return true; } - + + public override void Dispose() + { + exRegs.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("exRegs", ref exRegs); + } + public override byte ReadPPU(int addr) { if (addr < 0x2000) @@ -167,28 +173,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.WritePPU(addr, value); } - protected override int Get_PRGBank_8K(int addr) - { - if (addr >= 0x4000 && addr < 0x6000) - { - return exRegs[0]; - } - else if (addr >= 0x6000) - { - return exRegs[1]; - } - - return base.Get_PRGBank_8K(addr); - } - - public override void WritePRG(int addr, byte value) - { - if ((addr == 1) && ((mmc3.cmd & 0x8) > 0)) - { - exRegs[mmc3.cmd & 3] = value; - } - else - base.WritePRG(addr, value); - } - } -} + protected override int Get_PRGBank_8K(int addr) + { + if (addr >= 0x4000 && addr < 0x6000) + { + return exRegs[0]; + } + else if (addr >= 0x6000) + { + return exRegs[1]; + } + + return base.Get_PRGBank_8K(addr); + } + + public override void WritePRG(int addr, byte value) + { + if ((addr == 1) && ((mmc3.cmd & 0x8) > 0)) + { + exRegs[mmc3.cmd & 3] = value; + } + else + base.WritePRG(addr, value); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs index 11a3fdbbd4..ff8961091e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs @@ -39,6 +39,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs index 83bdafa7fd..3496146d08 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs @@ -74,6 +74,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + prg_regs_8k.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs index e142867282..ed2a41300f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs @@ -1,34 +1,34 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; - -namespace BizHawk.Emulation.Cores.Nintendo.NES -{ - public sealed class Mapper217 : MMC3Board_Base - { - private ByteBuffer exRegs = new ByteBuffer(4); - +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class Mapper217 : MMC3Board_Base + { + private ByteBuffer exRegs = new ByteBuffer(4); + public ByteBuffer prg_regs_8k = new ByteBuffer(4); private int prg_mask_8k, chr_mask_1k; private byte[] regs_sec = { 0, 6, 3, 7, 5, 2, 4, 1 }; - public override bool Configure(NES.EDetectionOrigin origin) - { - switch (Cart.board_type) - { - case "MAPPER217": - break; - default: - return false; - } - - BaseSetup(); - - exRegs[0] = 0x00; - exRegs[1] = 0xFF; - exRegs[2] = 0x03; - exRegs[3] = 0x00; - + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER217": + break; + default: + return false; + } + + BaseSetup(); + + exRegs[0] = 0x00; + exRegs[1] = 0xFF; + exRegs[2] = 0x03; + exRegs[3] = 0x00; + prg_mask_8k = Cart.prg_size / 8 - 1; chr_mask_1k = Cart.chr_size - 1; @@ -36,19 +36,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_regs_8k[1] = 1; prg_regs_8k[2] = (byte)(0xFE & prg_mask_8k); prg_regs_8k[3] = (byte)(0xFF & prg_mask_8k); - - return true; - } - - public override void SyncState(Serializer ser) - { - base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - ser.Sync("ptg_regs_8k", ref prg_regs_8k); + + return true; + } + + public override void Dispose() + { + exRegs.Dispose(); + prg_regs_8k.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("exRegs", ref exRegs); + ser.Sync("ptg_regs_8k", ref prg_regs_8k); ser.Sync("prg_mask", ref prg_mask_8k); - ser.Sync("chr_mask", ref chr_mask_1k); - } - + ser.Sync("chr_mask", ref chr_mask_1k); + } + public void sync_prg() { int temp = 0; @@ -64,13 +71,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES temp |= (exRegs[1] << 5 & 0x60); prg_regs_8k[i] = (byte)(temp & prg_mask_8k); } - } - - public override void WriteEXP(int addr, byte value) - { - if (addr == 0x1000) - { - exRegs[0] = value; + } + + public override void WriteEXP(int addr, byte value) + { + if (addr == 0x1000) + { + exRegs[0] = value; if ((value & 0x80)>0) { int bank = (byte)((value & 0x0F) | (exRegs[1] << 4 & 0x30)); @@ -86,23 +93,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else { sync_prg(); - } - } - - else if (addr == 0x1001) - { - exRegs[1] = value; - sync_prg(); - } - - else if (addr == 0x1007) - { - exRegs[2] = value; - } - - base.WriteEXP(addr, value); - } - + } + } + + else if (addr == 0x1001) + { + exRegs[1] = value; + sync_prg(); + } + + else if (addr == 0x1007) + { + exRegs[2] = value; + } + + base.WriteEXP(addr, value); + } + public override void WritePRG(int addr, byte value) { switch ((addr + 0x8000) & 0xE001) @@ -175,8 +182,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr>=0x4000) base.WritePRG(addr, value); - } - + } + public override byte ReadPPU(int addr) { if (addr < 0x2000) @@ -192,14 +199,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return VROM[addr]; } else return base.ReadPPU(addr); - } - - + } + + public override byte ReadPRG(int addr) { int bank = addr >> 13; bank = prg_regs_8k[bank]; return ROM[(bank << 13) + (addr & 0x1FFF)]; - } - } -} + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs index bcd6112fd4..d2baf71db5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs @@ -21,6 +21,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs index 22c028b0d4..e8642c2aec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs @@ -40,6 +40,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + prg_regs_8k.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs index 389a6d243e..71704b5f9c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs @@ -32,6 +32,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg_banks_8k.Dispose(); + base.Dispose(); + } public override byte ReadPRG(int addr) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs index 6c0444a40f..05e81b9d21 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs @@ -39,6 +39,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + reg.Dispose(); + base.Dispose(); + } + public void sync(byte value) { prg=reg[2]>>2; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper142.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper142.cs index 794d4366b6..c976c8ab30 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper142.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper142.cs @@ -28,6 +28,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + reg.Dispose(); + base.Dispose(); + } + public override byte ReadWRAM(int addr) { return ROM[(reg[4] << 13) + (addr & 0x1FFF)]; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs index 31b6d8f4e3..99b153d352 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs @@ -27,6 +27,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + latch.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs index dc8789dba3..7427ae7c47 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs @@ -46,6 +46,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg_banks_8k.Dispose(); + chr_banks_8k.Dispose(); + base.Dispose(); + } + static readonly EMirrorType[] kMirrorTypes = {EMirrorType.Vertical,EMirrorType.Horizontal,EMirrorType.OneScreenA,EMirrorType.OneScreenB}; void SyncMirror() { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs index 59226d1422..c3f1610282 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs @@ -31,6 +31,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg_banks_32k.Dispose(); + base.Dispose(); + } + public override void WriteEXP(int addr, byte value) { switch (addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs index 8820a28f1e..acdbb7b7df 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs @@ -1,57 +1,64 @@ -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; using System; -namespace BizHawk.Emulation.Cores.Nintendo.NES -{ - // Adpated from FCEUX src - public sealed class Mapper183 : NES.NESBoardBase - { - private ByteBuffer prg = new ByteBuffer(4); - private ByteBuffer chr = new ByteBuffer(8); - +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Adpated from FCEUX src + public sealed class Mapper183 : NES.NESBoardBase + { + private ByteBuffer prg = new ByteBuffer(4); + private ByteBuffer chr = new ByteBuffer(8); + private int IRQLatch = 0; private int IRQCount = 0; private bool IRQMode; - private bool IRQa = false; - private bool IRQr = false; - - private int prg_bank_mask_8k, chr_bank_mask_1k, IRQPre=341; - - public override bool Configure(NES.EDetectionOrigin origin) - { - switch (Cart.board_type) - { - case "MAPPER183": - break; - default: - return false; - } - - prg_bank_mask_8k = Cart.prg_size / 8 - 1; - chr_bank_mask_1k = Cart.chr_size - 1; - - return true; - } - - public override void SyncState(Serializer ser) - { - base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); - } - - private void SetMirroring(int mirr) - { - switch (mirr & 3) - { - case 0: SetMirrorType(EMirrorType.Vertical); break; - case 1: SetMirrorType(EMirrorType.Horizontal); break; - case 2: SetMirrorType(EMirrorType.OneScreenA); break; - case 3: SetMirrorType(EMirrorType.OneScreenB); break; - } - } - + private bool IRQa = false; + private bool IRQr = false; + + private int prg_bank_mask_8k, chr_bank_mask_1k, IRQPre=341; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER183": + break; + default: + return false; + } + + prg_bank_mask_8k = Cart.prg_size / 8 - 1; + chr_bank_mask_1k = Cart.chr_size - 1; + + return true; + } + + public override void Dispose() + { + prg.Dispose(); + chr.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("prg", ref prg); + ser.Sync("chr", ref chr); + } + + private void SetMirroring(int mirr) + { + switch (mirr & 3) + { + case 0: SetMirrorType(EMirrorType.Vertical); break; + case 1: SetMirrorType(EMirrorType.Horizontal); break; + case 2: SetMirrorType(EMirrorType.OneScreenA); break; + case 3: SetMirrorType(EMirrorType.OneScreenB); break; + } + } + public override void ClockCPU() { if (IRQa) @@ -81,41 +88,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - } - - - - public override void WriteWRAM(int addr, byte value) - { - WriteReg(addr + 0x6000, value); - } - - public override void WritePRG(int addr, byte value) - { - WriteReg(addr + 0x8000, value); - } - - private void WriteReg(int addr, byte value) - { - if ((addr & 0xF800) == 0x6800) - { - prg[3] = (byte)(addr & 0x3F); - } - else if (((addr & 0xF80C) >= 0xB000) && ((addr & 0xF80C) <= 0xE00C)) - { - int index = (((addr >> 11) - 6) | (addr >> 3)) & 7; - chr[index] = (byte)((chr[index] & (0xF0 >> (addr & 4))) | ((value & 0x0F) << (addr & 4))); - } - else switch (addr & 0xF80C) - { - case 0x8800: prg[0] = value; break; - case 0xA800: prg[1] = value; break; - case 0xA000: prg[2] = value; break; + } + + + + public override void WriteWRAM(int addr, byte value) + { + WriteReg(addr + 0x6000, value); + } + + public override void WritePRG(int addr, byte value) + { + WriteReg(addr + 0x8000, value); + } + + private void WriteReg(int addr, byte value) + { + if ((addr & 0xF800) == 0x6800) + { + prg[3] = (byte)(addr & 0x3F); + } + else if (((addr & 0xF80C) >= 0xB000) && ((addr & 0xF80C) <= 0xE00C)) + { + int index = (((addr >> 11) - 6) | (addr >> 3)) & 7; + chr[index] = (byte)((chr[index] & (0xF0 >> (addr & 4))) | ((value & 0x0F) << (addr & 4))); + } + else switch (addr & 0xF80C) + { + case 0x8800: prg[0] = value; break; + case 0xA800: prg[1] = value; break; + case 0xA000: prg[2] = value; break; case 0x9800: SetMirroring(value & 3); break; // TODO: IRQ case 0xF000: IRQLatch = ((IRQLatch & 0xF0) | (value & 0xF)); break; - case 0xF004: IRQLatch = ((IRQLatch & 0x0F) | ((value & 0xF) << 4)); break; + case 0xF004: IRQLatch = ((IRQLatch & 0x0F) | ((value & 0xF) << 4)); break; case 0xF008: IRQMode = value.Bit(2); IRQa = value.Bit(1);//value>0 ? true:false; @@ -126,54 +133,54 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES IRQCount = IRQLatch; } IRQSignal = false; - break; + break; case 0xF00C: IRQSignal = false; IRQa = IRQr; break; - } - } - - public override byte ReadPPU(int addr) - { - if (addr < 0x2000) - { - int x = (addr >> 10) & 7; - int bank = (chr[x] & chr_bank_mask_1k) << 10; - return VROM[bank + (addr & 0x3FF)]; // TODO - } - - return base.ReadPPU(addr); - } - - public override byte ReadWRAM(int addr) + } + } + + public override byte ReadPPU(int addr) { - return ROM[(((prg[3] & prg_bank_mask_8k)) << 13) + (addr & 0x1FFF)]; - } - - public override byte ReadPRG(int addr) - { - int bank_8k; - if (addr < 0x2000) // 0x8000 - { - bank_8k = prg[0] & prg_bank_mask_8k; - - } - else if (addr < 0x4000) // 0xA000 - { - bank_8k = prg[1] & prg_bank_mask_8k; - } - else if (addr < 0x6000) // 0xC000 - { - bank_8k = prg[2] & prg_bank_mask_8k; - } - else - { - bank_8k = prg_bank_mask_8k; - } - - return ROM[(bank_8k << 13) + (addr & 0x1FFF)]; - } - } -} + if (addr < 0x2000) + { + int x = (addr >> 10) & 7; + int bank = (chr[x] & chr_bank_mask_1k) << 10; + return VROM[bank + (addr & 0x3FF)]; // TODO + } + + return base.ReadPPU(addr); + } + + public override byte ReadWRAM(int addr) + { + return ROM[(((prg[3] & prg_bank_mask_8k)) << 13) + (addr & 0x1FFF)]; + } + + public override byte ReadPRG(int addr) + { + int bank_8k; + if (addr < 0x2000) // 0x8000 + { + bank_8k = prg[0] & prg_bank_mask_8k; + + } + else if (addr < 0x4000) // 0xA000 + { + bank_8k = prg[1] & prg_bank_mask_8k; + } + else if (addr < 0x6000) // 0xC000 + { + bank_8k = prg[2] & prg_bank_mask_8k; + } + else + { + bank_8k = prg_bank_mask_8k; + } + + return ROM[(bank_8k << 13) + (addr & 0x1FFF)]; + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs index 77ae9596bc..51aa6e1286 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs @@ -20,6 +20,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + _SRAM.Dispose(); + regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { ser.Sync("SRAM", ref _SRAM); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs index c2435da69d..464944047e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs @@ -36,6 +36,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg_banks_16k.Dispose(); + base.Dispose(); + } + public override byte ReadPRG(int addr) { int bank_16k = addr >> 14; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs index 4823b5245c..7499234655 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs @@ -31,6 +31,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg_banks_32k.Dispose(); + base.Dispose(); + } + public override byte ReadEXP(int addr) { //some kind of magic number.. diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs index f9398c5298..3c92f064c0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs @@ -28,6 +28,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { ser.Sync("reg_addr", ref reg_addr); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs index 11f73e3025..365c7f9ee6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs @@ -82,7 +82,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - void SyncMap() + private void SyncMap() { ApplyMemoryMapMask(prg_bank_mask_8k, prg_banks_8k); ApplyMemoryMapMask(chr_bank_mask_2k, chr_banks_2k); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs index 55b533f218..52af4d130e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs @@ -34,6 +34,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + preg.Dispose(); + creg.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs index 5e3c9fc3b0..89bb8d6dc0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs @@ -31,6 +31,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + prg.Dispose(); + chrlo.Dispose(); + chrhi.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); @@ -148,9 +156,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } - return base.ReadPPU(addr); } + public override void WritePPU(int addr, byte value) { if (addr < 0x2000) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs index 02e711333b..361a5b3d31 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs @@ -23,6 +23,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + regs.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs index 887562f752..87c94d79cb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs @@ -32,6 +32,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SyncIRQ(); } + public override void Dispose() + { + prg_banks_16k.Dispose(); + chr_banks_2k.Dispose(); + base.Dispose(); + } + public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs index 75a165f3e4..9386a87c91 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs @@ -25,6 +25,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + regs.Dispose(); + base.Dispose(); + } + public override void WriteEXP(int addr, byte value) { if (addr >= 0x1000 && addr <= 0x1003) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs index 5651c23ca7..afef3e003d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs @@ -1,75 +1,81 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; using System; -namespace BizHawk.Emulation.Cores.Nintendo.NES -{ - // Adapted from FCEUX src - public sealed class UNIF_BMC_Ghostbusters63in1 : NES.NESBoardBase - { - private ByteBuffer reg = new ByteBuffer(2); - private readonly int[] banks = new [] { 0, 0, 524288, 1048576}; - private int bank; - - [MapperProp] - public bool Ghostbusters63in1_63set=true; - [MapperProp] - public int Ghostbusters63in1_chip_22_select; - - public override bool Configure(NES.EDetectionOrigin origin) - { - switch (Cart.board_type) - { - case "UNIF_BMC-Ghostbusters63in1": - break; - default: - return false; - } - - AutoMapperProps.Apply(this); - - return true; - } - - public override void SyncState(Serializer ser) - { - ser.Sync("reg", ref reg); - ser.Sync("bank", ref bank); - ser.Sync("bank", ref Ghostbusters63in1_63set); - ser.Sync("bank", ref Ghostbusters63in1_chip_22_select); - base.SyncState(ser); - } - - public override void WritePRG(int addr, byte value) - { - reg[addr & 1] = value; - - bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1); - - SetMirrorType(reg[0].Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal); - Console.WriteLine(reg[0]); - Console.WriteLine(reg[1]); - } - - public override byte ReadPRG(int addr) - { - //if (bank == 1) - //{ - // return NES.DB; - //} - - if (reg[0].Bit(5)) +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Adapted from FCEUX src + public sealed class UNIF_BMC_Ghostbusters63in1 : NES.NESBoardBase + { + private ByteBuffer reg = new ByteBuffer(2); + private readonly int[] banks = new [] { 0, 0, 524288, 1048576}; + private int bank; + + [MapperProp] + public bool Ghostbusters63in1_63set=true; + [MapperProp] + public int Ghostbusters63in1_chip_22_select; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_BMC-Ghostbusters63in1": + break; + default: + return false; + } + + AutoMapperProps.Apply(this); + + return true; + } + + public override void Dispose() + { + reg.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + ser.Sync("reg", ref reg); + ser.Sync("bank", ref bank); + ser.Sync("bank", ref Ghostbusters63in1_63set); + ser.Sync("bank", ref Ghostbusters63in1_chip_22_select); + base.SyncState(ser); + } + + public override void WritePRG(int addr, byte value) + { + reg[addr & 1] = value; + + bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1); + + SetMirrorType(reg[0].Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal); + Console.WriteLine(reg[0]); + Console.WriteLine(reg[1]); + } + + public override byte ReadPRG(int addr) + { + //if (bank == 1) + //{ + // return NES.DB; + //} + + if (reg[0].Bit(5)) { var offset=0; if (Ghostbusters63in1_63set) offset = banks[bank]; else offset = banks[Ghostbusters63in1_chip_22_select]; - - int b = (reg[0] & 0x1F); - return ROM[offset + (b << 14) + (addr & 0x3FFF)]; - } - else + + int b = (reg[0] & 0x1F); + return ROM[offset + (b << 14) + (addr & 0x3FFF)]; + } + else { var offset = 0; if (Ghostbusters63in1_63set) @@ -77,9 +83,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else offset = banks[Ghostbusters63in1_chip_22_select]; - int b = ((reg[0] >> 1) & 0x0F); - return ROM[offset + (b << 15) + addr]; - } - } - } -} + int b = ((reg[0] >> 1) & 0x0F); + return ROM[offset + (b << 15) + addr]; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs index 1d3bcbd36c..3f70692c66 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs @@ -15,7 +15,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private int prg_mask_8k, chr_mask_1k; - public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) @@ -69,6 +68,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + exRegs.Dispose(); + chr_regs_1k.Dispose(); + prg_regs_8k.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs index d576df6be2..8bd3ad0fdd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs @@ -1,52 +1,58 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; - -namespace BizHawk.Emulation.Cores.Nintendo.NES -{ - public sealed class UNIF_BMC_Super24in1SC03 : MMC3Board_Base - { - private ByteBuffer exRegs = new ByteBuffer(3); - private readonly int[] masko8 = { 63, 31, 15, 1, 3, 0, 0, 0 }; - public override bool Configure(NES.EDetectionOrigin origin) - { - switch (Cart.board_type) - { - case "UNIF_BMC-Super24in1SC03": - break; - default: - return false; - } - - BaseSetup(); - - exRegs[0] = 0x24; - exRegs[1] = 159; - exRegs[2] = 0; - - return true; - } - - public override void SyncState(Serializer ser) - { - base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - } - - public override void WriteEXP(int addr, byte value) - { - switch (addr) - { - case 0x1FF0: - exRegs[0] = value; break; - case 0x1FF1: - exRegs[1] = value; break; - case 0x1FF2: - exRegs[2] = value; break; - } - - base.WriteEXP(addr, value); - } - +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class UNIF_BMC_Super24in1SC03 : MMC3Board_Base + { + private ByteBuffer exRegs = new ByteBuffer(3); + private readonly int[] masko8 = { 63, 31, 15, 1, 3, 0, 0, 0 }; + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_BMC-Super24in1SC03": + break; + default: + return false; + } + + BaseSetup(); + + exRegs[0] = 0x24; + exRegs[1] = 159; + exRegs[2] = 0; + + return true; + } + + public override void Dispose() + { + exRegs.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("exRegs", ref exRegs); + } + + public override void WriteEXP(int addr, byte value) + { + switch (addr) + { + case 0x1FF0: + exRegs[0] = value; break; + case 0x1FF1: + exRegs[1] = value; break; + case 0x1FF2: + exRegs[2] = value; break; + } + + base.WriteEXP(addr, value); + } + public override byte ReadPRG(int addr) { int bank_8k = addr >> 13; @@ -56,8 +62,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES NV |= (exRegs[1] << 1); return ROM[(NV << 13) + (addr & 0x1FFF)]; - } - + } + public override byte ReadPPU(int addr) { if (addr < 0x2000) @@ -76,8 +82,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else return base.ReadPPU(addr); - } - + } + public override void WritePPU(int addr, byte value) { if (addr < 0x2000) @@ -95,6 +101,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else base.WritePPU(addr, value); - } - } -} + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs index 5f9d5447c5..ff6e12e7d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs @@ -94,4 +94,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return base.ReadPPU(addr); } } -} +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs index 56a2b73bcf..04df29aadc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs @@ -31,6 +31,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + chr.Dispose(); + base.Dispose(); + } + public override void SyncState(Serializer ser) { base.SyncState(ser);