1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef TWINE_RESOURCES_RESOURCES_H 24 #define TWINE_RESOURCES_RESOURCES_H 25 26 #include "common/hashmap.h" 27 #include "common/scummsys.h" 28 #include "twine/parser/body.h" 29 #include "twine/parser/holomap.h" 30 #include "twine/parser/sprite.h" 31 #include "twine/parser/text.h" 32 #include "twine/resources/hqr.h" 33 #include "twine/scene/gamestate.h" 34 #include "twine/scene/scene.h" 35 36 namespace TwinE { 37 38 /** RESS.HQR FILE */ 39 #define RESSHQR_MAINPAL 0 40 #define RESSHQR_LBAFONT 1 41 #define RESSHQR_BLANK 2 42 #define RESSHQR_SPRITEBOXDATA 3 43 #define RESSHQR_SPRITESHADOW 4 44 #define RESSHQR_HOLOPAL 5 45 #define RESSHQR_HOLOSURFACE 6 46 #define RESSHQR_HOLOIMG 7 47 #define RESSHQR_HOLOARROWINFO 8 48 #define RESSHQR_HOLOTWINMDL 9 49 #define RESSHQR_HOLOARROWMDL 10 50 #define RESSHQR_HOLOTWINARROWMDL 11 51 52 #define RESSHQR_GAMEOVERMDL 21 53 54 #define RESSHQR_ALARMREDPAL 22 55 #define RESSHQR_FLAINFO 23 56 #define RESSHQR_DARKPAL 24 57 58 #define RESSHQR_HOLOPOINTMDL 29 59 #define RESSHQR_HOLOPOINTANIM 30 60 61 #define RESSHQR_PLASMAEFFECT 51 62 63 #define FLA_DRAGON3 "dragon3" 64 #define FLA_INTROD "introd" 65 #define FLA_THEEND "the_end" 66 #define FLA_BATEAU "bateau" 67 68 #define FILE3DHQR_HERONORMAL 0 69 #define FILE3DHQR_HEROATHLETIC 1 70 #define FILE3DHQR_HEROAGGRESSIVE 2 71 #define FILE3DHQR_HERODISCRETE 3 72 #define FILE3DHQR_HEROPROTOPACK 4 73 74 /** Behaviour menu sprite values */ 75 #define SPRITEHQR_KASHES 3 76 #define SPRITEHQR_LIFEPOINTS 4 77 #define SPRITEHQR_MAGICPOINTS 5 78 #define SPRITEHQR_KEY 6 79 #define SPRITEHQR_CLOVERLEAF 7 80 #define SPRITEHQR_CLOVERLEAFBOX 41 81 82 #define SPRITEHQR_MAGICBALL_YELLOW 1 83 #define SPRITEHQR_MAGICBALL_FIRE 13 84 #define SPRITEHQR_MAGICBALL_GREEN 42 85 #define SPRITEHQR_MAGICBALL_RED 43 86 #define SPRITEHQR_MAGICBALL_YELLOW_TRANS 44 87 #define SPRITEHQR_EXPLOSION_FIRST_FRAME 97 // 7 frames 88 #define SPRITEHQR_FENCE_1 18 89 #define SPRITEHQR_FENCE_2 19 90 #define SPRITEHQR_FENCE_3 22 91 #define SPRITEHQR_FENCE_4 23 92 #define SPRITEHQR_FENCE_METAL 35 93 #define SPRITEHQR_FENCE_METAL_2 54 94 #define SPRITEHQR_FENCE_METAL_3 83 95 #define SPRITEHQR_MUSHROOM 92 96 #define SPRITEHQR_DOOR_WODDEN_1 31 97 #define SPRITEHQR_DOOR_WODDEN_2 32 98 #define SPRITEHQR_DOOR_PRISON_WODDEN 37 99 #define SPRITEHQR_DOOR_PADLOCK 58 100 #define SPRITEHQR_DOOR_BRICKED_UP 76 101 #define SPRITEHQR_DOOR_1 104 102 #define SPRITEHQR_DOOR_2 107 103 #define SPRITEHQR_DOOR_3 24 104 #define SPRITEHQR_DOOR_4 11 105 #define SPRITEHQR_DOOR_5 12 106 #define SPRITEHQR_DOOR_PRISON_GRID 15 107 #define SPRITEHQR_DOOR_PRISON_HARMED 16 108 #define SPRITEHQR_DOOR_PRISON_WITH_F_LETTER 17 109 #define SPRITEHQR_MAGICBALL_GREEN_TRANS 109 110 #define SPRITEHQR_MAGICBALL_RED_TRANS 110 111 112 #define SPRITEHQR_DIAG_BUBBLE_RIGHT 90 113 #define SPRITEHQR_DIAG_BUBBLE_LEFT 91 114 115 /** Total number of animations allowed in the game */ 116 #define NUM_ANIMS 2083 // 600 for lba1 117 118 /** Total number of samples allowed in the game */ 119 #define NUM_SAMPLES 895 // 243 for lba1 120 121 class TwinEEngine; 122 123 class Resources { 124 private: 125 TwinEEngine *_engine; 126 127 void preloadInventoryItems(); 128 /** Init standard menu and in-game palette */ 129 void initPalettes(); 130 /** Preload all sprites */ 131 void preloadSprites(); 132 /** Preload all animations */ 133 void preloadAnimations(); 134 void preloadSamples(); 135 void loadMovieInfo(); 136 137 using MovieInfoMap = Common::HashMap<Common::String, Common::Array<int32> >; 138 MovieInfoMap _movieInfo; 139 140 TrajectoryData _trajectories; 141 142 TextData _textData; 143 144 public: Resources(TwinEEngine * engine)145 Resources(TwinEEngine *engine) : _engine(engine) {} 146 ~Resources(); 147 148 /** 149 * For lba1 this is returning the gif images that are used as a placeholder for the fla movies 150 * For lba2 this is the list of videos that are mapped by their entry index 151 */ 152 const Common::Array<int32> &getMovieInfo(const Common::String &name) const; 153 154 /** Table with all loaded samples */ 155 BodyData _inventoryTable[NUM_INVENTORY_ITEMS]; 156 157 /** Table with all loaded sprites */ 158 uint8 *_spriteTable[NUM_SPRITES]{nullptr}; 159 /** Table with all loaded sprite sizes */ 160 uint32 _spriteSizeTable[NUM_SPRITES]{0}; 161 SpriteData _spriteData[NUM_SPRITES]; 162 163 AnimData _animData[NUM_ANIMS]; 164 165 /** Actors 3D body table - size of NUM_BODIES */ 166 BodyData _bodyData[NUM_BODIES]; 167 168 /** Table with all loaded samples */ 169 uint8 *_samplesTable[NUM_SAMPLES]{nullptr}; 170 /** Table with all loaded samples sizes */ 171 uint32 _samplesSizeTable[NUM_SAMPLES]{0}; 172 173 /** Font buffer pointer */ 174 int32 _fontBufSize = 0; 175 uint8 *_fontPtr = nullptr; 176 177 SpriteData _spriteShadowPtr; 178 SpriteBoundingBoxData _spriteBoundingBox; 179 180 BodyData _holomapPointModelPtr; 181 BodyData _holomapTwinsenModelPtr; 182 BodyData _holomapTwinsenArrowPtr; 183 BodyData _holomapArrowPtr; 184 185 /** Initialize resource pointers */ 186 void initResources(); 187 188 const Trajectory *getTrajectory(int index) const; 189 190 const TextEntry *getText(TextBankId textBankId, TextId index) const; 191 192 // main palette 193 static constexpr const char *HQR_RESS_FILE = "ress.hqr"; 194 // dialoges 195 static constexpr const char *HQR_TEXT_FILE = "text.hqr"; 196 // samples 197 static constexpr const char *HQR_SAMPLES_FILE = "samples.hqr"; 198 /** 199 * This file contains isometric grids that are used to display area backgrounds and define 3D shape of the surface. 200 * Each of the entries is associated with the entry of lba_bll.hqr with the same index. lba_bll entries define block 201 * sets for use with the grids. Each grid may use only one set of blocks (one entry of lba_bll.hqr). 202 */ 203 static constexpr const char *HQR_LBA_GRI_FILE = "lba_gri.hqr"; 204 // isometric libraries for use in grids. 205 static constexpr const char *HQR_LBA_BLL_FILE = "lba_bll.hqr"; 206 /** 207 * isometric bricks, which are some kind of tiles, that are used for building the terrains in LBA 1 isometric scenes. 208 * One brick is the tiniest piece of a grid, which has 64 x 64 x 25 cells. Bricks cannot be used directly on a grid, 209 * but instead they are grouped into blocks by block libraries, which are then referenced by grids 210 * Bricks are images or sprites in a special format. 211 */ 212 static constexpr const char *HQR_LBA_BRK_FILE = "lba_brk.hqr"; 213 // scenes (active area content (actors, scripts, etc.)) 214 static constexpr const char *HQR_SCENE_FILE = "scene.hqr"; 215 // full screen images (lba2) 216 static constexpr const char *HQR_SCREEN_FILE = "screen.hqr"; 217 // sprites 218 static constexpr const char *HQR_SPRITES_FILE = "sprites.hqr"; 219 /** 220 * model/animation entities 221 * contains data associating 3D models (Body.hqr) with animations (Anim.hqr) for the game characters. 222 */ 223 static constexpr const char *HQR_FILE3D_FILE = "file3d.hqr"; 224 // 3d model data 225 static constexpr const char *HQR_BODY_FILE = "body.hqr"; 226 // animations 227 static constexpr const char *HQR_ANIM_FILE = "anim.hqr"; 228 // inventory objects 229 static constexpr const char *HQR_INVOBJ_FILE = "invobj.hqr"; 230 231 /** 232 * @brief Floppy version of the game uses gifs for replacing the videos 233 */ 234 static constexpr const char *HQR_FLAGIF_FILE = "fla_gif.hqr"; 235 static constexpr const char *HQR_FLASAMP_FILE = "flasamp.hqr"; 236 static constexpr const char *HQR_MIDI_MI_DOS_FILE = "midi_mi.hqr"; 237 static constexpr const char *HQR_MIDI_MI_WIN_FILE = "midi_mi_win.hqr"; 238 239 static constexpr const char *HQR_VIDEO_FILE = "video.hqr"; // lba2 - smk files 240 adelineLogo()241 TwineImage adelineLogo() const { 242 if (_engine->isLBA1()) { 243 return TwineImage(Resources::HQR_RESS_FILE, 27, 28); 244 } 245 return TwineImage(Resources::HQR_SCREEN_FILE, 0, 1); 246 } 247 lbaLogo()248 TwineImage lbaLogo() const { 249 if (_engine->isLBA1()) { 250 return TwineImage(Resources::HQR_RESS_FILE, 49, 50); 251 } 252 return TwineImage(Resources::HQR_SCREEN_FILE, 60, 61); 253 } 254 eaLogo()255 TwineImage eaLogo() const { 256 if (_engine->isLBA1()) { 257 return TwineImage(Resources::HQR_RESS_FILE, 52, 53); 258 } 259 return TwineImage(Resources::HQR_SCREEN_FILE, 74, 75); 260 } 261 activisionLogo()262 TwineImage activisionLogo() const { 263 assert(_engine->isLBA2()); 264 return TwineImage(Resources::HQR_SCREEN_FILE, 72, 73); 265 } 266 virginLogo()267 TwineImage virginLogo() const { 268 assert(_engine->isLBA2()); 269 return TwineImage(Resources::HQR_SCREEN_FILE, 76, 77); 270 } 271 relentLogo()272 TwineImage relentLogo() const { 273 assert(_engine->isLBA1()); 274 return TwineImage(Resources::HQR_RESS_FILE, 12, 13); 275 } 276 menuBackground()277 TwineImage menuBackground() const { 278 if (_engine->isLBA1()) { 279 return TwineImage(Resources::HQR_RESS_FILE, 14, -1); 280 } 281 return TwineImage(Resources::HQR_SCREEN_FILE, 4, 5); 282 } 283 }; 284 285 } // namespace TwinE 286 287 #endif 288