Skip to content

PPF File Format

John Peel edited this page Aug 26, 2021 · 7 revisions

Structures

PPAK

Type Name Expected
char[4] magic "PPAK"
Version12 version 1 or 0
Language[]1 languages
u16 texture_count > 0
GameTexture[texture_count] game_textures
char[4] mesh_magic "MPAK"
u16 mesh_count > 0
Mesh[mesh_count] meshes
ScriptsVersion12 scripts_version 1 or 0
u16 global_count > 0
Global[global_count] globals
u16 script_count > 0
Script[script_count] scripts
u8[*][3 domain/scene

1 This only exists if it's magic is next.

2 These default to 0.

3 The rest of the file.

Version

Type Name Expected
u16 magic 0xFDFD
u16 version 0x0001

Language

Type Name Expected
u16 magic 0xFFFF
u16 id 1 or 2
u32 size > 0
u16 texture_count > 0
GameTexture[texture_count] game_textures

GameTexture

This varies based on Version.

Version 1

Type Name Expected
char[4] magic "XT1 "
u32 size
GameTexture game_texture (See Version 0)

Version 0

Type Name Expected
u32 element_id (ignored)
u32 texture_handle (can be ignored)
u32 palette_handle (can be ignored)
u32 path_ptr
u32 anim_ptr
f32 density (can be ignored)
u32 visual_importance (can be ignored)
u32 memory_importance (can be ignored)
u32 unknown0 ???
u32 flags (can be ignored?)
Path1 path if path_ptr != 0
AnimationInfo1 anim_info if anim_ptr != 0
Texture[*]2 textures

1 This exists based on previous values. See Expected.

2 There are anim_info.frame_count textures, or 1 texture if anim_info doesn't exist.

AnimationInfo

Type Name Expected
u32 frame_count >= 1
f32 start_frame >= 0
f32 loop_frame >= 0
f32 start_time
f32 frame_rate Large
u32 play_mode See PlayMode
bool playing false
u8[3]1 _padding

1 This exists because of alignment.

Texture

Type Name Expected
u32 element_id (ignored)
u32 format See TextureFormat
u32 type See TextureType
u32 flags
u32 width > 0
u32 height > 0
u32 mipmaps >= 0
u32 _ignored0 (ignored)
u32 _ignored1 (ignored)
u32 _ignored2 (ignored)
u32 lock_count (can be ignored)
Palette palette if format == PAL8
u8[*]1 texture

1 You need to calculate texture size based on DDS specification.

Palette

Type Name Expected
u16 has_palette 0 or 1
u32[0x100] palette if has_palette != 0

Path

Type Name Expected
u16 path_length > 0
char[path_length] path path[path_length - 1] == 0

ScriptsVersion

Type Name Expected
u16 magic 0xFCFC
u16 version 0x0001

Global

Type Name Expected
Path path
u32 size > 0
u8[size] global

Script

Type Name Expected
Path1 path
u32 size > 0
u8[size] script

1 This will only exist if scripts_version == 1.

Enums

TextureFormat

Name Value
A8R8G8B8 0x0000
R8G8B8 0x0001
A4R4G4B4 0x0002
A1R5G5B5 0x0003
X1R5G5B5 0x0004
R5G6B51 0x0005
A82 0x0006
L8 0x0007
AL81 0x0008
DXT1 0x0009
DXT3 0x000a
DXT5 0x000b
V8U8 0x000c
V16U161 0x000d
PAL8 0x000e

1 Unused by Psychonauts.

2 Loading from disk is broken in Psychnauts, it tries to load this as L8.

TextureType

Name Value
BITMAP 0x0000
CUBEMAP 0x0001
VOLUMEMAP1 0x0002
DEPTHBUFFER1 0x0003

1 Invalid inside of a Psychonauts PPF file.