diff -BburN zlib-1.1.4/Makefile zlib-1.1.4-palmos/Makefile
--- zlib-1.1.4/Makefile	Mon Mar 11 08:58:30 2002
+++ zlib-1.1.4-palmos/Makefile	Sat Mar 30 17:48:54 2002
@@ -12,9 +12,15 @@
 # To install in $HOME instead of /usr/local, use:
 #    make install prefix=$HOME
 
-CC=cc
+%.o: %.S
+	$(CC) $(CFLAGS) $< -c -o $@
 
-CFLAGS=-O
+#TYPE=palmos-coff
+TYPE=palmos
+
+CC=m68k-$(TYPE)-gcc
+#For PalmOS - Leave MAX_WBITS=15 for inflate, but lower for deflate in call
+CFLAGS= -O3 -DPALMOS -Wall -DNEWGCC -DASMV -I/usr/local/palmdev/sdk/Incs -I/usr/local/palmdev/sdk/Incs/Core -I/usr/local/palmdev/sdk/Incs/Core/System -I/usr/local/palmdev/sdk/Incs/Core/UI -I/usr/local/palmdev/sdk/Incs/Core/Hardware -I/usr/local/palmdev/sdk/Incs/Core/System/Unix -L/usr/lib
 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
 #CFLAGS=-g -DDEBUG
 #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
@@ -28,20 +34,20 @@
 LIBS=libz.a
 SHAREDLIB=libz.so
 
-AR=ar rc
-RANLIB=ranlib
+AR=m68k-$(TYPE)-ar rcs
+RANLIB=m68k-$(TYPE)-ranlib
 TAR=tar
 SHELL=/bin/sh
 
-prefix = /usr/local
+prefix = /usr/local/
 exec_prefix = ${prefix}
 libdir = ${exec_prefix}/lib
 includedir = ${prefix}/include
 
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
-       zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
+OBJS = deflate.o zutil.o uncompr.o compress.o \
+	inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
 
-OBJA =
+OBJA = adler32.o crc32.o lmatch.o
 # to use the asm code: make OBJA=match.o
 
 TEST_OBJS = example.o minigzip.o
