89 template<
typename Archive>
90 void serialize(Archive& ar,
unsigned version);
97 void clear(
unsigned size);
100 [[nodiscard]]
unsigned getLength()
const {
return unsigned(data.size()); }
108 void write(
int idx, uint8_t val,
bool setIdam =
false);
112 int size = narrow<int>(data.size());
113 int tmp = idx % size;
114 return (tmp >= 0) ? tmp : (tmp + size);
118 [[nodiscard]] std::span<const uint8_t>
getRawBuffer()
const {
return data; }
122 [[nodiscard]] std::vector<Sector>
decodeAll()
const;
125 [[nodiscard]] std::optional<Sector>
decodeNextSector(
unsigned startIdx)
const;
132 [[nodiscard]] std::optional<Sector>
decodeSector(uint8_t sectorNum)
const;
135 void readBlock (
int idx, std::span<uint8_t> destination)
const;
136 void writeBlock(
int idx, std::span<const uint8_t> source);
139 [[nodiscard]] uint16_t
calcCrc(
int idx,
int size)
const;
144 template<
typename Archive>
145 void serialize(Archive& ar,
unsigned version);
148 [[nodiscard]] std::optional<Sector> decodeSectorImpl(
int idx)
const;
154 std::vector<unsigned> idam;
159 std::vector<uint8_t> data;
This class calculates CRC numbers for the polygon x^16 + x^12 + x^5 + 1.
std::vector< Sector > decodeAll() const
Get info on all sectors in this track.
void write(int idx, uint8_t val, bool setIdam=false)
void addIdam(unsigned idx)
uint8_t read(int idx) const
void serialize(Archive &ar, unsigned version)
const auto & getIdamBuffer() const
std::optional< Sector > decodeNextSector(unsigned startIdx) const
Get the next sector (starting from a certain index).
std::optional< Sector > decodeSector(uint8_t sectorNum) const
Get a sector with a specific number.
std::span< uint8_t > getRawBuffer()
static constexpr unsigned STANDARD_SIZE
void applyWd2793ReadTrackQuirk()
int wrapIndex(int idx) const
void updateCrc(CRC16 &crc, int idx, int size) const
void writeBlock(int idx, std::span< const uint8_t > source)
void clear(unsigned size)
Clear track data.
std::span< const uint8_t > getRawBuffer() const
void readBlock(int idx, std::span< uint8_t > destination) const
Like memcpy() but copy from/to circular buffer.
unsigned getLength() const
Get track length.
uint16_t calcCrc(int idx, int size) const
Convenience method to calculate CRC for part of this track.
This file implemented 3 utility functions:
void serialize(Archive &ar, unsigned version)