ScummVM API documentation
animation.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 MADS_ANIMATION_H
23 #define MADS_ANIMATION_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "mads/msurface.h"
28 #include "mads/scene_data.h"
29 #include "mads/font.h"
30 
31 namespace MADS {
32 
33 enum AnimFlag {
34  ANIMFLAG_LOAD_BACKGROUND = 0x0100, // Load background
35  ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200, // Load background only
36 
37  ANIMFLAG_DITHER = 0x0001, // Dither to 16 colors
38  ANIMFLAG_CUSTOM_FONT = 0x2000, // Load custom fonts
39  ANIMFLAG_ANIMVIEW = 0x4000 // Cutscene animation
40 };
41 
42 enum AnimBgType {
43  ANIMBG_ROOM = 1, ANIMBG_FULL_SIZE = 2, ANIMBG_BLACK_SCREEN = 3,
44  ANIMBG_INTERFACE = 4
45 };
46 
47 class MADSEngine;
48 class Scene;
49 
50 class AnimMessage {
51 public:
52  int16 _soundId;
53  Common::String _msg;
54  Common::Point _pos;
55  byte _rgb1[3], _rgb2[3];
56  int _flags;
57  int _startFrame, _endFrame;
58  int _kernelMsgIndex;
59 
64 };
65 
67 public:
68  int _frameNumber;
69  int _seqIndex;
70  SpriteSlotSubset _spriteSlot;
71 
75  void load(Common::SeekableReadStream *f, bool uiFlag);
76 };
77 
79 public:
80  int _soundId;
81  int _msgIndex;
82  int _numTicks;
83  Common::Point _posAdjust;
84  Common::Point _scroll;
85 
90 };
91 
92 #define ANIM_SPAWN_COUNT 2
93 
94 class AnimUIEntry {
95 public:
96  int _probability;
97  int _imageCount;
98  int _firstImage;
99  int _lastImage;
100  int _counter;
101  int _spawn[ANIM_SPAWN_COUNT];
102  int _spawnFrame[ANIM_SPAWN_COUNT];
103  int _sound;
104  int _soundFrame;
105 
110 };
111 
112 class AAHeader {
113 public:
114  int _spriteSetsCount;
115  int _miscEntriesCount;
116  int _frameEntriesCount;
117  int _messagesCount;
118  int _loadFlags;
119  int _charSpacing;
120  AnimBgType _bgType;
121  int _roomNumber;
122  bool _manualFlag;
123  int _spritesIndex;
124  Common::Point _scrollPosition;
125  uint32 _scrollTicks;
126  Common::String _backgroundFile;
127  Common::StringArray _spriteSetNames;
128  Common::String _lbmFilename;
129  Common::String _spritesFilename;
130  Common::String _soundName;
131  Common::String _dsrName;
132  Common::String _fontResource;
133 
138 };
139 
140 class Animation {
141 private:
142  MADSEngine *_vm;
143  Scene *_scene;
144 
145  Common::Array<AnimMiscEntry> _miscEntries;
146  Common::Array<SpriteAsset *> _spriteSets;
147  Font *_font;
148 
149  bool _freeFlag;
150  bool _skipLoad;
151  int _unkIndex;
152  Common::Point _unkList[2];
153  uint32 _nextFrameTimer;
154  uint32 _nextScrollTimer;
155  int _messageCtr;
156  int _trigger;
157  int _flags;
158  int _rgbResult;
159  int _palIndex1, _palIndex2;
160  TriggerMode _triggerMode;
161  ActionDetails _actionDetails;
162 
167  void loadFrame(int frameNumber);
168 
169  bool drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber);
170 
174  void loadBackground(MSurface &backSurface, DepthSurface &depthSurface,
175  AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
176 
180  bool hasScroll() const;
181 protected:
182  Animation(MADSEngine *vm, Scene *scene);
183 public:
184  AAHeader _header;
185  Common::Array<int> _spriteListIndexes;
186  Common::Array<AnimFrameEntry> _frameEntries;
187  Common::Array<AnimUIEntry> _uiEntries;
188  Common::Array<AnimMessage> _messages;
189  bool _resetFlag;
190  bool _canChangeView;
191  int _currentFrame;
192  int _oldFrameEntry;
193  int _dynamicHotspotIndex;
194 
195  static Animation *init(MADSEngine *vm, Scene *scene);
196  /*
197  * Destructor
198  */
199  ~Animation();
200 
204  void load(MSurface &backSurface, DepthSurface &depthSurface, const Common::Path &resName,
205  int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
206 
210  void preLoad(const Common::Path &resName, int level);
211 
215  void startAnimation(int endTrigger);
216 
220  void update();
221 
225  void eraseSprites();
226 
227  void setNextFrameTimer(uint32 newTimer);
228  uint32 getNextFrameTimer() const { return _nextFrameTimer; }
229  void setCurrentFrame(int frameNumber);
230  int getCurrentFrame() const { return _currentFrame; }
231 
232  bool freeFlag() const { return _freeFlag; }
233  int roomNumber() const { return _header._roomNumber; }
234 
235  void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called
236 
237  SpriteAsset *getSpriteSet(int idx) { return _spriteSets[idx]; }
238 
239  Common::Point getFramePosAdjust(int idx);
240 };
241 
242 } // End of namespace MADS
243 
244 #endif /* MADS_ANIMATION_H */
Definition: animation.h:94
Definition: str.h:59
Definition: animation.h:112
Definition: path.h:52
Definition: stream.h:745
Definition: animation.h:66
Definition: animation.h:50
Definition: msurface.h:184
Definition: rect.h:45
Definition: action.h:75
void load(Common::SeekableReadStream *f)
Definition: scene_data.h:141
Definition: scene.h:44
Definition: sprites.h:124
Definition: mads.h:87
Definition: font.h:47
Definition: assets.h:61
Definition: animation.h:78
Definition: action.h:28
Definition: msurface.h:172
Definition: animation.h:140