ScummVM API documentation
frame.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 DIRECTOR_FRAME_H
23 #define DIRECTOR_FRAME_H
24 
25 namespace Image {
26 class ImageDecoder;
27 }
28 
29 namespace Graphics {
30 class ManagedSurface;
31 struct Surface;
32 }
33 
34 namespace Common {
35 class ReadStreamEndian;
36 class MemoryReadStreamEndian;
37 class SeekableWriteStream;
38 }
39 
40 namespace Director {
41 
42 class Score;
43 class Sprite;
44 class TextCastMember;
45 
46 enum {
47  kMainChannelSizeD2 = 32,
48  kSprChannelSizeD2 = 16,
49 
50  kMainChannelSizeD4 = 40,
51  kSprChannelSizeD4 = 20,
52 
53  kMainChannelSizeD5 = 48,
54  kSprChannelSizeD5 = 24,
55 
56  kMainChannelSizeD6 = 144,
57  kSprChannelSizeD6 = 24,
58 
59  kMainChannelSizeD7 = 288,
60  kSprChannelSizeD7 = 48,
61 };
62 
63 struct PaletteInfo {
64  CastMemberID paletteId;
65 
66  byte firstColor;
67  byte lastColor;
68  byte flags;
69  bool colorCycling;
70  bool normal;
71  bool fadeToWhite;
72  bool fadeToBlack;
73  bool autoReverse;
74  bool overTime;
75  byte speed;
76  uint16 frameCount;
77  uint16 cycleCount;
78  byte fade;
79  byte delay;
80  byte style;
81  byte colorCode;
82 
83  uint32 spriteListIdx; // D6+
84 
85  PaletteInfo() {
86  paletteId = CastMemberID(0, 0);
87  firstColor = lastColor = 0;
88  flags = 0; colorCycling = false;
89  normal = false; fadeToWhite = false;
90  fadeToBlack = false; autoReverse = false;
91  overTime = false; speed = 0;
92  frameCount = cycleCount = 0;
93  fade = delay = style = colorCode = 0;
94  spriteListIdx = 0;
95  }
96 };
97 
98 struct MainChannels {
99  CastMemberID actionId;
100  uint32 scriptSpriteListIdx; // D6+
101 
102  uint16 transDuration;
103  uint8 transArea; // 1 - Whole Window, 0 - Changing Area
104  uint8 transChunkSize;
105  TransitionType transType;
106  CastMemberID trans;
107  uint32 transSpriteListIdx; // D6+
108  PaletteInfo palette;
109  uint8 tempo;
110  uint32 tempoSpriteListIdx; // D6+
111  uint16 tempoD6Flags;
112 
113  uint8 scoreCachedTempo;
114  CastMemberID scoreCachedPaletteId;
115 
116  CastMemberID sound1;
117  uint8 soundType1;
118  uint32 sound1SpriteListIdx; // D6+
119  CastMemberID sound2;
120  uint8 soundType2;
121  uint32 sound2SpriteListIdx; // D6+
122 
123  byte colorTempo;
124  byte colorSound1;
125  byte colorSound2;
126  byte colorScript;
127  byte colorTrans;
128 
129  uint8 skipFrameFlag;
130  uint8 blend;
131 
132  MainChannels() {
133  transDuration = 0;
134  transType = kTransNone;
135  transArea = 0;
136  transChunkSize = 0;
137  tempo = 0;
138  tempoSpriteListIdx = 0;
139  tempoD6Flags = 0;
140 
141  scoreCachedTempo = 0;
142  scoreCachedPaletteId = CastMemberID(0, 0);
143 
144  sound1 = CastMemberID(0, 0);
145  sound2 = CastMemberID(0, 0);
146  soundType1 = 0;
147  soundType2 = 0;
148  sound1SpriteListIdx = 0;
149  sound2SpriteListIdx = 0;
150 
151  actionId = CastMemberID(0, 0);
152  scriptSpriteListIdx = 0;
153  skipFrameFlag = 0;
154  blend = 0;
155 
156  colorTempo = 0;
157  colorSound1 = 0;
158  colorSound2 = 0;
159  colorScript = 0;
160  colorTrans = 0;
161  }
162 };
163 
164 struct FrameEntity {
165  uint16 spriteId;
166  Common::Rect rect;
167 };
168 
169 
170 class Frame {
171 public:
172  Frame(Score *score, int numChannels);
173  Frame(const Frame &frame);
174  ~Frame();
175 
176  void reset();
177 
178  Score *getScore() const { return _score; }
179 
180  void readChannel(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size, uint16 version);
181  void writeMainChannels(Common::SeekableWriteStream *writeStream, uint16 version);
182 
183  void executeImmediateScripts();
184 
185  Common::String formatChannelInfo();
186 
187 private:
188 
189  void readChannelD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
190  void readSpriteD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
191  void readMainChannelsD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
192 
193  void readChannelD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
194  void readSpriteD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
195  void readMainChannelsD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
196 
197  void writeMainChannelsD4(Common::SeekableWriteStream *writeStream);
198 
199  void readChannelD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
200  void readSpriteD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
201  void readMainChannelsD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
202 
203  void writeMainChannelsD5(Common::SeekableWriteStream *writeStream);
204 
205  void readChannelD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
206  void readSpriteD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
207  void readMainChannelsD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
208 
209  void writeMainChannelsD6(Common::SeekableWriteStream *writeStream);
210 
211  void readChannelD7(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
212  void readSpriteD7(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
213  void readMainChannelsD7(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
214 
215  void writeMainChannelsD7(Common::SeekableWriteStream *writeStream);
216 
217  Image::ImageDecoder *getImageFrom(uint16 spriteId);
218  Common::String readTextStream(Common::SeekableReadStreamEndian *textStream, TextCastMember *textCast);
219 
220 
221 public:
222  int _numChannels;
223  MainChannels _mainChannels;
224  Common::Array<Sprite *> _sprites;
225  Score *_score;
226  DirectorEngine *_vm;
227 };
228 
229 void readSpriteDataD2(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
230 void readSpriteDataD4(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
231 void readSpriteDataD5(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
232 void readSpriteDataD6(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
233 void readSpriteDataD7(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
234 
235 void writeSpriteDataD4(Common::SeekableWriteStream *writeStream, Sprite &sprite);
236 void writeSpriteDataD5(Common::SeekableWriteStream *writeStream, Sprite &sprite);
237 void writeSpriteDataD6(Common::SeekableWriteStream *writeStream, Sprite &sprite);
238 void writeSpriteDataD7(Common::SeekableWriteStream *writeStream, Sprite &sprite);
239 
240 } // End of namespace Director
241 
242 #endif
Definition: image_decoder.h:53
Definition: str.h:59
Definition: array.h:52
Definition: frame.h:63
Definition: rect.h:524
Definition: archive.h:36
Definition: memstream.h:103
Definition: algorithm.h:29
Definition: sprite.h:56
Definition: formatinfo.h:28
Definition: score.h:64
Definition: stream.h:351
Definition: frame.h:164
Definition: stream.h:944
Definition: director.h:156
Definition: text.h:33
Definition: movie_decoder.h:32
Definition: frame.h:170
Definition: frame.h:98
Definition: types.h:411