diff options
author | Torbjörn Andersson | 2006-03-21 17:17:24 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2006-03-21 17:17:24 +0000 |
commit | 0c0c41d495b35b44ab3b17b39649b5a09d9afc1a (patch) | |
tree | 093c007b5424cd86408ec0aa6cb4e87d2b4c05f1 /engines | |
parent | 3586905f93ab27bd1274ee432ff24281f2fd14bd (diff) | |
download | scummvm-rg350-0c0c41d495b35b44ab3b17b39649b5a09d9afc1a.tar.gz scummvm-rg350-0c0c41d495b35b44ab3b17b39649b5a09d9afc1a.tar.bz2 scummvm-rg350-0c0c41d495b35b44ab3b17b39649b5a09d9afc1a.zip |
Implemented "sound triggers" so that the music does not stop shortly after
entering the castle. I hope this is a fair approximation of how the original
worked. Of course, this led to a couple of more renamings:
_unk5 -> _soundTrigger
updateCallback54() -> update_setSoundTrigger()
snd_setUnk5() -> snd_getSoundTrigger() (yes, "get")
At the moment, the only known sound triggers are the ones in the castle. If an
unknown trigger is set, the debugging messages will be really, really noisy. I
don't know if I should consider this a bug or an extremely annoying feature.
svn-id: r21396
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sound.h | 35 | ||||
-rw-r--r-- | engines/kyra/sound_adlib.cpp | 52 |
3 files changed, 61 insertions, 28 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 0347d2c65e..be56e05a44 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -711,6 +711,8 @@ void KyraEngine::mainLoop() { _handleInput = true; delay((frameTime + _gameSpeed) - _system->getMillis(), true, true); _handleInput = false; + + _sound->process(); } } diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 158270c201..117b0c2cf1 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -45,19 +45,20 @@ public: virtual ~Sound(); virtual bool init() = 0; - + virtual void process() {} + virtual void setVolume(int volume) = 0; virtual int getVolume() = 0; - + virtual void loadMusicFile(const char *file) = 0; - + virtual void playTrack(uint8 track) = 0; virtual void haltTrack() = 0; - + virtual void playSoundEffect(uint8 track) = 0; - + virtual void beginFadeOut() = 0; - + void voicePlay(const char *file); void voiceUnload() {} bool voiceIsPlaying(); @@ -70,12 +71,12 @@ private: AudioStream *_currentVocFile; Audio::SoundHandle _vocHandle; Common::File _compressHandle; - + struct SpeechCodecs { const char *fileext; AudioStream *(*streamFunc)(Common::File*, uint32); }; - + static const SpeechCodecs _supportedCodes[]; }; @@ -87,6 +88,7 @@ public: ~SoundAdlibPC(); bool init(); + void process(); void setVolume(int volume); int getVolume(); @@ -114,11 +116,16 @@ private: uint8 _sfxPriority; uint8 _sfxFourthByteOfSong; + + int _numSoundTriggers; + const int *_soundTriggers; + + static const int _kyra1NumSoundTriggers; + static const int _kyra1SoundTriggers[]; }; class SoundMidiPC : public MidiDriver, public Sound { public: - SoundMidiPC(MidiDriver *driver, Audio::Mixer *mixer, KyraEngine *engine); ~SoundMidiPC(); @@ -128,10 +135,10 @@ public: int getVolume() { return _volume; } void loadMusicFile(const char *file); - + void playTrack(uint8 track); void haltTrack(); - + void playSoundEffect(uint8 track); void beginFadeOut(); @@ -148,9 +155,9 @@ public: //Channel allocation functions MidiChannel *allocateChannel() { return 0; } MidiChannel *getPercussionChannel() { return 0; } - + void setPassThrough(bool b) { _passThrough = b; } - + void hasNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; } bool isMT32() { return _nativeMT32; } @@ -159,7 +166,7 @@ private: void stopMusic(); void loadSoundEffectFile(const char *file); void loadSoundEffectFile(uint8 *data, uint32 size); - + void stopSoundEffect(); static void onTimer(void *data); diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 79a6c6191f..d634e2f713 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -95,7 +95,7 @@ private: int snd_unkOpcode3(va_list &list); int snd_readByte(va_list &list); int snd_writeByte(va_list &list); - int snd_setUnk5(va_list &list); + int snd_getSoundTrigger(va_list &list); int snd_unkOpcode4(va_list &list); int snd_dummy(va_list &list); int snd_getNullvar4(va_list &list); @@ -106,7 +106,6 @@ private: // These variables have not yet been named, but some of them are partly // known nevertheless: // - // unk4 - Unknown. Related to sound timing? // unk11 - Unknown. Used for updating random durations. // unk16 - Sound-related. Possibly some sort of pitch bend. // unk18 - Sound-effect. Used for secondaryEffect1() @@ -286,14 +285,13 @@ private: int updateCallback51(uint8 *&dataptr, Channel &channel, uint8 value); int updateCallback52(uint8 *&dataptr, Channel &channel, uint8 value); int updateCallback53(uint8 *&dataptr, Channel &channel, uint8 value); - int updateCallback54(uint8 *&dataptr, Channel &channel, uint8 value); + int update_setSoundTrigger(uint8 *&dataptr, Channel &channel, uint8 value); int update_setTempoReset(uint8 *&dataptr, Channel &channel, uint8 value); int updateCallback56(uint8 *&dataptr, Channel &channel, uint8 value); private: // These variables have not yet been named, but some of them are partly // known nevertheless: // - // _unk5 - Currently unused, except for updateCallback54() // _unkValue1 - Unknown. Used for updating _unkValue2 // _unkValue2 - Unknown. Used for updating _unkValue4 // _unkValue3 - Unknown. Used for updating _unkValue2 @@ -330,7 +328,7 @@ private: int8 _flagTrigger; int _curChannel; uint8 _rhythmSection; - uint8 _unk5; + uint8 _soundTrigger; int _soundsPlaying; uint16 _rnd; @@ -402,6 +400,7 @@ AdlibDriver::AdlibDriver(Audio::Mixer *mixer) { _rnd = 0x1234; _tempo = 0; + _soundTrigger = 0; _unkValue3 = 0xFF; _unkValue1 = _unkValue2 = _unkValue4 = _unkValue5 = 0; @@ -495,8 +494,7 @@ int AdlibDriver::snd_startSong(va_list &list) { } } - _soundIdTable[_soundsPlaying] = songId; - ++_soundsPlaying; + _soundIdTable[_soundsPlaying++] = songId; _soundsPlaying &= 0x0F; return 0; @@ -548,9 +546,8 @@ int AdlibDriver::snd_writeByte(va_list &list) { return oldValue; } -int AdlibDriver::snd_setUnk5(va_list &list) { - warning("unimplemented snd_setUnk5"); - return 0; +int AdlibDriver::snd_getSoundTrigger(va_list &list) { + return _soundTrigger; } int AdlibDriver::snd_unkOpcode4(va_list &list) { @@ -1793,8 +1790,8 @@ int AdlibDriver::updateCallback53(uint8 *&dataptr, Channel &channel, uint8 value return 0; } -int AdlibDriver::updateCallback54(uint8 *&dataptr, Channel &channel, uint8 value) { - _unk5 = value; +int AdlibDriver::update_setSoundTrigger(uint8 *&dataptr, Channel &channel, uint8 value) { + _soundTrigger = value; return 0; } @@ -1824,7 +1821,7 @@ const AdlibDriver::OpcodeEntry AdlibDriver::_opcodeList[] = { COMMAND(snd_unkOpcode3), COMMAND(snd_readByte), COMMAND(snd_writeByte), - COMMAND(snd_setUnk5), + COMMAND(snd_getSoundTrigger), COMMAND(snd_unkOpcode4), COMMAND(snd_dummy), COMMAND(snd_getNullvar4), @@ -1940,7 +1937,7 @@ const AdlibDriver::ParserOpcode AdlibDriver::_parserOpcodeTable[] = { COMMAND(updateCallback51), COMMAND(updateCallback52), COMMAND(updateCallback53), - COMMAND(updateCallback54), + COMMAND(update_setSoundTrigger), // 72 COMMAND(update_setTempoReset), @@ -2123,6 +2120,15 @@ const uint8 AdlibDriver::_unkTables[][32] = { #pragma mark - +// At the time of writing, the only known case where Kyra 1 uses sound triggers +// is in the castle, to cycle between three different songs. + +const int SoundAdlibPC::_kyra1SoundTriggers[] = { + 0, 4, 5, 3 +}; + +const int SoundAdlibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdlibPC::_kyra1SoundTriggers); + SoundAdlibPC::SoundAdlibPC(Audio::Mixer *mixer, KyraEngine *engine) : Sound(engine, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) { memset(_trackEntries, 0, sizeof(_trackEntries)); @@ -2131,6 +2137,9 @@ SoundAdlibPC::SoundAdlibPC(Audio::Mixer *mixer, KyraEngine *engine) _sfxPlayingSound = -1; _soundFileLoaded = ""; + + _soundTriggers = _kyra1SoundTriggers; + _numSoundTriggers = _kyra1NumSoundTriggers; } SoundAdlibPC::~SoundAdlibPC() { @@ -2144,6 +2153,21 @@ bool SoundAdlibPC::init() { return true; } +void SoundAdlibPC::process() { + uint8 trigger = _driver->callback(11); + + if (trigger < _numSoundTriggers) { + int soundId = _soundTriggers[trigger]; + + if (soundId) { + playTrack(soundId); + } + } else { + warning("Unknown sound trigger %d", trigger); + // TODO: At this point, we really want to clear the trigger... + } +} + void SoundAdlibPC::setVolume(int volume) { } |