Logo Search packages:      
Sourcecode: freecraft version File versions  Download package

mpq.c

//   ___________             _________                _____  __
//   \_       _____/______   ____   ____ \_   ___ \____________ _/ ____\/  |_
//    |    __) \_  __ \_/ __ \_/ __ \/    \  \/\_  __ \__  \\   __\\   __|
//    |     \   |  | \/\  ___/\  ___/\     \____|  | \// __ \|  |   |  |
//    \___  /   |__|    \___  >\___  >\______  /|__|  (____  /__|   |__|
//      \/            \/         \/      \/              \/
//  ______________________                           ______________________
//                  T H E   W A R   B E G I N S
//       FreeCraft - A free fantasy real time strategy game engine
//
/**@name mpq.c          -     Mpq. */
//
//    (c) Copyright 1998-2002 by Lutz Sammer
//
//    FreeCraft is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published
//    by the Free Software Foundation; only version 2 of the License.
//
//    FreeCraft is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    $Id: mpq.c,v 1.11 2002/12/17 06:40:41 nehalmistry Exp $

//@{

/*----------------------------------------------------------------------------
--    Includes
----------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "freecraft.h"
#include "iocompat.h"
#include "mpq.h"


/*----------------------------------------------------------------------------
--    Declarations
----------------------------------------------------------------------------*/

#define UInt8     unsigned char
#define UInt16    unsigned short
#define SInt16    short
#define UInt32    unsigned long
#define SInt32    int

#define DCL_NO_ERROR    0L
#define DCL_ERROR_1     1L
#define DCL_ERROR_2     2L
#define DCL_ERROR_3     3L
#define DCL_ERROR_4     4L

#define DEFAULT_LIST    "mpqlist.txt"

typedef UInt16 read_data_proc(UInt8 * buffer, UInt16 size, void *param);
typedef void write_data_proc(UInt8 * buffer, UInt16 size, void *param);

typedef struct {
    char *buf_in;
    char *buf_out;
} params;

local UInt16 __explode_1(UInt8 * buf);
local UInt16 __explode_2(UInt8 * buf);
local UInt16 __explode_3(UInt8 * buf, UInt16 result);
local UInt16 __explode_4(UInt8 * buf, UInt32 flag);
local void __explode_5(UInt16 count, UInt8 * buf_1, const UInt8 * table, UInt8 * buf_2);
local void __explode_6(UInt8 * buf, const UInt8 * table);
local void __explode_7(UInt8 * buf, const UInt8 * table, UInt32 count);

local void BuildBaseMassive(void);
local int InitializeLocals(void);
local UInt32 Crc(char *string, UInt32 * massive_base, UInt32 massive_base_offset);
local void Decode(UInt32 * data_in, UInt32 * massive_base, UInt32 crc, UInt32 length);
local UInt16 read_data(UInt8 * buffer, UInt16 size, void *crap);
local void write_data(UInt8 * buffer, UInt16 size, void *crap);
local UInt32 explode(read_data_proc read_data, write_data_proc write_data, void *param);

UInt32      ExtWavUnp1(UInt32,UInt32,UInt32,UInt32);
UInt32      ExtWavUnp2(UInt32,UInt32,UInt32,UInt32);
UInt32      ExtWavUnp3(UInt32,UInt32,UInt32,UInt32);
void  Sub_WavUnp1(UInt32,UInt32);
UInt32      Sub_WavUnp2(UInt32,UInt32,UInt32);
void  Sub_WavUnp3(UInt32);  
void  Sub_WavUnp4(UInt32,UInt32,UInt32,UInt32);
UInt32      Sub_WavUnp5(UInt32);
void  Sub_WavUnp6(UInt32);
UInt32      Sub_WavUnp7(UInt32);
UInt32      Sub_WavUnp8(UInt32);
void  Sub_WavUnp9(UInt32,UInt32);
void  Sub_WavUnp10(UInt32,UInt32);
UInt32      Sub_WavUnp11(UInt32,UInt32,UInt32,UInt32);
void  Sub_WavUnp12(UInt32);
UInt32      Sub_WavUnp13(UInt32,UInt32,UInt32,UInt32,UInt32);



/*----------------------------------------------------------------------------
--    Variables
----------------------------------------------------------------------------*/

extern const unsigned char dcl_table[];
local UInt8 *explode_buffer;

extern const UInt8 wav_table[2512];
extern const UInt32 small_tbl1[90];
extern const UInt32 small_tbl2[32];

local UInt32 offset_mpq;            /// Offset to MPQ file data
local UInt32 offset_htbl;           /// Offset to hash_table of MPQ
local UInt32 offset_btbl;           /// Offset to MpqBlockTable of MPQ
local UInt32 length_mpq_part;       /// Length of MPQ file data
local UInt32 length_htbl;           /// Length of hash table
local UInt32 length_btbl;           /// Length of block table
local UInt32 *hash_table;           /// Hash table
global int MpqFileCount;            /// Number of files in MPQ (calculated from size of MpqBlockTable)
local UInt32 massive_base[0x500];   /// This massive is used to calculate crc and decode files
global char *MpqFilenameTable;            /// Array of MPQ filenames
global char *MpqIdentifyTable;            /// Bitmap table of MPQ filenames 1 - if file name for this entry is known, 0 - if is not

global UInt32 *MpqBlockTable;       /// Block table

local UInt32 avail_metods[4] = { 0x08, 0x01, 0x40, 0x80 };
local UInt32 length_write;
local UInt8 *global_buffer, *read_buffer_start, *write_buffer_start;
local UInt32 *file_header;


/*----------------------------------------------------------------------------
--    Functions
----------------------------------------------------------------------------*/

/**
**    Analyzing archive
*/
global int MpqReadInfo(FILE *fpMpq)
{
    UInt32 mpq_header[2] = { 0x1a51504d, 0x00000020 };
    int i, j;
    UInt32 detected = 0;
    UInt32 tmp, scrc1, scrc2, scrc3, pointer_ht;
    FILE *fpList;
    char prnbuf[PATH_MAX+100];
    static char *name_htable = "(hash table)";  // Name of hash table (used to decode hash table)
    static char *name_btable = "(block table)"; // Name of block table (used to decode block tabl

    while (fread(&tmp, sizeof(UInt32), 1, fpMpq)) {
      if (mpq_header[0] == tmp) {
          fread(&tmp, sizeof(UInt32), 1, fpMpq);
          if (mpq_header[1] == tmp) {
            detected = 1;
            break;
          }
      }
    }
    if (!detected) {
//    printf("\nError: File \'%s\' is not valid MPQ archive", file_name);
      fclose(fpMpq);
      return -1;
    }
    offset_mpq = ftell(fpMpq) - 8;
    fread(&length_mpq_part, sizeof(UInt32), 1, fpMpq);
    fseek(fpMpq, offset_mpq + 16, SEEK_SET);
    fread(&offset_htbl, sizeof(UInt32), 1, fpMpq);
    fread(&offset_btbl, sizeof(UInt32), 1, fpMpq);
    fread(&length_htbl, sizeof(UInt32), 1, fpMpq);
    length_htbl *= 4;
    fread(&length_btbl, sizeof(UInt32), 1, fpMpq);
    MpqFileCount = length_btbl;
    length_btbl *= 4;

    BuildBaseMassive();
    if (InitializeLocals()) {
      fclose(fpMpq);
      return -2;
    }

    fseek(fpMpq, offset_mpq + offset_htbl, SEEK_SET);
    fread(hash_table, sizeof(UInt32), length_htbl, fpMpq);
    fseek(fpMpq, offset_mpq + offset_btbl, SEEK_SET);
    fread(MpqBlockTable, sizeof(UInt32), length_btbl, fpMpq);
    tmp = Crc(name_htable, massive_base, 0x300);
    Decode(hash_table, massive_base, tmp, length_htbl);
    tmp = Crc(name_btable, massive_base, 0x300);
    Decode(MpqBlockTable, massive_base, tmp, length_btbl);

    fpList = fopen(DEFAULT_LIST, "rt");
    if (!fpList) {
      sprintf(prnbuf, "tools/%s", DEFAULT_LIST);
      fpList = fopen(prnbuf, "rt");
    }
    if (fpList) {
      while (fgets(prnbuf, PATH_MAX, fpList) != 0) {
          if (*(prnbuf + strlen(prnbuf) - 1) == '\n') {
            *(prnbuf + strlen(prnbuf) - 1) = 0;
          }
          if (*(prnbuf + strlen(prnbuf) - 1) == '\r') {
            *(prnbuf + strlen(prnbuf) - 1) = 0;
          }
          scrc1 = Crc(prnbuf, massive_base, 0);
          scrc2 = Crc(prnbuf, massive_base, 0x100);
          scrc3 = Crc(prnbuf, massive_base, 0x200);
          pointer_ht = (scrc1 & (length_htbl / 4 - 1)) * 4;
          for (; pointer_ht < length_htbl; pointer_ht += 4) {
            if ((*(hash_table + pointer_ht) == scrc2)
                && (*(hash_table + pointer_ht + 1) == scrc3)) {
                // - fill MpqFilenameTable
                sprintf((MpqFilenameTable + PATH_MAX * (*(hash_table + pointer_ht + 3))), "%s", prnbuf);
                // . fill MpqIdentifyTable
                *(MpqIdentifyTable + *(hash_table + pointer_ht + 3)) = 1;
                break;
            }
          }
      }
      fclose(fpList);
    } else {
//    printf("Warning: Can't open default list: %s\n", DEFAULT_LIST);
    }

    j = 1;
    for (i = 0; i < MpqFileCount; ++i) {  // if there are not identified files, then
      if (!*(MpqIdentifyTable + i)) {           // fill MpqFilenameTable with "unknow\unknowN
          sprintf(MpqFilenameTable + PATH_MAX*i, "unknow\\unk%05d.xxx", j);
          ++j;
      }
    }
    return 0;
}

/**
**    Allocation of memory for hash_table,MpqBlockTable,
**    MpqFilenameTable,MpqIdentifyTable and working buffers 
**    7to decompress files
*/
local int InitializeLocals(void)
{
    global_buffer = (UInt8 *) malloc(0x60000);  // Allocation 384 KB for global_buffer
    if (!global_buffer) {
      printf("\nError! Insufficient memory");
      return -1;
    }
    read_buffer_start = global_buffer;    // 4 KB for read_buffer
    write_buffer_start = global_buffer + 0x1000;      // 4 KB for write_buffer
    explode_buffer = global_buffer + 0x2000;    // 16 KB for explode_buffer
    file_header = (UInt32 *) (global_buffer + 0x6000);      // 360 KB for file_header (max size of unpacked file can't exceed 360 MB)

    hash_table = (UInt32 *) malloc(length_htbl * 4);
    MpqBlockTable = (UInt32 *)malloc(length_btbl * 4);
    MpqFilenameTable = (char *)calloc(length_btbl / 4, PATH_MAX);
    MpqIdentifyTable = (char *)calloc(length_btbl / 4, sizeof(char));
    if (hash_table && MpqBlockTable && MpqFilenameTable && MpqIdentifyTable) {
      return 0;
    } else {
      printf("\nError! Insufficient memory");
      return -1;
    }
}

