Skip to content

Commit

Permalink
[#57] Support for KryoFlux and associated images (Part 191: Checkbox …
Browse files Browse the repository at this point in the history
…to ignore verification errors in sectors marked as "Bad" in FAT)
  • Loading branch information
tomas-nestorovic committed Feb 19, 2024
1 parent 24503eb commit b41b5a0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 14 deletions.
10 changes: 6 additions & 4 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1791,12 +1791,12 @@ BEGIN
LTEXT "Error",ID_ERROR,15,73,47,15,WS_BORDER | NOT WS_GROUP
END

IDR_CAPS_DEVICE_ACCESS DIALOG DISCARDABLE 0, 0, 225, 284
IDR_CAPS_DEVICE_ACCESS DIALOG DISCARDABLE 0, 0, 225, 295
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "Flux device access options"
BEGIN
DEFPUSHBUTTON "OK",IDOK,115,263,50,14
PUSHBUTTON "Cancel",IDCANCEL,168,263,50,14
DEFPUSHBUTTON "OK",IDOK,115,274,50,14
PUSHBUTTON "Cancel",IDCANCEL,168,274,50,14
LTEXT "Firmware:",IDC_STATIC,7,8,31,8,NOT WS_GROUP
LTEXT "Static",ID_SYSTEM,71,8,147,8,NOT WS_GROUP
LTEXT "&Precision:",IDC_STATIC,7,24,32,8
Expand Down Expand Up @@ -1846,6 +1846,8 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,7,230,112,10
CONTROL "(<a id=""correction"">Settings</a>)",ID_TIME,"SysLink",
WS_TABSTOP,119,231,49,10
CONTROL "Verify sectors marked as bad in FAT",ID_VERIFY_SECTOR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,252,200,10
END

IDR_CAPS DIALOGEX 0, 0, 186, 127
Expand Down Expand Up @@ -2267,7 +2269,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 218
TOPMARGIN, 7
BOTTOMMARGIN, 277
BOTTOMMARGIN, 288
END

IDR_CAPS, DIALOG
Expand Down
29 changes: 25 additions & 4 deletions Main/src/CapsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,20 @@
else if (const auto pBadRegions=Utils::MakeCallocPtr<CTrackReader::TRegion>(vp.nSesItems)){
// composition and display of non-overlapping erroneously written regions of the Track
const DWORD nBadRegions=writtenBits.ScriptToLocalRegions( pSes, vp.nSesItems, pBadRegions, COLOR_RED );
const auto peTrack=pitWritten->ScanAndAnalyze( CActionProgress::None, false ); // False = only linear, time-inexpensive analysis (thus no need for doing this in parallel)
CTrackReader::CParseEventList peTrack;
TSectorId ids[Revolution::MAX*(TSector)-1]; TLogTime idEnds[Revolution::MAX*(TSector)-1]; TLogTime dataEnds[Revolution::MAX*(TSector)-1];
const auto nSectors=pitWritten->ScanAndAnalyze( ids, idEnds, dataEnds, peTrack, CActionProgress::None, false ); // False = only linear, time-inexpensive analysis (thus no need for doing this in parallel)
if (!params.verifyBadSectors) // remove Events that relate to Bad Sectors
for( auto i=nSectors; i>0; ){
const TPhysicalAddress chs={ cyl, head, ids[--i] };
if (dos->GetSectorStatus(chs)==CDos::TSectorStatus::BAD){
peTrack.RemoveConsecutiveBeforeEnd( idEnds[i] );
peTrack.RemoveConsecutiveBeforeEnd( dataEnds[i] );
}
}
err=ERROR_CONTINUE; // assumption (no intersection with ID or Data fields, thus ignore this error in writing)
for( DWORD i=nBadRegions; i>0; )
if (peTrack.IntersectsWith(pBadRegions[--i])){
for( DWORD i=0; i<nBadRegions; i++ )
if (peTrack.IntersectsWith(pBadRegions[i])){
switch (pitWritten->ShowModal( pBadRegions, nBadRegions, MB_ABORTRETRYIGNORE, true, pBadRegions[i].tStart, _T("Track %02d.%c verification failed: Review RED-MARKED errors (use J and L keys) and decide how to proceed!"), cyl, '0'+head )){
case IDOK: // ignore
break;
Expand Down Expand Up @@ -1203,6 +1213,7 @@
#define INI_CALIBRATE_SECTOR_ERROR_KNOWN _T("clbknw")
#define INI_CALIBRATE_FORMATTING _T("clbfmt")
#define INI_VERIFY_WRITTEN_TRACKS _T("vwt")
#define INI_VERIFY_BAD_SECTORS _T("vwtbs")

CCapsBase::TParams::TParams(LPCTSTR iniSectionName)
// ctor
Expand All @@ -1217,6 +1228,7 @@
, calibrationStepDuringFormatting( app.GetProfileInt(iniSectionName,INI_CALIBRATE_FORMATTING,0) )
, corrections( iniSectionName )
, verifyWrittenTracks( app.GetProfileInt(iniSectionName,INI_VERIFY_WRITTEN_TRACKS,true)!=0 )
, verifyBadSectors( app.GetProfileInt(iniSectionName,INI_VERIFY_BAD_SECTORS,true)!=0 )
// - volatile (current session only)
, flippyDisk(false) , userForcedFlippyDisk(false)
, doubleTrackStep(false) , userForcedDoubleTrackStep(false) { // True once the ID_40D80 button in Settings dialog is pressed
Expand All @@ -1233,6 +1245,7 @@
app.WriteProfileInt( iniSectionName, INI_CALIBRATE_FORMATTING, calibrationStepDuringFormatting );
corrections.Save( iniSectionName );
app.WriteProfileInt( iniSectionName, INI_VERIFY_WRITTEN_TRACKS, verifyWrittenTracks );
app.WriteProfileInt( iniSectionName, INI_VERIFY_BAD_SECTORS, verifyBadSectors );
}

CImage::CTrackReader::TDecoderMethod CCapsBase::TParams::GetGlobalFluxDecoder() const{
Expand Down Expand Up @@ -1410,7 +1423,7 @@
ID_ROTATION, // precision
ID_NONE, ID_CYLINDER, ID_SECTOR, ID_READABLE, // calibration upon read failure
ID_ZERO, ID_CYLINDER_N, ID_ADD, // calibration upon write failure
ID_VERIFY_TRACK,
ID_VERIFY_TRACK, ID_VERIFY_SECTOR,
0
};
const bool isRealDevice=rcb.properties->IsRealDevice();
Expand Down Expand Up @@ -1458,6 +1471,10 @@
tmp=params.verifyWrittenTracks&&isRealDevice;
DDX_Check( pDX, ID_VERIFY_TRACK, tmp );
params.verifyWrittenTracks=tmp!=0;
tmp=params.verifyBadSectors&&isRealDevice;
DDX_Check( pDX, ID_VERIFY_SECTOR, tmp );
EnableDlgItem( ID_VERIFY_SECTOR, params.verifyWrittenTracks );
params.verifyBadSectors=tmp!=0;
}

LRESULT WindowProc(UINT msg,WPARAM wParam,LPARAM lParam) override{
Expand Down Expand Up @@ -1516,6 +1533,10 @@
// adjusting possibility to edit the CalibrationStep according to selected option
EnableDlgItem( ID_NUMBER, wParam!=ID_ZERO );
break;
case MAKELONG(ID_VERIFY_TRACK,BN_CLICKED):
// whole Track verification
EnableDlgItem( ID_VERIFY_SECTOR, IsDlgItemChecked(ID_VERIFY_TRACK) );
break;
case IDOK:
// attempting to confirm the Dialog
params.flippyDisk=IsDlgItemChecked(ID_SIDE);
Expand Down
2 changes: 1 addition & 1 deletion Main/src/CapsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
bool calibrationAfterErrorOnlyForKnownSectors;
BYTE calibrationStepDuringFormatting;
TCorrections corrections;
bool verifyWrittenTracks;
bool verifyWrittenTracks, verifyBadSectors;
// volatile (current session only)
bool flippyDisk, userForcedFlippyDisk;
bool doubleTrackStep, userForcedDoubleTrackStep;
Expand Down
4 changes: 3 additions & 1 deletion Main/src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
bool IntersectsWith(const TLogTimeInterval &ti) const;
void AddCopyAscendingByStart(const TParseEvent &pe);
void AddCopiesAscendingByStart(const CParseEventList &list);
void RemoveConsecutiveBeforeEnd(TLogTime tEndMax);
};
protected:
const PLogTime logTimes; // absolute logical times since the start of recording
Expand Down Expand Up @@ -548,7 +549,8 @@
bool ReadBits32(DWORD &rOut);
char ReadByte(ULONGLONG &rOutBits,PBYTE pOutValue=nullptr);
WORD Scan(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses,CParseEventList *pOutParseEvents=nullptr);
WORD ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis=true);
WORD ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses,PLogTime pOutDataEnds,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis=true);
WORD ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,PLogTime pOutDataEnds,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis=true);
CParseEventList ScanAndAnalyze(CActionProgress &ap,bool fullAnalysis=true);
TFdcStatus ReadData(const TSectorId &id,TLogTime idEndTime,const TProfile &idEndProfile,WORD nBytesToRead,CParseEventList *pOutParseEvents);
TFdcStatus ReadData(const TSectorId &id,TLogTime idEndTime,const TProfile &idEndProfile,WORD nBytesToRead,LPBYTE buffer);
Expand Down
30 changes: 26 additions & 4 deletions Main/src/Image_TrackRW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
return nSectorsFound;
}

WORD CImage::CTrackReader::ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis){
WORD CImage::CTrackReader::ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses,PLogTime pOutDataEnds,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis){
// returns the number of Sectors recognized and decoded from underlying Track bits over all complete revolutions
constexpr int StepGranularity=1000;
const BYTE nFullRevolutions=std::max( 0, GetIndexCount()-1 );
Expand All @@ -362,7 +362,9 @@
auto &r=dataEnds[nDataEnds++];
r.time=currentTime;
r.profile=profile;
}
pOutDataEnds[s]=currentTime;
}else
pOutDataEnds[s]=0;
rOutParseEvents.AddCopiesAscendingByStart( peSector );
}
if (!fullAnalysis)
Expand Down Expand Up @@ -586,12 +588,18 @@
// - successfully analyzed
return nSectorsFound;
}

WORD CImage::CTrackReader::ScanAndAnalyze(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,PLogTime pOutDataEnds,CParseEventList &rOutParseEvents,CActionProgress &ap,bool fullAnalysis){
// returns the number of Sectors recognized and decoded from underlying Track bits over all complete revolutions
CImage::CTrackReader::TProfile idProfiles[Revolution::MAX*(TSector)-1]; TFdcStatus statuses[Revolution::MAX*(TSector)-1];
return ScanAndAnalyze( pOutFoundSectors, pOutIdEnds, idProfiles, statuses, pOutDataEnds, rOutParseEvents, ap, fullAnalysis );
}

CImage::CTrackReader::CParseEventList CImage::CTrackReader::ScanAndAnalyze(CActionProgress &ap,bool fullAnalysis){
// returns the number of Sectors recognized and decoded from underlying Track bits over all complete revolutions
CImage::CTrackReader::CParseEventList peTrack;
TSectorId ids[Revolution::MAX*(TSector)-1]; TLogTime idEnds[Revolution::MAX*(TSector)-1]; CImage::CTrackReader::TProfile idProfiles[Revolution::MAX*(TSector)-1]; TFdcStatus statuses[Revolution::MAX*(TSector)-1];
ScanAndAnalyze( ids, idEnds, idProfiles, statuses, peTrack, ap, fullAnalysis );
TSectorId ids[Revolution::MAX*(TSector)-1]; TLogTime idEnds[Revolution::MAX*(TSector)-1]; TLogTime dataEnds[Revolution::MAX*(TSector)-1];
ScanAndAnalyze( ids, idEnds, dataEnds, peTrack, ap, fullAnalysis );
return peTrack;
}

Expand Down Expand Up @@ -962,6 +970,20 @@
AddTail( list.GetNext(listPos) );
}

void CImage::CTrackReader::CParseEventList::RemoveConsecutiveBeforeEnd(TLogTime tEndMax){
// removes all ParseEvents that touch or overlap just before the End time
POSITION pos=GetPositionByEnd(tEndMax);
if (pos && GetAt(pos).tEnd>tEndMax)
GetPrev(pos);
for( bool consequtive=pos!=nullptr; consequtive; ){
const POSITION curr=pos;
const auto &peCurr=GetPrev(pos);
const TLogTime tPrevEnd= pos!=nullptr ? GetAt(pos).tEnd : -1;
consequtive=peCurr.tStart<=tPrevEnd; // touching or overlapping?
RemoveAt(curr);
}
}




Expand Down

0 comments on commit b41b5a0

Please sign in to comment.