diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs index c14a7bcc62..978d815c52 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs @@ -19,6 +19,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum string PrevBlock = "Prev Tape Block"; string TapeStatus = "Get Tape Status"; + string HardResetStr = "Hard Reset"; + string SoftResetStr = "Soft Reset"; + bool pressed_Play = false; bool pressed_Stop = false; bool pressed_RTZ = false; @@ -27,6 +30,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum bool pressed_NextBlock = false; bool pressed_PrevBlock = false; bool pressed_TapeStatus = false; + bool pressed_HardReset = false; + bool pressed_SoftReset = false; /// /// Cycles through all the input callbacks @@ -191,6 +196,28 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } else pressed_TapeStatus = false; + + if (Spectrum._controller.IsPressed(HardResetStr)) + { + if (!pressed_HardReset) + { + HardReset(); + pressed_HardReset = true; + } + } + else + pressed_HardReset = false; + + if (Spectrum._controller.IsPressed(SoftResetStr)) + { + if (!pressed_SoftReset) + { + SoftReset(); + pressed_SoftReset = true; + } + } + else + pressed_SoftReset = false; } /// diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs index b7fcee7e93..d5c1fff9a6 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs @@ -207,6 +207,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { //ResetBorder(); ULADevice.ResetInterrupt(); + CPU.RegPC = 0; } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs index 1ba7dd5b74..38a281ecca 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs @@ -82,6 +82,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum definition.CategoryLabels[s] = "Keyboard"; } + // Datacorder (tape device) + List power = new List + { + // Tape functions + "Soft Reset", "Hard Reset" + }; + + foreach (var s in power) + { + definition.BoolButtons.Add(s); + definition.CategoryLabels[s] = "Power"; + } + // Datacorder (tape device) List tape = new List { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs index 39bd7c984f..0cd1c37a8d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs @@ -50,19 +50,49 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ms.Close(); core = ms.ToArray(); } - _cpu.SyncState(ser); - ser.BeginSection("ZXSpectrum"); - _machine.SyncState(ser); - ser.Sync("Frame", ref _machine.FrameCount); - ser.Sync("LagCount", ref _lagCount); - ser.Sync("IsLag", ref _isLag); + - ser.EndSection(); + if (ser.IsWriter) + { + ser.SyncEnum("_machineType", ref _machineType); + _cpu.SyncState(ser); + ser.BeginSection("ZXSpectrum"); + _machine.SyncState(ser); + ser.Sync("Frame", ref _machine.FrameCount); + ser.Sync("LagCount", ref _lagCount); + ser.Sync("IsLag", ref _isLag); + ser.EndSection(); + } + if (ser.IsReader) { - SyncAllByteArrayDomains(); + var tmpM = _machineType; + ser.SyncEnum("_machineType", ref _machineType); + if (tmpM != _machineType) + { + string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; + msg += "Current Configuration: " + _machineType.ToString(); + msg += "\n"; + msg += "Saved Configuration: " + tmpM.ToString(); + msg += "\n\n"; + msg += "If you with to load this SaveState ensure that you have to correct machine configuration selected, reboot the core, then try again."; + CoreComm.ShowMessage(msg); + _machineType = tmpM; + } + else + { + _cpu.SyncState(ser); + ser.BeginSection("ZXSpectrum"); + _machine.SyncState(ser); + ser.Sync("Frame", ref _machine.FrameCount); + ser.Sync("LagCount", ref _lagCount); + ser.Sync("IsLag", ref _isLag); + ser.EndSection(); + + SyncAllByteArrayDomains(); + } } } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index c09598667c..27eb361a88 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -185,9 +185,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return result; } + private MachineType _machineType; private void Init(MachineType machineType, BorderType borderType, TapeLoadSpeed tapeLoadSpeed, List files, List joys) { + _machineType = machineType; + // setup the emulated model based on the MachineType switch (machineType) {