home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d09xx / d0985.lha / NewIFF / NewIFF.ReadMe < prev    next >
Text File  |  1994-04-04  |  12KB  |  280 lines

  1.  
  2.                  NewIFF39: IFF Modules with AA Support
  3.  
  4.  
  5. The NewIFF39 code modules and examples based on iffparse.library are
  6. designed as replacements for the original EA IFF code.  The object code
  7. modules (with source provided) contain many high-level support functions
  8. for reading and writing IFF files and clipboard data, and for loading,
  9. saving, and displaying ILBM files in a 1.3 through 3.0/AA compatible manner.
  10. In some modules, it has been possible to retain much of the original
  11. EA IFF code.  However, most structures and most higher level function
  12. interfaces have changed.
  13.  
  14. On the plus side, these new modules contain many easy-to-use functions
  15. for querying, loading, displaying, and saving ILBMs.  During their
  16. development, modules similar to these have been used inhouse at Commodore
  17. for the Display program and several other ILBM applications.
  18. The screen.c module provides powerful display-opening functions which are
  19. 1.3-compatible yet provide a host of new options under 2.0 and 3.0 such
  20. as centered overscan screens, full-video display clips, border transparency
  21. control, and autoscroll.  This 39.x releases of the NewIFF code also support
  22. V39 and the AA chipset for full 8-bit-per-gun color and AA modes.
  23. Modules are provided for printing (screendump) and for preserving or
  24. adding chunks (copychunks). And the 8SVX example now actually plays samples
  25. and instruments.  In addition, clipboard support is automatic for all
  26. applications that use the IFFP modules because parse.c's openifile()
  27. interprets the filename -c[n] (ie. "-c", "-c1", "-c2", etc.) as clipboard
  28. unit n.
  29.  
  30. All of the applications with the NewIFF code require iffparse.library
  31. which has been part of the OS since Workbench 2.0.  Please note that
  32. the 2.04 Workbench version of iffparse.library is a 1.3-compatible library,
  33. and that all of the modules and examples (with the exception of Save8)
  34. have been designed to take advantage of 2.0/3.0, but also work under 1.3.
  35. Developers who wish to distribute iffparse.library on their commercial
  36. products may execute a 2.0 Workbench license, or may get an amendment to
  37. their 1.3 Workbench license to allow distribution of iffparse.library.
  38.  
  39.  
  40. The NewIFF39 modules contain enhanced code in many areas to take
  41. advantage of 2.0 and 3.0 features while remaining functional under
  42. 1.3 (with 2.04 iffparse.library).  In addition, great effort has been
  43. put into identifying and replacing any code sections which were
  44. inflexible or not upwards compatible.  The code implements 32-bit
  45. CAMG, display database aspect ratios, 8-bit CMAP from 4, 8, or 32-bit
  46. color data, mode fallback when an ILBM's display mode is not available,
  47. overscan centering (except under 1.3) based on the user's closest
  48. Preference setting with display clips properly constrained to maximum
  49. limits, setting of as many colors as the destination can handle,
  50. default detection and adjustment of old 4-bit left-shifted CMAP values,
  51. and built-in support for up to 24 planes of data plus a Mask plane.
  52. Note that currently, the 24 planes plus 1 mask plane limit is hardcoded,
  53. but we expect to make this more flexible in a future release of the code,
  54. perhaps also adding alpha channel support.
  55.  
  56.  
  57. Through the use of tag-like arrays of desired chunk ID's, applications
  58. can control which chunks are gathered by the parsing module.  It is also
  59. possible to clone chunks for rewriting and for applications to add chunks
  60. to written FORMs.  Applications may also pass additional screen tags
  61. to the display-opening module (screen.c) and may control much of this
  62. module's default behavior through flags (see iffp/ilbmapp.h of NewIFF39).
  63.  
  64.  
  65. Most of the high-level function pairs provided in these modules have
  66. been designed to provide safe cleanup for themselves.  For example,
  67. a loadbrush() that succeeds or fails at any point can be cleaned up
  68. via unloadbrush.  The cleanup routines null out the appropriate
  69. pointers so that allocations will not be freed twice.
  70.  
  71.  
  72. All applications use the parse.c module.  The basic steps
  73. for using the parse.c module are:
  74.  
  75.     o Define tag-like arrays of your desired chunks (readers only)
  76.  
  77.     o Allocate one or more [form]Info structures as defined in
  78.       iffp/[form]app.h (for example an ILBMInfo defined in
  79.       iffp/ilbmapp.h).
  80.  
  81.     o Initialize the ParseInfo part of these structures to the
  82.       desired chunk arrays, and to an IFFHandle allocated via
  83.       iffparse AllocIFF().
  84.  
  85.     o Use the provided high level load/save functions, or use the
  86.       lower level parse.c openifile(), reader-only parseifile()/
  87.       getcontext()/nextcontext(), and closeifile().  The filename
  88.       -c[n] may be used to read/write clipboard unit n.
  89.  
  90.     o Clean up, FreeIFF(), and deallocate [form]Info's.
  91.  
  92.  
  93. V39/AA Support
  94.  
  95. For NewIFF39, the ILBMInfo was extended to support a 32-bit-per-gun
  96. representation of the CMAP for use with the V39 color setting
  97. functions.
  98.  
  99. /* --- New --- */
  100. WORD  *colorrecord;     /* Passed to LoadRGB32 (ncolors,firstreg,table) */
  101. Color32 *colortable32;  /* 32-bit-per-gun representation of colors      */
  102. ULONG crecsize;         /* Bytes allocated including colorrecord WORDs  */
  103.  
  104.  
  105. For compatibility, the old style WORD array colortable of xRGB 4-bit values
  106. is still created for all loaded ILBMs.
  107. But the NewIFF39 code will also automatically allocate and create the 32-bit
  108. color table under V39 or higher, unless the calling application asks it
  109. not to by setting IFFPF_NOCOLOR32 in ILBMInfo->IFFPFlags:
  110.  
  111. /* Don't allocate or use a 32-bit-per-gun Color Table under V39 or above */
  112. #define IFFPB_NOCOLOR32 0
  113. #define IFFPF_NOCOLOR32 (1L << IFFPB_NOCOLOR32)
  114.  
  115.  
  116. By default, the NewIFF39 code will examine the low nibbles
  117. of an ILBM.CMAP to determine if it is an old-style left-shifted
  118. 4-bit-per-gun CMAP, and if all of the low nibbles of all usable
  119. registers are zero, the code will assume a 4-bit CMAP and scale the 4-bit
  120. values properly to 32 bits.  This CMAP examination is disabled if
  121. either the ILBM.BMHD->Flags contains the flags BMHDF_CMAPOK (1L << 7),
  122. OR if the calling application passes the IFFPF_CMAPOK flag in
  123. ILBMInfo->IFFPFlags.  In either of these cases, the 8-bit CMAP
  124. values will be accepted as-is, and scaled to 32 bits.
  125.  
  126.  
  127. Since V37, the NewIFF code has supported saving of 8-bit-significant
  128. CMAP data, and the function interface will accept 4-bit, 8-bit, or
  129. 32-bit per gun color data.
  130.  
  131.  
  132. Currently, the NewIFF code does not make use of V39 Datatypes,
  133. and therefore has does not have the capability to load non-IFF file formats.
  134. You may wish to link with the NewIFF modules but also add conditional
  135. application code to make use of Datatypes when datatypes.library is
  136. present.  This would allow you program to be backwards compatible
  137. while taking even greater advantage of V39.
  138.  
  139.  
  140. Locale Support
  141.  
  142. The NewIFF39 code does not use locale.library as-is.  However, the code
  143. is prepared for localization.  A catalog file of all module strings
  144. is provided (iffp.cd), and the module include file iffpstrings.h is
  145. generated from this iffp.cd file using CatComp 39.x.  All string handling
  146. for the modules has been centralized in modules/iffpstrings.c which
  147. includes comments regarding locale support.  See the Locale.Readme
  148. in the NewIFF39 archive for additional tips on writing localized
  149. IFF applications.
  150.  
  151.  
  152. IMPORTANT NOTES
  153.  
  154. o Clipboard and File Handles
  155.  
  156.     Most of the higher-level load functions keep the
  157.     IFFHandle (file or clipboard) open.  While the handle is
  158.     open, you may use parse.c functions (such as findpropdata)
  159.     OR direct iffparse functions (FindProp(), FindCollection())
  160.     for accessing the gathered chunks.  However, it is not a good
  161.     idea to keep a filehandle OR the clipboard open.  While
  162.     a clipboard unit is open, no other applications can clip
  163.     to the unit.  And while a file is open, you can't write the
  164.     file back out.  So, instead of keeping the file or unit
  165.     open, you can use copychunks (in copychunks.c) to create
  166.     a copy of your gathered chunks, and do an early closeifile()
  167.     (parse.c).  Then access and later write back out (if you wish)
  168.     and deallocate your copied chunks via the routines in the
  169.     copychunks module (findchunk, writechunklist, freechunklist).
  170.  
  171. o Complex Forms
  172.  
  173.         The parse.c module will enter complex formats such as
  174.     CATSs, LISTs, and nested FORMs to find the FORM
  175.     that you are interested in.  This is great.  However, if you are
  176.         a read-modify-write program, you should warn your user when this
  177.         occurs unless YOU are capable of recreating the complex format.
  178.     Otherwise, your user may unknowingly destroy his complex file
  179.     by writing over it with your program.  Example - a paint
  180.     program could read an ILBM out of a complex LIST containing
  181.     pictures and music, and then save it back out as a simple ILBM,
  182.     causing the user to lose his music and other pictures.
  183.     To determine if a complex form was entered after a load,
  184.     check the (form)Info.ParseInfo.hunt field.  If TRUE (non-zero), 
  185.     then your file was found inside a complex format.
  186.  
  187.  
  188.  
  189.         LIST OF IFFP MODULES AND APPLICATIONS
  190.                 =====================================
  191.     NOTE - Some useful functions are listed with each module
  192.         See module source code for docs on each function.
  193.         See application examples for usage.
  194.  
  195. APPLICATIONS (these require linkage with modules - see Makefiles)
  196. ============
  197. ILBMDemo    Displays an ILBM, loads a brush, saves an ILBM, opt. print
  198. ILBMLoad    Queries an ILBM and loads it into an existing screen
  199. ILBMtoC        Outputs an ILBM as C source code
  200. ILBMtoRaw    Converts an ILBM to raw plane/color file
  201. RawtoILBM    Converts raw plane/color file (from ILBMtoRaw) to an ILBM
  202. 24bitDemo    Saves a simple 24-bit ILBM and then shows it 4 planes at
  203.         a time (if given filename, just does the show part)
  204. Play8SVX    Reads and plays an 8SVX sound effect or instrument
  205.           - LoadSample, UnloadSample, PlaySample, OpenAudio,
  206.             CloseAudio, and body load/unpack functions
  207. PlaySMUS    Just a skeleton for a SMUS player - it loads the SMUS
  208.         and samples.
  209. ScreenSave    Save the front screen or viewport as an ILBM, with an icon
  210. Save8        Create and save an 8-plane 256 color screen (V39/AA)
  211.  
  212.  
  213. OTHER EXAMPLES (use iffparse.library directly and require no modules)
  214. ==============
  215. Sift        Checks and prints outline of any IFF file (uses RAWSTEP)
  216. ILBMScan    Prints out useful info about any ILBM
  217. ClipFTXT    Demonstrates simply clipping of FTXT to/from clipboard
  218. apack.asm    Dr. Gerald Hull's assembler replacement for packer.c
  219. unpacker.asm    An assembler replacement
  220.  
  221. ALSO PROVIDED
  222. =============
  223. Display        1.3 through 3.0 compatible ILBM display and slideshow
  224.         program - supports AA.
  225. bumprev        updated version of bumprev revision file creation utility
  226.  
  227. GENERAL IFFPARSE SUPPORT MODULE
  228. ===============================
  229. parse.c        File/clipboard IO and general parsing
  230.           - openifile, closeifile, parseifile, getcontext,
  231.             nextcontext, contextis, currentchunkis, PutCk chunk
  232.             writing function, and IFFerr text error routine
  233.  
  234. iffpstrings.c   Centralized string and message handling for modules.
  235.  
  236. ILBM READ MODULES
  237. =================
  238. loadilbm.c    High level ILBM load routines which are passed filenames
  239.         (calls getbitmap)
  240.           - loadbrush/unloadbrush, loadilbm/unloadilbm, and queryilbm
  241. getbitmap.c    brush/bitmap loading (non-display, calls ilbmr.c)
  242.           - createbrush/deletebrush, getbitmap/freebitmap
  243. getdisplay.c    bitmap load/display (calls screen.c, ilbmr.c)
  244.           - showilbm/unshowilbm, createdisplay/deletedisplay
  245. screen.c    1.3/2.0/3.0 AA/ECS/non-ECS compatible screen/window module
  246.           - opendisplay, openidscreen, modefallback, clipit
  247. ilbmr.c        Lower level ILBM body/color load routines (calls unpacker.c)
  248.           - loadbody, loadcmap, getcolors/freecolors,
  249.             alloccolortable, getcamg (gets or creates modeid)
  250. unpacker.c    BODY unpacker
  251.  
  252.  
  253. ILBM WRITE MODULES
  254. ==================
  255. saveilbm.c    High level ILBM saving routines which are passed filenames
  256.         (calls ilbmw.c)
  257.           - screensave and saveilbm
  258. ilbmw.c        Lower level ILBM body/color save routines (calls packer.c)
  259.           - InitBMHD, PutCMAP, PutBODY
  260. packer.c    BODY packer
  261.  
  262.  
  263. EXTRA MODULES
  264. =============
  265. copychunks.c    Chunk cloning and chunk list writing routines
  266.           - copychunks, findchunk, writechunklist, freechunklist
  267. screendump.c    Screen printing module (iffparse not required)
  268. bmprintc.c    Module to output ILBM as C code
  269.  
  270.  
  271. INCLUDE FILES
  272. =============
  273. iffp/#?.h    This subdirectory may be kept in your current directory
  274.         or in your main include directory.
  275.  
  276.  
  277. Thanks to Steve Walton for his code changes for Manx/SAS compatibility,
  278. and to Bill Barton and John Bittner for their comments and suggestions.
  279.  
  280.