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