2018-05-05 03:11:12 +00:00
|
|
|
//
|
|
|
|
// Sector.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/05/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-05-05 03:11:12 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2018-05-05 03:11:12 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Encodings::AppleGCR {
|
2018-05-05 03:11:12 +00:00
|
|
|
|
|
|
|
struct Sector {
|
|
|
|
/*!
|
|
|
|
Describes the location of a sector, implementing < to allow for use as a set key.
|
|
|
|
*/
|
|
|
|
struct Address {
|
2020-07-20 23:50:33 +00:00
|
|
|
union {
|
2019-07-11 20:28:52 +00:00
|
|
|
/// For Apple II-type sectors, provides the volume number.
|
2020-07-20 23:50:33 +00:00
|
|
|
uint_fast8_t volume;
|
2019-07-11 21:37:07 +00:00
|
|
|
/// For Macintosh-type sectors, provides the format from the sector header.
|
|
|
|
uint_fast8_t format = 0;
|
2019-07-11 20:28:52 +00:00
|
|
|
};
|
|
|
|
uint_fast8_t track = 0;
|
|
|
|
uint_fast8_t sector = 0;
|
|
|
|
|
|
|
|
/// Filled in for Macintosh sectors only; always @c false for Apple II sectors.
|
|
|
|
bool is_side_two = false;
|
2018-05-05 03:11:12 +00:00
|
|
|
|
|
|
|
bool operator < (const Address &rhs) const {
|
2019-07-11 20:28:52 +00:00
|
|
|
return (
|
|
|
|
((is_side_two ? 1 : 0) << 24) |
|
|
|
|
(volume << 16) |
|
|
|
|
(track << 8) |
|
|
|
|
sector
|
|
|
|
) < (
|
|
|
|
((rhs.is_side_two ? 1 : 0) << 24) |
|
|
|
|
(rhs.volume << 16) |
|
|
|
|
(rhs.track << 8) |
|
|
|
|
rhs.sector
|
|
|
|
);
|
2018-05-05 03:11:12 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Address address;
|
|
|
|
std::vector<uint8_t> data;
|
|
|
|
|
|
|
|
bool has_data_checksum_error = false;
|
|
|
|
bool has_header_checksum_error = false;
|
|
|
|
|
|
|
|
enum class Encoding {
|
2019-07-11 20:28:52 +00:00
|
|
|
FiveAndThree, SixAndTwo, Macintosh
|
2018-05-05 03:11:12 +00:00
|
|
|
};
|
|
|
|
Encoding encoding = Encoding::SixAndTwo;
|
2018-05-05 20:37:33 +00:00
|
|
|
|
|
|
|
Sector() {}
|
|
|
|
|
|
|
|
Sector(Sector &&rhs) :
|
|
|
|
address(rhs.address),
|
|
|
|
data(std::move(rhs.data)),
|
|
|
|
has_data_checksum_error(rhs.has_data_checksum_error),
|
|
|
|
has_header_checksum_error(rhs.has_header_checksum_error),
|
|
|
|
encoding(rhs.encoding) {}
|
|
|
|
|
|
|
|
Sector(const Sector &rhs) :
|
|
|
|
address(rhs.address),
|
|
|
|
data(rhs.data),
|
|
|
|
has_data_checksum_error(rhs.has_data_checksum_error),
|
|
|
|
has_header_checksum_error(rhs.has_header_checksum_error),
|
|
|
|
encoding(rhs.encoding) {}
|
2018-05-05 03:11:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|