Skip to content

Commit

Permalink
[#64] Internal FDD improvements and bugfixes (Part 1: Each sector can…
Browse files Browse the repository at this point in the history
… formally be queried infinite amount of times)
  • Loading branch information
tomas-nestorovic committed May 23, 2021
1 parent 1f4d1b9 commit 57f4e3c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Main/src/FDD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ error: switch (const TStdWinError err=::GetLastError()){
return 2; // latest PC floppy drives had two Heads
}

BYTE CFDD::GetAvailableRevolutionCount() const{
// returns the number of data variations of one Sector that are guaranteed to be distinct
return Revolution::INFINITY;
}

CFDD::PInternalTrack CFDD::__scanTrack__(TCylinder cyl,THead head){
// scans given Track and returns the number of discovered Sectors; returns Null if Track cannot be scanned (e.g. due to an hardware error or "out-of-range" error)
// - attempting to scan the specified Track
Expand Down
1 change: 1 addition & 0 deletions Main/src/FDD.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
BOOL OnOpenDocument(LPCTSTR) override;
TCylinder GetCylinderCount() const override;
THead GetHeadCount() const override;
BYTE GetAvailableRevolutionCount() const override;
TSector ScanTrack(TCylinder cyl,THead head,Codec::PType pCodec=nullptr,PSectorId bufferId=nullptr,PWORD bufferLength=nullptr,PLogTime startTimesNanoseconds=nullptr,PBYTE pAvgGap3=nullptr) const override;
void GetTrackData(TCylinder cyl,THead head,Revolution::TType rev,PCSectorId bufferId,PCBYTE bufferNumbersOfSectorsToSkip,TSector nSectors,bool silentlyRecoverFromErrors,PSectorData *outBufferData,PWORD outBufferLengths,TFdcStatus *outFdcStatuses) override;
TStdWinError MarkSectorAsDirty(RCPhysicalAddress chs,BYTE nSectorsToSkip,PCFdcStatus pFdcStatus) override;
Expand Down
1 change: 1 addition & 0 deletions Main/src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
MAX,
NONE,
UNKNOWN,
INFINITY,
// the following constants should be ignored by all containers
ANY_GOOD,
ALL_INTERSECTED
Expand Down
2 changes: 1 addition & 1 deletion Main/src/ImageFloppy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
ps->scannedTracks.infos[req.track].bufferedRevs|=1<<req.revolution;
}else{
// all Revolutions wanted
for( BYTE rev=image->GetAvailableRevolutionCount(); rev-->0; )
for( BYTE rev=std::min<BYTE>(Revolution::MAX,image->GetAvailableRevolutionCount()); rev-->0; )
image->BufferTrackData(
req.track>>1, req.track&1, (Revolution::TType)rev,
ids, Utils::CByteIdentity(),
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Image_SectorDataSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CImage::CSectorDataSerializer::CSectorDataSerializer(CHexaEditor *pParentHexaEditor,PImage image,LONG dataTotalLength)
// ctor
: pParentHexaEditor(pParentHexaEditor) , image(image) , dataTotalLength(dataTotalLength) , position(0) , currTrack(0)
, nAvailableRevolutions( image->GetAvailableRevolutionCount() )
, nAvailableRevolutions( std::min<BYTE>(Revolution::MAX,image->GetAvailableRevolutionCount()) )
, revolution(Revolution::ANY_GOOD) {
sector.indexOnTrack=0, sector.offset=0;
}
Expand Down
2 changes: 1 addition & 1 deletion Main/src/ViewDiskBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
case ID_DEFAULT6:
case ID_DEFAULT7:
case ID_DEFAULT8:
if (nID-ID_DEFAULT1<IMAGE->GetAvailableRevolutionCount()){
if (nID-ID_DEFAULT1<std::min<BYTE>(Revolution::MAX,IMAGE->GetAvailableRevolutionCount())){
pCmdUi->SetRadio( revolution==nID-ID_DEFAULT1 );
}else
pCmdUi->m_pMenu->RemoveMenu( nID, MF_BYCOMMAND );
Expand Down

0 comments on commit 57f4e3c

Please sign in to comment.