2017-08-10 21:10:21 +00:00
|
|
|
//
|
|
|
|
// CPM.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/08/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-08-10 21:10:21 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-08-10 21:10:21 +00:00
|
|
|
|
|
|
|
#include "../Disk.hpp"
|
2017-08-11 02:33:08 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
2017-08-10 21:10:21 +00:00
|
|
|
#include <memory>
|
2017-08-11 02:33:08 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-08-10 21:10:21 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Disk::CPM {
|
2017-08-10 21:10:21 +00:00
|
|
|
|
|
|
|
struct ParameterBlock {
|
|
|
|
int sectors_per_track;
|
2017-08-11 14:46:50 +00:00
|
|
|
int tracks;
|
2017-08-11 02:33:08 +00:00
|
|
|
int block_size;
|
2017-08-10 21:10:21 +00:00
|
|
|
int first_sector;
|
|
|
|
uint16_t catalogue_allocation_bitmap;
|
|
|
|
int reserved_tracks;
|
2024-08-21 01:43:31 +00:00
|
|
|
|
|
|
|
// Some well-known formats.
|
|
|
|
static ParameterBlock cpc_data_format() {
|
|
|
|
Storage::Disk::CPM::ParameterBlock data_format;
|
|
|
|
data_format.sectors_per_track = 9;
|
|
|
|
data_format.tracks = 40;
|
|
|
|
data_format.block_size = 1024;
|
|
|
|
data_format.first_sector = 0xc1;
|
|
|
|
data_format.catalogue_allocation_bitmap = 0xc000;
|
|
|
|
data_format.reserved_tracks = 0;
|
|
|
|
return data_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ParameterBlock cpc_system_format() {
|
|
|
|
Storage::Disk::CPM::ParameterBlock system_format;
|
|
|
|
system_format.sectors_per_track = 9;
|
|
|
|
system_format.tracks = 40;
|
|
|
|
system_format.block_size = 1024;
|
|
|
|
system_format.first_sector = 0x41;
|
|
|
|
system_format.catalogue_allocation_bitmap = 0xc000;
|
|
|
|
system_format.reserved_tracks = 2;
|
|
|
|
return system_format;
|
|
|
|
}
|
2017-08-10 21:10:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct File {
|
2017-08-11 02:33:08 +00:00
|
|
|
uint8_t user_number;
|
|
|
|
std::string name;
|
|
|
|
std::string type;
|
|
|
|
bool read_only;
|
|
|
|
bool system;
|
|
|
|
std::vector<uint8_t> data;
|
2017-08-10 21:10:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Catalogue {
|
2017-08-11 02:33:08 +00:00
|
|
|
std::vector<File> files;
|
2024-08-23 01:17:35 +00:00
|
|
|
|
|
|
|
bool is_zx_spectrum_booter();
|
2017-08-10 21:10:21 +00:00
|
|
|
};
|
|
|
|
|
2024-10-09 16:27:51 +00:00
|
|
|
std::unique_ptr<Catalogue> GetCatalogue(const std::shared_ptr<Storage::Disk::Disk> &disk, const ParameterBlock ¶meters, bool with_contents);
|
2017-08-10 21:10:21 +00:00
|
|
|
|
|
|
|
}
|