From 9d032c9a1c0eca663c6877f5421957f50cb1eb79 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 20 Jan 2016 23:46:17 -0500 Subject: rewrite sound code in asm, shed 186 bytes --- titlecompression.txt | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'titlecompression.txt') diff --git a/titlecompression.txt b/titlecompression.txt index 9c30232..456ddf2 100644 --- a/titlecompression.txt +++ b/titlecompression.txt @@ -214,8 +214,49 @@ containing the table definition and the rest of the decoding code. If you look at titlecomp.pl, you'll see it takes an optional argument, forcing it to use a particular byte value as the first code value. This -number is determined by running the script repeatedly with different -arguments, to find the one with the smallest table size. +number is determined by: + +$ perl titlecomp.pl < titledata.dat +200 unique byte values +36 available run codes >= 128 +1st code 128, last 189, table size 62 +3437 bytes compressed data, 58.3% ratio +used 25 codes + +The table size worked out to 62 bytes. We can likely do better than that, +but the process isn't automated. The "used 25 codes" bit is important: +we call titlecomp.pl with that number as an argument to its -l option: + +$ perl titlecomp.pl -l 25 < titledata.dat +200 unique byte values +36 available run codes >= 128 +133 57 +147 57 +148 62 +149 65 +151 64 +154 62 +162 57 +163 67 +164 71 +166 70 +== optimum firstcode value is 133 + +So now we compress the file for real, using 133 as the first code: + +$ perl titlecomp.pl 133 < titledata.dat +200 unique byte values +36 available run codes >= 133 +1st code 133, last 189, table size 57 +3437 bytes compressed data, 58.3% ratio +used 25 codes + +Plug the number 133 into the Makefile (under the comptitle.xex target) and +we're done. Whew, that was a lot of work just to save 5 bytes... the good +news is that this procedure only needs to be repeated if newtitle.png is +edited. The other good news is, those 5 bytes wouldn't have hurt anything +anyway. Worst case scenario, they would have added 1 sector to the file +size (and made it take ever so slightly longer to load). Wait, what do I mean by smallest table size? Well, I said the table contains one entry for each byte value 0 to 255... This isn't really -- cgit v1.2.3