2017-08-05 14:02:10 +00:00
|
|
|
//
|
|
|
|
// CPCDSK.cpp
|
|
|
|
// 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
|
|
|
//
|
|
|
|
|
|
|
|
#include "CPCDSK.hpp"
|
|
|
|
|
2017-11-03 02:32:00 +00:00
|
|
|
#include "../../Encodings/MFM/Constants.hpp"
|
2017-09-25 01:40:43 +00:00
|
|
|
#include "../../Encodings/MFM/Encoder.hpp"
|
2017-11-03 02:32:00 +00:00
|
|
|
#include "../../Encodings/MFM/SegmentParser.hpp"
|
|
|
|
#include "../../Track/TrackSerialiser.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-08-05 15:44:53 +00:00
|
|
|
|
2017-08-05 14:02:10 +00:00
|
|
|
using namespace Storage::Disk;
|
|
|
|
|
2018-04-06 21:42:24 +00:00
|
|
|
CPCDSK::CPCDSK(const std::string &file_name) :
|
2017-11-04 01:10:22 +00:00
|
|
|
file_name_(file_name),
|
2017-11-03 02:32:00 +00:00
|
|
|
is_extended_(false) {
|
|
|
|
FileHolder file(file_name);
|
|
|
|
is_read_only_ = file.get_is_known_read_only();
|
|
|
|
|
|
|
|
if(!file.check_signature("MV - CPC")) {
|
2017-08-05 14:02:10 +00:00
|
|
|
is_extended_ = true;
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(0, SEEK_SET);
|
|
|
|
if(!file.check_signature("EXTENDED"))
|
2018-04-28 03:18:45 +00:00
|
|
|
throw Error::InvalidFormat;
|
2017-08-05 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't really care about about the creator; skip.
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(0x30, SEEK_SET);
|
|
|
|
head_position_count_ = file.get8();
|
|
|
|
head_count_ = file.get8();
|
2017-08-05 15:44:53 +00:00
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// Used only for non-extended disks.
|
2017-11-01 01:32:28 +00:00
|
|
|
long size_of_a_track = 0;
|
2017-10-31 23:41:16 +00:00
|
|
|
|
|
|
|
// Used only for extended disks.
|
2017-11-11 20:28:40 +00:00
|
|
|
std::vector<std::size_t> track_sizes;
|
2017-10-31 23:41:16 +00:00
|
|
|
|
2017-08-05 15:44:53 +00:00
|
|
|
if(is_extended_) {
|
2017-08-07 15:38:19 +00:00
|
|
|
// Skip two unused bytes and grab the track size table.
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(2, SEEK_CUR);
|
2017-10-07 01:45:12 +00:00
|
|
|
for(int c = 0; c < head_position_count_ * head_count_; c++) {
|
2020-05-10 03:00:39 +00:00
|
|
|
track_sizes.push_back(size_t(file.get8()) << 8);
|
2017-08-05 15:44:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-11-03 02:32:00 +00:00
|
|
|
size_of_a_track = file.get16le();
|
2017-10-31 23:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long file_offset = 0x100;
|
2020-05-10 03:00:39 +00:00
|
|
|
for(std::size_t c = 0; c < size_t(head_position_count_ * head_count_); c++) {
|
2017-10-31 23:41:16 +00:00
|
|
|
if(!is_extended_ || (track_sizes[c] > 0)) {
|
|
|
|
// Skip the introductory text, 'Track-Info\r\n' and its unused bytes.
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(file_offset + 16, SEEK_SET);
|
2017-10-31 23:41:16 +00:00
|
|
|
|
|
|
|
tracks_.emplace_back(new Track);
|
|
|
|
Track *track = tracks_.back().get();
|
|
|
|
|
|
|
|
// Track and side are stored, being a byte each.
|
2017-11-03 02:32:00 +00:00
|
|
|
track->track = file.get8();
|
|
|
|
track->side = file.get8();
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// If this is an extended disk image then John Elliott's extension provides some greater
|
|
|
|
// data rate and encoding context. Otherwise the next two bytes have no defined meaning.
|
|
|
|
if(is_extended_) {
|
2017-11-03 02:32:00 +00:00
|
|
|
switch(file.get8()) {
|
2017-10-31 23:41:16 +00:00
|
|
|
default: track->data_rate = Track::DataRate::Unknown; break;
|
|
|
|
case 1: track->data_rate = Track::DataRate::SingleOrDoubleDensity; break;
|
|
|
|
case 2: track->data_rate = Track::DataRate::HighDensity; break;
|
|
|
|
case 3: track->data_rate = Track::DataRate::ExtendedDensity; break;
|
|
|
|
}
|
2017-11-03 02:32:00 +00:00
|
|
|
switch(file.get8()) {
|
2017-10-31 23:41:16 +00:00
|
|
|
default: track->data_encoding = Track::DataEncoding::Unknown; break;
|
|
|
|
case 1: track->data_encoding = Track::DataEncoding::FM; break;
|
|
|
|
case 2: track->data_encoding = Track::Track::DataEncoding::MFM; break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
track->data_rate = Track::DataRate::Unknown;
|
|
|
|
track->data_encoding = Track::DataEncoding::Unknown;
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(2, SEEK_CUR);
|
2017-10-31 23:41:16 +00:00
|
|
|
}
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// Sector size, number of sectors, gap 3 length and the filler byte are then common
|
|
|
|
// between both variants of DSK.
|
2017-11-03 02:32:00 +00:00
|
|
|
track->sector_length = file.get8();
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t number_of_sectors = file.get8();
|
2017-11-03 02:32:00 +00:00
|
|
|
track->gap3_length = file.get8();
|
|
|
|
track->filler_byte = file.get8();
|
2017-10-31 23:41:16 +00:00
|
|
|
|
|
|
|
// Sector information begins immediately after the track information table.
|
|
|
|
while(number_of_sectors--) {
|
|
|
|
track->sectors.emplace_back();
|
|
|
|
Track::Sector §or = track->sectors.back();
|
|
|
|
|
|
|
|
// Track, side, sector, size and two FDC8272-esque status bytes are stored
|
|
|
|
// per sector, in both regular and extended DSK files.
|
2017-11-03 02:32:00 +00:00
|
|
|
sector.address.track = file.get8();
|
|
|
|
sector.address.side = file.get8();
|
|
|
|
sector.address.sector = file.get8();
|
|
|
|
sector.size = file.get8();
|
|
|
|
sector.fdc_status1 = file.get8();
|
|
|
|
sector.fdc_status2 = file.get8();
|
2017-10-31 23:41:16 +00:00
|
|
|
|
2017-11-01 01:32:28 +00:00
|
|
|
if(sector.fdc_status2 & 0x20) {
|
|
|
|
// The CRC failed in the data field.
|
|
|
|
sector.has_data_crc_error = true;
|
|
|
|
} else {
|
|
|
|
if(sector.fdc_status1 & 0x20) {
|
|
|
|
// The CRC failed in the ID field.
|
|
|
|
sector.has_header_crc_error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sector.fdc_status2 & 0x40) {
|
|
|
|
// This sector is marked as deleted.
|
|
|
|
sector.is_deleted = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sector.fdc_status2 & 0x01) {
|
|
|
|
// Data field wasn't found.
|
|
|
|
sector.samples.clear();
|
|
|
|
}
|
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// Figuring out the actual data size is a little more work...
|
2020-05-10 03:00:39 +00:00
|
|
|
std::size_t data_size = size_t(128 << sector.size);
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t stored_data_size = data_size;
|
|
|
|
std::size_t number_of_samplings = 1;
|
2017-10-31 23:41:16 +00:00
|
|
|
|
|
|
|
if(is_extended_) {
|
|
|
|
// In an extended DSK, oblige two Simon Owen extensions:
|
|
|
|
//
|
|
|
|
// Allow a declared data size less than the sector's declared size to act as an abbreviation.
|
|
|
|
// Extended DSK varies the 8kb -> 0x1800 bytes special case by this means.
|
|
|
|
//
|
|
|
|
// Use a declared data size greater than the sector's declared size as a record that this
|
|
|
|
// sector was weak or fuzzy and that multiple samplings are provided. If the greater size
|
|
|
|
// is not an exact multiple then my reading of the documentation is that this is an invalid
|
|
|
|
// disk image.
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t declared_data_size = file.get16le();
|
2017-10-31 23:41:16 +00:00
|
|
|
if(declared_data_size != stored_data_size) {
|
|
|
|
if(declared_data_size > data_size) {
|
|
|
|
number_of_samplings = declared_data_size / data_size;
|
|
|
|
if(declared_data_size % data_size)
|
2018-04-28 03:18:45 +00:00
|
|
|
throw Error::InvalidFormat;
|
2017-10-31 23:41:16 +00:00
|
|
|
} else {
|
|
|
|
stored_data_size = declared_data_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// In a regular DSK, these two bytes are unused, and a special case is applied that ostensibly 8kb
|
|
|
|
// sectors are abbreviated to only 0x1800 bytes.
|
|
|
|
if(data_size == 0x2000) stored_data_size = 0x1800;
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(2, SEEK_CUR);
|
2017-10-31 23:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// As per the weak/fuzzy sector extension, multiple samplings may be stored here.
|
2020-01-20 01:05:52 +00:00
|
|
|
// Plan to read as many as there were.
|
2017-11-01 01:32:28 +00:00
|
|
|
sector.samples.emplace_back();
|
|
|
|
sector.samples.resize(number_of_samplings);
|
2017-10-31 23:41:16 +00:00
|
|
|
while(number_of_samplings--) {
|
2017-11-01 01:32:28 +00:00
|
|
|
sector.samples[number_of_samplings].resize(stored_data_size);
|
2017-10-31 23:41:16 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-01 01:32:28 +00:00
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// Sector contents are at offset 0x100 into the track.
|
2017-11-03 02:32:00 +00:00
|
|
|
file.seek(file_offset + 0x100, SEEK_SET);
|
2017-10-31 23:41:16 +00:00
|
|
|
for(auto §or: track->sectors) {
|
2017-11-01 01:32:28 +00:00
|
|
|
for(auto &data : sector.samples) {
|
2017-11-03 02:32:00 +00:00
|
|
|
file.read(data.data(), data.size());
|
2017-10-31 23:41:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// An extended disk image, which declares that there is no data stored for this track.
|
|
|
|
tracks_.emplace_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advance to the beginning of the next track.
|
|
|
|
if(is_extended_)
|
2020-05-10 03:00:39 +00:00
|
|
|
file_offset += long(track_sizes[c]);
|
2017-10-31 23:41:16 +00:00
|
|
|
else
|
|
|
|
file_offset += size_of_a_track;
|
2017-08-05 15:44:53 +00:00
|
|
|
}
|
2017-08-05 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 03:17:36 +00:00
|
|
|
HeadPosition CPCDSK::get_maximum_head_position() {
|
|
|
|
return HeadPosition(head_position_count_);
|
2017-08-05 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 01:45:12 +00:00
|
|
|
int CPCDSK::get_head_count() {
|
2017-08-05 14:02:10 +00:00
|
|
|
return head_count_;
|
|
|
|
}
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t CPCDSK::index_for_track(::Storage::Disk::Track::Address address) {
|
2020-05-10 03:00:39 +00:00
|
|
|
return size_t((address.position.as_int() * head_count_) + address.head);
|
2017-11-03 02:32:00 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
std::shared_ptr<Track> CPCDSK::get_track_at_position(::Storage::Disk::Track::Address address) {
|
2017-08-05 15:44:53 +00:00
|
|
|
// Given that thesea are interleaved images, determine which track, chronologically, is being requested.
|
2021-03-22 23:55:03 +00:00
|
|
|
const std::size_t chronological_track = index_for_track(address);
|
2017-08-05 15:44:53 +00:00
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// Return a nullptr if out of range or not provided.
|
|
|
|
if(chronological_track >= tracks_.size()) return nullptr;
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2021-03-22 23:55:03 +00:00
|
|
|
Track *const track = tracks_[chronological_track].get();
|
2017-10-31 23:41:16 +00:00
|
|
|
if(!track) return nullptr;
|
2017-08-17 19:32:24 +00:00
|
|
|
|
2017-11-01 01:32:28 +00:00
|
|
|
std::vector<const Storage::Encodings::MFM::Sector *> sectors;
|
2017-10-31 23:41:16 +00:00
|
|
|
for(auto §or : track->sectors) {
|
2017-11-01 01:32:28 +00:00
|
|
|
sectors.push_back(§or);
|
2017-08-05 15:44:53 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 23:41:16 +00:00
|
|
|
// TODO: FM encoding, data rate?
|
2023-12-11 03:17:23 +00:00
|
|
|
return Storage::Encodings::MFM::TrackWithSectors(
|
|
|
|
Storage::Encodings::MFM::Density::Double,
|
|
|
|
sectors,
|
|
|
|
track->gap3_length,
|
|
|
|
track->filler_byte);
|
2017-08-05 14:02:10 +00:00
|
|
|
}
|
2017-11-03 02:32:00 +00:00
|
|
|
|
|
|
|
void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::shared_ptr<::Storage::Disk::Track>> &tracks) {
|
|
|
|
// Patch changed tracks into the disk image.
|
|
|
|
for(auto &pair: tracks) {
|
|
|
|
// Assume MFM for now; with extensions DSK can contain FM tracks.
|
|
|
|
const bool is_double_density = true;
|
2017-11-11 20:28:40 +00:00
|
|
|
std::map<std::size_t, Storage::Encodings::MFM::Sector> sectors =
|
2017-11-03 02:32:00 +00:00
|
|
|
Storage::Encodings::MFM::sectors_from_segment(
|
|
|
|
Storage::Disk::track_serialisation(*pair.second, is_double_density ? Storage::Encodings::MFM::MFMBitLength : Storage::Encodings::MFM::FMBitLength),
|
2023-12-11 03:17:23 +00:00
|
|
|
Storage::Encodings::MFM::Density::Double);
|
2017-11-03 02:32:00 +00:00
|
|
|
|
|
|
|
// Find slot for track, making it if neccessary.
|
2021-03-22 23:55:03 +00:00
|
|
|
const std::size_t chronological_track = index_for_track(pair.first);
|
2017-11-03 02:32:00 +00:00
|
|
|
if(chronological_track >= tracks_.size()) {
|
|
|
|
tracks_.resize(chronological_track+1);
|
2018-05-07 03:17:36 +00:00
|
|
|
head_position_count_ = pair.first.position.as_int();
|
2017-11-03 02:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the track, or create it if necessary.
|
|
|
|
Track *track = tracks_[chronological_track].get();
|
|
|
|
if(!track) {
|
|
|
|
track = new Track;
|
2020-05-10 03:00:39 +00:00
|
|
|
track->track = uint8_t(pair.first.position.as_int());
|
|
|
|
track->side = uint8_t(pair.first.head);
|
2017-11-03 02:32:00 +00:00
|
|
|
track->data_rate = Track::DataRate::SingleOrDoubleDensity;
|
|
|
|
track->data_encoding = Track::DataEncoding::MFM;
|
|
|
|
track->sector_length = 2;
|
|
|
|
track->gap3_length = 78;
|
|
|
|
track->filler_byte = 0xe5;
|
|
|
|
|
|
|
|
tracks_[chronological_track] = std::unique_ptr<Track>(track);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store sectors.
|
|
|
|
track->sectors.clear();
|
|
|
|
for(auto &source_sector: sectors) {
|
|
|
|
track->sectors.emplace_back();
|
|
|
|
Track::Sector §or = track->sectors.back();
|
|
|
|
|
|
|
|
sector.address = source_sector.second.address;
|
|
|
|
sector.size = source_sector.second.size;
|
|
|
|
sector.has_data_crc_error = source_sector.second.has_data_crc_error;
|
|
|
|
sector.has_header_crc_error = source_sector.second.has_header_crc_error;
|
|
|
|
sector.is_deleted = source_sector.second.is_deleted;
|
|
|
|
sector.samples = std::move(source_sector.second.samples);
|
2017-11-04 01:29:42 +00:00
|
|
|
|
|
|
|
sector.fdc_status1 = 0;
|
|
|
|
sector.fdc_status2 = 0;
|
|
|
|
|
2018-11-24 03:32:32 +00:00
|
|
|
if(source_sector.second.has_data_crc_error) sector.fdc_status2 |= 0x20;
|
2017-11-04 01:29:42 +00:00
|
|
|
if(source_sector.second.has_header_crc_error) sector.fdc_status1 |= 0x20;
|
|
|
|
if(source_sector.second.is_deleted) sector.fdc_status2 |= 0x40;
|
2017-11-03 02:32:00 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-11-03 02:32:00 +00:00
|
|
|
// Rewrite the entire disk image, in extended form.
|
2017-11-04 01:10:22 +00:00
|
|
|
Storage::FileHolder output(file_name_, Storage::FileHolder::FileMode::Rewrite);
|
|
|
|
output.write(reinterpret_cast<const uint8_t *>("EXTENDED CPC DSK File\r\nDisk-Info\r\n"), 34);
|
|
|
|
output.write(reinterpret_cast<const uint8_t *>("Clock Signal "), 14);
|
2020-05-10 03:00:39 +00:00
|
|
|
output.put8(uint8_t(head_position_count_));
|
|
|
|
output.put8(uint8_t(head_count_));
|
2017-11-04 01:10:22 +00:00
|
|
|
output.putn(2, 0);
|
|
|
|
|
|
|
|
// Output size table.
|
2020-05-10 03:00:39 +00:00
|
|
|
for(std::size_t index = 0; index < size_t(head_position_count_ * head_count_); ++index) {
|
2017-11-04 01:10:22 +00:00
|
|
|
if(index >= tracks_.size()) {
|
|
|
|
output.put8(0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Track *track = tracks_[index].get();
|
|
|
|
if(!track) {
|
|
|
|
output.put8(0);
|
|
|
|
continue;
|
|
|
|
}
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-11-04 01:10:22 +00:00
|
|
|
// Calculate size of track.
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t track_size = 256;
|
2017-11-04 01:10:22 +00:00
|
|
|
for(auto §or: track->sectors) {
|
|
|
|
for(auto &sample: sector.samples) {
|
|
|
|
track_size += sample.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Round upward and output.
|
|
|
|
track_size += (256 - (track_size & 255)) & 255;
|
2020-05-10 03:00:39 +00:00
|
|
|
output.put8(uint8_t(track_size >> 8));
|
2017-11-04 01:10:22 +00:00
|
|
|
}
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-11-04 01:10:22 +00:00
|
|
|
// Advance to offset 256.
|
2020-05-10 03:00:39 +00:00
|
|
|
output.putn(size_t(256 - output.tell()), 0);
|
2017-11-04 01:10:22 +00:00
|
|
|
|
|
|
|
// Output each track.
|
2020-05-10 03:00:39 +00:00
|
|
|
for(std::size_t index = 0; index < size_t(head_position_count_ * head_count_); ++index) {
|
2017-11-04 01:10:22 +00:00
|
|
|
if(index >= tracks_.size()) continue;
|
2021-03-22 23:55:03 +00:00
|
|
|
Track *const track = tracks_[index].get();
|
2017-11-04 01:10:22 +00:00
|
|
|
if(!track) continue;
|
|
|
|
|
|
|
|
// Output track header.
|
|
|
|
output.write(reinterpret_cast<const uint8_t *>("Track-Info\r\n"), 13);
|
|
|
|
output.putn(3, 0);
|
|
|
|
output.put8(track->track);
|
|
|
|
output.put8(track->side);
|
|
|
|
switch (track->data_rate) {
|
|
|
|
default:
|
|
|
|
output.put8(0);
|
|
|
|
break;
|
|
|
|
case Track::DataRate::SingleOrDoubleDensity:
|
|
|
|
output.put8(1);
|
|
|
|
break;
|
|
|
|
case Track::DataRate::HighDensity:
|
|
|
|
output.put8(2);
|
|
|
|
break;
|
|
|
|
case Track::DataRate::ExtendedDensity:
|
|
|
|
output.put8(3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (track->data_encoding) {
|
|
|
|
default:
|
|
|
|
output.put8(0);
|
|
|
|
break;
|
|
|
|
case Track::DataEncoding::FM:
|
|
|
|
output.put8(1);
|
|
|
|
break;
|
|
|
|
case Track::DataEncoding::MFM:
|
|
|
|
output.put8(2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
output.put8(track->sector_length);
|
2020-05-10 03:00:39 +00:00
|
|
|
output.put8(uint8_t(track->sectors.size()));
|
2017-11-04 01:10:22 +00:00
|
|
|
output.put8(track->gap3_length);
|
|
|
|
output.put8(track->filler_byte);
|
|
|
|
|
|
|
|
// Output sector information list.
|
|
|
|
for(auto §or: track->sectors) {
|
|
|
|
output.put8(sector.address.track);
|
|
|
|
output.put8(sector.address.side);
|
|
|
|
output.put8(sector.address.sector);
|
|
|
|
output.put8(sector.size);
|
|
|
|
output.put8(sector.fdc_status1);
|
|
|
|
output.put8(sector.fdc_status2);
|
|
|
|
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t data_size = 0;
|
2017-11-04 01:10:22 +00:00
|
|
|
for(auto &sample: sector.samples) {
|
|
|
|
data_size += sample.size();
|
|
|
|
}
|
2020-05-10 03:00:39 +00:00
|
|
|
output.put16le(uint16_t(data_size));
|
2017-11-04 01:10:22 +00:00
|
|
|
}
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2017-11-04 01:10:22 +00:00
|
|
|
// Move to next 256-byte boundary.
|
2017-11-12 22:46:06 +00:00
|
|
|
long distance = (256 - (output.tell()&255))&255;
|
2020-05-10 03:00:39 +00:00
|
|
|
output.putn(size_t(distance), 0);
|
2017-11-04 01:10:22 +00:00
|
|
|
|
|
|
|
// Output sector contents.
|
|
|
|
for(auto §or: track->sectors) {
|
|
|
|
for(auto &sample: sector.samples) {
|
|
|
|
output.write(sample);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to next 256-byte boundary.
|
2017-11-12 22:46:06 +00:00
|
|
|
distance = (256 - (output.tell()&255))&255;
|
2020-05-10 03:00:39 +00:00
|
|
|
output.putn(size_t(distance), 0);
|
2017-11-04 01:10:22 +00:00
|
|
|
}
|
2017-11-03 02:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CPCDSK::get_is_read_only() {
|
|
|
|
return is_read_only_;
|
|
|
|
}
|