Skip to main content

DBPF

DBPF.js v1.1.0Docs


DBPF.js v1.1.0 / spec / DBPF

The DBPF File Format

Introduction

The DBPF file format is a file format used in various games, including The Sims Series, SimCity, and Spore. It is known as a "Database Packed File" and is used to store various types of data, including textures, meshes, and other game assets. The format is often used in .package files, but can also be found in other file types.

Versions

The DBPF file format has undergone a few revisions over the last few decades. There are 2 version sets for the format:

  • DBPF archive version: This is the version of the archive format itself.
  • DBPF index version: This is the version of the index table format.

Known Versions

GameDBPF Archive VersionDBPF Index Version
The Sims Online1.07.0
SimCity 41.07.0
The Sims 21.0, 1.17.1
MySims2.0n/a
Spore2.0n/a
The Sims 32.0n/a
SimCity 20133.0n/a
The Sims 42.0n/a

Structure

The following is a table describing the first several bytes of the DBPF file format known as the "Header":

FieldBytesVersionsDescription
Magic Number4AllThe magic number for the DBPF file format. This is used to identify the file format. Consists of ASCII/Hex characters "DBPF"
Major Version4AllThe major version of the DBPF file format. Known versions: 1, 2, 3
Minor Version4AllThe minor version of the DBPF file format.
User Major42.0The major version specified by the user.
User Minor42.0The minor version specified by the user.
Date Created41.0The date the file was created. This is a Unix timestamp.
Date Modified41.0The date the file was last modified. This is a Unix timestamp.
Index Major4<2.0The major version of the index table format.
Index Count4AllThe number of entries in the index table.
Index First4<2.0The first entry in the index table.
Index Size4AllThe size of the index table in bytes.
Trash Count4<2.0The number of entries in the trash table (also known as the "Hole" table).
Trash Offset4<2.0The number of entries in the trash table.
Trash Size4<2.0The size of the trash table in bytes.
Index Minor4<2.0The minor version of the index table format.
Index Offset42.0The offset of the index table in the file (also known as "Index Position").
Unknown42.0Unknown field.
Reserved32AllReserved space for future use.

The Tables

The DBPF file format contains 3 types of tables that function as a table of contents for the file:

  • The Index Table: This table contains information about the files embedded in the DBPF file.
  • The Trash Table (also known as the Hole Table): This table was used as a way to mark entries as deleted without actually removing them from the file.
  • The DIR Table: This table is a subtable used when an entry for the index table is an archive. It is duplicative of the index table, but shows the uncompressed file size, instead of the compressed file size field of the entry.

Table Entries (AKA "DBPF Resources")

Each table is a consecutive array of entries. Each entry is a fixed size and contains information about the file it represents.

The size of the entries is determined by the version of the DBPF archive and the index table.

DBPF v1.0 - Table Version 7.0

This is the oldest revision of the DBPF file entry. While defined in v1.0, it is also occasionally used in v1.1 files.

It is only 20 bytes long and contains the following fields:

FieldBytesDescription
Type ID4The type ID of the file. This is commonly rendered as a hex string. See: Resource Types
Group ID4The group ID of the file. This is commonly rendered as a hex string.
Instance ID4The instance ID associated with the file. This is commonly rendered as a hex string.
Offset4The offset of the file in the DBPF file.
Size4The size of the file in bytes.
DBPF v1.1 - Table Version 7.1

This revision is 24 bytes long

FieldBytesDescription
Type ID4The type ID of the file. This is commonly rendered as a hex string. See: Resource Types
Group ID4The group ID of the file. This is commonly rendered as a hex string.
Instance ID High4The high 32 bits of the instance ID associated with the file. This is commonly rendered as a hex string.
Instance ID Low4The low 32 bits of the instance ID associated with the file. This is commonly rendered as a hex string.
Offset4The offset of the file in the DBPF file.
Size4The size of the file in bytes.
DBPF v2.0

v2.0 uses a slightly different format for the table entries. Every entry is a total of 32 bytes long, but a portion of that may be shared with what is known as the "Header Entry."

The header entry is a partial entry that all DBPF v2.0 entries are derived from. It is variable length, and is typically 0-8 bytes long, but could theoretically be 32 bytes long.

The size of the header entry and the fields present in it are determined by the mode flag (also known as the "Index Type") of the DBPF file. The mode flag is an enum that dictates what fields from the derived entries are to be populated by the header entry.

Flag enums can be tricky to understand and explain, but they are easiest understood when rendered as a binary number. Basically, for each set bit in the underlying binary number, that marks what field is to be pulled from the header entry.

For example, a mode flag of 7 (0b0111) would mean that the Type, Group, and Lower Instance fields are pulled from the header entry, while the rest is unique to each entry. NOTE that the "flags" are read from right-to-left, so the rightmost bit represents the Type ID.

FieldBytesDescription
Type ID4The type ID of the file. This is commonly rendered as a hex string. See: Resource Types
Group ID4The group ID of the file. This is commonly rendered as a hex string.
Instance ID High4The high 32 bits of the instance ID associated with the file. This is commonly rendered as a hex string.
Instance ID Low4The low 32 bits of the instance ID associated with the file. This is commonly rendered as a hex string.
Offset4The offset of the file in the DBPF file.
Size - File4The number of bytes the resource takes up in the DBPF file.
Size - Memory4The number of bytes the resource takes up uncompressed.
Compression Flag2A the resource compression. Currently, ownly 3 values (other than 0 for no compression) are well defined: 0xFFFF for RefPack, 0xFFFE for streamable RefPack, and 0x5A42 for zlib. There's also a supposed 0xFFE0 for deleted entries.
Unknown2Unknown field.
DBPF v3.0

This format is uncommon, and not much is known about it other than it is possibly used in SimCity 2013.

 

Edit this page