ATR File header

struct sio2pc_image_hdr {
byte code_lo, code_hi; /* ID code = 0x0296 */
byte size_b1, size_b2; /* low 16-bits of size */
byte secsize_lo, secsize_hi; /* sectors size: 128/256 */
byte size_b3, size_b4; /* high 16-bits of size (paragraphs) */
byte resv[6]; /* reserved */
byte numerr_hi, numerr_lo; /* number of sectors with errors */
};

struct errormap {
byte sec_lo, sec_hi; /* sector with error */
byte cstat; /* communication status */
byte hstat; /* hardware status */
byte resv[4]; /* reserved */
};

Note that the size (which is stored in size_b1 through size_b4) is in paragraphs, or multiples of 16. Thus, take the total number of sectors, multiply by the sector size, and divide by 16, then store this result across those four bytes. (Actually, I might have added bytes 3 and 4 to it…. or someone else might have already. I can’t remember now)

Note that the errormap was an extension I added, but I’d like to see it get standardized, since they’re useful for some disks.

Basically, the errormap sits at the end of the data, and ’numerr‘ specifies the number of error records. Each one tells what sector should give an error when reading it, along with the  codes that should be given for the error. The reserved part could be used to add other information for really strange errors. (but make sure you publish the extensions, if you add any!)