1581CP51.ZIP             1581-Copy, version 0.51               1999-08-17


(C) Copyright 1998, 1999 Wolfgang Moser,
    published under the GNU public license

    1581-Copy is an official FairLight tools release,
    visit FairLight at http://www.fairlight.to.


1. Introduction
2. Troubleshooting
3. Parameter description
4. Some details about the sector layout of MFM encoded Commodore disks
   and the internals of 1581-Copy
5. Linux and Commodore MFM encoded disks
6. The Credits
7. Additional and distribution info
8. Contact


1. Introduction

   This is version 0.51 of the CBM 1581 floppy disk copy util for DOS. It
   should be able to im- or export a CBM 1581 disk within 39 seconds on a
   PC based 3.5" floppy drive and disk controller. There are also some
   informations about Linux and Commodore disks included.


   If you don't have some 3.5" DD disks anymore, but want to test this
   tool you can do the following: Get a normal 1,44 MB 3,5" HD disk and
   close the second detection whole (it's on the other side of the write
   protection switch) on the floppy disk by putting some adhesive tape
   over it. Take notice, that writing won't work with this method on
   drives that contain a DD mechanic only (720 KB).
   But some CBM 1581 disk drives and most of the PC floppy drives contain
   HD mechanics (1,44 MB), that are able to write "taped" HD disks. I
   don't know, what happens, if you replace your CBM 1581 drive mechanic
   by a PC based HD drive mechanic (1,44 MB disk drive), because I never
   tested it, I do own only some CBM 1541 disk drives myself. Don't ask,
   how I was able to write this utility without having a CBM 1581,
   otherwise you may think, that I'm very crazy or simply mindless!

   Included within this package is a user menu configuration file for
   The Star Commander. It supplies the Commander with some very simple
   methods for importing and exporting disk images from and to drive A:
   (press F2, when browsing the standard file system). Importing disks
   without overwrite takes only the first part of the filename (without
   extension) and generates a new filename with the appropriate extension
   (D81 or D2M). Be sure to select a file with the correct extension, if
   you want to use importing with overwrite. If you want to import into
   a completely new generated file, you have to create a new empty image
   first (Shift-F1) followed by renaming it to the correct extension. It
   doesn't matter, if the file has the wrong file size, 1581-Copy
   corrects this, if overwrite importing is selected.

   There's a modified floppy disk parameter table for Linux included into
   this package. This way you should be able to do image file transfers
   under Linux, too. First the GAP sizes for the CBM1581 parameter have
   been adjusted to a better working value, secondly a parameter for CMD
   FD2000 support has been added. Try it out, if you are Linux'ed.


2. Troubleshooting

   You may encounter some problems, if your floppy disc controller is of
   some unusual type or if you run this tool under multitasking
   environments. 1581-Copy has some parameters, that control, how the
   tracks of the floppy are accessed. Please try out the following
   sequence, if your drive doesn't reach a im-/export speed of less than
   40 seconds per disc:

     1. Enable the multiple sector feature and specify an interleave of
        two (/P /I:2). Attention, on some rare systems, the multiple
        sector feature may crash the system (hangup). If the transfer
        gets a better performace now, you may try to choose the default
        interleave of 1 (only selecting /P).

     2. If the multiple sector feature doesn't work on your system or
        doesn't help, you should specify an interleave of 2 only (/I:2),
        but this will slow down the disk transfer time to 70 seconds.

     3. Try out higher interleaves, but be warned, this will decrease
        the transfer performance heavily. Nevertheless, it may be higher
        than without any parameter.

     4. If you can't optimize the performance on your system and want to
        transfer only a single file, you should delete all unused files
        from the disk (with your C64) or the disk image (with The Star
        Commander or another tool). Then try out the BAM copy switch
        (/B), this transfers only tracks which are allocated by the file.

     5. If disks aren't recognized by 1581-Copy "CBM incompatible disk
        media detected", but you are sure, that this is a disk recognized
        from your CBM 1581 floppy, disable the "swapped side ID" media
        check (/D). This prevents 1581-Copy from doing too much
        consistency checks.