@@ -58,7 +64,7 @@
   contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
   contrib/delphi*/*.???
 
-all: example minigzip
+all: SysZLib.prc
 
 test: all
 	@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
@@ -70,6 +76,15 @@
 	  echo '		*** zlib test FAILED ***'; \
 	fi
 
+#PalmOS System Shared Library
+SysZLib.prc: SysZLib0.o SysZLib.o libz.a
+	m68k-$(TYPE)-gcc -nostartfiles -o SysZLib $^
+	m68k-$(TYPE)-obj-res SysZLib
+	rm -f {code,pref,data}0000.SysZLib.grc
+	mv code0001.SysZLib.grc libr0000.bin
+	awk 'BEGIN{printf "1.1.4-1\0";}' >tver0001.bin
+	build-prc -L SysZLib.prc "ZLib" ZLib libr0000.bin tver0001.bin
+
 libz.a: $(OBJS) $(OBJA)
 	$(AR) $@ $(OBJS) $(OBJA)
 	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
@@ -123,7 +138,7 @@
 
 clean:
 	rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
-	   _match.s maketree
+	   _match.s maketree *.grc SysZLib SysZLib.prc libr0000.bin tver0001.bin
 
 distclean:	clean
 
@@ -154,22 +169,3 @@
 	makedepend -- $(CFLAGS) -- *.[ch]
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
-infcodes.o: zutil.h zlib.h zconf.h
-infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h
-inffast.o: infblock.h infcodes.h infutil.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h infblock.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-minigzip.o:  zlib.h zconf.h 
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h  
diff -BburN zlib-1.1.4/PALMREAD.me zlib-1.1.4-palmos/PALMREAD.me
--- zlib-1.1.4/PALMREAD.me	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/PALMREAD.me	Sun Mar 31 17:40:11 2002
@@ -0,0 +1,72 @@
+For more information, see the ZLib home page at:
+
+http://www.info-zip.org/pub/infozip/zlib/
+
+Or http://www.palmos.com/devzone for information about Palm.
+
+1.1.4 update
+
+I now have integrated the 7.1 patch and use awk to create a version
+file, tver0001.bin - this is merely a null terminated string with
+"1.1.4-1" in it.
+
+WHAT IS IMPLEMENTED
+
+This is now implmented as a Palm System Shared library.  You
+technically don't need to call open and/or close (and there will be a
+problem if a called program unloads the library without verifying the
+open count).  But you do have to Find and/or Load the library.  A
+ZSetup and ZTeardown shim is included in the header.  See the unzip
+routine in boxer (www.palmboxer.com) to see how I use it.
+
+Everything except gzio - mainly because filestreams aren't used much,
+and I do some of this in Boxer, so it could be adapted there.
+
+Also some of the other internal routines (some of which are disabled
+in the source) like state copy or state reset are not available.
+
+Some routines are now #defined when they were real routines in ZLib
+(that just called the more general routine with default parameters).
+
+Routines have been moved from table entries to lookup routines so that
+all constant tables (the only global data) could be put in the text
+segment.
+
+zlib.h has the interface (which is used in boxer and a number of other
+routines), but that file itself isn't included by SysZLib.h It also
+describes the API in detail.
+
+It is set for m68k-palmos-gcc flavor tools with SDK 3.5, however the
+makefile mods for palmos-coff or earlier Palm SDKs are fairly easy.
+(Patches to automate this or for CodeWarrior are welcome).
+
+I tacked in the Lib reference word into the calls visible in the API.
+This was mainly to make the SysZLib.S easier.
+
+LIMITATIONS & NOTES
+
+MEM_LEVEL can be up to 8 in a real system, but since you can only
+allocate just under 64K using standard palm malloc routines, only up
+to 6 is usable for now (requiring 32k).  The NUM_BITS similarly is
+limited to 13 (8K window, requires 4x or 32K).  The larger the slower.
+Also the compressor will be much faster with a compression level of 3.
+Don't confuse Memory level, Number of Bits, and Compression level -
+read the docs.
+
+It can Inflate anything as long as 32K (plus about 4k) is available
+for buffers.
+
+Note that something other than Z_OK might be returned when it is not a
+real error - e.g. if the stream terminates without an EOF tag.  You
+need to keep calling inflate/deflate until no more data is returned.
+
+lmatch.S isn't too much faster than a C version, but I altered the
+original C file first (*scan++ works faster since it resolves to
+(%aX)++, but the original uses pre instead of post increment).
+
+I un-unrolled the loops in adler32 and crc32, but I have fewer
+instructions in my adapted versions per step, so the assembly is still
+faster.
+
+Compression is about 5K/sec with fairly aggressive
+parameters. Decompression is about 30K/sec.  YMMV.
diff -BburN zlib-1.1.4/SysZLib.c zlib-1.1.4-palmos/SysZLib.c
--- zlib-1.1.4/SysZLib.c	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/SysZLib.c	Sat Mar 30 13:03:05 2002
@@ -0,0 +1,25 @@
+#include <PalmOS.h>
+
+Err zlib_open(UInt16 ref) {
+  UInt32 val=0;
+  FtrGet('ZLib', ref, &val);
+  FtrSet('ZLib', ref, ++val);
+  return 0;
+}
+
+Err zlib_close(UInt16 ref, UInt16 *numop) {
+  UInt32 val = 0;
+  *numop = 0;
+
+  FtrGet('ZLib', ref, &val);
+  if( val <= 0 )
+    return -1;
+
+  FtrSet('ZLib', ref, --val);
+  *numop = val;
+  return 0;
+}
+
+Err zlib_null(UInt16 ref) {
+  return 0;
+}
diff -BburN zlib-1.1.4/SysZLib.h zlib-1.1.4-palmos/SysZLib.h
--- zlib-1.1.4/SysZLib.h	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/SysZLib.h	Sat Mar 30 13:08:39 2002
@@ -0,0 +1,157 @@
+#ifndef __ZLIB_H__
+#define __ZLIB_H__
+
+#define ZLIB_VERSION "1.1.4"
+
+#define PALMOS
+#include "zconf.h"
+
+/* constants */
+#define Z_NO_FLUSH      0
+#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
+#define Z_SYNC_FLUSH    2
+#define Z_FULL_FLUSH    3
+#define Z_FINISH        4
+/* Allowed flush values; see deflate() below for details */
+#define Z_OK            0
+#define Z_STREAM_END    1
+#define Z_NEED_DICT     2
+#define Z_ERRNO        (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR   (-3)
+#define Z_MEM_ERROR    (-4)
+#define Z_BUF_ERROR    (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative
+ * values are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION         0
+#define Z_BEST_SPEED             1
+#define Z_BEST_COMPRESSION       9
+#define Z_DEFAULT_COMPRESSION  (-1)
+/* compression levels */
+
+#define Z_FILTERED            1
+#define Z_HUFFMAN_ONLY        2
+#define Z_DEFAULT_STRATEGY    0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY   0
+#define Z_ASCII    1
+#define Z_UNKNOWN  2
+/* Possible values of the data_type field */
+
+#define Z_DEFLATED   8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+    Bytef    *next_in;  /* next input byte */
+    uInt     avail_in;  /* number of bytes available at next_in */
+    uLong    total_in;  /* total nb of input bytes read so far */
+
+    Bytef    *next_out; /* next output byte should be put there */
+    uInt     avail_out; /* remaining free space at next_out */
+    uLong    total_out; /* total nb of bytes output so far */
+
+    char     *msg;      /* last error message, NULL if no error */
+    struct internal_state FAR *state; /* not visible by applications */
+
+    alloc_func zalloc;  /* used to allocate the internal state */
+    free_func  zfree;   /* used to free the internal state */
+    voidpf     opaque;  /* private data object passed to zalloc and zfree */
+
+    int     data_type;  /* best guess about the data type: ascii or binary */
+    uLong   adler;      /* adler32 value of the uncompressed data */
+    uLong   reserved;   /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+    /* Function declarations */
+Err ZLibOpen(UInt refNum) SYS_TRAP(sysLibTrapOpen);
+Err ZLibClose(UInt refNum, UIntPtr numappsP) SYS_TRAP(sysLibTrapClose);
+Err ZLibSleep(UInt refNum) SYS_TRAP(sysLibTrapSleep);
+Err ZLibWake(UInt refNum) SYS_TRAP(sysLibTrapWake);
+
+Err ZLibdeflateinit2(UInt refnum, z_streamp strm, int level, int method,
+                      int windowBits, int memLevel,
+                      int strategy, const char *version, int stream_size)
+        SYS_TRAP(sysLibTrapCustom);
+
+Err ZLibdeflate(UInt refnum, z_streamp strm, int flush)
+        SYS_TRAP(sysLibTrapCustom+1);
+
+Err ZLibdeflateend(UInt refnum, z_streamp strm)
+        SYS_TRAP(sysLibTrapCustom+2);
+
+Err ZLibinflateinit2(UInt refnum, z_streamp strm,
+                      int windowBits, const char *version, int stream_size)
+        SYS_TRAP(sysLibTrapCustom+3);
+
+Err ZLibinflate(UInt refnum, z_streamp strm, int flush)
+        SYS_TRAP(sysLibTrapCustom+4);
+
+Err ZLibinflateend(UInt refnum, z_streamp strm)
+        SYS_TRAP(sysLibTrapCustom+5);
+
+uLong ZLibcrc32(UInt refnum, uLong crc, const Bytef * buf, uInt len)
+        SYS_TRAP(sysLibTrapCustom+6);
+
+uLong ZLibadler32(UInt refnum, uLong adler, const Bytef * buf, uInt len)
+        SYS_TRAP(sysLibTrapCustom+7);
+
+Err ZLibcompress2(UInt refnum, Bytef * dest, uLongf * destLen,
+                   const Bytef * source, uLong sourceLen, int level)
+        SYS_TRAP(sysLibTrapCustom+8);
+
+Err ZLibuncompress(UInt refnum, Bytef * dest, uLongf * destLen,
+                    const Bytef * source, uLong sourceLen)
+        SYS_TRAP(sysLibTrapCustom+9);
+
+#ifndef NOZLIBDEFS
+UInt ZLibRef = 0;
+#else
+extern UInt ZLibRef;
+#endif
+
+
+#define ZLSetup  !ZLibRef && SysLibFind("Z.lib", &ZLibRef) && SysLibLoad('libr', 'ZLib', &ZLibRef) \
+		   && SysLibFind("Z.lib", &ZLibRef) && ZLibOpen(ZLibRef) && (ErrFatalDisplay("No ZLib"),0)
+
+#define ZLTeardown  if(ZLibRef){\
+                      UInt zltmp;\
+                      ZLibClose(ZLibRef,&zltmp);\
+                      if(!zltmp)\
+                        SysLibRemove(ZLibRef);\
+                      ZLibRef = 0;}
+
+
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+        ZLibdeflateinit2((ZLibRef),(strm),(level),(method),(windowBits),(memLevel),\
+                      (strategy), ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit2(strm, windowBits) \
+        ZLibinflateinit2((ZLibRef), (strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+
+/* 13 bits requires 32k, Memlevel 6 requires 32k.  Each increment doubles (for each) */
+#define deflateInit(a,b) ZLibdeflateinit2((ZLibRef), a, b, Z_DEFLATED, 13, 6, Z_DEFAULT_STRATEGY, ZLIB_VERSION, sizeof(z_stream))
+#define deflateInit_(a,b,c,d) ZLibdeflateinit2((ZLibRef), a, b, Z_DEFLATED, 13, 6, Z_DEFAULT_STRATEGY, c, d)
+
+#define inflateInit(a) ZLibinflateinit2((ZLibRef), a, 15, ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit_(a,b,c) ZLibinflateinit2((ZLibRef), a, 15, b, c)
+
+#define inflate(x,y) ZLibinflate(ZLibRef,x,y)
+#define deflate(x,y) ZLibdeflate(ZLibRef,x,y)
+#define inflateEnd(x) ZLibinflateend(ZLibRef,x)
+#define deflateEnd(x) ZLibdeflateend(ZLibRef,x)
+#define crc32(a,b,c) ZLibcrc32(ZLibRef,a,b,c)
+#define adler32(a,b,c) ZLibadler32(ZLibRef,a,b,c)
+
+#endif
diff -BburN zlib-1.1.4/SysZLib0.S zlib-1.1.4-palmos/SysZLib0.S
--- zlib-1.1.4/SysZLib0.S	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/SysZLib0.S	Sat Mar 30 13:03:05 2002
@@ -0,0 +1,39 @@
+	.text
+	move.l	%a0,%d0		| do I need to preserve A0?
+	move.l	6(%a7),%a0
+	pea	table(%pc)	| if not I could exg a lot, but this works.
+	move.l	(%a7)+,(%a0)+
+	clr.l	(%a0)
+	move.l	%d0,%a0
+	moveq	#0,%d0
+	rts
+
+| dispatch table - note the lack of jump to jump to jumps.  Note this
+| can be moved to keep this and the entry points within 0..32K
+
+table:
+	dc.w	name-table
+| 1
+	dc.w	zlib_open-table	
+	dc.w	zlib_close-table
+	dc.w	zlib_null-table
+	dc.w	zlib_null-table
+| 5
+	dc.w	deflateInit2_-table
+	dc.w	deflate-table
+	dc.w	deflateEnd-table
+| 8
+	dc.w	inflateInit2_-table
+	dc.w	inflate-table
+	dc.w	inflateEnd-table
+| 11
+	dc.w	crc32-table
+	dc.w	adler32-table
+	dc.w	compress2-table
+	dc.w	uncompress-table
+
+name:
+	.asciz	"Z.lib"
+	.asciz  "Palm ZLib adaptation Copyright 2000, Tom Zerucha, tz@execpc.com"
+	.even
+
diff -BburN zlib-1.1.4/adler32.S zlib-1.1.4-palmos/adler32.S
--- zlib-1.1.4/adler32.S	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/adler32.S	Sat Mar 30 13:03:05 2002
@@ -0,0 +1,59 @@
+	.text
+	.even
+	.globl adler32
+adler32:
+	link.w %a6,#0
+	movm.l #0x1c20,-(%sp)
+	move.l 10(%a6),%d0
+	move.l 14(%a6),%a2
+	move.w 18(%a6),%d5
+
+	moveq.l #0,%d4
+	moveq.l #0,%d3
+
+	move.w %d0,%d3
+	swap %d0
+	move.w %d0,%d4
+
+	cmp.w #0,%a2
+	jbne .L32
+	moveq.l #1,%d0
+	bra .L31
+
+.L23:
+	move.w %d5,%d0
+	cmp.w #5552,%d5
+	jbls .L24
+	move.w #5552,%d0
+.L24:
+	sub.w %d0,%d5
+	tst.w %d0
+	jbeq .L25
+	moveq.l #0,%d1
+	subq.w #1,%d0
+
+.L29:
+	move.b (%a2)+,%d1
+	add.l %d1,%d3
+	add.l %d3,%d4
+	dbra.w %d0,.L29
+.L25:
+	divu  #65521,%d3
+	clr.w %d3
+	swap  %d3
+
+	divu  #65521,%d4
+	clr.w %d4
+	swap  %d4
+
+.L32:
+	tst.w %d5
+	jbne .L23
+
+	move.w %d4,%d0
+	swap %d0
+	move.w %d3,%d0
+.L31:
+	movm.l -16(%a6),#0x438
+	unlk %a6
+	rts
diff -BburN zlib-1.1.4/adler32.c zlib-1.1.4-palmos/adler32.c
--- zlib-1.1.4/adler32.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/adler32.c	Sat Mar 30 13:03:05 2002
@@ -18,7 +18,8 @@
 #define DO16(buf)   DO8(buf,0); DO8(buf,8);
 
 /* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
+uLong ZEXPORT adler32(d, adler, buf, len)
+     UInt16 d;
     uLong adler;
     const Bytef *buf;
     uInt len;
@@ -32,11 +33,13 @@
     while (len > 0) {
         k = len < NMAX ? len : NMAX;
         len -= k;
+#ifndef PALMOS
         while (k >= 16) {
             DO16(buf);
 	    buf += 16;
             k -= 16;
         }
+#endif
         if (k != 0) do {
             s1 += *buf++;
 	    s2 += s1;
diff -BburN zlib-1.1.4/compress.c zlib-1.1.4-palmos/compress.c
--- zlib-1.1.4/compress.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/compress.c	Sat Mar 30 13:03:05 2002
@@ -45,17 +45,18 @@
     err = deflateInit(&stream, level);
     if (err != Z_OK) return err;
 
-    err = deflate(&stream, Z_FINISH);
+    err = deflate(0, &stream, Z_FINISH);
     if (err != Z_STREAM_END) {
-        deflateEnd(&stream);
+        deflateEnd(0, &stream);
         return err == Z_OK ? Z_BUF_ERROR : err;
     }
     *destLen = stream.total_out;
 
-    err = deflateEnd(&stream);
+    err = deflateEnd(0, &stream);
     return err;
 }
 
+#ifndef PALMOS
 /* ===========================================================================
  */
 int ZEXPORT compress (dest, destLen, source, sourceLen)
@@ -66,3 +67,4 @@
 {
     return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
 }
+#endif
diff -BburN zlib-1.1.4/crc32.S zlib-1.1.4-palmos/crc32.S
--- zlib-1.1.4/crc32.S	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/crc32.S	Sat Mar 30 13:03:05 2002
@@ -0,0 +1,298 @@
+	.file	"crc32.c"
+gcc2_compiled.:
+__gnu_compiled_c:
+.text
+	.even
+crc_table:
+	.long 0
+	.long 1996959894
+	.long -301047508
+	.long -1727442502
+	.long 124634137
+	.long 1886057615
+	.long -379345611
+	.long -1637575261
+	.long 249268274
+	.long 2044508324
+	.long -522852066
+	.long -1747789432
+	.long 162941995
+	.long 2125561021
+	.long -407360249
+	.long -1866523247
+	.long 498536548
+	.long 1789927666
+	.long -205950648
+	.long -2067906082
+	.long 450548861
+	.long 1843258603
+	.long -187386543
+	.long -2083289657
+	.long 325883990
+	.long 1684777152
+	.long -43845254
+	.long -1973040660
+	.long 335633487
+	.long 1661365465
+	.long -99664541
+	.long -1928851979
+	.long 997073096
+	.long 1281953886
+	.long -715111964
+	.long -1570279054
+	.long 1006888145
+	.long 1258607687
+	.long -770865667
+	.long -1526024853
+	.long 901097722
+	.long 1119000684
+	.long -608450090
+	.long -1396901568
+	.long 853044451
+	.long 1172266101
+	.long -589951537
+	.long -1412350631
+	.long 651767980
+	.long 1373503546
+	.long -925412992
+	.long -1076862698
+	.long 565507253
+	.long 1454621731
+	.long -809855591
+	.long -1195530993
+	.long 671266974
+	.long 1594198024
+	.long -972236366
+	.long -1324619484
+	.long 795835527
+	.long 1483230225
+	.long -1050600021
+	.long -1234817731
+	.long 1994146192
+	.long 31158534
+	.long -1731059524
+	.long -271249366
+	.long 1907459465
+	.long 112637215
+	.long -1614814043
+	.long -390540237
+	.long 2013776290
+	.long 251722036
+	.long -1777751922
+	.long -519137256
+	.long 2137656763
+	.long 141376813
+	.long -1855689577
+	.long -429695999
+	.long 1802195444
+	.long 476864866
+	.long -2056965928
+	.long -228458418
+	.long 1812370925
+	.long 453092731
+	.long -2113342271
+	.long -183516073
+	.long 1706088902
+	.long 314042704
+	.long -1950435094
+	.long -54949764
+	.long 1658658271
+	.long 366619977
+	.long -1932296973
+	.long -69972891
+	.long 1303535960
+	.long 984961486
+	.long -1547960204
+	.long -725929758
+	.long 1256170817
+	.long 1037604311
+	.long -1529756563
+	.long -740887301
+	.long 1131014506
+	.long 879679996
+	.long -1385723834
+	.long -631195440
+	.long 1141124467
+	.long 855842277
+	.long -1442165665
+	.long -586318647
+	.long 1342533948
+	.long 654459306
+	.long -1106571248
+	.long -921952122
+	.long 1466479909
+	.long 544179635
+	.long -1184443383
+	.long -832445281
+	.long 1591671054
+	.long 702138776
+	.long -1328506846
+	.long -942167884
+	.long 1504918807
+	.long 783551873
+	.long -1212326853
+	.long -1061524307
+	.long -306674912
+	.long -1698712650
+	.long 62317068
+	.long 1957810842
+	.long -355121351
+	.long -1647151185
+	.long 81470997
+	.long 1943803523
+	.long -480048366
+	.long -1805370492
+	.long 225274430
+	.long 2053790376
+	.long -468791541
+	.long -1828061283
+	.long 167816743
+	.long 2097651377
+	.long -267414716
+	.long -2029476910
+	.long 503444072
+	.long 1762050814
+	.long -144550051
+	.long -2140837941
+	.long 426522225
+	.long 1852507879
+	.long -19653770
+	.long -1982649376
+	.long 282753626
+	.long 1742555852
+	.long -105259153
+	.long -1900089351
+	.long 397917763
+	.long 1622183637
+	.long -690576408
+	.long -1580100738
+	.long 953729732
+	.long 1340076626
+	.long -776247311
+	.long -1497606297
+	.long 1068828381
+	.long 1219638859
+	.long -670225446
+	.long -1358292148
+	.long 906185462
+	.long 1090812512
+	.long -547295293
+	.long -1469587627
+	.long 829329135
+	.long 1181335161
+	.long -882789492
+	.long -1134132454
+	.long 628085408
+	.long 1382605366
+	.long -871598187
+	.long -1156888829
+	.long 570562233
+	.long 1426400815
+	.long -977650754
+	.long -1296233688
+	.long 733239954
+	.long 1555261956
+	.long -1026031705
+	.long -1244606671
+	.long 752459403
+	.long 1541320221
+	.long -1687895376
+	.long -328994266
+	.long 1969922972
+	.long 40735498
+	.long -1677130071
+	.long -351390145
+	.long 1913087877
+	.long 83908371
+	.long -1782625662
+	.long -491226604
+	.long 2075208622
+	.long 213261112
+	.long -1831694693
+	.long -438977011
+	.long 2094854071
+	.long 198958881
+	.long -2032938284
+	.long -237706686
+	.long 1759359992
+	.long 534414190
+	.long -2118248755
+	.long -155638181
+	.long 1873836001
+	.long 414664567
+	.long -2012718362
+	.long -15766928
+	.long 1711684554
+	.long 285281116
+	.long -1889165569
+	.long -127750551
+	.long 1634467795
+	.long 376229701
+	.long -1609899400
+	.long -686959890
+	.long 1308918612
+	.long 956543938
+	.long -1486412191
+	.long -799009033
+	.long 1231636301
+	.long 1047427035
+	.long -1362007478
+	.long -640263460
+	.long 1088359270
+	.long 936918000
+	.long -1447252397
+	.long -558129467
+	.long 1202900863
+	.long 817233897
+	.long -1111625188
+	.long -893730166
+	.long 1404277552
+	.long 615818150
+	.long -1160759803
+	.long -841546093
+	.long 1423857449
+	.long 601450431
+	.long -1285129682
+	.long -1000256840
+	.long 1567103746
+	.long 711928724
+	.long -1274298825
+	.long -1022587231
+	.long 1510334235
+	.long 755167117
+
+	.even
+.globl crc32
+crc32:
+	link.w %a6,#0
+	move.l 10(%a6),%d2
+	move.l 14(%a6),%a1
+	move.w 18(%a6),%d0
+
+	cmp.w #0,%a1
+	jbne .L47
+	moveq.l #0,%d0
+	bra .L53
+
+.L47:	not.l %d2
+	tst.w %d0
+	jbeq .L48
+	subq  #1,%d0
+	lea crc_table(%pc),%a0
+
+.L49:	move.b (%a1)+,%d1
+	eor.w %d2,%d1
+	and.l #0xFF,%d1
+	asl.l #2,%d1
+
+	lsr.l #8,%d2
+	move.l (%a0,%d1.l),%d1
+	eor.l %d1,%d2
+
+	dbf %d0,.L49
+
+.L48:	move.l %d2,%d0
+	not.l %d0
+
+.L53:	unlk %a6
+	rts
diff -BburN zlib-1.1.4/crc32.c zlib-1.1.4-palmos/crc32.c
--- zlib-1.1.4/crc32.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/crc32.c	Sat Mar 30 13:03:05 2002
@@ -150,11 +150,13 @@
       make_crc_table();
 #endif
     crc = crc ^ 0xffffffffL;
+#ifndef PALMOS
     while (len >= 8)
     {
       DO8(buf);
       len -= 8;
     }
+#endif
     if (len) do {
       DO1(buf);
     } while (--len);
diff -BburN zlib-1.1.4/deflate.c zlib-1.1.4-palmos/deflate.c
--- zlib-1.1.4/deflate.c	Mon Mar 11 10:00:39 2002
+++ zlib-1.1.4-palmos/deflate.c	Sat Mar 30 13:03:05 2002
@@ -49,7 +49,7 @@
 
 /* @(#) $Id$ */
 
-#include "deflate.h"
+#include "trees.c"
 
 const char deflate_copyright[] =
    " deflate 1.1.4 Copyright 1995-2002 Jean-loup Gailly ";
@@ -120,9 +120,14 @@
    ush max_lazy;    /* do not perform lazy search above this match length */
    ush nice_length; /* quit search above this match length */
    ush max_chain;
-   compress_func func;
+   ush speed;
+  //   compress_func func;
 } config;
 
+#define deflate_stored 0
+#define deflate_fast 1
+#define deflate_slow 2
+
 local const config configuration_table[10] = {
 /*      good lazy nice chain */
 /* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
@@ -137,6 +142,19 @@
 /* 8 */ {32, 128, 258, 1024, deflate_slow},
 /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */
 
+#undef deflate_stored
+#undef deflate_fast
+#undef deflate_slow
+
+compress_func dfunc(int which) {
+switch (which) {
+ case 1: return deflate_fast;
+ case 2: return deflate_slow;
+ default: break;
+}
+return deflate_stored;
+}
+
 /* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
  * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
  * meaning.
@@ -145,7 +163,9 @@
 #define EQUAL 0
 /* result of memcmp for equal strings */
 
+#ifndef PALMOS
 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
+#endif
 
 /* ===========================================================================
  * Update a hash value with the given input byte
@@ -186,6 +206,7 @@
     s->head[s->hash_size-1] = NIL; \
     zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
 
+#ifndef PALMOS
 /* ========================================================================= */
 int ZEXPORT deflateInit_(strm, level, version, stream_size)
     z_streamp strm;
@@ -197,10 +218,12 @@
 			 Z_DEFAULT_STRATEGY, version, stream_size);
     /* To do: ignore strm->next_in if we use it as window */
 }
+#endif
 
 /* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
+int ZEXPORT deflateInit2_(dummy, strm, level, method, windowBits, memLevel, strategy,
 		  version, stream_size)
+     UInt dummy;
     z_streamp strm;
     int  level;
     int  method;
@@ -212,7 +235,7 @@
 {
     deflate_state *s;
     int noheader = 0;
-    static const char* my_version = ZLIB_VERSION;
+    static const char my_version[] = ZLIB_VERSION;
 
     ushf *overlay;
     /* We overlay pending_buf and d_buf+l_buf. This works since the average
@@ -274,7 +297,7 @@
     if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
         s->pending_buf == Z_NULL) {
         strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
-        deflateEnd (strm);
+        deflateEnd (0, strm);
         return Z_MEM_ERROR;
     }
     s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
@@ -284,6 +307,10 @@
     s->strategy = strategy;
     s->method = (Byte)method;
 
+    s->l_desc.stat_desc = ZALLOC(strm, 3 , sizeof(static_tree_desc));
+    s->d_desc.stat_desc = &s->l_desc.stat_desc[1];
+    s->bl_desc.stat_desc = &s->l_desc.stat_desc[2];
+
     return deflateReset(strm);
 }
 
@@ -302,7 +329,7 @@
         strm->state->status != INIT_STATE) return Z_STREAM_ERROR;
 
     s = strm->state;
-    strm->adler = adler32(strm->adler, dictionary, dictLength);
+    strm->adler = adler32(0, strm->adler, dictionary, dictLength);
 
     if (length < MIN_MATCH) return Z_OK;
     if (length > MAX_DIST(s)) {
@@ -377,11 +404,11 @@
     if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
 	return Z_STREAM_ERROR;
     }
-    func = configuration_table[s->level].func;
+    func = dfunc(configuration_table[s->level].speed);
 
-    if (func != configuration_table[level].func && strm->total_in != 0) {
+    if (func != dfunc(configuration_table[level].speed) && strm->total_in != 0) {
 	/* Flush the last buffer: */
-	err = deflate(strm, Z_PARTIAL_FLUSH);
+	err = deflate(0, strm, Z_PARTIAL_FLUSH);
     }
     if (s->level != level) {
 	s->level = level;
@@ -433,7 +460,8 @@
 }
 
 /* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
+int ZEXPORT deflate (dummy, strm, flush)
+     UInt dummy;
     z_streamp strm;
     int flush;
 {
@@ -513,7 +541,7 @@
         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
         block_state bstate;
 
-	bstate = (*(configuration_table[s->level].func))(s, flush);
+	bstate = (*(dfunc(configuration_table[s->level].speed)))(s, flush);
 
         if (bstate == finish_started || bstate == finish_done) {
             s->status = FINISH_STATE;
@@ -567,7 +595,8 @@
 }
 
 /* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
+int ZEXPORT deflateEnd (dummy, strm)
+     UInt dummy;
     z_streamp strm;
 {
     int status;
@@ -581,6 +610,8 @@
     }
 
     /* Deallocate in reverse order of allocations: */
