|
419 | 419 | params.GetGlobalFluxDecoder(), params.resetFluxDecoderOnIndex
|
420 | 420 | );
|
421 | 421 | const PCBYTE pEnd=p+length;
|
422 |
| - for( int sampleCounter=0,sampleCounterSinceIndex=0; p<pEnd; p++ ){ |
423 |
| - const BYTE i=*p; |
424 |
| - if (i<TFluxOp::Special){ |
425 |
| - // flux information |
426 |
| - if (i<250) |
427 |
| - // "short" flux (1-249 samples, single Byte; 0 indicates end of Stream) |
428 |
| - sampleCounter+=i; |
429 |
| - else{ |
430 |
| - // "long" flux (250-1524 samples, two Bytes) |
431 |
| - if (++p>=pEnd) // unexpected end of Stream? |
432 |
| - return CTrackReaderWriter::Invalid; |
433 |
| - sampleCounter+=250+(i-250)*255+*p-1; |
434 |
| - } |
435 |
| - result.AddTime( |
436 |
| - result.GetLastIndexTime()+sampleClock*( sampleCounterSinceIndex+=sampleCounter ) |
437 |
| - ); |
438 |
| - sampleCounter=0; |
439 |
| - }else{ |
440 |
| - // special information |
441 |
| - if (++p>=pEnd) // unexpected end of Stream? (incl. below Opcode) |
442 |
| - return CTrackReaderWriter::Invalid; |
443 |
| - switch (const TFluxOp opcode=(TFluxOp)*p++){ |
444 |
| - case TFluxOp::Index:{ // index information |
445 |
| - if (p+sizeof(int)>=pEnd) // unexpected end of Stream? |
446 |
| - return CTrackReaderWriter::Invalid; |
447 |
| - const int value=ReadBits28(p); |
448 |
| - p+=sizeof(int)-1; // "-1" = see "p++" at the end of cycle |
449 |
| - result.AddIndexTime( |
450 |
| - result.GetLastIndexTime()+sampleClock*( sampleCounterSinceIndex+sampleCounter+value ) |
451 |
| - ); |
452 |
| - sampleCounterSinceIndex= -(sampleCounter+value); |
453 |
| - break; |
454 |
| - } |
455 |
| - case TFluxOp::Space: // "extra long" flux (1525-(2^28-1), seven Bytes, e.g. unformatted area) |
456 |
| - if (p+sizeof(int)>=pEnd) // unexpected end of Stream? |
457 |
| - return CTrackReaderWriter::Invalid; |
458 |
| - sampleCounter+=ReadBits28(p); // addendum to ... |
459 |
| - p+=sizeof(int)-1; // "-1" = see "p++" at the end of cycle |
460 |
| - break; // ... another flux |
461 |
| - //case TFluxOp::Astable: |
462 |
| - //commented out as Astable is intended for representation of non-formatted areas during writing, so it never appears during reading [personal communication with Keir Fraser] |
463 |
| - default: |
464 |
| - return CTrackReaderWriter::Invalid; |
465 |
| - } |
466 |
| - } |
467 |
| - } |
468 |
| - return result; |
| 422 | + for( int sampleCounter=0,sampleCounterSinceIndex=0; p<pEnd; p++ ){ |
| 423 | + const BYTE i=*p; |
| 424 | + if (i<TFluxOp::Special){ |
| 425 | + // flux information |
| 426 | + if (i<250) |
| 427 | + // "short" flux (1-249 samples, single Byte; 0 indicates end of Stream) |
| 428 | + sampleCounter+=i; |
| 429 | + else{ |
| 430 | + // "long" flux (250-1524 samples, two Bytes) |
| 431 | + if (++p>=pEnd) // unexpected end of Stream? |
| 432 | + return CTrackReaderWriter::Invalid; |
| 433 | + sampleCounter+=250+(i-250)*255+*p-1; |
| 434 | + } |
| 435 | + result.AddTime( |
| 436 | + result.GetLastIndexTime()+sampleClock*( sampleCounterSinceIndex+=sampleCounter ) |
| 437 | + ); |
| 438 | + sampleCounter=0; |
| 439 | + }else{ |
| 440 | + // special information |
| 441 | + if (++p>=pEnd) // unexpected end of Stream? (incl. below Opcode) |
| 442 | + return CTrackReaderWriter::Invalid; |
| 443 | + switch (const TFluxOp opcode=(TFluxOp)*p++){ |
| 444 | + case TFluxOp::Index:{ // index information |
| 445 | + if (p+sizeof(int)>=pEnd) // unexpected end of Stream? |
| 446 | + return CTrackReaderWriter::Invalid; |
| 447 | + const int value=ReadBits28(p); |
| 448 | + p+=sizeof(int)-1; // "-1" = see "p++" at the end of cycle |
| 449 | + result.AddIndexTime( |
| 450 | + result.GetLastIndexTime()+sampleClock*( sampleCounterSinceIndex+sampleCounter+value ) |
| 451 | + ); |
| 452 | + sampleCounterSinceIndex= -(sampleCounter+value); |
| 453 | + break; |
| 454 | + } |
| 455 | + case TFluxOp::Space: // "extra long" flux (1525-(2^28-1), seven Bytes, e.g. unformatted area) |
| 456 | + if (p+sizeof(int)>=pEnd) // unexpected end of Stream? |
| 457 | + return CTrackReaderWriter::Invalid; |
| 458 | + sampleCounter+=ReadBits28(p); // addendum to ... |
| 459 | + p+=sizeof(int)-1; // "-1" = see "p++" at the end of cycle |
| 460 | + break; // ... another flux |
| 461 | + //case TFluxOp::Astable: |
| 462 | + //commented out as Astable is intended for representation of non-formatted areas during writing, so it never appears during reading [personal communication with Keir Fraser] |
| 463 | + default: |
| 464 | + return CTrackReaderWriter::Invalid; |
| 465 | + } |
| 466 | + } |
| 467 | + } |
| 468 | + return result; |
469 | 469 | }
|
470 | 470 |
|
471 | 471 | CImage::CTrackReader CGreaseweazleV4::ReadTrack(TCylinder cyl,THead head) const{
|
|
650 | 650 | }
|
651 | 651 |
|
652 | 652 | void CGreaseweazleV4::SetPathName(LPCTSTR lpszPathName,BOOL bAddToMRU){
|
653 |
| - __super::SetPathName( lpszPathName, bAddToMRU ); |
654 |
| - m_strPathName=lpszPathName; |
| 653 | + TCHAR copy[DEVICE_NAME_CHARS_MAX+1]; |
| 654 | + __super::SetPathName( ::lstrcpy(copy,lpszPathName), bAddToMRU ); |
| 655 | + m_strPathName=copy; |
655 | 656 | }
|
0 commit comments