2016-09-18 17:35:54 +00:00
|
|
|
//
|
|
|
|
// MFM.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 18/09/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-09-18 17:35:54 +00:00
|
|
|
//
|
|
|
|
|
2017-09-25 01:40:43 +00:00
|
|
|
#include "Encoder.hpp"
|
2016-09-18 17:35:54 +00:00
|
|
|
|
2017-09-25 01:40:43 +00:00
|
|
|
#include "Constants.hpp"
|
2017-09-25 00:07:56 +00:00
|
|
|
#include "../../Track/PCMTrack.hpp"
|
2020-01-20 04:14:35 +00:00
|
|
|
#include "../../../../Numeric/CRC.hpp"
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
#include <cassert>
|
2017-08-17 19:31:53 +00:00
|
|
|
#include <set>
|
|
|
|
|
2016-09-18 20:53:21 +00:00
|
|
|
using namespace Storage::Encodings::MFM;
|
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
enum class SurfaceItem {
|
|
|
|
Mark,
|
|
|
|
Data
|
|
|
|
};
|
|
|
|
|
2016-11-26 05:39:20 +00:00
|
|
|
class MFMEncoder: public Encoder {
|
2016-09-18 21:16:20 +00:00
|
|
|
public:
|
2020-01-20 02:08:15 +00:00
|
|
|
MFMEncoder(std::vector<bool> &target, std::vector<bool> *fuzzy_target = nullptr) : Encoder(target, fuzzy_target) {}
|
2019-01-14 00:19:01 +00:00
|
|
|
virtual ~MFMEncoder() {}
|
2016-09-18 21:16:20 +00:00
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
void add_byte(uint8_t input, uint8_t fuzzy_mask = 0) final {
|
2016-12-28 23:29:37 +00:00
|
|
|
crc_generator_.add(input);
|
2020-01-20 02:20:21 +00:00
|
|
|
const uint16_t spread_value =
|
2020-05-10 03:00:39 +00:00
|
|
|
uint16_t(
|
2016-09-18 21:16:20 +00:00
|
|
|
((input & 0x01) << 0) |
|
|
|
|
((input & 0x02) << 1) |
|
|
|
|
((input & 0x04) << 2) |
|
|
|
|
((input & 0x08) << 3) |
|
|
|
|
((input & 0x10) << 4) |
|
|
|
|
((input & 0x20) << 5) |
|
|
|
|
((input & 0x40) << 6) |
|
|
|
|
((input & 0x80) << 7)
|
|
|
|
);
|
2020-05-10 03:00:39 +00:00
|
|
|
const uint16_t or_bits = uint16_t((spread_value << 1) | (spread_value >> 1) | (last_output_ << 15));
|
2020-01-20 02:20:21 +00:00
|
|
|
const uint16_t output = spread_value | ((~or_bits) & 0xaaaa);
|
|
|
|
|
|
|
|
const uint16_t spread_mask =
|
2020-05-10 03:00:39 +00:00
|
|
|
uint16_t(
|
2020-01-20 02:20:21 +00:00
|
|
|
((fuzzy_mask & 0x01) << 0) |
|
|
|
|
((fuzzy_mask & 0x02) << 1) |
|
|
|
|
((fuzzy_mask & 0x04) << 2) |
|
|
|
|
((fuzzy_mask & 0x08) << 3) |
|
|
|
|
((fuzzy_mask & 0x10) << 4) |
|
|
|
|
((fuzzy_mask & 0x20) << 5) |
|
|
|
|
((fuzzy_mask & 0x40) << 6) |
|
|
|
|
((fuzzy_mask & 0x80) << 7)
|
|
|
|
);
|
|
|
|
|
|
|
|
output_short(output, spread_mask);
|
2016-09-18 20:53:21 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_index_address_mark() final {
|
2016-12-28 23:29:37 +00:00
|
|
|
for(int c = 0; c < 3; c++) output_short(MFMIndexSync);
|
2016-12-31 20:25:11 +00:00
|
|
|
add_byte(IndexAddressByte);
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_ID_address_mark() final {
|
2016-12-28 23:29:37 +00:00
|
|
|
output_sync();
|
2016-12-31 20:25:11 +00:00
|
|
|
add_byte(IDAddressByte);
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_data_address_mark() final {
|
2016-12-28 23:29:37 +00:00
|
|
|
output_sync();
|
2016-12-31 20:25:11 +00:00
|
|
|
add_byte(DataAddressByte);
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_deleted_data_address_mark() final {
|
2016-12-28 23:29:37 +00:00
|
|
|
output_sync();
|
2016-12-31 20:25:11 +00:00
|
|
|
add_byte(DeletedDataAddressByte);
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
size_t item_size(SurfaceItem item) {
|
|
|
|
switch(item) {
|
|
|
|
case SurfaceItem::Mark: return 8; // Three syncs plus the mark type.
|
|
|
|
case SurfaceItem::Data: return 2; // Just a single encoded byte.
|
|
|
|
default: assert(false);
|
|
|
|
}
|
2020-01-03 04:43:53 +00:00
|
|
|
return 0; // Should be impossible to reach in debug builds.
|
2019-12-20 00:22:48 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 21:16:20 +00:00
|
|
|
private:
|
2016-12-28 23:29:37 +00:00
|
|
|
uint16_t last_output_;
|
2020-01-20 02:20:21 +00:00
|
|
|
void output_short(uint16_t value, uint16_t fuzzy_mask = 0) final {
|
2016-12-28 23:29:37 +00:00
|
|
|
last_output_ = value;
|
2020-01-20 02:20:21 +00:00
|
|
|
Encoder::output_short(value, fuzzy_mask);
|
2016-12-28 23:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void output_sync() {
|
|
|
|
for(int c = 0; c < 3; c++) output_short(MFMSync);
|
|
|
|
crc_generator_.set_value(MFMPostSyncCRCValue);
|
|
|
|
}
|
2016-09-18 21:16:20 +00:00
|
|
|
};
|
|
|
|
|
2016-11-26 05:39:20 +00:00
|
|
|
class FMEncoder: public Encoder {
|
2016-09-18 22:46:58 +00:00
|
|
|
// encodes each 16-bit part as clock, data, clock, data [...]
|
2016-09-18 21:16:20 +00:00
|
|
|
public:
|
2020-01-20 02:08:15 +00:00
|
|
|
FMEncoder(std::vector<bool> &target, std::vector<bool> *fuzzy_target = nullptr) : Encoder(target, fuzzy_target) {}
|
2016-11-26 05:39:20 +00:00
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
void add_byte(uint8_t input, uint8_t fuzzy_mask = 0) final {
|
2016-12-28 23:29:37 +00:00
|
|
|
crc_generator_.add(input);
|
2016-11-26 05:39:20 +00:00
|
|
|
output_short(
|
2020-05-10 03:00:39 +00:00
|
|
|
uint16_t(
|
2016-09-18 22:46:58 +00:00
|
|
|
((input & 0x01) << 0) |
|
|
|
|
((input & 0x02) << 1) |
|
|
|
|
((input & 0x04) << 2) |
|
|
|
|
((input & 0x08) << 3) |
|
|
|
|
((input & 0x10) << 4) |
|
|
|
|
((input & 0x20) << 5) |
|
|
|
|
((input & 0x40) << 6) |
|
|
|
|
((input & 0x80) << 7) |
|
|
|
|
0xaaaa
|
2020-01-20 02:20:21 +00:00
|
|
|
),
|
2020-05-10 03:00:39 +00:00
|
|
|
uint16_t(
|
2020-01-20 02:20:21 +00:00
|
|
|
((fuzzy_mask & 0x01) << 0) |
|
|
|
|
((fuzzy_mask & 0x02) << 1) |
|
|
|
|
((fuzzy_mask & 0x04) << 2) |
|
|
|
|
((fuzzy_mask & 0x08) << 3) |
|
|
|
|
((fuzzy_mask & 0x10) << 4) |
|
|
|
|
((fuzzy_mask & 0x20) << 5) |
|
|
|
|
((fuzzy_mask & 0x40) << 6) |
|
|
|
|
((fuzzy_mask & 0x80) << 7)
|
|
|
|
)
|
|
|
|
);
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_index_address_mark() final {
|
2016-12-28 23:56:53 +00:00
|
|
|
crc_generator_.reset();
|
2016-12-31 20:25:11 +00:00
|
|
|
crc_generator_.add(IndexAddressByte);
|
2016-12-28 23:56:53 +00:00
|
|
|
output_short(FMIndexAddressMark);
|
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_ID_address_mark() final {
|
2016-12-28 23:56:53 +00:00
|
|
|
crc_generator_.reset();
|
2016-12-31 20:25:11 +00:00
|
|
|
crc_generator_.add(IDAddressByte);
|
2016-12-28 23:56:53 +00:00
|
|
|
output_short(FMIDAddressMark);
|
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_data_address_mark() final {
|
2016-12-28 23:56:53 +00:00
|
|
|
crc_generator_.reset();
|
2016-12-31 20:25:11 +00:00
|
|
|
crc_generator_.add(DataAddressByte);
|
2016-12-28 23:56:53 +00:00
|
|
|
output_short(FMDataAddressMark);
|
|
|
|
}
|
|
|
|
|
2020-01-20 01:37:54 +00:00
|
|
|
void add_deleted_data_address_mark() final {
|
2016-12-28 23:56:53 +00:00
|
|
|
crc_generator_.reset();
|
2016-12-31 20:25:11 +00:00
|
|
|
crc_generator_.add(DeletedDataAddressByte);
|
2016-12-28 23:56:53 +00:00
|
|
|
output_short(FMDeletedDataAddressMark);
|
|
|
|
}
|
2019-12-20 00:22:48 +00:00
|
|
|
|
2020-05-30 05:06:43 +00:00
|
|
|
size_t item_size(SurfaceItem) {
|
2019-12-20 00:22:48 +00:00
|
|
|
// Marks are just slightly-invalid bytes, so everything is the same length.
|
|
|
|
return 2;
|
|
|
|
}
|
2016-09-18 21:16:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class T> std::shared_ptr<Storage::Disk::Track>
|
2017-03-26 18:34:47 +00:00
|
|
|
GetTrackWithSectors(
|
2017-11-01 01:32:28 +00:00
|
|
|
const std::vector<const Sector *> §ors,
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t post_index_address_mark_bytes, uint8_t post_index_address_mark_value,
|
|
|
|
std::size_t pre_address_mark_bytes,
|
|
|
|
std::size_t post_address_mark_bytes, uint8_t post_address_mark_value,
|
|
|
|
std::size_t pre_data_mark_bytes,
|
|
|
|
std::size_t post_data_bytes, uint8_t post_data_value,
|
|
|
|
std::size_t expected_track_bytes) {
|
2016-11-26 05:39:20 +00:00
|
|
|
Storage::Disk::PCMSegment segment;
|
2018-07-01 18:40:48 +00:00
|
|
|
segment.data.reserve(expected_track_bytes * 8);
|
2016-11-26 05:39:20 +00:00
|
|
|
T shifter(segment.data);
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Make a pre-estimate of output size, in case any of the idealised gaps
|
|
|
|
// provided need to be shortened.
|
|
|
|
const size_t data_size = shifter.item_size(SurfaceItem::Data);
|
|
|
|
const size_t mark_size = shifter.item_size(SurfaceItem::Mark);
|
|
|
|
const size_t max_size = (expected_track_bytes + (expected_track_bytes / 10)) * 8;
|
|
|
|
|
|
|
|
size_t total_sector_bytes = 0;
|
|
|
|
for(const auto sector : sectors) {
|
|
|
|
total_sector_bytes += size_t(128 << sector->size) + 2;
|
|
|
|
}
|
|
|
|
|
2020-01-20 02:41:10 +00:00
|
|
|
// Seek appropriate gap sizes, if the defaults don't allow all data to fit.
|
2019-12-20 00:22:48 +00:00
|
|
|
while(true) {
|
|
|
|
const size_t size =
|
|
|
|
mark_size +
|
|
|
|
post_index_address_mark_bytes * data_size +
|
|
|
|
total_sector_bytes * data_size +
|
|
|
|
sectors.size() * (
|
|
|
|
(pre_address_mark_bytes + 6 + post_address_mark_bytes + pre_data_mark_bytes + post_data_bytes) * data_size + 2 * mark_size
|
|
|
|
);
|
|
|
|
|
|
|
|
// If this track already fits, do nothing.
|
|
|
|
if(size*8 < max_size) break;
|
|
|
|
|
|
|
|
// If all gaps are already zero, do nothing.
|
|
|
|
if(!post_index_address_mark_bytes && !pre_address_mark_bytes && !post_address_mark_bytes && !pre_data_mark_bytes && !post_data_bytes)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Very simple solution: try halving all gaps.
|
|
|
|
post_index_address_mark_bytes >>= 1;
|
|
|
|
pre_address_mark_bytes >>= 1;
|
|
|
|
post_address_mark_bytes >>= 1;
|
|
|
|
pre_data_mark_bytes >>= 1;
|
|
|
|
post_data_bytes >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output the index mark.
|
2016-09-18 20:53:21 +00:00
|
|
|
shifter.add_index_address_mark();
|
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Add the post-index mark.
|
2017-11-11 20:28:40 +00:00
|
|
|
for(std::size_t c = 0; c < post_index_address_mark_bytes; c++) shifter.add_byte(post_index_address_mark_value);
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Add sectors.
|
2017-11-01 01:32:28 +00:00
|
|
|
for(const Sector *sector : sectors) {
|
2019-12-20 00:22:48 +00:00
|
|
|
// Gap.
|
2017-11-11 20:28:40 +00:00
|
|
|
for(std::size_t c = 0; c < pre_address_mark_bytes; c++) shifter.add_byte(0x00);
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Sector header.
|
2016-09-18 20:53:21 +00:00
|
|
|
shifter.add_ID_address_mark();
|
2017-11-01 01:32:28 +00:00
|
|
|
shifter.add_byte(sector->address.track);
|
|
|
|
shifter.add_byte(sector->address.side);
|
|
|
|
shifter.add_byte(sector->address.sector);
|
|
|
|
shifter.add_byte(sector->size);
|
|
|
|
shifter.add_crc(sector->has_header_crc_error);
|
2016-09-18 22:33:26 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Gap.
|
2017-11-11 20:28:40 +00:00
|
|
|
for(std::size_t c = 0; c < post_address_mark_bytes; c++) shifter.add_byte(post_address_mark_value);
|
|
|
|
for(std::size_t c = 0; c < pre_data_mark_bytes; c++) shifter.add_byte(0x00);
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Data, if attached.
|
2017-11-01 01:32:28 +00:00
|
|
|
if(!sector->samples.empty()) {
|
|
|
|
if(sector->is_deleted)
|
2017-08-11 18:24:50 +00:00
|
|
|
shifter.add_deleted_data_address_mark();
|
|
|
|
else
|
|
|
|
shifter.add_data_address_mark();
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t c = 0;
|
2020-05-10 03:00:39 +00:00
|
|
|
std::size_t declared_length = size_t(128 << sector->size);
|
2020-01-20 02:41:10 +00:00
|
|
|
if(sector->samples.size() > 1) {
|
|
|
|
// For each byte, mark as fuzzy any bits that differ. Which isn't exactly the
|
|
|
|
// same thing as obeying the multiple samples, as it discards the implied
|
|
|
|
// probabilities of different values.
|
|
|
|
for(c = 0; c < sector->samples[0].size() && c < declared_length; c++) {
|
|
|
|
auto sample_iterator = sector->samples.begin();
|
|
|
|
uint8_t value = (*sample_iterator)[c], fuzzy_mask = 0;
|
|
|
|
|
|
|
|
++sample_iterator;
|
|
|
|
while(sample_iterator != sector->samples.end()) {
|
|
|
|
// Mark as fuzzy any bits that differ here from the
|
|
|
|
// canonical value, and zero them out in the original.
|
|
|
|
// That might cause them to retrigger, but who cares?
|
|
|
|
fuzzy_mask |= value ^ (*sample_iterator)[c];
|
|
|
|
value &= ~fuzzy_mask;
|
|
|
|
|
|
|
|
++sample_iterator;
|
|
|
|
}
|
|
|
|
shifter.add_byte(sector->samples[0][c], fuzzy_mask);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(c = 0; c < sector->samples[0].size() && c < declared_length; c++) {
|
|
|
|
shifter.add_byte(sector->samples[0][c]);
|
|
|
|
}
|
2017-08-11 18:24:50 +00:00
|
|
|
}
|
|
|
|
for(; c < declared_length; c++) {
|
|
|
|
shifter.add_byte(0x00);
|
|
|
|
}
|
2017-11-01 01:32:28 +00:00
|
|
|
shifter.add_crc(sector->has_data_crc_error);
|
2016-09-18 22:33:26 +00:00
|
|
|
}
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-20 00:22:48 +00:00
|
|
|
// Gap.
|
2017-11-11 20:28:40 +00:00
|
|
|
for(std::size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(post_data_value);
|
2016-09-18 20:53:21 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 19:43:31 +00:00
|
|
|
while(segment.data.size() < expected_track_bytes*8) shifter.add_byte(0x00);
|
2017-08-18 01:36:14 +00:00
|
|
|
|
|
|
|
// Allow the amount of data written to be up to 10% more than the expected size. Which is generous.
|
|
|
|
if(segment.data.size() > max_size) segment.data.resize(max_size);
|
2016-09-18 20:53:21 +00:00
|
|
|
|
2019-12-22 04:34:25 +00:00
|
|
|
return std::make_shared<Storage::Disk::PCMTrack>(std::move(segment));
|
2016-09-18 20:53:21 +00:00
|
|
|
}
|
2016-09-18 21:16:20 +00:00
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
Encoder::Encoder(std::vector<bool> &target, std::vector<bool> *fuzzy_target) :
|
|
|
|
target_(&target), fuzzy_target_(fuzzy_target) {}
|
2020-01-19 17:11:56 +00:00
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
void Encoder::reset_target(std::vector<bool> &target, std::vector<bool> *fuzzy_target) {
|
2020-01-19 17:11:56 +00:00
|
|
|
target_ = ⌖
|
2020-01-20 02:08:15 +00:00
|
|
|
fuzzy_target_ = fuzzy_target;
|
2020-01-19 17:11:56 +00:00
|
|
|
}
|
2016-11-26 05:39:20 +00:00
|
|
|
|
2020-01-20 02:20:21 +00:00
|
|
|
void Encoder::output_short(uint16_t value, uint16_t fuzzy_mask) {
|
|
|
|
const bool write_fuzzy_bits = fuzzy_mask;
|
|
|
|
|
|
|
|
if(write_fuzzy_bits) {
|
|
|
|
assert(fuzzy_target_);
|
|
|
|
|
2020-01-20 02:41:10 +00:00
|
|
|
// Zero-fill the bits to date, to cover any shorts written without fuzzy bits,
|
|
|
|
// and make sure the value has a 0 anywhere it should be fuzzy.
|
2020-01-20 02:20:21 +00:00
|
|
|
fuzzy_target_->resize(target_->size());
|
2020-01-20 02:41:10 +00:00
|
|
|
value &= ~fuzzy_mask;
|
2020-01-20 02:20:21 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 16:05:41 +00:00
|
|
|
uint16_t mask = 0x8000;
|
|
|
|
while(mask) {
|
2020-01-20 02:20:21 +00:00
|
|
|
target_->push_back(value & mask);
|
|
|
|
if(write_fuzzy_bits) fuzzy_target_->push_back(fuzzy_mask & mask);
|
2018-07-01 18:40:48 +00:00
|
|
|
mask >>= 1;
|
2018-07-01 16:05:41 +00:00
|
|
|
}
|
2016-11-26 05:39:20 +00:00
|
|
|
}
|
2016-09-18 21:16:20 +00:00
|
|
|
|
2017-08-11 18:24:50 +00:00
|
|
|
void Encoder::add_crc(bool incorrectly) {
|
2020-01-20 02:41:10 +00:00
|
|
|
const uint16_t crc_value = crc_generator_.get_value();
|
2016-12-29 00:48:46 +00:00
|
|
|
add_byte(crc_value >> 8);
|
2017-08-11 18:24:50 +00:00
|
|
|
add_byte((crc_value & 0xff) ^ (incorrectly ? 1 : 0));
|
2016-12-28 23:29:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
const std::size_t Storage::Encodings::MFM::DefaultSectorGapLength = std::numeric_limits<std::size_t>::max();
|
2017-08-11 18:24:50 +00:00
|
|
|
|
2017-11-01 01:32:28 +00:00
|
|
|
static std::vector<const Sector *> sector_pointers(const std::vector<Sector> §ors) {
|
|
|
|
std::vector<const Sector *> pointers;
|
|
|
|
for(const Sector §or: sectors) {
|
|
|
|
pointers.push_back(§or);
|
|
|
|
}
|
|
|
|
return pointers;
|
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSectors(const std::vector<Sector> §ors, std::size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
2017-11-01 01:32:28 +00:00
|
|
|
return GetTrackWithSectors<FMEncoder>(
|
|
|
|
sector_pointers(sectors),
|
|
|
|
26, 0xff,
|
|
|
|
6,
|
2020-05-30 23:31:17 +00:00
|
|
|
11, sector_gap_filler_byte,
|
2017-11-01 01:32:28 +00:00
|
|
|
6,
|
|
|
|
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 27, 0xff,
|
|
|
|
6250); // i.e. 250kbps (including clocks) * 60 = 15000kpm, at 300 rpm => 50 kbits/rotation => 6250 bytes/rotation
|
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSectors(const std::vector<const Sector *> §ors, std::size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
2016-11-26 05:39:20 +00:00
|
|
|
return GetTrackWithSectors<FMEncoder>(
|
2016-09-18 21:16:20 +00:00
|
|
|
sectors,
|
2017-08-14 01:52:48 +00:00
|
|
|
26, 0xff,
|
2017-08-11 18:24:50 +00:00
|
|
|
6,
|
2020-05-30 23:31:17 +00:00
|
|
|
11, sector_gap_filler_byte,
|
2017-08-14 01:52:48 +00:00
|
|
|
6,
|
|
|
|
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 27, 0xff,
|
2016-09-20 02:06:56 +00:00
|
|
|
6250); // i.e. 250kbps (including clocks) * 60 = 15000kpm, at 300 rpm => 50 kbits/rotation => 6250 bytes/rotation
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSectors(const std::vector<Sector> §ors, std::size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
2017-11-01 01:32:28 +00:00
|
|
|
return GetTrackWithSectors<MFMEncoder>(
|
|
|
|
sector_pointers(sectors),
|
|
|
|
50, 0x4e,
|
|
|
|
12,
|
2020-05-30 23:31:17 +00:00
|
|
|
22, sector_gap_filler_byte,
|
2017-11-01 01:32:28 +00:00
|
|
|
12,
|
|
|
|
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 54, 0xff,
|
|
|
|
12500); // unintelligently: double the single-density bytes/rotation (or: 500kbps @ 300 rpm)
|
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSectors(const std::vector<const Sector *> §ors, std::size_t sector_gap_length, uint8_t sector_gap_filler_byte) {
|
2016-11-26 05:39:20 +00:00
|
|
|
return GetTrackWithSectors<MFMEncoder>(
|
2016-09-18 21:16:20 +00:00
|
|
|
sectors,
|
|
|
|
50, 0x4e,
|
2017-08-11 18:24:50 +00:00
|
|
|
12,
|
2020-05-30 23:31:17 +00:00
|
|
|
22, sector_gap_filler_byte,
|
2017-08-14 01:52:48 +00:00
|
|
|
12,
|
|
|
|
(sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 54, 0xff,
|
2017-09-17 00:28:24 +00:00
|
|
|
12500); // unintelligently: double the single-density bytes/rotation (or: 500kbps @ 300 rpm)
|
2016-09-18 21:16:20 +00:00
|
|
|
}
|
2016-11-26 05:39:20 +00:00
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
std::unique_ptr<Encoder> Storage::Encodings::MFM::GetMFMEncoder(std::vector<bool> &target, std::vector<bool> *fuzzy_target) {
|
|
|
|
return std::make_unique<MFMEncoder>(target, fuzzy_target);
|
2016-11-26 05:39:20 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 02:08:15 +00:00
|
|
|
std::unique_ptr<Encoder> Storage::Encodings::MFM::GetFMEncoder(std::vector<bool> &target, std::vector<bool> *fuzzy_target) {
|
|
|
|
return std::make_unique<FMEncoder>(target, fuzzy_target);
|
2016-11-26 05:39:20 +00:00
|
|
|
}
|