3. Parameter description

   1581COPY [/F[:x]][/V][/B][/M][/P][/D][/I:n][/T:nnn] [SRC] DST

     SRC - This is the source disk or image file. If you read a disk, it
           must be a filename. If you write or format and write a disk,
           this must be a disk drive (A: or B:). When you want to format
           disks only, this parameter must not be specified.

     DST - This is the destination disk or image file. If you read a
           disk, it has to be the disk drive (A: or B:). If you write or
           format and write a disk, it must be a filename. When you want
           to format disks only, this parameter selects the disk drive,
           which does the formatting.


     /F[:x]
         - This switch enables formatting. If you are in the write mode,
           the disk is formatted before writing any contents to it. If
           the disk is not in write mode, this switch selects formatting
           only. You mustn't specify the SOURCE parameter then. If
           formatting only is selected, an empty default BAM is written
           to the disk and a system partition on CMD FD2000 disks, too.
           With the additional parameter 'x' you are able to specify the
           destination format; 2 selects the CMD FD2000 disk format, 1
           selects the CBM 1581 format. If this parameter is not
           specified and you aren't writing an image to the disk, always
           the CBM 1581 is selected.

     /F:W  Note: This switch has been disabled again in version 0.51 and
                 later, it can be enabled by commenting out a #define in
                 CENTRAL.H and recompiling the source. You could download
                 version 0.50 alternatively, if you want to test this
                 feature.
         - This switch let's 1581-Copy use a very special floppy disk
           controller command, that is available on intel's 82078
           controller. This makes it possible to format and write a track
           at once. But because I couldn't find a computer or mainboard
           that contains such a controller, this feature couldn't be
           tested. Therefore if you select this switch and 1581-Copy
           detects the controller as "intel 82078 compatible", verify is
           enabled to make sure, that this command works as expected. If
           you think you own such a working controller please
           (PLEASE !!! :-) send me a report with the FDC type and
           version, the command line switches and something else you did.

     /V  - This switch enables the verify mode. It can be used, if you
           write and/or format disks. It doesn't compare the disk
           contents written with the source buffer again, but does a CRC
           check of the written data only.


     /B  - Enables _simple_ BAM copying. Only tracks with allocated
           blocks on it are transferred. Take notice, that BAM copying is
           currently only supported on CBM 1581 disks. I didn't do this
           for CMD FD2000 disks, because of their much more complex
           partitioning system. If someone installs different partitions,
           I would have to check all the BAMs of all these partitions.

     /M  - Enables mass importing or formatting with least user
           interaction. You can read or only format multiple disks, if
           you enable this switch. After a disk has been processed,
           1581-Copy proceeds automatically after a disk change has been
           detected. If reading is selected, new filenames are generated
           automatically with Joe Forster's indexing algorithm. Multiple
           disk writing is _not_ possible.

     /P  - Enables the "read/write multiple sectors" FDC feature. On some
           controllers (e.g. Adaptec 2842), this can help fixing speed
           problems. Pay attention, that this switch could cause a hangup
           of your computer system and many other problems.

     /D  - Disables the "swapped side ID" CBM format check. If 1581-Copy
           complains about a "CBM incompatible disk media detected" but
           you are very sure, that you created and/or used this disk on a
           CBM 1581 (CMD FD2000) disk drive, you should try out this
           parameter. But be warned, the data read may be incomplete,
           wrong or corrupted. If you want to write to such a disk, it
           would be much better to reformat the disk while writing.

     /I:n
         - Specify an interleave factor for higher transfer speed on very
           slow FDCs. If your system is not able to read sectors
           continously from the disk, you should specify an interleave
           factor of 2. The transfer will need 70 seconds then, but this
           may be faster than without specifying an interleave. Values
           from 0 to 9 are possible, 1 is the default. If you specify the
           /P parameter too, the selected interleave is only used, if
           verify is enabled or a multiple sector transfer fails, so that
           the normal transfer is used.

     /T:nnn
         - Specifies the number of retries to do, if an error occurs. The
           default are 3 retries on every access.


     Some parameter examples:
           1581COPY A: 1581IMG.D81 /T:999  - read an errornous 1581 disk
           1581COPY A: /F:2 /M             - format multiple FD2000 disks
           1581COPY TESTDISK.D81 B: /B     - BAM copy an image to A:
           1581COPY NEWDISK.D2M A: /F /V   - format, write and verify
           1581COPY /F A:                  - format a D81 in drive A:
           1581COPY A: NEWDISK /M /P       - read multiple disks from A:


4. Some details about the sector layout of MFM encoded Commodore disks
   and the internals of 1581-Copy

   Each sector of a MFM encoded disk contains a sector header like the
   GCR encoded disks, too. Each sector header contains a cylinder number
   and a disk side descriptor byte that normally corresponds to the
   mechanically selected track and head number. The third byte holds the
   sector number and the forth byte descibes how many bytes are stored
   within this sector.
   But there is a little difference between IBM-PC formatted disks and
   CBM related formatted disks. On IBM-PC disk layouts sectors of the
   logical side 0 are stored to the physical side 0 (accessed by head 0),
   sectors of the logical side 1 are stored to the physical side 1.
   On CBM related disk formats (e.g. CBM 1581, FD2000 native) the both
   sides are swapped. Sectors of the logical disk side 0 are stored onto
   the physical disk side 1 (head 1), sectors of the logical side 1 are
   stored onto the physical disk side 0 (head 0). This implies, that the
   sector header disk side descriptor bytes are "wrong", too. A physical
   disk side 0 contains only sector headers, where all the disk side
   descriptors contain the value 1.
   After serveral reports, I assume, that the CBM 1581 disk drive doesn't
   recognize these disk side descriptors, so that there may exist floppy
   disks where the disk side descriptors on both sides are marked with 0.
   I tried to implement 1581-Copy in a way, so that it is also able to
   ignore the disk side descriptors, but as you may know, this cannot be
   done perfectly, because the FDC always wants to know the correct disk
   side descriptor for the sector to read/write/verify. So 1581-Copy does
   the following: For each track to copy, 1581-Copy determines the side
   descriptor value of the first sector the FDC is able to read. Then it
   uses this value as the side descriptor for the whole track operation.
   Along with the side descriptor value, 1581-Copy gets the sector number
   to determine the sector number to start the track operation with.


    The CBM 1581 disk sector layout:

      Number of cylinders:          80, physically numbered from 0 to 79,
                                        logically numbered from 1 to 80
      Number of sides per cylinder:  2, physically stored on side 1 and 0
      (also described as tracks)        logically numbered 0 and 1
      Number of sectors per track:  10, physically and logically numbered
                                        from 1 to 10
      Number of bytes per sector:  512


    The CMD FD 2000 disk sector layout:

      Number of cylinders:          81, physically numbered from 0 to 80,
                                        logically numbered from 1 to 81
      Number of sides per cylinder:  2, physically stored on side 1 and 0
      (also described as tracks)        logically numbered 0 and 1
      Number of sectors per track:  10, physically and logically numbered
                                        from 1 to 10
      Number of bytes per sector: 1024

      Note: The logical numbering of the cylinders may not be correct.
            But at least _I_ will do number the cylinders from 1 to 81,
            because the analysis of an image I got showed me, that the
            logical sector chaining uses the same numbering mechanism.
            Because I don't know nothing about CMD partitions, that may
            be wrong.


   Whenever the disk sector size contains more than 256 bytes, CBM drives
   divide such big physical sectors into several logical sectors, that
   all contain 256 bytes. Therefore the physical sector size must be a
   multiple of 256.

   Currently I don't know any utility, that can handle other disk images
   than CBM 1581 ones (D81). When I add disk image transfer support for
   other CBM related MFM disk formats, it may be of no use for you,
   because you can't handle the file contents of these images. It's up
   to you to find out, how the file contents of these images can be
   handled, because I don't want and never will implement file based
   support into 1581-Copy. It may be the job of Peter Schepers (64 Copy),
   Bernhard Schwall (Trans64) and Joe Forster/STA (The Star Commander) to
   integrate file access support into their utilities. You can support
   them by sending reports of any information you know or find out about
   unknown CBM disk formats. You can send me such reports, too, I'll
   forward them, but please write in english, I don't want and am
   absolutely unable to be a translation machine for you. And you should
   wait until the desired disk format is supported by 1581-Copy, because
   it may be of no use, when we know how to handle files of a disk image,
   that cannot be transferred to and from real disks.


