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 TRECISION_VIDEO_H
24 #define TRECISION_VIDEO_H
25 
26 #include "common/stream.h"
27 #include "common/serializer.h"
28 #include "video/smk_decoder.h"
29 
30 #include "trecision/struct.h"
31 
32 namespace Trecision {
33 
34 #define MAXANIM  750
35 #define MAXSMACK 3
36 
37 // SMACKER ANIMATION FLAGS
38 #define SMKANIM_BKG 1
39 #define SMKANIM_ICON 2
40 #define SMKANIM_LOOP 4
41 #define SMKANIM_OLD 8
42 #define SMKANIM_ON 16
43 
44 enum SmackerType {
45 	kSmackerBackground = 0,		// Scene background animations
46 	kSmackerAction = 1,			// Main character action animations
47 	kSmackerIcon = 2			// Smacker inventory animations
48 };
49 
50 class TrecisionEngine;
51 
52 class NightlongSmackerDecoder : public Video::SmackerDecoder {
53 public:
54 	bool loadStream(Common::SeekableReadStream *stream) override;
55 	void muteTrack(uint track, bool mute);
56 	void setMute(bool mute);
57 	bool forceSeekToFrame(uint frame);
58 	bool endOfFrames() const;
59 };
60 
61 class AnimManager {
62 public:
63 	AnimManager(TrecisionEngine *vm);
64 	~AnimManager();
65 
66 private:
67 	TrecisionEngine *_vm;
68 
69 	NightlongSmackerDecoder *_smkAnims[MAXSMACK];
70 	uint16 _playingAnims[MAXSMACK];
71 
72 	FastFile _animFile[MAXSMACK]; // nlanim.cd1 / nlanim.cd2 / nlanim.cd3
73 	int _curCD;
74 	bool _bgAnimRestarted;
75 
76 	void openSmk(int slot, Common::SeekableReadStream *stream);
77 	void openSmkAnim(int slot, const Common::String &name);
78 	void toggleMuteBgAnim(uint16 animation);
79 	void closeSmk(int slot);
80 	void drawFrame(NightlongSmackerDecoder *smkDecoder, uint16 x, uint16 y, bool updateScreen);
81 	void drawFrameSubtitles(Graphics::Surface *surface, int frameNum);
82 	void setVideoRange(NightlongSmackerDecoder *smkDecoder, int &startFrame, int &endFrame);
83 	void refreshSmkAnim(uint16 animation);
84 	void handleEndOfVideo(int animation, int slot);
85 	bool shouldShowAnim(int animation, Common::Rect curRect);
86 
87 	void drawSmkBackgroundFrame(int animation);
88 	void drawSmkIconFrame(uint16 startIcon, uint16 iconNum);
89 	void drawSmkActionFrame();
90 	void swapCD(int cd);
91 	void patchAnimTab();
92 
93 public:
94 	Common::Rect _animRect;
95 	SAnim _animTab[MAXANIM];
96 
97 	void smkGoto(int slot, int frame);
98 	void smkToggleAudio(int slot, bool on);
99 	void smkToggleTrackAudio(int slot, int track, bool on);
100 	int16 smkCurFrame(int slot);
101 	void smkStop(uint16 slot);
refreshActionAnimation()102 	void refreshActionAnimation() { refreshSmkAnim(_playingAnims[kSmackerAction]); }
isActionActive()103 	bool isActionActive() const { return _playingAnims[kSmackerAction] != 0; }
104 	void playMovie(const Common::String &filename, int startFrame = 0, int endFrame = -1, bool singleChoice = false);
105 	void startFullMotion();
106 	void stopFullMotion();
107 
108 	void refreshAnim(int box);
109 	void startSmkAnim(uint16 animation);
110 	void stopAllSmkAnims();
111 
112 	void syncGameStream(Common::Serializer &ser);
113 	void loadAnimTab(Common::SeekableReadStreamEndian *stream);
114 };
115 } // End of namespace Trecision
116 #endif
117