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 KYRA_SOUND_ADLIB_H
24 #define KYRA_SOUND_ADLIB_H
25 
26 #include "kyra/sound/sound.h"
27 
28 #include "common/mutex.h"
29 
30 namespace Kyra {
31 class PCSoundDriver;
32 
33 /**
34  * AdLib/PC Speaker (early version) implementation of the
35  * sound output device.
36  *
37  * It uses a special sound file format special to EoB I, II,
38  * Dune II, Kyrandia 1 and 2 and LoL. EoB I has a slightly
39  * different (oldest) file format, EoB II, Dune II and
40  * Kyrandia 1 have the exact same format, Kyrandia 2  and
41  * LoL have a slightly different format.
42  *
43  * For PC Speaker this is a little different. Only the EoB
44  * games use the old driver with this data file format. The
45  * newer games use a MIDI-like driver (see pcspeaker_v2.cpp).
46  *
47  * See AdLibDriver / PCSpeakerDriver for more information.
48  * @see AdLibDriver
49  */
50 class SoundPC_v1 : public Sound {
51 public:
52 	SoundPC_v1(KyraEngine_v1 *vm, Audio::Mixer *mixer, kType type);
53 	~SoundPC_v1() override;
54 
getMusicType()55 	kType getMusicType() const override { return _type; }
56 
57 	bool init() override;
58 	void process() override;
59 
60 	void updateVolumeSettings() override;
61 
62 	void initAudioResourceInfo(int set, void *info) override;
63 	void selectAudioResourceSet(int set) override;
64 	bool hasSoundFile(uint file) const override;
65 	void loadSoundFile(uint file) override;
66 	void loadSoundFile(Common::String file) override;
67 
68 	void playTrack(uint8 track) override;
69 	void haltTrack() override;
70 	bool isPlaying() const override;
71 
72 	void playSoundEffect(uint16 track, uint8 volume = 0xFF) override;
73 
74 	void beginFadeOut() override;
75 
76 	int checkTrigger() override;
77 	void resetTrigger() override;
78 private:
79 	void internalLoadFile(Common::String file);
80 
81 	void play(uint8 track, uint8 volume);
82 
res()83 	const SoundResourceInfo_PC *res() const {return _resInfo[_currentResourceSet]; }
84 	SoundResourceInfo_PC *_resInfo[3];
85 	int _currentResourceSet;
86 
87 	PCSoundDriver *_driver;
88 
89 	int _version;
90 	kType _type;
91 	uint8 _trackEntries[500];
92 	uint8 *_soundDataPtr;
93 	int _sfxPlayingSound;
94 
95 	Common::String _soundFileLoaded;
96 
97 	int _numSoundTriggers;
98 	const int *_soundTriggers;
99 
100 	static const int _kyra1NumSoundTriggers;
101 	static const int _kyra1SoundTriggers[];
102 };
103 
104 } // End of namespace Kyra
105 
106 #endif
107