
                              F64Check 0.10 beta

  This program checks F64 files, created by FCOPY-PC, and displays information
about unusual sectors on the screen.



  1. Usage

  Run the program without any command line parameters:

  F64CHECK

  The program reads through all '*.f64' files in the current directory and all
subdirectories. If the corresponding disk images (the name is the same but the
extension is '.d64') are present  then  those  are  processed,  as  well.  The
program can only handle short file names.

  For valid F64 files, information about each  sector,  marked  as  'bad',  is
displayed. Also, the sector header  signature  byte  is  checked  against  the
default value and a message is displayed upon a  mismatch.  If  a  valid  disk
image is present then the computed checksum of each sector is compared against
the checksum stored in the F64 and a message is displayed upon a mismatch.

  When all files have been processed, a grand total  is  displayed  about  the
number of files processed, the number of bad sectors per each status code  and
the number of mismatching header signature bytes and data block checksums.



  2. Messages

  File-related messages are the following:

  - filename.f64:INVALID FILESIZE
    The F64 file has an invalid file size. Valid file sizes  are  2.051  bytes
    (35 tracks) and 2.306 bytes (40 tracks).
    An error; the F64 file is not processed further.
  - filename.d64:INVALID FILESIZE
    The disk image has an invalid file size.  Valid  file  sizes  are  174.848
    bytes (35 tracks, no error info block), 175.531  bytes  (35  tracks,  with
    error info block), 196.608 bytes (40 tracks,  no  error  info  block)  and
    197.376 bytes (40 tracks, with error info block).
    An error; the disk image is not processed further but the F64 file is.
  - filename.d64:XX/YY TRACK NUMBER MISMATCH
    The disk image has a different number of tracks (XX tracks) than  the  F64
    file (YY tracks). The two files, most probably, don't belong together.
    An error; the disk image is not processed further but the F64 file is.
  - filename.d64:ERROR INFO PRESENT
    The disk image contains an error info block. Because an F64 file  is  also
    supposed to contain similar information, it is possible that the two files
    don't belong together.
    A warning; the disk image is further processed.
  - filename.d64:"XX"/"YY" HEADER/BAM ID MISMATCH
    The sector header ID in the F64 file and the BAM  ID  (two  bytes  at  the
    offsets $A2-$A3 in sector 18;00) in the disk  image  are  different.  Note
    that PETSCII characters in the ID's are converted  to  ASCII  and  unusual
    PETSCII characters are displayed in the hexadecimal form of "\$xy".
    An information.

  In sector-related messages, "TT" and "SS" are the track  and  sector  number
where the problem occurs:

  - filename.f64:TT;SS:"X" INVALID ERROR
    An invalid sector status code of "X" was found.  Most  probably,  the  F64
    file is damaged. (See the list of codes, currently known as valid, below.)
    Note that the PETSCII status  code  is  converted  to  ASCII,  an  unusual
    PETSCII character is displayed in the hexadecimal form of "\$xy".
    A warning; the F64 file is further processed.
  - filename.f64:TT;SS:"X" error
    The sector is marked as 'bad', with status code "X", in the F64 file.
    An information.
  - filename.f64:TT;SS:XXX/YYY block sign
    The data block signature byte is invalid; XXX is  the  value  in  the  F64
    file, YYY is the valid value.
    An information.
  - filename.f64:TT;SS:XXX/YYY checksum
    The checksum, computed from the data in the disk image, does not match the
    checksum in the F64 file; XXX is the checksum in the F64 file, YYY is  the
    one computed from the disk image.
    An information; can only appear if a valid disk image is also present.
  - filename.f64:TT;SS:MULTIPLE ERRORS
    More than one error occurred for the  sector.  Probably,  the  errors  are
    somehow related to each other.
    An information.



  3. The structure of F64 files

  F64 files are companion files for disk  images.  They  are  created  by  the
