1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Renamed DiskCopy42 to MacintoshIMG, now that it's not just DiskCopy 4.2 files.

This commit is contained in:
Thomas Harte 2019-06-18 14:32:58 -04:00
parent b98f10cb45
commit 68a3e5a739
4 changed files with 33 additions and 29 deletions

View File

@ -36,7 +36,7 @@
#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/DiskCopy42.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/HFE.hpp"
@ -112,7 +112,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
Disk::DiskImageHolder<Storage::Disk::HFE>,
TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore | TargetPlatform::Oric)
// HFE (TODO: switch to AllDisk once the MSX stops being so greedy)
Format("img", result.disks, Disk::DiskImageHolder<Storage::Disk::DiskCopy42>, TargetPlatform::Macintosh) // IMG (DiskCopy 4.2)
Format("img", result.disks, Disk::DiskImageHolder<Storage::Disk::MacintoshIMG>, TargetPlatform::Macintosh) // IMG (DiskCopy 4.2)
Format("nib", result.disks, Disk::DiskImageHolder<Storage::Disk::NIB>, TargetPlatform::DiskII) // NIB
Format("o", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // O
Format("p", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P

View File

@ -591,7 +591,7 @@
4BB299F91B587D8400A49093 /* tyan in Resources */ = {isa = PBXBuildFile; fileRef = 4BB298ED1B587D8400A49093 /* tyan */; };
4BB2A9AF1E13367E001A5C23 /* CRCTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BB2A9AE1E13367E001A5C23 /* CRCTests.mm */; };
4BB4BFAD22A33DE50069048D /* DriveSpeedAccumulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4BFAC22A33DE50069048D /* DriveSpeedAccumulator.cpp */; };
4BB4BFB022A42F290069048D /* DiskCopy42.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4BFAE22A42F290069048D /* DiskCopy42.cpp */; };
4BB4BFB022A42F290069048D /* MacintoshIMG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4BFAE22A42F290069048D /* MacintoshIMG.cpp */; };
4BB4BFB922A4372F0069048D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4BFB822A4372E0069048D /* StaticAnalyser.cpp */; };
4BB4BFBA22A4372F0069048D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4BFB822A4372E0069048D /* StaticAnalyser.cpp */; };
4BB697CB1D4B6D3E00248BDF /* TimedEventLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB697C91D4B6D3E00248BDF /* TimedEventLoop.cpp */; };
@ -1351,8 +1351,8 @@
4BB4BFAA22A300710069048D /* DeferredAudio.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DeferredAudio.hpp; sourceTree = "<group>"; };
4BB4BFAB22A33D710069048D /* DriveSpeedAccumulator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DriveSpeedAccumulator.hpp; sourceTree = "<group>"; };
4BB4BFAC22A33DE50069048D /* DriveSpeedAccumulator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DriveSpeedAccumulator.cpp; sourceTree = "<group>"; };
4BB4BFAE22A42F290069048D /* DiskCopy42.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DiskCopy42.cpp; sourceTree = "<group>"; };
4BB4BFAF22A42F290069048D /* DiskCopy42.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DiskCopy42.hpp; sourceTree = "<group>"; };
4BB4BFAE22A42F290069048D /* MacintoshIMG.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MacintoshIMG.cpp; sourceTree = "<group>"; };
4BB4BFAF22A42F290069048D /* MacintoshIMG.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MacintoshIMG.hpp; sourceTree = "<group>"; };
4BB4BFB722A4372E0069048D /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StaticAnalyser.hpp; sourceTree = "<group>"; };
4BB4BFB822A4372E0069048D /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticAnalyser.cpp; sourceTree = "<group>"; };
4BB697C61D4B558F00248BDF /* Factors.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Factors.hpp; path = ../../NumberTheory/Factors.hpp; sourceTree = "<group>"; };
@ -1964,7 +1964,7 @@
4B0333AD2094081A0050B93D /* AppleDSK.cpp */,
4B45188F1F75FD1B00926311 /* CPCDSK.cpp */,
4B4518911F75FD1B00926311 /* D64.cpp */,
4BB4BFAE22A42F290069048D /* DiskCopy42.cpp */,
4BB4BFAE22A42F290069048D /* MacintoshIMG.cpp */,
4BAF2B4C2004580C00480230 /* DMK.cpp */,
4B4518931F75FD1B00926311 /* G64.cpp */,
4B4518951F75FD1B00926311 /* HFE.cpp */,
@ -1979,7 +1979,7 @@
4B0333AE2094081A0050B93D /* AppleDSK.hpp */,
4B4518901F75FD1B00926311 /* CPCDSK.hpp */,
4B4518921F75FD1B00926311 /* D64.hpp */,
4BB4BFAF22A42F290069048D /* DiskCopy42.hpp */,
4BB4BFAF22A42F290069048D /* MacintoshIMG.hpp */,
4BAF2B4D2004580C00480230 /* DMK.hpp */,
4B4518941F75FD1B00926311 /* G64.hpp */,
4B4518961F75FD1B00926311 /* HFE.hpp */,
@ -4015,7 +4015,7 @@
4B595FAD2086DFBA0083CAA8 /* AudioToggle.cpp in Sources */,
4B1497921EE4B5A800CE2596 /* ZX8081.cpp in Sources */,
4B643F3F1D77B88000D431D6 /* DocumentController.swift in Sources */,
4BB4BFB022A42F290069048D /* DiskCopy42.cpp in Sources */,
4BB4BFB022A42F290069048D /* MacintoshIMG.cpp in Sources */,
4B05401E219D1618001BF69C /* ScanTarget.cpp in Sources */,
4B4518861F75E91A00926311 /* MFMDiskController.cpp in Sources */,
4B54C0BF1F8D8F450050900F /* Keyboard.cpp in Sources */,

