Re: nibtools, GCR, G64

From: Nate Lawson <>
Date: Fri, 31 May 2013 17:43:48 -0700
Message-Id: <>
On May 31, 2013, at 5:34 PM, wrote:

> Ugh.. I eventually started getting some valid results out of this exercise. But in order to do more thorough tests, I need many different test cases, which means many more various examples of valid G64s than I have. Especially those, which are not byte-aligned, which wrap around somewhere in the middle of data, which have track gap wrapping around from $55s to $AAs, etc.
> Could you guys (Pete, Nate, maybe someone else too?) be so kind as to put up a good testing set for me somewhere for download? Or - if this is a problem - then just send in a private e-mail? I'd be grateful.

You can create them yourself using nibedit.{py,exe}. Pass in -t TRACKS and -r BITS to rotate the given track(s) right by the number of bits.

Here is the full usage (-h flag) to understand how it works.


usage: [-h] [-o] [-t TRACKS] [-r ROTATE] input_file [output_file]

Read/write data in the C64 G64 format and translate it to a text-based
TRK format for easy editing. The TRK file (.trk) can be edited by hand or
processed in-place by specifying various arguments to this program.
Afterward, it can be converted back to a G64 file.


Create a working file called "doc.trk", rotating tracks 2 and 3 right
by 207 bits before writing the output text file. This can be done in two
separate steps (creating and then processing).

  $ nibedit -t 2-3 -r 207 doc.g64 doc.trk

Rotate track 34.5 right by 2 bits and write the result back to the same
TRK file in place.

  $ nibedit -t 34.5 -r 2 --overwrite doc.trk

Convert a TRK file back into a G64 for testing. This will warn if the
"doc2.g64" file exists and would be overwritten.

  $ nibedit doc.trk doc2.g64

While converting an image, these options can be applied:

* Rotate entire track right any number of bits. Can be used to create
  track-to-track alignment, as well as bytewise alignment for emulators.

Future options not supported yet:

* Align start to first sync in image
* Align start to longest sync
* Align start to arbitrary byte pattern
* Align start to arbitrary sector number. Must have valid Commodore DOS

Images are processed in a text file format (.trk), which can be modified
in arbitrary ways, including:

* Insert, change, delete GCR bytes
* Change SYNC length, delete SYNCs, add them, etc. Syncs are decoded and
  list their length in number of bits. Example: SYNC:40 is a normal
  5-byte sync.
* Data is dumped as raw GCR, two 5-byte chunks per line (10 bytes GCR).
  Decoded data is displayed at the end of the line, after a # mark.
  All data after the # mark is ignored when reading a TRK file.
  GCR symbols that are not 8-bits long are described in binary with
  a trailing '.'. However, these non-hex values can only appear at the
  end of each track, not in the middle. Example: "1001." is "9" in 4 GCR bits.
* Specify arbitrary density for any byte ranges. Density is either a single
  int value (whole track) or a series of (start, end, density) tuples.
  (future, not supported yet)

positional arguments:
  input_file            file to be read (.trk or .g64 formats)
  output_file           file to be written (.trk or .g64 formats)

optional arguments:
  -h, --help            show this help message and exit
  -o, --overwrite       overwrite input file as output after processing via
  -t TRACKS, --tracks TRACKS
                        start through end (half)track to operate on. Example:
                        -t 1-1.5
  -r ROTATE, --rotate ROTATE
                        rotate the specified track(s) right by N bits
       Message was sent through the cbm-hackers mailing list
Received on 2013-06-01 01:02:01

Archive generated by hypermail 2.2.0.