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 BLADERUNNER_SLICE_ANIMATIONS_H 24 #define BLADERUNNER_SLICE_ANIMATIONS_H 25 26 #include "common/array.h" 27 #include "common/file.h" 28 #include "common/str.h" 29 #include "common/types.h" 30 31 #include "bladerunner/color.h" 32 #include "bladerunner/vector.h" 33 34 35 namespace BladeRunner { 36 37 class BladeRunnerEngine; 38 39 40 class SliceAnimations { 41 friend class SliceRenderer; 42 43 struct Animation { 44 uint32 frameCount; 45 uint32 frameSize; 46 float fps; 47 Vector3 positionChange; 48 float facingChange; 49 uint32 offset; 50 }; 51 52 struct Palette { 53 uint32 value[256]; 54 Color256 color[256]; 55 56 // uint16 &operator[](size_t i) { return color555[i]; } 57 }; 58 59 struct Page { 60 void *_data; 61 uint32 _lastAccess; 62 PagePage63 Page() : _data(nullptr), _lastAccess(0) {} 64 }; 65 66 struct PageFile { 67 int _fileNumber; 68 SliceAnimations *_sliceAnimations; 69 Common::File _files[5]; 70 Common::Array<int32> _pageOffsets; 71 Common::Array<int8> _pageOffsetsFileIdx; 72 PageFilePageFile73 PageFile(SliceAnimations *sliceAnimations) : _sliceAnimations(sliceAnimations), _fileNumber(-1) {} 74 75 bool open(const Common::String &name, int8 fileIdx); 76 void close(int8 fileIdx); 77 void *loadPage(uint32 page); 78 }; 79 80 BladeRunnerEngine *_vm; 81 82 uint32 _timestamp; 83 uint32 _pageSize; 84 uint32 _pageCount; 85 uint32 _paletteCount; 86 87 Common::Array<Palette> _palettes; 88 Common::Array<Animation> _animations; 89 Common::Array<Page> _pages; 90 91 PageFile _coreAnimPageFile; 92 PageFile _framesPageFile; 93 94 public: SliceAnimations(BladeRunnerEngine * vm)95 SliceAnimations(BladeRunnerEngine *vm) 96 : _vm(vm) 97 , _coreAnimPageFile(this) 98 , _framesPageFile(this) 99 , _timestamp(0) 100 , _pageSize(0) 101 , _pageCount(0) 102 , _paletteCount(0) {} 103 ~SliceAnimations(); 104 105 bool open(const Common::String &name); 106 107 bool openCoreAnim(); 108 bool openFrames(int fileNumber); 109 getPalette(int i)110 Palette &getPalette(int i) { return _palettes[i]; }; 111 void *getFramePtr(uint32 animation, uint32 frame); 112 getFrameCount(int animation)113 int getFrameCount(int animation) const { return _animations[animation].frameCount; } getFPS(int animation)114 float getFPS(int animation) const { return _animations[animation].fps; } 115 116 Vector3 getPositionChange(int animation) const; 117 float getFacingChange(int animation) const; 118 }; 119 120 } // End of namespace BladeRunner 121 122 #endif 123