While there are some other bug fixes and documentation to be done on what’s already been implemented, I started thinking about writing ADF’s to disk over the last few days.
While the hardware part of it is already in place, there are some things that would need done:
- The interrupt service routine would need modified to not just read data by reacting to edges, but now extract a bit from memory and put an appropriate pulse on the writedata pin. Floppy drive specs say the pulse should be 0.1us to 1.1us wide.
- Write an SX routine that would receive data from the PC and store it in the fram. This would need to checksum the received data and either error out or request a retransmit.
- Write PC routines that would create the full MFM track: I’d need to create a header (easy enough, use sector numbers, 11-sector number, track number, and then checksum everything), then MFM encode the data. I’m already doing much of this in the decode portion, so I can basically do the opposite for encoding.
- Of course there’ll need to be a “controlling” pc routine, much like my current readtrack() routine.
So the whole process of writing a disk would go something like this:
- Have user browse for the filename, select the file, load it into a “floppydisk” structure/object that currently exists.
- Rewind and make sure I’m at track 0.
- Create the first track’s data.
- Send a command to the SX to tell it to receive a track’s worth of data.
- Send the data making sure it’s been received correctly.
- Tell the SX to write the track.
- SX enables the write gate by lowering it, and starts pulsing out data, pausing the appropriate times for 0-bits.
I don’t see any major hangups, although there are a few timing related things to get right. I’ve got make sure 18ms has passed after each step pulse. And I’ve got to make sure 100us has passed since I’ve selected the drive(this is mainly during setup for the first trak). For the last track, I need to make sure I pause for 650us after the last track is written. I also have to make sure that the time from the write gate dropping to the first bit MUST be 8us or less. Same with the final bit, I have to raise that write-gate within 8us after the last pulse.
I’ve got to look into creating a gap, sending SYNC words, learning wtf pre-write compensation is, etc.