5. Linux and Commodore MFM encoded disks

   As you may have noticed, there's a Linux floppy disk parameter table
   included in this distribution. This is done, because I learned much
   from the Linux floppy driver about supporting MFM encoded Commodore
   disks. But I recognized, that the parameters for the CBM1581 format
   normally stored in /etc/fdprm were not optimally. The GAP size of this
   parameter was too big, as I figured out with 1581-Copy. So I created a
   possibly better working entry, that should be much more compatible to
   Commodores format. Later, when I started implementing support for CMD
   FD2000 disks, I created an entry for Linux, too.
   If you are a Commodore and Linux power user, you should get Alain
   Knaff's fdutils, it can be downloaded from Alain's pages:

        http://alain.knaff.linux.lu/
        http://fdutils.linux.lu/index.html
     or simply ftpsearch for: fdutils-5.3.tar.gz

   The package is the most massive attack against floppy disk drives,
   that I've seen ever. You should be able to read/write nearly any FM
   and MFM encoded disks. The distribution contains a README file, that
   describes, how to integrate autodetection support for the CBM 1581
   format into Linux, here's a shorted description:

        mknod /dev/fd0cbm1581 b 2 124
        setfdprm /dev/fd0cmb1581 1600 10 2 80 2 0x0C 0x02 0xDF 0x23
        floppycontrol --autodetect /dev/fd0 31,7,8,4,25,28,22,21

   The second and third entry have to be issued after each reboot, so you
   have to integrate the command into your startup scripts (e.g. init.d).
   Take notice, that I haven't tested this configuration with the changed
   parameters (gap sizes) for setfdprm, I don't know, if the
   floppycontrol parameters have also to be changed. And there's no such
   configuration available for CMD FD2000 disks; if I find some fun in
   experimenting with this I'll tell you about.


6. The Credits

   This list is created in more or less cronological order to describe
   the history of 1581-Copy (you should also check SRC\HISTORY.TXT).

	Greets go to... (am I writing an intro or demo??? :)

     Womo aka Wolfgang Moser <womo@mindless.com>
       If he wouldn't have born 1969-07-27-22:03, I would neither know
       what or who I am, nor why I like such sophisticated things like
       programming calculators.
       
     Nicolas Welte <welte@chemie.uni-konstanz.de>
       A man like me, very hardware interested. After I joined The Star
       Commander beta testing crew, we had hundreds of email discussions
       about all these hardware based design questions. Our greatest work
       was the design of the XE1541 cable, I think. Don't think, that
       only 4 diodes can impossibly cause any trouble.

     Joe Forster/STA aka Kovcs Balzs <sta@c64.org>
       If I wouldn't have had so many discussions with Joe about so many
       different C64 related things, this project would have never been
       started. It was the The Star Commander, that has let me start
       thinking about such a smart technology, like direct CBM 1581 disk
       access.

     Marko Mkel <msmakela@cc.hut.fi>
       I think he is one of the real gurus of the european CBM scene,
       thanks for simply beeing there.

     Jens-Michael Gross <grossibr@buran.fb10.tu-berlin.de>
       He wrote READ81, the first IBM-PC/DOS transfer utility, that was
       and is able to read CBM 1581 formatted disks. He showed me, that
       it must be possible to do the same myself. The difference is, that
       his util is shareware and he doesn't distribute the sources of it.
       So there was no possibility to integrate his routines into The
       Star Commander. His util is able to do direct file accesses on CBM
       1581 disks. To protect his work and to prevent me from
       implementing too much uninteresting stuff, I decided, that
       1581-Copy should be a disk image transfer utility only without any
       file handling support.

     Zenith Data System
       Their Technical Reference Manual teached me in accessing and
       programming different hardware components of the IBM-PCs (like
       the LPT ports, the IRQ and the DMA controller).

     Dan Fandrich <dan@fch.wimsey.bc.ca>
       He wrote a CBM 1581 disk driver and filesystem access utility for
       Linux and some wonderful documentation, that could explain me,
       why it is so difficult (is it really?) to access CBM 1581 disks
       with IBM-PC based operating systems (the disk side swap).

     Christoph H. Hochsttter <christoh@microsoft.com>
       His DOS utility FDFORMAT was my first step into learning how to
       do direct floppy disk controller programming.

     Ciriaco Garca de Celis <ciri@gui.uva.es>
       The "son" of Christof Hochsttter, he wrote the tools 2M, 2MGUI
       and 765DEBUG. Without the sources of 765DEBUG, I wouldn't have
       been able to implement the low level FDC routines. If you compare
       the sources, you will see, that I derived the whole low level FDC
       accessing routines from the sources of 765DEBUG. Well, in the
       meantime I did so many restructures, that you won't see anything
       anymore :-)

     Ralf Brown <ralf+@cs.cmu.edu>
       His interrupt list at http://www.pobox.com/~ralf/files.html is the
       greatest resource for IBM-PC based low level programming people,
       that helped me very much in improving different routines and
       especially in learning how to program the DMA controller.

     Sorex/WOW aka Geert Verschueren <Sorex@skynet.be>
       One of my first testers. He owns a very sophisticated test
       platform, a 386DX running Windows 95.

     Pontus Berg <Bacchus@FairLight.Org>
       The maintainer of the best sorted and commented CBM related tools
       page. Thanks for publishing 1581-Copy on your page and the
       invitation for letting 1581-Copy become a FairLight tools release.

     Andreas Boose <boose@Linux.RZ.FH-Hannover.DE>
       He supported me with informations from the IBM PC/AT technical
       reference manual and just informed me, that he plans to integrate
       direct CBM disk access support into a future version of VICE for
       DOS, this is really a great idea, isn't it.

     Near Letter Quantity aka Jochen Adler <NLQ@gmx.de>
       This is the author of several floppy speeder improvements, like
       SupraDOS, SuperJiffyDOS and SuperJiffyDOS for the 1541. He
       provided me with several informations about the CBM 1581 and
       espcially some analyses about the exact track format. Without him,
       I wouldn't have been able to solve the problem with the different
       (wrong) GAP sizes of the earlier versions.

     Johannes Schulze-Oechtering <st0159@aixrs1.hrz.uni-essen.de>
     Mark Seelye <mseelye@yahoo.com>
       These both people were pushing me for integrating CMD FD2000
       support into 1581-Copy. The rough FD2000 support of 1581-Copy is
       mainly their merit. Mark did some special tests, so that I was
       able to identify the low level disk layout for the first time.
       Johannes did send me some native CBM 1581 formatted disks, so
       that I could test the new adjusted GAP sizes.

     Credo/SCS*TRC aka Ray Nemes <credo@bigfoot.com>
     MagerValp aka Per Olofsson <cl3polof@cling.gu.se>
     Frank Reichel <Frank.Reichel@forchheim.baynet.de>
       These people are also in the 1581-Copy test crew and helped me
       debugging 1581-Copy by writing test reports from time to time.

     Ingo Korb <unseen@gmx.net>
       He reported some problems in combination with the C64 copy suite
       Maverick. It seems, that Maverick creates 1581 disks, where the
       SideIDs on both sides of a 1581 disk are set to 0. This brought me
       to a good idea how to make 1581-Copy independent from the SideIDs.

     Alain Knaff <Alain@linux.lu>
       A little bit late, I discovered Alain Knaff's fdutils for Linux,
       the most massive attack against floppy disks I have seen ever.
       He's also the man behind the Linux floppy driver. Nice to see,
       that a tool like 1581-Copy is not needed under Linux, except for
       the new introduced feature of ignoring SideIDs, like the CBM 1581
       floppy does.


