💾 Archived View for mirrors.apple2.org.za › archive › apple.cabi.net › FAQs.and.INFO › lzss1.01.doc.… captured on 2023-04-20 at 00:25:15.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

LZSS File Compressor with Depacker Source                  by Harihuko Okamura
IIgs translation/enhancements                   by Davius Rex/Anarchic Designs
______________________________________________________________________________

Okay I was running the net late at nite and I ran across some old C source for
LZSS compression/decompression. "Hey cool", I said, and quickly ported it.

Sadly...

It was evilly slow. Apparently the programmer came from the world of 66 MHZ
computers. Ickity ick. I noticed some things that could be done to make it
faster, and did. Compression is still very very slow, but decompression is
blazingly fast (okay... not as fast as Dave Huang's asm version :P).

Compression is so slow because ORCA/C chokes when you try to turn on all
optimizations and makes bad code. Decompression is simple enough that
ICKY/C doesn't throw a shit fit, so it's very fast.

So.

Here we are.

Usage:
~~~~~~
   lzss <cmd> <source> <dest>

   where:
   <cmd> is e for encode or d for decode
   <source> is the file to be compressed
   <dest> will be the compressed file (i recommend the suffix .lzss)

   While it's compressing, a thermometer of 'O's will come up to display the
   progress of the operation. You can hit escape to abort.

Try this now:
~~~~~~~~~~~~~
   Stop reading this and go into ORCA or GNO/ME, and use lzss like this:

   lzss d test.lzss test.pic

   Then view with FinderView or whatever... This is ~32k depacked, but only
a fraction of that size when packed. How cool!


Depacking from within your own programs:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   There should be a file "lzssd.cc" in this archive, containing a subroutine
called "LZSSDecode" and a few variables. You can just compile this and link
it in to your programs for easy decompression. Then, call LZSSDecode with
the following params:

   LZSSDecode (sourceptr, sourcesize, destptr);
               ^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^
                   |          |          |______________ ptr to a place to store
                   |          |                          the unpacked data
                   |          |_________________________ size in bytes of the
                   |                                     source data
                   |____________________________________ ptr to the source data


for example, here's some easy code to load and depack a SHR screen image.

   FILE *f;
   int size;
   Pointer srcPtr;

   f = fopen ("1:Data:pic.lzss", "rb");            /* open picture */
   size = fsize (f);                               /* find the size */
   srcPtr = malloc (size);                         /* allocate needed memory */
   fread (srcPtr, 1, size, f);                     /* read the data */
   LZSSDecode (srcPtr, size, (void*) 0x00E12000);  /* depack it to SHR screen */
   free (srcPtr);                                  /* free the pointer */
   fclose (f);                                     /* close the file */

   oops, fsize() is one of my subroutines. Write your own, duh, it's handy.

Why LZSS?
~~~~~~~~~
   LZSS is fast when decompressing, which is what most programs will be doing.

About me:
~~~~~~~~~
   I am Davius Rex, member of Anarchic Designs, a group consisting of myself
and JimBob (huhuh I said "member" huhuhuh), and since we're the same person,
it gets kinda lonely. Fortunately I have a girlfriend (finally!) who I'd like
to thank for mental health support.
   This utility was produced with the help of Nirvana, Vito's "Real Italian"
Pizza, and Pepsi (tm).

How to reach me: (like you'd really want to do this...)
~~~~~~~~~~~~~~~~
   Internet: Davius_Rex@bastards.colum.fnet.org (i've never tried this)
   IRCNick: JimBob, j-bob, DaviusRex
   FVNet: Davius Rex@Byte Bastards

See my other products!
~~~~~~~~~~~~~~~~~~~~~~
   sc 1.03 - scroll code generator
   JimBobDemo - ickity ick, lame demo :P

Watch for more cool utils like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ver - easily put rVersion resources in from the command line

And another demo! ("ick", you say.. well this new one's much better already! :)
~~~~~~~~~~~~~~~~~