/*
 *  Version 0.01 supported 1.2M drives only (fixed revolution time).
 *  Version 0.07 added weak bits table support, changed definition of
 *		 time_diff in SECTOR_INFO
 *  Version 0.09 added FM data support, refined definition of
 *		 time_diff in SECTOR_INFO.
 *		 This is first public release of CM, so data versions
 *		 below 0.09 should not be encountered (but they are still
 *		 supported)
 *  CM uses tag file format with variable records, i.e. in all future releases,
 *  first word of each entity will contain it's length (count word included),
 *  and second word - tag value. If CM will not be able to understand tag word,
 *  it will skip entity containing it.
 */
#define VERSION 	0x0009
#define TRACK_ID	0x55aa
#define SECTOR_ID	0x5350
#define COMMENT_ID	0x4F43

#pragma pack(1)
typedef struct	_x	{
	unsigned char    c, h, r, n ;
	long	time_diff ;
	char	hidden_ID ;		/* See enum below		*/
	} SECTOR_INFO ;

enum {  no_hidden, hidden_address, Super_Lock } ;

typedef struct	{
	unsigned	length ;	/* Length of TRACK_LAYOUT	*/
					/* length including this word ! */
	unsigned	id ;		/* Should be TRACK_ID		*/
	unsigned	version ;	/* CM version of data		*/
	char		cyl ;		/* Track number 		*/
	char		head ;		/* Surface number		*/
	char		rate ;		/* Data xfer rate		*/
					/* Bit 7 ( & 0x80 ) set if FM	*/
	char		count ; 	/* Sector count 		*/
					/* If zero,track causes MA error*/
	char		treatment ;	/* Sector treatment code	*/
					/* (see below)			*/
	long		revolution_time;/* Disk revolution time of	*/
					/* source disk			*/
					/* Reserved for version 1	*/
	SECTOR_INFO sectors[ 1 ] ;  /* C/H/R/N + spacing time   */
	} TRACK_LAYOUT ;

enum {					/* Treatment code definition	*/
	ORDINARY_TREATMENT,		/* Format all track, when	*/
					/* write all data		*/
	SPECIAL_FORMAT, 		/* Format sector by sector	*/
					/* to provide different 	*/
					/* intersector gaps, then write */
					/* all data			*/
	SPECIAL_WRITE,			/* Format & write sector by	*/
					/* sector to provide gaps,	*/
					/* CRCs, data in gaps and short */
					/* data 			*/
					/* Currently, SPECIAL_WRITE is	*/
					/* equal to SPECIAL_FORMAT	*/
	} ;

typedef struct	{
	unsigned	length ;	/* Length of SECTOR_LAYOUT	*/
	unsigned	id ;		/* Should be SECTOR_ID		*/
	int		data_length ;	/* If zero,missing data address */
					/* mark error occured		*/
	char		deleted ;	/* 1 if deleted data mark	*/
	char		data_code ;	/* see below			*/
	unsigned	weak_cnt ;	/* Number of bytes with weak	*/
					/* bits, weak_cnt words after	*/
					/* data[] (Version 0.07 or	*/
					/* above)			*/
	unsigned	reserved[ 1 ] ;
	char        data[1] ;    /* Sector data ( including CRC  */
					/* and gap data, if any 	*/
/*	unsigned	weak_table[] */ /* Weak data offsets from	*/
					/* the beginning of sector data */
	} SECTOR_LAYOUT ;

enum {					/* Data code definition 	*/
	ORDINARY_DATA,
	SHORT_DATA,
	BAD_CRC,
	GAP_DATA,
	HIDDEN_DATA,
	SLOCK_MARK,
	NO_DATA,
	DATA_CODE_MASK = 0x7f,
	DATA_ON_IAM    = 0x80,		/* May be OR'ed with data code  */
	} ;

#pragma pack()
