1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00
CLK/Storage/Disk/DiskImage/Formats/CPCDSK.hpp

72 lines
1.8 KiB
C++
Raw Normal View History

//
// CPCDSK.hpp
// Clock Signal
//
// Created by Thomas Harte on 05/08/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#pragma once
#include "../DiskImage.hpp"
2017-09-23 02:39:23 +00:00
#include "../../../FileHolder.hpp"
#include "../../Encodings/MFM/Sector.hpp"
#include <string>
#include <vector>
2023-05-10 21:02:18 +00:00
namespace Storage::Disk {
/*!
Provides a @c Disk containing an Amstrad CPC-type disk image: some arrangement of sectors with status bits.
*/
class CPCDSK: public DiskImage {
public:
/*!
2023-12-08 20:37:13 +00:00
Construct a @c CPCDSK containing content from the file with name @c file_name.
@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.
*/
CPCDSK(const std::string &file_name);
2023-12-08 20:37:13 +00:00
// DiskImage interface.
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;
std::shared_ptr<::Storage::Disk::Track> get_track_at_position(::Storage::Disk::Track::Address address) final;
private:
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;
struct Sector: public ::Storage::Encodings::MFM::Sector {
uint8_t fdc_status1;
uint8_t fdc_status2;
};
std::vector<Sector> sectors;
};
2017-11-04 01:10:22 +00:00
std::string file_name_;
std::vector<std::unique_ptr<Track>> tracks_;
std::size_t index_for_track(::Storage::Disk::Track::Address address);
int head_count_;
int head_position_count_;
bool is_extended_;
bool is_read_only_;
};
}