• Please review our updated Terms and Rules here

My Floppy Drive Image tool 1.00

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,285
Location
USA
Hi Everyone,

I used to have another floppy disk tool that I wrote that I used for reading and writing diskettes, but it was only for 1.44mb diskettes and its compression made my 8088 come to a slow slow crawl. I decided to write a new tool that is a simple disk image read/write/verify, but this time it supports multiple formats and can also optionally split a disk image into multiple pieces to help for those times where you can't fit a disk image on a disk for example. I've learned that some of my other DOS tools wouldn't run on my 8088 because they had been compiled for 286, 386, etc. as well, so I made sure this tool would work on 8088's. There is also a windows version (WIN32 console application) that autodetects NT or 9X style environment and uses the correct system calls to work with a floppy, so you can run FDIMAGEW on 32-bit or 64-bit Windows operating systems as well.

Here is the help file for the tool and I've attached a ZIP with the help, DOS version, and Windows version. Let me know if you encounter any bugs that need to be fixed!

FDIMAGE 1.00
_______________________________________________________________________________

FDIMAGE is a floppy drive image tool that can image:
from drive to file
from file to drive
from drive to drive (effectively a diskcopy)
from file to file (for splitting or combining)

Here is the help and usage:

SA Development Floppy Drive Image 1.00 (WIN32)
Free to use; no warranty or responsibility provided.

Usage: FDIMAGEW [options] source target

Options:
The source and target can be a filename or floppy drive (a: or b: ).
/y will skip target filename overwrite prompting.
/v will verify an operation (the target will be verified, not written).
The source media format is determined automatically, but can be overridden
with /160, /180, /320, /360, /720, /1200, /1440, or /2880.
The target media format is checked unless the /smfc option is specified.
The /k will prompt the user to press a key before all operations so the
user can swap disks if necessary.
The /s2, /s4, and /s8 options indicate that the source is multiple files.
The /t2, /t4, and /t8 options indicate that the target is multiple files.
Options may appear anywhere on the command line.
/? will show this help.
_______________________________________________________________________________

There are two versions of this tool:

FDIMAGE.EXE - DOS version (16-bit) that can run under DOS as well as
environments that emulate dos bios calls for floppy drive
access. It also works under 32-bit versions of windows that
emulate the 16-bit environment, though the windows version may
be more optimal. This tool is compiled so that it can run
on machines even with old CPU's like the 8088.

FDIMAGEW.EXE - WIN32 version (32-bit) that can run under Windows 32-bit or
64-bit operating systems. This tool is compiled to run on
80386 and above.

Both versions have exactly the same options and functionality.
_______________________________________________________________________________

FDIMAGE generally works like a copy command except that the source and target
can be either a floppy drive letter (a: or b: ) or a filename. Given this, you
can copy from a file to drive, drive to file, or even drive to drive or file
to file.

The (/y) will skip overwrite prompting for files. There is no overwrite
prompting for disks. Be sure to have the correct command and correct disk
mounted in the correct drive so that a disk you care about is not overwritten
by accident. It is always safer to set any disk you don't want changed to
read only so that it can't occur. I am not be responsible for lost data.

The (/v) verify option does not do a copy, but verifies or compares the source
and target. *** No writing will be done with the /v command. ***

It currently supports these floppy formats:
5.25" - 160K, 180K, 320K, 360K, and 1200K (1.2M)
3.50" - 720K, 1440K (1.44M), and 2880K (2.88M)

It will determine the format automatically by looking at the media in the
source. If you want to override the format, you can use the /160, /180,
/320, /360, /720, /1200, /1440, or /2880 option.

It will also look at the target media format (if a drive) to verify it is
the correct media. You can override this with the /smfc (skip media format
check) option.

The (/k) option will prompt the user to press a key before each operation.
This gives the user the option to swap disks if necessary. The design of the
tool is that it uses available memory as a track buffer so it will load as
many tracks into memory as it can to reduce unnecessary swapping.

The (/s2, /s4, /s8, /t2, /t4, /t8 ) options allow you to specify that the file
is being referenced by the source or target is split into 2, 4, or 8 parts.
If a file is split, it will be mydisk.img, mydisk.002, mydisk.003, and so on.
This allows you to build up a full disk image even on drives that are smaller
than the disk image. It is very useful to use with the (/k) command.
_______________________________________________________________________________

