LTA (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

LTA (LE-CODE Track Archive) is an archive format developed by Wiimm with ideas of Leseratte. The SZS files of the tracks are stored in the archives. The purpose is to reduce the size of the main directory in order to reduce its storage space.


LE-CODE supports up to 4096 tracks including the original tracks and arenas. In addition there are approx. 5% _d tracks, so that we have a total of approx. 4300 tracks. Each normal track requires 20 bytes and each _d track 22 bytes in the main directory of the image. That's a total of more than 86 KB permanently stored in main memory. Extracted common files increases this amount.

The idea now is to replace these 4300 files with about 4 LTA files (max size is 2 GiB), which then only occupy an estimated 100 bytes in the main directory. This saves about 86 KB of main memory. LE-CODE then searches for the tracks in these files. By the way, the main directory of the original DVD has a size of 64 KB.

Within LTA files, the SZS files are addressed via a slot index so that no space is required for file names. Wiimms SZS Tools from version 2.37a can manage LTA files.


  • 3 sections: File Header, Node List, Data. Each section is aligned to 32 Bytes.
  • One node for each slot. Each node supports up to 4 files: SZS and LFL files, standard and _d files. Each node and each file data is aligned to 32 Bytes.
  • LFL files are used for ./common/ files. This means that they no longer have to be unpacked manually.
  • Up to 5 LTA files (tracks-1.lta to tracks-5.lta) are supported by LE-CODE.
  • LE-CODE can manage any number of nodes. So there is no limit here. Anyway, LTA generators may have a limit.
  • Maximum file size must be <2GiB. Because of aligned data, the maximum size of an LTA file is 0x7fffffe0 (2147483616) bytes.
  • Files with identical content are recognized and the content is saved only once.
  • If no _d file is found, then the standard record is copied to the _d record. So only 1 LTA lookup is needed.
  • Since the Wii reads data from the DVD in blocks of 32 bytes, all blocks of data are aligned accordingly.

How LE-CODE searches SZS and Common files

This section describes plans for how LE-CODE will use LTA files. However, this has not yet been implemented.

If the new track index (slot) is known, LE-CODE checks, if file Race/Course/###.szs exists. If it exists, then the classic mode is used. Otherwise LTA mode is used. In classic mode, each supported common file is searched in directory Race/Common/###/.

File Format

All integer values are stored in network byte order (big endian).

File Header

Each file starts with an LTA header.

File header of LTA files
Offset Name Type Description
0x00 magic char[8] File magic, always »LTR-ARCH«
0x08 version uint32 Major version number, 1 at the moment.
0x0c head_size uint32 Size of this header (also minor version number). 0x24 at the moment.
0x10 file_size uint32 Total size of this LTA file. Aligned to 32 bytes. Maximum is 0x7fffffe0.
0x14 node_offset uint32 Offset of node list. Aligned to 32 bytes. Usually placed at the end of the file.
0x18 node_size uint32 Size of a single node. 32 at the moment.
0x1c base_slot uint32 First used slot. The last used slot is base_slot + n_slots - 1.
0x20 n_slots uint32 Number of used slots.
0x24 End of file header

Node List

Nodes consist of 2 records, one for the standard track and one for the _d track. If a _d track is not found, a copy of the standard track is used instead. The node list is usually stored at the end of the file (behind the data). This allows the LTA generator to process all source files in a single pass.

Node record of LTA files
Offset Name Type Description
0x00 szs_offset uint32 Offset of data of SZS file. Null if nonexistent. Aligned to 32 bytes.
0x04 szs_size uint32 Size of data of SZS file. Null if nonexistent.
0x08 lfl_offset uint32 Offset of data of LFL file. Null if nonexistent. Aligned to 32 bytes.
0x0c lfl_size uint32 Size of data of LFL file. Null if nonexistent.
0x10 End of node-record
Node of LTA files
Offset Name Type Description
0x00 std node_record_t Offsets and sizes of standard files.
0x10 d node_record_t Offsets and sizes of _d files. Same as std if no _d file exists.
0x20 End of node


The data of each file is stored at any place behind the file header. Usually it is stored before the node list in slot order, and here standard before _d file, and SZS before LFL. Each data part is aligned to 32 bytes and padded to the next 32 bytes boundary. Files with identical content are recognized and the content is stored only once.

Manage LTA files

Creating an LTA file

As of version 2.38a of Wiimms SZS Tools, the command wlect distrib supports the instructions lta=DIRECTORY and lta=OPTIONS=DIRECTORY. It creates the LTA files according to the internal distribution model and stores the files into the given directory. Due to the file limit of 2 GiB, several LTA files may be created.

OPTIONS is a comma separated list of 0 or more options:

remove or rm
Remove all used SZS source files at the very end of command wlect distrib.
yaz0, bz, bzip2, lz and lzma
Force a compression method for all added track files. Re-compress track files with other methods.

DIRECTORY specifies the destination directory. Only files with valid member PATH are added to the archives. SZS files with unknown paths are searched in directories defined by the options --copy-tracks, --move-tracks, --move1-tracks and --link-tracks. Files with identical content are recognized and the content is saved only once.

Executing this instruction may take a little longer as all track files need to be processed. Much more time is required if compression is forced. When creating an LTA file, a log message is displayed:

tracks-1.lta (1245 MB), slots 0..1048 (1028 std, 49 _d, 10 LFL, 57 cache, 67 conv, 165+3 dup), 2m07s

It means: File tracks-1.lta with 1245 MB was created. The slot range goes from 0 to 1048. 1028 standard and 49 _d files were added. 10 LFL files were created for common stuff. 57 files were loaded from cache and 67 files were converted (new compression method). 165 duplicates of the tracks and 3 duplicates of the LFL files were detected. The duplicate data was only saved once (like hard links).

Other commands

Command wszst filetype detects LTA files. Command wszst list (including all list variants) lists the content of LTA files. Command wszst extract extracts all included files.