printtok-002.c/cc65 online: help needed

4 posts / 0 new
Last post
Offline
Last seen: 3 hours 32 min ago
Joined: Nov 12 2022 - 16:50
Posts: 200
printtok-002.c/cc65 online: help needed

Hi!  I have printtok-002.c online.  It is a way to print token-compressed strings using my SimpleIO libraries.  It is at c65 additions - Manage /ui at SourceForge.net.  It's pretty good but has two problems: 1. poor compression ratio (it helped a text adventure's text by a little over 25%) and 2. it requires manual compression.  :(  I want to improve it by adding support for compressing individual literals by using 5 bits per character for text containing just lowercase and certain punctuation, 6 bits if uppercase is also needed and 7 bits at worst, shortening extended token size after the escape sequence to no more than 6 bits and shortening RLE of spaces to just 4 bits for the length.  What do you think?  Until I'm ready to implement these, what other ways can I compress strings?

mmphosis's picture
Offline
Last seen: 2 days 22 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 433
It depends on the text that

It depends on the text that is being compressed. Is it words? Is it sentences? Can people add, change and delete the words and sentences, or is it read only? I try to get some heuristics from the text in my program. How many of various combinations are used? How important is it to compress text? Are there other things that could be removed first? It's good to think about optimizations for speed and size when creating data structures and code.

 

I rarely, if at all, use compression.

 

 

 

Offline
Last seen: 3 hours 32 min ago
Joined: Nov 12 2022 - 16:50
Posts: 200
I am compressing the text for

I am compressing the text for a text adventure.  The text is mainly sentences the text adventure will reply to the user.  The text adventure won't change the text, but I will likely change the text at code time.  Right now, the printtok-002 code has two ways of compressing tokens: 32 tokens are mapped in the literals range from 0x80 to 0x9F and 52 more as a % followed by a letter.  It also can compress spaces using RLE.  I'm wondering if there are any other ways to compress text strings, something I can do before I apply literals compression and support for auromatic compression.

Offline
Last seen: 3 hours 32 min ago
Joined: Nov 12 2022 - 16:50
Posts: 200
It is currently not essential

It is currently not essential that I compress the text, as the text adventure's main executable is <8k and the text file is <5k on a Commodore 64--a 64k system.  I really like compression, though, and I want to create it for a system with little memory and make it available to other users.  As it is a text adventure, I am optimizing for size.

Log in or register to post comments