Compare commits

...

2 Commits
imgui ... fixes

Author SHA1 Message Date
dg
4ab66afca0 Split the encoder's use of clock and bitcell, as for FM/MFM they're different
things; make the FM/MFM decoders use twice the bitcell for the clock.
2021-12-06 23:18:31 +00:00
dg
0af57f3e97 Create new branch named "fixes" 2021-12-06 22:42:19 +00:00
19 changed files with 39 additions and 29 deletions

View File

@@ -32,8 +32,9 @@ public:
RecordType advanceToNextRecord()
{
_sector->clock = _fmr->seekToPattern(SECTOR_PATTERN);
if (_fmr->eof() || !_sector->clock)
_sector->bitcell = _fmr->seekToPattern(SECTOR_PATTERN);
_sector->clock = _sector->bitcell * 2;
if (_fmr->eof() || !_sector->bitcell)
return UNKNOWN_RECORD;
return SECTOR_RECORD;
}

View File

@@ -31,8 +31,9 @@ public:
RecordType advanceToNextRecord() override
{
_sector->clock = _fmr->seekToPattern(SECTOR_PATTERN);
if (_fmr->eof() || !_sector->clock)
_sector->bitcell = _fmr->seekToPattern(SECTOR_PATTERN);
_sector->clock = _sector->bitcell * 2;
if (_fmr->eof() || !_sector->bitcell)
return UNKNOWN_RECORD;
return SECTOR_RECORD;
}

View File

