aboutsummaryrefslogtreecommitdiff
path: root/titlecompression.txt
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-20 23:46:17 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-20 23:46:17 -0500
commit9d032c9a1c0eca663c6877f5421957f50cb1eb79 (patch)
tree3626b074e0beece467318f41d35d42cb146d57e0 /titlecompression.txt
parent8aec40856588437a20906a0820941382475344ec (diff)
downloadtaipan-9d032c9a1c0eca663c6877f5421957f50cb1eb79.tar.gz
rewrite sound code in asm, shed 186 bytes
Diffstat (limited to 'titlecompression.txt')
-rw-r--r--titlecompression.txt45
1 files changed, 43 insertions, 2 deletions
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