fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1PBIT File Format (Version 0)
2============================
3
4All integers are in big-endian format.
5
6
7File structure
8--------------
9
10<file header chunk>
11
12[<comment chunk>]
13
14For each track:
15 <track header chunk>
16 [other chunks]
17 [<track data chunk>]
18
19<end chunk>
20
21
22File header chunk
23-----------------
24
250 4 Magic ('PBIT')
264 4 Size (8)
278 4 Version (0)
2812 4 File flags
2916 4 CRC
30
31
32Comment chunk
33-------------
34
350 4 Magic ('TEXT')
364 4 Size (n)
378 n Data
388+n 4 CRC
39
40
41Track header chunk
42------------------
43
440 4 Magic ('TRAK')
454 4 Size (20)
468 4 Cylinder
4712 4 Head
4816 4 Track length in bits
4920 4 Bit clock rate
5024 4 Track flags
5128 4 CRC
52
53
54Track data chunk
55----------------
56
570 4 Magic ('DATA')
584 4 Size (n)
598 n Track data
60n+8 4 CRC
61
62
63End chunk
64---------
65
660 4 Magic ('END ')
674 4 Size (0)
688 4 CRC (0x3d64af78)
69
70
71CRC
72---
73
74 - The algorithm used is big-endian CRC-32C with generator
75 polynomial 0x1edc6f41. The CRC value is initialized to 0.
76
77 unsigned long pbit_crc (const unsigned char *src, unsigned cnt)
78 {
79 unsigned i, j;
80 unsigned long crc;
81
82 crc = 0;
83
84 for (i = 0; i < cnt; i++) {
85 crc ^= (unsigned long) (src[i] & 0xff) << 24;
86
87 for (j = 0; j < 8; j++) {
88 if (crc & 0x80000000) {
89 crc = (crc << 1) ^ 0x1edc6f41;
90 }
91 else {
92 crc = crc << 1;
93 }
94 }
95 }
96
97 return (crc & 0xffffffff);
98 }