Example #1 - read a disk in drive A: to a file.

If you want to read the disk in drive A: and store it to a file in the current
path, you can use:

FDIMAGE A: mydisk

It will automatically add a .img file extension if one is not specified.

In this case, it will read the entire disk in drive A: (autodetecting the
format) and store it in a file called mydisk.img in the current path.

If mydisk.img exists, it will ask if you want to overwrite it unless you also
add the /y option.
_______________________________________________________________________________

Example #2 - read a file and write a disk in drive B:

The opposite of example #1, one can use:

FDIMAGE mydisk b:

Again, it will automatically append .img to mydisk to look for mydisk.img.

It will read the contents of mydisk.img in the current path, check the disk in
drive B: to make sure it is the same format, and then write that disk.
_______________________________________________________________________________

Example #3 - verify the disk from example #2:

FDIMAGE mydisk b: /v

The /v option means that drive B: will not be written, instead it will be read
and compared to the file in mydisk.img. Any difference in data will be
reported.
_______________________________________________________________________________

Example #4 - write a 360K diskette on a system without a hard drive:

One issue with creating a disk from an image is that you need a drive that is
able to hold the size of that full image in a file. You can't fit a 360K disk
image for example on a 360K because of filesystem overhead. FDIMAGE has a
solution for this where it can split an image file into 2, 4, or 8 pieces.

I had an old Compaq Portable (8088 ) that had two 360K floppy drives and no
hard drive yet. I had an older bootable DOS disk, so I could boot that, but I
wanted to make a DOS 6.22 bootable diskette. I had a 360K disk image of DOS
6.22, but no other system that could write 5.25" disks. The solution is to
split the image into 2 pieces so that each piece will fit on a 360K disk, and
then recombine them back to a single diskette. I was able to transfer files
across a serial link to the machine.

Step #1 - split the image on the computer with the image:

FDIMAGE dos622.img dossplit.img /t2

This produced a dossplit.img and dossplit.002. I copied these over the serial
connection along with the FDIMAGE.EXE tool to two separate disks. I then ran:

FDIMAGE dossplit.img /s2 b: /k

In this case I was using a: as my source drive, and b: as my target drive,
though I could have used a: as my target drive too if I had had only one
drive.

The /s2 says that the source file will be split into two files, so it will
expect 2 files. The /k option will pause before each disk operation so I can
swap the correct disk into place. When it prompts for the dossplit.img file,
I can put that disk in, then when it prompts for the dossplit.002 file, I can
put that disk in. I had enough memory that it could cache a full disk in
memory, so it will prompt for dossplit.img, then prompt for dossplit.002,
and then finally prompt to write the disk.
 

Attachments

  • fdimage_100.zip
    54.1 KB · Views: 90
Yes exactly, it is limited to 512 byte sectors and plain-jane sector ID schemes (if that means all tracks have the same sectors, etc.)

It uses the number of sectors/maxsect/maxhead values found in the FAT header to automatically determine the tracks, heads, and sectors. You can override that with an option though. Either way, ultimately it attempts to use the BIOS to load a track at a time by iterating through the tracks/heads into memory.

I'm not sure the encoding comes into play as I think that would be abstracted from my code in the hardware, right? I don't think you can change the encoding in the BIOS as all, right?

I don't know much about PC98 formats - do they have a FAT boot sector or do they use a different filesystem?
 
1) By encoding, I mean modulation scheme. Many floppy controllers can handle FM as well as MFM, even though there's no support for it in the BIOS. Interestingly there was support for it in SC-DOS.

2. PC98 uses 8x1024 byte sectors and an HD drive spinning at 360 RPM (not 300). Interestingly, most USB floppies can handle it just fine. No so much for legacy controllers, unless you have a 3-mode drive.
 
That is interesting. I am using the BIOS only for floppy access (in FDIMAGE), and operating system calls in the Windows version (FDIMAGEW) which probably get translated and make it down the BIOS in 9X, but are likely emulated in NT/2K/XP/7/8/10/etc.
 
Here is version 1.01 - I added DMF (1.68M) support to it last night.
 

Attachments

  • fdimage_101.zip
    54.3 KB · Views: 37
Here is an update - it is now FDIMAGE 1.05.

