Libtiny.a v1.0: Library Functions and Memory Requirements 31/01/01 === Compression === ---- Compress data using zlib deflation int z_compress(u_char *source_p, u_int sourcelen, u_char *destination_p) source_p pointer to data to compress sourcelen number of bytes to compress destination_p pointer to buffer to store compressed data Return values >0 compressed data size in bytes, including header 0(T_LEN_ERROR) sourcelen is zero -2(T_MEM_ERROR) out of memory, workspace couldn't be allocated -3(T_BUF_ERROR) destination buffer too small, this error is returned if the source data cannot be compressed It's the responsibility of the application to allocate the destination buffer space, the size of which should be at least 0.1% + 32 bytes larger than the source data length. ---- ---- Compress data using huffman encoding int huf_compress(u_char *source_p, u_int sourcelen, u_char *destination_p) source_p pointer to data to compress sourcelen number of bytes to compress destination_p pointer to buffer to store compressed data Return values >0 compressed data size in bytes, including header 0(T_LEN_ERROR) sourcelen is zero -2(T_MEM_ERROR) out of memory, workspace couldn't be allocated -3(T_BUF_ERROR) destination buffer too small, this error is returned if the compressed data would be larger than the source data As above, it's the responsibility of the application to allocate the destination buffer space, the size of which should be at least 0.1% + 32 bytes larger than the source data length. ---- === Decompression === ---- Decompress data that's been compressed with zlib deflation int z_uncompress(u_char *source_p, u_char *destination_p) *source_p pointer to data to decompress, destination_p pointer to buffer to store decompressed data Return values >0 decompressed data size in bytes, -1(T_ID_ERROR) bad header id value, should be ID_ZLIB, -2(T_MEM_ERROR) out of memory, workspace couldn't be allocated, -3(T_BUF_ERROR) destination buffer too small, should never be returned unless header has become corrupted, -4(T_DATA_ERROR) header or compressed data has been corrupted */ z_uncompress() decompresses data compressed with either tiny.exe option -z or z_compress(). The destination buffer should be at least the size of the original uncompressed data. This information is available within the compressed data's header as header->orig_size (see libtiny.h for header definition). ---- ---- Decompress huffman encoded data int huf_uncompress(u_char *source_p, u_char *destination_p) *source_p pointer to data to decompress, destination_p pointer to buffer to store decompressed data Return values >0 decompressed data size in bytes, -1(T_ID_ERROR) bad header id value, should be ID_HUFF, -2(T_MEM_ERROR) out of memory, workspace couldn't be allocated, -3(T_BUF_ERROR) destination buffer too small, should never be returned unless header or data has become corrupted, -4(T_DATA_ERROR) header or compressed data has been corrupted */ huf_uncompress() decompresses data compressed with either tiny.exe option -h or huf_compress(). The destination buffer should be at least the size of the original uncompressed data. This information is available within the compressed data's header as header->orig_size (see libtiny.h for header definition. ---- === Memory Requirements === Below is a table detailing the memory requirements for each function Size in exe - how much your psx exe file size will increase when the function is included Size in mem - how much your psx exe size will increase when in psx memory Dynamically alloc'ed - how much workspace is allocated from the heap Stack use - the required stack space for each function Function Size in exe Size in mem Dynamically alloc'ed Stack use z_compress 24k 24k 55k <1k z_uncompress 20k 20k 23k <1k huf_compress 4k 15k 9k <2k huf_uncompress 2k 13k 7k <2k In practice the values vary but they shouldn't exceed the above.