From 88fc7ff9c3562f564992a78d50c7a7ef955230b0 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 15 Sep 2022 21:45:12 +0200 Subject: [PATCH 1/7] Begin cleaning up the Layout stuff. --- arch/ibm/encoder.cc | 6 +++--- lib/decoders/decoders.cc | 8 ++++---- lib/encoders/encoders.cc | 4 ++-- lib/image.cc | 8 ++++---- lib/imagereader/imagereader.cc | 4 ++-- lib/imagereader/imgimagereader.cc | 6 +++--- lib/imagewriter/imagewriter.cc | 4 ++-- lib/imagewriter/imgimagewriter.cc | 8 ++++---- lib/layout.cc | 10 +++++----- lib/layout.h | 4 ++-- lib/vfs/amigaffs.cc | 2 +- lib/vfs/fluxsectorinterface.cc | 6 +++--- lib/vfs/vfs.cc | 14 +++++++------- 13 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index 2d9130a7..2c4afa17 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -114,7 +114,7 @@ public: IbmEncoderProto::TrackdataProto trackdata; getEncoderTrackData(trackdata, location.logicalTrack, location.logicalSide); - auto& trackLayout = + auto trackLayout = Layout::getLayoutOfTrack(location.logicalTrack, location.logicalSide); auto writeBytes = [&](const Bytes& bytes) @@ -151,7 +151,7 @@ public: uint8_t sectorSize = 0; { - int s = trackLayout.sectorSize >> 7; + int s = trackLayout->sectorSize >> 7; while (s > 1) { s >>= 1; @@ -237,7 +237,7 @@ public: bw.write_8(damUnencoded); Bytes truncatedData = - sectorData->data.slice(0, trackLayout.sectorSize); + sectorData->data.slice(0, trackLayout->sectorSize); bw += truncatedData; uint16_t crc = crc16(CCITT_POLY, data); bw.write_be16(crc); diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index d700ff6d..d43f3314 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -133,7 +133,7 @@ std::shared_ptr Decoder::decodeToSectors( if (_sector->status != Sector::MISSING) { - auto& trackLayout = Layout::getLayoutOfTrack( + auto trackLayout = Layout::getLayoutOfTrack( _sector->logicalTrack, _sector->logicalSide); _trackdata->sectors.push_back(_sector); } @@ -224,12 +224,12 @@ uint64_t Decoder::readRaw64() std::set Decoder::requiredSectors( const Location& location) const { - const auto& trackLayout = + const auto trackLayout = Layout::getLayoutOfTrackPhysical(location.physicalTrack, location.physicalSide); std::set results; - for (unsigned sectorId : trackLayout.logicalSectorOrder) + for (unsigned sectorId : trackLayout->logicalSectorOrder) results.insert(LogicalLocation{ - trackLayout.logicalTrack, trackLayout.logicalSide, sectorId}); + trackLayout->logicalTrack, trackLayout->logicalSide, sectorId}); return results; } diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index 87b8d761..4fbd47c4 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -67,9 +67,9 @@ std::vector> Encoder::collectSectors( { std::vector> sectors; - const auto& trackLayout = + const auto trackLayout = Layout::getLayoutOfTrack(location.logicalTrack, location.logicalSide); - for (unsigned sectorId : trackLayout.diskSectorOrder) + for (unsigned sectorId : trackLayout->diskSectorOrder) { const auto& sector = getSector(location, image, sectorId); if (!sector) diff --git a/lib/image.cc b/lib/image.cc index b2a58919..2b2a0621 100644 --- a/lib/image.cc +++ b/lib/image.cc @@ -29,9 +29,9 @@ void Image::createBlankImage() { unsigned track = trackAndHead.first; unsigned side = trackAndHead.second; - auto& trackLayout = Layout::getLayoutOfTrack(track, side); - Bytes blank(trackLayout.sectorSize); - for (unsigned sectorId : trackLayout.logicalSectorOrder) + auto trackLayout = Layout::getLayoutOfTrack(track, side); + Bytes blank(trackLayout->sectorSize); + for (unsigned sectorId : trackLayout->logicalSectorOrder) put(track, side, sectorId)->data = blank; } } @@ -62,7 +62,7 @@ std::shared_ptr Image::get( std::shared_ptr Image::put( unsigned track, unsigned side, unsigned sectorid) { - auto& trackLayout = Layout::getLayoutOfTrack(track, side); + auto trackLayout = Layout::getLayoutOfTrack(track, side); key_t key = std::make_tuple(track, side, sectorid); std::shared_ptr sector = std::make_shared(); sector->logicalTrack = track; diff --git a/lib/imagereader/imagereader.cc b/lib/imagereader/imagereader.cc index add746df..0b8fe271 100644 --- a/lib/imagereader/imagereader.cc +++ b/lib/imagereader/imagereader.cc @@ -107,12 +107,12 @@ std::unique_ptr ImageReader::readMappedImage() std::set> sectors; for (const auto& e : *rawImage) { - auto& trackLayout = + auto trackLayout = Layout::getLayoutOfTrack(e->logicalTrack, e->logicalSide); auto newSector = std::make_shared(); *newSector = *e; newSector->logicalSector = - trackLayout.filesystemToLogicalSectorMap.at(e->logicalSector); + trackLayout->filesystemToLogicalSectorMap.at(e->logicalSector); sectors.insert(newSector); } diff --git a/lib/imagereader/imgimagereader.cc b/lib/imagereader/imgimagereader.cc index a1e993e0..303e303c 100644 --- a/lib/imagereader/imgimagereader.cc +++ b/lib/imagereader/imgimagereader.cc @@ -39,10 +39,10 @@ public: if (inputFile.eof()) break; - auto& trackLayout = Layout::getLayoutOfTrack(track, side); - for (int sectorId : trackLayout.logicalSectorOrder) + auto trackLayout = Layout::getLayoutOfTrack(track, side); + for (int sectorId : trackLayout->logicalSectorOrder) { - Bytes data(trackLayout.sectorSize); + Bytes data(trackLayout->sectorSize); inputFile.read((char*)data.begin(), data.size()); const auto& sector = image->put(track, side, sectorId); diff --git a/lib/imagewriter/imagewriter.cc b/lib/imagewriter/imagewriter.cc index f969ea0d..a1e9e19f 100644 --- a/lib/imagewriter/imagewriter.cc +++ b/lib/imagewriter/imagewriter.cc @@ -213,12 +213,12 @@ void ImageWriter::writeMappedImage(const Image& image) std::set> sectors; for (const auto& e : image) { - auto& trackLayout = + auto trackLayout = Layout::getLayoutOfTrack(e->logicalTrack, e->logicalSide); auto newSector = std::make_shared(); *newSector = *e; newSector->logicalSector = - trackLayout.logicalToFilesystemSectorMap.at(e->logicalSector); + trackLayout->logicalToFilesystemSectorMap.at(e->logicalSector); sectors.insert(newSector); } diff --git a/lib/imagewriter/imgimagewriter.cc b/lib/imagewriter/imgimagewriter.cc index 04f0cf42..22f32eb4 100644 --- a/lib/imagewriter/imgimagewriter.cc +++ b/lib/imagewriter/imgimagewriter.cc @@ -36,14 +36,14 @@ public: int track = p.first; int side = p.second; - auto& trackLayout = Layout::getLayoutOfTrack(track, side); - for (int sectorId : trackLayout.logicalSectorOrder) + auto trackLayout = Layout::getLayoutOfTrack(track, side); + for (int sectorId : trackLayout->logicalSectorOrder) { const auto& sector = image.get(track, side, sectorId); if (sector) - sector->data.slice(0, trackLayout.sectorSize).writeTo(outputFile); + sector->data.slice(0, trackLayout->sectorSize).writeTo(outputFile); else - outputFile.seekp(trackLayout.sectorSize, std::ios::cur); + outputFile.seekp(trackLayout->sectorSize, std::ios::cur); } } diff --git a/lib/layout.cc b/lib/layout.cc index 5b329697..a7a97675 100644 --- a/lib/layout.cc +++ b/lib/layout.cc @@ -4,7 +4,7 @@ #include "lib/environment.h" #include -static Local, std::unique_ptr>> +static Local, std::shared_ptr>> layoutCache; static unsigned getTrackStep() @@ -141,13 +141,13 @@ std::vector Layout::expandSectorList( return sectors; } -const Layout& Layout::getLayoutOfTrack( +std::shared_ptr Layout::getLayoutOfTrack( unsigned logicalTrack, unsigned logicalSide) { auto& layout = (*layoutCache)[std::make_pair(logicalTrack, logicalSide)]; if (!layout) { - layout.reset(new Layout()); + layout = std::make_shared(); LayoutProto::LayoutdataProto layoutdata; for (const auto& f : config.layout().layoutdata()) @@ -203,10 +203,10 @@ const Layout& Layout::getLayoutOfTrack( } } - return *layout; + return layout; } -const Layout& Layout::getLayoutOfTrackPhysical( +std::shared_ptr Layout::getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide) { return getLayoutOfTrack(remapTrackPhysicalToLogical(physicalTrack), diff --git a/lib/layout.h b/lib/layout.h index 55dd9cf4..66927403 100644 --- a/lib/layout.h +++ b/lib/layout.h @@ -45,11 +45,11 @@ public: unsigned guessedTracks = 0, unsigned guessedSides = 0); /* Returns the layout of a given track. */ - static const Layout& getLayoutOfTrack( + static std::shared_ptr getLayoutOfTrack( unsigned logicalTrack, unsigned logicalHead); /* Returns the layout of a given track via physical location. */ - static const Layout& getLayoutOfTrackPhysical( + static std::shared_ptr getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide); /* Expand a SectorList into the actual sector IDs. */ diff --git a/lib/vfs/amigaffs.cc b/lib/vfs/amigaffs.cc index 706d3fe7..c70b232d 100644 --- a/lib/vfs/amigaffs.cc +++ b/lib/vfs/amigaffs.cc @@ -91,7 +91,7 @@ public: dev.devType = DEVTYPE_FLOPDD; dev.cylinders = config.layout().tracks(); dev.heads = config.layout().sides(); - dev.sectors = Layout::getLayoutOfTrack(0, 0).numSectors; + dev.sectors = Layout::getLayoutOfTrack(0, 0)->numSectors; adfInitDevice(&dev, nullptr, false); int res = adfCreateFlop(&dev, (char*)volumeName.c_str(), 0); if (res != RC_OK) diff --git a/lib/vfs/fluxsectorinterface.cc b/lib/vfs/fluxsectorinterface.cc index 71bd398b..32fb5680 100644 --- a/lib/vfs/fluxsectorinterface.cc +++ b/lib/vfs/fluxsectorinterface.cc @@ -62,7 +62,7 @@ public: { unsigned track = trackid.first; unsigned side = trackid.second; - auto& trackLayout = Layout::getLayoutOfTrack(track, side); + auto trackLayout = Layout::getLayoutOfTrack(track, side); locations.insert(Layout::computeLocationFor(track, side)); /* If we don't have all the sectors of this track, we may need to @@ -72,7 +72,7 @@ public: if (!imageContainsAllSectorsOf(_changedSectors, track, side, - trackLayout.logicalSectorOrder)) + trackLayout->logicalSectorOrder)) { /* If we don't have any loaded sectors for this track, pre-read * it. */ @@ -83,7 +83,7 @@ public: /* Now merge the loaded track with the changed one, and write * the result back. */ - for (unsigned sectorId : trackLayout.logicalSectorOrder) + for (unsigned sectorId : trackLayout->logicalSectorOrder) { if (!_changedSectors.contains(track, side, sectorId)) _changedSectors.put(track, side, sectorId)->data = diff --git a/lib/vfs/vfs.cc b/lib/vfs/vfs.cc index c9ab10d8..133ddc7c 100644 --- a/lib/vfs/vfs.cc +++ b/lib/vfs/vfs.cc @@ -164,12 +164,12 @@ Filesystem::Filesystem(std::shared_ptr sectors): int track = p.first; int side = p.second; - auto& trackLayout = Layout::getLayoutOfTrack(track, side); - if (trackLayout.numSectors == 0) + auto trackLayout = Layout::getLayoutOfTrack(track, side); + if (trackLayout->numSectors == 0) Error() << "FS: filesystem support cannot be used without concrete " "layout information"; - for (int sectorId : trackLayout.filesystemSectorOrder) + for (int sectorId : trackLayout->filesystemSectorOrder) _locations.push_back(std::make_tuple(track, side, sectorId)); } } @@ -273,9 +273,9 @@ Bytes Filesystem::getLogicalSector(uint32_t number, uint32_t count) int track = std::get<0>(it); int side = std::get<1>(it); int sector = std::get<2>(it); - auto& trackLayout = Layout::getLayoutOfTrack(track, side); + auto trackLayout = Layout::getLayoutOfTrack(track, side); bw += _sectors->get(track, side, sector) - ->data.slice(0, trackLayout.sectorSize); + ->data.slice(0, trackLayout->sectorSize); } return data; } @@ -293,7 +293,7 @@ void Filesystem::putLogicalSector(uint32_t number, const Bytes& data) int track = std::get<0>(it); int side = std::get<1>(it); int sector = std::get<2>(it); - int sectorSize = Layout::getLayoutOfTrack(track, side).sectorSize; + int sectorSize = Layout::getLayoutOfTrack(track, side)->sectorSize; _sectors->put(track, side, sector)->data = data.slice(pos, sectorSize); pos += sectorSize; @@ -322,7 +322,7 @@ unsigned Filesystem::getLogicalSectorCount() unsigned Filesystem::getLogicalSectorSize(unsigned track, unsigned side) { - return Layout::getLayoutOfTrack(track, side).sectorSize; + return Layout::getLayoutOfTrack(track, side)->sectorSize; } void Filesystem::eraseEverythingOnDisk() From 82f61eee126b47ad7db4c4f43bbcc8f4cc0af3cd Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 15 Sep 2022 23:52:07 +0200 Subject: [PATCH 2/7] Eliminate Location in favour of Layout. --- arch/amiga/encoder.cc | 2 +- arch/apple2/encoder.cc | 2 +- arch/brother/encoder.cc | 2 +- arch/c64/encoder.cc | 294 ++++---- arch/ibm/encoder.cc | 6 +- arch/macintosh/encoder.cc | 5 +- arch/micropolis/encoder.cc | 2 +- arch/northstar/encoder.cc | 2 +- arch/tids990/encoder.cc | 2 +- arch/victor9k/encoder.cc | 5 +- lib/decoders/decoders.cc | 12 +- lib/decoders/decoders.h | 7 +- lib/encoders/encoders.cc | 14 +- lib/encoders/encoders.h | 8 +- lib/flux.h | 34 +- lib/fluxsource/memoryfluxsource.cc | 4 +- lib/layout.cc | 22 +- lib/layout.h | 25 +- lib/readerwriter.cc | 97 +-- lib/readerwriter.h | 15 +- lib/sector.cc | 8 +- lib/sector.h | 6 +- lib/vfs/brother120fs.cc | 3 +- lib/vfs/fluxsectorinterface.cc | 8 +- src/gui/customstatusbar.h | 2 +- src/gui/fluxviewercontrol.cc | 39 +- src/gui/fluxviewercontrol.h | 56 +- src/gui/fluxviewerwindow.cc | 5 +- src/gui/fluxviewerwindow.h | 3 +- src/gui/gui.h | 31 +- src/gui/icon.png.h | 1063 +++++++++++++++++++++++++--- src/gui/layout.h | 647 ++++++++++------- src/gui/mainwindow.cc | 1 + src/gui/visualisationcontrol.cc | 10 +- 34 files changed, 1718 insertions(+), 724 deletions(-) diff --git a/arch/amiga/encoder.cc b/arch/amiga/encoder.cc index 16e07252..7851b2e0 100644 --- a/arch/amiga/encoder.cc +++ b/arch/amiga/encoder.cc @@ -110,7 +110,7 @@ public: } public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/apple2/encoder.cc b/arch/apple2/encoder.cc index f4cf8e39..c463a3cb 100644 --- a/arch/apple2/encoder.cc +++ b/arch/apple2/encoder.cc @@ -36,7 +36,7 @@ private: const Apple2EncoderProto& _config; public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/brother/encoder.cc b/arch/brother/encoder.cc index 65d6d69c..d0f62ad0 100644 --- a/arch/brother/encoder.cc +++ b/arch/brother/encoder.cc @@ -108,7 +108,7 @@ public: public: std::unique_ptr encode( - const Location& location, + std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/c64/encoder.cc b/arch/c64/encoder.cc index e854eb2a..9f9318ca 100644 --- a/arch/c64/encoder.cc +++ b/arch/c64/encoder.cc @@ -9,6 +9,7 @@ #include "fmt/format.h" #include "arch/c64/c64.pb.h" #include "lib/encoders/encoders.pb.h" +#include "lib/layout.h" #include #include "bytes.h" @@ -18,29 +19,32 @@ static int encode_data_gcr(uint8_t data) { switch (data) { - #define GCR_ENTRY(gcr, data) \ - case data: return gcr; - #include "data_gcr.h" - #undef GCR_ENTRY +#define GCR_ENTRY(gcr, data) \ + case data: \ + return gcr; +#include "data_gcr.h" +#undef GCR_ENTRY } return -1; } -static void write_bits(std::vector& bits, unsigned& cursor, const std::vector& src) +static void write_bits( + std::vector& bits, unsigned& cursor, const std::vector& src) { - for (bool bit : src) //Range-based for loop + for (bool bit : src) // Range-based for loop { if (cursor < bits.size()) bits[cursor++] = bit; } } -static void write_bits(std::vector& bits, unsigned& cursor, uint64_t data, int width) +static void write_bits( + std::vector& bits, unsigned& cursor, uint64_t data, int width) { cursor += width; - for (int i=0; i>= 1; @@ -51,18 +55,17 @@ void bindump(std::ostream& stream, std::vector& buffer) { size_t pos = 0; - while ((pos < buffer.size()) and (pos <520)) + while ((pos < buffer.size()) and (pos < 520)) { stream << fmt::format("{:5d} : ", pos); - for (int i=0; i<40; i++) + for (int i = 0; i < 40; i++) { - if ((pos+i) < buffer.size()) - stream << fmt::format("{:01b}", (buffer[pos+i])); + if ((pos + i) < buffer.size()) + stream << fmt::format("{:01b}", (buffer[pos + i])); else stream << "-- "; if ((((pos + i + 1) % 8) == 0) and i != 0) stream << " "; - } stream << std::endl; pos += 40; @@ -71,51 +74,51 @@ void bindump(std::ostream& stream, std::vector& buffer) static std::vector encode_data(uint8_t input) { /* - * Four 8-bit data bytes are converted to four 10-bit GCR bytes at a time by - * the 1541 DOS. RAM is only an 8-bit storage device though. This hardware - * limitation prevents a 10-bit GCR byte from being stored in a single - * memory location. Four 10-bit GCR bytes total 40 bits - a number evenly - * divisible by our overriding 8-bit constraint. Commodore sub- divides the - * 40 GCR bits into five 8-bit bytes to solve this dilemma. This explains - * why four 8-bit data bytes are converted to GCR form at a time. The - * following step by step example demonstrates how this bit manipulation is - * performed by the DOS. - * - * STEP 1. Four 8-bit Data Bytes - * $08 $10 $00 $12 - * - * STEP 2. Hexadecimal to Binary Conversion - * 1. Binary Equivalents - * $08 $10 $00 $12 - * 00001000 00010000 00000000 00010010 - * - * STEP 3. Binary to GCR Conversion - * 1. Four 8-bit Data Bytes - * 00001000 00010000 00000000 00010010 - * 2. High and Low Nybbles - * 0000 1000 0001 0000 0000 0000 0001 0010 - * 3. High and Low Nybble GCR Equivalents - * 01010 01001 01011 01010 01010 01010 01011 10010 - * 4. Four 10-bit GCR Bytes - * 0101001001 0101101010 0101001010 0101110010 - * - * STEP 4. 10-bit GCR to 8-bit GCR Conversion - * 1. Concatenate Four 10-bit GCR Bytes - * 0101001001010110101001010010100101110010 - * 2. Five 8-bit Subdivisions - * 01010010 01010110 10100101 00101001 01110010 - * - * STEP 5. Binary to Hexadecimal Conversion - * 1. Hexadecimal Equivalents - * 01010010 01010110 10100101 00101001 01110010 - * $52 $56 $A5 $29 $72 - * - * STEP 6. Four 8-bit Data Bytes are Recorded as Five 8-bit GCR Bytes - * $08 $10 $00 $12 - * - * are recorded as - * $52 $56 $A5 $29 $72 - */ + * Four 8-bit data bytes are converted to four 10-bit GCR bytes at a time by + * the 1541 DOS. RAM is only an 8-bit storage device though. This hardware + * limitation prevents a 10-bit GCR byte from being stored in a single + * memory location. Four 10-bit GCR bytes total 40 bits - a number evenly + * divisible by our overriding 8-bit constraint. Commodore sub- divides the + * 40 GCR bits into five 8-bit bytes to solve this dilemma. This explains + * why four 8-bit data bytes are converted to GCR form at a time. The + * following step by step example demonstrates how this bit manipulation is + * performed by the DOS. + * + * STEP 1. Four 8-bit Data Bytes + * $08 $10 $00 $12 + * + * STEP 2. Hexadecimal to Binary Conversion + * 1. Binary Equivalents + * $08 $10 $00 $12 + * 00001000 00010000 00000000 00010010 + * + * STEP 3. Binary to GCR Conversion + * 1. Four 8-bit Data Bytes + * 00001000 00010000 00000000 00010010 + * 2. High and Low Nybbles + * 0000 1000 0001 0000 0000 0000 0001 0010 + * 3. High and Low Nybble GCR Equivalents + * 01010 01001 01011 01010 01010 01010 01011 10010 + * 4. Four 10-bit GCR Bytes + * 0101001001 0101101010 0101001010 0101110010 + * + * STEP 4. 10-bit GCR to 8-bit GCR Conversion + * 1. Concatenate Four 10-bit GCR Bytes + * 0101001001010110101001010010100101110010 + * 2. Five 8-bit Subdivisions + * 01010010 01010110 10100101 00101001 01110010 + * + * STEP 5. Binary to Hexadecimal Conversion + * 1. Hexadecimal Equivalents + * 01010010 01010110 10100101 00101001 01110010 + * $52 $56 $A5 $29 $72 + * + * STEP 6. Four 8-bit Data Bytes are Recorded as Five 8-bit GCR Bytes + * $08 $10 $00 $12 + * + * are recorded as + * $52 $56 $A5 $29 $72 + */ std::vector output(10, false); uint8_t hi = 0; @@ -123,40 +126,40 @@ static std::vector encode_data(uint8_t input) uint8_t lo_GCR = 0; uint8_t hi_GCR = 0; - //Convert the byte in high and low nibble - lo = input >> 4; //get the lo nibble shift the bits 4 to the right - hi = input & 15; //get the hi nibble bij masking the lo bits (00001111) + // Convert the byte in high and low nibble + lo = input >> 4; // get the lo nibble shift the bits 4 to the right + hi = input & 15; // get the hi nibble bij masking the lo bits (00001111) - - lo_GCR = encode_data_gcr(lo); //example value: 0000 GCR = 01010 - hi_GCR = encode_data_gcr(hi); //example value: 1000 GCR = 01001 - //output = [0,1,2,3,4,5,6,7,8,9] - //value = [0,1,0,1,0,0,1,0,0,1] - // 01010 01001 + lo_GCR = encode_data_gcr(lo); // example value: 0000 GCR = 01010 + hi_GCR = encode_data_gcr(hi); // example value: 1000 GCR = 01001 + // output = [0,1,2,3,4,5,6,7,8,9] + // value = [0,1,0,1,0,0,1,0,0,1] + // 01010 01001 int b = 4; for (int i = 0; i < 10; i++) { - if (i < 5) //01234 - { //i = 0 op - output[4-i] = (lo_GCR & 1); //01010 + if (i < 5) // 01234 + { // i = 0 op + output[4 - i] = (lo_GCR & 1); // 01010 - //01010 -> & 00001 -> 00000 output[4] = 0 - //00101 -> & 00001 -> 00001 output[3] = 1 - //00010 -> & 00001 -> 00000 output[2] = 0 - //00001 -> & 00001 -> 00001 output[1] = 1 - //00000 -> & 00001 -> 00000 output[0] = 0 + // 01010 -> & 00001 -> 00000 output[4] = 0 + // 00101 -> & 00001 -> 00001 output[3] = 1 + // 00010 -> & 00001 -> 00000 output[2] = 0 + // 00001 -> & 00001 -> 00001 output[1] = 1 + // 00000 -> & 00001 -> 00000 output[0] = 0 lo_GCR >>= 1; - } else + } + else { - output[i+b] = (hi_GCR & 1); //01001 - //01001 -> & 00001 -> 00001 output[9] = 1 - //00100 -> & 00001 -> 00000 output[8] = 0 - //00010 -> & 00001 -> 00000 output[7] = 0 - //00001 -> & 00001 -> 00001 output[6] = 1 - //00000 -> & 00001 -> 00000 output[5] = 0 + output[i + b] = (hi_GCR & 1); // 01001 + // 01001 -> & 00001 -> 00001 output[9] = 1 + // 00100 -> & 00001 -> 00000 output[8] = 0 + // 00010 -> & 00001 -> 00000 output[7] = 0 + // 00001 -> & 00001 -> 00001 output[6] = 1 + // 00000 -> & 00001 -> 00000 output[5] = 0 hi_GCR >>= 1; - b = b-2; + b = b - 2; } } return output; @@ -165,59 +168,68 @@ static std::vector encode_data(uint8_t input) class Commodore64Encoder : public Encoder { public: - Commodore64Encoder(const EncoderProto& config): + Commodore64Encoder(const EncoderProto& config): Encoder(config), - _config(config.c64()) - {} + _config(config.c64()) + { + } public: - std::unique_ptr encode(const Location& location, - const std::vector>& sectors, const Image& image) override + std::unique_ptr encode(std::shared_ptr& layout, + const std::vector>& sectors, + const Image& image) override { - /* The format ID Character # 1 and # 2 are in the .d64 image only present - * in track 18 sector zero which contains the BAM info in byte 162 and 163. - * it is written in every header of every sector and track. headers are not - * stored in a d64 disk image so we have to get it from track 18 which - * contains the BAM. - */ + /* The format ID Character # 1 and # 2 are in the .d64 image only + * present in track 18 sector zero which contains the BAM info in byte + * 162 and 163. it is written in every header of every sector and track. + * headers are not stored in a d64 disk image so we have to get it from + * track 18 which contains the BAM. + */ - const auto& sectorData = image.get(C64_BAM_TRACK, 0, 0); //Read de BAM to get the DISK ID bytes + const auto& sectorData = image.get( + C64_BAM_TRACK, 0, 0); // Read de BAM to get the DISK ID bytes if (sectorData) { ByteReader br(sectorData->data); - br.seek(162); //goto position of the first Disk ID Byte + br.seek(162); // goto position of the first Disk ID Byte _formatByte1 = br.read_8(); _formatByte2 = br.read_8(); } else _formatByte1 = _formatByte2 = 0; - - double clockRateUs = clockPeriodForC64Track(location.logicalTrack); + + double clockRateUs = clockPeriodForC64Track(layout->logicalTrack); int bitsPerRevolution = 200000.0 / clockRateUs; std::vector bits(bitsPerRevolution); unsigned cursor = 0; - fillBitmapTo(bits, cursor, _config.post_index_gap_us() / clockRateUs, { true, false }); + fillBitmapTo(bits, + cursor, + _config.post_index_gap_us() / clockRateUs, + {true, false}); lastBit = false; for (const auto& sector : sectors) writeSector(bits, cursor, sector); if (cursor >= bits.size()) - Error() << fmt::format("track data overrun by {} bits", cursor - bits.size()); - fillBitmapTo(bits, cursor, bits.size(), { true, false }); + Error() << fmt::format( + "track data overrun by {} bits", cursor - bits.size()); + fillBitmapTo(bits, cursor, bits.size(), {true, false}); std::unique_ptr fluxmap(new Fluxmap); - fluxmap->appendBits(bits, - calculatePhysicalClockPeriod(clockRateUs*1e3, 200e6)); + fluxmap->appendBits( + bits, calculatePhysicalClockPeriod(clockRateUs * 1e3, 200e6)); return fluxmap; } private: - void writeSector(std::vector& bits, unsigned& cursor, std::shared_ptr sector) const + void writeSector(std::vector& bits, + unsigned& cursor, + std::shared_ptr sector) const { - /* Source: http://www.unusedino.de/ec64/technical/formats/g64.html + /* Source: http://www.unusedino.de/ec64/technical/formats/g64.html * 1. Header sync FF FF FF FF FF (40 'on' bits, not GCR) * 2. Header info 52 54 B5 29 4B 7A 5E 95 55 55 (10 GCR bytes) * 3. Header gap 55 55 55 55 55 55 55 55 55 (9 bytes, never read) @@ -225,23 +237,27 @@ private: * 5. Data block 55...4A (325 GCR bytes) * 6. Inter-sector gap 55 55 55 55...55 55 (4 to 12 bytes, never read) * 1. Header sync (SYNC for the next sector) - */ - if ((sector->status == Sector::OK) or (sector->status == Sector::BAD_CHECKSUM)) + */ + if ((sector->status == Sector::OK) or + (sector->status == Sector::BAD_CHECKSUM)) { // There is data to encode to disk. if ((sector->data.size() != C64_SECTOR_LENGTH)) - Error() << fmt::format("unsupported sector size {} --- you must pick 256", sector->data.size()); + Error() << fmt::format( + "unsupported sector size {} --- you must pick 256", + sector->data.size()); // 1. Write header Sync (not GCR) - for (int i=0; i<6; i++) - write_bits(bits, cursor, C64_HEADER_DATA_SYNC, 1*8); /* sync */ + for (int i = 0; i < 6; i++) + write_bits( + bits, cursor, C64_HEADER_DATA_SYNC, 1 * 8); /* sync */ // 2. Write Header info 10 GCR bytes /* - * The 10 byte header info (#2) is GCR encoded and must be decoded to - * it's normal 8 bytes to be understood. Once decoded, its breakdown is - * as follows: - * + * The 10 byte header info (#2) is GCR encoded and must be decoded + * to it's normal 8 bytes to be understood. Once decoded, its + * breakdown is as follows: + * * Byte $00 - header block ID ($08) * 01 - header block checksum 16 (EOR of $02-$05) * 02 - Sector @@ -250,11 +266,14 @@ private: * 05 - Format ID byte #1 * 06-07 - $0F ("off" bytes) */ - uint8_t encodedTrack = ((sector->logicalTrack) + 1); // C64 track numbering starts with 1. Fluxengine with 0. + uint8_t encodedTrack = + ((sector->logicalTrack) + + 1); // C64 track numbering starts with 1. Fluxengine with 0. uint8_t encodedSector = sector->logicalSector; // uint8_t formatByte1 = C64_FORMAT_ID_BYTE1; // uint8_t formatByte2 = C64_FORMAT_ID_BYTE2; - uint8_t headerChecksum = (encodedTrack ^ encodedSector ^ _formatByte1 ^ _formatByte2); + uint8_t headerChecksum = + (encodedTrack ^ encodedSector ^ _formatByte1 ^ _formatByte2); write_bits(bits, cursor, encode_data(C64_HEADER_BLOCK_ID)); write_bits(bits, cursor, encode_data(headerChecksum)); write_bits(bits, cursor, encode_data(encodedSector)); @@ -265,22 +284,26 @@ private: write_bits(bits, cursor, encode_data(C64_PADDING)); // 3. Write header GAP not GCR - for (int i=0; i<9; i++) - write_bits(bits, cursor, C64_HEADER_GAP, 1*8); /* header gap */ + for (int i = 0; i < 9; i++) + write_bits( + bits, cursor, C64_HEADER_GAP, 1 * 8); /* header gap */ // 4. Write Data sync not GCR - for (int i=0; i<6; i++) - write_bits(bits, cursor, C64_HEADER_DATA_SYNC, 1*8); /* sync */ + for (int i = 0; i < 6; i++) + write_bits( + bits, cursor, C64_HEADER_DATA_SYNC, 1 * 8); /* sync */ // 5. Write data block 325 GCR bytes /* - * The 325 byte data block (#5) is GCR encoded and must be decoded to its - * normal 260 bytes to be understood. The data block is made up of the following: - * + * The 325 byte data block (#5) is GCR encoded and must be decoded + * to its normal 260 bytes to be understood. The data block is made + * up of the following: + * * Byte $00 - data block ID ($07) * 01-100 - 256 bytes data * 101 - data block checksum (EOR of $01-100) - * 102-103 - $00 ("off" bytes, to make the sector size a multiple of 5) + * 102-103 - $00 ("off" bytes, to make the sector size a + * multiple of 5) */ write_bits(bits, cursor, encode_data(C64_DATA_BLOCK_ID)); @@ -290,29 +313,28 @@ private: for (i = 0; i < C64_SECTOR_LENGTH; i++) { uint8_t val = br.read_8(); - write_bits(bits, cursor, encode_data(val)); + write_bits(bits, cursor, encode_data(val)); } write_bits(bits, cursor, encode_data(dataChecksum)); write_bits(bits, cursor, encode_data(C64_PADDING)); write_bits(bits, cursor, encode_data(C64_PADDING)); - //6. Write inter-sector gap 9 - 12 bytes nor gcr - for (int i=0; i<9; i++) - write_bits(bits, cursor, C64_INTER_SECTOR_GAP, 1*8); /* sync */ - + // 6. Write inter-sector gap 9 - 12 bytes nor gcr + for (int i = 0; i < 9; i++) + write_bits( + bits, cursor, C64_INTER_SECTOR_GAP, 1 * 8); /* sync */ } } - + private: - const Commodore64EncoderProto& _config; - uint8_t _formatByte1; - uint8_t _formatByte2; + const Commodore64EncoderProto& _config; + uint8_t _formatByte1; + uint8_t _formatByte2; }; std::unique_ptr createCommodore64Encoder(const EncoderProto& config) { - return std::unique_ptr(new Commodore64Encoder(config)); + return std::unique_ptr(new Commodore64Encoder(config)); } // vim: sw=4 ts=4 et - diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index 2c4afa17..7264607b 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -107,15 +107,15 @@ private: } public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { IbmEncoderProto::TrackdataProto trackdata; - getEncoderTrackData(trackdata, location.logicalTrack, location.logicalSide); + getEncoderTrackData(trackdata, layout->logicalTrack, layout->logicalSide); auto trackLayout = - Layout::getLayoutOfTrack(location.logicalTrack, location.logicalSide); + Layout::getLayoutOfTrack(layout->logicalTrack, layout->logicalSide); auto writeBytes = [&](const Bytes& bytes) { diff --git a/arch/macintosh/encoder.cc b/arch/macintosh/encoder.cc index bc0786d7..a9b07ea8 100644 --- a/arch/macintosh/encoder.cc +++ b/arch/macintosh/encoder.cc @@ -7,6 +7,7 @@ #include "image.h" #include "fmt/format.h" #include "lib/encoders/encoders.pb.h" +#include "lib/layout.h" #include "arch/macintosh/macintosh.pb.h" #include @@ -219,11 +220,11 @@ public: } public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { - double clockRateUs = clockRateUsForTrack(location.logicalTrack); + double clockRateUs = clockRateUsForTrack(layout->logicalTrack); int bitsPerRevolution = 200000.0 / clockRateUs; std::vector bits(bitsPerRevolution); unsigned cursor = 0; diff --git a/arch/micropolis/encoder.cc b/arch/micropolis/encoder.cc index 9196d225..b0d6238c 100644 --- a/arch/micropolis/encoder.cc +++ b/arch/micropolis/encoder.cc @@ -77,7 +77,7 @@ public: { } - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/northstar/encoder.cc b/arch/northstar/encoder.cc index 2f635fb0..68f5a807 100644 --- a/arch/northstar/encoder.cc +++ b/arch/northstar/encoder.cc @@ -128,7 +128,7 @@ public: { } - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/tids990/encoder.cc b/arch/tids990/encoder.cc index 5fc52967..825be0c5 100644 --- a/arch/tids990/encoder.cc +++ b/arch/tids990/encoder.cc @@ -60,7 +60,7 @@ private: } public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/victor9k/encoder.cc b/arch/victor9k/encoder.cc index 1578aca6..df136a03 100644 --- a/arch/victor9k/encoder.cc +++ b/arch/victor9k/encoder.cc @@ -9,6 +9,7 @@ #include "fmt/format.h" #include "arch/victor9k/victor9k.pb.h" #include "lib/encoders/encoders.pb.h" +#include "lib/layout.h" #include #include "bytes.h" @@ -163,12 +164,12 @@ private: } public: - std::unique_ptr encode(const Location& location, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { Victor9kEncoderProto::TrackdataProto trackdata; - getTrackFormat(trackdata, location.logicalTrack, location.logicalSide); + getTrackFormat(trackdata, layout->logicalTrack, layout->logicalSide); unsigned bitsPerRevolution = (trackdata.rotational_period_ms() * 1e3) / trackdata.clock_period_us(); diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index d43f3314..5491f0b5 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -60,19 +60,19 @@ std::unique_ptr Decoder::create(const DecoderProto& config) return (decoder->second)(config); } -std::shared_ptr Decoder::decodeToSectors( - std::shared_ptr fluxmap, const Location& location) +std::shared_ptr Decoder::decodeToSectors( + std::shared_ptr fluxmap, std::shared_ptr& layout) { _trackdata = std::make_shared(); _trackdata->fluxmap = fluxmap; - _trackdata->location = location; + _trackdata->layout = layout; FluxmapReader fmr(*fluxmap); _fmr = &fmr; auto newSector = [&] { - _sector = std::make_shared(location); + _sector = std::make_shared(layout, 0); _sector->status = Sector::MISSING; }; @@ -222,10 +222,10 @@ uint64_t Decoder::readRaw64() } std::set Decoder::requiredSectors( - const Location& location) const + std::shared_ptr& layout) const { const auto trackLayout = - Layout::getLayoutOfTrackPhysical(location.physicalTrack, location.physicalSide); + Layout::getLayoutOfTrackPhysical(layout->physicalTrack, layout->physicalSide); std::set results; for (unsigned sectorId : trackLayout->logicalSectorOrder) diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index 4af2391a..5af9d855 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -49,9 +49,9 @@ public: }; public: - std::shared_ptr decodeToSectors( + std::shared_ptr decodeToSectors( std::shared_ptr fluxmap, - const Location& location); + std::shared_ptr& location); void pushRecord( const Fluxmap::Position& start, const Fluxmap::Position& end); @@ -89,7 +89,8 @@ public: return _fmr->getDuration(); } - virtual std::set requiredSectors(const Location& location) const; + virtual std::set requiredSectors( + std::shared_ptr& location) const; protected: virtual void beginTrack(){}; diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index 4fbd47c4..a55245f3 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -57,25 +57,23 @@ nanoseconds_t Encoder::calculatePhysicalClockPeriod( } std::shared_ptr Encoder::getSector( - const Location& location, const Image& image, unsigned sectorId) + std::shared_ptr& layout, const Image& image, unsigned sectorId) { - return image.get(location.logicalTrack, location.logicalSide, sectorId); + return image.get(layout->logicalTrack, layout->logicalSide, sectorId); } std::vector> Encoder::collectSectors( - const Location& location, const Image& image) + std::shared_ptr& trackLayout, const Image& image) { std::vector> sectors; - const auto trackLayout = - Layout::getLayoutOfTrack(location.logicalTrack, location.logicalSide); for (unsigned sectorId : trackLayout->diskSectorOrder) { - const auto& sector = getSector(location, image, sectorId); + const auto& sector = getSector(trackLayout, image, sectorId); if (!sector) Error() << fmt::format("sector {}.{}.{} is missing from the image", - location.logicalTrack, - location.logicalSide, + trackLayout->logicalTrack, + trackLayout->logicalSide, sectorId); sectors.push_back(sector); } diff --git a/lib/encoders/encoders.h b/lib/encoders/encoders.h index c1bb104e..c82fac72 100644 --- a/lib/encoders/encoders.h +++ b/lib/encoders/encoders.h @@ -4,7 +4,7 @@ class EncoderProto; class Fluxmap; class Image; -class Location; +class Layout; class Sector; class Encoder @@ -17,12 +17,12 @@ public: public: virtual std::shared_ptr getSector( - const Location& location, const Image& image, unsigned sectorId); + std::shared_ptr&, const Image& image, unsigned sectorId); virtual std::vector> collectSectors( - const Location& location, const Image& image); + std::shared_ptr&, const Image& image); - virtual std::unique_ptr encode(const Location& location, + virtual std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) = 0; diff --git a/lib/flux.h b/lib/flux.h index 709f07e4..7b37d43b 100644 --- a/lib/flux.h +++ b/lib/flux.h @@ -6,6 +6,7 @@ class Fluxmap; class Sector; class Image; +class Layout; struct Record { @@ -15,34 +16,9 @@ struct Record Bytes rawData; }; -struct Location -{ - unsigned physicalTrack; - unsigned physicalSide; - unsigned logicalTrack; - unsigned logicalSide; - unsigned groupSize; - - bool operator==(const Location& other) const - { - return key() == other.key(); - } - - bool operator<(const Location& other) const - { - return key() < other.key(); - } - -private: - std::tuple key() const - { - return std::make_tuple(physicalTrack, physicalSide); - } -}; - struct TrackDataFlux { - Location location; + std::shared_ptr layout; std::shared_ptr fluxmap; std::vector> records; std::vector> sectors; @@ -50,14 +26,14 @@ struct TrackDataFlux struct TrackFlux { - Location location; - std::vector> trackDatas; + std::shared_ptr layout; + std::vector> trackDatas; std::set> sectors; }; struct DiskFlux { - std::vector> tracks; + std::vector> tracks; std::shared_ptr image; }; diff --git a/lib/fluxsource/memoryfluxsource.cc b/lib/fluxsource/memoryfluxsource.cc index c288e7bd..e4d4848f 100644 --- a/lib/fluxsource/memoryfluxsource.cc +++ b/lib/fluxsource/memoryfluxsource.cc @@ -3,6 +3,7 @@ #include "lib/flux.h" #include "lib/fluxsource/fluxsource.h" #include "lib/fluxmap.h" +#include "lib/layout.h" #include #include @@ -40,6 +41,7 @@ class EmptyFluxSourceIterator : public FluxSourceIterator std::unique_ptr next() override { Error() << "no flux to read"; + throw nullptr; } }; @@ -55,7 +57,7 @@ public: { for (const auto& trackFlux : _flux.tracks) { - if ((trackFlux->location.physicalTrack == physicalTrack) && (trackFlux->location.physicalSide == physicalSide)) + if ((trackFlux->layout->physicalTrack == physicalTrack) && (trackFlux->layout->physicalSide == physicalSide)) return std::make_unique(*trackFlux); } diff --git a/lib/layout.cc b/lib/layout.cc index a7a97675..ce3f2556 100644 --- a/lib/layout.cc +++ b/lib/layout.cc @@ -38,7 +38,7 @@ unsigned Layout::remapSideLogicalToPhysical(unsigned lside) return lside ^ config.layout().swap_sides(); } -std::set Layout::computeLocations() +std::vector> Layout::computeLocations() { std::set tracks; if (config.has_tracks()) @@ -52,31 +52,15 @@ std::set Layout::computeLocations() else heads = iterate(0, config.layout().sides()); - std::set locations; + std::vector> locations; for (unsigned logicalTrack : tracks) { for (unsigned logicalHead : heads) - locations.insert(computeLocationFor(logicalTrack, logicalHead)); + locations.push_back(getLayoutOfTrack(logicalTrack, logicalHead)); } return locations; } -Location Layout::computeLocationFor(unsigned logicalTrack, unsigned logicalSide) -{ - if ((logicalTrack < config.layout().tracks()) && - (logicalSide < config.layout().sides())) - { - return Location {.physicalTrack = remapTrackLogicalToPhysical(logicalTrack), - .physicalSide = remapSideLogicalToPhysical(logicalSide), - .logicalTrack = logicalTrack, - .logicalSide = logicalSide, - .groupSize = getTrackStep()}; - } - - Error() << fmt::format( - "track {}.{} is not part of the image", logicalTrack, logicalSide); -} - std::vector> Layout::getTrackOrdering( unsigned guessedTracks, unsigned guessedSides) { diff --git a/lib/layout.h b/lib/layout.h index 66927403..431e8402 100644 --- a/lib/layout.h +++ b/lib/layout.h @@ -29,15 +29,10 @@ public: static unsigned remapSidePhysicalToLogical(unsigned physicalSide); static unsigned remapSideLogicalToPhysical(unsigned logicalSide); - /* Computes a Location for a given logical track and side, which - * contains the physical drive location and group size. */ - static Location computeLocationFor( - unsigned logicalTrack, unsigned logicalSide); - /* Uses the layout and current track and heads settings to determine * which Locations are going to be read from or written to. 8/ */ - static std::set computeLocations(); + static std::vector> computeLocations(); /* Returns a series of pairs representing the filesystem * ordering of the disk, in logical numbers. */ @@ -57,30 +52,30 @@ public: const SectorListProto& sectorsProto); public: - unsigned numTracks; - unsigned numSides; + unsigned numTracks = 0; + unsigned numSides = 0; /* The number of sectors in this track. */ - unsigned numSectors; + unsigned numSectors = 0; /* Physical location of this track. */ - unsigned physicalTrack; + unsigned physicalTrack = 0; /* Physical side of this track. */ - unsigned physicalSide; + unsigned physicalSide = 0; /* Logical location of this track. */ - unsigned logicalTrack; + unsigned logicalTrack = 0; /* Logical side of this track. */ - unsigned logicalSide; + unsigned logicalSide = 0; /* The number of physical tracks which need to be written for one logical * track. */ - unsigned groupSize; + unsigned groupSize = 0; /* Number of bytes in a sector. */ - unsigned sectorSize; + unsigned sectorSize = 0; /* Sector IDs in disk order. */ std::vector diskSectorOrder; diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index e546b802..6d55ed30 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -154,8 +154,9 @@ static std::set> collectSectors( return sector_set; } -BadSectorsState combineRecordAndSectors( - TrackFlux& trackFlux, Decoder& decoder, const Location& location) +BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, + Decoder& decoder, + std::shared_ptr& layout) { std::set> track_sectors; @@ -163,7 +164,7 @@ BadSectorsState combineRecordAndSectors( track_sectors.insert( trackdataflux->sectors.begin(), trackdataflux->sectors.end()); - for (auto& logicalLocation : decoder.requiredSectors(trackFlux.location)) + for (auto& logicalLocation : decoder.requiredSectors(trackFlux.layout)) { auto sector = std::make_shared(logicalLocation); sector->status = Sector::MISSING; @@ -181,22 +182,22 @@ BadSectorsState combineRecordAndSectors( } ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, - const Location& location, + std::shared_ptr& layout, TrackFlux& trackFlux, Decoder& decoder) { ReadResult result = BAD_AND_CAN_NOT_RETRY; - for (unsigned offset = 0; offset < location.groupSize; + for (unsigned offset = 0; offset < layout->groupSize; offset += config.drive().head_width()) { auto& fluxSourceIterator = fluxSourceIteratorHolder.getIterator( - location.physicalTrack + offset, location.physicalSide); + layout->physicalTrack + offset, layout->physicalSide); if (!fluxSourceIterator.hasNext()) continue; Logger() << BeginReadOperationLogMessage{ - location.physicalTrack + offset, location.physicalSide}; + layout->physicalTrack + offset, layout->physicalSide}; std::shared_ptr fluxmap = fluxSourceIterator.next(); // ->rescale( // 1.0 / config.flux_source().rescale()); @@ -205,9 +206,9 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, (int)(fluxmap->duration() / 1e6), fluxmap->bytes()); - auto trackdataflux = decoder.decodeToSectors(fluxmap, location); + auto trackdataflux = decoder.decodeToSectors(fluxmap, layout); trackFlux.trackDatas.push_back(trackdataflux); - if (combineRecordAndSectors(trackFlux, decoder, location) == + if (combineRecordAndSectors(trackFlux, decoder, layout) == HAS_NO_BAD_SECTORS) { result = GOOD_READ; @@ -222,18 +223,18 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, } void writeTracks(FluxSink& fluxSink, - std::function(const Location& location)> - producer, - std::function verifier, - const std::set& locations) + std::function( + std::shared_ptr& layout)> producer, + std::function& layout)> verifier, + std::vector>& layouts) { Logger() << BeginOperationLogMessage{"Encoding and writing to disk"}; int index = 0; - for (const auto& location : locations) + for (auto& layout : layouts) { Logger() << OperationProgressLogMessage{ - index * 100 / (unsigned)locations.size()}; + index * 100 / (unsigned)layouts.size()}; index++; testForEmergencyStop(); @@ -241,22 +242,22 @@ void writeTracks(FluxSink& fluxSink, int retriesRemaining = config.decoder().retries(); for (;;) { - for (int offset = 0; offset < location.groupSize; + for (int offset = 0; offset < layout->groupSize; offset += config.drive().head_width()) { - unsigned physicalTrack = location.physicalTrack + offset; + unsigned physicalTrack = layout->physicalTrack + offset; Logger() << BeginWriteOperationLogMessage{ - physicalTrack, location.physicalSide}; + physicalTrack, layout->physicalSide}; if (offset == config.drive().group_offset()) { - auto fluxmap = producer(location); + auto fluxmap = producer(layout); if (!fluxmap) goto erase; fluxSink.writeFlux( - physicalTrack, location.physicalSide, *fluxmap); + physicalTrack, layout->physicalSide, *fluxmap); Logger() << fmt::format("writing {0} ms in {1} bytes", int(fluxmap->duration() / 1e6), fluxmap->bytes()); @@ -268,14 +269,14 @@ void writeTracks(FluxSink& fluxSink, Fluxmap blank; fluxSink.writeFlux( - physicalTrack, location.physicalSide, blank); + physicalTrack, layout->physicalSide, blank); Logger() << "erased"; } Logger() << EndWriteOperationLogMessage(); } - if (verifier(location)) + if (verifier(layout)) break; if (retriesRemaining == 0) @@ -293,20 +294,20 @@ void writeTracks(FluxSink& fluxSink, void writeTracks(FluxSink& fluxSink, Encoder& encoder, const Image& image, - const std::set& locations) + std::vector>& layouts) { writeTracks( fluxSink, - [&](const Location& location) + [&](std::shared_ptr& layout) { - auto sectors = encoder.collectSectors(location, image); - return encoder.encode(location, sectors, image); + auto sectors = encoder.collectSectors(layout, image); + return encoder.encode(layout, sectors, image); }, [](const auto&) { return true; }, - locations); + layouts); } void writeTracksAndVerify(FluxSink& fluxSink, @@ -314,22 +315,22 @@ void writeTracksAndVerify(FluxSink& fluxSink, FluxSource& fluxSource, Decoder& decoder, const Image& image, - const std::set& locations) + std::vector>& locations) { writeTracks( fluxSink, - [&](const Location& location) + [&](std::shared_ptr& layout) { - auto sectors = encoder.collectSectors(location, image); - return encoder.encode(location, sectors, image); + auto sectors = encoder.collectSectors(layout, image); + return encoder.encode(layout, sectors, image); }, - [&](const Location& location) + [&](std::shared_ptr& layout) { auto trackFlux = std::make_shared(); - trackFlux->location = location; + trackFlux->layout = layout; FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource); auto result = readGroup( - fluxSourceIteratorHolder, location, *trackFlux, decoder); + fluxSourceIteratorHolder, layout, *trackFlux, decoder); Logger() << TrackReadLogMessage{trackFlux}; if (result != GOOD_READ) @@ -339,7 +340,7 @@ void writeTracksAndVerify(FluxSink& fluxSink, } Image wanted; - for (const auto& sector : encoder.collectSectors(location, image)) + for (const auto& sector : encoder.collectSectors(layout, image)) wanted .put(sector->logicalTrack, sector->logicalSide, @@ -380,7 +381,7 @@ void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - const std::set& locations) + std::vector>& locations) { if (fluxSource && decoder) writeTracksAndVerify( @@ -401,33 +402,35 @@ void writeDiskCommand(const Image& image, void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) { + auto locations = Layout::computeLocations(); writeTracks( fluxSink, - [&](const Location& location) + [&](std::shared_ptr& layout) { return fluxSource - .readFlux(location.physicalTrack, location.physicalSide) + .readFlux(layout->physicalTrack, layout->physicalSide) ->next(); }, [](const auto&) { return true; }, - Layout::computeLocations()); + locations); } -std::shared_ptr readAndDecodeTrack( - FluxSource& fluxSource, Decoder& decoder, const Location& location) +std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, + Decoder& decoder, + std::shared_ptr& layout) { auto trackFlux = std::make_shared(); - trackFlux->location = location; + trackFlux->layout = layout; FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource); int retriesRemaining = config.decoder().retries(); for (;;) { auto result = - readGroup(fluxSourceIteratorHolder, location, *trackFlux, decoder); + readGroup(fluxSourceIteratorHolder, layout, *trackFlux, decoder); if (result == GOOD_READ) break; if (result == BAD_AND_CAN_NOT_RETRY) @@ -462,7 +465,7 @@ std::shared_ptr readDiskCommand( Logger() << BeginOperationLogMessage{"Reading and decoding disk"}; auto locations = Layout::computeLocations(); unsigned index = 0; - for (const auto& location : locations) + for (auto& layout : locations) { Logger() << OperationProgressLogMessage{ index * 100 / (unsigned)locations.size()}; @@ -470,14 +473,14 @@ std::shared_ptr readDiskCommand( testForEmergencyStop(); - auto trackFlux = readAndDecodeTrack(fluxSource, decoder, location); + auto trackFlux = readAndDecodeTrack(fluxSource, decoder, layout); diskflux->tracks.push_back(trackFlux); if (outputFluxSink) { for (const auto& data : trackFlux->trackDatas) - outputFluxSink->writeFlux(location.physicalTrack, - location.physicalSide, + outputFluxSink->writeFlux(layout->physicalTrack, + layout->physicalSide, *data->fluxmap); } diff --git a/lib/readerwriter.h b/lib/readerwriter.h index 4207acd0..c627e6a6 100644 --- a/lib/readerwriter.h +++ b/lib/readerwriter.h @@ -11,7 +11,7 @@ class Fluxmap; class Image; class ImageReader; class ImageWriter; -class Location; +class Layout; class TrackFlux; extern void measureDiskRotation( @@ -19,15 +19,15 @@ extern void measureDiskRotation( extern void writeTracks(FluxSink& fluxSink, const std::function( - const Location& location)> producer, - const std::set& locations); + std::shared_ptr& layout)> producer, + std::vector>& locations); extern void writeTracksAndVerify(FluxSink& fluxSink, Encoder& encoder, FluxSource& fluxSource, Decoder& decoder, const Image& image, - const std::set& locations); + std::vector>& locations); extern void fillBitmapTo(std::vector& bitmap, unsigned& cursor, @@ -39,7 +39,7 @@ extern void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - const std::set& locations); + std::vector>& locations); extern void writeDiskCommand(const Image& image, Encoder& encoder, @@ -49,8 +49,9 @@ extern void writeDiskCommand(const Image& image, extern void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink); -extern std::shared_ptr readAndDecodeTrack( - FluxSource& fluxSource, Decoder& decoder, const Location& location); +extern std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, + Decoder& decoder, + std::shared_ptr& layout); extern std::shared_ptr readDiskCommand( FluxSource& fluxsource, Decoder& decoder); diff --git a/lib/sector.cc b/lib/sector.cc index 96aad02b..a7fd3ca9 100644 --- a/lib/sector.cc +++ b/lib/sector.cc @@ -10,10 +10,10 @@ Sector::Sector(const LogicalLocation& location): physicalSide(Layout::remapSideLogicalToPhysical(location.logicalSide)) {} -Sector::Sector(const Location& location): - LogicalLocation({ location.logicalTrack, location.logicalSide, 0 }), - physicalTrack(location.physicalTrack), - physicalSide(location.physicalSide) +Sector::Sector(std::shared_ptr& layout, unsigned sectorId): + LogicalLocation({ layout->logicalTrack, layout->logicalSide, sectorId }), + physicalTrack(layout->physicalTrack), + physicalSide(layout->physicalSide) {} std::string Sector::statusToString(Status status) diff --git a/lib/sector.h b/lib/sector.h index 46a48e94..f58fa7e5 100644 --- a/lib/sector.h +++ b/lib/sector.h @@ -5,7 +5,7 @@ #include "fluxmap.h" class Record; -class Location; +class Layout; struct LogicalLocation { @@ -65,9 +65,9 @@ struct Sector : public LogicalLocation Sector() {} - Sector(const LogicalLocation& location); + Sector(std::shared_ptr& layout, unsigned sectorId=0); - Sector(const Location& location); + Sector(const LogicalLocation& location); std::tuple key() const { diff --git a/lib/vfs/brother120fs.cc b/lib/vfs/brother120fs.cc index 535bd04b..bb4091fd 100644 --- a/lib/vfs/brother120fs.cc +++ b/lib/vfs/brother120fs.cc @@ -291,7 +291,8 @@ public: auto& filename = path.back(); if (filename.size() > 8) - throw CannotWriteException("filename too long (eight characters maximum)"); + throw CannotWriteException( + "filename too long (eight characters maximum)"); int sectorLength = (data.size() + SECTOR_SIZE - 1) / SECTOR_SIZE; if (sectorLength > 0xff) diff --git a/lib/vfs/fluxsectorinterface.cc b/lib/vfs/fluxsectorinterface.cc index 32fb5680..e91fd2e3 100644 --- a/lib/vfs/fluxsectorinterface.cc +++ b/lib/vfs/fluxsectorinterface.cc @@ -56,14 +56,14 @@ public: void flushChanges() override { - std::set locations; + std::vector> locations; for (const auto& trackid : _changedTracks) { unsigned track = trackid.first; unsigned side = trackid.second; auto trackLayout = Layout::getLayoutOfTrack(track, side); - locations.insert(Layout::computeLocationFor(track, side)); + locations.push_back(trackLayout); /* If we don't have all the sectors of this track, we may need to * populate any non-changed sectors as we can only write a track at @@ -128,8 +128,8 @@ private: void populateSectors(unsigned track, unsigned side) { - auto location = Layout::computeLocationFor(track, side); - auto trackdata = readAndDecodeTrack(*_fluxSource, *_decoder, location); + auto layout = Layout::getLayoutOfTrack(track, side); + auto trackdata = readAndDecodeTrack(*_fluxSource, *_decoder, layout); for (const auto& sector : trackdata->sectors) *_loadedSectors.put(track, side, sector->logicalSector) = *sector; diff --git a/src/gui/customstatusbar.h b/src/gui/customstatusbar.h index 59093569..b4fb2140 100644 --- a/src/gui/customstatusbar.h +++ b/src/gui/customstatusbar.h @@ -15,7 +15,7 @@ public: void ShowProgressBar(); void HideProgressBar(); void SetProgress(int amount); - void SetLeftLabel(const std::string& text); + void SetLeftLabel(const std::string& text); void SetRightLabel(const std::string& text); private: diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index fccfa8e4..47c58da0 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -5,6 +5,7 @@ #include "lib/flux.h" #include "lib/fluxmap.h" #include "lib/sector.h" +#include "lib/layout.h" #include "lib/decoders/fluxmapreader.h" DECLARE_COLOUR(BACKGROUND, 192, 192, 192); @@ -35,14 +36,18 @@ FluxViewerControl::FluxViewerControl(wxWindow* parent, SetDoubleBuffered(true); } -wxBEGIN_EVENT_TABLE(FluxViewerControl, wxPanel) EVT_PAINT( - FluxViewerControl::OnPaint) EVT_MOUSEWHEEL(FluxViewerControl::OnMouseWheel) +// clang-format off +wxBEGIN_EVENT_TABLE(FluxViewerControl, wxPanel) + EVT_PAINT(FluxViewerControl::OnPaint) + EVT_MOUSEWHEEL(FluxViewerControl::OnMouseWheel) EVT_LEFT_DOWN(FluxViewerControl::OnMouseMotion) - EVT_LEFT_UP(FluxViewerControl::OnMouseMotion) - EVT_MOTION(FluxViewerControl::OnMouseMotion) EVT_CONTEXT_MENU( - FluxViewerControl::OnContextMenu) wxEND_EVENT_TABLE() + EVT_LEFT_UP(FluxViewerControl::OnMouseMotion) + EVT_MOTION(FluxViewerControl::OnMouseMotion) + EVT_CONTEXT_MENU(FluxViewerControl::OnContextMenu) +wxEND_EVENT_TABLE(); +// clang-format on - void FluxViewerControl::SetScrollbar(wxScrollBar* scrollbar) +void FluxViewerControl::SetScrollbar(wxScrollBar* scrollbar) { _scrollbar = scrollbar; _scrollbar->Bind( @@ -130,7 +135,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&) int x = -_scrollPosition / _nanosecondsPerPixel; nanoseconds_t fluxStartTime = 0; - for (const auto& trackdata : _flux->trackDatas) + for (auto& trackdata : _flux->trackDatas) { nanoseconds_t duration = trackdata->fluxmap->duration(); int fw = duration / _nanosecondsPerPixel; @@ -224,7 +229,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&) dc.SetBackgroundMode(wxTRANSPARENT); dc.SetTextForeground(*wxBLACK); - for (const auto& sector : trackdata->sectors) + for (auto& sector : trackdata->sectors) { nanoseconds_t sr = sector->dataEndTime; if (!sr) @@ -261,7 +266,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&) dc.SetPen(FOREGROUND_PEN); dc.SetBrush(RECORD_BRUSH); - for (const auto& record : trackdata->records) + for (auto& record : trackdata->records) { int rp = record->startTime / _nanosecondsPerPixel; int rw = (record->endTime - record->startTime) / @@ -281,7 +286,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&) text, {x + rp + BORDER, t2y - size.GetHeight() / 2}); if (_rightClicked && hovered) - ShowRecordMenu(trackdata->location, record); + ShowRecordMenu(trackdata->layout, record); } /* Flux chart. */ @@ -429,8 +434,8 @@ void FluxViewerControl::ShowSectorMenu(std::shared_ptr sector) PopupMenu(&menu, _mouseX, _mouseY); } -void FluxViewerControl::ShowRecordMenu( - const Location& location, std::shared_ptr record) +void FluxViewerControl::ShowRecordMenu(std::shared_ptr& layout, + std::shared_ptr record) { wxMenu menu; @@ -438,7 +443,7 @@ void FluxViewerControl::ShowRecordMenu( wxEVT_COMMAND_MENU_SELECTED, [&](wxCommandEvent&) { - DisplayRawData(location, record); + DisplayRawData(layout, record); }, menu.Append(wxID_ANY, "Show record data")->GetId()); @@ -497,14 +502,14 @@ void FluxViewerControl::DisplayRawData(std::shared_ptr sector) TextViewerWindow::Create(this, title, s.str())->Show(); } -void FluxViewerControl::DisplayRawData( - const Location& location, std::shared_ptr record) +void FluxViewerControl::DisplayRawData(std::shared_ptr& layout, + std::shared_ptr record) { std::stringstream s; auto title = fmt::format("Raw data for record c{}.h{} + {:.3f}ms", - location.physicalTrack, - location.physicalSide, + layout->physicalTrack, + layout->physicalSide, record->startTime / 1e6); s << title << "\n\n"; hexdump(s, record->rawData); diff --git a/src/gui/fluxviewercontrol.h b/src/gui/fluxviewercontrol.h index a4db62fb..142b1c7a 100644 --- a/src/gui/fluxviewercontrol.h +++ b/src/gui/fluxviewercontrol.h @@ -1,14 +1,14 @@ #ifndef FLUXVIEWERCONTROL_H #define FLUXVIEWERCONTROL_H -#include "globals.h" +#include "lib/globals.h" class TrackFlux; class wxScrollBar; class wxScrollEvent; class Sector; class Record; -class Location; +class Layout; class FluxViewerControl : public wxWindow { @@ -18,40 +18,42 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0); + virtual ~FluxViewerControl() {} public: - void SetScrollbar(wxScrollBar* scrollbar); - void SetFlux(std::shared_ptr flux); + void SetScrollbar(wxScrollBar* scrollbar); + void SetFlux(std::shared_ptr flux); private: - void UpdateScale(); - void ShowSectorMenu(std::shared_ptr sector); - void ShowRecordMenu(const Location& location, std::shared_ptr record); - void DisplayDecodedData(std::shared_ptr sector); - void DisplayRawData(std::shared_ptr sector); - void DisplayRawData(const Location& location, std::shared_ptr record); + void UpdateScale(); + void ShowSectorMenu(std::shared_ptr sector); + void ShowRecordMenu(std::shared_ptr& layout, + std::shared_ptr record); + void DisplayDecodedData(std::shared_ptr sector); + void DisplayRawData(std::shared_ptr sector); + void DisplayRawData(std::shared_ptr& layout, + std::shared_ptr record); private: - void OnPaint(wxPaintEvent&); - void OnMouseWheel(wxMouseEvent&); - void OnScrollbarChanged(wxScrollEvent&); - void OnMouseMotion(wxMouseEvent&); - void OnContextMenu(wxContextMenuEvent&); + void OnPaint(wxPaintEvent&); + void OnMouseWheel(wxMouseEvent&); + void OnScrollbarChanged(wxScrollEvent&); + void OnMouseMotion(wxMouseEvent&); + void OnContextMenu(wxContextMenuEvent&); private: - wxScrollBar* _scrollbar; - std::shared_ptr _flux; - nanoseconds_t _scrollPosition = 0; - nanoseconds_t _totalDuration = 0; - double _nanosecondsPerPixel = 0; - std::vector _densityMap; - int _dragStartX = -1; - nanoseconds_t _dragStartPosition = -1; - int _mouseX = -1; - int _mouseY = -1; - bool _rightClicked = false; + wxScrollBar* _scrollbar; + std::shared_ptr _flux; + nanoseconds_t _scrollPosition = 0; + nanoseconds_t _totalDuration = 0; + double _nanosecondsPerPixel = 0; + std::vector _densityMap; + int _dragStartX = -1; + nanoseconds_t _dragStartPosition = -1; + int _mouseX = -1; + int _mouseY = -1; + bool _rightClicked = false; wxDECLARE_EVENT_TABLE(); }; #endif - diff --git a/src/gui/fluxviewerwindow.cc b/src/gui/fluxviewerwindow.cc index 82bb3dc4..b8a12648 100644 --- a/src/gui/fluxviewerwindow.cc +++ b/src/gui/fluxviewerwindow.cc @@ -4,6 +4,7 @@ #include "fluxviewerwindow.h" #include "fluxviewercontrol.h" #include "lib/flux.h" +#include "lib/layout.h" #include "fmt/format.h" FluxViewerWindow::FluxViewerWindow( @@ -14,8 +15,8 @@ FluxViewerWindow::FluxViewerWindow( fluxviewer->SetScrollbar(scrollbar); fluxviewer->SetFlux(flux); SetTitle(fmt::format("Flux for c{} h{}", - flux->location.physicalTrack, - flux->location.physicalSide)); + flux->layout->physicalTrack, + flux->layout->physicalSide)); } void FluxViewerWindow::OnExit(wxCommandEvent& event) diff --git a/src/gui/fluxviewerwindow.h b/src/gui/fluxviewerwindow.h index 0ef7d6a6..61c39df2 100644 --- a/src/gui/fluxviewerwindow.h +++ b/src/gui/fluxviewerwindow.h @@ -14,8 +14,7 @@ private: void OnExit(wxCommandEvent& event); private: - std::shared_ptr _flux; + std::shared_ptr _flux; }; #endif - diff --git a/src/gui/gui.h b/src/gui/gui.h index 6be26a18..44367ccf 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -14,37 +14,37 @@ wxDECLARE_EVENT(UPDATE_STATE_EVENT, wxCommandEvent); template static inline R runOnUiThread(std::function callback) { - R retvar; - runOnUiThread( - [&]() { - retvar = callback(); - } - ); - return retvar; + R retvar; + runOnUiThread( + [&]() + { + retvar = callback(); + }); + return retvar; } class FluxEngineApp : public wxApp, public wxThreadHelper { public: virtual bool OnInit(); - void RunOnWorkerThread(std::function callback); + void RunOnWorkerThread(std::function callback); private: - void OnExec(const ExecEvent& event); + void OnExec(const ExecEvent& event); public: - bool IsWorkerThreadRunning() const; + bool IsWorkerThreadRunning() const; protected: - virtual wxThread::ExitCode Entry(); + virtual wxThread::ExitCode Entry(); private: - static wxWindow* CreateMainWindow(); - void SendUpdateEvent(); + static wxWindow* CreateMainWindow(); + void SendUpdateEvent(); private: - std::function _callback; - wxWindow* _mainWindow; + std::function _callback; + wxWindow* _mainWindow; }; wxDECLARE_APP(FluxEngineApp); @@ -54,4 +54,3 @@ wxDECLARE_APP(FluxEngineApp); static const wxPen name##_PEN(name##_COLOUR) #endif - diff --git a/src/gui/icon.png.h b/src/gui/icon.png.h index 4d76b49a..83326b5c 100644 --- a/src/gui/icon.png.h +++ b/src/gui/icon.png.h @@ -5,113 +5,968 @@ #include #include -static const unsigned char icon_png[] = -{ - 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, - 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0xAA, - 0x69, 0x71, 0xDE, 0x00, 0x00, 0x03, 0x80, 0x49, 0x44, 0x41, - 0x54, 0x78, 0x9C, 0xD5, 0x9B, 0x5B, 0x9A, 0xA3, 0x20, 0x10, - 0x85, 0x0F, 0xF3, 0xCD, 0x6A, 0xDC, 0x4F, 0xBB, 0x9D, 0x90, - 0xED, 0x98, 0xFD, 0x64, 0x3B, 0xCC, 0x43, 0x02, 0x2D, 0x25, - 0x97, 0x2A, 0x28, 0xC0, 0x39, 0x2F, 0x1D, 0x6D, 0x29, 0xF8, - 0x8F, 0x65, 0x81, 0xC6, 0x00, 0x6B, 0xE5, 0x16, 0xF7, 0x8F, - 0x3F, 0x0B, 0xFB, 0x76, 0xD6, 0x5A, 0x60, 0xB1, 0x09, 0x66, - 0x51, 0xBF, 0x1E, 0x1E, 0x00, 0xF0, 0xFD, 0xBC, 0x64, 0x2C, - 0x2B, 0x3A, 0x8D, 0xE0, 0xBD, 0x56, 0x99, 0x30, 0xBB, 0xC3, - 0x24, 0xBC, 0xD7, 0x0A, 0x13, 0x66, 0xD6, 0x80, 0x22, 0xFC, - 0xE7, 0x08, 0x07, 0x4C, 0xAE, 0x09, 0xB3, 0xDC, 0xAE, 0xC2, - 0xDB, 0xC7, 0xE3, 0x77, 0xC3, 0x18, 0x60, 0xD2, 0xD8, 0x66, - 0x74, 0x22, 0x83, 0xF7, 0x9A, 0x64, 0xC2, 0xE8, 0x0E, 0xDA, - 0xE0, 0xBD, 0x26, 0x98, 0x30, 0x32, 0x78, 0x1F, 0xBC, 0xD7, - 0x60, 0x13, 0x46, 0x05, 0xD6, 0x81, 0xF7, 0x1A, 0x68, 0xC2, - 0x88, 0x59, 0xA0, 0x09, 0xDE, 0x9A, 0x67, 0x21, 0xE2, 0xB8, - 0xD9, 0x41, 0xDB, 0x80, 0x66, 0x78, 0xEB, 0x1E, 0x97, 0x7D, - 0x71, 0xE4, 0x31, 0x26, 0xFC, 0x55, 0x8C, 0xA5, 0x72, 0xE6, - 0xFD, 0x36, 0x35, 0xE4, 0xD3, 0x83, 0x03, 0x8C, 0x71, 0x50, - 0xBC, 0x1C, 0xB4, 0x02, 0xA9, 0xA6, 0x7D, 0x12, 0xFE, 0x2C, - 0xC5, 0x9A, 0xA0, 0x11, 0x64, 0x2E, 0xBC, 0x97, 0x92, 0x09, - 0xBD, 0x01, 0xD6, 0xC0, 0x7B, 0x29, 0x98, 0xD0, 0x53, 0x04, - 0xF5, 0xAB, 0xBD, 0x78, 0x04, 0xFD, 0x85, 0xB1, 0xD5, 0x3D, - 0x75, 0xF8, 0xDC, 0xD9, 0x2F, 0x16, 0x45, 0xAF, 0x8E, 0x4C, - 0x68, 0x69, 0x34, 0xF4, 0xCC, 0x5B, 0xF7, 0x08, 0xD3, 0x22, - 0x0B, 0xDE, 0xAB, 0xD1, 0x04, 0x69, 0x83, 0x25, 0x69, 0x3F, - 0xB2, 0x30, 0x4A, 0x6A, 0x40, 0xD7, 0x22, 0x27, 0x05, 0xC1, - 0x01, 0x4B, 0xB6, 0xCB, 0x19, 0xDA, 0x50, 0x13, 0xB8, 0x0B, - 0xA1, 0xE6, 0xB5, 0x7D, 0x2B, 0x78, 0xB6, 0x6D, 0x62, 0xD5, - 0x18, 0x49, 0xB8, 0x58, 0xE2, 0x64, 0x40, 0xFD, 0x49, 0x0E, - 0x00, 0xFB, 0x2C, 0xA7, 0x79, 0xEE, 0x7A, 0x2E, 0xC1, 0x84, - 0x36, 0xE4, 0x6F, 0xED, 0x78, 0x49, 0x26, 0xD4, 0x5C, 0x62, - 0xC1, 0x47, 0x83, 0xC8, 0x65, 0x42, 0xE6, 0xCC, 0xB5, 0xD6, - 0x87, 0xD4, 0xBD, 0xC3, 0x25, 0x3E, 0xA3, 0x26, 0x94, 0x32, - 0xA0, 0x0A, 0xBF, 0x6D, 0x1B, 0xB6, 0x6D, 0x8B, 0x07, 0x92, - 0xC8, 0x84, 0x52, 0xDA, 0x4A, 0x32, 0x22, 0xDB, 0x26, 0x17, - 0x9F, 0x91, 0x09, 0x39, 0x77, 0x58, 0xF0, 0x67, 0xBD, 0xDF, - 0xEF, 0x78, 0x50, 0xCC, 0xFB, 0xFD, 0x73, 0x06, 0x9C, 0x21, - 0xB8, 0xAB, 0xC5, 0x6A, 0x4D, 0x00, 0x8A, 0x99, 0x90, 0xCA, - 0x00, 0x31, 0x3C, 0x10, 0x1E, 0x69, 0xFF, 0x6E, 0x57, 0x6A, - 0x02, 0xD0, 0x0E, 0x7F, 0xAE, 0x09, 0xAC, 0x82, 0x5A, 0xC8, - 0x04, 0xEA, 0x4A, 0x13, 0xFC, 0xBE, 0xEF, 0x70, 0xCE, 0xC1, - 0x18, 0x73, 0x35, 0xA2, 0x90, 0x09, 0xC5, 0x4B, 0x83, 0x51, - 0x1B, 0xC4, 0xB3, 0x44, 0x22, 0x13, 0xCE, 0x19, 0xD0, 0x05, - 0x0F, 0x00, 0xCE, 0x39, 0x51, 0x26, 0xF4, 0xC2, 0xA7, 0x66, - 0x89, 0x6C, 0xCC, 0xE7, 0xD3, 0x8F, 0x2D, 0xCA, 0x84, 0xB3, - 0x1B, 0x45, 0x03, 0x6A, 0xF0, 0x51, 0x50, 0x61, 0x26, 0x44, - 0xC7, 0xD1, 0x07, 0x24, 0x27, 0xD0, 0x6A, 0xDB, 0x02, 0x7C, - 0xB4, 0x7D, 0xFA, 0x06, 0x8A, 0xB5, 0x12, 0x94, 0xC0, 0x03, - 0xF2, 0x4C, 0x08, 0xC7, 0x90, 0x55, 0xA3, 0xE4, 0xF6, 0x98, - 0x0B, 0x0F, 0x20, 0xCA, 0x84, 0xAA, 0x01, 0x12, 0xF8, 0xD7, - 0xEB, 0x15, 0x3E, 0xB7, 0x98, 0x10, 0x15, 0x42, 0x52, 0xF0, - 0xB8, 0xED, 0x72, 0xFD, 0x59, 0x6B, 0xA3, 0x6B, 0xDF, 0x9B, - 0x50, 0x34, 0xA0, 0x05, 0xBE, 0xD7, 0x04, 0xAA, 0x5A, 0x36, - 0x48, 0xE0, 0xCF, 0x26, 0xF8, 0xCB, 0x20, 0x3B, 0x0B, 0xB4, - 0x9E, 0x79, 0xAF, 0x9F, 0x9F, 0x9F, 0xF0, 0xB9, 0xB7, 0x26, - 0xE4, 0xEA, 0x80, 0x30, 0xED, 0x8D, 0xB5, 0xD6, 0x7D, 0x3F, - 0x03, 0xDF, 0x1A, 0x90, 0x5A, 0x1C, 0xB8, 0xE3, 0x38, 0x2E, - 0x3B, 0x25, 0xF0, 0x5E, 0xBD, 0x26, 0xD0, 0xAA, 0x9E, 0x5B, - 0x37, 0x44, 0x6D, 0x6A, 0x97, 0x19, 0xF9, 0x0A, 0x3E, 0x75, - 0x09, 0x98, 0x7D, 0xDF, 0xA3, 0x1D, 0x2D, 0xF0, 0x54, 0xE2, - 0x29, 0x72, 0x02, 0xFC, 0x65, 0x83, 0xC8, 0x1D, 0xC7, 0xD1, - 0x0C, 0x7F, 0x3E, 0xFB, 0x51, 0x87, 0x8C, 0x4C, 0x28, 0xDD, - 0x38, 0x69, 0xC2, 0x27, 0x77, 0x10, 0x39, 0x4D, 0xF8, 0xD0, - 0x69, 0xC1, 0x84, 0x99, 0xF0, 0xD9, 0x9D, 0x44, 0x91, 0x09, - 0xBD, 0xF0, 0xA1, 0x63, 0x41, 0x4D, 0x18, 0x05, 0x5F, 0xFC, - 0x07, 0x51, 0x30, 0x81, 0x5B, 0xF4, 0x38, 0xEA, 0x99, 0x1D, - 0x80, 0x7E, 0xF8, 0xEA, 0x3F, 0x89, 0x8A, 0x26, 0x48, 0xE1, - 0xC3, 0x00, 0x1A, 0x4D, 0xD0, 0x80, 0x67, 0x1D, 0x40, 0x94, - 0x34, 0xA1, 0x15, 0x3E, 0x0C, 0x42, 0x7A, 0x17, 0xA9, 0x04, - 0xCF, 0x3E, 0x88, 0x28, 0x32, 0xA1, 0x17, 0x3E, 0x0C, 0x84, - 0x69, 0x82, 0x26, 0xBC, 0xE8, 0x40, 0xA2, 0xE4, 0xEC, 0x00, - 0x7C, 0x40, 0x72, 0xFF, 0xAB, 0x0E, 0xA6, 0x62, 0x82, 0x36, - 0xBC, 0xF8, 0x60, 0xA2, 0xA9, 0x26, 0x8C, 0x80, 0x6F, 0x6A, - 0x40, 0x14, 0x4C, 0xA0, 0xD0, 0xAD, 0x26, 0x18, 0x63, 0x70, - 0x1C, 0xC7, 0xE5, 0x19, 0x63, 0x49, 0x3D, 0x6F, 0x98, 0xAA, - 0xBC, 0x1F, 0xA0, 0x65, 0x82, 0x87, 0xF7, 0xE2, 0x98, 0xD0, - 0xFB, 0x7A, 0xAD, 0xDA, 0x1B, 0x22, 0xBD, 0x26, 0x50, 0x78, - 0xAF, 0x92, 0x09, 0x1A, 0xEF, 0x16, 0x6B, 0xBE, 0x7A, 0xD6, - 0x6C, 0xC2, 0x2A, 0x78, 0x95, 0x00, 0x44, 0x62, 0x13, 0x56, - 0xC2, 0xAB, 0x05, 0x21, 0xCA, 0x9A, 0x70, 0xE9, 0x7C, 0x31, - 0xBC, 0x6A, 0x20, 0xA2, 0xAA, 0x09, 0x77, 0x80, 0x57, 0x0F, - 0x46, 0x54, 0x5C, 0x27, 0xDC, 0x01, 0x7E, 0x48, 0x40, 0xA2, - 0x8B, 0x09, 0x77, 0x82, 0x1F, 0x16, 0x94, 0x28, 0xBA, 0x1C, - 0xEE, 0x04, 0x3F, 0x34, 0x30, 0x91, 0x03, 0x70, 0x3B, 0x78, - 0x60, 0xDE, 0x6F, 0x86, 0x92, 0x10, 0xAB, 0xE1, 0xA7, 0x74, - 0x40, 0x14, 0x1E, 0xB9, 0xDF, 0x01, 0x1E, 0x98, 0xFF, 0xCB, - 0x51, 0x03, 0xDC, 0x07, 0x7E, 0x6A, 0x47, 0x44, 0xB7, 0xF9, - 0xF1, 0xE4, 0x2A, 0x03, 0x80, 0x1B, 0xFD, 0x7C, 0x76, 0xA5, - 0xDC, 0xF7, 0xFB, 0xBA, 0xAE, 0x17, 0x9E, 0xFF, 0x77, 0x2D, - 0x85, 0xFF, 0x07, 0xE6, 0x6F, 0xFC, 0xB7, 0xE2, 0xFB, 0x3A, - 0x0B, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, - 0x42, 0x60, 0x82, +static const unsigned char icon_png[] = { + 0x89, + 0x50, + 0x4E, + 0x47, + 0x0D, + 0x0A, + 0x1A, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x0D, + 0x49, + 0x48, + 0x44, + 0x52, + 0x00, + 0x00, + 0x00, + 0x40, + 0x00, + 0x00, + 0x00, + 0x40, + 0x08, + 0x06, + 0x00, + 0x00, + 0x00, + 0xAA, + 0x69, + 0x71, + 0xDE, + 0x00, + 0x00, + 0x03, + 0x80, + 0x49, + 0x44, + 0x41, + 0x54, + 0x78, + 0x9C, + 0xD5, + 0x9B, + 0x5B, + 0x9A, + 0xA3, + 0x20, + 0x10, + 0x85, + 0x0F, + 0xF3, + 0xCD, + 0x6A, + 0xDC, + 0x4F, + 0xBB, + 0x9D, + 0x90, + 0xED, + 0x98, + 0xFD, + 0x64, + 0x3B, + 0xCC, + 0x43, + 0x02, + 0x2D, + 0x25, + 0x97, + 0x2A, + 0x28, + 0xC0, + 0x39, + 0x2F, + 0x1D, + 0x6D, + 0x29, + 0xF8, + 0x8F, + 0x65, + 0x81, + 0xC6, + 0x00, + 0x6B, + 0xE5, + 0x16, + 0xF7, + 0x8F, + 0x3F, + 0x0B, + 0xFB, + 0x76, + 0xD6, + 0x5A, + 0x60, + 0xB1, + 0x09, + 0x66, + 0x51, + 0xBF, + 0x1E, + 0x1E, + 0x00, + 0xF0, + 0xFD, + 0xBC, + 0x64, + 0x2C, + 0x2B, + 0x3A, + 0x8D, + 0xE0, + 0xBD, + 0x56, + 0x99, + 0x30, + 0xBB, + 0xC3, + 0x24, + 0xBC, + 0xD7, + 0x0A, + 0x13, + 0x66, + 0xD6, + 0x80, + 0x22, + 0xFC, + 0xE7, + 0x08, + 0x07, + 0x4C, + 0xAE, + 0x09, + 0xB3, + 0xDC, + 0xAE, + 0xC2, + 0xDB, + 0xC7, + 0xE3, + 0x77, + 0xC3, + 0x18, + 0x60, + 0xD2, + 0xD8, + 0x66, + 0x74, + 0x22, + 0x83, + 0xF7, + 0x9A, + 0x64, + 0xC2, + 0xE8, + 0x0E, + 0xDA, + 0xE0, + 0xBD, + 0x26, + 0x98, + 0x30, + 0x32, + 0x78, + 0x1F, + 0xBC, + 0xD7, + 0x60, + 0x13, + 0x46, + 0x05, + 0xD6, + 0x81, + 0xF7, + 0x1A, + 0x68, + 0xC2, + 0x88, + 0x59, + 0xA0, + 0x09, + 0xDE, + 0x9A, + 0x67, + 0x21, + 0xE2, + 0xB8, + 0xD9, + 0x41, + 0xDB, + 0x80, + 0x66, + 0x78, + 0xEB, + 0x1E, + 0x97, + 0x7D, + 0x71, + 0xE4, + 0x31, + 0x26, + 0xFC, + 0x55, + 0x8C, + 0xA5, + 0x72, + 0xE6, + 0xFD, + 0x36, + 0x35, + 0xE4, + 0xD3, + 0x83, + 0x03, + 0x8C, + 0x71, + 0x50, + 0xBC, + 0x1C, + 0xB4, + 0x02, + 0xA9, + 0xA6, + 0x7D, + 0x12, + 0xFE, + 0x2C, + 0xC5, + 0x9A, + 0xA0, + 0x11, + 0x64, + 0x2E, + 0xBC, + 0x97, + 0x92, + 0x09, + 0xBD, + 0x01, + 0xD6, + 0xC0, + 0x7B, + 0x29, + 0x98, + 0xD0, + 0x53, + 0x04, + 0xF5, + 0xAB, + 0xBD, + 0x78, + 0x04, + 0xFD, + 0x85, + 0xB1, + 0xD5, + 0x3D, + 0x75, + 0xF8, + 0xDC, + 0xD9, + 0x2F, + 0x16, + 0x45, + 0xAF, + 0x8E, + 0x4C, + 0x68, + 0x69, + 0x34, + 0xF4, + 0xCC, + 0x5B, + 0xF7, + 0x08, + 0xD3, + 0x22, + 0x0B, + 0xDE, + 0xAB, + 0xD1, + 0x04, + 0x69, + 0x83, + 0x25, + 0x69, + 0x3F, + 0xB2, + 0x30, + 0x4A, + 0x6A, + 0x40, + 0xD7, + 0x22, + 0x27, + 0x05, + 0xC1, + 0x01, + 0x4B, + 0xB6, + 0xCB, + 0x19, + 0xDA, + 0x50, + 0x13, + 0xB8, + 0x0B, + 0xA1, + 0xE6, + 0xB5, + 0x7D, + 0x2B, + 0x78, + 0xB6, + 0x6D, + 0x62, + 0xD5, + 0x18, + 0x49, + 0xB8, + 0x58, + 0xE2, + 0x64, + 0x40, + 0xFD, + 0x49, + 0x0E, + 0x00, + 0xFB, + 0x2C, + 0xA7, + 0x79, + 0xEE, + 0x7A, + 0x2E, + 0xC1, + 0x84, + 0x36, + 0xE4, + 0x6F, + 0xED, + 0x78, + 0x49, + 0x26, + 0xD4, + 0x5C, + 0x62, + 0xC1, + 0x47, + 0x83, + 0xC8, + 0x65, + 0x42, + 0xE6, + 0xCC, + 0xB5, + 0xD6, + 0x87, + 0xD4, + 0xBD, + 0xC3, + 0x25, + 0x3E, + 0xA3, + 0x26, + 0x94, + 0x32, + 0xA0, + 0x0A, + 0xBF, + 0x6D, + 0x1B, + 0xB6, + 0x6D, + 0x8B, + 0x07, + 0x92, + 0xC8, + 0x84, + 0x52, + 0xDA, + 0x4A, + 0x32, + 0x22, + 0xDB, + 0x26, + 0x17, + 0x9F, + 0x91, + 0x09, + 0x39, + 0x77, + 0x58, + 0xF0, + 0x67, + 0xBD, + 0xDF, + 0xEF, + 0x78, + 0x50, + 0xCC, + 0xFB, + 0xFD, + 0x73, + 0x06, + 0x9C, + 0x21, + 0xB8, + 0xAB, + 0xC5, + 0x6A, + 0x4D, + 0x00, + 0x8A, + 0x99, + 0x90, + 0xCA, + 0x00, + 0x31, + 0x3C, + 0x10, + 0x1E, + 0x69, + 0xFF, + 0x6E, + 0x57, + 0x6A, + 0x02, + 0xD0, + 0x0E, + 0x7F, + 0xAE, + 0x09, + 0xAC, + 0x82, + 0x5A, + 0xC8, + 0x04, + 0xEA, + 0x4A, + 0x13, + 0xFC, + 0xBE, + 0xEF, + 0x70, + 0xCE, + 0xC1, + 0x18, + 0x73, + 0x35, + 0xA2, + 0x90, + 0x09, + 0xC5, + 0x4B, + 0x83, + 0x51, + 0x1B, + 0xC4, + 0xB3, + 0x44, + 0x22, + 0x13, + 0xCE, + 0x19, + 0xD0, + 0x05, + 0x0F, + 0x00, + 0xCE, + 0x39, + 0x51, + 0x26, + 0xF4, + 0xC2, + 0xA7, + 0x66, + 0x89, + 0x6C, + 0xCC, + 0xE7, + 0xD3, + 0x8F, + 0x2D, + 0xCA, + 0x84, + 0xB3, + 0x1B, + 0x45, + 0x03, + 0x6A, + 0xF0, + 0x51, + 0x50, + 0x61, + 0x26, + 0x44, + 0xC7, + 0xD1, + 0x07, + 0x24, + 0x27, + 0xD0, + 0x6A, + 0xDB, + 0x02, + 0x7C, + 0xB4, + 0x7D, + 0xFA, + 0x06, + 0x8A, + 0xB5, + 0x12, + 0x94, + 0xC0, + 0x03, + 0xF2, + 0x4C, + 0x08, + 0xC7, + 0x90, + 0x55, + 0xA3, + 0xE4, + 0xF6, + 0x98, + 0x0B, + 0x0F, + 0x20, + 0xCA, + 0x84, + 0xAA, + 0x01, + 0x12, + 0xF8, + 0xD7, + 0xEB, + 0x15, + 0x3E, + 0xB7, + 0x98, + 0x10, + 0x15, + 0x42, + 0x52, + 0xF0, + 0xB8, + 0xED, + 0x72, + 0xFD, + 0x59, + 0x6B, + 0xA3, + 0x6B, + 0xDF, + 0x9B, + 0x50, + 0x34, + 0xA0, + 0x05, + 0xBE, + 0xD7, + 0x04, + 0xAA, + 0x5A, + 0x36, + 0x48, + 0xE0, + 0xCF, + 0x26, + 0xF8, + 0xCB, + 0x20, + 0x3B, + 0x0B, + 0xB4, + 0x9E, + 0x79, + 0xAF, + 0x9F, + 0x9F, + 0x9F, + 0xF0, + 0xB9, + 0xB7, + 0x26, + 0xE4, + 0xEA, + 0x80, + 0x30, + 0xED, + 0x8D, + 0xB5, + 0xD6, + 0x7D, + 0x3F, + 0x03, + 0xDF, + 0x1A, + 0x90, + 0x5A, + 0x1C, + 0xB8, + 0xE3, + 0x38, + 0x2E, + 0x3B, + 0x25, + 0xF0, + 0x5E, + 0xBD, + 0x26, + 0xD0, + 0xAA, + 0x9E, + 0x5B, + 0x37, + 0x44, + 0x6D, + 0x6A, + 0x97, + 0x19, + 0xF9, + 0x0A, + 0x3E, + 0x75, + 0x09, + 0x98, + 0x7D, + 0xDF, + 0xA3, + 0x1D, + 0x2D, + 0xF0, + 0x54, + 0xE2, + 0x29, + 0x72, + 0x02, + 0xFC, + 0x65, + 0x83, + 0xC8, + 0x1D, + 0xC7, + 0xD1, + 0x0C, + 0x7F, + 0x3E, + 0xFB, + 0x51, + 0x87, + 0x8C, + 0x4C, + 0x28, + 0xDD, + 0x38, + 0x69, + 0xC2, + 0x27, + 0x77, + 0x10, + 0x39, + 0x4D, + 0xF8, + 0xD0, + 0x69, + 0xC1, + 0x84, + 0x99, + 0xF0, + 0xD9, + 0x9D, + 0x44, + 0x91, + 0x09, + 0xBD, + 0xF0, + 0xA1, + 0x63, + 0x41, + 0x4D, + 0x18, + 0x05, + 0x5F, + 0xFC, + 0x07, + 0x51, + 0x30, + 0x81, + 0x5B, + 0xF4, + 0x38, + 0xEA, + 0x99, + 0x1D, + 0x80, + 0x7E, + 0xF8, + 0xEA, + 0x3F, + 0x89, + 0x8A, + 0x26, + 0x48, + 0xE1, + 0xC3, + 0x00, + 0x1A, + 0x4D, + 0xD0, + 0x80, + 0x67, + 0x1D, + 0x40, + 0x94, + 0x34, + 0xA1, + 0x15, + 0x3E, + 0x0C, + 0x42, + 0x7A, + 0x17, + 0xA9, + 0x04, + 0xCF, + 0x3E, + 0x88, + 0x28, + 0x32, + 0xA1, + 0x17, + 0x3E, + 0x0C, + 0x84, + 0x69, + 0x82, + 0x26, + 0xBC, + 0xE8, + 0x40, + 0xA2, + 0xE4, + 0xEC, + 0x00, + 0x7C, + 0x40, + 0x72, + 0xFF, + 0xAB, + 0x0E, + 0xA6, + 0x62, + 0x82, + 0x36, + 0xBC, + 0xF8, + 0x60, + 0xA2, + 0xA9, + 0x26, + 0x8C, + 0x80, + 0x6F, + 0x6A, + 0x40, + 0x14, + 0x4C, + 0xA0, + 0xD0, + 0xAD, + 0x26, + 0x18, + 0x63, + 0x70, + 0x1C, + 0xC7, + 0xE5, + 0x19, + 0x63, + 0x49, + 0x3D, + 0x6F, + 0x98, + 0xAA, + 0xBC, + 0x1F, + 0xA0, + 0x65, + 0x82, + 0x87, + 0xF7, + 0xE2, + 0x98, + 0xD0, + 0xFB, + 0x7A, + 0xAD, + 0xDA, + 0x1B, + 0x22, + 0xBD, + 0x26, + 0x50, + 0x78, + 0xAF, + 0x92, + 0x09, + 0x1A, + 0xEF, + 0x16, + 0x6B, + 0xBE, + 0x7A, + 0xD6, + 0x6C, + 0xC2, + 0x2A, + 0x78, + 0x95, + 0x00, + 0x44, + 0x62, + 0x13, + 0x56, + 0xC2, + 0xAB, + 0x05, + 0x21, + 0xCA, + 0x9A, + 0x70, + 0xE9, + 0x7C, + 0x31, + 0xBC, + 0x6A, + 0x20, + 0xA2, + 0xAA, + 0x09, + 0x77, + 0x80, + 0x57, + 0x0F, + 0x46, + 0x54, + 0x5C, + 0x27, + 0xDC, + 0x01, + 0x7E, + 0x48, + 0x40, + 0xA2, + 0x8B, + 0x09, + 0x77, + 0x82, + 0x1F, + 0x16, + 0x94, + 0x28, + 0xBA, + 0x1C, + 0xEE, + 0x04, + 0x3F, + 0x34, + 0x30, + 0x91, + 0x03, + 0x70, + 0x3B, + 0x78, + 0x60, + 0xDE, + 0x6F, + 0x86, + 0x92, + 0x10, + 0xAB, + 0xE1, + 0xA7, + 0x74, + 0x40, + 0x14, + 0x1E, + 0xB9, + 0xDF, + 0x01, + 0x1E, + 0x98, + 0xFF, + 0xCB, + 0x51, + 0x03, + 0xDC, + 0x07, + 0x7E, + 0x6A, + 0x47, + 0x44, + 0xB7, + 0xF9, + 0xF1, + 0xE4, + 0x2A, + 0x03, + 0x80, + 0x1B, + 0xFD, + 0x7C, + 0x76, + 0xA5, + 0xDC, + 0xF7, + 0xFB, + 0xBA, + 0xAE, + 0x17, + 0x9E, + 0xFF, + 0x77, + 0x2D, + 0x85, + 0xFF, + 0x07, + 0xE6, + 0x6F, + 0xFC, + 0xB7, + 0xE2, + 0xFB, + 0x3A, + 0x0B, + 0x00, + 0x00, + 0x00, + 0x00, + 0x49, + 0x45, + 0x4E, + 0x44, + 0xAE, + 0x42, + 0x60, + 0x82, }; wxBitmap& icon_png_to_wx_bitmap() { - static wxMemoryInputStream memIStream( icon_png, sizeof( icon_png ) ); - static wxImage image( memIStream, wxBITMAP_TYPE_PNG ); - static wxBitmap bmp( image ); - return bmp; + static wxMemoryInputStream memIStream(icon_png, sizeof(icon_png)); + static wxImage image(memIStream, wxBITMAP_TYPE_PNG); + static wxBitmap bmp(image); + return bmp; } - -#endif //ICON_PNG_H +#endif // ICON_PNG_H diff --git a/src/gui/layout.h b/src/gui/layout.h index 22e1e1de..8bdd447f 100644 --- a/src/gui/layout.h +++ b/src/gui/layout.h @@ -50,122 +50,223 @@ /////////////////////////////////////////////////////////////////////////////// class MainWindowGen : public wxFrame { - private: +private: +protected: + wxMenuBar* menuBar; + wxMenu* m_menu1; + wxMenu* m_menu2; + wxSimplebook* dataNotebook; + wxScrolledWindow* idlePanel; + wxStaticBitmap* applicationBitmap; + wxStaticText* m_staticText61; + wxRadioButton* realDiskRadioButton; + wxPanel* realDiskRadioButtonPanel; + wxComboBox* deviceCombo; + wxChoice* driveChoice; + wxCheckBox* highDensityToggle; + wxCheckBox* fortyTrackDriveToggle; + wxRadioButton* fluxImageRadioButton; + wxPanel* fluxImageRadioButtonPanel; + wxFilePickerCtrl* fluxImagePicker; + wxRadioButton* diskImageRadioButton; + wxPanel* diskImageRadioButtonPanel; + wxFilePickerCtrl* diskImagePicker; + wxStaticText* m_staticText23; + wxPanel* m_panel11; + wxChoice* formatChoice; + wxButton* customConfigurationButton; + wxStaticText* m_staticText19; + wxButton* readButton; + wxButton* writeButton; + wxButton* browseButton; + wxButton* formatButton; + wxPanel* imagePanel; + wxAuiToolBar* imagerToolbar; + wxAuiToolBarItem* imagerBackTool; + VisualisationControl* visualiser; + wxButton* imagerSaveImageButton; + wxButton* imagerSaveFluxButton; + wxStaticText* m_staticText4; + wxButton* imagerGoAgainButton; + wxPanel* browsePanel; + wxAuiToolBar* browserToolbar; + wxAuiToolBarItem* browserBackTool; + wxAuiToolBarItem* browserInfoTool; + wxAuiToolBarItem* browserViewTool; + wxAuiToolBarItem* browserSaveTool; + wxAuiToolBarItem* browserMoreMenuButton; + wxMenu* browserMoreMenu; + wxMenuItem* browserAddMenuItem; + wxMenuItem* browserNewDirectoryMenuItem; + wxMenuItem* browserRenameMenuItem; + wxMenuItem* browserDeleteMenuItem; + wxAuiToolBarItem* browserFormatTool; + wxDataViewCtrl* browserTree; + wxDataViewColumn* m_dataViewColumn1; + wxDataViewColumn* m_dataViewColumn2; + wxDataViewColumn* m_dataViewColumn3; + wxGauge* diskSpaceGauge; + wxButton* browserDiscardButton; + wxButton* browserCommitButton; + wxStaticText* m_staticText12; - protected: - wxMenuBar* menuBar; - wxMenu* m_menu1; - wxMenu* m_menu2; - wxSimplebook* dataNotebook; - wxScrolledWindow* idlePanel; - wxStaticBitmap* applicationBitmap; - wxStaticText* m_staticText61; - wxRadioButton* realDiskRadioButton; - wxPanel* realDiskRadioButtonPanel; - wxComboBox* deviceCombo; - wxChoice* driveChoice; - wxCheckBox* highDensityToggle; - wxCheckBox* fortyTrackDriveToggle; - wxRadioButton* fluxImageRadioButton; - wxPanel* fluxImageRadioButtonPanel; - wxFilePickerCtrl* fluxImagePicker; - wxRadioButton* diskImageRadioButton; - wxPanel* diskImageRadioButtonPanel; - wxFilePickerCtrl* diskImagePicker; - wxStaticText* m_staticText23; - wxPanel* m_panel11; - wxChoice* formatChoice; - wxButton* customConfigurationButton; - wxStaticText* m_staticText19; - wxButton* readButton; - wxButton* writeButton; - wxButton* browseButton; - wxButton* formatButton; - wxPanel* imagePanel; - wxAuiToolBar* imagerToolbar; - wxAuiToolBarItem* imagerBackTool; - VisualisationControl* visualiser; - wxButton* imagerSaveImageButton; - wxButton* imagerSaveFluxButton; - wxStaticText* m_staticText4; - wxButton* imagerGoAgainButton; - wxPanel* browsePanel; - wxAuiToolBar* browserToolbar; - wxAuiToolBarItem* browserBackTool; - wxAuiToolBarItem* browserInfoTool; - wxAuiToolBarItem* browserViewTool; - wxAuiToolBarItem* browserSaveTool; - wxAuiToolBarItem* browserMoreMenuButton; - wxMenu* browserMoreMenu; - wxMenuItem* browserAddMenuItem; - wxMenuItem* browserNewDirectoryMenuItem; - wxMenuItem* browserRenameMenuItem; - wxMenuItem* browserDeleteMenuItem; - wxAuiToolBarItem* browserFormatTool; - wxDataViewCtrl* browserTree; - wxDataViewColumn* m_dataViewColumn1; - wxDataViewColumn* m_dataViewColumn2; - wxDataViewColumn* m_dataViewColumn3; - wxGauge* diskSpaceGauge; - wxButton* browserDiscardButton; - wxButton* browserCommitButton; - wxStaticText* m_staticText12; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnAboutMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExit(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnShowLogWindow(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnShowConfigWindow(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnConfigRadioButtonClicked(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnControlsChanged(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnControlsChanged(wxFileDirPickerEvent& event) + { + event.Skip(); + } + virtual void OnCustomConfigurationButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnReadButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnWriteButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowseButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnFormatButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBackButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSaveImageButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSaveFluxButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnImagerGoAgainButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserInfoButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserViewButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserSaveButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserAddMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserNewDirectoryMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserRenameMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDeleteMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserFormatButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserBeginDrag(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDrop(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDropPossible(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserFilenameChanged(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDirectoryExpanding(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserSelectionChanged(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDiscardButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserCommitButton(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnAboutMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExit( wxCommandEvent& event ) { event.Skip(); } - virtual void OnShowLogWindow( wxCommandEvent& event ) { event.Skip(); } - virtual void OnShowConfigWindow( wxCommandEvent& event ) { event.Skip(); } - virtual void OnConfigRadioButtonClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void OnControlsChanged( wxCommandEvent& event ) { event.Skip(); } - virtual void OnControlsChanged( wxFileDirPickerEvent& event ) { event.Skip(); } - virtual void OnCustomConfigurationButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnReadButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnWriteButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowseButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnFormatButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSaveImageButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSaveFluxButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnImagerGoAgainButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserInfoButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserViewButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserSaveButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserAddMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserNewDirectoryMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserRenameMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserDeleteMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserFormatButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserBeginDrag( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDrop( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDropPossible( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserFilenameChanged( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDirectoryExpanding( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserSelectionChanged( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDiscardButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserCommitButton( wxCommandEvent& event ) { event.Skip(); } +public: + MainWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("FluxEngine"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(616, 607), + long style = wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | + wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL); + ~MainWindowGen(); - public: - - MainWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("FluxEngine"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 616,607 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); - - ~MainWindowGen(); - - void browserMoreMenuButtonOnDropDownMenu( wxAuiToolBarEvent &event ) - { - if ( event.IsDropDownClicked() ) - { - browserToolbar->SetToolSticky( event.GetId(), true ); - wxRect rect = browserToolbar->GetToolRect( event.GetId() ); - wxPoint pt = browserToolbar->ClientToScreen( rect.GetBottomLeft() ); - pt = ScreenToClient( pt ); - browserToolbar->PopupMenu( browserMoreMenu, pt ); - browserToolbar->SetToolSticky( event.GetId(), false ); - } - } - + void browserMoreMenuButtonOnDropDownMenu(wxAuiToolBarEvent& event) + { + if (event.IsDropDownClicked()) + { + browserToolbar->SetToolSticky(event.GetId(), true); + wxRect rect = browserToolbar->GetToolRect(event.GetId()); + wxPoint pt = browserToolbar->ClientToScreen(rect.GetBottomLeft()); + pt = ScreenToClient(pt); + browserToolbar->PopupMenu(browserMoreMenu, pt); + browserToolbar->SetToolSticky(event.GetId(), false); + } + } }; /////////////////////////////////////////////////////////////////////////////// @@ -173,24 +274,32 @@ class MainWindowGen : public wxFrame /////////////////////////////////////////////////////////////////////////////// class TextViewerWindowGen : public wxDialog { - private: +private: +protected: + wxTextCtrl* textControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - wxTextCtrl* textControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - TextViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 208,143 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~TextViewerWindowGen(); +public: + TextViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(208, 143), + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~TextViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -198,25 +307,33 @@ class TextViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FluxViewerWindowGen : public wxDialog { - private: +private: +protected: + FluxViewerControl* fluxviewer; + wxScrollBar* scrollbar; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - FluxViewerControl* fluxviewer; - wxScrollBar* scrollbar; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - FluxViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,200 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~FluxViewerWindowGen(); +public: + FluxViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(400, 200), + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~FluxViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -224,26 +341,37 @@ class FluxViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class TextEditorWindowGen : public wxDialog { - private: +private: +protected: + wxTextCtrl* textControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2Save; + wxButton* m_sdbSizer2Cancel; - protected: - wxTextCtrl* textControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2Save; - wxButton* m_sdbSizer2Cancel; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnCancel(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSave(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSave( wxCommandEvent& event ) { event.Skip(); } - - - public: - - TextEditorWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~TextEditorWindowGen(); +public: + TextEditorWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~TextEditorWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -251,27 +379,32 @@ class TextEditorWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileViewerWindowGen : public wxDialog { - private: +private: +protected: + wxNotebook* m_notebook1; + wxPanel* m_panel8; + wxTextCtrl* textControl; + wxPanel* m_panel7; + wxTextCtrl* hexControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - wxNotebook* m_notebook1; - wxPanel* m_panel8; - wxTextCtrl* textControl; - wxPanel* m_panel7; - wxTextCtrl* hexControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - FileViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 408,269 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~FileViewerWindowGen(); +public: + FileViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(408, 269), + long style = wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | + wxRESIZE_BORDER); + ~FileViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -279,23 +412,26 @@ class FileViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class GetfileDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* filenameText; + wxFilePickerCtrl* targetFilePicker; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* filenameText; - wxFilePickerCtrl* targetFilePicker; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - GetfileDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Copy file off disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~GetfileDialog(); + GetfileDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Copy file off disk"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~GetfileDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -303,24 +439,27 @@ class GetfileDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileConflictDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxTextCtrl* oldNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxTextCtrl* oldNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FileConflictDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Filename conflict"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FileConflictDialog(); + FileConflictDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Filename conflict"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FileConflictDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -328,24 +467,27 @@ class FileConflictDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileRenameDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxTextCtrl* oldNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxTextCtrl* oldNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FileRenameDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Rename or move file"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FileRenameDialog(); + FileRenameDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Rename or move file"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FileRenameDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -353,22 +495,25 @@ class FileRenameDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class CreateDirectoryDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - CreateDirectoryDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Create new directory"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~CreateDirectoryDialog(); + CreateDirectoryDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Create new directory"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~CreateDirectoryDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -376,22 +521,24 @@ class CreateDirectoryDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FormatDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; +public: + wxTextCtrl* volumeNameText; + wxCheckBox* quickFormatCheckBox; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* volumeNameText; - wxCheckBox* quickFormatCheckBox; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FormatDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Format disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FormatDialog(); + FormatDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Format disk"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FormatDialog(); }; - diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 73e41555..15316be6 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -20,6 +20,7 @@ #include "customstatusbar.h" #include "lib/vfs/vfs.h" #include "lib/environment.h" +#include "lib/layout.h" #include #include #include diff --git a/src/gui/visualisationcontrol.cc b/src/gui/visualisationcontrol.cc index 156fbd16..ac20dc53 100644 --- a/src/gui/visualisationcontrol.cc +++ b/src/gui/visualisationcontrol.cc @@ -5,6 +5,7 @@ #include "flux.h" #include "sector.h" #include "image.h" +#include "lib/layout.h" #include "fmt/format.h" #define BORDER 20 @@ -194,8 +195,8 @@ void VisualisationControl::OnPaint(wxPaintEvent&) std::string logicalText = "logical: (none)"; if (it != _tracks.end()) logicalText = fmt::format("logical: {}.{}", - it->second->location.logicalTrack, - it->second->location.logicalSide); + it->second->layout->logicalTrack, + it->second->layout->logicalSide); centreText(logicalText, h - 35); } @@ -271,7 +272,7 @@ void VisualisationControl::Clear() void VisualisationControl::SetTrackData(std::shared_ptr track) { - key_t key = {track->location.physicalTrack, track->location.physicalSide}; + key_t key = {track->layout->physicalTrack, track->layout->physicalSide}; _tracks[key] = track; _sectors.erase(key); for (auto& sector : track->sectors) @@ -285,8 +286,7 @@ void VisualisationControl::SetDiskData(std::shared_ptr disk) _sectors.clear(); for (const auto& track : disk->tracks) { - key_t key = { - track->location.physicalTrack, track->location.physicalSide}; + key_t key = {track->layout->physicalTrack, track->layout->physicalSide}; _tracks[key] = track; } From 4a565b5ea071372a9607224317a6b88e27df7079 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 16 Sep 2022 00:07:22 +0200 Subject: [PATCH 3/7] Split the Layout class. --- arch/amiga/encoder.cc | 2 +- arch/apple2/encoder.cc | 2 +- arch/brother/encoder.cc | 2 +- arch/c64/encoder.cc | 2 +- arch/ibm/encoder.cc | 2 +- arch/macintosh/encoder.cc | 2 +- arch/micropolis/encoder.cc | 2 +- arch/northstar/encoder.cc | 2 +- arch/tids990/encoder.cc | 2 +- arch/victor9k/encoder.cc | 2 +- lib/decoders/decoders.cc | 4 ++-- lib/decoders/decoders.h | 4 ++-- lib/encoders/encoders.cc | 4 ++-- lib/encoders/encoders.h | 6 +++--- lib/flux.h | 6 +++--- lib/layout.cc | 12 ++++++------ lib/layout.h | 25 ++++++++++++++----------- lib/readerwriter.cc | 26 +++++++++++++------------- lib/readerwriter.h | 12 ++++++------ lib/sector.cc | 2 +- lib/sector.h | 4 ++-- lib/vfs/fluxsectorinterface.cc | 2 +- src/gui/fluxviewercontrol.cc | 4 ++-- src/gui/fluxviewercontrol.h | 6 +++--- 24 files changed, 70 insertions(+), 67 deletions(-) diff --git a/arch/amiga/encoder.cc b/arch/amiga/encoder.cc index 7851b2e0..4521e1e4 100644 --- a/arch/amiga/encoder.cc +++ b/arch/amiga/encoder.cc @@ -110,7 +110,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/apple2/encoder.cc b/arch/apple2/encoder.cc index c463a3cb..4c92d3a0 100644 --- a/arch/apple2/encoder.cc +++ b/arch/apple2/encoder.cc @@ -36,7 +36,7 @@ private: const Apple2EncoderProto& _config; public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/brother/encoder.cc b/arch/brother/encoder.cc index d0f62ad0..b48a3a4b 100644 --- a/arch/brother/encoder.cc +++ b/arch/brother/encoder.cc @@ -108,7 +108,7 @@ public: public: std::unique_ptr encode( - std::shared_ptr& layout, + std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/c64/encoder.cc b/arch/c64/encoder.cc index 9f9318ca..4dbaee6f 100644 --- a/arch/c64/encoder.cc +++ b/arch/c64/encoder.cc @@ -175,7 +175,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index 7264607b..e28cc883 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -107,7 +107,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/macintosh/encoder.cc b/arch/macintosh/encoder.cc index a9b07ea8..9b20ed1a 100644 --- a/arch/macintosh/encoder.cc +++ b/arch/macintosh/encoder.cc @@ -220,7 +220,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/micropolis/encoder.cc b/arch/micropolis/encoder.cc index b0d6238c..f26a1cc4 100644 --- a/arch/micropolis/encoder.cc +++ b/arch/micropolis/encoder.cc @@ -77,7 +77,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/northstar/encoder.cc b/arch/northstar/encoder.cc index 68f5a807..89aa2197 100644 --- a/arch/northstar/encoder.cc +++ b/arch/northstar/encoder.cc @@ -128,7 +128,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/tids990/encoder.cc b/arch/tids990/encoder.cc index 825be0c5..ea2bdd0d 100644 --- a/arch/tids990/encoder.cc +++ b/arch/tids990/encoder.cc @@ -60,7 +60,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/victor9k/encoder.cc b/arch/victor9k/encoder.cc index df136a03..cc839e02 100644 --- a/arch/victor9k/encoder.cc +++ b/arch/victor9k/encoder.cc @@ -164,7 +164,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index 5491f0b5..bdb180b6 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -61,7 +61,7 @@ std::unique_ptr Decoder::create(const DecoderProto& config) } std::shared_ptr Decoder::decodeToSectors( - std::shared_ptr fluxmap, std::shared_ptr& layout) + std::shared_ptr fluxmap, std::shared_ptr& layout) { _trackdata = std::make_shared(); _trackdata->fluxmap = fluxmap; @@ -222,7 +222,7 @@ uint64_t Decoder::readRaw64() } std::set Decoder::requiredSectors( - std::shared_ptr& layout) const + std::shared_ptr& layout) const { const auto trackLayout = Layout::getLayoutOfTrackPhysical(layout->physicalTrack, layout->physicalSide); diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index 5af9d855..76b9ccd5 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -51,7 +51,7 @@ public: public: std::shared_ptr decodeToSectors( std::shared_ptr fluxmap, - std::shared_ptr& location); + std::shared_ptr& location); void pushRecord( const Fluxmap::Position& start, const Fluxmap::Position& end); @@ -90,7 +90,7 @@ public: } virtual std::set requiredSectors( - std::shared_ptr& location) const; + std::shared_ptr& location) const; protected: virtual void beginTrack(){}; diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index a55245f3..b24d87e3 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -57,13 +57,13 @@ nanoseconds_t Encoder::calculatePhysicalClockPeriod( } std::shared_ptr Encoder::getSector( - std::shared_ptr& layout, const Image& image, unsigned sectorId) + std::shared_ptr& layout, const Image& image, unsigned sectorId) { return image.get(layout->logicalTrack, layout->logicalSide, sectorId); } std::vector> Encoder::collectSectors( - std::shared_ptr& trackLayout, const Image& image) + std::shared_ptr& trackLayout, const Image& image) { std::vector> sectors; diff --git a/lib/encoders/encoders.h b/lib/encoders/encoders.h index c82fac72..82f161d2 100644 --- a/lib/encoders/encoders.h +++ b/lib/encoders/encoders.h @@ -17,12 +17,12 @@ public: public: virtual std::shared_ptr getSector( - std::shared_ptr&, const Image& image, unsigned sectorId); + std::shared_ptr&, const Image& image, unsigned sectorId); virtual std::vector> collectSectors( - std::shared_ptr&, const Image& image); + std::shared_ptr&, const Image& image); - virtual std::unique_ptr encode(std::shared_ptr& layout, + virtual std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) = 0; diff --git a/lib/flux.h b/lib/flux.h index 7b37d43b..aa0d7165 100644 --- a/lib/flux.h +++ b/lib/flux.h @@ -6,7 +6,7 @@ class Fluxmap; class Sector; class Image; -class Layout; +class Track; struct Record { @@ -18,7 +18,7 @@ struct Record struct TrackDataFlux { - std::shared_ptr layout; + std::shared_ptr layout; std::shared_ptr fluxmap; std::vector> records; std::vector> sectors; @@ -26,7 +26,7 @@ struct TrackDataFlux struct TrackFlux { - std::shared_ptr layout; + std::shared_ptr layout; std::vector> trackDatas; std::set> sectors; }; diff --git a/lib/layout.cc b/lib/layout.cc index ce3f2556..5b18d461 100644 --- a/lib/layout.cc +++ b/lib/layout.cc @@ -4,7 +4,7 @@ #include "lib/environment.h" #include -static Local, std::shared_ptr>> +static Local, std::shared_ptr>> layoutCache; static unsigned getTrackStep() @@ -38,7 +38,7 @@ unsigned Layout::remapSideLogicalToPhysical(unsigned lside) return lside ^ config.layout().swap_sides(); } -std::vector> Layout::computeLocations() +std::vector> Layout::computeLocations() { std::set tracks; if (config.has_tracks()) @@ -52,7 +52,7 @@ std::vector> Layout::computeLocations() else heads = iterate(0, config.layout().sides()); - std::vector> locations; + std::vector> locations; for (unsigned logicalTrack : tracks) { for (unsigned logicalHead : heads) @@ -125,13 +125,13 @@ std::vector Layout::expandSectorList( return sectors; } -std::shared_ptr Layout::getLayoutOfTrack( +std::shared_ptr Layout::getLayoutOfTrack( unsigned logicalTrack, unsigned logicalSide) { auto& layout = (*layoutCache)[std::make_pair(logicalTrack, logicalSide)]; if (!layout) { - layout = std::make_shared(); + layout = std::make_shared(); LayoutProto::LayoutdataProto layoutdata; for (const auto& f : config.layout().layoutdata()) @@ -190,7 +190,7 @@ std::shared_ptr Layout::getLayoutOfTrack( return layout; } -std::shared_ptr Layout::getLayoutOfTrackPhysical( +std::shared_ptr Layout::getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide) { return getLayoutOfTrack(remapTrackPhysicalToLogical(physicalTrack), diff --git a/lib/layout.h b/lib/layout.h index 431e8402..4f4282cd 100644 --- a/lib/layout.h +++ b/lib/layout.h @@ -4,17 +4,10 @@ #include "lib/flux.h" class SectorListProto; +class Track; class Layout { -public: - Layout() {} - -private: - /* Can't copy. */ - Layout(const Layout&); - Layout& operator=(const Layout&); - public: /* Translates logical track numbering (the numbers actually written in the * sector headers) to the track numbering on the actual drive, taking into @@ -32,7 +25,7 @@ public: /* Uses the layout and current track and heads settings to determine * which Locations are going to be read from or written to. 8/ */ - static std::vector> computeLocations(); + static std::vector> computeLocations(); /* Returns a series of pairs representing the filesystem * ordering of the disk, in logical numbers. */ @@ -40,16 +33,26 @@ public: unsigned guessedTracks = 0, unsigned guessedSides = 0); /* Returns the layout of a given track. */ - static std::shared_ptr getLayoutOfTrack( + static std::shared_ptr getLayoutOfTrack( unsigned logicalTrack, unsigned logicalHead); /* Returns the layout of a given track via physical location. */ - static std::shared_ptr getLayoutOfTrackPhysical( + static std::shared_ptr getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide); /* Expand a SectorList into the actual sector IDs. */ static std::vector expandSectorList( const SectorListProto& sectorsProto); +}; + +class Track { +public: + Track() {} + +private: + /* Can't copy. */ + Track(const Track&); + Track& operator=(const Track&); public: unsigned numTracks = 0; diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index 6d55ed30..6a273136 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -156,7 +156,7 @@ static std::set> collectSectors( BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& layout) { std::set> track_sectors; @@ -182,7 +182,7 @@ BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, } ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, - std::shared_ptr& layout, + std::shared_ptr& layout, TrackFlux& trackFlux, Decoder& decoder) { @@ -224,9 +224,9 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, void writeTracks(FluxSink& fluxSink, std::function( - std::shared_ptr& layout)> producer, - std::function& layout)> verifier, - std::vector>& layouts) + std::shared_ptr& layout)> producer, + std::function& layout)> verifier, + std::vector>& layouts) { Logger() << BeginOperationLogMessage{"Encoding and writing to disk"}; @@ -294,11 +294,11 @@ void writeTracks(FluxSink& fluxSink, void writeTracks(FluxSink& fluxSink, Encoder& encoder, const Image& image, - std::vector>& layouts) + std::vector>& layouts) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto sectors = encoder.collectSectors(layout, image); return encoder.encode(layout, sectors, image); @@ -315,16 +315,16 @@ void writeTracksAndVerify(FluxSink& fluxSink, FluxSource& fluxSource, Decoder& decoder, const Image& image, - std::vector>& locations) + std::vector>& locations) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto sectors = encoder.collectSectors(layout, image); return encoder.encode(layout, sectors, image); }, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto trackFlux = std::make_shared(); trackFlux->layout = layout; @@ -381,7 +381,7 @@ void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - std::vector>& locations) + std::vector>& locations) { if (fluxSource && decoder) writeTracksAndVerify( @@ -405,7 +405,7 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) auto locations = Layout::computeLocations(); writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { return fluxSource .readFlux(layout->physicalTrack, layout->physicalSide) @@ -420,7 +420,7 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& layout) { auto trackFlux = std::make_shared(); trackFlux->layout = layout; diff --git a/lib/readerwriter.h b/lib/readerwriter.h index c627e6a6..a03a5b18 100644 --- a/lib/readerwriter.h +++ b/lib/readerwriter.h @@ -11,7 +11,7 @@ class Fluxmap; class Image; class ImageReader; class ImageWriter; -class Layout; +class Track; class TrackFlux; extern void measureDiskRotation( @@ -19,15 +19,15 @@ extern void measureDiskRotation( extern void writeTracks(FluxSink& fluxSink, const std::function( - std::shared_ptr& layout)> producer, - std::vector>& locations); + std::shared_ptr& layout)> producer, + std::vector>& locations); extern void writeTracksAndVerify(FluxSink& fluxSink, Encoder& encoder, FluxSource& fluxSource, Decoder& decoder, const Image& image, - std::vector>& locations); + std::vector>& locations); extern void fillBitmapTo(std::vector& bitmap, unsigned& cursor, @@ -39,7 +39,7 @@ extern void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - std::vector>& locations); + std::vector>& locations); extern void writeDiskCommand(const Image& image, Encoder& encoder, @@ -51,7 +51,7 @@ extern void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink); extern std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, Decoder& decoder, - std::shared_ptr& layout); + std::shared_ptr& layout); extern std::shared_ptr readDiskCommand( FluxSource& fluxsource, Decoder& decoder); diff --git a/lib/sector.cc b/lib/sector.cc index a7fd3ca9..57dcf513 100644 --- a/lib/sector.cc +++ b/lib/sector.cc @@ -10,7 +10,7 @@ Sector::Sector(const LogicalLocation& location): physicalSide(Layout::remapSideLogicalToPhysical(location.logicalSide)) {} -Sector::Sector(std::shared_ptr& layout, unsigned sectorId): +Sector::Sector(std::shared_ptr& layout, unsigned sectorId): LogicalLocation({ layout->logicalTrack, layout->logicalSide, sectorId }), physicalTrack(layout->physicalTrack), physicalSide(layout->physicalSide) diff --git a/lib/sector.h b/lib/sector.h index f58fa7e5..6ca617fb 100644 --- a/lib/sector.h +++ b/lib/sector.h @@ -5,7 +5,7 @@ #include "fluxmap.h" class Record; -class Layout; +class Track; struct LogicalLocation { @@ -65,7 +65,7 @@ struct Sector : public LogicalLocation Sector() {} - Sector(std::shared_ptr& layout, unsigned sectorId=0); + Sector(std::shared_ptr& layout, unsigned sectorId=0); Sector(const LogicalLocation& location); diff --git a/lib/vfs/fluxsectorinterface.cc b/lib/vfs/fluxsectorinterface.cc index e91fd2e3..480f7139 100644 --- a/lib/vfs/fluxsectorinterface.cc +++ b/lib/vfs/fluxsectorinterface.cc @@ -56,7 +56,7 @@ public: void flushChanges() override { - std::vector> locations; + std::vector> locations; for (const auto& trackid : _changedTracks) { diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index 47c58da0..cb2a848b 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -434,7 +434,7 @@ void FluxViewerControl::ShowSectorMenu(std::shared_ptr sector) PopupMenu(&menu, _mouseX, _mouseY); } -void FluxViewerControl::ShowRecordMenu(std::shared_ptr& layout, +void FluxViewerControl::ShowRecordMenu(std::shared_ptr& layout, std::shared_ptr record) { wxMenu menu; @@ -502,7 +502,7 @@ void FluxViewerControl::DisplayRawData(std::shared_ptr sector) TextViewerWindow::Create(this, title, s.str())->Show(); } -void FluxViewerControl::DisplayRawData(std::shared_ptr& layout, +void FluxViewerControl::DisplayRawData(std::shared_ptr& layout, std::shared_ptr record) { std::stringstream s; diff --git a/src/gui/fluxviewercontrol.h b/src/gui/fluxviewercontrol.h index 142b1c7a..35c21325 100644 --- a/src/gui/fluxviewercontrol.h +++ b/src/gui/fluxviewercontrol.h @@ -8,7 +8,7 @@ class wxScrollBar; class wxScrollEvent; class Sector; class Record; -class Layout; +class Track; class FluxViewerControl : public wxWindow { @@ -27,11 +27,11 @@ public: private: void UpdateScale(); void ShowSectorMenu(std::shared_ptr sector); - void ShowRecordMenu(std::shared_ptr& layout, + void ShowRecordMenu(std::shared_ptr& layout, std::shared_ptr record); void DisplayDecodedData(std::shared_ptr sector); void DisplayRawData(std::shared_ptr sector); - void DisplayRawData(std::shared_ptr& layout, + void DisplayRawData(std::shared_ptr& layout, std::shared_ptr record); private: From 81cbd00cc8ed0116d7e67979136ac829e16f6fed Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 16 Sep 2022 00:09:39 +0200 Subject: [PATCH 4/7] Rename Track to TrackInfo, which better describes what it is. --- arch/amiga/encoder.cc | 2 +- arch/apple2/encoder.cc | 2 +- arch/brother/encoder.cc | 2 +- arch/c64/encoder.cc | 2 +- arch/ibm/encoder.cc | 2 +- arch/macintosh/encoder.cc | 2 +- arch/micropolis/encoder.cc | 2 +- arch/northstar/encoder.cc | 2 +- arch/tids990/encoder.cc | 2 +- arch/victor9k/encoder.cc | 2 +- lib/decoders/decoders.cc | 4 ++-- lib/decoders/decoders.h | 4 ++-- lib/encoders/encoders.cc | 4 ++-- lib/encoders/encoders.h | 6 +++--- lib/flux.h | 6 +++--- lib/layout.cc | 12 ++++++------ lib/layout.h | 16 ++++++++-------- lib/readerwriter.cc | 26 +++++++++++++------------- lib/readerwriter.h | 12 ++++++------ lib/sector.cc | 2 +- lib/sector.h | 4 ++-- lib/vfs/fluxsectorinterface.cc | 2 +- src/gui/fluxviewercontrol.cc | 4 ++-- src/gui/fluxviewercontrol.h | 6 +++--- 24 files changed, 64 insertions(+), 64 deletions(-) diff --git a/arch/amiga/encoder.cc b/arch/amiga/encoder.cc index 4521e1e4..5743de13 100644 --- a/arch/amiga/encoder.cc +++ b/arch/amiga/encoder.cc @@ -110,7 +110,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/apple2/encoder.cc b/arch/apple2/encoder.cc index 4c92d3a0..5d0e27d4 100644 --- a/arch/apple2/encoder.cc +++ b/arch/apple2/encoder.cc @@ -36,7 +36,7 @@ private: const Apple2EncoderProto& _config; public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/brother/encoder.cc b/arch/brother/encoder.cc index b48a3a4b..aa0dd3b4 100644 --- a/arch/brother/encoder.cc +++ b/arch/brother/encoder.cc @@ -108,7 +108,7 @@ public: public: std::unique_ptr encode( - std::shared_ptr& layout, + std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/c64/encoder.cc b/arch/c64/encoder.cc index 4dbaee6f..82d02821 100644 --- a/arch/c64/encoder.cc +++ b/arch/c64/encoder.cc @@ -175,7 +175,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index e28cc883..1b796838 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -107,7 +107,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/macintosh/encoder.cc b/arch/macintosh/encoder.cc index 9b20ed1a..f3519a83 100644 --- a/arch/macintosh/encoder.cc +++ b/arch/macintosh/encoder.cc @@ -220,7 +220,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/micropolis/encoder.cc b/arch/micropolis/encoder.cc index f26a1cc4..1b8b820c 100644 --- a/arch/micropolis/encoder.cc +++ b/arch/micropolis/encoder.cc @@ -77,7 +77,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/northstar/encoder.cc b/arch/northstar/encoder.cc index 89aa2197..dbb9dfde 100644 --- a/arch/northstar/encoder.cc +++ b/arch/northstar/encoder.cc @@ -128,7 +128,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/tids990/encoder.cc b/arch/tids990/encoder.cc index ea2bdd0d..2e2226d6 100644 --- a/arch/tids990/encoder.cc +++ b/arch/tids990/encoder.cc @@ -60,7 +60,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/arch/victor9k/encoder.cc b/arch/victor9k/encoder.cc index cc839e02..a5f91681 100644 --- a/arch/victor9k/encoder.cc +++ b/arch/victor9k/encoder.cc @@ -164,7 +164,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) override { diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index bdb180b6..db47103a 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -61,7 +61,7 @@ std::unique_ptr Decoder::create(const DecoderProto& config) } std::shared_ptr Decoder::decodeToSectors( - std::shared_ptr fluxmap, std::shared_ptr& layout) + std::shared_ptr fluxmap, std::shared_ptr& layout) { _trackdata = std::make_shared(); _trackdata->fluxmap = fluxmap; @@ -222,7 +222,7 @@ uint64_t Decoder::readRaw64() } std::set Decoder::requiredSectors( - std::shared_ptr& layout) const + std::shared_ptr& layout) const { const auto trackLayout = Layout::getLayoutOfTrackPhysical(layout->physicalTrack, layout->physicalSide); diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index 76b9ccd5..a50430d2 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -51,7 +51,7 @@ public: public: std::shared_ptr decodeToSectors( std::shared_ptr fluxmap, - std::shared_ptr& location); + std::shared_ptr& location); void pushRecord( const Fluxmap::Position& start, const Fluxmap::Position& end); @@ -90,7 +90,7 @@ public: } virtual std::set requiredSectors( - std::shared_ptr& location) const; + std::shared_ptr& location) const; protected: virtual void beginTrack(){}; diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index b24d87e3..0584bd74 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -57,13 +57,13 @@ nanoseconds_t Encoder::calculatePhysicalClockPeriod( } std::shared_ptr Encoder::getSector( - std::shared_ptr& layout, const Image& image, unsigned sectorId) + std::shared_ptr& layout, const Image& image, unsigned sectorId) { return image.get(layout->logicalTrack, layout->logicalSide, sectorId); } std::vector> Encoder::collectSectors( - std::shared_ptr& trackLayout, const Image& image) + std::shared_ptr& trackLayout, const Image& image) { std::vector> sectors; diff --git a/lib/encoders/encoders.h b/lib/encoders/encoders.h index 82f161d2..6e5d9b04 100644 --- a/lib/encoders/encoders.h +++ b/lib/encoders/encoders.h @@ -17,12 +17,12 @@ public: public: virtual std::shared_ptr getSector( - std::shared_ptr&, const Image& image, unsigned sectorId); + std::shared_ptr&, const Image& image, unsigned sectorId); virtual std::vector> collectSectors( - std::shared_ptr&, const Image& image); + std::shared_ptr&, const Image& image); - virtual std::unique_ptr encode(std::shared_ptr& layout, + virtual std::unique_ptr encode(std::shared_ptr& layout, const std::vector>& sectors, const Image& image) = 0; diff --git a/lib/flux.h b/lib/flux.h index aa0d7165..dafd664d 100644 --- a/lib/flux.h +++ b/lib/flux.h @@ -6,7 +6,7 @@ class Fluxmap; class Sector; class Image; -class Track; +class TrackInfo; struct Record { @@ -18,7 +18,7 @@ struct Record struct TrackDataFlux { - std::shared_ptr layout; + std::shared_ptr layout; std::shared_ptr fluxmap; std::vector> records; std::vector> sectors; @@ -26,7 +26,7 @@ struct TrackDataFlux struct TrackFlux { - std::shared_ptr layout; + std::shared_ptr layout; std::vector> trackDatas; std::set> sectors; }; diff --git a/lib/layout.cc b/lib/layout.cc index 5b18d461..8311f2fb 100644 --- a/lib/layout.cc +++ b/lib/layout.cc @@ -4,7 +4,7 @@ #include "lib/environment.h" #include -static Local, std::shared_ptr>> +static Local, std::shared_ptr>> layoutCache; static unsigned getTrackStep() @@ -38,7 +38,7 @@ unsigned Layout::remapSideLogicalToPhysical(unsigned lside) return lside ^ config.layout().swap_sides(); } -std::vector> Layout::computeLocations() +std::vector> Layout::computeLocations() { std::set tracks; if (config.has_tracks()) @@ -52,7 +52,7 @@ std::vector> Layout::computeLocations() else heads = iterate(0, config.layout().sides()); - std::vector> locations; + std::vector> locations; for (unsigned logicalTrack : tracks) { for (unsigned logicalHead : heads) @@ -125,13 +125,13 @@ std::vector Layout::expandSectorList( return sectors; } -std::shared_ptr Layout::getLayoutOfTrack( +std::shared_ptr Layout::getLayoutOfTrack( unsigned logicalTrack, unsigned logicalSide) { auto& layout = (*layoutCache)[std::make_pair(logicalTrack, logicalSide)]; if (!layout) { - layout = std::make_shared(); + layout = std::make_shared(); LayoutProto::LayoutdataProto layoutdata; for (const auto& f : config.layout().layoutdata()) @@ -190,7 +190,7 @@ std::shared_ptr Layout::getLayoutOfTrack( return layout; } -std::shared_ptr Layout::getLayoutOfTrackPhysical( +std::shared_ptr Layout::getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide) { return getLayoutOfTrack(remapTrackPhysicalToLogical(physicalTrack), diff --git a/lib/layout.h b/lib/layout.h index 4f4282cd..8780da36 100644 --- a/lib/layout.h +++ b/lib/layout.h @@ -4,7 +4,7 @@ #include "lib/flux.h" class SectorListProto; -class Track; +class TrackInfo; class Layout { @@ -25,7 +25,7 @@ public: /* Uses the layout and current track and heads settings to determine * which Locations are going to be read from or written to. 8/ */ - static std::vector> computeLocations(); + static std::vector> computeLocations(); /* Returns a series of pairs representing the filesystem * ordering of the disk, in logical numbers. */ @@ -33,11 +33,11 @@ public: unsigned guessedTracks = 0, unsigned guessedSides = 0); /* Returns the layout of a given track. */ - static std::shared_ptr getLayoutOfTrack( + static std::shared_ptr getLayoutOfTrack( unsigned logicalTrack, unsigned logicalHead); /* Returns the layout of a given track via physical location. */ - static std::shared_ptr getLayoutOfTrackPhysical( + static std::shared_ptr getLayoutOfTrackPhysical( unsigned physicalTrack, unsigned physicalSide); /* Expand a SectorList into the actual sector IDs. */ @@ -45,14 +45,14 @@ public: const SectorListProto& sectorsProto); }; -class Track { +class TrackInfo { public: - Track() {} + TrackInfo() {} private: /* Can't copy. */ - Track(const Track&); - Track& operator=(const Track&); + TrackInfo(const TrackInfo&); + TrackInfo& operator=(const TrackInfo&); public: unsigned numTracks = 0; diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index 6a273136..b751a598 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -156,7 +156,7 @@ static std::set> collectSectors( BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& layout) { std::set> track_sectors; @@ -182,7 +182,7 @@ BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, } ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, - std::shared_ptr& layout, + std::shared_ptr& layout, TrackFlux& trackFlux, Decoder& decoder) { @@ -224,9 +224,9 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, void writeTracks(FluxSink& fluxSink, std::function( - std::shared_ptr& layout)> producer, - std::function& layout)> verifier, - std::vector>& layouts) + std::shared_ptr& layout)> producer, + std::function& layout)> verifier, + std::vector>& layouts) { Logger() << BeginOperationLogMessage{"Encoding and writing to disk"}; @@ -294,11 +294,11 @@ void writeTracks(FluxSink& fluxSink, void writeTracks(FluxSink& fluxSink, Encoder& encoder, const Image& image, - std::vector>& layouts) + std::vector>& layouts) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto sectors = encoder.collectSectors(layout, image); return encoder.encode(layout, sectors, image); @@ -315,16 +315,16 @@ void writeTracksAndVerify(FluxSink& fluxSink, FluxSource& fluxSource, Decoder& decoder, const Image& image, - std::vector>& locations) + std::vector>& locations) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto sectors = encoder.collectSectors(layout, image); return encoder.encode(layout, sectors, image); }, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { auto trackFlux = std::make_shared(); trackFlux->layout = layout; @@ -381,7 +381,7 @@ void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - std::vector>& locations) + std::vector>& locations) { if (fluxSource && decoder) writeTracksAndVerify( @@ -405,7 +405,7 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) auto locations = Layout::computeLocations(); writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& layout) { return fluxSource .readFlux(layout->physicalTrack, layout->physicalSide) @@ -420,7 +420,7 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& layout) { auto trackFlux = std::make_shared(); trackFlux->layout = layout; diff --git a/lib/readerwriter.h b/lib/readerwriter.h index a03a5b18..c89f5068 100644 --- a/lib/readerwriter.h +++ b/lib/readerwriter.h @@ -11,7 +11,7 @@ class Fluxmap; class Image; class ImageReader; class ImageWriter; -class Track; +class TrackInfo; class TrackFlux; extern void measureDiskRotation( @@ -19,15 +19,15 @@ extern void measureDiskRotation( extern void writeTracks(FluxSink& fluxSink, const std::function( - std::shared_ptr& layout)> producer, - std::vector>& locations); + std::shared_ptr& layout)> producer, + std::vector>& locations); extern void writeTracksAndVerify(FluxSink& fluxSink, Encoder& encoder, FluxSource& fluxSource, Decoder& decoder, const Image& image, - std::vector>& locations); + std::vector>& locations); extern void fillBitmapTo(std::vector& bitmap, unsigned& cursor, @@ -39,7 +39,7 @@ extern void writeDiskCommand(const Image& image, FluxSink& fluxSink, Decoder* decoder, FluxSource* fluxSource, - std::vector>& locations); + std::vector>& locations); extern void writeDiskCommand(const Image& image, Encoder& encoder, @@ -51,7 +51,7 @@ extern void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink); extern std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, Decoder& decoder, - std::shared_ptr& layout); + std::shared_ptr& layout); extern std::shared_ptr readDiskCommand( FluxSource& fluxsource, Decoder& decoder); diff --git a/lib/sector.cc b/lib/sector.cc index 57dcf513..07a59d8d 100644 --- a/lib/sector.cc +++ b/lib/sector.cc @@ -10,7 +10,7 @@ Sector::Sector(const LogicalLocation& location): physicalSide(Layout::remapSideLogicalToPhysical(location.logicalSide)) {} -Sector::Sector(std::shared_ptr& layout, unsigned sectorId): +Sector::Sector(std::shared_ptr& layout, unsigned sectorId): LogicalLocation({ layout->logicalTrack, layout->logicalSide, sectorId }), physicalTrack(layout->physicalTrack), physicalSide(layout->physicalSide) diff --git a/lib/sector.h b/lib/sector.h index 6ca617fb..d5fd269e 100644 --- a/lib/sector.h +++ b/lib/sector.h @@ -5,7 +5,7 @@ #include "fluxmap.h" class Record; -class Track; +class TrackInfo; struct LogicalLocation { @@ -65,7 +65,7 @@ struct Sector : public LogicalLocation Sector() {} - Sector(std::shared_ptr& layout, unsigned sectorId=0); + Sector(std::shared_ptr& layout, unsigned sectorId=0); Sector(const LogicalLocation& location); diff --git a/lib/vfs/fluxsectorinterface.cc b/lib/vfs/fluxsectorinterface.cc index 480f7139..3e4ef294 100644 --- a/lib/vfs/fluxsectorinterface.cc +++ b/lib/vfs/fluxsectorinterface.cc @@ -56,7 +56,7 @@ public: void flushChanges() override { - std::vector> locations; + std::vector> locations; for (const auto& trackid : _changedTracks) { diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index cb2a848b..047ad74b 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -434,7 +434,7 @@ void FluxViewerControl::ShowSectorMenu(std::shared_ptr sector) PopupMenu(&menu, _mouseX, _mouseY); } -void FluxViewerControl::ShowRecordMenu(std::shared_ptr& layout, +void FluxViewerControl::ShowRecordMenu(std::shared_ptr& layout, std::shared_ptr record) { wxMenu menu; @@ -502,7 +502,7 @@ void FluxViewerControl::DisplayRawData(std::shared_ptr sector) TextViewerWindow::Create(this, title, s.str())->Show(); } -void FluxViewerControl::DisplayRawData(std::shared_ptr& layout, +void FluxViewerControl::DisplayRawData(std::shared_ptr& layout, std::shared_ptr record) { std::stringstream s; diff --git a/src/gui/fluxviewercontrol.h b/src/gui/fluxviewercontrol.h index 35c21325..d3fbac5c 100644 --- a/src/gui/fluxviewercontrol.h +++ b/src/gui/fluxviewercontrol.h @@ -8,7 +8,7 @@ class wxScrollBar; class wxScrollEvent; class Sector; class Record; -class Track; +class TrackInfo; class FluxViewerControl : public wxWindow { @@ -27,11 +27,11 @@ public: private: void UpdateScale(); void ShowSectorMenu(std::shared_ptr sector); - void ShowRecordMenu(std::shared_ptr& layout, + void ShowRecordMenu(std::shared_ptr& layout, std::shared_ptr record); void DisplayDecodedData(std::shared_ptr sector); void DisplayRawData(std::shared_ptr sector); - void DisplayRawData(std::shared_ptr& layout, + void DisplayRawData(std::shared_ptr& layout, std::shared_ptr record); private: From d0fb85e7128491f0f69547c8106b74a5bfbc4343 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 16 Sep 2022 00:20:54 +0200 Subject: [PATCH 5/7] Rename all the remaining layout and location variables to trackInfo (where appropriate). --- arch/amiga/encoder.cc | 2 +- arch/apple2/encoder.cc | 2 +- arch/brother/encoder.cc | 2 +- arch/c64/encoder.cc | 4 ++-- arch/ibm/encoder.cc | 6 +++--- arch/macintosh/encoder.cc | 4 ++-- arch/micropolis/encoder.cc | 2 +- arch/northstar/encoder.cc | 2 +- arch/tids990/encoder.cc | 2 +- arch/victor9k/encoder.cc | 4 ++-- lib/decoders/decoders.cc | 10 +++++----- lib/decoders/decoders.h | 4 ++-- lib/encoders/encoders.cc | 4 ++-- lib/encoders/encoders.h | 2 +- lib/flux.h | 4 ++-- lib/fluxsource/memoryfluxsource.cc | 2 +- lib/readerwriter.cc | 12 ++++++------ lib/vfs/fluxsectorinterface.cc | 4 ++-- src/gui/fluxviewercontrol.cc | 2 +- src/gui/fluxviewerwindow.cc | 4 ++-- src/gui/visualisationcontrol.cc | 8 ++++---- 21 files changed, 43 insertions(+), 43 deletions(-) diff --git a/arch/amiga/encoder.cc b/arch/amiga/encoder.cc index 5743de13..0756238f 100644 --- a/arch/amiga/encoder.cc +++ b/arch/amiga/encoder.cc @@ -110,7 +110,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/apple2/encoder.cc b/arch/apple2/encoder.cc index 5d0e27d4..7af72c95 100644 --- a/arch/apple2/encoder.cc +++ b/arch/apple2/encoder.cc @@ -36,7 +36,7 @@ private: const Apple2EncoderProto& _config; public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/brother/encoder.cc b/arch/brother/encoder.cc index aa0dd3b4..a01e0a56 100644 --- a/arch/brother/encoder.cc +++ b/arch/brother/encoder.cc @@ -108,7 +108,7 @@ public: public: std::unique_ptr encode( - std::shared_ptr& layout, + std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/c64/encoder.cc b/arch/c64/encoder.cc index 82d02821..c7697e88 100644 --- a/arch/c64/encoder.cc +++ b/arch/c64/encoder.cc @@ -175,7 +175,7 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { @@ -198,7 +198,7 @@ public: else _formatByte1 = _formatByte2 = 0; - double clockRateUs = clockPeriodForC64Track(layout->logicalTrack); + double clockRateUs = clockPeriodForC64Track(trackInfo->logicalTrack); int bitsPerRevolution = 200000.0 / clockRateUs; std::vector bits(bitsPerRevolution); diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index 1b796838..f04cc5fd 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -107,15 +107,15 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { IbmEncoderProto::TrackdataProto trackdata; - getEncoderTrackData(trackdata, layout->logicalTrack, layout->logicalSide); + getEncoderTrackData(trackdata, trackInfo->logicalTrack, trackInfo->logicalSide); auto trackLayout = - Layout::getLayoutOfTrack(layout->logicalTrack, layout->logicalSide); + Layout::getLayoutOfTrack(trackInfo->logicalTrack, trackInfo->logicalSide); auto writeBytes = [&](const Bytes& bytes) { diff --git a/arch/macintosh/encoder.cc b/arch/macintosh/encoder.cc index f3519a83..cea0ef6d 100644 --- a/arch/macintosh/encoder.cc +++ b/arch/macintosh/encoder.cc @@ -220,11 +220,11 @@ public: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { - double clockRateUs = clockRateUsForTrack(layout->logicalTrack); + double clockRateUs = clockRateUsForTrack(trackInfo->logicalTrack); int bitsPerRevolution = 200000.0 / clockRateUs; std::vector bits(bitsPerRevolution); unsigned cursor = 0; diff --git a/arch/micropolis/encoder.cc b/arch/micropolis/encoder.cc index 1b8b820c..186d06c4 100644 --- a/arch/micropolis/encoder.cc +++ b/arch/micropolis/encoder.cc @@ -77,7 +77,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/northstar/encoder.cc b/arch/northstar/encoder.cc index dbb9dfde..4b08a8f0 100644 --- a/arch/northstar/encoder.cc +++ b/arch/northstar/encoder.cc @@ -128,7 +128,7 @@ public: { } - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/tids990/encoder.cc b/arch/tids990/encoder.cc index 2e2226d6..a69c7cce 100644 --- a/arch/tids990/encoder.cc +++ b/arch/tids990/encoder.cc @@ -60,7 +60,7 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { diff --git a/arch/victor9k/encoder.cc b/arch/victor9k/encoder.cc index a5f91681..4bde505f 100644 --- a/arch/victor9k/encoder.cc +++ b/arch/victor9k/encoder.cc @@ -164,12 +164,12 @@ private: } public: - std::unique_ptr encode(std::shared_ptr& layout, + std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) override { Victor9kEncoderProto::TrackdataProto trackdata; - getTrackFormat(trackdata, layout->logicalTrack, layout->logicalSide); + getTrackFormat(trackdata, trackInfo->logicalTrack, trackInfo->logicalSide); unsigned bitsPerRevolution = (trackdata.rotational_period_ms() * 1e3) / trackdata.clock_period_us(); diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index db47103a..f4f1962a 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -61,18 +61,18 @@ std::unique_ptr Decoder::create(const DecoderProto& config) } std::shared_ptr Decoder::decodeToSectors( - std::shared_ptr fluxmap, std::shared_ptr& layout) + std::shared_ptr fluxmap, std::shared_ptr& trackInfo) { _trackdata = std::make_shared(); _trackdata->fluxmap = fluxmap; - _trackdata->layout = layout; + _trackdata->trackInfo = trackInfo; FluxmapReader fmr(*fluxmap); _fmr = &fmr; auto newSector = [&] { - _sector = std::make_shared(layout, 0); + _sector = std::make_shared(trackInfo, 0); _sector->status = Sector::MISSING; }; @@ -222,10 +222,10 @@ uint64_t Decoder::readRaw64() } std::set Decoder::requiredSectors( - std::shared_ptr& layout) const + std::shared_ptr& trackInfo) const { const auto trackLayout = - Layout::getLayoutOfTrackPhysical(layout->physicalTrack, layout->physicalSide); + Layout::getLayoutOfTrackPhysical(trackInfo->physicalTrack, trackInfo->physicalSide); std::set results; for (unsigned sectorId : trackLayout->logicalSectorOrder) diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index a50430d2..e2798e5c 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -51,7 +51,7 @@ public: public: std::shared_ptr decodeToSectors( std::shared_ptr fluxmap, - std::shared_ptr& location); + std::shared_ptr& trackInfo); void pushRecord( const Fluxmap::Position& start, const Fluxmap::Position& end); @@ -90,7 +90,7 @@ public: } virtual std::set requiredSectors( - std::shared_ptr& location) const; + std::shared_ptr& trackInfo) const; protected: virtual void beginTrack(){}; diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index 0584bd74..002f482a 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -57,9 +57,9 @@ nanoseconds_t Encoder::calculatePhysicalClockPeriod( } std::shared_ptr Encoder::getSector( - std::shared_ptr& layout, const Image& image, unsigned sectorId) + std::shared_ptr& trackInfo, const Image& image, unsigned sectorId) { - return image.get(layout->logicalTrack, layout->logicalSide, sectorId); + return image.get(trackInfo->logicalTrack, trackInfo->logicalSide, sectorId); } std::vector> Encoder::collectSectors( diff --git a/lib/encoders/encoders.h b/lib/encoders/encoders.h index 6e5d9b04..02292063 100644 --- a/lib/encoders/encoders.h +++ b/lib/encoders/encoders.h @@ -22,7 +22,7 @@ public: virtual std::vector> collectSectors( std::shared_ptr&, const Image& image); - virtual std::unique_ptr encode(std::shared_ptr& layout, + virtual std::unique_ptr encode(std::shared_ptr& trackInfo, const std::vector>& sectors, const Image& image) = 0; diff --git a/lib/flux.h b/lib/flux.h index dafd664d..ad355154 100644 --- a/lib/flux.h +++ b/lib/flux.h @@ -18,7 +18,7 @@ struct Record struct TrackDataFlux { - std::shared_ptr layout; + std::shared_ptr trackInfo; std::shared_ptr fluxmap; std::vector> records; std::vector> sectors; @@ -26,7 +26,7 @@ struct TrackDataFlux struct TrackFlux { - std::shared_ptr layout; + std::shared_ptr trackInfo; std::vector> trackDatas; std::set> sectors; }; diff --git a/lib/fluxsource/memoryfluxsource.cc b/lib/fluxsource/memoryfluxsource.cc index e4d4848f..b7aa930f 100644 --- a/lib/fluxsource/memoryfluxsource.cc +++ b/lib/fluxsource/memoryfluxsource.cc @@ -57,7 +57,7 @@ public: { for (const auto& trackFlux : _flux.tracks) { - if ((trackFlux->layout->physicalTrack == physicalTrack) && (trackFlux->layout->physicalSide == physicalSide)) + if ((trackFlux->trackInfo->physicalTrack == physicalTrack) && (trackFlux->trackInfo->physicalSide == physicalSide)) return std::make_unique(*trackFlux); } diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index b751a598..298a0339 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -164,7 +164,7 @@ BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, track_sectors.insert( trackdataflux->sectors.begin(), trackdataflux->sectors.end()); - for (auto& logicalLocation : decoder.requiredSectors(trackFlux.layout)) + for (auto& logicalLocation : decoder.requiredSectors(trackFlux.trackInfo)) { auto sector = std::make_shared(logicalLocation); sector->status = Sector::MISSING; @@ -324,13 +324,13 @@ void writeTracksAndVerify(FluxSink& fluxSink, auto sectors = encoder.collectSectors(layout, image); return encoder.encode(layout, sectors, image); }, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& trackInfo) { auto trackFlux = std::make_shared(); - trackFlux->layout = layout; + trackFlux->trackInfo = trackInfo; FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource); auto result = readGroup( - fluxSourceIteratorHolder, layout, *trackFlux, decoder); + fluxSourceIteratorHolder, trackInfo, *trackFlux, decoder); Logger() << TrackReadLogMessage{trackFlux}; if (result != GOOD_READ) @@ -340,7 +340,7 @@ void writeTracksAndVerify(FluxSink& fluxSink, } Image wanted; - for (const auto& sector : encoder.collectSectors(layout, image)) + for (const auto& sector : encoder.collectSectors(trackInfo, image)) wanted .put(sector->logicalTrack, sector->logicalSide, @@ -423,7 +423,7 @@ std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, std::shared_ptr& layout) { auto trackFlux = std::make_shared(); - trackFlux->layout = layout; + trackFlux->trackInfo = layout; FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource); int retriesRemaining = config.decoder().retries(); diff --git a/lib/vfs/fluxsectorinterface.cc b/lib/vfs/fluxsectorinterface.cc index 3e4ef294..43a46463 100644 --- a/lib/vfs/fluxsectorinterface.cc +++ b/lib/vfs/fluxsectorinterface.cc @@ -128,8 +128,8 @@ private: void populateSectors(unsigned track, unsigned side) { - auto layout = Layout::getLayoutOfTrack(track, side); - auto trackdata = readAndDecodeTrack(*_fluxSource, *_decoder, layout); + auto trackInfo = Layout::getLayoutOfTrack(track, side); + auto trackdata = readAndDecodeTrack(*_fluxSource, *_decoder, trackInfo); for (const auto& sector : trackdata->sectors) *_loadedSectors.put(track, side, sector->logicalSector) = *sector; diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index 047ad74b..9927ad18 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -286,7 +286,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&) text, {x + rp + BORDER, t2y - size.GetHeight() / 2}); if (_rightClicked && hovered) - ShowRecordMenu(trackdata->layout, record); + ShowRecordMenu(trackdata->trackInfo, record); } /* Flux chart. */ diff --git a/src/gui/fluxviewerwindow.cc b/src/gui/fluxviewerwindow.cc index b8a12648..18887881 100644 --- a/src/gui/fluxviewerwindow.cc +++ b/src/gui/fluxviewerwindow.cc @@ -15,8 +15,8 @@ FluxViewerWindow::FluxViewerWindow( fluxviewer->SetScrollbar(scrollbar); fluxviewer->SetFlux(flux); SetTitle(fmt::format("Flux for c{} h{}", - flux->layout->physicalTrack, - flux->layout->physicalSide)); + flux->trackInfo->physicalTrack, + flux->trackInfo->physicalSide)); } void FluxViewerWindow::OnExit(wxCommandEvent& event) diff --git a/src/gui/visualisationcontrol.cc b/src/gui/visualisationcontrol.cc index ac20dc53..ed7ffa0c 100644 --- a/src/gui/visualisationcontrol.cc +++ b/src/gui/visualisationcontrol.cc @@ -195,8 +195,8 @@ void VisualisationControl::OnPaint(wxPaintEvent&) std::string logicalText = "logical: (none)"; if (it != _tracks.end()) logicalText = fmt::format("logical: {}.{}", - it->second->layout->logicalTrack, - it->second->layout->logicalSide); + it->second->trackInfo->logicalTrack, + it->second->trackInfo->logicalSide); centreText(logicalText, h - 35); } @@ -272,7 +272,7 @@ void VisualisationControl::Clear() void VisualisationControl::SetTrackData(std::shared_ptr track) { - key_t key = {track->layout->physicalTrack, track->layout->physicalSide}; + key_t key = {track->trackInfo->physicalTrack, track->trackInfo->physicalSide}; _tracks[key] = track; _sectors.erase(key); for (auto& sector : track->sectors) @@ -286,7 +286,7 @@ void VisualisationControl::SetDiskData(std::shared_ptr disk) _sectors.clear(); for (const auto& track : disk->tracks) { - key_t key = {track->layout->physicalTrack, track->layout->physicalSide}; + key_t key = {track->trackInfo->physicalTrack, track->trackInfo->physicalSide}; _tracks[key] = track; } From 201fd22861345d9ff899c0fc5b10eb0512c1f479 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 16 Sep 2022 00:26:02 +0200 Subject: [PATCH 6/7] Roll requiredSectors into readerwriter.cc. --- lib/decoders/decoders.cc | 16 ++-------------- lib/decoders/decoders.h | 3 --- lib/readerwriter.cc | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index f4f1962a..4c19c8d7 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -61,7 +61,8 @@ std::unique_ptr Decoder::create(const DecoderProto& config) } std::shared_ptr Decoder::decodeToSectors( - std::shared_ptr fluxmap, std::shared_ptr& trackInfo) + std::shared_ptr fluxmap, + std::shared_ptr& trackInfo) { _trackdata = std::make_shared(); _trackdata->fluxmap = fluxmap; @@ -220,16 +221,3 @@ uint64_t Decoder::readRaw64() { return toBytes(readRawBits(64)).reader().read_be64(); } - -std::set Decoder::requiredSectors( - std::shared_ptr& trackInfo) const -{ - const auto trackLayout = - Layout::getLayoutOfTrackPhysical(trackInfo->physicalTrack, trackInfo->physicalSide); - - std::set results; - for (unsigned sectorId : trackLayout->logicalSectorOrder) - results.insert(LogicalLocation{ - trackLayout->logicalTrack, trackLayout->logicalSide, sectorId}); - return results; -} diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index e2798e5c..93889b12 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -89,9 +89,6 @@ public: return _fmr->getDuration(); } - virtual std::set requiredSectors( - std::shared_ptr& trackInfo) const; - protected: virtual void beginTrack(){}; virtual nanoseconds_t advanceToNextRecord() = 0; diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index 298a0339..a2e4c9d9 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -156,21 +156,29 @@ static std::set> collectSectors( BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& trackLayout) { std::set> track_sectors; + /* Add the sectors which were there. */ + for (auto& trackdataflux : trackFlux.trackDatas) track_sectors.insert( trackdataflux->sectors.begin(), trackdataflux->sectors.end()); - for (auto& logicalLocation : decoder.requiredSectors(trackFlux.trackInfo)) + /* Add the sectors which should be there. */ + + for (unsigned sectorId : trackLayout->logicalSectorOrder) { - auto sector = std::make_shared(logicalLocation); + auto sector = std::make_shared(LogicalLocation{ + trackLayout->logicalTrack, trackLayout->logicalSide, sectorId}); + sector->status = Sector::MISSING; track_sectors.insert(sector); } + /* Deduplicate. */ + trackFlux.sectors = collectSectors(track_sectors); if (trackFlux.sectors.empty()) return HAS_BAD_SECTORS; @@ -402,7 +410,7 @@ void writeDiskCommand(const Image& image, void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) { - auto locations = Layout::computeLocations(); + auto locations = Layout::computeLocations(); writeTracks( fluxSink, [&](std::shared_ptr& layout) From 12fb39baa9a84365b0a47e97c5d815effd14ac55 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 16 Sep 2022 00:31:19 +0200 Subject: [PATCH 7/7] More variable renaming. --- lib/readerwriter.cc | 74 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index a2e4c9d9..04445ab9 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -190,22 +190,22 @@ BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux, } ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, - std::shared_ptr& layout, + std::shared_ptr& trackInfo, TrackFlux& trackFlux, Decoder& decoder) { ReadResult result = BAD_AND_CAN_NOT_RETRY; - for (unsigned offset = 0; offset < layout->groupSize; + for (unsigned offset = 0; offset < trackInfo->groupSize; offset += config.drive().head_width()) { auto& fluxSourceIterator = fluxSourceIteratorHolder.getIterator( - layout->physicalTrack + offset, layout->physicalSide); + trackInfo->physicalTrack + offset, trackInfo->physicalSide); if (!fluxSourceIterator.hasNext()) continue; Logger() << BeginReadOperationLogMessage{ - layout->physicalTrack + offset, layout->physicalSide}; + trackInfo->physicalTrack + offset, trackInfo->physicalSide}; std::shared_ptr fluxmap = fluxSourceIterator.next(); // ->rescale( // 1.0 / config.flux_source().rescale()); @@ -214,9 +214,9 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, (int)(fluxmap->duration() / 1e6), fluxmap->bytes()); - auto trackdataflux = decoder.decodeToSectors(fluxmap, layout); + auto trackdataflux = decoder.decodeToSectors(fluxmap, trackInfo); trackFlux.trackDatas.push_back(trackdataflux); - if (combineRecordAndSectors(trackFlux, decoder, layout) == + if (combineRecordAndSectors(trackFlux, decoder, trackInfo) == HAS_NO_BAD_SECTORS) { result = GOOD_READ; @@ -232,17 +232,17 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, void writeTracks(FluxSink& fluxSink, std::function( - std::shared_ptr& layout)> producer, - std::function& layout)> verifier, - std::vector>& layouts) + std::shared_ptr& trackInfo)> producer, + std::function& trackInfo)> verifier, + std::vector>& trackInfos) { Logger() << BeginOperationLogMessage{"Encoding and writing to disk"}; int index = 0; - for (auto& layout : layouts) + for (auto& trackInfo : trackInfos) { Logger() << OperationProgressLogMessage{ - index * 100 / (unsigned)layouts.size()}; + index * 100 / (unsigned)trackInfos.size()}; index++; testForEmergencyStop(); @@ -250,22 +250,22 @@ void writeTracks(FluxSink& fluxSink, int retriesRemaining = config.decoder().retries(); for (;;) { - for (int offset = 0; offset < layout->groupSize; + for (int offset = 0; offset < trackInfo->groupSize; offset += config.drive().head_width()) { - unsigned physicalTrack = layout->physicalTrack + offset; + unsigned physicalTrack = trackInfo->physicalTrack + offset; Logger() << BeginWriteOperationLogMessage{ - physicalTrack, layout->physicalSide}; + physicalTrack, trackInfo->physicalSide}; if (offset == config.drive().group_offset()) { - auto fluxmap = producer(layout); + auto fluxmap = producer(trackInfo); if (!fluxmap) goto erase; fluxSink.writeFlux( - physicalTrack, layout->physicalSide, *fluxmap); + physicalTrack, trackInfo->physicalSide, *fluxmap); Logger() << fmt::format("writing {0} ms in {1} bytes", int(fluxmap->duration() / 1e6), fluxmap->bytes()); @@ -277,14 +277,14 @@ void writeTracks(FluxSink& fluxSink, Fluxmap blank; fluxSink.writeFlux( - physicalTrack, layout->physicalSide, blank); + physicalTrack, trackInfo->physicalSide, blank); Logger() << "erased"; } Logger() << EndWriteOperationLogMessage(); } - if (verifier(layout)) + if (verifier(trackInfo)) break; if (retriesRemaining == 0) @@ -302,20 +302,20 @@ void writeTracks(FluxSink& fluxSink, void writeTracks(FluxSink& fluxSink, Encoder& encoder, const Image& image, - std::vector>& layouts) + std::vector>& trackInfos) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& trackInfo) { - auto sectors = encoder.collectSectors(layout, image); - return encoder.encode(layout, sectors, image); + auto sectors = encoder.collectSectors(trackInfo, image); + return encoder.encode(trackInfo, sectors, image); }, [](const auto&) { return true; }, - layouts); + trackInfos); } void writeTracksAndVerify(FluxSink& fluxSink, @@ -323,14 +323,14 @@ void writeTracksAndVerify(FluxSink& fluxSink, FluxSource& fluxSource, Decoder& decoder, const Image& image, - std::vector>& locations) + std::vector>& trackInfos) { writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& trackInfo) { - auto sectors = encoder.collectSectors(layout, image); - return encoder.encode(layout, sectors, image); + auto sectors = encoder.collectSectors(trackInfo, image); + return encoder.encode(trackInfo, sectors, image); }, [&](std::shared_ptr& trackInfo) { @@ -381,7 +381,7 @@ void writeTracksAndVerify(FluxSink& fluxSink, } return true; }, - locations); + trackInfos); } void writeDiskCommand(const Image& image, @@ -413,10 +413,10 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) auto locations = Layout::computeLocations(); writeTracks( fluxSink, - [&](std::shared_ptr& layout) + [&](std::shared_ptr& trackInfo) { return fluxSource - .readFlux(layout->physicalTrack, layout->physicalSide) + .readFlux(trackInfo->physicalTrack, trackInfo->physicalSide) ->next(); }, [](const auto&) @@ -428,17 +428,17 @@ void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink) std::shared_ptr readAndDecodeTrack(FluxSource& fluxSource, Decoder& decoder, - std::shared_ptr& layout) + std::shared_ptr& trackInfo) { auto trackFlux = std::make_shared(); - trackFlux->trackInfo = layout; + trackFlux->trackInfo = trackInfo; FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource); int retriesRemaining = config.decoder().retries(); for (;;) { auto result = - readGroup(fluxSourceIteratorHolder, layout, *trackFlux, decoder); + readGroup(fluxSourceIteratorHolder, trackInfo, *trackFlux, decoder); if (result == GOOD_READ) break; if (result == BAD_AND_CAN_NOT_RETRY) @@ -473,7 +473,7 @@ std::shared_ptr readDiskCommand( Logger() << BeginOperationLogMessage{"Reading and decoding disk"}; auto locations = Layout::computeLocations(); unsigned index = 0; - for (auto& layout : locations) + for (auto& trackInfo : locations) { Logger() << OperationProgressLogMessage{ index * 100 / (unsigned)locations.size()}; @@ -481,14 +481,14 @@ std::shared_ptr readDiskCommand( testForEmergencyStop(); - auto trackFlux = readAndDecodeTrack(fluxSource, decoder, layout); + auto trackFlux = readAndDecodeTrack(fluxSource, decoder, trackInfo); diskflux->tracks.push_back(trackFlux); if (outputFluxSink) { for (const auto& data : trackFlux->trackDatas) - outputFluxSink->writeFlux(layout->physicalTrack, - layout->physicalSide, + outputFluxSink->writeFlux(trackInfo->physicalTrack, + trackInfo->physicalSide, *data->fluxmap); }