aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/sound/entry.h
blob: 84a2342cf368bad4307542ea260fe7cb9ae191b7 (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
/* 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 the savegames)
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - entity
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    char {16}       - name 1
	    char {16}       - name 2

	Sound queue entry: 120 bytes
	    uint16 {2}      - status
	    byte {1}        - ??
	    byte {1}        - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - file data pointer
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - archive structure pointer
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    uint32 {4}      - entity
	    uint32 {4}      - ??
	    uint32 {4}      - ??
	    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"

namespace LastExpress {

class LastExpressEngine;
class SubtitleEntry;

enum SoundStatus {
	kSoundStatus_20       = 0x20,
	kSoundStatus_40       = 0x40,
	kSoundStatus_180      = 0x180,
	kSoundStatusRemoved   = 0x200,
	kSoundStatus_400      = 0x400,

	kSoundStatus_8000     = 0x8000,
	kSoundStatus_20000    = 0x20000,
	kSoundStatus_100000   = 0x100000,
	kSoundStatus_40000000 = 0x40000000,

	kSoundStatusClear0    = 0x10,
	kSoundStatusClear1    = 0x1F,
	kSoundStatusClear2    = 0x80,
	kSoundStatusClear3    = 0x200,
	kSoundStatusClear4    = 0x800,
	kSoundStatusClearAll  = 0xFFFFFFE0
};

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

	SoundStatusUnion() {
		status = 0;
	}
};

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

	void setStatus(SoundFlag flag);
	void setInCache();
	void update(uint val);
	void updateState();
	void reset();

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

private:
	LastExpressEngine *_engine;

public:
	SoundStatusUnion status;
	SoundType type;    // int
	//int data;
	//int endOffset;
	int currentDataPtr;
	void *soundData;
	//int currentBufferPtr;
	int blockCount;
	uint32 time;
	//int size;
	//int field_28;
	Common::SeekableReadStream *stream;	// int
	//int field_30;
	int field_34;
	int field_38;
	int field_3C;
	int field_40;
	EntityIndex entity;
	int field_48;
	uint32 priority;
	Common::String name1; //char[16];
	Common::String name2; //char[16];
	//int next; // offset to the next structure in the list (not used)
	SubtitleEntry *subtitle;

	// Sound stream
	StreamedSound *soundStream;
};

//////////////////////////////////////////////////////////////////////////
// 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