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