ttunpack.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /******************************************************************************
  2. *
  3. * project name: TIGCC Tools Suite
  4. * file name: ttunpack.h
  5. * initial date: 01/02/2001
  6. * authors: thomas.nussbaumer@gmx.net
  7. * samuel@nyall.net
  8. *
  9. * description: defines for exepack functionalities including unpack routine
  10. * (complete rewrite of TIGCC Tools Suite header file)
  11. *
  12. * This is a 100% assembly version of the ttunpack routine, which is
  13. * based on code by Pasi 'Albert' Ojala, albert@cs.tut.fi, then
  14. * reduced by Thomas Nussbaumer to fit his needs. For a full details
  15. * on the algorithm see:
  16. *
  17. * http://www.cs.tut.fi/~albert/Dev/pucrunch/index.html
  18. *
  19. *
  20. * Liscense:
  21. *
  22. * The liscense is quite similar to that of the origional version in c.
  23. *
  24. * The code may be freely used in any non commercial application. If
  25. * you do use it please give credit to tict (http://tict.ticalc.org) and
  26. * myself (Samuel Stearley). I state this as a request but it is actually
  27. * not.
  28. *
  29. * The author(s) (Samuel/Tict/Any other contributor) make no
  30. * representations or warranties about the suitability of the software,
  31. * either express or implied. The author(s) shall not be liable for
  32. * any damages suffered as a result of using or distributing this
  33. * software.
  34. *
  35. * If you distribute this file on a website or as part of
  36. * the source of a project do not remove the liscense from this file.
  37. *
  38. *
  39. * $Id: ttunpack.h,v 1.1 2006-02-28 23:36:58 kevinkofler Exp $
  40. *
  41. ******************************************************************************/
  42. #ifndef __TTUNPACK_H__
  43. #define __TTUNPACK_H__
  44. typedef struct {
  45. unsigned char osize_lo; // original size lowbyte
  46. unsigned char osize_hi; // original size highbyte
  47. unsigned char magic1; // must be equal to TTUNPACK_MAGIC1
  48. unsigned char magic2; // must be equal to TTUNPACK_MAGIC2
  49. unsigned char csize_lo; // compressed size lowbyte
  50. unsigned char csize_hi; // compressed size lowbyte
  51. unsigned char esc1; // escape >> (8-escBits)
  52. unsigned char notused3;
  53. unsigned char notused4;
  54. unsigned char esc2; // escBits
  55. unsigned char gamma1; // maxGamma + 1
  56. unsigned char gamma2; // (1<<maxGamma)
  57. unsigned char extralz; // extraLZPosBits
  58. unsigned char notused1;
  59. unsigned char notused2;
  60. unsigned char rleentries; // rleUsed
  61. } TTUNPACK_HEADER;
  62. #define TTUNPACK_MAGIC1 0x54
  63. #define TTUNPACK_MAGIC2 0x50
  64. #define ttunpack_size(_p_) ((unsigned short)(((TTUNPACK_HEADER*)(_p_))->osize_lo | (((TTUNPACK_HEADER*)(_p_))->osize_hi << 8)))
  65. #define ttunpack_valid(_p_) (((TTUNPACK_HEADER*)(_p_))->magic1 == TTUNPACK_MAGIC1 && ((TTUNPACK_HEADER*)(_p_))->magic2 == TTUNPACK_MAGIC2)
  66. #define TTUNPACK_OKAY 0
  67. #define TTUNPACK_NOESCFOUND 248
  68. #define TTUNPACK_ESCBITS 249
  69. #define TTUNPACK_MAXGAMMA 250
  70. #define TTUNPACK_EXTRALZP 251
  71. #define TTUNPACK_NOMAGIC 252
  72. #define TTUNPACK_OUTBUFOVERRUN 253
  73. #define TTUNPACK_LZPOSUNDERRUN 254
  74. #define ttunpack_decompress ((unsigned short(*)(unsigned char*,unsigned char*))(unsigned short[])\
  75. {\
  76. 0x48e7,0x1f3e,0x1a2b,0x0006,0x7e80,0x7008,0x548b,0x0c5b,0x5450,0x661c,\
  77. 0x5a8b,0x181b,0xb800,0x6214,0x0c5b,0x0880,0x660e,0xd02b,0x0003,0x43f3,\
  78. 0x08fc,0x0c13,0x0005,0x6512,0x4cdf,0x7cf8,0x4e75,0x6136,0xc145,0x7208,\
  79. 0x9204,0x613e,0x10c0,0x612a,0xb005,0x66f2,0x613c,0x3600,0x5340,0x6746,\
  80. 0x6134,0x5200,0x67da,0x5500,0x1213,0x6122,0x7207,0x6114,0x4600,0x4480,\
  81. 0x10f0,0x08ff,0x51cb,0xfffa,0x60d4,0x1204,0x7000,0x600a,0xe31f,0x6402,\
  82. 0x1c19,0xdc06,0xd140,0x5301,0x6af2,0x44c0,0x4e75,0x7406,0x61ea,0x54ca,\
  83. 0xfffc,0x7206,0x9242,0x7001,0x60e8,0x61dc,0x64c2,0x61d8,0x6498,0x61e6,\
  84. 0x1600,0x6a0c,0x61ce,0x3f00,0x61dc,0x5300,0x1e80,0x361f,0x61d4,0x5502,\
  85. 0x6b06,0x1033,0x0003,0x6004,0x7202,0x61b4,0x10c0,0x7000,0x60a2})
  86. #endif
  87. //=============================================================================
  88. // Revision History
  89. //=============================================================================
  90. //
  91. // $Log: not supported by cvs2svn $
  92. //
  93. // Revision 2.0 2004/08/30 12:00:00 Samuel Stearley
  94. // New extraction routine in 100% asm.
  95. //
  96. // Revision 1.4 2002/03/28 21:17:28 tnussb
  97. // project name in header changed to TIGCC Tools Suite
  98. //
  99. // Revision 1.3 2002/03/13 15:09:58 tnussb
  100. // new exepack decompression function generated from old/unpack.c added
  101. // (its a little bit smaller now). The new function should work as the old one,
  102. // but if there are problems I will leave the old hexcode array here, too
  103. //
  104. // Revision 1.2 2001/02/05 20:33:01 Thomas Nussbaumer
  105. // (1) magic of ttunpack header splitted again into 2 bytes to prevent address errors
  106. // (2) new (stable?) pc-relative version of unpacking routine
  107. //
  108. //