Skip to content

Commit

Permalink
[#57] Support for KryoFlux and associated images (Part 9: Cumulative …
Browse files Browse the repository at this point in the history
…improvements of CImage::CTrackReader)
  • Loading branch information
tomas-nestorovic committed Nov 11, 2020
1 parent 4252bda commit 79913cd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
9 changes: 6 additions & 3 deletions Main/src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,14 @@
TLogTime iwTime; // inspection window size; a "1" is expected in its centre
TLogTime iwTimeMin,iwTimeMax; // inspection window possible time range
BYTE adjustmentPercentMax; // percentual "speed" in inspection window adjustment

void Reset();
} profile;
protected:
const PLogTime logTimes; // absolute logical times since the start of recording
DWORD iNextTime,nLogTimes;
TLogTime indexPulses[DEVICE_REVOLUTIONS_MAX];
BYTE nIndexPulses;
TLogTime indexPulses[DEVICE_REVOLUTIONS_MAX+1];
BYTE iNextIndexPulse,nIndexPulses;
TLogTime currentTime;
TCodec codec;
TMedium::TType mediumType;
Expand Down Expand Up @@ -307,7 +309,7 @@
//TSector Scan(BYTE revolutionIndex,PSectorId pOutFoundSectors,PLogTime pOutDataStart);
WORD ScanFm(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses);
WORD ScanMfm(PSectorId pOutFoundSectors,PLogTime pOutIdEnds,TProfile *pOutIdProfiles,TFdcStatus *pOutIdStatuses);
TFdcStatus ReadData(WORD nBytesToRead,LPBYTE buffer);
//TFdcStatus ReadData(WORD nBytesToRead,LPBYTE buffer);
TFdcStatus ReadDataFm(WORD nBytesToRead,LPBYTE buffer);
TFdcStatus ReadDataMfm(WORD nBytesToRead,LPBYTE buffer);
};
Expand Down Expand Up @@ -420,6 +422,7 @@
virtual TStdWinError SetMediumTypeAndGeometry(PCFormat pFormat,PCSide sideMap,TSector firstSectorNumber);
virtual bool EditSettings(bool initialEditing)=0;
virtual TStdWinError Reset()=0;
virtual std::unique_ptr<CTrackReader> GetTrackDescription(TCylinder cyl,THead head) const;
virtual TStdWinError SaveTrack(TCylinder cyl,THead head);
virtual TStdWinError FormatTrack(TCylinder cyl,THead head,TSector nSectors,PCSectorId bufferId,PCWORD bufferLength,PCFdcStatus bufferFdcStatus,BYTE gap3,BYTE fillerByte)=0;
virtual bool RequiresFormattedTracksVerification() const;
Expand Down
39 changes: 31 additions & 8 deletions Main/src/Image_TrackRW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
CImage::CTrackReader::CTrackReader(PLogTime _logTimes,DWORD nLogTimes,PCLogTime indexPulses,BYTE _nIndexPulses,TMedium::TType mediumType,TCodec codec)
// ctor
: logTimes(_logTimes+1) , nLogTimes(nLogTimes) // "+1" = hidden item represents reference counter
, nIndexPulses( std::min<BYTE>( DEVICE_REVOLUTIONS_MAX, _nIndexPulses ) )
, iNextIndexPulse(0) , nIndexPulses( std::min<BYTE>( DEVICE_REVOLUTIONS_MAX, _nIndexPulses ) )
, iNextTime(0) , currentTime(0)
, nConsecutiveZeros(0) {
::memcpy( this->indexPulses, indexPulses, nIndexPulses*sizeof(TLogTime) );
this->indexPulses[nIndexPulses]=INT_MAX; // a virtual IndexPulse in infinity
logTimes[-1]=1; // initializing the reference counter
SetCodec(codec); // setting values associated with the specified Codec
SetMediumType(mediumType); // setting values associated with the specified MediumType
Expand Down Expand Up @@ -39,9 +40,14 @@
// seeks to the specified LogicalTime
if (!nLogTimes)
return;
if (logTime<0)
logTime=0;
for( iNextIndexPulse=0; iNextIndexPulse<nIndexPulses; iNextIndexPulse++ )
if (logTime<=indexPulses[iNextIndexPulse])
break;
if (logTime<*logTimes){
iNextTime=0;
currentTime=std::max( logTime, 0 );
currentTime=logTime;
return;
}
DWORD L=0, R=nLogTimes;
Expand Down Expand Up @@ -73,12 +79,7 @@

TLogTime CImage::CTrackReader::ReadTime(){
// returns the next LogicalTime (or zero if all time information already read)
if (*this){
const TLogTime result= logTimes[iNextTime] - currentTime;
currentTime=logTimes[iNextTime++];
return result;
}else
return 0;
return *this ? logTimes[iNextTime++] : 0;
}

void CImage::CTrackReader::SetCodec(TCodec codec){
Expand Down Expand Up @@ -137,6 +138,12 @@

bool CImage::CTrackReader::ReadBit(){
// returns first bit not yet read
// - if we just crossed an IndexPulse, resetting the Profile
if (currentTime>=indexPulses[iNextIndexPulse]){
profile.Reset();
iNextIndexPulse++;
}
// - reading next bit
//switch (method){
//case TMethod::FDD_KEIR_FRASIER:
// FDC-like flux reversal decoding from Keir Frasier's Disk-Utilities/libdisk
Expand Down Expand Up @@ -354,6 +361,22 @@




void CImage::CTrackReader::TProfile::Reset(){
iwTime=iwTimeDefault;
}












CImage::CTrackReaderWriter::CTrackReaderWriter(DWORD nLogTimesMax)
// ctor
: CTrackReader( (PLogTime)::calloc(nLogTimesMax+1,sizeof(TLogTime)), 0, nullptr, 0, TMedium::FLOPPY_DD_350, TCodec::MFM ) // "+1" = hidden item represents reference counter
Expand Down

0 comments on commit 79913cd

Please sign in to comment.