{"id":17059513,"url":"https://github.com/trapexit/3ct","last_synced_at":"2026-04-24T12:06:58.838Z","repository":{"id":237450105,"uuid":"533080538","full_name":"trapexit/3ct","owner":"trapexit","description":"3DO Compression Folio compatible compressor/decompressor","archived":false,"fork":false,"pushed_at":"2026-04-21T22:09:45.000Z","size":225,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-22T00:24:24.831Z","etag":null,"topics":["3do","homebrew","retrogaming"],"latest_commit_sha":null,"homepage":"https://3dodev.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trapexit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-05T22:37:12.000Z","updated_at":"2026-04-21T22:09:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f335e97c-6fa9-4502-8639-2af3710d4e58","html_url":"https://github.com/trapexit/3ct","commit_stats":null,"previous_names":["trapexit/3ct"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/trapexit/3ct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapexit%2F3ct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapexit%2F3ct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapexit%2F3ct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapexit%2F3ct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapexit","download_url":"https://codeload.github.com/trapexit/3ct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapexit%2F3ct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32222531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3do","homebrew","retrogaming"],"created_at":"2024-10-14T10:34:36.858Z","updated_at":"2026-04-24T12:06:58.833Z","avatar_url":"https://github.com/trapexit.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 3ct: 3DO Compression Tool\n\nA port of the 3DO SDK's compression library to modern platforms with a\ncommand line tool.\n\n\n## Usage\n\n```\n$ 3ct --help-all\n3ct: 3DO Compression Tool (v1.0.0)\nUsage: 3ct [OPTIONS] SUBCOMMAND\n\nOptions:\n  -h,--help                   Print this help message and exit\n  --help-all                  List help for all subcommands\n\nSubcommands:\ncompress\n  Compress input file\n  Positionals:\n    input-filepath PATH:FILE REQUIRED\n                                Path to input file\n    output-filepath PATH:FILE   Path to output file (default: input + '.compressed')\n\ndecompress\n  Decompress input file\n  Positionals:\n    input-filepath PATH:FILE REQUIRED\n                                Path to input file\n    output-filepath PATH:FILE   Path to output file (default: input + '.decompressed')\n\ncheck\n  Checks the compressor and decompressor against data generated by the 3DO SDK compression library\n\n\n$ 3ct compress example.txt\n- input:\n  - filepath: example.txt\n  - size_in_bytes: 1024\n  - size_in_words: 256\n- output:\n  - filepath: example.txt.compressed\n  - size_in_bytes: 144\n  - size_in_words: 36\n\n$ 3ct check\n* output of 3ct compressor matches SDK\n* output of 3ct decompressor matches SDK\n```\n\n## TODOs\n\n* Reverse engineer Game Guru compression format and add to 3ct\n* Rework and modernize compression code\n\n\n## Algorithm\n\nThe 3DO SDK compression algorithm is based on [LZSS\n(Lempel–Ziv–Storer–Szymanski)](https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Storer%E2%80%93Szymanski). An\nLZ77-style dictionary-based algorithm optimized for the 3DO platform\nwhich replaces repeated byte sequences with back-references into a\nsliding window, whilee emitting novel bytes as literals.\n\n\n### Algorithm Details\n\n* **type:** Dictionary-based lossless compression (LZ77-style)\n* **data structure:** Binary search tree for fast string matching\n* **sliding window:** 4096 bytes (2^12)\n  * 12-bit index for window position references\n  * Window maintains previously seen data for pattern matching\n* **look-ahead buffer:** 18 bytes (2^4 + 2)\n  * 4-bit length field encoding phase lengths of 2-18 bytes\n  * Allows efficient encoding of repeated sequences\n* **break-even point:** 2 bytes (minimum phrase length is 3 bytes)\n  * Phrases shorter than 3 bytes are stored as literal bytes instead\n  \n### Encoding Format\n\nEach token in the compressed stream is prefixed with a header bit:\n\n* **header bit = 1:** Literal byte (1 bit + 8 data bits, 9 total.)\n  Emitted when no match longer than 2 bytes (`BREAK_EVEN`) is found.\n* **header bit = 0:** Phrase reference (1 bit + 12-bit index + 4-bit\n  length, 17 total.) The length field stores `match_length \u003e= 3`,\n  encoding match lengths from 3 to 18 bytes.\n* **end of stream:** header bit = 0 followed by position = 0\n  (`END_OF_STREAM`), signaling the decompressor that no more data\n  follows.\n\nThe phrase reference encodes:\n* **position:** 12-bit index into the sliding window (0 - 4095)\n* **length:** 4-bit value representing match length minus 3 (0 - 15,\n  corresponding to 3 - 18 bytes)\n  \n\n### String Matching\n\nThe compressor maintains a binary search tree (BST) over all\nsubstrings in the sliding window for efficient longest-match\nlookup. Each node stores parent, left-child, and right-child\nindices. When a maxium-lenght match (18 bytes) is found, the new node\nreplaces the matched node in the tree. Strings are deleted from the\ntree as they slide out of the window.\n\n### Data Format\n\n* Input and output are word-oriented (32-bit words)\n* The bitstream is packed into 32-bit words in big-endian byte order,\n  matching the 3DO's big-endian ARM60 processor. On little-endian\n  hosts the words are byte-swapped.\n\n\n### Streaming API\n\nThe compressor and decompressor support incremental (streaming)\noperation. Data is fed in chunks via `FeedCompressor` or\n`FeedDecompressor`; internal state (window position, BST, partial\nbit-buffer) is preserved between calls. Convienece wrappers handle\none-shot operation.\n\n\n## Documentation\n\n* https://3dodev.com\n* https://3dodev.com/documentation/development/opera/pf25/ppgfldr/pgsfldr/spg/14spg\n* https://github.com/trapexit/portfolio_os_m2/tree/master/ws_root/src/tools/comp3do\n* https://github.com/trapexit/portfolio_os_m2/tree/master/ws_root/src/tools/decomp3do\n\n\n## Donations / Sponsorship\n\nIf you find 3ct useful please consider supporting its ongoing development.\n\nhttps://github.com/trapexit/support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapexit%2F3ct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapexit%2F3ct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapexit%2F3ct/lists"}