ZXHawk: Some PZX changes

This commit is contained in:
Asnivor 2018-06-21 13:39:23 +01:00
parent 50123bf8e2
commit 8236d7b645
3 changed files with 38 additions and 22 deletions

View File

@ -408,7 +408,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
counter++;
if (counter > 30)
if (counter > 20)
{
counter = 0;
bool state = GetEarBit(_machine.CPU.TotalExecutedCycles);
@ -451,15 +451,27 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// decrement cycles
cycles -= _waitEdge;
// flip the current state
currentState = !currentState;
if (_position == 0 && _tapeIsPlaying)
{
// start of block
//if (!_dataBlocks[_currentDataBlockIndex].InitialPulseLevel[_position])
//currentState = !currentState;
// start of block - take care of initial pulse level for PZX
switch (_dataBlocks[_currentDataBlockIndex].BlockDescription)
{
case BlockType.PULS:
// initial pulse level is always low
if (currentState)
FlipTapeState();
break;
case BlockType.DATA:
// initial pulse level is stored in block
if (currentState != _dataBlocks[_currentDataBlockIndex].InitialPulseLevel)
FlipTapeState();
break;
case BlockType.PAUS:
// initial pulse level is stored in block
if (currentState != _dataBlocks[_currentDataBlockIndex].InitialPulseLevel)
FlipTapeState();
break;
}
// notify about the current block
var bl = _dataBlocks[_currentDataBlockIndex];
@ -569,7 +581,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}
// update waitEdge with current position within the current block
_waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods[_position];
_waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods[_position];
// flip the current state
FlipTapeState();
}
@ -582,6 +597,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return currentState;
}
private void FlipTapeState()
{
currentState = !currentState;
}
/// <summary>
/// Flash loading implementation
/// (Deterministic Emulation must be FALSE)

View File

@ -174,6 +174,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
t.BlockID = GetInt32(b, 0);
t.DataPeriods = new List<int>();
t.InitialPulseLevel = false;
List<ushort[]> pulses = new List<ushort[]>();
while (pos < blockSize + 8)
@ -210,7 +212,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
for (int i = 0; i < x[0]; i++)
{
t.DataPeriods.Add(x[1]);
t.InitialPulseLevel.Add(true);
}
}
@ -248,6 +249,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
dCount = GetInt32(b, pos);
initPulseLevel = (uint)((dCount & 0x80000000) == 0 ? 0 : 1);
t.InitialPulseLevel = initPulseLevel == 1 ? true : false;
dCount = (int)(dCount & 0x7FFFFFFF);
pos += 4;
@ -277,8 +280,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
dData.Add(buff);
}
bool initPulse = initPulseLevel == 1 ? true : false;
foreach (var by in dData)
{
for (int i = 7; i >= 0; i--)
@ -288,7 +289,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
foreach (var pu in s1)
{
t.DataPeriods.Add((int)pu);
t.InitialPulseLevel.Add(initPulse);
}
}
@ -297,13 +297,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
foreach (var pu in s0)
{
t.DataPeriods.Add((int)pu);
t.InitialPulseLevel.Add(initPulse);
}
}
}
}
if (tail > 0)
t.DataPeriods.Add(tail);
dData.Clear();
}
@ -312,7 +312,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
t.PauseInMS = 0;
// tail
t.DataPeriods.Add(tail);
//t.DataPeriods.Add(tail);
_datacorder.DataBlocks.Add(t);
@ -334,17 +334,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
var d = GetInt32(b, pos);
iniPulseLevel = ((d & 0x80000000) == 0 ? 0 : 1);
t.InitialPulseLevel = iniPulseLevel == 1 ? true : false;
pCount = (d & 0x7FFFFFFF);
// convert to tape block
t.BlockDescription = BlockType.PAUS;
t.DataPeriods.Add(pCount);
if (iniPulseLevel == 1)
t.InitialPulseLevel.Add(true);
else
t.InitialPulseLevel.Add(false);
_datacorder.DataBlocks.Add(t);
break;

View File

@ -113,7 +113,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary>
public List<int> DataPeriods = new List<int>();
public List<bool> InitialPulseLevel = new List<bool>();
public bool InitialPulseLevel;
/// <summary>
/// Command that is raised by this data block