From a9d4fe0b41b2bcde5b7c36e289461824908f7ccd Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 29 Apr 2018 16:34:10 -0400 Subject: [PATCH] Introduces filetype wiring for DO and PO files. Also corrects sector numbering logic to ensure there is a sector 15. --- Analyser/Static/StaticAnalyser.cpp | 2 ++ OSBindings/Mac/Clock Signal/Info.plist | 3 ++- Storage/Disk/DiskImage/Formats/AppleDSK.cpp | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index 7d85ac366..b822bc76c 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -94,6 +94,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: Format("csw", result.tapes, Tape::CSW, TargetPlatform::AllTape) // CSW Format("d64", result.disks, Disk::DiskImageHolder, TargetPlatform::Commodore) // D64 Format("dmk", result.disks, Disk::DiskImageHolder, TargetPlatform::MSX) // DMK + Format("do", result.disks, Disk::DiskImageHolder, TargetPlatform::AppleII) // DO Format("dsd", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // DSD Format("dsk", result.disks, Disk::DiskImageHolder, TargetPlatform::AmstradCPC) // DSK (Amstrad CPC) Format("dsk", result.disks, Disk::DiskImageHolder, TargetPlatform::AppleII) // DSK (Apple) @@ -108,6 +109,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform:: 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("po", result.disks, Disk::DiskImageHolder, TargetPlatform::AppleII) // PO Format("p81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // P81 // PRG diff --git a/OSBindings/Mac/Clock Signal/Info.plist b/OSBindings/Mac/Clock Signal/Info.plist index 11051c044..dfa0820d8 100644 --- a/OSBindings/Mac/Clock Signal/Info.plist +++ b/OSBindings/Mac/Clock Signal/Info.plist @@ -398,6 +398,8 @@ nib woz + do + po CFBundleTypeIconFile floppy525 @@ -408,7 +410,6 @@ LSItemContentTypes public.item - nl.xs4all.gp.virtualii.nibdisk LSTypeIsPackage 0 diff --git a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp index 5915f56cd..fe9521365 100644 --- a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp +++ b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp @@ -24,6 +24,18 @@ AppleDSK::AppleDSK(const std::string &file_name) : sectors_per_track_ = static_cast(file_.stats().st_size / (number_of_tracks*bytes_per_sector)); if(sectors_per_track_ != 13 && sectors_per_track_ != 16) throw Error::InvalidFormat; + + // Check whether this is a Pro DOS disk by inspecting the filename. + if(sectors_per_track_ == 16) { + size_t string_index = file_name.size()-1; + while(file_name[string_index] != '.') { + if(file_name[string_index] == 'p') { + is_prodos_ = true; + break; + } + --string_index; + } + } } int AppleDSK::get_head_position_count() { @@ -51,7 +63,8 @@ std::shared_ptr AppleDSK::get_track_at_position(Track::Address address) { // DOS and Pro DOS interleave sectors on disk, and they're represented in a disk // image in physical order rather than logical. So that skew needs to be applied here. - sector_number_ = (sector_number_ + (is_prodos_ ? 8 : 7)) % 15; + sector_number_ += is_prodos_ ? 8 : 7; + if(sector_number_ > 0xf) sector_number_ %= 15; } // Pad if necessary.