+    TRY_FREE(strm,strm->state->l_desc.stat_desc);
+
     TRY_FREE(strm, strm->state->pending_buf);
     TRY_FREE(strm, strm->state->head);
     TRY_FREE(strm, strm->state->prev);
@@ -601,7 +632,7 @@
     z_streamp dest;
     z_streamp source;
 {
-#ifdef MAXSEG_64K
+#if defined(MAXSEG_64K)
     return Z_STREAM_ERROR;
 #else
     deflate_state *ds;
@@ -672,7 +703,7 @@
     strm->avail_in  -= len;
 
     if (!strm->state->noheader) {
-        strm->adler = adler32(strm->adler, strm->next_in, len);
+        strm->adler = adler32(0, strm->adler, strm->next_in, len);
     }
     zmemcpy(buf, strm->next_in, len);
     strm->next_in  += len;
@@ -705,7 +736,9 @@
     s->match_available = 0;
     s->ins_h = 0;
 #ifdef ASMV
+#ifndef PALMOS
     match_init(); /* initialize the asm code */
+#endif
 #endif
 }
 
diff -BburN zlib-1.1.4/deflate.h zlib-1.1.4-palmos/deflate.h
--- zlib-1.1.4/deflate.h	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/deflate.h	Sat Mar 30 13:03:05 2002
@@ -284,12 +284,17 @@
 #ifndef DEBUG
 /* Inline versions of _tr_tally for speed: */
 
