home *** CD-ROM | disk | FTP | other *** search
/ D!Zone (Collector's Edition) / D_ZONE_CD.ISO / helps / dmijum / wadfile.h < prev   
C/C++ Source or Header  |  1994-12-06  |  6KB  |  155 lines

  1. /*
  2.  *    WADFILE.H
  3.  *
  4.  *    Version 1.0.0
  5.  *
  6.  *    Abstract:
  7.  *     This module contains all the WADFILE definitions for the WadLib library.
  8.  *
  9.  *    History:
  10.  *     1.0.0    (March 31, 1994)
  11.  *
  12.  *  Author:
  13.  *     Michael McMahon
  14.  *
  15.  ****************************************************************************
  16.  * Wadfile Structure Directory
  17.  *---------------------------------------------------------------------------
  18.  *Index: Name      : Description
  19.  *---------------------------------------------------------------------------
  20.  * #1  : Wadfile  : The definition for a Wadfile context.
  21.  ****************************************************************************
  22.  *
  23.  *  WADLIB SOFTWARE LICENSE AGREEMENT
  24.  *
  25.  *    1. GRANT OF LICENSE. Michael McMahon and his affiliations (collectively
  26.  *       the "AUTHOR") grant you (either an individual or an entity) the
  27.  *       non-exclusive, royalty-free right to use this library source code,
  28.  *       documentation, and sample code (collectively, the "SOFTWARE") for
  29.  *       any lawful purpose subject to the terms of this license.  By using the
  30.  *       SOFTWARE you are agreeing to be bound to all the terms of this license.
  31.  *
  32.  *    2. COPYRIGHT.  The SOFTWARE is Copyright (c) 1994, Michael McMahon,
  33.  *       PO Box 14807, San Luis Nabisco, CA 93406-4807 USA. All Rights Reserved
  34.  *       Worldwide.  You may not use, modify, or distribute the SOFTWARE except
  35.  *       as otherwise provided herein.
  36.  *
  37.  *    2. DECLARATION OF PUBLIC DOMAIN DISTRIBUTION AND USE. The distribution
  38.  *       and use of the SOFTWARE is hereby designated PUBLIC DOMAIN by the
  39.  *       the AUTHOR.    You may not sell, rent, or lease this SOFTWARE.  The
  40.  *       SOFTWARE may be reproduced verbatim in part or in full by any
  41.  *       reproduction means for any lawful purpose, and may also be subject to
  42.  *       the following agreement.
  43.  *
  44.  *    3. AGREEMENT FOR USE OF SOFTWARE. The AUTHOR grants you a non-exclusive,
  45.  *       royalty-free right to incorporate the SOFTWARE into any production for
  46.  *       any legal purpose as long as you agree
  47.  *        (a) to indemnify, hold harmless, and defend the AUTHOR from and against
  48.  *            any claims or lawsuits, including attorneys' fees, that arise or
  49.  *            result from the use or distribution of your software production; and
  50.  *        (b) no matter how much the SOFTWARE is modified, the AUTHOR owns the
  51.  *            copyright and this original, unmodified copyright notice remains
  52.  *            intact in the source code; and,
  53.  *        (c) the AUTHOR is not held responsible for fixing bugs or making
  54.  *            enhancements or changes to the SOFTWARE for any reason; and,
  55.  *        (d) the SOFTWARE is not redistributed if it is modified in any way; and,
  56.  *      (e) otherwise comply with the terms of this agreement; and,
  57.  *        (f) the AUTHOR is forgiven for making so many demands.
  58.  *
  59.  *     THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE
  60.  *     AUTHOR FURTHER DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING WITHOUT
  61.  *     LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS
  62.  *     FOR A PARTICULAR PURPOSE.    THE ENTIRE RISK ARISING OUT OF THE USE
  63.  *     OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU.
  64.  *
  65.  *     The author can be reached at:
  66.  *      Michael McMahon
  67.  *      P.O. Box 14807
  68.  *      San Luis Nabisco, CA 93406-4807 USA
  69.  *      Internet: mmcmahon@oboe.calpoly.edu
  70.  *      [Bug reports, suggestions, success stories, etc. are welcome; tech
  71.  *       support, and other unnecessary two-way mail, is not]
  72.  */
  73.  
  74. #ifndef WADFILE
  75. #define WADFILE
  76.  
  77. /* Values that are DOOM specific */
  78. #define DOOM_LASTEPISODE     3
  79. #define DOOM_BOSSLEVEL         8
  80. #define DOOM_LASTMAP         9
  81. #define NUM_ENTRIES_PER_MAP  11
  82.  
  83. /* Values for flag field */
  84. #define FLAG_WADFILE_OPEN        1
  85. #define FLAG_WADFILE_IWAD        2
  86. #define FLAG_WADFILE_DIRCACHED    4
  87. #define FLAG_WADFILE_WRITEONLY    8
  88. #define FLAG_LUMP_OPEN            16
  89.  
  90. /* Fixed wadfile sizes */
  91. #define SIZEOF_WAD_DIR_LOCATION 4
  92. #define SIZEOF_WAD_DIR_SIZE     4
  93. #define SIZEOF_WAD_SIGNATURE    4
  94. #define SIZEOF_WAD_DIR_NAME     8
  95. #define SIZEOF_WAD_DIR_ENTRY    16
  96.  
  97. /* Constants for WadfileOpen command */
  98. #define WANTIWAD       1
  99. #define WANTPWAD       2
  100. #define IWADPWAD       3
  101.  
  102. /* Constants for WadfileCreate command */
  103. #define TYPE_IWAD        WANTIWAD
  104. #define TYPE_PWAD        WANTPWAD
  105.  
  106. /* WAD file signatures */
  107. #define IWAD_SIGNATURE    "IWAD"
  108. #define PWAD_SIGNATURE    "PWAD"
  109.  
  110. /* Invalid WAD cached directory entry */
  111. #define INVALID_ENTRY    0xffff
  112.  
  113. /* Wadfile memory allocation routine pointers */
  114. typedef void * (*WadfileMalloc) (unsigned long size);
  115. typedef void (*WadfileFree) (void * ptr);
  116.  
  117. /* Our WAD file handler structure */
  118. typedef struct {
  119.     unsigned long flags;
  120.     FILE * wf;
  121.     unsigned long dirLocation;
  122.     unsigned long dirNumEntries;
  123.     unsigned int  entryIndex;
  124.     unsigned long entryLocation;
  125.     unsigned long entrySize;
  126.     unsigned char entryName[SIZEOF_WAD_DIR_NAME+1];
  127.     unsigned char * dirCache;
  128.     unsigned long lumpLocation;
  129.     unsigned long lumpSize;
  130.     unsigned char lumpName[SIZEOF_WAD_DIR_NAME];
  131.     unsigned char * lumpData;
  132. } Wadfile;
  133.  
  134. /* Wadfile Function Prototypes */
  135. int  WadfileAddLump(Wadfile * wad, unsigned long size, char * name, char * data);
  136. void WadfileClose(Wadfile * wad);
  137. int  WadfileCopyEntry(Wadfile * dest, char * destName,
  138.                      Wadfile * src,  char * srcName);
  139. int  WadfileCopyMap(Wadfile * dest, int destEpisode, int destMap,
  140.                    Wadfile * src,  int srcEpisode,  int srcMap);
  141. int  WadfileCreate(Wadfile * wad, char * filename, int type, int maxEntries);
  142. int  WadfileGetDirInfo(Wadfile * wad, int entryNum);
  143. int  WadfileGetNextDirInfo(Wadfile * wad);
  144. int  WadfileGetPrevDirInfo(Wadfile * wad);
  145. int  WadfileInitialize(WadfileMalloc wfm, WadfileFree wff);
  146. int  WadfileLumpClose(Wadfile * wad);
  147. int  WadfileLumpCopy(Wadfile * dest, char * destName, Wadfile * src);
  148. int  WadfileLumpOpen(Wadfile * wad);
  149. int  WadfileOpen(Wadfile * wad, char * filename, int fileType);
  150. int  WadfileSeek(Wadfile * wad, char * targetName);
  151. int  WadfileSeekMap(Wadfile * wad, int episodeNum, int mapNum);
  152.  
  153. #endif
  154.  
  155.