1 /* $Id: piggy.h,v 1.27 2004-08-28 23:17:45 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Interface to piggy functions.
29 #define D1_PIGFILE "descent.pig"
31 #define D1_SHARE_BIG_PIGSIZE 5092871 // v1.0 - 1.4 before RLE compression
32 #define D1_SHARE_10_PIGSIZE 2529454 // v1.0 - 1.2
33 #define D1_SHARE_PIGSIZE 2509799 // v1.4
34 #define D1_10_BIG_PIGSIZE 7640220 // v1.0 before RLE compression
35 #define D1_10_PIGSIZE 4520145 // v1.0
36 #define D1_PIGSIZE 4920305 // v1.4 - 1.5 (Incl. OEM v1.4a)
37 #define D1_OEM_PIGSIZE 5039735 // v1.0
38 #define D1_MAC_PIGSIZE 3975533
39 #define D1_MAC_SHARE_PIGSIZE 2714487
41 #define MAX_ALIASES 20
43 typedef struct alias {
44 char alias_name[FILENAME_LEN];
45 char file_name[FILENAME_LEN];
48 extern alias alias_list[MAX_ALIASES];
49 extern int Num_aliases;
51 extern int Piggy_hamfile_version;
53 // an index into the bitmap collection of the piggy file
54 typedef struct bitmap_index {
56 } __pack__ bitmap_index;
60 void piggy_dump_all();
61 bitmap_index piggy_register_bitmap( grs_bitmap * bmp, char * name, int in_file );
62 int piggy_register_sound( digi_sound * snd, char * name, int in_file );
63 bitmap_index piggy_find_bitmap( char * name );
64 int piggy_find_sound( char * name );
66 extern int Pigfile_initialized;
68 void piggy_read_bitmap_data(grs_bitmap * bmp);
69 void piggy_read_sound_data(digi_sound *snd);
71 void piggy_load_level_data();
73 char* piggy_game_bitmap_name(grs_bitmap *bmp);
75 #define MAX_BITMAP_FILES 2620 // Upped for CD Enhanced
76 #define MAX_SOUND_FILES MAX_SOUNDS
78 extern digi_sound GameSounds[MAX_SOUND_FILES];
79 extern grs_bitmap GameBitmaps[MAX_BITMAP_FILES];
82 #ifdef PIGGY_USE_PAGING
83 extern void piggy_bitmap_page_in( bitmap_index bmp );
84 extern void piggy_bitmap_page_out_all();
85 extern int piggy_page_flushed;
87 /* Make GNUC use static inline function as #define with backslash continuations causes problems with dos linefeeds */
89 # define PIGGY_PAGE_IN(bmp) _piggy_page_in(bmp)
90 static inline void _piggy_page_in(bitmap_index bmp) {
91 if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {
92 piggy_bitmap_page_in( bmp );
98 #define PIGGY_PAGE_IN(bmp) \
100 if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {\
101 piggy_bitmap_page_in( bmp ); \
104 /* mprintf(( 0, "Paging in '%s' from file '%s', line %d\n", #bmp, __FILE__,__LINE__ )); \ */
105 # endif /* __GNUC__ */
107 # define PIGGY_PAGE_IN(bmp)
110 void piggy_read_sounds();
112 //reads in a new pigfile (for new palette)
113 //returns the size of all the bitmap data
114 void piggy_new_pigfile(char *pigname);
116 //loads custom bitmaps for current level
117 void load_bitmap_replacements(char *level_name);
118 //if descent.pig exists, loads descent 1 texture bitmaps
119 void load_d1_bitmap_replacements();
122 #define bitmap_index_read(bi, fp) cfread(bi, sizeof(bitmap_index), 1, fp)
123 #define bitmap_index_read_n(bi, n, fp) cfread(bi, sizeof(bitmap_index), n, fp)
126 * reads a bitmap_index structure from a CFILE
128 void bitmap_index_read(bitmap_index *bi, CFILE *fp);
131 * reads n bitmap_index structs from a CFILE
133 int bitmap_index_read_n(bitmap_index *bi, int n, CFILE *fp);
134 #endif // FAST_FILE_IO
137 * Find and load the named bitmap from descent.pig
139 bitmap_index read_extra_bitmap_d1_pig(char *name);