8 // N.B.: All 32/16-bit values are stored in little endian. Which means, to
9 // read/write them safely, we need to use translators as this code may or
10 // may not be compiled on an architecture that supports little endian
20 uint8_t spliceBitCount;
26 uint8_t metaTag[4]; // "META"
27 uint32_t metaSize; // Size of the META chunk
28 uint8_t data[]; // Variable length array of metadata
34 uint8_t magic[8]; // "WOZ1" $FF $0A $0D $0A
35 uint32_t crc32; // CRC32 of the remaining data in the file
38 uint8_t infoTag[4]; // "INFO"
39 uint32_t infoSize; // Always 60 bytes long
40 uint8_t infoVersion; // Currently 1
41 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
42 uint8_t writeProtected; // 1 = write protected disk
43 uint8_t synchronized; // 1 = cross-track sync was used during imaging
44 uint8_t cleaned; // 1 = fake bits removed from image
45 uint8_t creator[32]; // Software that made this image, padded with 0x20
46 uint8_t pad1[23]; // Padding to 60 bytes
49 uint8_t tmapTag[4]; // "TMAP"
50 uint32_t tmapSize; // Always 160 bytes long
51 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
54 uint8_t trksTag[4]; // "TRKS"
55 uint32_t trksSize; // Varies, depending on # of tracks imaged
56 WOZ1Track track[]; // Variable length array for the track data proper
61 uint16_t startingBlock; // 512 byte block # where this track starts (relative to the start of the file)
62 uint16_t blockCount; // # of blocks in this track
63 uint32_t bitCount; // # of bits in this track
69 uint8_t magic[8]; // "WOZ2" $FF $0A $0D $0A
70 uint32_t crc32; // CRC32 of the remaining data in the file
73 uint8_t infoTag[4]; // "INFO"
74 uint32_t infoSize; // Always 60 bytes long
75 uint8_t infoVersion; // Currently 1
76 uint8_t diskType; // 1 = 5 1/4", 2 = 3 1/2"
77 uint8_t writeProtected; // 1 = write protected disk
78 uint8_t synchronized; // 1 = cross-track sync was used during imaging
79 uint8_t cleaned; // 1 = fake bits removed from image
80 uint8_t creator[32]; // Software that made this image, padded with 0x20
81 uint8_t diskSides; // 5 1/4" disks always have 1 side (v2 from here on)
82 uint8_t bootSectorFmt; // 5 1/4" only (0=unknown, 1=16 sector, 2=13 sector, 3=both)
83 uint8_t optimalBitTmg; // In ticks, standard for 5 1/4" is 32 (4 µs)
84 uint16_t compatibleHW; // Bitfield showing hardware compatibility (1=][, 2=][+, 4=//e (unenh), 8=//c, 16=//e (enh), 32=IIgs, 64=//c+, 128=///, 256=///+)
85 uint16_t requiredRAM; // Minimum size in K, 0=unknown
86 uint16_t largestTrack; // Number of 512 byte blocks used by largest track
87 uint8_t pad1[14]; // Padding to 60 bytes
90 uint8_t tmapTag[4]; // "TMAP"
91 uint32_t tmapSize; // Always 160 bytes long
92 uint8_t tmap[160]; // Track map, with empty tracks set to $FF
95 uint8_t trksTag[4]; // "TRKS"
96 uint32_t trksSize; // Varies, depending on # of tracks imaged
97 WOZTrack2 track[160]; // Actual track info (corresponding to TMAP data)
98 uint8_t data[]; // Variable length array for the track data proper
101 // Exported functions
102 uint8_t * ReadFile(const char * filename, uint32_t * size);
103 void InitWOZ2Headers(WOZ2 &);
104 uint8_t * InitWOZ(uint32_t * pSize = NULL);
105 uint8_t * UpconvertWOZ1ToWOZ2(uint8_t * woz1Data, uint32_t woz1Size, uint32_t * newSize);
106 uint8_t CheckWOZType(const uint8_t * wozData, uint32_t wozSize);
107 bool CheckWOZIntegrity(const uint8_t * wozData, uint32_t wozSize);
108 bool SaveWOZ(const char * filename, WOZ2 * woz, uint32_t size);
110 // Static in-line functions, for clarity & speed, mostly for reading values out
111 // of the WOZ struct, which stores its data in LE; some for swapping variables
112 static inline uint16_t Uint16LE(uint16_t v)
114 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
115 return ((v & 0xFF) << 8) | ((v & 0xFF00) >> 8);
122 static inline uint32_t Uint32LE(uint32_t v)
124 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
125 return ((v & 0xFF) << 24) | ((v & 0xFF00) << 8)
126 | ((v & 0xFF0000) >> 8) | ((v & 0xFF000000) >> 24);
132 #endif // __FILEIO_H__