Skip to content

Instantly share code, notes, and snippets.

Last active Dec 15, 2020
What would you like to do?
# TIC80 packer
# Uses the zlib code chunk to crunch down your source
# Usage: tic80packer [lua file]
import sys
import zlib
with open(sys.argv[1], mode='rb') as file:
uncomp =
print("Uncompressed length: {} bytes".format(len(uncomp)))
comp = zlib.compress(uncomp, zlib.Z_BEST_COMPRESSION)
print("Compressed length: {} bytes".format(len(comp)))
print("With header: {} bytes".format(len(comp)+4))
with open(sys.argv[1]+".tic", 'wb') as file:
file.write(bytes([len(comp) & 0xFF]))
file.write(bytes([len(comp) >> 8]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment