Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Last active December 7, 2023 14:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanfb/d3395c8404463d4ba868f668ae9ddb3d to your computer and use it in GitHub Desktop.
Save ryanfb/d3395c8404463d4ba868f668ae9ddb3d to your computer and use it in GitHub Desktop.
WOZ/MOOF explainer script draft

The Apple II and Macintosh sold millions of units, and the software made for them had a huge impact not only on the people who used them, but on computer history as a whole. But did you know that until recently, there was almost no way to accurately preserve the floppy disks these systems used?

In this video I’m going to break down what WOZ and MOOF disk images are, what makes them different from most other disk image formats, and why I think it’s worth playing them today. Stick around for a little bonus content at the end if you’re interested in how you can play these disk images yourself!

First off, what are WOZ and MOOF disk images and what makes them different from other disk image formats?

This can get pretty technical, but the high-level overview is that WOZ and MOOF disk images enable greater accuracy than other disk image formats in emulating the physical disks they represent. This allows them to, for example, pass copy protection checks that are on the disk without being modified or cracked. In many cases, before a WOZ or MOOF disk image was created, a lot of the software which is now accurately preserved in those disk images was only available in a cracked or modified form—or in some cases, not at all.

But how do they achieve this higher-accuracy emulation and why exactly is it needed?

You might already know that computers can only work with and store what’s called “binary data”—data encoded as ones and zeroes. Since you know computers can store data on magnetic floppy disks, a convenient mental model might be that the ones and zeroes the computer needs are directly encoded as the presence or absence of a magnetic signal on the disk’s surface. So, all you should need to do to make an exact bit-for-bit copy of the binary data on a floppy disk is to start at the beginning of the disk, read out all the ones and zeroes into a file, and you’re done!

Unfortunately for us, this is completely wrong. At the lowest level, floppy disks are an analog medium, and the magnetic surface alone can’t record a binary data stream in a completely unambiguous way. What the magnetic surface records instead are what are called “flux transitions”—and this is the whole reason why advanced disk image formats like WOZ and MOOF are needed for digital preservation.

You see, all the way back when Steve Wozniak was designing the first floppy disk drive for the Apple II, he had a lot of choices to make. Other companies in the early home computer market were introducing disk drives for their machines as well, and Wozniak needed to do something that would set the Apple II apart from the crowd. What he decided to do has had a huge impact on computer history: he decided to embrace the physical nature of the floppy disk. While other disk drives might closely mimic your mental model of binary stored on a floppy disk, allowing the computer to simply ask for a range of data and get back a binary stream, having the disk drive itself provide this much abstraction added serious costs to the hardware. Woz decided to go in the opposite direction: provide the smallest amount of abstraction as possible in the disk drive itself in order to cut down on costs. The result was the Disk II: an inexpensive disk drive that gave full control over how data was read to the host computer, and which gave the Apple II the competitive advantage that cemented its place in popular computer history.

So how exactly does raw magnetic flux differ from a binary data stream? After all, we’re encoding the disk image as binary at some point, and the computer is reading binary at some point, so there has to be some way to get from the magnetic flux transitions to the binary encoding. And for that, we’re going to have to dive a little bit deeper.

If everything about converting the magnetic flux on the disk into a binary data stream is left to the host computer, in this case the Apple II, what does that really mean? Well since there’s no other fixed storage on the Apple II than ROM, there has to be some agreed-upon way to bootstrap reading a disk and starting up from it. And in fact there is. One of Wozniak’s cost-cutting measures was eliminating the sensor some disk drives used to reset the read head’s position over the magnetic disk. As a result, the signature Apple II startup sound is the Disk II repeatedly slamming the read head into the outermost track—if you’ve ever used a real Apple II with real disks, you’ll be familiar with this sound. Once the Apple II can be sure the read head is over the right track, it needs to know it’s over the right position on the track to boot up. Other, fancier, disk drives used another sensor for this, an optical sensor that could read a special hole drilled in the floppy disk, so the drive could tell when the disk was rotated to an agreed-upon “zero” position. Wozniak’s Disk II skipped this, too, of course. Instead the Apple II looks for a signature pattern while spinning the disk. This signature pattern tells it where the start of the track is. Once it knows where that is, it uses an agreed-upon encoding to decode the first two blocks of binary data, which it reads into memory and executes. This is the only universally agreed-upon part you need for a bootable Apple II disk and it happens in only 256 bytes of Disk II ROM: literally everything else is up to that first bit of code that gets read into memory and executed. That means everything, including the conventions for reading binary data from the disk, is up to that code. You might have heard of “DOS” and know that it stands for “Disk Operating System”, and that’s literally what it means in many cases here: various versions of DOS provided a structure that programmers could easily use to interface with the low-level encoding on a floppy disk at a higher level of abstraction. But that ability to access and interpret the disk at the lowest levels was always there, and that’s how we wound up needing more advanced disk formats like WOZ and MOOF that can support and emulate this low level access.

Your mental model of how a floppy disk works might also be a little bit like a vinyl record: the computer can read multiple tracks of binary data, moving from outside to inside. This is accurate in some ways, but misleading in others. When I talked about Wozniak’s Disk II giving full control to the host computer, one of the things it gave the Apple II control over was precisely positioning the read head over a disk track—not just at the track level, but in increments of quarter tracks. [script will continue after this point]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment