diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs
index 066570f6c9..48701e0f88 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs
@@ -103,12 +103,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
private long _lastCycle = 0;
///
- ///
+ /// Edge
///
private int _waitEdge = 0;
///
- ///
+ /// Current tapebit state
///
private bool currentState = false;
@@ -132,11 +132,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
#region Emulator
- ///
- /// This is the address the that ROM will jump to when the spectrum has quit tape playing
- ///
- public const ushort ERROR_ROM_ADDRESS = 0x0008;
-
///
/// Should be fired at the end of every frame
/// Primary purpose is to detect tape traps and manage auto play (if/when this is ever implemented)
@@ -522,7 +517,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_lastCycle = cpuCycle - (long)cycles;
// play the buzzer
- _buzzer.ProcessPulseValue(true, currentState);
+ _buzzer.ProcessPulseValue(false, currentState);
return currentState;
}
@@ -598,7 +593,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
_machine.Spectrum.OSD_TapePlayingAuto();
}
- _monitorTimeOut = 50;
+ _monitorTimeOut = 250;
}
}
else
@@ -613,7 +608,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public void AutoStopTape()
{
- if (!_tapeIsPlaying)
+ if (_tapeIsPlaying)
+ return;
+
+ if (!_machine.Spectrum.Settings.AutoLoadTape)
return;
Stop();
@@ -625,25 +623,27 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
if (_tapeIsPlaying)
return;
+ if (!_machine.Spectrum.Settings.AutoLoadTape)
+ return;
+
Play();
_machine.Spectrum.OSD_TapePlayingAuto();
}
private void MonitorFrame()
{
- /*
if (_tapeIsPlaying && _machine.Spectrum.Settings.AutoLoadTape)
{
-
_monitorTimeOut--;
if (_monitorTimeOut < 0)
{
+ // does not work properly - disabled for now (handled elsewhere)
+
//Stop();
//_machine.Spectrum.OSD_TapeStoppedAuto();
}
}
- */
}
#endregion
@@ -665,6 +665,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
public bool ReadPort(ushort port, ref int result)
{
+ if (TapeIsPlaying)
+ {
+ GetEarBit(_cpu.TotalExecutedCycles);
+ }
+ if (currentState)
+ {
+ result |= TAPE_BIT;
+ }
+ else
+ {
+ result &= ~TAPE_BIT;
+ }
+
+ MonitorRead();
+
+ /*
+
if (TapeIsPlaying)
{
if (GetEarBit(_cpu.TotalExecutedCycles))
@@ -702,6 +719,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
}
+ */
+
return true;
}
@@ -713,8 +732,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
public bool WritePort(ushort port, int result)
{
- // not implemented yet
- return false;
+ if (!TapeIsPlaying)
+ {
+ currentState = ((byte)result & 0x10) != 0;
+ }
+
+ return true;
}
#endregion
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
index a25bbc8186..a23c2796ff 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs
@@ -176,36 +176,58 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return false;
}
-
+ ///
+ /// Monitors ROM access
+ /// Used to auto start/stop the tape device when appropriate
+ ///
+ ///
public virtual void TestForTapeTraps(int addr)
{
- if (!TapeDevice.TapeIsPlaying)
+ if (TapeDevice.TapeIsPlaying)
{
+ // THE 'ERROR' RESTART
if (addr == 8)
{
TapeDevice?.AutoStopTape();
return;
}
+ // THE 'ED-ERROR' SUBROUTINE
if (addr == 4223)
{
TapeDevice?.AutoStopTape();
return;
}
+ // THE 'ERROR-2' ROUTINE
if (addr == 83)
{
TapeDevice?.AutoStopTape();
return;
}
+
+ // THE 'MASKABLE INTERRUPT' ROUTINE
+ if (addr == 56)
+ {
+ //TapeDevice?.AutoStopTape();
+ return;
+ }
}
else
{
+ // THE 'LD-BYTES' SUBROUTINE
if (addr == 1366)
{
TapeDevice?.AutoStartTape();
return;
}
+
+ // THE 'LD-EDGE-2' AND 'LD-EDGE-1' SUBROUTINES
+ if (addr == 1507)
+ {
+ TapeDevice?.AutoStartTape();
+ return;
+ }
}
}
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 353d7bdacd..e01525017a 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs
@@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// not a lagframe
InputRead = true;
- // tape loading monitor cycle
- TapeDevice.MonitorRead();
-
// process tape INs
TapeDevice.ReadPort(port, ref result);
}
@@ -229,6 +226,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// Buzzer
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
+ TapeDevice.WritePort(port, value);
// Tape
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs
index a99d2c53bc..24e7a13760 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs
@@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// not a lagframe
InputRead = true;
- // tape loading monitor cycle
- TapeDevice.MonitorRead();
-
// process tape INs
TapeDevice.ReadPort(port, ref result);
}
@@ -255,6 +252,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// Buzzer
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
+ // Tape
+ TapeDevice.WritePort(port, value);
+
// Tape
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
}
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs
index ce92c7c93f..e56c23440b 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs
@@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// not a lagframe
InputRead = true;
- // tape loading monitor cycle
- TapeDevice.MonitorRead();
-
// process tape INs
TapeDevice.ReadPort(port, ref result);
}
@@ -182,6 +179,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// Buzzer
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
+ // Tape
+ TapeDevice.WritePort(port, value);
+
// Tape
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
}
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
index 09b1b8d073..0cb5b9c7c1 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs
@@ -40,10 +40,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
KeyboardDevice.ReadPort(port, ref result);
// not a lagframe
- InputRead = true;
-
- // tape loading monitor cycle
- TapeDevice.MonitorRead();
+ InputRead = true;
// process tape INs
TapeDevice.ReadPort(port, ref result);
@@ -120,9 +117,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// Buzzer
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
+ // Tape
+ TapeDevice.WritePort(port, value);
+
// Tape mic processing (not implemented yet)
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
-
+
}
}