Adds basic text compression. Algorithm works by brute-force finding the best sequence of characters to commonize and pulling it out to a table until it can't find any left that would save any space. "Best" in this case is defined by the formula:
(l c) - (2 c) - l - 1
Where l is the length of the string, and c is the number of time it's used. This is the number of bytes saved by extracting one instance of that string to a table and replacing all instances of it with a two-byte reference ID. -1 more for the additional null terminator.
This also adds print_compressed_string and updates BLOCK_PRINT to use it.
The algorithm likely has room for improvement, but saves approximately 335 bytes of text (62ish of which are taken back up by print_compressed_string) in the "flagship" project (no the test campaign) for this library.
Adds basic text compression. Algorithm works by brute-force finding the best sequence of characters to commonize and pulling it out to a table until it can't find any left that would save any space. "Best" in this case is defined by the formula:
Where
l
is the length of the string, andc
is the number of time it's used. This is the number of bytes saved by extracting one instance of that string to a table and replacing all instances of it with a two-byte reference ID. -1 more for the additional null terminator.This also adds
print_compressed_string
and updatesBLOCK_PRINT
to use it.The algorithm likely has room for improvement, but saves approximately 335 bytes of text (62ish of which are taken back up by
print_compressed_string
) in the "flagship" project (no the test campaign) for this library.