Subversion Repositories ipe_artfile_utils

Rev

Blame | Last modification | View Log | RSS feed

  1. /**
  2.  * LZW Decoder for Imagination Pilots Entertainment 16-bit games (IPE16)
  3.  * - Blown Away - The Interactive Game by Imagination Pilots (BA)
  4.  * - Panic in the Park - The Interactive Game by Imagination Pilots (PiP)
  5.  * - Where's Waldo? At the Circus (Waldo1)
  6.  * ART file packer and unpacker by Daniel Marschall, ViaThinkSoft (C) 2014-2018
  7.  * Revision: 2018-02-15
  8.  *
  9.  * The code is based on "Cross platform GIF source code" (c) L. Patrick
  10.  * http://www.cs.usyd.edu.au/~graphapp/package/src/libgif/gif.c
  11.  * It was simplified and modified to encode IPE16-LZW instead of GIF-LZW.
  12.  * The game uses exactly the compressed stream as defined in the GIF standard,
  13.  * but the compressed stream is not divided into chunks.
  14.  **/
  15.  
  16. #ifndef __inc__ipe16_lzw_decoder
  17. #define __inc__ipe16_lzw_decoder
  18.  
  19. #include <stdio.h>
  20. #include <stdbool.h>
  21.  
  22. #define LZ_MIN_BITS     9
  23. #define LZ_MAX_BITS     12
  24.  
  25. #define LZ_MAX_CODE     4095    /* Largest 12 bit code */
  26. #define NO_SUCH_CODE    4098    /* Impossible code = empty */
  27.  
  28. #define CLEAR_CODE      256
  29. #define END_CODE        257
  30. #define FIRST_CODE      258
  31.  
  32. typedef struct tagIpe16LZWDecoder {
  33.     int running_code;
  34.         int running_bits;
  35.         int max_code_plus_one;
  36.     int shift_state;
  37.     unsigned long shift_data;
  38.     unsigned char stack[LZ_MAX_CODE+1];
  39.     unsigned int  suffix[LZ_MAX_CODE+1];
  40.     unsigned int  prefix[LZ_MAX_CODE+1];
  41.   } Ipe16LZWDecoder;
  42.  
  43. Ipe16LZWDecoder* new_ipe16lzw_decoder(void);
  44. void del_ipe16lzw_decoder(Ipe16LZWDecoder* decoder);
  45. /*unsigned*/ int ipe16lzw_decode(FILE* outFile, Ipe16LZWDecoder *decoder, unsigned char *input, int inputLength);
  46.  
  47. #endif // #ifndef __inc__ipe16_lzw_decoder
  48.  
  49.