ZXHawk: Some UPD ReadID improvements

This commit is contained in:
Asnivor 2018-05-03 15:33:30 +01:00
parent 282c3533b4
commit a374f9f4b8
3 changed files with 37 additions and 6 deletions

View File

@ -598,7 +598,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ActiveCommandParams.Cylinder++;
// reset sector
ActiveCommandParams.Sector = 1;
ActiveCommandParams.Sector = sector.SectorID; // 1;
ActiveDrive.SectorIndex = 0;
}
else
@ -1598,6 +1598,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ActiveDrive.SectorIndex = 0;
}
if (ActiveDrive.SectorIndex == 0 && ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1)
{
// looks like readid always skips the first sector on a track
ActiveDrive.SectorIndex++;
}
// read the sector data
var data = track.Sectors[ActiveDrive.SectorIndex]; //.GetCHRN();
ResBuffer[RS_C] = data.TrackNumber;
@ -2710,8 +2716,24 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// set seek flag
ActiveDrive.SeekStatus = SEEK_SEEK;
// immediate seek
ActiveDrive.CurrentTrackID = CommBuffer[CM_C];
if (ActiveDrive.CurrentTrackID == CommBuffer[CM_C])
{
// we are already on the correct track
ActiveDrive.SectorIndex = 0;
}
else
{
// immediate seek
ActiveDrive.CurrentTrackID = CommBuffer[CM_C];
ActiveDrive.SectorIndex = 0;
if (ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1)
{
// always read the first sector
//ActiveDrive.SectorIndex++;
}
}
// skip execution mode and go directly to idle
// result is determined by SIS command
@ -2773,6 +2795,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
ActiveDrive.TrackIndex = 0;
ActiveDrive.SectorIndex = 0;
// recalibrate appears to always skip the first sector
//if (ActiveDrive.Disk.DiskTracks[ActiveDrive.TrackIndex].Sectors.Length > 1)
//ActiveDrive.SectorIndex++;
// set seek flag
ActiveDrive.SeekStatus = SEEK_RECALIBRATE;

View File

@ -204,14 +204,14 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
Spectrum.IsLagFrame = !InputRead;
// FDC debug
/*
if (UPDDiskDevice != null && UPDDiskDevice.writeDebug)
{
// only write UPD log every second
if (FrameCount % 10 == 0)
System.IO.File.WriteAllText(UPDDiskDevice.outputfile, UPDDiskDevice.outputString);
}
*/
}
#endregion

View File

@ -129,7 +129,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Disk);
sb.Clear();
sb.Append("Detected Protection: " + Enum.GetName(typeof(ProtectionType), _machine.UPDDiskDevice.DiskPointer.Protection));
string protection = "None";
protection = Enum.GetName(typeof(ProtectionType), _machine.UPDDiskDevice.DiskPointer.Protection);
if (protection == "None")
protection += " (OR UNKNOWN)";
sb.Append("Detected Protection: " + protection);
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Disk);
sb.Clear();