+#ifndef PALMOS
 #if defined(GEN_TREES_H) || !defined(STDC)
-  extern uch _length_code[];
-  extern uch _dist_code[];
+  extern uch *_length_code;
+  extern uch *_dist_code;
 #else
   extern const uch _length_code[];
   extern const uch _dist_code[];
+#endif
+#else
+extern const uch _dist_code[];
+extern const uch _length_code[];
 #endif
 
 # define _tr_tally_lit(s, c, flush) \
diff -BburN zlib-1.1.4/infblock.c zlib-1.1.4-palmos/infblock.c
--- zlib-1.1.4/infblock.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/infblock.c	Sat Mar 30 13:03:05 2002
@@ -81,7 +81,7 @@
   s->bitb = 0;
   s->read = s->write = s->window;
   if (s->checkfn != Z_NULL)
-    z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
+    z->adler = s->check = (*s->checkfn)(0, 0L, (const Bytef *)Z_NULL, 0);
   Tracev((stderr, "inflate:   blocks reset\n"));
 }
 
@@ -269,7 +269,7 @@
 
         t = s->sub.trees.bb;
         NEEDBITS(t)
-        h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
+        h = s->sub.trees.tb + ((uInt)b & inflate_mask(t));
         t = h->bits;
         c = h->base;
         if (c < 16)
