If you used radix 40 you could pack 3 characters per word. That gets you upper case 'A' to 'Z', '0' to '9' and four left over for punctuation e.g. ' ', '.', '?' and '!'.
You can do even better with "dictionary" compression. Colossal Cave (and any text adventure) reuses many words, so at some point it may be worth actually compressing the text that way and writing a simple decompressor.
For example, if you just did something really dumb and stored a 16 bit address for each word, then the decompressor would look something like this, conceptually:
- Get address of next word
- If it's 0, stop.
- If it's not zero, print the word stored at the address.
- Print a space character.
Since most words will be more than 2 characters and since the space character is implicit, that super simple scheme would net you a noticeable savings.
To take most of the pain out of it, though, it may be worth scripting the compression outside of the assembler, and have it generate the assembly for you. Otherwise, you'd have to write all that stuff manually:
@@Welcome S16 "Welcome"
@@to S16 "to"
@@Colossal S16 "Colossal"
@@Cave_ S16 "Cave."
@@intro DECLE DICT.Welcome, DICT.to, DICT.Colossal, DICT.Cave_, 0
That encoding took up 15 words (if I counted correctly). The original phrase took 27 bytes (including terminating NUL), so there's a modest increase here, since there was no reuse. I say modest increase because 15 words is 30 bytes. But the moment you reuse a word, you start gaining. (Side note: S16 is my macro for encoding packed strings, with two bytes per word.)
You can obviously gain much, much more with more sophisticated compression.
(Second side note: This editor hates me when I try to post well formatted code.)
I don't think I ever played Colossal Cave Adventure, but from what I understand it is the granddaddy of text adventure and interactive-fiction games.
It appears my Ubuntu box has it installed (under the name "adventure"). I wouldn't be surprised if you could find a version that compiles on MacOS X easily, since I think it's part of the BSD Games distribution. (I'd check right now, but for whatever reason I can't connect to my wife's Mac.)
Edit: This appears to be a MacOS X port of one version of Adventure: http://www.lobotomo....ture/index.html
Edited by intvnut, Fri Feb 10, 2012 1:29 PM.