-
Notifications
You must be signed in to change notification settings - Fork 6
/
readme.txt
106 lines (66 loc) · 3.73 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
TSCrunch V1.1
by Antonio Savona
March 2022
About
=====
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). The memory decruncher 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
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"
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 fast bit-cruncher, B2, on two real-case compression scenarios: Chopper Command and Frostbite, from the same author.
Chopper Command - Raw encoding - game prg
Tscrunch 1.0 TinyCrunch 1.2 B2
Size 46913 46913 46913
Crunched size 13321 15419 11181
% of original 28.40% 32.87% 23.83%
Decrunch cycles 799826 1133039 1694585
Cycles per byte 17.0491335 24.15191951 36.12186388
Frostbite - Raw encoding - game prg
Tscrunch 1.0 TinyCrunch 1.2 B2
Size 61185 61185 61185
Crunched size 21329 22931 17759
% of original 34.86% 37.48% 29.03%
Decrunch cycles 1176826 1507239 2475450
Cycles per byte 19.2338972 24.63412601 40.4584457
Future development
==================
-Block-loading management for integration in disk loaders.
-Speed up crunching, possibly rewriting the code C.