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 CHEWY_VIDEO_CFO_DECODER_H
24 #define CHEWY_VIDEO_CFO_DECODER_H
25 
26 #include "graphics/surface.h"
27 #include "video/flic_decoder.h"
28 
29 namespace Chewy {
30 
31 #define MAX_SOUND_EFFECTS 14
32 
33 class Sound;
34 
35 // A FLIC decoder, with a modified header and additional custom frames
36 class CfoDecoder : public Video::FlicDecoder {
37 public:
CfoDecoder(Sound * sound)38 	CfoDecoder(Sound *sound) : Video::FlicDecoder(), _sound(sound) {}
~CfoDecoder()39 	~CfoDecoder() override {}
40 
41 	bool loadStream(Common::SeekableReadStream *stream) override;
42 
43 private:
44 	Sound *_sound;
45 
46 	class CfoVideoTrack : public Video::FlicDecoder::FlicVideoTrack {
47 	public:
48 		CfoVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, Sound *sound);
49 		~CfoVideoTrack() override;
50 
51 		void readHeader() override;
52 
isRewindable()53 		bool isRewindable() const override { return false; }
rewind()54 		bool rewind() override { return false; }
55 
56 		const ::Graphics::Surface *decodeNextFrame() override;
57 
58 	private:
59 		void handleFrame() override;
60 		void handleCustomFrame();
61 		void fadeOut();
62 
63 		Sound *_sound;
64 
65 		byte *_soundEffects[MAX_SOUND_EFFECTS];
66 		uint32 _soundEffectSize[MAX_SOUND_EFFECTS];
67 		byte *_musicData;
68 		uint32 _musicSize;
69 	};
70 };
71 
72 } // End of namespace Chewy
73 
74 #endif
75