home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PACKOBJ / PACKOBJ.DOC < prev    next >
Text File  |  1992-05-07  |  6KB  |  145 lines

  1.         PACKOBJ.DOC  --  The Turbo Pascal Compressing Data Objitizer
  2.  
  3.                         By Wilbert van Leijen
  4.  
  5. Introduction
  6. ────────────
  7.  
  8. PACKOBJ is a program that takes binary data as input, compresses it using
  9. a fast LZW algorithm and converts it to an .OBJ file that you can link in
  10. a Turbo Pascal (TP) program, version 4.0 or later.
  11. TPUNPACK.PAS is the TP unit that takes care of decompressing the data.
  12.  
  13. The PACKOBJ.EXE program and the Turbo Pascal TPUNPACK unit are distributed
  14. as Shareware.  If you use them, you are kindly asked to register this
  15. product.  The fee for becoming a Registered User of PACKOBJ/TPUNPACK is
  16. $15.-- or ƒ25.-- (that's twentyfive Dutch guilders).  Just send a cheque or
  17. money order to the author.  My address is mentioned at the bottom of this
  18. document.
  19.  
  20. Upon registration, you will become a disk with:
  21. -  the source code of the PACKOBJ utility and UNPACK routine
  22. -  3 different customised TP 6.0 Runtime libraries (SYSTEM.TPU):
  23.    one 'Regular Version': 100% compatible with Borland's, but with many
  24.    code enhancements and improved 'smart linking';
  25.    one 'Regular 286 Version', with 286 code throughout, aborts automatically
  26.    when an attempt is made to run a program on an XT-class system; and
  27.    one 'STUB Version', designed especially for crafting ultra compact
  28.    utilities and TSR programs.
  29.  
  30. The STUB version of SYSTEM.TPU was used to compile PACKOBJ.  STUB is a
  31. limited version of the runtime library in the following respects:
  32. it does not support overlays and virtual methods; it doesn't automatically
  33. open/close the text files Input and Output (they are pre-declared, however);
  34. it doesn't take over any interrupts; and it passes control to DOS to do the
  35. allocation and deallocation of data structures on the heap.  STUB will be
  36. accompanied with guidelines for developers.  As a rule, if you're not
  37. deeply into object oriented programming, the majority of your TP programs
  38. will benefit from STUB.  Example: the minimum .EXE size of a program created
  39. with STUB ('begin end.') is only 224 bytes.
  40.  
  41. Using PACKOBJ
  42. ─────────────
  43.  
  44. PACKOBJ's command line is akin to BINOBJ, a utility shipped with every
  45. version of Turbo Pascal since 4.0.  BINOBJ expects you to specify an input
  46. file, an output file and an exported identifier.  PACKOBJ wants you to tell
  47. it:
  48.  
  49. -  the name of the input file; this file can be of any type, whether it is
  50.    an ASCII document, a picture bitmap or whatever.  The only limitation
  51.    here is that it must be smaller than 64 kByte;
  52. -  the name of the output file; this will hold the compressed result and is
  53.    linkable in a TP program;
  54. -  an exported identifier or 'public name': this is the symbol that must
  55.    be specified in order to link the .OBJ file in your TP program.
  56.  
  57. Unlike BINOBJ, the PACKOBJ utility will declare not one but two public
  58. names.  And unlike BINOBJ too, these two public names are callable by your
  59. program, i.e. you don't have to pass a pointer to it to access your data.
  60.  
  61. The public names exported by PACKOBJ are of the format:
  62.  
  63.    Funtion PublicNameSIZE : Integer; Far; External;
  64.    Procedure UNPACKPublicName(Var buffer); Far; External;
  65.  
  66. The PublicNameSIZE will return the size of the unpacked image.  This is
  67. handy if you want to know how many bytes you'll have to allocate on the
  68. heap to hold the result in 'buffer'.
  69.  
  70. UNPACKPublicName does not do any unpacking.  Rather, it pushes a few
  71. parameters on the stack and performs a far call to UNPACK.  UNPACK is
  72. the interfaced procedure of unit TPUNPACK.
  73.  
  74. Note that you must attach the pseudo-type 'Far' to the declaration in
  75. your declaration or alternatively, enable the compiler directive {$F+ }.
  76. Failure to do so will most likely crash your program or the entire system.
  77.  
  78. Sample usage:
  79.    PACKOBJ joltcola.PIC joltcola JoltCola
  80.  
  81. This will take JOLTCOLA.PIC as input, writes JOLTCOLA.OBJ as output.
  82. It will declare the procedure 'UNPACKJoltCola' and function 'JoltColaSIZE'
  83. public.
  84.  
  85. Suppose you have JOLTCOLA.PIC.  This is the raw bitmap of a VGA mode 13h
  86. picture of a cola brand, loved by weary programmers because it promises
  87. 'Twice the Caffeine'.  The picture is 64 kByte big, but we can put the
  88. squeeze on this.  
  89.  
  90. In this case, JoltColaSIZE returns the size of the raw, uncompressed bitmap:
  91. 65520 bytes.  For a straight dump of the picture to the VGA display
  92. however, calling JoltColaSIZE is not needed: the VGA memory is already
  93. there, and unaccessible by TP's heap manager anyway.
  94.  
  95. Using TPUNPACK
  96. ──────────────
  97.  
  98. UNPACKJoltCola calls a Far routine by the name of UNPACK.  This routine is
  99. exported by unit TPUNPACK and it takes care of the actual decompression of
  100. the information.  TPUNPACK is entirely written in assembler and optimised
  101. for speed.  Hence, it uses no more than a mere 474 bytes of code space.
  102.  
  103. Please note that UNPACK's stack requirements are somewhat less modest.
  104. You must reserve 29 kByte of stack space to allow room for UNPACK's work
  105. space.
  106.  
  107. The deal is here that you must include 'uses TpUnpack' under the program
  108. header of your TP application and, specify a memory allocation directive
  109. to allow for 32 kByte or more of stack space.  Example:
  110.  
  111.    {$M 32768, 0, 0 }              { Allocate 32k stack space, no heap }
  112.  
  113. Do not call UNPACK by your application -- unless you know exactly what
  114. you're doing.  UNPACK will be called by the loader code of any .OBJ file
  115. created by PACKOBJ.
  116.  
  117. Running the demo
  118. ────────────────
  119.  
  120. In order to compile and run the demo, you must have the following:
  121. -  Turbo Pascal, version 4.0 or later
  122. -  A VGA display.  (Any VGA display will do.)
  123.  
  124. What you must do:
  125. -  Make TPC.EXE, the Turbo Pascal command line compiler, accessible
  126.    on the DOS path
  127. -  Run JOLTCOLA.BAT
  128.  
  129. Trade Marks
  130. ───────────
  131.  
  132. Turbo Pascal is Copyrighted by Borland International.
  133. PACKOBJ and TPUNPACK are Copyright 1991-92 by Wilbert van Leijen,
  134. Amsterdam, The Netherlands.
  135.  
  136. Author
  137. ──────
  138.  
  139. Wilbert van Leijen
  140. Marathonweg 72-2
  141. NL-1076 TM Amsterdam
  142. The Netherlands
  143.  
  144. Wilbert van.Leijen at Fidonet 2:500/12.10956
  145.