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
 * Bitmap and Palette loading functions.
23
 *
24
 */
25
 
26
#pragma once
27
 
28
#include <physfs.h>
29
#include "maths.h"
30
#include "fwd-vclip.h"
31
 
32
struct bitmap_index;
33
 
34
#ifdef __cplusplus
35
#include <cstdint>
36
 
37
struct grs_bitmap;
38
 
39
#ifdef dsx
40
namespace dsx {
41
#if defined(DXX_BUILD_DESCENT_I)
42
constexpr std::integral_constant<unsigned, 800> MAX_TEXTURES{};
43
#elif defined(DXX_BUILD_DESCENT_II)
44
constexpr std::integral_constant<unsigned, 1200> MAX_TEXTURES{};
45
#endif
46
}
47
#endif
48
 
49
//tmapinfo flags
50
#define TMI_VOLATILE    1   //this material blows up when hit
51
#if defined(DXX_BUILD_DESCENT_II)
52
#define TMI_WATER       2   //this material is water
53
#define TMI_FORCE_FIELD 4   //this is force field - flares don't stick
54
#define TMI_GOAL_BLUE   8   //this is used to remap the blue goal
55
#define TMI_GOAL_RED    16  //this is used to remap the red goal
56
#define TMI_GOAL_HOARD  32  //this is used to remap the goals
57
#endif
58
 
59
#ifdef dsx
60
#include "inferno.h"
61
namespace dsx {
62
struct tmap_info : prohibit_void_ptr<tmap_info>
63
{
64
#if defined(DXX_BUILD_DESCENT_I)
65
        d_fname filename;
66
        uint8_t                 flags;
67
        fix                     lighting;               // 0 to 1
68
        fix                     damage;                 //how much damage being against this does
69
        unsigned eclip_num;             //if not -1, the eclip that changes this   
70
#define N_COCKPIT_BITMAPS 4
71
#elif defined(DXX_BUILD_DESCENT_II)
72
        fix     lighting;  //how much light this casts
73
        fix     damage;    //how much damage being against this does (for lava)
74
        uint16_t eclip_num; //the eclip that changes this, or -1
75
        short   destroyed; //bitmap to show when destroyed, or -1
76
        short   slide_u,slide_v;    //slide rates of texture, stored in 8:8 fix
77
        uint8_t   flags;     //values defined above
78
#if DXX_USE_EDITOR
79
        d_fname filename;       //used by editor to remap textures
80
        #endif
81
 
82
#define TMAP_INFO_SIZE 20   // how much space it takes up on disk
83
#define N_COCKPIT_BITMAPS 6
84
#endif
85
};
86
}
87
 
88
namespace dcx {
89
extern int Num_object_types;
90
 
91
struct player_ship;
92
//right now there's only one player ship, but we can have another by
93
//adding an array and setting the pointer to the active ship.
94
extern struct player_ship only_player_ship;
95
constexpr struct player_ship *Player_ship = &only_player_ship;
96
extern unsigned Num_cockpits;
97
}
98
 
99
namespace dsx {
100
extern std::array<bitmap_index, N_COCKPIT_BITMAPS> cockpit_bitmap;
101
#if DXX_USE_EDITOR
102
using tmap_xlate_table_array = std::array<short, MAX_TEXTURES>;
103
extern tmap_xlate_table_array tmap_xlate_table;
104
#endif
105
 
106
/* This is level-unique because hoard mode assumes it can overwrite a
107
 * texture.
108
 */
109
struct d_level_unique_tmap_info_state
110
{
111
        using TmapInfo_array = std::array<tmap_info, MAX_TEXTURES>;
112
        unsigned Num_tmaps;
113
        TmapInfo_array TmapInfo;
114
};
115
 
116
extern d_level_unique_tmap_info_state LevelUniqueTmapInfoState;
117
// Initializes the palette, bitmap system...
118
void gamedata_close();
119
}
120
int gamedata_init();
121
void bm_close();
122
 
123
// Initializes the Texture[] array of bmd_bitmap structures.
124
void init_textures();
125
 
126
#ifdef dsx
127
 
128
namespace dsx {
129
 
130
#if defined(DXX_BUILD_DESCENT_I)
131
 
132
#define OL_ROBOT                                1
133
#define OL_HOSTAGE                      2
134
#define OL_POWERUP                      3
135
#define OL_CONTROL_CENTER       4
136
#define OL_PLAYER                               5
137
#define OL_CLUTTER                      6               //some sort of misc object
138
#define OL_EXIT                         7               //the exit model for external scenes
139
 
140
#define MAX_OBJTYPE                     100
141
 
142
extern int Num_total_object_types;              //      Total number of object types, including robots, hostages, powerups, control centers, faces
143
extern int8_t   ObjType[MAX_OBJTYPE];           // Type of an object, such as Robot, eg if ObjType[11] == OL_ROBOT, then object #11 is a robot
144
extern int8_t   ObjId[MAX_OBJTYPE];                     // ID of a robot, within its class, eg if ObjType[11] == 3, then object #11 is the third robot
145
extern fix      ObjStrength[MAX_OBJTYPE];       // initial strength of each object
146
 
147
constexpr std::integral_constant<unsigned, 210> MAX_OBJ_BITMAPS{};
148
 
149
#elif defined(DXX_BUILD_DESCENT_II)
150
 
151
//the model number of the marker object
152
extern int Marker_model_num;
153
extern int Robot_replacements_loaded;
154
constexpr std::integral_constant<unsigned, 610> MAX_OBJ_BITMAPS{};
155
extern unsigned N_ObjBitmaps;
156
extern int extra_bitmap_num;
157
extern bool Exit_models_loaded;
158
extern bool Exit_bitmaps_loaded;
159
#endif
160
 
161
}
162
 
163
#endif
164
 
165
extern int  Num_object_subtypes;     // Number of possible IDs for the current type of object to be placed
166
 
167
extern std::array<bitmap_index, MAX_OBJ_BITMAPS> ObjBitmaps;
168
extern std::array<ushort, MAX_OBJ_BITMAPS> ObjBitmapPtrs;
169
extern int First_multi_bitmap_num;
170
void compute_average_rgb(grs_bitmap *bm, std::array<fix, 3> &rgb);
171
 
172
namespace dsx {
173
void load_robot_replacements(const d_fname &level_name);
174
// Initializes all bitmaps from BITMAPS.TBL file.
175
int gamedata_read_tbl(d_vclip_array &Vclip, int pc_shareware);
176
 
177
void bm_read_all(d_vclip_array &Vclip, PHYSFS_File * fp);
178
#if defined(DXX_BUILD_DESCENT_I)
179
void properties_read_cmp(d_vclip_array &Vclip, PHYSFS_File * fp);
180
#endif
181
}
182
#endif
183
 
184
int ds_load(int skip, const char * filename );
185
int compute_average_pixel(grs_bitmap *n);
186
 
187
#if defined(DXX_BUILD_DESCENT_II)
188
namespace dsx {
189
int load_exit_models();
190
//these values are the number of each item in the release of d2
191
//extra items added after the release get written in an additional hamfile
192
constexpr std::integral_constant<unsigned, 66> N_D2_ROBOT_TYPES{};
193
constexpr std::integral_constant<unsigned, 1145> N_D2_ROBOT_JOINTS{};
194
constexpr std::integral_constant<unsigned, 422> N_D2_OBJBITMAPS{};
195
constexpr std::integral_constant<unsigned, 502> N_D2_OBJBITMAPPTRS{};
196
constexpr std::integral_constant<unsigned, 62> N_D2_WEAPON_TYPES{};
197
}
198
#endif
199
 
200
#endif