/**
**    Free memory
*/
global void CleanMpq(void)
{
    if (global_buffer) {
      free(global_buffer);
      global_buffer = NULL;
    }
    if (hash_table) {
      free(hash_table);
      hash_table = NULL;
    }
    if (MpqBlockTable) {
      free(MpqBlockTable);
      MpqBlockTable = NULL;
    }
    if (MpqFilenameTable) {
      free(MpqFilenameTable);
      MpqFilenameTable = NULL;
    }
    if (MpqIdentifyTable) {
      free(MpqIdentifyTable);
      MpqIdentifyTable = NULL;
    }
    return;
}

/**
**    Fill massive_base
*/
local void BuildBaseMassive(void)
{
    UInt32 s1;
    int i, j;
    ldiv_t divres;

    divres.rem = 0x100001;
    for (i = 0; i < 0x100; ++i) {
      for (j = 0; j < 5; ++j) {
          divres = ldiv(divres.rem * 125 + 3, 0x002AAAAB);
          s1 = (divres.rem & 0xFFFFL) << 0x10;
          divres = ldiv(divres.rem * 125 + 3, 0x002AAAAB);
          s1 = s1 | (divres.rem & 0xFFFFL);
          massive_base[i + 0x100 * j] = s1;
      }
    }
    return;
}

/**
**    Calculate crc
*/
local UInt32 Crc(char *string, UInt32 *massive_base, UInt32 massive_base_offset)
{
    char byte;
    UInt32 crc = 0x7fed7fed;
    UInt32 s1 = 0xEEEEEEEE;

    byte = *string;
    while (byte) {
      if (byte > 0x60 && byte < 0x7B) {
          byte -= 0x20;
      }
      crc = *(massive_base + massive_base_offset + byte) ^ (crc + s1);
      s1 += crc + (s1 << 5) + byte + 3;
      string++;
      byte = *string;
    }
    return crc;
}

/**
**    (called by explode)
*/
UInt16 read_data(UInt8 *buffer, UInt16 size, void *crap)
{
    params *param;
    
    param = (params *)crap;
    memcpy(buffer, param->buf_in, size);
    param->buf_in += size;
    return size;
}

/**
**    (called by explode)
*/
local void write_data(UInt8 * buffer, UInt16 size, void *crap)
{
    params *param;
    
    param = (params *)crap;
    memcpy(param->buf_out, buffer, size);
    param->buf_out += size;
    length_write += size;
}

/**
**    Decode data
*/
local void Decode(UInt32 * data_in, UInt32 * massive_base, UInt32 crc, UInt32 length)
{
    UInt32 i, dec;
    UInt32 s1;
    
    s1 = 0xEEEEEEEE;
    for (i = 0; i < length; i++) {
      s1 += *(massive_base + 0x400 + (crc & 0xFFL));
      dec = *(data_in + i) ^ (s1 + crc);
      s1 += dec + (s1 << 5) + 3;
      *(data_in + i) = dec;
      crc = (crc >> 0x0b) | (0x11111111 + ((crc ^ 0x7FFL) << 0x15));
    }
    return;
}

/**
**    Calculate crc for file without name
*/
local UInt32 GetUnknowCrc(UInt32 entry, FILE *fpMpq)
{
    UInt32 tmp, i, j, coded_dword, crc_file;
    UInt32 flag, size_pack, size_unpack, num_block, offset_body;
    UInt32 sign_riff1 = 0x46464952; // 'RIFF'
    UInt32 sign_riff3 = 0x45564157; // 'WAVE'
    UInt32 sign_mpq1 = 0x1a51504d;  // 'MPQ'
    UInt32 sign_mpq2 = 0x00000020;
    ldiv_t divres;

    offset_body = *(MpqBlockTable + entry * 4); // get offset of analized file
    flag = *(MpqBlockTable + entry * 4 + 3);    // get flag of analized file
    fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
    fread(&coded_dword, sizeof(UInt32), 1, fpMpq);    // read first coded dword from file

    if (flag & 0x200 || flag & 0x100) {   // IF FILE PACKED:
      size_unpack = *(MpqBlockTable + entry * 4 + 2); // . get size of unpacked file
      size_pack = *(MpqBlockTable + entry * 4 + 1);   // . get size of packed file
      divres = ldiv(size_unpack - 1, 0x1000);
      num_block = divres.quot + 2;  // . calculate length of file header
      for (j = 0; j <= 0xff; j++) { // . now we're gonna find crc_file of 0x100 possible variants
          crc_file = ((num_block * 4) ^ coded_dword) - 0xeeeeeeee - *(massive_base + 0x400 + j);      // . calculate possible crc
          if ((crc_file & 0xffL) == j) {  // . IF FIRST CHECK is succesfull - do second one
            fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
            fread(file_header, sizeof(UInt32), num_block, fpMpq); // . read file header 
            Decode(file_header, massive_base, crc_file, num_block);     // . decode file header with possible crc
            tmp = num_block * 4;    // . tmp = size header (bytes)
            if (tmp == *file_header) {    // . IF SECOND CHECK is succesfull - do third one
                for (i = 0; i < num_block - 1; i++) {
                  tmp += *(file_header + i + 1) - *(file_header + i);
                  if (*(file_header + i + 1) - *(file_header + i) >
                      0x1000) {
                      tmp = 0xffffffff;
                      break;
                  }
                }
                if (tmp != 0xffffffff) {  // . IF THIRD CHECK is succesfull
                  crc_file++; // . great! we got right crc_file
                  break;
                }
            }
          }
          crc_file = 0;       // . if its impossible to get right crc return 0
      }

    } else {                        // IF FILE IS NOT PACKED:
      for (j = 0; j <= 0xff; j++) { // Calculate crc as if it was WAV FILE
          crc_file = (sign_riff1 ^ coded_dword) - 0xeeeeeeee - *(massive_base + 0x400 + j);     // . calculate possible crc
          if ((crc_file & 0xff) == j) {   // . IF FIRST CHECK is succesfull - do second one
            fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
            fread(file_header, sizeof(UInt32), 3, fpMpq);   // . read file file_header 
            Decode(file_header, massive_base, crc_file, 3); // . decode file file_header with possible crc
            if (sign_riff1 == *file_header) {
                if (sign_riff3 == *(file_header + 2)) {     // . IF SECOND CHECK is succesfull - we got right crc
                  break;
                }
            }
          }
          crc_file = 0;       // . if its impossible to get right crc return 0
      }
      if (!crc_file) {        // Calculate crc as if it was MPQ FILE
          for (j = 0; j <= 0xff; j++) {
            crc_file =
                (sign_mpq1 ^ coded_dword) - 0xeeeeeeee - *(massive_base +
                0x400 + j);
            if ((crc_file & 0xffL) == j) {
                fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
                fread(file_header, sizeof(UInt32), 2, fpMpq);
                Decode(file_header, massive_base, crc_file, 2);
                if (sign_mpq1 == *file_header) {
                  if (sign_mpq2 == *(file_header + 1)) {
                      break;
                  }
                }
            }
            crc_file = 0;
          }
      }
    }
    return crc_file;
}

/**
**    Extract file from archive
*/
global int MpqExtractTo(unsigned char *mpqbuf, UInt32 entry, FILE *fpMpq)
{
    UInt32 size_pack, size_unpack;
    UInt8 *read_buffer, *write_buffer;
    UInt32 i, j, offset_body, flag, crc_file;
    UInt32 num_block, length_read, iteration;
    UInt8 *szNameFile;
    UInt8 metod;
    ldiv_t divres;
    params param;
    unsigned char *mpqptr;

    mpqptr = mpqbuf;

    offset_body = *(MpqBlockTable + entry * 4); // get offset of file in mpq
    size_unpack = *(MpqBlockTable + entry * 4 + 2);   // get unpacked size of file
    flag = *(MpqBlockTable + entry * 4 + 3);    // get flags for file
    crc_file = 0;

    if (flag & 0x30000) {           // If file is coded, calculate its crc
      if (*(MpqIdentifyTable + entry) & 0x1) {  // . Calculate crc_file for identified file:
          szNameFile = MpqFilenameTable + PATH_MAX * entry; // . . get name of file
          if (strrchr(szNameFile, '\\')) {
            szNameFile = strrchr(szNameFile, '\\') + 1;
          }
          crc_file = Crc(szNameFile, massive_base, 0x300);  // . . calculate crc_file (for Diablo I MPQs)
          if ((flag & 0x20200) == 0x20200) {          // . . if flag indicates Starcraft MPQ
            crc_file = (crc_file + offset_body) ^ size_unpack;    // . . calculate crc_file (for Starcraft MPQs)
          }
      } else {
          crc_file = GetUnknowCrc(entry, fpMpq);      // . calculate crc_file for not identified file:
      }
    }

    if (flag & 0x200 || flag & 0x100) {   // IF FILE IS PACKED:
      divres = ldiv(size_unpack - 1, 0x1000);
      num_block = divres.quot + 2;  // . calculate length of file header
      fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
      fread(file_header, sizeof(UInt32), num_block, fpMpq); // . read file header 
      if (flag & 0x30000) {
          Decode(file_header, massive_base, (crc_file - 1), num_block); // . decode file header (if file is coded)
      }
      read_buffer = read_buffer_start;
      for (j = 0; j < (num_block - 1); j++) {
          length_read = *(file_header + j + 1) - *(file_header + j);    // . get length of block to read
          fread(read_buffer, sizeof(char), length_read, fpMpq);   // . read block
          if (flag & 0x30000) {
            Decode((UInt32 *) read_buffer, massive_base, crc_file, length_read / 4);      // . decode block (if file is coded)
          }
          if (length_read == 0x1000 || (j == num_block - 2 && length_read == (size_unpack & 0xFFF))) {      // . if block is unpacked (its length=0x1000 or its last block and length=remainder)
            memcpy(mpqptr, read_buffer, length_read);
            mpqptr += length_read;
//          fwrite(read_buffer, sizeof(char), length_read, fp_new);     // . write block "as is"
          }
          else {              // . block is packed
            if (flag & 0x200) {     // . If this file is from Starcraft MPQ (or Diablo 2), then
                metod = *read_buffer;     // . . first byte determinates metod of packing
                iteration = 0;
                for (i = 0; i < 4; i++) { // . . calculate number of iterations
                  if (metod & avail_metods[i]) {
                      iteration++;
                  }
                }
                read_buffer += 1;
                length_read -= 1;
            } else {          // . Else: file is from Diablo I MPQ, then
                iteration = 1;
                metod = 8;          // . .file is compressed with DCL
            }
            write_buffer = write_buffer_start;
            if (metod & 0x08) {
                param.buf_in = read_buffer;
                param.buf_out = write_buffer;
                length_write = 0;
                explode(&read_data, &write_data, &param);
                length_read = length_write;
                iteration--;
                if (iteration) {
                  read_buffer = write_buffer;
                  write_buffer = read_buffer_start;
                }
            }
            if (metod & 0x01) {
                length_read =
                  ExtWavUnp1((UInt32) read_buffer,
                  (UInt32) length_read, (UInt32) write_buffer,
                  0x1000);
                iteration--;
                if (iteration) {
                  read_buffer = write_buffer;
                  write_buffer = read_buffer_start;
                }
            }
            if (metod & 0x40) {
                length_read =
                  ExtWavUnp2((UInt32) read_buffer,
                  (UInt32) length_read, (UInt32) write_buffer,
                  0x1000);
            }
            if (metod & 0x80) {
                length_read =
                  ExtWavUnp3((UInt32) read_buffer,
                  (UInt32) length_read, (UInt32) write_buffer,
                  0x1000);
            }
            memcpy(mpqptr, write_buffer, length_read);
            mpqptr += length_read;
//          fwrite(write_buffer, 1, length_read, fp_new);
            read_buffer = read_buffer_start;
          }
          crc_file++;               // . calculate crc_file for next block
      }
    }

    else {                    // IF FILE IS NOT PACKED
      size_pack = *(MpqBlockTable + entry * 4 + 1);   // get size  of file
      if (flag & 0x30000) {
          length_read = 0x1000;     // if file is coded, length_read=0x1000 (4 KB)
      } else {
          length_read = 0x60000;    // if file is not coded, length_read=0x60000 (384KB)
      }
      if (size_pack < length_read) {
          length_read = size_pack;  // if size of file < length_read, length read = size of file
      }
      read_buffer = read_buffer_start;
      if (length_read) {
          divres = ldiv(size_pack, length_read);      // .
          num_block = divres.quot;  // .
      } else {                // .
          num_block = 0;            // .
          divres.rem = 0;           // .
      }
      fseek(fpMpq, offset_mpq + offset_body, SEEK_SET);
      for (j = 0; j < num_block; j++) {
          fread(read_buffer, 1, length_read, fpMpq);
          if (flag & 0x30000) {
            Decode((UInt32 *) read_buffer, massive_base, crc_file, length_read / 4);      // if file is coded, decode block
            crc_file++;       // and calculate crc_file for next block
          }
          memcpy(mpqptr, read_buffer, length_read);
          mpqptr += length_read;
//        fwrite(read_buffer, 1, length_read, fp_new);
      }
      if (divres.rem) {
          fread(read_buffer, 1, divres.rem, fpMpq);
          if (flag & 0x30000)
            Decode((UInt32 *) read_buffer, massive_base, crc_file,
                divres.rem / 4);
          memcpy(mpqptr, read_buffer, divres.rem);
          mpqptr += divres.rem;
//        fwrite(read_buffer, 1, divres.rem, fp_new);
      }
    }
    return 0;
}

