6 // N.B.: All 32/16-bit values are stored in little endian. Which means, to
7 // read/write them safely, we need to use translators as this code may or
8 // may not be compiled on an architecture that supports little endian
13 uint8_t location; // Quarter track for this stream
14 uint8_t captureType; // 1 = timing, 2 = bits, 3 = ext. timing
15 uint8_t dataLength[4]; // Length of the stream
16 uint8_t estLoopPoint[4];// Estimated loop point in ticks (125 ns/tick)
17 uint8_t data[]; // Variable length array for stream data
22 uint8_t metaTag[4]; // "META"
23 uint32_t metaSize; // Size of the META chunk
24 uint8_t data[]; // Variable length array of metadata
30 uint8_t magic1[4]; // "A2R2"
31 uint8_t magic2[4]; // $FF $0A $0D $0A
34 uint8_t infoTag[4]; // "INFO"
35 uint32_t infoSize; // Always 36 bytes long
36 uint8_t infoVersion; // Currently 1
37 uint8_t creator[32]; // Software that made this image, padded with 0x20
38 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
39 uint8_t writeProtected; // 1 = write protected disk
40 uint8_t synchronized; // 1 = cross-track sync was used during imaging
43 uint8_t strmTag[4]; // "STRM"
44 uint32_t strmSize; // Varies, depending on # of tracks imaged
45 uint8_t data[]; // Variable length array for stream data proper
55 uint8_t spliceBitCount;
61 uint8_t metaTag[4]; // "META"
62 uint32_t metaSize; // Size of the META chunk
63 uint8_t data[]; // Variable length array of metadata
69 uint8_t magic1[4]; // "WOZ1"
70 uint8_t magic2[4]; // $FF $0A $0D $0A
71 uint32_t crc32; // CRC32 of the remaining data in the file
74 uint8_t infoTag[4]; // "INFO"
75 uint32_t infoSize; // Always 60 bytes long
76 uint8_t infoVersion; // Currently 1
77 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
78 uint8_t writeProtected; // 1 = write protected disk
79 uint8_t synchronized; // 1 = cross-track sync was used during imaging
80 uint8_t cleaned; // 1 = fake bits removed from image
81 uint8_t creator[32]; // Software that made this image, padded with 0x20
82 uint8_t pad1[23]; // Padding to 60 bytes
85 uint8_t tmapTag[4]; // "TMAP"
86 uint32_t tmapSize; // Always 160 bytes long
87 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
90 uint8_t trksTag[4]; // "TRKS"
91 uint32_t trksSize; // Varies, depending on # of tracks imaged
92 WOZTrack track[]; // Variable length array for the track data proper
97 uint16_t startingBlock; // 512 byte block # where this track starts (relative to the start of the file)
98 uint16_t blockCount; // # of blocks in this track
99 uint32_t bitCount; // # of bits in this track
105 uint8_t magic1[4]; // "WOZ1"
106 uint8_t magic2[4]; // $FF $0A $0D $0A
107 uint32_t crc32; // CRC32 of the remaining data in the file
110 uint8_t infoTag[4]; // "INFO"
111 uint32_t infoSize; // Always 60 bytes long
112 uint8_t infoVersion; // Currently 1
113 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
114 uint8_t writeProtected; // 1 = write protected disk
115 uint8_t synchronized; // 1 = cross-track sync was used during imaging
116 uint8_t cleaned; // 1 = fake bits removed from image
117 uint8_t creator[32]; // Software that made this image, padded with 0x20
118 uint8_t diskSides; // 5 1/4" disks always have 1 side (v2 from here on)
119 uint8_t bootSectorFmt; // 5 1/4" only (0=unknown, 1=16 sector, 2=13 sector, 3=both)
120 uint8_t optimalBitTmg; // In ticks, standard for 5 1/4" is 32 (4 µs)
121 uint16_t compatibleHW; // Bitfield showing hardware compatibility (1=][, 2=][+, 4=//e (unenh), 8=//c, 16=//e (enh), 32=IIgs, 64=//c+, 128=///, 256=///+)
122 uint16_t requiredRAM; // Minimum size in K, 0=unknown
123 uint16_t largestTrack; // Number of 512 byte blocks used by largest track
124 uint8_t pad1[14]; // Padding to 60 bytes
127 uint8_t tmapTag[4]; // "TMAP"
128 uint32_t tmapSize; // Always 160 bytes long
129 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
132 uint8_t trksTag[4]; // "TRKS"
133 uint32_t trksSize; // Varies, depending on # of tracks imaged
134 WOZTrack2 track[160]; // Actual track info (corresponding to TMAP data)
135 uint8_t data[]; // Variable length array for the track data proper
139 // Exported functions
140 uint32_t CRC32(const uint8_t * data, uint32_t length);
141 uint8_t * ReadFile(const char * filename, uint32_t * size);
142 bool LoadA2R(const char * filename);
143 bool WriteWOZFile(const char * filename);
146 // Inline functions ("get" functions--need to write "set" functions)
147 static inline uint16_t Uint16LE(uint16_t v)
149 uint8_t * w = (uint8_t *)&v;
150 return (w[1] << 8) | (w[0] << 0);
153 static inline uint32_t Uint32LE(uint32_t v)
155 uint8_t * w = (uint8_t *)&v;
156 return (w[3] << 24) | (w[2] << 16) | (w[1] << 8) | (w[0] << 0);
159 static inline uint32_t Uint32LE(uint8_t * v)
161 return (v[3] << 24) | (v[2] << 16) | (v[1] << 8) | (v[0] << 0);
164 static inline uint32_t Uint32BE(uint8_t * v)
166 return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | (v[3] << 0);
169 static inline void SwapBytes32(uint8_t * b)
179 #endif // __FILEIO_H__