1 2 /** 3 * 4 * @file jj1scene.h 5 * 6 * Part of the OpenJazz project 7 * 8 * @par History: 9 * - 23rd August 2005: Created scene.c 10 * - 3rd February 2009: Created scene.h from parts of scene.c 11 * - 1st August 2012: Renamed scene.h to jj1scene.h 12 * 13 * @par Licence: 14 * Copyright (c) 2005-2017 Alister Thomson 15 * 16 * OpenJazz is distributed under the terms of 17 * the GNU General Public License, version 2.0 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 */ 24 25 26 #ifndef _SCENE_H 27 #define _SCENE_H 28 29 30 #include "io/file.h" 31 32 33 // Enums 34 35 /** 36 * Cutscene file animation headers 37 11 38 1L 39 /0/0 40 PB 41 FF 42 RN 43 RB 44 RC 45 RL 46 RR 47 ][ 48 PL 49 AN 50 _E 51 MX 52 ST 53 SL 54 */ 55 enum ANIHeaders 56 { 57 E11AniHeader = 0x3131, ///< Background/start image 58 E1LAniHeader = 0x4c31, 59 EPBAniHeader = 0x4250, 60 EFFAniHeader = 0x4646, ///< Floodfill? or full frame? 61 ERNAniHeader = 0x4e52, 62 ERBAniHeader = 0x4252, 63 ERCAniHeader = 0x4352, 64 ERLAniHeader = 0x4c52, 65 ERRAniHeader = 0x5252, 66 E_EHeader = 0x455F, ///< ANI End 67 ESquareAniHeader = 0x5b5d, 68 EMXAniHeader = 0x584d, 69 ESTAniHeader = 0x5453, ///< Sound tag 70 ESoundListAniHeader = 0x4C53, 71 EPlayListAniHeader = 0x4C50 72 }; 73 74 /// Cutscene script types - these are the known types 75 enum { 76 ESceneYesNo = 0x23, 77 ESceneMusic = 0x2A, 78 ESceneStopMusic = 0x2D, 79 ESceneFadeType = 0x3F, 80 ESceneTextBlock = 0x40, 81 ESceneTextColour = 0x41, 82 ESceneFontFun = 0x45, 83 ESceneFontIndex = 0x46, 84 ESceneTextPosition = 0x47, 85 ESceneTextAlign = 0x4A, 86 ESceneTextAlign2 = 0x4B, 87 ESceneBackground = 0x4c, 88 ESceneBreaker = 0x50, 89 ESceneSomethingElse = 0x51, 90 ESceneTextRect = 0x57, 91 ESceneFontDefine = 0x58, 92 ESceneTime = 0x5d, 93 ESceneTextLine = 0x5e, 94 ESceneTextVAdjust = 0x5f, 95 ESceneAnimationPlayAndContinue = 0xA7, 96 ESceneAnimation = 0xA6, 97 ESceneBackgroundFade = 0xb1, 98 ESceneTextSomething = 0xd9, 99 ESceneTextShadow = 0xdb 100 101 }; 102 103 104 // Classes 105 106 class Font; 107 108 /// Cutscene page text 109 class JJ1SceneText { 110 111 public: 112 unsigned char* text; 113 int alignment; 114 int fontId; 115 int x; 116 int y; 117 SDL_Rect textRect; 118 int extraLineHeight; 119 int shadowColour; 120 121 JJ1SceneText (); 122 ~JJ1SceneText (); 123 124 }; 125 126 /// Cutscene page 127 class JJ1ScenePage { 128 129 public: 130 int backgrounds; 131 int bgIndex[30]; 132 unsigned short int bgX[30]; 133 unsigned short int bgY[30]; 134 135 int animLoops; 136 int animSpeed; 137 int animIndex; 138 int nextPageAfterAnim; 139 140 /// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction 141 int pageTime; 142 JJ1SceneText texts[100]; 143 int nTexts; 144 char* musicFile; 145 int paletteIndex; 146 int askForYesNo; 147 int stopMusic; 148 int backgroundFade; 149 JJ1ScenePage (); 150 ~JJ1ScenePage (); 151 152 }; 153 154 /// Cutscene background image 155 class JJ1SceneImage { 156 157 public: 158 JJ1SceneImage* next; 159 SDL_Surface* image; 160 int id; 161 162 JJ1SceneImage (JJ1SceneImage* newNext); 163 ~JJ1SceneImage (); 164 165 }; 166 167 /// Cutscene palette 168 class JJ1ScenePalette { 169 170 public: 171 JJ1ScenePalette* next; 172 SDL_Color palette[256]; 173 int id; 174 175 JJ1ScenePalette (JJ1ScenePalette* newNext); 176 ~JJ1ScenePalette (); 177 178 }; 179 180 /// Cutscene font 181 class JJ1SceneFont { 182 183 public: 184 Font *font; 185 int id; 186 187 }; 188 189 /// Cutscene animation frame 190 class JJ1SceneFrame { 191 192 public: 193 JJ1SceneFrame* next; 194 JJ1SceneFrame* prev; 195 unsigned char* frameData; 196 int frameSize; 197 unsigned int frameType; 198 unsigned char soundId; 199 200 JJ1SceneFrame (int frameType, unsigned char* frameData, int frameSize); 201 ~JJ1SceneFrame (); 202 203 }; 204 205 /// Cutscene animation 206 class JJ1SceneAnimation { 207 208 public: 209 JJ1SceneAnimation* next; 210 JJ1SceneFrame* sceneFrames; 211 JJ1SceneFrame* lastFrame; 212 213 SDL_Surface* background; 214 int id; 215 int frames; 216 int reverseAnimation; 217 218 JJ1SceneAnimation (JJ1SceneAnimation* newNext); 219 ~JJ1SceneAnimation (); 220 221 void addFrame (int frameType, unsigned char* frameData, int frameSize); 222 223 }; 224 225 /// Cutscene 226 class JJ1Scene { 227 228 private: 229 JJ1SceneAnimation* animations; 230 JJ1SceneImage* images; 231 JJ1ScenePalette* palettes; 232 JJ1SceneFont fonts[5]; 233 int nFonts; 234 unsigned short int scriptItems; 235 unsigned short int dataItems; 236 signed long int* scriptStarts; 237 signed long int* dataOffsets; 238 239 /// Scripts all information needed to render script pages, text etc 240 JJ1ScenePage* pages; 241 242 void loadScripts (File* f); 243 void loadData (File* f); 244 void loadAni (File* f, int dataIndex); 245 void loadCompactedMem (int size, unsigned char* frameData, unsigned char* pixdata); 246 void loadFFMem (int size, unsigned char* frameData, unsigned char* pixdata); 247 unsigned short int loadShortMem (unsigned char **data); 248 249 public: 250 JJ1Scene (const char* fileName); 251 ~JJ1Scene (); 252 253 int play (); 254 255 }; 256 257 #endif 258 259