@@ -283,7 +283,7 @@
           j = c == 18 ? 11 : 3;
           NEEDBITS(t + i)
           DUMPBITS(t)
-          j += (uInt)b & inflate_mask[i];
+          j += (uInt)b & inflate_mask(i);
           DUMPBITS(i)
           i = s->sub.trees.index;
           t = s->sub.trees.table;
diff -BburN zlib-1.1.4/infcodes.c zlib-1.1.4-palmos/infcodes.c
--- zlib-1.1.4/infcodes.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/infcodes.c	Sat Mar 30 13:03:05 2002
@@ -121,7 +121,7 @@
     case LEN:           /* i: get length/literal/eob next */
       j = c->sub.code.need;
       NEEDBITS(j)
-      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+      t = c->sub.code.tree + ((uInt)b & inflate_mask(j));
       DUMPBITS(t->bits)
       e = (uInt)(t->exop);
       if (e == 0)               /* literal */
@@ -159,7 +159,7 @@
     case LENEXT:        /* i: getting length extra (have base) */
       j = c->sub.copy.get;
       NEEDBITS(j)
-      c->len += (uInt)b & inflate_mask[j];
+      c->len += (uInt)b & inflate_mask(j);
       DUMPBITS(j)
       c->sub.code.need = c->dbits;
       c->sub.code.tree = c->dtree;
@@ -168,7 +168,7 @@
     case DIST:          /* i: get distance next */
       j = c->sub.code.need;
       NEEDBITS(j)
-      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+      t = c->sub.code.tree + ((uInt)b & inflate_mask(j));
       DUMPBITS(t->bits)
       e = (uInt)(t->exop);
       if (e & 16)               /* distance */
@@ -191,7 +191,7 @@
     case DISTEXT:       /* i: getting distance extra */
       j = c->sub.copy.get;
       NEEDBITS(j)
-      c->sub.copy.dist += (uInt)b & inflate_mask[j];
+      c->sub.copy.dist += (uInt)b & inflate_mask(j);
       DUMPBITS(j)
       Tracevv((stderr, "inflate:         distance %u\n", c->sub.copy.dist));
       c->mode = COPY;
diff -BburN zlib-1.1.4/inffast.c zlib-1.1.4-palmos/inffast.c
--- zlib-1.1.4/inffast.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/inffast.c	Sat Mar 30 13:03:05 2002
@@ -50,8 +50,8 @@
   LOAD
 
   /* initialize masks */
