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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Bitmap and Palette loading functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-01-29 04:27:35 +00:00
|
|
|
#pragma once
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-01-29 04:27:35 +00:00
|
|
|
#include <physfs.h>
|
2015-07-25 23:10:45 +00:00
|
|
|
#include "maths.h"
|
2018-10-21 00:24:07 +00:00
|
|
|
#include "fwd-vclip.h"
|
2022-02-12 18:57:12 +00:00
|
|
|
#include "fwd-game.h"
|
2020-10-07 03:59:14 +00:00
|
|
|
#include "d_array.h"
|
2021-11-01 03:37:20 +00:00
|
|
|
#include "inferno.h"
|
2015-01-29 04:27:35 +00:00
|
|
|
|
|
|
|
struct bitmap_index;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-07-25 23:10:45 +00:00
|
|
|
#include <cstdint>
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2021-09-04 12:17:14 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2015-01-29 04:27:36 +00:00
|
|
|
struct grs_bitmap;
|
|
|
|
|
2021-11-01 03:37:20 +00:00
|
|
|
enum class tmapinfo_flag : uint8_t
|
|
|
|
{
|
|
|
|
lava = 1 << 0, //this material blows up when hit
|
|
|
|
/* if DXX_BUILD_DESCENT_II */
|
|
|
|
water = 1 << 1, //this material is water
|
|
|
|
force_field = 1 << 2, //this is force field - flares don't stick
|
|
|
|
goal_blue = 1 << 3, //this is used to remap the blue goal
|
|
|
|
goal_red = 1 << 4, //this is used to remap the red goal
|
|
|
|
goal_hoard = 1 << 5,//this is used to remap the goals
|
|
|
|
/* endif */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class tmapinfo_flags : uint8_t;
|
|
|
|
|
|
|
|
static constexpr uint8_t operator&(tmapinfo_flags flags, tmapinfo_flag mask)
|
|
|
|
{
|
|
|
|
return static_cast<uint8_t>(flags) & static_cast<uint8_t>(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr tmapinfo_flags &operator|=(tmapinfo_flags &flags, tmapinfo_flag mask)
|
|
|
|
{
|
|
|
|
return flags = static_cast<tmapinfo_flags>(static_cast<uint8_t>(flags) | static_cast<uint8_t>(mask));
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr tmapinfo_flag operator|(tmapinfo_flag a, tmapinfo_flag b)
|
|
|
|
{
|
|
|
|
return static_cast<tmapinfo_flag>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
|
|
|
|
}
|
|
|
|
|
2021-09-04 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2016-07-10 04:11:35 +00:00
|
|
|
#ifdef dsx
|
|
|
|
namespace dsx {
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<unsigned, 800> MAX_TEXTURES{};
|
2013-03-03 01:03:33 +00:00
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<unsigned, 1200> MAX_TEXTURES{};
|
2016-07-10 04:11:35 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-07-23 02:09:33 +00:00
|
|
|
struct tmap_info : prohibit_void_ptr<tmap_info>
|
2013-12-22 22:03:07 +00:00
|
|
|
{
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2014-07-23 02:27:22 +00:00
|
|
|
d_fname filename;
|
2021-11-01 03:37:20 +00:00
|
|
|
tmapinfo_flags flags;
|
2013-03-03 01:03:33 +00:00
|
|
|
fix lighting; // 0 to 1
|
|
|
|
fix damage; //how much damage being against this does
|
2018-03-31 21:53:01 +00:00
|
|
|
unsigned eclip_num; //if not -1, the eclip that changes this
|
2013-03-03 01:03:33 +00:00
|
|
|
#define N_COCKPIT_BITMAPS 4
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
fix lighting; //how much light this casts
|
|
|
|
fix damage; //how much damage being against this does (for lava)
|
2018-03-31 21:53:01 +00:00
|
|
|
uint16_t eclip_num; //the eclip that changes this, or -1
|
2006-03-20 17:12:09 +00:00
|
|
|
short destroyed; //bitmap to show when destroyed, or -1
|
|
|
|
short slide_u,slide_v; //slide rates of texture, stored in 8:8 fix
|
2021-11-01 03:37:20 +00:00
|
|
|
tmapinfo_flags flags;
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2014-07-23 02:27:22 +00:00
|
|
|
d_fname filename; //used by editor to remap textures
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TMAP_INFO_SIZE 20 // how much space it takes up on disk
|
2013-03-03 01:03:33 +00:00
|
|
|
#define N_COCKPIT_BITMAPS 6
|
|
|
|
#endif
|
2014-07-23 02:09:33 +00:00
|
|
|
};
|
2016-07-10 04:11:35 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2016-10-02 19:35:34 +00:00
|
|
|
namespace dcx {
|
2006-03-20 17:12:09 +00:00
|
|
|
extern int Num_object_types;
|
|
|
|
|
2012-11-11 00:12:17 +00:00
|
|
|
struct player_ship;
|
2013-11-17 00:50:32 +00:00
|
|
|
//right now there's only one player ship, but we can have another by
|
|
|
|
//adding an array and setting the pointer to the active ship.
|
2012-11-11 00:12:17 +00:00
|
|
|
extern struct player_ship only_player_ship;
|
2016-07-16 16:52:04 +00:00
|
|
|
constexpr struct player_ship *Player_ship = &only_player_ship;
|
2015-02-14 22:48:30 +00:00
|
|
|
extern unsigned Num_cockpits;
|
2016-10-02 19:35:34 +00:00
|
|
|
}
|
|
|
|
|
2016-07-10 04:11:35 +00:00
|
|
|
namespace dsx {
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2020-05-02 21:18:42 +00:00
|
|
|
using tmap_xlate_table_array = std::array<short, MAX_TEXTURES>;
|
2016-07-10 04:11:35 +00:00
|
|
|
extern tmap_xlate_table_array tmap_xlate_table;
|
2015-04-02 02:36:52 +00:00
|
|
|
#endif
|
2018-12-30 00:43:59 +00:00
|
|
|
|
|
|
|
/* This is level-unique because hoard mode assumes it can overwrite a
|
|
|
|
* texture.
|
|
|
|
*/
|
|
|
|
struct d_level_unique_tmap_info_state
|
|
|
|
{
|
2020-05-02 21:18:42 +00:00
|
|
|
using TmapInfo_array = std::array<tmap_info, MAX_TEXTURES>;
|
2018-12-30 00:43:59 +00:00
|
|
|
unsigned Num_tmaps;
|
2018-12-30 00:43:59 +00:00
|
|
|
TmapInfo_array TmapInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern d_level_unique_tmap_info_state LevelUniqueTmapInfoState;
|
2006-03-20 17:12:09 +00:00
|
|
|
// Initializes the palette, bitmap system...
|
2008-11-14 16:56:40 +00:00
|
|
|
void gamedata_close();
|
2016-08-25 04:05:32 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
void bm_close();
|
|
|
|
|
|
|
|
// Initializes the Texture[] array of bmd_bitmap structures.
|
|
|
|
void init_textures();
|
|
|
|
|
2020-01-18 21:57:39 +00:00
|
|
|
#ifdef dsx
|
|
|
|
|
|
|
|
namespace dsx {
|
|
|
|
|
2020-10-07 03:59:14 +00:00
|
|
|
int gamedata_init();
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#define OL_ROBOT 1
|
|
|
|
#define OL_HOSTAGE 2
|
|
|
|
#define OL_POWERUP 3
|
|
|
|
#define OL_CONTROL_CENTER 4
|
|
|
|
#define OL_PLAYER 5
|
|
|
|
#define OL_CLUTTER 6 //some sort of misc object
|
|
|
|
#define OL_EXIT 7 //the exit model for external scenes
|
|
|
|
|
|
|
|
#define MAX_OBJTYPE 100
|
|
|
|
|
|
|
|
extern int Num_total_object_types; // Total number of object types, including robots, hostages, powerups, control centers, faces
|
2015-07-25 23:10:45 +00:00
|
|
|
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
|
|
|
|
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
|
2013-03-03 01:03:33 +00:00
|
|
|
extern fix ObjStrength[MAX_OBJTYPE]; // initial strength of each object
|
|
|
|
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<unsigned, 210> MAX_OBJ_BITMAPS{};
|
2013-03-03 01:03:33 +00:00
|
|
|
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
|
2012-11-11 00:14:30 +00:00
|
|
|
extern int Robot_replacements_loaded;
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<unsigned, 610> MAX_OBJ_BITMAPS{};
|
2016-02-06 22:12:54 +00:00
|
|
|
extern unsigned N_ObjBitmaps;
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-07 03:59:14 +00:00
|
|
|
enum class object_bitmap_index : uint16_t
|
|
|
|
{
|
|
|
|
None = UINT16_MAX
|
|
|
|
};
|
|
|
|
extern enumerated_array<bitmap_index, MAX_OBJ_BITMAPS, object_bitmap_index> ObjBitmaps;
|
|
|
|
extern std::array<object_bitmap_index, MAX_OBJ_BITMAPS> ObjBitmapPtrs;
|
2020-10-07 03:59:14 +00:00
|
|
|
|
2020-01-18 21:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
extern int Num_object_subtypes; // Number of possible IDs for the current type of object to be placed
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern int First_multi_bitmap_num;
|
2020-05-02 21:18:42 +00:00
|
|
|
void compute_average_rgb(grs_bitmap *bm, std::array<fix, 3> &rgb);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2016-06-25 23:21:36 +00:00
|
|
|
namespace dsx {
|
2022-02-12 18:57:12 +00:00
|
|
|
extern enumerated_array<bitmap_index, N_COCKPIT_BITMAPS, cockpit_mode_t> cockpit_bitmap;
|
2020-01-18 21:57:39 +00:00
|
|
|
void load_robot_replacements(const d_fname &level_name);
|
2006-03-20 17:12:09 +00:00
|
|
|
// Initializes all bitmaps from BITMAPS.TBL file.
|
2018-10-21 00:24:07 +00:00
|
|
|
int gamedata_read_tbl(d_vclip_array &Vclip, int pc_shareware);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2018-10-21 00:24:07 +00:00
|
|
|
void bm_read_all(d_vclip_array &Vclip, PHYSFS_File * fp);
|
2012-11-11 00:14:30 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2018-10-21 00:24:07 +00:00
|
|
|
void properties_read_cmp(d_vclip_array &Vclip, PHYSFS_File * fp);
|
2012-11-11 00:14:30 +00:00
|
|
|
#endif
|
|
|
|
int ds_load(int skip, const char * filename );
|
|
|
|
int compute_average_pixel(grs_bitmap *n);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-09-27 15:42:45 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2020-01-18 21:57:39 +00:00
|
|
|
int load_exit_models();
|
2014-09-27 15:42:45 +00:00
|
|
|
//these values are the number of each item in the release of d2
|
|
|
|
//extra items added after the release get written in an additional hamfile
|
2017-10-14 17:10:30 +00:00
|
|
|
constexpr std::integral_constant<unsigned, 66> N_D2_ROBOT_TYPES{};
|
|
|
|
constexpr std::integral_constant<unsigned, 1145> N_D2_ROBOT_JOINTS{};
|
|
|
|
constexpr std::integral_constant<unsigned, 422> N_D2_OBJBITMAPS{};
|
|
|
|
constexpr std::integral_constant<unsigned, 502> N_D2_OBJBITMAPPTRS{};
|
|
|
|
constexpr std::integral_constant<unsigned, 62> N_D2_WEAPON_TYPES{};
|
2014-09-27 15:42:45 +00:00
|
|
|
#endif
|
2020-10-07 03:59:14 +00:00
|
|
|
}
|
2014-09-27 15:42:45 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|