TSCrunch

package module
v0.0.0-...-7d8d1dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

README

TSCrunch

TSCrunch is an optimal, byte-aligned, LZ+RLE hybrid encoder, designed to maximize decoding speed on NMOS 6502 and derived CPUs, while keeping decent compression performance (for a bytecruncher, that is). TSCrunch was designed as the default asset cruncher for the upcoming game A Pig Quest, and, as such, it's optimized for in-memory level compression, but at as of version 1.0 it can also create SFX executables for off-line prg crunching.

Requirements

TSCrunch requires python 3.x with scipy library installed, or a windows x64 machine(A pre-compiled windows x64 command line executable is also provided). A GO version is also supplied to facilitate building on your OS of choice. The memory decrunchers requires Kick Assembler, but it should be quite easy to port it to your assembler of choice.

Usage

tscrunch [option] infile outfile

Crunching examples:

tscrunch -x $0820 game.prg crunched.prg

Crunches the file game.prg and generates a self executable crunched.prg, using $0820 as post-decrunch jmp address

tscrunch -p game.prg crunched.bin

Mem-crunches the file game.prg, stripping the 2-byte header and generates a binary file crunched.bin

tscrunch data.bin crunched.bin

Mem-crunches the file data.bin and generates a binary file crunched.bin

tscrunch -i data.prg crunched.prg

Mem-crunches the file data.prg for in-place use, and generates a prg file crunched.prg with the appropriate load address

Please refer to the inline help (tscrunch -h) for a detailed description of the different crunching options. Note that with the exception of self executables and inplace, all the files generated by TSCrunch are headless binaries, that is they don't come with a 2 byte loader offset.

Decrunching files from code

For memory decrunching, please #include decrunch.asm and include the crunched binaries in your code, then use the macro TS_DECRUNCH, as explained by the following code fragment

	.pc = $1000 "test"
	//decrunches data to $4000
	:TS_DECRUNCH(compressed_data,$4000) 
	jmp *

	.align $100
	#include "decrunch.asm"
	
	compressed_data:
	.import binary "data.bin"

For inplace decrunching, please #define INPLACE before including the decruncher code, as explained by the following code fragment

	#define INPLACE

	.pc = $1000 "test"
	//decrunches data inplace
	:TS_DECRUNCH(compressed_data) 
	jmp *

	.align $100
	#include "decrunch.asm"
	
	.pc = LoadAddress //as provided by the cruncher
	compressed_data:
	.import c64 "data.bin"

decruncher.asm is the recommended decruncher for the general case, but other than it two alternative decrunchers are supplied: a small version, which saves some bytes at the cost of speed, and an extreme version which is generally marginally faster, but comes with a increased footprint.

Performance

TSCrunch is designed for ultra-fast decrunching while keeping a decent compression ratio. Being a byte-cruncher, it falls short of popular bit-crunchers, such as exomizer or B2, when comparing compression efficiency, but it is usually much faster at decoding. Furthermore, you can expect a 20% to 40% speed bump compared to popular byte-crunchers with similar compression efficiency. The following benchmark compares TSCrunch performance with those of a fast byte-cruncher, TinyCrunch, and a two fast bit-crunchers, B2 and dali, on a real-case compression scenario: Chopper Command, from the same author.

benchmark

Documentation

Index

Constants

View Source
const LITERALID = 4
View Source
const LITERALMASK = 0x00
View Source
const LONGESTLITERAL = 31
View Source
const LONGESTLONGLZ = 64
View Source
const LONGESTLZ = 32
View Source
const LONGESTRLE = 64
View Source
const LONGLZID = 5
View Source
const LZ2ID = 3
View Source
const LZ2MASK = 0x00
View Source
const LZ2OFFSET = 94
View Source
const LZID = 2
View Source
const LZMASK = 0x80
View Source
const LZOFFSET = 32767
View Source
const MINLZ = 3
View Source
const MINRLE = 2
View Source
const RLEID = 1
View Source
const RLEMASK = 0x81
View Source
const TERMINATOR = LONGESTLITERAL + 1
View Source
const Version = "1.3"
View Source
const ZERORUNID = 6

Variables

This section is empty.

Functions

func LIT

func LIT(i int, size int) token

func New

func New(opt Options, r io.Reader) (*tsc, error)

Types

type Options

type Options struct {
	QUIET   bool
	PRG     bool
	SFX     bool
	INPLACE bool
	STATS   bool
	Fast    bool // skipping RLE ranges drastically improves crunch time at the cost of pack-ratio.
	JumpTo  string
	// contains filtered or unexported fields
}

Directories

Path Synopsis
cmd
multitonycrunch
TonyCrunch is a fork of Antonio Savona's TSCrunch.
TonyCrunch is a fork of Antonio Savona's TSCrunch.
tonycrunch
TonyCrunch is a fork of Antonio Savona's TSCrunch.
TonyCrunch is a fork of Antonio Savona's TSCrunch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL