| 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 <ranges> |
| 29 |
#include <span> |
| 30 |
#include "dsx-ns.h" |
| 31 |
#include "fwd-inferno.h" |
| 32 |
#include "fwd-gr.h" |
| 33 |
#include "fwd-partial_range.h" |
| 34 |
#include "sounds.h" |
| 35 |
#include "physfsx.h" |
| 36 |
|
| 37 |
namespace dcx { |
| 38 |
|
| 39 |
enum class game_sound_offset : int |
| 40 |
{ |
| 41 |
}; |
| 42 |
|
| 43 |
struct digi_sound; |
| 44 |
extern digi_sound bogus_sound; |
| 45 |
extern unsigned Num_sound_files; |
| 46 |
struct BitmapFile; |
| 47 |
|
| 48 |
void swap_0_255(grs_bitmap &bmp); |
| 49 |
void remove_char(char * s, char c); // in piggy.cpp |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
#ifdef DXX_BUILD_DESCENT |
| 54 |
#if DXX_BUILD_DESCENT == 2 |
| 55 |
#define D1_PIGFILE "descent.pig" |
| 56 |
#define MAX_ALIASES 20 |
| 57 |
|
| 58 |
namespace dsx { |
| 59 |
extern char descent_pig_basename[12]; |
| 60 |
struct alias; |
| 61 |
#if DXX_USE_EDITOR |
| 62 |
extern std::array<alias, MAX_ALIASES> alias_list; |
| 63 |
extern unsigned Num_aliases; |
| 64 |
#endif |
| 65 |
|
| 66 |
extern uint8_t Pigfile_initialized; |
| 67 |
} |
| 68 |
#endif |
| 69 |
#endif |
| 70 |
|
| 71 |
// an index into the bitmap collection of the piggy file |
| 72 |
enum class bitmap_index : uint16_t; |
| 73 |
|
| 74 |
#ifdef DXX_BUILD_DESCENT |
| 75 |
#if DXX_BUILD_DESCENT == 1 |
| 76 |
|
| 77 |
extern grs_bitmap bogus_bitmap; |
| 78 |
#endif |
| 79 |
#endif |
| 80 |
extern std::array<uint8_t, 64 * 64> bogus_data; |
| 81 |
|
| 82 |
#ifdef DXX_BUILD_DESCENT |
| 83 |
namespace dsx { |
| 84 |
#if DXX_BUILD_DESCENT == 1 |
| 85 |
extern bool MacPig; |
| 86 |
extern bool PCSharePig; |
| 87 |
#endif |
| 88 |
|
| 89 |
void piggy_close(); |
| 90 |
bitmap_index piggy_register_bitmap(grs_bitmap &bmp, std::span<const char> name, int in_file); |
| 91 |
int piggy_register_sound(digi_sound &snd, std::span<const char> name); |
| 92 |
bitmap_index piggy_find_bitmap(std::span<const char> name); |
| 93 |
void piggy_load_level_data(); |
| 94 |
|
| 95 |
#if DXX_BUILD_DESCENT == 1 |
| 96 |
constexpr std::integral_constant<unsigned, 1800> MAX_BITMAP_FILES{}; |
| 97 |
#define PIGGY_PC_SHAREWARE 2 |
| 98 |
#elif DXX_BUILD_DESCENT == 2 |
| 99 |
// Upped for CD Enhanced |
| 100 |
constexpr std::integral_constant<unsigned, 2620> MAX_BITMAP_FILES{}; |
| 101 |
#endif |
| 102 |
#define MAX_SOUND_FILES MAX_SOUNDS |
| 103 |
|
| 104 |
using GameBitmaps_array = enumerated_array<grs_bitmap, MAX_BITMAP_FILES, bitmap_index>; |
| 105 |
extern std::array<digi_sound, MAX_SOUND_FILES> GameSounds; |
| 106 |
extern GameBitmaps_array GameBitmaps; |
| 107 |
void piggy_bitmap_page_in(GameBitmaps_array &, bitmap_index bmp); |
| 108 |
|
| 109 |
#if DXX_BUILD_DESCENT == 1 |
| 110 |
void piggy_read_sounds(int pc_shareware); |
| 111 |
#elif DXX_BUILD_DESCENT == 2 |
| 112 |
void piggy_init_pigfile(std::span<const char> filename); |
| 113 |
void piggy_read_sounds(void); |
| 114 |
|
| 115 |
//reads in a new pigfile (for new palette) |
| 116 |
//returns the size of all the bitmap data |
| 117 |
void piggy_new_pigfile(std::span<char, FILENAME_LEN> pigname); |
| 118 |
|
| 119 |
//loads custom bitmaps for current level |
| 120 |
void load_bitmap_replacements(std::span<const char, FILENAME_LEN> level_name); |
| 121 |
//if descent.pig exists, loads descent 1 texture bitmaps |
| 122 |
void load_d1_bitmap_replacements(); |
| 123 |
/* |
| 124 |
* Find and load the named bitmap from descent.pig |
| 125 |
*/ |
| 126 |
grs_bitmap *read_extra_bitmap_d1_pig(std::span<const char> name, grs_bitmap &out); |
| 127 |
void read_sndfile(int required); |
| 128 |
#endif |
| 129 |
/* |
| 130 |
* reads a bitmap_index structure from a PHYSFS_File |
| 131 |
*/ |
| 132 |
void bitmap_index_read(NamedPHYSFS_File fp, bitmap_index &bi); |
| 133 |
void bitmap_index_read_n(NamedPHYSFS_File fp, std::ranges::subrange<bitmap_index *> r); |
| 134 |
|
| 135 |
} |
| 136 |
int piggy_find_sound(std::span<const char> name); |
| 137 |
|
| 138 |
void piggy_read_bitmap_data(grs_bitmap * bmp); |
| 139 |
|
| 140 |
#define REMOVE_EOL(s) remove_char((s),'\n') |
| 141 |
#define REMOVE_COMMENTS(s) remove_char((s),';') |
| 142 |
#define REMOVE_DOTS(s) remove_char((s),'.') |
| 143 |
|
| 144 |
extern unsigned Num_bitmap_files; |
| 145 |
extern ubyte bogus_bitmap_initialized; |
| 146 |
#endif |
| 147 |
#define space_tab " \t" |
| 148 |
#define equal_space " \t=" |
| 149 |
#ifdef DXX_BUILD_DESCENT |
| 150 |
#if DXX_BUILD_DESCENT == 1 |
| 151 |
#include "hash.h" |
| 152 |
extern hashtable AllBitmapsNames; |
| 153 |
extern hashtable AllDigiSndNames; |
| 154 |
#elif DXX_BUILD_DESCENT == 2 |
| 155 |
extern enumerated_array<BitmapFile, MAX_BITMAP_FILES, bitmap_index> AllBitmaps; |
| 156 |
#endif |
| 157 |
#endif |
| 158 |
|
| 159 |
enum class pig_bitmap_offset : unsigned |
| 160 |
{ |
| 161 |
None = 0 |
| 162 |
}; |