1571-11.TXT rev 1a 96-11-06 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * THIS DOCUMENT IS COPYRIGHT (C) 1988, 1996 BY HERNE DATA SYSTEMS LTD. THE MATERIAL CONTAINED HEREIN MAY BE FREELY USED FOR PERSONAL INFORMATION ONLY. IF YOU REPRODUCE IT, THIS COPYRIGHT NOTICE MUST NOT BE REMOVED. THIS MATERIAL MAY NOT BE EXPLOITED FOR COMMERCIAL PURPOSES. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Herne Data Systems Ltd., PO Box 250, Tiverton, ON N0G 2T0 CANADA. Voice/fax 519-366-2732, e-mail herne@herne.com, internet: http://www.herne.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Formatting MFM Disks on the 1571 Disk Drive The 1571 disk drive is capable of reading and writing a number of standard CP/M disk formats when used with a C-128 in CP/M mode including: IBM CP/M-86 single sided IBM CP/M-86 double sided Kaypro II single sided Kaypro IV double sided Osborne single sided Epson QX-10 double sided Epson Euro single sided? and Slicer 9 among others. These are all referred to as MFM (maximum frequency modulation) formats, based on the technique used to record the data on the disk. Normal Commodore DOS (eg. 1541 format) uses a method called GCR (group coded recording) which is totally different from MFM. There are several other differences between MFM and GCR disks. MFM disks generally have the same number of sectors on each track while Commodore GCR disks usually have different numbers of sectors for different ranges of track numbers. The numbering system for MFM tracks start from 0 and go to a high value (usually 39) while the sectors on each track are numbered from 1 to a high number. This is the opposite of Commodore GCR disks where tracks are numbered from one and sectors start at zero. Although Commodore CP/M can read and write in MFM formats with a 1571 drive, the current version of the FORMAT.COM program supplied on the CP/M system disk cannot create or format new disks in these extended disk formats. It is, however, quite simple to format disks in these or any other format you wish with a 1571 drive. In addition to the standard Commodore DOS commands, the 1571 has a few new ones. These commands, collectively defined as "burst mode" in the 1571 manual, allow you to read, write and format disks in virtually any format you choose. Most of the commands, such as those for reading and writing data from/to the disk, need fairly sophisticated machine language programming to access because the required high speed data transfer is under totally manual control. The extended "FORMAT" command is the simplest to use. It can be quite easily invoked from BASIC because high speed data transmission is not required. The description of the burst mode commands in the 1571 manual is at best cryptic and is often quite confusing. The syntax for the MFM FORMAT command can be simplified to: OPEN15,8,15,"U0"+CHR$(B1)+CHR$(129)+CHR$(0)+CHR$(B4)+CHR$(39)+ CHR$(B6):DCLOSE Where: B1 equals 70 for a single sided disk or 102 for a double sided disk; B4 equals 0 for 128 bytes per sector 1 for 256 bytes per sector 2 for 512 bytes per sector or 3 for 1024 bytes per sector; and B6 equals the number of sectors per track. The actual bit patterns for the various CHR$ after the U0 (the bit patterns for the first two parameters listed in the manual, bytes 0 and 1, are equal to the characters U0 for all of the burst mode commands) are explained in detail in the 1571 manual. I have simplified them here to make the command easier to use. There are other optional parameters which allow you to partially format a disk, format different areas of the disk in a different manner, change the sector slew rate, change the fill byte etc. These can be the basis of, for example, a simple yet very effective copy protection scheme you can use on your own disks and programs. Try re-formatting track 35 on a standard 1541 DOS disk with the command: OPEN15,8,15,"U0"+CHR$(198)+CHR$(129)+CHR$(0)+CHR$(0)+CHR$(35) +CHR$(10)+CHR$(34)+CHR$(34):DCLOSE. Then see what happens when you try to copy the disk, even with a whole disk nibble type copier for protected disks. If the program you wish to protect tries a random block read or write to this track, an error will result. If the drive (either a 1541 or 1571) does not return an appropriate read error code, then disk has been formatted in GCR and is obviously not an original. The re-formatting of track 35 should be done before you copy your program to the disk. This is to ensure that no valuable program data are lost by wiping out the track. In addition, you should use the DOS Block-Allocate command to allocate all of the sectors on that track to prevent DOS from accidentally trying to write there during a legitimate SAVE or other type of operation. Listing one, MFMFORMAT, is a short BASIC 7 program for use in C-128 native mode which allows you to effortlessly format disks in a number of different MFM formats on the 1571 drive. The data statements at the end of the program contain the required parameters (number of sectors per track, number of bytes per sector and number of sides) for each type of disk. These parameters can all be changed to create custom disk formats if you wish. However, most of the custom formats will not be supported by CP/M on the C-128. In addition, the line numbers for the DATA statments are very important due to the use of a calculated line number reference in line 30 for reading the selected data. LISTING 1: 10 PRINT" MFM DISK FORMATTER":PRINT" BY M. GARAMSZEGHY " 20 PRINT" OPTIONS: ":FORI=1TO5:READA,A,A,A$:PRINTI": ";A$:NEXT 30 INPUT" SELECT A FORMAT";F:RESTORE(F*10+100):READ B6,BS,SD,F$ 40 PRINT" FORMAT >> ";F$:PRINT" PRESS TO CONTINUE" 50 PRINT" OR PRESS ANY OTHER KEY TO ABORT ":GETKEYA$:IFA$<>CHR$(13)THENRUN 60 B5=39:S(0)=128:S(1)=256:S(2)=512:S(3)=1024:SI=0:IFSD=2THENSI=32 70 B1=70ORSI:FORI=0TO3:IFBS=S(I)THENB4=I:ELSENEXT 80 OPEN15,8,15,"U0"+CHR$(B1)+CHR$(129)+CHR$(0)+CHR$(B4)+CHR$(39)+CHR $(B6) 90 INPUT#15,A:DCLOSE:INPUT" FORMAT ANOTHER ";FA$:IFFA$="Y"THEN40 100 REM DATA #SECTORS PER TRACK,#BYTES PER SECTOR,#SIDES 110 DATA 8,512,1,"IBM CP/M-86 SINGLE SIDED" 120 DATA 8,512,2,"IBM CP/M-86 DOUBLE SIDED" 130 DATA 10,512,2,"KAYPRO IV DOUBLE SIDED" 140 DATA 10,512,1,"KAYPRO II SINGLE SIDED" 150 DATA 5,1024,1,"OSBORNE SINGLE SIDED"