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 metaTag[4]; // "META"
14 uint32_t metaSize; // Size of the META chunk
15 uint8_t data[]; // Variable length array of metadata
20 uint8_t location; // Quarter track for this stream
21 uint8_t captureType; // 1 = timing, 2 = bits, 3 = ext. timing
22 uint8_t dataLength[4]; // Length of the stream
23 uint8_t estLoopPoint[4];// Estimated loop point in ticks (125 ns/tick)
24 uint8_t data[]; // Variable length array for stream data
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;
62 uint8_t magic1[4]; // "WOZ1"
63 uint8_t magic2[4]; // $FF $0A $0D $0A
64 uint32_t crc32; // CRC32 of the remaining data in the file
67 uint8_t infoTag[4]; // "INFO"
68 uint32_t infoSize; // Always 60 bytes long
69 uint8_t infoVersion; // Currently 1
70 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
71 uint8_t writeProtected; // 1 = write protected disk
72 uint8_t synchronized; // 1 = cross-track sync was used during imaging
73 uint8_t cleaned; // 1 = fake bits removed from image
74 uint8_t creator[32]; // Software that made this image, padded with 0x20
75 uint8_t pad1[23]; // Padding to 60 bytes
78 uint8_t tmapTag[4]; // "TMAP"
79 uint32_t tmapSize; // Always 160 bytes long
80 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
83 uint8_t trksTag[4]; // "TRKS"
84 uint32_t trksSize; // Varies, depending on # of tracks imaged
85 WOZTrack track[]; // Variable length array for the track data proper
90 uint16_t startingBlock; // 512 byte block # where this track starts (relative to the start of the file)
91 uint16_t blockCount; // # of blocks in this track
92 uint32_t bitCount; // # of bits in this track
98 uint8_t magic1[4]; // "WOZ1"
99 uint8_t magic2[4]; // $FF $0A $0D $0A
100 uint32_t crc32; // CRC32 of the remaining data in the file
103 uint8_t infoTag[4]; // "INFO"
104 uint32_t infoSize; // Always 60 bytes long
105 uint8_t infoVersion; // Currently 1
106 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
107 uint8_t writeProtected; // 1 = write protected disk
108 uint8_t synchronized; // 1 = cross-track sync was used during imaging
109 uint8_t cleaned; // 1 = fake bits removed from image
110 uint8_t creator[32]; // Software that made this image, padded with 0x20
111 uint8_t diskSides; // 5 1/4" disks always have 1 side (v2 from here on)
112 uint8_t bootSectorFmt; // 5 1/4" only (0=unknown, 1=16 sector, 2=13 sector, 3=both)
113 uint8_t optimalBitTmg; // In ticks, standard for 5 1/4" is 32 (4 µs)
114 uint16_t compatibleHW; // Bitfield showing hardware compatibility (1=][, 2=][+, 4=//e (unenh), 8=//c, 16=//e (enh), 32=IIgs, 64=//c+, 128=///, 256=///+)
115 uint16_t requiredRAM; // Minimum size in K, 0=unknown
116 uint16_t largestTrack; // Number of 512 byte blocks used by largest track
117 uint8_t pad1[14]; // Padding to 60 bytes
120 uint8_t tmapTag[4]; // "TMAP"
121 uint32_t tmapSize; // Always 160 bytes long
122 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
125 uint8_t trksTag[4]; // "TRKS"
126 uint32_t trksSize; // Varies, depending on # of tracks imaged
127 WOZTrack2 track[160]; // Actual track info (corresponding to TMAP data)
128 uint8_t data[]; // Variable length array for the track data proper
132 // Exported functions
133 uint32_t CRC32(const uint8_t * data, uint32_t length);
134 uint8_t * ReadFile(const char * filename, uint32_t * size);
135 bool LoadA2R(const char * filename);
136 bool WriteWOZFile(const char * filename);
137 void UnpackMetadata(Metadata * data);
138 uint8_t * GetMetadata(const char * keyword);
139 uint16_t GetRequiredMachineBits(void);
140 uint16_t GetRequiredRAMInK(void);
143 // Inline functions ("get" functions--need to write "set" functions)
144 static inline uint16_t Uint16LE(uint16_t v)
146 uint8_t * w = (uint8_t *)&v;
147 return (w[1] << 8) | (w[0] << 0);
150 static inline uint32_t Uint32LE(uint32_t v)
152 uint8_t * w = (uint8_t *)&v;
153 return (w[3] << 24) | (w[2] << 16) | (w[1] << 8) | (w[0] << 0);
156 static inline uint32_t Uint32LE(uint8_t * v)
158 return (v[3] << 24) | (v[2] << 16) | (v[1] << 8) | (v[0] << 0);
161 static inline uint32_t Uint32BE(uint8_t * v)
163 return (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | (v[3] << 0);
166 static inline void SwapBytes32(uint8_t * b)
176 #endif // __FILEIO_H__