2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2016-05-18 00:42:11 +00:00
|
|
|
// Copyright (C) 1999-2016 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file w_wad.h
|
|
|
|
/// \brief WAD I/O functions, wad resource definitions (some)
|
|
|
|
|
|
|
|
#ifndef __W_WAD__
|
|
|
|
#define __W_WAD__
|
|
|
|
|
|
|
|
#ifdef HWRENDER
|
|
|
|
#include "hardware/hw_data.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ==============================================================
|
|
|
|
// WAD FILE STRUCTURE DEFINITIONS
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
// header of a wad file
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char identification[4]; // should be "IWAD" or "PWAD"
|
|
|
|
UINT32 numlumps; // how many resources
|
|
|
|
UINT32 infotableofs; // the 'directory' of resources
|
|
|
|
} wadinfo_t;
|
|
|
|
|
2017-05-16 19:10:02 +00:00
|
|
|
// a raw entry of the wad directory
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
UINT32 filepos; // file offset of the resource
|
|
|
|
UINT32 size; // size of the resource
|
|
|
|
char name[8]; // name of the resource
|
|
|
|
} ATTRPACK filelump_t;
|
|
|
|
|
2017-04-30 12:49:33 +00:00
|
|
|
// Available compression methods for lumps.
|
2017-05-02 17:20:29 +00:00
|
|
|
enum compmethod{CM_NONE, CM_DEFLATE, CM_LZF, CM_UNSUPPORTED};
|
2017-04-30 12:49:33 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// a memory entry of the wad directory
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned long position; // filelump_t filepos
|
|
|
|
unsigned long disksize; // filelump_t size
|
|
|
|
char name[9]; // filelump_t name[]
|
2017-05-07 10:30:06 +00:00
|
|
|
char *name2; // Used by PK3s. Dynamically allocated name.
|
2014-03-15 16:59:03 +00:00
|
|
|
size_t size; // real (uncompressed) size
|
|
|
|
INT32 compressed; // i
|
2017-04-30 12:49:33 +00:00
|
|
|
enum compmethod compression; // lump compression method
|
2014-03-15 16:59:03 +00:00
|
|
|
} lumpinfo_t;
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
// DYNAMIC WAD LOADING
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
#define MAX_WADPATH 128
|
|
|
|
#define MAX_WADFILES 48 // maximum of wad files used at the same time
|
|
|
|
// (there is a max of simultaneous open files anyway, and this should be plenty)
|
|
|
|
|
|
|
|
#define lumpcache_t void *
|
|
|
|
|
|
|
|
#ifdef HWRENDER
|
2016-06-05 20:29:40 +00:00
|
|
|
#include "m_aatree.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-30 12:49:33 +00:00
|
|
|
// Resource type of the WAD. Yeah, I know this sounds dumb, but I'll leave it like this until I clean up the code further.
|
|
|
|
enum restype {RET_WAD, RET_PK3};
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
typedef struct wadfile_s
|
|
|
|
{
|
|
|
|
char *filename;
|
2017-04-30 18:05:26 +00:00
|
|
|
enum restype type;
|
2014-03-15 16:59:03 +00:00
|
|
|
lumpinfo_t *lumpinfo;
|
|
|
|
lumpcache_t *lumpcache;
|
|
|
|
#ifdef HWRENDER
|
|
|
|
aatree_t *hwrcache; // patches are cached in renderer's native format
|
|
|
|
#endif
|
|
|
|
UINT16 numlumps; // this wad's number of resources
|
|
|
|
FILE *handle;
|
|
|
|
UINT32 filesize; // for network
|
|
|
|
UINT8 md5sum[16];
|
2017-05-27 13:01:26 +00:00
|
|
|
boolean important; // also network - !W_VerifyNMUSlumps
|
2014-03-15 16:59:03 +00:00
|
|
|
} wadfile_t;
|
|
|
|
|
|
|
|
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word
|
|
|
|
#define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad
|
|
|
|
|
|
|
|
extern UINT16 numwadfiles;
|
|
|
|
extern wadfile_t *wadfiles[MAX_WADFILES];
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
void W_Shutdown(void);
|
|
|
|
|
2017-02-16 21:55:17 +00:00
|
|
|
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
|
|
|
|
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
|
2014-03-15 16:59:03 +00:00
|
|
|
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
|
2017-05-07 10:30:06 +00:00
|
|
|
UINT16 W_InitFile(const char *filename);
|
2014-03-15 16:59:03 +00:00
|
|
|
#ifdef DELFILE
|
|
|
|
void W_UnloadWadFile(UINT16 num);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
|
|
|
|
// so that it stops with a message if a file was not found, but not if all is okay.
|
|
|
|
INT32 W_InitMultipleFiles(char **filenames);
|
|
|
|
|
|
|
|
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
|
|
|
|
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
|
|
|
|
|
|
|
UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad
|
2017-05-01 14:37:32 +00:00
|
|
|
|
|
|
|
UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump);
|
2017-05-28 19:47:15 +00:00
|
|
|
UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump);
|
2017-05-01 14:37:32 +00:00
|
|
|
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump);
|
|
|
|
|
2017-05-18 19:13:18 +00:00
|
|
|
lumpnum_t W_CheckNumForMap(const char *name);
|
2014-03-15 16:59:03 +00:00
|
|
|
lumpnum_t W_CheckNumForName(const char *name);
|
|
|
|
lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR
|
2015-01-01 19:50:31 +00:00
|
|
|
lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend);
|
2014-03-25 02:17:59 +00:00
|
|
|
UINT8 W_LumpExists(const char *name); // Lua uses this.
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump);
|
|
|
|
size_t W_LumpLength(lumpnum_t lumpnum);
|
|
|
|
|
|
|
|
size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, size_t offset);
|
|
|
|
size_t W_ReadLumpHeader(lumpnum_t lump, void *dest, size_t size, size_t offest); // read all or a part of a lump
|
|
|
|
void W_ReadLumpPwad(UINT16 wad, UINT16 lump, void *dest);
|
|
|
|
void W_ReadLump(lumpnum_t lump, void *dest);
|
|
|
|
|
|
|
|
void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag);
|
|
|
|
void *W_CacheLumpNum(lumpnum_t lump, INT32 tag);
|
|
|
|
void *W_CacheLumpNumForce(lumpnum_t lumpnum, INT32 tag);
|
|
|
|
|
|
|
|
boolean W_IsLumpCached(lumpnum_t lump, void *ptr);
|
|
|
|
|
|
|
|
void *W_CacheLumpName(const char *name, INT32 tag);
|
|
|
|
void *W_CachePatchName(const char *name, INT32 tag);
|
|
|
|
|
|
|
|
#ifdef HWRENDER
|
|
|
|
//void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); // return a patch_t
|
|
|
|
void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t
|
|
|
|
#else
|
|
|
|
//#define W_CachePatchNumPwad(wad, lump, tag) W_CacheLumpNumPwad(wad, lump, tag)
|
|
|
|
#define W_CachePatchNum(lumpnum, tag) W_CacheLumpNum(lumpnum, tag)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void W_UnlockCachedPatch(void *patch);
|
|
|
|
|
|
|
|
void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5);
|
|
|
|
|
|
|
|
int W_VerifyNMUSlumps(const char *filename);
|
|
|
|
|
|
|
|
#endif // __W_WAD__
|