/**
**
*/
local UInt32 explode(read_data_proc read_data, write_data_proc write_data, void *param)
{
    UInt32 result;
    UInt16 read_result;
    const UInt8 *table = dcl_table;
    UInt8 *work_buff;

    work_buff = (UInt8 *) explode_buffer;

    *((UInt32 *) (work_buff + 0x16)) = (UInt32) read_data;
    *((UInt32 *) (work_buff + 0x1A)) = (UInt32) write_data;
    *((void **)(work_buff + 0x12)) = param;
    *((UInt16 *) (work_buff + 0x0E)) = 0x0800;
    read_result = read_data(work_buff + 0x2222, 0x0800, param);
    if (read_result == DCL_ERROR_4) {
      result = DCL_ERROR_3;
    } else {
      UInt16 flag_0 = *(work_buff + 0x2222), flag_1 =
          *(work_buff + 0x2223), flag_2 = *(work_buff + 0x2224);

      *((UInt16 *) (work_buff + 0x02)) = flag_0;
      *((UInt16 *) (work_buff + 0x06)) = flag_1;
      *((UInt16 *) (work_buff + 0x0A)) = flag_2;
      *((UInt16 *) (work_buff + 0x0C)) = 0x00;
      *((UInt16 *) (work_buff + 0x0E)) = 0x03;
      *((UInt16 *) (work_buff + 0x10)) = read_result;
      if ((flag_1 < 0x04) || (flag_1 > 0x06)) {
          result = DCL_ERROR_1;
      } else {
          *((UInt16 *) (work_buff + 0x08)) =
            (UInt16) (0x0000FFFFL >> (0x0010 - flag_1));
          if (flag_0 > 0x01) {
            result = DCL_ERROR_2;
          } else {
            if (flag_0) {
                __explode_7(work_buff + 0x2FA2, table + 0x00D0, 0x0100);
                __explode_6(work_buff, table + 0x01D0);
            }
            __explode_7(work_buff + 0x30E2, table + 0x00B0, 0x0010);
            __explode_5(0x0010, work_buff + 0x30E2, table + 0x00C0,
                work_buff + 0x2B22);
            __explode_7(work_buff + 0x30F2, table + 0x0080, 0x0010);
            __explode_7(work_buff + 0x3102, table + 0x0090, 0x0020);
            __explode_7(work_buff + 0x30A2, table, 0x0040);
            __explode_5(0x0040, work_buff + 0x30A2, table + 0x0040,
                work_buff + 0x2A22);
            if (__explode_1(work_buff) != 0x0306) {
                result = DCL_NO_ERROR;
            } else {
                result = DCL_ERROR_4;
            }
          }
      }
    }
//  free(work_buff);
    return result;
}

/**
**
*/
local UInt16 __explode_1(UInt8 * buf)
{
    UInt32 result, temp;
    UInt8 *s, *d;
    write_data_proc *write_data;
    void *param;

    *((UInt16 *) (buf + 0x04)) = 0x1000;
    while (result = __explode_2(buf), (UInt16) result < 0x0305) {
      if ((UInt16) result < 0x0100) {
          temp = *((UInt16 *) (buf + 0x04));
          *((UInt16 *) (buf + 0x04)) = (UInt16) (temp + 0x01);
          *(buf + temp + 0x1E) = (UInt8) result;
      } else {
          result -= 0x00FE;
          s = (UInt8 *) (UInt32)__explode_3(buf, (UInt16) result);
          if (!s) {
            result = 0x0306;
            break;
          } else {
            temp = *((UInt16 *) (buf + 0x04));
            d = temp + 0x1E + buf;
            *((UInt16 *) (buf + 0x04)) = (UInt16) (temp + result);
            s = (UInt8 *) ((UInt32) d - (UInt32) s);
            do {
                result--;
                *(d++) = *(s++);
            } while (result);
          }
      }
      if (*((UInt16 *) (buf + 4)) >= 0x2000) {
          result = 0x1000;
          write_data = (write_data_proc *) * ((UInt32 *) (buf + 0x1A));
          param = (void *)*((UInt32 *) (buf + 0x12));
          write_data(buf + 0x101E, 0x1000, param);
          __explode_7(buf + 0x001E, buf + 0x101E,
            *((UInt16 *) (buf + 0x04)) - 0x1000);
          *((UInt16 *) (buf + 0x04)) -= 0x1000;
      }
    }
    write_data = (write_data_proc *) * ((UInt32 *) (buf + 0x1A));
    param = (void *)*((UInt32 *) (buf + 0x12));
    write_data(buf + 0x101E,
      (UInt16) (*((UInt16 *) (buf + 0x04)) - 0x1000), param);
    return (UInt16) result;
}

/**
**
*/
local UInt16 __explode_2(UInt8 * buf)
{
    UInt32 result, flag, flag_1;

    if (*((UInt16 *) (buf + 0x0A)) & 0x01) {
      if (__explode_4(buf, 0x01)) {
          return 0x0306;
      }
      result = *(buf + ((UInt8) * ((UInt16 *) (buf + 0x0A))) + 0x2B22);
      if (__explode_4(buf, *(buf + ((UInt16) result) + 0x30E2))) {
          return 0x0306;
      }
      flag = *(buf + ((UInt16) result) + 0x30F2);
      if (flag) {
          flag_1 = (*((UInt16 *) (buf + 0x0A))) & ((0x01 << flag) - 0x01);
          if (__explode_4(buf, flag)) {
            if ((((UInt16) result) + ((UInt16) flag_1)) != 0x010E) {
                return 0x0306;
            }
          }
          result =
            *((UInt16 *) (buf + (((UInt16) result) << 0x01) +
                0x3102)) + flag_1;
      }
      result += 0x0100;
    } else {
      if (__explode_4(buf, 0x01)) {
          return 0x0306;
      }
      if (!*((UInt16 *) (buf + 0x02))) {
          result = (UInt8) * ((UInt16 *) (buf + 0x0A));
          if (__explode_4(buf, 0x08)) {
            return 0x0306;
          }
      } else {
          flag = *((UInt16 *) (buf + 0x0A));
          if ((UInt8) flag) {
            result = *(buf + ((UInt8) flag) + 0x2C22);
            if (((UInt16) result) == 0x00FF) {
                if (flag & 0x003F) {
                  if (__explode_4(buf, 0x04)) {
                      return 0x0306;
                  }
                  result =
                      *(buf + ((UInt8) * ((UInt16 *) (buf + 0x0A))) +
                      0x2D22);
                } else {
                  if (__explode_4(buf, 0x06)) {
                      return 0x0306;
                  }
                  result =
                      *(buf + ((*((UInt16 *) (buf + 0x0A))) & 0x007F) +
                      0x2E22);
                }
            }
          } else {
            if (__explode_4(buf, 0x08)) {
                return 0x0306;
            }
            result =
                *(buf + ((UInt8) * ((UInt16 *) (buf + 0x0A))) +
                0x2EA2);
          }
          flag = *(buf + ((UInt16) result) + 0x2FA2);
          if (__explode_4(buf, flag)) {
            return 0x0306;
          }
      }
    }
    return (UInt16) result;
}

/**
**
*/
local UInt16 __explode_3(UInt8 * buf, UInt16 flag)
{
    UInt32 result, flag_1;

    result = *(buf + ((UInt8) * ((UInt16 *) (buf + 0x0A))) + 0x2A22);
    if (__explode_4(buf, *(buf + ((UInt16) result) + 0x30A2))) {
      return 0x00;
    }
    if (((UInt16) flag) == 0x02) {
      result <<= 0x02;
      result |= *((UInt16 *) (buf + 0x0A)) & 0x03;
      if (__explode_4(buf, 0x02)) {
          return 0x00;
      }
    } else {
      flag_1 = *((UInt16 *) (buf + 0x06));
      result <<= flag_1;
      result |= *((UInt16 *) (buf + 0x08)) & *((UInt16 *) (buf + 0x0A));
      if (__explode_4(buf, flag_1)) {
          return 0x00;
      }
    }
    return (UInt16) (result + 0x01);
}

