2017-08-05 14:02:10 +00:00
|
|
|
//
|
|
|
|
// CPCDSK.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 05/08/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-08-05 14:02:10 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-08-05 14:02:10 +00:00
|
|
|
|
2017-09-23 00:28:11 +00:00
|
|
|
#include "../DiskImage.hpp"
|
2017-09-23 02:39:23 +00:00
|
|
|
#include "../../../FileHolder.hpp"
|
2017-11-01 01:32:28 +00:00
|
|
|
#include "../../Encodings/MFM/Sector.hpp"
|
2017-08-05 14:02:10 +00:00
|
|
|
|
2018-04-06 21:42:24 +00:00
|
|
|
#include <string>
|
2017-08-05 15:44:53 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Disk {
|
2017-08-05 14:02:10 +00:00
|
|
|
|
|
|
|
/*!
|
2018-05-13 19:34:31 +00:00
|
|
|
Provides a @c Disk containing an Amstrad CPC-type disk image: some arrangement of sectors with status bits.
|
2017-08-05 14:02:10 +00:00
|
|
|
*/
|
2017-11-03 02:32:00 +00:00
|
|
|
class CPCDSK: public DiskImage {
|
2017-08-05 14:02:10 +00:00
|
|
|
public:
|
|
|
|
/*!
|
2023-12-08 20:37:13 +00:00
|
|
|
Construct a @c CPCDSK containing content from the file with name @c file_name.
|
2017-08-05 14:02:10 +00:00
|
|
|
|
2018-04-28 03:18:45 +00:00
|
|
|
@throws Storage::FileHolder::Error::CantOpen if this file can't be opened.
|
|
|
|
@throws Error::InvalidFormat if the file doesn't appear to contain an Acorn .ADF format image.
|
2017-08-05 14:02:10 +00:00
|
|
|
*/
|
2018-04-06 21:42:24 +00:00
|
|
|
CPCDSK(const std::string &file_name);
|
2017-08-05 14:02:10 +00:00
|
|
|
|
2023-12-08 20:37:13 +00:00
|
|
|
// DiskImage interface.
|
2020-01-24 03:57:51 +00:00
|
|
|
HeadPosition get_maximum_head_position() final;
|
|
|
|
int get_head_count() final;
|
|
|
|
bool get_is_read_only() final;
|
2023-12-08 20:37:13 +00:00
|
|
|
void set_tracks(const std::map<::Storage::Disk::Track::Address, std::shared_ptr<::Storage::Disk::Track>> &tracks) final;
|
2020-01-24 03:57:51 +00:00
|
|
|
std::shared_ptr<::Storage::Disk::Track> get_track_at_position(::Storage::Disk::Track::Address address) final;
|
2017-08-05 14:02:10 +00:00
|
|
|
|
|
|
|
private:
|
2017-10-31 23:41:16 +00:00
|
|
|
struct Track {
|
|
|
|
uint8_t track;
|
|
|
|
uint8_t side;
|
|
|
|
enum class DataRate {
|
|
|
|
Unknown, SingleOrDoubleDensity, HighDensity, ExtendedDensity
|
|
|
|
} data_rate;
|
|
|
|
enum class DataEncoding {
|
|
|
|
Unknown, FM, MFM
|
|
|
|
} data_encoding;
|
|
|
|
uint8_t sector_length;
|
|
|
|
uint8_t gap3_length;
|
|
|
|
uint8_t filler_byte;
|
|
|
|
|
2017-11-01 01:32:28 +00:00
|
|
|
struct Sector: public ::Storage::Encodings::MFM::Sector {
|
2017-10-31 23:41:16 +00:00
|
|
|
uint8_t fdc_status1;
|
|
|
|
uint8_t fdc_status2;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<Sector> sectors;
|
|
|
|
};
|
2017-11-04 01:10:22 +00:00
|
|
|
std::string file_name_;
|
2017-10-31 23:41:16 +00:00
|
|
|
std::vector<std::unique_ptr<Track>> tracks_;
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t index_for_track(::Storage::Disk::Track::Address address);
|
2017-10-31 23:41:16 +00:00
|
|
|
|
2017-10-07 01:45:12 +00:00
|
|
|
int head_count_;
|
|
|
|
int head_position_count_;
|
2017-08-05 14:02:10 +00:00
|
|
|
bool is_extended_;
|
2017-11-03 02:32:00 +00:00
|
|
|
bool is_read_only_;
|
2017-08-05 14:02:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|