From fab35b360a0ca1ad9a601fc05d81de05a0340fe5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Jan 2020 22:37:00 -0500 Subject: [PATCH] Ensure an encoder is created even if no sectors are placed. --- Storage/Disk/DiskImage/Formats/STX.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Storage/Disk/DiskImage/Formats/STX.cpp b/Storage/Disk/DiskImage/Formats/STX.cpp index 38c499076..05734bdcf 100644 --- a/Storage/Disk/DiskImage/Formats/STX.cpp +++ b/Storage/Disk/DiskImage/Formats/STX.cpp @@ -174,16 +174,16 @@ class TrackConstructor { } } + // Just create an encoder if one doesn't exist. TODO: factor in data rate. + if(!encoder) { + segment.reset(new PCMSegment); + encoder = Storage::Encodings::MFM::GetMFMEncoder(segment->data); + } + // Write out, being wary of potential overlapping sectors, and copying from track_data_ to fill in gaps. auto location = locations.begin(); track_position = track_data_.begin(); while(location != locations.end()) { - // Just create an encoder if one doesn't exist. TODO: factor in data rate. - if(!encoder) { - segment.reset(new PCMSegment); - encoder = Storage::Encodings::MFM::GetMFMEncoder(segment->data); - } - // Advance to location.position. while(track_position != location->position) { encoder->add_byte(*track_position);