diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs index 862699e97d..0f1987ea69 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs @@ -21,6 +21,9 @@ namespace BizHawk CoreComm = comm; var domains = new List(1); domains.Add(new MemoryDomain("Main RAM", 128, Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value)); + domains.Add(new MemoryDomain("TIA", 16, Endian.Little, addr => tia.ReadMemory((ushort)addr, true), (addr, value) => tia.WriteMemory((ushort)addr, value))); + domains.Add(new MemoryDomain("PIA", 1024, Endian.Little, addr => m6532.ReadMemory((ushort)addr, true), (addr, value) => m6532.WriteMemory((ushort)addr, value))); + domains.Add(new MemoryDomain("System Bus", 8192, Endian.Little, addr => mapper.PeekMemory((ushort)addr), (addr, value) => {})); memoryDomains = domains.AsReadOnly(); CoreComm.CpuTraceAvailable = true; this.rom = rom; diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m2K.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m2K.cs index 1ab0901aff..607baa68cf 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m2K.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m2K.cs @@ -15,6 +15,11 @@ namespace BizHawk if (addr < 0x1000) return base.ReadMemory(addr); return core.rom[addr & 0x7FF]; } + + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } } } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3E.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3E.cs index 52f9e52888..e918651fff 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3E.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3E.cs @@ -78,6 +78,39 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 return base.ReadMemory(addr); } + public override byte PeekMemory(ushort addr) + { + if (addr < 0x1000) + { + return base.ReadMemory(addr); + } + else if (addr < 0x17FF) //Low 2k Bank + { + if (hasRam) + { + if (addr < 0x13FF) + { + return ram[(addr & 0x03FF) + (rambank_1k << 10)]; + } + else + { + return ram[(addr & 0x03FF) + (rambank_1k << 10)]; //Reading from the write port triggers an unwanted write + } + } + else + { + int a = addr & 0x07FF; //2K + int bank = lowbank_2k << 11; + return core.rom[bank + a]; + } + } + else if (addr < 0x2000) //High bank fixed to last 2k of ROM + { + return core.rom[(core.rom.Length - 2048) + (addr & 0x07FF)]; + } + return base.ReadMemory(addr); + } + public override void WriteMemory(ushort addr, byte value) { if (addr < 0x1000) diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3F.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3F.cs index c39d89ecbd..c9f8f2d7e3 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3F.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m3F.cs @@ -53,6 +53,11 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 return base.ReadMemory(addr); } + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } + public override void WriteMemory(ushort addr, byte value) { if (addr < 0x0040) diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4A50.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4A50.cs index ef9cb7aac2..9103f74536 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4A50.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4A50.cs @@ -45,6 +45,11 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 private ByteBuffer myRAM = new ByteBuffer(32768); + public override byte PeekMemory(ushort addr) + { + return base.PeekMemory(addr); //TODO + } + public override byte ReadMemory(ushort addr) { byte val = 0; diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4K.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4K.cs index aa604e90de..5724be4e12 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4K.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/m4K.cs @@ -15,6 +15,11 @@ namespace BizHawk if (addr < 0x1000) return base.ReadMemory(addr); return core.rom[addr & 0xFFF]; } + + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } } } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs index b2eacae9dc..1b36964f2f 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mCV.cs @@ -33,6 +33,12 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 return core.rom[(addr & 0x7FF)]; else return base.ReadMemory(addr); } + + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } + public override void WriteMemory(ushort addr, byte value) { if (addr < 0x1000) diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mDPC.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mDPC.cs index 584429e9b6..22ea62f324 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mDPC.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mDPC.cs @@ -20,6 +20,11 @@ namespace BizHawk bool[] MusicMode = new bool[3]; //TOOD: savestates + public override byte PeekMemory(ushort addr) + { + return base.PeekMemory(addr); //TODO + } + public override byte ReadMemory(ushort addr) { if (addr < 0x1000) diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE0.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE0.cs index 554d72aa29..d131860c64 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE0.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE0.cs @@ -31,17 +31,32 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 int toggle1 = 0; int toggle2 = 0; int toggle3 = 0; - - public override byte ReadMemory(ushort addr) + + private byte ReadMem(ushort addr, bool peek) { - Address(addr); + if (!peek) + { + Address(addr); + } + if (addr < 0x1000) return base.ReadMemory(addr); else if (addr < 0x1400) return core.rom[toggle1 * 1024 + (addr & 0x3FF)]; else if (addr < 0x1800) return core.rom[toggle2 * 1024 + (addr & 0x3FF)]; else if (addr < 0x1C00) return core.rom[toggle3 * 1024 + (addr & 0x3FF)]; - else + else return core.rom[7 * 1024 + (addr & 0x3FF)]; //7 because final bank is always set to last } + + public override byte ReadMemory(ushort addr) + { + return ReadMem(addr, false); + } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE7.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE7.cs index db74fc619e..eaafe98a9b 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE7.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mE7.cs @@ -38,14 +38,18 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 ByteBuffer rambank1 = new ByteBuffer(1024); bool EnableRam0 = false; - public override byte ReadMemory(ushort addr) + private byte ReadMem(ushort addr, bool peek) { if (addr < 0x1000) { return base.ReadMemory(addr); } - Address(addr); + if (!peek) + { + Address(addr); + } + if (addr < 0x1800) { if (EnableRam0) @@ -84,6 +88,17 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 return base.ReadMemory(addr); } } + + public override byte ReadMemory(ushort addr) + { + return ReadMem(addr, false); + } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mEF.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mEF.cs index 6c27803a02..62831a4531 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mEF.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mEF.cs @@ -19,12 +19,27 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int toggle = 0; - public override byte ReadMemory(ushort addr) + private byte ReadMem(ushort addr, bool peek) { - Address(addr); + if (!peek) + { + Address(addr); + } + if (addr < 0x1000) return base.ReadMemory(addr); return core.rom[toggle * 4 * 1024 + (addr & 0xFFF)]; } + + public override byte ReadMemory(ushort addr) + { + return ReadMem(addr, false); + } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs index a774293814..f7616497dd 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs @@ -25,14 +25,28 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int bank = 0; + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + if (addr == 0x1FF0) + Increment(); + } + + if (addr < 0x1000) return base.ReadMemory(addr); + else return core.rom[bank * 4096 + (addr & 0xFFF)]; + } + public override byte ReadMemory(ushort addr) { - if (addr == 0x1FF0) - Increment(); - - if (addr < 0x1000) return base.ReadMemory(addr); - else return core.rom[bank * 4 * 1024 + (addr & 0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { if (addr < 0x1000) base.WriteMemory(addr, value); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF4.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF4.cs index f99ccd30cc..2a76e5cb9a 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF4.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF4.cs @@ -17,12 +17,27 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int toggle = 0; + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) return base.ReadMemory(addr); + return core.rom[toggle * 4096 + (addr & 0xFFF)]; + } + public override byte ReadMemory(ushort addr) { - Address(addr); - if (addr < 0x1000) return base.ReadMemory(addr); - return core.rom[toggle * 4 * 1024 + (addr & 0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs index 57431f13cb..867df16026 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF6.cs @@ -18,12 +18,27 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int toggle = 0; + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) return base.ReadMemory(addr); + return core.rom[(toggle << 12) + (addr & 0xFFF)]; + } + public override byte ReadMemory(ushort addr) { - Address(addr); - if (addr < 0x1000) return base.ReadMemory(addr); - return core.rom[toggle * 4 * 1024 + (addr & 0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF8.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF8.cs index fe077caf4f..a0f7534fb6 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF8.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF8.cs @@ -28,14 +28,28 @@ namespace BizHawk class mF8 : MapperBase { int bank_4k = 0; - + + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) return base.ReadMemory(addr); + return core.rom[(bank_4k << 12) + (addr & 0xFFF)]; + } public override byte ReadMemory(ushort addr) { - Address(addr); - if (addr < 0x1000) return base.ReadMemory(addr); - return core.rom[(bank_4k << 12) + (addr&0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mFA.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mFA.cs index e5bfa8712b..091e0a737e 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mFA.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mFA.cs @@ -22,19 +22,41 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 int toggle = 0; ByteBuffer aux_ram = new ByteBuffer(256); + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) + { + return base.ReadMemory(addr); + } + else if (addr < 0x1100) + { + return 0xFF; + } + else if (addr < 0x1200) + { + return aux_ram[addr & 0xFF]; + } + else + { + return core.rom[(toggle * 4096) + (addr & 0xFFF)]; + } + } + public override byte ReadMemory(ushort addr) { - Address(addr); - - if (addr < 0x1000) - return base.ReadMemory(addr); - else if (addr < 0x1100) - return 0xFF; - else if (addr < 0x1200) - return aux_ram[addr & 0xFF]; - else - return core.rom[(toggle * 4 * 1024) + (addr & 0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mUA.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mUA.cs index d479b80f85..222c172a78 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mUA.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mUA.cs @@ -19,12 +19,27 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int toggle = 0; + private byte ReadMem(ushort addr, bool peek) + { + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) return base.ReadMemory(addr); + return core.rom[toggle * 4096 + (addr & 0xFFF)]; + } + public override byte ReadMemory(ushort addr) { - Address(addr); - if (addr < 0x1000) return base.ReadMemory(addr); - return core.rom[toggle * 4 * 1024 + (addr & 0xFFF)]; + return ReadMem(addr, false); } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mX07.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mX07.cs index 5ca578d2fe..818128129b 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mX07.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mX07.cs @@ -40,9 +40,13 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 { int rombank_2k = 0; - public override byte ReadMemory(ushort addr) + private byte ReadMem(ushort addr, bool peek) { - Address(addr); + if (!peek) + { + Address(addr); + } + if (addr < 0x1000) { return base.ReadMemory(addr); @@ -52,6 +56,17 @@ namespace BizHawk.Emulation.Consoles.Atari._2600 return core.rom[(rombank_2k << 12) + (addr & 0xFFF)]; } } + + public override byte ReadMemory(ushort addr) + { + return ReadMem(addr, false); + } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + public override void WriteMemory(ushort addr, byte value) { Address(addr); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index c05f24d2c3..5e2070c97f 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -3030,8 +3030,6 @@ namespace BizHawk.MultiClient Global.Sound.UpdateSilence(); } - - /// /// Update all tools that are frame dependent like Ram Search before processing ///