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  * Additional copyright for this file:
8  * Copyright (C) 1994-1998 Revolution Software Ltd.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  */
24 
25 #ifndef SWORD2_ANIMATION_H
26 #define SWORD2_ANIMATION_H
27 
28 #include "sword2/screen.h"
29 
30 namespace Graphics {
31 struct Surface;
32 }
33 
34 namespace Video {
35 class VideoDecoder;
36 }
37 
38 namespace Sword2 {
39 
40 enum DecoderType {
41 	kVideoDecoderDXA = 0,
42 	kVideoDecoderSMK = 1,
43 	kVideoDecoderPSX = 2,
44 	kVideoDecoderMP2 = 3
45 };
46 
47 struct MovieText {
48 	uint16 _startFrame;
49 	uint16 _endFrame;
50 	uint32 _textNumber;
51 	byte *_textMem;
52 	SpriteInfo _textSprite;
53 	uint16 _speechId;
54 	bool _played;
55 
resetMovieText56 	void reset() {
57 		_textMem = NULL;
58 		_speechId = 0;
59 		_played = false;
60 	}
61 };
62 
63 class MoviePlayer {
64 public:
65 	MoviePlayer(Sword2Engine *vm, OSystem *system, Video::VideoDecoder *decoder, DecoderType decoderType);
66 	virtual ~MoviePlayer();
67 
68 	bool load(const char *name);
69 	void play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadIn, uint32 leadOut);
70 
71 protected:
72 	Sword2Engine *_vm;
73 	OSystem *_system;
74 	MovieText *_movieTexts;
75 	uint32 _numMovieTexts;
76 	uint32 _currentMovieText;
77 	byte *_textSurface;
78 	int _textX, _textY;
79 	byte _white, _black;
80 	DecoderType _decoderType;
81 
82 	Video::VideoDecoder *_decoder;
83 
84 	uint32 _leadOut;
85 	int _leadOutFrame;
86 
87 	void performPostProcessing(Graphics::Surface *screen, uint16 pitch);
88 	bool playVideo();
89 	void drawFramePSX(const Graphics::Surface *frame);
90 
91 	void openTextObject(uint32 index);
92 	void closeTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch);
93 	void drawTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch);
94 
95 	uint32 getBlackColor();
96 	uint32 getWhiteColor();
97 };
98 
99 MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, OSystem *system, uint32 frameCount);
100 
101 } // End of namespace Sword2
102 
103 #endif
104