News:

I've successfully built LOS from source!: https://lisalist2.com/index.php/topic,644.0.html

Main Menu

Disk image conversion utility

Started by RebeccaRGB, Today at 01:28:37 AM

Previous topic - Next topic

RebeccaRGB

Upon finding that ProFile images in dc42 format I've used in LisaEm do not work with the ESProFile, I took a deep dive into all the formats involved and produced the following utility, which I successfully used to convert the dc42 images to the raw format expected by the ESProFile:

https://github.com/RebeccaRGB/mooftools/blob/main/tools/dc42.py

To convert from the LisaEm format to the ESProFile format:

dc42.py -x -r lisaem -w esprofile -o out.image in.dc42
To convert from the ESProFile format to the LisaEm format:

dc42.py -x -r esprofile -w lisaem -o out.dc42 in.image
I made the tool able to read and write dc42 images and just about every raw format I could think of. The above commands are just shortcuts for the fully expanded form:

dc42.py --convert --read-format dc42 --write-format tdtd --sector-size 512 --tag-size 20 --deinterleave 0,13,10,7,4,1,14,11,8,5,2,15,12,9,6,3 --interleave none --output out.image in.dc42
resp:

dc42.py --convert --read-format tdtd --write-format dc42 --sector-size 512 --tag-size 20 --deinterleave none --interleave 0,5,10,15,4,9,14,3,8,13,2,7,12,1,6,11 --output out.dc42 in.image
All the options are explained in the built-in man page:

dc42.py --help
dc42.py - Verify, create, and convert DiskCopy 4.2 disk images.

Usage:
  dc42.py [-i|--info] [-v|--verify] <input-files>
  dc42.py -c <sector-count> [-s <sector-size>] [-t <tag-size>] \
          [-w <output-format>] [-n|--dry-run] <output-files>
  dc42.py -x [-r <input-format>] [-s <sector-size>] [-t <tag-size>] \
          [-d <interleave>] [-e <interleave>] [-w <output-format>] \
          [-o <output-spec>] [-n|--dry-run] <input-files>

Options:
  -i, --info
      Print DiskCopy 4.2 header information.
  -v, --verify
      Print and verify DiskCopy 4.2 checksum.
  -x, --convert
      Convert between DiskCopy 4.2 and raw image formats.
  -c, --create <sector-count>
      Create a new image with <sector-count> blank sectors.
  -r, --read-format <format>
      Specify format of input files. Default: dc42
  -s, --sector-size <bytes>
      Specify size of sector data in bytes. Default: 512
  -t, --tag-size <bytes>
      Specify size of tag data in bytes. Default: 0
  -d, --deinterleave <interleave>
      Deinterleave sectors after reading. Default: none
  -e, --interleave <interleave>
      Interleave sectors before writing. Default: none
  -w, --write-format <format>
      Specify format of output files. Default: dc42
  -o, --output <spec>
      Specify output directory, file path, or file name. Plain file names
      will be treated as relative to the parent directory of the input file;
      for the current directory, use ./ before the file name.
  -n, --dry-run
      Process arguments and read input files, but do not write any output
      files. Instead, only report which files would have been written.

Formats:
  dc42        DiskCopy 4.2
  lisaem      ProFile images used by the LisaEm emulator; equivalent
              to `-r dc42 -s 512 -t 20 -d lisaem` when reading
              or `-w dc42 -s 512 -t 20 -e lisaem` when writing.
  esprofile   ProFile images used by the ESProFile emulator; equivalent
              to `-r tdtd -s 512 -t 20 -d none` when reading
              or `-w tdtd -s 512 -t 20 -e none` when writing.
  tdtd        Raw format: tag, data; tag, data; ...
  dtdt        Raw format: data, tag; data, tag; ...
  dtxdtx      Raw format: data, tag, padding; data, tag, padding; ...
  tdxtdx      Raw format: tag, data, padding; tag, data, padding; ...
  txdtxd      Raw format: tag, padding, data; tag, padding, data; ...
  dxtdxt      Raw format: data, padding, tag; data, padding, tag; ...
  xtdxtd      Raw format: padding, tag, data; padding, tag, data; ...
  xdtxdt      Raw format: padding, data, tag; padding, data, tag; ...
  ddtt        Raw format: data, data, ...; tag, tag, ...
  ttdd        Raw format: tag, tag, ...; data, data, ...
  ddtxtx      Raw format: data, data, ...; tag, padding, tag, padding, ...
  txtxdd      Raw format: tag, padding, tag, padding, ...; data, data, ...
  dd          Raw format, data only: data, data, ...
  tt          Raw format, tags only: tag, tag, ...
  txtx        Raw format, tags only: tag, padding, tag, padding, ...

The padding size is always equal to the sector size minus the tag size.

Sector Count:
  720         MFM Single-Sided (360K)
  1440        MFM Double-Sided (720K)
  2880        MFM High-Density (1440K)
  800         GCR Single-Sided (400K)
  1600        GCR Double-Sided (800K)
  3200        GCR High-Density (1600K)
  1702        Twiggy (851K)
  9728        ProFile 5M (4864K; 4.75MiB)
  19456       ProFile 10M (9728K; 9.5MiB)

Tag Size:
  0           None
  12          Twiggy, Sony
  20          ProFile

Interleave:
  none        No interleave.
  lisaem      For ProFile images used by the LisaEm emulator; equivalent
              to `-d 0,13,10,7,4,1,14,11,8,5,2,15,12,9,6,3` when reading
              or `-e 0,5,10,15,4,9,14,3,8,13,2,7,12,1,6,11` when writing.
  0,3,1,2     A custom interleave. Specify sector numbers separated by commas.
              Must be a complete mapping with no duplicate or missing numbers:
              0,3,1,2 is valid; 0,3,1,1,2 and 0,3,2 are not.

Examples:
  Create a blank 5M ProFile image for LisaEm:
      dc42.py -c 9728 -w lisaem blank.dc42
    Equivalently:
      dc42.py -c 9728 -w dc42 -s 512 -t 20 -e lisaem blank.dc42
  Create a blank 10M ProFile image for ESProFile:
      dc42.py -c 19456 -w esprofile blank.image
    Equivalently:
      dc42.py -c 19456 -w tdtd -s 512 -t 20 -e none blank.image
  Convert a LisaEm ProFile image to an ESProFile image:
      dc42.py -x -r lisaem -w esprofile -o out.image in.dc42
    Equivalently:
      dc42.py -x -r dc42 -w tdtd -s 512 -t 20 -d lisaem -e none -o out.image...
  Convert an ESProFile image to a LisaEm ProFile image:
      dc42.py -x -r esprofile -w lisaem -o out.dc42 in.image
    Equivalently:
      dc42.py -x -r tdtd -w dc42 -s 512 -t 20 -d none -e lisaem -o out.dc42 ...
  Convert a DiskCopy 4.2 image to a raw image without tags:
      dc42.py -x -r dc42 -w dd -o out.img in.dc42

Enjoy!