From 93dcc7e2421735c8a20ab49ff55b47573639dd72 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 15 May 2021 12:33:22 +0200 Subject: [PATCH] Convert the image readers and Mac encoder and decoder. --- arch/macintosh/macintosh.h | 4 ++++ arch/macintosh/macintosh.proto | 5 +++++ lib/decoders/decoders.cc | 4 ++++ lib/decoders/decoders.proto | 2 ++ lib/encoders/encoders.cc | 4 ++++ lib/encoders/encoders.proto | 2 ++ lib/imagereader/imagereader.cc | 20 ++++++++++++++++---- lib/imagereader/imagereader.proto | 7 +++++++ mkninja.sh | 13 +++++-------- src/fe-readmac.cc | 26 -------------------------- src/fe-writemac.cc | 24 ------------------------ src/readables/macintosh.textpb | 27 +++++++++++++++++++++++++++ src/writables/macintosh.textpb | 27 +++++++++++++++++++++++++++ 13 files changed, 103 insertions(+), 62 deletions(-) create mode 100644 arch/macintosh/macintosh.proto delete mode 100644 src/fe-readmac.cc delete mode 100644 src/fe-writemac.cc create mode 100644 src/readables/macintosh.textpb create mode 100644 src/writables/macintosh.textpb diff --git a/arch/macintosh/macintosh.h b/arch/macintosh/macintosh.h index 1b3791ab..379e1047 100644 --- a/arch/macintosh/macintosh.h +++ b/arch/macintosh/macintosh.h @@ -15,10 +15,13 @@ class Sector; class Fluxmap; +class MacintoshInputProto; +class MacintoshOutputProto; class MacintoshDecoder : public AbstractDecoder { public: + MacintoshDecoder(const MacintoshInputProto&) {} virtual ~MacintoshDecoder() {} RecordType advanceToNextRecord(); @@ -31,6 +34,7 @@ public: class MacintoshEncoder : public AbstractEncoder { public: + MacintoshEncoder(const MacintoshOutputProto&) {} virtual ~MacintoshEncoder() {} public: diff --git a/arch/macintosh/macintosh.proto b/arch/macintosh/macintosh.proto new file mode 100644 index 00000000..80a599a1 --- /dev/null +++ b/arch/macintosh/macintosh.proto @@ -0,0 +1,5 @@ +syntax = "proto2"; + +message MacintoshInputProto {} +message MacintoshOutputProto {} + diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index 6f57341c..7a71c075 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -9,6 +9,7 @@ #include "arch/c64/c64.h" #include "arch/f85/f85.h" #include "arch/ibm/ibm.h" +#include "arch/macintosh/macintosh.h" #include "decoders/fluxmapreader.h" #include "record.h" #include "protocol.h" @@ -41,6 +42,9 @@ std::unique_ptr AbstractDecoder::create(const DecoderProto& con case DecoderProto::kIbm: return std::unique_ptr(new IbmDecoder(config.ibm())); + case DecoderProto::kMacintosh: + return std::unique_ptr(new MacintoshDecoder(config.macintosh())); + default: Error() << "no input disk format specified"; } diff --git a/lib/decoders/decoders.proto b/lib/decoders/decoders.proto index 7d45a364..b8b6d907 100644 --- a/lib/decoders/decoders.proto +++ b/lib/decoders/decoders.proto @@ -7,6 +7,7 @@ import "arch/c64/c64.proto"; import "arch/f85/f85.proto"; import "arch/fb100/fb100.proto"; import "arch/ibm/ibm.proto"; +import "arch/macintosh/macintosh.proto"; message DecoderProto { optional double pulse_debounce_threshold = 1 [default = 0.30]; @@ -22,6 +23,7 @@ message DecoderProto { Commodore64InputProto c64 = 9; F85InputProto f85 = 10; Fb100InputProto fb100 = 11; + MacintoshInputProto macintosh = 12; } } diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index cabaff70..c5495bd5 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -5,6 +5,7 @@ #include "arch/amiga/amiga.h" #include "arch/brother/brother.h" #include "arch/ibm/ibm.h" +#include "arch/macintosh/macintosh.h" #include "lib/encoders/encoders.pb.h" #include "protocol.h" @@ -21,6 +22,9 @@ std::unique_ptr AbstractEncoder::create(const EncoderProto& con case EncoderProto::kBrother: return std::unique_ptr(new BrotherEncoder(config.brother())); + case EncoderProto::kMacintosh: + return std::unique_ptr(new MacintoshEncoder(config.macintosh())); + default: Error() << "no input disk format specified"; } diff --git a/lib/encoders/encoders.proto b/lib/encoders/encoders.proto index 03fe2366..c96bec9c 100644 --- a/lib/encoders/encoders.proto +++ b/lib/encoders/encoders.proto @@ -3,6 +3,7 @@ syntax = "proto2"; import "arch/amiga/amiga.proto"; import "arch/brother/brother.proto"; import "arch/ibm/ibm.proto"; +import "arch/macintosh/macintosh.proto"; //import "lib/common.proto"; message EncoderProto { @@ -10,5 +11,6 @@ message EncoderProto { IBMOutputProto ibm = 3; BrotherOutputProto brother = 4; AmigaOutputProto amiga = 5; + MacintoshOutputProto macintosh = 6; } } diff --git a/lib/imagereader/imagereader.cc b/lib/imagereader/imagereader.cc index 7f469c0a..2ea4a20a 100644 --- a/lib/imagereader/imagereader.cc +++ b/lib/imagereader/imagereader.cc @@ -12,10 +12,22 @@ std::unique_ptr ImageReader::create(const InputFileProto& config) { - if (config.has_img()) - return ImageReader::createImgImageReader(config); - else - Error() << "bad input file config"; + switch (config.format_case()) + { + case InputFileProto::kImd: + return ImageReader::createIMDImageReader(config); + + case InputFileProto::kImg: + return ImageReader::createImgImageReader(config); + + case InputFileProto::kDiskcopy: + return ImageReader::createDiskCopyImageReader(config); + + case InputFileProto::kJv3: + return ImageReader::createJv3ImageReader(config); + } + + Error() << "bad input file config"; return std::unique_ptr(); } diff --git a/lib/imagereader/imagereader.proto b/lib/imagereader/imagereader.proto index 77518a28..ddab0c0f 100644 --- a/lib/imagereader/imagereader.proto +++ b/lib/imagereader/imagereader.proto @@ -14,10 +14,17 @@ message ImgInputOutputProto { optional int32 sides = 6 [default=2]; } +message DiskCopyInputProto {} +message ImdInputProto {} +message Jv3InputProto {} + message InputFileProto { optional string filename = 1; oneof format { ImgInputOutputProto img = 2; + DiskCopyInputProto diskcopy = 3; + ImdInputProto imd = 4; + Jv3InputProto jv3 = 5; } } diff --git a/mkninja.sh b/mkninja.sh index ee3f747e..f0bf3dad 100644 --- a/mkninja.sh +++ b/mkninja.sh @@ -264,6 +264,7 @@ buildproto libproto.a \ arch/f85/f85.proto \ arch/fb100/fb100.proto \ arch/ibm/ibm.proto \ + arch/macintosh/macintosh.proto \ lib/common.proto \ lib/config.proto \ lib/decoders/decoders.proto \ @@ -342,15 +343,16 @@ buildlibrary libbackend.a \ lib/writer.cc \ READABLES="\ - amiga \ - aeslanier \ acornadfs \ acorndfs \ + aeslanier \ + amiga \ brother \ c64 \ f85 \ fb100 \ ibm \ + macintosh \ " WRITABLES="\ @@ -358,6 +360,7 @@ WRITABLES="\ brother120 \ brother240 \ ibm1440 \ + macintosh \ " for pb in $READABLES; do @@ -403,17 +406,11 @@ buildlibrary libfrontend.a \ # src/fe-readampro.cc \ # src/fe-readapple2.cc \ # src/fe-readatarist.cc \ -# src/fe-readf85.cc \ -# src/fe-readfb100.cc \ -# src/fe-readibm.cc \ -# src/fe-readmac.cc \ # src/fe-readmicropolis.cc \ # src/fe-readmx.cc \ # src/fe-readtids990.cc \ # src/fe-readvictor9k.cc \ # src/fe-readzilogmcz.cc \ -# src/fe-writeibm.cc \ -# src/fe-writemac.cc \ # src/fe-writetids990.cc \ buildprogram fluxengine \ diff --git a/src/fe-readmac.cc b/src/fe-readmac.cc deleted file mode 100644 index 5adcbe1e..00000000 --- a/src/fe-readmac.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "globals.h" -#include "flags.h" -#include "reader.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "macintosh/macintosh.h" -#include "sector.h" -#include "sectorset.h" -#include "record.h" -#include "fmt/format.h" -#include - -static FlagGroup flags { &readerFlags }; - -int mainReadMac(int argc, const char* argv[]) -{ - setReaderDefaultSource(":t=0-79:s=0-1"); - setReaderDefaultOutput("mac.img"); - setReaderRevolutions(2); - flags.parseFlags(argc, argv); - - MacintoshDecoder decoder; - readDiskCommand(decoder); - - return 0; -} diff --git a/src/fe-writemac.cc b/src/fe-writemac.cc deleted file mode 100644 index 2b1f71a2..00000000 --- a/src/fe-writemac.cc +++ /dev/null @@ -1,24 +0,0 @@ -#include "globals.h" -#include "flags.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "macintosh/macintosh.h" -#include "writer.h" -#include "fmt/format.h" -#include - -static FlagGroup flags { &writerFlags, &macintoshEncoderFlags }; - -int mainWriteMac(int argc, const char* argv[]) -{ - setWriterDefaultInput(":c=80:h=2:s=12:b=524"); - setWriterDefaultDest(":d=0:t=0-79:s=0-1"); - flags.parseFlags(argc, argv); - - MacintoshEncoder encoder; - writeDiskCommand(encoder); - - return 0; -} - - diff --git a/src/readables/macintosh.textpb b/src/readables/macintosh.textpb new file mode 100644 index 00000000..f8701d60 --- /dev/null +++ b/src/readables/macintosh.textpb @@ -0,0 +1,27 @@ +input { + disk { + drive {} + } +} + +output { + file { + filename: "macintosh.diskcopy" + diskcopy {} + } +} + +decoder { + macintosh {} +} + +cylinders { + start: 0 + end: 79 +} + +heads { + start: 0 + end: 1 +} + diff --git a/src/writables/macintosh.textpb b/src/writables/macintosh.textpb new file mode 100644 index 00000000..dc922712 --- /dev/null +++ b/src/writables/macintosh.textpb @@ -0,0 +1,27 @@ +input { + file { + filename: "macintosh.diskcopy42" + diskcopy {} + } +} + +output { + disk { + drive: 0 + } +} + +encoder { + macintosh {} +} + +cylinders { + start: 0 + end: 79 +} + +heads { + start: 0 + end: 1 +} +