Massive refactor to work in logical cylinders everywhere. The logical/physical

mapping is now done at the last stage and should, ideally, be automatic. I'm
sure there are bugs everywhere.
This commit is contained in:
David Given
2022-03-25 00:22:28 +01:00
parent aaccd648b3
commit d303067deb
47 changed files with 2149 additions and 1643 deletions

View File

@@ -18,23 +18,27 @@ extern void setDecoderManualClockRate(double clockrate_us);
extern Bytes decodeFmMfm(std::vector<bool>::const_iterator start,
std::vector<bool>::const_iterator end);
extern void encodeMfm(std::vector<bool>& bits, unsigned& cursor, const Bytes& input, bool& lastBit);
extern void encodeFm(std::vector<bool>& bits, unsigned& cursor, const Bytes& input);
extern void encodeMfm(std::vector<bool>& bits,
unsigned& cursor,
const Bytes& input,
bool& lastBit);
extern void encodeFm(
std::vector<bool>& bits, unsigned& cursor, const Bytes& input);
extern Bytes encodeMfm(const Bytes& input, bool& lastBit);
static inline Bytes decodeFmMfm(const std::vector<bool> bits)
{ return decodeFmMfm(bits.begin(), bits.end()); }
{
return decodeFmMfm(bits.begin(), bits.end());
}
class AbstractDecoder
{
public:
AbstractDecoder(const DecoderProto& config):
_config(config)
{}
AbstractDecoder(const DecoderProto& config): _config(config) {}
virtual ~AbstractDecoder() {}
static std::unique_ptr<AbstractDecoder> create(const DecoderProto& config);
static std::unique_ptr<AbstractDecoder> create(const DecoderProto& config);
public:
enum RecordType
@@ -45,47 +49,59 @@ public:
};
public:
std::shared_ptr<const TrackDataFlux> decodeToSectors(std::shared_ptr<const Fluxmap> fluxmap, unsigned cylinder, unsigned head);
void pushRecord(const Fluxmap::Position& start, const Fluxmap::Position& end);
std::shared_ptr<const TrackDataFlux> decodeToSectors(
std::shared_ptr<const Fluxmap> fluxmap,
const Location& location);
void resetFluxDecoder();
void pushRecord(
const Fluxmap::Position& start, const Fluxmap::Position& end);
void resetFluxDecoder();
std::vector<bool> readRawBits(unsigned count);
uint8_t readRaw8();
uint16_t readRaw16();
uint32_t readRaw20();
uint32_t readRaw24();
uint32_t readRaw32();
uint64_t readRaw48();
uint64_t readRaw64();
uint8_t readRaw8();
uint16_t readRaw16();
uint32_t readRaw20();
uint32_t readRaw24();
uint32_t readRaw32();
uint64_t readRaw48();
uint64_t readRaw64();
Fluxmap::Position tell()
{ return _fmr->tell(); }
{
return _fmr->tell();
}
void seek(const Fluxmap::Position& pos)
{ return _fmr->seek(pos); }
{
return _fmr->seek(pos);
}
nanoseconds_t seekToPattern(const FluxMatcher& pattern);
void seekToIndexMark();
nanoseconds_t seekToPattern(const FluxMatcher& pattern);
void seekToIndexMark();
bool eof() const
{ return _fmr->eof(); }
{
return _fmr->eof();
}
nanoseconds_t getFluxmapDuration() const
{ return _fmr->getDuration(); }
nanoseconds_t getFluxmapDuration() const
{
return _fmr->getDuration();
}
virtual std::set<unsigned> requiredSectors(unsigned cylinder, unsigned head) const;
virtual std::set<unsigned> requiredSectors(const Location& location) const;
protected:
virtual void beginTrack() {};
virtual void beginTrack(){};
virtual nanoseconds_t advanceToNextRecord() = 0;
virtual void decodeSectorRecord() = 0;
virtual void decodeDataRecord() {};
virtual void decodeDataRecord(){};
const DecoderProto& _config;
std::shared_ptr<TrackDataFlux> _trackdata;
const DecoderProto& _config;
std::shared_ptr<TrackDataFlux> _trackdata;
std::shared_ptr<Sector> _sector;
std::unique_ptr<FluxDecoder> _decoder;
std::vector<bool> _recordBits;
std::unique_ptr<FluxDecoder> _decoder;
std::vector<bool> _recordBits;
private:
FluxmapReader* _fmr = nullptr;