14 · Media & Data

Asset File Formats

Every format in Data/ decoded against its loader: ALLZ compression (byte-exact verified), ALAR archives in three versions, ALSN sound containers, and the recursive DAT\0 tagged directory that organizes the map data.

14.1The universal pipeline

Extensions lie: .dat, .txm, .pak carry no format information. What matters is the header: every asset the game opens goes through one path:

ALStreamImp::CreateTry(filename)
  → read header; if magic == 0x5A4C4C41 ("ALLZ") → ALLzDecoder::Decode
  → returns the (decompressed) stream, size aligned to 0x800
    → the consumer parses its own container (ALAR / ALSN / TXM / DAT\0 / raw)

14.2ALLZ compression: solved byte-exact

struct DGF_ALLZ_Header {          // 12 bytes
    uint32 magic;                 // 0x5A4C4C41 little-endian "ALLZ"
    uint8  version;               // must be < 2 (0/1 supported)
    uint8  match_length_base_bits;      // variable-length int coding
    uint8  back_distance_base_bits;
    uint8  literal_length_base_bits;
    uint32 uncompressed_size;
};

An LZ-family codec whose variable-length integers are parameterized by the three base-bit fields in the header. The decoder (ALLzDecoder::Decode) was reimplemented out-of-band and verified byte-exact against full files; this format is fully closed. Most .dat and .atx files begin with ALLZ.

14.3ALAR archives (three versions)

Aqualead archives bundle named resources; three header generations exist in the shipped data:

VersionLayoutNotes
v1filename/resource recordssimplest; names inline
v2range/flags + inline name/hashadds range counts and flag words
v3u16 header_size @+0x10, then a u16 descriptor-offset table; descriptors: ID/offset/stored-size @+0/4/8, range count @+0x0c (24-bit mask), flags @+0x0f, name hash @+0x10, optional inline name @+0x12flag bit 2 = separate entry (lazy extended header); bit 6 = name-hash support. Accessors GetOffset/GetSize @ 0x31c430/0x31c464

The archive handler registry (ALArchiveImp::ArchiveHandlers) dispatches per version; BG.aar, Effect.aar (boot-loaded) and the hundreds of *TextureD/N*.aar pairs all resolve through it.

14.4ALSN sound containers

struct DGF_ALSN_Header {          // 32 bytes, in .asn files (3,728 of them)
    u32 channels; u32 sample_rate;
    u32 loop_start, loop_end;     // loop points for BGM/engine sounds
    u32 pcm_offset; …
};

Payload is typically Ogg Vorbis (libs compiled in) or raw PCM. Loader: ALSoundImp::CreateTry. The LoopUpdateFunc feeds OpenAL streaming queues from these.

14.5The DAT\0 recursive container

Map data and many game resources live in a self-describing tagged directory:

struct DAT_HEAD { char magic[4]; /* "DAT\0" on disk — "dAT" in memory after fixup */
                  uint count; };               // 8-byte header
entries: (pointer, size) pairs                  // DatGetTag: returns base+2 (skips header)

On disk the magic reads DAT\0; after the loader's pointer-fixup pass the in-memory magic reads dAT (case change = "already fixed up"). Entries' internal offsets get the container base added at load; nested DAT\0 containers are legal and common. The route/map pack structure: map.dat (per-line geometry) + areapacNN.dat (per-segment area banks, double-buffered), containing 76-byte ROUTE_TAG centerline segments, 16-byte RAIL_TAG rail samples (cant as signed Q8, range ±1536), sub-rail geometry pairs, sight/OKI objects and event trigger records.

14.6Textures and models

FormatHeaderRole
ALTX (.atx)magic 0x58544C41 "ALTX", 12-byte header + 8-byte descriptorUI/texture containers (Warning.atx, menu sheets)
TXM (.txm)16-byte TXM_HEAD: image+CLUT format/dims, PS2-style PSM codestexture+palette pairs, recursive DAT directory
ALIG28–32 bytes, 3 layout modes, pixel fourccraw images (BMP/TGA handlers registered too)
ETC1/KTXFourCC "ETC1"GPU-compressed world textures (GLES2 path)
ALMS/AMS40-byte mesh header / versioned skeletal blocksstatic meshes / skinned train models with bone remaps
ALOD v2variable node/property directoryscene graph (bace.aod in BG.aar)
VMAanimation streams38 files of motion data

14.7The corpus

ExtensionCountRole
.asn3,728ALSN sound containers (Ogg Vorbis payloads)
.dat726ALLZ-compressed packs: maps, models, timetables
.aar350ALAR archives (models/textures/UI)
.txm85texture + CLUT resources
.vma38animation/motion data
.mp424intro/ending videos (CedarX)
.atx4ALTX texture/UI containers

Total: 4,975 files, ~1.6 GB. The loaders for every container above exist in the binary and are traced; a reimplementation that implements ALLZ + ALAR + ALSN + the DAT walker can mount the original Data/ tree unmodified.

← 13 · Audio System