/**
**
*/
local UInt16 __explode_4(UInt8 * buf, UInt32 flag)
{
    UInt32 result;
    UInt16 read_result;
    read_data_proc *read_data =
      (read_data_proc *) * ((UInt32 *) (buf + 0x16));
    void *param = (void *)*((UInt32 *) (buf + 0x12));

    result = *((UInt16 *) (buf + 0x0C));
    if ((UInt16) flag <= result) {
      *((UInt16 *) (buf + 0x0A)) >>= flag;
      *((UInt16 *) (buf + 0x0C)) -= (UInt16) flag;
      result = 0x00;
    } else {
      *((UInt16 *) (buf + 0x0A)) >>= result;
      result = *((UInt16 *) (buf + 0x0E));
      if (result == *((UInt16 *) (buf + 0x10))) {
          *((UInt16 *) (buf + 0x0E)) = 0x0800;
          read_result = read_data(buf + 0x2222, 0x0800, param);
          *((UInt16 *) (buf + 0x10)) = read_result;
          if (!read_result) {
            return 0x01;
          }
          *((UInt16 *) (buf + 0x0E)) = 0x00;
      }
      result = *((UInt16 *) (buf + 0x0E)) + 0x2222;
      *((UInt16 *) (buf + 0x0A)) |= *(buf + result) << 0x08;
      *((UInt16 *) (buf + 0x0E)) += 0x01;
      *((UInt16 *) (buf + 0x0A)) >>= flag - *((UInt16 *) (buf + 0x0C));
      *((UInt16 *) (buf + 0x0C)) =
          (UInt16) (0x08 - (flag - *((UInt16 *) (buf + 0x0C))));
      result = 0x00;
    }
    return (UInt16) result;
}

/**
**
*/
local void __explode_5(UInt16 count, UInt8 * buf_1, const UInt8 * table,
    UInt8 * buf_2)
{
    SInt16 i = (SInt16) (count - 1);
    UInt32 idx_1, idx_2;

    for (; i >= 0; i--) {
      idx_1 = *(table + i);
      idx_2 = 0x01 << *(buf_1 + i);
      for (;;) {
          *(buf_2 + (UInt16) idx_1) = (UInt8) i;
          idx_1 += idx_2;
          if ((UInt16) idx_1 >= 0x0100) {
            break;
          }
      }
    }
}

/**
**
*/
local void __explode_6(UInt8 * buf, const UInt8 * table)
{
    SInt16 i;
    UInt32 idx_1, idx_2;

    for (i = 0x00FF; i >= 0; i--) {
      idx_1 = *(buf + i + 0x2FA2);
      if (idx_1 <= 0x08) {
          idx_2 = *((UInt16 *) (table + (i << 0x01)));
          idx_1 = 0x01 << idx_1;
          do {
            *(buf + idx_2 + 0x2C22) = (UInt8) i;
            idx_2 += idx_1;
          } while ((UInt16) idx_2 < 0x0100);
      } else {
          idx_2 = *((UInt16 *) (table + (i << 0x01)));
          if ((UInt8) idx_2) {

            *(buf + (UInt8) idx_2 + 0x2C22) = 0xFF;
            if (*((UInt16 *) (table + (i << 0x01))) & 0x003F) {
                *(buf + i + 0x2FA2) -= 0x04;
                idx_1 = 0x01 << *(buf + i + 0x2FA2);
                idx_2 = *((UInt16 *) (table + (i << 0x01))) >> 0x04;
                do {
                  *(buf + idx_2 + 0x2D22) = (UInt8) i;
                  idx_2 += idx_1;
                } while ((UInt16) idx_2 < 0x0100);
            } else {
                *(buf + i + 0x2FA2) -= 0x06;
                idx_1 = 0x01 << *(buf + i + 0x2FA2);
                idx_2 = *((UInt16 *) (table + (i << 0x01))) >> 0x06;
                do {
                  *(buf + idx_2 + 0x2E22) = (UInt8) i;
                  idx_2 += idx_1;
                } while ((UInt16) idx_2 < 0x0080);
            }
          } else {
            *(buf + i + 0x2FA2) -= 0x08;
            idx_1 = 0x01 << *(buf + i + 0x2FA2);
            idx_2 = *((UInt16 *) (table + (i << 0x01))) >> 0x08;
            do {
                *(buf + idx_2 + 0x2EA2) = (UInt8) i;
                idx_2 += idx_1;
            } while ((UInt16) idx_2 < 0x0100);
          }
      }
    }
}

/**
**
*/
local void __explode_7(UInt8 *buf, const UInt8 *table, UInt32 count)
{
    UInt32 half_count;
    UInt8 *buf_end;

    half_count = count >> 0x02;
    if (half_count) {
      buf_end = buf + (half_count << 0x02);
      do {
          *((UInt32 *) buf) = *((UInt32 *) table);
          buf += 4;
          table += 4;
      } while (buf < buf_end);
    }
    switch (count - (half_count << 0x02)) {
      case 3:
          *(buf++) = *(table++);

      case 2:
          *(buf++) = *(table++);

      case 1:
          *buf = *table;

      default:
          break;
    }
}

/**
**
*/
UInt32 ExtWavUnp3(UInt32 buf_in, UInt32 size_in, UInt32 buf_out, UInt32 size_out)
{
    return Sub_WavUnp13(buf_in, size_in, 2, buf_out, size_out);
}

/**
**
*/
UInt32 ExtWavUnp2(UInt32 buf_in, UInt32 size_in, UInt32 buf_out, UInt32 size_out)
{
    return Sub_WavUnp13(buf_in, size_in, 1, buf_out, size_out);
}

/**
**
*/
UInt32 Sub_WavUnp13(UInt32 buf_in, UInt32 size_in, UInt32 flag, UInt32 buf_out, UInt32 size_out)
{
    UInt32 var14,var18,var1c;
    UInt32 tmp0,tmp1,tmp2,tmp3,tmp4;
    UInt32 var8[2];
    UInt32 var10[2];

    var14=buf_in;
    size_in+=buf_in;
    tmp0=var14+2;
    var1c=size_out;
    tmp3=buf_out;
    var18=buf_out;
    var10[0]=0x2C;
    var10[1]=0x2C;
    if((SInt32)flag>0) {
      for(tmp2=0;tmp2<flag;tmp2++) {
          var8[tmp2]=(SInt32)*((SInt16 *)tmp0);
          tmp0+=2;
          if(size_out<2) {
            return tmp3-var18;
          }
          *((UInt16 *)tmp3)=(UInt16) var8[tmp2];
          tmp3+=2;
          var1c-=2;
      }
    }
    tmp2=flag-1;
    while(tmp0<size_in) {
      if(flag==2) {
          if(tmp2==0) {
            tmp2=1;
          } else {
            tmp2=0;
          }
      }
      tmp1=(UInt32)*((UInt8 *)tmp0);
      tmp0++;
      buf_in=tmp0;
      if(tmp1&0x80) {
          tmp1&=0x7F;
          tmp4=1;
          if(tmp1==0) {
            if(var10[tmp2]) {
                var10[tmp2]--;
            }
            if(var1c<2) {
                return tmp3-var18;
            }
            *((UInt16 *)tmp3)=(UInt16)var8[tmp2];
            tmp3+=2;
            var1c-=2;
            if((tmp4==0)&&(flag==2)) {
                if(tmp2==0) {
                  tmp2=1;
                } else {
                  tmp2=0;
                }
            }
          } else {
            tmp1--;
            if(tmp1==0) {
                var10[tmp2]+=8;
                tmp4=var10[tmp2];
                if(tmp4>0x58) {
                  var10[tmp2]=0x58;
                }
                tmp4=0;
                if(tmp4==0 && flag==2) {
                  if(tmp2==0) {
                      tmp2=1;
                  } else {
                      tmp2=0;
                  }
                }
            } else {
                tmp1--;
                if(tmp1==0)   {
                  var10[tmp2]+=0xFFFFFFF8;
                  if((SInt32)var10[tmp2]<0) {
                      var10[tmp2]=0;
                  }
                  tmp4=0;
                }
                if((tmp4==0)&&(flag==2)) {
                  if(tmp2==0) {
                      tmp2=1;
                  } else {
                      tmp2=0;
                  }
                }
            }
          }
      } else {
          tmp0=small_tbl1[var10[tmp2]];
          tmp4=tmp0>>(*((UInt8 *)(var14+1)));
          if(tmp1&1) {
            tmp4+=tmp0;
          }
          if(tmp1&2) {
            tmp4+=tmp0>>1;
          }
          if(tmp1&4) {
            tmp4+=tmp0>>2;
          }
          if(tmp1&8) {
            tmp4+=tmp0>>3;
          }
          if(tmp1&0x10) {
            tmp4+=tmp0>>4;
          }
          if(tmp1&0x20) {
            tmp4+=tmp0>>5;
          }
          tmp0=var8[tmp2];
          if((tmp1&0xFF)&0x40) {
            tmp0-=tmp4;
            if((SInt32)tmp0<=(SInt32)0xFFFF8000) {
                tmp0=0xFFFF8000;
            }
          } else {
            tmp0+=tmp4;
            if((SInt32)tmp0>=0x7FFF) {
                tmp0=0x7FFF;
            }
          }
          var8[tmp2]=tmp0;
          tmp0=var1c;
          if(tmp0<2) {
            return tmp3-var18;
          }
          *((UInt16 *)tmp3)=(UInt16)var8[tmp2];
          tmp1&=0x1F;
          tmp3+=2;
          var1c-=2;
          tmp4=var10[tmp2]+small_tbl2[tmp1];
          var10[tmp2]=tmp4;
          if((SInt32)tmp4<0) {
            var10[tmp2]=0;
          } else {
            if(tmp4>0x58) {
                var10[tmp2]=0x58;
            }
          }
          tmp0=buf_in;
      }
    }
    return tmp3-var18;
}

