ANA2DSK.TXT Some notes on making .DSK images of FLEX disks using Anadisk Dell W. Setzer dsetzer@panix.com 31 March 2001 Using Anadisk, a shareware DOS floppy disk utility, it's fairly easy to transfer 5.25" FLEX floppy disks to the .DSK file format used by most FLEX emulators. Here are some notes and a little utility program which work for me -- your milage may very well vary. By the way, if you're transferring 3.5" floppies, you'll probably have to make changes in the utility -- it only knows about 5.25" formats. Also, be aware that this utility does very little logical (ie, disk layout) error checking, so be sure to test the images you make with it. I find that using your emulator and LISTing a few text files on the image usually tells you very quickly whether the image is correct. * As you probably know, most, if not all, 5.25" FLEX floppies have track 0 formatted as single density, even if the rest of the disk is double density. In the third sector of track 0, side 0, is the FLEX System Information Record (SIR in my utility), which describes the layout of the disk. Among other information in the SIR is the number of sectors, from which you can figure out whether the rest of the disk is single or double density and/or single or double sided. Also in the SIR is the highest (0-relative) track number. * The .DSK format used by most FLEX emulators assumes an "orthogonal" layout where all "tracks" in the disk image have the same number of sectors. However, on double density disks, the single density track 0 has fewer sectors that the rest of the tracks, so we must "pad out" track 0 when we build the image. My utility does this. * You have to run Anadisk from DOS, not from a Windows DOS box. It just plain won't work under any flavor of Windows, 95/98, or NT, at least not reliably. Others have written extensively on the reasons, so I won't. I've been using DOS 5.0 and Anadisk 2.07, dated 26-Aug-92 with good results. * You may have to try Anadisk on different machines. The floppy drive and controller must be able to read both single and double density (see above). On my fancy HP Vectra, Anadisk cannot read the single-density track 0 on FLEX disks (Anadisk reports that track 0 is blank). However, a P90 clone gathering dust in my closet works just fine. Go figure. By the way, a high density (1.2mb) drive is required to read 80 track disks, and I'm assuming you're using one. * Anadisk on my P90 clone seems to treat all disks -- 35, 40, and 80 tracks -- as 80 track disks. This seems to be true no matter how and on what kind of drive the disk was originally formatted. Perhaps on other hardware, Anadisk could detect the different track densities, but it doesn't on mine, so I'm assuming it doesn't on yours. What this means is that with 35/40 track floppies, Anadisk tries to read the spaces "between the tracks", and reports that every other "track" is either blank or has "data" (often with CRC errors) which is actually being picked up from the adjacent track. My utility deals with this by skipping any data from odd-numbered (physical) tracks if the SIR says it's not an 80 track disk image. If your hardware doesn't behave like mine, you'll have to change the utility. When using Anadisk to dump the raw disk data to a disk image file, we must tell Anadisk to include "Sector ID information" (see below) in the data so that the filtering software can weed out the bogus odd numbered track data. In this mode, Anadisk writes out an 8 byte header for each sector (called an ADREC in my utility), followed by the sector data. When my utility encounters an image whose SIR reports a hi track of less than 79, it uses the "actual cylinder" number in each sector's ADREC to discard any data for odd-numbered tracks. Of course, on 80 track images, the utility transfers data from all tracks. By the way, when Anadisk decides that a track is "blank", it doesn't write anything to the dump file, so normally there wouldn't be any odd track info in the dump file and we wouldn't have to do this dance. However, Anadisk occasionally thinks it has read some actual data from some sectors on these tracks (often with CRC and other errors), and puts records for them in the dump file. That's why we need the odd-track filter, and why the dump files aren't twice as large. * Normally, the sector count value in the SIR is 10 (SS/SD), 18 (SS/DD), 20 (DS/SD), or 36 (DS/DD). However, on some double density floppies formatted using Frank Hogg's CoCo FLEX, the sector count is 35 (instead of the expected 36). This indicates a "trimmed" format where the last sector on each side is ommited. I don't know why, but I assume it's because of some CoCo hardware wierdness. Perhaps someone knows. Anyway, because of the way the sectors are numbered, on these disks a dummy sector 18 must be inserted into the .DSK image file. My utility does this. Using Anadisk ============= If you download Anadisk from the net, it should come with documentation. Even if you don't have the docs, it's really easy to use. Although it comes with a setup program, you shouldn't even have to run it if your BIOS is sane. The main screen has a number of selections, several of which have to do with digesting, repairing, and formatting DOS floppies. The ones we're interested are SECTOR and DUMP. Use SECTOR to browse a disk's tracks and sectors, and DUMP to make an image file from the disk. The first thing you should do is fire up Anadisk, put in a FLEX disk (start with a double density disk), and pick SECTOR. This will take you to a screen with a couple of output panes and a track map at the top. It will automatically read track 0 and print some info on the left pane. This should say that track 0 is single density, and what the sector numbering is. If it doesn't, you're having the same problem I had on my HP Vectra, and you need to try different hardware. If you like, press ENTER and browse the sector data. Back at the SECTOR screen, press the right arrow to select track 1 on the track map at the top of the screen, and press ENTER to read the track. What happens now depends on whether it's an 80 track disk or not. If it's an 80 track disk, the left pane will now report double density, and new sector numbering. The right pane will report that sector IDs and interleaving have changed -- this is normal for the switch from single to double density. Reading subsequent tracks will not repeat these reports. If it's not an 80 track disk, the right pane will report that the track is blank, or that there are errors. Again, this is normal, at least in my experience (see above). Now press right arrow again to select track 2, and press ENTER. Now the left pane should report double density, and the right pane will complain that the track numbers don't match. Again, this is normal. From then on, every other track (ie, the odd tracks) will be "blank" or have errors, and the even tracks will report mismatched track data (the "actual" track will be double the "logical" track, which makes sense if you think about it). By the way, Anadisk seems to do a good job of figuring out whether it's a single or double sided disk. However, if you have a disk which is formatted as single sided, but in fact has data recorded on the other side, you may have problems and you may need to make changes to the utility. If you've gotten this far with similar results, your chances for success are good. Go back to the main menu, and select DUMP. Select the drive and both sides (if it's a double sided disk), and select YES for "Include sector ID information". Now press ENTER and give it a filename. Press ENTER and you'll be prompted for first and last track. Always answer 0 and 79 respectively. As Anadisk reads and dumps the disk, the left and right panes will report info as above. Again, if it's not an 80 track disk, every other track will be reported as "blank", and the other tracks will report mismatched track info. Anadisk will recal the floppy drive after each "blank" track, so your drive will make a lot of unhappy sounding noise, though it doesn't seem to hurt anything. The Utility =========== The utility I wrote, ana2dsk.c, is a quick attempt to address the problems mentioned above when converting Anadisk disk dumps to .DSK files. I've included a Win32 executable along with the source and this file -- it's written in generic C, and should port easily to other platforms. It does the following: * Reads the Anadisk dump file created with sector ID info * Pads out track 0 to the appropriate length * Drops odd-numbered tracks if the SIR reports non-80 track disk * Adds dummy sector 18's if the SIR reports "trimmed" DS/DD disk Usage is simply: ana2dsk inputname outputname where inputname is the name of the Anadisk dump file to be read, and outputname is the name of the DSK format output file to be created.