@@ -74,7 +74,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return RecordType::SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -63,7 +63,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return RecordType::SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -61,7 +61,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return RecordType::SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -61,7 +61,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return RecordType::SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -107,7 +107,8 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(SECTOR_ID_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(SECTOR_ID_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
if (matcher == &SECTOR_ID_PATTERN)
return RecordType::SECTOR_RECORD;
return RecordType::UNKNOWN_RECORD;

View File

@@ -101,7 +101,8 @@ public:
RecordType advanceToNextRecord() override
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
/* If this is the MFM prefix byte, the the decoder is going to expect three
* extra bytes on the front of the header. */

View File

@@ -132,7 +132,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -35,7 +35,8 @@ public:
{
_fmr->seekToIndexMark();
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(SECTOR_SYNC_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(SECTOR_SYNC_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
if (matcher == &SECTOR_SYNC_PATTERN) {
return SECTOR_RECORD;
}

View File

@@ -31,7 +31,7 @@ public:
void beginTrack()
{
_currentSector = -1;
_clock = 0;
_bitcell = 0;
}
RecordType advanceToNextRecord()
@@ -40,8 +40,9 @@ public:
{
/* First sector in the track: look for the sync marker. */
const FluxMatcher* matcher = nullptr;
_sector->clock = _clock = _fmr->seekToPattern(ID_PATTERN, matcher);
readRawBits(32); /* skip the ID mark */
_sector->bitcell = _bitcell = _fmr->seekToPattern(ID_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
readRawBits(32); /* skip the ID mark */
_logicalTrack = decodeFmMfm(readRawBits(32)).slice(0, 32).reader().read_be16();
}
else if (_currentSector == 10)
@@ -54,7 +55,7 @@ public:
/* Otherwise we assume the clock from the first sector is still valid.
* The decoder framwork will automatically stop when we hit the end of
* the track. */
_sector->clock = _clock;
_sector->bitcell = _bitcell;
}
_currentSector++;
@@ -80,7 +81,7 @@ public:
}
private:
nanoseconds_t _clock;
nanoseconds_t _bitcell;
int _currentSector;
int _logicalTrack;
};

View File

@@ -105,7 +105,8 @@ public:
* past one or more sector pulses. For this reason, calculate
* _hardSectorId after the sector header is found.
*/
_sector->clock = _fmr->seekToPattern(ANY_SECTOR_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(ANY_SECTOR_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
int sectorFoundTimeRaw = std::round((_fmr->tell().ns()) / 1e6);
int sectorFoundTime;

View File

@@ -48,7 +48,8 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
if (matcher == &SECTOR_RECORD_PATTERN)
return RecordType::SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -62,7 +62,7 @@ public:
RecordType advanceToNextRecord()
{
const FluxMatcher* matcher = nullptr;
_sector->clock = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
_sector->clock = _sector->bitcell = _fmr->seekToPattern(ANY_RECORD_PATTERN, matcher);
if (matcher == &SECTOR_RECORD_PATTERN)
return SECTOR_RECORD;
if (matcher == &DATA_RECORD_PATTERN)

View File

@@ -24,7 +24,8 @@ public:
{
const FluxMatcher* matcher = nullptr;
_fmr->seekToIndexMark();
_sector->clock = _fmr->seekToPattern(SECTOR_START_PATTERN, matcher);
_sector->bitcell = _fmr->seekToPattern(SECTOR_START_PATTERN, matcher);
_sector->clock = _sector->bitcell * 2;
if (matcher == &SECTOR_START_PATTERN)
return SECTOR_RECORD;
return UNKNOWN_RECORD;

View File

@@ -77,9 +77,9 @@ std::unique_ptr<TrackDataFlux> AbstractDecoder::decodeToSectors(
_sector->physicalHead = physicalHead;
Fluxmap::Position recordStart = fmr.tell();
_decoder.reset(new FluxDecoder(&fmr, _sector->clock, _config));
_decoder.reset(new FluxDecoder(&fmr, _sector->bitcell, _config));
RecordType r = advanceToNextRecord();
if (fmr.eof() || !_sector->clock)
if (fmr.eof() || !_sector->bitcell)
return std::move(_trackdata);
if ((r == UNKNOWN_RECORD) || (r == DATA_RECORD))
{
@@ -134,17 +134,17 @@ void AbstractDecoder::pushRecord(const Fluxmap::Position& start, const Fluxmap::
record->startTime = start.ns();
record->endTime = end.ns();
record->clock = _sector->clock;
record->bitcell = _sector->bitcell;
_fmr->seek(start);
FluxDecoder decoder(_fmr, _sector->clock, _config);
FluxDecoder decoder(_fmr, _sector->bitcell, _config);
record->rawData = toBytes(decoder.readBits(end));
_fmr->seek(here);
}
void AbstractDecoder::resetFluxDecoder()
{
_decoder.reset(new FluxDecoder(_fmr, _sector->clock, _config));
_decoder.reset(new FluxDecoder(_fmr, _sector->bitcell, _config));
}
std::vector<bool> AbstractDecoder::readRawBits(unsigned count)

View File

@@ -6,7 +6,7 @@ class Image;
struct Record
{
nanoseconds_t clock = 0;
nanoseconds_t bitcell = 0;
nanoseconds_t startTime = 0;
nanoseconds_t endTime = 0;
Bytes rawData;

View File

@@ -156,9 +156,9 @@ void readDiskCommand(FluxSource& fluxsource, AbstractDecoder& decoder, ImageWrit
std::cout << "\nRaw (undecoded) records follow:\n\n";
for (const auto& record : track_records)
{
std::cout << fmt::format("I+{:.2f}us with {:.2f}us clock\n",
std::cout << fmt::format("I+{:.2f}us with {:.2f}us bitcell\n",
record->startTime / 1000.0,
record->clock / 1000.0);
record->bitcell / 1000.0);
hexdump(std::cout, record->rawData);
std::cout << std::endl;
}

View File

@@ -28,6 +28,7 @@ public:
Status status = Status::INTERNAL_ERROR;
Fluxmap::Position position;
nanoseconds_t clock = 0;
nanoseconds_t bitcell = 0;
nanoseconds_t headerStartTime = 0;
nanoseconds_t headerEndTime = 0;
nanoseconds_t dataStartTime = 0;