From c82d5178ae3aab0fdfc2be339b5e0ff54ac558e1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 27 Feb 2016 17:38:06 -0500 Subject: use dictionary entries for M_taipan, etc. 7720 bytes free. --- .gitignore | 1 + Makefile | 5 +++++ messages.pl | 12 ++++++++++++ textdecomp.s | 2 ++ 4 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 392f6ab..45483cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +msg.inc messages.c msg.out msg.tmp diff --git a/Makefile b/Makefile index e561e73..758f06b 100644 --- a/Makefile +++ b/Makefile @@ -297,6 +297,11 @@ convfont: convfont.c textcomp: textcomp.c $(HOSTCC) $(HOSTCFLAGS) -o textcomp textcomp.c +# textdecomp.s includes msg.inc +textdecomp.s: msg.inc + +msg.inc: messages.c + # messages.c is a generated file messages.c: messages.pl textcomp perl messages.pl > messages.c diff --git a/messages.pl b/messages.pl index 1120a8b..61ae824 100644 --- a/messages.pl +++ b/messages.pl @@ -13,6 +13,7 @@ open my $t, ") { next unless /^dict(\d\d):.*;\s*"([^"]*)"/; my $id = $1; + my $dictlabel = "dict$1"; if($id < 27) { $id = chr($id + 96); } else { @@ -21,6 +22,7 @@ while(<$t>) { my $value = 'Z' . $id; my $key = quotemeta $2; $dictionary{$key} = $value; + $dictlabels{$value} = $dictlabel; } close $t; @@ -29,6 +31,8 @@ close $t; #} #exit 0; +open ASMINC, ">msg.inc" or die $!; +print ASMINC "; do not edit, contents are generated by messages.pl\n\n"; print "// do not edit, contents are generated by messages.pl\n\n"; while() { @@ -53,6 +57,14 @@ while() { } } +# if a string turns out to be exactly a dict entry, no need to include +# the compressed version in messages.c. + if(/^Z.$/) { + print "\nextern const char M_$label\[\]; // dictionary used, $dictlabels{$_}\n\n"; + print ASMINC " _M_$label = $dictlabels{$_}\n .export _M_$label\n\n"; + next; + } + if(@ARGV) { my $w = $_; $w =~ s/\n/\\n/g; diff --git a/textdecomp.s b/textdecomp.s index fa82d7e..403507c 100644 --- a/textdecomp.s +++ b/textdecomp.s @@ -167,6 +167,8 @@ dict_offsets: dictsize = * - dict00 .out .sprintf("dictionary plus dict_offsets is %d bytes", dictsize) + .include "msg.inc" + .rodata table: ; outsnac values 53..63 .byte ' ', '!', '%', ',', '.', '?', ':', 39, 40, 41, $9b -- cgit v1.2.3