7. Additional and distribution info

   Please read the history (SRC\HISTORY.TXT) for further version
   informations and much of the implementation background. And you should
   check the sources of course, perhaps you want to derive your own
   project from my work.


   If you are an owner or maintainer of a CBM related site please do
   place the util onto your site, if you find it useful.


   This, older or newer versions of 1581-Copy may be found on the
   following sites:

   - The "FairLight tools" page of Bacchus/FLT
       http://www.fairlight.to/tools/pc.html

   - The author's developer site
       http://www.dollar8000.de/womo/sourcen/sources.html
       http://advm2.gm.fh-koeln.de/~womo/sourcen/sources.html
   
   - The Star Commander site of Joe Forster/STA
       http://sta.c64.org/scextprg.html

   - Marko Mkels FTP site
       http://www.funet.fi/pub/cbm/transfer/misc
       ftp://ftp.funet.fi/pub/cbm/transfer/misc/


8. Contact

   Please send me bug reports, so that I can fix as most bugs as
   possible. Perhaps I should define this software as Anti-Shareware,
   where I pay _you_ for every _new_ bug you find and report to me :-)

   Redirected addresses:
      Wolfgang Moser <womo@fairlight.to>
       http://www.dollar8000.de/womo

   Current workplace (up to Dezember 1999):
      Wolfgang Moser <womo@advm2.gm.fh-koeln.de>
       http://advm2.gm.fh-koeln.de/~womo
