aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/sound/entry.h
blob: d92b16a5dda2b5eb1291a5686ed79ce3c9920759 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/* 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.
 *
 */

#ifndef LASTEXPRESS_SOUND_ENTRY_H
#define LASTEXPRESS_SOUND_ENTRY_H

/*
	Sound entry: 68 bytes (this is what appears in savegames)
	    uint32 {4}      - status
	    uint32 {4}      - type
	    uint32 {4}      - blockCount
	    uint32 {4}      - time
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - entity
	    uint32 {4}      - ??
	    uint32 {4}      - priority
	    char {16}       - name 1
	    char {16}       - name 2

	Sound queue entry: 120 bytes
	    uint16 {2}      - status
	    byte {1}        - type
	    byte {1}        - ??
	    uint32 {4}      - ??
	    uint32 {4}      - currentDataPtr
	    uint32 {4}      - soundData
	    uint32 {4}      - currentBufferPtr
	    uint32 {4}      - blockCount
	    uint32 {4}      - time
	    uint32 {4}      - size
	    uint32 {4}      - ??
	    uint32 {4}      - archive structure pointer
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - entity
	    uint32 {4}      - ??
	    uint32 {4}      - priority
	    char {16}       - name 1
	    char {16}       - name 2
	    uint32 {4}      - pointer to next entry in the queue
	    uint32 {4}      - subtitle data pointer
*/

#include "lastexpress/data/snd.h"
#include "lastexpress/data/subtitle.h"

#include "lastexpress/shared.h"

#include "common/serializer.h"

namespace LastExpress {

class LastExpressEngine;
class SubtitleEntry;

union SoundStatusUnion {
	uint32 status;
	byte status1;
	byte status2;
	byte status3;
	byte status4;

	SoundStatusUnion() {
		status = 0;
	}
};

//////////////////////////////////////////////////////////////////////////
// SoundEntry
//////////////////////////////////////////////////////////////////////////
class SoundEntry : Common::Serializable {
public:
	SoundEntry(LastExpressEngine *engine);
	~SoundEntry();

	void open(Common::String name, SoundFlag flag, int priority);
	void close();
	void play();
	void reset();
	bool isFinished();
	void update(uint val);
	bool updateSound();
	void updateState();
	void updateEntryFlag(SoundFlag flag);

	// Subtitles
	void showSubtitle(Common::String filename);

	// Serializable
	void saveLoadWithSerializer(Common::Serializer &ser);

	// Accessors
	void setStatus(int status)         { _status.status = status; }
	void setType(SoundType type)       { _type = type; }
	void setEntity(EntityIndex entity) { _entity = entity; }
	void setField48(int val)           { _field_48 = val; }

	SoundStatusUnion getStatus()   { return _status; }
	SoundType        getType()     { return _type; }
	uint32           getTime()     { return _time; }
	EntityIndex      getEntity()   { return _entity; }
	uint32           getPriority() { return _priority; }
	Common::String   getName2()    { return _name2; }

	// Streams
	SimpleSound *getSoundStream() { return _soundStream; }

private:
	LastExpressEngine *_engine;

	SoundStatusUnion _status;
	SoundType _type;    // int
	//int _data;
	//int _endOffset;
	byte * _currentDataPtr;
	//int _currentBufferPtr;
	int _blockCount;
	uint32 _time;
	//int _size;
	//int _field_28;
	Common::SeekableReadStream *_stream;    // The file stream
	//int _archive;
	int _field_34;
	int _field_38;
	int _field_3C;
	int _variant;
	EntityIndex _entity;
	int _field_48;
	uint32 _priority;
	Common::String _name1;    //char[16];
	Common::String _name2;    //char[16];
	// original has pointer to the next structure in the list (not used)
	SubtitleEntry *_subtitle;

	// Sound buffer & stream
	bool _queued;
	StreamedSound *_soundStream;    // the filtered sound stream

	void setType(SoundFlag flag);
	void setupStatus(SoundFlag flag);
	void loadStream(Common::String name);
};

//////////////////////////////////////////////////////////////////////////
// SubtitleEntry
//////////////////////////////////////////////////////////////////////////
class SubtitleEntry {
public:
	SubtitleEntry(LastExpressEngine *engine);
	~SubtitleEntry();

	void load(Common::String filename, SoundEntry *soundEntry);
	void loadData();
	void draw();
	void setupAndDraw();
	void drawOnScreen();

	// Accessors
	SoundStatusUnion getStatus() { return _status; }
	SoundEntry *getSoundEntry()  { return _sound; }

private:
	LastExpressEngine *_engine;

	Common::String    _filename;
	SoundStatusUnion  _status;
	SoundEntry       *_sound;
	SubtitleManager  *_data;
};

} // End of namespace LastExpress

#endif // LASTEXPRESS_SOUND_ENTRY_H