aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/bmv.h
blob: 7891075315f1090bf06c63761f85db9cca16476c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 * Plays films within a scene, takes into account the actor in each 'column'.
 */

#ifndef TINSEL_BMV_H
#define TINSEL_BMV_H

#include "common/file.h"

#include "sound/audiostream.h"
#include "sound/mixer.h"

#include "tinsel/coroutine.h"
#include "tinsel/object.h"
#include "tinsel/palette.h"

namespace Tinsel {


class BMVPlayer {

	bool bOldAudio;

	/// Set when a movie is on
	bool bMovieOn;

	/// Set to kill one off
	bool bAbort;

	/// For escaping out of movies
	int bmvEscape;

	/// Movie file pointer
	Common::File stream;

	/// Movie file name
	char szMovieFile[14];

	/// Pointers to buffers
	byte *bigBuffer;

	/// Next data to use to extract a frame
	int nextUseOffset;

	/// Next data to use to extract sound data
	int nextSoundOffset;

	/// When above offset gets to what this is set at, rewind
	int wrapUseOffset;

	/// The offset of the most future packet
	int mostFutureOffset;

	/// The current frame
	int currentFrame;
	int currentSoundFrame;

	/// Number of packets currently in RAM
	int numAdvancePackets;

	/// Next slot that will be read from disc
	int nextReadSlot;

	/// Set when the whole file has been read
	bool bFileEnd;

	/// Palette
	COLORREF moviePal[256];

	int blobsInBuffer;

	struct {
		POBJECT	pText;
		int	dieFrame;
	} texts[2];

	COLORREF talkColour;

	int bigProblemCount;

	bool bIsText;

	int movieTick;
	int startTick;
	uint32 nextMovieTime;

	uint16 Au_Prev1;
	uint16 Au_Prev2;
	byte *ScreenBeg;
	byte *screenBuffer;

	bool audioStarted;

	Audio::AppendableAudioStream *audioStream;
	Audio::SoundHandle audioHandle;

	int nextMaintain;
public:
	BMVPlayer();

	void PlayBMV(CORO_PARAM, SCNHANDLE hFileStem, int myEscape);
	void FinishBMV();
	void CopyMovieToScreen(void);
	void FettleBMV(void);

	bool MoviePlaying(void);

	int32 MovieAudioLag(void);

	uint32 NextMovieTime(void);

	void AbortMovie(void);

private:
	void InitBMV(byte *memoryBuffer);
	void PrepAudio(const byte *sourceData, int blobCount, byte *destPtr);
	void MoviePalette(int paletteOffset);
	void InitialiseMovieSound();
	void StartMovieSound();
	void FinishMovieSound();
	void MovieAudio(int audioOffset, int blobs);
	void FettleMovieText(void);
	void BmvDrawText(bool bDraw);
	void MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, COLORREF *pTalkColour, int duration);
	int MovieCommand(char cmd, int commandOffset);
	int FollowingPacket(int thisPacket, bool bReallyImportant);
	void LoadSlots(int number);
	void InitialiseBMV(void);
	bool MaintainBuffer(void);
	bool DoBMVFrame(void);
	bool DoSoundFrame(void);
	void LookAtBuffers(void);
};


} // End of namespace Tinsel

#endif