Next: Supported file formats, Previous: The joystick emulation, Up: About VICE [Contents][Index]

### 2.10 The disk drive emulation

All the emulators support up to 4 external disk drives as devices 8, 9, 10 and 11. Each of these devices can emulate virtual Commodore 1541, 1541-II, 1571, 1581, 2031, 2040, 3040, 4040, 1001, 8050, 8250, and D9090/60 drives in one of the following ways:

- using disk images, i.e., files that contain a dump of all the blocks contained in a real floppy disk;
- accessing file system directories, thus giving you the use of files without having to copy them to disk images; this also allows you to read and write files in the `P00` format.
- accessing a real device connected to the host machine. This works using the OpenCBM library. You can get it from https://spiro.trikaliotis.net/opencbm.

When using disk images there are two available types of drive emulation. One of them the virtual drive emulation. It does not really emulate the serial line, but patches the kernal ROM (with the so-called kernal traps) so that serial line operations can be emulated via C language routines. This emulation is very fast, but only allows use of standard DOS functions (and not even all of them). For real device access it is required to enable this type of emulation.

The IEEE488 drives (2031, 2040, 3040, 4040, 1001, 8050, 8250, and D9090/60) do not use kernal traps. Instead the IEEE488 interface lines are monitored and the data is passed to the drive emulation. To use them on the C64, you need to enable the IEEE488 interface emulation. Only if the IEEE488 emulation is enabled, those drives can be selected.

The other alternative is a true drive emulation. The Commodore disk drives are provided with their own CPU (a 6502 as the VIC20 and the PETs) and their own RAM and ROM. So, in order to more closely emulate its features, a complete emulation of this hardware must be provided and that is what the hardware level emulation does. When the hardware level emulation is used, the kernal routines remain unpatched and the serial line is fully emulated. The problem with this emulation is that it needs a lot of processing power, mainly because the emulator has to emulate two CPUs instead of one.

The PETs do not use a serial IEC bus to communicate with the floppy drive but instead use the parallel IEEE488 bus. This does byte by byte transfers, as opposed to the bit by bit transfers of the C64 and VIC20, so making it feasible to emulate the parallel line completely while emulating the drive at DOS level only. The IEEE488 line interpreter maps the drives 8-11 (as described above) to the IEEE488 disk units, and no kernal traps are needed. The same emulation of the Commodore IEEE488 bus interface is available for the C64 and the VIC20. With IEEE488 drives you can have true 2031 emulation at unit #8, and still have filesystem access at units #10 or #11, because monitoring the IEEE488 lines does not interfere with the true drive emulation.

The IEEE488 disk drives 2040, 3040, 4040, 8050 and 8250 are Dual Drive Floppy Disks. This means that these drives handle two disks. To accomplish the emulation, only two disks can be emulated, namely units #8 and #10. The attached image, track display and LED display of unit #9 and #11 are used for the second drive of the dual disk drives. On unix the unit number display (8 or 9, 10 or 11) in the emulation window changes to the drive number display (0 or 1).

The Commodore 2040, 3040, 4040, 1001, 8050, 8250, and D9090/60 drives are so-called "old-style" disk drives. Their architecture includes not one, but two processors of the 6502 type, namely a 6502 for the file handling and communication with the PET (IP), and a 6504 (which is a 6502 with reduced address space) for the drive handling (FDC). Both processors communicate over a shared memory area. The IP writes commands to read/write blocks to this area and the FDC executes them. To make the emulation feasible, the FDC processor is not emulated cycle-exactly as a 6504, but simply by checking the commands and executing them on the host. This provides a fast FDC emulation, but disallows the sending the FDC processor commands to execute code. Applications where this is necessary are believed to be rather seldom. Only the format command uses this feature, but this is checked for.

The dual disk drive 2040 emulates one of the very first CBM disk drives. This drive has DOS version 1. DOS1 uses an own disk type, that is closely related to the 1541 disk image. Only on tracks 18-24 DOS1 disks have a sector more than 1541 disks. DOS1 disk images have the extension .d67.

The dual disk drives 3040 and 4040 use the same logical disk format as the VC1541 and the 2031. In fact, the 4040 was the first disk with DOS version 2. The 3040 emulated here originally was the same as 2040, only for the european 30xx PET series. As many of the original DOS1 disk drives were upgraded (a simple ROM upgrade!) to DOS2, I use the 3040 number for a DOS 2.0 disk drive, and 4040 for a revised DOS 2 disk drive. It is, however, not yet clear whether the disks here are write compatible to the 1541, as rumors exist that the write gap between sectors is different. But read compatible they are. As VICE emulates the FDC processor in C and not as 6504 emulation, this does not matter in VICE.

The drives 1001, 8050 and 8250 do actually have the very same DOS ROM. Only the code in the FDC is different, which is taken care of by VICE. So for all three of those disk drives, only `dos1001` is needed. The DOS version used is 2.7.

The D9090/60 is the only Commodore branded hard drive produced for the PET series computers, and were often used by C64 and C128 users for their significant storage capacity (29162/19441 free blocks). Just like the other IEEE drives before it, it uses a separate CPU as the FDC which in turn communicates with the SASI-to-ST506 bridge (which is controlled by an AM2910). The hardware design is very similar to the 8050/8250 drive.

Creative Micro Designs (CMD) produced the last drives for the Commodore 8-bit systems. They first released the hard drive (HD) line, and later the floppy drive (FD) line. The CMD HD series can support up to 4 GiB HDs with 255 separate partitions, while the CMD FD series can support up to 3.3 MB extended density floppy disks with 31 separate partitions. The FD series are also backwards compatible with 1581 media. The DOS for the FD series is stored on a ROM (`dos2000` and `dos4000`, the latest versions being 1.40).

The CMD HD uses a small boot ROM (`dosCMDHD`, the latest version is 2.80) which loads the primary DOS (latest is 1.92) off the HD itself. This allows for easy upgrades and expandability. This is also the only drive to use the front panel buttons to control the mode of the drive on reset. There are three modes of operation: normal, configuration, and installation. VICE supports placing the drive in either of these modes through the "Reset" sub-menu on the status bar for the GTK3 interface, and the "Reset" menu in the SDL interface. When creating a new DHD image, simply create an EMPTY file and VICE will automatically place the drive in installation mode. Once the DOS is installed, the CMD "hd-tools" program can be used to configure various settings and partition the drive; this is done in configuration mode for safety. When in either configuration or installation mode, the device number is set to 30. Therefore, it is not suggested to place two or more CMD HDs in either of these modes on the same bus at the same time. When migrating from real CMD hardware, use any HDD imaging software ("dd" or GNU "ddrescue" on Linux) to copy the raw contents of a device to a file. The destination file should have a "DHD" extension. For those users with multiple disks, SCSI ID 0 should have the extension "DHD", but any other drives should have ".S<ID>0" where <ID> is the SCSI ID. Place all the files in the same folder when attaching to the "DHD" file. The other files will automatically be scanned for and connected as well. The CMD HD boot ROM is used for partition management, and ALL versions have a known bug which corrupts data when deleting paritions across multiple SCSI drives. To avoid this scenario, it is highly suggested that another full DHD image be created in VICE (on another unit) and all the files be copied over from multi-disk configurations, using CMD "fcopy" for example, to the new unit. This will allow the user to take advantage of all the CMD HD features without the potential for data loss.

Next: Supported file formats, Previous: The joystick emulation, Up: About VICE [Contents][Index]