Difference between revisions of "Mohawk archive format"
(finalization) |
m (classed (this should work once the CSS is in place)) |
||
Line 17: | Line 17: | ||
==IFF header== | ==IFF header== | ||
This is always at the beginning of the file. | This is always at the beginning of the file. | ||
− | {| | + | {| class="structure" |
− | + | |4 bytes||chunk signature (MHWK), identifies Mohawk archive format | |
− | |chunk signature (MHWK), identifies Mohawk archive format | + | |
|- | |- | ||
− | + | |unsigned long||file size in bytes, '''not''' counting this IFF header (that is, file size - 8) | |
− | |file size in bytes, '''not''' counting this IFF header (that is, file size - 8) | + | |
|} | |} | ||
==RSRC header== | ==RSRC header== | ||
I think this is actually the "Resource Dir header". Note that the Dir can be anywhere in file, but this header always follows the IFF Header. | I think this is actually the "Resource Dir header". Note that the Dir can be anywhere in file, but this header always follows the IFF Header. | ||
− | {| | + | {| class="structure" |
− | + | |4 bytes||chunk signature (RSRC) | |
− | |chunk signature (RSRC) | + | |
|- | |- | ||
− | + | |unsigned long||should be length of RSRC chunk (never bothered to check) | |
− | |should be length of RSRC chunk (never bothered to check) | + | |
|- | |- | ||
− | + | |unsigned long||total file size in bytes | |
− | |total file size in bytes | + | |
|- | |- | ||
− | + | |unsigned long||absolute offset of the Resource Dir | |
− | |absolute offset of the Resource Dir | + | |
|- | |- | ||
− | + | |unsigned short||offset in Resource Dir of the File Table | |
− | |offset in Resource Dir of the File Table | + | |
|- | |- | ||
− | + | |unsigned short||File Table size in bytes | |
− | |File Table size in bytes | + | |
|} | |} | ||
Line 51: | Line 43: | ||
Header: | Header: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned short||offset in Resource Dir of the Resource Name List (maybe this should go with the RSRC Header) | |
− | |offset in Resource Dir of the Resource Name List (maybe this should go with the RSRC Header) | + | |
|- | |- | ||
− | + | |unsigned short||number of resource types in this file | |
− | |number of resource types in this file | + | |
|} | |} | ||
Entry (one for each type): | Entry (one for each type): | ||
− | {| | + | {| class="structure" |
− | + | |4 bytes||resource type (tWAV, tBMP, NAME etc.) | |
− | |resource type (tWAV, tBMP, NAME etc.) | + | |
|- | |- | ||
− | + | |unsigned short||offset in Resource Dir of the Resource Table for this type | |
− | |offset in Resource Dir of the Resource Table for this type | + | |
|- | |- | ||
− | + | |unsigned short||offset in Resource Dir of the Name Table for this type | |
− | |offset in Resource Dir of the Name Table for this type | + | |
|} | |} | ||
Line 75: | Line 62: | ||
Header: | Header: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned short||number of name entries (can be zero) | |
− | |number of name entries (can be zero) | + | |
|} | |} | ||
Entry: | Entry: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned short||offset of the name string in Name List | |
− | |offset of the name string in Name List | + | |
|- | |- | ||
− | + | |unsigned short||resource index (equal to the resource's index in File Table) | |
− | |resource index (equal to the resource's index in File Table) | + | |
|} | |} | ||
Line 93: | Line 77: | ||
Header: | Header: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned short||number of resources for this type (number of table entries) | |
− | |number of resources for this type (number of table entries) | + | |
|} | |} | ||
Entry: | Entry: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned short||resource ID | |
− | |resource ID | + | |
|- | |- | ||
− | + | |unsigned short||index in file table (starting from 1). Also used to find the matching name table entry | |
− | |index in file table (starting from 1). Also used to find the matching name table entry | + | |
|} | |} | ||
Line 114: | Line 95: | ||
Header: | Header: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned long||number of file table entries | |
− | |number of file table entries | + | |
|} | |} | ||
Entry: | Entry: | ||
− | {| | + | {| class="structure" |
− | + | |unsigned long||absolute offset of resource data block | |
− | |absolute offset of resource data block | + | |
|- | |- | ||
− | + | |unsigned short||resource data size, bits 15-0 | |
− | |resource data size, bits 15-0 | + | |
|- | |- | ||
− | + | |byte||resource data size, bits 23-16 | |
− | |resource data size, bits 23-16 | + | |
|- | |- | ||
− | + | |byte||resource flags (unknown) | |
− | |resource flags (unknown) | + | |
|- | |- | ||
− | + | |unsigned short||unknown (usually zero in Riven files) | |
− | |unknown (usually zero in Riven files) | + | |
|} | |} |
Revision as of 22:18, 4 February 2008
Contents
General layout
Mohawk archives are organized in chunks, and this is the chunk layout:
- IFF chunk
- IFF header
- RSRC header
- Resource dir
- Type table
- Name tables (one for each resource type)
- Resource tables (one for each resource type)
- Resource name list
- File table
- Actual data (resource contents)
Note that the chunks may be found in a different order: never trust on them being at fixed locations, and use the offsets to reach them.
Every integer is in big-endian (Motorola) byte order.
IFF header
This is always at the beginning of the file.
4 bytes | chunk signature (MHWK), identifies Mohawk archive format |
unsigned long | file size in bytes, not counting this IFF header (that is, file size - 8) |
RSRC header
I think this is actually the "Resource Dir header". Note that the Dir can be anywhere in file, but this header always follows the IFF Header.
4 bytes | chunk signature (RSRC) |
unsigned long | should be length of RSRC chunk (never bothered to check) |
unsigned long | total file size in bytes |
unsigned long | absolute offset of the Resource Dir |
unsigned short | offset in Resource Dir of the File Table |
unsigned short | File Table size in bytes |
Type table
It lists resource types in the Mohawk file. This table is always at the beginning of the Resource Dir.
Header:
unsigned short | offset in Resource Dir of the Resource Name List (maybe this should go with the RSRC Header) |
unsigned short | number of resource types in this file |
Entry (one for each type):
4 bytes | resource type (tWAV, tBMP, NAME etc.) |
unsigned short | offset in Resource Dir of the Resource Table for this type |
unsigned short | offset in Resource Dir of the Name Table for this type |
Name table
There is one name table for each resource type. Many types don't have resource names; usually only tBMP, tWAV and tMOV do. Each entry holds the name offset in the name list for a resource.
Header:
unsigned short | number of name entries (can be zero) |
Entry:
unsigned short | offset of the name string in Name List |
unsigned short | resource index (equal to the resource's index in File Table) |
Resource table
Again, there is one resource table for each resource type. The resource table holds crucial information about each resource of this type.
Header:
unsigned short | number of resources for this type (number of table entries) |
Entry:
unsigned short | resource ID |
unsigned short | index in file table (starting from 1). Also used to find the matching name table entry |
Resource name list
This is a simple list of null-terminated strings (C strings), where each string is a resource name. Given a resource, you can get the offset to its name by looking in the name table entry for that resource.
File table
This table holds other important data about each resource, notably the location and size of the resource content within the whole Mohawk file. I wonder why this information couldn't go directly inside the resource table entry.
Header:
unsigned long | number of file table entries |
Entry:
unsigned long | absolute offset of resource data block |
unsigned short | resource data size, bits 15-0 |
byte | resource data size, bits 23-16 |
byte | resource flags (unknown) |
unsigned short | unknown (usually zero in Riven files) |