ZXHawk: removed all Rand() references from weak sector disk read implementation (now all speedlock protected games should load *every* time without issue)
This commit is contained in:
parent
9bdcc81863
commit
6a3377417e
|
@ -480,6 +480,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
ExecBuffer[buffPos++] = sector.ActualData[i];
|
||||
}
|
||||
|
||||
// mark the sector read
|
||||
sector.SectorReadCompleted();
|
||||
|
||||
// any CRC errors?
|
||||
if (Status1.Bit(SR1_DE) || Status2.Bit(SR2_DD))
|
||||
{
|
||||
|
@ -806,6 +809,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
ExecBuffer[buffPos++] = sector.ActualData[i];
|
||||
}
|
||||
|
||||
// mark the sector read
|
||||
sector.SectorReadCompleted();
|
||||
|
||||
if (sector.SectorID == ActiveCommandParams.EOT)
|
||||
{
|
||||
// this was the last sector to read
|
||||
|
@ -1044,6 +1050,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
ExecBuffer[buffPos++] = sec.ActualData[b];
|
||||
}
|
||||
|
||||
// mark the sector read
|
||||
sec.SectorReadCompleted();
|
||||
|
||||
// end of sector - compare IDs
|
||||
if (sec.TrackNumber != ActiveCommandParams.Cylinder ||
|
||||
sec.SideNumber != ActiveCommandParams.Head ||
|
||||
|
|
|
@ -857,7 +857,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
#endregion
|
||||
|
||||
#region StateSerialization
|
||||
#region StateSerialization
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
|
|
|
@ -636,6 +636,14 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
public byte[] SectorData { get; set; }
|
||||
public bool ContainsMultipleWeakSectors { get; set; }
|
||||
|
||||
public int WeakReadIndex = 0;
|
||||
|
||||
public void SectorReadCompleted()
|
||||
{
|
||||
if (ContainsMultipleWeakSectors)
|
||||
WeakReadIndex++;
|
||||
}
|
||||
|
||||
public int DataLen
|
||||
{
|
||||
get
|
||||
|
@ -681,6 +689,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
}
|
||||
else
|
||||
{
|
||||
// weak read neccessary
|
||||
int copies = ActualDataByteLength / (0x80 << SectorSize);
|
||||
|
||||
// handle index wrap-around
|
||||
if (WeakReadIndex > copies - 1)
|
||||
WeakReadIndex = copies - 1;
|
||||
|
||||
// get the sector data based on the current weakreadindex
|
||||
int step = WeakReadIndex * (0x80 << SectorSize);
|
||||
byte[] res = new byte[(0x80 << SectorSize)];
|
||||
Array.Copy(SectorData, step, res, 0, 0x80 << SectorSize);
|
||||
return res;
|
||||
|
||||
/*
|
||||
int copies = ActualDataByteLength / (0x80 << SectorSize);
|
||||
Random rnd = new Random();
|
||||
int r = rnd.Next(0, copies - 1);
|
||||
|
@ -688,6 +710,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
byte[] res = new byte[(0x80 << SectorSize)];
|
||||
Array.Copy(SectorData, step, res, 0, 0x80 << SectorSize);
|
||||
return res;
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue