Skip to content

Commit

Permalink
[#80] Support for HxC Floppy Emulator *.HFE images (Part 7: Fixed det…
Browse files Browse the repository at this point in the history
…ermination of medium type)
  • Loading branch information
tomas-nestorovic committed Sep 10, 2024
1 parent e7e174c commit 9a48cb0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Main/src/HFE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
CImage::CTrackReader CHFE::ReadTrack(TCylinder cyl,THead head) const{
// creates and returns a general description of the specified Track, represented using neutral LogicalTimes
EXCLUSIVELY_LOCK_THIS_IMAGE();
// - if Track already read before, returning the result from before
if (const auto tr=ReadExistingTrack(cyl,head))
return tr;
// - if Track already read before, returning the result from before
if (const auto tr=ReadExistingTrack(cyl,head))
return tr;
// - checking that specified Track actually CAN exist
if (cyl>capsImageInfo.maxcylinder || head>capsImageInfo.maxhead)
return CTrackReaderWriter::Invalid;
Expand All @@ -194,9 +194,13 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
return dataBitRate*2; // "*2" = data and clock bits
}

inline static TLogTime GetCellTime(int dataBitRate){
return TIME_SECOND(1)/GetTotalBitRate(dataBitRate);
}

TStdWinError CHFE::SetMediumTypeAndGeometry(PCFormat pFormat,PCSide sideMap,TSector firstSectorNumber){
// sets the given MediumType and its geometry; returns Windows standard i/o error
EXCLUSIVELY_LOCK_THIS_IMAGE();
EXCLUSIVELY_LOCK_THIS_IMAGE();
// - must be setting Medium compatible with the FloppyInterface specified in the Header
if (header.floppyInterface<TFloppyInterface::LAST_KNOWN)
switch (pFormat->mediumType){
Expand All @@ -223,13 +227,11 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
return ERROR_UNRECOGNIZED_MEDIA;
}
// - must be setting Medium compatible with the nominal # of Cells
if (pFormat->mediumType!=Medium::UNKNOWN)
for( TCylinder cyl=0; cyl<=capsImageInfo.maxcylinder; cyl++ ) // inclusive!
if (cylInfos[cyl].IsValid())
if (Medium::GetProperties(pFormat->mediumType)->IsAcceptableCountOfCells( GetTotalBitRate(header.dataBitRate) ))
break;
else
return ERROR_UNRECOGNIZED_MEDIA;
if (pFormat->mediumType!=Medium::UNKNOWN){
const auto mp=Medium::GetProperties(pFormat->mediumType);
if (!mp->IsAcceptableCountOfCells( mp->revolutionTime/GetCellTime(header.dataBitRate*1000) ))
return ERROR_UNRECOGNIZED_MEDIA;
}
// - base
if (floppyType!=pFormat->mediumType) // must reconstruct all Tracks with parameters corresponding to new Medium Type?
if (m_strPathName.GetLength()>0)
Expand Down

0 comments on commit 9a48cb0

Please sign in to comment.