/**
**
*/
UInt32 ExtWavUnp1(UInt32 buf_in, UInt32 size_in __attribute__((unused)),
      UInt32 buf_out, UInt32 size_out)
{
    UInt32 work_buff,base;
    UInt32 tmp1,tmp2,tmp3;
    SInt32 i;

    work_buff=(UInt32)(UInt8 *)malloc(0x3a80);
    *((UInt32 *)work_buff)=buf_in+4;
    *((UInt32 *)(work_buff+4))=*((UInt32 *)buf_in);
    *((UInt32 *)(work_buff+8))=0x20;
    base=work_buff+0xC;
    Sub_WavUnp12(base);
    size_out=Sub_WavUnp11(buf_out,size_out,work_buff,base);
    while(1) {
      tmp2=*((UInt32 *)(work_buff+0x3070));
      if((SInt32)tmp2<=0) {
          break;
      }
      tmp3=Sub_WavUnp5(tmp2);
      *((UInt32 *)tmp3)=*((UInt32 *)tmp2);
      tmp3=*((UInt32 *)tmp2);
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp2+4));
      *((UInt32 *)tmp2)=0;
      *((UInt32 *)(tmp2+4))=0;
    }
    if(*((UInt32 *)(work_buff+0x306C))) {
      tmp3=Sub_WavUnp5(*((UInt32 *)(work_buff+0x306C)));
      *((UInt32 *)tmp3)=*((UInt32 *)(work_buff+0x306C));
      tmp3=*((UInt32 *)(work_buff+0x306C));
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(work_buff+0x3070));
      *((UInt32 *)(work_buff+0x306C))=0;
      *((UInt32 *)(work_buff+0x3070))=0;
    }
    while(1) {
      tmp2=*((UInt32 *)(work_buff+0x3064));
      if((SInt32)tmp2<=0) {
          break;
      }
      tmp3=Sub_WavUnp5(tmp2);
      *((UInt32 *)tmp3)=*((UInt32 *)tmp2);
      tmp3=*((UInt32 *)tmp2);
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp2+4));
      *((UInt32 *)tmp2)=0;
      *((UInt32 *)(tmp2+4))=0;
    }
    if(*((UInt32 *)(work_buff+0x3060))) {
      tmp3=Sub_WavUnp5(*((UInt32 *)(work_buff+0x3060)));
      *((UInt32 *)tmp3)=*((UInt32 *)(work_buff+0x3060));
      tmp3=*((UInt32 *)(work_buff+0x3060));
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(work_buff+0x3064));
      *((UInt32 *)(work_buff+0x3060))=0;
      *((UInt32 *)(work_buff+0x3064))=0;
    }
    tmp2=work_buff+0x305C;
    for(i=0x203;i!=0;i--) {
      tmp3=*((UInt32 *)(tmp2-0x18));
      tmp2-=0x18;
      if(tmp3) {
          tmp3=Sub_WavUnp5(tmp2);
          *((UInt32 *)tmp3)=*((UInt32 *)tmp2);
          tmp3=*((UInt32 *)tmp2);
          *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp2+4));
          *((UInt32 *)tmp2)=0;
          *((UInt32 *)(tmp2+4))=0;
      }
      tmp1=*((UInt32 *)tmp2);
      if(tmp1) {
          tmp3=*((UInt32 *)(tmp2+4));
          if((SInt32)tmp3<0) {
            tmp3=~tmp3;
          } else {
            tmp3=tmp2+tmp3-*((UInt32 *)(tmp1+4));
          }
          *((UInt32 *)tmp3)=tmp1;
          tmp3=*((UInt32 *)tmp2);
          *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp2+4));
          *((UInt32 *)tmp2)=0;
          *((UInt32 *)(tmp2+4))=0;
      }
    }
    free((UInt8 *)work_buff);
    return size_out;
}

/**
**
*/
void Sub_WavUnp12(UInt32 base)
{
    UInt32 tmp;
    SInt32 i;

    Sub_WavUnp6(base);
    tmp=base+0x3474;
    for(i=0x80; i!=0; --i) {
      *((UInt32 *)tmp)=0;
      tmp+=0xC;
    }
    return;
}

/**
**
*/
UInt32 Sub_WavUnp11(UInt32 buf_out, UInt32 size_out, UInt32 work_buff, UInt32 base)
{
    UInt32 var4,var8,varc,var10,var14;
    UInt32 flag,tmp0,tmp1,tmp2,tmp3,tmp4,tmp5;

    IfDebug( var14=0; );            // Disable warning! Correct?
    var4=0;
    if(size_out==0) {
      return 0;
    }
    tmp0=work_buff;
    if(*((UInt32 *)(tmp0+8))<=8) {
      tmp3=*((UInt32 *)tmp0);
      *((UInt32 *)(tmp0+4))|=((UInt32)*((UInt16 *)tmp3)&0xFFFF)<<(*((UInt32 *)(tmp0+8))&0xFF);
      *((UInt32 *)(tmp0+8))+=0x10;
      *((UInt32 *)tmp0)+=2;
    }
    *((UInt32 *)(tmp0+8))+=0xFFFFFFF8;
    varc=*((UInt32 *)(tmp0+4))&0xFF;
    *((UInt32 *)(tmp0+4))=*((UInt32 *)(tmp0+4))>>8;
    Sub_WavUnp1(varc,base);
    if((varc&0xFF)==0) {
      *((UInt32 *)base)=1;
    } else {
      *((UInt32 *)base)=0;
    }
    varc=buf_out;

    while(1) {
      if(*((UInt32 *)(tmp0+8))<=7) {
          tmp3=*((UInt32 *)tmp0);
          *((UInt32 *)(tmp0+4))|=((UInt32)*((UInt16 *)tmp3)&0xFFFF)<<(*((UInt32 *)(tmp0+8))&0xFF);          
          *((UInt32 *)(tmp0+8))+=0x10;
          *((UInt32 *)tmp0)+=2;
      }
      tmp3=*((UInt32 *)(tmp0+4));
      tmp4=tmp3&0x7F;
      tmp2=base+(tmp4+0x45F)*12;
      tmp1=*((UInt32 *)tmp2);
      var8=0;
      flag=1;
      if(tmp1==*((UInt32 *)(base+4))) {
          var8=1;
          tmp5=*((UInt32 *)(tmp2+4));
          if(tmp5>7) {
            *((UInt32 *)(tmp0+4))=*((UInt32 *)(tmp0+4))>>7;
            *((UInt32 *)(tmp0+8))+=0xFFFFFFF9;
            var14=*((UInt32 *)(tmp2+8));
          } else {
            *((UInt32 *)(tmp0+4))=*((UInt32 *)(tmp0+4))>>(*((UInt32 *)(tmp2+4))&0xFF);
            *((UInt32 *)(tmp0+8))-=*((UInt32 *)(tmp2+4));
            tmp5=*((UInt32 *)(tmp2+8));
            flag=0;
          }
      } else {
          tmp5=*((UInt32 *)(base+0x3060));
          tmp3=*((UInt32 *)tmp5);
          var14=*((UInt32 *)(tmp3+4));
          tmp3=var14;
          if((SInt32)var14<=0) {
            var14=0;
          }
      }
      if(flag) {
          var10=0;
          do {
            var14=*((UInt32 *)(var14+0x14));
            if(Sub_WavUnp8(tmp0)) {
                tmp3=*((UInt32 *)(var14+4));
                var14=tmp3;
            } else {
                tmp3=var14;
            }
            var10++;
            if(var10==7) {
                var4=tmp3;
            }
          } while(*((UInt32 *)(tmp3+0x14)));
          if(var8==0) {
            if(var10>7) {
                *((UInt32 *)tmp2)=*((UInt32 *)(base+4));
                *((UInt32 *)(tmp2+4))=var10;
                *((UInt32 *)(tmp2+8))=var4;
            } else {
                tmp3=(((var10|0xFFFFFFFF)>>((0x20-var10)&0xFF)))&tmp4;
                tmp1=1<<(var10&0xFF);
                tmp5=base+0x347C+tmp3*12;
                tmp2=(tmp1*3)<<2;
                do {
                  tmp3+=tmp1;
                  *((UInt32 *)(tmp5-8))=*((UInt32 *)(base+4));
                  *((UInt32 *)(tmp5-4))=var10;
                  *((UInt32 *)tmp5)=*((UInt32 *)(var14+8));
                  tmp5+=tmp2;
                } while(tmp3<=0x7F);
            }
          }
          var10=*((UInt32 *)(var14+8));
          tmp5=var10;
      }
      if(tmp5==0x101) {
          tmp5=*((UInt32 *)(tmp0+8));
          if(tmp5<=8)   {
            tmp3=*((UInt32 *)tmp0);
            *((UInt32 *)(tmp0+4))|=((UInt32)*((UInt16 *)tmp3)&0xFFFF)<<(*((UInt32 *)(tmp0+8))&0xFF);
            *((UInt32 *)(tmp0+8))+=0x10;
            *((UInt32 *)tmp0)+=2;
          }
          tmp2=*((UInt32 *)(tmp0+4))&0xFF;
          *((UInt32 *)(tmp0+4))=*((UInt32 *)(tmp0+4))>>8;
          *((UInt32 *)(tmp0+8))+=0xFFFFFFF8;
          var10=tmp2;
          Sub_WavUnp9(tmp2,base);
          if(*((UInt32 *)base)==0) {
            tmp2=*((UInt32 *)(base+tmp2*4+0x306C));
            if(tmp2) {
                while(tmp2) {
                  tmp3=*((UInt32 *)(tmp2+0xC));
                  tmp3++;
                  *((UInt32 *)(tmp2+0xC))=tmp3;
                  tmp0=tmp2;
                  tmp5=tmp3;
                  while(1) {
                      tmp4=*((UInt32 *)(tmp0+4));
                      if((SInt32)tmp4<0) {
                        tmp4=0;
                      }
                      if(tmp4) {
                        if(*((UInt32 *)(tmp4+0xC))<tmp5) {
                            tmp0=tmp4;
                        }
                        else {
                            break;
                        }
                      } else {
                        break;
                      }
                  }
                  if(tmp0!=tmp2) {
                      Sub_WavUnp4(tmp0,2,tmp2,base+0x305C);
                      Sub_WavUnp4(tmp2,2,tmp4,base+0x305C);
                      tmp3=*((UInt32 *)(tmp0+0x10));
                      tmp5=*((UInt32 *)(tmp3+0x14));
                      tmp3=*((UInt32 *)(tmp2+0x10));
                      if(*((UInt32 *)(tmp3+0x14))==tmp2) {
                        *((UInt32 *)(tmp3+0x14))=tmp0;
                      }
                      if(tmp5==tmp0) {
                        tmp5=*((UInt32 *)(tmp0+0x10));
                        *((UInt32 *)(tmp5+0x14))=tmp2;
                      }
                      tmp3=*((UInt32 *)(tmp2+0x10));
                      *((UInt32 *)(tmp2+0x10))=*((UInt32 *)(tmp0+0x10));
                      *((UInt32 *)(tmp0+0x10))=tmp3;
                      *((UInt32 *)(base+4))+=1;
                  }
                  tmp2=*((UInt32 *)(tmp2+0x10));
                }
                tmp5=var10;
                tmp0=work_buff;
            }
            else {
                tmp5=var10;
            }
          }
          else {
            tmp5=var10;
          }
      }
      tmp3=varc;
      if(tmp5!=0x100) {
          size_out--;
          *((UInt8 *)varc)=(UInt8)tmp5&0xFF;
          tmp3++;
          varc=tmp3;
          if(size_out) {
            if(*((UInt32 *)base)) {
                tmp3=*((UInt32 *)(base+tmp5*4+0x306C));
                Sub_WavUnp10(tmp3,base);
            }
          } else {
            return tmp3-buf_out;
          }
      }
      else {
          return tmp3-buf_out;
      }
    }
}

