The clever bit of the heads of a double-sided 3.5" floppy drive:
The heads aren't aligned with each other, they're offset by a little bit
The heads aren't aligned with each other, they're offset by a little bit
This is done for a few reasons, to protect the disk from being pressed too hard at the same point on both sides, to keep the heads from hitting into each other if the drive closes with no disk inside it, and to avoid any interference between the heads
I'm not sure if it's the same on 3.5" drives, but on 5.25" drives the difference is 8 tracks.
this means that while both sides of the disk have 80 tracks, only the middle 64 tracks overlap vertically. The top side has 8 tracks farther out than the bottom, and the bottom has 8 tracks closer in than the top.
so double sided drives usually work this way... but there have been other solutions.
The Apple "Twiggy" Fileware disk tried to solve the double-sided problem by putting the heads at opposite ends of the disk.
The Apple "Twiggy" Fileware disk tried to solve the double-sided problem by putting the heads at opposite ends of the disk.
but the other time this disk-offset mattered was with "flippy disks", like this copy of Castlevania for the C64. The 1541 used by the C64 is single sided, so you have to flip the disk to read the other side.
But hey, the PC disk is double-sided! So you can just hook up an alternative controller (like a Kryoflux, SupercardPro, Greaseweazle, etc) and then use a PC drive to read a C64 disk without flipping it, right?
NOPE!
NOPE!
Because the PC drive does the top/bottom offset thing, right?
So when you try to seek to track 10 on the C64 disk, The bottom will read track 10, and the top will get... track 2!
So when you try to seek to track 10 on the C64 disk, The bottom will read track 10, and the top will get... track 2!
but that's okay, right? you can just adjust your seeking, and seek to track 18 instead, and now you can read the top track 10.
NOPE!
NOPE!
PC drives are designed to seek to 80 tracks, maybe 81 or 82 depending on the drive.
But the offset is 8 tracks, which means that there'll always be some tracks that you can't seek to.
You can't seek to track 88 to read the real track 80, for example, and you can't seek to -8
But the offset is 8 tracks, which means that there'll always be some tracks that you can't seek to.
You can't seek to track 88 to read the real track 80, for example, and you can't seek to -8
The C64's drive, the 1541, doesn't do this offset thing because it doesn't have the ability. It uses the same head to read both top and bottom, so on the C64 disks, the tracks are laid out vertically aligned. Track 5 on the top is at the same place as Track 5 on the bottom.
so OK, let's just give up on the doublesidedness of the PC drive, and just read C64 disks with one side of it. Basically just pretend it's single-sided and ignore the second head and the offset, right? We'll have to flip it, but it's fine... right?
NOPE!
NOPE!
So the index hole is a hole punched in the magnetic material of the disc, and in the vinyl jacket surrounding it. It's used by the drive to detect the position of sectors, in hard-sectored disks. But PC disks are soft-sectored, without multiple index holes...
Since PC disks are soft-sectored, each sector has to tell the disk controller what sector it is.
C64 disks are soft-sectored too.
So what's the problem?
SPEED!
C64 disks are soft-sectored too.
So what's the problem?
SPEED!
Because disks are a rotational medium, the speed at which they rotate determines how big the bits are. If the drive was spinning faster, the bits are smaller, and have to be written or read faster, and vice versa.
So the drive has to ensure the disk is spinning at the right speed. That's 300 RPM for most 5.25" disks, or about 5 rotations a second.
And it could detect that using a hall effect sensor on the motor, or something like that...
And it could detect that using a hall effect sensor on the motor, or something like that...
but you know what'd be easier? by just using the index hole the drive already has to have for some computers.
The drive shines a light through that hole, and sees when it gets blocked with a sensor.
By measuring how often it gets blocked, it can measure RPM and adjust speed
The drive shines a light through that hole, and sees when it gets blocked with a sensor.
By measuring how often it gets blocked, it can measure RPM and adjust speed
You flip the disk, and now the index sensor is checking for the spinning right here.
There's no hole there. (well, there is on the magnetic disc, but not in the jacket)
There's no hole there. (well, there is on the magnetic disc, but not in the jacket)
So the drive goes "WELL I TRIED BUT I DIDN'T SEE ANY INDEX HOLES SO YOUR DISK IS BROKEN. MAKE SURE YOU DIDN'T STUFF A SLICE OF PIZZA IN THERE INSTEAD?" and stops spinning.
So if you want to use double-sided disks in a PC drive, you'd have to either:
1. mod your disks by punching a separate hole in them. That's probably not a good idea for preservation...
1. mod your disks by punching a separate hole in them. That's probably not a good idea for preservation...
2. mod your drive so that it does have a hall effect sensor on the motor, and then figure out how to wire that in to replace the index sensor.
Now your drive knows it's spinning even when it can't see the index holes! Will this always work? NOPE!
Now your drive knows it's spinning even when it can't see the index holes! Will this always work? NOPE!
it turns out there's an Evil Trick that can be done to disks as a form of copy protection, and it will break if you make copies of disks using a drive that doesn't know where the index hole is.
so to understand how it works, you have to understand that floppy disk sectors are laid out in concentric tracks, with small gaps between them (to handle the "slop" when they're rewritten), and each one has a header.
the header says like "sector 5, track 9", so if a floppy drive needs to read a given sector, it does it by moving over to the appropriate track, and sitting there reading all the sector headers as they come by. As soon as it sees the header of the one wants, it reads the payload.
Formatting a floppy disk is the process of putting down these sectors + sector headers, btw. A fully blank (like demagnetized) floppy disk has no sector headers, so the drive can't find them, which is why you can't just write a floppy disk image to a blank disk
you'd have to format it first, otherwise it'll be trying to write sector 0 of track 0 and it can't find that sector.
and when you format a disk, it just seeks to each track one by one, and writes a sector header for sector 0, with a payload that's full of some value. (I believe it's E7 on DOS)
then it next writes the sector header for 1, then 2, then 3, and so on
then it next writes the sector header for 1, then 2, then 3, and so on
and later when the disk drive is trying to write to track 2, sector 4, it doesn't just go there and WRITE. it can't! it doesn't know where that sector is, only that it's on track 2.
So what it actually does is go to track 2 and start reading, watching the sector headers... eventually sector 4 will come by, and as soon as that happens it'll start writing the new sector. over the previous payload.
BUT WAIT! what if someone cheated when formatting?
Remember how I said it starts with sector 0 and just goes up until you have enough sectors for that track?
Remember how I said it starts with sector 0 and just goes up until you have enough sectors for that track?
what if you instead made the sectors go:
0, 1, 0, 1, 0...
0, 1, 0, 1, 0...
well, now every time you tell the drive "read sector 0" it'll give you... one of them. Just whichever one comes up next, but you don't really have a way to know which one it is, because it depends on what rotational position the drive is in when you asked.
And you could, of course, put different contents in each of those sectors. The drive isn't smart enough to know that they are "the same" so it can't enforce any sort of consistency.
but how do you use this for copy protection? Well, one way would be to put a random value in each of the 0 sectors, then ask the drive for sector 0, then see what you get, and then wait a bit and try again.
On a real, legitimate disk, you'd get something different, because while you were waiting, the disk was spinning. It's moved along so when it tries to find sector 0, it'll find a different one.
So that's how a legitimate disk works. What happens when you have a copied disk?
Well, first of all you can't format a disk like this, because no standard disk formatter can do this. They're gonna format it as usual, with sectors 0,1,2,3,4...
Well, first of all you can't format a disk like this, because no standard disk formatter can do this. They're gonna format it as usual, with sectors 0,1,2,3,4...
and then when you try to copy sector 0, you'll get a random one, then you copy sector 1, and get a random one, then you try to copy sector 2... and you can't find it.
ERROR: COPY FAILED
ERROR: COPY FAILED
but maybe you can just set up your disk copier to ignore missing sectors. So now you have a disk track with sectors 0 and 1, copied from some 0 and 1 on the real disk, but only one copy of each.
So now when the program checks if the disk is legitimate, it will see that it always gets the same sector 0, not a different one each time.
You know where that happens? ON COPIED DISKS!
YELL AT THE PIRATE! TURN OFF THE GAME! CALL THE FBI!
You know where that happens? ON COPIED DISKS!
YELL AT THE PIRATE! TURN OFF THE GAME! CALL THE FBI!
But you CAN write a custom formatter, and you CAN write a copier program that is fine with there being multiple sectors with the same number on a track, it's tricky but it's doable.
And now you can write out copied disks, and they'll read as genuine.
And now you can write out copied disks, and they'll read as genuine.
But that's only phase 1 duplicate-sectors copy protection scheme.
phase 2 makes it impossible to copy, at least on the system that's reading them and detecting the piracy...
phase 2 makes it impossible to copy, at least on the system that's reading them and detecting the piracy...
so first, you need to understand how systems like the apple II and C64 (which single-sided drives to read double-sided disks) treat the index hole: They just ignore it.
Now, there are some disks that solve it by having two holes in the jacket which means a drive can detect the index hole no matter which way it's flipped... but that's not how apple II and c64 did it.
they just ignore the hole and do speed-regulation stuff using a hall effect sensor or some other mechanism.
Because of this, when you format a disk the track rotation isn't consistent. It's not like the sector-0s are all nicely lined up, they can be wherever along the track
Because of this, when you format a disk the track rotation isn't consistent. It's not like the sector-0s are all nicely lined up, they can be wherever along the track
and this should be fine, right? the sectors have headers, the drive just waits for a sector to come along, it doesn't care that on track 0 the sector 0 is at 0 degrees, and on track 1 it's at 75 degrees, and on track 2 it's at 270 degrees. Who cares?
WELL IT TURNS OUT YOU CAN MAKE THE DRIVE CARE, even without an index sensor
So what you do is have a regular track next to your weird one with sectors 0,1,0,1,0,1... And instead of just seeking to the weird track, you seek to the regular track and read a given sector there, like sector 0...
then you jump tracks.
then you jump tracks.
so after reading sector 0 on the regular track, you tell it to read sector 0 on the weird track. The drive head will move over and then start waiting for sector 0, and since every other sector is sector 0, it'll find it quickly.
But here's the thing: Which one it finds is dependent the rotational position of the disk, and we KNOW what the rotational position of the disk is, because we just a dozen milliseconds ago read sector 0 on the normal track next to it.
so after doing all the previous tricks with duplicate sectors and using that as copy protection, we can do this track-skipping trick to figure out what the rotational alignment of the two tracks are.
If they're laid out how we expect, we'll get the duplicate sector we expect!
if they're not, we'll get some other sector, which'd happen if we're on some kind of copied disk.
if they're not, we'll get some other sector, which'd happen if we're on some kind of copied disk.
So the pirates just fix this, right? they just need to make their copier know about the rotational alignment and ensure it always writes out tracks with the right alignment, right?
NOPE!
NOPE!
remember, this is a trick used on disk drives that don't use an index hole.
The drive doesn't know what the rotation of the disk is, so while it can copy single tracks accurately, it can't ensure that they are aligned (rotationally) when it writes them back out
The drive doesn't know what the rotation of the disk is, so while it can copy single tracks accurately, it can't ensure that they are aligned (rotationally) when it writes them back out
The original manufacturers of the legitimate disks can ensure it by writing the disks using special drives or drives on a different system. They can ensure the rotational alignment, but for the pirates? it's very difficult to impossible.
so all of this is to say that MAINTAINING ROTATIONAL ALIGNMENT IS IMPORTANT and to do that consistently you need an index hole. So the solution of sticking a hall effect sensor on the motor... that won't work. It'll be fine for 99% of disks, sure, but the 1% will break.
Which leads us to solution #3 on how you fix the problem of disk heads being aligned differently on the top and bottom of disks:
HACK THE ZERO SENSOR
HACK THE ZERO SENSOR
So the way floppy drives work:
The head is moved in and out using a stepper motor, and the way it knows which track it's on is simple: It remembers, and it can reset to track 0.
The head is moved in and out using a stepper motor, and the way it knows which track it's on is simple: It remembers, and it can reset to track 0.
The "remembering" is simple: the controller knows that it's over track 5, so if you tell it "go to track 7" it just knows to move two tracks in, and now remembers that it's on track 7.
but this has to start somewhere. You can't remember where you are if you just turned on, because who knows where the head was when the computer was turned off?
even if you saved it in flash memory or something, someone might have opened it up and manually moved the head.
even if you saved it in flash memory or something, someone might have opened it up and manually moved the head.
so what it does is that it has a sensor which tells it when the head is over track 0.
Basically there's a little plastic arm on the head, and when it is at the right place, it interrupts a light beam.
Basically there's a little plastic arm on the head, and when it is at the right place, it interrupts a light beam.
So when you turn on the computer it goes "OH NO I DON'T KNOW WHAT TRACK I'M ON!" and starts sending "go back a track" commands, watching for the track-zero sensor to turn on.
Eventually it will, and the drive now knows where it is, and can start remembering from that point on
Eventually it will, and the drive now knows where it is, and can start remembering from that point on
BTW, if you were wanting to save money, you could design a drive to not have a track zero sensor, and just send TRACK_NUMBER "move down a track" commands at power on.
eventually the head will get to track zero, you won't know it, and you'll keep moving the head, smacking it against the side of the disk drive case, thud-thud-thud-thud-thud.
Noisy, slow, but it saves like a dollar or two of parts.
Noisy, slow, but it saves like a dollar or two of parts.
this is exactly why, when you turn on an Apple II with a disk drive, it sounds like this. No track zero sensor, so it just bangs against the side of the case.
(from )
(from )
But PC drives do use the track zero sensors... and what if you lied to them?
It works by having a little piece of plastic interrupt a sensor, right?
what if you moved the plastic?
It works by having a little piece of plastic interrupt a sensor, right?
what if you moved the plastic?
By adjusting where the track-zero sensor engages, you may be able to seek past track 0, and get to track -1, -2, and so on, until the drive runs out of room for the head.
So you could take a drive that you know has room, and adjust the track-zero sensor, and now you can have a drive that is off by 8 tracks, because the track-0 sensor is triggering at the wrong place.
Since this only affects the bottom range of the head's movement, you can now seek from track 80 to track -8 (although the drive thinks they're 88 to 0)
and that gives you enough room to read all the tracks on a single-sided drive, using a double-sided drive!
and that gives you enough room to read all the tracks on a single-sided drive, using a double-sided drive!
This is called the "flippy mod" by the Kryoflux team which developed it. I've got a drive I've modded this way, for dumping c64/apple II disks through the kryoflux.
so the moral of the story is that double sided drives were a neat idea and they work as well as they do because of a neat trick where the drive heads are offset but it also causes annoying compatibility problems with single-sided disks in double-sided drives.
also this was supposed to be my quick post before I go to bed
that was over an hour ago
my feet are cold
I need to sleep (and dream of floppies)
that was over an hour ago
my feet are cold
I need to sleep (and dream of floppies)