Difference between revisions of "DFI image format"
(Added comments, thanks fjkraan!) |
|||
| Line 40: | Line 40: | ||
carry = 0 | carry = 0 | ||
For every byte in the stream: | For every byte in the stream: | ||
| − | if ((byte AND 0x7f) == 0x7f): | + | if ((byte AND 0x7f) == 0x7f): // if lower 7 bit value is 0x7f |
carry = carry + 127 | carry = carry + 127 | ||
| − | else if (byte AND 0x80) != 0: | + | else if (byte AND 0x80) != 0: // if high bit set in byte |
| − | carry = carry + (byte & 0x7F) | + | carry = carry + (byte & 0x7F) // add lower 7 bit value to carry |
| − | add_index_position(carry) | + | add_index_position(carry) // add high bit to carry |
| − | else: | + | else: // here byte < 0x7f |
| − | emit((byte AND 0x7f) + carry) | + | emit((byte AND 0x7f) + carry) // ?? the AND 0x7f is superfluous here. report carry + byte |
| − | carry = 0 | + | carry = 0 // reset carry |
| − | if carry > 0: | + | if carry > 0: // |
| − | emit(carry) | + | emit(carry) // report carry |
| + | |||
| + | // emit() looks like a written value | ||
| + | // add_index_position() is just setting the high bit of the last data value | ||
| + | // | ||
</nowiki> | </nowiki> | ||
Revision as of 22:54, 15 January 2012
Format originator: DiscFerret software.
Overall format
All integers in this file format are stored in big-endian form.
The DFI file consists of a 4-byte magic string, followed by a series of disc sample blocks.
The magic string is "DFER" for old-style DiscFerret images, or "DFE2" for new-style DiscFerret images.
Each sample block has a header --
uint16_be cylinder; uint16_be head; uint16_be sector; uint32_be data_length;
The cylinder number starts at zero and counts up to the number of cylinders on the disk. The head number follows the same rule (starts at zero, increments for each additional head). The sector number is optional, and only used for hard-sectored discs. For soft-sectored discs, it is set to zero. Data_length indicates the number of bytes of data which follow.
Decoding data
Old-style images
carry = 0
For every byte in the stream:
if (byte AND 0x7f) == 0x00:
carry = carry + 127
else:
emit((byte AND 0x7f) + carry)
carry = 0
if carry > 0:
emit(carry)
New-style images
carry = 0
For every byte in the stream:
if ((byte AND 0x7f) == 0x7f): // if lower 7 bit value is 0x7f
carry = carry + 127
else if (byte AND 0x80) != 0: // if high bit set in byte
carry = carry + (byte & 0x7F) // add lower 7 bit value to carry
add_index_position(carry) // add high bit to carry
else: // here byte < 0x7f
emit((byte AND 0x7f) + carry) // ?? the AND 0x7f is superfluous here. report carry + byte
carry = 0 // reset carry
if carry > 0: //
emit(carry) // report carry
// emit() looks like a written value
// add_index_position() is just setting the high bit of the last data value
//