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
34namespace BladeRunner {
35
36class 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 // Use a doubly linked list to sort pages by access time
62 Page *_prevPage;
63 Page *_nextPage;
64
65 Page() : _data(nullptr), _lastAccess(0), _prevPage(nullptr), _nextPage(nullptr) {}
66 };
67
68 struct PageFile {
69 int _fileNumber;
70 SliceAnimations *_sliceAnimations;
71 Common::File _files[5];
72 Common::Array<int32> _pageOffsets;
73 Common::Array<int8> _pageOffsetsFileIdx;
74
75 PageFile(SliceAnimations *sliceAnimations) : _sliceAnimations(sliceAnimations), _fileNumber(-1) {}
76
77 bool open(const Common::Path &name, int8 fileIdx);
78 void close(int8 fileIdx);
79 void *loadPage(uint32 page);
80 };
81
83
84 uint32 _timestamp;
85 uint32 _pageSize;
86 uint32 _pageCount;
87 uint32 _paletteCount;
88
89 Common::Array<Palette> _palettes;
90 Common::Array<Animation> _animations;
92 Page *_lastUsedPage;
93
94 PageFile _coreAnimPageFile;
95 PageFile _framesPageFile;
96
97 void updatePagesList(Page &page, bool newPage);
98 void cleanupOutdatedPages();
99
100public:
102 : _vm(vm)
103 , _coreAnimPageFile(this)
104 , _framesPageFile(this)
105 , _timestamp(0)
106 , _pageSize(0)
107 , _pageCount(0)
108 , _paletteCount(0)
109 , _lastUsedPage(nullptr) {}
111
112 bool open(const Common::String &name);
113
114 bool openCoreAnim();
115 bool openFrames(int fileNumber);
116
117 Palette &getPalette(int i) { return _palettes[i]; };
118 void *getFramePtr(uint32 animation, uint32 frame);
119
120 int getFrameCount(int animation) const { return _animations[animation].frameCount; }
121 float getFPS(int animation) const { return _animations[animation].fps; }
122
123 Vector3 getPositionChange(int animation) const;
124 float getFacingChange(int animation) const;
125};
126
127} // End of namespace BladeRunner
128
129#endif
Definition: bladerunner.h:113
Definition: slice_animations.h:39
Definition: slice_renderer.h:45
Definition: vector.h:47
Definition: file.h:47
Definition: path.h:52
Definition: str.h:59
Definition: color.h:47