Prepare new maemo release
[maemo-rb.git] / apps / plugins / doom / w_wad.h
blob05e25c17b08bf8dfe40a85e3639e74e65021f7b4
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * WAD I/O functions.
30 *-----------------------------------------------------------------------------*/
33 #ifndef __W_WAD__
34 #define __W_WAD__
36 #ifdef __GNUG__
37 #pragma interface
38 #endif
40 #include "m_fixed.h"
43 // TYPES
46 typedef struct
48 char identification[4]; // Should be "IWAD" or "PWAD".
49 int numlumps;
50 int infotableofs;
51 } wadinfo_t;
53 typedef struct
55 int filepos;
56 int size;
57 char name[8];
58 } filelump_t;
60 #ifndef ALL_IN_ONE
62 // NO_PREDEFINED_LUMPS causes none of the predefined lumps in info.c to be
63 // included, and removes all extra code which is only there for them
64 // Saves a little memory normally, lots if any were overridden, and makes
65 // the executable smaller
66 #define NO_PREDEFINED_LUMPS
68 #endif
71 // WADFILE I/O related stuff.
74 // CPhipps - defined enum in wider scope
75 // Ty 08/29/98 - add source field to identify where this lump came from
76 enum {
77 // CPhipps - define elements in order of 'how new/unusual'
78 source_iwad=0, // iwad file load
79 source_pre, // predefined lump
80 source_auto_load, // lump auto-loaded by config file
81 source_pwad, // pwad file load
82 source_lmp, // lmp file load
83 source_net // CPhipps
85 typedef unsigned wad_source_t;
87 enum {
88 ns_global=0,
89 ns_sprites,
90 ns_flats,
91 ns_colormaps
92 }; /* namespace */
94 typedef struct
96 // WARNING: order of some fields important (see info.c).
98 char name[8];
99 int size;
100 #ifndef NO_PREDEFINED_LUMPS
101 const void *data; // killough 1/31/98: points to predefined lump data
102 #endif
104 // killough 1/31/98: hash table fields, used for ultra-fast hash table lookup
105 int index, next;
107 // killough 4/17/98: namespace tags, to prevent conflicts between resources
108 unsigned namespace;
110 int handle;
111 int position;
112 unsigned int locks; // CPhipps - wad lump locking
113 wad_source_t source;
114 } lumpinfo_t;
116 // killough 1/31/98: predefined lumps
117 extern const size_t num_predefined_lumps;
118 extern const lumpinfo_t predefined_lumps[];
120 extern void **lumpcache;
121 extern lumpinfo_t *lumpinfo;
122 extern int numlumps;
124 // CPhipps - changed wad init
125 // We _must_ have the wadfiles[] the same as those actually loaded, so there
126 // is no point having these separate entities. This belongs here.
127 struct wadfile_info {
128 const char* name;
129 wad_source_t src;
132 extern struct wadfile_info *wadfiles;
134 extern size_t numwadfiles; // CPhipps - size of the wadfiles array
136 void W_Init(void); // CPhipps - uses the above array
138 // killough 4/17/98: if W_CheckNumForName() called with only
139 // one argument, pass ns_global as the default namespace
141 #define W_CheckNumForName(name) (W_CheckNumForName)(name, ns_global)
142 int (W_CheckNumForName)(const char* name, int); // killough 4/17/98
143 int W_GetNumForName (const char* name);
144 int W_LumpLength (int lump);
145 void W_ReadLump (int lump, void *dest);
146 // CPhipps - modified for 'new' lump locking
147 void* W_CacheLumpNum (int lump, unsigned short locks);
148 void W_UnlockLumpNum(int lump, signed short unlocks);
150 /* cph - special version to return lump with padding, for sound lumps */
151 void * W_CacheLumpNumPadded(int lump, size_t len, unsigned char pad);
153 // CPhipps - convenience macros
154 #define W_CacheLumpNum(num) (W_CacheLumpNum)((num),1)
155 #define W_CacheLumpName(name) W_CacheLumpNum (W_GetNumForName(name))
157 #define W_UnlockLumpNum(num) (W_UnlockLumpNum)((num),1)
158 #define W_UnlockLumpName(name) W_UnlockLumpNum (W_GetNumForName(name))
160 char *AddDefaultExtension(char *, const char *); // killough 1/18/98
161 void ExtractFileBase(const char *, char *); // killough
162 unsigned W_LumpNameHash(const char *s); // killough 1/31/98
164 // Function to write all predefined lumps to a PWAD if requested
165 extern void WritePredefinedLumpWad(const char *filename); // jff 5/6/98
167 #endif