Skip to content

Instantly share code, notes, and snippets.

@DRKV333
DRKV333 / WadCompressor.py
Last active July 3, 2026 05:01
Compresses DOOM WAD files using the LZSS algorthm from the Atari Jaguar port
from io import BytesIO
import struct
import sys
from typing import BinaryIO, cast, override
# Based on LZSS.C by Haruhiko Okumura
# https://web.archive.org/web/19990203141013/http://oak.oakland.edu/pub/simtelnet/msdos/arcutils/lz_comp2.zip
# Compared to the original, the version used in DOOM is a bit different:
# - The flag bits are inverted (0 = literal, 1 = compressed)
# - The offset is encoded differently