View File

@ -6,7 +6,7 @@
// Copyright © 2019 Thomas Harte. All rights reserved.
//
#include "DiskCopy42.hpp"
#include "MacintoshIMG.hpp"
#include "../../Track/PCMTrack.hpp"
#include "../../Encodings/AppleGCR/Encoder.hpp"
@ -19,7 +19,7 @@
using namespace Storage::Disk;
DiskCopy42::DiskCopy42(const std::string &file_name) :
MacintoshIMG::MacintoshIMG(const std::string &file_name) :
file_(file_name) {
// Test 1: is this a raw secctor dump? If so it'll start with
@ -29,13 +29,6 @@ DiskCopy42::DiskCopy42(const std::string &file_name) :
//
// Luckily, 0x4c is an invalid string length for the proper
// DiskCopy 4.2 format, so there's no ambiguity here.
// File format starts with 64 bytes dedicated to the disk name;
// this is a Pascal-style string though there is apparently a
// bug in one version of Disk Copy that can cause the length to
// be one too high.
//
// Validate the length, then skip the rest of the string.
const auto name_length = file_.get8();
if(name_length == 0x4c) {
if(file_.stats().st_size != 819200 && file_.stats().st_size != 409600)
@ -56,6 +49,14 @@ DiskCopy42::DiskCopy42(const std::string &file_name) :
data_ = file_.read(409600);
}
} else {
// DiskCopy 4.2 it is then:
//
// File format starts with 64 bytes dedicated to the disk name;
// this is a Pascal-style string though there is apparently a
// bug in one version of Disk Copy that can cause the length to
// be one too high.
//
// Validate the length, then skip the rest of the string.
if(name_length > 64)
throw Error::InvalidFormat;
@ -104,7 +105,7 @@ DiskCopy42::DiskCopy42(const std::string &file_name) :
}
}
uint32_t DiskCopy42::checksum(const std::vector<uint8_t> &data, size_t bytes_to_skip) {
uint32_t MacintoshIMG::checksum(const std::vector<uint8_t> &data, size_t bytes_to_skip) {
uint32_t result = 0;
// Checksum algorith is: take each two bytes as a big-endian word; add that to a
@ -118,21 +119,21 @@ uint32_t DiskCopy42::checksum(const std::vector<uint8_t> &data, size_t bytes_to_
return result;
}
HeadPosition DiskCopy42::get_maximum_head_position() {
HeadPosition MacintoshIMG::get_maximum_head_position() {
return HeadPosition(80);
}
int DiskCopy42::get_head_count() {
int MacintoshIMG::get_head_count() {
// Bit 5 in the format field indicates whether this disk is double
// sided, regardless of whether it is GCR or MFM.
return 1 + ((format_ & 0x20) >> 5);
}
bool DiskCopy42::get_is_read_only() {
bool MacintoshIMG::get_is_read_only() {
return true;
}
std::shared_ptr<::Storage::Disk::Track> DiskCopy42::get_track_at_position(::Storage::Disk::Track::Address address) {
std::shared_ptr<::Storage::Disk::Track> MacintoshIMG::get_track_at_position(::Storage::Disk::Track::Address address) {
/*
The format_ byte has the following meanings:

View File

@ -1,13 +1,13 @@
//
// DiskCopy42.hpp
// MacintoshIMG.hpp
// Clock Signal
//
// Created by Thomas Harte on 02/06/2019.
// Copyright © 2019 Thomas Harte. All rights reserved.
//
#ifndef DiskCopy42_hpp
#define DiskCopy42_hpp
#ifndef MacintoshIMG_hpp
#define MacintoshIMG_hpp
#include "../DiskImage.hpp"
#include "../../../FileHolder.hpp"
@ -16,17 +16,20 @@ namespace Storage {
namespace Disk {
/*!
Provides a @c DiskImage containing a disk imaged by Apple's Disk Copy 4.2: sector contents
(plus tag data) in either an Apple GCR or standard MFM encoding.
Provides a @c DiskImage containing either:
* a disk imaged by Apple's Disk Copy 4.2: sector contents (optionally plus tag data),
in either an Apple GCR or standard MFM encoding; or
* a raw sector dump of a Macintosh GCR disk.
*/
class DiskCopy42: public DiskImage {
class MacintoshIMG: public DiskImage {
public:
/*!
Construct a @c DiskCopy42 containing content from the file with name @c file_name.
@throws Error::InvalidFormat if this file doesn't appear to be in Disk Copy 4.2 format.
*/
DiskCopy42(const std::string &file_name);
MacintoshIMG(const std::string &file_name);
// implemented to satisfy @c Disk
HeadPosition get_maximum_head_position() override;