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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef TWINE_FLAMOVIES_H
24 #define TWINE_FLAMOVIES_H
25 
26 #include "common/memstream.h"
27 #include "common/scummsys.h"
28 #include "common/file.h"
29 
30 namespace TwinE {
31 
32 /** Original FLA screen width */
33 #define FLASCREEN_WIDTH 320
34 /** Original FLA screen height */
35 #define FLASCREEN_HEIGHT 200
36 
37 /** FLA movie header structure */
38 struct FLAHeaderStruct {
39 	/** FLA version */
40 	int8 version[6] {0};
41 	/** Number of frames */
42 	int32 numOfFrames = 0;
43 	/** Frames per second */
44 	int8 speed = 0;
45 	/** Unknown var1 */
46 	int8 var1 = 0;
47 	/** Frame width */
48 	int16 xsize = 0;
49 	/** Frame height */
50 	int16 ysize = 0;
51 };
52 
53 /** FLA movie frame structure */
54 struct FLAFrameDataStruct {
55 	/** Current frame size */
56 	int16 videoSize = 0;
57 	/** Unknown frameVar0 */
58 	int32 frameVar0 = 0;
59 };
60 
61 class TwinEEngine;
62 
63 class Movies {
64 private:
65 	TwinEEngine *_engine;
66 
67 	Common::File _file;
68 
69 	/** Auxiliar FLA fade out variable */
70 	int32 _fadeOut = 0;
71 	/** Auxiliar FLA fade out variable to count frames between the fade */
72 	int32 _fadeOutFrames = 0;
73 	bool _flaPaletteVar = false;
74 
75 	/** FLA movie file buffer */
76 	uint8 _flaBuffer[FLASCREEN_WIDTH * FLASCREEN_HEIGHT] {0};
77 
78 	/** Number of samples in FLA movie */
79 	int32 _samplesInFla = 0;
80 	/** FLA movie header data */
81 	FLAHeaderStruct _flaHeaderData;
82 	/** FLA movie header data */
83 	FLAFrameDataStruct _frameData;
84 
85 	void drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height);
86 	void drawDeltaFrame(Common::MemoryReadStream &stream, int32 width);
87 	/**
88 	 * Scale FLA movie 2 times
89 	 * According with the settins we can put the original aspect radio stretch
90 	 * to fullscreen or preserve it and use top and button black bars
91 	 */
92 	void scaleFla2x();
93 	void processFrame();
94 
95 	void prepareGIF(int index);
96 	void playGIFMovie(const char *flaName);
97 
98 public:
99 	Movies(TwinEEngine *engine);
100 
101 	/**
102 	 * Play FLA movies
103 	 * @param flaName FLA movie name
104 	 * @return @c true if finished. @c false if aborted.
105 	 */
106 	bool playFlaMovie(const char *flaName);
107 
108 	void playSmkMovie(int index);
109 };
110 
111 } // namespace TwinE
112 
113 #endif
114