From 7cb16a3fc5742246039868be7dde65f201896559 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 16 Jul 2021 18:11:07 -0400 Subject: [PATCH] Introduces a shell for Amiga ADF decoding. --- Analyser/Static/StaticAnalyser.cpp | 4 +- .../Clock Signal.xcodeproj/project.pbxproj | 8 ++++ Storage/Disk/DiskImage/Formats/AmigaADF.cpp | 38 +++++++++++++++ Storage/Disk/DiskImage/Formats/AmigaADF.hpp | 47 +++++++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 Storage/Disk/DiskImage/Formats/AmigaADF.cpp create mode 100644 Storage/Disk/DiskImage/Formats/AmigaADF.hpp diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index 7f88415d2..0dc00fe8e 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -38,6 +38,7 @@ // Disks #include "../../Storage/Disk/DiskImage/Formats/2MG.hpp" #include "../../Storage/Disk/DiskImage/Formats/AcornADF.hpp" +#include "../../Storage/Disk/DiskImage/Formats/AmigaADF.hpp" #include "../../Storage/Disk/DiskImage/Formats/AppleDSK.hpp" #include "../../Storage/Disk/DiskImage/Formats/CPCDSK.hpp" #include "../../Storage/Disk/DiskImage/Formats/D64.hpp" @@ -128,7 +129,8 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: Format("80", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 80 Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81 Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26 - Format("adf", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // ADF + Format("adf", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // ADF (Acorn) + Format("adf", result.disks, Disk::DiskImageHolder, TargetPlatform::Amiga) // ADF (Amiga) Format("adl", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // ADL Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN (cartridge dump) Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 1a434a410..88fc727c7 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -890,6 +890,8 @@ 4BBFBB6C1EE8401E00C01E7A /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFBB6A1EE8401E00C01E7A /* ZX8081.cpp */; }; 4BBFE83D21015D9C00BF1C40 /* CSJoystickManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFE83C21015D9C00BF1C40 /* CSJoystickManager.m */; }; 4BBFFEE61F7B27F1005F3FEB /* TrackSerialiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFFEE51F7B27F1005F3FEB /* TrackSerialiser.cpp */; }; + 4BC080CA26A238CC00D03FD8 /* AmigaADF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC080C826A238CC00D03FD8 /* AmigaADF.cpp */; }; + 4BC080CB26A238CC00D03FD8 /* AmigaADF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC080C826A238CC00D03FD8 /* AmigaADF.cpp */; }; 4BC0CB282446BC7B00A79DBB /* OPLTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BC0CB272446BC7B00A79DBB /* OPLTests.mm */; }; 4BC131702346DE5000E4FF3D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC1316F2346DE5000E4FF3D /* StaticAnalyser.cpp */; }; 4BC131712346DE5000E4FF3D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC1316F2346DE5000E4FF3D /* StaticAnalyser.cpp */; }; @@ -1907,6 +1909,8 @@ 4BBFE83C21015D9C00BF1C40 /* CSJoystickManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSJoystickManager.m; sourceTree = ""; }; 4BBFE83E21015DAE00BF1C40 /* CSJoystickManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSJoystickManager.h; sourceTree = ""; }; 4BBFFEE51F7B27F1005F3FEB /* TrackSerialiser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TrackSerialiser.cpp; sourceTree = ""; }; + 4BC080C826A238CC00D03FD8 /* AmigaADF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AmigaADF.cpp; sourceTree = ""; }; + 4BC080C926A238CC00D03FD8 /* AmigaADF.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AmigaADF.hpp; sourceTree = ""; }; 4BC0CB272446BC7B00A79DBB /* OPLTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OPLTests.mm; sourceTree = ""; }; 4BC1316D2346DE5000E4FF3D /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StaticAnalyser.hpp; sourceTree = ""; }; 4BC1316E2346DE5000E4FF3D /* Target.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Target.hpp; sourceTree = ""; }; @@ -2719,6 +2723,7 @@ children = ( 4B80CD74256CA15E00176FCC /* 2MG.cpp */, 4B45188D1F75FD1B00926311 /* AcornADF.cpp */, + 4BC080C826A238CC00D03FD8 /* AmigaADF.cpp */, 4B0333AD2094081A0050B93D /* AppleDSK.cpp */, 4B45188F1F75FD1B00926311 /* CPCDSK.cpp */, 4B4518911F75FD1B00926311 /* D64.cpp */, @@ -2737,6 +2742,7 @@ 4B6ED2EE208E2F8A0047B343 /* WOZ.cpp */, 4B80CD75256CA15E00176FCC /* 2MG.hpp */, 4B45188E1F75FD1B00926311 /* AcornADF.hpp */, + 4BC080C926A238CC00D03FD8 /* AmigaADF.hpp */, 4B0333AE2094081A0050B93D /* AppleDSK.hpp */, 4B4518901F75FD1B00926311 /* CPCDSK.hpp */, 4B4518921F75FD1B00926311 /* D64.hpp */, @@ -5273,6 +5279,7 @@ 4B6AAEAC230E40250078E864 /* SCSI.cpp in Sources */, 4B055A981FAE85C50060FFFF /* Drive.cpp in Sources */, 4BD424E62193B5830097291A /* Shader.cpp in Sources */, + 4BC080CB26A238CC00D03FD8 /* AmigaADF.cpp in Sources */, 4B4B1A3D200198CA00A0F866 /* KonamiSCC.cpp in Sources */, 4B055AC31FAE9AE80060FFFF /* AmstradCPC.cpp in Sources */, 4B055A9E1FAE85DA0060FFFF /* G64.cpp in Sources */, @@ -5482,6 +5489,7 @@ 4B05401E219D1618001BF69C /* ScanTarget.cpp in Sources */, 4B4518861F75E91A00926311 /* MFMDiskController.cpp in Sources */, 4B0ACC2C23775819008902D0 /* IntelligentKeyboard.cpp in Sources */, + 4BC080CA26A238CC00D03FD8 /* AmigaADF.cpp in Sources */, 4B92E26A234AE35100CD6D1B /* MFP68901.cpp in Sources */, 4B051C97266EF5F600CA44E8 /* CSAppleII.mm in Sources */, 4B0ACC2A23775819008902D0 /* Video.cpp in Sources */, diff --git a/Storage/Disk/DiskImage/Formats/AmigaADF.cpp b/Storage/Disk/DiskImage/Formats/AmigaADF.cpp new file mode 100644 index 000000000..82c91506c --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/AmigaADF.cpp @@ -0,0 +1,38 @@ +// +// AmigaADF.cpp +// Clock Signal +// +// Created by Thomas Harte on 16/07/2021. +// Copyright © 2021 Thomas Harte. All rights reserved. +// + +#include "AmigaADF.hpp" + + +using namespace Storage::Disk; + +AmigaADF::AmigaADF(const std::string &file_name) : + file_(file_name) { + // Dumb validation only for now: a size check. + if(file_.stats().st_size != 901120) throw Error::InvalidFormat; +} + +HeadPosition AmigaADF::get_maximum_head_position() { + return HeadPosition(80); +} + +int AmigaADF::get_head_count() { + return 2; +} + +std::shared_ptr AmigaADF::get_track_at_position(Track::Address address) { + file_.seek(get_file_offset_for_position(address), SEEK_SET); + + // TODO. + + return nullptr; +} + +long AmigaADF::get_file_offset_for_position(Track::Address address) { + return (address.position.as_int() * 2 + address.head) * 512 * 11; +} diff --git a/Storage/Disk/DiskImage/Formats/AmigaADF.hpp b/Storage/Disk/DiskImage/Formats/AmigaADF.hpp new file mode 100644 index 000000000..79a9ec6b3 --- /dev/null +++ b/Storage/Disk/DiskImage/Formats/AmigaADF.hpp @@ -0,0 +1,47 @@ +// +// AmigaADF.hpp +// Clock Signal +// +// Created by Thomas Harte on 16/07/2021. +// Copyright © 2021 Thomas Harte. All rights reserved. +// + +#ifndef AmigaADF_hpp +#define AmigaADF_hpp + +#include "MFMSectorDump.hpp" + +#include + +namespace Storage { +namespace Disk { + +/*! + Provides a @c DiskImage containing an Amiga ADF, which is an MFM sector contents dump, + but the Amiga doesn't use IBM-style sector demarcation. +*/ +class AmigaADF: public DiskImage { + public: + /*! + Construct an @c AmigaADF 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 .ADF format image. + */ + AmigaADF(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_; + long get_file_offset_for_position(Track::Address address); + +}; + +} +} + +#endif /* AmigaADF_hpp */