From baa46f3c99fa9a871542e8ae8d576933b9562eb7 Mon Sep 17 00:00:00 2001 From: Asnivor Date: Mon, 12 Mar 2018 15:48:00 +0000 Subject: [PATCH] Detection method for 48k (or 128k in 48k mode) - needed for 'stop the tape 48k' tzx block command detection --- .../Hardware/Datacorder/DatacorderDevice.cs | 25 +------ .../Machine/SpectrumBase.Memory.cs | 18 +++-- .../Machine/ZXSpectrum128K/ZX128.Memory.cs | 56 +--------------- .../Machine/ZXSpectrum128K/ZX128.Port.cs | 12 ++-- .../ZX128Plus2a.Memory.cs | 66 +------------------ .../ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs | 66 +------------------ .../Machine/ZXSpectrum48K/ZX48.Memory.cs | 30 --------- 7 files changed, 17 insertions(+), 256 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs index 88d5f844f3..e71a17d8f0 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs @@ -484,28 +484,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } _monitorTimeOut = 2000; - } - /* - if ((_machine.GetType() != typeof(ZX128) && - _machine.GetType() != typeof(ZX128Plus2) && - _machine.GetType() != typeof(ZX128Plus3)) || - (_machine.GetType() == typeof(ZX128) || - _machine.GetType() != typeof(ZX128Plus2) || - _machine.GetType() != typeof(ZX128Plus3)) && - _machine._ROMpaged == 1) - { - _machine.Spectrum.OSD_TapeStoppedAuto(); - - if (_currentDataBlockIndex >= _dataBlocks.Count()) - RTZ(); - else - { - Stop(); - } - - _monitorTimeOut = 2000; - } - */ + } break; } @@ -515,8 +494,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _position = 0; _currentDataBlockIndex++; - - if (_currentDataBlockIndex >= _dataBlocks.Count()) { break; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs index 49a7bbd561..e625ecae77 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs @@ -102,21 +102,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } /// - /// Helper function to refresh memory array (probably not the best way to do things) - /// - //public abstract void ReInitMemory(); - - /// - /// Detects whether the 48k rom is resident (or paged in) at 0x0001 + /// Detects whether this is a 48k machine (or a 128k in 48k mode) /// /// public virtual bool IsIn48kMode() { - var data = ReadBus(0x0001); - if (data == 0xaf) + if (this.GetType() == typeof(ZX48) || + this.GetType() == typeof(ZX16) || + PagingDisabled) + { return true; - - return false; + } + else + return false; } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Memory.cs index b9eb26cbb8..e76cffbaf7 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Memory.cs @@ -208,61 +208,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum WriteBus(addr, value); } - /* - public override void ReInitMemory() - { - if (Memory.ContainsKey(0)) - Memory[0] = ROM0; - else - Memory.Add(0, ROM0); - - if (Memory.ContainsKey(1)) - Memory[1] = ROM1; - else - Memory.Add(1, ROM1); - - if (Memory.ContainsKey(2)) - Memory[2] = RAM0; - else - Memory.Add(2, RAM0); - - if (Memory.ContainsKey(3)) - Memory[3] = RAM1; - else - Memory.Add(3, RAM1); - - if (Memory.ContainsKey(4)) - Memory[4] = RAM2; - else - Memory.Add(4, RAM2); - - if (Memory.ContainsKey(5)) - Memory[5] = RAM3; - else - Memory.Add(5, RAM3); - - if (Memory.ContainsKey(6)) - Memory[6] = RAM4; - else - Memory.Add(6, RAM4); - - if (Memory.ContainsKey(7)) - Memory[7] = RAM5; - else - Memory.Add(7, RAM5); - - if (Memory.ContainsKey(8)) - Memory[8] = RAM6; - else - Memory.Add(8, RAM6); - - if (Memory.ContainsKey(9)) - Memory[9] = RAM7; - else - Memory.Add(9, RAM7); - } - */ - + /// /// ULA reads the memory at the specified address /// (No memory contention) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs index 0fb70d9bca..130264a4c7 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs @@ -48,16 +48,14 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // process tape INs TapeDevice.ReadPort(port, ref result); } + else if ((port & 0xc002) == 0xc000) + { + // AY sound chip + result = (int)AYDevice.PortRead(); + } else { // devices other than the ULA will respond here - // (e.g. the AY sound chip in a 128k spectrum) - - // AY register activate - if ((port & 0xc002) == 0xc000) - { - result = (int)AYDevice.PortRead(); - } // Kempston Mouse (not implemented yet) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs index 3ce0adcc73..33aa0c2bcf 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs @@ -374,71 +374,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum WriteBus(addr, value); } - /* - public override void ReInitMemory() - { - if (Memory.ContainsKey(0)) - Memory[0] = ROM0; - else - Memory.Add(0, ROM0); - - if (Memory.ContainsKey(1)) - Memory[1] = ROM1; - else - Memory.Add(1, ROM1); - - if (Memory.ContainsKey(2)) - Memory[2] = ROM2; - else - Memory.Add(2, ROM2); - - if (Memory.ContainsKey(3)) - Memory[3] = ROM3; - else - Memory.Add(3, ROM3); - - if (Memory.ContainsKey(4)) - Memory[4] = RAM0; - else - Memory.Add(4, RAM0); - - if (Memory.ContainsKey(5)) - Memory[5] = RAM1; - else - Memory.Add(5, RAM1); - - if (Memory.ContainsKey(6)) - Memory[6] = RAM2; - else - Memory.Add(6, RAM2); - - if (Memory.ContainsKey(7)) - Memory[7] = RAM3; - else - Memory.Add(7, RAM3); - - if (Memory.ContainsKey(8)) - Memory[8] = RAM4; - else - Memory.Add(8, RAM4); - - if (Memory.ContainsKey(9)) - Memory[9] = RAM5; - else - Memory.Add(9, RAM5); - - if (Memory.ContainsKey(10)) - Memory[10] = RAM6; - else - Memory.Add(10, RAM6); - - if (Memory.ContainsKey(11)) - Memory[11] = RAM7; - else - Memory.Add(11, RAM7); - } - */ - + /// /// ULA reads the memory at the specified address /// (No memory contention) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs index 7ca4147f9d..ad3d846ffd 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs @@ -374,71 +374,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum WriteBus(addr, value); } - /* - public override void ReInitMemory() - { - if (Memory.ContainsKey(0)) - Memory[0] = ROM0; - else - Memory.Add(0, ROM0); - - if (Memory.ContainsKey(1)) - Memory[1] = ROM1; - else - Memory.Add(1, ROM1); - - if (Memory.ContainsKey(2)) - Memory[2] = ROM2; - else - Memory.Add(2, ROM2); - - if (Memory.ContainsKey(3)) - Memory[3] = ROM3; - else - Memory.Add(3, ROM3); - - if (Memory.ContainsKey(4)) - Memory[4] = RAM0; - else - Memory.Add(4, RAM0); - - if (Memory.ContainsKey(5)) - Memory[5] = RAM1; - else - Memory.Add(5, RAM1); - - if (Memory.ContainsKey(6)) - Memory[6] = RAM2; - else - Memory.Add(6, RAM2); - - if (Memory.ContainsKey(7)) - Memory[7] = RAM3; - else - Memory.Add(7, RAM3); - - if (Memory.ContainsKey(8)) - Memory[8] = RAM4; - else - Memory.Add(8, RAM4); - - if (Memory.ContainsKey(9)) - Memory[9] = RAM5; - else - Memory.Add(9, RAM5); - - if (Memory.ContainsKey(10)) - Memory[10] = RAM6; - else - Memory.Add(10, RAM6); - - if (Memory.ContainsKey(11)) - Memory[11] = RAM7; - else - Memory.Add(11, RAM7); - } - */ - + /// /// ULA reads the memory at the specified address /// (No memory contention) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs index c6f319cec0..8b9427d66b 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs @@ -121,36 +121,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum WriteBus(addr, value); } - /* - public override void ReInitMemory() - { - if (Memory.ContainsKey(0)) - Memory[0] = ROM0; - else - Memory.Add(0, ROM0); - - if (Memory.ContainsKey(1)) - Memory[1] = RAM0; - else - Memory.Add(1, RAM0); - - if (Memory.ContainsKey(2)) - Memory[2] = RAM1; - else - Memory.Add(2, RAM1); - - if (Memory.ContainsKey(3)) - Memory[3] = RAM2; - else - Memory.Add(3, RAM2); - - if (Memory.ContainsKey(4)) - Memory[4] = RAM3; - else - Memory.Add(4, RAM3); - } - */ - /// /// Sets up the ROM ///