Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Yaz0

From ReverseEngineering.wiki
Format
Platforms Platform:Nintendo GameCube, Wii, Nintendo Switch, Platform:Nintendo 64
Magic 59 61 7A 30 ("Yaz0")
Extensions .szs, .yaz0, .carc
Endianness big
On this wiki Facts · Code · Notes · Topics

Nintendo's LZ77 compression format of GameCube, Wii, Switch and some N64 games (.szs, .yaz0, Yaz0-compressed .arc/.rarc and .carc): a 16-byte header ("Yaz0", big-endian decompressed size, 8 reserved bytes) followed by groups of one flag byte and eight literal bytes or 2-3-byte back-references (distance 1-4096, length 3-273).

Overview

Yaz0 is the compression of most first-party GameCube and Wii archives (Format:RARC archive in GameCube JSystem games, U8 on the Wii) and of SARC on the Switch. Library:JSystem decodes it with JKRDecomp::decodeSZS (S-Z-S: the .szs extension). The earlier Format:Yay0 uses the same token semantics with separate streams.

Header

Offset Size Field
0x00 4 magic Yaz0
0x04 4 decompressed size (big endian)
0x08 4 data alignment: required alignment of the destination buffer, 0 in GameCube files; oead's yaz0::Header calls it data_alignment ("newer files only") and Compress takes it as a parameter, see Fact:Yaz0/struct/Yaz0 header
0x0C 4 reserved, zero
0x10 ... compressed data

Decoding

Read one group header byte; for each of its 8 bits from the most significant:

  • 1: copy one literal byte.
  • 0: read two bytes b0 b1. Distance = ((b0 & 0x0F) << 8 | b1) + 1 (1-4096 back from the current output position). If b0 >> 4 is 0, read a third byte: length = that byte + 0x12 (18-273); else length = (b0 >> 4) + 2 (3-17). Copy byte by byte, so a distance smaller than the length repeats a pattern.

Stop when the decompressed size is reached (the last group may have unused bits). JSystem's decoder also supports starting at an output offset and skipping (used by streaming rippers).

Test vectors

From the decoding rules (checked with the Python decoder on Code:DOL executable/GameCube formats toolkit (Python)):

  • 59 61 7A 30 00 00 00 0A + 8 zero bytes + 80 61 70 00 decodes to aaaaaaaaaa (literal a, then distance 1, length 9).
  • 59 61 7A 30 00 00 00 13 + 8 zero bytes + 80 62 00 00 00 decodes to 19 bytes b (three-byte form, length 0x00 + 0x12 = 18).

Encoders

Nintendo's encoder and community ones (wszst, yaz0enc, oead, Wiimm's tools) produce different but compatible streams; a matching re-encode of a retail file needs the same algorithm. oead's yaz0::Compress (GPL, derived from syaz0) does not search matches itself: it runs zlib-ng's deflate at a level clamped to 6-9 (default 7) and converts each literal or (distance, length) pair zlib reports into Yaz0 tokens, so its output is valid but not byte-identical to Nintendo's. Its decoder rejects a copy that reaches before the start or past the end of the output and reads the length as (b0 >> 4) + 2, or third byte + 0x12 when the nibble is 0. The greedy encoder of the code page above is compatible, not identical.

Code & repositories

  • https://github.com/zeldamods/oead @ 5fb74e1128468380b47da23a5690891c8af4ab72 · license: GPL-2.0-or-later (declared by the contributor for the files used; GitHub reports GPL-2.0 for the repository)
    Library and Python module for Nintendo formats: SARC, BYML, AAMP, Yaz0 (zlib-based encoder), FSTM/FSTP/FWAV audio header readers; src/sarc.cpp and src/byml.cpp define the binary layouts
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-02