fadden / CiderPress2

Tool for working with Apple II and vintage Mac disk images and file archives.
https://ciderpress2.com/
Apache License 2.0
44 stars 7 forks source link

Unable to create 3.5" disk images with .img or .dsk file extensions. #6

Closed NJRoadfan closed 8 months ago

NJRoadfan commented 8 months ago

As reported here: https://68kmla.org/bb/index.php?threads/have-you-seen-ciderpress-2-mac-and-more-disk-image-can-opener.46146/

CiderPress2's type checking is a bit restrictive when trying to create a new disk image with certain file extensions.

-.DSK: This one seems to make sense as it is indeed ambiguous, but some emulators (software and hardware) use this extension for disk images.

-.IMG: This appears to be a logic error looking at the code. Sector ordering should not be enforced for images that are not 140k 5.25" disk. As before, .IMG is a popular extension with many emulators. If an image is larger then 140k, assume it is sector ordered and don't check for ProDOS vs. DOS 3.3 ordering.

fadden commented 8 months ago

Hello!

Let me start by saying that I'm more familiar with Apple II emulators than Mac emulators, so I'm not clear on the filename conventions.

In the Apple II world, ".dsk" usually means ".do", but sometimes means ".po". The result is that anything that wants to handle ".dsk" needs to assume it's one thing, or scan it to try to figure out what it is. That's only an issue for 5.25" disk images though; for 3.5" disk images, it's always straight block order. I've been rejecting ".dsk" as an extension because of the potential ambiguity, but there's no reason to do so for 800KB floppy images.

(FWIW, 80-track 16-sector DOS images are 320KB, so I need to worry about sector ordering up to that point. 50-track 32-sector DOS images are 400KB but sector ordering isn't an issue for those, so I should be safe using 400KB as a threshold.)

In the Apple II world, ".img" was used for weird 5.25" images created by one specific version of Copy ][+ on the Apple II. Nobody uses them. I handle them because supporting weird formats used by 0.001% of disk images is my hobby. The code that opens files and the code that creates files share a "switch" statement (here), and the primary definition specified "physical" sector order for an 800KB disk image, which confused the image creator.

https://github.com/fadden/CiderPress2/blob/main/docs/Manual-cp2.md#filename-extensions lists the extensions and how they're currently handled. ".img" isn't currently in the list.

The code that opens disk images accepts both ".dsk" and ".img" as potential names for DiskCopy 4.2 images. For creation you could use ".image" or ".dc", which I've seen more of than ".img", but mostly I've been looking at CD-ROMs with disk images (which often just use dCpy with no particular extension).

We're pre-alpha (for another few days... almost there), so changing the behavior isn't going to break anything. My question to you is: what do you think the results of cp2 cdi foo.dsk 800k hfs and cp2 cdi foo.img 800k hfs should be? ".dsk" = straight block order, ".img" = DiskCopy 4.2?

NJRoadfan commented 8 months ago

Macintosh emulators are a bit more loose with disk image formats and file name extensions. The FloppyEmu with Macintosh firmware supports both DiskCopy 4.2 and raw block images. DiskCopy support came later. Basilisk II and Mini vMac generally supports raw block images for both floppy and hard disks although some forks (and other emulators) support hard disk images with partition maps. These commonly use the .dsk and .img extension with no indication of what they actually are.

fadden commented 8 months ago

There are two separate but related issues: (1) what can .dsk/.img be, and (2) what should be created when you ask for "newthing.dsk" and "newthing.img". I'm trying to avoid taking a "--format=diskcopy" sort of argument, which means the filename extension needs to specify exactly one thing to the create-disk-image command.

The code that opens files is easier to be flexible with, especially for something like DC42 which has a recognizable header.

In concrete terms: when you typed cp2 create-disk-image testdisk.img 800K hfs, what was your expectation? If you got a DiskCopy 4.2 image file, would you be satisfied, disappointed, or confused? I'm thinking it might make sense to handle ".img" this way, but if it's fully interchangeable with ".dsk" then there's no real need.

fadden commented 8 months ago

This now creates a simple block image: cp2 cdi testimage.dsk 800k hfs This now fails with an "is ambiguous" message: cp2 cdi testimage.img 800k hfs