Her Interactive CIFTREE File Format

Introduction

The CIFTREE format is an archive format, where individual files are LZSS-compressed. It's used to bundle up TGA images and scene files for the game, along with a few files of other types. This format is not to be confused with CIFFILEs, which are (judging by the names) similar to CIFTREEs, but are otherwise distinct formats.

Note that the format tends to change slightly between games, with the first game in particular featuring some one-time differences. After the first game, additional CIFTREE archives are used to store character animations.

All multi-byte values are little-endian unless otherwise specified.

Games Examined

The following games have had their CIFTREE files examined and figured out to the extent described below. Other games in the series are potentially different.

  1. Secrets Can Kill
  2. Stay Tuned for Danger
  3. Message in a Haunted Mansion
  4. Secret of Shadow Ranch
  5. Curse of Blackmoor Manor

File Format

Header

The CIFTREE archive starts with a header, unsurprisingly, containing the number of files, an identifying magic number, and unknown values.

Byte Offset Size Description
0x00 20 Null-terminated constant string CIF TREE WayneSikes. Can be used as magic number.
0x14 8 Unknown constant sequence 00 00 00 00 02 00 01 00, except for the first game, where it's 00 00 00 00 02 00 00 00. Maybe be in part a version indicator for the file format.
0x1C 2 The number of entries in the index, and thus the number of files.
0x1E 2 Except for the first game, two more bytes of unknown value. Does not appear to be part of the "padding".

"Padding"

Immediately after the header follows 2 KiB (2048 B) of unknown data. It's termed "padding" in this documentation because it is filled mostly with 0xFF bytes. However, quite a few bytes of this "padding" are different, meaning this section is potentially important in some way. Regardless, ignoring this "padding" does not seem to adversely affect extracting any files from the archive.

File Index

After the so-called padding comes the file index. This index helps locate the files in the archive and provides other metadata important for the game. The structure of entries in the index changes throughout the series. Unfortunately, there is no currently-known way of learning what version of the structure is used from the file itself. Thus, tools manipulating these archives need to know what game they are targeting.

Note that there are generally two types of files in the archive: PLAIN and DATA files. PLAIN files are headerless TGA images, and DATA files are non-image files (such as scene files or text files). PLAIN files need their header reconstructed from the metadata in its index entry. (As a consequence, some of the entry's bytes change meaning between the two types of files.) A third type, known as DECAL, is described in some places, but doesn't actually appear in any examined Nancy Drew game; they may have been used in previous, non-Nancy Drew, Her Interactive games.

The following table gives a brief overview of the currently-known versions. The following subsections describe each version of the structure in detail.

Version Size of Each Entry Filename Limit
1 38 8
2 70 8
3 94 32
10 94 32

Version 1 (ND#1 SCK)

This version of the entry is by far the shortest, with each file entry being just 38 bytes long. Filenames are limited to 8 characters, not counting the null terminator. This version also misses some information needed to reconstruct TGA files, namely the origin. The x- and y-origin for TGA images in this game are both zero.

Offset Size Description
DATA PLAIN DATA PLAIN
0x00 9 Null-terminated and null-padded filename.
0x09 2 File entry number
0x0B 7 2 Seemingly always zero Image width
0x0D 2 Unknown.
0x0F 2 Image height
0x11 1 Unknown. Possibly bits-per-pixel?
0x12 1 Unknown constant 0x02
0x13 4 Offset into CIFTREE archive where the file begins.
0x17 4 Size of file decompressed
0x1B 4 Unknown. Might always be zero.
0x1F 4 Size of file in the CIFTREE archive.
0x23 1 File type indicator, determines if it's PLAIN or DATA.
0x03 for DATA 0x02 for PLAIN
0x24 2 Unknown.

Version 2 (ND#2 STD)