From 6592745e53f065c8dee82a20c5f7dd2c4dfd34e1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 21 Apr 2018 21:21:57 -0700 Subject: [PATCH] Adds the bare minimum to respond to attempts to open NIB files with an Apple II. --- Analyser/Static/AppleII/StaticAnalyser.cpp | 9 +++- Analyser/Static/AppleII/Target.hpp | 26 +++++++++++ Analyser/Static/StaticAnalyser.cpp | 2 + Machines/AppleII/AppleII.cpp | 10 ++++ .../Clock Signal.xcodeproj/project.pbxproj | 10 ++++ OSBindings/Mac/Clock Signal/Info.plist | 21 +++++++++ Storage/Disk/DiskImage/Formats/DMK.hpp | 2 +- Storage/Disk/DiskImage/Formats/MSXDSK.hpp | 2 +- Storage/Disk/DiskImage/Formats/NIB.cpp | 44 ++++++++++++++++++ Storage/Disk/DiskImage/Formats/NIB.hpp | 46 +++++++++++++++++++ 10 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 Analyser/Static/AppleII/Target.hpp create mode 100644 Storage/Disk/DiskImage/Formats/NIB.cpp create mode 100644 Storage/Disk/DiskImage/Formats/NIB.hpp diff --git a/Analyser/Static/AppleII/StaticAnalyser.cpp b/Analyser/Static/AppleII/StaticAnalyser.cpp index c2996bbee..c12292336 100644 --- a/Analyser/Static/AppleII/StaticAnalyser.cpp +++ b/Analyser/Static/AppleII/StaticAnalyser.cpp @@ -7,7 +7,14 @@ // #include "StaticAnalyser.hpp" +#include "Target.hpp" Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) { - return TargetList(); + auto target = std::unique_ptr(new Target); + target->machine = Machine::AppleII; + target->media = media; + + TargetList targets; + targets.push_back(std::move(target)); + return targets; } diff --git a/Analyser/Static/AppleII/Target.hpp b/Analyser/Static/AppleII/Target.hpp new file mode 100644 index 000000000..0f47d3a62 --- /dev/null +++ b/Analyser/Static/AppleII/Target.hpp @@ -0,0 +1,26 @@ +// +// Target.hpp +// Clock Signal +// +// Created by Thomas Harte on 21/04/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#ifndef Target_h +#define Target_h + +#include "../StaticAnalyser.hpp" + +namespace Analyser { +namespace Static { +namespace AppleII { + +struct Target: public ::Analyser::Static::Target { + // TODO: probably some Disk II options here? +}; + +} +} +} + +#endif /* Target_h */ diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index c4ae7a7be..2ca13cac9 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -36,6 +36,7 @@ #include "../../Storage/Disk/DiskImage/Formats/DMK.hpp" #include "../../Storage/Disk/DiskImage/Formats/HFE.hpp" #include "../../Storage/Disk/DiskImage/Formats/MSXDSK.hpp" +#include "../../Storage/Disk/DiskImage/Formats/NIB.hpp" #include "../../Storage/Disk/DiskImage/Formats/OricMFMDSK.hpp" #include "../../Storage/Disk/DiskImage/Formats/SSD.hpp" @@ -101,6 +102,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: Disk::DiskImageHolder, TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore | TargetPlatform::Oric) // HFE (TODO: switch to AllDisk once the MSX stops being so greedy) + Format("nib", result.disks, Disk::DiskImageHolder, TargetPlatform::AppleII) // NIB Format("o", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // O Format("p", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81 diff --git a/Machines/AppleII/AppleII.cpp b/Machines/AppleII/AppleII.cpp index fda5dd81c..f66fea105 100644 --- a/Machines/AppleII/AppleII.cpp +++ b/Machines/AppleII/AppleII.cpp @@ -8,6 +8,7 @@ #include "AppleII.hpp" +#include "../ConfigurationTarget.hpp" #include "../CRTMachine.hpp" #include "../KeyboardMachine.hpp" #include "../Utility/MemoryFuzzer.hpp" @@ -25,6 +26,7 @@ namespace { class ConcreteMachine: public CRTMachine::Machine, + public ConfigurationTarget::Machine, public KeyboardMachine::Machine, public CPU::MOS6502::BusHandler, public Inputs::Keyboard, @@ -218,6 +220,14 @@ class ConcreteMachine: Inputs::Keyboard &get_keyboard() override { return *this; } + + // MARK: ConfigurationTarget + void configure_as_target(const Analyser::Static::Target *target) override { + } + + bool insert_media(const Analyser::Static::Media &media) override { + return true; + } }; } diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 18ab9f86b..2905d456e 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -120,6 +120,8 @@ 4B0E04FA1FC9FA3100F43484 /* 9918.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0E04F91FC9FA3100F43484 /* 9918.cpp */; }; 4B0E04FB1FC9FA3100F43484 /* 9918.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0E04F91FC9FA3100F43484 /* 9918.cpp */; }; 4B0E61071FF34737002A9DBD /* MSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0E61051FF34737002A9DBD /* MSX.cpp */; }; + 4B0F94FE208C1A1600FE41D9 /* NIB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0F94FC208C1A1600FE41D9 /* NIB.cpp */; }; + 4B0F94FF208C1A1600FE41D9 /* NIB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0F94FC208C1A1600FE41D9 /* NIB.cpp */; }; 4B121F951E05E66800BFDA12 /* PCMPatchedTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B121F941E05E66800BFDA12 /* PCMPatchedTrackTests.mm */; }; 4B121F9B1E06293F00BFDA12 /* PCMSegmentEventSourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B121F9A1E06293F00BFDA12 /* PCMSegmentEventSourceTests.mm */; }; 4B12C0ED1FCFA98D005BFD93 /* Keyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B12C0EB1FCFA98D005BFD93 /* Keyboard.cpp */; }; @@ -697,6 +699,9 @@ 4B0E04F91FC9FA3100F43484 /* 9918.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = 9918.cpp; path = 9918/9918.cpp; sourceTree = ""; }; 4B0E61051FF34737002A9DBD /* MSX.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = MSX.cpp; path = Parsers/MSX.cpp; sourceTree = ""; }; 4B0E61061FF34737002A9DBD /* MSX.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = MSX.hpp; path = Parsers/MSX.hpp; sourceTree = ""; }; + 4B0F94FC208C1A1600FE41D9 /* NIB.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NIB.cpp; sourceTree = ""; }; + 4B0F94FD208C1A1600FE41D9 /* NIB.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = NIB.hpp; sourceTree = ""; }; + 4B0F9500208C42A300FE41D9 /* Target.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Target.hpp; path = AppleII/Target.hpp; sourceTree = ""; }; 4B121F941E05E66800BFDA12 /* PCMPatchedTrackTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMPatchedTrackTests.mm; sourceTree = ""; }; 4B121F9A1E06293F00BFDA12 /* PCMSegmentEventSourceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMSegmentEventSourceTests.mm; sourceTree = ""; }; 4B12C0EB1FCFA98D005BFD93 /* Keyboard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Keyboard.cpp; path = MSX/Keyboard.cpp; sourceTree = ""; }; @@ -1534,6 +1539,7 @@ children = ( 4B15A9FA208249BB005E6C8D /* StaticAnalyser.cpp */, 4B15A9FB208249BB005E6C8D /* StaticAnalyser.hpp */, + 4B0F9500208C42A300FE41D9 /* Target.hpp */, ); name = AppleII; sourceTree = ""; @@ -1858,6 +1864,7 @@ 4B4518951F75FD1B00926311 /* HFE.cpp */, 4B58601C1F806AB200AEE2E3 /* MFMSectorDump.cpp */, 4BEBFB4B2002C4BF000708CC /* MSXDSK.cpp */, + 4B0F94FC208C1A1600FE41D9 /* NIB.cpp */, 4B4518971F75FD1B00926311 /* OricMFMDSK.cpp */, 4B4518991F75FD1B00926311 /* SSD.cpp */, 4B45188E1F75FD1B00926311 /* AcornADF.hpp */, @@ -1868,6 +1875,7 @@ 4B4518961F75FD1B00926311 /* HFE.hpp */, 4B58601D1F806AB200AEE2E3 /* MFMSectorDump.hpp */, 4BEBFB4C2002C4BF000708CC /* MSXDSK.hpp */, + 4B0F94FD208C1A1600FE41D9 /* NIB.hpp */, 4B4518981F75FD1B00926311 /* OricMFMDSK.hpp */, 4B45189A1F75FD1B00926311 /* SSD.hpp */, 4BFDD7891F7F2DB4008579B9 /* Utility */, @@ -3638,6 +3646,7 @@ 4B055AE71FAE9B6F0060FFFF /* Shader.cpp in Sources */, 4B894523201967B4007DE474 /* StaticAnalyser.cpp in Sources */, 4B055AEC1FAE9BA20060FFFF /* Z80Base.cpp in Sources */, + 4B0F94FF208C1A1600FE41D9 /* NIB.cpp in Sources */, 4B0E04EB1FC9E78800F43484 /* CAS.cpp in Sources */, 4B055AE31FAE9B6F0060FFFF /* TextureBuilder.cpp in Sources */, 4BB0A65D2045009000FB3688 /* ColecoVision.cpp in Sources */, @@ -3740,6 +3749,7 @@ 4B4518851F75E91A00926311 /* DiskController.cpp in Sources */, 4B8334841F5DA0360097E338 /* Z80Storage.cpp in Sources */, 4BA61EB01D91515900B3C876 /* NSData+StdVector.mm in Sources */, + 4B0F94FE208C1A1600FE41D9 /* NIB.cpp in Sources */, 4B89452A201967B4007DE474 /* File.cpp in Sources */, 4B4DC8211D2C2425003C5BF8 /* Vic20.cpp in Sources */, 4B71368E1F788112008B8ED9 /* Parser.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Info.plist b/OSBindings/Mac/Clock Signal/Info.plist index 12a8aee31..d3a56a987 100644 --- a/OSBindings/Mac/Clock Signal/Info.plist +++ b/OSBindings/Mac/Clock Signal/Info.plist @@ -393,6 +393,27 @@ NSDocumentClass $(PRODUCT_MODULE_NAME).MachineDocument + + CFBundleTypeExtensions + + nib + + CFBundleTypeIconFile + floppy525 + CFBundleTypeName + Apple II Disk Image + CFBundleTypeRole + Viewer + LSItemContentTypes + + public.item + nl.xs4all.gp.virtualii.nibdisk + + LSTypeIsPackage + 0 + NSDocumentClass + $(PRODUCT_MODULE_NAME).MachineDocument + CFBundleExecutable $(EXECUTABLE_NAME) diff --git a/Storage/Disk/DiskImage/Formats/DMK.hpp b/Storage/Disk/DiskImage/Formats/DMK.hpp index e0b616829..6be4eaed4 100644 --- a/Storage/Disk/DiskImage/Formats/DMK.hpp +++ b/Storage/Disk/DiskImage/Formats/DMK.hpp @@ -18,7 +18,7 @@ namespace Storage { namespace Disk { /*! - Provides a @c Disk containing a DMK disk image — mostly a decoded byte stream, but with + Provides a @c DiskImage containing a DMK disk image — mostly a decoded byte stream, but with a record of IDAM locations. */ class DMK: public DiskImage { diff --git a/Storage/Disk/DiskImage/Formats/MSXDSK.hpp b/Storage/Disk/DiskImage/Formats/MSXDSK.hpp index 0b6fba53c..8bf8936c1 100644 --- a/Storage/Disk/DiskImage/Formats/MSXDSK.hpp +++ b/Storage/Disk/DiskImage/Formats/MSXDSK.hpp @@ -17,7 +17,7 @@ namespace Storage { namespace Disk { /*! - Provides a @c Disk containing an MSX-style disk image: + Provides a @c DiskImage descriging an MSX-style disk image: a sector dump of appropriate proportions. */ class MSXDSK: public MFMSectorDump { diff --git a/Storage/Disk/DiskImage/Formats/NIB.cpp b/Storage/Disk/DiskImage/Formats/NIB.cpp new file mode 100644 index 000000000..015816cfb --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/NIB.cpp @@ -0,0 +1,44 @@ +// +// NIB.cpp +// Clock Signal +// +// Created by Thomas Harte on 21/04/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#include "NIB.hpp" + +using namespace Storage::Disk; + +namespace { + +const std::size_t track_length = 6656; +const std::size_t number_of_tracks = 35; + +} + +NIB::NIB(const std::string &file_name) : + file_(file_name) { + // A NIB should be 35 tracks, each 6656 bytes long. + if(file_.stats().st_size != track_length*number_of_tracks) { + throw ErrorNotNIB; + } + + // TODO: all other validation. +} + +int NIB::get_head_position_count() { + return 35; +} + +int NIB::get_head_count() { + return 1; +} + +bool NIB::get_is_read_only() { + return true; +} + +std::shared_ptr<::Storage::Disk::Track> NIB::get_track_at_position(::Storage::Disk::Track::Address address) { + return nullptr; +} diff --git a/Storage/Disk/DiskImage/Formats/NIB.hpp b/Storage/Disk/DiskImage/Formats/NIB.hpp new file mode 100644 index 000000000..b1113f7e0 --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/NIB.hpp @@ -0,0 +1,46 @@ +// +// NIB.hpp +// Clock Signal +// +// Created by Thomas Harte on 21/04/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#ifndef NIB_hpp +#define NIB_hpp + +#include "../DiskImage.hpp" +#include "../../../FileHolder.hpp" + +namespace Storage { +namespace Disk { + +/*! + Provides a @c DiskImage describing an Apple NIB disk image: + mostly a bit stream capture, but syncs are implicitly packed + into 8 bits instead of 9. +*/ +class NIB: public DiskImage { + public: + NIB(const std::string &file_name); + + enum { + ErrorNotNIB, + }; + + int get_head_position_count() override; + int get_head_count() override; + bool get_is_read_only() override; + + std::shared_ptr<::Storage::Disk::Track> get_track_at_position(::Storage::Disk::Track::Address address) override; + + private: + FileHolder file_; + long get_file_offset_for_position(Track::Address address); + +}; + +} +} + +#endif /* NIB_hpp */