diff options
author | Johannes Schickel | 2006-02-27 22:39:55 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-02-27 22:39:55 +0000 |
commit | f3106feaf524d065eb495b9bd423011171623fcb (patch) | |
tree | c26cfc6384d236c82a842d207d3ecc9ef04d7da3 /engines/kyra/sound.h | |
parent | 1b1bc9cde4071ceda6531f0d12c7cbf9be77b582 (diff) | |
download | scummvm-rg350-f3106feaf524d065eb495b9bd423011171623fcb.tar.gz scummvm-rg350-f3106feaf524d065eb495b9bd423011171623fcb.tar.bz2 scummvm-rg350-f3106feaf524d065eb495b9bd423011171623fcb.zip |
Added WIP Adlib sound playing code to kyra.
It needs some checks since it doesn't work correctly in every case at the moment.
svn-id: r20960
Diffstat (limited to 'engines/kyra/sound.h')
-rw-r--r-- | engines/kyra/sound.h | 97 |
1 files changed, 69 insertions, 28 deletions
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index f63283d129..21b99d8056 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -41,14 +41,15 @@ namespace Kyra { class Sound { public: - Sound() {} - virtual ~Sound() {} + Sound(KyraEngine *engine, Audio::Mixer *mixer); + virtual ~Sound(); + + virtual bool init() = 0; virtual void setVolume(int volume) = 0; virtual int getVolume() = 0; virtual void playMusic(const char *file) = 0; - virtual void playMusic(uint8 *data, uint32 size) = 0; virtual void stopMusic() = 0; virtual void playTrack(uint8 track, bool looping = true) = 0; @@ -56,7 +57,6 @@ public: virtual void startTrack() = 0; virtual void loadSoundEffectFile(const char *file) = 0; - virtual void loadSoundEffectFile(uint8 *data, uint32 size) = 0; virtual void stopSoundEffect() = 0; virtual void playSoundEffect(uint8 track) = 0; @@ -64,16 +64,74 @@ public: virtual void beginFadeOut() = 0; virtual bool fadeOut() = 0; - virtual void voicePlay(const char *file) = 0; - virtual void voiceUnload() = 0; - virtual bool voiceIsPlaying() = 0; + void voicePlay(const char *file); + void voiceUnload() {} + bool voiceIsPlaying(); + +protected: + KyraEngine *_engine; + Audio::Mixer *_mixer; + +private: + AudioStream *_currentVocFile; + Audio::SoundHandle _vocHandle; + Common::File _compressHandle; + + struct SpeechCodecs { + const char *fileext; + AudioStream *(*streamFunc)(Common::File*, uint32); + }; + + static const SpeechCodecs _supportedCodes[]; +}; + +class AdlibDriver; + +class SoundAdlibPC : public Sound { +public: + SoundAdlibPC(Audio::Mixer *mixer, KyraEngine *engine); + ~SoundAdlibPC(); + + bool init(); + + void setVolume(int volume); + int getVolume(); + + void playMusic(const char *file); + void stopMusic(); + + void playTrack(uint8 track, bool looping); + void haltTrack(); + void startTrack(); + + void loadSoundEffectFile(const char *file); + void stopSoundEffect(); + + void playSoundEffect(uint8 track); + + void beginFadeOut(); + bool fadeOut(); +private: + void loadSoundFile(const char *file); + + AdlibDriver *_driver; + + uint8 _trackEntries[120]; + uint8 *_soundDataPtr; + int _sfxPlayingSound; + Common::String _soundFileLoaded; + + uint8 _sfxSecondByteOfSong; + uint8 _sfxFourthByteOfSong; }; -class SoundPC : public MidiDriver, public Sound { +class SoundMidiPC : public MidiDriver, public Sound { public: - SoundPC(MidiDriver *driver, Audio::Mixer *mixer, KyraEngine *engine); - ~SoundPC(); + SoundMidiPC(MidiDriver *driver, Audio::Mixer *mixer, KyraEngine *engine); + ~SoundMidiPC(); + + bool init() { return true; } void setVolume(int volume); int getVolume() { return _volume; } @@ -98,10 +156,6 @@ public: void beginFadeOut(); bool fadeOut() { return _fadeMusicOut; } - - void voicePlay(const char *file); - void voiceUnload() {}; - bool voiceIsPlaying(); //MidiDriver interface implementation int open(); @@ -116,7 +170,7 @@ public: MidiChannel *allocateChannel() { return 0; } MidiChannel *getPercussionChannel() { return 0; } -protected: +private: static void onTimer(void *data); @@ -137,19 +191,6 @@ protected: byte *_parserSource; MidiParser *_soundEffect; byte *_soundEffectSource; - KyraEngine *_engine; - - Audio::Mixer *_mixer; - AudioStream *_currentVocFile; - Audio::SoundHandle _vocHandle; - Common::File _compressHandle; - - struct SpeechCodecs { - const char *fileext; - AudioStream *(*streamFunc)(Common::File*, uint32); - }; - - static const SpeechCodecs _supportedCodes[]; }; } // end of namespace Kyra |