/**
**
*/
void Sub_WavUnp1(UInt32 arg1, UInt32 base)
{
    UInt32 var_4,var_8,var_c;
    UInt32 tmp0,tmp1,tmp2,tmp3,tmp4;
    SInt32 i;

    while((SInt32)*((UInt32 *)(base+0x3064))>0) {       
      tmp0=Sub_WavUnp2(0,*((UInt32 *)(base+0x3050)),*((UInt32 *)(base+0x3064)));
      if(*((UInt32 *) tmp0)) {
          Sub_WavUnp3(tmp0);
      }
      tmp2=base+0x3054;
      *((UInt32 *)(tmp0))=tmp2;
      *((UInt32 *)(tmp0+4))=*((UInt32 *)(tmp2+4));
      tmp3=*((UInt32 *)(tmp2+4));
      if((SInt32)tmp3<=0) {
          tmp3=~tmp3;
      }
      tmp3=Sub_WavUnp2(0,*((UInt32 *)(base+0x3050)),tmp3);
      *((UInt32 *)tmp3)=(UInt32)tmp0;
      *((UInt32 *)(tmp2+4))=base;
    }
    tmp0=base+0x306c;
    for(i=0x102;i!=0;i--) {
      *((UInt32 *)tmp0)=0;
      tmp0+=4;
    }
    var_c=0;
    var_8=base+0x306C;
    tmp1=(UInt32)wav_table+(((arg1&0xff)<<7)+(arg1&0xff))*2;
    var_4=tmp1;
    tmp0=0;
    while(tmp0<0x100) {
      if(*((UInt8 *)(tmp0+tmp1))) { 
          tmp2=*((UInt32 *)(base+0x3058));
          if((SInt32)tmp2<=0) {
            tmp2=*((UInt32 *)(base+0x3068))*24+base+8;
            *((UInt32 *)(base+0x3068))=*((UInt32 *)(base+0x3068))+1;
          }
          Sub_WavUnp4(tmp2,2,0,base+0x305C);
          *((UInt32 *)(tmp2+0x10))=0;
          *((UInt32 *)(tmp2+0x14))=0;
          *((UInt32 *)var_8)=tmp2;
          *((UInt32 *)(tmp2+8))=tmp0;
          tmp3=*((UInt32 *)(tmp0+tmp1))&0xFF;
          *((UInt32 *)(tmp2+0xC))=tmp3;
          if(tmp3>=var_c) {
            var_c=tmp3;
          } else {
            tmp1=*((UInt32 *)(base+0x3064));
            if((SInt32)tmp1>0) {
                while(tmp1) {
                  if(*((UInt32 *)(tmp1+0xC))<tmp3) {
                      tmp1=*((UInt32 *)(tmp1+4));
                  } else {
                      break;
                  }
                }
            } else {
                tmp1=0;
            }
            arg1=Sub_WavUnp2(0,*((UInt32 *)(base+0x305C)),tmp2);
            if(*((UInt32 *)arg1)) {
                Sub_WavUnp3(arg1);
            }
            if(tmp1) {
                tmp3=Sub_WavUnp2(0,*((UInt32 *)(base+0x305C)),tmp1);
            } else {
                tmp3=base+0x3060;
            }
            tmp4=*((UInt32 *)tmp3);
            *((UInt32 *)arg1)=tmp4;
            *((UInt32 *)(arg1+4))=*((UInt32 *)(tmp4+4));
            tmp1=var_4;
            *((UInt32 *)(tmp4+4))=tmp2;
            *((UInt32 *)tmp3)=arg1;
          }
      }
      var_8+=4;
      tmp0++;
    }
    if(tmp0<0x102) {
      tmp1=base+tmp0*4+0x306C;
      while(tmp0<0x102) {
          tmp2=*((UInt32 *)(base+0x3058));
          if((SInt32)tmp2<=0) {
            tmp2=base+*((UInt32 *)(base+0x3068))*24+8;
            *((UInt32 *)(base+0x3068))=*((UInt32 *)(base+0x3068))+1;
          }
          Sub_WavUnp4(tmp2,1,0,base+0x305C);
          tmp1+=4;
          *((UInt32 *)(tmp2+0x10))=0;
          *((UInt32 *)(tmp2+0x14))=0;
          *((UInt32 *)(tmp1-4))=tmp2;
          *((UInt32 *)(tmp2+8))=tmp0;
          tmp0++;
          *((UInt32 *)(tmp2+0xC))=1;
      }
    }
    tmp0=*((UInt32 *)(base+0x3064));
    if((SInt32)tmp0<=0) {
      tmp0=0;
    }
    while(tmp0) {
      tmp1=*((UInt32 *)(tmp0+4));
      if((SInt32)tmp1<=0) {
          tmp1=0;
      }
      arg1=tmp1;
      if(tmp1) {
          tmp2=*((UInt32 *)(base+0x3058));
          if((SInt32)tmp2<=0) {
            tmp2=base+*((UInt32 *)(base+0x3068))*24+8;
            *((UInt32 *)(base+0x3068))=*((UInt32 *)(base+0x3068))+1;
          }
          Sub_WavUnp4(tmp2,2,0,base+0x305C);
          *((UInt32 *)(tmp2+0x10))=0;
          *((UInt32 *)(tmp2+0x14))=0;
          *((UInt32 *)(tmp2+0x14))=tmp0;
          *((UInt32 *)(tmp2+0xC))=*((UInt32 *)(tmp1+0xC))+*((UInt32 *)(tmp0+0xC));
          *((UInt32 *)(tmp0+0x10))=tmp2;
          *((UInt32 *)(tmp1+0x10))=tmp2;
          tmp3=*((UInt32 *)(tmp2+0xC));
          if(tmp3>=var_c) {
            var_c=tmp3;
          } else {
            tmp1=*((UInt32 *)(tmp1+4));
            tmp0=tmp1;
            if((SInt32)tmp0<=0) {
                tmp0=0;
            }
            while(tmp0) {
                if(*((UInt32 *)(tmp0+0xC))<tmp3) {
                  tmp0=*((UInt32 *)(tmp0+4));
                  if((SInt32)tmp0<=0) {
                      tmp0=0;
                  }
                }
                else {
                  break;
                }
            }
            tmp1=Sub_WavUnp2(0,*((UInt32 *)(base+0x305C)),tmp2);
            if(*((UInt32 *)(tmp1))) {
                tmp3=Sub_WavUnp5(tmp1);
                *((UInt32 *)(tmp3))=*((UInt32 *)(tmp1));
                tmp4=*((UInt32 *)tmp1);
                *((UInt32 *)(tmp4+4))=*((UInt32 *)(tmp1+4));
                *((UInt32 *)tmp1)=0;
                *((UInt32 *)(tmp1+4))=0;
            }
            if(tmp0) {
                tmp3=Sub_WavUnp2(0,*((UInt32 *)(base+0x305C)),tmp0);
            } else {
                tmp3=base+0x3060;
            }
            tmp4=*((UInt32 *)(tmp3));
            *((UInt32 *)(tmp1))=tmp4;
            *((UInt32 *)(tmp1+4))=*((UInt32 *)(tmp4+4));
            *((UInt32 *)(tmp4+4))=tmp2;
            *((UInt32 *)(tmp3))=tmp1;
            tmp1=arg1;
          }
          tmp0=*((UInt32 *)(tmp1+4));
          if((SInt32)tmp0<=0) {
            tmp0=0;
          }
      } else {
          break;
      }
    }
    *((UInt32 *)(base+4))=1;
    return;
}

/**
**
*/
void Sub_WavUnp9(UInt32 arg1, UInt32 arg2)
{
    UInt32 var4,var8,tmp0,tmp1,tmp2,tmp3,tmp4;

    tmp0=*((UInt32 *)(arg2+0x3064));
    if((SInt32)tmp0<0) {
      tmp0=0;
    }
    tmp2=*((UInt32 *)(arg2+0x3058));
    if((SInt32)tmp2<0) {
      tmp2=0;
    }
    var4=arg2;
    if(tmp2==0) {
      tmp2=var4+*((UInt32 *)(var4+0x3068))*24+8;
      *((UInt32 *)(var4+0x3068))+=1;
    }
    var8=arg2+0x305C;
    tmp1=Sub_WavUnp2(0,*((UInt32 *)var8),tmp2);
    if(*((UInt32 *)tmp1)) {
      tmp3=Sub_WavUnp5(tmp1);
      *((UInt32 *)tmp3)=*((UInt32 *)tmp1);
      tmp3=*((UInt32 *)tmp1);
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp1+4));
      *((UInt32 *)tmp1)=0;
      *((UInt32 *)(tmp1+4))=0;
    }
    *((UInt32 *)tmp1)=var8+4;
    *((UInt32 *)(tmp1+4))=*((UInt32 *)(var8+8));
    tmp3=Sub_WavUnp2(0,*((UInt32 *)var8),Sub_WavUnp7(var8+4));
    *((UInt32 *)tmp3)=tmp1;
    *((UInt32 *)(var8+8))=tmp2;
    *((UInt32 *)(tmp2+0x10))=0;
    *((UInt32 *)(tmp2+0x14))=0;
    *((UInt32 *)(tmp2+8))=*((UInt32 *)(tmp0+8));
    *((UInt32 *)(tmp2+0xC))=*((UInt32 *)(tmp0+0xC));
    *((UInt32 *)(tmp2+0x10))=tmp0;
    *((UInt32 *)(var4+*((UInt32 *)(tmp0+8))*4+0x306C))=tmp2;
    tmp2=*((UInt32 *)(var4+0x3058));
    if((SInt32)tmp2<0) {
      tmp2=0;
    }
    if(tmp2==0)   {
      tmp2=var4+*((UInt32 *)(var4+0x3068))*24+8;
      *((UInt32 *)(var4+0x3068))+=1;
    }
    tmp1=Sub_WavUnp2(0,*((UInt32 *)var8),tmp2);
    if(*((UInt32 *)tmp1)) {
      tmp3=Sub_WavUnp5(tmp1);
      *((UInt32 *)tmp3)=*((UInt32 *)tmp1);
      tmp3=*((UInt32 *)tmp1);
      *((UInt32 *)(tmp3+4))=*((UInt32 *)(tmp1+4));
      *((UInt32 *)tmp1)=0;
      *((UInt32 *)(tmp1+4))=0;
    }
    *((UInt32 *)tmp1)=var8+4;
    *((UInt32 *)(tmp1+4))=*((UInt32 *)(var8+8));
    tmp3=Sub_WavUnp2(0,*((UInt32 *)var8),Sub_WavUnp7(var8+4));
    *((UInt32 *)tmp3)=tmp1;
    tmp3=arg1;
    *((UInt32 *)(var8+8))=tmp2;
    *((UInt32 *)(tmp2+0x14))=0;
    *((UInt32 *)(tmp2+8))=tmp3;
    *((UInt32 *)(tmp2+0xC))=0;
    *((UInt32 *)(tmp2+0x10))=tmp0;
    *((UInt32 *)(var4+tmp3*4+0x306C))=tmp2;
    *((UInt32 *)(tmp0+0x14))=tmp2;
    while(tmp2) {
      tmp4=tmp2;
      *((UInt32 *)(tmp2+0xC))+=1;
      tmp3=*((UInt32 *)(tmp2+0xC));
      while(1) {
          tmp1=*((UInt32 *)(tmp4+4));
          if((SInt32)tmp1<=0) {
            tmp1=0;
            break;
          }
          if(*((UInt32 *)(tmp1+0xC))>=tmp3) {
            break;
          }
          tmp4=tmp1;
      }
      if(tmp4!=tmp2) {
          Sub_WavUnp4(tmp4,2,tmp2,var8);
          Sub_WavUnp4(tmp2,2,tmp1,var8);
          tmp3=*((UInt32 *)(tmp4+0x10));
          tmp1=*((UInt32 *)(tmp2+0x10));
          tmp0=*((UInt32 *)(tmp3+0x14));
          tmp3=*((UInt32 *)(tmp1+0x14));
          if(tmp3==tmp2) {
            *((UInt32 *)(tmp1+0x14))=tmp4;
          }
          if(tmp0==tmp4) {
            tmp1=*((UInt32 *)(tmp4+0x10));
            *((UInt32 *)(tmp1+0x14))=tmp2;
          }
          tmp3=*((UInt32 *)(tmp2+0x10));
          *((UInt32 *)(tmp2+0x10))=*((UInt32 *)(tmp4+0x10));
          *((UInt32 *)(tmp4+0x10))=tmp3;
          *((UInt32 *)(var4+4))+=1;
      }
      tmp2=*((UInt32 *)(tmp2+0x10));
    }
    return;
}

