1 /************************************************************************ 2 * * 3 * FreeSynd - a remake of the classic Bullfrog game "Syndicate". * 4 * * 5 * Copyright (C) 2005 Stuart Binge <skbinge@gmail.com> * 6 * Copyright (C) 2005 Joost Peters <joostp@users.sourceforge.net> * 7 * Copyright (C) 2006 Trent Waddington <qg@biodome.org> * 8 * * 9 * This program is free software; you can redistribute it and / or * 10 * modify it under the terms of the GNU General Public License as * 11 * published by the Free Software Foundation; either version 2 of the * 12 * License, or (at your option) any later version. * 13 * * 14 * This program is distributed in the hope that it will be useful, * 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 17 * General Public License for more details. * 18 * * 19 * You can view the GNU General Public License, online, at the GNU * 20 * project's web site; see <http://www.gnu.org/licenses/gpl.html>. * 21 * The full text of the license is also included in the file COPYING. * 22 * * 23 ************************************************************************/ 24 25 #ifndef FLIPLAYER_H 26 #define FLIPLAYER_H 27 28 #include "common.h" 29 #include "system.h" 30 31 typedef struct FliHeader { 32 uint32 size; 33 uint16 type; //0xAF12 34 uint16 numFrames; 35 uint16 width; 36 uint16 height; 37 } FliHeader; 38 39 typedef struct ChunkHeader { 40 uint32 size; 41 uint16 type; 42 } ChunkHeader; 43 44 typedef struct FrameTypeChunkHeader { 45 ChunkHeader header; 46 uint16 numChunks; 47 uint16 delay; 48 uint16 reserved; // always zero 49 uint16 widthOverride; 50 uint16 heightOverride; 51 } FrameTypeChunkHeader; 52 53 class Font; 54 class MenuManager; 55 56 /*! 57 * A player for fli animation. 58 */ 59 class FliPlayer { 60 public: FliPlayer(MenuManager * pManager)61 FliPlayer(MenuManager *pManager) : fli_data_(0), offscreen_(0) {pManager_ = pManager;} 62 virtual ~FliPlayer(); 63 64 //! Play an entire animation without interruption 65 bool play(bool intro = false, Font *pIntroFont = NULL); 66 void loadFliData(uint8 *buf); 67 bool decodeFrame(); 68 void copyCurrentFrameToScreen(); 69 width()70 int width() const { return fli_data_ ? fli_info_.width : 0; } height()71 int height() const { return fli_data_ ? fli_info_.height : 0; } 72 hasFrames()73 bool hasFrames() const { 74 return fli_data_ ? fli_info_.numFrames > 0 : false; 75 } 76 offscreen()77 const uint8 *offscreen() const { return offscreen_; } 78 79 protected: 80 bool isValidChunk(uint16 type); 81 ChunkHeader readChunkHeader(uint8 *mem); 82 FrameTypeChunkHeader readFrameTypeChunkHeader(ChunkHeader chunkHead, 83 uint8 *&mem); 84 void decodeByteRun(uint8 *data); 85 void decodeDeltaFLC(uint8 *data); 86 void setPalette(uint8 *mem); 87 88 uint8 *fli_data_; 89 const uint8 *offscreen_; 90 uint8 palette_[256 * 3]; 91 FliHeader fli_info_; 92 MenuManager *pManager_; 93 }; 94 95 #endif 96