From 09258b75d7d9bb5d25159179fa8ef768ad365dca Mon Sep 17 00:00:00 2001 From: tomascz Date: Mon, 28 Mar 2022 18:38:44 +0200 Subject: [PATCH] [#64] Internal FDD improvements and bugfixes (Part 16.1: Fixed) --- Main/src/FDD.cpp | 47 +++++++++++++++++++++++++--------------------- Main/src/Image.cpp | 1 + Main/src/Image.h | 1 + 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Main/src/FDD.cpp b/Main/src/FDD.cpp index cfe2508e..79015894 100644 --- a/Main/src/FDD.cpp +++ b/Main/src/FDD.cpp @@ -215,6 +215,8 @@ terminateWithError: fdd->UnformatInternalTrack(cyl,head); // disposing any new TInternalTrack::TSectorInfo *psi=sectors; for( TSector s=0; sseqNum=s++ ){ psi->length=fdd->GetUsableSectorLength(( psi->id=*bufferId++ ).lengthCode ); + for( BYTE r=0; rrevolutions[r].fdcStatus=TFdcStatus::Unknown; // not yet attempted for reading psi->dirtyRevolution=Revolution::NONE; if (sectorStartsNanoseconds>(PCLogTime)0x100) // if start times provided (that is, if no Gap3 information from <0;255> Bytes provided) ... psi->startNanoseconds=*sectorStartsNanoseconds++; // ... they are used @@ -891,7 +893,6 @@ error: switch (const TStdWinError err=::GetLastError()){ } } // . executing the above composed Plan - const bool silentlyRecoverFromErrors=rev>=Revolution::ANY_GOOD; for( const TPlanStep *pPlanStep=plan; pPlanSteppsi; const BYTE index=pPlanStep->indexIntoOutputBuffers; @@ -902,22 +903,24 @@ error: switch (const TStdWinError err=::GetLastError()){ rsi.currentRevolution=rsi.dirtyRevolution; else switch (rev){ + case Revolution::CURRENT: + // getting Current Revolution + break; default: - if (rev if the Next Revolution maps to an existing Revolution, return it @@ -932,18 +935,10 @@ error: switch (const TStdWinError err=::GetLastError()){ ); rsi.nRevolutions--; } + // > attempt for the Data auto &rev=rsi.revolutions[ rsi.currentRevolution=rsi.nRevolutions ]; // the last Revolution, below set empty rev.data=nullptr; // Sector with given ID physically not found or has no DAM) - rev.fdcStatus=TFdcStatus::NoDataField; - // > seek Head over the given Cylinder - if (!fddHead.__seekTo__(cyl)) - return; // Sectors cannot be found as Head cannot be seeked - // > attempt for the Data - if (__bufferSectorData__( cyl, head, &rsi.id, length, pit, bufferNumbersOfSectorsToSkip[index], &rev.fdcStatus ) // yes, Sector found ... - && - !rev.fdcStatus.DescribesMissingDam() // ... and has a DAM - ) - rev.data=(PSectorData)::memcpy( ALLOCATE_SECTOR_DATA(length), dataBuffer, length ); + rev.fdcStatus=TFdcStatus::Unknown; // attempt for the data below rsi.nRevolutions++; break; } @@ -987,8 +982,18 @@ error: switch (const TStdWinError err=::GetLastError()){ break; } } + // : if not yet attempted for the data, doing so now + auto &rev=rsi.revolutions[rsi.currentRevolution]; + if (rev.fdcStatus.ToWord()==TFdcStatus::Unknown.ToWord()){ + if (!fddHead.__seekTo__(cyl)) + return; // Sectors cannot be found as Head cannot be seeked + if (__bufferSectorData__( cyl, head, &rsi.id, length, pit, bufferNumbersOfSectorsToSkip[index], &rev.fdcStatus ) // yes, Sector found ... + && + !rev.fdcStatus.DescribesMissingDam() // ... and has a DAM + ) + rev.data=(PSectorData)::memcpy( ALLOCATE_SECTOR_DATA(length), dataBuffer, length ); + } // : returning (any) Data - const auto &rev=rsi.revolutions[rsi.currentRevolution]; outFdcStatuses[index]=rev.fdcStatus; outBufferData[index]=rev.data; } diff --git a/Main/src/Image.cpp b/Main/src/Image.cpp index 9ff4b144..15c8b35d 100644 --- a/Main/src/Image.cpp +++ b/Main/src/Image.cpp @@ -98,6 +98,7 @@ + const TFdcStatus TFdcStatus::Unknown(-1,-1); const TFdcStatus TFdcStatus::WithoutError; const TFdcStatus TFdcStatus::SectorNotFound( FDC_ST1_NO_ADDRESS_MARK, 0 ); const TFdcStatus TFdcStatus::IdFieldCrcError( FDC_ST1_DATA_ERROR|FDC_ST1_NO_DATA, 0 ); diff --git a/Main/src/Image.h b/Main/src/Image.h index be4fe704..26277220 100644 --- a/Main/src/Image.h +++ b/Main/src/Image.h @@ -194,6 +194,7 @@ #pragma pack(1) typedef const struct TFdcStatus sealed{ + static const TFdcStatus Unknown; // e.g. when Sector not yet attempted for reading static const TFdcStatus WithoutError; static const TFdcStatus SectorNotFound; static const TFdcStatus IdFieldCrcError;