/**
**
*/
void Sub_WavUnp6(UInt32 ptr_base)
{
    UInt32 ptr1;
    SInt32 i;

    ptr1=ptr_base+8;                      
    for(i=0x203;i!=0;i--) {         
      *((UInt32 *)ptr1)=0;
      *((UInt32 *)(ptr1+4))=0;
      ptr1+=0x18;                   
    }
    ptr1=ptr_base+0x3054;
    *((UInt32 *)ptr1)=0;
    *((UInt32 *)(ptr1+4))=0;
    *((UInt32 *)ptr1)=ptr1;
    *((UInt32 *)(ptr_base+0x3050))=0;
    *((UInt32 *)(ptr_base+0x3058))=~ptr1;
    ptr1=ptr_base+0x3060;
    *((UInt32 *)ptr1)=0;
    *((UInt32 *)(ptr1+4))=0;
    *((UInt32 *)ptr1)=(UInt32) ptr1;
    *((UInt32 *)(ptr_base+0x305C))=0;
    *((UInt32 *)(ptr_base+0x3064))=~ptr1;
    *((UInt32 *)(ptr_base+0x3068))=0;
    *((UInt32 *)(ptr_base+4))=1;
    return;
}

/**
**
*/
UInt32 Sub_WavUnp2(UInt32 arg1, UInt32 arg2, UInt32 arg3)
{
    if(arg1) {
      return arg3+arg2;
    }
    return arg3;
}
         
/**
**
*/
void Sub_WavUnp3(UInt32 ptr)  
{
    UInt32 ptr0,ptr1;

    ptr0=*((UInt32 *)ptr);
    if(ptr0) {
      ptr1=*((UInt32 *)(ptr+4));
      if((SInt32)ptr1<0) {
          ptr1=~ptr1;
      } else {
          ptr1=ptr1+ptr-*((UInt32 *)(ptr0+4));
      }
      *((UInt32 *)ptr1)=ptr0;
      *((UInt32 *)(ptr0+4))=*((UInt32 *)(ptr+4));
      *((UInt32 *)ptr)=0;
      *((UInt32 *)(ptr+4))=0;
    }
    return;
}
            
/**
**
*/
void Sub_WavUnp4(UInt32 arg1, UInt32 arg2, UInt32 arg3, UInt32 arg4)
{
    UInt32 tmp0,tmp1;

    tmp0=*((UInt32 *)arg1);
    if(tmp0) {
      tmp1=*((UInt32 *)(arg1+4));
      if((SInt32)tmp1<0) {
          tmp1=~tmp1;
      } else {
          tmp1+=arg1-*((UInt32 *)(tmp0+4));
      }
      *((UInt32 *)tmp1)=(UInt32)tmp0;
      *((UInt32 *)(tmp0+4))=*((UInt32 *)(arg1+4));
      *((UInt32 *)arg1)=0;
      *((UInt32 *)(arg1+4))=0;
    }
    if(arg3==0) {
      arg3=arg4+4;
    }
    if(arg2-1) {
      if((arg2-2)==0) {
          tmp1=*((UInt32 *)arg3);
          *((UInt32 *)arg1)=tmp1;
          *((UInt32 *)(arg1+4))=*((UInt32 *)(tmp1+4));
          *((UInt32 *)(tmp1+4))=arg1;
          *((UInt32 *)arg3)=arg1;
      }
      return;
    }
    *((UInt32 *)arg1)=arg3;
    *((UInt32 *)(arg1+4))=*((UInt32 *)(arg3+4));
    tmp1=*((UInt32 *)(arg3+4));
    if((SInt32)tmp1<=0) {
      tmp1=~tmp1;
    }
    *((UInt32 *)tmp1)=arg1;
    *((UInt32 *)(arg3+4))=arg1;
    return;
}

/**
**
*/
UInt32 Sub_WavUnp5(UInt32 arg1)
{
    UInt32 tmp0,tmp1;

    tmp0=*((UInt32 *)(arg1+4));
    if((SInt32)tmp0<0) {
      return ~tmp0;
    }
    tmp1=*((UInt32 *)arg1);
    tmp0+=arg1-*((UInt32 *)(tmp1+4));
    return tmp0;
}

/**
**
*/
UInt32 Sub_WavUnp7(UInt32 arg1)
{
    UInt32 tmp;

    tmp=*((UInt32 *)(arg1+4));
    if((SInt32)tmp<=0) {
      return ~tmp;
    }
    return tmp;
}

/**
**
*/
UInt32 Sub_WavUnp8(UInt32 arg1)
{
    UInt32 tmp0,tmp1;

    tmp0=*((UInt32 *)(arg1+4));
    *((UInt32 *)(arg1+4))=tmp0>>1;
    tmp0&=1;
    *((UInt32 *)(arg1+8))-=1;
    if(*((UInt32 *)(arg1+8))==0) {
      tmp1=*((UInt32 *)arg1);
      *((UInt32 *)arg1)+=4;
      *((UInt32 *)(arg1+4))=*((UInt32 *)tmp1);
      *((UInt32 *)(arg1+8))=0x20;
    }
    return tmp0;
}

/**
**
*/
void Sub_WavUnp10(UInt32 arg1, UInt32 arg2)
{
    UInt32 tmp0,tmp1,tmp2,tmp3,arg2_old;

    arg2_old=arg2;
    while(arg1) {
      tmp2=arg1;
      *((UInt32 *)(arg1+0xC))+=1;
      tmp3=*((UInt32 *)(arg1+0xC));
      while(1) {
          tmp0=*((UInt32 *)(tmp2+4));
          if((SInt32)tmp0<=0) {
            tmp0=0;
            break;
          }
          if(*((UInt32 *)(tmp0+0xC))>=tmp3) {
            break;
          }
          tmp2=tmp0;
      }
      if(tmp2!=arg1) {
          if(*((UInt32 *)tmp2)) {
            tmp3=Sub_WavUnp5(tmp2);
            *((UInt32 *)tmp3)=*((UInt32 *)tmp2);
            tmp1=*((UInt32 *)tmp2);
            *((UInt32 *)(tmp1+4))=*((UInt32 *)(tmp2+4));
            *((UInt32 *)tmp2)=0;
            *((UInt32 *)(tmp2+4))=0;
          }
          tmp1=arg1;
          if(tmp1==0) {
            tmp1=arg2+0x3060;
          }
          tmp3=*((UInt32 *)tmp1);
          *((UInt32 *)tmp2)=tmp3;
          *((UInt32 *)(tmp2+4))=*((UInt32 *)(tmp3+4));
          *((UInt32 *)tmp1)=tmp2;
          arg2=Sub_WavUnp2(0,*((UInt32 *)(arg2+0x205C)),arg1);
          if(*((UInt32 *)arg2)) {
            tmp3=Sub_WavUnp5(arg2);
            *((UInt32 *)tmp3)=*((UInt32 *)arg2);
            tmp1=*((UInt32 *)arg2);
            *((UInt32 *)(tmp1+4))=*((UInt32 *)(arg2+4));
            *((UInt32 *)arg2)=0;
            *((UInt32 *)(arg2+4))=0;
          }
          if(tmp0) {
            tmp3=Sub_WavUnp2(0,*((UInt32 *)(arg2_old+0x305C)),tmp0);
          } else {
            tmp3=arg2_old+0x3060;
          }
          tmp1=*((UInt32 *)tmp3);
          *((UInt32 *)arg2)=tmp1;
          tmp0=*((UInt32 *)(tmp1+4));
          *((UInt32 *)(arg2+4))=tmp0;
          *((UInt32 *)(tmp1+4))=arg1;
          *((UInt32 *)tmp3)=arg2;
          tmp3=*((UInt32 *)(tmp2+0x10));
          tmp1=*((UInt32 *)(tmp3+0x14));
          tmp3=*((UInt32 *)(arg1+0x10));
          if(*((UInt32 *)(tmp3+0x14))==arg1) {
            *((UInt32 *)(tmp3+0x14))=tmp2;
          }
          if(tmp1==tmp2) {
            tmp1=*((UInt32 *)(tmp2+0x10));
            *((UInt32 *)(tmp1+0x14))=arg1;
          }
          tmp3=*((UInt32 *)(arg1+0x10));
          *((UInt32 *)(arg1+0x10))=*((UInt32 *)(tmp2+0x10));
          *((UInt32 *)(tmp2+0x10))=tmp3;
          arg2=arg2_old;
          *((UInt32 *)(arg2_old+4))+=1;
      }
      arg1=*((UInt32 *)(arg1+0x10));
    }
    return;
}


