2017-09-25 00:31:19 +00:00
|
|
|
//
|
|
|
|
// Sector.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 24/09/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-09-25 00:31:19 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-09-25 00:31:19 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Encodings::MFM {
|
2017-09-25 00:31:19 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Represents a single [M]FM sector, identified by its track, side and sector records, a blob of data
|
|
|
|
and a few extra flags of metadata.
|
|
|
|
*/
|
|
|
|
struct Sector {
|
2017-09-25 01:57:21 +00:00
|
|
|
/*!
|
|
|
|
Describes the location of a sector, implementing < to allow for use as a set key.
|
|
|
|
*/
|
|
|
|
struct Address {
|
|
|
|
uint8_t track = 0, side = 0, sector = 0;
|
|
|
|
|
2017-09-25 02:40:38 +00:00
|
|
|
bool operator < (const Address &rhs) const {
|
2017-09-25 01:57:21 +00:00
|
|
|
return ((track << 24) | (side << 8) | sector) < ((rhs.track << 24) | (rhs.side << 8) | rhs.sector);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Address address;
|
2018-05-13 19:34:31 +00:00
|
|
|
uint8_t size = 0; // Size is stored in ordinary MFM form: the number of bytes included in this sector
|
2018-05-04 22:02:55 +00:00
|
|
|
// is 2^(7 + size), or 128 << size.
|
2017-11-01 01:32:28 +00:00
|
|
|
|
|
|
|
// Multiple samplings of the underlying data are accepted, to allow weak and fuzzy data to be communicated.
|
|
|
|
std::vector<std::vector<uint8_t>> samples;
|
2017-09-25 00:31:19 +00:00
|
|
|
|
2017-09-25 01:57:21 +00:00
|
|
|
bool has_data_crc_error = false;
|
|
|
|
bool has_header_crc_error = false;
|
|
|
|
bool is_deleted = false;
|
2017-09-25 02:40:38 +00:00
|
|
|
|
2017-09-25 23:53:22 +00:00
|
|
|
Sector() noexcept {}
|
2017-09-25 02:40:38 +00:00
|
|
|
|
2017-09-25 23:53:22 +00:00
|
|
|
Sector(const Sector &&rhs) noexcept :
|
2017-09-25 02:40:38 +00:00
|
|
|
address(rhs.address),
|
|
|
|
size(rhs.size),
|
2017-11-01 01:32:28 +00:00
|
|
|
samples(std::move(rhs.samples)),
|
2017-09-25 02:40:38 +00:00
|
|
|
has_data_crc_error(rhs.has_data_crc_error),
|
|
|
|
has_header_crc_error(rhs.has_header_crc_error),
|
|
|
|
is_deleted(rhs.is_deleted ){}
|
2017-09-25 00:31:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|