Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * Portions of this file are copyright Rebirth contributors and licensed as
3
 * described in COPYING.txt.
4
 * Portions of this file are copyright Parallax Software and licensed
5
 * according to the Parallax license below.
6
 * See COPYING.txt for license details.
7
 
8
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9
SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
10
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12
IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14
FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
16
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
18
*/
19
 
20
/*
21
 *
22
 * Interface to piggy functions.
23
 *
24
 */
25
 
26
#pragma once
27
 
28
#include <physfs.h>
29
#include "sounds.h"
30
#include "inferno.h"
31
#include "gr.h"
32
#include "fwd-partial_range.h"
33
 
34
#ifdef __cplusplus
35
#include "dxxsconf.h"
36
#include "dsx-ns.h"
37
#include <array>
38
 
39
#ifdef dsx
40
namespace dsx {
41
struct digi_sound;
42
}
43
#endif
44
 
45
#define D1_SHARE_BIG_PIGSIZE    5092871 // v1.0 - 1.4 before RLE compression
46
#define D1_SHARE_10_PIGSIZE     2529454 // v1.0 - 1.2
47
#define D1_SHARE_PIGSIZE        2509799 // v1.4
48
#define D1_10_BIG_PIGSIZE       7640220 // v1.0 before RLE compression
49
#define D1_10_PIGSIZE           4520145 // v1.0
50
#define D1_PIGSIZE              4920305 // v1.4 - 1.5 (Incl. OEM v1.4a)
51
#define D1_OEM_PIGSIZE          5039735 // v1.0
52
#define D1_MAC_PIGSIZE          3975533
53
#define D1_MAC_SHARE_PIGSIZE    2714487
54
 
55
#if defined(DXX_BUILD_DESCENT_II)
56
#define D1_PIGFILE              "descent.pig"
57
#define MAX_ALIASES 20
58
 
59
struct alias
60
{
61
        char alias_name[FILENAME_LEN];
62
        char file_name[FILENAME_LEN];
63
};
64
 
65
extern std::array<alias, MAX_ALIASES> alias_list;
66
extern unsigned Num_aliases;
67
 
68
extern int Piggy_hamfile_version;
69
extern int Pigfile_initialized;
70
#endif
71
 
72
// an index into the bitmap collection of the piggy file
73
struct bitmap_index
74
{
75
        ushort index;
76
};
77
#define DEFINE_BITMAP_SERIAL_UDT() DEFINE_SERIAL_UDT_TO_MESSAGE(bitmap_index, b, (b.index))
78
 
79
struct BitmapFile
80
{
81
        std::array<char, 13> name;
82
};
83
 
84
#if defined(DXX_BUILD_DESCENT_I)
85
extern int MacPig;
86
extern int PCSharePig;
87
 
88
extern grs_bitmap bogus_bitmap;
89
#endif
90
extern std::array<uint8_t, 64 * 64> bogus_data;
91
 
92
#ifdef dsx
93
int properties_init();
94
namespace dsx {
95
void piggy_close();
96
bitmap_index piggy_register_bitmap(grs_bitmap &bmp, const char * name, int in_file);
97
int piggy_register_sound( digi_sound * snd, const char * name, int in_file );
98
bitmap_index piggy_find_bitmap(const char *name);
99
}
100
int piggy_find_sound(const char *name);
101
 
102
void piggy_read_bitmap_data(grs_bitmap * bmp);
103
namespace dsx {
104
void piggy_read_sound_data(digi_sound *snd);
105
}
106
 
107
void piggy_load_level_data();
108
 
109
#if defined(DXX_BUILD_DESCENT_I)
110
constexpr std::integral_constant<unsigned, 1800> MAX_BITMAP_FILES{};
111
#define PIGGY_PC_SHAREWARE 2
112
#elif defined(DXX_BUILD_DESCENT_II)
113
// Upped for CD Enhanced
114
constexpr std::integral_constant<unsigned, 2620> MAX_BITMAP_FILES{};
115
#endif
116
#define MAX_SOUND_FILES     MAX_SOUNDS
117
 
118
 
119
#ifdef dsx
120
namespace dsx {
121
extern void piggy_bitmap_page_in( bitmap_index bmp );
122
void piggy_bitmap_page_out_all();
123
 
124
using GameBitmaps_array = std::array<grs_bitmap, MAX_BITMAP_FILES>;
125
extern std::array<digi_sound, MAX_SOUND_FILES> GameSounds;
126
extern GameBitmaps_array GameBitmaps;
127
#  define  PIGGY_PAGE_IN(bmp) _piggy_page_in(bmp)
128
static inline void _piggy_page_in(bitmap_index bmp) {
129
        if (GameBitmaps[bmp.index].get_flag_mask(BM_FLAG_PAGED_OUT))
130
        {
131
        piggy_bitmap_page_in( bmp );
132
    }
133
}
134
}
135
#endif
136
 
137
#if defined(DXX_BUILD_DESCENT_I)
138
void piggy_read_sounds(int pc_shareware);
139
#elif defined(DXX_BUILD_DESCENT_II)
140
void piggy_read_sounds(void);
141
 
142
//reads in a new pigfile (for new palette)
143
//returns the size of all the bitmap data
144
void piggy_new_pigfile(char *pigname);
145
 
146
//loads custom bitmaps for current level
147
void load_bitmap_replacements(const char *level_name);
148
//if descent.pig exists, loads descent 1 texture bitmaps
149
void load_d1_bitmap_replacements();
150
 
151
/*
152
 * Find and load the named bitmap from descent.pig
153
 */
154
bitmap_index read_extra_bitmap_d1_pig(const char *name);
155
#endif
156
 
157
/*
158
 * reads a bitmap_index structure from a PHYSFS_File
159
 */
160
void bitmap_index_read(PHYSFS_File *fp, bitmap_index &bi);
161
void bitmap_index_read_n(PHYSFS_File *fp, partial_range_t<bitmap_index *> r);
162
 
163
extern void remove_char( char * s, char c );    // in piggy.c
164
#define REMOVE_EOL(s)           remove_char((s),'\n')
165
#define REMOVE_COMMENTS(s)      remove_char((s),';')
166
#define REMOVE_DOTS(s)          remove_char((s),'.')
167
 
168
extern unsigned Num_bitmap_files;
169
extern int Num_sound_files;
170
extern ubyte bogus_bitmap_initialized;
171
namespace dsx {
172
extern digi_sound bogus_sound;
173
}
174
#endif
175
#define space_tab " \t"
176
#define equal_space " \t="
177
#if defined(DXX_BUILD_DESCENT_I)
178
#include "hash.h"
179
extern hashtable AllBitmapsNames;
180
extern hashtable AllDigiSndNames;
181
#elif defined(DXX_BUILD_DESCENT_II)
182
extern std::array<BitmapFile, MAX_BITMAP_FILES> AllBitmaps;
183
int read_sndfile();
184
#endif
185
void piggy_init_pigfile(const char *filename);
186
int read_hamfile();
187
void swap_0_255(grs_bitmap &bmp);
188
 
189
#endif