2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Interface to piggy functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PIGGY_H
|
|
|
|
#define _PIGGY_H
|
|
|
|
|
2014-07-20 01:09:55 +00:00
|
|
|
#include <physfs.h>
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "sounds.h"
|
2012-11-11 00:14:30 +00:00
|
|
|
#include "hash.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "inferno.h"
|
2013-10-26 03:40:50 +00:00
|
|
|
#include "gr.h"
|
2015-02-14 22:48:30 +00:00
|
|
|
#include "fwd-partial_range.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2013-12-26 04:18:28 +00:00
|
|
|
struct digi_sound;
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#define D1_SHARE_BIG_PIGSIZE 5092871 // v1.0 - 1.4 before RLE compression
|
|
|
|
#define D1_SHARE_10_PIGSIZE 2529454 // v1.0 - 1.2
|
|
|
|
#define D1_SHARE_PIGSIZE 2509799 // v1.4
|
|
|
|
#define D1_10_BIG_PIGSIZE 7640220 // v1.0 before RLE compression
|
|
|
|
#define D1_10_PIGSIZE 4520145 // v1.0
|
|
|
|
#define D1_PIGSIZE 4920305 // v1.4 - 1.5 (Incl. OEM v1.4a)
|
|
|
|
#define D1_OEM_PIGSIZE 5039735 // v1.0
|
|
|
|
#define D1_MAC_PIGSIZE 3975533
|
|
|
|
#define D1_MAC_SHARE_PIGSIZE 2714487
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
|
|
|
#define D1_PIGFILE "descent.pig"
|
2006-03-20 17:12:09 +00:00
|
|
|
#define MAX_ALIASES 20
|
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct alias
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
char alias_name[FILENAME_LEN];
|
|
|
|
char file_name[FILENAME_LEN];
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-02-14 22:48:27 +00:00
|
|
|
extern array<alias, MAX_ALIASES> alias_list;
|
|
|
|
extern unsigned Num_aliases;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern int Piggy_hamfile_version;
|
2013-03-03 01:03:33 +00:00
|
|
|
extern int Pigfile_initialized;
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// an index into the bitmap collection of the piggy file
|
2013-12-22 22:03:07 +00:00
|
|
|
struct bitmap_index
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
ushort index;
|
2014-01-12 23:00:43 +00:00
|
|
|
};
|
2014-09-27 22:46:25 +00:00
|
|
|
#define DEFINE_BITMAP_SERIAL_UDT() DEFINE_SERIAL_UDT_TO_MESSAGE(bitmap_index, b, (b.index))
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct BitmapFile
|
|
|
|
{
|
2012-11-11 00:14:30 +00:00
|
|
|
char name[15];
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2012-11-11 00:14:30 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
extern int MacPig;
|
|
|
|
extern int PCSharePig;
|
|
|
|
|
|
|
|
extern grs_bitmap bogus_bitmap;
|
|
|
|
#endif
|
2012-11-11 00:14:30 +00:00
|
|
|
extern ubyte bogus_data[64 * 64];
|
2013-03-03 01:03:33 +00:00
|
|
|
|
2008-02-11 12:12:57 +00:00
|
|
|
int properties_init();
|
2006-03-20 17:12:09 +00:00
|
|
|
void piggy_close();
|
2013-06-08 22:24:17 +00:00
|
|
|
bitmap_index piggy_register_bitmap( grs_bitmap * bmp, const char * name, int in_file );
|
|
|
|
int piggy_register_sound( digi_sound * snd, const char * name, int in_file );
|
2014-07-26 23:51:39 +00:00
|
|
|
bitmap_index piggy_find_bitmap(const char *name);
|
|
|
|
int piggy_find_sound(const char *name);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
void piggy_read_bitmap_data(grs_bitmap * bmp);
|
|
|
|
void piggy_read_sound_data(digi_sound *snd);
|
|
|
|
|
|
|
|
void piggy_load_level_data();
|
|
|
|
|
|
|
|
char* piggy_game_bitmap_name(grs_bitmap *bmp);
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
#define MAX_BITMAP_FILES 1800
|
|
|
|
#define MAX_SOUND_FILES MAX_SOUNDS
|
|
|
|
#define PIGGY_PC_SHAREWARE 2
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
#define MAX_BITMAP_FILES 2620 // Upped for CD Enhanced
|
|
|
|
#define MAX_SOUND_FILES MAX_SOUNDS
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
|
2008-04-06 20:23:28 +00:00
|
|
|
extern void piggy_bitmap_page_in( bitmap_index bmp );
|
|
|
|
extern void piggy_bitmap_page_out_all();
|
|
|
|
extern int piggy_page_flushed;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
|
|
|
|
extern digi_sound GameSounds[MAX_SOUND_FILES];
|
|
|
|
extern grs_bitmap GameBitmaps[MAX_BITMAP_FILES];
|
2006-03-20 17:12:09 +00:00
|
|
|
/* Make GNUC use static inline function as #define with backslash continuations causes problems with dos linefeeds */
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# define PIGGY_PAGE_IN(bmp) _piggy_page_in(bmp)
|
|
|
|
static inline void _piggy_page_in(bitmap_index bmp) {
|
|
|
|
if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {
|
|
|
|
piggy_bitmap_page_in( bmp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# else /* __GNUC__ */
|
|
|
|
|
|
|
|
#define PIGGY_PAGE_IN(bmp) \
|
|
|
|
do { \
|
|
|
|
if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {\
|
|
|
|
piggy_bitmap_page_in( bmp ); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
# endif /* __GNUC__ */
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
void piggy_read_sounds(int pc_shareware);
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
void piggy_read_sounds(void);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//reads in a new pigfile (for new palette)
|
|
|
|
//returns the size of all the bitmap data
|
|
|
|
void piggy_new_pigfile(char *pigname);
|
|
|
|
|
|
|
|
//loads custom bitmaps for current level
|
2013-06-08 22:24:17 +00:00
|
|
|
void load_bitmap_replacements(const char *level_name);
|
2006-03-20 17:12:09 +00:00
|
|
|
//if descent.pig exists, loads descent 1 texture bitmaps
|
|
|
|
void load_d1_bitmap_replacements();
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
/*
|
|
|
|
* Find and load the named bitmap from descent.pig
|
|
|
|
*/
|
2013-06-08 22:24:17 +00:00
|
|
|
bitmap_index read_extra_bitmap_d1_pig(const char *name);
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2011-06-01 07:59:55 +00:00
|
|
|
* reads a bitmap_index structure from a PHYSFS_file
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2015-02-14 22:48:30 +00:00
|
|
|
void bitmap_index_read(PHYSFS_file *fp, bitmap_index &bi);
|
|
|
|
void bitmap_index_read_n(PHYSFS_file *fp, partial_range_t<bitmap_index *> r);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-01-03 15:28:53 +00:00
|
|
|
extern void remove_char( char * s, char c ); // in piggy.c
|
|
|
|
#define REMOVE_EOL(s) remove_char((s),'\n')
|
|
|
|
#define REMOVE_COMMENTS(s) remove_char((s),';')
|
|
|
|
#define REMOVE_DOTS(s) remove_char((s),'.')
|
|
|
|
|
2012-11-11 00:14:30 +00:00
|
|
|
extern int Num_bitmap_files;
|
|
|
|
extern int Num_sound_files;
|
2012-11-11 00:12:17 +00:00
|
|
|
extern ubyte bogus_bitmap_initialized;
|
|
|
|
extern digi_sound bogus_sound;
|
2015-01-29 04:27:35 +00:00
|
|
|
#define space_tab " \t"
|
|
|
|
#define equal_space " \t="
|
2012-11-11 00:14:30 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
extern hashtable AllBitmapsNames;
|
|
|
|
extern hashtable AllDigiSndNames;
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
extern BitmapFile AllBitmaps[ MAX_BITMAP_FILES ];
|
|
|
|
#endif
|
|
|
|
void piggy_init_pigfile(const char *filename);
|
|
|
|
int read_hamfile();
|
|
|
|
void swap_0_255(grs_bitmap *bmp);
|
2012-11-11 00:12:17 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif //_PIGGY_H
|