IPF Image-File Reader-Writer  1.0
IPF File information
IPFStruct.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Runtime.InteropServices;
5 using System.Text;
6 using System.Threading.Tasks;
7 
8 namespace ipf {
10  public enum MediaType : uint { Unknown, Floppy_Disk };
11 
13  public enum EncoderType : uint { Unknown, CAPS, SPS };
14 
27  public enum Platform : uint {
28  Unknown, Amiga, Atari_ST, PC, Amstrad_CPC, Spectrum, Sam_Coupe, Archimedes, C64, Atari_8bit
29  }
30 
32  public enum Density : uint {
33  Unknown, Noise, Auto, Copylock_Amiga, Copylock_Amiga_New, Copylock_ST, Speedlock_Amiga,
34  Speedlock_Amiga_Old, Adam_Brierley_Amiga, Adam_Brierley_Key_Amiga
35  }
36 
38  public enum SignalType : uint { Unknown, cell_2us }
39 
41  [Flags]
42  public enum TrackFlags : uint {
43  None = 0x0,
44  Fuzzy = 0x1
45  }
46 
48  public enum BlockEncoderType : uint { Unknown, MFM, RAW }
49 
50 
52  [Flags]
53  public enum BlockFlags : uint {
54  None = 0x00,
55  FwGap = 0x01,
56  BwGap = 0x02,
57  DataInBit = 0x04
58  }
59 
60  // Flags
61  // https://msdn.microsoft.com/fr-fr/library/cc138362.aspx
62  //if ((bd.blockFlags & BlockFlags.BwGap) == BlockFlags.BwGap) {
63  //if (bd.blockFlags.HasFlag(BlockFlags.BwGap)) {
64  //if(bd.blockFlags.Equals(BlockFlags.None))
65 
66 
68  public enum DataType : uint { Unknown, Sync, Data, IGap, Raw, Fuzzy }
69 
71  public enum GapType : uint { Unknown, Forward, Backward }
72 
74  public enum GapElemType { Unknown, GapLength, SampleLength }
75 
78  public class RecordHeader {
80  public char[] type = new char[4];
81 
83  public uint length;
84 
86  public uint crc;
87 
90  public override string ToString() {
91  return String.Format("Record={0} Size={1} CRC={2:X8}",
92  new string(type), length, crc);
93  }
94  } // RecordHeader
95 
96 
100  public class InfoRecord {
104 
110 
113  public uint encoderRev;
114 
119  public uint fileKey;
120 
123  public uint fileRev;
124 
126  public uint origin;
127 
130  public uint minTrack;
131 
134  public uint maxTrack;
135 
138  public uint minSide;
139 
141  public uint maxSide;
142 
145  public uint creationDate;
146 
149  public uint creationTime;
150 
154  public Platform[] platforms = new Platform[4];
155 
157  public uint diskNumber;
158 
160  public uint creatorId;
161 
163  public uint[] reserved = new uint[3];
164 
165 
168  public override string ToString() {
169  string date = String.Format("{0:D2}/{1:D2}/{2:D2}", creationDate / 10000, (creationDate/100) % 100, creationDate % 100);
170  string time = String.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", creationTime/10000000, (creationTime/100000) % 100,
171  (creationTime/1000)%100, creationTime % 1000);
172  string pstring = null;
173  foreach (Platform p in platforms)
174  if (p != 0) pstring += (p.ToString() + " ");
175 
176  return String.Format(
177  " Type={0} Encoder={1}(V{2}) File={3}(V{4}) Disk={5} Origin={6:X8} Creator={7:X8}\n" +
178  " Track={8:D2}-{9:D2} Side={10}-{11} Date={12} Time={13} Platforms={14}\n",
179  mediaType.ToString(), encoderType.ToString(), encoderRev, fileKey, fileRev, diskNumber, origin,
180  creatorId, minTrack, maxTrack, minSide, maxSide, date, time, pstring);
181  }
182  }
183 
187  public class ImageRecord {
188  public uint track;
189  public uint side;
190  public Density density;
191  public SignalType signalType;
192  public uint trackBytes;
193  public uint startBytePos;
194  public uint startBitPos;
195  public uint dataBits;
196  public uint gapBits;
197  public uint trackBits;
198  public uint blockCount;
199  public uint encoder;
200  public TrackFlags trackFlags;
201  public uint dataKey;
203  public uint[] reserved = new uint[3];
204 
207  public override string ToString() {
208  return String.Format(
209  " T{0:D2}.{1} Size={2} bytes ({3} bits = Data={4} + Gap={5}) Start Byte={6} Bit={7}\n" +
210  " DataKey={8:D3} Block={9} Density={10} Signal={11} Encoder={12} Flags={13}\n",
211  track, side, trackBytes, trackBits, dataBits, gapBits, startBytePos, startBitPos,
212  dataKey, blockCount, density.ToString(), signalType.ToString(), encoder, trackFlags.ToString());
213  }
214  }
215 
216 
220  public class DataRecord {
221  public uint length;
222  public uint bitSize;
223  public uint crc;
224  public uint key;
225  public override string ToString() {
226  return String.Format("== DataKey={0:D3} Length={1} bytes bitSize={2} bits CRC={3:X8}",
227  key, length, bitSize, crc);
228  }
229  }
230 
231 
236  [StructLayout(LayoutKind.Explicit)]
237  public struct BlockDescriptor {
238  [FieldOffset(0)]
239  public uint dataBits;
240  [FieldOffset(4)]
241  public uint gapBits;
242 
243  [FieldOffset(8)] // CAPS
244  public uint dataBytes;
245  [FieldOffset(12)]
246  public uint gapBytes;
247 
248  [FieldOffset(8)] // SPS
249  public uint gapOffset;
250  [FieldOffset(12)]
251  public SignalType cellType;
252 
253  [FieldOffset(16)]
254  public BlockEncoderType encoderType;
255  [FieldOffset(20)]
256  public BlockFlags blockFlags;
257  [FieldOffset(24)]
258  public uint gapDefaultValue;
259  [FieldOffset(28)]
260  public uint dataOffset;
261  }
262 
263 
264  public class CteiRecord {
265  public uint releaseCrc;
266  public uint analyzerRev;
267  public uint[] reserved = new uint[14];
268  public override string ToString() {
269  return String.Format(" Associated IPF CRC={0:X8} Analyzer revision={1}\n",
270  releaseCrc, analyzerRev);
271  }
272  }
273 
274 
275  public class CtexRecord {
276  public uint track;
277  public uint side;
278  public Density density;
279  public uint formatId;
280  public uint fix;
281  public uint trackSize;
282  public uint[] reserved = new uint[2];
283  public override string ToString() {
284  return String.Format(" T{0:D2}.{1} Density={2} Format={3} Fix={4} TrackSize={5}\n",
285  track, side, density.ToString(), formatId, fix, trackSize);
286  }
287  }
288 
289 
290 }
uint diskNumber
Number of the disk in a multi-disc release otherwise 0
Definition: IPFStruct.cs:157
uint creatorId
A unique user ID of the disk image creator
Definition: IPFStruct.cs:160
BlockFlags
Flags for a block descriptor
Definition: IPFStruct.cs:53
override string ToString()
Override ToString() to display Image record content
Definition: IPFStruct.cs:207
uint fileRev
Revision of the file.
Definition: IPFStruct.cs:123
uint creationTime
The image creation time: Specify the hour, the minute, the second, and the tick
Definition: IPFStruct.cs:149
IPF record Header Descriptor
Definition: IPFStruct.cs:78
DataType
Type of Data in data element
Definition: IPFStruct.cs:68
uint origin
Reference to original source
Definition: IPFStruct.cs:126
EncoderType
Image encoder Type
Definition: IPFStruct.cs:13
uint length
Length of the record
Definition: IPFStruct.cs:83
MediaType
Type of media imaged
Definition: IPFStruct.cs:10
uint[] reserved
reserved for future
Definition: IPFStruct.cs:163
uint[] reserved
reserved for future
Definition: IPFStruct.cs:203
uint creationDate
The image creation date: Specify the year, the month, the day
Definition: IPFStruct.cs:145
GapType
Type of a gap element
Definition: IPFStruct.cs:71
MediaType mediaType
Type of media imaged
Definition: IPFStruct.cs:103
Definition: App.xaml.cs:9
Platform
Platform on which the image can be run
Definition: IPFStruct.cs:27
The image record definition
Definition: IPFStruct.cs:187
uint minTrack
The first track number of the floppy image.
Definition: IPFStruct.cs:130
uint encoderRev
Image encoder revision
Definition: IPFStruct.cs:113
SignalType
Signal Processing Type
Definition: IPFStruct.cs:38
Block descriptor definition
Definition: IPFStruct.cs:237
char[] type
Identify the record
Definition: IPFStruct.cs:80
uint minSide
The lowest head (side) number of the floppy image.
Definition: IPFStruct.cs:138
uint maxTrack
The last track number of the floppy image.
Definition: IPFStruct.cs:134
GapElemType
Type of information in a gap element
Definition: IPFStruct.cs:74
uint fileKey
Each IPF file has a unique ID that can be used as a unique key for database
Definition: IPFStruct.cs:119
The info record definition
Definition: IPFStruct.cs:100
The Data record definition
Definition: IPFStruct.cs:220
Density
The cell density for this track
Definition: IPFStruct.cs:32
EncoderType encoderType
image encoder type
Definition: IPFStruct.cs:109
TrackFlags
Flags for the track
Definition: IPFStruct.cs:42
BlockEncoderType
Block Encoder Type
Definition: IPFStruct.cs:48
override string ToString()
Override ToString() to display info record content
Definition: IPFStruct.cs:168
Platform[] platforms
Array of four possible platforms
Definition: IPFStruct.cs:154
uint crc
CRC32 for the complete record
Definition: IPFStruct.cs:86
override string ToString()
Override ToString() to display record header info
Definition: IPFStruct.cs:90
uint maxSide
The highest head (side) number of the floppy image. Usually 1
Definition: IPFStruct.cs:141