Skip to content

Commit

Permalink
[#80] Support for HxC Floppy Emulator *.HFE images (Part 9: The "flop…
Browse files Browse the repository at this point in the history
…pyInterface" value in header seems to be not trusted at all; came across a MS-DOS HD disk where set to ATARI_ST_DD)
  • Loading branch information
tomas-nestorovic committed Sep 10, 2024
1 parent ef7f487 commit 69ee55b
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions Main/src/HFE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,37 @@

#define TRACK_BYTES_MAX USHRT_MAX

CHFE::CTrackBytes::CTrackBytes(WORD count)
// ctor
: Utils::CCallocPtr<BYTE>( Utils::RoundUpToMuls<int>(count,sizeof(TTrackData)), 0 )
, count(count) {
ASSERT( count>0 ); // call Invalidate() to indicate "no Bytes"
}

CHFE::CTrackBytes::CTrackBytes(CTrackBytes &&r)
// move ctor
: count(r.count) {
reset( r.release() );
}

void CHFE::CTrackBytes::Invalidate(){
// disposes all Bytes, rendering this object unusable
reset(nullptr), count=0;
}

void CHFE::CTrackBytes::ReverseBitsInEachByte() const{
// reverses the order of bits in each Byte
for( PBYTE p=*this,pLast=GetEnd(); p<pLast; p++ )
*p=Utils::GetReversedByte(*p);
}
CHFE::CTrackBytes::CTrackBytes(WORD count)
// ctor
: Utils::CCallocPtr<BYTE>( Utils::RoundUpToMuls<int>(count,sizeof(TTrackData)), 0 )
, count(count) {
ASSERT( count>0 ); // call Invalidate() to indicate "no Bytes"
}

CHFE::CTrackBytes::CTrackBytes(CTrackBytes &&r)
// move ctor
: count(r.count) {
reset( r.release() );
}

void CHFE::CTrackBytes::Invalidate(){
// disposes all Bytes, rendering this object unusable
reset(nullptr), count=0;
}

void CHFE::CTrackBytes::ReverseBitsInEachByte() const{
// reverses the order of bits in each Byte
for( PBYTE p=*this,pLast=GetEnd(); p<pLast; p++ )
*p=Utils::GetReversedByte(*p);
}









#define INI_SECTION _T("HxC2k1")

CHFE::CHFE()
Expand Down 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,15 +194,15 @@ 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);
}
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();
// - must be setting Medium compatible with the FloppyInterface specified in the Header
if (header.floppyInterface<TFloppyInterface::LAST_KNOWN)
/*if (header.floppyInterface<TFloppyInterface::LAST_KNOWN)
switch (pFormat->mediumType){
case Medium::FLOPPY_DD:{
static constexpr TFloppyInterface Compatibles[]={ TFloppyInterface::IBM_PC_DD, TFloppyInterface::ATARI_ST_DD, TFloppyInterface::AMIGA_DD, TFloppyInterface::CPC_DD, TFloppyInterface::GENERIC_SHUGART, TFloppyInterface::MSX2_DD, TFloppyInterface::C64_DD, TFloppyInterface::EMU_SHUGART, TFloppyInterface::S950_DD };
Expand All @@ -225,7 +225,7 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
}
default:
return ERROR_UNRECOGNIZED_MEDIA;
}
}*/
// - must be setting Medium compatible with the nominal # of Cells
if (pFormat->mediumType!=Medium::UNKNOWN){
const auto mp=Medium::GetProperties(pFormat->mediumType);
Expand Down

0 comments on commit 69ee55b

Please sign in to comment.