File archive: Difference between revisions

From Trickstart wiki
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
|0x0
|0x0
|0x4
|0x4
|Magic, <code>44 49 52 1A</code> ("'''DIR\x1A'''")
|Magic, <code>44 49 52 1A</code> (<code>DIR\x1A</code>)
|-
|-
|0x4
|0x4
Line 22: Line 22:
|}
|}


* file data spans up to the "address of directory". These two subpoints are optional, but they provide nice alignment
* file data spans up to the "address of directory". These two points are optional, but they provide a nice alignment:
** There is <code>1A 00</code> at the end of each file
** There is <code>1A 00</code> at the end of each file
** There may be <code>00</code> padding after that, so the next file/section starts at offset % 4 == 0
** There may be <code>00</code> padding after that, so the next file/section starts at offset aligned to 4 bytes


Following offsets are counted from "Directory address"
Following offsets are counted from "Directory address"
Line 48: Line 48:


* each entry value + "address of directory" is a pointer to corresponding ''file descriptor''
* each entry value + "address of directory" is a pointer to corresponding ''file descriptor''
* each position is calculated, hash function is available at <nowiki>https://worms2d.info/Graphics_directory</nowiki>
* each position is calculated, hash function is available at https://worms2d.info/Graphics_directory


each '''file descriptor''' have following structure:
each '''file descriptor''' have following structure:

Latest revision as of 21:24, 23 October 2022

.wad file format is exactly the same as Worms .dir format, only extension is different.

Offset Size Description
0x0 0x4 Magic, 44 49 52 1A (DIR\x1A)
0x4 0x4 File size
0x8 0x4 Directory address
0xC ??? Files data
  • file data spans up to the "address of directory". These two points are optional, but they provide a nice alignment:
    • There is 1A 00 at the end of each file
    • There may be 00 padding after that, so the next file/section starts at offset aligned to 4 bytes

Following offsets are counted from "Directory address"

Offset Size Description
0x0 0x4 Magic, 0A 00 00 00
0x4 0x1000 Hash table, 1024 4-byte entries
0x1004 ??? File descriptors

Hash table

each file descriptor have following structure:

Offset Size Description
0x0 0x4 Next hash, by default is set to 00 00 00 00
0x4 0x4 File data offset in archive
0x8 0x4 File size
0xC 0x4 Filename with path

File descriptors

  • if two files have the same hash, then hash table points to first file, which have "next hash" to another file descriptor with the same hash. If there is no collision then it's 0.
  • filename is 4 bytes aligned, terminated by 0x00 (and padded with 0x00 to 4 bytes)