C64-to-PC transfer program called FCOPY-PC. The original program is FCOPY III,
by Thomas Tempelmann, which has been heavily modified and  C64-to-PC  transfer
functionality added by M. Edzes; see http://d81.de/FCopy_III/ for more  infos.
F64 files appear in a large number on the Unicorn  CD  whose  homepage  is  at
http://www.whiz-zards.com/Sell/c64cd96.shtml.

  The following structure description, at some places, is a  mere  assumption,
based on sample F64 files and by reverse engineering the C64 part of FCOPY-PC.

  The first two bytes of F64 files contains a single sector header ID for  the
complete disk. It is unknown which sector this header ID comes from - perhaps,
the BAM sector, sector 18;00. It is also  unknown  why  there  are  no  sector
header ID's for each sector.

  The remainder of F64 files consists of three-byte blocks  for  each  sector.
The first byte of the three is a (lowercase PETSCII) character, a status code:

  - "+": 00,OK; the sector is fine.
  - "-": 00,OK; the sector is fine. For an unknown reason,  sectors  that  are
    considered to be empty (their contents  match  the  original  1541  format
    pattern: XX-$01-$01-...-$01, the first byte does not  matter)  are  marked
    with this status code rather than "+".
  - "?": Unknown; it is assumed to also stand for the sector being fine.
  - "H": 20,READ ERROR; no header can be found for the sector.
  - "S": 21,READ ERROR; there are no SYNC marks on the track at all.
  - "I": 22,READ ERROR; the signature byte of the data block  has  an  invalid
    value.
  - "C": 23,READ ERROR; the checksum stored in the data block does  not  match
    the checksum computed from the actual data.
  - "L": 24,READ ERROR; an invalid GCR pattern is present in  the  data  block
    (does not occur on 1541 drives normally).
  - "F": 25,WRITE ERROR; the data written onto the disk  does  not  match  the
    data read back upon verification.
  - "P": 26,WRITE PROTECT; the sector can't be written onto the  disk  because
    the write protection notch is not cut out.
  - "H": 27,READ ERROR; the checksum stored in  the  sector  header  does  not
    match the checksum computed from the actual data.

  The second byte of the three is the data block  signature  byte.  This  must
have the value of $07; if it doesn't, the 1541 drive returns 22,READ ERROR.

  The third byte of the three is the data block checksum. This must match  the
checksum generated by XOR'ing the 256 data bytes of the sector; if it doesn't,
the 1541 drive returns 23,READ ERROR.

  It is worth mentioning that:

  - As the original FCOPY III is  capable  of  copying  35-track  disks  only,
    FCOPY-PC also creates 35-track disk images and F64  files  only.  So,  you
    will, most probably, never see 40-track F64 files - unless created by some
    other FCOPY-compatible transfer or conversion program.

  - Sector status codes "I" (22,READ ERROR) and invalid sector signature bytes
    always come in pairs. This is obvious as the latter is the reason for  the
    former.

  - Sector status codes "C" (23,READ ERROR) and mismatching  checksums  always
    come in pairs. This is obvious as the latter is the reason for the former.

  - Sector status code "H" stands for both 20,READ ERROR  and  27,READ  ERROR.
    The reason for this is unknown. A hint could be that, because of  the  way
    the 1541 DOS works internally, a mismatching sector header  checksum  (the
    reason for 27,READ ERROR) can also cause the sector header to not be found
    (the reason for 20,READ ERROR). It is recommended that conversion programs
    convert this status code to 27,READ ERROR as  that  is  the  less  serious
    error.

  - There is no status code for 29,DISK ID MISMATCH which is also an important
    disk error. Probably, the lack of support for this error is related to the
    lack of header ID's for each sector in F64 files.



  4.  Copyright and legal issues

  The source of this program is public domain and provided here "as  is"  -  I
don't feel like commenting it more but if you have problems then feel free  to
ask me. If you derive your own program from the source or put a  part  of  the
source into your own program, please, give me a credit and send a copy to me.



  5. The author

  If you're interested in some similarly useful utilities you can  contact  me
at sta@c64.org or visit my homepage at http://sta.c64.org.

  Joe Forster/STA
  5th January, 2003
