[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compressing ProDOS File Type Table



Mike Pfaiffer suggested:

>Jonathyn Bet'nct wrote:
> > I'm writing a program launcher in assembly language, and I want to
> > have a table of all 136 defined ProDOS file types (found at
> > http://www.geocities.com/jonrelay/software/a2info/abftypes.htm) as
> > part of it.
> >
> > To keep the program small and simple, I want to compress the table
> > like BASIC.SYSTEM compresses its keywords (or at least how I _think_
> > it does). For example, I can take the types AWP, WPF, PFS, FST, STN,
> > TNJ, JAP, PTX, TXT, and TOL (totaling 30 bytes) and compress it into
> > AWPFSTNJAPTXTOL (which is only 15 bytes).
> >
> > Doing this by hand, the shortest string I came up with was 277 bytes
> > long. I want one that's 256 bytes or less (so I can fit it in a
> > single page of memory).
> >
> > Here's my question: Is there a program out there that can compress
> > strings this way into the shortest string possible so I don't have
> > to?
> >
>	There is something else you can do. If you won't care about speed you 
>could take the letters (normally 8 bits), disgard the MSB and compress 8 
>bytes into 7.
>
>	You could also come up with a code describing the 26 letters A - Z and 
>the numbers 0 - 9 and perform a similar compression. Looking at an ASCII 
>table it could handle from 0 - 63 characters (with some left over) very 
>nicely. This should compress down to about 25% of the size. You may want 
>to consider taking the number of possible characters down to 0 - 47 and 
>get a tighter compression but at 0 - 63 you get four characters per byte 
>which should make uncompression easier.

Actually, if you go to a 0-63 encoding (six bits per character) you will
get a 25% saving in space (at some cost in code space to expand it.

64 is 25% of 256, but that just means that it uses two fewer bits.  ;-)

The good news is that a 25% saving is more than enough for Jonathyn's
purposes.

-michael

Check out 8-bit Apple sound that will amaze you on my
Home page:  http://members.aol.com/MJMahon/