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 LASTEXPRESS_ANIMATION_H
23 #define LASTEXPRESS_ANIMATION_H
24 
25 /*
26  Animation format (.NIS)
27 
28  uint32 {4} - Number of chunks
29 
30  // for each chunk
31  uint16 {2} - Type
32  uint16 {2} - Tag
33  uint32 {4} - Size of chunk
34  byte {x} - Data (for "data" chunks: backgrounds, overlay & audio data)
35 */
36 
37 #include "lastexpress/drawable.h"
38 
39 #include "common/array.h"
40 
41 namespace Common {
42 class SeekableReadStream;
43 }
44 
45 namespace LastExpress {
46 
47 class AnimFrame;
48 class AppendableSound;
49 
50 class Animation : public Drawable {
51 public:
52  enum FlagType {
53  kFlagDefault = 16384,
54  kFlagProcess = 49152
55  };
56 
57  Animation();
58  ~Animation() override;
59 
60  bool load(Common::SeekableReadStream *stream, int flag = kFlagDefault);
61  bool process();
62  bool hasEnded();
63  Common::Rect draw(Graphics::Surface *surface) override;
64  void play();
65 
66 private:
67  static const uint32 _soundBlockSize = 739;
68 
69  // despite their size field, info chunks don't have a payload
70  enum ChunkType {
71  kChunkTypeNone = 0,
72  kChunkTypeUnknown1 = 1,
73  kChunkTypeUnknown2 = 2,
74  kChunkTypeAudioInfo = 3,
75  kChunkTypeUnknown4 = 4,
76  kChunkTypeUnknown5 = 5,
77  kChunkTypeBackground1 = 10,
78  kChunkTypeSelectBackground1 = 11,
79  kChunkTypeBackground2 = 12,
80  kChunkTypeSelectBackground2 = 13,
81  kChunkTypeOverlay = 20,
82  kChunkTypeUpdate = 21,
83  kChunkTypeUpdateTransition = 22,
84  kChunkTypeSound1 = 30,
85  kChunkTypeSound2 = 31,
86  kChunkTypeAudioData = 32,
87  kChunkTypeAudioEnd = 99
88  };
89 
90  struct Chunk {
91  ChunkType type;
92  uint16 frame;
93  uint32 size;
94 
95  Chunk() {
96  type = kChunkTypeNone;
97  frame = 0;
98  size = 0;
99  }
100  };
101 
102  void reset();
103  AnimFrame *processChunkFrame(Common::SeekableReadStream *in, const Chunk &c) const;
104  void processChunkAudio(Common::SeekableReadStream *in, const Chunk &c);
105 
107  Common::Array<Chunk> _chunks;
108  Common::Array<Chunk>::iterator _currentChunk;
109  AnimFrame *_overlay, *_background1, *_background2;
110  byte _backgroundCurrent;
111  AppendableSound *_audio;
112 
113  uint32 _startTime;
114  bool _changed;
115 };
116 
117 } // End of namespace LastExpress
118 
119 #endif // LASTEXPRESS_ANIMATION_H
Definition: surface.h:67
Definition: animation.h:50
Definition: sequence.h:130
Definition: snd.h:93
T * iterator
Definition: array.h:54
Definition: rect.h:144
Definition: stream.h:745
Definition: animation.h:45
Definition: drawable.h:29
Definition: algorithm.h:29