XPCK
Filetype: Archive
File Extension(s): .pck, .xc, .xv, .xa, .xb, .xk, .xf, .xr
Signature: XPCK
Platform(s): Nintendo 3DS
Endianness: Little-endian
Used in: Yo-kai Watch 1, Yo-kai Watch 2, Yo-kai Watch Blasters, Yo-kai Watch 3, Yo-kai Watch Busters 2
Alignment: 4 Byte Alignment
String Encoding: ASCII
The XPCK file format is a generic flat archive (no directories) used to bundle related files together. The purpose of the XPCK in question can generally be inferred based on the file extension as shown below:
| Extension | Description |
|---|---|
.pck | A somewhat rare file extension that is completely generic in usage. |
.xc | Used for model files containing many different properietary file formats ranging from bones to materials and outlines. |
.xv | Holds camera files, including CMR.bin and .cmr2 files. |
.xa | Contains ANM (ANiMe) resources. |
.xk | Named XSky, used to configure fog, sky, and related data. Includes SKY.bin, FOG.bin, SUB.bin, and .lgt files. |
.xf | Known as XFont files, used to define custom fonts. |
.xr | Generic resource bundle. Can contain 2D or 3D assets, though mostly 2D. |
.xb | - |
XPCK has an earlier sibling format by the name of XFSP. Many games allow their use interchangeably such as Yo-kai Watch 1 for Smartphone. However, despite their (theoretical) utility, they are unused in the Yo-kai Watch series in favour of XPCK. Therefore, XFSP will not be documented here.
An XPCK archive has the following layout:
| XPCK |
|---|
| Header |
| File Entry Table |
| L5CC(Name Table) |
| (4-byte alignment pad) |
| File Data Section |
[!NOTE] All offsets within an XPCK archive are stored as 32-bit words (4 byte units). Meaning, to derive the offset in bytes, you must multiply the given offset by 4 (or
<< 2). This will still be mentioned for each applicable field to be safe.
Header
struct XPCKHeader {
u32 magic; // XPCK
u16 fileCountData; // the high nibble is fileIdxBits, the remainder is fileCount
u16 fileMetadataOffset; // offset to the File Entry Table in words
u16 nameTableOffset; // offset to the (compressed) Name Table in words
u16 fileDataOffset; // offset to the File Data section in words
u16 fileMetadataSize; // size of the File Entry Table in words
u16 nameTableSize; // size of the (compressed) Name Table in words
u32 fileDataSize; // size of the File Data section in words
};
[!NOTE]
fileIdxBitscan be calculated using the following formula:ceil(log2(fileCount)). It appears to be unused, so in theory, one may ignore this field.It is unknown what occurs in the case
fileCount == 0as no such samples exist within the Yo-kai Watch franchise, although it is very likely that in this casefileIdxBits = 0.
File Entry Table
This table contains fileCount entries - each of size 0x0C. Aditionally, all entries are sorted by their crc32 value in ascending order when written.
struct XPCKFileEntry {
u32 crc32; // CRC-32B (ISO-HLDC) hash of the filename string
u16 nameOffset; // offset relative to the start of the (decompressed) name table in words
// okay what the hell level5 alignment cannot be this important
u16 fileOffsetLow;
u16 fileSizeLow;
u8 fileOffsetHigh;
u8 fileSizeHigh;
};
[!NOTE] As typical with Level-5, the CRC-32 hash does not include the null terminator.
Name Table
The Name Table is a compressed string table located at nameTableOffset << 2, of (compressed) size nameTableSize << 2 - it is composed of sequential null-terminated ASCII filenames.
Entry Ordering
Note that when writing, files should be sorted alphabetically by name when assigning offsets, just as the entries of the file entry table are sorted by crc32.