-  ml = inflate_mask[bl];
-  md = inflate_mask[bd];
+  ml = inflate_mask(bl);
+  md = inflate_mask(bd);
 
   /* do until not enough input or output space for fast loop */
   do {                          /* assume called with m >= 258 && n >= 10 */
@@ -73,7 +73,7 @@
       {
         /* get extra bits for length */
         e &= 15;
-        c = t->base + ((uInt)b & inflate_mask[e]);
+        c = t->base + ((uInt)b & inflate_mask(e));
         DUMPBITS(e)
         Tracevv((stderr, "inflate:         * length %u\n", c));
 
@@ -87,7 +87,7 @@
             /* get extra bits to add to distance base */
             e &= 15;
             GRABBITS(e)         /* get extra bits (up to 13) */
-            d = t->base + ((uInt)b & inflate_mask[e]);
+            d = t->base + ((uInt)b & inflate_mask(e));
             DUMPBITS(e)
             Tracevv((stderr, "inflate:         * distance %u\n", d));
 
@@ -133,7 +133,7 @@
           else if ((e & 64) == 0)
           {
             t += t->base;
-            e = (t += ((uInt)b & inflate_mask[e]))->exop;
+            e = (t += ((uInt)b & inflate_mask(e)))->exop;
           }
           else
           {
@@ -148,7 +148,7 @@
       if ((e & 64) == 0)
       {
         t += t->base;
-        if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
+        if ((e = (t += ((uInt)b & inflate_mask(e)))->exop) == 0)
         {
           DUMPBITS(t->bits)
           Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
diff -BburN zlib-1.1.4/inffixed.h zlib-1.1.4-palmos/inffixed.h
--- zlib-1.1.4/inffixed.h	Tue Jun 16 07:29:49 1998
+++ zlib-1.1.4-palmos/inffixed.h	Sat Mar 30 13:03:05 2002
@@ -7,9 +7,9 @@
    subject to change. Applications should only use zlib.h.
  */
 
-local uInt fixed_bl = 9;
-local uInt fixed_bd = 5;
-local inflate_huft fixed_tl[] = {
+local const uInt fixed_bl = 9;
+local const uInt fixed_bd = 5;
+local const inflate_huft fixed_tl[] = {
     {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
     {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
     {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
@@ -139,7 +139,7 @@
     {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
     {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
   };
-local inflate_huft fixed_td[] = {
+local const inflate_huft fixed_td[] = {
     {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
     {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
     {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
diff -BburN zlib-1.1.4/inflate.c zlib-1.1.4-palmos/inflate.c
--- zlib-1.1.4/inflate.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/inflate.c	Sat Mar 30 13:03:05 2002
@@ -64,7 +64,8 @@
 }
 
 
-int ZEXPORT inflateEnd(z)
+int ZEXPORT inflateEnd(d, z)
+     UInt d;
 z_streamp z;
 {
   if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
@@ -78,7 +79,8 @@
 }
 
 
-int ZEXPORT inflateInit2_(z, w, version, stream_size)
+int ZEXPORT inflateInit2_(d, z, w, version, stream_size)
+     UInt d;
 z_streamp z;
 int w;
 const char *version;
@@ -114,17 +116,18 @@
   /* set window size */
   if (w < 8 || w > 15)
   {
-    inflateEnd(z);
+    inflateEnd(0, z);
     return Z_STREAM_ERROR;
   }
   z->state->wbits = (uInt)w;
 
   /* create inflate_blocks state */
-  if ((z->state->blocks =
-      inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
-      == Z_NULL)
+  if ((z->state->blocks = z->state->nowrap ? 
+       inflate_blocks_new(z, NULL , (uInt)1 << w) :
+       inflate_blocks_new(z, adler32, (uInt)1 << w)
+      ) == Z_NULL)
   {
-    inflateEnd(z);
+    inflateEnd(0, z);
     return Z_MEM_ERROR;
   }
   Tracev((stderr, "inflate: allocated\n"));
@@ -134,7 +137,7 @@
   return Z_OK;
 }
 
-
+#ifndef PALMOS
 int ZEXPORT inflateInit_(z, version, stream_size)
 z_streamp z;
 const char *version;
@@ -142,12 +145,13 @@
 {
   return inflateInit2_(z, DEF_WBITS, version, stream_size);
 }
-
+#endif
 
 #define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
 #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
 
-int ZEXPORT inflate(z, f)
+int ZEXPORT inflate(d, z, f)
+     UInt d;
 z_streamp z;
 int f;
 {
@@ -285,7 +289,7 @@
   if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
     return Z_STREAM_ERROR;
 
-  if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
+  if (adler32(0, 1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
   z->adler = 1L;
 
   if (length >= ((uInt)1<<z->state->wbits))
diff -BburN zlib-1.1.4/inftrees.c zlib-1.1.4-palmos/inftrees.c
--- zlib-1.1.4/inftrees.c	Mon Mar 11 08:18:06 2002
+++ zlib-1.1.4-palmos/inftrees.c	Sat Mar 30 13:03:05 2002
@@ -448,7 +448,12 @@
 #endif
   *bl = fixed_bl;
   *bd = fixed_bd;
+#ifdef PALMOS
+  *tl = (inflate_huft *) fixed_tl;
+  *td = (inflate_huft *) fixed_td;
+#else
   *tl = fixed_tl;
   *td = fixed_td;
+#endif
   return Z_OK;
 }
diff -BburN zlib-1.1.4/infutil.c zlib-1.1.4-palmos/infutil.c
--- zlib-1.1.4/infutil.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/infutil.c	Sat Mar 30 13:03:05 2002
@@ -12,12 +12,14 @@
 struct inflate_codes_state {int dummy;}; /* for buggy compilers */
 
 /* And'ing with mask[n] masks the lower n bits */
+
+#if 0
 uInt inflate_mask[17] = {
     0x0000,
     0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
     0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
 };
-
+#endif
 
 /* copy as much as possible from the sliding window to the output area */
 int inflate_flush(s, z, r)
@@ -44,7 +46,7 @@
 
   /* update check information */
   if (s->checkfn != Z_NULL)
-    z->adler = s->check = (*s->checkfn)(s->check, q, n);
+    z->adler = s->check = (*s->checkfn)(0, s->check, q, n);
 
   /* copy as far as end of window */
   zmemcpy(p, q, n);
@@ -70,7 +72,7 @@
 
     /* update check information */
     if (s->checkfn != Z_NULL)
-      z->adler = s->check = (*s->checkfn)(s->check, q, n);
+      z->adler = s->check = (*s->checkfn)(0, s->check, q, n);
 
     /* copy */
     zmemcpy(p, q, n);
diff -BburN zlib-1.1.4/lmatch.S zlib-1.1.4-palmos/lmatch.S
--- zlib-1.1.4/lmatch.S	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/lmatch.S	Sat Mar 30 13:03:05 2002
@@ -0,0 +1,144 @@
+	.file	"lmatch.c"
+gcc2_compiled.:
+__gnu_compiled_c:
+.text
+	.even
+.globl longest_match
+longest_match:
+	link.w %a6,#-12
+	movm.l #0x1f38,-(%sp)
+	move.l 8(%a6),%a3
+	move.w 12(%a6),%d3
+	move.w 76(%a3),%d5
+	clr.l %d0
+	move.w 68(%a3),%d0
+	move.l 32(%a3),%a2
+	add.l %d0,%a2 /*JANE2*/
+	move.w 74(%a3),%d4
+	move.w 86(%a3),%a4
+	move.w 26(%a3),%d2
+	move.w %d2,%d0
+	add.w #-262,%d0
+	move.w 68(%a3),%d1
+	cmp.w %d1,%d0
+	jbcc .L20
+	move.w %d1,%d6
+	add.w #262,%d6
+	sub.w %d2,%d6
+	bra .L21
+
+.L20:
+	clr.w %d6
+.L21:
+	move.l 40(%a3),-4(%a6)
+	move.w 30(%a3),-6(%a6)
+	clr.l %d0
+	move.w 68(%a3),%d0
+	add.l 32(%a3),%d0 /*JANE2*/
+	move.l %d0,%d1
+	add.l #258,%d1 /*JANE2*/
+	move.w %d4,%a0
+	move.b -1(%a2,%a0.l),%d7
+	move.b (%a0,%a2.l),%d2
+	move.w 84(%a3),%d0
+	cmp.w 74(%a3),%d0
+	jbhi .L22
+	lsr.w #2,%d5
+.L22:
+	move.w 72(%a3),%d0
+	cmp.w %a4,%d0
+	jbcc .L23
+	move.w %d0,%a4
+.L23:
+	clr.l -10(%a6)
+
+
+
+.L37:
+	move.w %d3,-8(%a6)
+
+	move.l -10(%a6),%a0
+	add.l 32(%a3),%a0
+
+	cmp.b (%a0,%d4.w),%d2
+	jbne .L26
+	cmp.b -1(%a0,%d4.w),%d7
+	jbne .L26
+
+	move.b (%a0)+,%d0
+	cmp.b (%a2),%d0
+	jbne .L26
+
+	move.b (%a0),%d0
+	cmp.b 1(%a2),%d0
+	jbne .L26
+
+	addq.l #3,%a2
+	addq.l #2,%a0
+
+	move.l %d1,%a1
+	lea (-258,%a1),%a1
+
+.L31:
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+	cmpm.b (%a0)+,(%a2)+
+	jbne .L30
+
+	cmp.l %a2,%d1
+	jbcc .L31
+
+
+.L30:
+	add.w	#257,%a2
+	sub.l	%d1,%a2
+	move.w	%a2,%d0
+
+	move.l %a1,%a2
+
+	cmp.w %d0,%d4
+	jbge .L26
+
+	move.w %d3,70(%a3)
+	move.w %d0,%d4
+	cmp.w %a4,%d4
+	jbge .L25
+
+	move.b -1(%a1,%d4.w),%d7
+	move.b (%a1,%d4.w),%d2
+.L26:
+	and.w -6(%a6),%d3
+	clr.l %d0
+	move.w %d3,%d0
+	add.l %d0,%d0
+	move.l -4(%a6),%a0
+	move.w (%a0,%d0.l),%d3
+	cmp.w %d3,%d6
+	jbcc .L25
+	subq.w #1,%d5
+	jbne .L37
+
+
+
+.L25:
+	move.w 72(%a3),%d1
+	move.w %d4,%d0
+	cmp.w %d0,%d1
+	jbcc .L39
+	move.w %d1,%d0
+.L39:
+	movm.l (%sp)+,#0x1cf8
+	unlk %a6
+	rts
diff -BburN zlib-1.1.4/trees.c zlib-1.1.4-palmos/trees.c
--- zlib-1.1.4/trees.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/trees.c	Sat Mar 30 13:03:05 2002
@@ -126,20 +126,23 @@
     int     max_length;          /* max bit length for the codes */
 };
 
-local static_tree_desc  static_l_desc =
+#ifndef PALMOS
+local const static_tree_desc  static_l_desc =
 {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
 
-local static_tree_desc  static_d_desc =
+local const static_tree_desc  static_d_desc =
 {static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
 
-local static_tree_desc  static_bl_desc =
+local const static_tree_desc  static_bl_desc =
 {(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
-
+#endif
 /* ===========================================================================
  * Local (static) routines in this file.
  */
 
+#ifndef PALMOS
 local void tr_static_init OF((void));
+#endif
 local void init_block     OF((deflate_state *s));
 local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));
 local void gen_bitlen     OF((deflate_state *s, tree_desc *desc));
@@ -236,9 +239,9 @@
 /* ===========================================================================
  * Initialize the various 'constant' tables.
  */
+#if defined(GEN_TREES_H) || !defined(STDC)
 local void tr_static_init()
 {
-#if defined(GEN_TREES_H) || !defined(STDC)
     static int static_init_done = 0;
     int n;        /* iterates over tree elements */
     int bits;     /* bit counter */
@@ -313,8 +316,9 @@
 #  ifdef GEN_TREES_H
     gen_trees_header();
 #  endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
+
 }
+#endif /* defined(GEN_TREES_H) || !defined(STDC) */
 
 /* ===========================================================================
  * Genererate the file trees.h describing the static trees.
@@ -383,16 +387,37 @@
 void _tr_init(s)
     deflate_state *s;
 {
-    tr_static_init();
+static_tree_desc *s1;
 
-    s->l_desc.dyn_tree = s->dyn_ltree;
-    s->l_desc.stat_desc = &static_l_desc;
+//    tr_static_init();
 
+    s->l_desc.dyn_tree = s->dyn_ltree;
     s->d_desc.dyn_tree = s->dyn_dtree;
-    s->d_desc.stat_desc = &static_d_desc;
-
     s->bl_desc.dyn_tree = s->bl_tree;
-    s->bl_desc.stat_desc = &static_bl_desc;
+
+    s1 = s->l_desc.stat_desc;
+
+    s1->static_tree = static_ltree;
+    s1->extra_bits = extra_lbits;
+    s1->extra_base = LITERALS + 1;
+    s1->elems = L_CODES;
+    s1->max_length = MAX_BITS;
+
+    s1 = s->d_desc.stat_desc;
+
+    s1->static_tree = static_dtree;
+    s1->extra_bits = extra_dbits;
+    s1->extra_base = 0;
+    s1->elems = D_CODES;
+    s1->max_length = MAX_BITS;
+
+    s1 = s->bl_desc.stat_desc;
+
+    s1->static_tree = NULL;
+    s1->extra_bits = extra_blbits;
+    s1->extra_base = 0;
+    s1->elems = BL_CODES;
+    s1->max_length = MAX_BL_BITS;
 
     s->bi_buf = 0;
     s->bi_valid = 0;
diff -BburN zlib-1.1.4/trees.h zlib-1.1.4-palmos/trees.h
--- zlib-1.1.4/trees.h	Tue Feb 24 07:14:55 1998
+++ zlib-1.1.4-palmos/trees.h	Sat Mar 30 13:03:05 2002
@@ -70,7 +70,7 @@
 {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
 };
 
-const uch _dist_code[DIST_CODE_LEN] = {
+const uch _dist_code[512] = {
  0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -99,7 +99,7 @@
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 };
 
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
+const uch _length_code[MAX_MATCH-MIN_MATCH+1] = {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
diff -BburN zlib-1.1.4/uncompr.c zlib-1.1.4-palmos/uncompr.c
--- zlib-1.1.4/uncompr.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/uncompr.c	Sat Mar 30 13:03:05 2002
@@ -46,13 +46,13 @@
     err = inflateInit(&stream);
     if (err != Z_OK) return err;
 
-    err = inflate(&stream, Z_FINISH);
+    err = inflate(0, &stream, Z_FINISH);
     if (err != Z_STREAM_END) {
-        inflateEnd(&stream);
+        inflateEnd(0, &stream);
         return err == Z_OK ? Z_BUF_ERROR : err;
     }
     *destLen = stream.total_out;
 
-    err = inflateEnd(&stream);
+    err = inflateEnd(0, &stream);
     return err;
 }
diff -BburN zlib-1.1.4/ver.bin zlib-1.1.4-palmos/ver.bin
--- zlib-1.1.4/ver.bin	Wed Dec 31 19:00:00 1969
+++ zlib-1.1.4-palmos/ver.bin	Sat Mar 30 13:14:20 2002
@@ -0,0 +1 @@
+1.1.4
\ No newline at end of file
diff -BburN zlib-1.1.4/zconf.h zlib-1.1.4-palmos/zconf.h
--- zlib-1.1.4/zconf.h	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/zconf.h	Sat Mar 30 13:03:05 2002
@@ -210,18 +210,22 @@
 #   define FAR
 #endif
 
-#if !defined(MACOS) && !defined(TARGET_OS_MAC)
+#if !defined(MACOS) && !defined(TARGET_OS_MAC) && !defined(PALMOS)
 typedef unsigned char  Byte;  /* 8 bits */
 #endif
 typedef unsigned int   uInt;  /* 16 bits or more */
 typedef unsigned long  uLong; /* 32 bits or more */
 
+#ifdef PALMOS
+typedef unsigned char FAR Bytef;
+#else
 #ifdef SMALL_MEDIUM
    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
 #  define Bytef Byte FAR
 #else
    typedef Byte  FAR Bytef;
 #endif
+#endif
 typedef char  FAR charf;
 typedef int   FAR intf;
 typedef uInt  FAR uIntf;
@@ -274,6 +278,55 @@
 #   pragma map(inflate_trees_dynamic,"INTRDY")
 #   pragma map(inflate_trees_fixed,"INTRFI")
 #   pragma map(inflate_trees_free,"INTRFR")
+#endif
+
+#ifdef PALMOS
+#undef Byte
+
+#ifndef NEWGCC
+
+#pragma pack(2)
+#include <Common.h>
+#include <System/SysAll.h>
+#include <UI/UIAll.h>
+
+#else
+
+#include <PalmOS.h>
+#include <PalmCompatibility.h>
+
+#endif
+
+#include <System/Unix/unix_stdlib.h>
+#include <System/Unix/unix_string.h>
+
+#define NO_MEMCPY
+#define MAXSEG_64K
+
+extern inline void zmemzero OF((Bytef* dst, uInt num))
+{
+  while (num--)
+    *((char *) dst)++ = 0;
+}
+
+extern inline void zmemcpy  OF((Bytef* dst, const Bytef* src, uInt num))
+{
+  while (num--)
+    *((char *) dst)++ = *((char *) src)++;
+}
+
+extern inline int  zmemcmp  OF((const Bytef* dst, const Bytef* src, uInt num))
+{
+
+  while (num-- && (*((char *) dst)++ == *((char *) src)++));
+  if (num >= 0)
+    return *--((char *) dst) - *--((char *) src);
+  else
+    return 0;
+}
+
+#define inflate_mask(x) (0xffffU >> ( 16 - x ))
+
 #endif
 
 #endif /* _ZCONF_H */
diff -BburN zlib-1.1.4/zlib.h zlib-1.1.4-palmos/zlib.h
--- zlib-1.1.4/zlib.h	Mon Mar 11 08:56:38 2002
+++ zlib-1.1.4-palmos/zlib.h	Sat Mar 30 13:03:05 2002
@@ -198,7 +198,7 @@
 */
 
 
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+ZEXTERN int ZEXPORT deflate OF((UInt d, z_streamp strm, int flush));
 /*
     deflate compresses as much data as possible, and stops when the input
   buffer becomes empty or the output buffer becomes full. It may introduce some
@@ -276,7 +276,7 @@
 */
 
 
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+ZEXTERN int ZEXPORT deflateEnd OF((UInt d, z_streamp strm));
 /*
      All dynamically allocated data structures for this stream are freed.
    This function discards any unprocessed input and does not flush any
@@ -311,7 +311,7 @@
 */
 
 
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+ZEXTERN int ZEXPORT inflate OF((UInt d, z_streamp strm, int flush));
 /*
     inflate decompresses as much data as possible, and stops when the input
   buffer becomes empty or the output buffer becomes full. It may some
@@ -380,7 +380,7 @@
 */
 
 
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+ZEXTERN int ZEXPORT inflateEnd OF((UInt d, z_streamp strm));
 /*
      All dynamically allocated data structures for this stream are freed.
    This function discards any unprocessed input and does not flush any
@@ -605,8 +605,12 @@
    utility functions can easily be modified if you need special options.
 */
 
+#ifndef PALMOS
 ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
                                  const Bytef *source, uLong sourceLen));
+#else
+#define compress(a,b,c,d) compress2(a,b,c,d, Z_DEFAULT_COMPRESSION);
+#endif
 /*
      Compresses the source buffer into the destination buffer.  sourceLen is
    the byte length of the source buffer. Upon entry, destLen is the total
@@ -818,7 +822,7 @@
    compression library.
 */
 
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+ZEXTERN uLong ZEXPORT adler32 OF((UInt d, uLong adler, const Bytef *buf, uInt len));
 
 /*
      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@@ -835,7 +839,7 @@
      if (adler != original_adler) error();
 */
 
-ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
+ZEXTERN uLong ZEXPORT crc32   OF((UInt d, uLong crc, const Bytef *buf, uInt len));
 /*
      Update a running crc with the bytes buf[0..len-1] and return the updated
    crc. If buf is NULL, this function returns the required initial value
@@ -852,8 +856,39 @@
 */
 
 
+
                         /* various hacks, don't look :) */
 
+ZEXTERN int ZEXPORT deflateInit2_ OF((UInt d, z_streamp strm, int  level, int  method,
+                                      int windowBits, int memLevel,
+                                      int strategy, const char *version,
+                                      int stream_size));
+
+ZEXTERN int ZEXPORT inflateInit2_ OF((UInt d, z_streamp strm, int  windowBits,
+                                      const char *version, int stream_size));
+
+#ifdef PALMOS
+
+#ifndef DEF_WBITS
+#  define DEF_WBITS MAX_WBITS
+#endif
+#if MAX_MEM_LEVEL >= 8
+#  define DEF_MEM_LEVEL 8
+#else
+#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#endif
+/* default memLevel */
+
+#define deflateInit(a,b) deflateInit2_(0, a,b,Z_DEFLATED, MAX_WBITS,\
+          DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, ZLIB_VERSION, sizeof(z_stream) )
+
+#define deflateInit_(a,b,c,d) deflateInit2_(0, a,b, Z_DEFLATED, MAX_WBITS, \
+		     DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, c,d)
+#define inflateInit(a) inflateInit2_(0, a, DEF_WBITS, ZLIB_VERSION,\
+				     sizeof(z_stream))
+#define inflateInit_(a,b,c) inflateInit2_(0, a, DEF_WBITS, b, c)
+
+#else
 /* deflateInit and inflateInit are macros to allow checking the zlib version
  * and the compiler's view of z_stream:
  */
@@ -861,21 +896,19 @@
                                      const char *version, int stream_size));
 ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
                                      const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
-                                      int windowBits, int memLevel,
-                                      int strategy, const char *version,
-                                      int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
-                                      const char *version, int stream_size));
+
 #define deflateInit(strm, level) \
         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
 #define inflateInit(strm) \
         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
+
+#endif
+
 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
-        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+        deflateInit2_(0, (strm),(level),(method),(windowBits),(memLevel),\
                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
 #define inflateInit2(strm, windowBits) \
-        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+        inflateInit2_(0, (strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
 
 
 #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
diff -BburN zlib-1.1.4/zutil.c zlib-1.1.4-palmos/zutil.c
--- zlib-1.1.4/zutil.c	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/zutil.c	Sat Mar 30 13:03:09 2002
@@ -13,6 +13,7 @@
 extern void exit OF((int));
 #endif
 
+#ifndef PALMOS
 const char *z_errmsg[10] = {
 "need dictionary",     /* Z_NEED_DICT       2  */
 "stream end",          /* Z_STREAM_END      1  */
@@ -86,12 +87,14 @@
     Bytef* dest;
     uInt  len;
 {
-    if (len == 0) return;
+    if (len == 0 || dest == Z_NULL)
+       	return;
     do {
         *dest++ = 0;  /* ??? to be unrolled */
     } while (--len != 0);
 }
 #endif
+#endif
 
 #ifdef __TURBOC__
 #if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__)
@@ -210,8 +213,28 @@
     unsigned items;
     unsigned size;
 {
+#ifndef PALMOS
     if (opaque) items += size - size; /* make compiler happy */
     return (voidpf)calloc(items, size);
+#else
+  voidpf x;
+  UInt32 free, max;
+  
+    x = (voidpf) malloc(items*size);
+    
+    if(x == Z_NULL)
+    {
+		MemHeapFreeBytes(0, &free, &max);
+		if(items*size > max)
+		MemHeapCompact(0);
+		MemHeapFreeBytes(0, &free, &max);
+		if(max >= size)
+			x = (voidpf) malloc(items*size);
+	}    	
+    if(x != Z_NULL)
+    zmemzero(x,items*size);
+    return x;
+#endif
 }
 
 void  zcfree (opaque, ptr)
diff -BburN zlib-1.1.4/zutil.h zlib-1.1.4-palmos/zutil.h
--- zlib-1.1.4/zutil.h	Mon Mar 11 08:16:01 2002
+++ zlib-1.1.4-palmos/zutil.h	Sat Mar 30 13:03:05 2002
@@ -15,7 +15,7 @@
 
 #include "zlib.h"
 
-#ifdef STDC
+#if defined(STDC) && !defined(PALMOS)
 #  include <stddef.h>
 #  include <string.h>
 #  include <stdlib.h>
@@ -37,10 +37,14 @@
 typedef ush FAR ushf;
 typedef unsigned long  ulg;
 
+#ifndef PALMOS
 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
 /* (size given to avoid silly warnings with Visual C++) */
 
 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
+#else
+#define ERR_MSG(err) ""
+#endif
 
 #define ERR_RETURN(strm,err) \
   return (strm->msg = (char*)ERR_MSG(err), (err))
@@ -207,7 +211,7 @@
 #endif
 
 
-typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
+typedef uLong (ZEXPORT *check_func) OF((UInt d, uLong check, const Bytef *buf,
 				       uInt len));
 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
 void   zcfree  OF((voidpf opaque, voidpf ptr));