const unsigned char dcl_table[] =
{
    0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06,
    0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
    0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07,
    0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
    0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
    0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
    0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
    0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
    0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E,
    0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A,
    0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02,
    0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C,
    0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04,
    0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08,
    0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10,
    0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00,
    0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00,
    0x08, 0x00, 0x0A, 0x00, 0x0E, 0x00, 0x16, 0x00,
    0x26, 0x00, 0x46, 0x00, 0x86, 0x00, 0x06, 0x01,
    0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05,
    0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07,
    0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14,
    0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00,
    0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08,
    0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08,
    0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07,
    0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B,
    0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08,
    0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06,
    0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08,
    0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08,
    0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06,
    0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05,
    0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07,
    0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
    0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D,
    0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D,
    0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D,
    0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
    0x90, 0x04, 0xE0, 0x0F, 0xE0, 0x07, 0xE0, 0x0B,
    0xE0, 0x03, 0xE0, 0x0D, 0xE0, 0x05, 0xE0, 0x09,
    0xE0, 0x01, 0xB8, 0x00, 0x62, 0x00, 0xE0, 0x0E,
    0xE0, 0x06, 0x22, 0x00, 0xE0, 0x0A, 0xE0, 0x02,
    0xE0, 0x0C, 0xE0, 0x04, 0xE0, 0x08, 0xE0, 0x00,
    0x60, 0x0F, 0x60, 0x07, 0x60, 0x0B, 0x60, 0x03,
    0x60, 0x0D, 0x60, 0x05, 0x40, 0x12, 0x60, 0x09,
    0x60, 0x01, 0x60, 0x0E, 0x60, 0x06, 0x60, 0x0A,
    0x0F, 0x00, 0x50, 0x02, 0x38, 0x00, 0x60, 0x02,
    0x50, 0x00, 0x60, 0x0C, 0x90, 0x03, 0xD8, 0x00,
    0x42, 0x00, 0x02, 0x00, 0x58, 0x00, 0xB0, 0x01,
    0x7C, 0x00, 0x29, 0x00, 0x3C, 0x00, 0x98, 0x00,
    0x5C, 0x00, 0x09, 0x00, 0x1C, 0x00, 0x6C, 0x00,
    0x2C, 0x00, 0x4C, 0x00, 0x18, 0x00, 0x0C, 0x00,
    0x74, 0x00, 0xE8, 0x00, 0x68, 0x00, 0x60, 0x04,
    0x90, 0x00, 0x34, 0x00, 0xB0, 0x00, 0x10, 0x07,
    0x60, 0x08, 0x31, 0x00, 0x54, 0x00, 0x11, 0x00,
    0x21, 0x00, 0x17, 0x00, 0x14, 0x00, 0xA8, 0x00,
    0x28, 0x00, 0x01, 0x00, 0x10, 0x03, 0x30, 0x01,
    0x3E, 0x00, 0x64, 0x00, 0x1E, 0x00, 0x2E, 0x00,
    0x24, 0x00, 0x10, 0x05, 0x0E, 0x00, 0x36, 0x00,
    0x16, 0x00, 0x44, 0x00, 0x30, 0x00, 0xC8, 0x00,
    0xD0, 0x01, 0xD0, 0x00, 0x10, 0x01, 0x48, 0x00,
    0x10, 0x06, 0x50, 0x01, 0x60, 0x00, 0x88, 0x00,
    0xA0, 0x0F, 0x07, 0x00, 0x26, 0x00, 0x06, 0x00,
    0x3A, 0x00, 0x1B, 0x00, 0x1A, 0x00, 0x2A, 0x00,
    0x0A, 0x00, 0x0B, 0x00, 0x10, 0x02, 0x04, 0x00,
    0x13, 0x00, 0x32, 0x00, 0x03, 0x00, 0x1D, 0x00,
    0x12, 0x00, 0x90, 0x01, 0x0D, 0x00, 0x15, 0x00,
    0x05, 0x00, 0x19, 0x00, 0x08, 0x00, 0x78, 0x00,
    0xF0, 0x00, 0x70, 0x00, 0x90, 0x02, 0x10, 0x04,
    0x10, 0x00, 0xA0, 0x07, 0xA0, 0x0B, 0xA0, 0x03,
    0x40, 0x02, 0x40, 0x1C, 0x40, 0x0C, 0x40, 0x14,
    0x40, 0x04, 0x40, 0x18, 0x40, 0x08, 0x40, 0x10,
    0x40, 0x00, 0x80, 0x1F, 0x80, 0x0F, 0x80, 0x17,
    0x80, 0x07, 0x80, 0x1B, 0x80, 0x0B, 0x80, 0x13,
    0x80, 0x03, 0x80, 0x1D, 0x80, 0x0D, 0x80, 0x15,
    0x80, 0x05, 0x80, 0x19, 0x80, 0x09, 0x80, 0x11,
    0x80, 0x01, 0x80, 0x1E, 0x80, 0x0E, 0x80, 0x16,
    0x80, 0x06, 0x80, 0x1A, 0x80, 0x0A, 0x80, 0x12,
    0x80, 0x02, 0x80, 0x1C, 0x80, 0x0C, 0x80, 0x14,
    0x80, 0x04, 0x80, 0x18, 0x80, 0x08, 0x80, 0x10,
    0x80, 0x00, 0x00, 0x1F, 0x00, 0x0F, 0x00, 0x17,
    0x00, 0x07, 0x00, 0x1B, 0x00, 0x0B, 0x00, 0x13,
    0xA0, 0x0D, 0xA0, 0x05, 0xA0, 0x09, 0xA0, 0x01,
    0xA0, 0x0E, 0xA0, 0x06, 0xA0, 0x0A, 0xA0, 0x02,
    0xA0, 0x0C, 0xA0, 0x04, 0xA0, 0x08, 0xA0, 0x00,
    0x20, 0x0F, 0x20, 0x07, 0x20, 0x0B, 0x20, 0x03,
    0x20, 0x0D, 0x20, 0x05, 0x20, 0x09, 0x20, 0x01,
    0x20, 0x0E, 0x20, 0x06, 0x20, 0x0A, 0x20, 0x02,
    0x20, 0x0C, 0x20, 0x04, 0x20, 0x08, 0x20, 0x00,
    0xC0, 0x0F, 0xC0, 0x07, 0xC0, 0x0B, 0xC0, 0x03,
    0xC0, 0x0D, 0xC0, 0x05, 0xC0, 0x09, 0xC0, 0x01,
    0xC0, 0x0E, 0xC0, 0x06, 0xC0, 0x0A, 0xC0, 0x02,
    0xC0, 0x0C, 0xC0, 0x04, 0xC0, 0x08, 0xC0, 0x00,
    0x40, 0x0F, 0x40, 0x07, 0x40, 0x0B, 0x40, 0x03,
    0x00, 0x03, 0x40, 0x0D, 0x00, 0x1D, 0x00, 0x0D,
    0x00, 0x15, 0x40, 0x05, 0x00, 0x05, 0x00, 0x19,
    0x00, 0x09, 0x40, 0x09, 0x00, 0x11, 0x00, 0x01,
    0x00, 0x1E, 0x00, 0x0E, 0x40, 0x01, 0x00, 0x16,
    0x00, 0x06, 0x00, 0x1A, 0x40, 0x0E, 0x40, 0x06,
    0x40, 0x0A, 0x00, 0x0A, 0x00, 0x12, 0x00, 0x02,
    0x00, 0x1C, 0x00, 0x0C, 0x00, 0x14, 0x00, 0x04,
    0x00, 0x18, 0x00, 0x08, 0x00, 0x10, 0x00, 0x00
};

local const UInt8 wav_table[2512] =
{
    0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
    0x00, 0x00, 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08,
    0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04,
    0x03, 0x05, 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09,
    0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02,
    0x02, 0x02, 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04,
    0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03,
    0x02, 0x02, 0x09, 0x06, 0x04, 0x04, 0x04, 0x04,
    0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03,
    0x02, 0x04, 0x08, 0x03, 0x04, 0x07, 0x09, 0x05,
    0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03,
    0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02,
    0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x02, 0x02, 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07,
    0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02,
    0x03, 0x03, 0x04, 0x03, 0x07, 0x07, 0x09, 0x06,
    0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02,
    0x02, 0x02, 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02,
    0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05,
    0x02, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01,
    0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08,
    0x0C, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x03, 0x04, 0x01, 0x02, 0x04, 0x05, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02,
    0x06, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00,
    0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01,
    0x06, 0x0E, 0x10, 0x04, 0x06, 0x08, 0x05, 0x04,
    0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01,
    0x01, 0x02, 0x01, 0x01, 0x01, 0x04, 0x02, 0x04,
    0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01,
    0x02, 0x03, 0x03, 0x02, 0x03, 0x01, 0x03, 0x06,
    0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
    0x01, 0x02, 0x01, 0x01, 0x01, 0x29, 0x07, 0x16,
    0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03,
    0x17, 0x10, 0x26, 0x2A, 0x10, 0x01, 0x23, 0x23,
    0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x0B,
    0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02,
    0x02, 0x01, 0x04, 0x02, 0x01, 0x03, 0x09, 0x01,
    0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x05, 0x01,
    0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x04,
    0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x05, 0x02,
    0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01,
    0x01, 0x02, 0x01, 0x02, 0x03, 0x03, 0x01, 0x03,
    0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03,
    0x05, 0x01, 0x03, 0x01, 0x03, 0x03, 0x02, 0x01,
    0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,
    0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07,
    0x02, 0x17, 0x01, 0x05, 0x01, 0x01, 0x0E, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x02,
    0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01,
    0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01,
    0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x00, 0x00,
    0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64,
    0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B,
    0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88,
    0x80, 0x82, 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B,
    0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41,
    0x37, 0x37, 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21,
    0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10,
    0x0D, 0x0D, 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08,
    0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04,
    0x19, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xC3, 0xCB, 0xF5, 0x41,
    0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xBF, 0xCC, 0xF2, 0x40,
    0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x7A, 0x46, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xD9,
    0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB,
    0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0xD9,
    0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE,
    0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6C,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18,
    0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10,
    0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15,
    0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18,
    0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11,
    0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15,
    0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x33, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x50, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x4D, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00,
    0x80, 0x00, 0x00, 0x00, 0x9A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x3A, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x00, 0x00,
    0x46, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00,
    0x60, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00,
    0x7A, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00,
    0x93, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00,
    0xAD, 0x00, 0x00, 0x00, 0xBA, 0x00, 0x00, 0x00,
    0xC6, 0x00, 0x00, 0x00, 0xD3, 0x00, 0x00, 0x00,
    0xE0, 0x00, 0x00, 0x00, 0xED, 0x00, 0x00, 0x00,
    0xFA, 0x00, 0x00, 0x00, 0x06, 0x01, 0x00, 0x00
};

local const UInt32 small_tbl1[90] =
{
    0x7,    0x8,  0x9,  0xA,  0xB,  0xC,  0xD,  0xE,  0x10, 0x11,
    0x13,   0x15, 0x17, 0x19, 0x1C, 0x1F, 0x22, 0x25, 0x29, 0x2D,
    0x32,   0x37, 0x3C, 0x42, 0x49, 0x50, 0x58, 0x61, 0x6B, 0x76,
    0x82,   0x8F, 0x9D, 0xAD, 0xBE, 0xD1, 0xE6, 0xFD, 0x117,      0x133,
    0x151,  0x173,      0x198,      0x1C1,      0x1EE,      0x220,      0x256,      0x292,      0x2D4,      0x31C,
    0x36C,  0x3C3,      0x424,      0x48E,      0x502,      0x583,      0x610,      0x6AB,      0x756,      0x812,
    0x8E0,  0x9C3,      0xABD,      0xBD0,      0xCFF,      0xE4C,      0xFBA,      0x114C,     0x1307,     0x14EE,
    0x1706, 0x1954,     0x1BDC,     0x1EA5,     0x21B6,     0x2515,     0x28CA,     0x2CDF,     0x315B,     0x364B,
    0x3BB9, 0x41B2,     0x4844,     0x4F7E,     0x5771,     0x602F,     0x69CE,     0x7462,     0x7FFF,     0x0
};

local const UInt32 small_tbl2[32] =
{
    0xFFFFFFFF, 0x0, 0xFFFFFFFF, 0x4, 0xFFFFFFFF, 0x2, 0xFFFFFFFF, 0x6,
    0xFFFFFFFF, 0x1, 0xFFFFFFFF, 0x5, 0xFFFFFFFF, 0x3, 0xFFFFFFFF, 0x7,
    0xFFFFFFFF, 0x1, 0xFFFFFFFF, 0x5, 0xFFFFFFFF, 0x3, 0xFFFFFFFF, 0x7,
    0xFFFFFFFF, 0x2, 0xFFFFFFFF, 0x4, 0xFFFFFFFF, 0x6, 0xFFFFFFFF, 0x8
};

Generated by  Doxygen 1.6.0   Back to index