diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs index 0d8035840a..8c0bf9a303 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs @@ -15,10 +15,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { var domains = new List { - //new MemoryDomainByteArray( - // "Main RAM", - // MemoryDomain.Endian.Little, - // Ram, true, 1), new MemoryDomainDelegate( "TIA", 16, @@ -39,13 +35,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 (addr, value) => _mapper.PokeMemory((ushort) addr, value), 1) }; - //if (_mapper is mDPC) // TODO: also mDPCPlus - //{ - // domains.Add(new MemoryDomainByteArray( - // "DPC", - // MemoryDomain.Endian.Little,(_mapper as mDPC).DspData, true, 1)); - //} - if (_mapper.HasCartRam) { domains.Add(new MemoryDomainDelegate( @@ -59,8 +48,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 SyncAllByteArrayDomains(); MemoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); - MemoryDomains.MainMemory = _byteArrayDomains["Main RAM"]; - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); _memoryDomainsInit = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs index 8ba1a19e69..97a064c057 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using BizHawk.Emulation.Common; @@ -8,13 +9,14 @@ namespace BizHawk.Emulation.Cores.ColecoVision public partial class ColecoVision { private MemoryDomainList memoryDomains; + private readonly Dictionary _byteArrayDomains = new Dictionary(); + private bool _memoryDomainsInit = false; private void SetupMemoryDomains() { - var domains = new List(3); - var MainMemoryDomain = new MemoryDomainByteArray("Main RAM", MemoryDomain.Endian.Little, Ram, true, 1); - var VRamDomain = new MemoryDomainByteArray("Video RAM", MemoryDomain.Endian.Little, VDP.VRAM, true, 1); - var SystemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, + var domains = new List + { + new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 65536) @@ -32,13 +34,35 @@ namespace BizHawk.Emulation.Cores.ColecoVision } Cpu.WriteMemory((ushort)addr, value); - }, 1); + }, 1) + }; - domains.Add(MainMemoryDomain); - domains.Add(VRamDomain); - domains.Add(SystemBusDomain); - memoryDomains = new MemoryDomainList(domains); + SyncAllByteArrayDomains(); + + memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); (ServiceProvider as BasicServiceProvider).Register(memoryDomains); + + _memoryDomainsInit = true; + } + + private void SyncAllByteArrayDomains() + { + SyncByteArrayDomain("Main RAM", Ram); + SyncByteArrayDomain("Video RAM", VDP.VRAM); + } + + private void SyncByteArrayDomain(string name, byte[] data) + { + if (_memoryDomainsInit) + { + var m = _byteArrayDomains[name]; + m.Data = data; + } + else + { + var m = new MemoryDomainByteArray(name, MemoryDomain.Endian.Little, data, true, 1); + _byteArrayDomains.Add(name, m); + } } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs index 1c9e8931fc..0f11d20682 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs @@ -64,6 +64,11 @@ namespace BizHawk.Emulation.Cores.ColecoVision ser.Sync("LagCount", ref _lagCount); ser.Sync("IsLag", ref _isLag); ser.EndSection(); + + if (ser.IsReader) + { + SyncAllByteArrayDomains(); + } } private byte[] _stateBuffer;