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 }
38 
39 namespace Director {
40 
41 class Score;
42 class Sprite;
43 class TextCastMember;
44 
45 enum {
46  kMainChannelSizeD2 = 32,
47  kSprChannelSizeD2 = 16,
48 
49  kMainChannelSizeD4 = 40,
50  kSprChannelSizeD4 = 20,
51 
52  kMainChannelSizeD5 = 48,
53  kSprChannelSizeD5 = 24,
54 
55  kMainChannelSizeD6 = 48,
56  kSprChannelSizeD6 = 24,
57 };
58 
59 struct PaletteInfo {
60  CastMemberID paletteId;
61 
62  byte firstColor;
63  byte lastColor;
64  byte flags;
65  bool colorCycling;
66  bool normal;
67  bool fadeToWhite;
68  bool fadeToBlack;
69  bool autoReverse;
70  bool overTime;
71  byte speed;
72  uint16 frameCount;
73  uint16 cycleCount;
74  byte fade;
75  byte delay;
76  byte style;
77  byte colorCode;
78 
79  PaletteInfo() {
80  paletteId = CastMemberID(0, 0);
81  firstColor = lastColor = 0;
82  flags = 0; colorCycling = false;
83  normal = false; fadeToWhite = false;
84  fadeToBlack = false; autoReverse = false;
85  overTime = false; speed = 0;
86  frameCount = cycleCount = 0;
87  fade = delay = style = colorCode = 0;
88  }
89 };
90 
91 struct MainChannels {
92  CastMemberID actionId;
93  uint16 transDuration;
94  uint8 transArea; // 1 - Whole Window, 0 - Changing Area
95  uint8 transChunkSize;
96  TransitionType transType;
97  CastMemberID trans;
98  PaletteInfo palette;
99  uint8 tempo;
100 
101  uint8 scoreCachedTempo;
102  CastMemberID scoreCachedPaletteId;
103 
104  CastMemberID sound1;
105  uint8 soundType1;
106  CastMemberID sound2;
107  uint8 soundType2;
108 
109  byte colorTempo;
110  byte colorSound1;
111  byte colorSound2;
112  byte colorScript;
113  byte colorTrans;
114 
115  uint8 skipFrameFlag;
116  uint8 blend;
117 
118  MainChannels() {
119  transDuration = 0;
120  transType = kTransNone;
121  transArea = 0;
122  transChunkSize = 0;
123  tempo = 0;
124 
125  scoreCachedTempo = 0;
126  scoreCachedPaletteId = CastMemberID(0, 0);
127 
128  sound1 = CastMemberID(0, 0);
129  sound2 = CastMemberID(0, 0);
130  soundType1 = 0;
131  soundType2 = 0;
132 
133  actionId = CastMemberID(0, 0);
134  skipFrameFlag = 0;
135  blend = 0;
136 
137  colorTempo = 0;
138  colorSound1 = 0;
139  colorSound2 = 0;
140  colorScript = 0;
141  colorTrans = 0;
142  }
143 };
144 
145 struct FrameEntity {
146  uint16 spriteId;
147  Common::Rect rect;
148 };
149 
150 
151 class Frame {
152 public:
153  Frame(Score *score, int numChannels);
154  Frame(const Frame &frame);
155  ~Frame();
156 
157  void reset();
158 
159  Score *getScore() const { return _score; }
160 
161  void readChannel(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size, uint16 version);
162 
163  void executeImmediateScripts();
164 
165  Common::String formatChannelInfo();
166 
167 private:
168 
169  void readChannelD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
170  void readSpriteD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
171  void readMainChannelsD2(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
172 
173  void readChannelD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
174  void readSpriteD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
175  void readMainChannelsD4(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
176 
177  void readChannelD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
178  void readSpriteD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
179  void readMainChannelsD5(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
180 
181  void readChannelD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
182  void readSpriteD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
183  void readMainChannelsD6(Common::MemoryReadStreamEndian &stream, uint16 offset, uint16 size);
184 
185  Image::ImageDecoder *getImageFrom(uint16 spriteId);
186  Common::String readTextStream(Common::SeekableReadStreamEndian *textStream, TextCastMember *textCast);
187 
188 
189 public:
190  int _numChannels;
191  MainChannels _mainChannels;
192  Common::Array<Sprite *> _sprites;
193  Score *_score;
194  DirectorEngine *_vm;
195 };
196 
197 void readSpriteDataD2(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
198 void readSpriteDataD4(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
199 void readSpriteDataD5(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
200 void readSpriteDataD6(Common::SeekableReadStreamEndian &stream, Sprite &sprite, uint32 startPosition, uint32 finishPosition);
201 
202 } // End of namespace Director
203 
204 #endif
Definition: image_decoder.h:52
Definition: str.h:59
Definition: array.h:52
Definition: frame.h:59
Definition: rect.h:144
Definition: archive.h:35
Definition: memstream.h:103
Definition: algorithm.h:29
Definition: sprite.h:56
Definition: formatinfo.h:28
Definition: score.h:63
Definition: frame.h:145
Definition: stream.h:944
Definition: director.h:150
Definition: text.h:29
Definition: movie_decoder.h:32
Definition: frame.h:151
Definition: frame.h:91
Definition: types.h:414