28
28
29
29
30
30
31
- #define HEADER_SIGNATURE " HXCPICFE"
31
+ #define HEADER_SIGNATURE " HXCPICFE"
32
32
33
- CHFE::UHeader::UHeader (){
33
+ CHFE::UHeader::UHeader (){
34
34
// ctor
35
35
::ZeroMemory ( this , sizeof (*this ) );
36
- ::lstrcpyA ( signature, HEADER_SIGNATURE );
36
+ ::lstrcpyA ( signature, HEADER_SIGNATURE );
37
37
trackEncoding=TTrackEncoding::UNKNOWN;
38
38
floppyInterface=TFloppyInterface::DISABLED;
39
39
cylInfosBegin=1 ;
43
43
44
44
bool CHFE::UHeader::IsValid () const {
45
45
// True <=> this Header follows HFE specification, otherwise False
46
- return !::memcmp ( signature, HEADER_SIGNATURE, sizeof (signature) )
46
+ return !::memcmp ( signature, HEADER_SIGNATURE, sizeof (signature) )
47
+ &&
48
+ formatRevision==0
47
49
&&
48
- formatRevision==0
49
- &&
50
50
0 <nCylinders // mustn't be zero for 'capsImageInfo.maxcylinder' is inclusive! (and "-1" isn't valid)
51
51
&&
52
52
0 <nHeads && nHeads<=2
67
67
68
68
CHFE::CTrackBytes::CTrackBytes (WORD count)
69
69
// ctor
70
- : Utils::CCallocPtr<BYTE>( Utils::RoundUpToMuls(count,(WORD) sizeof(TTrackData)), 0 )
70
+ : Utils::CCallocPtr<BYTE>( Utils::RoundUpToMuls< int > (count,sizeof (TTrackData)), 0 )
71
71
, count(count) {
72
72
ASSERT ( count>0 ); // call Invalidate() to indicate "no Bytes"
73
73
}
85
85
86
86
void CHFE::CTrackBytes::ReverseBitsInEachByte () const {
87
87
// reverses the order of bits in each Byte
88
- for ( PBYTE p=*this ,pLast=p+count ; p<pLast; p++ )
88
+ for ( PBYTE p=*this ,pLast=GetEnd () ; p<pLast; p++ )
89
89
*p=Utils::GetReversedByte (*p);
90
90
}
91
91
95
95
96
96
97
97
98
-
98
+
99
99
#define INI_SECTION _T (" HxC2k1" )
100
100
101
- CHFE::CHFE()
102
- // ctor
103
- : CCapsBase( &Properties, ' \0 ' , true , INI_SECTION ) {
104
- Reset ();
101
+ CHFE::CHFE()
102
+ // ctor
103
+ : CCapsBase( &Properties, ' \0 ' , true , INI_SECTION ) {
104
+ Reset ();
105
105
}
106
106
107
107
@@ -232,8 +232,9 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
232
232
else
233
233
return ERROR_UNRECOGNIZED_MEDIA;
234
234
// - base
235
- if (floppyType!=pFormat->mediumType )
236
- DestroyAllTracks (); // must reconstruct all Tracks with parameters corresponding to new Medium Type
235
+ if (floppyType!=pFormat->mediumType ) // must reconstruct all Tracks with parameters corresponding to new Medium Type?
236
+ if (m_strPathName.GetLength ()>0 )
237
+ DestroyAllTracks ();
237
238
return __super::SetMediumTypeAndGeometry ( pFormat, sideMap, firstSectorNumber );
238
239
}
239
240
@@ -249,12 +250,12 @@ formatError: ::SetLastError(ERROR_BAD_FORMAT);
249
250
if (const TStdWinError err=__super::Reset ())
250
251
return err;
251
252
// - reinitializing to an empty Image
252
- header=UHeader ();
253
+ header=UHeader ();
253
254
::ZeroMemory ( cylInfos, sizeof (cylInfos) );
254
255
::ZeroMemory ( &capsImageInfo, sizeof (capsImageInfo) );
255
256
return ERROR_SUCCESS;
256
257
}
257
-
258
+
258
259
259
260
CHFE::CTrackBytes CHFE::ReadTrackBytes (TCylinder cyl,THead head) const {
260
261
// reads from File and returns raw data of specified Track
0 commit comments