From dba3a3d9426cf45cc92ee2939fda43b28ec1a0f8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 25 Dec 2021 17:06:47 -0500 Subject: [PATCH] Add through route to an IPF container. --- Analyser/Static/StaticAnalyser.cpp | 13 +++-- .../Clock Signal.xcodeproj/project.pbxproj | 8 +++ OSBindings/Mac/Clock Signal/Info.plist | 20 +++++++ Storage/Disk/DiskImage/Formats/IPF.cpp | 27 +++++++++ Storage/Disk/DiskImage/Formats/IPF.hpp | 56 +++++++++++++++++++ 5 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 Storage/Disk/DiskImage/Formats/IPF.cpp create mode 100644 Storage/Disk/DiskImage/Formats/IPF.hpp diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index fb0c1b7a5..99668d6e1 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -43,11 +43,12 @@ #include "../../Storage/Disk/DiskImage/Formats/AppleDSK.hpp" #include "../../Storage/Disk/DiskImage/Formats/CPCDSK.hpp" #include "../../Storage/Disk/DiskImage/Formats/D64.hpp" -#include "../../Storage/Disk/DiskImage/Formats/MacintoshIMG.hpp" #include "../../Storage/Disk/DiskImage/Formats/G64.hpp" #include "../../Storage/Disk/DiskImage/Formats/DMK.hpp" #include "../../Storage/Disk/DiskImage/Formats/FAT12.hpp" #include "../../Storage/Disk/DiskImage/Formats/HFE.hpp" +#include "../../Storage/Disk/DiskImage/Formats/IPF.hpp" +#include "../../Storage/Disk/DiskImage/Formats/MacintoshIMG.hpp" #include "../../Storage/Disk/DiskImage/Formats/MSA.hpp" #include "../../Storage/Disk/DiskImage/Formats/NIB.hpp" #include "../../Storage/Disk/DiskImage/Formats/OricMFMDSK.hpp" @@ -103,8 +104,8 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: #define InsertInstance(list, instance, platforms) \ list.emplace_back(instance);\ potential_platforms |= platforms;\ - TargetPlatform::TypeDistinguisher *distinguisher = dynamic_cast(list.back().get());\ - if(distinguisher) potential_platforms &= distinguisher->target_platform_type(); \ + TargetPlatform::TypeDistinguisher *const distinguisher = dynamic_cast(list.back().get());\ + if(distinguisher) potential_platforms &= distinguisher->target_platform_type(); #define Insert(list, class, platforms, ...) \ InsertInstance(list, new Storage::class(__VA_ARGS__), platforms); @@ -161,7 +162,11 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: // HFE (TODO: switch to AllDisk once the MSX stops being so greedy) Format("img", result.disks, Disk::DiskImageHolder, TargetPlatform::Macintosh) // IMG (DiskCopy 4.2) Format("image", result.disks, Disk::DiskImageHolder, TargetPlatform::Macintosh) // IMG (DiskCopy 4.2) - Format("img", result.disks, Disk::DiskImageHolder, TargetPlatform::Enterprise) // IMG (Enterprise/MS-DOS style) + Format("img", result.disks, Disk::DiskImageHolder, TargetPlatform::Enterprise) // IMG (Enterprise/MS-DOS style) + Format( "ipf", + result.disks, + Disk::DiskImageHolder, + TargetPlatform::Amiga | TargetPlatform::AtariST | TargetPlatform::AmstradCPC | TargetPlatform::ZXSpectrum) // IPF Format("msa", result.disks, Disk::DiskImageHolder, TargetPlatform::AtariST) // MSA Format("nib", result.disks, Disk::DiskImageHolder, TargetPlatform::DiskII) // NIB Format("o", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // O diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 7962a7be7..734e8c3cb 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -273,6 +273,8 @@ 4B59199C1DAC6C46005BB85C /* OricTAP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B59199A1DAC6C46005BB85C /* OricTAP.cpp */; }; 4B595FAD2086DFBA0083CAA8 /* AudioToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B595FAC2086DFBA0083CAA8 /* AudioToggle.cpp */; }; 4B595FAE2086DFBA0083CAA8 /* AudioToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B595FAC2086DFBA0083CAA8 /* AudioToggle.cpp */; }; + 4B5B37312777C7FC0047F238 /* IPF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5B372F2777C7FC0047F238 /* IPF.cpp */; }; + 4B5B37322777C7FC0047F238 /* IPF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5B372F2777C7FC0047F238 /* IPF.cpp */; }; 4B5D5C9725F56FC7001B4623 /* Spectrum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5D5C9525F56FC7001B4623 /* Spectrum.cpp */; }; 4B5D5C9825F56FC7001B4623 /* Spectrum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5D5C9525F56FC7001B4623 /* Spectrum.cpp */; }; 4B5FADBA1DE3151600AEC565 /* FileHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5FADB81DE3151600AEC565 /* FileHolder.cpp */; }; @@ -1350,6 +1352,8 @@ 4B59199B1DAC6C46005BB85C /* OricTAP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OricTAP.hpp; sourceTree = ""; }; 4B595FAB2086DFBA0083CAA8 /* AudioToggle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AudioToggle.hpp; sourceTree = ""; }; 4B595FAC2086DFBA0083CAA8 /* AudioToggle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioToggle.cpp; sourceTree = ""; }; + 4B5B372F2777C7FC0047F238 /* IPF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IPF.cpp; sourceTree = ""; }; + 4B5B37302777C7FC0047F238 /* IPF.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IPF.hpp; sourceTree = ""; }; 4B5D5C9525F56FC7001B4623 /* Spectrum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Spectrum.cpp; path = Parsers/Spectrum.cpp; sourceTree = ""; }; 4B5D5C9625F56FC7001B4623 /* Spectrum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Spectrum.hpp; path = Parsers/Spectrum.hpp; sourceTree = ""; }; 4B5FADB81DE3151600AEC565 /* FileHolder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileHolder.cpp; sourceTree = ""; }; @@ -2788,6 +2792,7 @@ 4BEBFB4B2002C4BF000708CC /* FAT12.cpp */, 4B4518931F75FD1B00926311 /* G64.cpp */, 4B4518951F75FD1B00926311 /* HFE.cpp */, + 4B5B372F2777C7FC0047F238 /* IPF.cpp */, 4BB4BFAE22A42F290069048D /* MacintoshIMG.cpp */, 4B58601C1F806AB200AEE2E3 /* MFMSectorDump.cpp */, 4BC131782346DF2B00E4FF3D /* MSA.cpp */, @@ -2807,6 +2812,7 @@ 4BEBFB4C2002C4BF000708CC /* FAT12.hpp */, 4B4518941F75FD1B00926311 /* G64.hpp */, 4B4518961F75FD1B00926311 /* HFE.hpp */, + 4B5B37302777C7FC0047F238 /* IPF.hpp */, 4BB4BFAF22A42F290069048D /* MacintoshIMG.hpp */, 4B58601D1F806AB200AEE2E3 /* MFMSectorDump.hpp */, 4BC131792346DF2B00E4FF3D /* MSA.hpp */, @@ -5421,6 +5427,7 @@ 4BC131772346DE9100E4FF3D /* StaticAnalyser.cpp in Sources */, 4B055ACF1FAE9B030060FFFF /* SoundGenerator.cpp in Sources */, 4B4DEC08252BFA56004583AC /* 65816Base.cpp in Sources */, + 4B5B37322777C7FC0047F238 /* IPF.cpp in Sources */, 4B894519201967B4007DE474 /* ConfidenceCounter.cpp in Sources */, 4B055AEE1FAE9BBF0060FFFF /* Keyboard.cpp in Sources */, 4B055AED1FAE9BA20060FFFF /* Z80Storage.cpp in Sources */, @@ -5574,6 +5581,7 @@ 4B89451E201967B4007DE474 /* Tape.cpp in Sources */, 4BAF2B4E2004580C00480230 /* DMK.cpp in Sources */, 4BB697CE1D4BA44400248BDF /* CommodoreGCR.cpp in Sources */, + 4B5B37312777C7FC0047F238 /* IPF.cpp in Sources */, 4B0ACC3023775819008902D0 /* TIASound.cpp in Sources */, 4B7136861F78724F008B8ED9 /* Encoder.cpp in Sources */, 4B0E04EA1FC9E5DA00F43484 /* CAS.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Info.plist b/OSBindings/Mac/Clock Signal/Info.plist index c0ae89362..635d364c9 100644 --- a/OSBindings/Mac/Clock Signal/Info.plist +++ b/OSBindings/Mac/Clock Signal/Info.plist @@ -652,6 +652,26 @@ NSDocumentClass $(PRODUCT_MODULE_NAME).MachineDocument + + CFBundleTypeExtensions + + ipf + + CFBundleTypeName + Software Preservation Society Disk Image + CFBundleTypeOSTypes + + ???? + + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSTypeIsPackage + + NSDocumentClass + $(PRODUCT_MODULE_NAME).MachineDocument + CFBundleExecutable $(EXECUTABLE_NAME) diff --git a/Storage/Disk/DiskImage/Formats/IPF.cpp b/Storage/Disk/DiskImage/Formats/IPF.cpp new file mode 100644 index 000000000..44999490e --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/IPF.cpp @@ -0,0 +1,27 @@ +// +// IPF.cpp +// Clock Signal +// +// Created by Thomas Harte on 25/12/2021. +// Copyright © 2021 Thomas Harte. All rights reserved. +// + +#include "IPF.hpp" + +using namespace Storage::Disk; + + +IPF::IPF(const std::string &file_name) : file_(file_name) { +} + +HeadPosition IPF::get_maximum_head_position() { + return HeadPosition(80); // TODO; +} + +int IPF::get_head_count() { + return 2; // TODO; +} + +std::shared_ptr IPF::get_track_at_position([[maybe_unused]] Track::Address address) { + return nullptr; +} diff --git a/Storage/Disk/DiskImage/Formats/IPF.hpp b/Storage/Disk/DiskImage/Formats/IPF.hpp new file mode 100644 index 000000000..b7f08a52b --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/IPF.hpp @@ -0,0 +1,56 @@ +// +// IPF.hpp +// Clock Signal +// +// Created by Thomas Harte on 25/12/2021. +// Copyright © 2021 Thomas Harte. All rights reserved. +// + +#ifndef IPF_hpp +#define IPF_hpp + +#include "../DiskImage.hpp" +#include "../../../FileHolder.hpp" +#include "../../../TargetPlatforms.hpp" + +#include + +namespace Storage { +namespace Disk { + +/*! + Provides a @c DiskImage containing an IPF. +*/ +class IPF: public DiskImage, public TargetPlatform::TypeDistinguisher { + public: + /*! + Construct an @c IPF containing content from the file with name @c file_name. + + @throws Storage::FileHolder::Error::CantOpen if this file can't be opened. + @throws Error::InvalidFormat if the file doesn't appear to contain an .HFE format image. + @throws Error::UnknownVersion if the file looks correct but is an unsupported version. + */ + IPF(const std::string &file_name); + + // implemented to satisfy @c Disk + HeadPosition get_maximum_head_position() final; + int get_head_count() final; + std::shared_ptr get_track_at_position(Track::Address address) final; + + private: + Storage::FileHolder file_; + uint16_t seek_track(Track::Address address); + + int head_count_; + int track_count_; + + TargetPlatform::Type target_platform_type() final { + return platform_type_; + } + TargetPlatform::Type platform_type_ = TargetPlatform::Amiga; +}; + +} +} + +#endif /* IPF_hpp */