14void SectorBasedDisk::writeTrackImpl(uint8_t track, uint8_t side,
const RawTrack& input)
16 for (
const auto& s : input.decodeAll()) {
25 auto logicalSector =
physToLog(track, side, s.sector);
32void SectorBasedDisk::readTrack(uint8_t track, uint8_t side, RawTrack& output)
43 int num = track | (side << 8);
44 if (num == cachedTrackNum) {
45 output = cachedTrackData;
85 auto write = [&](
unsigned n, uint8_t value) {
86 repeat(n, [&] { output.write(idx++, value); });
99 output.write(idx++, 0xFE,
true);
100 output.write(idx++, track);
101 output.write(idx++, side);
102 output.write(idx++, narrow<uint8_t>(j + 1));
103 output.write(idx++, 0x02);
104 uint16_t addrCrc = output.calcCrc(idx - 8, 8);
105 output.write(idx++, narrow_cast<uint8_t>(addrCrc >> 8));
106 output.write(idx++, narrow_cast<uint8_t>(addrCrc & 0xff));
114 auto logicalSector =
physToLog(track, side, narrow<uint8_t>(j + 1));
117 for (
auto r : buf.raw) output.write(idx++, r);
119 uint16_t dataCrc = output.calcCrc(idx - (512 + 4), 512 + 4);
120 output.write(idx++, narrow_cast<uint8_t>(dataCrc >> 8));
121 output.write(idx++, narrow_cast<uint8_t>(dataCrc & 0xff));
128 }
catch (MSXException& ) {
137 cachedTrackData = output;
146size_t SectorBasedDisk::getNbSectorsImpl()
const
148 assert(nbSectors !=
size_t(-1));
153 assert(nbSectors ==
size_t(-1));
size_t physToLog(uint8_t track, uint8_t side, uint8_t sector)
unsigned getSectorsPerTrack()
void setNbSides(unsigned num)
void setSectorsPerTrack(unsigned num)
virtual void detectGeometry()
static constexpr unsigned STANDARD_SIZE
void readBlock(int idx, std::span< uint8_t > destination) const
Like memcpy() but copy from/to circular buffer.
virtual void checkCaches()
size_t getNbSectors() const
virtual void flushCaches()
void readSector(size_t sector, SectorBuffer &buf) const
void writeSector(size_t sector, const SectorBuffer &buf)
void detectGeometry() override
void setNbSectors(size_t num)
void flushCaches() override
SectorBasedDisk(DiskName name)
This file implemented 3 utility functions:
std::array< uint8_t, 512 > raw
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
constexpr auto xrange(T e)