It can now test disks by reading them fully if a target is not specified.
Disk splitting is much better and can be any size now.
A verify option has been added to do read after write verification.
Multiple targets allows reading a disk once and writing it many times (or comparing many times) if the entire source fits in memory.
Fast LZ compression option allows reducing image size without running horribly slow on old systems.
Doesn't require more than an 8088 to run.
Can use conventional/XMS/EMS memory to reduce disk swapping (it will try to load an entire disk image into memory).

It also still has a windows version (FDIMAGEW) that will run under 9X/NT style systems (x86/x64).
 

Attachments

  • fdimage_105.zip
    120.8 KB · Views: 38
Let me know when support for 16-hard-sectored Wang 8" floppies is incorporated. ;)

Can one use this tool to convert, say, 1200K images to 2.88M ED media?
Do you do a "smart" image (copying only allocated sectors) or a "blind" image (copying all sectors, allocated or not)? Can you turn an image into a self-extracting file that writes and formats a floppy?
 
Chuck you always have many advanced ideas for me on this! :)

This update was mostly a learning adventure for me to see how I can improve the way I coded it. I also finally was able to add compression to make disk images smaller without it being so slow on 8088's that it is very noticeable. It is a simple tool that doesn't understand filsystems at all, it just copies tracks essentially, but it can copy a 2.88M ED media disk in one pass if there is enough XMS/EMS memory or by using the 32-bit version. If a disk is mostly empty sectors and compression is used, it will greatly reduce the image size (somewhat like not having to copy them, but they are being copied, just compressed).

I use winimage for disk conversion between formats!

Here is the FDIMAGE 1.05 options/help for everyone to see what its options are (also in the ZIP is a PDF):

FDIMAGE 1.05 (DOS)
Free to use; no warranty or responsibility provided

Usage: FDIMAGE source [target] [options]

Options:
Source and target can be a drive (a: or b:) or filename
If target is not specified, the source will be read to test it
The source media type will be determined and the target media type will be
checked unless the media type is overridden by specifying /160, /180, /320,
/360, /720, /1200, /1440, /1680, or /2880
/c compare source and target (target will not be written)
/dx, /de, or /dxe disable XMS, EMS, or both
/k prompt to press a key before all operations to allow disk swapping
/m multiple targets (if the entire source fits in memory)
/r reduce the target file size with compression
/s# split the target file into #KB sized files
/v verify target while writing (read after write)
/y skip target overwrite prompts
 
So did you change it so the /V option does the copy and verify in a single operation? Previously it only does the read/verify. If not can you add a feature that does that?

Also I may have asked this before but would it be possible to add support for drives beyond A & B?
 
It was renamed to make more sense.

/C is now for compare
/V will now verify while writing (read afrer write)

>Also I may have asked this before but would it be possible to add support for drives beyond A & B?

What drive letters would a 3rd/4th drive have? I'm assuming in the DOS functions I'd be specifying drives 0x02 and 0x03. I would need to figure out how to map a correct drive letter to them though.
 
It was renamed to make more sense.

/C is now for compare
/V will now verify while writing (read afrer write)

>Also I may have asked this before but would it be possible to add support for drives beyond A & B?

What drive letters would a 3rd/4th drive have? I'm assuming in the DOS functions I'd be specifying drives 0x02 and 0x03. I would need to figure out how to map a correct drive letter to them though.
Awesome, makes sense.

Well for my use case I have 3 floppy drives and would need support for a D:
 
I am wondering if there is a way to query DOS drive letters for the type of drive that it is.
 
Ever hear of Ralf Brown? His interrupt list shows INT 21h AX=440Dh CX=0860h

His list should be bookmarked if you're going to write much MSDOS code.

Ray Duncan's hard-bound big thick DOS encyclopedia was on my desk while writing code. You'll find the function described on page 1347.
Ralf Brown's list included a lot of non-Microsoft information and was updated frequently.
 
Last edited:
I certainly have been to the RB interrupt list many times! I'll check out the ones you mention.

I'll need to figure out if there are equivalent API calls for WIn9X/WinNT as my tool works under DOS/Win9X/WInNT.
 
32-bit WIN32 API for both win9x and winnt. For NT style OS's I'm using CreateFile to open a handle to the physical drive, then I lock the volume and get its geometry for readfile/writefile. For 9x I open a handle to "\\\\.\\vwin32" and then use DeviceIoControl() to lock the volume, then lock it with more rights, then yet more DeviceIoControl to perform 0x300 or 0x200 functions.
 
Back
Top