TomHarte / CLK

A latency-hating emulator of: the Acorn Electron and Archimedes, Amstrad CPC, Apple II/II+/IIe and early Macintosh, Atari 2600 and ST, ColecoVision, Enterprise 64/128, Commodore Vic-20 and Amiga, MSX 1/2, Oric 1/Atmos, early PC compatibles, Sega Master System, Sinclair ZX80/81 and ZX Spectrum.
MIT License
930 stars 52 forks source link

Macintosh #768

Open mbrethen opened 4 years ago

mbrethen commented 4 years ago

Tom,

Question: What file format does CLK accept for macintosh emulation? I assumed this needed to be a bootable disk, but it would not open apple's 6.0.8 Startup Disk image. Btw, which System version works best?

TomHarte commented 4 years ago

That's most likely a bug — I use 6.0.8 myself. For floppies it is supposed to accept either plain disk images or Disk Copy 4.2 images, and for hard disks it expects to receive a raw image of just the HFS partition, to which it will automatically prefix the other things that are usually physically on a hard disk.

If there's a specific image you can point me to, I can check that one further.

Otherwise, 6.0.8 is probably the best bet. My barely-filled-in emulation of the serial chip currently causes System 7 to pause forever during startup while trying to AppleTalk. That's #691 and is something I definitely intend to work on in the coming weeks as System 7 support would open up a much wider pool of applications.

I also have in my head that I should allow the user to specify once a fallback boot disk which the emulator could take a copy of, and then automatically insert into the second drive if you open a disk that isn't bootable. That's not ticketed, but I think it'd be a good idea.

TomHarte commented 4 years ago

Oh, addendum! I checked out the disk images at archive.org — https://archive.org/details/mac_MacOS_6.0.8 — and could the issue be that you have high-density disk images? At the minute I support only the Macintosh 512ke and Plus, neither of which supports high-density floppies. If your images are larger than 800kb then that could be the problem; the emulator will gamely try to treat the 1.4mb image as a really small hard disk, but with limited success.

Offhand, I think the SE is both the first thing with high-density floppy support and the final thing described in the technical documentation I was using. So if that's the issue, it might be smart to treat this as a support-the-SE feature request. The SE is also slightly faster in general and a lot faster at hard-disk access so it is something I should probably do.

mbrethen commented 4 years ago

That's it! I downloaded the two System 6.0.8 install disks from Apple: “SSW_6.0.8-1.4MB_Disk1of2.sea.bin” and “SSW_6.0.8-1.4MB_Disk2of2.sea.bin”. CLK did mount a 40MB system 7 disk that I created in minivmac, using a RAW image file.

Edit: After looking at the url you provided, those appear to be the same HD image files that I downloaded from Apple.

mbrethen commented 4 years ago

I managed to mount a 40Mb HD, preinstalled w/ system 6.0.8. How do you mount floppy disks in either the internal or external drive? I tried dropping them on the window or using open/insert to no avail.

Edit: Okay I was able drag and drop a blank 800kb disk image. The disk I was trying to mount must not be in the correct format.

TomHarte commented 4 years ago

If it's an image you can redistribute then I'd love to find out what the problem is, otherwise I'm going to keep this ticket open if I may as a "make high-density floppies work" ticket. Which likely means implementing an SE, but e.g. if I can find a profile for a SCSI floppy drive that the Mac supports then that might also work. But getting to this not being confusing is the goal.

mbrethen commented 4 years ago

Stuffit Expander 4.0.1 repackaged into a zipped hfs disk image and checksum file. Got it from the minivmac site. It's redistributable according to the license. stuffit_expander_40.zip

mbrethen commented 4 years ago

This has been an exercise trying to figure out how to migrate software to the emulated mac plus in CLK. I ended up putting the self-extracting stuffit archive on to a blank 800kb hfs image in minvmac and then dropping that on to CLK.

TomHarte commented 4 years ago

I think the problem with that one is just the file size; when you drag a DSK over Clock Signal it has to figure out what sort of disk image it is from the many that are called .DSK and just contain sector contents, and in the Mac's case I haven't yet written anything to introspect the filing system so it just makes a very broad guess based on file size.

So the TODO is probably to write MFS and HFS parsers, in order more accurately to peg DSKs. I might also look at using the currently-running machine as a hint for file type identification as at the minute it's always from first principles, but it'd be nice to be able to get this right from a plain File -> Open... .

mbrethen commented 4 years ago

Today I tried to install SSW 6.0.8 using the four 800kb disks on to a 40MB blank disk. I tried dropping it onto CLK but it would not mount the drive. Apple HD SC Setup recognizes it as a SCSI Device: 6.

040M.zip

ryandesign commented 9 months ago

So the TODO is probably to write MFS and HFS parsers, in order more accurately to peg DSKs.

A very simple parser could just look at the word at 0x400. 0x4244 indicates an HFS disk. This would identify the blank hard disk image Mark uploaded in the previous comment. 0xD2D7 indicates an MFS disk.

If you want to do another sanity check, you could check that the disk image is at least as large as the word at 0x412 (number of allocation blocks) multiplied by the long at 0x414 (size of allocation blocks). It's the same for MFS and HFS disks. The disk images I checked were each a few K larger than this product which is why I suggest a greater-than-or-equal-to comparison rather than an equal-to one.

The word at 0x0 will be 0x4C4B if it is a bootable disk. Mark's blank hard disk doesn't have this marker since it's blank and hasn't had an OS installed on it. Clock Signal probably doesn't need to look at this word; it can just pass HFS and MFS disks to the emulated machine and let it eject it if it's not bootable. The user certainly might want to insert non-bootable data disks after the machine has been booted.

I found this information here but I'm sure it's in Inside Macintosh somewhere too.

ryandesign commented 9 months ago

The word at 0x0 will be 0x4C4B if it is a bootable disk.

I see you know this already:

https://github.com/TomHarte/CLK/blob/def1f90d86078ff02be19d48d28548d6de1a9b6f/Storage/Disk/DiskImage/Formats/MacintoshIMG.cpp#L41-L44

if I can find a profile for a SCSI floppy drive that the Mac supports then that might also work

I had never heard of any such device existing but I found now that there did exist the PLI TurboFloppy 1.4.

The closest device I was previously aware of is the AE HD+ but that's pretty esoteric. It connects to the floppy port and as that write-up says it doesn't work as the boot drive. Emulating that in Clock Signal would probably not be the most useful thing.

There is a difficulty in that the two most frequently used Macintosh emulators handle disk images in different ways. My go-to emulator, Mini vMac, implements only floppy disks but entirely replaces the Mac OS floppy disk driver so it accepts "floppy disk images" of any size, which is not authentic but is very convenient since you can make disk images of whatever size you want and initialize them in the emulator without needing any other driver or formatting software. Basilisk II on the other hand supports hard disk images which must be initialized by Apple HD SC Setup, Drive Setup, or other formatting software. Basilisk II hard disk images contain all the usual things you would find on a hard disk, like drivers and partitions, whereas a Mini vMac floppy disk image contains none of that. Being able to read and write to either type of image in Clock Signal would be wonderful but I don't know how you achieve that if your goal is authenticity.

ryandesign commented 9 months ago

And to be clear, the 40MB image Mark uploaded is a Mini vMac-style "floppy disk image".